MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / quadricFromTriangle

Function quadricFromTriangle

Source/ThirdParty/meshoptimizer/simplifier.cpp:832–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

830}
831
832static void quadricFromTriangle(Quadric& Q, const Vector3& p0, const Vector3& p1, const Vector3& p2, float weight)
833{
834 Vector3 p10 = {p1.x - p0.x, p1.y - p0.y, p1.z - p0.z};
835 Vector3 p20 = {p2.x - p0.x, p2.y - p0.y, p2.z - p0.z};
836
837 // normal = cross(p1 - p0, p2 - p0)
838 Vector3 normal = {p10.y * p20.z - p10.z * p20.y, p10.z * p20.x - p10.x * p20.z, p10.x * p20.y - p10.y * p20.x};
839 float area = normalize(normal);
840
841 float distance = normal.x * p0.x + normal.y * p0.y + normal.z * p0.z;
842
843 // we use sqrtf(area) so that the error is scaled linearly; this tends to improve silhouettes
844 quadricFromPlane(Q, normal.x, normal.y, normal.z, -distance, sqrtf(area) * weight);
845}
846
847static void quadricFromTriangleEdge(Quadric& Q, const Vector3& p0, const Vector3& p1, const Vector3& p2, float weight)
848{

Callers 3

fillFaceQuadricsFunction · 0.85
fillEdgeQuadricsFunction · 0.85
fillCellQuadricsFunction · 0.85

Calls 2

quadricFromPlaneFunction · 0.85
normalizeFunction · 0.70

Tested by

no test coverage detected