Correctly draw selection box outline of submodels.

This commit is contained in:
leo 2014-12-30 16:56:13 +00:00
parent d7396b4edb
commit 98aa121dec
4 changed files with 31 additions and 9 deletions

View file

@ -77,6 +77,7 @@ void lcApplication::SetProject(Project* Project)
for (int ViewIdx = 0; ViewIdx < Views.GetSize(); ViewIdx++)
Views[ViewIdx]->SetModel(lcGetActiveModel());
gMainWindow->UpdateAllViews();
gMainWindow->UpdateModels();
gMainWindow->UpdateTitle();
}

View file

@ -449,7 +449,6 @@ void lcModel::LoadLDraw(QTextStream& Stream)
continue;
}
// todo: mpd
// todo: load from disk
Info = lcGetPiecesLibrary()->FindPiece(PartID.toLatin1().constData(), true);
@ -954,10 +953,6 @@ void lcModel::SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMat
PieceInfo* Info = Piece->mPieceInfo;
Info->AddRenderMeshes(Scene, lcMul(Piece->mModelWorld, WorldMatrix), ColorIndex, Focused, Selected);
}
// todo: add model bounding box
// if (Selected)
// Scene.InterfaceObjects.Add(Piece);
}
void lcModel::DrawBackground(lcContext* Context)
@ -1172,6 +1167,33 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
gMainWindow->UpdateAllViews();
}
void lcModel::SetActive(bool Active)
{
if (Active)
{
CalculateStep(mCurrentStep);
}
else
{
CalculateStep(LC_STEP_MAX);
float BoundingBox[6];
GetPiecesBoundingBox(BoundingBox);
mPieceInfo->m_fDimensions[0] = BoundingBox[3];
mPieceInfo->m_fDimensions[1] = BoundingBox[4];
mPieceInfo->m_fDimensions[2] = BoundingBox[5];
mPieceInfo->m_fDimensions[3] = BoundingBox[0];
mPieceInfo->m_fDimensions[4] = BoundingBox[1];
mPieceInfo->m_fDimensions[5] = BoundingBox[2];
strncpy(mPieceInfo->m_strName, mProperties.mName.toLatin1().constData(), sizeof(mPieceInfo->m_strName));
mPieceInfo->m_strName[sizeof(mPieceInfo->m_strName) - 1] = 0;
strncpy(mPieceInfo->m_strDescription, mProperties.mName.toLatin1().constData(), sizeof(mPieceInfo->m_strDescription));
mPieceInfo->m_strDescription[sizeof(mPieceInfo->m_strDescription) - 1] = 0;
}
}
void lcModel::CalculateStep(lcStep Step)
{
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)

View file

@ -170,6 +170,7 @@ public:
return mCurrentStep;
}
void SetActive(bool Active);
void CalculateStep(lcStep Step);
void SetCurrentStep(lcStep Step)
{

View file

@ -55,11 +55,9 @@ void Project::SetActiveModel(int ModelIndex)
return;
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
if (ModelIdx != ModelIndex)
mModels[ModelIdx]->CalculateStep(LC_STEP_MAX);
mModels[ModelIdx]->SetActive(ModelIdx == ModelIndex);
mActiveModel = mModels[ModelIndex];
mActiveModel->CalculateStep(mActiveModel->GetCurrentStep());
mActiveModel->UpdateInterface();
gMainWindow->UpdateModels();
@ -242,7 +240,7 @@ bool Project::Load(const QString& FileName)
Model->CreatePieceInfo();
}
mActiveModel = mModels[0];
SetActiveModel(0);
/*