Luanti 5.16.0-dev
Loading...
Searching...
No Matches
mesh_compare.cpp File Reference
#include "mesh_compare.h"
#include <algorithm>
#include <map>
#include <stdexcept>
Include dependency graph for mesh_compare.cpp:

Functions

static std::vector< TriangleexpandMesh (const std::vector< video::S3DVertex > &vertices, const std::vector< u16 > &indices)
static Triangle sortTriangle (Triangle t)
 Sorts triangle vertices, keeping winding order.
static std::vector< TrianglecanonicalizeMesh (const std::vector< video::S3DVertex > &vertices, const std::vector< u16 > &indices)
bool checkMeshEqual (const std::vector< video::S3DVertex > &vertices, const std::vector< u16 > &indices, const std::vector< Triangle > &expected)
 Compare two meshes for equality.
bool checkMeshEqual (const std::vector< video::S3DVertex > &vertices, const std::vector< u16 > &indices, const std::vector< Quad > &expected)
 Compare two meshes for equality.

Function Documentation

◆ canonicalizeMesh()

std::vector< Triangle > canonicalizeMesh ( const std::vector< video::S3DVertex > & vertices,
const std::vector< u16 > & indices )
static

References expandMesh(), and sortTriangle().

Referenced by checkMeshEqual(), and checkMeshEqual().

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

◆ checkMeshEqual() [1/2]

bool checkMeshEqual ( const std::vector< video::S3DVertex > & vertices,
const std::vector< u16 > & indices,
const std::vector< Quad > & expected )
nodiscard

Compare two meshes for equality.

Parameters
verticesVertices of the first mesh. Order doesn’t matter.
indicesIndices of the first mesh. Triangle order doesn’t matter. Vertex order in a triangle only matters for winding.
expectedThe second mesh, in a quad form.
Returns
Whether the two meshes are equal.
Note
There are two ways to split a quad into 2 triangles; either is allowed.

References canonicalizeMesh(), and sortTriangle().

Here is the call graph for this function:

◆ checkMeshEqual() [2/2]

bool checkMeshEqual ( const std::vector< video::S3DVertex > & vertices,
const std::vector< u16 > & indices,
const std::vector< Triangle > & expected )
nodiscard

Compare two meshes for equality.

Parameters
verticesVertices of the first mesh. Order doesn’t matter.
indicesIndices of the first mesh. Triangle order doesn’t matter. Vertex order in a triangle only matters for winding.
expectedThe second mesh, in an expanded form. Must be sorted.
Returns
Whether the two meshes are equal.

References canonicalizeMesh().

Referenced by TestMeshCompare::testQuad(), and TestMeshCompare::testTriangle().

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

◆ expandMesh()

std::vector< Triangle > expandMesh ( const std::vector< video::S3DVertex > & vertices,
const std::vector< u16 > & indices )
static

Referenced by canonicalizeMesh().

Here is the caller graph for this function:

◆ sortTriangle()

Triangle sortTriangle ( Triangle t)
static

Sorts triangle vertices, keeping winding order.

Referenced by canonicalizeMesh(), and checkMeshEqual().

Here is the caller graph for this function: