Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9061 in orxonox.OLD for trunk/src/lib/collision_reaction


Ignore:
Timestamp:
Jul 3, 2006, 6:39:10 PM (18 years ago)
Author:
patrick
Message:

merged the single_player branche to trunk

Location:
trunk/src/lib/collision_reaction
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_reaction/cr_defs.h

    r8894 r9061  
    2929
    3030//!< the collision axis x collision event
    31 #define COLLISION_TYPE_AXIS_X   1
     31#define COLLISION_TYPE_AXIS_X      1
     32#define COLLISION_TZPE_AXIS_X_NEG  2
    3233//!< the collision axis y collision event
    33 #define COLLISION_TYPE_AXIS_Y   2
     34#define COLLISION_TYPE_AXIS_Y      3
     35#define COLLISION_TYPE_AXIS_Y_NEG  4
    3436//!< the collision axis z collision event
    35 #define COLLISION_TYPE_AXIS_Z   4
     37#define COLLISION_TYPE_AXIS_Z      5
     38#define COLLISION_TYPE_AXIS_Z_NEG  6
    3639//!< the collision is a obb collision
    3740#define COLLISION_TYPE_OBB      8
  • trunk/src/lib/collision_reaction/cr_object_damage.cc

    r9027 r9061  
    6464    damage = collision->getEntityB()->getDamage();
    6565    collision->getEntityA()->hit(damage, collision->getEntityB());
     66    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
    6667  }
    67   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
    6868
    6969  if( collision->isEntityBCollide()) {
    7070    damage = collision->getEntityA()->getDamage();
    7171    collision->getEntityB()->hit(damage, collision->getEntityA());
     72    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
    7273  }
    73   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
    7474
    7575  collision->flushCollisionEvents();
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9027 r9061  
    9595        // collision in the x-axis
    9696      case COLLISION_TYPE_AXIS_X:
    97         front = collPos.x - box->halfLength[0]; // should be [0]
     97        front = collPos.len() - box->halfLength[0]; // should be [0]
    9898
    9999        // object is beneath the plane (ground)
    100100        if( front <= 0.0f )
    101101        {
    102           Vector backoff = entity->getAbsDirX() * front;
    103 //           entity->shiftCoor(backoff);
    104         }
    105         // object is already in the wall
    106         else if( ce->isInWall())
    107         {
    108 //           entity->setAbsCoor(entity->getLastAbsCoor());
     102          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     103          Vector backoff = dirX * front;
     104         
     105          entity->setAbsCoor(entity->getLastAbsCoor());
     106         // entity->shiftCoor(backoff);
     107        }
     108        // object is already in the wall
     109        else if( ce->isInWall())
     110        {
     111              entity->setAbsCoor(entity->getLastAbsCoor());
     112        }
     113        break;
     114       
     115      case COLLISION_TYPE_AXIS_X_NEG:
     116        front = collPos.len() - box->halfLength[0]; // should be [0]
     117
     118        // object is beneath the plane (ground)
     119        if( front <= 0.0f )
     120        {
     121          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     122          Vector backoff = dirX * front * -1.0f;
     123         
     124          entity->setAbsCoor(entity->getLastAbsCoor());
     125         // entity->shiftCoor(backoff);
     126        }
     127        // object is already in the wall
     128        else if( ce->isInWall())
     129        {
     130          entity->setAbsCoor(entity->getLastAbsCoor());
    109131        }
    110132        break;
     
    112134
    113135        // collision in the y-axis
    114       case COLLISION_TYPE_AXIS_Y:
     136      case COLLISION_TYPE_AXIS_Y_NEG:
    115137        // calulate the height above ground
    116138        height = collPos.y - box->halfLength[1];
     
    118140
    119141        // object is beneath the plane (ground)
    120         if( height <= 0.0f )
    121         {
    122           entity->shiftCoor(Vector(0.0f, -height, 0.0f));
     142        if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
     143        else if( height < 0.0f )
     144        {
     145          entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f));
    123146          entity->setOnGround(true);
    124147        }
     
    140163      case COLLISION_TYPE_AXIS_Z:
    141164
    142         side = collPos.z - box->halfLength[2]; // should be [2]
     165        side = collPos.len() - box->halfLength[2]; // should be [2]
    143166
    144167        // object is beneath the plane (ground)
    145168        if( side <= 0.0f )
    146169        {
    147           Vector backoff = entity->getAbsDirX() * side;
    148 //           entity->shiftCoor(backoff);
    149         }
    150         // object is already in the wall
    151         else if( ce->isInWall())
    152         {
    153 //           entity->setAbsCoor(entity->getLastAbsCoor());
     170          entity->setAbsCoor(entity->getAbsCoor());
     171          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     172          Vector backoff = dirZ * side;
     173          entity->shiftCoor(backoff);
     174        }
     175        // object is already in the wall
     176        else if( ce->isInWall())
     177        {
     178          entity->setAbsCoor(entity->getLastAbsCoor());
     179        }
     180        break;
     181       
     182       
     183         // collision in the z-axis
     184      case COLLISION_TYPE_AXIS_Z_NEG:
     185
     186        side = collPos.len()  - box->halfLength[2]; // should be [2]
     187
     188        // object is beneath the plane (ground)
     189        if( side <= 0.0f )
     190        {
     191         
     192          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     193          Vector backoff = dirZ * side*-1.0f;
     194          entity->shiftCoor(backoff);
     195        }
     196        // object is already in the wall
     197        else if( ce->isInWall())
     198        {
     199          entity->setAbsCoor(entity->getLastAbsCoor());
    154200        }
    155201        break;
Note: See TracChangeset for help on using the changeset viewer.