mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Array cleanup.
This commit is contained in:
parent
ee5ed32172
commit
80d144fea8
19 changed files with 320 additions and 317 deletions
|
@ -934,7 +934,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
|
|
||||||
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
||||||
{
|
{
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcCamera*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcCamera*>(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
|
|
||||||
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
||||||
{
|
{
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcCamera*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcCamera*>(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +970,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
|
|
||||||
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
||||||
{
|
{
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcCamera*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcCamera*>(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
: lcArray((int)Init.size())
|
: lcArray((int)Init.size())
|
||||||
{
|
{
|
||||||
for (const T& Element : Init)
|
for (const T& Element : Init)
|
||||||
Add(Element);
|
emplace_back(Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
~lcArray()
|
~lcArray()
|
||||||
|
@ -112,17 +112,17 @@ public:
|
||||||
return &mData[0] + mLength;
|
return &mData[0] + mLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEmpty() const
|
bool empty() const
|
||||||
{
|
{
|
||||||
return mLength == 0;
|
return mLength == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetSize() const
|
int size() const
|
||||||
{
|
{
|
||||||
return mLength;
|
return mLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSize(size_t NewSize)
|
void resize(size_t NewSize)
|
||||||
{
|
{
|
||||||
if (NewSize > mAlloc)
|
if (NewSize > mAlloc)
|
||||||
AllocGrow(NewSize - mLength);
|
AllocGrow(NewSize - mLength);
|
||||||
|
@ -152,13 +152,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(const T& NewItem)
|
void emplace_back(const T& NewItem)
|
||||||
{
|
{
|
||||||
AllocGrow(1);
|
AllocGrow(1);
|
||||||
mData[mLength++] = NewItem;
|
mData[mLength++] = NewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& Add()
|
T& emplace_back()
|
||||||
{
|
{
|
||||||
AllocGrow(1);
|
AllocGrow(1);
|
||||||
mData[mLength++] = T();
|
mData[mLength++] = T();
|
||||||
|
|
|
@ -2173,7 +2173,7 @@ void lcMainWindow::CameraMenuAboutToShow()
|
||||||
QAction* Action = mActions[ActionIdx];
|
QAction* Action = mActions[ActionIdx];
|
||||||
int CameraIdx = ActionIdx - LC_VIEW_CAMERA_FIRST;
|
int CameraIdx = ActionIdx - LC_VIEW_CAMERA_FIRST;
|
||||||
|
|
||||||
if (CameraIdx < Cameras.GetSize())
|
if (CameraIdx < Cameras.size())
|
||||||
{
|
{
|
||||||
if (CurrentCamera == Cameras[CameraIdx])
|
if (CurrentCamera == Cameras[CameraIdx])
|
||||||
{
|
{
|
||||||
|
@ -2242,7 +2242,7 @@ void lcMainWindow::UpdateModels()
|
||||||
QAction* Action = mActions[ActionIdx];
|
QAction* Action = mActions[ActionIdx];
|
||||||
int ModelIdx = ActionIdx - LC_MODEL_FIRST;
|
int ModelIdx = ActionIdx - LC_MODEL_FIRST;
|
||||||
|
|
||||||
if (ModelIdx < Models.GetSize())
|
if (ModelIdx < Models.size())
|
||||||
{
|
{
|
||||||
Action->setChecked(CurrentModel == Models[ModelIdx]);
|
Action->setChecked(CurrentModel == Models[ModelIdx]);
|
||||||
Action->setText(QString::fromLatin1("%1%2 %3").arg(ModelIdx < 9 ? QString("&") : QString(), QString::number(ModelIdx + 1), Models[ModelIdx]->GetProperties().mFileName));
|
Action->setText(QString::fromLatin1("%1%2 %3").arg(ModelIdx < 9 ? QString("&") : QString(), QString::number(ModelIdx + 1), Models[ModelIdx]->GetProperties().mFileName));
|
||||||
|
@ -2395,7 +2395,7 @@ void lcMainWindow::MergeProject()
|
||||||
|
|
||||||
if (NewProject->Load(LoadFileName, true))
|
if (NewProject->Load(LoadFileName, true))
|
||||||
{
|
{
|
||||||
int NumModels = NewProject->GetModels().GetSize();
|
int NumModels = NewProject->GetModels().size();
|
||||||
|
|
||||||
lcGetActiveProject()->Merge(NewProject);
|
lcGetActiveProject()->Merge(NewProject);
|
||||||
|
|
||||||
|
@ -2461,7 +2461,7 @@ bool lcMainWindow::SaveProject(const QString& FileName)
|
||||||
if (SaveFileName.isEmpty())
|
if (SaveFileName.isEmpty())
|
||||||
SaveFileName = QFileInfo(QDir(lcGetProfileString(LC_PROFILE_PROJECTS_PATH)), Project->GetTitle()).absoluteFilePath();
|
SaveFileName = QFileInfo(QDir(lcGetProfileString(LC_PROFILE_PROJECTS_PATH)), Project->GetTitle()).absoluteFilePath();
|
||||||
|
|
||||||
QString Filter = (Project->GetModels().GetSize() > 1) ? tr("Supported Files (*.mpd);;All Files (*.*)") : tr("Supported Files (*.ldr *.dat *.mpd);;All Files (*.*)");
|
QString Filter = (Project->GetModels().size() > 1) ? tr("Supported Files (*.mpd);;All Files (*.*)") : tr("Supported Files (*.ldr *.dat *.mpd);;All Files (*.*)");
|
||||||
|
|
||||||
SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Model"), SaveFileName, Filter);
|
SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Model"), SaveFileName, Filter);
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize
|
||||||
{
|
{
|
||||||
if (Optimize)
|
if (Optimize)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = mVertices.GetSize() - 1; VertexIdx >= 0; VertexIdx--)
|
for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--)
|
||||||
{
|
{
|
||||||
const lcMeshLoaderVertex& Vertex = mVertices[VertexIdx];
|
const lcMeshLoaderVertex& Vertex = mVertices[VertexIdx];
|
||||||
|
|
||||||
|
@ -177,20 +177,20 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcMeshLoaderVertex& Vertex = mVertices.Add();
|
lcMeshLoaderVertex& Vertex = mVertices.emplace_back();
|
||||||
|
|
||||||
Vertex.Position = Position;
|
Vertex.Position = Position;
|
||||||
Vertex.Normal = lcVector3(0.0f, 0.0f, 0.0f);
|
Vertex.Normal = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
Vertex.NormalWeight = 0.0f;
|
Vertex.NormalWeight = 0.0f;
|
||||||
|
|
||||||
return mVertices.GetSize() - 1;
|
return mVertices.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVector3& Normal, float NormalWeight, bool Optimize)
|
quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVector3& Normal, float NormalWeight, bool Optimize)
|
||||||
{
|
{
|
||||||
if (Optimize)
|
if (Optimize)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = mVertices.GetSize() - 1; VertexIdx >= 0; VertexIdx--)
|
for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--)
|
||||||
{
|
{
|
||||||
lcMeshLoaderVertex& Vertex = mVertices[VertexIdx];
|
lcMeshLoaderVertex& Vertex = mVertices[VertexIdx];
|
||||||
|
|
||||||
|
@ -212,25 +212,25 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVecto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcMeshLoaderVertex& Vertex = mVertices.Add();
|
lcMeshLoaderVertex& Vertex = mVertices.emplace_back();
|
||||||
|
|
||||||
Vertex.Position = Position;
|
Vertex.Position = Position;
|
||||||
Vertex.Normal = Normal;
|
Vertex.Normal = Normal;
|
||||||
Vertex.NormalWeight = 1.0f;
|
Vertex.NormalWeight = 1.0f;
|
||||||
|
|
||||||
return mVertices.GetSize() - 1;
|
return mVertices.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4])
|
quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4])
|
||||||
{
|
{
|
||||||
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.Add();
|
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.emplace_back();
|
||||||
|
|
||||||
Vertex.Position[0] = Position[0];
|
Vertex.Position[0] = Position[0];
|
||||||
Vertex.Position[1] = Position[1];
|
Vertex.Position[1] = Position[1];
|
||||||
Vertex.Position[2] = Position[2];
|
Vertex.Position[2] = Position[2];
|
||||||
Vertex.Position[3] = Position[3];
|
Vertex.Position[3] = Position[3];
|
||||||
|
|
||||||
return mConditionalVertices.GetSize() - 1;
|
return mConditionalVertices.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Material, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize)
|
void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Material, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize)
|
||||||
|
@ -277,15 +277,15 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater
|
||||||
{
|
{
|
||||||
if (WindingCCW)
|
if (WindingCCW)
|
||||||
{
|
{
|
||||||
Section->mIndices.Add(Indices[0]);
|
Section->mIndices.emplace_back(Indices[0]);
|
||||||
Section->mIndices.Add(Indices[1]);
|
Section->mIndices.emplace_back(Indices[1]);
|
||||||
Section->mIndices.Add(Indices[2]);
|
Section->mIndices.emplace_back(Indices[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Section->mIndices.Add(Indices[2]);
|
Section->mIndices.emplace_back(Indices[2]);
|
||||||
Section->mIndices.Add(Indices[1]);
|
Section->mIndices.emplace_back(Indices[1]);
|
||||||
Section->mIndices.Add(Indices[0]);
|
Section->mIndices.emplace_back(Indices[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,8 +299,8 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater
|
||||||
|
|
||||||
if (Indices[0] != Indices[1])
|
if (Indices[0] != Indices[1])
|
||||||
{
|
{
|
||||||
Section->mIndices.Add(Indices[0]);
|
Section->mIndices.emplace_back(Indices[0]);
|
||||||
Section->mIndices.Add(Indices[1]);
|
Section->mIndices.emplace_back(Indices[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (LineType == 5)
|
else if (LineType == 5)
|
||||||
|
@ -308,22 +308,22 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater
|
||||||
int Indices[2];
|
int Indices[2];
|
||||||
|
|
||||||
Indices[0] = AddConditionalVertex(Vertices);
|
Indices[0] = AddConditionalVertex(Vertices);
|
||||||
Section->mIndices.Add(Indices[0]);
|
Section->mIndices.emplace_back(Indices[0]);
|
||||||
|
|
||||||
std::swap(Vertices[0], Vertices[1]);
|
std::swap(Vertices[0], Vertices[1]);
|
||||||
|
|
||||||
Indices[1] = AddConditionalVertex(Vertices);
|
Indices[1] = AddConditionalVertex(Vertices);
|
||||||
Section->mIndices.Add(Indices[1]);
|
Section->mIndices.emplace_back(Indices[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap)
|
void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap)
|
||||||
{
|
{
|
||||||
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
|
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
|
||||||
lcArray<quint32> IndexRemap(DataVertices.GetSize());
|
lcArray<quint32> IndexRemap(DataVertices.size());
|
||||||
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
|
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
|
||||||
|
|
||||||
mVertices.AllocGrow(DataVertices.GetSize());
|
mVertices.AllocGrow(DataVertices.size());
|
||||||
|
|
||||||
for (const lcMeshLoaderVertex& DataVertex : DataVertices)
|
for (const lcMeshLoaderVertex& DataVertex : DataVertices)
|
||||||
{
|
{
|
||||||
|
@ -340,11 +340,11 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
|
||||||
Index = AddVertex(Position, Normal, DataVertex.NormalWeight, true);
|
Index = AddVertex(Position, Normal, DataVertex.NormalWeight, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexRemap.Add(Index);
|
IndexRemap.emplace_back(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
mConditionalVertices.AllocGrow(Data.mConditionalVertices.GetSize());
|
mConditionalVertices.AllocGrow(Data.mConditionalVertices.size());
|
||||||
lcArray<quint32> ConditionalRemap(Data.mConditionalVertices.GetSize());
|
lcArray<quint32> ConditionalRemap(Data.mConditionalVertices.size());
|
||||||
|
|
||||||
for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices)
|
for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices)
|
||||||
{
|
{
|
||||||
|
@ -356,7 +356,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
|
||||||
Position[3] = lcMul31(DataVertex.Position[3], Transform);
|
Position[3] = lcMul31(DataVertex.Position[3], Transform);
|
||||||
|
|
||||||
const int Index = AddConditionalVertex(Position);
|
const int Index = AddConditionalVertex(Position);
|
||||||
ConditionalRemap.Add(Index);
|
ConditionalRemap.emplace_back(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::unique_ptr<lcMeshLoaderSection>& SrcSection : Data.mSections)
|
for (const std::unique_ptr<lcMeshLoaderSection>& SrcSection : Data.mSections)
|
||||||
|
@ -385,25 +385,25 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
|
||||||
DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode));
|
DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize());
|
DstSection->mIndices.AllocGrow(SrcSection->mIndices.size());
|
||||||
|
|
||||||
if (PrimitiveType == LC_MESH_CONDITIONAL_LINES)
|
if (PrimitiveType == LC_MESH_CONDITIONAL_LINES)
|
||||||
{
|
{
|
||||||
for (const quint32 Index : SrcSection->mIndices)
|
for (const quint32 Index : SrcSection->mIndices)
|
||||||
DstSection->mIndices.Add(ConditionalRemap[Index]);
|
DstSection->mIndices.emplace_back(ConditionalRemap[Index]);
|
||||||
}
|
}
|
||||||
else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES))
|
else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES))
|
||||||
{
|
{
|
||||||
for (const quint32 Index : SrcSection->mIndices)
|
for (const quint32 Index : SrcSection->mIndices)
|
||||||
DstSection->mIndices.Add(IndexRemap[Index]);
|
DstSection->mIndices.emplace_back(IndexRemap[Index]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx += 3)
|
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3)
|
||||||
{
|
{
|
||||||
DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 2]]);
|
DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 2]]);
|
||||||
DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 1]]);
|
DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 1]]);
|
||||||
DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 0]]);
|
DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 0]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,15 +415,15 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
|
||||||
quint32 BaseIndex;
|
quint32 BaseIndex;
|
||||||
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
|
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
|
||||||
|
|
||||||
BaseIndex = mVertices.GetSize();
|
BaseIndex = mVertices.size();
|
||||||
|
|
||||||
mVertices.SetGrow(lcMin(mVertices.GetSize(), 8 * 1024 * 1024));
|
mVertices.SetGrow(lcMin(mVertices.size(), 8 * 1024 * 1024));
|
||||||
mVertices.AllocGrow(DataVertices.GetSize());
|
mVertices.AllocGrow(DataVertices.size());
|
||||||
|
|
||||||
for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.GetSize(); SrcVertexIdx++)
|
for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.size(); SrcVertexIdx++)
|
||||||
{
|
{
|
||||||
const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx];
|
const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx];
|
||||||
lcMeshLoaderVertex& DstVertex = mVertices.Add();
|
lcMeshLoaderVertex& DstVertex = mVertices.emplace_back();
|
||||||
DstVertex.Position = lcMul31(SrcVertex.Position, Transform);
|
DstVertex.Position = lcMul31(SrcVertex.Position, Transform);
|
||||||
DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
|
DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
|
||||||
if (InvertNormals)
|
if (InvertNormals)
|
||||||
|
@ -431,12 +431,12 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
|
||||||
DstVertex.NormalWeight = SrcVertex.NormalWeight;
|
DstVertex.NormalWeight = SrcVertex.NormalWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
mConditionalVertices.AllocGrow(Data.mConditionalVertices.GetSize());
|
mConditionalVertices.AllocGrow(Data.mConditionalVertices.size());
|
||||||
const quint32 BaseConditional = mConditionalVertices.GetSize();
|
const quint32 BaseConditional = mConditionalVertices.size();
|
||||||
|
|
||||||
for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices)
|
for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices)
|
||||||
{
|
{
|
||||||
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.Add();
|
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.emplace_back();
|
||||||
|
|
||||||
Vertex.Position[0] = lcMul31(DataVertex.Position[0], Transform);
|
Vertex.Position[0] = lcMul31(DataVertex.Position[0], Transform);
|
||||||
Vertex.Position[1] = lcMul31(DataVertex.Position[1], Transform);
|
Vertex.Position[1] = lcMul31(DataVertex.Position[1], Transform);
|
||||||
|
@ -470,26 +470,26 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
|
||||||
DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode));
|
DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
DstSection->mIndices.SetGrow(lcMin(DstSection->mIndices.GetSize(), 8 * 1024 * 1024));
|
DstSection->mIndices.SetGrow(lcMin(DstSection->mIndices.size(), 8 * 1024 * 1024));
|
||||||
DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize());
|
DstSection->mIndices.AllocGrow(SrcSection->mIndices.size());
|
||||||
|
|
||||||
if (PrimitiveType == LC_MESH_CONDITIONAL_LINES)
|
if (PrimitiveType == LC_MESH_CONDITIONAL_LINES)
|
||||||
{
|
{
|
||||||
for (const quint32 Index : SrcSection->mIndices)
|
for (const quint32 Index : SrcSection->mIndices)
|
||||||
DstSection->mIndices.Add(BaseConditional + Index);
|
DstSection->mIndices.emplace_back(BaseConditional + Index);
|
||||||
}
|
}
|
||||||
else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES))
|
else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES))
|
||||||
{
|
{
|
||||||
for (const quint32 Index : SrcSection->mIndices)
|
for (const quint32 Index : SrcSection->mIndices)
|
||||||
DstSection->mIndices.Add(BaseIndex + Index);
|
DstSection->mIndices.emplace_back(BaseIndex + Index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx += 3)
|
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3)
|
||||||
{
|
{
|
||||||
DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 2]);
|
DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 2]);
|
||||||
DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 1]);
|
DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 1]);
|
||||||
DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 0]);
|
DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,9 +498,9 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
|
||||||
void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, int VertexCount, int* BaseVertex, lcMeshLoaderVertex** VertexBuffer)
|
void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, int VertexCount, int* BaseVertex, lcMeshLoaderVertex** VertexBuffer)
|
||||||
{
|
{
|
||||||
lcArray<lcMeshLoaderVertex>& Vertices = mData[MeshDataType].mVertices;
|
lcArray<lcMeshLoaderVertex>& Vertices = mData[MeshDataType].mVertices;
|
||||||
int CurrentSize = Vertices.GetSize();
|
int CurrentSize = Vertices.size();
|
||||||
|
|
||||||
Vertices.SetSize(CurrentSize + VertexCount);
|
Vertices.resize(CurrentSize + VertexCount);
|
||||||
|
|
||||||
*BaseVertex = CurrentSize;
|
*BaseVertex = CurrentSize;
|
||||||
*VertexBuffer = &Vertices[CurrentSize];
|
*VertexBuffer = &Vertices[CurrentSize];
|
||||||
|
@ -510,9 +510,9 @@ void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, lcMeshPrimitiveT
|
||||||
{
|
{
|
||||||
lcMeshLoaderSection* Section = mData[MeshDataType].AddSection(PrimitiveType, GetMaterial(ColorCode));
|
lcMeshLoaderSection* Section = mData[MeshDataType].AddSection(PrimitiveType, GetMaterial(ColorCode));
|
||||||
lcArray<quint32>& Indices = Section->mIndices;
|
lcArray<quint32>& Indices = Section->mIndices;
|
||||||
const int CurrentSize = Indices.GetSize();
|
const int CurrentSize = Indices.size();
|
||||||
|
|
||||||
Indices.SetSize(CurrentSize + IndexCount);
|
Indices.resize(CurrentSize + IndexCount);
|
||||||
|
|
||||||
*IndexBuffer = &Indices[CurrentSize];
|
*IndexBuffer = &Indices[CurrentSize];
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,7 @@ static bool lcMeshLoaderFinalSectionCompare(const lcMeshLoaderFinalSection& a, c
|
||||||
|
|
||||||
quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoords)
|
quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoords)
|
||||||
{
|
{
|
||||||
for (int VertexIndex = mTexturedVertices.GetSize() - 1; VertexIndex >= 0; VertexIndex--)
|
for (int VertexIndex = mTexturedVertices.size() - 1; VertexIndex >= 0; VertexIndex--)
|
||||||
{
|
{
|
||||||
const lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices[VertexIndex];
|
const lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices[VertexIndex];
|
||||||
|
|
||||||
|
@ -639,13 +639,13 @@ quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lc
|
||||||
return VertexIndex;
|
return VertexIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices.Add();
|
lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices.emplace_back();
|
||||||
|
|
||||||
Vertex.Position = Position;
|
Vertex.Position = Position;
|
||||||
Vertex.Normal = Normal;
|
Vertex.Normal = Normal;
|
||||||
Vertex.TexCoords = TexCoords;
|
Vertex.TexCoords = TexCoords;
|
||||||
|
|
||||||
return mTexturedVertices.GetSize() - 1;
|
return mTexturedVertices.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcLibraryMeshData::GeneratePlanarTexcoords(lcMeshLoaderSection* Section, const lcMeshLoaderTypeData& Data)
|
void lcLibraryMeshData::GeneratePlanarTexcoords(lcMeshLoaderSection* Section, const lcMeshLoaderTypeData& Data)
|
||||||
|
@ -688,7 +688,7 @@ void lcLibraryMeshData::GenerateCylindricalTexcoords(lcMeshLoaderSection* Sectio
|
||||||
const lcVector4 Plane2 = lcVector4(Plane2Normal, -lcDot(Plane2Normal, Material->Points[1]));
|
const lcVector4 Plane2 = lcVector4(Plane2Normal, -lcDot(Plane2Normal, Material->Points[1]));
|
||||||
const float Angle = 360.0f / Material->Angles[0];
|
const float Angle = 360.0f / Material->Angles[0];
|
||||||
|
|
||||||
for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.GetSize(); TriangleIndex += 3)
|
for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3)
|
||||||
{
|
{
|
||||||
const lcVector3 Positions[3] =
|
const lcVector3 Positions[3] =
|
||||||
{
|
{
|
||||||
|
@ -731,7 +731,7 @@ void lcLibraryMeshData::GenerateSphericalTexcoords(lcMeshLoaderSection* Section,
|
||||||
const float Angle1 = 360.0f / Material->Angles[0];
|
const float Angle1 = 360.0f / Material->Angles[0];
|
||||||
const float Angle2 = 180.0f / Material->Angles[1];
|
const float Angle2 = 180.0f / Material->Angles[1];
|
||||||
|
|
||||||
for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.GetSize(); TriangleIndex += 3)
|
for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3)
|
||||||
{
|
{
|
||||||
const lcVector3 Positions[3] =
|
const lcVector3 Positions[3] =
|
||||||
{
|
{
|
||||||
|
@ -808,9 +808,9 @@ lcMesh* lcLibraryMeshData::CreateMesh()
|
||||||
for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++)
|
for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++)
|
||||||
{
|
{
|
||||||
BaseVertices[MeshDataIdx] = NumVertices;
|
BaseVertices[MeshDataIdx] = NumVertices;
|
||||||
NumVertices += mData[MeshDataIdx].mVertices.GetSize();
|
NumVertices += mData[MeshDataIdx].mVertices.size();
|
||||||
BaseConditionalVertices[MeshDataIdx] = ConditionalVertexCount;
|
BaseConditionalVertices[MeshDataIdx] = ConditionalVertexCount;
|
||||||
ConditionalVertexCount += mData[MeshDataIdx].mConditionalVertices.GetSize();
|
ConditionalVertexCount += mData[MeshDataIdx].mConditionalVertices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasTextures)
|
if (mHasTextures)
|
||||||
|
@ -829,7 +829,7 @@ lcMesh* lcLibraryMeshData::CreateMesh()
|
||||||
if (FinalSection.PrimitiveType == Section->mPrimitiveType && FinalSection.Color == Section->mMaterial->Color && !strcmp(FinalSection.Name, Section->mMaterial->Name))
|
if (FinalSection.PrimitiveType == Section->mPrimitiveType && FinalSection.Color == Section->mMaterial->Color && !strcmp(FinalSection.Name, Section->mMaterial->Name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcMeshLoaderFinalSection& FinalSection = FinalSections.Add();
|
lcMeshLoaderFinalSection& FinalSection = FinalSections.emplace_back();
|
||||||
|
|
||||||
FinalSection.PrimitiveType = Section->mPrimitiveType;
|
FinalSection.PrimitiveType = Section->mPrimitiveType;
|
||||||
FinalSection.Color = Section->mMaterial->Color;
|
FinalSection.Color = Section->mMaterial->Color;
|
||||||
|
@ -838,23 +838,23 @@ lcMesh* lcLibraryMeshData::CreateMesh()
|
||||||
|
|
||||||
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LC_MESHDATA_SHARED].mSections)
|
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LC_MESHDATA_SHARED].mSections)
|
||||||
{
|
{
|
||||||
NumIndices += Section->mIndices.GetSize();
|
NumIndices += Section->mIndices.size();
|
||||||
|
|
||||||
AddFinalSection(Section.get(), FinalSections[LodIdx]);
|
AddFinalSection(Section.get(), FinalSections[LodIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LodIdx].mSections)
|
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LodIdx].mSections)
|
||||||
{
|
{
|
||||||
NumIndices += Section->mIndices.GetSize();
|
NumIndices += Section->mIndices.size();
|
||||||
|
|
||||||
AddFinalSection(Section.get(), FinalSections[LodIdx]);
|
AddFinalSection(Section.get(), FinalSections[LodIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumSections[LodIdx] = FinalSections[LodIdx].GetSize();
|
NumSections[LodIdx] = FinalSections[LodIdx].size();
|
||||||
std::sort(FinalSections[LodIdx].begin(), FinalSections[LodIdx].end(), lcMeshLoaderFinalSectionCompare);
|
std::sort(FinalSections[LodIdx].begin(), FinalSections[LodIdx].end(), lcMeshLoaderFinalSectionCompare);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh->Create(NumSections, NumVertices, mTexturedVertices.GetSize(), ConditionalVertexCount, NumIndices);
|
Mesh->Create(NumSections, NumVertices, mTexturedVertices.size(), ConditionalVertexCount, NumIndices);
|
||||||
|
|
||||||
lcVertex* DstVerts = (lcVertex*)Mesh->mVertexData;
|
lcVertex* DstVerts = (lcVertex*)Mesh->mVertexData;
|
||||||
|
|
||||||
|
@ -918,7 +918,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArray<lcMeshLoaderFi
|
||||||
|
|
||||||
for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++)
|
for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++)
|
||||||
{
|
{
|
||||||
for (int SectionIdx = 0; SectionIdx < FinalSections[LodIdx].GetSize(); SectionIdx++)
|
for (int SectionIdx = 0; SectionIdx < FinalSections[LodIdx].size(); SectionIdx++)
|
||||||
{
|
{
|
||||||
const lcMeshLoaderFinalSection& FinalSection = FinalSections[LodIdx][SectionIdx];
|
const lcMeshLoaderFinalSection& FinalSection = FinalSections[LodIdx][SectionIdx];
|
||||||
lcMeshSection& DstSection = Mesh->mLods[LodIdx].Sections[SectionIdx];
|
lcMeshSection& DstSection = Mesh->mLods[LodIdx].Sections[SectionIdx];
|
||||||
|
@ -953,7 +953,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArray<lcMeshLoaderFi
|
||||||
{
|
{
|
||||||
const IndexType BaseVertex = BaseVertices[SrcDataType];
|
const IndexType BaseVertex = BaseVertices[SrcDataType];
|
||||||
|
|
||||||
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++)
|
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++)
|
||||||
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];
|
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -962,14 +962,14 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArray<lcMeshLoaderFi
|
||||||
{
|
{
|
||||||
const IndexType BaseVertex = BaseConditionalVertices[SrcDataType];
|
const IndexType BaseVertex = BaseConditionalVertices[SrcDataType];
|
||||||
|
|
||||||
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++)
|
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++)
|
||||||
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];
|
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_MESH_TEXTURED_TRIANGLES:
|
case LC_MESH_TEXTURED_TRIANGLES:
|
||||||
{
|
{
|
||||||
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++)
|
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++)
|
||||||
*Index++ = SrcSection->mIndices[IndexIdx];
|
*Index++ = SrcSection->mIndices[IndexIdx];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -978,7 +978,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArray<lcMeshLoaderFi
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DstSection.NumIndices += SrcSection->mIndices.GetSize();
|
DstSection.NumIndices += SrcSection->mIndices.size();
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LC_MESHDATA_SHARED].mSections)
|
for (const std::unique_ptr<lcMeshLoaderSection>& Section : mData[LC_MESHDATA_SHARED].mSections)
|
||||||
|
|
|
@ -317,7 +317,7 @@ void lcModel::UpdatePieceInfo(std::vector<lcModel*>& UpdatedModels)
|
||||||
|
|
||||||
const lcMesh* Mesh = mPieceInfo->GetMesh();
|
const lcMesh* Mesh = mPieceInfo->GetMesh();
|
||||||
|
|
||||||
if (mPieces.IsEmpty() && !Mesh)
|
if (mPieces.empty() && !Mesh)
|
||||||
{
|
{
|
||||||
mPieceInfo->SetBoundingBox(lcVector3(0.0f, 0.0f, 0.0f), lcVector3(0.0f, 0.0f, 0.0f));
|
mPieceInfo->SetBoundingBox(lcVector3(0.0f, 0.0f, 0.0f), lcVector3(0.0f, 0.0f, 0.0f));
|
||||||
return;
|
return;
|
||||||
|
@ -405,7 +405,7 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep)
|
||||||
|
|
||||||
if (PieceGroup)
|
if (PieceGroup)
|
||||||
{
|
{
|
||||||
if (CurrentGroups.IsEmpty() || (!CurrentGroups.IsEmpty() && PieceGroup != CurrentGroups[CurrentGroups.GetSize() - 1]))
|
if (CurrentGroups.empty() || (!CurrentGroups.empty() && PieceGroup != CurrentGroups[CurrentGroups.size() - 1]))
|
||||||
{
|
{
|
||||||
lcArray<lcGroup*> PieceParents;
|
lcArray<lcGroup*> PieceParents;
|
||||||
|
|
||||||
|
@ -414,14 +414,14 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep)
|
||||||
|
|
||||||
int FoundParent = -1;
|
int FoundParent = -1;
|
||||||
|
|
||||||
while (!CurrentGroups.IsEmpty())
|
while (!CurrentGroups.empty())
|
||||||
{
|
{
|
||||||
lcGroup* Group = CurrentGroups[CurrentGroups.GetSize() - 1];
|
lcGroup* Group = CurrentGroups[CurrentGroups.size() - 1];
|
||||||
const int Index = PieceParents.FindIndex(Group);
|
const int Index = PieceParents.FindIndex(Group);
|
||||||
|
|
||||||
if (Index == -1)
|
if (Index == -1)
|
||||||
{
|
{
|
||||||
CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1);
|
CurrentGroups.RemoveIndex(CurrentGroups.size() - 1);
|
||||||
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -431,19 +431,19 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ParentIdx = FoundParent + 1; ParentIdx < PieceParents.GetSize(); ParentIdx++)
|
for (int ParentIdx = FoundParent + 1; ParentIdx < PieceParents.size(); ParentIdx++)
|
||||||
{
|
{
|
||||||
lcGroup* Group = PieceParents[ParentIdx];
|
lcGroup* Group = PieceParents[ParentIdx];
|
||||||
CurrentGroups.Add(Group);
|
CurrentGroups.emplace_back(Group);
|
||||||
Stream << QLatin1String("0 !LEOCAD GROUP BEGIN ") << Group->mName << LineEnding;
|
Stream << QLatin1String("0 !LEOCAD GROUP BEGIN ") << Group->mName << LineEnding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (CurrentGroups.GetSize())
|
while (CurrentGroups.size())
|
||||||
{
|
{
|
||||||
CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1);
|
CurrentGroups.RemoveIndex(CurrentGroups.size() - 1);
|
||||||
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,9 +495,9 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep)
|
||||||
CurrentLine++;
|
CurrentLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (CurrentGroups.GetSize())
|
while (CurrentGroups.size())
|
||||||
{
|
{
|
||||||
CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1);
|
CurrentGroups.RemoveIndex(CurrentGroups.size() - 1);
|
||||||
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
Stream << QLatin1String("0 !LEOCAD GROUP END\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||||
if (Camera->ParseLDrawLine(LineStream))
|
if (Camera->ParseLDrawLine(LineStream))
|
||||||
{
|
{
|
||||||
Camera->CreateName(mCameras);
|
Camera->CreateName(mCameras);
|
||||||
mCameras.Add(Camera);
|
mCameras.emplace_back(Camera);
|
||||||
Camera = nullptr;
|
Camera = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||||
if (Light->ParseLDrawLine(LineStream))
|
if (Light->ParseLDrawLine(LineStream))
|
||||||
{
|
{
|
||||||
Light->CreateName(mLights);
|
Light->CreateName(mLights);
|
||||||
mLights.Add(Light);
|
mLights.emplace_back(Light);
|
||||||
Light = nullptr;
|
Light = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,16 +671,16 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||||
{
|
{
|
||||||
QString Name = LineStream.readAll().trimmed();
|
QString Name = LineStream.readAll().trimmed();
|
||||||
lcGroup* Group = GetGroup(Name, true);
|
lcGroup* Group = GetGroup(Name, true);
|
||||||
if (!CurrentGroups.IsEmpty())
|
if (!CurrentGroups.empty())
|
||||||
Group->mGroup = CurrentGroups[CurrentGroups.GetSize() - 1];
|
Group->mGroup = CurrentGroups[CurrentGroups.size() - 1];
|
||||||
else
|
else
|
||||||
Group->mGroup = nullptr;
|
Group->mGroup = nullptr;
|
||||||
CurrentGroups.Add(Group);
|
CurrentGroups.emplace_back(Group);
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("END"))
|
else if (Token == QLatin1String("END"))
|
||||||
{
|
{
|
||||||
if (!CurrentGroups.IsEmpty())
|
if (!CurrentGroups.empty())
|
||||||
CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1);
|
CurrentGroups.RemoveIndex(CurrentGroups.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("SYNTH"))
|
else if (Token == QLatin1String("SYNTH"))
|
||||||
|
@ -739,8 +739,8 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||||
if (!Piece)
|
if (!Piece)
|
||||||
Piece = new lcPiece(nullptr);
|
Piece = new lcPiece(nullptr);
|
||||||
|
|
||||||
if (!CurrentGroups.IsEmpty())
|
if (!CurrentGroups.empty())
|
||||||
Piece->SetGroup(CurrentGroups[CurrentGroups.GetSize() - 1]);
|
Piece->SetGroup(CurrentGroups[CurrentGroups.size() - 1]);
|
||||||
|
|
||||||
PieceInfo* Info = Library->FindPiece(PartId.toLatin1().constData(), Project, true, true);
|
PieceInfo* Info = Library->FindPiece(PartId.toLatin1().constData(), Project, true, true);
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ bool lcModel::LoadBinary(lcFile* file)
|
||||||
file->ReadS32(&count, 1);
|
file->ReadS32(&count, 1);
|
||||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||||
|
|
||||||
const int FirstNewPiece = mPieces.GetSize();
|
const int FirstNewPiece = mPieces.size();
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
|
@ -919,13 +919,13 @@ bool lcModel::LoadBinary(lcFile* file)
|
||||||
|
|
||||||
if (fv >= 0.5f)
|
if (fv >= 0.5f)
|
||||||
{
|
{
|
||||||
const int NumGroups = mGroups.GetSize();
|
const int NumGroups = mGroups.size();
|
||||||
|
|
||||||
file->ReadS32(&count, 1);
|
file->ReadS32(&count, 1);
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
mGroups.Add(new lcGroup());
|
mGroups.emplace_back(new lcGroup());
|
||||||
|
|
||||||
for (int GroupIdx = NumGroups; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
for (int GroupIdx = NumGroups; GroupIdx < mGroups.size(); GroupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup* Group = mGroups[GroupIdx];
|
lcGroup* Group = mGroups[GroupIdx];
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ bool lcModel::LoadBinary(lcFile* file)
|
||||||
Group->FileLoad(file);
|
Group->FileLoad(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int GroupIdx = NumGroups; GroupIdx < mGroups.GetSize(); GroupIdx++)
|
for (int GroupIdx = NumGroups; GroupIdx < mGroups.size(); GroupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup* Group = mGroups[GroupIdx];
|
lcGroup* Group = mGroups[GroupIdx];
|
||||||
|
|
||||||
|
@ -954,7 +954,7 @@ bool lcModel::LoadBinary(lcFile* file)
|
||||||
Group->mGroup = mGroups[NumGroups + i];
|
Group->mGroup = mGroups[NumGroups + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int PieceIdx = FirstNewPiece; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = FirstNewPiece; PieceIdx < mPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -1092,7 +1092,7 @@ bool lcModel::LoadInventory(const QByteArray& Inventory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Library->WaitForLoadQueue();
|
Library->WaitForLoadQueue();
|
||||||
|
@ -1139,7 +1139,7 @@ bool lcModel::LoadInventory(const QByteArray& Inventory)
|
||||||
|
|
||||||
void lcModel::Merge(lcModel* Other)
|
void lcModel::Merge(lcModel* Other)
|
||||||
{
|
{
|
||||||
for (int PieceIdx = 0; PieceIdx < Other->mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < Other->mPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = Other->mPieces[PieceIdx];
|
lcPiece* Piece = Other->mPieces[PieceIdx];
|
||||||
Piece->SetFileLine(-1);
|
Piece->SetFileLine(-1);
|
||||||
|
@ -1148,29 +1148,29 @@ void lcModel::Merge(lcModel* Other)
|
||||||
|
|
||||||
Other->mPieces.RemoveAll();
|
Other->mPieces.RemoveAll();
|
||||||
|
|
||||||
for (int CameraIdx = 0; CameraIdx < Other->mCameras.GetSize(); CameraIdx++)
|
for (int CameraIdx = 0; CameraIdx < Other->mCameras.size(); CameraIdx++)
|
||||||
{
|
{
|
||||||
lcCamera* Camera = Other->mCameras[CameraIdx];
|
lcCamera* Camera = Other->mCameras[CameraIdx];
|
||||||
Camera->CreateName(mCameras);
|
Camera->CreateName(mCameras);
|
||||||
mCameras.Add(Camera);
|
mCameras.emplace_back(Camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
Other->mCameras.RemoveAll();
|
Other->mCameras.RemoveAll();
|
||||||
|
|
||||||
for (int LightIdx = 0; LightIdx < Other->mLights.GetSize(); LightIdx++)
|
for (int LightIdx = 0; LightIdx < Other->mLights.size(); LightIdx++)
|
||||||
{
|
{
|
||||||
lcLight* Light = Other->mLights[LightIdx];
|
lcLight* Light = Other->mLights[LightIdx];
|
||||||
Light->CreateName(mLights);
|
Light->CreateName(mLights);
|
||||||
mLights.Add(Light);
|
mLights.emplace_back(Light);
|
||||||
}
|
}
|
||||||
|
|
||||||
Other->mLights.RemoveAll();
|
Other->mLights.RemoveAll();
|
||||||
|
|
||||||
for (int GroupIdx = 0; GroupIdx < Other->mGroups.GetSize(); GroupIdx++)
|
for (int GroupIdx = 0; GroupIdx < Other->mGroups.size(); GroupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup* Group = Other->mGroups[GroupIdx];
|
lcGroup* Group = Other->mGroups[GroupIdx];
|
||||||
Group->CreateName(mGroups);
|
Group->CreateName(mGroups);
|
||||||
mGroups.Add(Group);
|
mGroups.emplace_back(Group);
|
||||||
}
|
}
|
||||||
|
|
||||||
Other->mGroups.RemoveAll();
|
Other->mGroups.RemoveAll();
|
||||||
|
@ -1215,8 +1215,8 @@ void lcModel::Paste(bool PasteToCurrentStep)
|
||||||
Model->LoadLDraw(Buffer, lcGetActiveProject());
|
Model->LoadLDraw(Buffer, lcGetActiveProject());
|
||||||
|
|
||||||
const lcArray<lcPiece*>& PastedPieces = Model->mPieces;
|
const lcArray<lcPiece*>& PastedPieces = Model->mPieces;
|
||||||
lcArray<lcObject*> SelectedObjects;
|
std::vector<lcObject*> SelectedObjects;
|
||||||
SelectedObjects.AllocGrow(PastedPieces.GetSize());
|
SelectedObjects.reserve(PastedPieces.size());
|
||||||
|
|
||||||
for (lcPiece* Piece : PastedPieces)
|
for (lcPiece* Piece : PastedPieces)
|
||||||
{
|
{
|
||||||
|
@ -1225,19 +1225,19 @@ void lcModel::Paste(bool PasteToCurrentStep)
|
||||||
if (PasteToCurrentStep)
|
if (PasteToCurrentStep)
|
||||||
{
|
{
|
||||||
Piece->SetStepShow(mCurrentStep);
|
Piece->SetStepShow(mCurrentStep);
|
||||||
SelectedObjects.Add(Piece);
|
SelectedObjects.emplace_back(Piece);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Piece->GetStepShow() <= mCurrentStep)
|
if (Piece->GetStepShow() <= mCurrentStep)
|
||||||
SelectedObjects.Add(Piece);
|
SelectedObjects.emplace_back(Piece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Merge(Model);
|
Merge(Model);
|
||||||
SaveCheckpoint(tr("Pasting"));
|
SaveCheckpoint(tr("Pasting"));
|
||||||
|
|
||||||
if (SelectedObjects.GetSize() == 1)
|
if (SelectedObjects.size() == 1)
|
||||||
ClearSelectionAndSetFocus(SelectedObjects[0], LC_PIECE_SECTION_POSITION, false);
|
ClearSelectionAndSetFocus(SelectedObjects[0], LC_PIECE_SECTION_POSITION, false);
|
||||||
else
|
else
|
||||||
SetSelectionAndFocus(SelectedObjects, nullptr, 0, false);
|
SetSelectionAndFocus(SelectedObjects, nullptr, 0, false);
|
||||||
|
@ -1249,7 +1249,7 @@ void lcModel::Paste(bool PasteToCurrentStep)
|
||||||
|
|
||||||
void lcModel::DuplicateSelectedPieces()
|
void lcModel::DuplicateSelectedPieces()
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> NewPieces;
|
std::vector<lcObject*> NewPieces;
|
||||||
lcPiece* Focus = nullptr;
|
lcPiece* Focus = nullptr;
|
||||||
std::map<lcGroup*, lcGroup*> GroupMap;
|
std::map<lcGroup*, lcGroup*> GroupMap;
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ void lcModel::DuplicateSelectedPieces()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ void lcModel::DuplicateSelectedPieces()
|
||||||
|
|
||||||
lcPiece* NewPiece = new lcPiece(*Piece);
|
lcPiece* NewPiece = new lcPiece(*Piece);
|
||||||
NewPiece->UpdatePosition(mCurrentStep);
|
NewPiece->UpdatePosition(mCurrentStep);
|
||||||
NewPieces.Add(NewPiece);
|
NewPieces.emplace_back(NewPiece);
|
||||||
|
|
||||||
if (Piece->IsFocused())
|
if (Piece->IsFocused())
|
||||||
Focus = NewPiece;
|
Focus = NewPiece;
|
||||||
|
@ -1303,7 +1303,7 @@ void lcModel::DuplicateSelectedPieces()
|
||||||
Piece->SetGroup(GetNewGroup(Group));
|
Piece->SetGroup(GetNewGroup(Group));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewPieces.IsEmpty())
|
if (NewPieces.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gMainWindow->UpdateTimeline(false, false);
|
gMainWindow->UpdateTimeline(false, false);
|
||||||
|
@ -1909,7 +1909,7 @@ void lcModel::RemoveStep(lcStep Step)
|
||||||
lcGroup* lcModel::AddGroup(const QString& Prefix, lcGroup* Parent)
|
lcGroup* lcModel::AddGroup(const QString& Prefix, lcGroup* Parent)
|
||||||
{
|
{
|
||||||
lcGroup* Group = new lcGroup();
|
lcGroup* Group = new lcGroup();
|
||||||
mGroups.Add(Group);
|
mGroups.emplace_back(Group);
|
||||||
|
|
||||||
Group->mName = GetGroupName(Prefix);
|
Group->mName = GetGroupName(Prefix);
|
||||||
Group->mGroup = Parent;
|
Group->mGroup = Parent;
|
||||||
|
@ -1927,7 +1927,7 @@ lcGroup* lcModel::GetGroup(const QString& Name, bool CreateIfMissing)
|
||||||
{
|
{
|
||||||
lcGroup* Group = new lcGroup();
|
lcGroup* Group = new lcGroup();
|
||||||
Group->mName = Name;
|
Group->mName = Name;
|
||||||
mGroups.Add(Group);
|
mGroups.emplace_back(Group);
|
||||||
|
|
||||||
return Group;
|
return Group;
|
||||||
}
|
}
|
||||||
|
@ -1984,7 +1984,7 @@ void lcModel::UngroupSelection()
|
||||||
if (SelectedGroups.FindIndex(Group) == -1)
|
if (SelectedGroups.FindIndex(Group) == -1)
|
||||||
{
|
{
|
||||||
mGroups.Remove(Group);
|
mGroups.Remove(Group);
|
||||||
SelectedGroups.Add(Group);
|
SelectedGroups.emplace_back(Group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2128,7 +2128,7 @@ void lcModel::RemoveEmptyGroups()
|
||||||
{
|
{
|
||||||
Removed = false;
|
Removed = false;
|
||||||
|
|
||||||
for (int GroupIdx = 0; GroupIdx < mGroups.GetSize();)
|
for (int GroupIdx = 0; GroupIdx < mGroups.size();)
|
||||||
{
|
{
|
||||||
lcGroup* Group = mGroups[GroupIdx];
|
lcGroup* Group = mGroups[GroupIdx];
|
||||||
int Ref = 0;
|
int Ref = 0;
|
||||||
|
@ -2137,7 +2137,7 @@ void lcModel::RemoveEmptyGroups()
|
||||||
if (Piece->GetGroup() == Group)
|
if (Piece->GetGroup() == Group)
|
||||||
Ref++;
|
Ref++;
|
||||||
|
|
||||||
for (int ParentIdx = 0; ParentIdx < mGroups.GetSize(); ParentIdx++)
|
for (int ParentIdx = 0; ParentIdx < mGroups.size(); ParentIdx++)
|
||||||
if (mGroups[ParentIdx]->mGroup == Group)
|
if (mGroups[ParentIdx]->mGroup == Group)
|
||||||
Ref++;
|
Ref++;
|
||||||
|
|
||||||
|
@ -2158,7 +2158,7 @@ void lcModel::RemoveEmptyGroups()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ParentIdx = 0; ParentIdx < mGroups.GetSize(); ParentIdx++)
|
for (int ParentIdx = 0; ParentIdx < mGroups.size(); ParentIdx++)
|
||||||
{
|
{
|
||||||
if (mGroups[ParentIdx]->mGroup == Group)
|
if (mGroups[ParentIdx]->mGroup == Group)
|
||||||
{
|
{
|
||||||
|
@ -2265,7 +2265,7 @@ void lcModel::AddPiece()
|
||||||
if (!CurPiece)
|
if (!CurPiece)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcPiece* Last = mPieces.IsEmpty() ? nullptr : mPieces[mPieces.GetSize() - 1];
|
lcPiece* Last = mPieces.empty() ? nullptr : mPieces[mPieces.size() - 1];
|
||||||
|
|
||||||
for (lcPiece* Piece : mPieces)
|
for (lcPiece* Piece : mPieces)
|
||||||
{
|
{
|
||||||
|
@ -2305,7 +2305,7 @@ void lcModel::AddPiece()
|
||||||
|
|
||||||
void lcModel::AddPiece(lcPiece* Piece)
|
void lcModel::AddPiece(lcPiece* Piece)
|
||||||
{
|
{
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
if (mPieces[PieceIdx]->GetStepShow() > Piece->GetStepShow())
|
if (mPieces[PieceIdx]->GetStepShow() > Piece->GetStepShow())
|
||||||
{
|
{
|
||||||
|
@ -2314,7 +2314,7 @@ void lcModel::AddPiece(lcPiece* Piece)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertPiece(Piece, mPieces.GetSize());
|
InsertPiece(Piece, mPieces.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::InsertPiece(lcPiece* Piece, int Index)
|
void lcModel::InsertPiece(lcPiece* Piece, int Index)
|
||||||
|
@ -2334,7 +2334,7 @@ void lcModel::InsertPiece(lcPiece* Piece, int Index)
|
||||||
|
|
||||||
void lcModel::DeleteAllCameras()
|
void lcModel::DeleteAllCameras()
|
||||||
{
|
{
|
||||||
if (mCameras.IsEmpty())
|
if (mCameras.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCameras.DeleteAll();
|
mCameras.DeleteAll();
|
||||||
|
@ -2423,9 +2423,9 @@ void lcModel::RemoveFocusedControlPoint()
|
||||||
|
|
||||||
void lcModel::ShowSelectedPiecesEarlier()
|
void lcModel::ShowSelectedPiecesEarlier()
|
||||||
{
|
{
|
||||||
lcArray<lcPiece*> MovedPieces;
|
std::vector<lcPiece*> MovedPieces;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -2438,7 +2438,7 @@ void lcModel::ShowSelectedPiecesEarlier()
|
||||||
Step--;
|
Step--;
|
||||||
Piece->SetStepShow(Step);
|
Piece->SetStepShow(Step);
|
||||||
|
|
||||||
MovedPieces.Add(Piece);
|
MovedPieces.emplace_back(Piece);
|
||||||
mPieces.RemoveIndex(PieceIdx);
|
mPieces.RemoveIndex(PieceIdx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2447,12 +2447,11 @@ void lcModel::ShowSelectedPiecesEarlier()
|
||||||
PieceIdx++;
|
PieceIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovedPieces.IsEmpty())
|
if (MovedPieces.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++)
|
for (lcPiece* Piece : MovedPieces)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = MovedPieces[PieceIdx];
|
|
||||||
Piece->SetFileLine(-1);
|
Piece->SetFileLine(-1);
|
||||||
AddPiece(Piece);
|
AddPiece(Piece);
|
||||||
}
|
}
|
||||||
|
@ -2467,7 +2466,7 @@ void lcModel::ShowSelectedPiecesLater()
|
||||||
{
|
{
|
||||||
lcArray<lcPiece*> MovedPieces;
|
lcArray<lcPiece*> MovedPieces;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -2483,7 +2482,7 @@ void lcModel::ShowSelectedPiecesLater()
|
||||||
if (!Piece->IsVisible(mCurrentStep))
|
if (!Piece->IsVisible(mCurrentStep))
|
||||||
Piece->SetSelected(false);
|
Piece->SetSelected(false);
|
||||||
|
|
||||||
MovedPieces.Add(Piece);
|
MovedPieces.emplace_back(Piece);
|
||||||
mPieces.RemoveIndex(PieceIdx);
|
mPieces.RemoveIndex(PieceIdx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2492,10 +2491,10 @@ void lcModel::ShowSelectedPiecesLater()
|
||||||
PieceIdx++;
|
PieceIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovedPieces.IsEmpty())
|
if (MovedPieces.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < MovedPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = MovedPieces[PieceIdx];
|
lcPiece* Piece = MovedPieces[PieceIdx];
|
||||||
Piece->SetFileLine(-1);
|
Piece->SetFileLine(-1);
|
||||||
|
@ -2510,7 +2509,7 @@ void lcModel::ShowSelectedPiecesLater()
|
||||||
|
|
||||||
void lcModel::SetPieceSteps(const QList<QPair<lcPiece*, lcStep>>& PieceSteps)
|
void lcModel::SetPieceSteps(const QList<QPair<lcPiece*, lcStep>>& PieceSteps)
|
||||||
{
|
{
|
||||||
if (PieceSteps.size() != mPieces.GetSize())
|
if (PieceSteps.size() != mPieces.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool Modified = false;
|
bool Modified = false;
|
||||||
|
@ -2561,7 +2560,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model)
|
||||||
lcStep FirstStep = LC_STEP_MAX;
|
lcStep FirstStep = LC_STEP_MAX;
|
||||||
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -2570,7 +2569,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model)
|
||||||
Piece->CompareBoundingBox(Min, Max);
|
Piece->CompareBoundingBox(Min, Max);
|
||||||
mPieces.RemoveIndex(PieceIdx);
|
mPieces.RemoveIndex(PieceIdx);
|
||||||
Piece->SetGroup(nullptr); // todo: copy groups
|
Piece->SetGroup(nullptr); // todo: copy groups
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
FirstStep = qMin(FirstStep, Piece->GetStepShow());
|
FirstStep = qMin(FirstStep, Piece->GetStepShow());
|
||||||
|
|
||||||
if (!ModelPiece)
|
if (!ModelPiece)
|
||||||
|
@ -2588,7 +2587,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model)
|
||||||
lcVector3 ModelCenter = (Min + Max) / 2.0f;
|
lcVector3 ModelCenter = (Min + Max) / 2.0f;
|
||||||
ModelCenter.z += (Min.z - Max.z) / 2.0f;
|
ModelCenter.z += (Min.z - Max.z) / 2.0f;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < Pieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < Pieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = Pieces[PieceIdx];
|
lcPiece* Piece = Pieces[PieceIdx];
|
||||||
Piece->SetFileLine(-1);
|
Piece->SetFileLine(-1);
|
||||||
|
@ -2612,9 +2611,9 @@ void lcModel::MoveSelectionToModel(lcModel* Model)
|
||||||
|
|
||||||
void lcModel::InlineSelectedModels()
|
void lcModel::InlineSelectedModels()
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> NewPieces;
|
std::vector<lcObject*> NewPieces;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -2644,7 +2643,7 @@ void lcModel::InlineSelectedModels()
|
||||||
NewPiece->SetColorIndex(ColorIndex);
|
NewPiece->SetColorIndex(ColorIndex);
|
||||||
NewPiece->UpdatePosition(mCurrentStep);
|
NewPiece->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
NewPieces.Add(NewPiece);
|
NewPieces.emplace_back(NewPiece);
|
||||||
InsertPiece(NewPiece, PieceIdx);
|
InsertPiece(NewPiece, PieceIdx);
|
||||||
PieceIdx++;
|
PieceIdx++;
|
||||||
}
|
}
|
||||||
|
@ -2652,7 +2651,7 @@ void lcModel::InlineSelectedModels()
|
||||||
delete Piece;
|
delete Piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NewPieces.GetSize())
|
if (!NewPieces.size())
|
||||||
{
|
{
|
||||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("No models selected."));
|
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("No models selected."));
|
||||||
return;
|
return;
|
||||||
|
@ -2669,7 +2668,7 @@ bool lcModel::RemoveSelectedObjects()
|
||||||
bool RemovedCamera = false;
|
bool RemovedCamera = false;
|
||||||
bool RemovedLight = false;
|
bool RemovedLight = false;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -2683,7 +2682,7 @@ bool lcModel::RemoveSelectedObjects()
|
||||||
PieceIdx++;
|
PieceIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); )
|
for (int CameraIdx = 0; CameraIdx < mCameras.size(); )
|
||||||
{
|
{
|
||||||
lcCamera* Camera = mCameras[CameraIdx];
|
lcCamera* Camera = mCameras[CameraIdx];
|
||||||
|
|
||||||
|
@ -2703,7 +2702,7 @@ bool lcModel::RemoveSelectedObjects()
|
||||||
CameraIdx++;
|
CameraIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); )
|
for (int LightIdx = 0; LightIdx < mLights.size(); )
|
||||||
{
|
{
|
||||||
lcLight* Light = mLights[LightIdx];
|
lcLight* Light = mLights[LightIdx];
|
||||||
|
|
||||||
|
@ -3035,7 +3034,7 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step)
|
||||||
lcArray<lcPiece*> MovedPieces;
|
lcArray<lcPiece*> MovedPieces;
|
||||||
bool SelectionChanged = false;
|
bool SelectionChanged = false;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); )
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
@ -3049,7 +3048,7 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step)
|
||||||
SelectionChanged = true;
|
SelectionChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MovedPieces.Add(Piece);
|
MovedPieces.emplace_back(Piece);
|
||||||
mPieces.RemoveIndex(PieceIdx);
|
mPieces.RemoveIndex(PieceIdx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3057,10 +3056,10 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step)
|
||||||
PieceIdx++;
|
PieceIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovedPieces.IsEmpty())
|
if (MovedPieces.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < MovedPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = MovedPieces[PieceIdx];
|
lcPiece* Piece = MovedPieces[PieceIdx];
|
||||||
Piece->SetFileLine(-1);
|
Piece->SetFileLine(-1);
|
||||||
|
@ -3241,7 +3240,7 @@ void lcModel::GetSubModels(lcArray<lcModel*>& SubModels) const
|
||||||
{
|
{
|
||||||
lcModel* SubModel = Piece->mPieceInfo->GetModel();
|
lcModel* SubModel = Piece->mPieceInfo->GetModel();
|
||||||
if (SubModels.FindIndex(SubModel) == -1)
|
if (SubModels.FindIndex(SubModel) == -1)
|
||||||
SubModels.Add(SubModel);
|
SubModels.emplace_back(SubModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3463,7 +3462,7 @@ lcBoundingBox lcModel::GetAllPiecesBoundingBox() const
|
||||||
{
|
{
|
||||||
lcBoundingBox Box;
|
lcBoundingBox Box;
|
||||||
|
|
||||||
if (!mPieces.IsEmpty())
|
if (!mPieces.empty())
|
||||||
{
|
{
|
||||||
Box.Min = lcVector3(FLT_MAX, FLT_MAX, FLT_MAX);
|
Box.Min = lcVector3(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||||
Box.Max = lcVector3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
Box.Max = lcVector3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
|
@ -3549,7 +3548,7 @@ void lcModel::GetSelectionInformation(int* Flags, std::vector<lcObject*>& Select
|
||||||
*Flags = 0;
|
*Flags = 0;
|
||||||
*Focus = nullptr;
|
*Focus = nullptr;
|
||||||
|
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.empty())
|
||||||
*Flags |= LC_SEL_NO_PIECES;
|
*Flags |= LC_SEL_NO_PIECES;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3637,11 +3636,11 @@ void lcModel::GetSelectionInformation(int* Flags, std::vector<lcObject*>& Select
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcArray<lcObject*> lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece) const
|
std::vector<lcObject*> lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece) const
|
||||||
{
|
{
|
||||||
const PieceInfo* Info = SelectedPiece->mPieceInfo;
|
const PieceInfo* Info = SelectedPiece->mPieceInfo;
|
||||||
const int ColorIndex = SelectedPiece->GetColorIndex();
|
const int ColorIndex = SelectedPiece->GetColorIndex();
|
||||||
lcArray<lcObject*> Pieces;
|
std::vector<lcObject*> Pieces;
|
||||||
|
|
||||||
switch (gMainWindow->GetSelectionMode())
|
switch (gMainWindow->GetSelectionMode())
|
||||||
{
|
{
|
||||||
|
@ -3651,19 +3650,19 @@ lcArray<lcObject*> lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece)
|
||||||
case lcSelectionMode::Piece:
|
case lcSelectionMode::Piece:
|
||||||
for (lcPiece* Piece : mPieces)
|
for (lcPiece* Piece : mPieces)
|
||||||
if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece != SelectedPiece)
|
if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece != SelectedPiece)
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcSelectionMode::Color:
|
case lcSelectionMode::Color:
|
||||||
for (lcPiece* Piece : mPieces)
|
for (lcPiece* Piece : mPieces)
|
||||||
if (Piece->IsVisible(mCurrentStep) && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece)
|
if (Piece->IsVisible(mCurrentStep) && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece)
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcSelectionMode::PieceColor:
|
case lcSelectionMode::PieceColor:
|
||||||
for (lcPiece* Piece : mPieces)
|
for (lcPiece* Piece : mPieces)
|
||||||
if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece)
|
if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece)
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3728,7 +3727,7 @@ void lcModel::FocusOrDeselectObject(const lcObjectSection& ObjectSection)
|
||||||
SelectGroup(Piece->GetTopGroup(), IsSelected);
|
SelectGroup(Piece->GetTopGroup(), IsSelected);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
||||||
AddToSelection(Pieces, false, false);
|
AddToSelection(Pieces, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3757,7 +3756,7 @@ void lcModel::ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool
|
||||||
|
|
||||||
if (EnableSelectionMode)
|
if (EnableSelectionMode)
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Object);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Object);
|
||||||
AddToSelection(Pieces, false, false);
|
AddToSelection(Pieces, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3772,7 +3771,7 @@ void lcModel::ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection, bo
|
||||||
ClearSelectionAndSetFocus(ObjectSection.Object, ObjectSection.Section, EnableSelectionMode);
|
ClearSelectionAndSetFocus(ObjectSection.Object, ObjectSection.Section, EnableSelectionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode)
|
void lcModel::SetSelectionAndFocus(const std::vector<lcObject*>& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode)
|
||||||
{
|
{
|
||||||
ClearSelection(false);
|
ClearSelection(false);
|
||||||
|
|
||||||
|
@ -3786,7 +3785,7 @@ void lcModel::SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject
|
||||||
|
|
||||||
if (EnableSelectionMode)
|
if (EnableSelectionMode)
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Focus);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Focus);
|
||||||
AddToSelection(Pieces, false, false);
|
AddToSelection(Pieces, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3795,7 +3794,7 @@ void lcModel::SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject
|
||||||
AddToSelection(Selection, EnableSelectionMode, true);
|
AddToSelection(Selection, EnableSelectionMode, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelectionMode, bool UpdateInterface)
|
void lcModel::AddToSelection(const std::vector<lcObject*>& Objects, bool EnableSelectionMode, bool UpdateInterface)
|
||||||
{
|
{
|
||||||
for (lcObject* Object : Objects)
|
for (lcObject* Object : Objects)
|
||||||
{
|
{
|
||||||
|
@ -3809,7 +3808,7 @@ void lcModel::AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelec
|
||||||
|
|
||||||
if (EnableSelectionMode)
|
if (EnableSelectionMode)
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Object);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces((lcPiece*)Object);
|
||||||
AddToSelection(Pieces, false, false);
|
AddToSelection(Pieces, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3822,7 +3821,7 @@ void lcModel::AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::RemoveFromSelection(const lcArray<lcObject*>& Objects)
|
void lcModel::RemoveFromSelection(const std::vector<lcObject*>& Objects)
|
||||||
{
|
{
|
||||||
for (lcObject* SelectedObject : Objects)
|
for (lcObject* SelectedObject : Objects)
|
||||||
{
|
{
|
||||||
|
@ -3837,7 +3836,7 @@ void lcModel::RemoveFromSelection(const lcArray<lcObject*>& Objects)
|
||||||
SelectGroup(Piece->GetTopGroup(), false);
|
SelectGroup(Piece->GetTopGroup(), false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
||||||
|
|
||||||
for (lcObject* Object : Pieces)
|
for (lcObject* Object : Pieces)
|
||||||
{
|
{
|
||||||
|
@ -3878,7 +3877,7 @@ void lcModel::RemoveFromSelection(const lcObjectSection& ObjectSection)
|
||||||
SelectGroup(Piece->GetTopGroup(), false);
|
SelectGroup(Piece->GetTopGroup(), false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
std::vector<lcObject*> Pieces = GetSelectionModePieces(Piece);
|
||||||
|
|
||||||
for (lcObject* Object : Pieces)
|
for (lcObject* Object : Pieces)
|
||||||
{
|
{
|
||||||
|
@ -4011,7 +4010,7 @@ void lcModel::UnhideAllPieces()
|
||||||
|
|
||||||
void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
{
|
{
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const lcFindReplaceParams& Params = lcView::GetFindReplaceParams();
|
const lcFindReplaceParams& Params = lcView::GetFindReplaceParams();
|
||||||
|
@ -4042,7 +4041,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
Piece->SetPieceInfo(Params.ReplacePieceInfo, QString(), true);
|
Piece->SetPieceInfo(Params.ReplacePieceInfo, QString(), true);
|
||||||
};
|
};
|
||||||
|
|
||||||
int StartIdx = mPieces.GetSize() - 1;
|
int StartIdx = mPieces.size() - 1;
|
||||||
int ReplacedCount = 0;
|
int ReplacedCount = 0;
|
||||||
|
|
||||||
if (!FindAll)
|
if (!FindAll)
|
||||||
|
@ -4052,7 +4051,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
|
|
||||||
if (FocusedPiece)
|
if (FocusedPiece)
|
||||||
{
|
{
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
if (FocusedPiece == mPieces[PieceIdx])
|
if (FocusedPiece == mPieces[PieceIdx])
|
||||||
{
|
{
|
||||||
|
@ -4071,7 +4070,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
|
|
||||||
int CurrentIdx = StartIdx;
|
int CurrentIdx = StartIdx;
|
||||||
lcPiece* Focus = nullptr;
|
lcPiece* Focus = nullptr;
|
||||||
lcArray<lcObject*> Selection;
|
std::vector<lcObject*> Selection;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -4081,8 +4080,8 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
CurrentIdx--;
|
CurrentIdx--;
|
||||||
|
|
||||||
if (CurrentIdx < 0)
|
if (CurrentIdx < 0)
|
||||||
CurrentIdx = mPieces.GetSize() - 1;
|
CurrentIdx = mPieces.size() - 1;
|
||||||
else if (CurrentIdx >= mPieces.GetSize())
|
else if (CurrentIdx >= mPieces.size())
|
||||||
CurrentIdx = 0;
|
CurrentIdx = 0;
|
||||||
|
|
||||||
lcPiece* Current = mPieces[CurrentIdx];
|
lcPiece* Current = mPieces[CurrentIdx];
|
||||||
|
@ -4091,7 +4090,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
|
||||||
{
|
{
|
||||||
if (FindAll)
|
if (FindAll)
|
||||||
{
|
{
|
||||||
Selection.Add(Current);
|
Selection.emplace_back(Current);
|
||||||
if (Replacing)
|
if (Replacing)
|
||||||
{
|
{
|
||||||
ReplacePiece(Current);
|
ReplacePiece(Current);
|
||||||
|
@ -4243,7 +4242,7 @@ void lcModel::InsertLightToolClicked(const lcVector3& Position, lcLightType Ligh
|
||||||
{
|
{
|
||||||
lcLight* Light = new lcLight(Position, LightType);
|
lcLight* Light = new lcLight(Position, LightType);
|
||||||
Light->CreateName(mLights);
|
Light->CreateName(mLights);
|
||||||
mLights.Add(Light);
|
mLights.emplace_back(Light);
|
||||||
|
|
||||||
ClearSelectionAndSetFocus(Light, LC_LIGHT_SECTION_POSITION, false);
|
ClearSelectionAndSetFocus(Light, LC_LIGHT_SECTION_POSITION, false);
|
||||||
|
|
||||||
|
@ -4274,7 +4273,7 @@ void lcModel::BeginCameraTool(const lcVector3& Position, const lcVector3& Target
|
||||||
{
|
{
|
||||||
lcCamera* Camera = new lcCamera(Position[0], Position[1], Position[2], Target[0], Target[1], Target[2]);
|
lcCamera* Camera = new lcCamera(Position[0], Position[1], Position[2], Target[0], Target[1], Target[2]);
|
||||||
Camera->CreateName(mCameras);
|
Camera->CreateName(mCameras);
|
||||||
mCameras.Add(Camera);
|
mCameras.emplace_back(Camera);
|
||||||
|
|
||||||
mMouseToolDistance = Position;
|
mMouseToolDistance = Position;
|
||||||
mMouseToolFirstMove = false;
|
mMouseToolFirstMove = false;
|
||||||
|
@ -4284,7 +4283,7 @@ void lcModel::BeginCameraTool(const lcVector3& Position, const lcVector3& Target
|
||||||
|
|
||||||
void lcModel::UpdateCameraTool(const lcVector3& Position)
|
void lcModel::UpdateCameraTool(const lcVector3& Position)
|
||||||
{
|
{
|
||||||
lcCamera* Camera = mCameras[mCameras.GetSize() - 1];
|
lcCamera* Camera = mCameras[mCameras.size() - 1];
|
||||||
|
|
||||||
Camera->MoveSelected(1, false, Position - mMouseToolDistance);
|
Camera->MoveSelected(1, false, Position - mMouseToolDistance);
|
||||||
Camera->UpdatePosition(1);
|
Camera->UpdatePosition(1);
|
||||||
|
@ -4541,7 +4540,7 @@ void lcModel::ShowPropertiesDialog()
|
||||||
|
|
||||||
void lcModel::ShowSelectByNameDialog()
|
void lcModel::ShowSelectByNameDialog()
|
||||||
{
|
{
|
||||||
if (mPieces.IsEmpty() && mCameras.IsEmpty() && mLights.IsEmpty())
|
if (mPieces.empty() && mCameras.empty() && mLights.empty())
|
||||||
{
|
{
|
||||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to select."));
|
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to select."));
|
||||||
return;
|
return;
|
||||||
|
@ -4576,7 +4575,7 @@ void lcModel::ShowArrayDialog()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcArray<lcObject*> NewPieces;
|
std::vector<lcObject*> NewPieces;
|
||||||
|
|
||||||
for (int Step1 = 0; Step1 < Dialog.mCounts[0]; Step1++)
|
for (int Step1 = 0; Step1 < Dialog.mCounts[0]; Step1++)
|
||||||
{
|
{
|
||||||
|
@ -4611,13 +4610,13 @@ void lcModel::ShowArrayDialog()
|
||||||
NewPiece->Initialize(ModelWorld, mCurrentStep);
|
NewPiece->Initialize(ModelWorld, mCurrentStep);
|
||||||
NewPiece->SetColorIndex(Piece->GetColorIndex());
|
NewPiece->SetColorIndex(Piece->GetColorIndex());
|
||||||
|
|
||||||
NewPieces.Add(NewPiece);
|
NewPieces.emplace_back(NewPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < NewPieces.GetSize(); PieceIdx++)
|
for (size_t PieceIdx = 0; PieceIdx < NewPieces.size(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = (lcPiece*)NewPieces[PieceIdx];
|
lcPiece* Piece = (lcPiece*)NewPieces[PieceIdx];
|
||||||
Piece->UpdatePosition(mCurrentStep);
|
Piece->UpdatePosition(mCurrentStep);
|
||||||
|
@ -4639,7 +4638,8 @@ void lcModel::ShowMinifigDialog()
|
||||||
gMainWindow->GetActiveView()->MakeCurrent();
|
gMainWindow->GetActiveView()->MakeCurrent();
|
||||||
|
|
||||||
lcGroup* Group = AddGroup(tr("Minifig #"), nullptr);
|
lcGroup* Group = AddGroup(tr("Minifig #"), nullptr);
|
||||||
lcArray<lcObject*> Pieces(LC_MFW_NUMITEMS);
|
std::vector<lcObject*> Pieces;
|
||||||
|
Pieces.reserve(LC_MFW_NUMITEMS);
|
||||||
lcMinifig& Minifig = Dialog.mMinifigWizard->mMinifig;
|
lcMinifig& Minifig = Dialog.mMinifigWizard->mMinifig;
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
||||||
|
@ -4655,7 +4655,7 @@ void lcModel::ShowMinifigDialog()
|
||||||
AddPiece(Piece);
|
AddPiece(Piece);
|
||||||
Piece->UpdatePosition(mCurrentStep);
|
Piece->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
||||||
|
@ -4667,7 +4667,8 @@ void lcModel::SetMinifig(const lcMinifig& Minifig)
|
||||||
{
|
{
|
||||||
DeleteModel();
|
DeleteModel();
|
||||||
|
|
||||||
lcArray<lcObject*> Pieces(LC_MFW_NUMITEMS);
|
std::vector<lcObject*> Pieces;
|
||||||
|
Pieces.reserve(LC_MFW_NUMITEMS);
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
||||||
{
|
{
|
||||||
|
@ -4681,7 +4682,7 @@ void lcModel::SetMinifig(const lcMinifig& Minifig)
|
||||||
AddPiece(Piece);
|
AddPiece(Piece);
|
||||||
Piece->UpdatePosition(1);
|
Piece->UpdatePosition(1);
|
||||||
|
|
||||||
Pieces.Add(Piece);
|
Pieces.emplace_back(Piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
||||||
|
|
|
@ -275,7 +275,7 @@ public:
|
||||||
|
|
||||||
bool HasPieces() const
|
bool HasPieces() const
|
||||||
{
|
{
|
||||||
return !mPieces.IsEmpty();
|
return !mPieces.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnyPiecesSelected() const;
|
bool AnyPiecesSelected() const;
|
||||||
|
@ -296,15 +296,15 @@ public:
|
||||||
void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative) const;
|
void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative) 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 GetSelectionInformation(int* Flags, std::vector<lcObject*>& Selection, lcObject** Focus) const;
|
void GetSelectionInformation(int* Flags, std::vector<lcObject*>& Selection, lcObject** Focus) const;
|
||||||
lcArray<lcObject*> GetSelectionModePieces(const lcPiece* SelectedPiece) const;
|
std::vector<lcObject*> GetSelectionModePieces(const lcPiece* SelectedPiece) const;
|
||||||
|
|
||||||
void FocusOrDeselectObject(const lcObjectSection& ObjectSection);
|
void FocusOrDeselectObject(const lcObjectSection& ObjectSection);
|
||||||
void ClearSelection(bool UpdateInterface);
|
void ClearSelection(bool UpdateInterface);
|
||||||
void ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool EnableSelectionMode);
|
void ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool EnableSelectionMode);
|
||||||
void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection, bool EnableSelectionMode);
|
void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection, bool EnableSelectionMode);
|
||||||
void SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode);
|
void SetSelectionAndFocus(const std::vector<lcObject*>& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode);
|
||||||
void AddToSelection(const lcArray<lcObject*>& Objects, bool EnableSelectionMode, bool UpdateInterface);
|
void AddToSelection(const std::vector<lcObject*>& Objects, bool EnableSelectionMode, bool UpdateInterface);
|
||||||
void RemoveFromSelection(const lcArray<lcObject*>& Objects);
|
void RemoveFromSelection(const std::vector<lcObject*>& Objects);
|
||||||
void RemoveFromSelection(const lcObjectSection& ObjectSection);
|
void RemoveFromSelection(const lcObjectSection& ObjectSection);
|
||||||
void SelectAllPieces();
|
void SelectAllPieces();
|
||||||
void InvertSelection();
|
void InvertSelection();
|
||||||
|
|
|
@ -179,7 +179,7 @@ void lcPartSelectionListModel::SetModelsCategory()
|
||||||
const lcArray<lcModel*>& Models = lcGetActiveProject()->GetModels();
|
const lcArray<lcModel*>& Models = lcGetActiveProject()->GetModels();
|
||||||
lcModel* ActiveModel = gMainWindow->GetActiveModel();
|
lcModel* ActiveModel = gMainWindow->GetActiveModel();
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < Models.size(); ModelIdx++)
|
||||||
{
|
{
|
||||||
lcModel* Model = Models[ModelIdx];
|
lcModel* Model = Models[ModelIdx];
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void lcPreviewDockWidget::UpdatePreview()
|
||||||
|
|
||||||
void lcPreviewDockWidget::ClearPreview()
|
void lcPreviewDockWidget::ClearPreview()
|
||||||
{
|
{
|
||||||
if (mPreview->GetModel()->GetPieces().GetSize())
|
if (mPreview->GetModel()->GetPieces().size())
|
||||||
mPreview->ClearPreview();
|
mPreview->ClearPreview();
|
||||||
|
|
||||||
mLabel->setText(QString());
|
mLabel->setText(QString());
|
||||||
|
@ -67,7 +67,7 @@ void lcPreviewDockWidget::SetPreviewLock()
|
||||||
{
|
{
|
||||||
bool Locked = mLockAction->isChecked();
|
bool Locked = mLockAction->isChecked();
|
||||||
|
|
||||||
if (Locked && mPreview->GetModel()->GetPieces().IsEmpty())
|
if (Locked && mPreview->GetModel()->GetPieces().empty())
|
||||||
{
|
{
|
||||||
mLockAction->setChecked(false);
|
mLockAction->setChecked(false);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -665,7 +665,7 @@ void lcSynthInfoCurved::CalculateSections(const std::vector<lcPieceControlPoint>
|
||||||
|
|
||||||
float SectionLength = 0.0f;
|
float SectionLength = 0.0f;
|
||||||
|
|
||||||
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.GetSize() < mNumSections + 2; ControlPointIndex++)
|
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.size() < mNumSections + 2; ControlPointIndex++)
|
||||||
{
|
{
|
||||||
lcVector3 SegmentControlPoints[4];
|
lcVector3 SegmentControlPoints[4];
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ void lcSynthInfoCurved::CalculateSections(const std::vector<lcPieceControlPoint>
|
||||||
else
|
else
|
||||||
SectionLength = mStart.Length;
|
SectionLength = mStart.Length;
|
||||||
|
|
||||||
Sections.Add(StartTransform);
|
Sections.emplace_back(StartTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
||||||
|
@ -703,20 +703,20 @@ void lcSynthInfoCurved::CalculateSections(const std::vector<lcPieceControlPoint>
|
||||||
float it = 1.0f - t;
|
float it = 1.0f - t;
|
||||||
|
|
||||||
lcVector3 Position = it * it * it * SegmentControlPoints[0] + it * it * 3.0f * t * SegmentControlPoints[1] + it * 3.0 * t * t * SegmentControlPoints[2] + t * t * t * SegmentControlPoints[3];
|
lcVector3 Position = it * it * it * SegmentControlPoints[0] + it * it * 3.0f * t * SegmentControlPoints[1] + it * 3.0 * t * t * SegmentControlPoints[2] + t * t * t * SegmentControlPoints[3];
|
||||||
CurvePoints.Add(Position);
|
CurvePoints.emplace_back(Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurrentSegmentLength = 0.0f;
|
float CurrentSegmentLength = 0.0f;
|
||||||
float TotalSegmentLength = 0.0f;
|
float TotalSegmentLength = 0.0f;
|
||||||
|
|
||||||
for (int PointIdx = 0; PointIdx < CurvePoints.GetSize() - 1; PointIdx++)
|
for (int PointIdx = 0; PointIdx < CurvePoints.size() - 1; PointIdx++)
|
||||||
TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]);
|
TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]);
|
||||||
|
|
||||||
lcVector3 StartUp = lcMul30(lcVector3(1.0f, 0.0f, 0.0f), StartTransform);
|
lcVector3 StartUp = lcMul30(lcVector3(1.0f, 0.0f, 0.0f), StartTransform);
|
||||||
float Twist = GetSectionTwist(StartTransform, EndTransform);
|
float Twist = GetSectionTwist(StartTransform, EndTransform);
|
||||||
int CurrentPointIndex = 0;
|
int CurrentPointIndex = 0;
|
||||||
|
|
||||||
while (CurrentPointIndex < CurvePoints.GetSize() - 1)
|
while (CurrentPointIndex < CurvePoints.size() - 1)
|
||||||
{
|
{
|
||||||
float Length = lcLength(CurvePoints[CurrentPointIndex + 1] - CurvePoints[CurrentPointIndex]);
|
float Length = lcLength(CurvePoints[CurrentPointIndex + 1] - CurvePoints[CurrentPointIndex]);
|
||||||
CurrentSegmentLength += Length;
|
CurrentSegmentLength += Length;
|
||||||
|
@ -744,41 +744,41 @@ void lcSynthInfoCurved::CalculateSections(const std::vector<lcPieceControlPoint>
|
||||||
Up = lcNormalize(lcCross(Side, Tangent));
|
Up = lcNormalize(lcCross(Side, Tangent));
|
||||||
StartUp = Up;
|
StartUp = Up;
|
||||||
|
|
||||||
Sections.Add(lcMatrix44(lcMatrix33(Up, Tangent, Side), CurvePoints[CurrentPointIndex]));
|
Sections.emplace_back(lcMatrix44(lcMatrix33(Up, Tangent, Side), CurvePoints[CurrentPointIndex]));
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(CurvePoints[CurrentPointIndex], ControlPointIndex, t);
|
SectionCallback(CurvePoints[CurrentPointIndex], ControlPointIndex, t);
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 2)
|
if (Sections.size() == mNumSections + 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1))
|
if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1))
|
||||||
SectionLength += mCenterLength;
|
SectionLength += mCenterLength;
|
||||||
else
|
else
|
||||||
SectionLength += mMiddle.Length;
|
SectionLength += mMiddle.Length;
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges)
|
if (Sections.size() == mNumSections + 1 && !mRigidEdges)
|
||||||
SectionLength += mEnd.Length;
|
SectionLength += mEnd.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Sections.GetSize() < mNumSections + 2)
|
while (Sections.size() < mNumSections + 2)
|
||||||
{
|
{
|
||||||
lcMatrix44 EndTransform = lcMatrix44LeoCADToLDraw(ControlPoints.back().Transform);
|
lcMatrix44 EndTransform = lcMatrix44LeoCADToLDraw(ControlPoints.back().Transform);
|
||||||
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
||||||
lcVector3 Position = lcMul31(lcVector3(0.0f, SectionLength, 0.0f), EndTransform);
|
lcVector3 Position = lcMul31(lcVector3(0.0f, SectionLength, 0.0f), EndTransform);
|
||||||
EndTransform.SetTranslation(Position);
|
EndTransform.SetTranslation(Position);
|
||||||
Sections.Add(EndTransform);
|
Sections.emplace_back(EndTransform);
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(Position, static_cast<quint32>(ControlPoints.size()) - 1, 1.0f);
|
SectionCallback(Position, static_cast<quint32>(ControlPoints.size()) - 1, 1.0f);
|
||||||
|
|
||||||
if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1))
|
if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1))
|
||||||
SectionLength += mCenterLength;
|
SectionLength += mCenterLength;
|
||||||
else
|
else
|
||||||
SectionLength += mMiddle.Length;
|
SectionLength += mMiddle.Length;
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges)
|
if (Sections.size() == mNumSections + 1 && !mRigidEdges)
|
||||||
SectionLength += mEnd.Length;
|
SectionLength += mEnd.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector<lcPieceContro
|
||||||
|
|
||||||
float SectionLength = 0.0f;
|
float SectionLength = 0.0f;
|
||||||
|
|
||||||
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.GetSize() < mNumSections + 2; ControlPointIndex++)
|
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.size() < mNumSections + 2; ControlPointIndex++)
|
||||||
{
|
{
|
||||||
lcVector3 SegmentControlPoints[4];
|
lcVector3 SegmentControlPoints[4];
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector<lcPieceContro
|
||||||
else
|
else
|
||||||
SectionLength = mStart.Length;
|
SectionLength = mStart.Length;
|
||||||
|
|
||||||
Sections.Add(StartTransform);
|
Sections.emplace_back(StartTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
||||||
|
@ -828,20 +828,20 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector<lcPieceContro
|
||||||
float it = 1.0f - t;
|
float it = 1.0f - t;
|
||||||
|
|
||||||
lcVector3 Position = it * it * it * SegmentControlPoints[0] + it * it * 3.0f * t * SegmentControlPoints[1] + it * 3.0 * t * t * SegmentControlPoints[2] + t * t * t * SegmentControlPoints[3];
|
lcVector3 Position = it * it * it * SegmentControlPoints[0] + it * it * 3.0f * t * SegmentControlPoints[1] + it * 3.0 * t * t * SegmentControlPoints[2] + t * t * t * SegmentControlPoints[3];
|
||||||
CurvePoints.Add(Position);
|
CurvePoints.emplace_back(Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurrentSegmentLength = 0.0f;
|
float CurrentSegmentLength = 0.0f;
|
||||||
float TotalSegmentLength = 0.0f;
|
float TotalSegmentLength = 0.0f;
|
||||||
|
|
||||||
for (int PointIdx = 0; PointIdx < CurvePoints.GetSize() - 1; PointIdx++)
|
for (int PointIdx = 0; PointIdx < CurvePoints.size() - 1; PointIdx++)
|
||||||
TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]);
|
TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]);
|
||||||
|
|
||||||
lcVector3 StartUp = lcMul30(lcVector3(0.0f, 1.0f, 0.0f), StartTransform);
|
lcVector3 StartUp = lcMul30(lcVector3(0.0f, 1.0f, 0.0f), StartTransform);
|
||||||
float Twist = GetSectionTwist(StartTransform, EndTransform);
|
float Twist = GetSectionTwist(StartTransform, EndTransform);
|
||||||
int CurrentPointIndex = 0;
|
int CurrentPointIndex = 0;
|
||||||
|
|
||||||
while (CurrentPointIndex < CurvePoints.GetSize() - 1)
|
while (CurrentPointIndex < CurvePoints.size() - 1)
|
||||||
{
|
{
|
||||||
float Length = lcLength(CurvePoints[CurrentPointIndex + 1] - CurvePoints[CurrentPointIndex]);
|
float Length = lcLength(CurvePoints[CurrentPointIndex + 1] - CurvePoints[CurrentPointIndex]);
|
||||||
CurrentSegmentLength += Length;
|
CurrentSegmentLength += Length;
|
||||||
|
@ -869,41 +869,41 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector<lcPieceContro
|
||||||
Up = lcNormalize(lcCross(Side, Tangent));
|
Up = lcNormalize(lcCross(Side, Tangent));
|
||||||
StartUp = Up;
|
StartUp = Up;
|
||||||
|
|
||||||
Sections.Add(lcMatrix44(lcMatrix33(Tangent, Up, -Side), CurvePoints[CurrentPointIndex]));
|
Sections.emplace_back(lcMatrix44(lcMatrix33(Tangent, Up, -Side), CurvePoints[CurrentPointIndex]));
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(CurvePoints[CurrentPointIndex], ControlPointIndex, t);
|
SectionCallback(CurvePoints[CurrentPointIndex], ControlPointIndex, t);
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 2)
|
if (Sections.size() == mNumSections + 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1))
|
if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1))
|
||||||
SectionLength += mCenterLength;
|
SectionLength += mCenterLength;
|
||||||
else
|
else
|
||||||
SectionLength += mMiddle.Length;
|
SectionLength += mMiddle.Length;
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges)
|
if (Sections.size() == mNumSections + 1 && !mRigidEdges)
|
||||||
SectionLength += mEnd.Length;
|
SectionLength += mEnd.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Sections.GetSize() < mNumSections + 2)
|
while (Sections.size() < mNumSections + 2)
|
||||||
{
|
{
|
||||||
lcMatrix44 EndTransform = lcMatrix44LeoCADToLDraw(ControlPoints.back().Transform);
|
lcMatrix44 EndTransform = lcMatrix44LeoCADToLDraw(ControlPoints.back().Transform);
|
||||||
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation());
|
||||||
lcVector3 Position = lcMul31(lcVector3(SectionLength, 0.0f, 0.0f), EndTransform);
|
lcVector3 Position = lcMul31(lcVector3(SectionLength, 0.0f, 0.0f), EndTransform);
|
||||||
EndTransform.SetTranslation(Position);
|
EndTransform.SetTranslation(Position);
|
||||||
Sections.Add(EndTransform);
|
Sections.emplace_back(EndTransform);
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(Position, static_cast<quint32>(ControlPoints.size()) - 1, 1.0f);
|
SectionCallback(Position, static_cast<quint32>(ControlPoints.size()) - 1, 1.0f);
|
||||||
|
|
||||||
if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1))
|
if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1))
|
||||||
SectionLength += mCenterLength;
|
SectionLength += mCenterLength;
|
||||||
else
|
else
|
||||||
SectionLength += mMiddle.Length;
|
SectionLength += mMiddle.Length;
|
||||||
|
|
||||||
if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges)
|
if (Sections.size() == mNumSections + 1 && !mRigidEdges)
|
||||||
SectionLength += mEnd.Length;
|
SectionLength += mEnd.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ void lcSynthInfoStraight::CalculateSections(const std::vector<lcPieceControlPoin
|
||||||
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size(); ControlPointIndex++)
|
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size(); ControlPointIndex++)
|
||||||
{
|
{
|
||||||
lcMatrix44 Transform = lcMatrix44LeoCADToLDraw(ControlPoints[ControlPointIndex].Transform);
|
lcMatrix44 Transform = lcMatrix44LeoCADToLDraw(ControlPoints[ControlPointIndex].Transform);
|
||||||
Sections.Add(Transform);
|
Sections.emplace_back(Transform);
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(Transform.GetTranslation(), ControlPointIndex, 1.0f);
|
SectionCallback(Transform.GetTranslation(), ControlPointIndex, 1.0f);
|
||||||
|
@ -925,7 +925,7 @@ void lcSynthInfoUniversalJoint::CalculateSections(const std::vector<lcPieceContr
|
||||||
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size(); ControlPointIndex++)
|
for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size(); ControlPointIndex++)
|
||||||
{
|
{
|
||||||
lcMatrix44 Transform = lcMatrix44LeoCADToLDraw(ControlPoints[ControlPointIndex].Transform);
|
lcMatrix44 Transform = lcMatrix44LeoCADToLDraw(ControlPoints[ControlPointIndex].Transform);
|
||||||
Sections.Add(Transform);
|
Sections.emplace_back(Transform);
|
||||||
|
|
||||||
if (SectionCallback)
|
if (SectionCallback)
|
||||||
SectionCallback(Transform.GetTranslation(), ControlPointIndex, 1.0f);
|
SectionCallback(Transform.GetTranslation(), ControlPointIndex, 1.0f);
|
||||||
|
@ -960,19 +960,19 @@ void lcSynthInfoFlexibleHose::AddParts(lcMemFile& File, lcLibraryMeshData&, cons
|
||||||
File.WriteBuffer(Line, strlen(Line));
|
File.WriteBuffer(Line, strlen(Line));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
lcMatrix33 Transform = lcMatrix33(Sections[SectionIdx]);
|
lcMatrix33 Transform = lcMatrix33(Sections[SectionIdx]);
|
||||||
lcVector3 Offset = Sections[SectionIdx].GetTranslation();
|
lcVector3 Offset = Sections[SectionIdx].GetTranslation();
|
||||||
|
|
||||||
if (SectionIdx < Sections.GetSize() / 2)
|
if (SectionIdx < Sections.size() / 2)
|
||||||
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, -1.0f, 0.0f), lcVector3(-1.0f, 0.0f, 0.0f)), Transform);
|
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, -1.0f, 0.0f), lcVector3(-1.0f, 0.0f, 0.0f)), Transform);
|
||||||
else if (SectionIdx != Sections.GetSize() / 2)
|
else if (SectionIdx != Sections.size() / 2)
|
||||||
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, 1.0f, 0.0f), lcVector3( 1.0f, 0.0f, 0.0f)), Transform);
|
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, 1.0f, 0.0f), lcVector3( 1.0f, 0.0f, 0.0f)), Transform);
|
||||||
else
|
else
|
||||||
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, 1.0f, 0.0f), lcVector3( 1.0f, 0.0f, 0.0f)), Transform);
|
Transform = lcMul(lcMatrix33(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, 1.0f, 0.0f), lcVector3( 1.0f, 0.0f, 0.0f)), Transform);
|
||||||
|
|
||||||
const char* Part = SectionIdx != Sections.GetSize() / 2 ? "754.dat" : "756.dat";
|
const char* Part = SectionIdx != Sections.size() / 2 ? "754.dat" : "756.dat";
|
||||||
|
|
||||||
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f %s\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
|
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f %s\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
|
||||||
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2], Part);
|
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2], Part);
|
||||||
|
@ -982,7 +982,7 @@ void lcSynthInfoFlexibleHose::AddParts(lcMemFile& File, lcLibraryMeshData&, cons
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < NumEdgeParts; PartIdx++)
|
for (int PartIdx = 0; PartIdx < NumEdgeParts; PartIdx++)
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 Transform(lcMul(EdgeTransforms[PartIdx], lcMatrix33(Sections[SectionIdx])));
|
lcMatrix33 Transform(lcMul(EdgeTransforms[PartIdx], lcMatrix33(Sections[SectionIdx])));
|
||||||
lcVector3 Offset = lcMul31(lcVector3(0.0f, 5.0f - 2.56f, 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(0.0f, 5.0f - 2.56f, 0.0f), Sections[SectionIdx]);
|
||||||
|
|
||||||
|
@ -1020,11 +1020,11 @@ void lcSynthInfoCurved::AddTubeParts(lcLibraryMeshData& MeshData, const lcArray<
|
||||||
int BaseVertex;
|
int BaseVertex;
|
||||||
lcMeshLoaderVertex* VertexBuffer;
|
lcMeshLoaderVertex* VertexBuffer;
|
||||||
quint32* IndexBuffer;
|
quint32* IndexBuffer;
|
||||||
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSectionVertices * (Sections.GetSize() - 1), &BaseVertex, &VertexBuffer);
|
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSectionVertices * (Sections.size() - 1), &BaseVertex, &VertexBuffer);
|
||||||
|
|
||||||
float NormalDirection = IsInner ? -1.0f : 1.0f;
|
float NormalDirection = IsInner ? -1.0f : 1.0f;
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize(); SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size(); SectionIdx++)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1035,7 +1035,7 @@ void lcSynthInfoCurved::AddTubeParts(lcLibraryMeshData& MeshData, const lcArray<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, 6 * NumSectionVertices * (Sections.GetSize() - 2), &IndexBuffer);
|
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, 6 * NumSectionVertices * (Sections.size() - 2), &IndexBuffer);
|
||||||
|
|
||||||
int Offset1, Offset2;
|
int Offset1, Offset2;
|
||||||
if (IsInner)
|
if (IsInner)
|
||||||
|
@ -1049,7 +1049,7 @@ void lcSynthInfoCurved::AddTubeParts(lcLibraryMeshData& MeshData, const lcArray<
|
||||||
Offset2 = 1;
|
Offset2 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1083,7 +1083,7 @@ void lcSynthInfoFlexSystemHose::AddParts(lcMemFile& File, lcLibraryMeshData& Mes
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(Sections[SectionIdx])));
|
lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(Sections[SectionIdx])));
|
||||||
lcVector3 Offset = lcMul31(lcVector3(0.0f, 1.0f, 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(0.0f, 1.0f, 0.0f), Sections[SectionIdx]);
|
||||||
|
|
||||||
|
@ -1115,7 +1115,7 @@ void lcSynthInfoPneumaticTube::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 EdgeTransform(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, -1.0f, 0.0f), lcVector3(1.0f, 0.0f, 0.0f));
|
lcMatrix33 EdgeTransform(lcVector3(0.0f, 0.0f, -1.0f), lcVector3(0.0f, -1.0f, 0.0f), lcVector3(1.0f, 0.0f, 0.0f));
|
||||||
lcMatrix33 Transform(lcMul(lcMul(EdgeTransform, lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), lcMatrix33(Sections[SectionIdx])));
|
lcMatrix33 Transform(lcMul(lcMul(EdgeTransform, lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), lcMatrix33(Sections[SectionIdx])));
|
||||||
lcVector3 Offset = lcMul31(lcVector3(0.0f, 0.0f, 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(0.0f, 0.0f, 0.0f), Sections[SectionIdx]);
|
||||||
|
@ -1146,7 +1146,7 @@ void lcSynthInfoRibbedHose::AddParts(lcMemFile& File, lcLibraryMeshData&, const
|
||||||
File.WriteBuffer(Line, strlen(Line));
|
File.WriteBuffer(Line, strlen(Line));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
const lcMatrix44& Transform = Sections[SectionIdx];
|
const lcMatrix44& Transform = Sections[SectionIdx];
|
||||||
|
|
||||||
|
@ -1157,7 +1157,7 @@ void lcSynthInfoRibbedHose::AddParts(lcMemFile& File, lcLibraryMeshData&, const
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 Transform(Sections[SectionIdx]);
|
lcMatrix33 Transform(Sections[SectionIdx]);
|
||||||
lcVector3 Offset = lcMul31(lcVector3(0.0f, -6.25f, 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(0.0f, -6.25f, 0.0f), Sections[SectionIdx]);
|
||||||
|
|
||||||
|
@ -1202,7 +1202,7 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < NumEdgeParts; PartIdx++)
|
for (int PartIdx = 0; PartIdx < NumEdgeParts; PartIdx++)
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 Transform(lcMul(EdgeTransforms[PartIdx], lcMatrix33(Sections[SectionIdx])));
|
lcMatrix33 Transform(lcMul(EdgeTransforms[PartIdx], lcMatrix33(Sections[SectionIdx])));
|
||||||
lcVector3 Offset = lcMul31(lcVector3(0.0f, 4.0f * (5 - PartIdx), 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(0.0f, 4.0f * (5 - PartIdx), 0.0f), Sections[SectionIdx]);
|
||||||
|
|
||||||
|
@ -1249,10 +1249,10 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||||
int BaseVertex;
|
int BaseVertex;
|
||||||
lcMeshLoaderVertex* VertexBuffer;
|
lcMeshLoaderVertex* VertexBuffer;
|
||||||
quint32* IndexBuffer;
|
quint32* IndexBuffer;
|
||||||
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSectionVertices * (Sections.GetSize() - 1), &BaseVertex, &VertexBuffer);
|
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSectionVertices * (Sections.size() - 1), &BaseVertex, &VertexBuffer);
|
||||||
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, 2 * 12 * (Sections.GetSize() - 2), &IndexBuffer);
|
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, 2 * 12 * (Sections.size() - 2), &IndexBuffer);
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize(); SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size(); SectionIdx++)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1265,7 +1265,7 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||||
|
|
||||||
int BaseLinesVertex = BaseVertex;
|
int BaseLinesVertex = BaseVertex;
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
const int Indices[] = { 1, 3, 5, 8, 10, 12, 15, 17, 19, 22, 24, 26 };
|
const int Indices[] = { 1, 3, 5, 8, 10, 12, 15, 17, 19, 22, 24, 26 };
|
||||||
|
|
||||||
|
@ -1278,9 +1278,9 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||||
BaseLinesVertex += NumSectionVertices;
|
BaseLinesVertex += NumSectionVertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, 6 * NumSectionVertices * (Sections.GetSize() - 2), &IndexBuffer);
|
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, 6 * NumSectionVertices * (Sections.size() - 2), &IndexBuffer);
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < NumSectionVertices; VertexIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1301,9 +1301,9 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||||
void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray<lcMatrix44>& SectionsIn) const
|
void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray<lcMatrix44>& SectionsIn) const
|
||||||
{
|
{
|
||||||
lcArray<lcMatrix44> Sections;
|
lcArray<lcMatrix44> Sections;
|
||||||
Sections.SetSize(SectionsIn.GetSize());
|
Sections.resize(SectionsIn.size());
|
||||||
|
|
||||||
for (int SectionIdx = 0; SectionIdx < Sections.GetSize(); SectionIdx++)
|
for (int SectionIdx = 0; SectionIdx < Sections.size(); SectionIdx++)
|
||||||
{
|
{
|
||||||
lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(SectionsIn[SectionIdx])));
|
lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(SectionsIn[SectionIdx])));
|
||||||
lcVector3 Offset = SectionsIn[SectionIdx].GetTranslation();
|
lcVector3 Offset = SectionsIn[SectionIdx].GetTranslation();
|
||||||
|
@ -1333,22 +1333,22 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh
|
||||||
int BaseVertex;
|
int BaseVertex;
|
||||||
lcMeshLoaderVertex* VertexBuffer;
|
lcMeshLoaderVertex* VertexBuffer;
|
||||||
quint32* IndexBuffer;
|
quint32* IndexBuffer;
|
||||||
MeshData.AddVertices(LC_MESHDATA_SHARED, NumBraids * ((Sections.GetSize() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer);
|
MeshData.AddVertices(LC_MESHDATA_SHARED, NumBraids * ((Sections.size() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer);
|
||||||
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, NumBraids * (Sections.GetSize() - 2) * NumSegments * 2, &IndexBuffer);
|
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, NumBraids * (Sections.size() - 2) * NumSegments * 2, &IndexBuffer);
|
||||||
|
|
||||||
for (int BraidIdx = 0; BraidIdx < NumBraids; BraidIdx++)
|
for (int BraidIdx = 0; BraidIdx < NumBraids; BraidIdx++)
|
||||||
{
|
{
|
||||||
int BaseX = (BraidIdx == 0 || BraidIdx == 2) ? 0 : 8;
|
int BaseX = (BraidIdx == 0 || BraidIdx == 2) ? 0 : 8;
|
||||||
int BaseY = (BraidIdx == 0 || BraidIdx == 3) ? 12 : 4;
|
int BaseY = (BraidIdx == 0 || BraidIdx == 3) ? 12 : 4;
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]);
|
lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]);
|
||||||
lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]);
|
lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]);
|
||||||
lcVector3 Offset1 = Sections[SectionIdx].GetTranslation();
|
lcVector3 Offset1 = Sections[SectionIdx].GetTranslation();
|
||||||
lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation();
|
lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation();
|
||||||
|
|
||||||
for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.GetSize() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++)
|
for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.size() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++)
|
||||||
{
|
{
|
||||||
float t = (float)SegmentIdx / (float)NumSegments;
|
float t = (float)SegmentIdx / (float)NumSegments;
|
||||||
|
|
||||||
|
@ -1375,17 +1375,17 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh
|
||||||
}
|
}
|
||||||
|
|
||||||
int NumSlices = 16;
|
int NumSlices = 16;
|
||||||
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSlices * ((Sections.GetSize() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer);
|
MeshData.AddVertices(LC_MESHDATA_SHARED, NumSlices * ((Sections.size() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer);
|
||||||
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, NumSlices * (Sections.GetSize() - 2) * NumSegments * 6, &IndexBuffer);
|
MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, NumSlices * (Sections.size() - 2) * NumSegments * 6, &IndexBuffer);
|
||||||
|
|
||||||
for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++)
|
for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++)
|
||||||
{
|
{
|
||||||
lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]);
|
lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]);
|
||||||
lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]);
|
lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]);
|
||||||
lcVector3 Offset1 = Sections[SectionIdx].GetTranslation();
|
lcVector3 Offset1 = Sections[SectionIdx].GetTranslation();
|
||||||
lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation();
|
lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation();
|
||||||
|
|
||||||
for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.GetSize() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++)
|
for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.size() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++)
|
||||||
{
|
{
|
||||||
float t1 = (float)SegmentIdx / (float)NumSegments;
|
float t1 = (float)SegmentIdx / (float)NumSegments;
|
||||||
int BaseX = 8;
|
int BaseX = 8;
|
||||||
|
@ -1420,7 +1420,7 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const int SectionIdx = Sections.GetSize() - 1;
|
const int SectionIdx = Sections.size() - 1;
|
||||||
lcMatrix33 Transform(Sections[SectionIdx]);
|
lcMatrix33 Transform(Sections[SectionIdx]);
|
||||||
lcVector3 Offset = lcMul31(lcVector3(8.0f, 0.0f, 0.0f), Sections[SectionIdx]);
|
lcVector3 Offset = lcMul31(lcVector3(8.0f, 0.0f, 0.0f), Sections[SectionIdx]);
|
||||||
|
|
||||||
|
|
|
@ -523,7 +523,7 @@ void lcTimelineWidget::CurrentItemChanged(QTreeWidgetItem* Current, QTreeWidgetI
|
||||||
|
|
||||||
void lcTimelineWidget::ItemSelectionChanged()
|
void lcTimelineWidget::ItemSelectionChanged()
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Selection;
|
std::vector<lcObject*> Selection;
|
||||||
lcStep LastStep = 1;
|
lcStep LastStep = 1;
|
||||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||||
|
|
||||||
|
@ -533,23 +533,26 @@ void lcTimelineWidget::ItemSelectionChanged()
|
||||||
if (Piece)
|
if (Piece)
|
||||||
{
|
{
|
||||||
LastStep = lcMax(LastStep, Piece->GetStepShow());
|
LastStep = lcMax(LastStep, Piece->GetStepShow());
|
||||||
Selection.Add(Piece);
|
Selection.emplace_back(Piece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcPiece* CurrentPiece = nullptr;
|
lcPiece* CurrentPiece = nullptr;
|
||||||
QTreeWidgetItem* CurrentItem = currentItem();
|
QTreeWidgetItem* CurrentItem = currentItem();
|
||||||
|
|
||||||
if (CurrentItem && CurrentItem->isSelected())
|
if (CurrentItem && CurrentItem->isSelected())
|
||||||
CurrentPiece = (lcPiece*)CurrentItem->data(0, Qt::UserRole).value<uintptr_t>();
|
CurrentPiece = (lcPiece*)CurrentItem->data(0, Qt::UserRole).value<uintptr_t>();
|
||||||
|
|
||||||
bool Blocked = blockSignals(true);
|
bool Blocked = blockSignals(true);
|
||||||
mIgnoreUpdates = true;
|
mIgnoreUpdates = true;
|
||||||
lcModel* Model = gMainWindow->GetActiveModel();
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
|
|
||||||
if (LastStep > Model->GetCurrentStep())
|
if (LastStep > Model->GetCurrentStep())
|
||||||
{
|
{
|
||||||
Model->SetCurrentStep(LastStep);
|
Model->SetCurrentStep(LastStep);
|
||||||
UpdateCurrentStepItem();
|
UpdateCurrentStepItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, false);
|
Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, false);
|
||||||
mIgnoreUpdates = false;
|
mIgnoreUpdates = false;
|
||||||
blockSignals(Blocked);
|
blockSignals(Blocked);
|
||||||
|
|
|
@ -586,7 +586,7 @@ lcPieceInfoRayTest lcView::FindPieceInfoUnderPointer(bool IgnoreSelected) const
|
||||||
return ObjectRayTest.PieceInfoRayTest;
|
return ObjectRayTest.PieceInfoRayTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcArray<lcObject*> lcView::FindObjectsInBox(float x1, float y1, float x2, float y2) const
|
std::vector<lcObject*> lcView::FindObjectsInBox(float x1, float y1, float x2, float y2) const
|
||||||
{
|
{
|
||||||
float Left, Top, Bottom, Right;
|
float Left, Top, Bottom, Right;
|
||||||
|
|
||||||
|
@ -1772,7 +1772,7 @@ void lcView::SetCamera(const QString& CameraName)
|
||||||
{
|
{
|
||||||
const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
|
const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
|
||||||
|
|
||||||
for (int CameraIdx = 0; CameraIdx < Cameras.GetSize(); CameraIdx++)
|
for (int CameraIdx = 0; CameraIdx < Cameras.size(); CameraIdx++)
|
||||||
{
|
{
|
||||||
if (CameraName.compare(Cameras[CameraIdx]->GetName(), Qt::CaseInsensitive) == 0)
|
if (CameraName.compare(Cameras[CameraIdx]->GetName(), Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1786,7 +1786,7 @@ void lcView::SetCameraIndex(int Index)
|
||||||
{
|
{
|
||||||
const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
|
const lcArray<lcCamera*>& Cameras = mModel->GetCameras();
|
||||||
|
|
||||||
if (Index >= Cameras.GetSize())
|
if (Index >= Cameras.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcCamera* Camera = Cameras[Index];
|
lcCamera* Camera = Cameras[Index];
|
||||||
|
@ -2334,7 +2334,7 @@ void lcView::StopTracking(bool Accept)
|
||||||
case lcTool::Select:
|
case lcTool::Select:
|
||||||
if (Accept && mMouseDownX != mMouseX && mMouseDownY != mMouseY)
|
if (Accept && mMouseDownX != mMouseX && mMouseDownY != mMouseY)
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mMouseX, mMouseY);
|
std::vector<lcObject*> Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mMouseX, mMouseY);
|
||||||
|
|
||||||
if (mMouseModifiers & Qt::ControlModifier)
|
if (mMouseModifiers & Qt::ControlModifier)
|
||||||
ActiveModel->AddToSelection(Objects, true, true);
|
ActiveModel->AddToSelection(Objects, true, true);
|
||||||
|
|
|
@ -264,7 +264,7 @@ public:
|
||||||
void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const;
|
void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const;
|
||||||
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
|
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
|
||||||
lcPieceInfoRayTest FindPieceInfoUnderPointer(bool IgnoreSelected) const;
|
lcPieceInfoRayTest FindPieceInfoUnderPointer(bool IgnoreSelected) const;
|
||||||
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
std::vector<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
||||||
|
|
||||||
lcVector3 ProjectPoint(const lcVector3& Point) const;
|
lcVector3 ProjectPoint(const lcVector3& Point) const;
|
||||||
lcVector3 UnprojectPoint(const lcVector3& Point) const;
|
lcVector3 UnprojectPoint(const lcVector3& Point) const;
|
||||||
|
|
|
@ -393,7 +393,7 @@ void lcLight::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
if (lcDot3(mWorldMatrix.GetTranslation(), ObjectBoxTest.Planes[PlaneIdx]) + ObjectBoxTest.Planes[PlaneIdx][3] > LC_LIGHT_SPHERE_RADIUS)
|
if (lcDot3(mWorldMatrix.GetTranslation(), ObjectBoxTest.Planes[PlaneIdx]) + ObjectBoxTest.Planes[PlaneIdx][3] > LC_LIGHT_SPHERE_RADIUS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcLight*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcLight*>(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ void lcLight::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
|
|
||||||
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes))
|
||||||
{
|
{
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcLight*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcLight*>(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct lcObjectBoxTest
|
||||||
{
|
{
|
||||||
lcCamera* ViewCamera;
|
lcCamera* ViewCamera;
|
||||||
lcVector4 Planes[6];
|
lcVector4 Planes[6];
|
||||||
lcArray<lcObject*> Objects;
|
std::vector<lcObject*> Objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LC_OBJECT_TRANSFORM_MOVE_X 0x001
|
#define LC_OBJECT_TRANSFORM_MOVE_X 0x001
|
||||||
|
|
|
@ -515,7 +515,7 @@ void lcPiece::RayTest(lcObjectRayTest& ObjectRayTest) const
|
||||||
void lcPiece::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
void lcPiece::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
{
|
{
|
||||||
if (mPieceInfo->BoxTest(mModelWorld, ObjectBoxTest.Planes))
|
if (mPieceInfo->BoxTest(mModelWorld, ObjectBoxTest.Planes))
|
||||||
ObjectBoxTest.Objects.Add(const_cast<lcPiece*>(this));
|
ObjectBoxTest.Objects.emplace_back(const_cast<lcPiece*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
||||||
|
|
|
@ -70,7 +70,7 @@ Project::Project(bool IsPreview)
|
||||||
mActiveModel = new lcModel(tr(mIsPreview ? "Preview.ldr" : "New Model.ldr"), this, mIsPreview);
|
mActiveModel = new lcModel(tr(mIsPreview ? "Preview.ldr" : "New Model.ldr"), this, mIsPreview);
|
||||||
mActiveModel->CreatePieceInfo(this);
|
mActiveModel->CreatePieceInfo(this);
|
||||||
mActiveModel->SetSaved();
|
mActiveModel->SetSaved();
|
||||||
mModels.Add(mActiveModel);
|
mModels.emplace_back(mActiveModel);
|
||||||
|
|
||||||
if (!mIsPreview && gMainWindow)
|
if (!mIsPreview && gMainWindow)
|
||||||
QObject::connect(&mFileWatcher, SIGNAL(fileChanged(const QString&)), gMainWindow, SLOT(ProjectFileChanged(const QString&)));
|
QObject::connect(&mFileWatcher, SIGNAL(fileChanged(const QString&)), gMainWindow, SLOT(ProjectFileChanged(const QString&)));
|
||||||
|
@ -95,7 +95,7 @@ bool Project::IsModified() const
|
||||||
if (mModified)
|
if (mModified)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
if (mModels[ModelIdx]->IsModified())
|
if (mModels[ModelIdx]->IsModified())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ QString Project::GetTitle() const
|
||||||
if (!mFileName.isEmpty())
|
if (!mFileName.isEmpty())
|
||||||
return QFileInfo(mFileName).fileName();
|
return QFileInfo(mFileName).fileName();
|
||||||
|
|
||||||
return mModels.GetSize() == 1 ? tr("New Model.ldr") : tr("New Model.mpd");
|
return mModels.size() == 1 ? tr("New Model.ldr") : tr("New Model.mpd");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Project::GetImageFileName(bool AllowCurrentFolder) const
|
QString Project::GetImageFileName(bool AllowCurrentFolder) const
|
||||||
|
@ -137,16 +137,16 @@ QString Project::GetImageFileName(bool AllowCurrentFolder) const
|
||||||
|
|
||||||
void Project::SetActiveModel(int ModelIndex)
|
void Project::SetActiveModel(int ModelIndex)
|
||||||
{
|
{
|
||||||
if (ModelIndex < 0 || ModelIndex >= mModels.GetSize())
|
if (ModelIndex < 0 || ModelIndex >= mModels.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->SetActive(ModelIdx == ModelIndex);
|
mModels[ModelIdx]->SetActive(ModelIdx == ModelIndex);
|
||||||
|
|
||||||
std::vector<lcModel*> UpdatedModels;
|
std::vector<lcModel*> UpdatedModels;
|
||||||
UpdatedModels.reserve(mModels.GetSize());
|
UpdatedModels.reserve(mModels.size());
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
||||||
|
|
||||||
mActiveModel = mModels[ModelIndex];
|
mActiveModel = mModels[ModelIndex];
|
||||||
|
@ -160,7 +160,7 @@ void Project::SetActiveModel(int ModelIndex)
|
||||||
|
|
||||||
void Project::SetActiveModel(const QString& FileName)
|
void Project::SetActiveModel(const QString& FileName)
|
||||||
{
|
{
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
{
|
{
|
||||||
if (FileName.compare(mModels[ModelIdx]->GetFileName(), Qt::CaseInsensitive) == 0)
|
if (FileName.compare(mModels[ModelIdx]->GetFileName(), Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +241,7 @@ lcModel* Project::CreateNewModel(bool ShowModel)
|
||||||
{
|
{
|
||||||
QStringList ModelNames;
|
QStringList ModelNames;
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
ModelNames.append(mModels[ModelIdx]->GetProperties().mFileName);
|
ModelNames.append(mModels[ModelIdx]->GetProperties().mFileName);
|
||||||
|
|
||||||
QString Name = GetNewModelName(gMainWindow, tr("New Submodel"), QString(), ModelNames);
|
QString Name = GetNewModelName(gMainWindow, tr("New Submodel"), QString(), ModelNames);
|
||||||
|
@ -253,11 +253,11 @@ lcModel* Project::CreateNewModel(bool ShowModel)
|
||||||
lcModel* Model = new lcModel(Name, this, false);
|
lcModel* Model = new lcModel(Name, this, false);
|
||||||
Model->CreatePieceInfo(this);
|
Model->CreatePieceInfo(this);
|
||||||
Model->SetSaved();
|
Model->SetSaved();
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
|
|
||||||
if (ShowModel)
|
if (ShowModel)
|
||||||
{
|
{
|
||||||
SetActiveModel(mModels.GetSize() - 1);
|
SetActiveModel(mModels.size() - 1);
|
||||||
|
|
||||||
lcView* ActiveView = gMainWindow ? gMainWindow->GetActiveView() : nullptr;
|
lcView* ActiveView = gMainWindow ? gMainWindow->GetActiveView() : nullptr;
|
||||||
if (ActiveView)
|
if (ActiveView)
|
||||||
|
@ -327,10 +327,10 @@ void Project::ShowModelListDialog()
|
||||||
mModified = true;
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewModels.Add(Model);
|
NewModels.emplace_back(Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
{
|
{
|
||||||
lcModel* Model = mModels[ModelIdx];
|
lcModel* Model = mModels[ModelIdx];
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors)
|
||||||
|
|
||||||
if (std::find_if(Models.begin(), Models.end(), ModelCompare) == Models.end())
|
if (std::find_if(Models.begin(), Models.end(), ModelCompare) == Models.end())
|
||||||
{
|
{
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
Models.emplace_back(std::make_pair(Pos, Model));
|
Models.emplace_back(std::make_pair(Pos, Model));
|
||||||
Model->CreatePieceInfo(this);
|
Model->CreatePieceInfo(this);
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors)
|
||||||
|
|
||||||
if (Model->LoadBinary(&MemFile))
|
if (Model->LoadBinary(&MemFile))
|
||||||
{
|
{
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
Model->CreatePieceInfo(this);
|
Model->CreatePieceInfo(this);
|
||||||
Model->SetSaved();
|
Model->SetSaved();
|
||||||
}
|
}
|
||||||
|
@ -452,14 +452,14 @@ bool Project::Load(const QString& FileName, bool ShowErrors)
|
||||||
delete Model;
|
delete Model;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mModels.IsEmpty())
|
if (mModels.empty())
|
||||||
{
|
{
|
||||||
if (ShowErrors)
|
if (ShowErrors)
|
||||||
QMessageBox::warning(parent, tr("Error"), tr("Error loading file '%1':\nFile format is not recognized.").arg(FileName));
|
QMessageBox::warning(parent, tr("Error"), tr("Error loading file '%1':\nFile format is not recognized.").arg(FileName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mModels.GetSize() == 1)
|
if (mModels.size() == 1)
|
||||||
{
|
{
|
||||||
lcModel* Model = mModels[0];
|
lcModel* Model = mModels[0];
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<lcModel*> UpdatedModels;
|
std::vector<lcModel*> UpdatedModels;
|
||||||
UpdatedModels.reserve(mModels.GetSize());
|
UpdatedModels.reserve(mModels.size());
|
||||||
|
|
||||||
for (lcModel* Model : mModels)
|
for (lcModel* Model : mModels)
|
||||||
{
|
{
|
||||||
|
@ -511,7 +511,7 @@ bool Project::Save(const QString& FileName)
|
||||||
|
|
||||||
bool Project::Save(QTextStream& Stream)
|
bool Project::Save(QTextStream& Stream)
|
||||||
{
|
{
|
||||||
bool MPD = mModels.GetSize() > 1;
|
bool MPD = mModels.size() > 1;
|
||||||
|
|
||||||
for (lcModel* Model : mModels)
|
for (lcModel* Model : mModels)
|
||||||
{
|
{
|
||||||
|
@ -538,7 +538,7 @@ void Project::Merge(Project* Other)
|
||||||
{
|
{
|
||||||
bool Duplicate = false;
|
bool Duplicate = false;
|
||||||
|
|
||||||
for (int SearchIdx = 0; SearchIdx < mModels.GetSize(); SearchIdx++)
|
for (int SearchIdx = 0; SearchIdx < mModels.size(); SearchIdx++)
|
||||||
{
|
{
|
||||||
if (mModels[SearchIdx]->GetProperties().mFileName == FileName)
|
if (mModels[SearchIdx]->GetProperties().mFileName == FileName)
|
||||||
{
|
{
|
||||||
|
@ -554,7 +554,7 @@ void Project::Merge(Project* Other)
|
||||||
Model->SetFileName(FileName);
|
Model->SetFileName(FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
Other->mModels.RemoveAll();
|
Other->mModels.RemoveAll();
|
||||||
|
@ -578,7 +578,7 @@ bool Project::ImportLDD(const QString& FileName)
|
||||||
|
|
||||||
if (Model->LoadLDD(QString::fromUtf8((const char*)XMLFile.mBuffer)))
|
if (Model->LoadLDD(QString::fromUtf8((const char*)XMLFile.mBuffer)))
|
||||||
{
|
{
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
Model->SetSaved();
|
Model->SetSaved();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -587,13 +587,13 @@ bool Project::ImportLDD(const QString& FileName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->CreatePieceInfo(this);
|
mModels[ModelIdx]->CreatePieceInfo(this);
|
||||||
|
|
||||||
std::vector<lcModel*> UpdatedModels;
|
std::vector<lcModel*> UpdatedModels;
|
||||||
UpdatedModels.reserve(mModels.GetSize());
|
UpdatedModels.reserve(mModels.size());
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
||||||
|
|
||||||
mModified = false;
|
mModified = false;
|
||||||
|
@ -611,7 +611,7 @@ bool Project::ImportInventory(const QByteArray& Inventory, const QString& Name,
|
||||||
|
|
||||||
if (Model->LoadInventory(Inventory))
|
if (Model->LoadInventory(Inventory))
|
||||||
{
|
{
|
||||||
mModels.Add(Model);
|
mModels.emplace_back(Model);
|
||||||
Model->SetSaved();
|
Model->SetSaved();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -622,13 +622,13 @@ bool Project::ImportInventory(const QByteArray& Inventory, const QString& Name,
|
||||||
|
|
||||||
Model->SetDescription(Description);
|
Model->SetDescription(Description);
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->CreatePieceInfo(this);
|
mModels[ModelIdx]->CreatePieceInfo(this);
|
||||||
|
|
||||||
std::vector<lcModel*> UpdatedModels;
|
std::vector<lcModel*> UpdatedModels;
|
||||||
UpdatedModels.reserve(mModels.GetSize());
|
UpdatedModels.reserve(mModels.size());
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++)
|
||||||
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels);
|
||||||
|
|
||||||
mModified = false;
|
mModified = false;
|
||||||
|
@ -640,7 +640,7 @@ std::vector<lcModelPartsEntry> Project::GetModelParts()
|
||||||
{
|
{
|
||||||
std::vector<lcModelPartsEntry> ModelParts;
|
std::vector<lcModelPartsEntry> ModelParts;
|
||||||
|
|
||||||
if (mModels.IsEmpty())
|
if (mModels.empty())
|
||||||
return ModelParts;
|
return ModelParts;
|
||||||
|
|
||||||
for (lcModel* Model : mModels)
|
for (lcModel* Model : mModels)
|
||||||
|
@ -698,7 +698,7 @@ bool Project::ExportCurrentStep(const QString& FileName)
|
||||||
|
|
||||||
const lcStep CurrentStep = lcGetActiveModel()->GetCurrentStep();
|
const lcStep CurrentStep = lcGetActiveModel()->GetCurrentStep();
|
||||||
|
|
||||||
bool MPD = mModels.GetSize() > 1;
|
bool MPD = mModels.size() > 1;
|
||||||
|
|
||||||
if (MPD)
|
if (MPD)
|
||||||
{
|
{
|
||||||
|
@ -1243,7 +1243,7 @@ void Project::ExportBrickLink()
|
||||||
{
|
{
|
||||||
lcPartsList PartsList;
|
lcPartsList PartsList;
|
||||||
|
|
||||||
if (!mModels.IsEmpty())
|
if (!mModels.empty())
|
||||||
mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList);
|
mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList);
|
||||||
|
|
||||||
if (PartsList.empty())
|
if (PartsList.empty())
|
||||||
|
@ -1536,7 +1536,7 @@ bool Project::ExportCSV(const QString& FileName)
|
||||||
{
|
{
|
||||||
lcPartsList PartsList;
|
lcPartsList PartsList;
|
||||||
|
|
||||||
if (!mModels.IsEmpty())
|
if (!mModels.empty())
|
||||||
mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList);
|
mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList);
|
||||||
|
|
||||||
if (PartsList.empty())
|
if (PartsList.empty())
|
||||||
|
@ -1594,10 +1594,10 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options)
|
||||||
lcArray<lcModel*> Models;
|
lcArray<lcModel*> Models;
|
||||||
|
|
||||||
if (Options.CurrentOnly)
|
if (Options.CurrentOnly)
|
||||||
Models.Add(mActiveModel);
|
Models.emplace_back(mActiveModel);
|
||||||
else if (Options.SubModels)
|
else if (Options.SubModels)
|
||||||
{
|
{
|
||||||
Models.Add(mActiveModel);
|
Models.emplace_back(mActiveModel);
|
||||||
mActiveModel->GetSubModels(Models);
|
mActiveModel->GetSubModels(Models);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1626,7 +1626,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options)
|
||||||
lcStep LastStep = Model->GetLastStep();
|
lcStep LastStep = Model->GetLastStep();
|
||||||
QString PageTitle;
|
QString PageTitle;
|
||||||
|
|
||||||
if (Models.GetSize() > 1)
|
if (Models.size() > 1)
|
||||||
{
|
{
|
||||||
BaseName += '-' + Model->GetProperties().mFileName;
|
BaseName += '-' + Model->GetProperties().mFileName;
|
||||||
PageTitle = Model->GetProperties().mFileName;
|
PageTitle = Model->GetProperties().mFileName;
|
||||||
|
@ -1756,7 +1756,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options)
|
||||||
Model->SaveStepImages(StepImageBaseName, true, false, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
|
Model->SaveStepImages(StepImageBaseName, true, false, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Models.GetSize() > 1)
|
if (Models.size() > 1)
|
||||||
{
|
{
|
||||||
QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1);
|
QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1);
|
||||||
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index.html")).absoluteFilePath();
|
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index.html")).absoluteFilePath();
|
||||||
|
@ -1772,7 +1772,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options)
|
||||||
|
|
||||||
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(ProjectTitle);
|
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(ProjectTitle);
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++)
|
for (int ModelIdx = 0; ModelIdx < Models.size(); ModelIdx++)
|
||||||
{
|
{
|
||||||
lcModel* Model = Models[ModelIdx];
|
lcModel* Model = Models[ModelIdx];
|
||||||
BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1) + '-' + Model->GetProperties().mFileName;
|
BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1) + '-' + Model->GetProperties().mFileName;
|
||||||
|
@ -2151,7 +2151,7 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
lcLightType LightType = lcLightType::Area;
|
lcLightType LightType = lcLightType::Area;
|
||||||
float Power = 0.0f, FadeDistance = 0.0f, FadePower = 0.0f, SpotRadius = 0.0f, SpotFalloff = 0.0f, SpotTightness = 0.0f;
|
float Power = 0.0f, FadeDistance = 0.0f, FadePower = 0.0f, SpotRadius = 0.0f, SpotFalloff = 0.0f, SpotTightness = 0.0f;
|
||||||
|
|
||||||
if (Lights.IsEmpty())
|
if (Lights.empty())
|
||||||
{
|
{
|
||||||
const lcVector3 LightTarget(0.0f, 0.0f, 0.0f), LightColor(1.0f, 1.0f, 1.0f);
|
const lcVector3 LightTarget(0.0f, 0.0f, 0.0f), LightColor(1.0f, 1.0f, 1.0f);
|
||||||
lcVector3 Location[4];
|
lcVector3 Location[4];
|
||||||
|
@ -2660,7 +2660,7 @@ void Project::SaveImage()
|
||||||
|
|
||||||
void Project::UpdatePieceInfo(PieceInfo* Info) const
|
void Project::UpdatePieceInfo(PieceInfo* Info) const
|
||||||
{
|
{
|
||||||
if (!mModels.IsEmpty())
|
if (!mModels.empty())
|
||||||
{
|
{
|
||||||
std::vector<lcModel*> UpdatedModels;
|
std::vector<lcModel*> UpdatedModels;
|
||||||
mModels[0]->UpdatePieceInfo(UpdatedModels);
|
mModels[0]->UpdatePieceInfo(UpdatedModels);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
|
|
||||||
lcModel* GetMainModel() const
|
lcModel* GetMainModel() const
|
||||||
{
|
{
|
||||||
return !mModels.IsEmpty() ? mModels[0] : nullptr;
|
return !mModels.empty() ? mModels[0] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsModified() const;
|
bool IsModified() const;
|
||||||
|
|
|
@ -26,7 +26,7 @@ lcQSelectDialog::~lcQSelectDialog()
|
||||||
|
|
||||||
void lcQSelectDialog::accept()
|
void lcQSelectDialog::accept()
|
||||||
{
|
{
|
||||||
mObjects.RemoveAll();
|
mObjects.clear();
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> Items;
|
QList<QTreeWidgetItem*> Items;
|
||||||
Items.append(ui->treeWidget->invisibleRootItem());
|
Items.append(ui->treeWidget->invisibleRootItem());
|
||||||
|
@ -41,7 +41,7 @@ void lcQSelectDialog::accept()
|
||||||
if (Item->checkState(0) == Qt::Checked)
|
if (Item->checkState(0) == Qt::Checked)
|
||||||
{
|
{
|
||||||
lcObject* Object = (lcObject*)Item->data(0, IndexRole).value<uintptr_t>();
|
lcObject* Object = (lcObject*)Item->data(0, IndexRole).value<uintptr_t>();
|
||||||
mObjects.Add(Object);
|
mObjects.emplace_back(Object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "lc_array.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class lcQSelectDialog;
|
class lcQSelectDialog;
|
||||||
|
@ -15,7 +14,7 @@ public:
|
||||||
lcQSelectDialog(QWidget* Parent, lcModel* Model);
|
lcQSelectDialog(QWidget* Parent, lcModel* Model);
|
||||||
~lcQSelectDialog();
|
~lcQSelectDialog();
|
||||||
|
|
||||||
lcArray<lcObject*> mObjects;
|
std::vector<lcObject*> mObjects;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue