mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
using an infinite plane for the ground
This commit is contained in:
parent
85e7c6166b
commit
d6c97be78e
1 changed files with 12 additions and 13 deletions
|
@ -147,22 +147,21 @@ void PhysicsEngine::init() {
|
|||
// TODO: set up gravity zones
|
||||
_dynamicsWorld->setGravity(btVector3(0.0f, 0.0f, 0.0f));
|
||||
|
||||
// GROUND HACK: In the meantime we add a big planar floor to catch falling objects
|
||||
// NOTE: we don't care about memory leaking groundShape and groundObject -->
|
||||
// they'll exist until the executable exits.
|
||||
const float halfSide = 200.0f;
|
||||
const float halfHeight = 1.0f;
|
||||
|
||||
btCollisionShape* groundShape = new btBoxShape(btVector3(halfSide, halfHeight, halfSide));
|
||||
// GROUND HACK: add a big planar floor (and walls for testing) to catch falling objects
|
||||
btTransform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setOrigin(btVector3(halfSide, -halfHeight, halfSide));
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
btVector3 normal(0.0f, 0.0f, 0.0f);
|
||||
normal[i] = 1.0f;
|
||||
btCollisionShape* plane = new btStaticPlaneShape(normal, 0.0f);
|
||||
|
||||
btCollisionObject* groundObject = new btCollisionObject();
|
||||
groundObject->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
|
||||
groundObject->setCollisionShape(groundShape);
|
||||
groundObject->setWorldTransform(groundTransform);
|
||||
_dynamicsWorld->addCollisionObject(groundObject);
|
||||
btCollisionObject* groundObject = new btCollisionObject();
|
||||
groundObject->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
|
||||
groundObject->setCollisionShape(plane);
|
||||
|
||||
groundObject->setWorldTransform(groundTransform);
|
||||
_dynamicsWorld->addCollisionObject(groundObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue