29#ifndef GU_BUCKET_PRUNER_H
30#define GU_BUCKET_PRUNER_H
32#include "common/PxPhysXCommonConfig.h"
34#include "GuSqInternal.h"
35#include "GuPruningPool.h"
36#include "foundation/PxHash.h"
38#define FREE_PRUNER_SIZE 16
40#ifdef USE_REGULAR_HASH_MAP
41 #include "foundation/PxHashMap.h"
50 typedef PxU32 BucketWord;
54 #pragma warning( disable : 4324 )
57 PX_ALIGN_PREFIX(16) struct BucketBox
72 return mCenter - mExtents;
77 return mCenter + mExtents;
82 mCenter = PxVec3(0.0f);
83 mExtents = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
86 mDebugMin = PX_MAX_BOUNDS_EXTENTS;
91 PX_ALIGN_PREFIX(16) struct BucketPrunerNode
95 void classifyBoxes(
float limitX,
float limitZ,
103 bool isCrossBucket, PxU32 sortAxis);
107 for(PxU32 i=0;i<5;i++)
109 for(PxU32 i=0;i<5;i++)
113 BucketWord mCounters[5];
114 BucketWord mOffsets[5];
115 BucketBox mBucketBox[5];
117 }PX_ALIGN_SUFFIX(16);
124 const PxU32 h0 = PxU32(PX_MAX_U32 & payload.data[0]);
125 const PxU32 h1 = PxU32(PX_MAX_U32 & payload.data[1]);
126 return physx::PxComputeHash(PxU64(h0)|(PxU64(h1)<<32));
128 return physx::PxComputeHash(PxU64(payload.data[0])|(PxU64(payload.data[1])<<32));
132#ifdef USE_REGULAR_HASH_MAP
133 struct BucketPrunerPair :
public PxUserAllocated
136 PX_FORCE_INLINE BucketPrunerPair(PxU32 index, PxU32 stamp) : mCoreIndex(index), mTimeStamp(stamp) {}
140 typedef PxHashMap<PrunerPayload, BucketPrunerPair> BucketPrunerMap;
160 bool removePair (
const PrunerPayload& payload, PxU32& coreIndex, PxU32& timeStamp);
164 return (PxU32((
size_t(pair) -
size_t(mActivePairs)))/
sizeof(
BucketPrunerPair));
169 PxU32 mNbActivePairs;
173 PxU32 mReservedMemory;
176 void removePairInternal(
const PrunerPayload& payload, PxU32 hashValue, PxU32 pairIndex);
178 void reserveMemory(PxU32 memSize);
193 bool removeObject(
const PrunerPayload&
object, PxU32& timeStamp);
198 PxU32 removeMarkedObjects(PxU32 timeStamp);
204 void getGlobalBounds(
PxBounds3& bounds)
const;
206 void shiftOrigin(
const PxVec3& shift);
212#ifdef FREE_PRUNER_SIZE
213 PX_FORCE_INLINE PxU32 getNbObjects()
const {
return mNbFree + mCoreNbObjects; }
219 PxU32 mCoreNbObjects;
226 BucketBox* mSortedWorldBoxes;
229#ifdef FREE_PRUNER_SIZE
234 PxU32 mFreeStamps[FREE_PRUNER_SIZE];
239 PxU32 mSortedCapacity;
242 BucketBox mGlobalBox;
243 BucketPrunerNode mLevel1;
244 BucketPrunerNode mLevel2[5];
245 BucketPrunerNode mLevel3[5][5];
250 PX_PHYSX_COMMON_API
void classifyBoxes();
251 void allocateSortedMemory(PxU32 nb);
267 DECLARE_BASE_PRUNER_API
271 DECLARE_PRUNER_API_COMMON
Definition GuBucketPruner.h:183
Definition GuBucketPruner.h:151
Definition GuBucketPruner.h:261
Definition GuPruningPool.h:55
Definition GuBounds.h:115
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxRenderOutput.h:50
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition GuBucketPruner.h:143
Definition GuPrunerPayload.h:43