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

◆ triangle_vertex_count()

constexpr uint32_t MayaFlux::Portal::Graphics::triangle_vertex_count ( PrimitiveTopology  topology,
uint32_t  n 
)
constexprnoexcept

Vertices a span of n at topology yields once reduced to a TRIANGLE_LIST, with points becoming quads and line segments ribbons.

Closed form, so a caller can size a destination or budget a dispatch without inspecting vertex data. Spans too short to assemble a primitive yield zero rather than underflowing, and list topologies floor to whole primitives, so an odd LINE_LIST count drops its dangling vertex instead of reading past the span.

Definition at line 417 of file GraphicsUtils.hpp.

420{
421 switch (topology) {
422 case PrimitiveTopology::POINT_LIST:
423 return 6U * n;
424 case PrimitiveTopology::LINE_LIST:
425 return 6U * (n / 2U);
426 case PrimitiveTopology::LINE_STRIP:
427 return n < 2U ? 0U : 6U * (n - 1U);
428 case PrimitiveTopology::TRIANGLE_LIST:
429 return 3U * (n / 3U);
430 case PrimitiveTopology::TRIANGLE_STRIP:
431 case PrimitiveTopology::TRIANGLE_FAN:
432 return n < 3U ? 0U : 3U * (n - 2U);
433 }
434 return 0U;
435}

References LINE_LIST, LINE_STRIP, POINT_LIST, TRIANGLE_FAN, TRIANGLE_LIST, and TRIANGLE_STRIP.

Referenced by MayaFlux::Portal::Graphics::PrimitiveMill::milled_vertex_count().

+ Here is the caller graph for this function: