ifcviewer: move sidecar / direct-load helpers into ViewportCore (#84-q)

applyCachedModel, uploadMeshChunk, uploadInstanceChunk, finalizeModel
all live in ViewportCore now. The bonsai-facing public entry points on
ViewportWindow are one-line forwarders that keep
SceneLoader → ViewportWindow* binding intact.

State + helpers that came along:
- pending_direct_loads_ (the SidecarData staging map keyed by model_id)
- initial_view_applied_ (auto-viewAll suppression; aliased on VW so
  setCamera can still flip it)
- getOrCreateDirectStaging + createBufferWithData (anon namespace
  helpers on the core side)

The Qt-bound isExposed() / requestUpdate() pair on the
applyCachedModel tail becomes host_->requestFrame() — the
QtViewportHost forwards to requestUpdate(); a WebViewportHost will
forward to requestAnimationFrame.

The sidecar load path is now fully core-side. ViewportWindow no
longer owns any of the model-creation machinery; everything from
"here's a parsed sidecar" to "fully-built models_gpu_ entry with
empty pool slices waiting on streaming" runs through ViewportCore.
This commit is contained in:
Dion Moult
2026-06-06 17:57:31 +10:00
parent d92121a62d
commit 4782f54e3b
4 changed files with 552 additions and 547 deletions
+4 -13
View File
@@ -972,19 +972,10 @@ private:
// Sidecar paths queued before init completes.
std::deque<std::string> pending_sidecars_;
// Direct-IFC staging buffers, keyed by streamer model_id. Populated
// by uploadMeshChunk / uploadInstanceChunk; consumed and cleared by
// finalizeModel. Shape matches SidecarData so the same chunk-planner
// + apply flow services both sidecar and direct-IFC loads. Held by
// unique_ptr so emplace / erase don't copy the (potentially huge)
// vertex byte vector when the map rehashes.
std::unordered_map<uint32_t, std::unique_ptr<SidecarData>>
pending_direct_loads_;
// Set after the first model load triggers a viewAll(); prevents
// subsequent loads from snapping the camera away from where the
// user pointed it.
bool initial_view_applied_ = false;
// pending_direct_loads_ + initial_view_applied_ moved to ViewportCore
// (#84-q). initial_view_applied_ stays accessible here as a reference
// alias so VW::setCamera can flip it without poking through core_.
bool& initial_view_applied_;
// Camera state at the previous render() for motion detection. Any
// change means we apply the motion contribution threshold this frame