summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorAngad Kambli <angadkambli@gmail.com>2021-02-17 20:00:03 +0530
committerAngad Kambli <angadkambli@gmail.com>2021-02-17 20:29:14 +0530
commitc97fffdc594d2fff05621565e2f6501234b1ba01 (patch)
treec282731ae0e40474bdccbba4f6284b606482896c /scene
parent7f63d6e848399d37915205da0829e839a8bcdaf4 (diff)
add null check in _update_particle_data_buffer()
add check to see if p_order is in range for CPUParticles3D::set_draw_order'
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/cpu_particles_3d.cpp2
-rw-r--r--scene/3d/cpu_particles_3d.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index 7825119e6e..979c6424b8 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -152,6 +152,7 @@ float CPUParticles3D::get_speed_scale() const {
}
void CPUParticles3D::set_draw_order(DrawOrder p_order) {
+ ERR_FAIL_INDEX(p_order, DRAW_ORDER_MAX);
draw_order = p_order;
}
@@ -1011,6 +1012,7 @@ void CPUParticles3D::_update_particle_data_buffer() {
sorter.compare.particles = r;
sorter.sort(order, pc);
} else if (draw_order == DRAW_ORDER_VIEW_DEPTH) {
+ ERR_FAIL_NULL(get_viewport());
Camera3D *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_3d.h b/scene/3d/cpu_particles_3d.h
index d650bf95ac..4af959a7bf 100644
--- a/scene/3d/cpu_particles_3d.h
+++ b/scene/3d/cpu_particles_3d.h
@@ -43,6 +43,7 @@ public:
DRAW_ORDER_INDEX,
DRAW_ORDER_LIFETIME,
DRAW_ORDER_VIEW_DEPTH,
+ DRAW_ORDER_MAX
};
enum Parameter {