Creating Static Object RigidBody Not Working Everytime

Post Reply
peymankop
Posts: 6
Joined: Wed Nov 02, 2016 4:05 pm

Creating Static Object RigidBody Not Working Everytime

Post by peymankop »

I have a strange problem and i don't know it is from models i use or how i implement code.
here is the code that i use for creating static rigid bodies(like a house):

Code: Select all

for (unsigned int i = 0;i < vec.size();i++)
		{
			btScalar * points = new btScalar[vec[i]->pointsSize*3];
			btConvexHullShape *tmp = new btConvexHullShape();
			for (unsigned int j = 0;j < vec[i]->pointsSize;j++)
			{
				points[j * 3 + 0] = vec[i]->points[j].x;
				points[j * 3 + 1] = vec[i]->points[j].y;
				points[j * 3 + 2] = vec[i]->points[j].z;
			}
			btTriangleIndexVertexArray * data =
				new btTriangleIndexVertexArray(vec[i]->indicesSize / 3,
					(int*)vec[i]->indciesInt.data(), 3 * sizeof(int)
					, vec[i]->pointsSize, points, 3 * sizeof(btScalar));
			btBvhTriangleMeshShape * d = new btBvhTriangleMeshShape(data, false, false);
			d->buildOptimizedBvh();
			d->usesQuantizedAabbCompression();
			m_meshRigidData[i].collisionShape = d;
			m_meshRigidData[i].collisionShape->setMargin(0.5f);
}
with this code with some models in works perfectly but with some other models it do nothing and i cannot see any collision. so my question is is there any problem with my code? or i should check for models i use? can bullet build collision model for every model?
Post Reply