MCPcopy Create free account
hub / github.com/TheRealMJP/Shadows / PointIsInTriangle

Function PointIsInTriangle

Shadows/SampleFramework11/Utility.cpp:77–93  ·  view source on GitHub ↗

Returns true if the given barycentric coordinate is in the triangle

Source from the content-addressed store, hash-verified

75
76// Returns true if the given barycentric coordinate is in the triangle
77BOOL PointIsInTriangle(const XMFLOAT3& r, float epsilon)
78{
79 float minr = 0.0f - epsilon;
80 float maxr = 1.0f + epsilon;
81
82 if(r.x < minr || r.x > maxr)
83 return false;
84
85 if(r.y < minr || r.y > maxr)
86 return false;
87
88 if(r.z < minr || r.z > maxr)
89 return false;
90
91 float rsum = r.x + r.y + r.z;
92 return rsum >= minr && rsum <= maxr;
93}
94
95// Computes a compute shader dispatch size given a thread group size, and number of elements to process
96uint32 DispatchSize(uint32 tgSize, uint32 numElements)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected