1 #ifndef GIM_BOX_SET_H_INCLUDED
2 #define GIM_BOX_SET_H_INCLUDED
214 template<
typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE,
typename _GIM_BOX_TREE_PROTOTYPE>
293 for (
GUINT i = 0;i<primitive_boxes.
size() ;i++ )
296 primitive_boxes[i].
m_data = i;
308 while (curIndex < numNodes)
318 if (isleafnode && aabbOverlap)
323 if (aabbOverlap || isleafnode)
334 if(collided_results.
size()>0)
return true;
344 return boxQuery(transbox,collided_results);
355 while (curIndex < numNodes)
362 bool aabbOverlap = bound.
collide_ray(ray_origin,ray_dir);
365 if (isleafnode && aabbOverlap)
370 if (aabbOverlap || isleafnode)
381 if(collided_results.
size()>0)
return true;
426 return m_box_tree.getLeftNodeIndex(nodeindex);
431 return m_box_tree.getRightNodeIndex(nodeindex);
436 return m_box_tree.getScapeNodeIndex(nodeindex);
450 template<
typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
462 template<
typename BOX_SET_CLASS0,
typename BOX_SET_CLASS1>
543 if(!result)
return false;
557 if(!result)
return false;
572 if(!result)
return false;
588 while(stack_collisions.
size())
629 stack_collisions.
push_pair(left0,right1);
631 stack_collisions.
push_pair(right0,left1);
633 stack_collisions.
push_pair(right0,right1);
643 BOX_SET_CLASS1 * boxset2,
const btTransform & trans2,
644 gim_pair_set & collision_pairs,
bool complete_primitive_tests =
true)
656 if(complete_primitive_tests)
672 #endif // GIM_BOXPRUNING_H_INCLUDED
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)
_GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager
GUINT m_data
primitive index if apply
BOX_SET_CLASS0 * m_boxset0
void build_tree(gim_array< GIM_AABB_DATA > &primitive_boxes)
prototype functions for box tree management
GUINT m_right
Right subtree.
bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
void push_pair(GUINT index1, GUINT index2)
bool node_collision(GUINT node0, GUINT node1)
BOX_SET_CLASS1 * m_boxset1
GUINT m_left
Left subtree.
GIM_BOX_TREE_TEMPLATE_SET()
GIM_PAIR(GUINT index1, GUINT index2)
#define G_UINT_INFINITY
A very very high value.
GUINT getRightNodeIndex(GUINT nodeindex) const
bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
GIM_BOX_SET collision methods.
void buildSet()
this rebuild the entire set
bool has_collision(const GIM_AABB &other) const
#define SIMD_FORCE_INLINE
void getNodeTriangle(GUINT nodeindex, GIM_TRIANGLE &triangle) const
void resize(GUINT size, bool call_constructor=true, const T &fillData=T())
void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE &primitive_manager)
virtual ~GIM_PRIMITIVE_MANAGER_PROTOTYPE()
GUINT getNodeCount() const
node count
void retrieve_node0_triangle(GUINT node0)
GUINT getRightNodeIndex(GUINT nodeindex) const
_GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
GUINT getNodeCount() const
node count
GUINT getLeftNodeIndex(GUINT nodeindex) const
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
GIM_AABB getGlobalBox() const
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
void get_plane(btVector4 &plane) const
void find_collision_pairs()
bool boxQuery(const GIM_AABB &box, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
GUINT m_escapeIndex
Scape index for traversing.
virtual GUINT get_primitive_count()=0
_GIM_BOX_TREE_PROTOTYPE m_box_tree
GUINT getNodeData(GUINT nodeindex) const
Class for colliding triangles.
void update()
node manager prototype functions
void retrieve_node1_info(GUINT node1)
bool is_leaf_node() const
Very simple array container with fast access and simd memory.
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
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
Basic Box tree structure.
GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0
btVector3 can be used to represent 3D points and vectors.
GUINT getScapeNodeIndex(GUINT nodeindex) const
void push_pair_inv(GUINT index1, GUINT index2)
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
virtual bool is_trimesh()=0
determines if this manager consist on only triangles, which special case will be optimized ...
GUINT getNodeData(GUINT nodeindex) const
void retrieve_node0_info(GUINT node0)
GUINT _sort_and_calc_splitting_index(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex, GUINT splitAxis)
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
gim_pair_set * m_collision_pairs
GIM_PAIR(const GIM_PAIR &p)
virtual void get_primitive_box(GUINT prim_index, GIM_AABB &primbox)=0
virtual void get_primitive_triangle(GUINT prim_index, GIM_TRIANGLE &triangle)=0
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
bool isTrimesh() const
tells if this set is a trimesh
void retrieve_node1_triangle(GUINT node1)
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
Generic Box Tree Template.
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
gim_array< GIM_BOX_TREE_NODE > m_node_array
Prototype Base class for primitive classification.
bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane)
test for a triangle, with edges
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
Node Structure for trees.
bool reserve(GUINT size)
public operations
void push_back(const GIM_PAIR &obj)
const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
btTransform trans_cache_0to1
void increment_margin(btScalar margin)
void merge(const GIM_AABB &box)
Merges a Box.
GUINT getScapeNodeIndex(GUINT nodeindex) const
void _build_sub_tree(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
GUINT getLeftNodeIndex(GUINT nodeindex) const
bool hasHierarchy() const
tells if this set has hierarcht