- Timestamp:
- Dec 15, 2008, 4:33:50 PM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects/worldentities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2465 r2466 85 85 this->angularDamping_ = 0; 86 86 this->friction_ = 0.5; 87 this->bCollisionCallbackActive_ = false; 87 88 88 89 this->registerVariables(); … … 144 145 registerVariable(this->getScale3D(), variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged)); 145 146 146 registerVariable((int&)this->collisionTypeSynchronised_, 147 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); 147 // Physics stuff 148 148 registerVariable(this->mass_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged)); 149 149 registerVariable(this->restitution_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged)); … … 152 152 registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged)); 153 153 registerVariable(this->friction_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged)); 154 registerVariable(this->bCollisionCallbackActive_, 155 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged)); 156 registerVariable((int&)this->collisionTypeSynchronised_, 157 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); 154 158 registerVariable(this->bPhysicsActiveSynchronised_, 155 159 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged)); 156 160 161 // Attach to parent if necessary 157 162 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged)); 158 163 } … … 192 197 else 193 198 this->deactivatePhysics(); 199 } 200 201 void WorldEntity::collisionCallbackActivityChanged() 202 { 203 if (this->hasPhysics()) 204 { 205 if (bCollisionCallbackActive_) 206 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() | 207 btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 208 else 209 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & 210 !btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 211 } 194 212 } 195 213 … … 525 543 recalculateMassProps(); 526 544 resetPhysicsProps(); 545 collisionCallbackActivityChanged(); 527 546 activatePhysics(); 528 547 } -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h
r2459 r2466 240 240 void notifyChildMassChanged(); 241 241 242 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 243 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 244 245 inline void enableCollisionCallback() 246 { this->bCollisionCallbackActive_ = true; this->collisionCallbackActivityChanged(); } 247 inline void disableCollisionCallback() 248 { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); } 249 inline bool isCollisionCallbackActive() 250 { return this->bCollisionCallbackActive_; } 251 242 252 protected: 243 253 virtual bool isCollisionTypeLegal(CollisionType type) const = 0; … … 253 263 void collisionTypeChanged(); 254 264 void physicsActivityChanged(); 265 void collisionCallbackActivityChanged(); 255 266 inline void massChanged() 256 267 { this->setMass(this->mass_); } … … 279 290 btScalar friction_; 280 291 btScalar childrenMass_; 292 bool bCollisionCallbackActive_; 281 293 }; 282 294 -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2463 r2466 61 61 // Be aware of this call: The collision type legality check will not reach derived classes! 62 62 this->setCollisionType(WorldEntity::Dynamic); 63 // Get notification about collisions 64 this->enableCollisionCallback(); 63 65 64 66 this->setConfigValues();
Note: See TracChangeset
for help on using the changeset viewer.