Fixed accessing const arrays as non-const.

This commit is contained in:
leo
2016-04-19 18:37:50 +00:00
parent 6547969d24
commit 9c8a602a09
8 changed files with 20 additions and 15 deletions
+6 -1
View File
@@ -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];
}
+1 -1
View File
@@ -147,7 +147,7 @@ bool lcSaveCategories(QTextStream& Stream, const lcArray<lcLibraryCategory>& 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);
}
+2 -2
View File
@@ -964,7 +964,7 @@ void lcContext::DrawOpaqueMeshes(const lcArray<lcRenderMesh>& 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<lcRenderMesh>& 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;
+5 -5
View File
@@ -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;
+1 -1
View File
@@ -415,7 +415,7 @@ void lcSynthInfo::AddFlexibleAxleParts(lcMemFile& File, lcLibraryMeshData& MeshD
}
}
void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray<lcMatrix44>& Sections) const
void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, lcArray<lcMatrix44>& Sections) const
{
for (int SectionIdx = 0; SectionIdx < Sections.GetSize(); SectionIdx++)
{
+1 -1
View File
@@ -33,7 +33,7 @@ protected:
void CalculateSections(const lcArray<lcPieceControlPoint>& ControlPoints, lcArray<lcMatrix44>& Sections, void(*SectionCallback)(const lcVector3& CurvePoint, int SegmentIndex, float t, void* Param), void* CallbackParam) const;
void AddRibbedHoseParts(lcMemFile& File, const lcArray<lcMatrix44>& Sections) const;
void AddFlexibleAxleParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray<lcMatrix44>& Sections) const;
void AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, const lcArray<lcMatrix44>& Sections) const;
void AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& MeshData, lcArray<lcMatrix44>& Sections) const;
lcSynthType mType;
lcSynthComponent mStart;
+2 -2
View File
@@ -93,7 +93,7 @@ protected:
const int Count = sizeof(T) / sizeof(float);
for (int KeyIdx = 0; KeyIdx < Keys.GetSize(); KeyIdx++)
{
lcObjectKey<T>& Key = Keys[KeyIdx];
const lcObjectKey<T>& 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<typename T>
const T& CalculateKey(const lcArray<lcObjectKey<T>>& Keys, lcStep Step)
{
lcObjectKey<T>* PreviousKey = &Keys[0];
const lcObjectKey<T>* PreviousKey = &Keys[0];
for (int KeyIdx = 0; KeyIdx < Keys.GetSize(); KeyIdx++)
{
+2 -2
View File
@@ -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));
}