Plasma Engine  2.0
Loading...
Searching...
No Matches
Declarations.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/Declarations.h>
5#include <Foundation/Math/Color16f.h>
6#include <Foundation/SimdMath/SimdTransform.h>
7#include <Foundation/Strings/HashedString.h>
8#include <Foundation/Types/SharedPtr.h>
9#include <ProcGenPlugin/ProcGenPluginDLL.h>
10
15
17{
18 using StorageType = plUInt8;
19
20 enum Enum
21 {
22 Add,
23 Subtract,
24 Multiply,
25 Divide,
26 Max,
27 Min,
28
29 Default = Multiply
30 };
31};
32
33PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcGenBinaryOperator);
34
36{
37 using StorageType = plUInt8;
38
39 enum Enum
40 {
41 Add,
42 Subtract,
43 Multiply,
44 Divide,
45 Max,
46 Min,
47 Set,
48
49 Default = Multiply
50 };
51};
52
53PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcGenBlendMode);
54
56{
57 using StorageType = plUInt8;
58
59 enum Enum
60 {
61 R,
62 G,
63 B,
64 A,
65 Black,
66 White,
67
68 Default = R
69 };
70};
71
72PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcVertexColorChannelMapping);
73
75{
76 plEnum<plProcVertexColorChannelMapping> m_R = plProcVertexColorChannelMapping::R;
77 plEnum<plProcVertexColorChannelMapping> m_G = plProcVertexColorChannelMapping::G;
78 plEnum<plProcVertexColorChannelMapping> m_B = plProcVertexColorChannelMapping::B;
79 plEnum<plProcVertexColorChannelMapping> m_A = plProcVertexColorChannelMapping::A;
80
81 plResult Serialize(plStreamWriter& inout_stream) const;
82 plResult Deserialize(plStreamReader& inout_stream);
83};
84
85PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcVertexColorMapping);
86
88{
89 using StorageType = plUInt8;
90
91 enum Enum
92 {
93 Raycast,
94 Fixed,
95
96 Default = Raycast
97 };
98};
99
100PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcPlacementMode);
101
103{
104 using StorageType = plUInt8;
105
106 enum Enum
107 {
108 RegularGrid,
109 HexGrid,
110 Natural,
111
112 COUNT,
113
114 Default = Natural
115 };
116};
117
118PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcPlacementPattern);
119
121{
122 using StorageType = plUInt8;
123
124 enum Enum
125 {
126 ReferenceColor,
127 ChannelR,
128 ChannelG,
129 ChannelB,
130 ChannelA,
131
132 Default = ReferenceColor
133 };
134};
135
136PL_DECLARE_REFLECTABLE_TYPE(PL_PROCGENPLUGIN_DLL, plProcVolumeImageMode);
137
139
140namespace plProcGenInternal
141{
142 class PlacementTile;
143 class FindPlacementTilesTask;
144 class PreparePlacementTask;
145 class PlacementTask;
146 class VertexColorTask;
147 struct PlacementData;
148
150 {
151 plBoundingBox m_Box;
152 plWorld* m_pWorld = nullptr;
153 };
154
155 struct Pattern
156 {
157 struct Point
158 {
159 float x;
160 float y;
161 float threshold;
162 };
163
164 plArrayPtr<Point> m_Points;
165 float m_fSize;
166 };
167
168 struct PL_PROCGENPLUGIN_DLL GraphSharedDataBase : public plRefCounted
169 {
170 virtual ~GraphSharedDataBase();
171 };
172
173 struct Output : public plRefCounted
174 {
175 virtual ~Output();
176
177 plHashedString m_sName;
178
179 plHybridArray<plUInt8, 4> m_VolumeTagSetIndices;
181
183 };
184
185 struct PlacementOutput : public Output
186 {
187 float GetTileSize() const { return m_pPattern->m_fSize * m_fFootprint; }
188
189 bool IsValid() const
190 {
191 return !m_ObjectsToPlace.IsEmpty() && m_pPattern != nullptr && m_fFootprint > 0.0f && m_fCullDistance > 0.0f && m_pByteCode != nullptr;
192 }
193
195
196 const Pattern* m_pPattern = nullptr;
197 float m_fFootprint = 1.0f;
198
199 plVec3 m_vMinOffset = plVec3::MakeZero();
200 plVec3 m_vMaxOffset = plVec3::MakeZero();
201
202 plAngle m_YawRotationSnap = plAngle::MakeFromRadian(0.0f);
203 float m_fAlignToNormal = 1.0f;
204
205 plVec3 m_vMinScale = plVec3(1.0f);
206 plVec3 m_vMaxScale = plVec3(1.0f);
207
208 float m_fCullDistance = 30.0f;
209
210 plUInt32 m_uiCollisionLayer = 0;
211
212 plColorGradientResourceHandle m_hColorGradient;
213
214 plSurfaceResourceHandle m_hSurface;
215
217 };
218
219 struct VertexColorOutput : public Output
220 {
221 };
222
223 struct PL_PROCGENPLUGIN_DLL ExpressionInputs
224 {
225 static plHashedString s_sPosition;
226 static plHashedString s_sPositionX;
227 static plHashedString s_sPositionY;
228 static plHashedString s_sPositionZ;
229 static plHashedString s_sNormal;
230 static plHashedString s_sNormalX;
231 static plHashedString s_sNormalY;
232 static plHashedString s_sNormalZ;
233 static plHashedString s_sColor;
234 static plHashedString s_sColorR;
235 static plHashedString s_sColorG;
236 static plHashedString s_sColorB;
237 static plHashedString s_sColorA;
238 static plHashedString s_sPointIndex;
239 };
240
241 struct PL_PROCGENPLUGIN_DLL ExpressionOutputs
242 {
243 static plHashedString s_sOutDensity;
244 static plHashedString s_sOutScale;
245 static plHashedString s_sOutColorIndex;
246 static plHashedString s_sOutObjectIndex;
247
248 static plHashedString s_sOutColor;
249 static plHashedString s_sOutColorR;
250 static plHashedString s_sOutColorG;
251 static plHashedString s_sOutColorB;
252 static plHashedString s_sOutColorA;
253 };
254
256 {
257 PL_DECLARE_POD_TYPE();
258
259 plVec3 m_vPosition;
260 float m_fScale;
261 plVec3 m_vNormal;
262 plUInt8 m_uiColorIndex;
263 plUInt8 m_uiObjectIndex;
264 plUInt16 m_uiPointIndex;
265 };
266
268 {
269 PL_DECLARE_POD_TYPE();
270
271 plSimdTransform m_Transform;
272 plColorLinear16f m_ObjectColor;
273 plUInt16 m_uiPointIndex;
274 plUInt8 m_uiObjectIndex;
275 bool m_bHasValidColor;
276 plUInt32 m_uiPadding;
277 };
278
280 {
281 plComponentHandle m_hComponent;
282 plUInt32 m_uiOutputIndex;
283 plInt32 m_iPosX;
284 plInt32 m_iPosY;
285 float m_fMinZ;
286 float m_fMaxZ;
287 float m_fTileSize;
288 float m_fDistanceToCamera;
289
290 bool operator==(const PlacementTileDesc& other) const
291 {
292 return m_hComponent == other.m_hComponent && m_uiOutputIndex == other.m_uiOutputIndex && m_iPosX == other.m_iPosX && m_iPosY == other.m_iPosY;
293 }
294
295 plBoundingBox GetBoundingBox() const
296 {
297 plVec2 vCenter = plVec2(m_iPosX * m_fTileSize, m_iPosY * m_fTileSize);
298 plVec3 vMin = (vCenter - plVec2(m_fTileSize * 0.5f)).GetAsVec3(m_fMinZ);
299 plVec3 vMax = (vCenter + plVec2(m_fTileSize * 0.5f)).GetAsVec3(m_fMaxZ);
300
301 return plBoundingBox::MakeFromMinMax(vMin, vMax);
302 }
303
305 };
306} // namespace plProcGenInternal
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromRadian(float fRadian)
Creates an instance of plAngle that was initialized from radian. (No need for any conversion)
Definition Angle_inl.h:38
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
static plBoundingBoxTemplate< float > MakeFromMinMax(const plVec3Template< float > &vMin, const plVec3Template< float > &vMax)
Definition BoundingBox_inl.h:42
A 16bit per channel float color storage format.
Definition Color16f.h:11
Definition ExpressionByteCode.h:10
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
Base class for reference counted objects.
Definition RefCounted.h:52
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
Definition SimdTransform.h:6
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
static plVec3Template< float > MakeZero()
Definition Vec3.h:38
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
A handle to a component.
Definition Declarations.h:138
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition Declarations.h:17
Definition Declarations.h:36
Definition Declarations.h:224
Definition Declarations.h:242
Definition Declarations.h:169
Definition Declarations.h:150
Definition Declarations.h:174
Definition Declarations.h:158
Definition Declarations.h:156
Definition Declarations.h:186
Definition Declarations.h:256
Definition Declarations.h:280
Definition Declarations.h:268
Definition Declarations.h:220
Definition Declarations.h:88
Definition Declarations.h:103
Definition Declarations.h:56
Definition Declarations.h:75
Definition Declarations.h:121
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54