Unravel Engine C++ Reference
Loading...
Searching...
No Matches
particle_system_soa.h
Go to the documentation of this file.
1#pragma once
2
3#include "emitter_desc.h"
4#include "emitter_runtime.h"
6#include "particle_types.h"
7
8#include <bgfx/bgfx.h>
9#include <context/context.hpp>
10#include <math/bbox.h>
11#include <math/math.h>
12
13namespace unravel
14{
15namespace ps_soa
16{
17
22void init(uint16_t max_emitters = 64);
23
28void init_gpu(rtti::context& ctx);
29
33void shutdown();
34
39
44
48void set_emitter_sim_backend(emitter_handle handle, particle_sim_backend backend);
49
54
58auto is_gpu_sim_available() -> bool;
59
63auto create_emitter(emitter_shape shape, emitter_direction direction, uint32_t max_particles) -> emitter_handle;
64
68void destroy_emitter(emitter_handle handle);
69
73void reset_emitter(emitter_handle handle);
74
83void update_emitter(emitter_handle handle,
84 float dt,
85 const emitter_desc& desc,
86 emitter_transform_state& transform,
87 emitter_playback_desc& playback);
88
92void update_emitter_bounds_only(emitter_handle handle,
93 const emitter_desc& desc,
94 emitter_transform_state& transform);
95
101
105auto has_updated(emitter_handle handle) -> bool;
106
110void get_aabb(emitter_handle handle, math::bbox& out_aabb);
111
115auto get_num_particles(emitter_handle handle) -> uint32_t;
116
122auto render_emitter_batch(const emitter_handle* handles,
123 uint32_t count,
124 uint8_t view,
125 bgfx::ProgramHandle program,
126 const float* mtx_view,
127 const math::vec3& eye,
128 bgfx::TextureHandle texture,
129 uint64_t blend_state,
130 bool sort_by_depth = true) -> uint32_t;
131
132} // namespace ps_soa
133} // namespace unravel
uint16_t view
imported_texture desc
void update_emitter(emitter_handle handle, float dt, const emitter_desc &desc, emitter_transform_state &transform, emitter_playback_desc &playback)
Advance simulation for one emitter.
void update_emitter_bounds_only(emitter_handle handle, const emitter_desc &desc, emitter_transform_state &transform)
Refresh transform-driven world bounds without advancing sim (renderer-based freeze).
void destroy_emitter(emitter_handle handle)
Destroy an emitter and free its particle storage.
emitter_direction
Initial emission direction. Ordinals match legacy EmitterDirection.
void init(uint16_t max_emitters)
Initialize the soa particle system.
particle_sim_backend
Selects CPU vs resident-GPU simulation backend.
void shutdown()
Shutdown and free all emitters / GPU resources.
emitter_shape
Emission volume shape. Ordinals match legacy EmitterShape for content compatibility.
auto create_emitter(emitter_shape shape, emitter_direction direction, uint32_t max_particles) -> emitter_handle
Create an emitter with shape/direction and capacity.
void get_aabb(emitter_handle handle, math::bbox &out_aabb)
World-space AABB used for culling.
auto get_emitter_sim_backend(emitter_handle handle) -> particle_sim_backend
Effective backend for an emitter (after availability checks).
void set_emitter_sim_backend(emitter_handle handle, particle_sim_backend backend)
Override backend for one emitter.
auto get_num_particles(emitter_handle handle) -> uint32_t
Live particle count.
auto render_emitter_batch(const emitter_handle *handles, uint32_t count, uint8_t view, bgfx::ProgramHandle program, const float *mtx_view, const math::vec3 &eye, bgfx::TextureHandle texture, uint64_t blend_state, bool sort_by_depth) -> uint32_t
Submit a homogeneous material batch (same texture / texture_mode / blend).
auto is_gpu_sim_available() -> bool
True when compute pack program loaded successfully.
void sync_gpu_simulation()
Flush staged GPU spawns and advance resident GPU sim for awake emitters.
void init_gpu(rtti::context &ctx)
Load compute pack program and enable GPU backend when available.
void reset_emitter(emitter_handle handle)
Clear particles and reset sim bookkeeping.
auto get_default_sim_backend() -> particle_sim_backend
Current default sim backend.
void set_default_sim_backend(particle_sim_backend backend)
Set default sim backend for new / unset emitters (cpu remains fallback).
auto has_updated(emitter_handle handle) -> bool
True after the first successful update.
Storage for box vector values and wraps up common functionality.
Definition bbox.h:21
gfx::uniform_handle handle
Definition uniform.cpp:9