MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / buildConvex

Method buildConvex

Engine/source/T3D/shapeBase.cpp:2881–2931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2879}
2880
2881void 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//----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 10

collectGarbageMethod · 0.80
addToWorkingListMethod · 0.80
findNodeTransformMethod · 0.80
isOverlappedMethod · 0.60
mulMethod · 0.45
convolveInverseMethod · 0.45
sizeMethod · 0.45
convolveMethod · 0.45
getTypeMethod · 0.45
registerObjectMethod · 0.45

Tested by

no test coverage detected