Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9893 in orxonox.OLD for branches/coll_rect/src/lib


Ignore:
Timestamp:
Oct 19, 2006, 3:37:40 PM (18 years ago)
Author:
patrick
Message:

collision reactions now only registered with collision tube. no compile

Location:
branches/coll_rect/src/lib/collision_reaction
Files:
6 edited

Legend:

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

    r9892 r9893  
    108108    this->targetList.push_back(target);
    109109    PRINTF(5)("addTarget: %i \n", target.id());
    110   }
    111 
    112 
    113   /**
    114    * registers a new Collision Object
    115    *  @param entityA WorldEntity A of the collision
    116    *  @param entityB WorldEntity B of the collision
    117    * if a there is already a collision object with the same stats
    118    * registration will be skipped and the last collision object is returned
    119    */
    120   Collision* CollisionHandle::registerCollision(WorldEntity* entityA, WorldEntity* entityB)
    121   {
    122     //first get the collision object, multiple sources
    123     Collision* c;
    124     if( this->collisionList.empty() ||
    125         ((this->collisionList.back())->getEntityA() != entityA && (this->collisionList.back())->getEntityB() != entityB ))
    126     {
    127       c = CREngine::getInstance()->popCollisionObject();
    128       c->collide(entityA, entityB);
    129       this->collisionList.push_back(c);
    130 
    131       // now register it as a shared collision with the other collision entity
    132       CollisionHandle* ch = entityB->getCollisionHandle(this->type);
    133       if( ch != NULL)
    134         ch->registerSharedCollision(c);
    135     }
    136     else
    137       c = this->collisionList.back();
    138 
    139     return c;
    140   }
    141 
    142 
    143   /**
    144    * register a Collision to the Collision handle.
    145    *  @param collision the collision object to register
    146    *
    147    * This is used for internal collision registration: sharing the collision objects between Collision Reactions
    148    * Therefore dispatching it only once
    149    */
    150   void CollisionHandle::registerSharedCollision(Collision* collision)
    151   {
    152     // fist check if we are listening for this Collision
    153     if( !this->filterCollision(collision))
    154       return;
    155 
    156     // set the state to not dispatched
    157     this->bDispatched = false;
    158     this->bCollided = true;
    159     collision->setEntityBCollide(true);
    160 
    161     this->collisionList.push_back(collision);
    162   }
    163 
    164 
    165   /**
    166    * this is the function to be called on a collision event for this handle
    167    *  @param collision the collision objects containing all collision informations
    168    */
    169   void CollisionHandle::registerCollisionEvent(CollisionEvent* collisionEvent)
    170   {
    171     if( !this->filterCollisionEvent(collisionEvent))
    172       return;
    173 
    174     // set the state to not dispatched
    175     this->bDispatched = false;
    176     this->bCollided = true;
    177 
    178     // checks if these WorldEntities have already collided or if its a new collision -> create a new Collision object
    179     Collision* c = this->registerCollision(collisionEvent->getEntityA(), collisionEvent->getEntityB());
    180     c->setEntityACollide(true);
    181 
    182     c->registerCollisionEvent(collisionEvent);
    183     PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassCName(), collisionEvent->getEntityB()->getClassCName());
    184   }
    185 
    186 
    187   /**
    188    * flushes the collision list
    189    */
    190   void CollisionHandle::flushCollisions()
    191   {
    192     this->collisionList.clear();
    193110  }
    194111
  • branches/coll_rect/src/lib/collision_reaction/collision_handle.h

    r9892 r9893  
    3636
    3737    void addTarget(const ClassID& target);
    38     Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);
    39     void registerSharedCollision(Collision* collision);
    40     void registerCollisionEvent(CollisionEvent* collisionEvent);
    4138
    4239    /** @returns true if regiestered some new collision events in this tick frame */
  • branches/coll_rect/src/lib/collision_reaction/collision_tube.cc

    r9892 r9893  
    6767
    6868    // check if there is already a collision defined between these objects
    69     if( collision->match(*entityA, *entityB))
     69    if( !collision->match(*entityA, *entityB))
    7070    {
    71       CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
    72       collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
    73       collision->registerCollisionEvent( collisionEvent);
     71      collision = CREngine::getInstance()->popCollisionObject();
     72      collision->collide( entityA, entityB);
    7473    }
     74
     75    // now register the new collision event
     76    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
     77    collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
     78    collision->registerCollisionEvent( collisionEvent);
    7579  }
    7680
     
    8589   * @param bInWall true if the entity is in the ground material
    8690   */
    87   void CollisionTube::registerCollisionEvent(int type, WorldEntity* entity, WorldEntity* groundEntity,
     91  void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity,
    8892                              const Vector& normal, const Vector& position, bool bInWall)
    8993  {
    90     //
     94    Collision* collision = this->_collisionList.back();
     95
     96    // check if there is already a collision defined between these objects
     97    if( !collision->match(*entity, *groundEntity))
     98    {
     99      collision = CREngine::getInstance()->popCollisionObject();
     100      collision->collide( entity, groundEntity);
     101    }
     102
     103    // now register the new collision event
     104    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
     105    collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall);
     106    collision->registerCollisionEvent( collisionEvent);
    91107  }
     108
     109
     110  /**
     111   * checks if two objects are
     112   */
     113  bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB)
     114  {
     115    //if( !this->isReactive( entityA, entityB) )
     116    //  return false;
     117
     118    //if( entityA->)
     119
     120  }
     121
    92122
    93123  /**
  • branches/coll_rect/src/lib/collision_reaction/collision_tube.h

    r9892 r9893  
    5656    inline bool isReactive(const WorldEntity& entityA, const WorldEntity& entityB) const
    5757    { return (entityA.isReactive() && entityB.isReactive()); }
     58    bool needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB);
    5859
    5960    void registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    60     void registerCollisionEvent(int type, WorldEntity* entity, WorldEntity* groundEntity,
     61    void registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity,
    6162                                const Vector& normal, const Vector& position, bool bInWall = false);
    6263
  • branches/coll_rect/src/lib/collision_reaction/cr_defs.h

    r9892 r9893  
    2828
    2929
    30 //!< the collision axis x collision event
    31 #define COLLISION_TYPE_AXIS_X      1
    32 #define COLLISION_TYPE_AXIS_X_NEG  2
    33 //!< the collision axis y collision event
    34 #define COLLISION_TYPE_AXIS_Y      3
    35 #define COLLISION_TYPE_AXIS_Y_NEG  4
    36 //!< the collision axis z collision event
    37 #define COLLISION_TYPE_AXIS_Z      5
    38 #define COLLISION_TYPE_AXIS_Z_NEG  6
    39 //!< the collision is a obb collision
    40 #define COLLISION_TYPE_OBB         8
    41 
    4230
    4331#endif /* _NETWORK_MANAGER */
  • branches/coll_rect/src/lib/collision_reaction/cr_engine.cc

    r9892 r9893  
    123123  {
    124124    // first clear all CollisionHandles
    125 
    126125    std::vector<CollisionHandle*>::iterator it = this->collisionHandles.begin();
    127126    for(; it < this->collisionHandles.end(); it++)
Note: See TracChangeset for help on using the changeset viewer.