- Timestamp:
- Dec 21, 2008, 2:44:00 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/collisionshapes/CollisionShape.cc
r2469 r2514 42 42 namespace orxonox 43 43 { 44 CreateFactory(CollisionShape);45 46 44 CollisionShape::CollisionShape(BaseObject* creator) 47 45 : BaseObject(creator) … … 62 60 CollisionShape::~CollisionShape() 63 61 { 62 // Detach from parent 63 if (this->isInitialized() && this->parent_) 64 this->parent_->removeChildShape(this); 64 65 } 65 66 … … 79 80 void CollisionShape::registerVariables() 80 81 { 81 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged ));82 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChangedCallback)); 82 83 } 83 84 84 85 void CollisionShape::parentChanged() 85 86 { 86 Synchronisable* synchronisable = Synchronisable::getSynchronisable(this->parentID_); 87 CompoundCollisionShape* CCSparent = dynamic_cast<CompoundCollisionShape*>(synchronisable); 88 if (CCSparent) 89 CCSparent->addChildShape(this); 90 else 91 { 92 WorldEntity* WEparent = dynamic_cast<WorldEntity*>(synchronisable); 93 if (WEparent) 94 WEparent->attachCollisionShape(this); 95 } 87 CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_)); 88 if (parent) 89 parent->addChildShape(this); 96 90 } 97 91 … … 118 112 } 119 113 114 void CollisionShape::updateShape() 115 { 116 btCollisionShape* oldShape = this->collisionShape_; 117 this->collisionShape_ = this->createNewShape(); 118 // When we recreate the shape, we have to inform the parent about this to update the shape 119 this->updateParent(); 120 if (oldShape) 121 delete oldShape; 122 } 123 120 124 void CollisionShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const 121 125 {
Note: See TracChangeset
for help on using the changeset viewer.