diff --git a/common/lc_library.cpp b/common/lc_library.cpp index c4be9f06..5484a6cd 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -164,7 +164,7 @@ PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentPro { 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; } diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 373d527e..4f984317 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -266,7 +266,7 @@ void lcPartSelectionListModel::SetFilter(const QString& Filter) PieceInfo* Info = mParts[PartIdx].first; bool Visible; - if (!mShowDecoratedParts && Info->IsPatterned()) + if (!mShowDecoratedParts && Info->IsPatterned() && !Info->IsProjectPiece()) Visible = false; else if (!mShowPartAliases && Info->m_strDescription[0] == '=') Visible = false; diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index 496b3521..fb7c4746 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -93,7 +93,8 @@ lcPreview::lcPreview() bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode) { 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) { diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index 8f5b8008..a1838575 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -112,6 +112,13 @@ void PieceInfo::CreateProject(Project* Project, const char* PieceName) 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 { if (IsModel()) @@ -346,7 +353,7 @@ void PieceInfo::GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool Add if (AddSubModels) PartsList[this][DefaultColorIndex]++; } - else if (IsProject()) + else if (IsProject() && !IsProjectPiece()) { const lcModel* const Model = mProject->GetMainModel(); if (Model) diff --git a/common/pieceinf.h b/common/pieceinf.h index b712f237..93cf43bf 100644 --- a/common/pieceinf.h +++ b/common/pieceinf.h @@ -158,6 +158,7 @@ public: return (m_strDescription[0] == '~'); } + bool IsProjectPiece() const; void ZoomExtents(float FoV, float AspectRatio, lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix) const; void AddRenderMesh(lcScene& Scene); void AddRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;