Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::mesh Class Reference

Main class representing a 3D mesh with support for different LODs, submeshes, and skinning. More...

#include <mesh.h>

Classes

struct  adjacent_edge_key
 
struct  armature_node
 
struct  bone_combination_key
 
struct  face_influences
 
struct  info
 
struct  load_data
 Struct used for mesh construction. More...
 
struct  mesh_submesh_key
 
struct  optimizer_triangle_info
 
struct  optimizer_vertex_info
 
struct  preparation_data
 
struct  submesh
 Structure describing an individual "piece" of the mesh, often grouped by material, but can be any arbitrary collection of triangles. More...
 
struct  triangle
 Structure describing data for a single triangle in the mesh. More...
 
struct  weld_key
 

Public Types

using triangle_array_t = std::vector<triangle>
 
using submesh_array_t = std::vector<submesh*>
 
using bone_palette_array_t = std::vector<bone_palette>
 
using submesh_array_indices_t = std::vector<size_t>
 
using submesh_array_map_t = std::map<uint32_t, submesh_array_indices_t>
 
using data_group_submesh_map_t = std::map<uint32_t, submesh_array_t>
 
using byte_array_t = std::vector<uint8_t>
 

Public Member Functions

 mesh ()
 Constructs a mesh object.
 
 ~mesh ()
 Destructor.
 
void dispose ()
 Clears out all the mesh data.
 
void bind_render_buffers_for_submesh (const submesh *submesh)
 Binds the mesh data for rendering the selected batch of primitives.
 
auto prepare_mesh (const gfx::vertex_layout &vertex_format) -> bool
 Prepares the mesh with the specified vertex format.
 
auto set_vertex_source (void *source, uint32_t vertex_count, const gfx::vertex_layout &source_format) -> bool
 Sets the source of the vertex buffer to pull data from while preparing the mesh.
 
auto set_vertex_source (byte_array_t &&source, uint32_t vertex_count, const gfx::vertex_layout &source_format) -> bool
 
auto set_bounding_box (const math::bbox &box) -> bool
 
auto set_submeshes (const std::vector< submesh > &submeshes) -> bool
 
auto set_primitives (triangle_array_t &&triangles) -> bool
 Adds primitives (triangles) to the mesh.
 
auto bind_skin (const skin_bind_data &bind_data) -> bool
 Binds the mesh as a skin with the specified skin binding data.
 
auto bind_armature (std::unique_ptr< armature_node > &root) -> bool
 Binds the armature tree.
 
auto load_mesh (load_data &&data) -> bool
 
auto create_plane (const gfx::vertex_layout &format, float width, float height, uint32_t width_segments, uint32_t height_segments, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a plane geometry.
 
auto create_cube (const gfx::vertex_layout &format, float width, float height, float depth, uint32_t width_segments, uint32_t height_segments, uint32_t depth_segments, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a cube geometry.
 
auto create_rounded_cube (const gfx::vertex_layout &format, float width, float height, float depth, uint32_t width_segments, uint32_t height_segments, uint32_t depth_segments, mesh_create_origin origin, bool hardware_copy=true) -> bool
 
auto create_sphere (const gfx::vertex_layout &format, float radius, uint32_t stacks, uint32_t slices, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a sphere geometry.
 
auto create_cylinder (const gfx::vertex_layout &format, float radius, float height, uint32_t stacks, uint32_t slices, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a cylinder geometry.
 
auto create_capsule (const gfx::vertex_layout &format, float radius, float height, uint32_t stacks, uint32_t slices, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a capsule geometry.
 
auto create_cone (const gfx::vertex_layout &format, float radius, float radius_tip, float height, uint32_t stacks, uint32_t slices, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a cone geometry.
 
auto create_torus (const gfx::vertex_layout &format, float outer_radius, float inner_radius, uint32_t bands, uint32_t sides, mesh_create_origin origin, bool hardware_copy=true) -> bool
 Creates a torus geometry.
 
auto create_teapot (const gfx::vertex_layout &format, bool hardware_copy=true) -> bool
 Creates a teapot geometry.
 
auto create_icosahedron (const gfx::vertex_layout &format, bool hardware_copy=true) -> bool
 Creates an icosahedron geometry.
 
auto create_dodecahedron (const gfx::vertex_layout &format, bool hardware_copy=true) -> bool
 Creates a dodecahedron geometry.
 
auto create_icosphere (const gfx::vertex_layout &format, int tesselation_level, bool hardware_copy=true) -> bool
 Creates an icosphere geometry.
 
auto end_prepare (bool hardware_copy=true, bool build_buffers=true, bool weld=false, bool optimize=false) -> bool
 Ends the preparation of the mesh and builds the render data.
 
void build_vb (bool hardware_copy=true)
 Builds the internal vertex buffer.
 
void build_ib (bool hardware_copy=true)
 Builds the internal index buffer.
 
auto generate_adjacency (std::vector< uint32_t > &adjacency) -> bool
 Generates edge-triangle adjacency information for the mesh data.
 
auto get_face_count () const -> uint32_t
 Determines the number of faces stored in the mesh.
 
auto get_vertex_count () const -> uint32_t
 Determines the number of vertices stored in the mesh.
 
auto get_system_vb () -> uint8_t *
 Retrieves the underlying vertex data from the mesh.
 
auto get_system_ib () -> uint32_t *
 Retrieves the underlying index data from the mesh.
 
auto get_vertex_format () const -> const gfx::vertex_layout &
 Retrieves the format of the underlying mesh vertex data.
 
auto get_skin_bind_data () const -> const skin_bind_data &
 Retrieves the skin bind data if this mesh has been bound as a skin.
 
auto get_bone_palettes () const -> const bone_palette_array_t &
 Retrieves the compiled bone combination palette data if this mesh has been bound as a skin.
 
auto get_armature () const -> const std::unique_ptr< armature_node > &
 Retrieves the armature tree of the mesh.
 
auto calculate_screen_rect (const math::transform &world, const camera &cam) const -> irect32_t
 Calculates the screen rectangle of the mesh based on its world transform and the camera.
 
auto get_submeshes () const -> const submesh_array_t &
 Retrieves information about the submesh of the mesh associated with the specified data group identifier.
 
auto get_submesh (uint32_t submesh_index=0) const -> const mesh::submesh &
 
auto get_bounds () const -> const math::bbox &
 Gets the local bounding box for this mesh.
 
auto get_status () const -> mesh_status
 Gets the preparation status for this mesh.
 
auto get_data_groups_count () const -> size_t
 Gets the number of data groups(materials) for this mesh.
 
auto get_submeshes_count () const -> size_t
 Gets the number of submeshes for this mesh.
 
auto get_skinned_submeshes_count () const -> size_t
 
auto get_skinned_submeshes_indices (uint32_t data_group_id) const -> const submesh_array_indices_t &
 
auto get_non_skinned_submeshes_count () const -> size_t
 
auto get_non_skinned_submeshes_indices (uint32_t data_group_id) const -> const submesh_array_indices_t &
 
auto get_submesh_index (const submesh *s) const -> int
 

Protected Types

using submesh_key_map_t = std::map<mesh_submesh_key, submesh*>
 
using submesh_key_array_t = std::vector<mesh_submesh_key>
 
using bone_combination_map_t = std::map<bone_combination_key, std::vector<uint32_t>*>
 

Protected Member Functions

void check_for_degenerates ()
 
auto generate_vertex_components (bool weld) -> bool
 Generates any vertex components that may be missing, such as normals, tangents, or binormals.
 
auto generate_vertex_normals (uint32_t *adjacency_ptr, std::vector< uint32_t > *remap_array_ptr=nullptr) -> bool
 Generates vertex normals for the mesh.
 
auto generate_vertex_barycentrics (uint32_t *adjacency) -> bool
 Generates vertex barycentric coordinates for the mesh.
 
auto generate_vertex_tangents () -> bool
 Generates vertex tangents for the mesh.
 
auto weld_vertices (float tolerance=0.000001f, std::vector< uint32_t > *vertex_remap_ptr=nullptr) -> bool
 Welds the vertices together that can be combined.
 
auto sort_mesh_data () -> bool
 Sorts the data in the mesh into material and data group order.
 

Static Protected Member Functions

static void build_optimized_index_buffer (const submesh *submesh, uint32_t *source_buffer_ptr, uint32_t *destination_buffer_ptr, uint32_t minimum_vertex, uint32_t maximum_vertex)
 Calculates the best order for triangle data, optimizing for efficient use of the hardware vertex cache.
 
static auto find_vertex_optimizer_score (const optimizer_vertex_info *vertex_info_ptr) -> float
 Generates scores used to identify important vertices when ordering triangle data.
 

Protected Attributes

bool force_tangent_generation_ = false
 < Whether to force the generation of tangent space vectors.
 
bool force_normal_generation_ = false
 Whether to force the generation of vertex barycentric coordinates.
 
bool force_barycentric_generation_ = false
 Whether to disable the automatic re-sort operation.
 
bool disable_final_sort_ = false
 The vertex data during data insertion and system memory copy.
 
uint8_t * system_vb_ = nullptr
 The vertex format used for the mesh internal vertex data.
 
gfx::vertex_layout vertex_format_
 The final system memory copy of the index buffer.
 
uint32_t * system_ib_ = nullptr
 Material and data group information for each triangle.
 
submesh_key_array_t triangle_data_
 The actual hardware vertex buffer resource.
 
std::shared_ptr< void > hardware_vb_
 The actual hardware index buffer resource.
 
std::shared_ptr< void > hardware_ib_
 The actual list of submeshes maintained by this mesh.
 
submesh_array_t mesh_submeshes_
 Indices in the subset array which are skinned.
 
submesh_array_map_t skinned_submesh_indices_
 
size_t skinned_submesh_count_ {}
 Indices in the subset array which are not skinned.
 
submesh_array_map_t non_skinned_submesh_indices_
 
size_t non_skinned_submesh_count_ {}
 Lookup information mapping data groups to submeshes batched by material.
 
data_group_submesh_map_t data_groups_
 Whether the mesh uses a hardware vertex/index buffer.
 
bool hardware_mesh_ = true
 Whether the mesh was optimized when it was prepared.
 
bool optimize_mesh_ = false
 Axis aligned bounding box describing object dimensions in object space.
 
math::bbox bbox_
 Total number of faces in the prepared mesh.
 
uint32_t face_count_ = 0
 Total number of vertices in the prepared mesh.
 
uint32_t vertex_count_ = 0
 Preparation status of the mesh.
 
mesh_status prepare_status_ = mesh_status::not_prepared
 Input data used for constructing the final mesh.
 
preparation_data preparation_data_
 Data describing how the mesh should be bound as a skin with supplied bone matrices.
 
skin_bind_data skin_bind_data_
 List of unique combinations of bones to use during rendering.
 
bone_palette_array_t bone_palettes_
 List of armature nodes.
 
std::unique_ptr< armature_noderoot_ = nullptr
 

Friends

auto operator< (const adjacent_edge_key &key1, const adjacent_edge_key &key2) -> bool
 
auto operator< (const mesh_submesh_key &key1, const mesh_submesh_key &key2) -> bool
 
auto operator< (const weld_key &key1, const weld_key &key2) -> bool
 
auto operator< (const bone_combination_key &key1, const bone_combination_key &key2) -> bool
 

Detailed Description

Main class representing a 3D mesh with support for different LODs, submeshes, and skinning.

Definition at line 309 of file mesh.h.

Member Typedef Documentation

◆ bone_combination_map_t

using unravel::mesh::bone_combination_map_t = std::map<bone_combination_key, std::vector<uint32_t>*>
protected

Definition at line 944 of file mesh.h.

◆ bone_palette_array_t

Definition at line 363 of file mesh.h.

◆ byte_array_t

using unravel::mesh::byte_array_t = std::vector<uint8_t>

Definition at line 368 of file mesh.h.

◆ data_group_submesh_map_t

Definition at line 367 of file mesh.h.

◆ submesh_array_indices_t

using unravel::mesh::submesh_array_indices_t = std::vector<size_t>

Definition at line 364 of file mesh.h.

◆ submesh_array_map_t

Definition at line 365 of file mesh.h.

◆ submesh_array_t

using unravel::mesh::submesh_array_t = std::vector<submesh*>

Definition at line 362 of file mesh.h.

◆ submesh_key_array_t

using unravel::mesh::submesh_key_array_t = std::vector<mesh_submesh_key>
protected

Definition at line 918 of file mesh.h.

◆ submesh_key_map_t

Definition at line 917 of file mesh.h.

◆ triangle_array_t

Definition at line 361 of file mesh.h.

Constructor & Destructor Documentation

◆ mesh()

unravel::mesh::mesh ( )

Constructs a mesh object.

Definition at line 115 of file mesh.cpp.

◆ ~mesh()

unravel::mesh::~mesh ( )

Destructor.

Definition at line 119 of file mesh.cpp.

Member Function Documentation

◆ bind_armature()

auto unravel::mesh::bind_armature ( std::unique_ptr< armature_node > & root) -> bool

Binds the armature tree.

Parameters
rootThe root node of the armature.
Returns
true If the armature was successfully bound.
false If binding the armature failed.

Definition at line 715 of file mesh.cpp.

◆ bind_render_buffers_for_submesh()

void unravel::mesh::bind_render_buffers_for_submesh ( const submesh * submesh)

Binds the mesh data for rendering the selected batch of primitives.

Parameters
face_startThe starting face index.
face_countThe number of faces to render.
vertex_startThe starting vertex index.
vertex_countThe number of vertices to render.

Definition at line 2811 of file mesh.cpp.

◆ bind_skin()

auto unravel::mesh::bind_skin ( const skin_bind_data & bind_data) -> bool

Binds the mesh as a skin with the specified skin binding data.

Parameters
bind_dataThe skin binding data.
Returns
true If the mesh was successfully bound as a skin.
false If binding the mesh as a skin failed.

Definition at line 478 of file mesh.cpp.

◆ build_ib()

void unravel::mesh::build_ib ( bool hardware_copy = true)

Builds the internal index buffer.

Parameters
hardware_copyWhether to use hardware copy.

Definition at line 1104 of file mesh.cpp.

◆ build_optimized_index_buffer()

void unravel::mesh::build_optimized_index_buffer ( const submesh * submesh,
uint32_t * source_buffer_ptr,
uint32_t * destination_buffer_ptr,
uint32_t minimum_vertex,
uint32_t maximum_vertex )
staticprotected

Calculates the best order for triangle data, optimizing for efficient use of the hardware vertex cache.

Parameters
submeshThe submesh to optimize.
source_buffer_ptrPointer to the source index buffer.
destination_buffer_ptrPointer to the destination index buffer.
minimum_vertexThe minimum vertex index.
maximum_vertexThe maximum vertex index.

Definition at line 2851 of file mesh.cpp.

◆ build_vb()

void unravel::mesh::build_vb ( bool hardware_copy = true)

Builds the internal vertex buffer.

Parameters
hardware_copyWhether to use hardware copy.

Definition at line 1090 of file mesh.cpp.

◆ calculate_screen_rect()

auto unravel::mesh::calculate_screen_rect ( const math::transform & world,
const camera & cam ) const -> irect32_t

Calculates the screen rectangle of the mesh based on its world transform and the camera.

Parameters
worldThe world transform of the mesh.
camThe camera.
Returns
irect32_t The screen rectangle.

Definition at line 1414 of file mesh.cpp.

◆ check_for_degenerates()

void unravel::mesh::check_for_degenerates ( )
protected

Definition at line 982 of file mesh.cpp.

◆ create_capsule()

auto unravel::mesh::create_capsule ( const gfx::vertex_layout & format,
float radius,
float height,
uint32_t stacks,
uint32_t slices,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a capsule geometry.

Parameters
formatThe vertex format.
radiusThe radius of the capsule.
heightThe height of the capsule.
stacksThe number of stacks.
slicesThe number of slices.
originThe origin of the capsule.
hardware_copyWhether to use hardware copy.
Returns
true If the capsule was successfully created.
false If creating the capsule failed.

Definition at line 857 of file mesh.cpp.

◆ create_cone()

auto unravel::mesh::create_cone ( const gfx::vertex_layout & format,
float radius,
float radius_tip,
float height,
uint32_t stacks,
uint32_t slices,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a cone geometry.

Parameters
formatThe vertex format.
radiusThe base radius of the cone.
radius_tipThe tip radius of the cone.
heightThe height of the cone.
stacksThe number of stacks.
slicesThe number of slices.
originThe origin of the cone.
hardware_copyWhether to use hardware copy.
Returns
true If the cone was successfully created.
false If creating the cone failed.

Definition at line 878 of file mesh.cpp.

◆ create_cube()

auto unravel::mesh::create_cube ( const gfx::vertex_layout & format,
float width,
float height,
float depth,
uint32_t width_segments,
uint32_t height_segments,
uint32_t depth_segments,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a cube geometry.

Parameters
formatThe vertex format.
widthThe width of the cube.
heightThe height of the cube.
depthThe depth of the cube.
width_segmentsThe number of segments along the width.
height_segmentsThe number of segments along the height.
depth_segmentsThe number of segments along the depth.
originThe origin of the cube.
hardware_copyWhether to use hardware copy.
Returns
true If the cube was successfully created.
false If creating the cube failed.

Definition at line 765 of file mesh.cpp.

◆ create_cylinder()

auto unravel::mesh::create_cylinder ( const gfx::vertex_layout & format,
float radius,
float height,
uint32_t stacks,
uint32_t slices,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a cylinder geometry.

Parameters
formatThe vertex format.
radiusThe radius of the cylinder.
heightThe height of the cylinder.
stacksThe number of stacks.
slicesThe number of slices.
originThe origin of the cylinder.
hardware_copyWhether to use hardware copy.
Returns
true If the cylinder was successfully created.
false If creating the cylinder failed.

Definition at line 832 of file mesh.cpp.

◆ create_dodecahedron()

auto unravel::mesh::create_dodecahedron ( const gfx::vertex_layout & format,
bool hardware_copy = true ) -> bool

Creates a dodecahedron geometry.

Parameters
formatThe vertex format.
hardware_copyWhether to use hardware copy.
Returns
true If the dodecahedron was successfully created.
false If creating the dodecahedron failed.

Definition at line 951 of file mesh.cpp.

◆ create_icosahedron()

auto unravel::mesh::create_icosahedron ( const gfx::vertex_layout & format,
bool hardware_copy = true ) -> bool

Creates an icosahedron geometry.

Parameters
formatThe vertex format.
hardware_copyWhether to use hardware copy.
Returns
true If the icosahedron was successfully created.
false If creating the icosahedron failed.

Definition at line 936 of file mesh.cpp.

◆ create_icosphere()

auto unravel::mesh::create_icosphere ( const gfx::vertex_layout & format,
int tesselation_level,
bool hardware_copy = true ) -> bool

Creates an icosphere geometry.

Parameters
formatThe vertex format.
tesselation_levelThe level of tesselation.
hardware_copyWhether to use hardware copy.
Returns
true If the icosphere was successfully created.
false If creating the icosphere failed.

Definition at line 966 of file mesh.cpp.

◆ create_plane()

auto unravel::mesh::create_plane ( const gfx::vertex_layout & format,
float width,
float height,
uint32_t width_segments,
uint32_t height_segments,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a plane geometry.

Parameters
formatThe vertex format.
widthThe width of the plane.
heightThe height of the plane.
width_segmentsThe number of segments along the width.
height_segmentsThe number of segments along the height.
originThe origin of the plane.
hardware_copyWhether to use hardware copy.
Returns
true If the plane was successfully created.
false If creating the plane failed.

Definition at line 740 of file mesh.cpp.

◆ create_rounded_cube()

auto unravel::mesh::create_rounded_cube ( const gfx::vertex_layout & format,
float width,
float height,
float depth,
uint32_t width_segments,
uint32_t height_segments,
uint32_t depth_segments,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Definition at line 789 of file mesh.cpp.

◆ create_sphere()

auto unravel::mesh::create_sphere ( const gfx::vertex_layout & format,
float radius,
uint32_t stacks,
uint32_t slices,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a sphere geometry.

Parameters
formatThe vertex format.
radiusThe radius of the sphere.
stacksThe number of stacks.
slicesThe number of slices.
originThe origin of the sphere.
hardware_copyWhether to use hardware copy.
Returns
true If the sphere was successfully created.
false If creating the sphere failed.

Definition at line 812 of file mesh.cpp.

◆ create_teapot()

auto unravel::mesh::create_teapot ( const gfx::vertex_layout & format,
bool hardware_copy = true ) -> bool

Creates a teapot geometry.

Parameters
formatThe vertex format.
hardware_copyWhether to use hardware copy.
Returns
true If the teapot was successfully created.
false If creating the teapot failed.

Definition at line 921 of file mesh.cpp.

◆ create_torus()

auto unravel::mesh::create_torus ( const gfx::vertex_layout & format,
float outer_radius,
float inner_radius,
uint32_t bands,
uint32_t sides,
mesh_create_origin origin,
bool hardware_copy = true ) -> bool

Creates a torus geometry.

Parameters
formatThe vertex format.
outer_radiusThe outer radius of the torus.
inner_radiusThe inner radius of the torus.
bandsThe number of bands.
sidesThe number of sides.
originThe origin of the torus.
hardware_copyWhether to use hardware copy.
Returns
true If the torus was successfully created.
false If creating the torus failed.

Definition at line 900 of file mesh.cpp.

◆ dispose()

void unravel::mesh::dispose ( )

Clears out all the mesh data.

Definition at line 124 of file mesh.cpp.

◆ end_prepare()

auto unravel::mesh::end_prepare ( bool hardware_copy = true,
bool build_buffers = true,
bool weld = false,
bool optimize = false ) -> bool

Ends the preparation of the mesh and builds the render data.

Parameters
hardware_copyWhether to use hardware copy.
weldWhether to weld vertices.
optimizeWhether to optimize the mesh.
build_buffersWhether to build the render buffers.
Returns
true If the mesh was successfully prepared.
false If the mesh preparation failed.

Definition at line 1017 of file mesh.cpp.

◆ find_vertex_optimizer_score()

auto unravel::mesh::find_vertex_optimizer_score ( const optimizer_vertex_info * vertex_info_ptr) -> float
staticprotected

Generates scores used to identify important vertices when ordering triangle data.

Parameters
vertex_info_ptrPointer to the vertex information.
Returns
float The vertex score.

Definition at line 3092 of file mesh.cpp.

◆ generate_adjacency()

auto unravel::mesh::generate_adjacency ( std::vector< uint32_t > & adjacency) -> bool

Generates edge-triangle adjacency information for the mesh data.

Parameters
adjacencyThe adjacency information output array.
Returns
true If the adjacency information was successfully generated.
false If generating the adjacency information failed.

Definition at line 1131 of file mesh.cpp.

◆ generate_vertex_barycentrics()

auto unravel::mesh::generate_vertex_barycentrics ( uint32_t * adjacency) -> bool
protected

Generates vertex barycentric coordinates for the mesh.

Parameters
adjacencyPointer to the adjacency information.
Returns
true If the vertex barycentric coordinates were successfully generated.
false If generating the vertex barycentric coordinates failed.

Definition at line 2066 of file mesh.cpp.

◆ generate_vertex_components()

auto unravel::mesh::generate_vertex_components ( bool weld) -> bool
protected

Generates any vertex components that may be missing, such as normals, tangents, or binormals.

Parameters
weldWhether to weld vertices.
Returns
true If the vertex components were successfully generated.
false If generating the vertex components failed.

Definition at line 1705 of file mesh.cpp.

◆ generate_vertex_normals()

auto unravel::mesh::generate_vertex_normals ( uint32_t * adjacency_ptr,
std::vector< uint32_t > * remap_array_ptr = nullptr ) -> bool
protected

Generates vertex normals for the mesh.

Parameters
adjacency_ptrPointer to the adjacency information.
remap_array_ptrPointer to the vertex remap array.
Returns
true If the vertex normals were successfully generated.
false If generating the vertex normals failed.

Definition at line 1781 of file mesh.cpp.

◆ generate_vertex_tangents()

auto unravel::mesh::generate_vertex_tangents ( ) -> bool
protected

Generates vertex tangents for the mesh.

Returns
true If the vertex tangents were successfully generated.
false If generating the vertex tangents failed.

Definition at line 2072 of file mesh.cpp.

◆ get_armature()

auto unravel::mesh::get_armature ( ) const -> const std::unique_ptr<armature_node>&

Retrieves the armature tree of the mesh.

Returns
const std::unique_ptr<armature_node>& The root node of the armature tree.

Definition at line 1409 of file mesh.cpp.

◆ get_bone_palettes()

auto unravel::mesh::get_bone_palettes ( ) const -> const bone_palette_array_t&

Retrieves the compiled bone combination palette data if this mesh has been bound as a skin.

Returns
const bone_palette_array_t& The bone palette data.

Definition at line 1404 of file mesh.cpp.

◆ get_bounds()

auto unravel::mesh::get_bounds ( ) const -> const math::bbox&

Gets the local bounding box for this mesh.

Returns
const math::bbox& The bounding box.

Definition at line 1507 of file mesh.cpp.

◆ get_data_groups_count()

auto unravel::mesh::get_data_groups_count ( ) const -> size_t

Gets the number of data groups(materials) for this mesh.

Returns
size_t The number of data groups.

Definition at line 1517 of file mesh.cpp.

◆ get_face_count()

auto unravel::mesh::get_face_count ( ) const -> uint32_t

Determines the number of faces stored in the mesh.

Returns
uint32_t The number of faces.

Definition at line 1356 of file mesh.cpp.

◆ get_non_skinned_submeshes_count()

auto unravel::mesh::get_non_skinned_submeshes_count ( ) const -> size_t

Definition at line 1490 of file mesh.cpp.

◆ get_non_skinned_submeshes_indices()

auto unravel::mesh::get_non_skinned_submeshes_indices ( uint32_t data_group_id) const -> const submesh_array_indices_t&

Definition at line 1495 of file mesh.cpp.

◆ get_skin_bind_data()

auto unravel::mesh::get_skin_bind_data ( ) const -> const skin_bind_data&

Retrieves the skin bind data if this mesh has been bound as a skin.

Returns
const skin_bind_data& The skin bind data.

Definition at line 1399 of file mesh.cpp.

◆ get_skinned_submeshes_count()

auto unravel::mesh::get_skinned_submeshes_count ( ) const -> size_t

Definition at line 1473 of file mesh.cpp.

◆ get_skinned_submeshes_indices()

auto unravel::mesh::get_skinned_submeshes_indices ( uint32_t data_group_id) const -> const submesh_array_indices_t&

Definition at line 1478 of file mesh.cpp.

◆ get_status()

auto unravel::mesh::get_status ( ) const -> mesh_status

Gets the preparation status for this mesh.

Returns
mesh_status The preparation status.

Definition at line 1512 of file mesh.cpp.

◆ get_submesh()

auto unravel::mesh::get_submesh ( uint32_t submesh_index = 0) const -> const mesh::submesh&

Definition at line 1453 of file mesh.cpp.

◆ get_submesh_index()

auto unravel::mesh::get_submesh_index ( const submesh * s) const -> int

Definition at line 1458 of file mesh.cpp.

◆ get_submeshes()

auto unravel::mesh::get_submeshes ( ) const -> const submesh_array_t&

Retrieves information about the submesh of the mesh associated with the specified data group identifier.

Parameters
data_group_idThe data group identifier.
Returns
const submesh* Pointer to the submesh information.

Definition at line 1443 of file mesh.cpp.

◆ get_submeshes_count()

auto unravel::mesh::get_submeshes_count ( ) const -> size_t

Gets the number of submeshes for this mesh.

Returns
size_t The number of data groups.

Definition at line 1448 of file mesh.cpp.

◆ get_system_ib()

auto unravel::mesh::get_system_ib ( ) -> uint32_t*

Retrieves the underlying index data from the mesh.

Returns
uint32_t* The index data.

Definition at line 1389 of file mesh.cpp.

◆ get_system_vb()

auto unravel::mesh::get_system_vb ( ) -> uint8_t*

Retrieves the underlying vertex data from the mesh.

Returns
uint8_t* The vertex data.

Definition at line 1384 of file mesh.cpp.

◆ get_vertex_count()

auto unravel::mesh::get_vertex_count ( ) const -> uint32_t

Determines the number of vertices stored in the mesh.

Returns
uint32_t The number of vertices.

Definition at line 1370 of file mesh.cpp.

◆ get_vertex_format()

auto unravel::mesh::get_vertex_format ( ) const -> const gfx::vertex_layout&

Retrieves the format of the underlying mesh vertex data.

Returns
const gfx::vertex_layout& The vertex format.

Definition at line 1394 of file mesh.cpp.

◆ load_mesh()

auto unravel::mesh::load_mesh ( load_data && data) -> bool

Definition at line 723 of file mesh.cpp.

◆ prepare_mesh()

auto unravel::mesh::prepare_mesh ( const gfx::vertex_layout & vertex_format) -> bool

Prepares the mesh with the specified vertex format.

Parameters
vertex_formatThe vertex format to use.
Returns
true If the mesh was successfully prepared.
false If the mesh preparation failed.

Definition at line 188 of file mesh.cpp.

◆ set_bounding_box()

auto unravel::mesh::set_bounding_box ( const math::bbox & box) -> bool

Definition at line 297 of file mesh.cpp.

◆ set_primitives()

auto unravel::mesh::set_primitives ( triangle_array_t && triangles) -> bool

Adds primitives (triangles) to the mesh.

Parameters
trianglesThe triangles to add.
Returns
true If the primitives were successfully added.
false If adding the primitives failed.

Definition at line 323 of file mesh.cpp.

◆ set_submeshes()

auto unravel::mesh::set_submeshes ( const std::vector< submesh > & submeshes) -> bool

Definition at line 305 of file mesh.cpp.

◆ set_vertex_source() [1/2]

auto unravel::mesh::set_vertex_source ( byte_array_t && source,
uint32_t vertex_count,
const gfx::vertex_layout & source_format ) -> bool

Definition at line 214 of file mesh.cpp.

◆ set_vertex_source() [2/2]

auto unravel::mesh::set_vertex_source ( void * source,
uint32_t vertex_count,
const gfx::vertex_layout & source_format ) -> bool

Sets the source of the vertex buffer to pull data from while preparing the mesh.

Parameters
sourceThe source vertex data.
vertex_countThe number of vertices.
source_formatThe format of the source vertex data.
Returns
true If the vertex source was successfully set.
false If setting the vertex source failed.

◆ sort_mesh_data()

auto unravel::mesh::sort_mesh_data ( ) -> bool
protected

Sorts the data in the mesh into material and data group order.

Returns
true If the mesh data was successfully sorted.
false If sorting the mesh data failed.

Definition at line 2739 of file mesh.cpp.

◆ weld_vertices()

auto unravel::mesh::weld_vertices ( float tolerance = 0.000001f,
std::vector< uint32_t > * vertex_remap_ptr = nullptr ) -> bool
protected

Welds the vertices together that can be combined.

Parameters
toleranceThe tolerance for welding vertices.
vertexRemapPointer to the vertex remap array.
Returns
true If the vertices were successfully welded.
false If welding the vertices failed.

Definition at line 2258 of file mesh.cpp.

Friends And Related Symbol Documentation

◆ operator< [1/4]

auto operator< ( const adjacent_edge_key & key1,
const adjacent_edge_key & key2 ) -> bool
friend

Definition at line 1536 of file mesh.cpp.

◆ operator< [2/4]

auto operator< ( const bone_combination_key & key1,
const bone_combination_key & key2 ) -> bool
friend

Definition at line 1672 of file mesh.cpp.

◆ operator< [3/4]

auto operator< ( const mesh_submesh_key & key1,
const mesh_submesh_key & key2 ) -> bool
friend

Definition at line 1569 of file mesh.cpp.

◆ operator< [4/4]

auto operator< ( const weld_key & key1,
const weld_key & key2 ) -> bool
friend

Definition at line 1574 of file mesh.cpp.

Member Data Documentation

◆ bbox_

math::bbox unravel::mesh::bbox_
protected

Total number of faces in the prepared mesh.

Definition at line 1072 of file mesh.h.

◆ bone_palettes_

bone_palette_array_t unravel::mesh::bone_palettes_
protected

List of armature nodes.

Definition at line 1086 of file mesh.h.

◆ data_groups_

data_group_submesh_map_t unravel::mesh::data_groups_
protected

Whether the mesh uses a hardware vertex/index buffer.

Definition at line 1065 of file mesh.h.

◆ disable_final_sort_

bool unravel::mesh::disable_final_sort_ = false
protected

The vertex data during data insertion and system memory copy.

Definition at line 1038 of file mesh.h.

◆ face_count_

uint32_t unravel::mesh::face_count_ = 0
protected

Total number of vertices in the prepared mesh.

Definition at line 1074 of file mesh.h.

◆ force_barycentric_generation_

bool unravel::mesh::force_barycentric_generation_ = false
protected

Whether to disable the automatic re-sort operation.

Definition at line 1036 of file mesh.h.

◆ force_normal_generation_

bool unravel::mesh::force_normal_generation_ = false
protected

Whether to force the generation of vertex barycentric coordinates.

Definition at line 1034 of file mesh.h.

◆ force_tangent_generation_

bool unravel::mesh::force_tangent_generation_ = false
protected

< Whether to force the generation of tangent space vectors.

Whether to force the generation of vertex normals.

Definition at line 1032 of file mesh.h.

◆ hardware_ib_

std::shared_ptr<void> unravel::mesh::hardware_ib_
protected

The actual list of submeshes maintained by this mesh.

Definition at line 1051 of file mesh.h.

◆ hardware_mesh_

bool unravel::mesh::hardware_mesh_ = true
protected

Whether the mesh was optimized when it was prepared.

Definition at line 1068 of file mesh.h.

◆ hardware_vb_

std::shared_ptr<void> unravel::mesh::hardware_vb_
protected

The actual hardware index buffer resource.

Definition at line 1049 of file mesh.h.

◆ mesh_submeshes_

submesh_array_t unravel::mesh::mesh_submeshes_
protected

Indices in the subset array which are skinned.

Definition at line 1054 of file mesh.h.

◆ non_skinned_submesh_count_

size_t unravel::mesh::non_skinned_submesh_count_ {}
protected

Lookup information mapping data groups to submeshes batched by material.

Definition at line 1062 of file mesh.h.

◆ non_skinned_submesh_indices_

submesh_array_map_t unravel::mesh::non_skinned_submesh_indices_
protected

Definition at line 1061 of file mesh.h.

◆ optimize_mesh_

bool unravel::mesh::optimize_mesh_ = false
protected

Axis aligned bounding box describing object dimensions in object space.

Definition at line 1070 of file mesh.h.

◆ preparation_data_

preparation_data unravel::mesh::preparation_data_
protected

Data describing how the mesh should be bound as a skin with supplied bone matrices.

Definition at line 1081 of file mesh.h.

◆ prepare_status_

mesh_status unravel::mesh::prepare_status_ = mesh_status::not_prepared
protected

Input data used for constructing the final mesh.

Definition at line 1079 of file mesh.h.

◆ root_

std::unique_ptr<armature_node> unravel::mesh::root_ = nullptr
protected

Definition at line 1088 of file mesh.h.

◆ skin_bind_data_

skin_bind_data unravel::mesh::skin_bind_data_
protected

List of unique combinations of bones to use during rendering.

Definition at line 1084 of file mesh.h.

◆ skinned_submesh_count_

size_t unravel::mesh::skinned_submesh_count_ {}
protected

Indices in the subset array which are not skinned.

Definition at line 1058 of file mesh.h.

◆ skinned_submesh_indices_

submesh_array_map_t unravel::mesh::skinned_submesh_indices_
protected

Definition at line 1057 of file mesh.h.

◆ system_ib_

uint32_t* unravel::mesh::system_ib_ = nullptr
protected

Material and data group information for each triangle.

Definition at line 1045 of file mesh.h.

◆ system_vb_

uint8_t* unravel::mesh::system_vb_ = nullptr
protected

The vertex format used for the mesh internal vertex data.

Definition at line 1041 of file mesh.h.

◆ triangle_data_

submesh_key_array_t unravel::mesh::triangle_data_
protected

The actual hardware vertex buffer resource.

Definition at line 1047 of file mesh.h.

◆ vertex_count_

uint32_t unravel::mesh::vertex_count_ = 0
protected

Preparation status of the mesh.

Definition at line 1076 of file mesh.h.

◆ vertex_format_

gfx::vertex_layout unravel::mesh::vertex_format_
protected

The final system memory copy of the index buffer.

Definition at line 1043 of file mesh.h.


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