35 #include "transform.h" 61 Plane get_plane(ClockDirection p_dir=CLOCKWISE)
const;
62 Vector3 get_random_point_inside()
const;
65 Side get_side_of(
const Face3& p_face,ClockDirection p_clock_dir=CLOCKWISE)
const;
67 bool is_degenerate()
const;
68 real_t get_area()
const;
70 Vector3 get_median_point()
const;
79 void project_range(
const Vector3& p_normal,
const Transform& p_transform,
float& r_min,
float& r_max)
const;
81 AABB get_aabb()
const {
84 aabb.expand_to( vertex[1] );
85 aabb.expand_to( vertex[2] );
90 _FORCE_INLINE_
bool intersects_aabb2(
const AABB& p_aabb)
const;
99 bool Face3::intersects_aabb2(
const AABB& p_aabb)
const {
101 Vector3 perp = (vertex[0]-vertex[2]).cross(vertex[0]-vertex[1]);
103 Vector3 half_extents = p_aabb.size * 0.5;
104 Vector3 ofs = p_aabb.pos + half_extents;
107 (perp.x>0) ? -half_extents.x : half_extents.x,
108 (perp.y>0) ? -half_extents.y : half_extents.y,
109 (perp.z>0) ? -half_extents.z : half_extents.z
112 float d = perp.dot(vertex[0]);
113 float dist_a = perp.dot(ofs+sup)-d;
114 float dist_b = perp.dot(ofs-sup)-d;
116 if (dist_a*dist_b > 0)
120 #define TEST_AXIS(m_ax)\ 122 float aabb_min=p_aabb.pos.m_ax;\ 123 float aabb_max=p_aabb.pos.m_ax+p_aabb.size.m_ax;\ 124 float tri_min,tri_max;\ 125 for (int i=0;i<3;i++) {\ 126 if (i==0 || vertex[i].m_ax > tri_max)\ 127 tri_max=vertex[i].m_ax;\ 128 if (i==0 || vertex[i].m_ax < tri_min)\ 129 tri_min=vertex[i].m_ax;\ 132 if (tri_max<aabb_min || aabb_max<tri_min)\ 149 for (
int i=0;i<12;i++) {
156 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z );
157 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z );
161 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
162 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z );
165 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
166 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
171 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z );
172 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
177 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
178 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
182 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
183 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
186 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
187 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
192 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
193 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
198 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
199 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
204 from=
Vector3( p_aabb.pos.x , p_aabb.pos.y , p_aabb.pos.z );
205 to=
Vector3( p_aabb.pos.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
210 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z );
211 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z );
216 from=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y , p_aabb.pos.z+p_aabb.size.z );
217 to=
Vector3( p_aabb.pos.x+p_aabb.size.x , p_aabb.pos.y+p_aabb.size.y , p_aabb.pos.z+p_aabb.size.z );
224 for (
int j=0;j<3;j++) {
227 Vector3 axis=vec3_cross( e1, e2 );
229 if (axis.length_squared()<0.0001)
234 (axis.x>0) ? -half_extents.x : half_extents.x,
235 (axis.y>0) ? -half_extents.y : half_extents.y,
236 (axis.z>0) ? -half_extents.z : half_extents.z
239 float maxB = axis.dot(ofs+sup2);
240 float minB = axis.dot(ofs-sup2);
245 float minT=1e20,maxT=-1e20;
246 for (
int k=0;k<3;k++) {
248 float d=axis.dot(vertex[k]);
257 if (maxB<minT || maxT<minB)
void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const
Definition: face3.cpp:292
ClockDirection get_clock_dir() const
todo, test if this is returning the proper clockwisity
Definition: face3.cpp:198
bool intersects_aabb(const AABB &p_aabb) const
Definition: face3.cpp:208
int split_by_plane(const Plane &p_plane, Face3 *p_res, bool *p_is_point_over) const
Definition: face3.cpp:32