diff options
author | Kasper Frandsen <kasper.arnklit@gmail.com> | 2024-04-17 17:33:30 +0100 |
---|---|---|
committer | Kasper Frandsen <kasper.arnklit@gmail.com> | 2024-04-17 17:33:30 +0100 |
commit | f8d08a83760d2b847de271c80c13d800b4a97aab (patch) | |
tree | 674081b2cb444c6c7e7207f1d2daaa0e5d09a48d /scene/3d/cpu_particles_3d.cpp | |
parent | 30e71782afd9a1fd35707b89511bcd1aa538f673 (diff) | |
download | redot-engine-f8d08a83760d2b847de271c80c13d800b4a97aab.tar.gz |
fix: avoid shader crash on null vector and negative x vector
Diffstat (limited to 'scene/3d/cpu_particles_3d.cpp')
-rw-r--r-- | scene/3d/cpu_particles_3d.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index e7b6aa1dba..0dc9834539 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -881,9 +881,9 @@ void CPUParticles3D::_particles_process(double p_delta) { case EMISSION_SHAPE_RING: { real_t ring_random_angle = Math::randf() * Math_TAU; real_t ring_random_radius = Math::randf() * (emission_ring_radius - emission_ring_inner_radius) + emission_ring_inner_radius; - Vector3 axis = emission_ring_axis.normalized(); + Vector3 axis = emission_ring_axis == Vector3(0.0, 0.0, 0.0) ? Vector3(0.0, 0.0, 1.0) : emission_ring_axis.normalized(); Vector3 ortho_axis; - if (axis == Vector3(1.0, 0.0, 0.0)) { + if (axis.abs() == Vector3(1.0, 0.0, 0.0)) { ortho_axis = Vector3(0.0, 1.0, 0.0).cross(axis); } else { ortho_axis = Vector3(1.0, 0.0, 0.0).cross(axis); |