| 2879 | } |
| 2880 | |
| 2881 | void ShapeBase::buildConvex(const Box3F& box, Convex* convex) |
| 2882 | { |
| 2883 | if (mShapeInstance == NULL) |
| 2884 | return; |
| 2885 | |
| 2886 | // These should really come out of a pool |
| 2887 | mConvexList->collectGarbage(); |
| 2888 | |
| 2889 | Box3F realBox = box; |
| 2890 | mWorldToObj.mul(realBox); |
| 2891 | realBox.minExtents.convolveInverse(mObjScale); |
| 2892 | realBox.maxExtents.convolveInverse(mObjScale); |
| 2893 | |
| 2894 | if (realBox.isOverlapped(getObjBox()) == false) |
| 2895 | return; |
| 2896 | |
| 2897 | for (U32 i = 0; i < mDataBlock->collisionDetails.size(); i++) |
| 2898 | { |
| 2899 | Box3F newbox = mDataBlock->collisionBounds[i]; |
| 2900 | newbox.minExtents.convolve(mObjScale); |
| 2901 | newbox.maxExtents.convolve(mObjScale); |
| 2902 | mObjToWorld.mul(newbox); |
| 2903 | if (box.isOverlapped(newbox) == false) |
| 2904 | continue; |
| 2905 | |
| 2906 | // See if this hull exists in the working set already... |
| 2907 | Convex* cc = 0; |
| 2908 | CollisionWorkingList& wl = convex->getWorkingList(); |
| 2909 | for (CollisionWorkingList* itr = wl.wLink.mNext; itr != &wl; itr = itr->wLink.mNext) { |
| 2910 | if (itr->mConvex->getType() == ShapeBaseConvexType && |
| 2911 | (static_cast<ShapeBaseConvex*>(itr->mConvex)->pShapeBase == this && |
| 2912 | static_cast<ShapeBaseConvex*>(itr->mConvex)->hullId == i)) { |
| 2913 | cc = itr->mConvex; |
| 2914 | break; |
| 2915 | } |
| 2916 | } |
| 2917 | if (cc) |
| 2918 | continue; |
| 2919 | |
| 2920 | // Create a new convex. |
| 2921 | ShapeBaseConvex* cp = new ShapeBaseConvex; |
| 2922 | mConvexList->registerObject(cp); |
| 2923 | convex->addToWorkingList(cp); |
| 2924 | cp->mObject = this; |
| 2925 | cp->pShapeBase = this; |
| 2926 | cp->hullId = i; |
| 2927 | cp->box = mDataBlock->collisionBounds[i]; |
| 2928 | cp->transform = 0; |
| 2929 | cp->findNodeTransform(); |
| 2930 | } |
| 2931 | } |
| 2932 | |
| 2933 | |
| 2934 | //---------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected