bonsaiviewer: View Selected Model from the models panel context menu

Right-clicking a model in the models panel now offers "View Selected Model",
which frames the camera on just that model's geometry — View All, scoped to
one model. With several models selected the action reads "View Selected
Models" and frames their union, matching how the panel's existing Move to
Group already treats a multi-selection.

The AABB fold behind viewAll moves into InstanceCompose, which exists so this
kind of logic is unit-testable without a Qt window or a wgpu device (populating
ViewportCore's model map needs a real GPU, so the fold was previously
untestable in place). It splits in two:

- sceneWorldAabb   — every VISIBLE model, what viewAll frames.
- modelsWorldAabb  — only the named models, hidden or not. A model the caller
                     named explicitly is framed even if hidden; second-guessing
                     that is worse than honouring it. Models with no loaded
                     geometry contribute nothing, and if none of them do the
                     camera is left alone rather than flying to the origin.

Both are covered by six new cases in test_instance_compose (131 total).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-07-14 13:53:30 +10:00
parent 89bb3074de
commit e4f8475ce8
10 changed files with 249 additions and 18 deletions
+3
View File
@@ -1402,6 +1402,9 @@ void ViewportWindow::setCamera(float tx, float ty, float tz,
// viewAll / frameAabb / computeObjectAabb moved to ViewportCore (#84-i).
void ViewportWindow::viewAll() { core_.viewAll(); }
bool ViewportWindow::viewModels(const std::vector<uint32_t>& session_model_ids) {
return core_.viewModels(session_model_ids);
}
void ViewportWindow::frameAabb(const float mn[3], const float mx[3], float padding) {
core_.frameAabb(mn, mx, padding);
}