Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 28, 2015, 11:55:18 PM (9 years ago)
Author:
landauf
Message:

added bullet settings for CCD (continuous collision detection) to WorldEntity. initially I thought we need this to avoid the tunneling effect of projectiles at low FPS, but now it turns out that this gets also fixed if projectiles use dynamic physics. I still add the new settings to WorldEntity because we may still need them for very fast objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/worldentities/WorldEntity.h

    r10216 r10288  
    355355                { return this->friction_; }
    356356
     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
    357387            void attachCollisionShape(CollisionShape* shape);
    358388            void detachCollisionShape(CollisionShape* shape);
     
    438468            inline void frictionChanged()
    439469                { 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_); }
    440476
    441477            CollisionType                collisionType_;                 //!< @see setCollisionType
     
    454490            btScalar                     friction_;                      //!< @see setFriction
    455491            btScalar                     childrenMass_;                  //!< Sum of all the children's masses
     492            btScalar                     ccdMotionThreshold_;            //!< @see setCcdMotionThreshold
     493            btScalar                     ccdSweptSphereRadius_;          //!< @see setCcdSweptSphereRadius
    456494            bool                         bCollisionCallbackActive_;      //!< @see enableCollisionCallback
    457495            bool                         bCollisionResponseActive_;      //!< Tells whether the object should respond to collisions
Note: See TracChangeset for help on using the changeset viewer.