Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2008, 4:33:50 PM (15 years ago)
Author:
rgrieder
Message:

Added callback for collisions. Every WorldEntity that collides against another will be called with the following function:
virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
btManifoldPoint is from Bullet and tells you more about the contact point, like position.

Per default, the callback is disabled. Enable it with this→enableCollisionCallback(), for instance in your derived class constructor.
Note that if you activate the callback for e.g. SpaceShips, but not for MovableEntities, then collidesAgainst will only be called in the SpaceShip. This could be changed however, just ask me.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h

    r2459 r2466  
    240240            void notifyChildMassChanged();
    241241
     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
    242252        protected:
    243253            virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
     
    253263            void collisionTypeChanged();
    254264            void physicsActivityChanged();
     265            void collisionCallbackActivityChanged();
    255266            inline void massChanged()
    256267                { this->setMass(this->mass_); }
     
    279290            btScalar                     friction_;
    280291            btScalar                     childrenMass_;
     292            bool                         bCollisionCallbackActive_;
    281293    };
    282294
Note: See TracChangeset for help on using the changeset viewer.