Skip to content

Commit 954ce86

Browse files
committed
Merge pull request godotengine#102405 from QbieShay/qbe/fix_rnd_git
Fix seed not randomizing for particles. Fix seed being stored when fixed seed is off
2 parents ff0049e + 2f3f6f6 commit 954ce86

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

scene/2d/cpu_particles_2d.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ void CPUParticles2D::_validate_property(PropertyInfo &p_property) const {
597597
}
598598

599599
if (p_property.name == "seed" && !use_fixed_seed) {
600-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
600+
p_property.usage = PROPERTY_USAGE_NONE;
601601
}
602602
}
603603

@@ -1392,6 +1392,8 @@ void CPUParticles2D::_bind_methods() {
13921392
BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
13931393
BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
13941394

1395+
ADD_PROPERTY_DEFAULT("seed", 0);
1396+
13951397
////////////////////////////////
13961398

13971399
ClassDB::bind_method(D_METHOD("set_direction", "direction"), &CPUParticles2D::set_direction);
@@ -1561,6 +1563,7 @@ CPUParticles2D::CPUParticles2D() {
15611563
set_emitting(true);
15621564
set_amount(8);
15631565
set_use_local_coordinates(false);
1566+
set_seed(Math::rand());
15641567

15651568
rng.instantiate();
15661569

scene/2d/gpu_particles_2d.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ Ref<Texture2D> GPUParticles2D::get_texture() const {
408408

409409
void GPUParticles2D::_validate_property(PropertyInfo &p_property) const {
410410
if (p_property.name == "seed" && !use_fixed_seed) {
411-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
411+
p_property.usage = PROPERTY_USAGE_NONE;
412412
}
413413
if (p_property.name == "emitting") {
414414
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
@@ -899,6 +899,8 @@ void GPUParticles2D::_bind_methods() {
899899
BIND_ENUM_CONSTANT(EMIT_FLAG_VELOCITY);
900900
BIND_ENUM_CONSTANT(EMIT_FLAG_COLOR);
901901
BIND_ENUM_CONSTANT(EMIT_FLAG_CUSTOM);
902+
903+
ADD_PROPERTY_DEFAULT("seed", 0);
902904
}
903905

904906
GPUParticles2D::GPUParticles2D() {
@@ -912,8 +914,8 @@ GPUParticles2D::GPUParticles2D() {
912914
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
913915
set_emitting(true);
914916
set_one_shot(false);
917+
set_seed(Math::rand());
915918
set_use_fixed_seed(false);
916-
set_seed(0);
917919
set_amount(8);
918920
set_amount_ratio(1.0);
919921
set_lifetime(1);

scene/3d/cpu_particles_3d.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ void CPUParticles3D::_validate_property(PropertyInfo &p_property) const {
612612
}
613613

614614
if (p_property.name == "seed" && !use_fixed_seed) {
615-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
615+
p_property.usage = PROPERTY_USAGE_NONE;
616616
}
617617
}
618618

@@ -1564,6 +1564,8 @@ void CPUParticles3D::_bind_methods() {
15641564
BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
15651565
BIND_ENUM_CONSTANT(DRAW_ORDER_VIEW_DEPTH);
15661566

1567+
ADD_PROPERTY_DEFAULT("seed", 0);
1568+
15671569
////////////////////////////////
15681570

15691571
ClassDB::bind_method(D_METHOD("set_direction", "direction"), &CPUParticles3D::set_direction);
@@ -1764,6 +1766,7 @@ CPUParticles3D::CPUParticles3D() {
17641766

17651767
set_emitting(true);
17661768
set_amount(8);
1769+
set_seed(Math::rand());
17671770

17681771
rng.instantiate();
17691772

scene/3d/gpu_particles_3d.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void GPUParticles3D::_validate_property(PropertyInfo &p_property) const {
464464
}
465465
}
466466
if (p_property.name == "seed" && !use_fixed_seed) {
467-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
467+
p_property.usage = PROPERTY_USAGE_NONE;
468468
}
469469
}
470470

@@ -868,6 +868,8 @@ void GPUParticles3D::_bind_methods() {
868868
BIND_ENUM_CONSTANT(TRANSFORM_ALIGN_Z_BILLBOARD);
869869
BIND_ENUM_CONSTANT(TRANSFORM_ALIGN_Y_TO_VELOCITY);
870870
BIND_ENUM_CONSTANT(TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY);
871+
872+
ADD_PROPERTY_DEFAULT("seed", 0);
871873
}
872874

873875
GPUParticles3D::GPUParticles3D() {
@@ -877,6 +879,7 @@ GPUParticles3D::GPUParticles3D() {
877879
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
878880
set_emitting(true);
879881
set_one_shot(false);
882+
set_seed(Math::rand());
880883
set_amount_ratio(1.0);
881884
set_amount(8);
882885
set_lifetime(1);
@@ -895,7 +898,6 @@ GPUParticles3D::GPUParticles3D() {
895898
set_collision_base_size(collision_base_size);
896899
set_transform_align(TRANSFORM_ALIGN_DISABLED);
897900
set_use_fixed_seed(false);
898-
set_seed(0);
899901
}
900902

901903
GPUParticles3D::~GPUParticles3D() {

0 commit comments

Comments
 (0)