Fixed bounding box calculation of submodels.

This commit is contained in:
leo 2014-12-31 16:15:51 +00:00
parent 8cf9ece4b4
commit 4c74b6ecf4
3 changed files with 7 additions and 7 deletions

View file

@ -1156,7 +1156,7 @@ void lcModel::SetActive(bool Active)
CalculateStep(LC_STEP_MAX); CalculateStep(LC_STEP_MAX);
float BoundingBox[6]; float BoundingBox[6];
GetPiecesBoundingBox(BoundingBox); GetPiecesBoundingBox(BoundingBox, true);
mPieceInfo->m_fDimensions[0] = BoundingBox[3]; mPieceInfo->m_fDimensions[0] = BoundingBox[3];
mPieceInfo->m_fDimensions[1] = BoundingBox[4]; mPieceInfo->m_fDimensions[1] = BoundingBox[4];
@ -2556,7 +2556,7 @@ bool lcModel::GetSelectionCenter(lcVector3& Center) const
return Selected; return Selected;
} }
bool lcModel::GetPiecesBoundingBox(float BoundingBox[6]) const bool lcModel::GetPiecesBoundingBox(float BoundingBox[6], bool IncludeHidden) const
{ {
if (mPieces.IsEmpty()) if (mPieces.IsEmpty())
return false; return false;
@ -2572,7 +2572,7 @@ bool lcModel::GetPiecesBoundingBox(float BoundingBox[6]) const
{ {
lcPiece* Piece = mPieces[PieceIdx]; lcPiece* Piece = mPieces[PieceIdx];
if (Piece->IsVisible(mCurrentStep)) if (IncludeHidden || Piece->IsVisible(mCurrentStep))
Piece->CompareBoundingBox(BoundingBox); Piece->CompareBoundingBox(BoundingBox);
} }
@ -3257,7 +3257,7 @@ void lcModel::LookAt(lcCamera* Camera)
{ {
float BoundingBox[6]; 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); Center = lcVector3((BoundingBox[0] + BoundingBox[3]) / 2, (BoundingBox[1] + BoundingBox[4]) / 2, (BoundingBox[2] + BoundingBox[5]) / 2);
else else
Center = lcVector3(0.0f, 0.0f, 0.0f); Center = lcVector3(0.0f, 0.0f, 0.0f);
@ -3276,7 +3276,7 @@ void lcModel::ZoomExtents(lcCamera* Camera, float Aspect)
{ {
float BoundingBox[6]; float BoundingBox[6];
if (!GetPiecesBoundingBox(BoundingBox)) if (!GetPiecesBoundingBox(BoundingBox, false))
return; return;
lcVector3 Center((BoundingBox[0] + BoundingBox[3]) / 2, (BoundingBox[1] + BoundingBox[4]) / 2, (BoundingBox[2] + BoundingBox[5]) / 2); lcVector3 Center((BoundingBox[0] + BoundingBox[3]) / 2, (BoundingBox[1] + BoundingBox[4]) / 2, (BoundingBox[2] + BoundingBox[5]) / 2);

View file

@ -232,7 +232,7 @@ public:
bool GetFocusPosition(lcVector3& Position) const; bool GetFocusPosition(lcVector3& Position) const;
lcObject* GetFocusObject() const; lcObject* GetFocusObject() const;
bool GetSelectionCenter(lcVector3& Center) 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<lcPartsListEntry>& PartsList) const; void GetPartsList(int DefaultColorIndex, lcArray<lcPartsListEntry>& PartsList) const;
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const; void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const;

View file

@ -1098,7 +1098,7 @@ void View::DrawGrid()
int MinX, MaxX, MinY, MaxY; int MinX, MaxX, MinY, MaxY;
float BoundingBox[6]; float BoundingBox[6];
bool GridSizeValid = mModel->GetPiecesBoundingBox(BoundingBox); bool GridSizeValid = mModel->GetPiecesBoundingBox(BoundingBox, false);
if (mTrackTool == LC_TRACKTOOL_INSERT) if (mTrackTool == LC_TRACKTOOL_INSERT)
{ {