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-11 19:47:30 +0000
committerStijn Buys <ingar@osirion.org>2012-10-11 19:47:30 +0000
commitb0d67843c43f50f36a92c4b8694b3df380ce50b1 (patch)
treebce9b7e4c30862a411909a96b2d7b298c9e0999f /src/core/entity.cc
parent529e80912f5a62eba69190aadf026a6cf1e27ea4 (diff)
Moved handling of the physics reset for the Docked and Destroyed state from game tp core.
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 46bcd5d..6ae9e87 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -696,9 +696,49 @@ void EntityDynamic::set_state(int state)
void EntityDynamic::reset()
{
+ // no bullet physics on NonSolid entities
if (!radius() || has_flag(NonSolid)) {
return;
}
+
+ // remove Docked and Destroyed entities from the physics simulation
+ if ((state() == core::Entity::Docked) || (state() == core::Entity::Destroyed)) {
+
+ if (entity_body) {
+
+ if (entity_motionstate) {
+ delete entity_motionstate;
+ entity_motionstate = 0;
+ }
+
+ if (zone() && zone()->physics()) {
+ entity_zone->physics()->removeRigidBody(body());
+ }
+
+ if (entity_collision_shape) {
+ delete entity_collision_shape;
+ entity_collision_shape = 0;
+ }
+
+ for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) {
+ delete (*sit);
+ (*sit) = 0;
+ }
+ entity_collision_child_shapes.clear();
+
+ if (entity_body) {
+ delete entity_body;
+ entity_body = 0;
+ }
+
+ if (entity_body_info) {
+ delete entity_body_info;
+ entity_body_info = 0;
+ }
+ }
+
+ return;
+ }
// location and orientation
btTransform t;
@@ -1182,10 +1222,55 @@ void EntityControlable::set_zone(Zone *zone)
void EntityControlable::reset()
{
+ // no bullet physics on NonSolid entities
if (!radius() || has_flag(NonSolid)) {
return;
}
+ // remove Docked and Destroyed entities from the physics simulation
+ if ((state() == core::Entity::Docked) || (state() == core::Entity::Destroyed)) {
+
+ if (entity_body) {
+
+ if (entity_motionstate) {
+ delete entity_motionstate;
+ entity_motionstate = 0;
+ }
+
+ if (zone() && zone()->physics()) {
+ if (entity_actioninterface) {
+ entity_zone->physics()->removeAction(entity_actioninterface);
+ delete entity_actioninterface;
+ entity_actioninterface = 0;
+ }
+ entity_zone->physics()->removeRigidBody(body());
+ }
+
+ if (entity_collision_shape) {
+ delete entity_collision_shape;
+ entity_collision_shape = 0;
+ }
+
+ for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) {
+ delete (*sit);
+ (*sit) = 0;
+ }
+ entity_collision_child_shapes.clear();
+
+ if (entity_body) {
+ delete entity_body;
+ entity_body = 0;
+ }
+
+ if (entity_body_info) {
+ delete entity_body_info;
+ entity_body_info = 0;
+ }
+ }
+
+ return;
+ }
+
// location and orientation
btTransform t;
t.setIdentity();