Plasma Engine  2.0
Loading...
Searching...
No Matches
SpatialData.h
1#pragma once
2
3#include <Core/World/Declarations.h>
4#include <Foundation/Strings/HashedString.h>
5
7{
8 struct Flags
9 {
10 using StorageType = plUInt8;
11
12 enum Enum
13 {
14 None = 0,
15 FrequentChanges = PL_BIT(0),
16
17 Default = None
18 };
19
20 struct Bits
21 {
22 StorageType FrequentUpdates : 1;
23 };
24 };
25
26 struct Category
27 {
28 PL_ALWAYS_INLINE Category()
29 : m_uiValue(plSmallInvalidIndex)
30 {
31 }
32
33 PL_ALWAYS_INLINE explicit Category(plUInt16 uiValue)
34 : m_uiValue(uiValue)
35 {
36 }
37
38 PL_ALWAYS_INLINE bool operator==(const Category& other) const { return m_uiValue == other.m_uiValue; }
39 PL_ALWAYS_INLINE bool operator!=(const Category& other) const { return m_uiValue != other.m_uiValue; }
40
41 plUInt16 m_uiValue;
42
43 PL_ALWAYS_INLINE plUInt32 GetBitmask() const { return m_uiValue != plSmallInvalidIndex ? static_cast<plUInt32>(PL_BIT(m_uiValue)) : 0; }
44 };
45
50 PL_CORE_DLL static Category RegisterCategory(plStringView sCategoryName, const plBitflags<Flags>& flags);
51
53 PL_CORE_DLL static Category FindCategory(plStringView sCategoryName);
54
56 PL_CORE_DLL static const plHashedString& GetCategoryName(Category category);
57
59 PL_CORE_DLL static const plBitflags<Flags>& GetCategoryFlags(Category category);
60
61private:
62 struct CategoryData
63 {
64 plHashedString m_sName;
65 plBitflags<Flags> m_Flags;
66 };
67
68 static plHybridArray<plSpatialData::CategoryData, 32>& GetCategoryData();
69};
70
72{
73 static plSpatialData::Category RenderStatic;
74 static plSpatialData::Category RenderDynamic;
75 static plSpatialData::Category OcclusionStatic;
76 static plSpatialData::Category OcclusionDynamic;
77};
78
84enum class plVisibilityState : plUInt8
85{
86 Invisible = 0,
87 Indirect = 1,
88 Direct = 2,
89};
90
91#define plInvalidSpatialDataCategory plSpatialData::Category()
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Definition SpatialData.h:72
Definition SpatialData.h:27
Definition SpatialData.h:21
Definition SpatialData.h:9
Enum
Definition SpatialData.h:13
@ FrequentChanges
Indicates that objects in this category change their bounds frequently. Spatial System implementation...
Definition SpatialData.h:15
Definition SpatialData.h:7
static PL_CORE_DLL const plBitflags< Flags > & GetCategoryFlags(Category category)
Returns the flags for the given category.
Definition SpatialData.cpp:66
static PL_CORE_DLL const plHashedString & GetCategoryName(Category category)
Returns the name of the given category.
Definition SpatialData.cpp:54
static PL_CORE_DLL Category RegisterCategory(plStringView sCategoryName, const plBitflags< Flags > &flags)
Registers a spatial data category under the given name.
Definition SpatialData.cpp:12
static PL_CORE_DLL Category FindCategory(plStringView sCategoryName)
Returns either an existing category with the given name or plInvalidSpatialDataCategory.
Definition SpatialData.cpp:40