2#include "math/transform.hpp"
25 component.desc_.reset();
26 component.recreate_emitter();
38 component.emitter_handle_ = {};
55 return emitter_handle_;
74 if(direction_ != direction)
76 direction_ = direction;
98 if(max_particles_ != max_particles)
100 max_particles_ = max_particles;
107 return max_particles_;
499 math::bbox bounds(math::vec3(-1.0f), math::vec3(1.0f));
506 auto bounds = get_world_bounds();
509 bounds.mul(world_transform);
590 culling_mode_ = mode;
595 return culling_mode_;
600 last_render_frame_ =
frame;
605 return last_render_frame_;
610 return last_render_frame_ == 0;
617 const bool was_used_recently = current_frame - last_render_frame_ <= 1;
618 return is_new || was_used_recently;
627 transform_state_.
current = world_transform;
628 bool should_simulate =
true;
631 should_simulate =
false;
653 emitter_handle_ = {};
685 simulation_backend_ = backend;
694 return simulation_backend_;
void generate_lut(size_t lut_size=256)
static auto default_color_map() -> asset_handle< gfx::texture > &
Gets the default color map.
auto get_owner() const noexcept -> entt::const_handle
Gets the owner of the component.
void set_owner(entt::handle owner)
Sets the owner of the component.
Component that wraps the soa particle system emitter.
auto get_texture() const -> const asset_handle< gfx::texture > &
auto get_desc() const -> const ps_soa::emitter_desc &
void set_align_to_direction(bool align)
auto get_size_by_speed_range() const -> const frange_t &
auto is_newly_created() const noexcept -> bool
auto is_paused() const -> bool
auto get_temporal_motion() const -> float
void set_size_by_speed_range(const frange_t &size_range)
auto get_emission_shape_position() const -> math::vec3
void set_color_by_speed_velocity_range(const frange_t &velocity_range)
auto get_pivot() const -> math::vec2
auto get_culling_mode() const -> culling_mode
auto get_color_by_speed_velocity_range() const -> const frange_t &
void set_texture(const asset_handle< gfx::texture > &texture)
void set_texture_sheet_tiles(math::vec2 tiles)
void set_start_delay(std::chrono::duration< float > delay)
static void on_destroy_component(entt::registry &r, entt::entity e)
auto get_shape() const -> ps_soa::emitter_shape
auto get_emitter_handle() const -> ps_soa::emitter_handle
void set_spawn_location(ps_soa::spawn_location spawn_location)
auto get_render_mode() const -> ps_soa::render_mode
auto get_blend_mode() const -> ps_soa::blend_mode
void set_texture_sheet_cycles(float cycles)
auto get_start_delay() const -> std::chrono::duration< float >
void set_opacity(float opacity)
void set_lifetime(std::chrono::duration< float > lifetime)
void set_render_mode(ps_soa::render_mode mode)
auto get_max_particles() const -> uint32_t
void update_emitter(const math::transform &world_transform, delta_t dt)
void set_texture_sheet_randomize(bool randomize)
void set_simulation_space(ps_soa::simulation_space space)
void set_color_by_speed_gradient(const math::gradient< math::color > &gradient)
auto is_loop() const -> bool
auto get_initial_scale_3d() const -> math::vec3
auto get_lifetime_by_emitter_speed_gradient() const -> const math::gradient< float > &
void set_size_by_speed_velocity_range(const frange_t &velocity_range)
auto get_texture_sheet_tiles() const -> math::vec2
auto get_emission_shape_scale() const -> math::vec3
auto get_texture_sheet_randomize() const -> bool
void set_enabled(bool enabled)
void set_temporal_motion(float temporal_motion)
void set_initial_scale_3d(const math::vec3 &scale)
auto get_texture_mode() const -> ps_soa::texture_mode
auto was_used_last_frame() const noexcept -> bool
void set_simulation_backend(ps_soa::particle_sim_backend backend)
CPU vs GPU particle pack/sim path for this emitter (artist-selectable).
void set_position_easing(bx::Easing::Enum easing)
auto get_scale_gradient() const -> const math::gradient< frange_t > &
void set_velocity_damping(float velocity_damping)
void set_velocity_gradient(const math::gradient< frange_t > &gradient)
void set_force_over_lifetime(const math::vec3 &force)
void set_emission_shape_scale(const math::vec3 &scale)
void set_blend_mode(ps_soa::blend_mode mode)
void set_color_gradient(const math::gradient< math::color > &gradient)
auto is_enabled() const -> bool
void set_texture_mode(ps_soa::texture_mode mode)
auto get_color_by_speed_gradient() const -> const math::gradient< math::color > &
void set_last_render_frame(uint64_t frame)
auto get_velocity_gradient() const -> const math::gradient< frange_t > &
auto get_align_to_direction() const -> bool
void set_emission_rate(float emission_rate)
auto is_playing() const -> bool
auto get_lifetime() const -> std::chrono::duration< float >
auto get_updated_world_bounds(const math::transform &world_transform) const -> math::bbox
auto get_force_over_lifetime() const -> math::vec3
auto get_direction() const -> ps_soa::emitter_direction
auto is_stopped() const -> bool
void set_lifetime_by_emitter_speed_gradient(const math::gradient< float > &gradient)
auto get_color_intensity() const -> float
void set_emission_lifetime(std::chrono::duration< float > lifetime)
void resume_sub_emitters()
auto get_velocity_damping() const -> float
auto get_simulation_space() const -> ps_soa::simulation_space
void set_gravity_scale(float scale)
void set_shape(ps_soa::emitter_shape shape)
auto get_color_gradient() const -> const math::gradient< math::color > &
auto get_simulation_backend() const -> ps_soa::particle_sim_backend
void set_color_intensity(float intensity)
auto get_world_bounds() const -> math::bbox
void set_culling_mode(culling_mode mode)
auto get_size_by_speed_velocity_range() const -> const frange_t &
auto get_spawn_location() const -> ps_soa::spawn_location
static void on_create_component(entt::registry &r, entt::entity e)
auto get_emission_lifetime() const -> std::chrono::duration< float >
void set_lifetime_by_emitter_speed_range(const frange_t &speed_range)
void pause_sub_emitters()
void set_pivot(const math::vec2 &pivot)
auto get_gravity_scale() const -> float
void set_emission_shape_position(const math::vec3 &position)
auto get_texture_sheet_cycles() const -> float
void stop_and_reset_sub_emitters()
auto get_last_render_frame() const noexcept -> uint64_t
auto get_opacity() const -> float
void set_scale_gradient(const math::gradient< frange_t > &gradient)
void set_direction(ps_soa::emitter_direction direction)
auto get_num_particles() const -> uint32_t
auto get_position_easing() const -> bx::Easing::Enum
auto get_lifetime_by_emitter_speed_range() const -> const frange_t &
auto get_emission_rate() const -> float
void set_max_particles(uint32_t max_particles)
std::chrono::duration< float > delta_t
#define APPLOG_ERROR(...)
uint32_t get_render_frame()
auto gradient_lerp(const vec4 &start, const vec4 &end, float progress) -> vec4
Hash specialization for batch_key to enable use in std::unordered_map.
blend_mode
Blend mode. Ordinals match legacy BlendMode.
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.
texture_mode
Texture interpretation. Ordinals match legacy TextureMode.
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.
particle_sim_backend
Selects CPU vs resident-GPU simulation backend.
emitter_shape
Emission volume shape. Ordinals match legacy EmitterShape for content compatibility.
simulation_space
Simulation space. Ordinals match legacy SimulationSpace.
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 is_valid(emitter_handle handle) -> bool
void set_emitter_sim_backend(emitter_handle handle, particle_sim_backend backend)
Override backend for one emitter.
spawn_location
Where particles spawn within the shape. Ordinals match legacy EmitterSpawnLocation.
auto get_num_particles(emitter_handle handle) -> uint32_t
Live particle count.
void reset_emitter(emitter_handle handle)
Clear particles and reset sim bookkeeping.
render_mode
Billboard / facing mode. Ordinals match legacy RenderMode.
auto has_updated(emitter_handle handle) -> bool
True after the first successful update.
void for_each_component_in_children(entt::handle parent, std::function< void(ComponentType &)> callback)
Iterates through all children (recursively) and calls the callback for each entity that has the speci...
std::vector< math::color > color
std::vector< float > scale
std::vector< math::vec3 > start
Thread-safe handle to an asset.
auto is_valid() const -> bool
Checks if the handle references a task.
Storage for box vector values and wraps up common functionality.
math::gradient< math::color > color_by_speed_gradient
frange_t size_by_speed_range
math::gradient< math::color > color_gradient
math::gradient< frange_t > scale_gradient
frange_t size_by_speed_velocity_range
frange_t color_by_speed_velocity_range
math::vec3 initial_scale_3d
emitter_appearance_desc appearance
emitter_emission_desc emission
emitter_render_desc render
emitter_motion_desc motion
emitter_playback_desc playback
float particles_per_second
spawn_location spawn_location
math::vec3 shape_position
bx::Easing::Enum position_easing
math::gradient< frange_t > velocity_gradient
math::gradient< float > lifetime_by_emitter_speed_gradient
math::vec3 force_over_lifetime
frange_t lifetime_by_emitter_speed_range
texture_mode texture_mode
math::vec2 tex_sheet_tiles