Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-10 21:27:41 +0000
committerStijn Buys <ingar@osirion.org>2012-10-10 21:27:41 +0000
commit05c560e7b9f508997a7c7c5e466329692796dab4 (patch)
treee427006ef35f23cb1ef987442b496e4eb2622aca /src/core/entity.cc
parent8a6f3d478c825d226a21b73f5bcec2b92bf31ccb (diff)
Provided bullet physics collision callback methods.
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 1b879f3..46bcd5d 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -646,6 +646,7 @@ void Entity::reset()
//entity_body->setActivationState(ISLAND_SLEEPING);
entity_body->setActivationState(WANTS_DEACTIVATION);
entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
+ entity_body->setUserPointer((void *) this);
if (zone())
zone()->physics()->addRigidBody(entity_body);
@@ -779,6 +780,10 @@ void EntityDynamic::reset()
// create physics body
entity_body_info = new btRigidBody::btRigidBodyConstructionInfo(entity_mass, entity_motionstate, entity_collision_shape, inertia);
entity_body = new btRigidBody(*entity_body_info);
+ // point the bullet user pointer to the entity
+ entity_body->setUserPointer((void *) this);
+ // enable custom collision callback
+ entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
if (entity_mass) {
entity_body->setActivationState(DISABLE_DEACTIVATION);
@@ -800,6 +805,9 @@ void EntityDynamic::reset()
motionstate()->setWorldTransform(t);
}
+ /* Does not work
+
+
if (entity_mass) {
if (entity_state == Docked) {
entity_body->setActivationState(DISABLE_SIMULATION);
@@ -809,6 +817,7 @@ void EntityDynamic::reset()
entity_body->setActivationState(DISABLE_DEACTIVATION);
}
}
+ */
set_dirty();
}
@@ -845,6 +854,10 @@ void EntityDynamic::frame(const unsigned long elapsed)
}
}
+void EntityDynamic::collision(Entity *other)
+{
+}
+
void EntityDynamic::serialize_server_create(std::ostream & os) const
{
Entity::serialize_server_create(os);
@@ -1253,6 +1266,11 @@ void EntityControlable::reset()
entity_body_info = new btRigidBody::btRigidBodyConstructionInfo(entity_mass, entity_motionstate, entity_collision_shape, inertia);
entity_body = new btRigidBody(*entity_body_info);
entity_body->setActivationState(DISABLE_DEACTIVATION);
+ // point the bullet user pointer to the entity
+ entity_body->setUserPointer((void *) this);
+ // enable custom collision callback
+ entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
+
//entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
entity_actioninterface = new ActionInterface(this);
@@ -1269,6 +1287,8 @@ void EntityControlable::reset()
body()->setWorldTransform(t);
motionstate()->setWorldTransform(t);
+ /* Does not work
+
if (entity_state == Docked) {
entity_body->setActivationState(DISABLE_SIMULATION);
entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
@@ -1276,7 +1296,7 @@ void EntityControlable::reset()
entity_body->setActivationState(DISABLE_DEACTIVATION);
entity_body->setCollisionFlags(entity_body->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
-
+ */
set_dirty();
}