diff --git a/common/lc_array.h b/common/lc_array.h index 6f96ba35..84e8b50f 100644 --- a/common/lc_array.h +++ b/common/lc_array.h @@ -55,7 +55,12 @@ public: return *this; } - T& operator[](int Index) const + const T& operator[](int Index) const + { + return mData[Index]; + } + + T& operator[](int Index) { return mData[Index]; } diff --git a/common/lc_category.cpp b/common/lc_category.cpp index 265582a2..a6f58d25 100644 --- a/common/lc_category.cpp +++ b/common/lc_category.cpp @@ -147,7 +147,7 @@ bool lcSaveCategories(QTextStream& Stream, const lcArray& Cat for (int CategoryIdx = 0; CategoryIdx < Categories.GetSize(); CategoryIdx++) { - lcLibraryCategory& Category = Categories[CategoryIdx]; + const lcLibraryCategory& Category = Categories[CategoryIdx]; Stream << Format.arg((const char*)Category.Name, (const char*)Category.Keywords); } diff --git a/common/lc_context.cpp b/common/lc_context.cpp index 8b9eee6e..1d67df03 100644 --- a/common/lc_context.cpp +++ b/common/lc_context.cpp @@ -964,7 +964,7 @@ void lcContext::DrawOpaqueMeshes(const lcArray& OpaqueMeshes) for (int MeshIdx = 0; MeshIdx < OpaqueMeshes.GetSize(); MeshIdx++) { - lcRenderMesh& RenderMesh = OpaqueMeshes[MeshIdx]; + const lcRenderMesh& RenderMesh = OpaqueMeshes[MeshIdx]; lcMesh* Mesh = RenderMesh.Mesh; int LodIndex = RenderMesh.LodIndex; @@ -1041,7 +1041,7 @@ void lcContext::DrawTranslucentMeshes(const lcArray& TranslucentMe for (int MeshIdx = 0; MeshIdx < TranslucentMeshes.GetSize(); MeshIdx++) { - lcRenderMesh& RenderMesh = TranslucentMeshes[MeshIdx]; + const lcRenderMesh& RenderMesh = TranslucentMeshes[MeshIdx]; lcMesh* Mesh = RenderMesh.Mesh; int LodIndex = RenderMesh.LodIndex; diff --git a/common/lc_library.cpp b/common/lc_library.cpp index 59109eb1..814913cc 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -1030,7 +1030,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData for (int VertexIdx = 0; VertexIdx < TexturedVertices.GetSize(); VertexIdx++) { lcVertexTextured& DstVertex = *DstTexturedVerts++; - lcVertexTextured& SrcVertex = TexturedVertices[VertexIdx]; + const lcVertexTextured& SrcVertex = TexturedVertices[VertexIdx]; const lcVector3& SrcPosition = SrcVertex.Position; lcVector3& DstPosition = DstVertex.Position; @@ -1986,7 +1986,7 @@ void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatri for (int SrcVertexIdx = 0; SrcVertexIdx < VertexCount; SrcVertexIdx++) { - lcVertex& SrcVertex = DataVertices[SrcVertexIdx]; + const lcVertex& SrcVertex = DataVertices[SrcVertexIdx]; lcVector3 Position = lcMul31(SrcVertex.Position, Transform); lcVector2 TexCoord(lcDot3(lcVector3(Position.x, Position.y, Position.z), TextureMap->Params[0]) + TextureMap->Params[0].w, lcDot3(lcVector3(Position.x, Position.y, Position.z), TextureMap->Params[1]) + TextureMap->Params[1].w); @@ -2027,7 +2027,7 @@ void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatri for (int SrcVertexIdx = 0; SrcVertexIdx < TexturedVertexCount; SrcVertexIdx++) { - lcVertexTextured& SrcVertex = DataTexturedVertices[SrcVertexIdx]; + const lcVertexTextured& SrcVertex = DataTexturedVertices[SrcVertexIdx]; lcVector3 Position = lcMul31(SrcVertex.Position, Transform); int Index = -1; @@ -2137,7 +2137,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.GetSize(); SrcVertexIdx++) { - lcVertex& SrcVertex = DataVertices[SrcVertexIdx]; + const lcVertex& SrcVertex = DataVertices[SrcVertexIdx]; lcVertexTextured& DstVertex = TexturedVertices.Add(); lcVector3 Position = lcMul31(SrcVertex.Position, Transform); @@ -2160,7 +2160,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat for (int SrcVertexIdx = 0; SrcVertexIdx < TexturedVertexCount; SrcVertexIdx++) { - lcVertexTextured& SrcVertex = DataTexturedVertices[SrcVertexIdx]; + const lcVertexTextured& SrcVertex = DataTexturedVertices[SrcVertexIdx]; lcVertexTextured& DstVertex = TexturedVertices.Add(); DstVertex.Position = lcMul31(SrcVertex.Position, Transform); DstVertex.TexCoord = SrcVertex.TexCoord; diff --git a/common/lc_synth.cpp b/common/lc_synth.cpp index d9a45279..2e787485 100644 --- a/common/lc_synth.cpp +++ b/common/lc_synth.cpp @@ -415,7 +415,7 @@ void lcSynthInfo::AddFlexibleAxleParts(lcMemFile& File, lcLibraryMeshData& MeshD } } -void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray& Sections) const +void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, lcArray& Sections) const { for (int SectionIdx = 0; SectionIdx < Sections.GetSize(); SectionIdx++) { diff --git a/common/lc_synth.h b/common/lc_synth.h index 60849bf1..57b9a035 100644 --- a/common/lc_synth.h +++ b/common/lc_synth.h @@ -33,7 +33,7 @@ protected: void CalculateSections(const lcArray& ControlPoints, lcArray& Sections, void(*SectionCallback)(const lcVector3& CurvePoint, int SegmentIndex, float t, void* Param), void* CallbackParam) const; void AddRibbedHoseParts(lcMemFile& File, const lcArray& Sections) const; void AddFlexibleAxleParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray& Sections) const; - void AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray& Sections) const; + void AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, lcArray& Sections) const; lcSynthType mType; lcSynthComponent mStart; diff --git a/common/object.h b/common/object.h index 12209122..265db857 100644 --- a/common/object.h +++ b/common/object.h @@ -93,7 +93,7 @@ protected: const int Count = sizeof(T) / sizeof(float); for (int KeyIdx = 0; KeyIdx < Keys.GetSize(); KeyIdx++) { - lcObjectKey& Key = Keys[KeyIdx]; + const lcObjectKey& Key = Keys[KeyIdx]; Stream << QLatin1String("0 !LEOCAD ") << KeyName << Key.Step << ' '; for (int ValueIdx = 0; ValueIdx < Count; ValueIdx++) Stream << ((float*)&Key.Value)[ValueIdx] << ' '; @@ -120,7 +120,7 @@ protected: template const T& CalculateKey(const lcArray>& Keys, lcStep Step) { - lcObjectKey* PreviousKey = &Keys[0]; + const lcObjectKey* PreviousKey = &Keys[0]; for (int KeyIdx = 0; KeyIdx < Keys.GetSize(); KeyIdx++) { diff --git a/common/piece.h b/common/piece.h index 56c24081..a1f9db34 100644 --- a/common/piece.h +++ b/common/piece.h @@ -473,7 +473,7 @@ public: if (ControlPointIndex >= 0 && ControlPointIndex < mControlPoints.GetSize()) { - lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform; + const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform; return lcMul31(Transform.GetTranslation(), mModelWorld); } @@ -498,7 +498,7 @@ public: if (ControlPointIndex >= 0 && ControlPointIndex < mControlPoints.GetSize()) { - lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform; + const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform; return lcMatrix33(lcMul(Transform, mModelWorld)); }