Differential D1739 Diff 5899 extern/bullet2/src/BulletCollision/Gimpact/gim_basic_geometry_operations.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletCollision/Gimpact/gim_basic_geometry_operations.h
| Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | |||||
| SIMD_FORCE_INLINE void SEGMENT_COLLISION( | SIMD_FORCE_INLINE void SEGMENT_COLLISION( | ||||
| const CLASS_POINT & vA1, | const CLASS_POINT & vA1, | ||||
| const CLASS_POINT & vA2, | const CLASS_POINT & vA2, | ||||
| const CLASS_POINT & vB1, | const CLASS_POINT & vB1, | ||||
| const CLASS_POINT & vB2, | const CLASS_POINT & vB2, | ||||
| CLASS_POINT & vPointA, | CLASS_POINT & vPointA, | ||||
| CLASS_POINT & vPointB) | CLASS_POINT & vPointB) | ||||
| { | { | ||||
| CLASS_POINT _AD,_BD,_N; | CLASS_POINT _AD,_BD,n; | ||||
| vec4f _M;//plane | vec4f _M;//plane | ||||
| VEC_DIFF(_AD,vA2,vA1); | VEC_DIFF(_AD,vA2,vA1); | ||||
| VEC_DIFF(_BD,vB2,vB1); | VEC_DIFF(_BD,vB2,vB1); | ||||
| VEC_CROSS(_N,_AD,_BD); | VEC_CROSS(n,_AD,_BD); | ||||
| GREAL _tp = VEC_DOT(_N,_N); | GREAL _tp = VEC_DOT(n,n); | ||||
| if(_tp<G_EPSILON)//ARE PARALELE | if(_tp<G_EPSILON)//ARE PARALELE | ||||
| { | { | ||||
| //project B over A | //project B over A | ||||
| bool invert_b_order = false; | bool invert_b_order = false; | ||||
| _M[0] = VEC_DOT(vB1,_AD); | _M[0] = VEC_DOT(vB1,_AD); | ||||
| _M[1] = VEC_DOT(vB2,_AD); | _M[1] = VEC_DOT(vB2,_AD); | ||||
| if(_M[0]>_M[1]) | if(_M[0]>_M[1]) | ||||
| { | { | ||||
| invert_b_order = true; | invert_b_order = true; | ||||
| GIM_SWAP_NUMBERS(_M[0],_M[1]); | GIM_SWAP_NUMBERS(_M[0],_M[1]); | ||||
| } | } | ||||
| _M[2] = VEC_DOT(vA1,_AD); | _M[2] = VEC_DOT(vA1,_AD); | ||||
| _M[3] = VEC_DOT(vA2,_AD); | _M[3] = VEC_DOT(vA2,_AD); | ||||
| //mid points | //mid points | ||||
| _N[0] = (_M[0]+_M[1])*0.5f; | n[0] = (_M[0]+_M[1])*0.5f; | ||||
| _N[1] = (_M[2]+_M[3])*0.5f; | n[1] = (_M[2]+_M[3])*0.5f; | ||||
| if(_N[0]<_N[1]) | if(n[0]<n[1]) | ||||
| { | { | ||||
| if(_M[1]<_M[2]) | if(_M[1]<_M[2]) | ||||
| { | { | ||||
| vPointB = invert_b_order?vB1:vB2; | vPointB = invert_b_order?vB1:vB2; | ||||
| vPointA = vA1; | vPointA = vA1; | ||||
| } | } | ||||
| else if(_M[1]<_M[3]) | else if(_M[1]<_M[3]) | ||||
| { | { | ||||
| Show All 23 Lines | if(_tp<G_EPSILON)//ARE PARALELE | ||||
| vPointB = invert_b_order?vB1:vB2; | vPointB = invert_b_order?vB1:vB2; | ||||
| CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2); | CLOSEST_POINT_ON_SEGMENT(vPointA,vPointB,vA1,vA2); | ||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| VEC_CROSS(_M,_N,_BD); | VEC_CROSS(_M,n,_BD); | ||||
| _M[3] = VEC_DOT(_M,vB1); | _M[3] = VEC_DOT(_M,vB1); | ||||
| LINE_PLANE_COLLISION(_M,_AD,vA1,vPointA,_tp,btScalar(0), btScalar(1)); | LINE_PLANE_COLLISION(_M,_AD,vA1,vPointA,_tp,btScalar(0), btScalar(1)); | ||||
| /*Closest point on segment*/ | /*Closest point on segment*/ | ||||
| VEC_DIFF(vPointB,vPointA,vB1); | VEC_DIFF(vPointB,vPointA,vB1); | ||||
| _tp = VEC_DOT(vPointB, _BD); | _tp = VEC_DOT(vPointB, _BD); | ||||
| _tp/= VEC_DOT(_BD, _BD); | _tp/= VEC_DOT(_BD, _BD); | ||||
| _tp = GIM_CLAMP(_tp,0.0f,1.0f); | _tp = GIM_CLAMP(_tp,0.0f,1.0f); | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||