Fix pointer error in raycast unit test

This commit is contained in:
Daniel Chappuis 2016-03-30 23:17:20 +02:00
parent b608efa032
commit 97fd840150

View File

@ -157,8 +157,8 @@ class TestRaycast : public Test {
std::vector<Vector3> mConcaveMeshVertices; std::vector<Vector3> mConcaveMeshVertices;
std::vector<uint> mConcaveMeshIndices; std::vector<uint> mConcaveMeshIndices;
TriangleVertexArray* mConcaveMeshVertexArray;
float mHeightFieldData[25]; float mHeightFieldData[100];
public : public :
@ -288,17 +288,19 @@ class TestRaycast : public Test {
mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(5);
mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(6); mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(6);
mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(5);
TriangleVertexArray* vertexArray = mConcaveMeshVertexArray =
new TriangleVertexArray(8, &(mConcaveMeshVertices[0]), sizeof(Vector3), new TriangleVertexArray(8, &(mConcaveMeshVertices[0]), sizeof(Vector3),
12, &(mConcaveMeshIndices[0]), sizeof(int), 12, &(mConcaveMeshIndices[0]), sizeof(int),
TriangleVertexArray::VERTEX_FLOAT_TYPE, TriangleVertexArray::VERTEX_FLOAT_TYPE,
TriangleVertexArray::INDEX_INTEGER_TYPE); TriangleVertexArray::INDEX_INTEGER_TYPE);
// Add the triangle vertex array of the subpart to the triangle mesh // Add the triangle vertex array of the subpart to the triangle mesh
mConcaveTriangleMesh.addSubpart(vertexArray); mConcaveTriangleMesh.addSubpart(mConcaveMeshVertexArray);
mConcaveMeshShape = new ConcaveMeshShape(&mConcaveTriangleMesh); mConcaveMeshShape = new ConcaveMeshShape(&mConcaveTriangleMesh);
mConcaveMeshProxyShape = mConcaveMeshBody->addCollisionShape(mConcaveMeshShape, mShapeTransform); mConcaveMeshProxyShape = mConcaveMeshBody->addCollisionShape(mConcaveMeshShape, mShapeTransform);
// Heightfield shape (plane height field at height=4) // Heightfield shape (plane height field at height=4)
for (int i=0; i<100; i++) mHeightFieldData[i] = 4; for (int i=0; i<100; i++) mHeightFieldData[i] = 4;
mHeightFieldShape = new HeightFieldShape(10, 10, 0, 4, mHeightFieldData, HeightFieldShape::HEIGHT_FLOAT_TYPE); mHeightFieldShape = new HeightFieldShape(10, 10, 0, 4, mHeightFieldData, HeightFieldShape::HEIGHT_FLOAT_TYPE);
@ -331,6 +333,8 @@ class TestRaycast : public Test {
delete mTriangleShape; delete mTriangleShape;
delete mConcaveMeshShape; delete mConcaveMeshShape;
delete mHeightFieldShape; delete mHeightFieldShape;
delete mConcaveMeshVertexArray;
} }
/// Run the tests /// Run the tests
@ -2194,6 +2198,7 @@ class TestRaycast : public Test {
test(mCallback.isHit); test(mCallback.isHit);
} }
void testConcaveMesh() { void testConcaveMesh() {
// ----- Test feedback data ----- // // ----- Test feedback data ----- //