----------------------------------------------------------------------------
| 652 | |
| 653 | //---------------------------------------------------------------------------- |
| 654 | void Item::updateWorkingCollisionSet(const U32 mask, const F32 dt) |
| 655 | { |
| 656 | // It is assumed that we will never accelerate more than 10 m/s for gravity... |
| 657 | // |
| 658 | Point3F scaledVelocity = mVelocity * dt; |
| 659 | F32 len = scaledVelocity.len(); |
| 660 | F32 newLen = len + (10 * dt); |
| 661 | |
| 662 | // Check to see if it is actually necessary to construct the new working list, |
| 663 | // or if we can use the cached version from the last query. We use the x |
| 664 | // component of the min member of the mWorkingQueryBox, which is lame, but |
| 665 | // it works ok. |
| 666 | bool updateSet = false; |
| 667 | |
| 668 | Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale()); |
| 669 | F32 l = (newLen * 1.1) + 0.1; // from Convex::updateWorkingList |
| 670 | convexBox.minExtents -= Point3F(l, l, l); |
| 671 | convexBox.maxExtents += Point3F(l, l, l); |
| 672 | |
| 673 | // Check containment |
| 674 | { |
| 675 | if (mWorkingQueryBox.minExtents.x != -1e9) |
| 676 | { |
| 677 | if (mWorkingQueryBox.isContained(convexBox) == false) |
| 678 | { |
| 679 | // Needed region is outside the cached region. Update it. |
| 680 | updateSet = true; |
| 681 | } |
| 682 | else |
| 683 | { |
| 684 | // We can leave it alone, we're still inside the cached region |
| 685 | } |
| 686 | } |
| 687 | else |
| 688 | { |
| 689 | // Must update |
| 690 | updateSet = true; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | // Actually perform the query, if necessary |
| 695 | if (updateSet == true) |
| 696 | { |
| 697 | mWorkingQueryBox = convexBox; |
| 698 | mWorkingQueryBox.minExtents -= Point3F(2 * l, 2 * l, 2 * l); |
| 699 | mWorkingQueryBox.maxExtents += Point3F(2 * l, 2 * l, 2 * l); |
| 700 | |
| 701 | disableCollision(); |
| 702 | if (mCollisionObject) |
| 703 | mCollisionObject->disableCollision(); |
| 704 | |
| 705 | mConvex.updateWorkingList(mWorkingQueryBox, mask); |
| 706 | |
| 707 | if (mCollisionObject) |
| 708 | mCollisionObject->enableCollision(); |
| 709 | enableCollision(); |
| 710 | } |
| 711 | } |
nothing calls this directly
no test coverage detected