Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8182 in orxonox.OLD


Ignore:
Timestamp:
Jun 7, 2006, 11:41:16 AM (18 years ago)
Author:
patrick
Message:

cr: extended the collisionevent and added the interface to the WE

Location:
branches/cr/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cr/src/lib/collision_reaction/collision_event.h

    r8028 r8182  
    1111class WorldEntity;
    1212class BoundingVolume;
     13class Plane;
    1314
    1415
     
    2324  inline void collide(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    2425  { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
     26  /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
     27  inline void collide(WorldEntity* entity, Plane* ground, Vector position)
     28  { this->entityA = entity; this->ground = ground; this->position = position; }
    2529
    2630
     
    3539
    3640
     41  inline void operator()(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) { this->collide(entityA, entityB, bvA, bvB); }
     42  inline void operator()(WorldEntity* entity, Plane* ground, Vector position) { this->collide(entity, ground, position); }
     43
     44
    3745 private:
    3846  WorldEntity*      entityA;                       //!< the collision body A
     
    4149  BoundingVolume*   bvA;                           //!< reference to the bounding volume A
    4250  BoundingVolume*   bvB;                           //!< reference to the bounding volume B
     51
     52  Plane*            ground;                        //!< the ground plane with which it collides (only for bsp-model collisions
     53  Vector            position;                      //!< position of the collision on the ground plane
    4354};
    4455
  • branches/cr/src/world_entities/world_entity.cc

    r8169 r8182  
    368368
    369369/**
    370  * registers a new collision to this world entity
     370 * registers a new collision event to this world entity
    371371 *  @param collisionEvent the event
    372372 */
     
    381381  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    382382  c->collide(entityA, entityB, bvA, bvB);
     383
     384  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
     385    if( this->collisionHandles[i] != NULL)
     386      this->collisionHandles[i]->registerCollisionEvent(c);
     387}
     388
     389
     390/**
     391 * registers a new collision event to this woeld entity
     392 *  @param entity the entity that collides
     393 *  @param plane it stands on
     394 *  @param position it collides on the plane
     395 */
     396bool WorldEntity::registerCollision(WorldEntity* entity, Plane* plane, Vector position)
     397{
     398  // is there any handler listening?
     399  if( !this->bReactive)
     400    return false;
     401
     402  // create a collision event
     403  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
     404  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
     405  c->collide(entity, plane, position);
    383406
    384407  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
  • branches/cr/src/world_entities/world_entity.h

    r8169 r8182  
    2929class CollisionHandle;
    3030class Collision;
     31class Plane;
    3132
    3233
     
    8182
    8283  bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
     84  bool registerCollision(WorldEntity* entity, Plane* plane, Vector position);
    8385  /** @return true if there is at least on collision reaction subscribed */
    8486  inline bool isReactive() const { return this->bReactive; }
Note: See TracChangeset for help on using the changeset viewer.