Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-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();