- Timestamp:
- Jul 4, 2006, 3:51:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/lib/collision_reaction/cr_physics_ground_walk.cc
r9096 r9099 70 70 71 71 72 float CR_MAX_WALK_HEIGHT = 1 0.0f;72 float CR_MAX_WALK_HEIGHT = 15.0f; 73 73 float CR_THRESHOLD = 0.2f; 74 74 75 float height = 0; 76 float front = 0; 77 float side = 0; 75 float height = 0.0f; 76 float front = 0.0f; 77 float back = 0.0f; 78 float right = 0.0f; 79 float left = 0.0f; 78 80 79 81 … … 92 94 switch( ce->getType()) 93 95 { 94 // collision in the x-axis96 /* collision in the X-AXIS */ 95 97 case COLLISION_TYPE_AXIS_X: 96 front = collPos.len() - box->halfLength[0]; // should be [0]98 front = collPos.len() - box->halfLength[0]; 97 99 98 100 // object is beneath the plane (ground) … … 113 115 114 116 case COLLISION_TYPE_AXIS_X_NEG: 115 front = collPos.len() - box->halfLength[0]; // should be [0] 116 117 // object is beneath the plane (ground) 118 if( front <= 0.0f) 117 back = collPos.len() - box->halfLength[0]; 118 119 PRINTF(0)("back: %f\n", back); 120 // object is beneath the plane (ground) 121 if( back <= 0.0f) 119 122 { 120 123 Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); … … 132 135 133 136 134 / / collision in the y-axis137 /* collision in the Y-AXIS */ 135 138 case COLLISION_TYPE_AXIS_Y_NEG: 136 139 // calulate the height above ground … … 140 143 // object is beneath the plane (ground) 141 144 // if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing 142 if( height < 0.0f /*&& height < -CR_MAX_WALK_HEIGHT*/)145 if( height < 0.0f && -height < CR_MAX_WALK_HEIGHT) 143 146 { 144 147 entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f)); … … 162 165 case COLLISION_TYPE_AXIS_Z: 163 166 164 side = collPos.len() - box->halfLength[2]; // should be [2]165 166 // object is beneath the plane (ground) 167 if( side<= 0.0f )167 right = collPos.len() - box->halfLength[2]; 168 169 // object is beneath the plane (ground) 170 if( right <= 0.0f ) 168 171 { 169 172 entity->setAbsCoor(entity->getAbsCoor()); 170 173 Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize(); 171 Vector backoff = dirZ * side;174 Vector backoff = dirZ * right; 172 175 entity->shiftCoor(backoff); 173 176 } … … 183 186 case COLLISION_TYPE_AXIS_Z_NEG: 184 187 185 side = collPos.len() - box->halfLength[2]; // should be [2] 186 187 // object is beneath the plane (ground) 188 if( side <= 0.0f ) 189 { 190 188 left = collPos.len() - box->halfLength[2]; 189 190 // object is beneath the plane (ground) 191 if( left <= 0.0f ) 192 { 191 193 Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize(); 192 Vector backoff = dirZ * side*-1.0f;194 Vector backoff = dirZ * left*-1.0f; 193 195 entity->shiftCoor(backoff); 194 196 }
Note: See TracChangeset
for help on using the changeset viewer.