Cogs.Core
InstancedMeshRenderComponent.cpp
1#include "InstancedMeshRenderComponent.h"
2
3#include "Types.h"
4
5using namespace Cogs::Reflection;
6
8{
9 Field fields[] = {
17 };
18
19 TypeDatabase::createType<InstancedMeshRenderComponent>().setBase<RenderComponent>().setFields(fields);
20}
21
22uint32_t Cogs::Core::InstancedMeshRenderComponent::getRenderCount(uint32_t startIndex, uint32_t instanceCount, uint32_t meshCount)
23{
24 if (startIndex >= meshCount) {
25 return 0u;
26 }
27
28 const uint32_t count = instanceCount != DrawRest ? instanceCount : meshCount - startIndex;
29
30 // Wrap-around not legal.
31 if (count > DrawRest - startIndex) {
32 return 0u;
33 }
34
35 // Limit to available mesh values.
36 return (startIndex + count > meshCount) ? (meshCount - startIndex) : count;
37}
uint32_t startIndex
Start vertex index to render from.
uint32_t vertexCount
Number of vertexes to draw. uint32_t(-1) to draw all remaining vertices.
uint32_t instanceCount
Instance count. uint32_t(-1) to draw all remaining instances.
static void registerType()
Register the type in the type system.
static uint32_t getRenderCount(uint32_t startIndex, uint32_t instanceCount, uint32_t meshCount)
Get number of instanced Meshes to render.
MaterialInstanceHandle material
Material instance used to render the mesh.
PrimitiveType::EPrimitiveType primitiveType
Primitive type to use when drawing. Default value -1 means use primitive type from mesh.
MeshHandle instanceMesh
Mesh containing instancing data.
Base component for all rendering content.
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Contains reflection support.
Definition: Component.h:11