summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h')
-rw-r--r--thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h109
1 files changed, 50 insertions, 59 deletions
diff --git a/thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h b/thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h
index e20e03cc1d..3cd8fa24e7 100644
--- a/thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h
+++ b/thirdparty/bullet/BulletCollision/Gimpact/btGImpactBvh.h
@@ -1,5 +1,5 @@
-#ifndef GIM_BOX_SET_H_INCLUDED
-#define GIM_BOX_SET_H_INCLUDED
+#ifndef BT_GIMPACT_BVH_H_INCLUDED
+#define BT_GIMPACT_BVH_H_INCLUDED
/*! \file gim_box_set.h
\author Francisco Leon Najera
@@ -24,7 +24,6 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-
#include "LinearMath/btAlignedObjectArray.h"
#include "btBoxCollision.h"
@@ -32,50 +31,48 @@ subject to the following restrictions:
#include "btGImpactBvhStructs.h"
//! A pairset array
-class btPairSet: public btAlignedObjectArray<GIM_PAIR>
+class btPairSet : public btAlignedObjectArray<GIM_PAIR>
{
public:
btPairSet()
{
reserve(32);
}
- inline void push_pair(int index1,int index2)
+ inline void push_pair(int index1, int index2)
{
- push_back(GIM_PAIR(index1,index2));
+ push_back(GIM_PAIR(index1, index2));
}
- inline void push_pair_inv(int index1,int index2)
+ inline void push_pair_inv(int index1, int index2)
{
- push_back(GIM_PAIR(index2,index1));
+ push_back(GIM_PAIR(index2, index1));
}
};
-class GIM_BVH_DATA_ARRAY:public btAlignedObjectArray<GIM_BVH_DATA>
+class GIM_BVH_DATA_ARRAY : public btAlignedObjectArray<GIM_BVH_DATA>
{
};
-
-class GIM_BVH_TREE_NODE_ARRAY:public btAlignedObjectArray<GIM_BVH_TREE_NODE>
+class GIM_BVH_TREE_NODE_ARRAY : public btAlignedObjectArray<GIM_BVH_TREE_NODE>
{
};
-
-
-
//! Basic Box tree structure
class btBvhTree
{
protected:
int m_num_nodes;
GIM_BVH_TREE_NODE_ARRAY m_node_array;
+
protected:
int _sort_and_calc_splitting_index(
- GIM_BVH_DATA_ARRAY & primitive_boxes,
- int startIndex, int endIndex, int splitAxis);
+ GIM_BVH_DATA_ARRAY& primitive_boxes,
+ int startIndex, int endIndex, int splitAxis);
- int _calc_splitting_axis(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex);
+ int _calc_splitting_axis(GIM_BVH_DATA_ARRAY& primitive_boxes, int startIndex, int endIndex);
+
+ void _build_sub_tree(GIM_BVH_DATA_ARRAY& primitive_boxes, int startIndex, int endIndex);
- void _build_sub_tree(GIM_BVH_DATA_ARRAY & primitive_boxes, int startIndex, int endIndex);
public:
btBvhTree()
{
@@ -84,7 +81,7 @@ public:
//! prototype functions for box tree management
//!@{
- void build_tree(GIM_BVH_DATA_ARRAY & primitive_boxes);
+ void build_tree(GIM_BVH_DATA_ARRAY& primitive_boxes);
SIMD_FORCE_INLINE void clearNodes()
{
@@ -109,25 +106,25 @@ public:
return m_node_array[nodeindex].getDataIndex();
}
- SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const
+ SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB& bound) const
{
bound = m_node_array[nodeindex].m_bound;
}
- SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+ SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB& bound)
{
m_node_array[nodeindex].m_bound = bound;
}
SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
{
- return nodeindex+1;
+ return nodeindex + 1;
}
SIMD_FORCE_INLINE int getRightNode(int nodeindex) const
{
- if(m_node_array[nodeindex+1].isLeafNode()) return nodeindex+2;
- return nodeindex+1 + m_node_array[nodeindex+1].getEscapeIndex();
+ if (m_node_array[nodeindex + 1].isLeafNode()) return nodeindex + 2;
+ return nodeindex + 1 + m_node_array[nodeindex + 1].getEscapeIndex();
}
SIMD_FORCE_INLINE int getEscapeNodeIndex(int nodeindex) const
@@ -135,7 +132,7 @@ public:
return m_node_array[nodeindex].getEscapeIndex();
}
- SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE * get_node_pointer(int index = 0) const
+ SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE* get_node_pointer(int index = 0) const
{
return &m_node_array[index];
}
@@ -143,7 +140,6 @@ public:
//!@}
};
-
//! Prototype Base class for primitive classification
/*!
This class is a wrapper for primitive collections.
@@ -153,18 +149,16 @@ This class can manage Compound shapes and trimeshes, and if it is managing trime
class btPrimitiveManagerBase
{
public:
-
virtual ~btPrimitiveManagerBase() {}
//! determines if this manager consist on only triangles, which special case will be optimized
virtual bool is_trimesh() const = 0;
virtual int get_primitive_count() const = 0;
- virtual void get_primitive_box(int prim_index ,btAABB & primbox) const = 0;
+ virtual void get_primitive_box(int prim_index, btAABB& primbox) const = 0;
//! retrieves only the points of the triangle, and the collision margin
- virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const= 0;
+ virtual void get_primitive_triangle(int prim_index, btPrimitiveTriangle& triangle) const = 0;
};
-
//! Structure for containing Boxes
/*!
This class offers an structure for managing a box tree of primitives.
@@ -174,13 +168,13 @@ class btGImpactBvh
{
protected:
btBvhTree m_box_tree;
- btPrimitiveManagerBase * m_primitive_manager;
+ btPrimitiveManagerBase* m_primitive_manager;
protected:
//stackless refit
void refit();
-public:
+public:
//! this constructor doesn't build the tree. you must call buildSet
btGImpactBvh()
{
@@ -188,31 +182,30 @@ public:
}
//! this constructor doesn't build the tree. you must call buildSet
- btGImpactBvh(btPrimitiveManagerBase * primitive_manager)
+ btGImpactBvh(btPrimitiveManagerBase* primitive_manager)
{
m_primitive_manager = primitive_manager;
}
- SIMD_FORCE_INLINE btAABB getGlobalBox() const
+ SIMD_FORCE_INLINE btAABB getGlobalBox() const
{
btAABB totalbox;
getNodeBound(0, totalbox);
return totalbox;
}
- SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase * primitive_manager)
+ SIMD_FORCE_INLINE void setPrimitiveManager(btPrimitiveManagerBase* primitive_manager)
{
m_primitive_manager = primitive_manager;
}
- SIMD_FORCE_INLINE btPrimitiveManagerBase * getPrimitiveManager() const
+ SIMD_FORCE_INLINE btPrimitiveManagerBase* getPrimitiveManager() const
{
return m_primitive_manager;
}
-
-//! node manager prototype functions
-///@{
+ //! node manager prototype functions
+ ///@{
//! this attemps to refit the box set.
SIMD_FORCE_INLINE void update()
@@ -224,21 +217,21 @@ public:
void buildSet();
//! returns the indices of the primitives in the m_primitive_manager
- bool boxQuery(const btAABB & box, btAlignedObjectArray<int> & collided_results) const;
+ bool boxQuery(const btAABB& box, btAlignedObjectArray<int>& collided_results) const;
//! returns the indices of the primitives in the m_primitive_manager
- SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB & box,
- const btTransform & transform, btAlignedObjectArray<int> & collided_results) const
+ SIMD_FORCE_INLINE bool boxQueryTrans(const btAABB& box,
+ const btTransform& transform, btAlignedObjectArray<int>& collided_results) const
{
- btAABB transbox=box;
+ btAABB transbox = box;
transbox.appy_transform(transform);
- return boxQuery(transbox,collided_results);
+ return boxQuery(transbox, collided_results);
}
//! returns the indices of the primitives in the m_primitive_manager
bool rayQuery(
- const btVector3 & ray_dir,const btVector3 & ray_origin ,
- btAlignedObjectArray<int> & collided_results) const;
+ const btVector3& ray_dir, const btVector3& ray_origin,
+ btAlignedObjectArray<int>& collided_results) const;
//! tells if this set has hierarcht
SIMD_FORCE_INLINE bool hasHierarchy() const
@@ -247,7 +240,7 @@ public:
}
//! tells if this set is a trimesh
- SIMD_FORCE_INLINE bool isTrimesh() const
+ SIMD_FORCE_INLINE bool isTrimesh() const
{
return m_primitive_manager->is_trimesh();
}
@@ -269,17 +262,16 @@ public:
return m_box_tree.getNodeData(nodeindex);
}
- SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB & bound) const
+ SIMD_FORCE_INLINE void getNodeBound(int nodeindex, btAABB& bound) const
{
m_box_tree.getNodeBound(nodeindex, bound);
}
- SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB & bound)
+ SIMD_FORCE_INLINE void setNodeBound(int nodeindex, const btAABB& bound)
{
m_box_tree.setNodeBound(nodeindex, bound);
}
-
SIMD_FORCE_INLINE int getLeftNode(int nodeindex) const
{
return m_box_tree.getLeftNode(nodeindex);
@@ -295,24 +287,23 @@ public:
return m_box_tree.getEscapeNodeIndex(nodeindex);
}
- SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex,btPrimitiveTriangle & triangle) const
+ SIMD_FORCE_INLINE void getNodeTriangle(int nodeindex, btPrimitiveTriangle& triangle) const
{
- m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex),triangle);
+ m_primitive_manager->get_primitive_triangle(getNodeData(nodeindex), triangle);
}
-
- SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE * get_node_pointer(int index = 0) const
+ SIMD_FORCE_INLINE const GIM_BVH_TREE_NODE* get_node_pointer(int index = 0) const
{
return m_box_tree.get_node_pointer(index);
}
#ifdef TRI_COLLISION_PROFILING
static float getAverageTreeCollisionTime();
-#endif //TRI_COLLISION_PROFILING
+#endif //TRI_COLLISION_PROFILING
- static void find_collision(btGImpactBvh * boxset1, const btTransform & trans1,
- btGImpactBvh * boxset2, const btTransform & trans2,
- btPairSet & collision_pairs);
+ static void find_collision(btGImpactBvh* boxset1, const btTransform& trans1,
+ btGImpactBvh* boxset2, const btTransform& trans2,
+ btPairSet& collision_pairs);
};
-#endif // GIM_BOXPRUNING_H_INCLUDED
+#endif // BT_GIMPACT_BVH_H_INCLUDED