mirror of
https://github.com/leozide/leocad
synced 2025-02-07 08:45:49 +01:00
More accurate bounding box calculation for submodels.
This commit is contained in:
parent
ca73f3e3ad
commit
70da56bb05
6 changed files with 50 additions and 8 deletions
|
@ -1764,6 +1764,13 @@ bool lcModel::SubModelBoxTest(const lcVector4 Planes[6]) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcModel::SubModelCompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const
|
||||||
|
{
|
||||||
|
for (lcPiece* Piece : mPieces)
|
||||||
|
if (Piece->IsVisibleInSubModel())
|
||||||
|
Piece->SubmodelCompareBoundingBox(WorldMatrix, Min, Max);
|
||||||
|
}
|
||||||
|
|
||||||
void lcModel::SaveCheckpoint(const QString& Description)
|
void lcModel::SaveCheckpoint(const QString& Description)
|
||||||
{
|
{
|
||||||
lcModelHistoryEntry* ModelHistoryEntry = new lcModelHistoryEntry();
|
lcModelHistoryEntry* ModelHistoryEntry = new lcModelHistoryEntry();
|
||||||
|
|
|
@ -237,6 +237,7 @@ public:
|
||||||
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
||||||
bool SubModelMinIntersectDist(const lcVector3& WorldStart, const lcVector3& WorldEnd, float& MinDistance) const;
|
bool SubModelMinIntersectDist(const lcVector3& WorldStart, const lcVector3& WorldEnd, float& MinDistance) const;
|
||||||
bool SubModelBoxTest(const lcVector4 Planes[6]) const;
|
bool SubModelBoxTest(const lcVector4 Planes[6]) const;
|
||||||
|
void SubModelCompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const;
|
||||||
|
|
||||||
bool HasPieces() const
|
bool HasPieces() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -703,6 +703,11 @@ void lcPiece::AddSubModelRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMat
|
||||||
Scene.AddInterfaceObject(this);
|
Scene.AddInterfaceObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcPiece::SubmodelCompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const
|
||||||
|
{
|
||||||
|
mPieceInfo->CompareBoundingBox(lcMul(mModelWorld, WorldMatrix), Min, Max);
|
||||||
|
}
|
||||||
|
|
||||||
void lcPiece::MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance)
|
void lcPiece::MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance)
|
||||||
{
|
{
|
||||||
quint32 Section = GetFocusSection();
|
quint32 Section = GetFocusSection();
|
||||||
|
@ -934,11 +939,12 @@ const lcBoundingBox& lcPiece::GetBoundingBox() const
|
||||||
|
|
||||||
void lcPiece::CompareBoundingBox(lcVector3& Min, lcVector3& Max) const
|
void lcPiece::CompareBoundingBox(lcVector3& Min, lcVector3& Max) const
|
||||||
{
|
{
|
||||||
|
if (!mMesh)
|
||||||
|
mPieceInfo->CompareBoundingBox(mModelWorld, Min, Max);
|
||||||
|
else
|
||||||
|
{
|
||||||
lcVector3 Points[8];
|
lcVector3 Points[8];
|
||||||
|
|
||||||
if (!mMesh)
|
|
||||||
lcGetBoxCorners(GetBoundingBox(), Points);
|
|
||||||
else
|
|
||||||
lcGetBoxCorners(mMesh->mBoundingBox, Points);
|
lcGetBoxCorners(mMesh->mBoundingBox, Points);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
@ -948,6 +954,7 @@ void lcPiece::CompareBoundingBox(lcVector3& Min, lcVector3& Max) const
|
||||||
Min = lcMin(Point, Min);
|
Min = lcMin(Point, Min);
|
||||||
Max = lcMax(Point, Max);
|
Max = lcMax(Point, Max);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcGroup* lcPiece::GetTopGroup()
|
lcGroup* lcPiece::GetTopGroup()
|
||||||
|
|
|
@ -407,6 +407,7 @@ public:
|
||||||
|
|
||||||
void AddMainModelRenderMeshes(lcScene& Scene, bool Highlight, bool Fade) const;
|
void AddMainModelRenderMeshes(lcScene& Scene, bool Highlight, bool Fade) const;
|
||||||
void AddSubModelRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
void AddSubModelRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
||||||
|
void SubmodelCompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const;
|
||||||
|
|
||||||
void InsertTime(lcStep Start, lcStep Time);
|
void InsertTime(lcStep Start, lcStep Time);
|
||||||
void RemoveTime(lcStep Start, lcStep Time);
|
void RemoveTime(lcStep Start, lcStep Time);
|
||||||
|
|
|
@ -358,6 +358,31 @@ void PieceInfo::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorInd
|
||||||
ModelParts.emplace_back(lcModelPartsEntry{ WorldMatrix, this, nullptr, DefaultColorIndex });
|
ModelParts.emplace_back(lcModelPartsEntry{ WorldMatrix, this, nullptr, DefaultColorIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PieceInfo::CompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const
|
||||||
|
{
|
||||||
|
if (!IsModel())
|
||||||
|
{
|
||||||
|
lcVector3 Points[8];
|
||||||
|
|
||||||
|
if (!mMesh)
|
||||||
|
lcGetBoxCorners(GetBoundingBox(), Points);
|
||||||
|
else
|
||||||
|
lcGetBoxCorners(mMesh->mBoundingBox, Points);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
lcVector3 Point = lcMul31(Points[i], WorldMatrix);
|
||||||
|
|
||||||
|
Min = lcMin(Point, Min);
|
||||||
|
Max = lcMax(Point, Max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mModel->SubModelCompareBoundingBox(WorldMatrix, Min, Max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PieceInfo::UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels)
|
void PieceInfo::UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels)
|
||||||
{
|
{
|
||||||
if (IsModel())
|
if (IsModel())
|
||||||
|
|
|
@ -159,6 +159,7 @@ public:
|
||||||
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
|
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
|
||||||
void GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool AddSubModels, lcPartsList& PartsList) const;
|
void GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool AddSubModels, lcPartsList& PartsList) const;
|
||||||
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector<lcModelPartsEntry>& ModelParts) const;
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector<lcModelPartsEntry>& ModelParts) const;
|
||||||
|
void CompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const;
|
||||||
void UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels);
|
void UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels);
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
|
|
Loading…
Add table
Reference in a new issue