37#define TRI_LOCAL_EPSILON 0.000001f
38#define MIN_EDGE_EDGE_DIS 0.00001f
92 else if(
D1*
D2>0.0f ||
D0!=0.0f)
483 contacts.m_separating_normal *= -1.f;
485 if(
contacts.m_point_count == 0)
return false;
508 const btVector4 & tri_plane,
509 const btVector3 * tripoints,
510 const btVector3 * srcpoints,
511 btVector3 * clipped_points)
517 EDGE_PLANE(tripoints[0],tripoints[1],tri_plane,edgeplane);
519 GUINT clipped_count = PLANE_CLIP_TRIANGLE3D(
520 edgeplane,srcpoints[0],srcpoints[1],srcpoints[2],temp_points);
522 if(clipped_count == 0) return 0;
526 EDGE_PLANE(tripoints[1],tripoints[2],tri_plane,edgeplane);
528 clipped_count = PLANE_CLIP_POLYGON3D(
529 edgeplane,temp_points,clipped_count,temp_points1);
531 if(clipped_count == 0) return 0;
535 EDGE_PLANE(tripoints[2],tripoints[0],tri_plane,edgeplane);
537 clipped_count = PLANE_CLIP_POLYGON3D(
538 edgeplane,temp_points1,clipped_count,clipped_points);
540 return clipped_count;
547 bool triangle_collision(
548 const btVector3 & u0,
549 const btVector3 & u1,
550 const btVector3 & u2,
552 const btVector3 & v0,
553 const btVector3 & v1,
554 const btVector3 & v2,
556 GIM_TRIANGLE_CONTACT_DATA & contacts)
559 margin = margin_u + margin_v;
571 // plane v vs U points
574 TRIANGLE_PLANE(tv_vertices[0],tv_vertices[1],tv_vertices[2],contacts1.m_separating_normal);
576 clipped_count = clip_triangle(
577 contacts1.m_separating_normal,tv_vertices,tu_vertices,clipped_points);
579 if(clipped_count == 0 )
581 return false;//Reject
584 //find most deep interval face1
585 contacts1.merge_points(contacts1.m_separating_normal,margin,clipped_points,clipped_count);
586 if(contacts1.m_point_count == 0) return false; // too far
588 //Normal pointing to triangle1
589 //contacts1.m_separating_normal *= -1.f;
591 //Clip tri1 by tri2 edges
593 TRIANGLE_PLANE(tu_vertices[0],tu_vertices[1],tu_vertices[2],contacts2.m_separating_normal);
595 clipped_count = clip_triangle(
596 contacts2.m_separating_normal,tu_vertices,tv_vertices,clipped_points);
598 if(clipped_count == 0 )
600 return false;//Reject
603 //find most deep interval face1
604 contacts2.merge_points(contacts2.m_separating_normal,margin,clipped_points,clipped_count);
605 if(contacts2.m_point_count == 0) return false; // too far
607 contacts2.m_separating_normal *= -1.f;
610 if(contacts2.m_penetration_depth<contacts1.m_penetration_depth)
612 contacts.copy_from(contacts2);
616 contacts.copy_from(contacts1);
const T & btMax(const T &a, const T &b)
#define SIMD_FORCE_INLINE
btVector3 temp_points[MAX_TRI_CLIPPING]
btVector3 closest_point_v
void sort_isect(GREAL &isect0, GREAL &isect1, GUINT &e0, GUINT &e1, btVector3 &vec0, btVector3 &vec1)
bool triangle_collision(const btVector3 &u0, const btVector3 &u1, const btVector3 &u2, GREAL margin_u, const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, GREAL margin_v, GIM_TRIANGLE_CONTACT_DATA &contacts)
collides by two sides
btVector3 closest_point_u
btVector3 temp_points1[MAX_TRI_CLIPPING]
bool compute_intervals(const GREAL &D0, const GREAL &D1, const GREAL &D2, const GREAL &D0D1, const GREAL &D0D2, GREAL &scale_edge0, GREAL &scale_edge1, GUINT &edge_index0, GUINT &edge_index1)
if returns false, the faces are paralele
GUINT cross_line_intersection_test()
Test verifying interval intersection with the direction between planes.
GUINT clip_triangle(const btVector4 &tri_plane, const btVector3 *tripoints, const btVector3 *srcpoints, btVector3 *clip_points)
clip triangle
btVector3 contact_points[MAX_TRI_CLIPPING]
Class for colliding triangles.
bool collide_triangle_hard_test(const GIM_TRIANGLE &other, GIM_TRIANGLE_CONTACT_DATA &contact_data) const
Test triangles by finding separating axis.
btVector3 can be used to represent 3D points and vectors.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 lerp(const btVector3 &v, const btScalar &t) const
Return the linear interpolation between this and another vector.
#define DISTANCE_PLANE_POINT(plane, point)
#define TRIANGLE_PLANE(v1, v2, v3, plane)
plane is a vec4f
#define EDGE_PLANE(e1, e2, n, plane)
Calc a plane from an edge an a normal. plane is a vec4f.
void SEGMENT_COLLISION(const CLASS_POINT &vA1, const CLASS_POINT &vA2, const CLASS_POINT &vB1, const CLASS_POINT &vB2, CLASS_POINT &vPointA, CLASS_POINT &vPointB)
Find closest points on segments.
GUINT PLANE_CLIP_POLYGON3D(const CLASS_PLANE &plane, const CLASS_POINT *polygon_points, GUINT polygon_point_count, CLASS_POINT *clipped)
GUINT PLANE_CLIP_TRIANGLE3D(const CLASS_PLANE &plane, const CLASS_POINT &point0, const CLASS_POINT &point1, const CLASS_POINT &point2, CLASS_POINT *clipped)
#define VEC_SWAP(b, a)
VECTOR SWAP.
#define VEC_COPY(b, a)
Copy 3D vector.
#define VEC_LENGTH(a, l)
Vector length.
#define VEC_SCALE_4(c, a, b)
scalar times vector
#define GIM_SWAP_NUMBERS(a, b)
Swap numbers.
#define GIM_MIN3(a, b, c)
#define GIM_MAX3(a, b, c)
#define MIN_EDGE_EDGE_DIS