Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2006, 2:24:40 PM (17 years ago)
Author:
patrick
Message:

removed many very heavy segfaults

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/coll_rect/src/lib/collision_reaction/collision_tube.cc

    r9995 r10006  
    2727#include "cr_physics_full_walk.h"
    2828
     29#include "debug.h"
    2930
    3031
     
    5253  CollisionTube::~CollisionTube ()
    5354  {
     55    this->reset();
     56  }
     57
     58
     59
     60  /**
     61   * resets the collision tube after each collision detection cycle
     62   */
     63  void CollisionTube::reset()
     64  {
    5465    this->_collisionList.clear();
     66  }
     67
     68
     69  /**
     70   * gets the collision object useable for collision events registarations
     71   * @param entityA collision partner 1
     72   * @param entityB collision partner 2
     73   * @return the collision object to be used
     74   */
     75  Collision* CollisionTube::registerCollision(WorldEntity* entityA, WorldEntity* entityB)
     76  {
     77    assert( entityA != NULL && entityB != NULL);
     78
     79    Collision* collision = NULL;
     80    if( !this->_collisionList.empty())
     81      collision = this->_collisionList.back();
     82
     83    // check if there is already a collision defined between these objects or this is the first collision at all
     84    if( collision == NULL || !collision->same(*entityA, *entityB))
     85    {
     86      collision = CREngine::getInstance()->popCollisionObject();
     87      collision->collide( entityA, entityB);
     88      this->_collisionList.push_back(collision);
     89    }
     90
     91    return collision;
    5592  }
    5693
     
    67104  void CollisionTube::registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    68105  {
    69     Collision* collision = NULL;
    70     if( !this->_collisionList.empty())
    71       collision = this->_collisionList.back();
    72 
    73     // check if there is already a collision defined between these objects or this is the first collision at all
    74     if( collision == NULL || !collision->match(*entityA, *entityB))
    75     {
    76       collision = CREngine::getInstance()->popCollisionObject();
    77       collision->collide( entityA, entityB);
    78     }
     106    // first get a useable collision object
     107    Collision* collision = this->registerCollision(entityA, entityB);
    79108
    80109    // now register the new collision event
     
    95124   */
    96125  void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity,
    97                               const Vector& normal, const Vector& position, bool bInWall)
     126      const Vector& normal, const Vector& position, bool bInWall)
    98127  {
    99     // get last collision
    100     Collision* collision = NULL;
    101     if( !this->_collisionList.empty())
    102       collision = this->_collisionList.back();
    103 
    104     // check if there is already a collision defined between these objects
    105     if( collision == NULL || !collision->match(*entity, *groundEntity))
    106     {
    107       // get a new collision object
    108       collision = CREngine::getInstance()->popCollisionObject();
    109       collision->collide( entity, groundEntity);
    110     }
     128    // first get a useable collision object
     129    Collision* collision = this->registerCollision(entity, groundEntity);
    111130
    112131    // now register the new collision event
Note: See TracChangeset for help on using the changeset viewer.