Mountain  1.0.0
Simple C++ 2D Game Framework
particle_system_modules.hpp
1 #pragma once
2 
3 #include "Mountain/core.hpp"
4 #include "Mountain/resource/compute_shader.hpp"
7 
8 namespace Mountain
9 {
10  class ParticleSystem;
11 }
12 
14 {
15  enum class MOUNTAIN_API Types : uint32_t // We might as well use an uint as it is the minimum amount of data we can transfer to the shader
16  {
17  None = 0,
18 
19  Shape = 1 << 0,
20  ForceOverLifetime = 1 << 1,
21  ColorOverLifetime = 1 << 2,
22  ColorBySpeed = 1 << 3,
23  Noise = 1 << 4,
24  Collision = 1 << 5,
25  Lights = 1 << 6,
26  Trails = 1 << 7,
27 
28  Default = Shape,
29 
30  All = 0xFFFFFFFF
31  };
32 
33  class MOUNTAIN_API Base
34  {
35  public:
36  Base() = default;
37  virtual ~Base() = default;
38  DEFAULT_COPY_MOVE_OPERATIONS(Base)
39 
40  virtual void SetComputeShaderUniforms(const ComputeShader& computeShader, Types enabledModules) const = 0;
41  virtual void RenderImGui(uint32_t* enabledModulesInt) = 0;
42  virtual void RenderDebug(const ParticleSystem& system, Vector2 renderTargetSizeDiff) const;
43 
44  protected:
45  bool_t BeginImGui(uint32_t* enabledModulesInt, Types type) const;
46  void EndImGui() const;
47  };
48 
49  enum class ShapeType : uint32_t // NOLINT(performance-enum-size)
50  {
51  Circle,
52  Line,
53  Rectangle,
54  };
55 
56  enum class ShapeArcMode : uint32_t // NOLINT(performance-enum-size)
57  {
58  Random,
59  Loop,
60  PingPong,
61  BurstSpread,
62  };
63 
64  struct ShapeArc
65  {
66  ShapeArcMode mode = ShapeArcMode::Random;
67  float_t spread = 0.f;
68  };
69 
70  struct ShapeCircle
71  {
72  float_t radius = 1.f;
74  float_t radiusThickness = 1.f;
76  float_t arcAngle = Calc::TwoPi;
77  ShapeArc arc;
78  };
79 
80  struct ShapeLine
81  {
82  float_t radius = 1.f;
83  ShapeArc arc;
84  };
85 
87  {
89  Vector2 scaleThickness = Vector2::One();
90  };
91 
92  class Shape : public Base
93  {
94  public:
95  ShapeType type = ShapeType::Circle;
96 
97  ShapeCircle circle;
98  ShapeLine line;
99  ShapeRectangle rectangle;
100 
101  Vector2 offset;
102  float_t rotation;
103  Vector2 scale = Vector2::One();
104 
105  float_t randomizeDirection = 0.f;
106  float_t randomizeRotation = 0.f;
107  float_t randomizePosition = 0.f;
108 
109  bool_t showSpawnArea = false;
110 
111  MOUNTAIN_API void SetComputeShaderUniforms(const ComputeShader& computeShader, Types enabledModules) const override;
112  MOUNTAIN_API void RenderImGui(uint32_t* enabledModulesInt) override;
113  MOUNTAIN_API void RenderDebug(const ParticleSystem& system, Vector2 renderTargetSizeDiff) const override;
114  };
115 
116  class MOUNTAIN_API ColorOverLifetime : public Base
117  {
118  public:
119  Color target = Color::Transparent();
120 
121  void SetComputeShaderUniforms(const ComputeShader& computeShader, Types enabledModules) const override;
122  void RenderImGui(uint32_t* enabledModulesInt) override;
123  };
124 
125  class MOUNTAIN_API ForceOverLifetime : public Base
126  {
127  public:
128  Vector2 force;
129 
130  void SetComputeShaderUniforms(const ComputeShader& computeShader, Types enabledModules) const override;
131  void RenderImGui(uint32_t* enabledModulesInt) override;
132  };
133 }
134 
135 ENUM_FLAGS(Mountain::ParticleSystemModules::Types)
Defines general utility functions.
Defines multiple color structs.
static constexpr Vector2 One() noexcept
static constexpr Color Transparent()
Constant for Transparent.
The Color struct represents a color in RGBA color space.
Definition: color.hpp:26
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22