diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-07 11:04:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 11:04:46 +0200 |
commit | 1fa26b969c296ca62462debf01c22e2cc0aa059e (patch) | |
tree | 824b51ef58bee4b9f17f68d336e40f3e35a0d255 /scene/3d/cpu_particles.cpp | |
parent | bf0c54ecf235a071e937cb608393aa464df07cdd (diff) | |
parent | 5fc8691176f97e9fdeb609012b0061fbb4de8eb4 (diff) |
Merge pull request #30357 from simonpuchert/spheres
Particles / CPUParticles: Return uniform density spheres.
Diffstat (limited to 'scene/3d/cpu_particles.cpp')
-rw-r--r-- | scene/3d/cpu_particles.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 358c4bdb44..86b407b9e6 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -643,7 +643,9 @@ void CPUParticles::_particles_process(float p_delta) { //do none } break; case EMISSION_SHAPE_SPHERE: { - p.transform.origin = Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0).normalized() * emission_sphere_radius; + float s = 2.0 * Math::randf() - 1.0, t = 2.0 * Math_PI * Math::randf(); + float radius = emission_sphere_radius * Math::sqrt(1.0 - s * s); + p.transform.origin = Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s); } break; case EMISSION_SHAPE_BOX: { p.transform.origin = Vector3(Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0, Math::randf() * 2.0 - 1.0) * emission_box_extents; |