Estella
0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ParticleForceField.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
13
#pragma once
14
15
#include "
../../core/Types.hpp
"
16
#include "
../../core/Reflection.hpp
"
17
#include "
../../math/Math.hpp
"
18
19
namespace
esengine::ecs
{
20
21
// Directional: a constant push along `direction` (wind). Point: pull toward
22
// (strength > 0) or push from (strength < 0) the field. Vortex: swirl tangentially
23
// around the field. Drag: damp velocity inside the zone (still air / water pocket).
24
// NOTE: keep these descriptions here, not as inline `//` comments on the values —
25
// the EHT enum parser treats trailing words as extra enum members.
26
ES_ENUM
()
27
enum class
ForceFieldType
:
i32
{
28
Directional
= 0,
29
Point
= 1,
30
Vortex
= 2,
31
Drag
= 3,
32
};
33
34
ES_COMPONENT
()
35
struct
ParticleForceField
{
36
ES_PROPERTY
(
enum
=
ForceFieldType
, category=Field)
37
i32
type
{
static_cast<
i32
>
(
ForceFieldType::Directional
)};
38
39
// Directional/Point/Vortex: acceleration magnitude (px/s²). Drag: damping rate
40
// per second. Negative flips a Point field from attractor to repeller.
41
ES_PROPERTY
(category=Field)
42
f32
strength
{200.0f};
43
44
// 0 = unbounded (affects the whole scene). > 0 = only particles within this world
45
// radius of the field's position are affected.
46
ES_PROPERTY
(min=0, category=Field)
47
f32
radius
{0.0f};
48
49
// Push direction for a Directional field (normalized at use). Point/Vortex/Drag
50
// derive their direction from the field→particle vector and ignore this.
51
ES_PROPERTY
(category=Field)
52
glm::vec3
direction
{1.0f, 0.0f, 0.0f};
53
54
// Fade the force linearly to 0 at the radius edge (only meaningful when radius > 0).
55
ES_PROPERTY
(category=Field)
56
bool
falloff
{
true
};
57
58
ES_PROPERTY
()
59
bool
enabled
{
true
};
60
61
ParticleForceField
() =
default
;
62
};
63
64
}
// namespace esengine::ecs
Math.hpp
Math utilities and GLM configuration for ESEngine.
Reflection.hpp
Reflection and metadata system for automatic binding generation.
ES_COMPONENT
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
Definition
Reflection.hpp:46
ES_ENUM
#define ES_ENUM(...)
Mark an enum that should be exposed to scripts.
Definition
Reflection.hpp:119
ES_PROPERTY
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Definition
Reflection.hpp:95
Types.hpp
Core type definitions and utilities for ESEngine.
esengine::ecs
Definition
AotComponents.generated.hpp:8
esengine::ecs::ForceFieldType
ForceFieldType
Definition
ParticleForceField.hpp:27
esengine::ecs::ForceFieldType::Vortex
@ Vortex
Definition
ParticleForceField.hpp:30
esengine::ecs::ForceFieldType::Directional
@ Directional
Definition
ParticleForceField.hpp:28
esengine::ecs::ForceFieldType::Drag
@ Drag
Definition
ParticleForceField.hpp:31
esengine::ecs::LightType::Point
@ Point
Definition
Light.hpp:37
esengine::ecs::LightType::Directional
@ Directional
Definition
Light.hpp:38
esengine::i32
std::int32_t i32
Signed 32-bit integer.
Definition
Types.hpp:54
esengine::f32
float f32
32-bit floating point
Definition
Types.hpp:59
esengine::ecs::ParticleForceField::enabled
bool enabled
Definition
ParticleForceField.hpp:59
esengine::ecs::ParticleForceField::strength
f32 strength
Definition
ParticleForceField.hpp:42
esengine::ecs::ParticleForceField::radius
f32 radius
Definition
ParticleForceField.hpp:47
esengine::ecs::ParticleForceField::ParticleForceField
ParticleForceField()=default
esengine::ecs::ParticleForceField::type
i32 type
Definition
ParticleForceField.hpp:37
esengine::ecs::ParticleForceField::direction
glm::vec3 direction
Definition
ParticleForceField.hpp:52
esengine::ecs::ParticleForceField::falloff
bool falloff
Definition
ParticleForceField.hpp:56
src
esengine
ecs
components
ParticleForceField.hpp
Generated by
1.15.0