Changeset 2469
- Timestamp:
- Dec 15, 2008, 7:57:48 PM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/collisionshapes/CollisionShape.cc
r2459 r2469 38 38 39 39 #include "CompoundCollisionShape.h" 40 #include "objects/worldentities/WorldEntity.h" 40 41 41 42 namespace orxonox … … 55 56 this->orientation_ = Quaternion::IDENTITY; 56 57 this->scale_ = Vector3::UNIT_SCALE; 58 59 this->registerVariables(); 57 60 } 58 61 … … 81 84 void CollisionShape::parentChanged() 82 85 { 83 CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_)); 84 if (parent) 85 parent->addChildShape(this); 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 } 86 96 } 87 97 -
code/branches/presentation/src/orxonox/objects/collisionshapes/CompoundCollisionShape.cc
r2463 r2469 47 47 48 48 this->compoundShape_ = new btCompoundShape(); 49 this->worldEntityParent_ = 0; 49 50 } 50 51 … … 66 67 } 67 68 69 void CompoundCollisionShape::setWorldEntityParent(WorldEntity* parent) 70 { 71 // suppress synchronisation 72 this->setObjectMode(0x0); 73 74 this->worldEntityParent_ = parent; 75 } 76 68 77 void CompoundCollisionShape::addChildShape(CollisionShape* shape) 69 78 { … … 87 96 88 97 // network synchro 89 shape->setParent(this, this->getObjectID()); 98 if (this->worldEntityParent_) 99 { 100 // This compound collision shape belongs to a WE and doesn't get synchronised 101 // So set our parent to be the WE 102 shape->setParent(this, this->worldEntityParent_->getObjectID()); 103 } 104 else 105 shape->setParent(this, this->getObjectID()); 90 106 } 91 107 … … 176 192 if (this->parent_) 177 193 this->parent_->updateChildShape(this); 178 else 179 { 180 // We can do this, because the CompoundCollisionShape of a WorldEntity always belongs to it, 181 // as long as its lifetime. 182 WorldEntity* parent = dynamic_cast<WorldEntity*>(this->getCreator()); 183 if (parent) 184 parent->notifyCollisionShapeChanged(); 185 } 194 else if (this->worldEntityParent_) 195 this->worldEntityParent_->notifyCollisionShapeChanged(); 186 196 } 187 197 -
code/branches/presentation/src/orxonox/objects/collisionshapes/CompoundCollisionShape.h
r2465 r2469 52 52 void updateChildShape(CollisionShape* shape); 53 53 54 inline void suppressSynchronisation() 55 { this->setObjectMode(0x0); } 54 void setWorldEntityParent(WorldEntity* parent); 56 55 57 56 protected: … … 63 62 btCompoundShape* compoundShape_; 64 63 std::map<CollisionShape*, btCollisionShape*> childShapes_; 64 WorldEntity* worldEntityParent_; 65 65 }; 66 66 } -
code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.cc
r2459 r2469 51 51 this->angularAcceleration_ = Vector3::ZERO; 52 52 this->angularVelocity_ = Vector3::ZERO; 53 54 this->registerVariables(); 53 55 } 54 56 -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2466 r2469 74 74 // Note: CompoundCollisionShape is a Synchronisable, but must not be synchronised. 75 75 // All objects will get attached on the client anyway, so we don't need synchronisation. 76 this->collisionShape_->s uppressSynchronisation();76 this->collisionShape_->setWorldEntityParent(this); 77 77 this->collisionType_ = None; 78 78 this->collisionTypeSynchronised_ = None; … … 459 459 void WorldEntity::setScale3D(const Vector3& scale) 460 460 { 461 if (this->hasPhysics() )461 if (this->hasPhysics() && scale != Vector3::UNIT_SCALE) 462 462 { 463 463 CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented." << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.