summaryrefslogtreecommitdiff
path: root/scene/resources/convex_polygon_shape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/convex_polygon_shape.cpp')
-rw-r--r--scene/resources/convex_polygon_shape.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index 1498eb4af9..b7463605b4 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -34,7 +34,7 @@
Vector<Vector3> ConvexPolygonShape::get_debug_mesh_lines() {
- PoolVector<Vector3> points = get_points();
+ Vector<Vector3> points = get_points();
if (points.size() > 3) {
@@ -55,20 +55,30 @@ Vector<Vector3> ConvexPolygonShape::get_debug_mesh_lines() {
return Vector<Vector3>();
}
+real_t ConvexPolygonShape::get_enclosing_radius() const {
+ Vector<Vector3> data = get_points();
+ const Vector3 *read = data.ptr();
+ real_t r = 0;
+ for (int i(0); i < data.size(); i++) {
+ r = MAX(read[i].length_squared(), r);
+ }
+ return Math::sqrt(r);
+}
+
void ConvexPolygonShape::_update_shape() {
PhysicsServer::get_singleton()->shape_set_data(get_shape(), points);
Shape::_update_shape();
}
-void ConvexPolygonShape::set_points(const PoolVector<Vector3> &p_points) {
+void ConvexPolygonShape::set_points(const Vector<Vector3> &p_points) {
points = p_points;
_update_shape();
notify_change_to_owners();
}
-PoolVector<Vector3> ConvexPolygonShape::get_points() const {
+Vector<Vector3> ConvexPolygonShape::get_points() const {
return points;
}