Zoom Extents now takes into account the current submodel transform. Fixes #953.

This commit is contained in:
Leonardo Zide 2024-11-14 11:30:38 -08:00
parent 0829365a51
commit a4f63fc54b
3 changed files with 12 additions and 5 deletions

View file

@ -1363,7 +1363,7 @@ QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
SetTemporaryStep(Step);
if (Zoom)
ZoomExtents(Camera, (float)Width / (float)Height);
ZoomExtents(Camera, (float)Width / (float)Height, lcMatrix44Identity());
View.OnDraw();
@ -4504,7 +4504,7 @@ void lcModel::MoveCamera(lcCamera* Camera, const lcVector3& Direction)
SaveCheckpoint(tr("Moving Camera"));
}
void lcModel::ZoomExtents(lcCamera* Camera, float Aspect)
void lcModel::ZoomExtents(lcCamera* Camera, float Aspect, const lcMatrix44& WorldMatrix)
{
std::vector<lcVector3> Points = GetPiecesBoundingBoxPoints();
@ -4513,8 +4513,10 @@ void lcModel::ZoomExtents(lcCamera* Camera, float Aspect)
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
for (const lcVector3& Point : Points)
for (lcVector3& Point : Points)
{
Point = lcMul31(Point, WorldMatrix);
Min = lcMin(Point, Min);
Max = lcMax(Point, Max);
}

View file

@ -345,7 +345,7 @@ public:
void ZoomRegionToolClicked(lcCamera* Camera, float AspectRatio, const lcVector3& Position, const lcVector3& TargetPosition, const lcVector3* Corners);
void LookAt(lcCamera* Camera);
void MoveCamera(lcCamera* Camera, const lcVector3& Direction);
void ZoomExtents(lcCamera* Camera, float Aspect);
void ZoomExtents(lcCamera* Camera, float Aspect, const lcMatrix44& WorldMatrix);
void Zoom(lcCamera* Camera, float Amount);
void MoveSelectedObjects(const lcVector3& Distance, bool AllowRelative, bool AlternateButtonDrag, bool Update, bool Checkpoint, bool FirstMove)

View file

@ -1880,8 +1880,13 @@ void lcView::Zoom(float Amount)
void lcView::ZoomExtents()
{
lcModel* ActiveModel = GetActiveModel();
if (ActiveModel)
ActiveModel->ZoomExtents(mCamera, (float)mWidth / (float)mHeight);
{
const lcMatrix44 WorldMatrix = mActiveSubmodelInstance ? mActiveSubmodelTransform : lcMatrix44Identity();
ActiveModel->ZoomExtents(mCamera, (float)mWidth / (float)mHeight, WorldMatrix);
}
}
lcCursor lcView::GetCursor() const