Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 28, 2006, 3:51:36 PM (19 years ago)
Author:
patrick
Message:

new collision registration functions

Location:
branches/single_player_map/src/lib/collision_reaction
Files:
3 edited

Legend:

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

    r8862 r8864  
    99#include "vector.h"
    1010
     11#include "cr_defs.h"
     12
     13
    1114class WorldEntity;
    1215class BoundingVolume;
    1316class Plane;
     17
    1418
    1519
     
    2226
    2327  /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
    24   inline void collide(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    25   { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
     28  inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
     29  { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
    2630  /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
    27   inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
    28   { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
     31  inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
     32  { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
    2933
    3034
     
    4448  inline Vector getCollisionPosition() { return this->position; }
    4549
     50  /** @return the type of the collision */
     51  inline int getType() { return this->collisionType; }
     52
    4653  /** @return true if the entity is in the wall */
    4754  inline bool isInWall() { return this->bInWall; }
     
    5966
    6067  bool              bInWall;                       //!< true if is in wall
     68  int               collisionType;                 //!< collision type
    6169};
    6270
  • branches/single_player_map/src/lib/collision_reaction/cr_defs.h

    r8190 r8864  
    2828
    2929
     30//!< the collision axis x collision event
     31#define COLLISION_TYPE_AXIS_X   1
     32//!< the collision axis y collision event
     33#define COLLISION_TYPE_AXIS_Y   2
     34//!< the collision axis z collision event
     35#define COLLISION_TYPE_AXIS_Z   4
     36//!< the collision is a obb collision
     37#define COLLISION_TYPE_OBB      8
     38
    3039
    3140#endif /* _NETWORK_MANAGER */
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8863 r8864  
    6666  //   collision->getEntityB()->getAbsCoor().debug();
    6767
    68   Vector height;
     68  float height;
    6969  AABB* box = collision->getEntityB()->getModelAABB();
    7070  WorldEntity* entity = collision->getEntityB();
     
    7373  float CR_THRESHOLD = 0.2f;
    7474
    75 //   if( box != NULL)
    76 //   {
    77 //
    78 //     Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
    79 //     height = collPos.y - box->halfLength[1];
    80 //
    81 //     PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    82 //     PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    83 //
    84 //     // object is beneath the plane (ground)
    85 //     if( height < 0.0f )
    86 //     {
    87 //       entity->shiftCoor(Vector(0, -height, 0));
    88 //     }
    89 //     // object is already in the wall
    90 //     else if( ce->isInWall())
    91 //     {
    92 //
    93 //     }
    94 //
    95 //
    96 //
    97 //   }
     75  if( box != NULL)
     76  {
     77
     78    Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     79    height = collPos.y - box->halfLength[1];
     80
     81    PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     82    PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     83
     84    // object is beneath the plane (ground)
     85    if( height < 0.0f )
     86    {
     87      entity->shiftCoor(Vector(0, -height, 0));
     88    }
     89    // object is already in the wall
     90    else if( ce->isInWall())
     91    {
     92      entity->setAbsCoor(entity->getLastAbsCoor());
     93    }
     94
     95
     96
     97  }
    9898
    9999
     
    101101
    102102
    103 // #if 0
     103#if 0
    104104  if( box != NULL)
    105105    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
     
    158158
    159159  }// if(box!= NULL)
    160 // #endif
     160#endif
    161161  /*
    162162  PRINTF(0)("Collision with Ground: \n");
Note: See TracChangeset for help on using the changeset viewer.