Changeset 2565
- Timestamp:
- Jan 4, 2009, 4:32:33 PM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2563 r2565 91 91 this->friction_ = 0.5; 92 92 this->bCollisionCallbackActive_ = false; 93 this->bCollisionResponseActive_ = true; 93 94 94 95 this->registerVariables(); … … 139 140 140 141 // Physics 141 XMLPortParam(WorldEntity, "collisionType", setCollisionTypeStr, getCollisionTypeStr, xmlelement, mode); 142 XMLPortParam(WorldEntity, "mass", setMass, getMass, xmlelement, mode); 143 XMLPortParam(WorldEntity, "restitution", setRestitution, getRestitution, xmlelement, mode); 144 XMLPortParam(WorldEntity, "angularFactor", setAngularFactor, getAngularFactor, xmlelement, mode); 145 XMLPortParam(WorldEntity, "linearDamping", setLinearDamping, getLinearDamping, xmlelement, mode); 146 XMLPortParam(WorldEntity, "angularDamping", setAngularDamping, getAngularDamping, xmlelement, mode); 147 XMLPortParam(WorldEntity, "friction", setFriction, getFriction, xmlelement, mode); 142 XMLPortParam(WorldEntity, "collisionType", setCollisionTypeStr, getCollisionTypeStr, xmlelement, mode); 143 XMLPortParam(WorldEntity, "collisionResponse", setCollisionResponse, hasCollisionResponse, xmlelement, mode); 144 XMLPortParam(WorldEntity, "mass", setMass, getMass, xmlelement, mode); 145 XMLPortParam(WorldEntity, "restitution", setRestitution, getRestitution, xmlelement, mode); 146 XMLPortParam(WorldEntity, "angularFactor", setAngularFactor, getAngularFactor, xmlelement, mode); 147 XMLPortParam(WorldEntity, "linearDamping", setLinearDamping, getLinearDamping, xmlelement, mode); 148 XMLPortParam(WorldEntity, "angularDamping", setAngularDamping, getAngularDamping, xmlelement, mode); 149 XMLPortParam(WorldEntity, "friction", setFriction, getFriction, xmlelement, mode); 148 150 149 151 // Other attached WorldEntities … … 171 173 registerVariable(this->bCollisionCallbackActive_, 172 174 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged)); 175 registerVariable(this->bCollisionResponseActive_, 176 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged)); 173 177 registerVariable((int&)this->collisionTypeSynchronised_, 174 178 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); … … 253 257 } 254 258 255 //! Function is called to set the right flags in Bullet (if there is physics at all)259 //! Function sets whether Bullet should issue a callback on collisions 256 260 void WorldEntity::collisionCallbackActivityChanged() 257 261 { 258 262 if (this->hasPhysics()) 259 263 { 260 if ( bCollisionCallbackActive_)264 if (this->bCollisionCallbackActive_) 261 265 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() | 262 266 btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); … … 264 268 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & 265 269 ~btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 270 } 271 } 272 273 //! Function sets whether Bullet should react itself to a collision 274 void WorldEntity::collisionResponseActivityChanged() 275 { 276 if (this->hasPhysics()) 277 { 278 if (this->bCollisionResponseActive_) 279 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & 280 ~btCollisionObject::CF_NO_CONTACT_RESPONSE); 281 else 282 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() | 283 btCollisionObject::CF_NO_CONTACT_RESPONSE); 266 284 } 267 285 } … … 759 777 internalSetPhysicsProps(); 760 778 collisionCallbackActivityChanged(); 779 collisionResponseActivityChanged(); 761 780 if (bReactivatePhysics) 762 781 activatePhysics(); -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h
r2562 r2565 343 343 inline void disableCollisionCallback() 344 344 { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); } 345 //! Tells whether there could be a collision responsevia collidesAgainst(.)345 //! Tells whether there could be a collision callback via collidesAgainst(.) 346 346 inline bool isCollisionCallbackActive() const 347 347 { return this->bCollisionCallbackActive_; } 348 349 //! Enables or disables collision response (default is of course on) 350 inline void setCollisionResponse(bool value) 351 { this->bCollisionResponseActive_ = value; this->collisionResponseActivityChanged(); } 352 //! Tells whether there could be a collision response 353 inline bool hasCollisionResponse() 354 { return this->bCollisionResponseActive_; } 348 355 349 356 protected: … … 373 380 void physicsActivityChanged(); 374 381 void collisionCallbackActivityChanged(); 382 void collisionResponseActivityChanged(); 375 383 //! Network callback workaround to call a function when the value changes. 376 384 inline void massChanged() … … 408 416 btScalar childrenMass_; //!< Sum of all the children's masses 409 417 bool bCollisionCallbackActive_; //!< @see enableCollisionCallback 418 bool bCollisionResponseActive_; //!< Tells whether the object should respond to collisions 410 419 }; 411 420
Note: See TracChangeset
for help on using the changeset viewer.