MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / computeBounds

Method computeBounds

physx/source/lowlevelaabb/src/BpAABBManager.cpp:981–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979}
980
981void Aggregate::computeBounds(const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances) /*PX_RESTRICT*/
982{
983// PX_PROFILE_ZONE("Aggregate::computeBounds",0);
984
985 const PxU32 size = getNbAggregated();
986 PX_ASSERT(size);
987
988 // PT: TODO: delay the conversion to integers until we sort (i.e. really need) the aggregated bounds?
989 PX_ALIGN(16, PxVec4) boxMin;
990 PX_ALIGN(16, PxVec4) boxMax;
991
992 const PxU32 lookAhead = 4;
993 Vec4V minimumV;
994 Vec4V maximumV;
995 {
996 const BoundsIndex index0 = getAggregated(0);
997 const PxU32 last = PxMin(lookAhead, size-1);
998 for(PxU32 i=1;i<=last;i++)
999 {
1000 const BoundsIndex index = getAggregated(i);
1001 Ps::prefetchLine(bounds + index, 0);
1002 Ps::prefetchLine(contactDistances + index, 0);
1003 }
1004 const PxBounds3& b = bounds[index0];
1005 const Vec4V offsetV = V4Load(contactDistances[index0]);
1006 minimumV = V4Sub(V4LoadU(&b.minimum.x), offsetV);
1007 maximumV = V4Add(V4LoadU(&b.maximum.x), offsetV);
1008 V4StoreA(minimumV, &boxMin.x);
1009 V4StoreA(maximumV, &boxMax.x);
1010 mInflatedBoundsX[0].initFromPxVec4(boxMin, boxMax);
1011 mInflatedBoundsYZ[0].initFromPxVec4(boxMin, boxMax);
1012 }
1013
1014 for(PxU32 i=1;i<size;i++)
1015 {
1016 const BoundsIndex index = getAggregated(i);
1017 if(i+lookAhead<size)
1018 {
1019 const BoundsIndex nextIndex = getAggregated(i+lookAhead);
1020 Ps::prefetchLine(bounds + nextIndex, 0);
1021 Ps::prefetchLine(contactDistances + nextIndex, 0);
1022 }
1023 const PxBounds3& b = bounds[index];
1024 const Vec4V offsetV = V4Load(contactDistances[index]);
1025 const Vec4V aggregatedBoundsMinV = V4Sub(V4LoadU(&b.minimum.x), offsetV);
1026 const Vec4V aggregatedBoundsMaxV = V4Add(V4LoadU(&b.maximum.x), offsetV);
1027 minimumV = V4Min(minimumV, aggregatedBoundsMinV);
1028 maximumV = V4Max(maximumV, aggregatedBoundsMaxV);
1029 V4StoreA(aggregatedBoundsMinV, &boxMin.x);
1030 V4StoreA(aggregatedBoundsMaxV, &boxMax.x);
1031 mInflatedBoundsX[i].initFromPxVec4(boxMin, boxMax);
1032 mInflatedBoundsYZ[i].initFromPxVec4(boxMin, boxMax);
1033 }
1034
1035 StoreBounds(mBounds, minimumV, maximumV);
1036// StoreBounds(boundsArray.begin()[mIndex], minimumV, maximumV);
1037// boundsArray.setChangedState();
1038

Callers 4

findOverlapsMethod · 0.45
handleOriginShiftMethod · 0.45
runInternalMethod · 0.45
updateAABBsAndBPMethod · 0.45

Calls 11

PxMinFunction · 0.85
prefetchLineFunction · 0.50
V4LoadFunction · 0.50
V4SubFunction · 0.50
V4LoadUFunction · 0.50
V4AddFunction · 0.50
V4StoreAFunction · 0.50
V4MinFunction · 0.50
V4MaxFunction · 0.50
initFromPxVec4Method · 0.45
initSentinelMethod · 0.45

Tested by

no test coverage detected