#include <gim_tri_collision.h>
Public Member Functions | |
GIM_TRIANGLE () | |
SIMD_FORCE_INLINE GIM_AABB | get_box () const |
SIMD_FORCE_INLINE void | get_normal (btVector3 &normal) const |
SIMD_FORCE_INLINE void | get_plane (btVector4 &plane) const |
SIMD_FORCE_INLINE void | apply_transform (const btTransform &trans) |
SIMD_FORCE_INLINE void | get_edge_plane (GUINT edge_index, const btVector3 &triangle_normal, btVector4 &plane) const |
SIMD_FORCE_INLINE void | get_triangle_transform (btTransform &triangle_transform) const |
Gets the relative transformation of this triangle. | |
bool | collide_triangle_hard_test (const GIM_TRIANGLE &other, GIM_TRIANGLE_CONTACT_DATA &contact_data) const |
Test triangles by finding separating axis. | |
SIMD_FORCE_INLINE bool | collide_triangle (const GIM_TRIANGLE &other, GIM_TRIANGLE_CONTACT_DATA &contact_data) const |
Test boxes before doing hard test. | |
SIMD_FORCE_INLINE bool | get_uv_parameters (const btVector3 &point, const btVector3 &tri_plane, GREAL &u, GREAL &v) const |
SIMD_FORCE_INLINE bool | is_point_inside (const btVector3 &point, const btVector3 &tri_normal) const |
is point in triangle beam? | |
SIMD_FORCE_INLINE bool | ray_collision (const btVector3 &vPoint, const btVector3 &vDir, btVector3 &pout, btVector3 &triangle_normal, GREAL &tparam, GREAL tmax=G_REAL_INFINITY) |
Bidireccional ray collision. | |
SIMD_FORCE_INLINE bool | ray_collision_front_side (const btVector3 &vPoint, const btVector3 &vDir, btVector3 &pout, btVector3 &triangle_normal, GREAL &tparam, GREAL tmax=G_REAL_INFINITY) |
one direccion ray collision | |
Public Attributes | |
btScalar | m_margin |
btVector3 | m_vertices [3] |
GIM_TRIANGLE::GIM_TRIANGLE | ( | ) | [inline] |
SIMD_FORCE_INLINE GIM_AABB GIM_TRIANGLE::get_box | ( | ) | const [inline] |
SIMD_FORCE_INLINE void GIM_TRIANGLE::get_normal | ( | btVector3 & | normal | ) | const [inline] |
SIMD_FORCE_INLINE void GIM_TRIANGLE::get_plane | ( | btVector4 & | plane | ) | const [inline] |
SIMD_FORCE_INLINE void GIM_TRIANGLE::apply_transform | ( | const btTransform & | trans | ) | [inline] |
SIMD_FORCE_INLINE void GIM_TRIANGLE::get_edge_plane | ( | GUINT | edge_index, | |
const btVector3 & | triangle_normal, | |||
btVector4 & | plane | |||
) | const [inline] |
SIMD_FORCE_INLINE void GIM_TRIANGLE::get_triangle_transform | ( | btTransform & | triangle_transform | ) | const [inline] |
Gets the relative transformation of this triangle.
The transformation is oriented to the triangle normal , and aligned to the 1st edge of this triangle. The position corresponds to vertice 0:
bool GIM_TRIANGLE::collide_triangle_hard_test | ( | const GIM_TRIANGLE & | other, | |
GIM_TRIANGLE_CONTACT_DATA & | contact_data | |||
) | const |
Test triangles by finding separating axis.
other | Triangle for collide | |
contact_data | Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle |
SIMD_FORCE_INLINE bool GIM_TRIANGLE::collide_triangle | ( | const GIM_TRIANGLE & | other, | |
GIM_TRIANGLE_CONTACT_DATA & | contact_data | |||
) | const [inline] |
Test boxes before doing hard test.
other | Triangle for collide | |
contact_data | Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle \ |
SIMD_FORCE_INLINE bool GIM_TRIANGLE::get_uv_parameters | ( | const btVector3 & | point, | |
const btVector3 & | tri_plane, | |||
GREAL & | u, | |||
GREAL & | v | |||
) | const [inline] |
Solve the System for u,v parameters:
u*axe1[i1] + v*axe2[i1] = vecproj[i1] u*axe1[i2] + v*axe2[i2] = vecproj[i2]
sustitute: v = (vecproj[i2] - u*axe1[i2])/axe2[i2]
then the first equation in terms of 'u':
--> u*axe1[i1] + ((vecproj[i2] - u*axe1[i2])/axe2[i2])*axe2[i1] = vecproj[i1]
--> u*axe1[i1] + vecproj[i2]*axe2[i1]/axe2[i2] - u*axe1[i2]*axe2[i1]/axe2[i2] = vecproj[i1]
--> u*(axe1[i1] - axe1[i2]*axe2[i1]/axe2[i2]) = vecproj[i1] - vecproj[i2]*axe2[i1]/axe2[i2]
--> u*((axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])/axe2[i2]) = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1])/axe2[i2]
--> u*(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) = vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]
--> u = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]) /(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])
if 0.0<= u+v <=1.0 then they are inside of triangle
SIMD_FORCE_INLINE bool GIM_TRIANGLE::is_point_inside | ( | const btVector3 & | point, | |
const btVector3 & | tri_normal | |||
) | const [inline] |
is point in triangle beam?
Test if point is in triangle, with m_margin tolerance
SIMD_FORCE_INLINE bool GIM_TRIANGLE::ray_collision | ( | const btVector3 & | vPoint, | |
const btVector3 & | vDir, | |||
btVector3 & | pout, | |||
btVector3 & | triangle_normal, | |||
GREAL & | tparam, | |||
GREAL | tmax = G_REAL_INFINITY | |||
) | [inline] |
Bidireccional ray collision.
SIMD_FORCE_INLINE bool GIM_TRIANGLE::ray_collision_front_side | ( | const btVector3 & | vPoint, | |
const btVector3 & | vDir, | |||
btVector3 & | pout, | |||
btVector3 & | triangle_normal, | |||
GREAL & | tparam, | |||
GREAL | tmax = G_REAL_INFINITY | |||
) | [inline] |
one direccion ray collision
btScalar GIM_TRIANGLE::m_margin |
btVector3 GIM_TRIANGLE::m_vertices[3] |