ifcviewer: orthographic toggle and standard axis-aligned views

- P toggles ortho/perspective.  The ortho box is sized so the
  visible rectangle at the pivot's distance matches what the
  perspective camera would show — toggling at any zoom keeps the
  framing identical, and the wheel keeps working by rescaling the
  box.  Contribution culling is disabled in ortho since its
  r_px = focal_px * r / dist formula assumes perspective; frustum
  and HiZ culling still run.
- X / Y / Z snap the camera to look from +X / +Y / +Z; Shift+X /
  Y / Z snap to the negative side.  Yaw and pitch are set
  directly so top/bottom land on exactly ±90°.
- updateCamera() picks the lookAt up vector dynamically: world +Z
  except within 1° of the pole, where it switches to world +Y.
  That keeps lookAt well-conditioned at the poles and gives top
  views the architectural "Y as north" screen orientation.
- Pan now derives screen-right / screen-up from the real camera
  basis instead of from yaw/pitch alone — the old derivation
  assumed up = world +Z and silently inverted at top/bottom.
- Standard views preserve target and distance — rotate only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-30 13:30:18 +10:00
parent 6341d7dd31
commit 6f0327d4b5
2 changed files with 97 additions and 16 deletions
+12
View File
@@ -204,6 +204,17 @@ public:
void toggleSectionTool();
bool sectionToolActive() const { return section_tool_active_; }
// Projection: orthographic vs perspective. In ortho mode the visible
// box is sized to match what the perspective camera would show at the
// pivot's distance, so toggling at any zoom level keeps the framing.
void toggleProjection();
bool projectionOrtho() const { return projection_ortho_; }
// Snap the camera to a canonical axis-aligned view. Yaw/pitch are
// clamped according to the orbit convention; target and distance are
// preserved (the user explicitly asked for a rotate-only behavior).
void setStandardView(float yaw_deg, float pitch_deg);
void setCamera(float tx, float ty, float tz, float dist, float yaw, float pitch);
void setBenchmarkFrames(int n);
QString cameraString() const;
@@ -489,6 +500,7 @@ private:
float camera_yaw_ = 45.0f;
float camera_pitch_ = 30.0f;
float camera_fov_y_deg_ = 45.0f;
bool projection_ortho_ = false;
QMatrix4x4 view_matrix_;
QMatrix4x4 proj_matrix_;