Cogs.Core
SceneComponent.cpp
1#include "SceneComponent.h"
2#include "Scene/PickingFlags.h"
3
4#include "Types.h"
5
6using namespace Cogs::Reflection;
7
8template<> Cogs::StringView getName<Cogs::Core::PickingFlags>() { return "PickingFlags"; }
9template<> Cogs::StringView getName<Cogs::Core::PicksReturned>() { return "PicksReturned"; }
10
12{
13 Field fields [] = {
15 Field(Name("pickable"), &SceneComponent::pickable),
16 Field(Name("children"), &SceneComponent::children),
17 };
18
19 TypeDatabase::createType<SceneComponent>().setBase<Component>().setFields(fields);
20
21 // Picking is enabled here. Initialize picking flags.
22 static constexpr EnumeratorDef pickingEnums[] = {
23 { "None", PickingFlags::None },
24 { "PickSprites", PickingFlags::PickSprites },
25 { "ReturnChildEntity", PickingFlags::ReturnChildEntity },
26 { "RemoveDuplicateEntities", PickingFlags::RemoveDuplicateEntities },
27 { "RemoveDuplicates", PickingFlags::RemoveDuplicates },
28 { "FlatTexcoordInterpolation", PickingFlags::FlatTexcoordInterpolation },
29 { "AddInstanceTexcoords", PickingFlags::AddInstanceTexcoords },
30 };
31
32 TypeDatabase::createType<PickingFlags>().setEnumerators(pickingEnums).setEnumFlags();
33
34
35 static constexpr EnumeratorDef pickReturnEnums[] = {
36 { "Closest", PicksReturned::Closest },
37 { "AllUnsorted", PicksReturned::AllUnsorted },
38 { "AllSorted", PicksReturned::AllSorted },
39 };
40
41 TypeDatabase::createType<PicksReturned>().setEnumerators(pickReturnEnums);
42}
std::vector< EntityPtr > children
Contains all child entities owned by this component.
static void registerType()
Register the type in the type system.
bool visible
If the entity this component is a member of should be visible.
bool pickable
If the entity this component is a member of should be pickable.
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
@ Closest
Return just the closest hit.
@ AllUnsorted
Return all hits in no specific order.
@ AllSorted
Return all hits sorted based on distance from the ray start, closest first.
@ ReturnChildEntity
Return ID if sub-entity picked, not set: return root parent entity.
@ RemoveDuplicates
For multi-pick return - remove entries with same EntityId & TextureId. Note: May cause slowdown with ...
@ None
No flags specified,.
@ FlatTexcoordInterpolation
Do not interpolate texture coordinates. Needed if integer IDs are encoded as texture coordinates.
@ PickSprites
Check picking for entities with SpriteRenderComponent. I.e. Text, Annotation, Billboard,...
@ RemoveDuplicateEntities
For multi-pick return - remove entries with same EntityId. Note: May cause slowdown with many hits du...
@ AddInstanceTexcoords
If mesh has an offset to IDs encoded in a per-instance texcoords stream, add this to the result.
Contains reflection support.
Definition: Component.h:11
Represents an unique name.
Definition: Name.h:70