Update camera settings for commandline rendering from the file context unless the --camera option is given in which case the camera is locked. Signed-off-by: Herbert Poetzl --- diff -u b/src/Camera.cc b/src/Camera.cc --- b/src/Camera.cc +++ b/src/Camera.cc @@ -15,6 +15,7 @@ pixel_width = RenderSettings::inst()->img_width; pixel_height = RenderSettings::inst()->img_height; + locked = false; } void Camera::setup(std::vector params) @@ -38,6 +39,7 @@ } else { assert("Gimbal cam needs 7 numbers, Vector camera needs 6"); } + locked = true; } /*! Moves camera so that the given bbox is fully visible. @@ -60,6 +62,7 @@ PRINTDB("modified obj trans x y z %f %f %f",object_trans.x() % object_trans.y() % object_trans.z()); PRINTDB("modified obj rot x y z %f %f %f",object_rot.x() % object_rot.y() % object_rot.z()); } + locked = true; } void Camera::zoom(int zoom, bool relative) @@ -90,6 +93,9 @@ */ void Camera::updateView(const std::shared_ptr ctx) { + if (locked) + return; + double x, y, z; const auto vpr = ctx->lookup_variable("$vpr"); if (vpr->getVec3(x, y, z, 0.0)){ diff -u b/src/Camera.h b/src/Camera.h --- b/src/Camera.h +++ b/src/Camera.h @@ -61,6 +61,10 @@ unsigned int pixel_width; unsigned int pixel_height; + // true if camera settings are fixed + // (--camera option in commandline mode) + bool locked; + protected: // Perspective settings double viewer_distance; only in patch2: unchanged: --- a/src/openscad.cc +++ b/src/openscad.cc @@ -379,7 +379,9 @@ int cmdline(const char *deps_output_file, const std::string &filename, const std top_ctx->setDocumentPath(fparent.string()); AbstractNode::resetIndexCounter(); - absolute_root_node = root_module->instantiate(top_ctx.ctx, &root_inst, nullptr); + ContextHandle filectx{Context::create(top_ctx.ctx)}; + absolute_root_node = root_module->instantiateWithFileContext(filectx.ctx, &root_inst, nullptr); + camera.updateView(filectx.ctx); // Do we have an explicit root node (! modifier)? const Location *nextLocation = nullptr;