Toast Engine
Loading...
Searching...
No Matches
mesh.hpp File Reference

Represents 3D geometry data, can be read from a .tmesh binary file. More...

#include "core_types.hpp"
#include <glm/glm.hpp>
#include <memory>
#include <toast/export.hpp>
#include <toast/log.hpp>
#include <toast/renderer/vertex.hpp>
Include dependency graph for mesh.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  assets::_detail::MeshFileHeader
 Fixed 16-byte .tmesh header. More...
class  assets::Mesh

Functions

void assets::generateTangents (std::vector< renderer::Vertex > &vertices, const std::vector< uint32_t > &indices)
 Derives per-vertex tangents from UVs, for geometry that arrived without them.

Variables

constexpr uint16_t assets::_detail::mesh_format_version = 7

Detailed Description

Represents 3D geometry data, can be read from a .tmesh binary file.

Author
Xein
Date
11 Jun 2026

Function Documentation

◆ generateTangents()

TOAST_API void assets::generateTangents ( std::vector< renderer::Vertex > & vertices,
const std::vector< uint32_t > & indices )

Derives per-vertex tangents from UVs, for geometry that arrived without them.

glTF expects the client to generate these when a material has no normal map, and exporters take that literally. The shader survives a missing tangent only by inventing a basis, which points any normal map it does have in a meaningless direction

The standard accumulate-and-orthonormalize scheme, not MikkTSpace - it differs on mirrored UV seams and hard edges, so a mesh baked against MikkTSpace is still better off exporting real tangents

Parameters
verticesModified in place; only the tangent member is written
indicesTriangle list; a trailing partial triangle is ignored

Variable Documentation

◆ mesh_format_version

uint16_t assets::_detail::mesh_format_version = 7
inlineconstexpr

The one .tmesh version this build reads or writes. Older ones are rejected with a reimport message rather than read best-effort, because a mismatched SkinVertex stride misparses instead of failing cleanly

Layout: header, uint8 name length, name, vertex_count Vertex, index_count uint32, uint32 skin vertex count + that many SkinVertex (0 for a static mesh)