From 4c74b6ecf40578f25ae20780e3d8faa12faa817e Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 31 Dec 2014 16:15:51 +0000 Subject: [PATCH] Fixed bounding box calculation of submodels. --- common/lc_model.cpp | 10 +++++----- common/lc_model.h | 2 +- common/view.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index ede48b41..8db875bb 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1156,7 +1156,7 @@ void lcModel::SetActive(bool Active) CalculateStep(LC_STEP_MAX); float BoundingBox[6]; - GetPiecesBoundingBox(BoundingBox); + GetPiecesBoundingBox(BoundingBox, true); mPieceInfo->m_fDimensions[0] = BoundingBox[3]; mPieceInfo->m_fDimensions[1] = BoundingBox[4]; @@ -2556,7 +2556,7 @@ bool lcModel::GetSelectionCenter(lcVector3& Center) const return Selected; } -bool lcModel::GetPiecesBoundingBox(float BoundingBox[6]) const +bool lcModel::GetPiecesBoundingBox(float BoundingBox[6], bool IncludeHidden) const { if (mPieces.IsEmpty()) return false; @@ -2572,7 +2572,7 @@ bool lcModel::GetPiecesBoundingBox(float BoundingBox[6]) const { lcPiece* Piece = mPieces[PieceIdx]; - if (Piece->IsVisible(mCurrentStep)) + if (IncludeHidden || Piece->IsVisible(mCurrentStep)) Piece->CompareBoundingBox(BoundingBox); } @@ -3257,7 +3257,7 @@ void lcModel::LookAt(lcCamera* Camera) { float BoundingBox[6]; - if (GetPiecesBoundingBox(BoundingBox)) + if (GetPiecesBoundingBox(BoundingBox, false)) Center = lcVector3((BoundingBox[0] + BoundingBox[3]) / 2, (BoundingBox[1] + BoundingBox[4]) / 2, (BoundingBox[2] + BoundingBox[5]) / 2); else Center = lcVector3(0.0f, 0.0f, 0.0f); @@ -3276,7 +3276,7 @@ void lcModel::ZoomExtents(lcCamera* Camera, float Aspect) { float BoundingBox[6]; - if (!GetPiecesBoundingBox(BoundingBox)) + if (!GetPiecesBoundingBox(BoundingBox, false)) return; lcVector3 Center((BoundingBox[0] + BoundingBox[3]) / 2, (BoundingBox[1] + BoundingBox[4]) / 2, (BoundingBox[2] + BoundingBox[5]) / 2); diff --git a/common/lc_model.h b/common/lc_model.h index b11cd1be..212f44db 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -232,7 +232,7 @@ public: bool GetFocusPosition(lcVector3& Position) const; lcObject* GetFocusObject() const; bool GetSelectionCenter(lcVector3& Center) const; - bool GetPiecesBoundingBox(float BoundingBox[6]) const; + bool GetPiecesBoundingBox(float BoundingBox[6], bool IncludeHidden) const; void GetPartsList(int DefaultColorIndex, lcArray& PartsList) const; void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray& ModelParts) const; diff --git a/common/view.cpp b/common/view.cpp index 5f6a04fc..18462352 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -1098,7 +1098,7 @@ void View::DrawGrid() int MinX, MaxX, MinY, MaxY; float BoundingBox[6]; - bool GridSizeValid = mModel->GetPiecesBoundingBox(BoundingBox); + bool GridSizeValid = mModel->GetPiecesBoundingBox(BoundingBox, false); if (mTrackTool == LC_TRACKTOOL_INSERT) {