summaryrefslogtreecommitdiffhomepage
path: root/Opcode/OPC_AABBTree.h
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-01-30 17:44:05 +0100
committerAki <please@ignore.pl>2022-01-30 17:44:05 +0100
commitc01469dddabe404506ef3a64542e8423f9e11f2c (patch)
tree740f6e0e0811227a6e40aac51ba48057f1166b41 /Opcode/OPC_AABBTree.h
parent51657e10769faa2617d546a06c42e4c62a19bb50 (diff)
downloadstarshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.zip
starshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.tar.gz
starshatter-c01469dddabe404506ef3a64542e8423f9e11f2c.tar.bz2
Converted Opcode and Ice into unix newlines format
Diffstat (limited to 'Opcode/OPC_AABBTree.h')
-rw-r--r--Opcode/OPC_AABBTree.h274
1 files changed, 137 insertions, 137 deletions
diff --git a/Opcode/OPC_AABBTree.h b/Opcode/OPC_AABBTree.h
index 377fbcb..298f482 100644
--- a/Opcode/OPC_AABBTree.h
+++ b/Opcode/OPC_AABBTree.h
@@ -1,137 +1,137 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/*
- * OPCODE - Optimized Collision Detection
- * Copyright (C) 2001 Pierre Terdiman
- * Homepage: http://www.codercorner.com/Opcode.htm
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Contains code for a versatile AABB tree.
- * \file OPC_AABBTree.h
- * \author Pierre Terdiman
- * \date March, 20, 2001
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Include Guard
-#ifndef __OPC_AABBTREE_H__
-#define __OPC_AABBTREE_H__
-
-#ifdef OPC_NO_NEG_VANILLA_TREE
- //! TO BE DOCUMENTED
- #define IMPLEMENT_TREE(base_class, volume) \
- public: \
- /* Constructor / Destructor */ \
- base_class(); \
- ~base_class(); \
- /* Data access */ \
- inline_ const volume* Get##volume() const { return &mBV; } \
- /* Clear the last bit */ \
- inline_ const base_class* GetPos() const { return (const base_class*)(mPos&~1); } \
- inline_ const base_class* GetNeg() const { const base_class* P = GetPos(); return P ? P+1 : null;} \
- \
- /* We don't need to test both nodes since we can't have one without the other */ \
- inline_ bool IsLeaf() const { return !GetPos(); } \
- \
- /* Stats */ \
- inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \
- protected: \
- /* Tree-independent data */ \
- /* Following data always belong to the BV-tree, regardless of what the tree actually contains.*/ \
- /* Whatever happens we need the two children and the enclosing volume.*/ \
- volume mBV; /* Global bounding-volume enclosing all the node-related primitives */ \
- udword mPos; /* "Positive" & "Negative" children */
-#else
- //! TO BE DOCUMENTED
- #define IMPLEMENT_TREE(base_class, volume) \
- public: \
- /* Constructor / Destructor */ \
- base_class(); \
- ~base_class(); \
- /* Data access */ \
- inline_ const volume* Get##volume() const { return &mBV; } \
- /* Clear the last bit */ \
- inline_ const base_class* GetPos() const { return (const base_class*)(mPos&~1); } \
- inline_ const base_class* GetNeg() const { return (const base_class*)(mNeg&~1); } \
- \
-/* inline_ bool IsLeaf() const { return (!GetPos() && !GetNeg()); } */ \
- /* We don't need to test both nodes since we can't have one without the other */ \
- inline_ bool IsLeaf() const { return !GetPos(); } \
- \
- /* Stats */ \
- inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \
- protected: \
- /* Tree-independent data */ \
- /* Following data always belong to the BV-tree, regardless of what the tree actually contains.*/ \
- /* Whatever happens we need the two children and the enclosing volume.*/ \
- volume mBV; /* Global bounding-volume enclosing all the node-related primitives */ \
- udword mPos; /* "Positive" child */ \
- udword mNeg; /* "Negative" child */
-#endif
-
- typedef void (*CullingCallback) (udword nb_primitives, udword* node_primitives, BOOL need_clipping, void* user_data);
-
- class OPCODE_API AABBTreeNode
- {
- IMPLEMENT_TREE(AABBTreeNode, AABB)
- public:
- // Data access
- inline_ const udword* GetPrimitives() const { return mNodePrimitives; }
- inline_ udword GetNbPrimitives() const { return mNbPrimitives; }
-
- protected:
- // Tree-dependent data
- udword* mNodePrimitives; //!< Node-related primitives (shortcut to a position in mIndices below)
- udword mNbPrimitives; //!< Number of primitives for this node
- // Internal methods
- udword Split(udword axis, AABBTreeBuilder* builder);
- bool Subdivide(AABBTreeBuilder* builder);
- void _BuildHierarchy(AABBTreeBuilder* builder);
- void _Refit(AABBTreeBuilder* builder);
- };
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * User-callback, called for each node by the walking code.
- * \param current [in] current node
- * \param depth [in] current node's depth
- * \param user_data [in] user-defined data
- * \return true to recurse through children, else false to bypass them
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- typedef bool (*WalkingCallback) (const AABBTreeNode* current, udword depth, void* user_data);
-
- class OPCODE_API AABBTree : public AABBTreeNode
- {
- public:
- // Constructor / Destructor
- AABBTree();
- ~AABBTree();
- // Build
- bool Build(AABBTreeBuilder* builder);
- void Release();
-
- // Data access
- inline_ const udword* GetIndices() const { return mIndices; } //!< Catch the indices
- inline_ udword GetNbNodes() const { return mTotalNbNodes; } //!< Catch the number of nodes
-
- // Infos
- bool IsComplete() const;
- // Stats
- udword ComputeDepth() const;
- udword GetUsedBytes() const;
- udword Walk(WalkingCallback callback, void* user_data) const;
-
- bool Refit(AABBTreeBuilder* builder);
- bool Refit2(AABBTreeBuilder* builder);
- private:
- udword* mIndices; //!< Indices in the app list. Indices are reorganized during build (permutation).
- AABBTreeNode* mPool; //!< Linear pool of nodes for complete trees. Null otherwise. [Opcode 1.3]
- // Stats
- udword mTotalNbNodes; //!< Number of nodes in the tree.
- };
-
-#endif // __OPC_AABBTREE_H__
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+ * OPCODE - Optimized Collision Detection
+ * Copyright (C) 2001 Pierre Terdiman
+ * Homepage: http://www.codercorner.com/Opcode.htm
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains code for a versatile AABB tree.
+ * \file OPC_AABBTree.h
+ * \author Pierre Terdiman
+ * \date March, 20, 2001
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Guard
+#ifndef __OPC_AABBTREE_H__
+#define __OPC_AABBTREE_H__
+
+#ifdef OPC_NO_NEG_VANILLA_TREE
+ //! TO BE DOCUMENTED
+ #define IMPLEMENT_TREE(base_class, volume) \
+ public: \
+ /* Constructor / Destructor */ \
+ base_class(); \
+ ~base_class(); \
+ /* Data access */ \
+ inline_ const volume* Get##volume() const { return &mBV; } \
+ /* Clear the last bit */ \
+ inline_ const base_class* GetPos() const { return (const base_class*)(mPos&~1); } \
+ inline_ const base_class* GetNeg() const { const base_class* P = GetPos(); return P ? P+1 : null;} \
+ \
+ /* We don't need to test both nodes since we can't have one without the other */ \
+ inline_ bool IsLeaf() const { return !GetPos(); } \
+ \
+ /* Stats */ \
+ inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \
+ protected: \
+ /* Tree-independent data */ \
+ /* Following data always belong to the BV-tree, regardless of what the tree actually contains.*/ \
+ /* Whatever happens we need the two children and the enclosing volume.*/ \
+ volume mBV; /* Global bounding-volume enclosing all the node-related primitives */ \
+ udword mPos; /* "Positive" & "Negative" children */
+#else
+ //! TO BE DOCUMENTED
+ #define IMPLEMENT_TREE(base_class, volume) \
+ public: \
+ /* Constructor / Destructor */ \
+ base_class(); \
+ ~base_class(); \
+ /* Data access */ \
+ inline_ const volume* Get##volume() const { return &mBV; } \
+ /* Clear the last bit */ \
+ inline_ const base_class* GetPos() const { return (const base_class*)(mPos&~1); } \
+ inline_ const base_class* GetNeg() const { return (const base_class*)(mNeg&~1); } \
+ \
+/* inline_ bool IsLeaf() const { return (!GetPos() && !GetNeg()); } */ \
+ /* We don't need to test both nodes since we can't have one without the other */ \
+ inline_ bool IsLeaf() const { return !GetPos(); } \
+ \
+ /* Stats */ \
+ inline_ udword GetNodeSize() const { return SIZEOFOBJECT; } \
+ protected: \
+ /* Tree-independent data */ \
+ /* Following data always belong to the BV-tree, regardless of what the tree actually contains.*/ \
+ /* Whatever happens we need the two children and the enclosing volume.*/ \
+ volume mBV; /* Global bounding-volume enclosing all the node-related primitives */ \
+ udword mPos; /* "Positive" child */ \
+ udword mNeg; /* "Negative" child */
+#endif
+
+ typedef void (*CullingCallback) (udword nb_primitives, udword* node_primitives, BOOL need_clipping, void* user_data);
+
+ class OPCODE_API AABBTreeNode
+ {
+ IMPLEMENT_TREE(AABBTreeNode, AABB)
+ public:
+ // Data access
+ inline_ const udword* GetPrimitives() const { return mNodePrimitives; }
+ inline_ udword GetNbPrimitives() const { return mNbPrimitives; }
+
+ protected:
+ // Tree-dependent data
+ udword* mNodePrimitives; //!< Node-related primitives (shortcut to a position in mIndices below)
+ udword mNbPrimitives; //!< Number of primitives for this node
+ // Internal methods
+ udword Split(udword axis, AABBTreeBuilder* builder);
+ bool Subdivide(AABBTreeBuilder* builder);
+ void _BuildHierarchy(AABBTreeBuilder* builder);
+ void _Refit(AABBTreeBuilder* builder);
+ };
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * User-callback, called for each node by the walking code.
+ * \param current [in] current node
+ * \param depth [in] current node's depth
+ * \param user_data [in] user-defined data
+ * \return true to recurse through children, else false to bypass them
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ typedef bool (*WalkingCallback) (const AABBTreeNode* current, udword depth, void* user_data);
+
+ class OPCODE_API AABBTree : public AABBTreeNode
+ {
+ public:
+ // Constructor / Destructor
+ AABBTree();
+ ~AABBTree();
+ // Build
+ bool Build(AABBTreeBuilder* builder);
+ void Release();
+
+ // Data access
+ inline_ const udword* GetIndices() const { return mIndices; } //!< Catch the indices
+ inline_ udword GetNbNodes() const { return mTotalNbNodes; } //!< Catch the number of nodes
+
+ // Infos
+ bool IsComplete() const;
+ // Stats
+ udword ComputeDepth() const;
+ udword GetUsedBytes() const;
+ udword Walk(WalkingCallback callback, void* user_data) const;
+
+ bool Refit(AABBTreeBuilder* builder);
+ bool Refit2(AABBTreeBuilder* builder);
+ private:
+ udword* mIndices; //!< Indices in the app list. Indices are reorganized during build (permutation).
+ AABBTreeNode* mPool; //!< Linear pool of nodes for complete trees. Null otherwise. [Opcode 1.3]
+ // Stats
+ udword mTotalNbNodes; //!< Number of nodes in the tree.
+ };
+
+#endif // __OPC_AABBTREE_H__