|
CeresEngine 0.2.0
A game development framework
|
A mesh that is usable by the renderer and the GPU. More...
#include <CeresEngine/Renderer/Resources/RendererMesh.hpp>
Public Member Functions | |
| RendererMesh (RendererMeshManager &manager, const MeshPtr &engineMesh) | |
| Creates a new renderer mesh instance. | |
| ~RendererMesh () | |
| Destroys the renderer mesh instance. | |
| void | bind (GPUCommandBuffer &commandBuffer) const |
| Binds the mesh vertex and index buffers. | |
| void | draw (GPUCommandBuffer &commandBuffer, const Optional< const ConvexVolume & > &viewFrustum={}, const RendererMeshDrawFlags &flags=RendererMeshDrawFlag::Default) const |
| Draws the entire mesh. | |
| void | draw (GPUCommandBuffer &commandBuffer, UInt32 subMeshIdx, const Optional< const ConvexVolume & > &viewFrustum={}, const RendererMeshDrawFlags &flags=RendererMeshDrawFlag::Default) const |
| Draws an specific sub-mesh index. | |
| void | draw (GPUCommandBuffer &commandBuffer, const Span< UInt32 > &subMeshIndices, const Optional< const ConvexVolume & > &viewFrustum={}, const RendererMeshDrawFlags &flags=RendererMeshDrawFlag::Default) const |
| Draws an specific set of sub-meshes by index. | |
| void | draw (GPUCommandBuffer &commandBuffer, const SubMesh &subMesh, const Optional< const ConvexVolume & > &viewFrustum={}, const RendererMeshDrawFlags &flags=RendererMeshDrawFlag::Default) const |
| Draws a specific sub-mesh. | |
| RendererMeshFlags | getFlags () const noexcept |
| A set of flags for the renderer mesh. | |
| RendererMeshState | getState () const noexcept |
| The state the renderer mesh is currently in. | |
| bool | isPending () const noexcept |
| The mesh is not uploaded to the GPU and the upload process hasn't started yet. | |
| bool | isUploading () const noexcept |
| The mesh is in the process of being uploaded to the GPU, but the asynchronous upload operation hasn't finished yet. | |
| bool | isRelocating () const noexcept |
| The mesh is uploaded to the GPU but is in the process of being relocated to another vertex and index buffers. | |
| bool | isUploaded () const noexcept |
| The mesh is uploaded to the GPU and is ready to be used by the renderer. | |
| bool | isReady () const noexcept |
| Checks if the mesh is ready to be used by the renderer. | |
| operator bool () const noexcept | |
| Checks if the mesh is ready to be used by the renderer. | |
| const SPtr< Mesh > & | getResource () const noexcept |
| A pointer to the mesh resource object that will be uploaded to the GPU. | |
| const GPUVertexBuffer & | getVertexBuffer () const noexcept |
| The current vertex buffer as allocated by the mesh manager. | |
| const GPUIndexBuffer & | getIndexBuffer () const noexcept |
| The current index buffer as allocated by the mesh manager. | |
| const GPUVertexFormat & | getVertexFormat () const noexcept |
| A structure that describes the format of the vertex data as it was uploaded to the GPU. | |
| const VertexDeclaration & | getVertexDeclaration () const noexcept |
| Determines how vertices are laid-out on a vertex buffer or a mesh data. | |
| AABox | getBoundingBox () const noexcept |
| Gets the mesh bounding box. | |
| Sphere | getBoundingSphere () const noexcept |
| Gets the mesh bounding sphere. | |
| const Vector< SubMesh > & | getSubMeshes () const noexcept |
| An array of sub-meshes. | |
Public Member Functions inherited from CeresEngine::RefCounted< RendererMesh > | |
| RefCounted (Args &&... args) | |
Creates a new RefCounted object and constructs a new Deleter by forwarding Args to it. | |
| void | retain () noexcept |
| Retains the object by increment it's reference count by one. | |
| bool | release () noexcept |
| Relases the object by decrementing it's reference count by one. | |
Public Attributes | |
| Event< void()> | didChangeVertexBuffer |
| An event triggered internally in the renderer whenever the vertex buffer for the mesh has changed. | |
| Event< void()> | didChangeIndexBuffer |
| An event triggered internally in the renderer whenever the index buffer for the mesh has changed. | |
Private Member Functions | |
| void | setFlags (RendererMeshFlags flags) |
| A set of flags for the renderer mesh. | |
| void | setState (RendererMeshState state) |
| The state the renderer mesh is currently in. | |
| void | setBuffers (GPUVertexBuffer &&vertexBuffer, GPUIndexBuffer &&indexBuffer, const GPUVertexFormat &vertexFormat) |
| Updates the vertex buffer, index buffer and the vertex formats. | |
| Async | uploadMesh () |
| Uploads the raw mesh data to the GPU. | |
Private Attributes | |
| RendererMeshManager & | mManager |
| The mesh manager that owns and manages this mesh instance. | |
| RendererMeshFlags | mFlags |
| A set of flags for the renderer mesh. | |
| RendererMeshState | mState = RendererMeshState::Pending |
| The state the renderer mesh is currently in. | |
| SPtr< Mesh > | mResource |
| A pointer to the mesh resource object that will be uploaded to the GPU. | |
| GPUVertexBuffer | mVertexBuffer |
| The current vertex buffer as allocated by the mesh manager. | |
| GPUIndexBuffer | mIndexBuffer |
| The current index buffer as allocated by the mesh manager. | |
| GPUVertexFormat | mVertexFormat |
| A structure that describes the format of the vertex data as it was uploaded to the GPU. | |
| VertexDeclaration | mVertexDeclaration |
| Determines how vertices are laid-out on a vertex buffer or a mesh data. | |
| Vector< SubMesh > | mSubMeshes |
| An array of sub-meshes. | |
Friends | |
| class | RendererMeshManager |
A mesh that is usable by the renderer and the GPU.
A renderer mesh is allocated by a RendererMeshManager, which is responsible for taking an Mesh instance, uploading it to the GPU in an appropriate set of vertex and, if necessary, index buffers.
The manager is free to relocate the vertex and index buffers inside the same GPU buffer or to different buffers at any time. Whenever the manager relocates data, the user can be notified of changes by subscribing to the onVertexBufferChanged and onIndexBufferChanged events.
|
explicit |
Creates a new renderer mesh instance.
| CeresEngine::RendererMesh::~RendererMesh | ( | ) |
Destroys the renderer mesh instance.
Since this object is reference counted, the destructor is usually called automatically when the reference count reaches zero.
| void CeresEngine::RendererMesh::bind | ( | GPUCommandBuffer & | commandBuffer | ) | const |
Binds the mesh vertex and index buffers.
| void CeresEngine::RendererMesh::draw | ( | GPUCommandBuffer & | commandBuffer, |
| const Optional< const ConvexVolume & > & | viewFrustum = {}, |
||
| const RendererMeshDrawFlags & | flags = RendererMeshDrawFlag::Default |
||
| ) | const |
Draws the entire mesh.
| commandBuffer | The command buffer to submit draw calls to. |
| viewFrustum | An optional view frustum to be used to perform frustum culling. If not set, frustum culling is disabled and the entire mesh is drawn. |
| flags | A set of flags that can be used to customize the mesh drawing behavior. |
| void CeresEngine::RendererMesh::draw | ( | GPUCommandBuffer & | commandBuffer, |
| const Span< UInt32 > & | subMeshIndices, | ||
| const Optional< const ConvexVolume & > & | viewFrustum = {}, |
||
| const RendererMeshDrawFlags & | flags = RendererMeshDrawFlag::Default |
||
| ) | const |
Draws an specific set of sub-meshes by index.
| commandBuffer | The command buffer to submit draw calls to. |
| subMeshIndices | A set of sub-mesh indices to be drawn. |
| viewFrustum | An optional view frustum to be used to perform frustum culling. If not set, frustum culling is disabled and the entire mesh is drawn. |
| flags | A set of flags that can be used to customize the mesh drawing behavior. |
| void CeresEngine::RendererMesh::draw | ( | GPUCommandBuffer & | commandBuffer, |
| const SubMesh & | subMesh, | ||
| const Optional< const ConvexVolume & > & | viewFrustum = {}, |
||
| const RendererMeshDrawFlags & | flags = RendererMeshDrawFlag::Default |
||
| ) | const |
Draws a specific sub-mesh.
| commandBuffer | The command buffer to submit draw calls to. |
| subMesh | The sub-mesh to be drawn. |
| viewFrustum | An optional view frustum to be used to perform frustum culling. If not set, frustum culling is disabled and the entire mesh is drawn. |
| flags | A set of flags that can be used to customize the mesh drawing behavior. |
| void CeresEngine::RendererMesh::draw | ( | GPUCommandBuffer & | commandBuffer, |
| UInt32 | subMeshIdx, | ||
| const Optional< const ConvexVolume & > & | viewFrustum = {}, |
||
| const RendererMeshDrawFlags & | flags = RendererMeshDrawFlag::Default |
||
| ) | const |
Draws an specific sub-mesh index.
| commandBuffer | The command buffer to submit draw calls to. |
| subMeshIdx | The index of the sub-mesh to be drawn. |
| viewFrustum | An optional view frustum to be used to perform frustum culling. If not set, frustum culling is disabled and the entire mesh is drawn. |
| flags | A set of flags that can be used to customize the mesh drawing behavior. |
|
noexcept |
Gets the mesh bounding box.
|
noexcept |
Gets the mesh bounding sphere.
|
inlinenoexcept |
A set of flags for the renderer mesh.
|
inlinenoexcept |
The current index buffer as allocated by the mesh manager.
The manager is free to relocate this index buffer into another location if it can prove that relocating it will yield in faster rendering or better buffer re-utilization.
A pointer to the mesh resource object that will be uploaded to the GPU.
|
inlinenoexcept |
The state the renderer mesh is currently in.
An array of sub-meshes.
|
inlinenoexcept |
The current vertex buffer as allocated by the mesh manager.
The manager is free to relocate this vertex buffer into another location if it can prove that relocating it will yield in faster rendering or better buffer re-utilization.
|
inlinenoexcept |
Determines how vertices are laid-out on a vertex buffer or a mesh data.
|
inlinenoexcept |
A structure that describes the format of the vertex data as it was uploaded to the GPU.
|
inlinenoexcept |
The mesh is not uploaded to the GPU and the upload process hasn't started yet.
|
inlinenoexcept |
Checks if the mesh is ready to be used by the renderer.
|
inlinenoexcept |
The mesh is uploaded to the GPU but is in the process of being relocated to another vertex and index buffers.
The current buffers are still valid, but will be replaced soon as soon as the GPU finishes coping the data.
|
inlinenoexcept |
The mesh is uploaded to the GPU and is ready to be used by the renderer.
|
inlinenoexcept |
The mesh is in the process of being uploaded to the GPU, but the asynchronous upload operation hasn't finished yet.
|
inlineexplicitnoexcept |
Checks if the mesh is ready to be used by the renderer.
|
private |
Updates the vertex buffer, index buffer and the vertex formats.
|
private |
A set of flags for the renderer mesh.
|
private |
The state the renderer mesh is currently in.
|
private |
Uploads the raw mesh data to the GPU.
Note that this operation will run in parallel on one or more background threads, but will always complete on the main thread.
|
friend |
An event triggered internally in the renderer whenever the index buffer for the mesh has changed.
Users of the renderer mesh can subscribe to this event to be notified when the manager relocates the index buffer.
An event triggered internally in the renderer whenever the vertex buffer for the mesh has changed.
Users of the renderer mesh can subscribe to this event to be notified when the manager relocates the vertex buffer.
|
private |
A set of flags for the renderer mesh.
|
private |
The current index buffer as allocated by the mesh manager.
The manager is free to relocate this index buffer into another location if it can prove that relocating it will yield in faster rendering or better buffer re-utilization.
|
private |
The mesh manager that owns and manages this mesh instance.
A pointer to the mesh resource object that will be uploaded to the GPU.
|
private |
The state the renderer mesh is currently in.
|
private |
The current vertex buffer as allocated by the mesh manager.
The manager is free to relocate this vertex buffer into another location if it can prove that relocating it will yield in faster rendering or better buffer re-utilization.
|
private |
Determines how vertices are laid-out on a vertex buffer or a mesh data.
|
private |
A structure that describes the format of the vertex data as it was uploaded to the GPU.