MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ triangle_list_bounds()

std::function< bool(glm::vec2)> MayaFlux::Kinesis::triangle_list_bounds ( std::span< const glm::vec2 > positions)
inlinenodiscard

Containment test for a triangle list: inside any triangle.

Consecutive groups of three positions are one triangle each; a trailing partial group is ignored. Triangles with zero area are dropped, so a degenerate triangle never makes the whole plane hit. Strips and fans are expanded to a list by the caller.

Parameters
positionsTriangle corners in NDC. Copied into the closure.

Definition at line 535 of file Bounds.hpp.

536{
537 std::vector<std::array<glm::vec2, 3>> triangles;
538 for (size_t i = 0; i + 2 < positions.size(); i += 3) {
539 const glm::vec2 u = positions[i + 1] - positions[i];
540 const glm::vec2 v = positions[i + 2] - positions[i];
541 if (std::abs(u.x * v.y - u.y * v.x) > 1e-12F)
542 triangles.push_back({ positions[i], positions[i + 1], positions[i + 2] });
543 }
544 return [triangles = std::move(triangles)](glm::vec2 p) {
545 return std::ranges::any_of(triangles, [&](const std::array<glm::vec2, 3>& t) {
546 return triangle_contains(p, t[0], t[1], t[2]);
547 });
548 };
549}
bool triangle_contains(glm::vec2 p, glm::vec2 a, glm::vec2 b, glm::vec2 c) noexcept
Whether a point lies inside or on a triangle, whichever way it winds.
Definition Bounds.hpp:512

References triangle_contains().

Referenced by MayaFlux::Portal::Forma::containment_of().

Here is the call graph for this function:
Here is the caller graph for this function: