Skip to content

only use camera objects in the scene#236

Merged
jeffamstutz merged 1 commit intonext_releasefrom
only_camera_objects
Feb 25, 2026
Merged

only use camera objects in the scene#236
jeffamstutz merged 1 commit intonext_releasefrom
only_camera_objects

Conversation

@jeffamstutz
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 25, 2026 15:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Viewport camera management system to use camera objects from the scene database rather than maintaining separate ANARI camera objects. The title "only use camera objects in the scene" accurately describes this fundamental change.

Changes:

  • Removed direct ANARI camera management (m_perspCamera, m_orthoCamera, m_omniCamera) in favor of using scene Camera objects
  • Introduced new ManipulatorToTSD module to bidirectionally sync between the camera manipulator and scene Camera objects
  • Enhanced Scene to provide a default camera via defaultCamera() method similar to defaultMaterial()
  • Reorganized viewport menu structure into separate methods for better maintainability

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Viewport.h/cpp Refactored camera management to use scene objects; reorganized UI menus into separate methods
ManipulatorToTSD.hpp/cpp New module for syncing manipulator state with Camera objects via metadata
Camera.hpp/cpp Added CameraAppRef typedef; updated default FOV to 40 degrees
Scene.hpp/cpp Added defaultCamera() method and default object tracking infrastructure
ObjectVersion.hpp New utility for change tracking using version numbers
RenderIndex.hpp/cpp Added camera() accessor and computeDefaultView() helper
AnariObjectCache Added camera cache support
Application.cpp Refactored menu bar into separate methods
LayerTree.cpp Minor menu reorganization; typo in new menu item
Various tool files Updated to use RenderIndex::computeDefaultView()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1246 to 1291
@@ -1556,7 +1262,6 @@ void Viewport::ui_gizmo()
const auto view = linalg::lookat_matrix(eye, at, up);

const float aspect = m_viewportSize.x / float(m_viewportSize.y);
const float fovRadians = math::radians(m_fov);
math::mat4 proj;

// Try and get some legroom for ImGuizmo get precision on depth.
@@ -1572,15 +1277,18 @@ void Viewport::ui_gizmo()
float near = std::max(1e-8f, distanceToSelectedObject * 1e-2f);
float far = std::max(1e-6f, distanceToSelectedObject * 1e2f);

if (m_currentCamera == m_perspCamera) {
if (m_currentCamera->subtype() == core::tokens::camera::perspective) {
const float fovRadians =
m_currentCamera->parameterValueAs<float>("fovy").value_or(
math::radians(40.f));
float oneOverTanFov = 1.0f / tan(fovRadians / 2.0f);
proj = math::mat4{
{oneOverTanFov / aspect, 0.0f, 0.0f, 0.0f},
{0.0f, oneOverTanFov, 0.0f, 0.0f},
{0.0f, 0.0f, -(far + near) / (far - near), -1.0f},
{0.0f, 0.0f, -2.0f * far * near / (far - near), 0.0f},
};
} else if (m_currentCamera == m_orthoCamera) {
} else if (m_currentCamera->subtype() == core::tokens::camera::orthographic) {
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential null pointer dereference: At lines 1246, 1280, 1282, and 1291, 'm_currentCamera' is dereferenced without null checks. The 'canShowGizmo()' check on line 1227 doesn't verify that 'm_currentCamera' is non-null. If the camera is null during gizmo rendering, this will crash. Consider adding a null check in 'canShowGizmo()' or at the beginning of this function.

Copilot uses AI. Check for mistakes.
@jeffamstutz jeffamstutz merged commit b926b3e into next_release Feb 25, 2026
13 checks passed
@jeffamstutz jeffamstutz deleted the only_camera_objects branch February 25, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants