aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h
diff options
context:
space:
mode:
authorSheikh Dawood <[email protected]>2018-04-09 10:13:48 -0500
committerSheikh Dawood <[email protected]>2018-04-09 10:13:48 -0500
commit238605d8225a9135d6b60646e05d066e25424eee (patch)
tree2b013bd4946bb3c699d7a06ef1f21be85d367f63 /PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h
parentAdd ParamTool.exe (diff)
downloadphysx-3.4-238605d8225a9135d6b60646e05d066e25424eee.tar.xz
physx-3.4-238605d8225a9135d6b60646e05d066e25424eee.zip
PhysX 3.4, APEX 1.4 patch release @23879214
Diffstat (limited to 'PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h')
-rw-r--r--PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h107
1 files changed, 1 insertions, 106 deletions
diff --git a/PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h b/PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h
index 376de64a..7444299e 100644
--- a/PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h
+++ b/PhysX_3.4/Source/SceneQuery/src/SqAABBTree.h
@@ -35,6 +35,7 @@
#include "PsUserAllocated.h"
#include "PsVecMath.h"
#include "SqTypedef.h"
+#include "SqAABBTreeBuild.h"
#include "PsArray.h"
namespace physx
@@ -91,80 +92,6 @@ namespace Sq
PxU32 mSize; //!< Size of the array in dwords
};
- //! Contains AABB-tree build statistics
- struct BuildStats
- {
- BuildStats() : mCount(0), mTotalPrims(0) {}
-
- PxU32 mCount; //!< Number of nodes created
- PxU32 mTotalPrims; //!< Total accumulated number of primitives. Should be much higher than the source
- //!< number of prims, since it accumulates all prims covered by each node (i.e. internal
- //!< nodes too, not just leaf ones)
-
- PX_FORCE_INLINE void reset() { mCount = mTotalPrims = 0; }
-
- PX_FORCE_INLINE void setCount(PxU32 nb) { mCount=nb; }
- PX_FORCE_INLINE void increaseCount(PxU32 nb) { mCount+=nb; }
- PX_FORCE_INLINE PxU32 getCount() const { return mCount; }
- };
-
- //! Contains AABB-tree build parameters
- class AABBTreeBuildParams : public Ps::UserAllocated
- {
- public:
- AABBTreeBuildParams(PxU32 limit=1, PxU32 nb_prims=0, const PxBounds3* boxes=NULL) :
- mLimit(limit), mNbPrimitives(nb_prims), mAABBArray(boxes), mCache(NULL) {}
- ~AABBTreeBuildParams()
- {
- reset();
- }
-
- PX_FORCE_INLINE void reset()
- {
- mLimit = mNbPrimitives = 0;
- mAABBArray = NULL;
- PX_FREE_AND_RESET(mCache);
- }
-
- PxU32 mLimit; //!< Limit number of primitives / node. If limit is 1, build a complete tree (2*N-1 nodes)
- PxU32 mNbPrimitives; //!< Number of (source) primitives.
- const PxBounds3* mAABBArray; //!< Shortcut to an app-controlled array of AABBs.
- PxVec3* mCache; //!< Cache for AABB centers - managed by build code.
- };
-
- class NodeAllocator;
-
- //! AABB tree node used for building
- class AABBTreeBuildNode : public Ps::UserAllocated
- {
- public:
- PX_FORCE_INLINE AABBTreeBuildNode() {}
- PX_FORCE_INLINE ~AABBTreeBuildNode() {}
-
- PX_FORCE_INLINE const PxBounds3& getAABB() const { return mBV; }
- PX_FORCE_INLINE const AABBTreeBuildNode* getPos() const { return mPos; }
- PX_FORCE_INLINE const AABBTreeBuildNode* getNeg() const { const AABBTreeBuildNode* P = mPos; return P ? P+1 : NULL; }
-
- PX_FORCE_INLINE bool isLeaf() const { return !getPos(); }
-
- PxBounds3 mBV; //!< Global bounding-volume enclosing all the node-related primitives
- const AABBTreeBuildNode* mPos; //!< "Positive" & "Negative" children
-
- PxU32 mNodeIndex; //!< Index of node-related primitives (in the tree's mIndices array)
- PxU32 mNbPrimitives; //!< Number of primitives for this node
-
- // Data access
- PX_FORCE_INLINE PxU32 getNbPrimitives() const { return mNbPrimitives; }
-
- PX_FORCE_INLINE PxU32 getNbRuntimePrimitives() const { return mNbPrimitives; }
- PX_FORCE_INLINE void setNbRunTimePrimitives(PxU32 val) { mNbPrimitives = val; }
- PX_FORCE_INLINE const PxU32* getPrimitives(const PxU32* base) const { return base+mNodeIndex; }
- PX_FORCE_INLINE PxU32* getPrimitives(PxU32* base) { return base+mNodeIndex; }
-
- // Internal methods
- void subdivide(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
- void _buildHierarchy(AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
- };
//! AABB tree node used for runtime (smaller than for build)
class AABBTreeRuntimeNode : public Ps::UserAllocated
@@ -254,38 +181,6 @@ namespace Sq
class FIFOStack;
//~Progressive building
- //! For complete trees we can predict the final number of nodes and preallocate them. For incomplete trees we can't.
- //! But we don't want to allocate nodes one by one (which would be quite slow), so we use this helper class to
- //! allocate N nodes at once, while minimizing the amount of nodes allocated for nothing. An initial amount of
- //! nodes is estimated using the max number for a complete tree, and the user-defined number of primitives per leaf.
- //! In ideal cases this estimated number will be quite close to the final number of nodes. When that number is not
- //! enough though, slabs of N=1024 extra nodes are allocated until the build is complete.
- class NodeAllocator : public Ps::UserAllocated
- {
- public:
- NodeAllocator();
- ~NodeAllocator();
-
- void release();
- void init(PxU32 nbPrimitives, PxU32 limit);
- void flatten(AABBTreeRuntimeNode* dest);
- AABBTreeBuildNode* getBiNode();
-
- AABBTreeBuildNode* mPool;
-
- struct Slab
- {
- PX_FORCE_INLINE Slab() {}
- PX_FORCE_INLINE Slab(AABBTreeBuildNode* pool, PxU32 nbUsedNodes, PxU32 maxNbNodes) : mPool(pool), mNbUsedNodes(nbUsedNodes), mMaxNbNodes(maxNbNodes) {}
- AABBTreeBuildNode* mPool;
- PxU32 mNbUsedNodes;
- PxU32 mMaxNbNodes;
- };
- Ps::Array<Slab> mSlabs;
- PxU32 mCurrentSlabIndex;
- PxU32 mTotalNbNodes;
- };
-
//! AABB-tree, N primitives/leaf
class AABBTree : public Ps::UserAllocated
{