20 #ifndef __OPC_OPTIMIZEDTREE_H__ 21 #define __OPC_OPTIMIZEDTREE_H__ 23 #if (defined __x86_64) || (defined __aarch64__) 30 #define IMPLEMENT_IMPLICIT_NODE(base_class, volume) \ 33 inline_ base_class() : mData(0) {} \ 34 inline_ ~base_class() {} \ 36 inline_ BOOL IsLeaf() const { return mData&1; } \ 38 inline_ const base_class* GetPos() const { return (base_class*)mData; } \ 39 inline_ const base_class* GetNeg() const { return ((base_class*)mData)+1; } \ 41 inline_ const base_class* GetB() const { return mB; } \ 42 inline_ udword GetPrimitive() const { return (mData>>1); } \ 44 inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \ 52 #define IMPLEMENT_NOLEAF_NODE(base_class, volume) \ 55 inline_ base_class() : mPosData(0), mNegData(0) {} \ 56 inline_ ~base_class() {} \ 58 inline_ BOOL HasPosLeaf() const { return mPosData&1; } \ 59 inline_ BOOL HasNegLeaf() const { return mNegData&1; } \ 61 inline_ const base_class* GetPos() const { return (base_class*)mPosData; } \ 62 inline_ const base_class* GetNeg() const { return (base_class*)mNegData; } \ 64 inline_ const base_class* GetB() const { return mB; } \ 65 inline_ udword GetPosPrimitive() const { return (mPosData>>1); } \ 66 inline_ udword GetNegPrimitive() const { return (mNegData>>1); } \ 68 inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \ 80 inline_ float GetVolume()
const {
return mAABB.mExtents.x * mAABB.mExtents.y * mAABB.mExtents.z; }
86 if(Bits[1]>Max) Max = Bits[1];
87 if(Bits[2]>Max) Max = Bits[2];
106 const uword* Bits = mAABB.mExtents;
108 if(Bits[1]>Max) Max = Bits[1];
109 if(Bits[2]>Max) Max = Bits[2];
127 #define IMPLEMENT_COLLISION_TREE(base_class, node) \ 131 virtual ~base_class(); \ 133 override(AABBOptimizedTree) bool Build(AABBTree* tree); \ 135 override(AABBOptimizedTree) bool Refit(const MeshInterface* mesh_interface); \ 137 override(AABBOptimizedTree) bool Walk(GenericWalkingCallback callback, void* user_data) const; \ 139 inline_ const node* GetNodes() const { return mNodes; } \ 141 override(AABBOptimizedTree) udword GetUsedBytes() const { return mNbNodes*sizeof(node); } \ 162 virtual bool Build(
AABBTree* tree) = 0;
185 virtual udword GetUsedBytes()
const = 0;
220 #endif // __OPC_OPTIMIZEDTREE_H__ unsigned short uword
sizeof(uword) must be 2
inline_ udword GetNbNodes() const
unsigned int udword
sizeof(udword) must be 4
#define IMPLEMENT_NOLEAF_NODE(base_class, volume)
Common interface for a node of a no-leaf tree.
bool(* GenericWalkingCallback)(const void *current, void *user_data)
inline_ float GetSize() const
virtual ~AABBOptimizedTree()
#define IMPLEMENT_IMPLICIT_NODE(base_class, volume)
Common interface for a node of an implicit tree.
inline_ udword GetRadius() const
#define IMPLEMENT_COLLISION_TREE(base_class, node)
Common interface for a collision tree.