-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cpuparticles randomness regression #101872
Conversation
scene/2d/cpu_particles_2d.h
Outdated
@@ -179,6 +180,8 @@ class CPUParticles2D : public Node2D { | |||
|
|||
Vector2 gravity = Vector2(0, 980); | |||
|
|||
Ref<RandomNumberGenerator> _rng; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref<RandomNumberGenerator> _rng; | |
Ref<RandomNumberGenerator> rng; |
We don't underscore private variables.
scene/2d/cpu_particles_2d.h
Outdated
@@ -31,6 +31,7 @@ | |||
#ifndef CPU_PARTICLES_2D_H | |||
#define CPU_PARTICLES_2D_H | |||
|
|||
#include "core/math/random_number_generator.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use forward declaration instead of include.
scene/2d/cpu_particles_2d.cpp
Outdated
Vector2 rot = Vector2(Math::cos(angle1_rad), Math::sin(angle1_rad)); | ||
p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_max[PARAM_INITIAL_LINEAR_VELOCITY], (real_t)rand_from_seed(_seed)); | ||
p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_max[PARAM_INITIAL_LINEAR_VELOCITY], (real_t)_rng->randf()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_max[PARAM_INITIAL_LINEAR_VELOCITY], (real_t)_rng->randf()); | |
p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_max[PARAM_INITIAL_LINEAR_VELOCITY], _rng->randf()); |
randf()
already returns real_t
, so not sure what the cast was for.
b93216c
to
c8b0509
Compare
Thanks! |
Closes #101859