Repository: godotengine/godot
File: scene/3d/navigation_obstacle_3d.cpp (C++)

Code before:
		RS::get_singleton()->instance_set_visible(fake_agent_radius_debug_instance, is_visible_in_tree());
	}
}
#endif // DEBUG_ENABLED

#ifdef DEBUG_ENABLED
void NavigationObstacle3D::_update_static_obstacle_debug() {
	bool is_debug_enabled = false;
	if (Engine::get_singleton()->is_editor_hint()) {
		is_debug_enabled = true;
	} else if (NavigationServer3D::get_singleton()->get_debug_enabled() &&
			NavigationServer3D::get_singleton()->get_debug_avoidance_enabled() &&
			NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_static()) {
		is_debug_enabled = true;
	}

	if (is_debug_enabled == false) {
		if (static_obstacle_debug_instance.is_valid()) {
			RS::get_singleton()->instance_set_visible(static_obstacle_debug_instance, false);
		}
		return;
	}

	if (vertices.size() < 3) {
		if (static_obstacle_debug_instance.is_valid()) {
			RS::get_singleton()->instance_set_visible(static_obstacle_debug_instance, false);
		}
		return;
	}

	if (!static_obstacle_debug_instance.is_valid()) {
		static_obstacle_debug_instance = RenderingServer::get_singleton()->instance_create();
	}
	if (!static_obstacle_debug_mesh.is_valid()) {
		static_obstacle_debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
	}
	static_obstacle_debug_mesh->clear_surfaces();

	Vector<Vector2> polygon_2d_vertices;
	polygon_2d_vertices.resize(vertices.size());
	Vector2 *polygon_2d_vertices_ptr = polygon_2d_vertices.ptrw();

	for (int i = 0; i < vertices.size(); ++i) {
		Vector3 obstacle_vertex = vertices[i];
		Vector2 obstacle_vertex_2d = Vector2(obstacle_vertex.x, obstacle_vertex.z);
		polygon_2d_vertices_ptr[i] = obstacle_vertex_2d;
	}

	Vector<int> triangulated_polygon_2d_indices = Geometry2D::triangulate_polygon(polygon_2d_vertices);

	if (triangulated_polygon_2d_indices.is_empty()) {

Review comment (bug):
```suggestion
	if (static_obstacle_debug_mesh.is_null()) {
```

Code after:
		RS::get_singleton()->instance_set_visible(fake_agent_radius_debug_instance, is_visible_in_tree());
	}
}
#endif // DEBUG_ENABLED

#ifdef DEBUG_ENABLED
void NavigationObstacle3D::_update_static_obstacle_debug() {
	bool is_debug_enabled = false;
	if (Engine::get_singleton()->is_editor_hint()) {
		is_debug_enabled = true;
	} else if (NavigationServer3D::get_singleton()->get_debug_enabled() &&
			NavigationServer3D::get_singleton()->get_debug_avoidance_enabled() &&
			NavigationServer3D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_static()) {
		is_debug_enabled = true;
	}

	if (is_debug_enabled == false) {
		if (static_obstacle_debug_instance.is_valid()) {
			RS::get_singleton()->instance_set_visible(static_obstacle_debug_instance, false);
		}
		return;
	}

	if (vertices.size() < 3) {
		if (static_obstacle_debug_instance.is_valid()) {
			RS::get_singleton()->instance_set_visible(static_obstacle_debug_instance, false);
		}
		return;
	}

	if (!static_obstacle_debug_instance.is_valid()) {
		static_obstacle_debug_instance = RenderingServer::get_singleton()->instance_create();
	}
	if (static_obstacle_debug_mesh.is_null()) {
		static_obstacle_debug_mesh.instantiate();
	}
	static_obstacle_debug_mesh->clear_surfaces();

	Vector<Vector2> polygon_2d_vertices;
	polygon_2d_vertices.resize(vertices.size());
	Vector2 *polygon_2d_vertices_ptr = polygon_2d_vertices.ptrw();

	for (int i = 0; i < vertices.size(); ++i) {
		Vector3 obstacle_vertex = vertices[i];
		Vector2 obstacle_vertex_2d = Vector2(obstacle_vertex.x, obstacle_vertex.z);
		polygon_2d_vertices_ptr[i] = obstacle_vertex_2d;
	}

	Vector<int> triangulated_polygon_2d_indices = Geometry2D::triangulate_polygon(polygon_2d_vertices);

	if (triangulated_polygon_2d_indices.is_empty()) {