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;
std::uint8_t uint8
Definition: Core.h:453
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition: Vec3.inl:645
JPH_INLINE Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition: Vec3.inl:590
JPH_INLINE float Length() const
Length of vector.
Definition: Vec3.inl:677
An active edge is an edge that either has no neighbouring edge or if the angle between the two connec...
Definition: ActiveEdges.h:13
bool GetBaryCentricCoordinates(Vec3Arg inA, Vec3Arg inB, float &outU, float &outV)
Definition: ClosestPoint.h:18