Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2006, 1:25:47 AM (18 years ago)
Author:
patrick
Message:

new interface to collision registers, more transparent. some more functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/coll_rect/src/lib/collision_reaction/cr_engine.h

    r9889 r9892  
    3131
    3232  public:
    33     typedef enum CRType {
    34       CR_PHYSICS_MOMENTUM   = 0,    //!< physical reaction: conservervation of momentum
    35       CR_PHYSICS_STEP_BACK,         //!< physical reaction: just go to the last position without collisions
    36       CR_PHYSICS_GROUND_WALK,       //!< physical reaction: stand on the ground, no movement: simulating simple normal force away from the gravity force
    37       CR_PHYSICS_FULL_WALK,         //!< physical reaction: walking on the ground (inkl. hills etc)
    38       CR_PHYSICS_DAMAGE,            //!< physical reaction: daling damage according to the object energy and their structural stability
     33    typedef enum ReactionType {
     34      CR_PHYSICS_MOMENTUM   = 0,           //!< physical reaction: conservervation of momentum
     35      CR_PHYSICS_STEP_BACK,                //!< physical reaction: just go to the last position without collisions
     36      CR_PHYSICS_GROUND_WALK,              //!< physical reaction: stand on the ground, no movement: simple normal force away from the gravity force
     37      CR_PHYSICS_FULL_WALK,                //!< physical reaction: walking on the ground (inkl. hills etc)
     38      CR_PHYSICS_DAMAGE,                   //!< physical reaction: daling damage according to the object energy and their structural stability
    3939
    40       CR_OBJECT_DAMAGE,             //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.)
    41       CR_OBJECT_PICKUP,             //!< object rection: calling the objects pickup functions, let them handle the collision (once!)
     40      CR_OBJECT_DAMAGE,                    //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.)
     41      CR_OBJECT_PICKUP,                    //!< object rection: calling the objects pickup functions, let them handle the collision (once!)
    4242
    43       CR_VERTEX_TRAFO,              //!< vertex trafo: transforming the vertex according to the damage
     43      CR_VERTEX_TRAFO,                     //!< vertex trafo: transforming the vertex according to the damage
    4444
    45       CR_SPECIAL_CALLBACK,          //!< special: call a callback function
     45      CR_SPECIAL_CALLBACK,                 //!< special: call a callback function
    4646
    4747      CR_NUMBER
    4848    };
     49
     50    typedef enum CollisionType {
     51      CR_COLLISION_TYPE_AXIS_X       = 0,  //!< collision on x axis
     52      CR_COLLISION_TYPE_AXIS_X_NEG,        //!< collision on negative x axis
     53      CR_COLLISION_TYPE_AXIS_Y,            //!< collision on y axis
     54      CR_COLLISION_TYPE_AXIS_Y_NEG,        //!< collision on negative y axis
     55      CR_COLLISION_TYPE_AXIS_Z,            //!< collision on z axis
     56      CR_COLLISION_TYPE_AXIS_Z_NEG,        //!< collision on negative z axis
     57      CR_COLLISION_TYPE_OBB,               //!< object aligned bounding box collide
     58
     59      CR_COLLISION_TYPE_NUMBER
     60    };
     61
     62
     63#define COLLISION_TYPE_AXIS_X      1
     64#define COLLISION_TYPE_AXIS_X_NEG  2
     65//!< the collision axis y collision event
     66#define COLLISION_TYPE_AXIS_Y      3
     67#define COLLISION_TYPE_AXIS_Y_NEG  4
     68//!< the collision axis z collision event
     69#define COLLISION_TYPE_AXIS_Z      5
     70#define COLLISION_TYPE_AXIS_Z_NEG  6
     71//!< the collision is a obb collision
     72#define COLLISION_TYPE_OBB         8
    4973
    5074    virtual ~CREngine(void);
     
    5377    inline static CREngine* getInstance() { if (!singletonRef) singletonRef = new CREngine();  return singletonRef; };
    5478
     79    CollisionHandle* subscribeReaction(WorldEntity* worldEntity, ReactionType type);
     80    bool unsubscribeReaction(CollisionHandle* collisionHandle);
     81
     82
     83    Collision* popCollisionObject();
     84    CollisionEvent* popCollisionEventObject();
    5585    void reset();
    5686
    57 
    58     CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type);
    59 
    60     bool unsubscribeReaction(CollisionHandle* collisionHandle);
    61 
    6287    void handleCollisions();
    63 
    64     /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */
    65     inline Collision* popCollisionObject()
    66     {
    67       if( !this->collisionsUnused.empty())
    68       {
    69         this->collisionsUsed.push_back(this->collisionsUnused.back()); this->collisionsUnused.pop_back(); return this->collisionsUsed.back();
    70       }
    71       else return NULL;
    72     }
    73 
    74 
    75     /** @return an instanco of a CollisionEvent object. instead of creating a new object this ones can be used and resycled */
    76     inline CollisionEvent* popCollisionEventObject()
    77     {
    78       if( !this->collisionEventsUnused.empty())
    79       {
    80         this->collisionEventsUsed.push_back(this->collisionEventsUnused.back()); this->collisionEventsUnused.pop_back(); return this->collisionEventsUsed.back();
    81       }
    82       else return NULL;
    83     }
    8488
    8589    void debug();
Note: See TracChangeset for help on using the changeset viewer.