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

Method buildConvex

Engine/source/environment/meshRoad.cpp:1636–1861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1634}
1635
1636void MeshRoad::buildConvex(const Box3F& box, Convex* convex)
1637{
1638 if ( mSlices.size() < 2 )
1639 return;
1640
1641 mConvexList->collectGarbage();
1642 mDebugConvex.clear();
1643
1644 Box3F realBox = box;
1645 mWorldToObj.mul(realBox);
1646 realBox.minExtents.convolveInverse(mObjScale);
1647 realBox.maxExtents.convolveInverse(mObjScale);
1648
1649 if (realBox.isOverlapped(getObjBox()) == false)
1650 return;
1651
1652 U32 segmentCount = mSegments.size();
1653
1654 U32 numConvexes ;
1655 U32 halfConvexes;
1656 U32 nextSegOffset = 2*mSideProfile.mNodes.size();
1657 U32 leftSideOffset = nextSegOffset/2;
1658 U32 k2, capIdx1, capIdx2, capIdx3;
1659
1660 // Create convex(s) for each segment
1661 for ( U32 i = 0; i < segmentCount; i++ )
1662 {
1663 const MeshRoadSegment &segment = mSegments[i];
1664
1665 // Is this segment overlapped?
1666 if ( !segment.getWorldBounds().isOverlapped( box ) )
1667 continue;
1668
1669 // Each segment has 6 faces
1670 for ( U32 j = 0; j < 6; j++ )
1671 {
1672 // Only first segment has front face
1673 if ( j == 4 && i != 0 )
1674 continue;
1675 // Only last segment has back face
1676 if ( j == 5 && i != segmentCount-1 )
1677 continue;
1678
1679 // The top and bottom sides have 2 convex(s)
1680 // The left, right, front, and back sides depend on the user-defined profile
1681 switch(j)
1682 {
1683 case 0: numConvexes = 2; break; // Top
1684 case 1: // Left
1685 case 2: numConvexes = 2* (mSideProfile.mNodes.size()-1); break; // Right
1686 case 3: numConvexes = 2; break; // Bottom
1687 case 4: // Front
1688 case 5: numConvexes = mSideProfile.mCap.getNumTris(); break; // Back
1689 default: numConvexes = 0;
1690 }
1691
1692 halfConvexes = numConvexes/2;
1693

Callers

nothing calls this directly

Calls 15

collectGarbageMethod · 0.80
getNumTrisMethod · 0.80
getTriIdxMethod · 0.80
addToWorkingListMethod · 0.80
isOverlappedMethod · 0.60
sizeMethod · 0.45
clearMethod · 0.45
mulMethod · 0.45
convolveInverseMethod · 0.45
getWorldBoundsMethod · 0.45
getTypeMethod · 0.45
registerObjectMethod · 0.45

Tested by

no test coverage detected