Changeset 9061 in orxonox.OLD for trunk/src/lib/collision_reaction
- Timestamp:
- Jul 3, 2006, 6:39:10 PM (18 years ago)
- Location:
- trunk/src/lib/collision_reaction
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_reaction/cr_defs.h
r8894 r9061 29 29 30 30 //!< 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 32 33 //!< 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 34 36 //!< 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 36 39 //!< the collision is a obb collision 37 40 #define COLLISION_TYPE_OBB 8 -
trunk/src/lib/collision_reaction/cr_object_damage.cc
r9027 r9061 64 64 damage = collision->getEntityB()->getDamage(); 65 65 collision->getEntityA()->hit(damage, collision->getEntityB()); 66 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName()); 66 67 } 67 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());68 68 69 69 if( collision->isEntityBCollide()) { 70 70 damage = collision->getEntityA()->getDamage(); 71 71 collision->getEntityB()->hit(damage, collision->getEntityA()); 72 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName()); 72 73 } 73 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());74 74 75 75 collision->flushCollisionEvents(); -
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r9027 r9061 95 95 // collision in the x-axis 96 96 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] 98 98 99 99 // object is beneath the plane (ground) 100 100 if( front <= 0.0f ) 101 101 { 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()); 109 131 } 110 132 break; … … 112 134 113 135 // collision in the y-axis 114 case COLLISION_TYPE_AXIS_Y :136 case COLLISION_TYPE_AXIS_Y_NEG: 115 137 // calulate the height above ground 116 138 height = collPos.y - box->halfLength[1]; … … 118 140 119 141 // 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)); 123 146 entity->setOnGround(true); 124 147 } … … 140 163 case COLLISION_TYPE_AXIS_Z: 141 164 142 side = collPos. z- box->halfLength[2]; // should be [2]165 side = collPos.len() - box->halfLength[2]; // should be [2] 143 166 144 167 // object is beneath the plane (ground) 145 168 if( side <= 0.0f ) 146 169 { 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()); 154 200 } 155 201 break;
Note: See TracChangeset
for help on using the changeset viewer.