Changeset 9110 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jul 4, 2006, 11:18:41 AM (18 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_detection/cd_engine.cc
r8894 r9110 45 45 46 46 this->bAbordOnFirstCollision = false; 47 48 this->terrain = NULL; 47 49 } 48 50 -
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r9061 r9110 70 70 71 71 72 float CR_MAX_WALK_HEIGHT = 2.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; 78 79 //PRINTF(0)("collision raction======================================\n"); 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; 80 80 81 81 82 const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents()); … … 93 94 switch( ce->getType()) 94 95 { 95 / / collision in the x-axis96 /* collision in the X-AXIS */ 96 97 case COLLISION_TYPE_AXIS_X: 97 front = collPos.len() - box->halfLength[0]; // should be [0]98 front = collPos.len() - box->halfLength[0]; 98 99 99 100 // object is beneath the plane (ground) 100 101 if( front <= 0.0f ) 101 102 { 102 Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); 103 Vector dirX = entity->getAbsDirX(); 104 dirX.y = 0.0f; 105 dirX.normalize(); 103 106 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 107 108 entity->shiftCoor(backoff); 109 } 110 else if( ce->isInWall()) 111 { 112 // object is already in the wall 113 entity->setAbsCoor(entity->getLastAbsCoor()); 114 } 115 break; 116 115 117 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()); 131 } 132 break; 133 134 135 // collision in the y-axis 118 back = collPos.len() - box->halfLength[0]; 119 120 // object is beneath the plane (ground) 121 if( back <= 0.0f) 122 { 123 Vector dirX = entity->getAbsDirX(); 124 dirX.y = 0.0f; 125 dirX.normalize(); 126 Vector backoff = dirX * back * -1.0f; 127 128 entity->shiftCoor(backoff); 129 } 130 else if( ce->isInWall()) 131 { 132 // object is already in the wall 133 entity->setAbsCoor(entity->getLastAbsCoor()); 134 } 135 break; 136 137 138 /* collision in the Y-AXIS */ 136 139 case COLLISION_TYPE_AXIS_Y_NEG: 137 140 // calulate the height above ground 138 height = collPos. y- box->halfLength[1];139 140 141 // object is beneath the plane (ground) 142 if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing143 else if( height < 0.0f)141 height = collPos.len() - box->halfLength[1]; 142 143 144 // object is beneath the plane (ground) 145 // if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing 146 if( height < 0.0f && -height < CR_MAX_WALK_HEIGHT) 144 147 { 145 148 entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f)); … … 160 163 161 164 165 /* collision in the Z-AXIS */ 166 case COLLISION_TYPE_AXIS_Z: 167 168 right = collPos.len() - box->halfLength[2]; 169 170 // object is beneath the plane (ground) 171 if( right <= 0.0f ) 172 { 173 Vector dirZ = entity->getAbsDirZ(); 174 dirZ.y = 0.0f; 175 dirZ.normalize(); 176 Vector backoff = dirZ * right; 177 entity->shiftCoor(backoff); 178 } 179 else if( ce->isInWall()) 180 { 181 // object is already in the wall 182 entity->setAbsCoor(entity->getLastAbsCoor()); 183 } 184 break; 185 186 162 187 // collision in the z-axis 163 case COLLISION_TYPE_AXIS_Z:164 165 side = collPos.len() - box->halfLength[2]; // should be [2]166 167 // object is beneath the plane (ground)168 if( side <= 0.0f )169 {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 wall176 else if( ce->isInWall())177 {178 entity->setAbsCoor(entity->getLastAbsCoor());179 }180 break;181 182 183 // collision in the z-axis184 188 case COLLISION_TYPE_AXIS_Z_NEG: 185 189 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; 190 left = collPos.len() - box->halfLength[2]; 191 192 // object is beneath the plane (ground) 193 if( left <= 0.0f ) 194 { 195 Vector dirZ = entity->getAbsDirZ(); 196 dirZ.y = 0.0f; 197 dirZ.normalize(); 198 Vector backoff = dirZ * left*-1.0f; 194 199 entity->shiftCoor(backoff); 195 200 } … … 209 214 210 215 211 #if 0212 if( box != NULL)213 height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;214 else215 height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;216 217 218 if( box != NULL)219 {220 221 222 if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f)223 {224 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());225 return;226 }227 if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f)228 {229 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());230 return;231 }232 233 if(ce->getGroundNormal().len() <= 0.1f)234 {235 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());236 return;237 }238 239 240 if(ce->getGroundNormal().len() >= 1.4f)241 {242 downspeed++;243 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));244 return;245 }246 247 248 if(height.y > box->halfLength[1] + 0.0f ) // Above ground249 {250 if(height.y < box->halfLength[1] + 2.3f) // Snap in251 {252 downspeed = 0;253 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() - Vector(0.0,height.y - box->halfLength[1] - 0.0f,0.0));254 } else255 {256 downspeed++;257 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));258 }259 260 }261 else262 {263 if(height.y < box->halfLength[1] + 0.0f /* && height.y > - 55.0f*/) // below ground264 {265 //if(downspeed <= 0) downspeed =1;266 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y + box->halfLength[1] + 2.0f,0.0));267 //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));268 downspeed = 0;269 }270 271 }272 273 }// if(box!= NULL)274 #endif275 /*276 PRINTF(0)("Collision with Ground: \n");277 collision->getEntityB()->getAbsCoor().debug();278 collision->getEntityB()->setVelocity(Vector());279 collision->getEntityB()->setAbsCoor(this->lastPositions[1]);280 281 */282 216 283 217 } -
trunk/src/lib/graphics/importer/bsp_manager.cc
r9061 r9110 960 960 this->outputFraction = 1.0f; 961 961 962 963 this->checkCollisionX(worldEntity); 964 this->checkCollisionY(worldEntity); 965 this->checkCollisionZ(worldEntity); 966 967 968 #if 0 962 969 // Retrieve Bounding box 963 970 AABB* box = worldEntity->getModelAABB(); … … 985 992 986 993 994 plane* testPlane; 995 996 bool xCollision = false; 997 bool zCollision = false; 998 987 999 988 1000 float height = 40; … … 998 1010 dest1 = worldEntity->getAbsCoor() + box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 999 1011 dest2 = worldEntity->getAbsCoor() - box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1000 1012 1001 1013 Vector dirZ = worldEntity->getAbsDirZ(); dirX.y = 0.0f; dirZ.normalize(); 1002 1014 //position2 = worldEntity->getAbsCoor() + box->center - dirZ * (box->halfLength[2] + BSP_Z_OFFSET); … … 1009 1021 1010 1022 1011 // PRINTF(0)("x and v\n"); 1012 // worldEntity->getAbsDirX().debug(); 1013 // worldEntity->getAbsDirV().debug(); 1014 1015 1016 // 1st Ray 1023 1024 // 1st Ray: Y RAY 1017 1025 this->inputStart = position; 1018 1026 this->inputEnd = dest; … … 1052 1060 this->out = out; 1053 1061 } 1054 1055 1056 } 1057 1058 plane* testPlane = this->collPlane; 1059 1060 bool xCollision = false; 1061 bool zCollision = false; 1062 } 1063 testPlane = this->collPlane; 1064 1065 1062 1066 bool xCollisionNeg = false; 1063 1067 bool zCollisionNeg = false; 1064 1065 1066 1067 // 2nd Collision Detection 1068 1069 1070 1071 // 2nd Collision Detection X-RAY 1068 1072 this->outputStartsOut = true; 1069 1073 this->outputAllSolid = false; … … 1093 1097 1094 1098 1095 // 3rd Collision Detection 1099 // 3rd Collision Detection Z-RAY 1096 1100 this->outputStartsOut = true; 1097 1101 this->outputAllSolid = false; … … 1121 1125 } 1122 1126 1123 //end if1124 /*1125 This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.1126 out.x = position1.x + (dest.x -position1.x) * this->outputFraction;1127 out.z = position1.z + (dest.z -position1.z) * this->outputFraction;1128 */1129 1130 1127 1131 1128 // Return the normal here: Normal's stored in this->collPlane; 1132 1129 if( collision) { 1133 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y _NEG, this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);1130 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1134 1131 } 1135 1132 if(xCollision) { 1136 1133 worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag); 1137 1134 } 1138 1135 1139 1136 if(zCollision) { 1140 1137 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag); 1141 1138 } 1142 1143 1144 //else worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false); 1145 1146 } 1139 #endif 1140 1141 } 1142 1143 1144 1145 /** 1146 * check the collision in the x direction (forward, backward) 1147 */ 1148 void BspManager::checkCollisionX(WorldEntity* entity) 1149 { 1150 // Retrieve Bounding box 1151 AABB* box = entity->getModelAABB(); 1152 1153 1154 plane* testPlane = NULL; //!< the collision test plane 1155 1156 Vector forward; //!< left collision ray 1157 Vector backward; //!< right collision ray 1158 Vector collPos; //!< the collision position 1159 1160 bool xCollisionForward = false; //!< flag true if right collision 1161 bool xCollisionBackward = false; //!< flag true if left collision 1162 bool SolidFlag = false; //!< flag set true if solid 1163 1164 Vector position; //!< current position of the entity 1165 Vector dirX; //!< direction x 1166 1167 position = entity->getAbsCoor(); 1168 dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); 1169 1170 // calculate the rays 1171 if( box != NULL) 1172 { 1173 forward = entity->getAbsCoor() + box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1174 backward = entity->getAbsCoor() + box->center - dirX * (box->halfLength[0] + BSP_X_OFFSET); 1175 } 1176 else 1177 { 1178 forward = position + dirX * 4.0f; 1179 backward = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0; 1180 } 1181 1182 1183 /* X Ray forward */ 1184 // init some member variables before collision check 1185 this->outputStartsOut = true; 1186 this->outputAllSolid = false; 1187 this->outputFraction = 1.0f; 1188 this->inputStart = position; 1189 this->inputEnd = forward; 1190 this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &forward ); 1191 1192 // collision occured 1193 if( this->outputFraction < 1.0f) 1194 { 1195 collPos = position + (forward - position) * this->outputFraction; 1196 xCollisionForward = true; 1197 testPlane = this->collPlane; 1198 } 1199 if(this->outputAllSolid ) 1200 { 1201 this->collPlane = new plane; 1202 this->collPlane->x = 0.0f; 1203 this->collPlane->y = 0.0f; 1204 this->collPlane->z = 0.0f; 1205 testPlane = this->collPlane; 1206 SolidFlag = true; 1207 xCollisionForward = true; 1208 } 1209 1210 // collision registration 1211 if( xCollisionForward) 1212 { 1213 entity->registerCollision(COLLISION_TYPE_AXIS_X , 1214 this->parent, entity, 1215 Vector(testPlane->x, testPlane->y, testPlane->z), 1216 collPos, 1217 SolidFlag); 1218 } 1219 1220 1221 1222 /* X Ray backward */ 1223 // init some member variables before collision check 1224 this->outputStartsOut = true; 1225 this->outputAllSolid = false; 1226 this->outputFraction = 1.0f; 1227 this->inputStart = position; 1228 this->inputEnd = backward; 1229 this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &backward ); 1230 1231 // collision occured 1232 if( this->outputFraction < 1.0f) 1233 { 1234 collPos = position + (backward - position) * this->outputFraction; 1235 xCollisionBackward = true; 1236 testPlane = this->collPlane; 1237 } 1238 if( this->outputAllSolid) 1239 { 1240 this->collPlane = new plane; 1241 this->collPlane->x = 0.0f; 1242 this->collPlane->y = 0.0f; 1243 this->collPlane->z = 0.0f; 1244 testPlane = this->collPlane; 1245 SolidFlag = true; 1246 xCollisionBackward = true; 1247 } 1248 1249 // collision registration 1250 if( xCollisionBackward) 1251 { 1252 entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , 1253 this->parent, entity, 1254 Vector(testPlane->x, testPlane->y, testPlane->z), 1255 collPos, 1256 SolidFlag); 1257 } 1258 } 1259 1260 1261 /** 1262 * check the collision in the z direction (up, down) 1263 */ 1264 void BspManager::checkCollisionY(WorldEntity* entity) 1265 { 1266 1267 // Retrieve Bounding box 1268 AABB* box = entity->getModelAABB(); 1269 1270 1271 plane* testPlane = NULL; //!< the collision test plane 1272 1273 Vector up; //!< up collision ray 1274 Vector down; //!< down collision ray 1275 Vector collPos; //!< the collision position 1276 1277 bool yCollisionUp = false; //!< flag true if right collision 1278 bool yCollisionDown = false; //!< flag true if left collision 1279 bool SolidFlag = false; //!< flag set true if solid 1280 1281 Vector position; //!< current position of the entity 1282 Vector dirY; //!< direction x 1283 1284 position = entity->getAbsCoor(); 1285 collPos = position; 1286 dirY = Vector(0.0, 1.0, 0.0); 1287 1288 // calculate the rays 1289 if( box != NULL) 1290 { 1291 up = position + box->center + dirY * (box->halfLength[1]/* + BSP_Y_OFFSET*/); 1292 down = position + box->center - dirY * (box->halfLength[1] + BSP_Y_OFFSET); 1293 } 1294 else 1295 { 1296 up = position + dirY * 4.0f; 1297 down = position + Vector(0.0, 1.0, 0.0) + dirY * 4.0; 1298 } 1299 1300 1301 1302 1303 /* Y Ray up */ 1304 // init some member variables before collision check 1305 this->inputStart = position; 1306 this->inputEnd = up; 1307 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &up ); 1308 1309 if( !this->outputStartsOut ) 1310 { 1311 this->collPlane = new plane; 1312 this->collPlane->x = 0.0f; 1313 this->collPlane->y = 0.0f; 1314 this->collPlane->z = 0.0f; 1315 yCollisionUp = true; 1316 } 1317 else 1318 { 1319 if( this->outputFraction == 1.0f) 1320 { 1321 if( this->outputAllSolid ) 1322 { 1323 this->collPlane = new plane; 1324 this->collPlane->x = 0.0f; 1325 this->collPlane->y = 0.0f; 1326 this->collPlane->z = 0.0f; 1327 yCollisionUp = true; 1328 SolidFlag = true; 1329 } 1330 else 1331 { 1332 yCollisionUp = false; 1333 collPos = up; 1334 } 1335 } 1336 else 1337 { 1338 yCollisionUp = true; 1339 collPos = position + (up - position) * this->outputFraction; 1340 this->out = collPos; // why this???? 1341 } 1342 } 1343 testPlane = this->collPlane; 1344 1345 // collision registration 1346 if( yCollisionUp) 1347 { 1348 entity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, 1349 entity, 1350 Vector(testPlane->x, testPlane->y, testPlane->z), 1351 collPos, SolidFlag); 1352 } 1353 1354 1355 1356 1357 /* Y Ray down */ 1358 // init some member variables before collision check 1359 this->inputStart = position; 1360 this->inputEnd = down; 1361 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &down ); 1362 1363 if( !this->outputStartsOut ) 1364 { 1365 this->collPlane = new plane; 1366 this->collPlane->x = 0.0f; 1367 this->collPlane->y = 0.0f; 1368 this->collPlane->z = 0.0f; 1369 yCollisionDown = true; 1370 } 1371 else 1372 { 1373 if( this->outputFraction == 1.0f) 1374 { 1375 if( this->outputAllSolid ) 1376 { 1377 this->collPlane = new plane; 1378 this->collPlane->x = 0.0f; 1379 this->collPlane->y = 0.0f; 1380 this->collPlane->z = 0.0f; 1381 yCollisionDown = true; 1382 SolidFlag = true; 1383 } 1384 else 1385 { 1386 yCollisionDown = false; 1387 collPos = down; 1388 } 1389 } 1390 else 1391 { 1392 yCollisionDown = true; 1393 collPos = position + (down - position) * this->outputFraction; 1394 this->out = collPos; // why this???? 1395 } 1396 } 1397 testPlane = this->collPlane; 1398 1399 // collision registration 1400 if( yCollisionDown) 1401 { 1402 entity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, 1403 entity, 1404 Vector(testPlane->x, testPlane->y, testPlane->z), 1405 collPos, SolidFlag); 1406 } 1407 1408 1409 } 1410 1411 1412 1413 1414 /** 1415 * check the collision in the z direction (left, right) 1416 */ 1417 void BspManager::checkCollisionZ(WorldEntity* entity) 1418 { 1419 // Retrieve Bounding box 1420 AABB* box = entity->getModelAABB(); 1421 1422 1423 plane* testPlane = NULL; //!< the collision test plane 1424 1425 Vector right; //!< right collision ray 1426 Vector left; //!< left collision ray 1427 Vector collPos; //!< the collision position 1428 1429 bool zCollisionRight = false; //!< flag true if right collision 1430 bool zCollisionLeft = false; //!< flag true if left collision 1431 bool SolidFlag = false; //!< flag set true if solid 1432 1433 Vector position; //!< current position of the entity 1434 Vector dirZ; //!< direction x 1435 1436 position = entity->getAbsCoor(); 1437 dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize(); 1438 1439 // calculate the rays 1440 if( box != NULL) 1441 { 1442 right = entity->getAbsCoor() + box->center + dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1443 left = entity->getAbsCoor() + box->center - dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1444 } 1445 else 1446 { 1447 right = position + dirZ * 4.0f; 1448 left = position + Vector(0.0, 1.0, 0.0) + dirZ * 4.0; 1449 } 1450 1451 1452 /* Z Ray right */ 1453 // init some member variables before collision check 1454 this->outputStartsOut = true; 1455 this->outputAllSolid = false; 1456 this->outputFraction = 1.0f; 1457 this->inputStart = position; 1458 this->inputEnd = right; 1459 this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &right ); 1460 1461 1462 // collision occured 1463 if( this->outputFraction < 1.0f ) 1464 { 1465 collPos = position + (right - position) * this->outputFraction; 1466 zCollisionRight = true; 1467 testPlane = this->collPlane; 1468 } 1469 if(this->outputAllSolid ) 1470 { 1471 this->collPlane = new plane; 1472 this->collPlane->x = 0.0f; 1473 this->collPlane->y = 0.0f; 1474 this->collPlane->z = 0.0f; 1475 testPlane = this->collPlane; 1476 1477 SolidFlag = true; 1478 zCollisionRight = true; 1479 } 1480 1481 1482 if( zCollisionRight) { 1483 entity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, 1484 entity, 1485 Vector(testPlane->x, testPlane->y, testPlane->z), 1486 collPos , SolidFlag); 1487 } 1488 1489 1490 1491 /* Z Ray left */ 1492 // init some member variables before collision check 1493 this->outputStartsOut = true; 1494 this->outputAllSolid = false; 1495 this->outputFraction = 1.0f; 1496 this->inputStart = position; 1497 this->inputEnd = left; 1498 this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &left); 1499 1500 1501 // collision occured 1502 if( this->outputFraction < 1.0f ) 1503 { 1504 collPos = position + (left - position) * this->outputFraction; 1505 zCollisionLeft = true; 1506 testPlane = this->collPlane; 1507 } 1508 if(this->outputAllSolid ) 1509 { 1510 this->collPlane = new plane; 1511 this->collPlane->x = 0.0f; 1512 this->collPlane->y = 0.0f; 1513 this->collPlane->z = 0.0f; 1514 testPlane = this->collPlane; 1515 1516 SolidFlag = true; 1517 zCollisionLeft = true; 1518 } 1519 1520 1521 if( zCollisionLeft) { 1522 entity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this->parent, 1523 entity, 1524 Vector(testPlane->x, testPlane->y, testPlane->z), 1525 collPos , SolidFlag); 1526 } 1527 1528 } 1529 1530 1147 1531 1148 1532 -
trunk/src/lib/graphics/importer/bsp_manager.h
r9061 r9110 28 28 29 29 30 #define BSP_X_OFFSET 40.0f30 #define BSP_X_OFFSET 20.0f 31 31 #define BSP_Y_OFFSET 40.0f 32 #define BSP_Z_OFFSET 40.0f32 #define BSP_Z_OFFSET 20.0f 33 33 34 34 … … 79 79 80 80 private: 81 // Functions81 // collision functions 82 82 BspTreeNode* getLeaf(BspTreeNode* node, Vector* cam) ; //!< Traverses the tree 83 83 void checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only! 84 84 void checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 85 85 void checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 86 void TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs ); 86 87 void checkCollisionX(WorldEntity* entity); 88 void checkCollisionY(WorldEntity* entity); 89 void checkCollisionZ(WorldEntity* entity); 90 87 91 void checkCollisionBox(void); 88 92 void checkBrushRay(brush* curBrush); 89 93 void checkBrushRayN(brush* curBrush); 90 94 void checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd); 91 float 95 float checkPatchAltitude(BspTreeNode* node); //! To be implemented... 92 96 97 void TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs ); 98 99 100 // visibility functions 93 101 void drawDebugCube(Vector* cam); 94 102 bool isAlreadyVisible(int Face); -
trunk/src/lib/graphics/importer/md3/md3_model.cc
r8724 r9110 525 525 float interpolatedMatrix[4][4]; 526 526 527 Quaternion currQuat(currFrameTag->matrix); currQuat.matrix(currRot); 528 Quaternion nextQuat(nextFrameTag->matrix); nextQuat.matrix(nextRot); 527 /// TODO CHANGED BY BENSCH TO MATCH NEW QUATERNION FUNCTIONALITY 528 Quaternion currQuat; currQuat.from3x3(currFrameTag->matrix); currQuat.matrix(currRot); 529 Quaternion nextQuat; nextQuat.from3x3(nextFrameTag->matrix); nextQuat.matrix(nextRot); 529 530 530 531 Quaternion interpolatedQuat = Quaternion::quatSlerp(currQuat, nextQuat, frac); interpolatedQuat.matrix(interpolatedMatrix); -
trunk/src/lib/graphics/importer/primitive_model.cc
r8316 r9110 18 18 #include "primitive_model.h" 19 19 20 #include <math.h>21 20 #include "vector.h" 22 21 #include "debug.h" -
trunk/src/lib/graphics/spatial_separation/quadtree.cc
r8293 r9110 52 52 53 53 /* make an array with access to the leafs of the Quad-Tree */ 54 this->nodes = new QuadtreeNode*[(int)pow(4 , treeDepth)];54 this->nodes = new QuadtreeNode*[(int)pow(4.0, treeDepth)]; 55 55 int index = 0; //new int; *index = 0; // !!changed by bensch!! 56 for(int i = 0; i < (int)pow(2 , treeDepth); ++i)56 for(int i = 0; i < (int)pow(2.0, treeDepth); ++i) 57 57 { 58 58 this->rootNode->buildHashTable(this->nodes, &index); … … 70 70 this->offset->x = xOff; 71 71 this->offset->z = yOff; 72 this->maxIndex = (int)pow(2 , this->treeDepth);72 this->maxIndex = (int)pow(2.0, this->treeDepth); 73 73 } 74 74 … … 103 103 void Quadtree::revertHashTable(QuadtreeNode** nodes) 104 104 { 105 int len = (int)pow(2 , this->treeDepth); //!< the length of a quadtree side105 int len = (int)pow(2.0, this->treeDepth); //!< the length of a quadtree side 106 106 int iterator = 0; //!< iterator used for mapping 107 107 QuadtreeNode* tmpNode = NULL; //!< temp saving place … … 132 132 void Quadtree::sortHashTable(QuadtreeNode** nodes) 133 133 { 134 int len = (int)pow(2 , this->treeDepth); //!< the length of a quadtree side134 int len = (int)pow(2.0, this->treeDepth); //!< the length of a quadtree side 135 135 float a; //!< temp place for float a 136 136 float b; //!< temp place for float b … … 207 207 { 208 208 //this->rootNode->drawTree(); 209 for(int i = 0; i < (int)pow(4 , this->treeDepth); ++i)209 for(int i = 0; i < (int)pow(4.0, this->treeDepth); ++i) 210 210 { 211 211 this->nodes[i]->draw(); -
trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r6022 r9110 164 164 165 165 /* offset #of elements in a row #of rows in a quadtree */ 166 int threshold = this->nodeIter + (int)pow(2 , this->maxDepth) * (int)pow(2, maxDepth - treeDepth - 1);166 int threshold = this->nodeIter + (int)pow(2.0, this->maxDepth) * (int)pow(2.0, maxDepth - treeDepth - 1); 167 167 int loopLimit = (*index < threshold)?2:4; 168 168 -
trunk/src/lib/gui/gl/glgui_box.cc
r8717 r9110 59 59 void GLGuiBox::unpack(GLGuiWidget* widget) 60 60 { 61 assert(widget == NULL);61 assert(widget != NULL); 62 62 63 63 std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget); -
trunk/src/lib/gui/gtk/gui_gtk.cc
r8145 r9110 30 30 #include <string.h> 31 31 #include <stdlib.h> 32 #include < math.h>32 #include <cmath> 33 33 34 34 using namespace std; -
trunk/src/lib/math/curve.cc
r5232 r9110 29 29 #include "debug.h" 30 30 31 #include < math.h>31 #include <cmath> 32 32 #include <stdio.h> 33 33 -
trunk/src/lib/math/line.h
r6617 r9110 24 24 #define __LINE_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 27 #include "vector.h" -
trunk/src/lib/math/matrix.cc
r7711 r9110 14 14 */ 15 15 #include "matrix.h" 16 #include < math.h>16 #include <cmath> 17 17 18 18 #ifdef DEBUG -
trunk/src/lib/math/matrix.h
r5698 r9110 4 4 */ 5 5 6 #include <math.h>7 6 #include "vector.h" 8 7 -
trunk/src/lib/math/plane.h
r7711 r9110 24 24 #define __PLANE_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 27 #include "vector.h" -
trunk/src/lib/math/quaternion.cc
r8731 r9110 28 28 #define PRINT(x) printf 29 29 #endif 30 31 using namespace std;32 30 33 31 ///////////////// … … 58 56 m[0][1] = x.y; 59 57 m[0][2] = x.z; 60 m[0][3] = 0 ;58 m[0][3] = 0.0; 61 59 m[1][0] = y.x; 62 60 m[1][1] = y.y; 63 61 m[1][2] = y.z; 64 m[1][3] = 0 ;62 m[1][3] = 0.0; 65 63 m[2][0] = z.x; 66 64 m[2][1] = z.y; 67 65 m[2][2] = z.z; 68 m[2][3] = 0 ;69 m[3][0] = 0 ;70 m[3][1] = 0 ;71 m[3][2] = 0 ;72 m[3][3] = 1 ;73 74 *this = Quaternion(m);66 m[2][3] = 0.0; 67 m[3][0] = 0.0; 68 m[3][1] = 0.0; 69 m[3][2] = 0.0; 70 m[3][3] = 1.0; 71 72 this->from4x4(m); 75 73 } 76 74 … … 279 277 * @param m: a 4x4 matrix in glMatrix order 280 278 */ 281 Quaternion::Quaternion(float m[4][4])279 void Quaternion::from4x4(float m[4][4]) 282 280 { 283 281 … … 285 283 int i, j, k; 286 284 287 int nxt[3] = {1, 2, 0};285 static int nxt[3] = {1, 2, 0}; 288 286 289 287 tr = m[0][0] + m[1][1] + m[2][2]; … … 327 325 328 326 /** 329 * Creates a quaternion from a 3x3 rotation matrix.327 * applies a quaternion from a 3x3 rotation matrix. 330 328 * @param mat The 3x3 source rotation matrix. 331 329 * @return The equivalent 4 float quaternion. 332 330 */ 333 Quaternion::Quaternion(float mat[3][3])331 void Quaternion::from3x3(float mat[3][3]) 334 332 { 335 333 int NXT[] = {1, 2, 0}; -
trunk/src/lib/math/quaternion.h
r8894 r9110 24 24 #define __QUATERNION_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 //! PI the circle-constant29 #define PI 3.14159265359f30 27 #include "vector.h" 31 28 … … 39 36 /** creates a Default quaternion (multiplicational identity Quaternion)*/ 40 37 inline Quaternion () { w = 1; v = Vector(0,0,0); } 38 /** Copy constructor @param q the Quaternion to copy. */ 39 inline Quaternion (const Quaternion& q) { w = q.w; v = q.v; }; 41 40 /** creates a Quaternion looking into the direction v @param v: the direction @param f: the value */ 42 41 inline Quaternion (const Vector& v, float f) { this->w = f; this->v = v; } 43 Quaternion (float m[4][4]);44 Quaternion (float m[3][3]);45 42 /** turns a rotation along an axis into a Quaternion @param angle: the amount of radians to rotate @param axis: the axis to rotate around */ 46 43 inline Quaternion (float angle, const Vector& axis) { w = cos(angle/2.0); v = axis * sin(angle/2.0); } 47 44 Quaternion (const Vector& dir, const Vector& up); 48 45 Quaternion (float roll, float pitch, float yaw); 46 47 void from3x3(float m[3][3]); 48 void from4x4(float m[4][4]); 49 49 50 50 51 /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */ -
trunk/src/lib/math/vector.cc
r6617 r9110 29 29 #endif 30 30 31 using namespace std;32 31 33 32 ///////////// … … 40 39 Vector Vector::getNormalized() const 41 40 { 42 float l = this->len();43 if (unlikely(l == 1.0 || l== 0.0))41 float length = this->len(); 42 if (unlikely(length == 0.0)) 44 43 return *this; 45 44 else 46 return (*this / l );45 return (*this / length); 47 46 } 48 47 -
trunk/src/lib/math/vector.h
r8894 r9110 24 24 #define __VECTOR_H_ 25 25 26 #include < math.h>26 #include <cmath> 27 27 #include "compiler.h" 28 28 //! PI the circle-constant … … 42 42 Vector (float x, float y, float z) : x(x), y(y), z(z) {} //!< assignment constructor 43 43 Vector () : x(0), y(0), z(0) {} 44 ~Vector () {}45 44 46 45 /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */ … … 90 89 void scale(const Vector& v) { x *= v.x; y *= v.y; z *= v.z; }; 91 90 /** @returns the length of the vector */ 92 inline float len() const { return sqrt (x*x +y*y+z*z); }91 inline float len() const { return sqrt (x*x + y*y + z*z); } 93 92 /** normalizes the vector */ 94 93 inline void normalize() { float l = len(); if( unlikely(l == 0.0))return; this->x=this->x/l; this->y=this->y/l; this->z=this->z/l; }; -
trunk/src/lib/network/network_game_manager.cc
r9059 r9110 98 98 ClassID playableClassId = rules.getPlayableClassId( userId, team ); 99 99 std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId ); 100 std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId ); 100 101 101 102 BaseObject * bo = Factory::fabricate( playableClassId ); … … 106 107 Playable & playable = *(dynamic_cast<Playable*>(bo)); 107 108 108 if ( playableModel != "" ) 109 if ( playableTexture != "" ) 110 playable.loadMD2Texture( playableTexture ); 111 if ( playableModel != "" ) 109 112 playable.loadModel( playableModel ); 110 113 playable.setOwner( userId ); -
trunk/src/lib/network/player_stats.cc
r8708 r9110 238 238 } 239 239 240 241 242 ScoreList PlayerStats::getScoreList( ) 243 { 244 ScoreList result; 245 246 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 247 248 if ( !list ) 249 { 250 return result; 251 } 252 253 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 254 { 255 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 256 257 TeamScoreList::iterator it = result[stats.getTeamId()].begin(); 258 259 while ( it != result[stats.getTeamId()].end() && stats.score > it->score ) 260 { 261 it++; 262 } 263 264 PlayerScore score; 265 score.name = stats.getNickName(); 266 score.score = stats.getScore(); 267 268 result[stats.getTeamId()].insert(it, score); 269 } 270 271 return result; 272 } -
trunk/src/lib/network/player_stats.h
r8623 r9110 20 20 TEAM_SPECTATOR = -1 21 21 }; 22 23 struct PlayerScore 24 { 25 std::string name; 26 int score; 27 }; 28 typedef std::list<PlayerScore> TeamScoreList; 29 typedef std::map<int,TeamScoreList> ScoreList; 22 30 23 31 //! A class for storing player information … … 62 70 63 71 static void deleteAllPlayerStats(); 72 73 static ScoreList getScoreList(); 64 74 65 75 private: -
trunk/src/lib/network/shared_network_data.cc
r6822 r9110 44 44 */ 45 45 SharedNetworkData::~SharedNetworkData() 46 {} 46 { 47 SharedNetworkData::singletonRef = NULL; 48 } -
trunk/src/lib/network/synchronizeable.cc
r8708 r9110 67 67 { 68 68 if ( this->networkStream ) 69 { 69 70 this->networkStream->disconnectSynchronizeable(*this); 70 71 71 if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) ) 72 NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() ); 72 if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) ) 73 NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() ); 74 } 73 75 74 76 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) -
trunk/src/lib/shell/shell_buffer.cc
r8350 r9110 41 41 ShellBuffer* ShellBuffer::singletonRef = NULL; 42 42 std::list<std::string> ShellBuffer::buffer; 43 char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] ;43 char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] = ""; 44 44 45 45 -
trunk/src/lib/util/loading/game_loader.cc
r8717 r9110 57 57 delete this->currentCampaign; 58 58 this->currentCampaign = NULL; 59 60 GameLoader::singletonRef = NULL; 59 61 } 60 62
Note: See TracChangeset
for help on using the changeset viewer.