Changeset 8876 in orxonox.OLD for branches/single_player_map/src/lib/collision_reaction
- Timestamp:
- Jun 28, 2006, 5:33:20 PM (18 years ago)
- 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 29 29 30 30 #include "aabb.h" 31 32 #include "cr_defs.h" 31 33 32 34 using namespace std; … … 70 72 WorldEntity* entity = collision->getEntityB(); 71 73 74 // collision position maths 75 Vector collPos = collision->getEntityB()->getAbsCoor() + box->center - ce->getCollisionPosition(); 76 72 77 float CR_MAX_WALK_HEIGHT = 2.0f; 73 78 float CR_THRESHOLD = 0.2f; 74 79 75 if( box != NULL)80 if( box == NULL) 76 81 { 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; 97 84 } 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 98 116 99 117 … … 177 195 void CRPhysicsGroundWalk::update(WorldEntity* owner) 178 196 { 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 184 198 } 185 199 -
branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.h
r8724 r8876 23 23 virtual void update(WorldEntity* entity); 24 24 25 25 26 private: 26 Vector lastPosition; //!< vector with the last valid position27 Vector afterLastPosition; //!< vector for the after last28 Quaternion lastDirection; //!< quat with the last valid direction29 30 Vector lastPositions[10]; //!< last 10 positions31 27 float downspeed; 32 28 };
Note: See TracChangeset
for help on using the changeset viewer.