From bba67729ca7c2c1804a8b69bb0b01c7ffede76e1 Mon Sep 17 00:00:00 2001 From: Angad Kambli Date: Wed, 17 Feb 2021 20:00:03 +0530 Subject: [PATCH] add null check in _update_particle_data_buffer() add check to see if p_order is in range for CPUParticles3D::set_draw_order' (cherry picked from commit c97fffdc594d2fff05621565e2f6501234b1ba01) --- scene/3d/cpu_particles.cpp | 3 ++- scene/3d/cpu_particles.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 4207e0b328e..39e4632ee7e 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -159,7 +159,7 @@ float CPUParticles::get_speed_scale() const { } void CPUParticles::set_draw_order(DrawOrder p_order) { - + ERR_FAIL_INDEX(p_order, DRAW_ORDER_MAX); draw_order = p_order; } @@ -1051,6 +1051,7 @@ void CPUParticles::_update_particle_data_buffer() { sorter.compare.particles = r.ptr(); sorter.sort(order, pc); } else if (draw_order == DRAW_ORDER_VIEW_DEPTH) { + ERR_FAIL_NULL(get_viewport()); Camera *c = get_viewport()->get_camera(); if (c) { Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h index 63330412600..41140404aa9 100644 --- a/scene/3d/cpu_particles.h +++ b/scene/3d/cpu_particles.h @@ -43,6 +43,7 @@ public: DRAW_ORDER_INDEX, DRAW_ORDER_LIFETIME, DRAW_ORDER_VIEW_DEPTH, + DRAW_ORDER_MAX }; enum Parameter {