Array pointers can change after reallocation

This commit is contained in:
Irlan 2019-04-22 14:33:59 -03:00
parent d2d8ade611
commit ecb4df45f4

View File

@ -29,12 +29,12 @@ struct b3QClothMesh : public b3ClothMesh
b3QClothMesh() b3QClothMesh()
{ {
vertices = clothVertices.Begin(); vertices = nullptr;
vertexCount = 0; vertexCount = 0;
triangles = clothTriangles.Begin(); triangles = nullptr;
triangleCount = 0; triangleCount = 0;
meshCount = 1; meshCount = 0;
meshes = &clothMesh; meshes = nullptr;
sewingLineCount = 0; sewingLineCount = 0;
sewingLines = nullptr; sewingLines = nullptr;
} }
@ -53,9 +53,9 @@ struct b3QClothMesh : public b3ClothMesh
clothTriangles.Resize(mesh.indexCount / 3); clothTriangles.Resize(mesh.indexCount / 3);
for (u32 i = 0; i < mesh.indexCount / 3; ++i) for (u32 i = 0; i < mesh.indexCount / 3; ++i)
{ {
triangles[i].v1 = mesh.indices[3 * i + 0]; clothTriangles[i].v1 = mesh.indices[3 * i + 0];
triangles[i].v2 = mesh.indices[3 * i + 1]; clothTriangles[i].v2 = mesh.indices[3 * i + 1];
triangles[i].v3 = mesh.indices[3 * i + 2]; clothTriangles[i].v3 = mesh.indices[3 * i + 2];
} }
clothMesh.startTriangle = 0; clothMesh.startTriangle = 0;
@ -63,8 +63,12 @@ struct b3QClothMesh : public b3ClothMesh
clothMesh.startVertex = 0; clothMesh.startVertex = 0;
clothMesh.vertexCount = clothVertices.Count(); clothMesh.vertexCount = clothVertices.Count();
vertices = clothVertices.Begin();
vertexCount = clothVertices.Count(); vertexCount = clothVertices.Count();
triangles = clothTriangles.Begin();
triangleCount = clothTriangles.Count(); triangleCount = clothTriangles.Count();
meshCount = 1;
meshes = &clothMesh;
} }
}; };