- Timestamp:
- Feb 28, 2015, 11:55:18 PM (10 years ago)
- Location:
- code/trunk/src/orxonox/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r10274 r10288 98 98 this->collisionType_ = None; 99 99 this->collisionTypeSynchronised_ = None; 100 this->mass_ = 1.0f;101 this->childrenMass_ = 0;100 this->mass_ = 1.0f; 101 this->childrenMass_ = 0; 102 102 // Using bullet default values 103 this->restitution_ = 0; 104 this->angularFactor_ = 1; 105 this->linearDamping_ = 0; 106 this->angularDamping_ = 0; 107 this->friction_ = 0.5; 103 this->restitution_ = 0; 104 this->angularFactor_ = 1; 105 this->linearDamping_ = 0; 106 this->angularDamping_ = 0; 107 this->friction_ = 0.5; 108 this->ccdMotionThreshold_ = 0.0; 109 this->ccdSweptSphereRadius_ = 0.0; 108 110 this->bCollisionCallbackActive_ = false; 109 111 this->bCollisionResponseActive_ = true; … … 198 200 registerVariable(this->angularDamping_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged)); 199 201 registerVariable(this->friction_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged)); 202 registerVariable(this->ccdMotionThreshold_, 203 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::ccdMotionThresholdChanged)); 204 registerVariable(this->ccdSweptSphereRadius_, 205 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::ccdSweptSphereRadiusChanged)); 200 206 registerVariable(this->bCollisionCallbackActive_, 201 207 VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged)); … … 1003 1009 this->physicalBody_->setDamping(this->linearDamping_, this->angularDamping_); 1004 1010 this->physicalBody_->setFriction(this->friction_); 1011 this->physicalBody_->setCcdMotionThreshold(this->ccdMotionThreshold_); 1012 this->physicalBody_->setCcdSweptSphereRadius(this->ccdSweptSphereRadius_); 1005 1013 } 1006 1014 } -
code/trunk/src/orxonox/worldentities/WorldEntity.h
r10216 r10288 355 355 { return this->friction_; } 356 356 357 /** 358 * Sets the motion threshold for continuous collision detection (CCD). This should be activated if an object moves further in one tick than its own 359 * size. This means that in one tick the object may be in front of a wall and in the next tick it will be behind the wall without ever triggering a 360 * collision. CCD ensures that collisions are still detected. By default it is deactivated (threshold = 0) which is fine for slow or static 361 * objects, but it should be set to a real value for fast moving objects (e.g. projectiles). 362 * 363 * A good value for the threshold is (diameter^2). 364 * 365 * @param ccdMotionThreshold CCD is enabled if the squared velocity of the object is > ccdMotionThreshold (default 0.0). 0.0 means deactivated. 366 */ 367 inline void setCcdMotionThreshold(float ccdMotionThreshold) 368 { this->ccdMotionThreshold_ = ccdMotionThreshold; internalSetPhysicsProps(); } 369 //! Returns the currently used motion threshold for CCD (0 means CCD is deactivated). 370 inline float getCcdMotionThreshold() const 371 { return this->ccdMotionThreshold_; } 372 373 /** 374 * Sets the radius of the sphere which is used for continuous collision detection (CCD). The sphere should be embedded inside the objects collision 375 * shape, preferably smaller. @see setCcdMotionThreshold for more information about CCD. 376 * 377 * A good value for the radius is (diameter/5). 378 * 379 * @param ccdSweptSphereRadius The diameter of the sphere which is used for CCD (default 0.0). 380 */ 381 inline void setCcdSweptSphereRadius(float ccdSweptSphereRadius) 382 { this->ccdSweptSphereRadius_ = ccdSweptSphereRadius; internalSetPhysicsProps(); } 383 //! Returns the currently used radius of the sphere for CCD. 384 inline float getCcdSweptSphereRadius() const 385 { return this->ccdSweptSphereRadius_; } 386 357 387 void attachCollisionShape(CollisionShape* shape); 358 388 void detachCollisionShape(CollisionShape* shape); … … 438 468 inline void frictionChanged() 439 469 { this->setFriction(this->friction_); } 470 //! Network callback workaround to call a function when the value changes. 471 inline void ccdMotionThresholdChanged() 472 { this->setCcdMotionThreshold(this->ccdMotionThreshold_); } 473 //! Network callback workaround to call a function when the value changes. 474 inline void ccdSweptSphereRadiusChanged() 475 { this->setCcdSweptSphereRadius(this->ccdSweptSphereRadius_); } 440 476 441 477 CollisionType collisionType_; //!< @see setCollisionType … … 454 490 btScalar friction_; //!< @see setFriction 455 491 btScalar childrenMass_; //!< Sum of all the children's masses 492 btScalar ccdMotionThreshold_; //!< @see setCcdMotionThreshold 493 btScalar ccdSweptSphereRadius_; //!< @see setCcdSweptSphereRadius 456 494 bool bCollisionCallbackActive_; //!< @see enableCollisionCallback 457 495 bool bCollisionResponseActive_; //!< Tells whether the object should respond to collisions
Note: See TracChangeset
for help on using the changeset viewer.