Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Object::Component::Mesh Struct Reference

Mesh structure. More...

#include <Mesh.hpp>

Public Member Functions

 Mesh ()=default
 ~Mesh ()
 Mesh (Mesh &&other) noexcept
Meshoperator= (Mesh &&other) noexcept
 Mesh (const Mesh &other)
Meshoperator= (const Mesh &other)
const std::vector< glm::vec3 > & GetVertices () const
const std::vector< glm::vec3 > & GetNormals () const
const std::vector< glm::vec2 > & GetTexCoords () const
const std::vector< uint32_t > & GetIndices () const
void SetVertices (const std::vector< glm::vec3 > &newVertices)
void SetVertexAt (size_t index, const glm::vec3 &vertex)
void ReserveVertices (size_t count)
template<typename... Args>
void EmplaceVertices (Args &&...args)
void SetNormals (const std::vector< glm::vec3 > &newNormals)
void SetNormalAt (size_t index, const glm::vec3 &normal)
void ReserveNormals (size_t count)
template<typename... Args>
void EmplaceNormals (Args &&...args)
void SetTexCoords (const std::vector< glm::vec2 > &newTexCoords)
void SetTexCoordAt (size_t index, const glm::vec2 &texCoord)
void ReserveTexCoords (size_t count)
template<typename... Args>
void EmplaceTexCoords (Args &&...args)
void SetIndices (const std::vector< uint32_t > &newIndices)
void SetIndexAt (size_t index, uint32_t indexValue)
void ReserveIndices (size_t count)
template<typename... Args>
void EmplaceIndices (Args &&...args)
bool IsDirty () const
 Check if the mesh data has been modified since last GPU sync.
void ClearDirty () const
 Clear the dirty flag after GPU buffer has been updated.

Private Attributes

std::vector< glm::vec3 > vertices {}
std::vector< glm::vec3 > normals {}
std::vector< glm::vec2 > texCoords {}
std::vector< uint32_t > indices {}
bool _dirty = false
 Dirty flag for GPU synchronization optimization.

Detailed Description

Mesh structure.

This structure is used to represent a mesh. It contains the vertices and indices of the mesh.

The mesh supports a dirty flag mechanism for efficient GPU updates. When mesh data is modified through the setter methods (SetVertices, SetVertexAt, etc.), the dirty flag is automatically set to signal that the GPU buffer needs to be updated.

Examples
Loading an OBJ file.

Constructor & Destructor Documentation

◆ Mesh() [1/3]

Object::Component::Mesh::Mesh ( )
explicitdefault

◆ ~Mesh()

Object::Component::Mesh::~Mesh ( )
inline

◆ Mesh() [2/3]

Object::Component::Mesh::Mesh ( Mesh && other)
inlinenoexcept

◆ Mesh() [3/3]

Object::Component::Mesh::Mesh ( const Mesh & other)
inline

Member Function Documentation

◆ ClearDirty()

void Object::Component::Mesh::ClearDirty ( ) const
inline

Clear the dirty flag after GPU buffer has been updated.

Called by the graphics system after successfully updating the GPU buffer to indicate the mesh is now in sync.

◆ EmplaceIndices()

template<typename... Args>
void Object::Component::Mesh::EmplaceIndices ( Args &&... args)
inline

◆ EmplaceNormals()

template<typename... Args>
void Object::Component::Mesh::EmplaceNormals ( Args &&... args)
inline

◆ EmplaceTexCoords()

template<typename... Args>
void Object::Component::Mesh::EmplaceTexCoords ( Args &&... args)
inline

◆ EmplaceVertices()

template<typename... Args>
void Object::Component::Mesh::EmplaceVertices ( Args &&... args)
inline

◆ GetIndices()

const std::vector< uint32_t > & Object::Component::Mesh::GetIndices ( ) const
inlinenodiscard

◆ GetNormals()

const std::vector< glm::vec3 > & Object::Component::Mesh::GetNormals ( ) const
inlinenodiscard

◆ GetTexCoords()

const std::vector< glm::vec2 > & Object::Component::Mesh::GetTexCoords ( ) const
inlinenodiscard

◆ GetVertices()

const std::vector< glm::vec3 > & Object::Component::Mesh::GetVertices ( ) const
inlinenodiscard

◆ IsDirty()

bool Object::Component::Mesh::IsDirty ( ) const
inlinenodiscard

Check if the mesh data has been modified since last GPU sync.

Returns
true if mesh data was modified and GPU buffer needs update.
false if mesh data is in sync with GPU buffer.

◆ operator=() [1/2]

Mesh & Object::Component::Mesh::operator= ( const Mesh & other)
inline

◆ operator=() [2/2]

Mesh & Object::Component::Mesh::operator= ( Mesh && other)
inlinenoexcept

◆ ReserveIndices()

void Object::Component::Mesh::ReserveIndices ( size_t count)
inline

◆ ReserveNormals()

void Object::Component::Mesh::ReserveNormals ( size_t count)
inline

◆ ReserveTexCoords()

void Object::Component::Mesh::ReserveTexCoords ( size_t count)
inline

◆ ReserveVertices()

void Object::Component::Mesh::ReserveVertices ( size_t count)
inline

◆ SetIndexAt()

void Object::Component::Mesh::SetIndexAt ( size_t index,
uint32_t indexValue )
inline

◆ SetIndices()

void Object::Component::Mesh::SetIndices ( const std::vector< uint32_t > & newIndices)
inline

◆ SetNormalAt()

void Object::Component::Mesh::SetNormalAt ( size_t index,
const glm::vec3 & normal )
inline

◆ SetNormals()

void Object::Component::Mesh::SetNormals ( const std::vector< glm::vec3 > & newNormals)
inline

◆ SetTexCoordAt()

void Object::Component::Mesh::SetTexCoordAt ( size_t index,
const glm::vec2 & texCoord )
inline

◆ SetTexCoords()

void Object::Component::Mesh::SetTexCoords ( const std::vector< glm::vec2 > & newTexCoords)
inline

◆ SetVertexAt()

void Object::Component::Mesh::SetVertexAt ( size_t index,
const glm::vec3 & vertex )
inline

◆ SetVertices()

void Object::Component::Mesh::SetVertices ( const std::vector< glm::vec3 > & newVertices)
inline

Member Data Documentation

◆ _dirty

bool Object::Component::Mesh::_dirty = false
mutableprivate

Dirty flag for GPU synchronization optimization.

Mutable to allow modification tracking on const mesh references. When true, indicates that mesh data has changed and the GPU buffer needs to be updated.

◆ indices

std::vector<uint32_t> Object::Component::Mesh::indices {}
private

◆ normals

std::vector<glm::vec3> Object::Component::Mesh::normals {}
private

◆ texCoords

std::vector<glm::vec2> Object::Component::Mesh::texCoords {}
private

◆ vertices

std::vector<glm::vec3> Object::Component::Mesh::vertices {}
private

The documentation for this struct was generated from the following file:
  • src/plugin/object/src/component/Mesh.hpp