Cogs.Core
InstancedMeshRenderComponent.cpp
1#include "InstancedMeshRenderComponent.h"
2
3#include "Types.h"
4
5using namespace Cogs::Reflection;
6
8{
9 Field fields[] = {
17 { "instanceIdMultiplier", &InstancedMeshRenderComponent::instanceIdMultiplier },
18 };
19
20 TypeDatabase::createType<InstancedMeshRenderComponent>().setBase<RenderComponent>().setFields(fields);
21}
22
23uint32_t Cogs::Core::InstancedMeshRenderComponent::getRenderCount(uint32_t startIndex, uint32_t instanceCount, uint32_t meshCount)
24{
25 if (startIndex >= meshCount) {
26 return 0u;
27 }
28
29 const uint32_t count = instanceCount != DrawRest ? instanceCount : meshCount - startIndex;
30
31 // Wrap-around not legal.
32 if (count > DrawRest - startIndex) {
33 return 0u;
34 }
35
36 // Limit to available mesh values.
37 return (startIndex + count > meshCount) ? (meshCount - startIndex) : count;
38}
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.
PrimitiveType primitiveType
Primitive type to use when drawing. Default value -1 means use primitive type from mesh.
MaterialInstanceHandle material
Material instance used to render the mesh.
Base component for all rendering content.
Field definition describing a single data member of a data structure.
Definition: Field.h:70
Contains reflection support.
Definition: Component.h:11