Changeset 4658 in orxonox.OLD for orxonox/trunk/src/lib/collision_detection
- Timestamp:
- Jun 20, 2005, 12:54:32 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4648 r4658 383 383 Plane p1(*box->axis[1], *box->center); 384 384 Plane p2(*box->axis[2], *box->center); 385 385 float maxLength[3]; 386 float minLength[3]; 387 388 389 /* get a bad bounding box */ 386 390 halfLength[0] = -1.0f; 387 391 for(int j = 0; j < length; ++j) 388 {389 tmpLength = fabs(p0.distancePoint(vertices[j]));390 if( tmpLength > halfLength[0])391 392 }392 { 393 tmpLength = fabs(p1.distancePoint(vertices[j])); 394 if( tmpLength > halfLength[0]) 395 halfLength[0] = tmpLength; 396 } 393 397 394 398 halfLength[1] = -1.0f; 395 399 for(int j = 0; j < length; ++j) 396 {397 tmpLength = fabs(p1.distancePoint(vertices[j]));398 if( tmpLength > halfLength[1])399 400 }400 { 401 tmpLength = fabs(p1.distancePoint(vertices[j])); 402 if( tmpLength > halfLength[1]) 403 halfLength[1] = tmpLength; 404 } 401 405 402 406 halfLength[2] = -1.0f; 403 407 for(int j = 0; j < length; ++j) 404 { 405 tmpLength = fabs(p2.distancePoint(vertices[j])); 406 if( tmpLength > halfLength[2]) 407 halfLength[2] = tmpLength; 408 } 408 { 409 tmpLength = fabs(p1.distancePoint(vertices[j])); 410 if( tmpLength > halfLength[2]) 411 halfLength[2] = tmpLength; 412 } 413 414 415 416 /* get the maximal dimensions of the body in all directions */ 417 maxLength[0] = 0.0f; 418 minLength[0] = 0.0f; 419 for(int j = 0; j < length; ++j) 420 { 421 tmpLength = p0.distancePoint(vertices[j]); 422 if( tmpLength > maxLength[0]) 423 maxLength[0] = tmpLength; 424 else if( tmpLength < minLength[0]) 425 minLength[0] = tmpLength; 426 } 427 428 maxLength[1] = 0.0f; 429 minLength[1] = 0.0f; 430 for(int j = 0; j < length; ++j) 431 { 432 tmpLength = p0.distancePoint(vertices[j]); 433 if( tmpLength > maxLength[1]) 434 maxLength[1] = tmpLength; 435 else if( tmpLength < minLength[1]) 436 minLength[1] = tmpLength; 437 } 438 439 maxLength[2] = 0.0f; 440 minLength[2] = 0.0f; 441 for(int j = 0; j < length; ++j) 442 { 443 tmpLength = p0.distancePoint(vertices[j]); 444 if( tmpLength > maxLength[2]) 445 maxLength[2] = tmpLength; 446 else if( tmpLength < minLength[2]) 447 minLength[2] = tmpLength; 448 } 449 450 451 /* calculate the real centre of the body by using the axis length */ 452 float center[3]; 453 float offset[3]; 454 for(int i = 0; i < 3; ++i) 455 { 456 center[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative 457 offset[i] = halfLength[i] - center[i]; 458 box->center[i] += *box->axis[i] * offset[i]; // update the new center vector 459 PRINTF(0)("Center Translation Operation: halfLength old: %f, new: %f\n", halfLength[i], center[i]); 460 halfLength[i] = center[i]; 461 } 462 463 409 464 410 465 box->halfLength = halfLength;
Note: See TracChangeset
for help on using the changeset viewer.