Fix USD camera orbit pivot — use scene bbox centroid instead of focus distance

When switching to a USD camera, the orbit pivot was set from
GfCamera::GetFocusDistance() which is a depth-of-field attribute
that defaults to 5 scene units regardless of scene scale.

InitCameraNavigation() now computes the scene bounding box centroid,
projects it onto the camera view ray to get a proper orbit distance,
and calls SetFocalPoint/SetDist to place the pivot correctly.
Added SetDist() setter on ViewportCamera to support this.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 04:46:20 +08:00
parent 8f309e5440
commit ee1b750f8c
2 changed files with 35 additions and 0 deletions
+8
View File
@@ -113,6 +113,14 @@ public:
m_cameraTransformDirty = true;
}
/// Set the orbit distance directly.
/// Used when initialising from a USD camera prim to override the camera's
/// authored focus distance (which is a DOF attribute, not an orbit radius).
void SetDist(double d) {
m_dist = d;
m_cameraTransformDirty = true;
}
/// Returns the current near-clip distance.
double GetNearClip() const {
return static_cast<double>(m_camera.GetClippingRange().GetMin());