Bumpy HeightField

Post Reply
kvagga
Posts: 1
Joined: Thu Apr 24, 2014 2:21 pm

Bumpy HeightField

Post by kvagga »

Hi! We have succesfully created a flat heightfield-terrain and a sphere which we control to roll around on the terrain. But there seems to be a problem, when the sphere reaches a certain speed the sphere starts to bounce. When we create a terrain using btStaticPlaneShape() to get a flat plane the sphere rolls perfectly fine, as expected.

we add our heightfield like below. MyHeightfield is a float array which right now is only filled with zeros.

Code: Select all

	
        btHeightfieldTerrainShape* groundShape = new btHeightfieldTerrainShape(terrain.width, terrain.height, &MyHeightfield, 1, 0, 50, 1, PHY_FLOAT, true);

	btCollisionShape* fallShape = new btSphereShape(1);

	btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(terrain.width / 2, 25, terrain.height / 2)));
	btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0, groundMotionState, groundShape, btVector3(0, 0, 0));
	btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
	groundRigidBody->setRestitution(0.5);
	groundRigidBody->setFriction(10);
	groundRigidBody->setCollisionFlags(groundRigidBody->getCollisionFlags() || btCollisionObject::CF_STATIC_OBJECT);

	dynamicsWorld->addRigidBody(groundRigidBody);

	btDefaultMotionState* fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(10, 10, 30)));

	btScalar mass = 1;
	btVector3 fallInertia(0, 0, 0);
	fallShape->calculateLocalInertia(mass, fallInertia);
	btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass, fallMotionState, fallShape, fallInertia);
	fallRigidBody1 = new btRigidBody(fallRigidBodyCI);
	fallRigidBody1->setRestitution(0.9);
	fallRigidBody1->setFriction(10);
	fallRigidBody1->setActivationState(DISABLE_DEACTIVATION);
	dynamicsWorld->addRigidBody(fallRigidBody1);
Our stepsimulation looks like this

Code: Select all

        dynamicsWorld->stepSimulation(1/60.f, 1);
This is how the ball behaves:
https://www.dropbox.com/s/gltaujhf00c8f ... 804%29.mp4
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Bumpy HeightField

Post by DannyChapman »

It will be collisions with the internal edges of the heightfield.

I don't have the solution immediately to hand, but this will hopefully be enough to get you started - e.g. I'm pretty sure Erwin posted some code a while ago that flags/removes internal edges from a triangle mesh. Not sure how that would be applied to a heightfield though.

If you work it out, please let me know (it's a low-importance problem for my application too!).
Post Reply