class render::Mesh

Inherits: MeshBase

Render thread portion of a Mesh.

Public

Constructors

Mesh

Mesh(const SPtr<MeshData> &initialMeshData, const MeshCreateInformation &meshCreateInformation)

Methods

~Mesh

~Mesh() noexcept

Initialize

void Initialize() override

Called on the render thread when the object is first created.

GetVertexData

SPtr<VertexData> GetVertexData() const override

Get vertex data used for rendering.

GetIndexBuffer

SPtr<GpuBuffer> GetIndexBuffer() const override

Get index data used for rendering.

GetVertexDescription

SPtr<VertexDescription> GetVertexDescription() const override

Returns a structure that describes how are the vertices stored in the mesh's vertex buffer.

GetSkeleton

SPtr<Skeleton> GetSkeleton() const

Returns a skeleton that can be used for animating the mesh.

GetMorphShapes

SPtr<MorphShapes> GetMorphShapes() const

Returns an object containing all shapes used for morph animation, if any are available.

WriteData

virtual void WriteData(const MeshData &data, bool discardEntireBuffer, bool updateBounds = true, const SPtr<GpuCommandBuffer> &commandBuffer = nullptr)

Updates the current mesh with the provided data.

data
Data to update the mesh with.
discardEntireBuffer
When true the existing contents of the resource you are updating will be discarded. This can make the operation faster. Resources with certain buffer types might require this flag to be in a specific state otherwise the operation will fail.
updateBounds
If true the internal bounds of the mesh will be recalculated based on the provided data.
commandBuffer
Command buffer on which to issue a copy operation, in case the internal buffers aren't directly writeable.

ReadData

virtual void ReadData(MeshData &data, const SPtr<GpuCommandBuffer> &commandBuffer = nullptr)

Reads the current mesh data into the provided parameter.

Data buffer needs to be pre-allocated.

data
Pre-allocated buffer of proper vertex/index format and size where data will be read to. You can use Mesh::allocBuffer() to allocate a buffer of a correct format and size.
commandBuffer
Command buffer on which to issue a copy operation, in case the internal buffers aren't directly readable.

staticCreate

static SPtr<Mesh> Create(u32 vertexCount, u32 indexCount, const SPtr<VertexDescription> &vertexDescription, MeshFlags flags = MeshFlag::Static, DrawOperationType primitiveType = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT)

Creates a new empty mesh.

Created mesh will have no sub-meshes.

vertexCount
Number of vertices in the mesh.
indexCount
Number of indices in the mesh.
vertexDescription
Vertex description structure that describes how are vertices organized in the vertex buffer. When binding a mesh to the pipeline you must ensure vertex description at least partially matches the input description of the currently bound vertex GPU program.
flags
Flags to control various mesh options.
primitiveType
Determines how should the provided indices be interpreted by the pipeline. Default option is a triangle list, where three indices represent a single triangle.
indexType
Size of indices, use smaller size for better performance, however be careful not to go over the number of vertices limited by the size.

staticCreate

static SPtr<Mesh> Create(const MeshCreateInformation &meshCreateInformation)

Creates a new empty mesh.

meshCreateInformation
Descriptor containing the properties of the mesh to create.
deviceMask
Mask that determines on which GPU devices should the object be created on.

staticCreate

static SPtr<Mesh> Create(const SPtr<MeshData> &initialData, const MeshCreateInformation &meshCreateInformation)

Creates a new mesh from an existing mesh data.

Created mesh will match the vertex and index buffers described by the mesh data exactly.

initialData
Vertex and index data to initialize the mesh with.
meshCreateInformation
Descriptor containing the properties of the mesh to create. Vertex and index count, vertex descriptor and index type properties are ignored and are read from provided mesh data instead.

staticCreate

static SPtr<Mesh> Create(const SPtr<MeshData> &initialData, MeshFlags flags = MeshFlag::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST)

Creates a new mesh from an existing mesh data.

Created mesh will match the vertex and index buffers described by the mesh data exactly. Mesh will have no sub-meshes.

initialData
Vertex and index data to initialize the mesh with.
flags
Flags to control various mesh options.
drawOp
Determines how should the provided indices be interpreted by the pipeline. Default option is a triangle strip, where three indices represent a single triangle.

Protected

Methods

UpdateBounds

void UpdateBounds(const MeshData &meshData)

Updates bounds by calculating them from the vertices in the provided mesh data object.

Fields

mVertexData

SPtr<VertexData> mVertexData

mIndexBuffer

SPtr<GpuBuffer> mIndexBuffer

mVertexDescription

SPtr<VertexDescription> mVertexDescription

mFlags

MeshFlags mFlags

mIndexType

IndexType mIndexType

mTempInitialMeshData

SPtr<MeshData> mTempInitialMeshData

mSkeleton

SPtr<Skeleton> mSkeleton

mMorphShapes

SPtr<MorphShapes> mMorphShapes