1 #ifndef GIM_BOX_SET_H_INCLUDED
2 #define GIM_BOX_SET_H_INCLUDED
189 template <
typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE,
typename _GIM_BOX_TREE_PROTOTYPE>
269 for (
GUINT i = 0; i < primitive_boxes.
size(); i++)
272 primitive_boxes[i].
m_data = i;
284 while (curIndex < numNodes)
294 if (isleafnode && aabbOverlap)
299 if (aabbOverlap || isleafnode)
310 if (collided_results.
size() > 0)
return true;
320 return boxQuery(transbox, collided_results);
331 while (curIndex < numNodes)
338 bool aabbOverlap = bound.
collide_ray(ray_origin, ray_dir);
341 if (isleafnode && aabbOverlap)
346 if (aabbOverlap || isleafnode)
357 if (collided_results.
size() > 0)
return true;
402 return m_box_tree.getLeftNodeIndex(nodeindex);
407 return m_box_tree.getRightNodeIndex(nodeindex);
412 return m_box_tree.getScapeNodeIndex(nodeindex);
425 template <
typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
432 template <
typename BOX_SET_CLASS0,
typename BOX_SET_CLASS1>
513 if (!
result)
return false;
527 if (!
result)
return false;
542 if (!
result)
return false;
557 while (stack_collisions.
size())
596 stack_collisions.
push_pair(left0, left1);
598 stack_collisions.
push_pair(left0, right1);
600 stack_collisions.
push_pair(right0, left1);
602 stack_collisions.
push_pair(right0, right1);
613 BOX_SET_CLASS1* boxset2,
const btTransform& trans2,
614 gim_pair_set& collision_pairs,
bool complete_primitive_tests =
true)
625 if (complete_primitive_tests)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
#define SIMD_FORCE_INLINE
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
SIMD_FORCE_INLINE bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
SIMD_FORCE_INLINE bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane)
test for a triangle, with edges
SIMD_FORCE_INLINE bool has_collision(const GIM_AABB &other) const
SIMD_FORCE_INLINE void merge(const GIM_AABB &box)
Merges a Box.
SIMD_FORCE_INLINE void increment_margin(btScalar margin)
SIMD_FORCE_INLINE void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
SIMD_FORCE_INLINE bool overlapping_trans_cache(const GIM_AABB &box, const GIM_BOX_BOX_TRANSFORM_CACHE &transcache, bool fulltest)
transcache is the transformation cache from box to this AABB
Generic Box Tree Template.
_GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager
SIMD_FORCE_INLINE void update()
this attemps to refit the box set.
SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
SIMD_FORCE_INLINE bool hasHierarchy() const
tells if this set has hierarcht
SIMD_FORCE_INLINE bool boxQuery(const GIM_AABB &box, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
SIMD_FORCE_INLINE void getNodeTriangle(GUINT nodeindex, GIM_TRIANGLE &triangle) const
SIMD_FORCE_INLINE GUINT getNodeCount() const
node count
GIM_BOX_TREE_TEMPLATE_SET()
SIMD_FORCE_INLINE bool isTrimesh() const
tells if this set is a trimesh
SIMD_FORCE_INLINE void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE &primitive_manager)
SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const
SIMD_FORCE_INLINE bool boxQueryTrans(const GIM_AABB &box, const btTransform &transform, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
_GIM_BOX_TREE_PROTOTYPE m_box_tree
SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
_GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
SIMD_FORCE_INLINE void buildSet()
this rebuild the entire set
SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
SIMD_FORCE_INLINE void refit()
SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const
SIMD_FORCE_INLINE GIM_AABB getGlobalBox() const
SIMD_FORCE_INLINE bool rayQuery(const btVector3 &ray_dir, const btVector3 &ray_origin, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
Basic Box tree structure.
SIMD_FORCE_INLINE GUINT getScapeNodeIndex(GUINT nodeindex) const
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
gim_array< GIM_BOX_TREE_NODE > m_node_array
SIMD_FORCE_INLINE GUINT getLeftNodeIndex(GUINT nodeindex) const
SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
SIMD_FORCE_INLINE void clearNodes()
SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
GUINT _sort_and_calc_splitting_index(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex, GUINT splitAxis)
SIMD_FORCE_INLINE GUINT getNodeData(GUINT nodeindex) const
SIMD_FORCE_INLINE GUINT getNodeCount() const
node count
SIMD_FORCE_INLINE GUINT getRightNodeIndex(GUINT nodeindex) const
void _build_sub_tree(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
void build_tree(gim_array< GIM_AABB_DATA > &primitive_boxes)
stackless build tree
Prototype Base class for primitive classification.
virtual void get_primitive_box(GUINT prim_index, GIM_AABB &primbox)=0
virtual GUINT get_primitive_count()=0
virtual bool is_trimesh()=0
determines if this manager consist on only triangles, which special case will be optimized
virtual ~GIM_PRIMITIVE_MANAGER_PROTOTYPE()
virtual void get_primitive_triangle(GUINT prim_index, GIM_TRIANGLE &triangle)=0
GIM_BOX_SET collision methods.
BOX_SET_CLASS1 * m_boxset1
void find_collision(BOX_SET_CLASS0 *boxset1, const btTransform &trans1, BOX_SET_CLASS1 *boxset2, const btTransform &trans2, gim_pair_set &collision_pairs, bool complete_primitive_tests=true)
SIMD_FORCE_INLINE void retrieve_node0_triangle(GUINT node0)
SIMD_FORCE_INLINE void retrieve_node1_triangle(GUINT node1)
SIMD_FORCE_INLINE void retrieve_node0_info(GUINT node0)
GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0
void find_collision_pairs()
SIMD_FORCE_INLINE bool node_collision(GUINT node0, GUINT node1)
SIMD_FORCE_INLINE void retrieve_node1_info(GUINT node1)
BOX_SET_CLASS0 * m_boxset0
btTransform trans_cache_0to1
gim_pair_set * m_collision_pairs
Class for colliding triangles.
SIMD_FORCE_INLINE void get_plane(btVector4 &plane) const
Very simple array container with fast access and simd memory.
void push_back(const GIM_PAIR &obj)
void resize(GUINT size, bool call_constructor=true, const T &fillData=T())
void push_pair(GUINT index1, GUINT index2)
void push_pair_inv(GUINT index1, GUINT index2)
#define G_UINT_INFINITY
A very very high value.
Node Structure for trees.
GUINT m_escapeIndex
Scape index for traversing.
GUINT m_left
Left subtree.
GUINT m_right
Right subtree.
SIMD_FORCE_INLINE bool is_leaf_node() const
GUINT m_data
primitive index if apply