MXVK Vulkan Framework 0.35.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< Triangle > polys
 Triangle storage.

Detailed Description

Flat list of triangles prepared for transformation and rasterization.

Definition at line 1232 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 1293 of file mxvk_math.h.

1293 {
1294 polys.push_back(triangle);
1295 num_polys = static_cast<int>(polys.size());
1296 }
int num_polys
Cached polygon count matching polys.size().
Definition mxvk_math.h:1238
std::vector< Triangle > polys
Triangle storage.
Definition mxvk_math.h:1235

◆ BuildRenderList() [2/2]

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

Append one triangle to the render list.

Definition at line 1259 of file mxvk_math_eigen.hpp.

1259 {
1260 polys.push_back(triangle);
1261 num_polys = static_cast<int>(polys.size());
1262 }

◆ 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 1278 of file mxvk_math.h.

1278 {
1279 if (type != 0) {
1280 return;
1281 }
1282 for (auto &poly : polys) {
1283 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1284 continue;
1285 }
1286 for (int i = 0; i < 3; ++i) {
1287 poly.tlist[i] = poly.vlist[i] + pos;
1288 }
1289 }
1290 }
@ MX_BACKFACE
Polygon is marked as a backface.
Definition mxvk_math.h:1225

◆ 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 1244 of file mxvk_math_eigen.hpp.

1244 {
1245 if (type != 0) {
1246 return;
1247 }
1248 for (auto &poly : polys) {
1249 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1250 continue;
1251 }
1252 for (int i = 0; i < 3; ++i) {
1253 poly.tlist[i] = poly.vlist[i] + pos;
1254 }
1255 }
1256 }

◆ RemoveFaces() [1/2]

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

Mark back-facing triangles relative to a view position.

Definition at line 1262 of file mxvk_math.h.

1262 {
1263 for (auto &poly : polys) {
1264 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1265 continue;
1266 }
1267 const vec4D u = vec4D().Build(poly.tlist[0], poly.tlist[1]);
1268 const vec4D v = vec4D().Build(poly.tlist[0], poly.tlist[2]);
1269 const vec4D n = u.CrossProduct(v);
1270 const vec4D view = vec4D().Build(poly.tlist[0], pos);
1271 if (n.DotProduct(view) <= 0.0f) {
1272 poly.state |= MX_BACKFACE;
1273 }
1274 }
1275 }
constexpr vec4D()
Construct the homogeneous origin.
Definition mxvk_math.h:378

◆ RemoveFaces() [2/2]

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

Mark back-facing triangles relative to a view position.

Definition at line 1228 of file mxvk_math_eigen.hpp.

1228 {
1229 for (auto &poly : polys) {
1230 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1231 continue;
1232 }
1233 const vec4D u = vec4D().Build(poly.tlist[0], poly.tlist[1]);
1234 const vec4D v = vec4D().Build(poly.tlist[0], poly.tlist[2]);
1235 const vec4D n = u.CrossProduct(v);
1236 const vec4D view = vec4D().Build(poly.tlist[0], pos);
1237 if (n.DotProduct(view) <= 0.0f) {
1238 poly.state |= MX_BACKFACE;
1239 }
1240 }
1241 }

◆ Reset() [1/2]

void mxvk::RenderList::Reset ( )
inline

Clear all triangles from the render list.

Definition at line 1241 of file mxvk_math.h.

1241 {
1242 polys.clear();
1243 num_polys = 0;
1244 }

◆ Reset() [2/2]

void mxvk::RenderList::Reset ( )
inline

Clear all triangles from the render list.

Definition at line 1207 of file mxvk_math_eigen.hpp.

1207 {
1208 polys.clear();
1209 num_polys = 0;
1210 }

◆ TransformRenderList() [1/2]

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

Transform active non-backface triangles by a matrix.

Definition at line 1247 of file mxvk_math.h.

1247 {
1248 if (type != 0) {
1249 return;
1250 }
1251 for (auto &poly : polys) {
1252 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1253 continue;
1254 }
1255 for (auto &vertex : poly.vlist) {
1256 vertex = mrot.MulVec(vertex);
1257 }
1258 }
1259 }

◆ TransformRenderList() [2/2]

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

Transform active non-backface triangles by a matrix.

Definition at line 1213 of file mxvk_math_eigen.hpp.

1213 {
1214 if (type != 0) {
1215 return;
1216 }
1217 for (auto &poly : polys) {
1218 if (poly.state == 0 || (poly.state & MX_BACKFACE) != 0) {
1219 continue;
1220 }
1221 for (auto &vertex : poly.vlist) {
1222 vertex = mrot.MulVec(vertex);
1223 }
1224 }
1225 }

Member Data Documentation

◆ num_polys

int mxvk::RenderList::num_polys = 0

Cached polygon count matching polys.size().

Definition at line 1238 of file mxvk_math.h.

◆ polys

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

Triangle storage.

Definition at line 1235 of file mxvk_math.h.


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