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

Method buildConvex

Engine/source/T3D/tsStatic.cpp:1375–1423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1373}
1374
1375void TSStatic::buildConvex(const Box3F& box, Convex* convex)
1376{
1377 if (mCollisionType == None)
1378 return;
1379
1380 if (mShapeInstance == NULL)
1381 return;
1382
1383 // These should really come out of a pool
1384 mConvexList->collectGarbage();
1385
1386 if (mCollisionType == Bounds)
1387 {
1388 // Just return a box convex for the entire shape...
1389 Convex* cc = 0;
1390 CollisionWorkingList& wl = convex->getWorkingList();
1391 for (CollisionWorkingList* itr = wl.wLink.mNext; itr != &wl; itr = itr->wLink.mNext)
1392 {
1393 if (itr->mConvex->getType() == BoxConvexType &&
1394 itr->mConvex->getObject() == this)
1395 {
1396 cc = itr->mConvex;
1397 break;
1398 }
1399 }
1400 if (cc)
1401 return;
1402
1403 // Create a new convex.
1404 BoxConvex* cp = new BoxConvex;
1405 mConvexList->registerObject(cp);
1406 convex->addToWorkingList(cp);
1407 cp->init(this);
1408
1409 mObjBox.getCenter(&cp->mCenter);
1410 cp->mSize.x = mObjBox.len_x() / 2.0f;
1411 cp->mSize.y = mObjBox.len_y() / 2.0f;
1412 cp->mSize.z = mObjBox.len_z() / 2.0f;
1413 }
1414 else // CollisionMesh || VisibleMesh
1415 {
1416 TSStaticPolysoupConvex::smCurObject = this;
1417
1418 for (U32 i = 0; i < mCollisionDetails.size(); i++)
1419 mShapeInstance->buildConvexOpcode(mObjToWorld, mObjScale, mCollisionDetails[i], box, convex, mConvexList);
1420
1421 TSStaticPolysoupConvex::smCurObject = NULL;
1422 }
1423}
1424
1425SceneObject* TSStaticPolysoupConvex::smCurObject = NULL;
1426

Callers

nothing calls this directly

Calls 12

collectGarbageMethod · 0.80
addToWorkingListMethod · 0.80
buildConvexOpcodeMethod · 0.80
getTypeMethod · 0.45
getObjectMethod · 0.45
registerObjectMethod · 0.45
initMethod · 0.45
getCenterMethod · 0.45
len_xMethod · 0.45
len_yMethod · 0.45
len_zMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected