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

Method testPoly

Engine/source/collision/extrudedPolyList.cpp:336–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334//----------------------------------------------------------------------------
335
336bool ExtrudedPolyList::testPoly(ExtrudedFace& face)
337{
338 // Build intial inside/outside plane masks
339 U32 indexStart = 0;
340 U32 indexEnd = mIndexList.size();
341 U32 oVertexSize = mVertexList.size();
342 U32 oIndexSize = mIndexList.size();
343
344 U32 frontMask = 0,backMask = 0;
345 for (U32 i = indexStart; i < indexEnd; i++)
346 {
347 U32 mask = mVertexList[mIndexList[i]].mask & face.planeMask;
348 frontMask |= mask;
349 backMask |= ~mask;
350 }
351
352 // Clip the mPoly against the planes that bound the face...
353 // Trivial accept if all the vertices are on the backsides of
354 // all the planes.
355 if (frontMask)
356 {
357 // Trivial reject if any plane not crossed has all it's points
358 // on the front.
359 U32 crossMask = frontMask & backMask;
360 if (~crossMask & frontMask)
361 return false;
362
363 // Need to do some clipping
364 for (U32 p=0; p < mPlaneList.size(); p++)
365 {
366 U32 pmask = BIT(p);
367 U32 newStart = mIndexList.size();
368
369 // Only test against this plane if we have something
370 // on both sides - otherwise skip.
371 if (!(face.planeMask & crossMask & pmask))
372 continue;
373
374 U32 i1 = indexEnd - 1;
375 U32 mask1 = mVertexList[mIndexList[i1]].mask;
376
377 for (U32 i2 = indexStart; i2 < indexEnd; i2++)
378 {
379 const U32 mask2 = mVertexList[mIndexList[i2]].mask;
380 if ((mask1 ^ mask2) & pmask)
381 {
382 // Clip the edge against the plane.
383 mVertexList.increment();
384 VectorF& v1 = mVertexList[mIndexList[i1]].point;
385 VectorF& v2 = mVertexList[mIndexList[i2]].point;
386 VectorF vv = v2 - v1;
387 F32 t = -mPlaneList[p].distToPlane(v1) / mDot(mPlaneList[p],vv);
388
389 mIndexList.push_back(mVertexList.size() - 1);
390 Vertex& iv = mVertexList.last();
391 iv.point.x = v1.x + vv.x * t;
392 iv.point.y = v1.y + vv.y * t;
393 iv.point.z = v1.z + vv.z * t;

Callers

nothing calls this directly

Calls 8

incrementMethod · 0.80
distToPlaneMethod · 0.80
mDotFunction · 0.50
Point3FClass · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
lastMethod · 0.45
setSizeMethod · 0.45

Tested by

no test coverage detected