- Timestamp:
- Jan 1, 2009, 7:34:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/collisionshapes/CollisionShape.cc
r2527 r2562 37 37 #include "tools/BulletConversions.h" 38 38 39 #include "objects/worldentities/WorldEntity.h" 39 40 #include "CompoundCollisionShape.h" 40 #include " objects/worldentities/WorldEntity.h"41 #include "WorldEntityCollisionShape.h" 41 42 42 43 namespace orxonox … … 85 86 void CollisionShape::parentChanged() 86 87 { 87 CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_)); 88 if (parent) 89 parent->attach(this); 88 Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_); 89 // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the 90 // internal collision shape (which is compound) of a WE doesn't get synchronised. 91 CompoundCollisionShape* parentCCS = dynamic_cast<CompoundCollisionShape*>(parent); 92 if (parentCCS) 93 parentCCS->attach(this); 94 else 95 { 96 WorldEntity* parentWE = dynamic_cast<WorldEntity*>(parent); 97 if (parentWE) 98 parentWE->attachCollisionShape(this); 99 } 100 } 101 102 bool CollisionShape::notifyBeingAttached(CompoundCollisionShape* newParent) 103 { 104 if (this->parent_) 105 this->parent_->detach(this); 106 107 this->parent_ = newParent; 108 109 WorldEntityCollisionShape* parentWECCS = dynamic_cast<WorldEntityCollisionShape*>(newParent); 110 if (parentWECCS) 111 this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID(); 112 else 113 this->parentID_ = newParent->getObjectID(); 114 115 return true; 116 } 117 118 void CollisionShape::notifyDetached() 119 { 120 this->parent_ = 0; 121 this->parentID_ = OBJECTID_UNKNOWN; 90 122 } 91 123
Note: See TracChangeset
for help on using the changeset viewer.