# Bullet - Things fall through my heightmap!

## Recommended Posts

A heightmap was created using the same technique as in the bullet heightmap demo. The heightmap is 16*16 samples, all are located at same height (y=-100 in the bullet physics world), and the heightmap is centered around x=0, z=0. I tried using a small epsilon to ensure AABB isn't of volume 0 just to be sure (but it seems that has no effect to my problem, see below). The size of each quad is 20 world units. I then drop a big sphere on it from slightly above y=0. When the sphere radius is 100, it comes to a halt when hitting the heightmap, rolls off it slowly, then continues falling after rolling over the edge. When the sphere radius is smaller, e.g. 10, the sphere just falls through the heightmap. Am I setting up the collision detection incorrectly? E.g. is it using static rather col det while it should be using dynamic col det? Or is the physics step size too long? Stepping is currently done by:
dynamicsWorld->stepSimulation(deltaTInSeconds, 10);


##### Share on other sites
No offense, but how can we possibly answer your question with so little information?

##### Share on other sites
No offense taken. I'm still a beginner at bullet so I have no idea what is relevant, thought I may have luck that someone recognized the problem already from that. In the meantime I'll try to create a minimal application that reproduces the problem and post the code!

##### Share on other sites
You mention using spheres for collision detection, but the first thing that I remember regarding objects falling through my height map is because I've tried to use a btTriangleMesh as a dynamic object, which must be a static object. I can't say if that's your case, but check it out.

##### Share on other sites
Hm looks like some experimentation solved it. What I changed was to set position already upon construction of the heightmap by:
	btVector3 pos(0.0f, -100.0f, 0.0f);	btTransform groundTransform;	groundTransform.setIdentity();	groundTransform.setOrigin(pos);	btRigidBody::btRigidBodyConstructionInfo rbInfo(0.0f, NULL, shape, btVector3(0,0,0));	body = new btRigidBody(rbInfo);	body->setWorldTransform(groundTransform);

	btVector3 pos(0.0f, 0.0f, 0.0f);	btTransform groundTransform;	groundTransform.setIdentity();	groundTransform.setOrigin(pos);	btRigidBody::btRigidBodyConstructionInfo rbInfo(0.0f, NULL, shape, btVector3(0,0,0));	body = new btRigidBody(rbInfo);	body->setWorldTransform(groundTransform);	body->translate(tmp2);	body->translate(btVector3(0.0f, -100.0f, 0.0f));

The question now is - why didn't the latter work?

##### Share on other sites
Personally I suggest checking which way your triangles are wound, clockwise or counter clockwise. I've had physics engines behave weird with that in the past.

##### Share on other sites
Quote:
 Original post by all_names_takenThe question now is - why didn't the latter work?

I'm not exactly sure because I'm new to Bullet but I think it is because you would need to specify the body as kinematic

like so

body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);

this will allow you to move it around with the translations

##### Share on other sites
Ah, that makes sense! Moving it around afterwards seemed to only be "sensed" by some parts of the API. I wonder why the API didn't assert() on moving it after construction...

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628350
• Total Posts
2982211

• 10
• 9
• 24
• 11
• 9