1 #ifndef GIM_BOX_COLLISION_H_INCLUDED
2 #define GIM_BOX_COLLISION_H_INCLUDED
100 #define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
102 const btScalar dir0 = -edge[i_dir_0];\
103 const btScalar dir1 = edge[i_dir_1];\
104 btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
105 btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
108 GIM_SWAP_NUMBERS(pmin,pmax); \
110 const btScalar abs_dir0 = absolute_edge[i_dir_0];\
111 const btScalar abs_dir1 = absolute_edge[i_dir_1];\
112 const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
113 if(pmin>rad || -rad>pmax) return false;\
117 #define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
119 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
122 #define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
124 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
127 #define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
129 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
144 static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
194 #define BOX_PLANE_EPSILON 0.000001f
288 template<
typename CLASS_POINT>
290 const CLASS_POINT & V1,
291 const CLASS_POINT & V2,
292 const CLASS_POINT & V3)
303 template<
typename CLASS_POINT>
305 const CLASS_POINT & V1,
306 const CLASS_POINT & V2,
307 const CLASS_POINT & V3,
btScalar margin)
331 center = trans(center);
337 m_min = center - textends;
338 m_max = center + textends;
354 template<
typename CLASS_POINT>
370 extend =
m_max - center;
410 btScalar Dx = vorigin[0] - center[0];
411 if(
GIM_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f)
return false;
412 btScalar Dy = vorigin[1] - center[1];
413 if(
GIM_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f)
return false;
414 btScalar Dz = vorigin[2] - center[2];
415 if(
GIM_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f)
return false;
418 btScalar f = vdir[1] * Dz - vdir[2] * Dy;
420 f = vdir[2] * Dx - vdir[0] * Dz;
422 f = vdir[0] * Dy - vdir[1] * Dx;
435 vmin = _fOrigin - _fMaximumExtent;
436 vmax = _fOrigin + _fMaximumExtent;
482 T[i] = transcache.
m_R1to0[i].dot(cb) + transcache.
m_T1to0[i] - ca[i];
483 t = transcache.
m_AR[i].dot(eb) + ea[i];
507 t = T[n]*transcache.
m_R1to0[m][j] - T[m]*transcache.
m_R1to0[n][j];
508 t2 = ea[o]*transcache.
m_AR[p][j] + ea[p]*transcache.
m_AR[o][j] +
509 eb[r]*transcache.
m_AR[i][q] + eb[q]*transcache.
m_AR[i][r];
588 #endif // GIM_BOX_COLLISION_H_INCLUDED