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

Method testEdgeCover

Engine/source/navigation/navMesh.cpp:1286–1327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1284}
1285
1286bool NavMesh::testEdgeCover(const Point3F &pos, const VectorF &dir, CoverPointData &data)
1287{
1288 data.peek[0] = data.peek[1] = data.peek[2] = false;
1289 // Get the edge normal.
1290 Point3F norm;
1291 mCross(dir, Point3F(0, 0, 1), &norm);
1292 RayInfo ray;
1293 U32 hits = 0;
1294 for(U32 j = 0; j < CoverPoint::NumSizes; j++)
1295 {
1296 Point3F test = pos + Point3F(0.0f, 0.0f, mWalkableHeight * j / CoverPoint::NumSizes);
1297 if(getContainer()->castRay(test, test + norm * mCoverDist, StaticObjectType, &ray))
1298 {
1299 // Test peeking.
1300 Point3F left = test + dir * mPeekDist;
1301 data.peek[0] = !getContainer()->castRay(test, left, StaticObjectType, &ray)
1302 && !getContainer()->castRay(left, left + norm * mCoverDist, StaticObjectType, &ray);
1303
1304 Point3F right = test - dir * mPeekDist;
1305 data.peek[1] = !getContainer()->castRay(test, right, StaticObjectType, &ray)
1306 && !getContainer()->castRay(right, right + norm * mCoverDist, StaticObjectType, &ray);
1307
1308 Point3F over = test + Point3F(0, 0, 1) * 0.2f;
1309 data.peek[2] = !getContainer()->castRay(test, over, StaticObjectType, &ray)
1310 && !getContainer()->castRay(over, over + norm * mCoverDist, StaticObjectType, &ray);
1311
1312 if(mInnerCover || data.peek[0] || data.peek[1] || data.peek[2])
1313 hits++;
1314 // If we couldn't peek here, we may be able to peek further up.
1315 }
1316 else
1317 // No cover at this height - break off.
1318 break;
1319 }
1320 if(hits > 0)
1321 {
1322 data.size = (CoverPoint::Size)(hits - 1);
1323 data.trans = MathUtils::createOrientFromDir(norm);
1324 data.trans.setPosition(pos);
1325 }
1326 return hits > 0;
1327}
1328
1329void NavMesh::renderToDrawer()
1330{

Callers

nothing calls this directly

Calls 6

createOrientFromDirFunction · 0.85
mCrossFunction · 0.50
Point3FClass · 0.50
getContainerFunction · 0.50
castRayMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected