Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 26, 2006, 3:43:40 PM (19 years ago)
Author:
patrick
Message:

merged the bsp model branche back to trunk and some npc code changes :D

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8724 r8796  
    2525
    2626#include <vector>
     27
     28#include "aabb.h"
    2729
    2830using namespace std;
     
    6264  //   collision->getEntityB()->getAbsCoor().debug();
    6365
     66  Vector height;
     67  AABB* box = collision->getEntityB()->getModelAABB();
     68 
     69 
     70 
     71  if(box!=NULL)
     72    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
     73  else
     74    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
    6475
    65   Vector height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor();
    66 
    67   if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
    68     collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    69     return;
    70   }
    71   if(ce->getGroundNormal().len() <= 0.1f) {
    72     collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    73     return;
    74   }
    75   if(ce->getGroundNormal().len() >= 1.4f) {
    76     downspeed++;
    77     collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
    78     return;
    79   }
     76  if(box!=NULL) {
    8077
    8178
    82   if(height.y < -3.510001 + 10.0) // Above ground
    83   {
    84     if(height.y > -15.6) // Snap in
    85     {
    86       downspeed = 0;
    87       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,height.y+3.500005 + 10.0,0.0));
    88     } else
    89     {
     79    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
     80      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
     81      return;
     82    }
     83    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
     84      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
     85      return;
     86    }
     87
     88    if(ce->getGroundNormal().len() <= 0.1f) {
     89      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
     90      return;
     91    }
     92   
     93   
     94    if(ce->getGroundNormal().len() >= 1.4f) {
    9095      downspeed++;
    9196      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
     97      return;
    9298    }
    9399
    94   }
    95   else {
    96     if(height.y > -3.50000 + 10.0  && height.y <    9.9+ 10.0) // below ground
     100
     101    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
    97102    {
    98       //if(downspeed <= 0) downspeed =1;
    99       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, 0.00001 /*height.y+3.500005 + 10.0*/,0.0));
    100       //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
    101       downspeed = 0;
     103      if(height.y < box->halfLength[1] + 1.3f) // Snap in
     104      {
     105        downspeed = 0;
     106        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() - Vector(0.0,height.y  - box->halfLength[1] - 0.0f,0.0));
     107      } else
     108      {
     109        downspeed++;
     110        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
     111      }
     112
     113    }
     114    else {
     115      if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
     116      {
     117        //if(downspeed <= 0) downspeed =1;
     118        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f/* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));
     119        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
     120        downspeed = 0;
     121      }
     122
    102123    }
    103124
    104   }
    105 
    106 
     125  }// if(box!= NULL)
    107126  /*
    108127  PRINTF(0)("Collision with Ground: \n");
Note: See TracChangeset for help on using the changeset viewer.