Browse Source

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)
Angad Kambli 4 years ago
parent
commit
bba67729ca
2 changed files with 3 additions and 1 deletions
  1. 2 1
      scene/3d/cpu_particles.cpp
  2. 1 0
      scene/3d/cpu_particles.h

+ 2 - 1
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

+ 1 - 0
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 {