You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix particle not re-randomizing every emission
This commit is contained in:
@@ -45,10 +45,22 @@ void CPUParticles2D::set_emitting(bool p_emitting) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p_emitting && !use_fixed_seed) {
|
||||||
|
set_seed(Math::rand());
|
||||||
|
}
|
||||||
|
|
||||||
emitting = p_emitting;
|
emitting = p_emitting;
|
||||||
if (emitting) {
|
if (emitting) {
|
||||||
|
_set_emitting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPUParticles2D::_set_emitting() {
|
||||||
active = true;
|
active = true;
|
||||||
set_process_internal(true);
|
set_process_internal(true);
|
||||||
|
// first update before rendering to avoid one frame delay after emitting starts
|
||||||
|
if (time == 0) {
|
||||||
|
_update_internal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +322,8 @@ void CPUParticles2D::restart(bool p_keep_seed) {
|
|||||||
seed = Math::rand();
|
seed = Math::rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
set_emitting(true);
|
emitting = true;
|
||||||
|
_set_emitting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUParticles2D::set_direction(Vector2 p_direction) {
|
void CPUParticles2D::set_direction(Vector2 p_direction) {
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ private:
|
|||||||
void _update_internal();
|
void _update_internal();
|
||||||
void _particles_process(double p_delta);
|
void _particles_process(double p_delta);
|
||||||
void _update_particle_data_buffer();
|
void _update_particle_data_buffer();
|
||||||
|
void _set_emitting();
|
||||||
|
|
||||||
Mutex update_mutex;
|
Mutex update_mutex;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
void GPUParticles2D::set_emitting(bool p_emitting) {
|
void GPUParticles2D::set_emitting(bool p_emitting) {
|
||||||
// Do not return even if `p_emitting == emitting` because `emitting` is just an approximation.
|
// Do not return even if `p_emitting == emitting` because `emitting` is just an approximation.
|
||||||
|
|
||||||
|
if (p_emitting && p_emitting != emitting && !use_fixed_seed) {
|
||||||
|
set_seed(Math::rand());
|
||||||
|
}
|
||||||
if (p_emitting && one_shot) {
|
if (p_emitting && one_shot) {
|
||||||
if (!active && !emitting) {
|
if (!active && !emitting) {
|
||||||
// Last cycle ended.
|
// Last cycle ended.
|
||||||
|
|||||||
@@ -48,17 +48,24 @@ void CPUParticles3D::set_emitting(bool p_emitting) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p_emitting && !use_fixed_seed) {
|
||||||
|
set_seed(Math::rand());
|
||||||
|
}
|
||||||
|
|
||||||
emitting = p_emitting;
|
emitting = p_emitting;
|
||||||
if (emitting) {
|
if (emitting) {
|
||||||
|
_set_emitting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPUParticles3D::_set_emitting() {
|
||||||
active = true;
|
active = true;
|
||||||
set_process_internal(true);
|
set_process_internal(true);
|
||||||
|
|
||||||
// first update before rendering to avoid one frame delay after emitting starts
|
// first update before rendering to avoid one frame delay after emitting starts
|
||||||
if (time == 0) {
|
if (time == 0) {
|
||||||
_update_internal();
|
_update_internal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CPUParticles3D::set_amount(int p_amount) {
|
void CPUParticles3D::set_amount(int p_amount) {
|
||||||
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0.");
|
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0.");
|
||||||
@@ -251,7 +258,8 @@ void CPUParticles3D::restart(bool p_keep_seed) {
|
|||||||
seed = Math::rand();
|
seed = Math::rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
set_emitting(true);
|
emitting = true;
|
||||||
|
_set_emitting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUParticles3D::set_direction(Vector3 p_direction) {
|
void CPUParticles3D::set_direction(Vector3 p_direction) {
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ private:
|
|||||||
void _update_internal();
|
void _update_internal();
|
||||||
void _particles_process(double p_delta);
|
void _particles_process(double p_delta);
|
||||||
void _update_particle_data_buffer();
|
void _update_particle_data_buffer();
|
||||||
|
void _set_emitting();
|
||||||
|
|
||||||
Mutex update_mutex;
|
Mutex update_mutex;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ AABB GPUParticles3D::get_aabb() const {
|
|||||||
|
|
||||||
void GPUParticles3D::set_emitting(bool p_emitting) {
|
void GPUParticles3D::set_emitting(bool p_emitting) {
|
||||||
// Do not return even if `p_emitting == emitting` because `emitting` is just an approximation.
|
// Do not return even if `p_emitting == emitting` because `emitting` is just an approximation.
|
||||||
|
if (p_emitting && p_emitting != emitting && !use_fixed_seed) {
|
||||||
|
set_seed(Math::rand());
|
||||||
|
}
|
||||||
if (p_emitting && one_shot) {
|
if (p_emitting && one_shot) {
|
||||||
if (!active && !emitting) {
|
if (!active && !emitting) {
|
||||||
// Last cycle ended.
|
// Last cycle ended.
|
||||||
|
|||||||
Reference in New Issue
Block a user