Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 28, 2006, 5:33:20 PM (18 years ago)
Author:
patrick
Message:

collision reaction stuff

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

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8864 r8876  
    2929
    3030#include "aabb.h"
     31
     32#include "cr_defs.h"
    3133
    3234using namespace std;
     
    7072  WorldEntity* entity = collision->getEntityB();
    7173
     74  // collision position maths
     75  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     76
    7277  float CR_MAX_WALK_HEIGHT = 2.0f;
    7378  float CR_THRESHOLD = 0.2f;
    7479
    75   if( box != NULL)
     80  if( box == NULL)
    7681  {
    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 
     82    PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
     83    return;
    9784  }
     85
     86
     87  switch( ce->getType())
     88  {
     89    case COLLISION_TYPE_AXIS_Y:
     90
     91      height = collPos.y - box->halfLength[1];
     92      PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     93      PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     94
     95      // object is beneath the plane (ground)
     96      if( height <= 0.0f )
     97      {
     98        entity->shiftCoor(Vector(0, -height, 0));
     99      }
     100      // object is already in the wall
     101      else if( ce->isInWall())
     102      {
     103        entity->setAbsCoor(entity->getLastAbsCoor());
     104      }
     105      break;
     106
     107
     108    case COLLISION_TYPE_AXIS_X:
     109    case COLLISION_TYPE_AXIS_Z:
     110      break;
     111
     112    }
     113
     114
     115
    98116
    99117
     
    177195void CRPhysicsGroundWalk::update(WorldEntity* owner)
    178196{
    179   for( int i = 9; i > 0; i--) {
    180     this->lastPositions[i] = this->lastPositions[i-1];
    181     //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
    182   }
    183   this->lastPositions[0] = owner->getAbsCoor();
     197
    184198}
    185199
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8724 r8876  
    2323    virtual void update(WorldEntity* entity);
    2424
     25
    2526  private:
    26     Vector       lastPosition;                //!< vector with the last valid position
    27     Vector       afterLastPosition;           //!< vector for the after last
    28     Quaternion   lastDirection;               //!< quat with the last valid direction
    29 
    30     Vector       lastPositions[10];           //!< last 10 positions
    3127    float        downspeed;
    3228};
Note: See TracChangeset for help on using the changeset viewer.