1#ifndef GIM_BOX_COLLISION_H_INCLUDED
2#define GIM_BOX_COLLISION_H_INCLUDED
100#ifndef TEST_CROSS_EDGE_BOX_MCR
102#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
104 const btScalar dir0 = -edge[i_dir_0];\
105 const btScalar dir1 = edge[i_dir_1];\
106 btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
107 btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
110 GIM_SWAP_NUMBERS(pmin,pmax); \
112 const btScalar abs_dir0 = absolute_edge[i_dir_0];\
113 const btScalar abs_dir1 = absolute_edge[i_dir_1];\
114 const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
115 if(pmin>rad || -rad>pmax) return false;\
120#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
122 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
125#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
127 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
130#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
132 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
196#ifndef BOX_PLANE_EPSILON
197#define BOX_PLANE_EPSILON 0.000001f
292 template<
typename CLASS_POINT>
307 template<
typename CLASS_POINT>
335 center =
trans(center);
338 trans.getBasis().getRow(1).absolute(),
339 trans.getBasis().getRow(2).absolute());
358 template<
typename CLASS_POINT>
578#ifndef BT_BOX_COLLISION_H_INCLUDED
582 if(!(
t1.getOrigin() ==
t2.getOrigin()) )
return false;
584 if(!(
t1.getBasis().getRow(0) ==
t2.getBasis().getRow(0)) )
return false;
585 if(!(
t1.getBasis().getRow(1) ==
t2.getBasis().getRow(1)) )
return false;
586 if(!(
t1.getBasis().getRow(2) ==
t2.getBasis().getRow(2)) )
return false;
const T & btMax(const T &a, const T &b)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btFabs(btScalar x)
#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
void calc_from_triangle(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3)
bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane)
test for a triangle, with edges
void projection_interval(const btVector3 &direction, btScalar &vmin, btScalar &vmax) const
void merge(const GIM_AABB &box)
Merges a Box.
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
GIM_AABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3, GREAL margin)
void copy_with_margin(const GIM_AABB &other, btScalar margin)
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
void merge_point(const CLASS_POINT &point)
Merges a point.
bool collide_plane(const btVector4 &plane)
Simple test for planes.
bool overlapping_trans_conservative(const GIM_AABB &box, btTransform &trans1_to_0)
GIM_AABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3)
bool has_collision(const GIM_AABB &other) const
void increment_margin(btScalar margin)
GIM_AABB(const GIM_AABB &other, btScalar margin)
GIM_AABB(const GIM_AABB &other)
void calc_from_triangle_margin(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3, btScalar margin)
void find_intersection(const GIM_AABB &other, GIM_AABB &intersection) const
Finds the intersecting box between this box and the other.
void get_center_extend(btVector3 ¢er, btVector3 &extend) const
Gets the extend and center.
ePLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btMatrix3x3 inverse() const
Return the inverse of the matrix.
btMatrix3x3 transpose() const
Return the transpose of the matrix.
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
btVector3 can be used to represent 3D points and vectors.
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
btVector3 absolute() const
Return a vector will the absolute values of each element.
#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
bool btCompareTransformsEqual(const btTransform &t1, const btTransform &t2)
Compairison of transformation objects.
#define BOX_PLANE_EPSILON
GREAL mat4f[4][4]
Matrix 4D, row ordered.
#define COPY_MATRIX_3X3(b, a)
#define MAT_GET_TRANSLATION(mat, vec3)
Get the triple(3) col of a transform matrix.
#define MAT_DOT_COL(mat, vec3, colindex)
Returns the dot product between a vec3f and the col of a matrix.
#define GIM_GREATER(x, y)
#define GIM_MIN3(a, b, c)
#define GIM_MAX3(a, b, c)