Jump to content
  • Advertisement
Sign in to follow this  
all_names_taken

Bullet - Things fall through my heightmap!

This topic is 3095 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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 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
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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!