diff --git a/common/lc_array.h b/common/lc_array.h deleted file mode 100644 index 991f3e3b..00000000 --- a/common/lc_array.h +++ /dev/null @@ -1,244 +0,0 @@ -#pragma once - -template -class lcArray -{ -public: - lcArray(int Size = 0, int Grow = 16) - { - mData = nullptr; - mLength = 0; - mAlloc = 0; - mGrow = Grow; - - if (Size != 0) - AllocGrow(Size); - } - - lcArray(const lcArray& Array) - { - mData = nullptr; - *this = Array; - } - - lcArray(std::initializer_list Init) - : lcArray((int)Init.size()) - { - for (const T& Element : Init) - emplace_back(Element); - } - - ~lcArray() - { - delete[] mData; - } - - lcArray& operator=(const lcArray& Array) - { - mLength = Array.mLength; - mAlloc = Array.mAlloc; - mGrow = Array.mGrow; - - delete[] mData; - mData = new T[mAlloc]; - - for (int i = 0; i < mLength; i++) - mData[i] = Array.mData[i]; - - return *this; - } - - lcArray(lcArray&& Array) - { - mData = nullptr; - *this = std::move(Array); - } - - lcArray& operator=(lcArray&& Array) - { - delete[] mData; - - mData = Array.mData; - Array.mData = nullptr; - mLength = Array.mLength; - Array.mLength = 0; - mAlloc = Array.mAlloc; - Array.mAlloc = 0; - mGrow = Array.mGrow; - Array.mGrow = 16; - - return *this; - } - - const T& operator[](int Index) const - { - return mData[Index]; - } - - T& operator[](int Index) - { - return mData[Index]; - } - - bool operator==(const lcArray& Array) const - { - if (mLength != Array.mLength) - return false; - - for (int i = 0; i < mLength; i++) - if (mData[i] != Array.mData[i]) - return false; - - return true; - } - - T* begin() - { - return &mData[0]; - } - - T* end() - { - return &mData[0] + mLength; - } - - const T* begin() const - { - return &mData[0]; - } - - const T* end() const - { - return &mData[0] + mLength; - } - - bool empty() const - { - return mLength == 0; - } - - int size() const - { - return mLength; - } - - void resize(size_t NewSize) - { - if (NewSize > mAlloc) - AllocGrow(NewSize - mLength); - - mLength = (int)NewSize; - } - - void SetGrow(int Grow) - { - if (Grow) - mGrow = Grow; - } - - void AllocGrow(size_t Grow) - { - if ((mLength + Grow) > mAlloc) - { - const size_t NewSize = ((mLength + Grow + mGrow - 1) / mGrow) * mGrow; - T* NewData = new T[NewSize]; - - for (int i = 0; i < mLength; i++) - NewData[i] = mData[i]; - - delete[] mData; - mData = NewData; - mAlloc = NewSize; - } - } - - void emplace_back(const T& NewItem) - { - AllocGrow(1); - mData[mLength++] = NewItem; - } - - T& emplace_back() - { - AllocGrow(1); - mData[mLength++] = T(); - return mData[mLength - 1]; - } - - T& InsertAt(int Index) - { - if (Index >= mLength) - AllocGrow(Index - mLength + 1); - else - AllocGrow(1); - - mLength++; - for (int i = mLength - 1; i > Index; i--) - mData[i] = mData[i - 1]; - - return mData[Index]; - } - - void InsertAt(int Index, const T& NewItem) - { - if (Index >= mLength) - AllocGrow(Index - mLength + 1); - else - AllocGrow(1); - - mLength++; - for (int i = mLength - 1; i > Index; i--) - mData[i] = mData[i - 1]; - - mData[Index] = NewItem; - } - - void RemoveIndex(int Index) - { - mLength--; - - for (int i = Index; i < mLength; i++) - mData[i] = mData[i + 1]; - } - - void Remove(const T& Item) - { - for (int i = 0; i < mLength; i++) - { - if (mData[i] == Item) - { - RemoveIndex(i); - return; - } - } - } - - void RemoveAll() - { - mLength = 0; - } - - void DeleteAll() - { - for (int i = 0; i < mLength; i++) - delete mData[i]; - - mLength = 0; - } - - int FindIndex(const T& Item) const - { - for (int i = 0; i < mLength; i++) - if (mData[i] == Item) - return i; - - return -1; - } - -protected: - T* mData; - int mLength; - size_t mAlloc; - int mGrow; -}; - diff --git a/common/lc_meshloader.cpp b/common/lc_meshloader.cpp index 29957a2a..0b64d388 100644 --- a/common/lc_meshloader.cpp +++ b/common/lc_meshloader.cpp @@ -168,7 +168,7 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize { if (Optimize) { - for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--) + for (int VertexIdx = static_cast(mVertices.size()) - 1; VertexIdx >= 0; VertexIdx--) { const lcMeshLoaderVertex& Vertex = mVertices[VertexIdx]; @@ -183,14 +183,14 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize Vertex.Normal = lcVector3(0.0f, 0.0f, 0.0f); Vertex.NormalWeight = 0.0f; - return mVertices.size() - 1; + return static_cast(mVertices.size()) - 1; } quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVector3& Normal, float NormalWeight, bool Optimize) { if (Optimize) { - for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--) + for (int VertexIdx = static_cast(mVertices.size()) - 1; VertexIdx >= 0; VertexIdx--) { lcMeshLoaderVertex& Vertex = mVertices[VertexIdx]; @@ -218,7 +218,7 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVecto Vertex.Normal = Normal; Vertex.NormalWeight = 1.0f; - return mVertices.size() - 1; + return static_cast(mVertices.size()) - 1; } quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4]) @@ -230,7 +230,7 @@ quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4] Vertex.Position[2] = Position[2]; Vertex.Position[3] = Position[3]; - return mConditionalVertices.size() - 1; + return static_cast(mConditionalVertices.size()) - 1; } void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Material, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize) @@ -319,11 +319,12 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap) { - const lcArray& DataVertices = Data.mVertices; - lcArray IndexRemap(DataVertices.size()); + const std::vector& DataVertices = Data.mVertices; + std::vector IndexRemap; const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform))); - mVertices.AllocGrow(DataVertices.size()); + IndexRemap.reserve(DataVertices.size()); + mVertices.reserve(mVertices.size() + DataVertices.size()); for (const lcMeshLoaderVertex& DataVertex : DataVertices) { @@ -343,8 +344,8 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l IndexRemap.emplace_back(Index); } - mConditionalVertices.AllocGrow(Data.mConditionalVertices.size()); - lcArray ConditionalRemap(Data.mConditionalVertices.size()); + mConditionalVertices.reserve(mConditionalVertices.size() + Data.mConditionalVertices.size()); + std::vector ConditionalRemap(Data.mConditionalVertices.size()); for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices) { @@ -385,7 +386,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode)); } - DstSection->mIndices.AllocGrow(SrcSection->mIndices.size()); + DstSection->mIndices.reserve(DstSection->mIndices.size() + SrcSection->mIndices.size()); if (PrimitiveType == LC_MESH_CONDITIONAL_LINES) { @@ -399,7 +400,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l } else { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) + for (size_t IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) { DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 2]]); DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 1]]); @@ -411,18 +412,16 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap) { - const lcArray& DataVertices = Data.mVertices; + const std::vector& DataVertices = Data.mVertices; quint32 BaseIndex; const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform))); - BaseIndex = mVertices.size(); + BaseIndex = static_cast(mVertices.size()); - mVertices.SetGrow(lcMin(mVertices.size(), 8 * 1024 * 1024)); - mVertices.AllocGrow(DataVertices.size()); + mVertices.reserve(mVertices.size() + DataVertices.size()); - for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.size(); SrcVertexIdx++) + for (const lcMeshLoaderVertex& SrcVertex : DataVertices) { - const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx]; lcMeshLoaderVertex& DstVertex = mVertices.emplace_back(); DstVertex.Position = lcMul31(SrcVertex.Position, Transform); DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform)); @@ -431,8 +430,8 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat DstVertex.NormalWeight = SrcVertex.NormalWeight; } - mConditionalVertices.AllocGrow(Data.mConditionalVertices.size()); - const quint32 BaseConditional = mConditionalVertices.size(); + mConditionalVertices.reserve(mConditionalVertices.size() + Data.mConditionalVertices.size()); + const quint32 BaseConditional = static_cast(mConditionalVertices.size()); for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices) { @@ -470,8 +469,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode)); } - DstSection->mIndices.SetGrow(lcMin(DstSection->mIndices.size(), 8 * 1024 * 1024)); - DstSection->mIndices.AllocGrow(SrcSection->mIndices.size()); + DstSection->mIndices.reserve(DstSection->mIndices.size() + SrcSection->mIndices.size()); if (PrimitiveType == LC_MESH_CONDITIONAL_LINES) { @@ -485,7 +483,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat } else { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) + for (size_t IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) { DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 2]); DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 1]); @@ -497,8 +495,8 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, size_t VertexCount, int* BaseVertex, lcMeshLoaderVertex** VertexBuffer) { - lcArray& Vertices = mData[MeshDataType].mVertices; - int CurrentSize = Vertices.size(); + std::vector& Vertices = mData[MeshDataType].mVertices; + int CurrentSize = static_cast(Vertices.size()); Vertices.resize(CurrentSize + VertexCount); @@ -509,8 +507,8 @@ void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, size_t VertexCo void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, lcMeshPrimitiveType PrimitiveType, quint32 ColorCode, size_t IndexCount, quint32** IndexBuffer) { lcMeshLoaderSection* Section = mData[MeshDataType].AddSection(PrimitiveType, GetMaterial(ColorCode)); - lcArray& Indices = Section->mIndices; - const int CurrentSize = Indices.size(); + std::vector& Indices = Section->mIndices; + const size_t CurrentSize = Indices.size(); Indices.resize(CurrentSize + IndexCount); @@ -631,7 +629,7 @@ static bool lcMeshLoaderFinalSectionCompare(const lcMeshLoaderFinalSection& a, c quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoords) { - for (int VertexIndex = mTexturedVertices.size() - 1; VertexIndex >= 0; VertexIndex--) + for (int VertexIndex = static_cast(mTexturedVertices.size()) - 1; VertexIndex >= 0; VertexIndex--) { const lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices[VertexIndex]; @@ -645,7 +643,7 @@ quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lc Vertex.Normal = Normal; Vertex.TexCoords = TexCoords; - return mTexturedVertices.size() - 1; + return static_cast(mTexturedVertices.size()) - 1; } void lcLibraryMeshData::GeneratePlanarTexcoords(lcMeshLoaderSection* Section, const lcMeshLoaderTypeData& Data) @@ -688,7 +686,7 @@ void lcLibraryMeshData::GenerateCylindricalTexcoords(lcMeshLoaderSection* Sectio const lcVector4 Plane2 = lcVector4(Plane2Normal, -lcDot(Plane2Normal, Material->Points[1])); const float Angle = 360.0f / Material->Angles[0]; - for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) + for (size_t TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) { const lcVector3 Positions[3] = { @@ -731,7 +729,7 @@ void lcLibraryMeshData::GenerateSphericalTexcoords(lcMeshLoaderSection* Section, const float Angle1 = 360.0f / Material->Angles[0]; const float Angle2 = 180.0f / Material->Angles[1]; - for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) + for (size_t TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) { const lcVector3 Positions[3] = { @@ -808,9 +806,9 @@ lcMesh* lcLibraryMeshData::CreateMesh() for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++) { BaseVertices[MeshDataIdx] = NumVertices; - NumVertices += mData[MeshDataIdx].mVertices.size(); + NumVertices += static_cast(mData[MeshDataIdx].mVertices.size()); BaseConditionalVertices[MeshDataIdx] = ConditionalVertexCount; - ConditionalVertexCount += mData[MeshDataIdx].mConditionalVertices.size(); + ConditionalVertexCount += static_cast(mData[MeshDataIdx].mConditionalVertices.size()); } if (mHasTextures) @@ -819,11 +817,11 @@ lcMesh* lcLibraryMeshData::CreateMesh() quint16 NumSections[LC_NUM_MESH_LODS]; int NumIndices = 0; - lcArray FinalSections[LC_NUM_MESH_LODS]; + std::vector FinalSections[LC_NUM_MESH_LODS]; for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++) { - auto AddFinalSection = [](lcMeshLoaderSection* Section, lcArray& FinalSections) + auto AddFinalSection = [](lcMeshLoaderSection* Section, std::vector& FinalSections) { for (const lcMeshLoaderFinalSection& FinalSection : FinalSections) if (FinalSection.PrimitiveType == Section->mPrimitiveType && FinalSection.Color == Section->mMaterial->Color && !strcmp(FinalSection.Name, Section->mMaterial->Name)) @@ -838,23 +836,23 @@ lcMesh* lcLibraryMeshData::CreateMesh() for (const std::unique_ptr& Section : mData[LC_MESHDATA_SHARED].mSections) { - NumIndices += Section->mIndices.size(); + NumIndices += static_cast(Section->mIndices.size()); AddFinalSection(Section.get(), FinalSections[LodIdx]); } for (const std::unique_ptr& Section : mData[LodIdx].mSections) { - NumIndices += Section->mIndices.size(); + NumIndices += static_cast(Section->mIndices.size()); AddFinalSection(Section.get(), FinalSections[LodIdx]); } - NumSections[LodIdx] = FinalSections[LodIdx].size(); + NumSections[LodIdx] = static_cast(FinalSections[LodIdx].size()); std::sort(FinalSections[LodIdx].begin(), FinalSections[LodIdx].end(), lcMeshLoaderFinalSectionCompare); } - Mesh->Create(NumSections, NumVertices, mTexturedVertices.size(), ConditionalVertexCount, NumIndices); + Mesh->Create(NumSections, NumVertices, static_cast(mTexturedVertices.size()), ConditionalVertexCount, NumIndices); lcVertex* DstVerts = (lcVertex*)Mesh->mVertexData; @@ -912,16 +910,16 @@ lcMesh* lcLibraryMeshData::CreateMesh() } template -void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArray (&FinalSections)[LC_NUM_MESH_LODS], int(&BaseVertices)[LC_NUM_MESHDATA_TYPES], int(&BaseConditionalVertices)[LC_NUM_MESHDATA_TYPES]) +void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const std::vector (&FinalSections)[LC_NUM_MESH_LODS], int(&BaseVertices)[LC_NUM_MESHDATA_TYPES], int(&BaseConditionalVertices)[LC_NUM_MESHDATA_TYPES]) { int NumIndices = 0; for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++) { - for (int SectionIdx = 0; SectionIdx < FinalSections[LodIdx].size(); SectionIdx++) + for (size_t SectionIndex = 0; SectionIndex < FinalSections[LodIdx].size(); SectionIndex++) { - const lcMeshLoaderFinalSection& FinalSection = FinalSections[LodIdx][SectionIdx]; - lcMeshSection& DstSection = Mesh->mLods[LodIdx].Sections[SectionIdx]; + const lcMeshLoaderFinalSection& FinalSection = FinalSections[LodIdx][SectionIndex]; + lcMeshSection& DstSection = Mesh->mLods[LodIdx].Sections[SectionIndex]; DstSection.ColorIndex = FinalSection.Color; DstSection.PrimitiveType = FinalSection.PrimitiveType; @@ -953,7 +951,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.size(); IndexIdx++) + for (size_t IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = BaseVertex + SrcSection->mIndices[IndexIdx]; } break; @@ -962,14 +960,14 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.size(); IndexIdx++) + for (size_t IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = BaseVertex + SrcSection->mIndices[IndexIdx]; } break; case LC_MESH_TEXTURED_TRIANGLES: { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) + for (size_t IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = SrcSection->mIndices[IndexIdx]; } break; @@ -978,7 +976,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.size(); + DstSection.NumIndices += static_cast(SrcSection->mIndices.size()); }; for (const std::unique_ptr& Section : mData[LC_MESHDATA_SHARED].mSections) diff --git a/common/lc_meshloader.h b/common/lc_meshloader.h index bd2e1362..b3a24298 100644 --- a/common/lc_meshloader.h +++ b/common/lc_meshloader.h @@ -1,6 +1,5 @@ #pragma once -#include "lc_array.h" #include "lc_math.h" #include "lc_mesh.h" @@ -55,13 +54,14 @@ class lcMeshLoaderSection { public: lcMeshLoaderSection(lcMeshPrimitiveType PrimitiveType, lcMeshLoaderMaterial* Material) - : mMaterial(Material), mPrimitiveType(PrimitiveType), mIndices(1024, 1024) + : mMaterial(Material), mPrimitiveType(PrimitiveType) { + mIndices.reserve(1024); } lcMeshLoaderMaterial* mMaterial; lcMeshPrimitiveType mPrimitiveType; - lcArray mIndices; + std::vector mIndices; }; struct lcMeshLoaderFinalSection @@ -96,11 +96,7 @@ struct lcMeshLoaderTextureMap class lcMeshLoaderTypeData { public: - lcMeshLoaderTypeData() - { - mVertices.SetGrow(1024); - mConditionalVertices.SetGrow(1024); - } + lcMeshLoaderTypeData() = default; lcMeshLoaderTypeData(const lcMeshLoaderTypeData&) = delete; lcMeshLoaderTypeData& operator=(const lcMeshLoaderTypeData&) = delete; @@ -113,8 +109,8 @@ class lcMeshLoaderTypeData void Clear() { mSections.clear(); - mVertices.RemoveAll(); - mConditionalVertices.RemoveAll(); + mVertices.clear(); + mConditionalVertices.clear(); } void SetMeshData(lcLibraryMeshData* MeshData) @@ -134,8 +130,8 @@ class lcMeshLoaderTypeData void AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap); std::vector> mSections; - lcArray mVertices; - lcArray mConditionalVertices; + std::vector mVertices; + std::vector mConditionalVertices; protected: lcLibraryMeshData* mMeshData = nullptr; @@ -195,7 +191,7 @@ class lcLibraryMeshData protected: lcMeshLoader* mMeshLoader = nullptr; std::vector> mMaterials; - lcArray mTexturedVertices; + std::vector mTexturedVertices; void GenerateTexturedVertices(); void GeneratePlanarTexcoords(lcMeshLoaderSection* Section, const lcMeshLoaderTypeData& Data); @@ -204,7 +200,7 @@ class lcLibraryMeshData quint32 AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoords); template - void WriteSections(lcMesh* Mesh, const lcArray (&FinalSections)[LC_NUM_MESH_LODS], int (&BaseVertices)[LC_NUM_MESHDATA_TYPES], int (&BaseConditionalVertices)[LC_NUM_MESHDATA_TYPES]); + void WriteSections(lcMesh* Mesh, const std::vector (&FinalSections)[LC_NUM_MESH_LODS], int (&BaseVertices)[LC_NUM_MESHDATA_TYPES], int (&BaseConditionalVertices)[LC_NUM_MESHDATA_TYPES]); static void UpdateMeshBoundingBox(lcMesh* Mesh); template diff --git a/common/lc_model.h b/common/lc_model.h index c3188488..efb69ae7 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -2,7 +2,6 @@ #include "lc_math.h" #include "lc_commands.h" -#include "lc_array.h" enum class lcObjectPropertyId; diff --git a/common/lc_modellistdialog.h b/common/lc_modellistdialog.h index ec2b91cc..53c30c80 100644 --- a/common/lc_modellistdialog.h +++ b/common/lc_modellistdialog.h @@ -1,7 +1,5 @@ #pragma once -#include "lc_array.h" - namespace Ui { class lcModelListDialog; diff --git a/common/lc_synth.cpp b/common/lc_synth.cpp index 2c02bbf0..5c8988b1 100644 --- a/common/lc_synth.cpp +++ b/common/lc_synth.cpp @@ -693,9 +693,9 @@ void lcSynthInfoCurved::CalculateSections(const std::vector SegmentControlPoints[2] = lcMul31(lcVector3(0.0f, -ControlPoints[ControlPointIndex + 1].Scale, 0.0f), EndTransform); SegmentControlPoints[3] = EndTransform.GetTranslation(); - const int NumCurvePoints = 8192; - lcArray CurvePoints; - CurvePoints.AllocGrow(NumCurvePoints); + const int NumCurvePoints = 4096; + std::vector CurvePoints; + CurvePoints.reserve(NumCurvePoints); for (int PointIdx = 0; PointIdx < NumCurvePoints; PointIdx++) { @@ -709,12 +709,12 @@ void lcSynthInfoCurved::CalculateSections(const std::vector float CurrentSegmentLength = 0.0f; float TotalSegmentLength = 0.0f; - for (int PointIdx = 0; PointIdx < CurvePoints.size() - 1; PointIdx++) + for (size_t PointIdx = 0; PointIdx < CurvePoints.size() - 1; PointIdx++) TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]); lcVector3 StartUp = lcMul30(lcVector3(1.0f, 0.0f, 0.0f), StartTransform); float Twist = GetSectionTwist(StartTransform, EndTransform); - int CurrentPointIndex = 0; + size_t CurrentPointIndex = 0; while (CurrentPointIndex < CurvePoints.size() - 1) { @@ -818,9 +818,9 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector CurvePoints; - CurvePoints.AllocGrow(NumCurvePoints); + const int NumCurvePoints = 4096; + std::vector CurvePoints; + CurvePoints.reserve(NumCurvePoints); for (int PointIdx = 0; PointIdx < NumCurvePoints; PointIdx++) { @@ -834,12 +834,12 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector