From fa26fb865ff1c1f6a107b45717c435e36abaa0e2 Mon Sep 17 00:00:00 2001 From: Pawel Lampe Date: Thu, 21 Oct 2021 22:25:06 +0200 Subject: Improve NavigationObstacle3D usability Fix NavigationObstacle3D to be attached to navigation map - without it the NavigationObstacle3D is not working. Replace radius approximation algorithm with simple "radius" property. --- scene/2d/navigation_obstacle_2d.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'scene/2d/navigation_obstacle_2d.h') diff --git a/scene/2d/navigation_obstacle_2d.h b/scene/2d/navigation_obstacle_2d.h index 9cffc2c0c3..a5603f059f 100644 --- a/scene/2d/navigation_obstacle_2d.h +++ b/scene/2d/navigation_obstacle_2d.h @@ -40,8 +40,12 @@ class NavigationObstacle2D : public Node { Node2D *parent_node2d = nullptr; RID agent; + bool estimate_radius = true; + real_t radius = 1.0; + protected: static void _bind_methods(); + void _validate_property(PropertyInfo &p_property) const override; void _notification(int p_what); public: @@ -52,10 +56,21 @@ public: return agent; } + void set_estimate_radius(bool p_estimate_radius); + bool is_radius_estimated() const { + return estimate_radius; + } + void set_radius(real_t p_radius); + real_t get_radius() const { + return radius; + } + TypedArray get_configuration_warnings() const override; private: - void update_agent_shape(); + void initialize_agent(); + void reevaluate_agent_radius(); + real_t estimate_agent_radius() const; }; #endif -- cgit v1.2.3