mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Clean up for loops.
This commit is contained in:
parent
322a070a48
commit
53935734eb
1 changed files with 101 additions and 245 deletions
|
@ -207,8 +207,8 @@ bool lcModel::IncludesModel(const lcModel* Model) const
|
|||
if (Model == this)
|
||||
return true;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
if (mPieces[PieceIdx]->mPieceInfo->IncludesModel(Model))
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->mPieceInfo->IncludesModel(Model))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -281,10 +281,8 @@ void lcModel::UpdatePieceInfo(lcArray<lcModel*>& UpdatedModels)
|
|||
|
||||
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->GetStepHide() == LC_STEP_MAX)
|
||||
{
|
||||
Piece->mPieceInfo->UpdateBoundingBox(UpdatedModels);
|
||||
|
@ -312,10 +310,8 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly) const
|
|||
int CurrentLine = 0;
|
||||
int AddedSteps = 0;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (SelectedOnly && !Piece->IsSelected())
|
||||
continue;
|
||||
|
||||
|
@ -459,21 +455,13 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly) const
|
|||
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
for (lcCamera* Camera : mCameras)
|
||||
if (!SelectedOnly || Camera->IsSelected())
|
||||
Camera->SaveLDraw(Stream);
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
for (lcLight* Light : mLights)
|
||||
if (!SelectedOnly || Light->IsSelected())
|
||||
Light->SaveLDraw(Stream);
|
||||
}
|
||||
|
||||
Stream.flush();
|
||||
}
|
||||
|
@ -906,8 +894,8 @@ bool lcModel::LoadBinary(lcFile* file)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
mCameras[CameraIdx]->FileLoad(*file);
|
||||
for (lcCamera* Camera : mCameras)
|
||||
Camera->FileLoad(*file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1267,21 +1255,13 @@ void lcModel::GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface,
|
|||
|
||||
if (DrawInterface && !ActiveSubmodelInstance)
|
||||
{
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
for (lcCamera* Camera : mCameras)
|
||||
if (Camera != ViewCamera && Camera->IsVisible())
|
||||
Scene.AddInterfaceObject(Camera);
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
for (lcLight* Light : mLights)
|
||||
if (Light->IsVisible())
|
||||
Scene.AddInterfaceObject(Light);
|
||||
}
|
||||
}
|
||||
|
||||
Scene.End();
|
||||
|
@ -1461,35 +1441,25 @@ void lcModel::RayTest(lcObjectRayTest& ObjectRayTest) const
|
|||
|
||||
void lcModel::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsVisible(mCurrentStep))
|
||||
Piece->BoxTest(ObjectBoxTest);
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
for (lcCamera* Camera : mCameras)
|
||||
if (Camera != ObjectBoxTest.ViewCamera && Camera->IsVisible())
|
||||
Camera->BoxTest(ObjectBoxTest);
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
if (mLights[LightIdx]->IsVisible())
|
||||
mLights[LightIdx]->BoxTest(ObjectBoxTest);
|
||||
for (lcLight* Light : mLights)
|
||||
if (Light->IsVisible())
|
||||
Light->BoxTest(ObjectBoxTest);
|
||||
}
|
||||
|
||||
bool lcModel::SubModelMinIntersectDist(const lcVector3& WorldStart, const lcVector3& WorldEnd, float& MinDistance) const
|
||||
{
|
||||
bool MinIntersect = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
lcMatrix44 InverseWorldMatrix = lcMatrix44AffineInverse(Piece->mModelWorld);
|
||||
lcVector3 Start = lcMul31(WorldStart, InverseWorldMatrix);
|
||||
lcVector3 End = lcMul31(WorldEnd, InverseWorldMatrix);
|
||||
|
@ -1503,10 +1473,8 @@ bool lcModel::SubModelMinIntersectDist(const lcVector3& WorldStart, const lcVect
|
|||
|
||||
bool lcModel::SubModelBoxTest(const lcVector4 Planes[6]) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->GetStepHide() != LC_STEP_MAX)
|
||||
continue;
|
||||
|
||||
|
@ -1541,9 +1509,9 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
|
|||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
lcArray<PieceInfo*> Infos;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
PieceInfo* Info = mPieces[PieceIdx]->mPieceInfo;
|
||||
PieceInfo* Info = Piece->mPieceInfo;
|
||||
Library->LoadPieceInfo(Info, true, true);
|
||||
Infos.Add(Info);
|
||||
}
|
||||
|
@ -1572,9 +1540,8 @@ void lcModel::SetActive(bool Active)
|
|||
|
||||
void lcModel::CalculateStep(lcStep Step)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
Piece->UpdatePosition(Step);
|
||||
|
||||
if (Piece->IsSelected())
|
||||
|
@ -1586,11 +1553,11 @@ void lcModel::CalculateStep(lcStep Step)
|
|||
}
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
mCameras[CameraIdx]->UpdatePosition(Step);
|
||||
for (lcCamera* Camera : mCameras)
|
||||
Camera->UpdatePosition(Step);
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
mLights[LightIdx]->UpdatePosition(Step);
|
||||
for (lcLight* Light : mLights)
|
||||
Light->UpdatePosition(Step);
|
||||
}
|
||||
|
||||
void lcModel::SetCurrentStep(lcStep Step)
|
||||
|
@ -1642,27 +1609,26 @@ lcStep lcModel::GetLastStep() const
|
|||
{
|
||||
lcStep Step = 1;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
Step = lcMax(Step, mPieces[PieceIdx]->GetStepShow());
|
||||
for (lcPiece* Piece : mPieces)
|
||||
Step = lcMax(Step, Piece->GetStepShow());
|
||||
|
||||
return Step;
|
||||
}
|
||||
|
||||
void lcModel::InsertStep(lcStep Step)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
Piece->InsertTime(Step, 1);
|
||||
if (Piece->IsSelected() && !Piece->IsVisible(mCurrentStep))
|
||||
Piece->SetSelected(false);
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
mCameras[CameraIdx]->InsertTime(Step, 1);
|
||||
for (lcCamera* Camera : mCameras)
|
||||
Camera->InsertTime(Step, 1);
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
mLights[LightIdx]->InsertTime(Step, 1);
|
||||
for (lcLight* Light : mLights)
|
||||
Light->InsertTime(Step, 1);
|
||||
|
||||
SaveCheckpoint(tr("Inserting Step"));
|
||||
SetCurrentStep(mCurrentStep);
|
||||
|
@ -1670,19 +1636,18 @@ void lcModel::InsertStep(lcStep Step)
|
|||
|
||||
void lcModel::RemoveStep(lcStep Step)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
Piece->RemoveTime(Step, 1);
|
||||
if (Piece->IsSelected() && !Piece->IsVisible(mCurrentStep))
|
||||
Piece->SetSelected(false);
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
mCameras[CameraIdx]->RemoveTime(Step, 1);
|
||||
for (lcCamera* Camera : mCameras)
|
||||
Camera->RemoveTime(Step, 1);
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
mLights[LightIdx]->RemoveTime(Step, 1);
|
||||
for (lcLight* Light : mLights)
|
||||
Light->RemoveTime(Step, 1);
|
||||
|
||||
SaveCheckpoint(tr("Removing Step"));
|
||||
SetCurrentStep(mCurrentStep);
|
||||
|
@ -1701,13 +1666,9 @@ lcGroup* lcModel::AddGroup(const QString& Prefix, lcGroup* Parent)
|
|||
|
||||
lcGroup* lcModel::GetGroup(const QString& Name, bool CreateIfMissing)
|
||||
{
|
||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
||||
{
|
||||
lcGroup* Group = mGroups[GroupIdx];
|
||||
|
||||
for (lcGroup* Group : mGroups)
|
||||
if (Group->mName == Name)
|
||||
return Group;
|
||||
}
|
||||
|
||||
if (CreateIfMissing)
|
||||
{
|
||||
|
@ -1741,10 +1702,8 @@ void lcModel::GroupSelection()
|
|||
|
||||
lcGroup* NewGroup = GetGroup(Dialog.mName, true);
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
lcGroup* Group = Piece->GetTopGroup();
|
||||
|
@ -1763,10 +1722,8 @@ void lcModel::UngroupSelection()
|
|||
{
|
||||
lcArray<lcGroup*> SelectedGroups;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
lcGroup* Group = Piece->GetTopGroup();
|
||||
|
@ -1779,22 +1736,17 @@ void lcModel::UngroupSelection()
|
|||
}
|
||||
}
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
lcGroup* Group = Piece->GetGroup();
|
||||
|
||||
if (SelectedGroups.FindIndex(Group) != -1)
|
||||
Piece->SetGroup(nullptr);
|
||||
}
|
||||
|
||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
||||
{
|
||||
lcGroup* Group = mGroups[GroupIdx];
|
||||
|
||||
for (lcGroup* Group : mGroups)
|
||||
if (SelectedGroups.FindIndex(Group->mGroup) != -1)
|
||||
Group->mGroup = nullptr;
|
||||
}
|
||||
|
||||
SelectedGroups.DeleteAll();
|
||||
|
||||
|
@ -1806,10 +1758,8 @@ void lcModel::AddSelectedPiecesToGroup()
|
|||
{
|
||||
lcGroup* Group = nullptr;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
Group = Piece->GetTopGroup();
|
||||
|
@ -1820,10 +1770,8 @@ void lcModel::AddSelectedPiecesToGroup()
|
|||
|
||||
if (Group)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused())
|
||||
{
|
||||
Piece->SetGroup(Group);
|
||||
|
@ -1838,10 +1786,8 @@ void lcModel::AddSelectedPiecesToGroup()
|
|||
|
||||
void lcModel::RemoveFocusPieceFromGroup()
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused())
|
||||
{
|
||||
Piece->SetGroup(nullptr);
|
||||
|
@ -1858,17 +1804,11 @@ void lcModel::ShowEditGroupsDialog()
|
|||
QMap<lcPiece*, lcGroup*> PieceParents;
|
||||
QMap<lcGroup*, lcGroup*> GroupParents;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
for (lcPiece* Piece : mPieces)
|
||||
PieceParents[Piece] = Piece->GetGroup();
|
||||
}
|
||||
|
||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
||||
{
|
||||
lcGroup* Group = mGroups[GroupIdx];
|
||||
for (lcGroup* Group : mGroups)
|
||||
GroupParents[Group] = Group->mGroup;
|
||||
}
|
||||
|
||||
lcQEditGroupsDialog Dialog(gMainWindow, PieceParents, GroupParents, this);
|
||||
|
||||
|
@ -1877,21 +1817,19 @@ void lcModel::ShowEditGroupsDialog()
|
|||
|
||||
bool Modified = Dialog.mNewGroups.isEmpty();
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
lcGroup* ParentGroup = Dialog.mPieceParents.value(Piece);
|
||||
|
||||
if (ParentGroup != Piece->GetGroup())
|
||||
{
|
||||
mPieces[PieceIdx]->SetGroup(ParentGroup);
|
||||
Piece->SetGroup(ParentGroup);
|
||||
Modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
||||
for (lcGroup* Group : mGroups)
|
||||
{
|
||||
lcGroup* Group = mGroups[GroupIdx];
|
||||
lcGroup* ParentGroup = Dialog.mGroupParents.value(Group);
|
||||
|
||||
if (ParentGroup != Group->mGroup)
|
||||
|
@ -1913,9 +1851,9 @@ QString lcModel::GetGroupName(const QString& Prefix)
|
|||
int Length = Prefix.length();
|
||||
int Max = 0;
|
||||
|
||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
||||
for (lcGroup* Group : mGroups)
|
||||
{
|
||||
const QString& Name = mGroups[GroupIdx]->mName;
|
||||
const QString& Name = Group->mName;
|
||||
|
||||
if (Name.startsWith(Prefix))
|
||||
{
|
||||
|
@ -1942,8 +1880,8 @@ void lcModel::RemoveEmptyGroups()
|
|||
lcGroup* Group = mGroups[GroupIdx];
|
||||
int Ref = 0;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
if (mPieces[PieceIdx]->GetGroup() == Group)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->GetGroup() == Group)
|
||||
Ref++;
|
||||
|
||||
for (int ParentIdx = 0; ParentIdx < mGroups.GetSize(); ParentIdx++)
|
||||
|
@ -1958,10 +1896,8 @@ void lcModel::RemoveEmptyGroups()
|
|||
|
||||
if (Ref != 0)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->GetGroup() == Group)
|
||||
{
|
||||
Piece->SetGroup(Group->mGroup);
|
||||
|
@ -2072,10 +2008,8 @@ void lcModel::AddPiece()
|
|||
|
||||
lcPiece* Last = mPieces.IsEmpty() ? nullptr : mPieces[mPieces.GetSize() - 1];
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused())
|
||||
{
|
||||
Last = Piece;
|
||||
|
@ -2165,13 +2099,9 @@ void lcModel::DeleteSelectedObjects()
|
|||
|
||||
void lcModel::ResetSelectedPiecesPivotPoint()
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsSelected())
|
||||
Piece->ResetPivotPoint();
|
||||
}
|
||||
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
@ -2546,10 +2476,8 @@ void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector
|
|||
|
||||
if (AlternateButtonDrag)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused())
|
||||
{
|
||||
Piece->MovePivotPoint(TransformedPieceDistance);
|
||||
|
@ -2560,10 +2488,8 @@ void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
Piece->MoveSelected(mCurrentStep, gMainWindow->GetAddKeys(), TransformedPieceDistance);
|
||||
|
@ -2578,10 +2504,8 @@ void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector
|
|||
{
|
||||
lcVector3 TransformedObjectDistance = lcMul(ObjectDistance, RelativeRotation);
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
for (lcCamera* Camera : mCameras)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
if (Camera->IsSelected())
|
||||
{
|
||||
Camera->MoveSelected(mCurrentStep, gMainWindow->GetAddKeys(), TransformedObjectDistance);
|
||||
|
@ -2590,10 +2514,8 @@ void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector
|
|||
}
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
for (lcLight* Light : mLights)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
if (Light->IsSelected())
|
||||
{
|
||||
Light->MoveSelected(mCurrentStep, gMainWindow->GetAddKeys(), TransformedObjectDistance);
|
||||
|
@ -2656,10 +2578,8 @@ void lcModel::RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool
|
|||
else
|
||||
WorldToFocusMatrix = lcMatrix33Identity();
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (!Piece->IsSelected())
|
||||
continue;
|
||||
|
||||
|
@ -2731,10 +2651,8 @@ void lcModel::SetSelectedPiecesColorIndex(int ColorIndex)
|
|||
{
|
||||
bool Modified = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected() && Piece->mColorIndex != ColorIndex)
|
||||
{
|
||||
Piece->SetColorIndex(ColorIndex);
|
||||
|
@ -2755,10 +2673,8 @@ void lcModel::SetSelectedPiecesPieceInfo(PieceInfo* Info)
|
|||
{
|
||||
bool Modified = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected() && Piece->mPieceInfo != Info)
|
||||
{
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
|
@ -2782,10 +2698,8 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step)
|
|||
bool Modified = false;
|
||||
bool SelectionChanged = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected() && Piece->GetStepShow() != Step)
|
||||
{
|
||||
Piece->SetStepShow(Step);
|
||||
|
@ -2814,10 +2728,8 @@ void lcModel::SetSelectedPiecesStepHide(lcStep Step)
|
|||
bool Modified = false;
|
||||
bool SelectionChanged = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected() && Piece->GetStepHide() != Step)
|
||||
{
|
||||
Piece->SetStepHide(Step);
|
||||
|
@ -2906,8 +2818,8 @@ void lcModel::SetCameraName(lcCamera* Camera, const char* Name)
|
|||
|
||||
bool lcModel::AnyPiecesSelected() const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
if (mPieces[PieceIdx]->IsSelected())
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsSelected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -2915,16 +2827,16 @@ bool lcModel::AnyPiecesSelected() const
|
|||
|
||||
bool lcModel::AnyObjectsSelected() const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
if (mPieces[PieceIdx]->IsSelected())
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsSelected())
|
||||
return true;
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
if (mCameras[CameraIdx]->IsSelected())
|
||||
for (lcCamera* Camera : mCameras)
|
||||
if (Camera->IsSelected())
|
||||
return true;
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
if (mLights[LightIdx]->IsSelected())
|
||||
for (lcLight* Light : mLights)
|
||||
if (Light->IsSelected())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -2932,52 +2844,34 @@ bool lcModel::AnyObjectsSelected() const
|
|||
|
||||
lcObject* lcModel::GetFocusObject() const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsFocused())
|
||||
return Piece;
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
for (lcCamera* Camera : mCameras)
|
||||
if (Camera->IsFocused())
|
||||
return Camera;
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
for (lcLight* Light : mLights)
|
||||
if (Light->IsFocused())
|
||||
return Light;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
lcModel* lcModel::GetFirstSelectedSubmodel() const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsSelected() && Piece->mPieceInfo->IsModel())
|
||||
return Piece->mPieceInfo->GetModel();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void lcModel::GetSubModels(lcArray<lcModel*> SubModels) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->mPieceInfo->IsModel())
|
||||
{
|
||||
lcModel* SubModel = Piece->mPieceInfo->GetModel();
|
||||
|
@ -2995,10 +2889,8 @@ bool lcModel::GetMoveRotateTransform(lcVector3& Center, lcMatrix33& RelativeRota
|
|||
Center = lcVector3(0.0f, 0.0f, 0.0f);
|
||||
RelativeRotation = lcMatrix33Identity();
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (!Piece->IsSelected())
|
||||
continue;
|
||||
|
||||
|
@ -3013,10 +2905,8 @@ bool lcModel::GetMoveRotateTransform(lcVector3& Center, lcMatrix33& RelativeRota
|
|||
NumSelected++;
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
for (lcCamera* Camera : mCameras)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
if (!Camera->IsSelected())
|
||||
continue;
|
||||
|
||||
|
@ -3033,10 +2923,8 @@ bool lcModel::GetMoveRotateTransform(lcVector3& Center, lcMatrix33& RelativeRota
|
|||
NumSelected += 3;
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
for (lcLight* Light : mLights)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
if (!Light->IsSelected())
|
||||
continue;
|
||||
|
||||
|
@ -3071,10 +2959,8 @@ bool lcModel::GetPieceFocusOrSelectionCenter(lcVector3& Center) const
|
|||
lcPiece* Selected = nullptr;
|
||||
int NumSelected = 0;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused())
|
||||
{
|
||||
Center = Piece->mModelWorld.GetTranslation();
|
||||
|
@ -3139,10 +3025,8 @@ bool lcModel::GetSelectionCenter(lcVector3& Center) const
|
|||
bool SinglePieceSelected = true;
|
||||
bool Selected = false;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
Piece->CompareBoundingBox(Min, Max);
|
||||
|
@ -3155,10 +3039,8 @@ bool lcModel::GetSelectionCenter(lcVector3& Center) const
|
|||
}
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
for (lcCamera* Camera : mCameras)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
if (Camera->IsSelected())
|
||||
{
|
||||
Camera->CompareBoundingBox(Min, Max);
|
||||
|
@ -3167,10 +3049,8 @@ bool lcModel::GetSelectionCenter(lcVector3& Center) const
|
|||
}
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
for (lcLight* Light : mLights)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
if (Light->IsSelected())
|
||||
{
|
||||
Light->CompareBoundingBox(Min, Max);
|
||||
|
@ -3195,10 +3075,8 @@ bool lcModel::GetPiecesBoundingBox(lcVector3& Min, lcVector3& Max) const
|
|||
Min = lcVector3(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
Max = lcVector3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsVisible(mCurrentStep))
|
||||
{
|
||||
Piece->CompareBoundingBox(Min, Max);
|
||||
|
@ -3211,10 +3089,8 @@ bool lcModel::GetPiecesBoundingBox(lcVector3& Min, lcVector3& Max) const
|
|||
|
||||
void lcModel::GetPartsList(int DefaultColorIndex, bool IncludeSubmodels, lcPartsList& PartsList) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
int ColorIndex = Piece->mColorIndex;
|
||||
|
||||
if (ColorIndex == gDefaultColor)
|
||||
|
@ -3226,10 +3102,8 @@ void lcModel::GetPartsList(int DefaultColorIndex, bool IncludeSubmodels, lcParts
|
|||
|
||||
void lcModel::GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->GetStepShow() != Step)
|
||||
continue;
|
||||
|
||||
|
@ -3244,10 +3118,8 @@ void lcModel::GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsLis
|
|||
|
||||
void lcModel::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
int ColorIndex = Piece->mColorIndex;
|
||||
|
||||
if (ColorIndex == gDefaultColor)
|
||||
|
@ -3269,10 +3141,8 @@ void lcModel::GetSelectionInformation(int* Flags, lcArray<lcObject*>& Selection,
|
|||
lcGroup* Group = nullptr;
|
||||
bool First = true;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsSelected())
|
||||
{
|
||||
Selection.Add(Piece);
|
||||
|
@ -3332,10 +3202,8 @@ void lcModel::GetSelectionInformation(int* Flags, lcArray<lcObject*>& Selection,
|
|||
}
|
||||
}
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
for (lcCamera* Camera : mCameras)
|
||||
{
|
||||
lcCamera* Camera = mCameras[CameraIdx];
|
||||
|
||||
if (Camera->IsSelected())
|
||||
{
|
||||
Selection.Add(Camera);
|
||||
|
@ -3346,10 +3214,8 @@ void lcModel::GetSelectionInformation(int* Flags, lcArray<lcObject*>& Selection,
|
|||
}
|
||||
}
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
for (lcLight* Light : mLights)
|
||||
{
|
||||
lcLight* Light = mLights[LightIdx];
|
||||
|
||||
if (Light->IsSelected())
|
||||
{
|
||||
Selection.Add(Light);
|
||||
|
@ -3396,14 +3262,14 @@ lcArray<lcObject*> lcModel::GetSelectionModePieces(lcPiece* SelectedPiece) const
|
|||
|
||||
void lcModel::ClearSelection(bool UpdateInterface)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
mPieces[PieceIdx]->SetSelected(false);
|
||||
for (lcPiece* Piece : mPieces)
|
||||
Piece->SetSelected(false);
|
||||
|
||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||
mCameras[CameraIdx]->SetSelected(false);
|
||||
for (lcCamera* Camera : mCameras)
|
||||
Camera->SetSelected(false);
|
||||
|
||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
mLights[LightIdx]->SetSelected(false);
|
||||
for (lcLight* Light : mLights)
|
||||
Light->SetSelected(false);
|
||||
|
||||
if (UpdateInterface)
|
||||
{
|
||||
|
@ -3417,13 +3283,9 @@ void lcModel::SelectGroup(lcGroup* TopGroup, bool Select)
|
|||
if (!TopGroup)
|
||||
return;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (!Piece->IsSelected() && Piece->IsVisible(mCurrentStep) && (Piece->GetTopGroup() == TopGroup))
|
||||
Piece->SetSelected(Select);
|
||||
}
|
||||
}
|
||||
|
||||
void lcModel::FocusOrDeselectObject(const lcObjectSection& ObjectSection)
|
||||
|
@ -4225,13 +4087,9 @@ void lcModel::ShowSelectByColorDialog()
|
|||
ColorIndex = Dialog.mColorIndex;
|
||||
lcArray<lcObject*> Selection;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
for (lcPiece* Piece : mPieces)
|
||||
if (Piece->IsVisible(mCurrentStep) && Piece->mColorIndex == ColorIndex)
|
||||
Selection.Add(Piece);
|
||||
}
|
||||
|
||||
SetSelectionAndFocus(Selection, nullptr, 0, false);
|
||||
}
|
||||
|
@ -4271,10 +4129,8 @@ void lcModel::ShowArrayDialog()
|
|||
lcVector3 RotationAngles = Dialog.mRotations[0] * Step1 + Dialog.mRotations[1] * Step2 + Dialog.mRotations[2] * Step3;
|
||||
lcVector3 Offset = Dialog.mOffsets[0] * Step1 + Dialog.mOffsets[1] * Step2 + Dialog.mOffsets[2] * Step3;
|
||||
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
for (lcPiece* Piece : mPieces)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (!Piece->IsSelected())
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue