Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::IMesh< TVertex > Class Template Referenceabstract

Stores polygon data and exposes GPU-ready vertex/index buffers. More...

#include <spk_mesh.hpp>

Collaboration diagram for spk::IMesh< TVertex >:
Collaboration graph

Public Types

using Polygon = IPolygon<TVertex>
 Polygon type stored by the mesh.
using EditionContract = ContractProvider::Contract
 Contract type returned by edition subscriptions.
using EditionJob = ContractProvider::Job
 Job type invoked on mesh edits.

Public Member Functions

 IMesh ()
 Builds an empty mesh with a dynamic buffer set.
 IMesh (const IMesh &p_other)
 Copies polygon data into a new mesh instance.
IMeshoperator= (const IMesh &p_other)
 Assigns polygon data from another mesh.
 IMesh (IMesh &&p_other) noexcept
 Moves polygon data from another mesh.
IMeshoperator= (IMesh &&p_other) noexcept
 Move-assigns polygon data from another mesh.
void clear ()
 Clears all polygons and notifies subscribers.
void append (const Polygon &p_shape)
 Appends a polygon and notifies subscribers.
EditionContract subscribeToEdition (const EditionJob &p_job) const
 Subscribes to mesh edition notifications.
const std::vector< TVertex > & vertices () const
 Returns the cached vertex list for all polygons.
const std::vector< Polygon > & polygons () const
 Returns the stored polygons.
const std::vector< uint32_t > & indexes () const
 Returns the cached triangle indices for the mesh.
IMeshoperator+= (const IMesh &p_other)
 Appends polygons from another mesh and notifies subscribers.
const std::shared_ptr< spk::OpenGL::BufferSetObject > & bufferSet () const
 Returns the underlying buffer set.
void synchronize () const
 Updates GPU buffers when mesh data has changed.
IMesh fuze (const IMesh &p_other) const
 Returns a new mesh by concatenating another mesh.

Friends

IMesh operator+ (const IMesh< TVertex > &p_lhs, const IMesh< TVertex > &p_rhs)
 Returns a mesh that combines both operands.

Detailed Description

template<typename TVertex>
class spk::IMesh< TVertex >

Stores polygon data and exposes GPU-ready vertex/index buffers.

Template Parameters
TVertexVertex type stored in polygons and buffers.
See also
IPolygon
mesh.synchronize();
Stores polygon data and exposes GPU-ready vertex/index buffers.
Definition spk_mesh.hpp:29
void append(const Polygon &p_shape)
Appends a polygon and notifies subscribers.
Definition spk_mesh.hpp:270
void synchronize() const
Updates GPU buffers when mesh data has changed.
Definition spk_mesh.hpp:346
static IPolygon< TVertex > makeTriangle(const TVertex &p_a, const TVertex &p_b, const TVertex &p_c)
Creates a triangle polygon.
Definition spk_polygon.hpp:46

Constructor & Destructor Documentation

◆ IMesh() [1/2]

template<typename TVertex>
spk::IMesh< TVertex >::IMesh ( const IMesh< TVertex > & p_other)
inline

Copies polygon data into a new mesh instance.

Parameters
p_otherMesh to copy from.

◆ IMesh() [2/2]

template<typename TVertex>
spk::IMesh< TVertex >::IMesh ( IMesh< TVertex > && p_other)
inlinenoexcept

Moves polygon data from another mesh.

Parameters
p_otherMesh to move from.

Member Function Documentation

◆ append()

template<typename TVertex>
void spk::IMesh< TVertex >::append ( const Polygon & p_shape)
inline

Appends a polygon and notifies subscribers.

Parameters
p_shapePolygon to add.
Here is the caller graph for this function:

◆ bufferSet()

template<typename TVertex>
const std::shared_ptr< spk::OpenGL::BufferSetObject > & spk::IMesh< TVertex >::bufferSet ( ) const
inline

Returns the underlying buffer set.

Returns
Shared pointer to the buffer set object.

◆ fuze()

template<typename TVertex>
IMesh spk::IMesh< TVertex >::fuze ( const IMesh< TVertex > & p_other) const
inline

Returns a new mesh by concatenating another mesh.

Parameters
p_otherMesh to combine with.
Returns
New mesh containing polygons from both meshes.

◆ indexes()

template<typename TVertex>
const std::vector< uint32_t > & spk::IMesh< TVertex >::indexes ( ) const
inline

Returns the cached triangle indices for the mesh.

Returns
Index vector.

◆ operator+=()

template<typename TVertex>
IMesh & spk::IMesh< TVertex >::operator+= ( const IMesh< TVertex > & p_other)
inline

Appends polygons from another mesh and notifies subscribers.

Parameters
p_otherMesh to append.
Returns
Reference to this mesh.

◆ operator=() [1/2]

template<typename TVertex>
IMesh & spk::IMesh< TVertex >::operator= ( const IMesh< TVertex > & p_other)
inline

Assigns polygon data from another mesh.

Parameters
p_otherMesh to copy from.
Returns
Reference to this mesh.
Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename TVertex>
IMesh & spk::IMesh< TVertex >::operator= ( IMesh< TVertex > && p_other)
inlinenoexcept

Move-assigns polygon data from another mesh.

Parameters
p_otherMesh to move from.
Returns
Reference to this mesh.

◆ polygons()

template<typename TVertex>
const std::vector< Polygon > & spk::IMesh< TVertex >::polygons ( ) const
inline

Returns the stored polygons.

Returns
Polygon vector.
Here is the caller graph for this function:

◆ subscribeToEdition()

template<typename TVertex>
EditionContract spk::IMesh< TVertex >::subscribeToEdition ( const EditionJob & p_job) const
inline

Subscribes to mesh edition notifications.

Parameters
p_jobCallback executed when mesh data changes.
Returns
Contract handle for the subscription.
Here is the caller graph for this function:

◆ vertices()

template<typename TVertex>
const std::vector< TVertex > & spk::IMesh< TVertex >::vertices ( ) const
inline

Returns the cached vertex list for all polygons.

Returns
Vertex vector.

◆ operator+

template<typename TVertex>
IMesh operator+ ( const IMesh< TVertex > & p_lhs,
const IMesh< TVertex > & p_rhs )
friend

Returns a mesh that combines both operands.

Parameters
p_lhsLeft mesh.
p_rhsRight mesh.
Returns
New mesh containing polygons from both meshes.

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