MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
mxvk::RenderList Class Reference

Flat list of triangles prepared for transformation and rasterization. More...

#include <mxvk/include/mxvk/mxvk_math.h>

Public Member Functions

void BuildRenderList (const Triangle &triangle)
 Append one triangle to the render list.
void BuildRenderList (const Triangle &triangle)
 Append one triangle to the render list.
void ModelToWorld (const vec4D &pos, int type)
 Translate model-space vertices into world-space transformed vertices.
void ModelToWorld (const vec4D &pos, int type)
 Translate model-space vertices into world-space transformed vertices.
void RemoveFaces (const vec4D &pos)
 Mark back-facing triangles relative to a view position.
void RemoveFaces (const vec4D &pos)
 Mark back-facing triangles relative to a view position.
void Reset ()
 Clear all triangles from the render list.
void Reset ()
 Clear all triangles from the render list.
void TransformRenderList (const Mat4D &mrot, int type)
 Transform active non-backface triangles by a matrix.
void TransformRenderList (const Mat4D &mrot, int type)
 Transform active non-backface triangles by a matrix.

Public Attributes

int num_polys = 0
 Cached polygon count matching polys.size().
std::vector< Trianglepolys
 Triangle storage.

Detailed Description

Flat list of triangles prepared for transformation and rasterization.

Definition at line 1371 of file mxvk_math.h.

Member Function Documentation

◆ BuildRenderList() [1/2]

void mxvk::RenderList::BuildRenderList ( const Triangle & triangle)
inline

Append one triangle to the render list.

Definition at line 1432 of file mxvk_math.h.

1432 {
1433 polys.push_back(triangle);
1434 num_polys = static_cast<int>(polys.size());
1435 }
int num_polys
Cached polygon count matching polys.size().
Definition mxvk_math.h:1377
std::vector< Triangle > polys
Triangle storage.
Definition mxvk_math.h:1374

◆ BuildRenderList() [2/2]

void mxvk::RenderList::BuildRenderList ( const Triangle & triangle)
inline

Append one triangle to the render list.

Definition at line 1432 of file mxvk_math_eigen.hpp.

1432 {
1433 polys.push_back(triangle);
1434 num_polys = static_cast<int>(polys.size());
1435 }

◆ ModelToWorld() [1/2]

void mxvk::RenderList::ModelToWorld ( const vec4D & pos,
int type )
inline

Translate model-space vertices into world-space transformed vertices.

Definition at line 1417 of file mxvk_math.h.

1417 {
1418 if (type != 0) {
1419 return;
1420 }
1421 for (auto &poly : polys) {
1422 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1423 continue;
1424 }
1425 for (int i = 0; i < 3; ++i) {
1426 poly.tlist[i] = poly.vlist[i] + pos;
1427 }
1428 }
1429 }
@ MX_BACKFACE
Polygon is marked as a backface.
Definition mxvk_math.h:1364

◆ ModelToWorld() [2/2]

void mxvk::RenderList::ModelToWorld ( const vec4D & pos,
int type )
inline

Translate model-space vertices into world-space transformed vertices.

Definition at line 1417 of file mxvk_math_eigen.hpp.

1417 {
1418 if (type != 0) {
1419 return;
1420 }
1421 for (auto &poly : polys) {
1422 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1423 continue;
1424 }
1425 for (int i = 0; i < 3; ++i) {
1426 poly.tlist[i] = poly.vlist[i] + pos;
1427 }
1428 }
1429 }

◆ RemoveFaces() [1/2]

void mxvk::RenderList::RemoveFaces ( const vec4D & pos)
inline

Mark back-facing triangles relative to a view position.

Definition at line 1401 of file mxvk_math.h.

1401 {
1402 for (auto &poly : polys) {
1403 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1404 continue;
1405 }
1406 const vec4D u = vec4D().Build(poly.tlist[0], poly.tlist[1]);
1407 const vec4D v = vec4D().Build(poly.tlist[0], poly.tlist[2]);
1408 const vec4D n = u.CrossProduct(v);
1409 const vec4D view = vec4D().Build(poly.tlist[0], pos);
1410 if (n.DotProduct(view) <= 0.0f) {
1411 poly.state |= MX_BACKFACE;
1412 }
1413 }
1414 }

◆ RemoveFaces() [2/2]

void mxvk::RenderList::RemoveFaces ( const vec4D & pos)
inline

Mark back-facing triangles relative to a view position.

Definition at line 1401 of file mxvk_math_eigen.hpp.

1401 {
1402 for (auto &poly : polys) {
1403 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1404 continue;
1405 }
1406 const vec4D u = vec4D().Build(poly.tlist[0], poly.tlist[1]);
1407 const vec4D v = vec4D().Build(poly.tlist[0], poly.tlist[2]);
1408 const vec4D n = u.CrossProduct(v);
1409 const vec4D view = vec4D().Build(poly.tlist[0], pos);
1410 if (n.DotProduct(view) <= 0.0f) {
1411 poly.state |= MX_BACKFACE;
1412 }
1413 }
1414 }

◆ Reset() [1/2]

void mxvk::RenderList::Reset ( )
inline

Clear all triangles from the render list.

Definition at line 1380 of file mxvk_math.h.

1380 {
1381 polys.clear();
1382 num_polys = 0;
1383 }

◆ Reset() [2/2]

void mxvk::RenderList::Reset ( )
inline

Clear all triangles from the render list.

Definition at line 1380 of file mxvk_math_eigen.hpp.

1380 {
1381 polys.clear();
1382 num_polys = 0;
1383 }

◆ TransformRenderList() [1/2]

void mxvk::RenderList::TransformRenderList ( const Mat4D & mrot,
int type )
inline

Transform active non-backface triangles by a matrix.

Definition at line 1386 of file mxvk_math.h.

1386 {
1387 if (type != 0) {
1388 return;
1389 }
1390 for (auto &poly : polys) {
1391 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1392 continue;
1393 }
1394 for (auto &vertex : poly.vlist) {
1395 vertex = mrot.MulVec(vertex);
1396 }
1397 }
1398 }

◆ TransformRenderList() [2/2]

void mxvk::RenderList::TransformRenderList ( const Mat4D & mrot,
int type )
inline

Transform active non-backface triangles by a matrix.

Definition at line 1386 of file mxvk_math_eigen.hpp.

1386 {
1387 if (type != 0) {
1388 return;
1389 }
1390 for (auto &poly : polys) {
1391 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1392 continue;
1393 }
1394 for (auto &vertex : poly.vlist) {
1395 vertex = mrot.MulVec(vertex);
1396 }
1397 }
1398 }

Member Data Documentation

◆ num_polys

int mxvk::RenderList::num_polys = 0

Cached polygon count matching polys.size().

Definition at line 1377 of file mxvk_math.h.

◆ polys

std::vector< Triangle > mxvk::RenderList::polys

Triangle storage.

Definition at line 1374 of file mxvk_math.h.


The documentation for this class was generated from the following files: