1#ifndef GIM_BOX_SET_H_INCLUDED
2#define GIM_BOX_SET_H_INCLUDED
189template <
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);
425template <
typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
432template <
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)
#define 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
bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane)
test for a triangle, with edges
void merge(const GIM_AABB &box)
Merges a Box.
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
bool has_collision(const GIM_AABB &other) const
void increment_margin(btScalar margin)
Generic Box Tree Template.
_GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager
GUINT getNodeData(GUINT nodeindex) const
GUINT getLeftNodeIndex(GUINT nodeindex) const
void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE &primitive_manager)
const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
GIM_BOX_TREE_TEMPLATE_SET()
_GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
void buildSet()
this rebuild the entire set
bool boxQuery(const GIM_AABB &box, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
bool hasHierarchy() const
tells if this set has hierarcht
GUINT getRightNodeIndex(GUINT nodeindex) const
void update()
node manager prototype functions
_GIM_BOX_TREE_PROTOTYPE m_box_tree
bool isTrimesh() const
tells if this set is a trimesh
GUINT getNodeCount() const
node count
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
void getNodeTriangle(GUINT nodeindex, GIM_TRIANGLE &triangle) const
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
GIM_AABB getGlobalBox() const
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
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
GUINT getScapeNodeIndex(GUINT nodeindex) const
Basic Box tree structure.
GUINT getScapeNodeIndex(GUINT nodeindex) const
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
gim_array< GIM_BOX_TREE_NODE > m_node_array
GUINT getLeftNodeIndex(GUINT nodeindex) const
GUINT getRightNodeIndex(GUINT nodeindex) const
GUINT getNodeData(GUINT nodeindex) const
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)
GUINT getNodeCount() const
node count
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)
prototype functions for box tree management
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.
bool node_collision(GUINT node0, GUINT node1)
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)
void retrieve_node1_triangle(GUINT node1)
void retrieve_node0_triangle(GUINT node0)
GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0
void find_collision_pairs()
BOX_SET_CLASS0 * m_boxset0
void retrieve_node0_info(GUINT node0)
void retrieve_node1_info(GUINT node1)
btTransform trans_cache_0to1
gim_pair_set * m_collision_pairs
Class for colliding triangles.
void get_plane(btVector4 &plane) const
btVector3 can be used to represent 3D points and vectors.
Very simple array container with fast access and simd memory.
void push_back(const GIM_PAIR &obj)
bool reserve(GUINT size)
public operations
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.
GUINT m_data
primitive index if apply
bool is_leaf_node() const