From 6a696713ab6f9dbff12b8c591f0ff76cc832b04a Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Thu, 30 Nov 2023 14:01:09 -0800 Subject: [PATCH 1/6] Update rendering.cpp --- .../visualization/rendering/rendering.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index b80590710f4..663fc3dc7fa 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -81,15 +81,19 @@ class PyOffscreenRenderer { void SetupCamera(float verticalFoV, const Eigen::Vector3f ¢er, const Eigen::Vector3f &eye, - const Eigen::Vector3f &up) { + const Eigen::Vector3f &up, + float nearClip = -1.0f, + float farClip = -1.0f) { float aspect = 1.0f; if (height_ > 0) { aspect = float(width_) / float(height_); } auto *camera = scene_->GetCamera(); auto far_plane = + farClip > 0.0 ? farClip : Camera::CalcFarPlane(*camera, scene_->GetBoundingBox()); - camera->SetProjection(verticalFoV, aspect, Camera::CalcNearPlane(), + camera->SetProjection(verticalFoV, aspect, + nearClip > 0.0 ? nearClip : Camera::CalcNearPlane(), far_plane, rendering::Camera::FovType::Vertical); camera->LookAt(center, eye, up); } @@ -164,10 +168,14 @@ void pybind_rendering_classes(py::module &m) { .def("setup_camera", py::overload_cast( + const Eigen::Vector3f &, + float, float>( &PyOffscreenRenderer::SetupCamera), - "setup_camera(vertical_field_of_view, center, eye, up): " - "sets camera view using bounding box of current geometry") + "setup_camera(vertical_field_of_view, center, eye, up, " + "near_clip, far_clip): " + "sets camera view using bounding box of current geometry " + "if the near_clip and far_clip parameters are unset", + py::arg("nearClip") = -1.0f, py::arg("farClip") = -1.0f) .def("setup_camera", py::overload_cast( From 56b911276d4d11159d0ab6044b763861a216767b Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Thu, 30 Nov 2023 14:08:10 -0800 Subject: [PATCH 2/6] Adjust formatting --- .../visualization/rendering/rendering.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index 663fc3dc7fa..7b3e297fa9a 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -83,18 +83,20 @@ class PyOffscreenRenderer { const Eigen::Vector3f &eye, const Eigen::Vector3f &up, float nearClip = -1.0f, - float farClip = -1.0f) { + float farClip = -1.0f) { float aspect = 1.0f; if (height_ > 0) { aspect = float(width_) / float(height_); } auto *camera = scene_->GetCamera(); - auto far_plane = - farClip > 0.0 ? farClip : - Camera::CalcFarPlane(*camera, scene_->GetBoundingBox()); - camera->SetProjection(verticalFoV, aspect, - nearClip > 0.0 ? nearClip : Camera::CalcNearPlane(), - far_plane, rendering::Camera::FovType::Vertical); + auto far_plane = farClip > 0.0 + ? farClip + : Camera::CalcFarPlane( + *camera, scene_->GetBoundingBox()); + camera->SetProjection( + verticalFoV, aspect, + nearClip > 0.0 ? nearClip : Camera::CalcNearPlane(), far_plane, + rendering::Camera::FovType::Vertical); camera->LookAt(center, eye, up); } @@ -168,8 +170,7 @@ void pybind_rendering_classes(py::module &m) { .def("setup_camera", py::overload_cast( + const Eigen::Vector3f &, float, float>( &PyOffscreenRenderer::SetupCamera), "setup_camera(vertical_field_of_view, center, eye, up, " "near_clip, far_clip): " From a2681275a54498cf817e0b430ae8bba8fecc68f7 Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Thu, 30 Nov 2023 14:15:23 -0800 Subject: [PATCH 3/6] Add changelog detail --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d91ac41c3c2..ac4526be541 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * Check for support of CUDA Memory Pools at runtime (#4679) * Fix `toString`, `CreateFromPoints` methods and improve docs in `AxisAlignedBoundingBox`. 🐛📝 * Migrate Open3d documentation to furo theme ✨ (#6470) +* Expose Near Clip + Far Clip parameters to setup_camera in OffscreenRenderer (#6520) ## 0.13 From ee7271eb1acee9f39ed448c4350671742b1ca5fe Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Fri, 1 Dec 2023 01:00:10 -0800 Subject: [PATCH 4/6] Add More Full PyBind11 Arg Annotation --- cpp/pybind/visualization/rendering/rendering.cpp | 2 ++ docs/make.bat | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index 7b3e297fa9a..67ed7eea32b 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -176,6 +176,8 @@ void pybind_rendering_classes(py::module &m) { "near_clip, far_clip): " "sets camera view using bounding box of current geometry " "if the near_clip and far_clip parameters are unset", + py::arg("verticalFoV"), py::arg("center"), + py::arg("eye"), py::arg("up"), py::arg("nearClip") = -1.0f, py::arg("farClip") = -1.0f) .def("setup_camera", py::overload_cast Date: Fri, 1 Dec 2023 01:31:27 -0800 Subject: [PATCH 5/6] Fix Formatting Again --- cpp/pybind/visualization/rendering/rendering.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index 67ed7eea32b..0d0e7cfc5af 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -176,9 +176,9 @@ void pybind_rendering_classes(py::module &m) { "near_clip, far_clip): " "sets camera view using bounding box of current geometry " "if the near_clip and far_clip parameters are unset", - py::arg("verticalFoV"), py::arg("center"), - py::arg("eye"), py::arg("up"), - py::arg("nearClip") = -1.0f, py::arg("farClip") = -1.0f) + py::arg("verticalFoV"), py::arg("center"), py::arg("eye"), + py::arg("up"), py::arg("nearClip") = -1.0f, + py::arg("farClip") = -1.0f) .def("setup_camera", py::overload_cast( From eaac3b9a9f24f1c47b263d660eab29bf690ceb99 Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Fri, 1 Dec 2023 17:34:16 -0800 Subject: [PATCH 6/6] Trigger Local GA Actions --- cpp/pybind/visualization/rendering/rendering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index 0d0e7cfc5af..51619f5cc68 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -175,7 +175,7 @@ void pybind_rendering_classes(py::module &m) { "setup_camera(vertical_field_of_view, center, eye, up, " "near_clip, far_clip): " "sets camera view using bounding box of current geometry " - "if the near_clip and far_clip parameters are unset", + "if the near_clip and far_clip parameters are not set", py::arg("verticalFoV"), py::arg("center"), py::arg("eye"), py::arg("up"), py::arg("nearClip") = -1.0f, py::arg("farClip") = -1.0f)