Plasma Engine  2.0
Loading...
Searching...
No Matches
VolumeCollection.h
1#pragma once
2
3#include <Core/World/World.h>
4#include <Foundation/Math/Float16.h>
5#include <Foundation/Types/TagSet.h>
6#include <ProcGenPlugin/Declarations.h>
7
9
10class PL_PROCGENPLUGIN_DLL plVolumeCollection : public plReflectedClass
11{
12 PL_ADD_DYNAMIC_REFLECTION(plVolumeCollection, plReflectedClass);
13
14public:
15 struct ShapeType
16 {
17 using StorageType = plUInt8;
18
19 enum Enum
20 {
21 Sphere,
22 Box,
23 Image,
24
25 Default = Sphere
26 };
27 };
28
29 struct Shape
30 {
31 plVec4 m_GlobalToLocalTransform0;
32 plVec4 m_GlobalToLocalTransform1;
33 plVec4 m_GlobalToLocalTransform2;
34 plEnum<ShapeType> m_Type;
36 plFloat16 m_fValue;
37 plUInt32 m_uiSortingKey;
38
39 PL_ALWAYS_INLINE bool operator<(const Shape& other) const { return m_uiSortingKey < other.m_uiSortingKey; }
40
41 void SetGlobalToLocalTransform(const plSimdMat4f& t);
42 plSimdMat4f GetGlobalToLocalTransform() const;
43 };
44
45 struct Sphere : public Shape
46 {
47 float m_fFadeOutScale;
48 float m_fFadeOutBias;
49 };
50
51 struct Box : public Shape
52 {
53 plVec3 m_vFadeOutScale;
54 plVec3 m_vFadeOutBias;
55 };
56
57 struct Image : public Box
58 {
60 const plColor* m_pPixelData = nullptr;
61 plUInt32 m_uiImageWidth = 0;
62 plUInt32 m_uiImageHeight = 0;
63 };
64
65 bool IsEmpty() { return m_Spheres.IsEmpty() && m_Boxes.IsEmpty(); }
66
67 float EvaluateAtGlobalPosition(const plSimdVec4f& vPosition, float fInitialValue, plProcVolumeImageMode::Enum imgMode, const plColor& refColor) const;
68
69 static void ExtractVolumesInBox(const plWorld& world, const plBoundingBox& box, plSpatialData::Category spatialCategory, const plTagSet& includeTags, plVolumeCollection& out_collection, const plRTTI* pComponentBaseType = nullptr);
70
71 void AddSphere(const plSimdTransform& transform, float fRadius, plEnum<plProcGenBlendMode> blendMode, float fSortOrder, float fValue, float fFadeOutStart);
72
73 void AddBox(const plSimdTransform& transform, const plVec3& vExtents, plEnum<plProcGenBlendMode> blendMode, float fSortOrder, float fValue, const plVec3& vFadeOutStart);
74
75 void AddImage(const plSimdTransform& transform, const plVec3& vExtents, plEnum<plProcGenBlendMode> blendMode, float fSortOrder, float fValue, const plVec3& vFadeOutStart, const plImageDataResourceHandle& hImage);
76
77private:
81
82 plDynamicArray<const Shape*> m_SortedShapes;
83};
84
85struct PL_PROCGENPLUGIN_DLL plMsgExtractVolumes : public plMessage
86{
87 PL_DECLARE_MESSAGE_TYPE(plMsgExtractVolumes, plMessage);
88
89 plVolumeCollection* m_pCollection = nullptr;
90};
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
Definition DynamicArray.h:81
A 16 bit IEEE float class. Often called "half".
Definition Float16.h:11
Base class for all message types. Each message type has it's own id which is used to dispatch message...
Definition Message.h:22
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
A 4x4 matrix class.
Definition SimdMat4f.h:7
Definition SimdTransform.h:6
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
A dynamic collection of tags featuring fast lookups.
Definition TagSet.h:23
Definition VolumeCollection.h:11
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition VolumeCollection.h:86
Definition SpatialData.h:27
Definition VolumeCollection.h:52
Definition VolumeCollection.h:58
Definition VolumeCollection.h:30
Definition VolumeCollection.h:16
Definition VolumeCollection.h:46