19 inline static bool IsEdgeActive(
Vec3Arg inNormal1,
Vec3Arg inNormal2,
Vec3Arg inEdgeDirection,
float inCosThresholdAngle)
22 float cos_angle_normals = inNormal1.
Dot(inNormal2);
23 if (cos_angle_normals < -0.999848f)
27 if (inNormal1.
Cross(inNormal2).
Dot(inEdgeDirection) < 0.0f)
31 return cos_angle_normals < inCosThresholdAngle;
51 float normal_length = inNormal.
Length();
52 float triangle_normal_length = inTriangleNormal.
Length();
53 if (inMovementDirection.
Dot(inNormal) * triangle_normal_length < inMovementDirection.
Dot(inTriangleNormal) * normal_length)
57 if (inActiveEdges == 0)
58 return inTriangleNormal;
62 if (inTriangleNormal.
Dot(inNormal) > 0.999848f * normal_length * triangle_normal_length)
65 const float cEpsilon = 1.0e-4f;
66 const float cOneMinusEpsilon = 1.0f - cEpsilon;
73 if (u > cOneMinusEpsilon)
76 colliding_edge = 0b101;
78 else if (v > cOneMinusEpsilon)
81 colliding_edge = 0b011;
83 else if (w > cOneMinusEpsilon)
86 colliding_edge = 0b110;
88 else if (u < cEpsilon)
91 colliding_edge = 0b010;
93 else if (v < cEpsilon)
96 colliding_edge = 0b100;
98 else if (w < cEpsilon)
101 colliding_edge = 0b001;
106 return inTriangleNormal;
110 return (inActiveEdges & colliding_edge) != 0? inNormal : inTriangleNormal;