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

Function sort

physx/source/scenequery/src/SqBucketPruner.cpp:935–1039  ·  view source on GitHub ↗

PT: hmmm, by construction, isn't the order always the same for all bucket pruners? => maybe not because the bucket boxes are still around the merged aabbs, not around the bucket Still we could do something here

Source from the content-addressed store, hash-verified

933// => maybe not because the bucket boxes are still around the merged aabbs, not around the bucket
934// Still we could do something here
935static /*PX_FORCE_INLINE*/ PxU32 sort(const BucketPrunerNode& parent, const PxVec3& rayDir)
936{
937 const PxU32 totalCount = parent.mCounters[0]+parent.mCounters[1]+parent.mCounters[2]+parent.mCounters[3]+parent.mCounters[4];
938 if(totalCount<NODE_SORT_MIN_COUNT)
939 return 0|(1<<3)|(2<<6)|(3<<9)|(4<<12);
940
941 float dp[5];
942/* const __m128 rayDirV = _mm_loadu_ps(&rayDir.x);
943 __m128 dp0V = DotV(rayDirV, _mm_loadu_ps(&parent.mBucketBox[0].mCenter.x)); _mm_store_ss(&dp[0], dp0V);
944 __m128 dp1V = DotV(rayDirV, _mm_loadu_ps(&parent.mBucketBox[1].mCenter.x)); _mm_store_ss(&dp[1], dp1V);
945 __m128 dp2V = DotV(rayDirV, _mm_loadu_ps(&parent.mBucketBox[2].mCenter.x)); _mm_store_ss(&dp[2], dp2V);
946 __m128 dp3V = DotV(rayDirV, _mm_loadu_ps(&parent.mBucketBox[3].mCenter.x)); _mm_store_ss(&dp[3], dp3V);
947 __m128 dp4V = DotV(rayDirV, _mm_loadu_ps(&parent.mBucketBox[4].mCenter.x)); _mm_store_ss(&dp[4], dp4V);
948*/
949
950#ifdef VERIFY_SORT
951 PxU32 code;
952 {
953 dp[0] = parent.mCounters[0] ? PxAbs(parent.mBucketBox[0].mCenter.dot(rayDir)) : PX_MAX_F32;
954 dp[1] = parent.mCounters[1] ? PxAbs(parent.mBucketBox[1].mCenter.dot(rayDir)) : PX_MAX_F32;
955 dp[2] = parent.mCounters[2] ? PxAbs(parent.mBucketBox[2].mCenter.dot(rayDir)) : PX_MAX_F32;
956 dp[3] = parent.mCounters[3] ? PxAbs(parent.mBucketBox[3].mCenter.dot(rayDir)) : PX_MAX_F32;
957 dp[4] = parent.mCounters[4] ? PxAbs(parent.mBucketBox[4].mCenter.dot(rayDir)) : PX_MAX_F32;
958
959 PxU32 ii0 = 0;
960 PxU32 ii1 = 1;
961 PxU32 ii2 = 2;
962 PxU32 ii3 = 3;
963 PxU32 ii4 = 4;
964
965 // PT: using integer cmps since we used fabsf above
966 // const PxU32* values = reinterpret_cast<const PxU32*>(dp);
967 const PxU32* values = PxUnionCast<PxU32*, PxF32*>(dp);
968
969 PxU32 value0 = values[0];
970 PxU32 value1 = values[1];
971 PxU32 value2 = values[2];
972 PxU32 value3 = values[3];
973 PxU32 value4 = values[4];
974
975 for(PxU32 j=0;j<5-1;j++)
976 {
977 if(value1<value0)
978 {
979 tswap(value0, value1);
980 tswap(ii0, ii1);
981 }
982 if(value2<value1)
983 {
984 tswap(value1, value2);
985 tswap(ii1, ii2);
986 }
987 if(value3<value2)
988 {
989 tswap(value2, value3);
990 tswap(ii2, ii3);
991 }
992 if(value4<value3)

Callers 2

gPrecomputeSortFunction · 0.70
buildProjectionTreesMethod · 0.50

Calls 3

PxAbsFunction · 0.85
tswapFunction · 0.85
dotMethod · 0.45

Tested by

no test coverage detected