Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::Mesh Class Reference

Buffers, the layout that describes them, and the bounds culling reads. More...

#include <Mesh.hpp>

Public Member Functions

bool hasEdges () const
bool isSkinned () const
bool isMorphable () const
bool isChunked () const
bool hasRealization () const
bool isDrawable () const

Public Attributes

resource::VertexBufferHandle vertices
resource::IndexBufferHandle indices
BufferHandle vertexBuffer = BufferHandle::Invalid
BufferHandle indexBuffer = BufferHandle::Invalid
VertexLayoutHandle layout = VertexLayoutHandle::Invalid
u32 indexCount = 0
u32 firstIndex = 0
u32 arenaPage = 0
u32 arenaFirstVertex = 0
resource::IndexBufferHandle edges
BufferHandle edgeIndexBuffer = BufferHandle::Invalid
u32 edgeIndexCount = 0
MeshRecovery recovery = MeshRecovery::HostOnly
bool hasNormals = false
bool hasLightmapUV = false
bool hasTangents = false
f32 uvDensity = 0.0f
glm::vec3 localMin {0.0f, 0.0f, 0.0f}
glm::vec3 localMax {0.0f, 0.0f, 0.0f}
std::vector< glm::mat4 > inverseBind
TextureHandle morphTexture = TextureHandle::Invalid
u32 morphTargetCount = 0
bool morphHasNormals = false
u32 vertexCount = 0
std::shared_ptr< const lod::ClusterHierarchy > clusters
std::vector< MeshSkinChunk > skinChunks
std::shared_ptr< const std::vector< u8 > > skinSource
std::shared_ptr< const std::vector< u32 > > skinIndices
MeshSkinLayout skinLayout
std::vector< u16 > skinChunkBones
u64 revision = 0

Detailed Description

Buffers, the layout that describes them, and the bounds culling reads.

One record because the three are inseparable: a buffer without its layout cannot be drawn, and bounds kept elsewhere go stale. Where the geometry comes back from after a device loss is the minting producer's to declare — tools/meshProducers.mjs.

Definition at line 85 of file Mesh.hpp.

Member Function Documentation

◆ hasEdges()

bool esengine::Mesh::hasEdges ( ) const
inline

Whether the edges can be drawn.

Definition at line 118 of file Mesh.hpp.

References edgeIndexBuffer, edgeIndexCount, and esengine::Invalid.

Referenced by esengine::MeshPlugin::collect().

◆ hasRealization()

bool esengine::Mesh::hasRealization ( ) const
inline

Whether GPU buffers stand behind this identity.

Definition at line 192 of file Mesh.hpp.

References indexBuffer, esengine::Invalid, layout, and vertexBuffer.

Referenced by isDrawable(), and esengine::resource::ResourceManager::meshRealizations().

◆ isChunked()

bool esengine::Mesh::isChunked ( ) const
inline

Definition at line 186 of file Mesh.hpp.

References skinChunks.

Referenced by esengine::MeshPlugin::collect().

◆ isDrawable()

bool esengine::Mesh::isDrawable ( ) const
inline

◆ isMorphable()

bool esengine::Mesh::isMorphable ( ) const
inline

Definition at line 162 of file Mesh.hpp.

References esengine::Invalid, morphTargetCount, and morphTexture.

Referenced by esengine::SkinCache::schedule().

◆ isSkinned()

bool esengine::Mesh::isSkinned ( ) const
inline

Member Data Documentation

◆ arenaFirstVertex

u32 esengine::Mesh::arenaFirstVertex = 0

Definition at line 105 of file Mesh.hpp.

Referenced by esengine::resource::ResourceManager::releaseMesh().

◆ arenaPage

u32 esengine::Mesh::arenaPage = 0

The page and first vertex of that place, to give it back: page 0 is buffers of the mesh's own.

Definition at line 104 of file Mesh.hpp.

Referenced by esengine::resource::ResourceManager::releaseMesh().

◆ clusters

std::shared_ptr<const lod::ClusterHierarchy> esengine::Mesh::clusters

The mesh at every level of detail, as clusters a view picks from (ClusterSelection.hpp). Null for a mesh drawn whole. indexBuffer holds level 0, the mesh's own triangles, so whatever knows nothing of clusters draws it as it always was. Given after the geometry is realized and dropped when it is realized again: the indices in it name these vertices.

Definition at line 171 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and esengine::resource::ResourceManager::setMeshClusters().

◆ edgeIndexBuffer

BufferHandle esengine::Mesh::edgeIndexBuffer = BufferHandle::Invalid

Definition at line 114 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and hasEdges().

◆ edgeIndexCount

u32 esengine::Mesh::edgeIndexCount = 0

Definition at line 115 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and hasEdges().

◆ edges

resource::IndexBufferHandle esengine::Mesh::edges

The mesh's own edges as line-list indices into the same vertices, one pair per distinct edge. Derived from indices when the mesh is realized, and only while the manager is asked for diagnostic geometry (an editor's wireframe view): a shipped game spends nothing on it. Invalid otherwise.

Definition at line 113 of file Mesh.hpp.

Referenced by esengine::resource::ResourceManager::releaseMesh().

◆ firstIndex

u32 esengine::Mesh::firstIndex = 0

Where this mesh's first index sits in indexBuffer: past zero when the mesh shares a page with others of its vertex shape (MeshArena), whose buffers and layout it then draws through. Its indices are rebased onto the page's vertices, so a draw reads indexCount of them from here and needs nothing else to find its own.

Definition at line 102 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and esengine::resource::ResourceManager::releaseMesh().

◆ hasLightmapUV

bool esengine::Mesh::hasLightmapUV = false

Whether the vertices carry a second UV set — the one a bake is read through. Beside hasNormals and for the same reason: an optional channel the geometry owns decides the record's shape and the variant.

Definition at line 132 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and esengine::placementCoarseMesh().

◆ hasNormals

bool esengine::Mesh::hasNormals = false

Whether the vertices carry normals — decides the per-object record's shape and which shader variant draws it.

Definition at line 127 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and esengine::placementCoarseMesh().

◆ hasTangents

bool esengine::Mesh::hasTangents = false

Whether the vertices carry a tangent (xyz along +u, w the bitangent's handedness) beside the normal — the frame a normal map was baked in. Without one the fragment derives a frame from screen-space derivatives.

Definition at line 136 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and esengine::placementCoarseMesh().

◆ indexBuffer

BufferHandle esengine::Mesh::indexBuffer = BufferHandle::Invalid

Definition at line 92 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and hasRealization().

◆ indexCount

◆ indices

◆ inverseBind

std::vector<glm::mat4> esengine::Mesh::inverseBind

The bind pose, one per joint the Joints channel indexes. Empty for geometry nothing skins; its size is what a skinned draw allocates.

Definition at line 148 of file Mesh.hpp.

Referenced by esengine::gatherLodLevels(), isSkinned(), and esengine::resource::ResourceManager::setMeshSkinChunks().

◆ layout

◆ localMax

glm::vec3 esengine::Mesh::localMax {0.0f, 0.0f, 0.0f}

◆ localMin

glm::vec3 esengine::Mesh::localMin {0.0f, 0.0f, 0.0f}

Local-space bounds of the vertices, for the frustum cull.

Definition at line 143 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), esengine::gatherLodLevels(), esengine::meshLocalBounds(), and esengine::renderer_renderMaterialPreview().

◆ morphHasNormals

bool esengine::Mesh::morphHasNormals = false

Definition at line 157 of file Mesh.hpp.

◆ morphTargetCount

u32 esengine::Mesh::morphTargetCount = 0

Definition at line 156 of file Mesh.hpp.

Referenced by isMorphable().

◆ morphTexture

TextureHandle esengine::Mesh::morphTexture = TextureHandle::Invalid

The shapes this geometry can be blended towards, as a texture of deltas: one texel per (target, vertex), and a second behind it where the targets bend normals. Realized with the buffers above and lost with them.

Definition at line 155 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), isMorphable(), and esengine::resource::ResourceManager::releaseMesh().

◆ recovery

MeshRecovery esengine::Mesh::recovery = MeshRecovery::HostOnly

Set at mint by the producer that created this mesh; never inferred later. Defaulted to the answer that promises nothing, so a mesh reaching the pool without one is never mistaken for recoverable.

Definition at line 123 of file Mesh.hpp.

Referenced by esengine::resource::ResourceManager::createMesh(), and esengine::resource::ResourceManager::rematerializeMesh().

◆ revision

u64 esengine::Mesh::revision = 0

Changes whenever this mesh's geometry does (it is realized again: a reload, a recovery): see core/Revision.hpp.

Definition at line 189 of file Mesh.hpp.

Referenced by esengine::SkinCache::schedule(), esengine::resource::ResourceManager::setMeshClusters(), and esengine::resource::ResourceManager::setMeshSkinChunks().

◆ skinChunkBones

std::vector<u16> esengine::Mesh::skinChunkBones

◆ skinChunks

std::vector<MeshSkinChunk> esengine::Mesh::skinChunks

The chunks a skin of more bones than one draw carries is drawn in, one draw each; empty for a mesh drawn in one. Given after the geometry is realized and dropped when it is realized again, like the clusters: its runs name these indices and its bones these bind matrices.

Definition at line 178 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), isChunked(), and esengine::resource::ResourceManager::setMeshSkinChunks().

◆ skinIndices

std::shared_ptr<const std::vector<u32> > esengine::Mesh::skinIndices

Its indices, with it: which vertices a chunk's run of triangles names.

Definition at line 183 of file Mesh.hpp.

◆ skinLayout

MeshSkinLayout esengine::Mesh::skinLayout

Definition at line 184 of file Mesh.hpp.

Referenced by esengine::SkinCache::schedule().

◆ skinSource

std::shared_ptr<const std::vector<u8> > esengine::Mesh::skinSource

A skinned mesh's vertices as uploaded, which the skin cache skins into a copy of its own each frame; with where its channels sit. Null for a mesh nothing skins. Shared, so a cache entry holds it past a reload of the mesh.

Definition at line 181 of file Mesh.hpp.

Referenced by esengine::SkinCache::schedule().

◆ uvDensity

f32 esengine::Mesh::uvDensity = 0.0f

UV units per world unit of the mesh's own surface (see MeshUvDensity.hpp): what a view asks a texture's size by. 0 without float positions and a float first UV set.

Definition at line 140 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect().

◆ vertexBuffer

BufferHandle esengine::Mesh::vertexBuffer = BufferHandle::Invalid

GPU-side handles, cached so a draw does not walk two pools per frame.

Definition at line 91 of file Mesh.hpp.

Referenced by esengine::MeshPlugin::collect(), and hasRealization().

◆ vertexCount

u32 esengine::Mesh::vertexCount = 0

Vertices the deltas are indexed by — the stride from one target to the next inside the texture, and the reason it is kept beside them.

Definition at line 160 of file Mesh.hpp.

Referenced by esengine::resource::ResourceManager::releaseMesh(), esengine::SkinCache::schedule(), and esengine::resource::ResourceManager::setMeshClusters().

◆ vertices


The documentation for this class was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/resource/Mesh.hpp