Unofficial project part

This commit is contained in:
Trevor SANDY 2022-07-06 16:23:31 +02:00
parent 23a93b4afb
commit 90d4feffe9
5 changed files with 13 additions and 4 deletions

View file

@ -164,7 +164,7 @@ PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentPro
{ {
PieceInfo* Info = PieceIt->second; PieceInfo* Info = PieceIt->second;
if ((!CurrentProject || !Info->IsModel() || CurrentProject->GetModels().FindIndex(Info->GetModel()) != -1) && (!ProjectPath.isEmpty() || !Info->IsProject())) if ((!CurrentProject || !Info->IsModel() || CurrentProject->GetModels().FindIndex(Info->GetModel()) != -1) && (!ProjectPath.isEmpty() || !Info->IsProject() || Info->IsProjectPiece()))
return Info; return Info;
} }

View file

@ -266,7 +266,7 @@ void lcPartSelectionListModel::SetFilter(const QString& Filter)
PieceInfo* Info = mParts[PartIdx].first; PieceInfo* Info = mParts[PartIdx].first;
bool Visible; bool Visible;
if (!mShowDecoratedParts && Info->IsPatterned()) if (!mShowDecoratedParts && Info->IsPatterned() && !Info->IsProjectPiece())
Visible = false; Visible = false;
else if (!mShowPartAliases && Info->m_strDescription[0] == '=') else if (!mShowPartAliases && Info->m_strDescription[0] == '=')
Visible = false; Visible = false;

View file

@ -93,7 +93,8 @@ lcPreview::lcPreview()
bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode) bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode)
{ {
lcPiecesLibrary* Library = lcGetPiecesLibrary(); lcPiecesLibrary* Library = lcGetPiecesLibrary();
PieceInfo* Info = Library->FindPiece(PartType.toLatin1().constData(), nullptr, false, false); Project* CurrentProject = lcGetActiveProject();
PieceInfo* Info = Library->FindPiece(PartType.toLatin1().constData(), CurrentProject, false, true);
if (Info) if (Info)
{ {

View file

@ -112,6 +112,13 @@ void PieceInfo::CreateProject(Project* Project, const char* PieceName)
m_strDescription[sizeof(m_strDescription) - 1] = 0; m_strDescription[sizeof(m_strDescription) - 1] = 0;
} }
bool PieceInfo::IsProjectPiece() const
{
if (mProject)
return !strcmp(m_strDescription, mProject->GetFileName().toLatin1().data());
return false;
}
bool PieceInfo::GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& WorldMatrix) const bool PieceInfo::GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& WorldMatrix) const
{ {
if (IsModel()) if (IsModel())
@ -346,7 +353,7 @@ void PieceInfo::GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool Add
if (AddSubModels) if (AddSubModels)
PartsList[this][DefaultColorIndex]++; PartsList[this][DefaultColorIndex]++;
} }
else if (IsProject()) else if (IsProject() && !IsProjectPiece())
{ {
const lcModel* const Model = mProject->GetMainModel(); const lcModel* const Model = mProject->GetMainModel();
if (Model) if (Model)

View file

@ -158,6 +158,7 @@ public:
return (m_strDescription[0] == '~'); return (m_strDescription[0] == '~');
} }
bool IsProjectPiece() const;
void ZoomExtents(float FoV, float AspectRatio, lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix) const; void ZoomExtents(float FoV, float AspectRatio, lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix) const;
void AddRenderMesh(lcScene& Scene); void AddRenderMesh(lcScene& Scene);
void AddRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const; void AddRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;