Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ParticlePlugin.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
3#pragma once
4
8
9#include <vector>
10
11namespace esengine {
12
13namespace particle { class ParticleSystem; }
14
16public:
17 void init(RenderFrameContext& ctx) override;
18 void shutdown() override {}
19
20
21 void setParticleSystem(particle::ParticleSystem* system) { particle_system_ = system; }
22
23 // An emitter inside a UI tree draws where that tree says it does — the reason
24 // a UI particle is a first-class thing here rather than an extension — so it
25 // follows the tree into the screen domain too.
26 bool drawsScreenUI() const override { return true; }
27 void collect(RenderCollectContext& ctx) override;
28 const char* collectScope() const override { return "render.collect.particle"; }
29
30private:
31 particle::ParticleSystem* particle_system_ = nullptr;
32 u32 particle_shader_id_ = 0; // PARTICLE_INSTANCE program (GPU instancing)
35 resource::ShaderHandle particle_shader_handle_;
36
37 // Reused per-frame scratch for per-particle trail ribbons.
38 std::vector<glm::vec3> trail_center_;
39 std::vector<BatchVertex> trail_verts_;
40 std::vector<u32> trail_indices_;
41};
42
43} // namespace esengine
Type-safe resource handle system.
void init(RenderFrameContext &ctx) override
void collect(RenderCollectContext &ctx) override
const char * collectScope() const override
What this plugin's collect is called in a frame profile.
void setParticleSystem(particle::ParticleSystem *system)
bool drawsScreenUI() const override
Whether this plugin can draw an entity that lives in a UI tree.
Handle< esengine::Shader > ShaderHandle
Handle to a shader resource.
Definition Handle.hpp:214
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
static EstellaContext & ctx()