summaryrefslogtreecommitdiff
path: root/scene/resources/convex_polygon_shape_2d.cpp
diff options
context:
space:
mode:
authorAndrea Catania <info@andreacatania.com>2020-01-10 12:22:34 +0100
committerAndrea Catania <info@andreacatania.com>2020-02-10 14:38:52 +0100
commite6be3f68da4b88cb0c7d8c7464916235c73e1f92 (patch)
tree2e65162fd1937df8b4dcd80900dd5b9b4aac58d1 /scene/resources/convex_polygon_shape_2d.cpp
parent8cd5102c65269f1ec4968627ca71df550954d914 (diff)
- Integrated NavigationServer and Navigation2DServer.
- Added Navigation Agents and Obstacles. - Integrated Collision Avoidance. This work has been kindly sponsored by IMVU.
Diffstat (limited to 'scene/resources/convex_polygon_shape_2d.cpp')
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index c404190398..296d014cc7 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -97,6 +97,14 @@ Rect2 ConvexPolygonShape2D::get_rect() const {
return rect;
}
+real_t ConvexPolygonShape2D::get_enclosing_radius() const {
+ real_t r = 0;
+ for (int i(0); i < get_points().size(); i++) {
+ r = MAX(get_points()[i].length_squared(), r);
+ }
+ return Math::sqrt(r);
+}
+
ConvexPolygonShape2D::ConvexPolygonShape2D() :
Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) {
}