mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
ifcviewer: move camera mutators + AABB helpers into ViewportCore (#84-i)
Move the cluster of camera-state mutators + per-object AABB helpers now that the camera fields all live in ViewportCore. CameraState struct is canonical in core; ViewportWindow keeps a `using` alias so bonsai's HomeView round-trip (Commands.cpp setHome / restoreHome) compiles unchanged. Moved: void viewAll() void setCamera(...) — pitch + distance clamping included void setStandardView(yaw, pitch) — bypasses clamp for ±90° void toggleProjection() std::string cameraString() const CameraState cameraState() const void frameAabb(mn, mx, padding) bool computeObjectAabb(id, float[3], float[3]) const bool computeObjectAabb(id, Eigen::Vector3f&, Eigen::Vector3f&) const ViewportWindow keeps thin forwarders for the public ones (bonsai calls them). setCamera additionally flips initial_view_applied_ on the VW side — the auto-viewAll suppression flag isn't in core yet because the trigger for auto-viewAll lives in the still-in-VW applyCachedModel path. The isExposed()+requestUpdate() Qt pattern inside the moved bodies becomes host_->requestFrame(); two viewAll/toggleProjection diagnostic prints become fprintf since Log::info() doesn't reach into core.cpp through the Qt logging surface. Builds: desktop / bonsai / web all green. Tests 100/100.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <Eigen/Dense>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "BufferPool.h"
|
||||
@@ -124,6 +125,39 @@ public:
|
||||
float chunkScreenAreaPx(const ModelGpuData::Chunk& c,
|
||||
const Eigen::Matrix4f& vp_mat) const;
|
||||
|
||||
// Camera state snapshot for save-view / restore-view round-trips.
|
||||
// Same shape as ViewportWindow::CameraState (kept as a `using` alias
|
||||
// there) so bonsai's HomeView code keeps working.
|
||||
struct CameraState {
|
||||
Eigen::Vector3f target = Eigen::Vector3f::Zero();
|
||||
float distance = 50.0f;
|
||||
float yaw = 45.0f;
|
||||
float pitch = 30.0f;
|
||||
};
|
||||
|
||||
// ---- Camera mutators / getters ------------------------------------------
|
||||
|
||||
void viewAll();
|
||||
void setCamera(float tx, float ty, float tz,
|
||||
float dist, float yaw_deg, float pitch_deg);
|
||||
void setStandardView(float yaw_deg, float pitch_deg);
|
||||
void toggleProjection();
|
||||
bool projectionOrtho() const { return projection_ortho_; }
|
||||
std::string cameraString() const;
|
||||
CameraState cameraState() const;
|
||||
|
||||
// Re-aim the orbit camera so [mn, mx] fits the view with `padding`
|
||||
// headroom (1.10 typical). Used by viewAll and focusOnSelectedObject.
|
||||
void frameAabb(const float mn[3], const float mx[3], float padding);
|
||||
|
||||
// Per-object AABB lookup. Aggregates every instance of `object_id`
|
||||
// across every loaded model. Two overloads — float[3] for internal
|
||||
// callers; the Eigen::Vector3f overload exists so bonsai's volume
|
||||
// readout + focus paths compile unchanged.
|
||||
bool computeObjectAabb(uint32_t object_id, float mn[3], float mx[3]) const;
|
||||
bool computeObjectAabb(uint32_t object_id,
|
||||
Eigen::Vector3f& mn, Eigen::Vector3f& mx) const;
|
||||
|
||||
// Friend access for ViewportWindow's reference proxies. As each
|
||||
// render method moves into ViewportCore it stops needing these
|
||||
// (it touches the fields directly); once everything has migrated
|
||||
|
||||
Reference in New Issue
Block a user