Sign in to follow this  
all_names_taken

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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);

Instead of:

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 this post


Link to post
Share on other sites
Quote:
Original post by all_names_taken
The 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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this