diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-10 22:48:50 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-10 22:48:50 +0200 |
| commit | 55282ddc106cb0b2fd8750e710fbd49efab5f56a (patch) | |
| tree | 779c65b521798db5ff8e0321b71ae6f3d65d7721 /servers/rendering/renderer_rd/storage_rd/particles_storage.cpp | |
| parent | c5291a3555343e8aa5aefa1c7e17f2ad05ee1fc9 (diff) | |
| parent | c228fe1a0d7cf9dc65404f63cddbc0dd85959f2e (diff) | |
| download | redot-engine-55282ddc106cb0b2fd8750e710fbd49efab5f56a.tar.gz | |
Merge pull request #79527 from QbieShay/qbe/particles-rework
Particle internal refactor and additions for more artistic control
Diffstat (limited to 'servers/rendering/renderer_rd/storage_rd/particles_storage.cpp')
| -rw-r--r-- | servers/rendering/renderer_rd/storage_rd/particles_storage.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index bf5a597bb9..3065da4d05 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -72,6 +72,7 @@ ParticlesStorage::ParticlesStorage() { actions.renames["ACTIVE"] = "particle_active"; actions.renames["RESTART"] = "restart"; actions.renames["CUSTOM"] = "PARTICLE.custom"; + actions.renames["AMOUNT_RATIO"] = "FRAME.amount_ratio"; for (int i = 0; i < ParticlesShader::MAX_USERDATAS; i++) { String udname = "USERDATA" + itos(i + 1); actions.renames[udname] = "PARTICLE.userdata" + itos(i + 1); @@ -88,6 +89,8 @@ ParticlesStorage::ParticlesStorage() { actions.renames["INDEX"] = "index"; //actions.renames["GRAVITY"] = "current_gravity"; actions.renames["EMISSION_TRANSFORM"] = "FRAME.emission_transform"; + actions.renames["EMITTER_VELOCITY"] = "FRAME.emitter_velocity"; + actions.renames["INTERPOLATE_TO_END"] = "FRAME.interp_to_end"; actions.renames["RANDOM_SEED"] = "FRAME.random_seed"; actions.renames["FLAG_EMIT_POSITION"] = "EMISSION_FLAG_HAS_POSITION"; actions.renames["FLAG_EMIT_ROT_SCALE"] = "EMISSION_FLAG_HAS_ROTATION_SCALE"; @@ -329,6 +332,13 @@ void ParticlesStorage::particles_set_amount(RID p_particles, int p_amount) { particles->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_PARTICLES); } +void ParticlesStorage::particles_set_amount_ratio(RID p_particles, float p_amount_ratio) { + Particles *particles = particles_owner.get_or_null(p_particles); + ERR_FAIL_NULL(particles); + + particles->amount_ratio = p_amount_ratio; +} + void ParticlesStorage::particles_set_lifetime(RID p_particles, double p_lifetime) { Particles *particles = particles_owner.get_or_null(p_particles); ERR_FAIL_NULL(particles); @@ -651,6 +661,20 @@ void ParticlesStorage::particles_set_emission_transform(RID p_particles, const T particles->emission_transform = p_transform; } +void ParticlesStorage::particles_set_emitter_velocity(RID p_particles, const Vector3 &p_velocity) { + Particles *particles = particles_owner.get_or_null(p_particles); + ERR_FAIL_NULL(particles); + + particles->emitter_velocity = p_velocity; +} + +void ParticlesStorage::particles_set_interp_to_end(RID p_particles, float p_interp) { + Particles *particles = particles_owner.get_or_null(p_particles); + ERR_FAIL_NULL(particles); + + particles->interp_to_end = p_interp; +} + int ParticlesStorage::particles_get_draw_passes(RID p_particles) const { const Particles *particles = particles_owner.get_or_null(p_particles); ERR_FAIL_NULL_V(particles, 0); @@ -791,9 +815,13 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta frame_params.cycle = p_particles->cycle_number; frame_params.frame = p_particles->frame_counter++; - frame_params.pad0 = 0; + frame_params.amount_ratio = p_particles->amount_ratio; frame_params.pad1 = 0; frame_params.pad2 = 0; + frame_params.emitter_velocity[0] = p_particles->emitter_velocity.x; + frame_params.emitter_velocity[1] = p_particles->emitter_velocity.y; + frame_params.emitter_velocity[2] = p_particles->emitter_velocity.z; + frame_params.interp_to_end = p_particles->interp_to_end; { //collision and attractors |
