summaryrefslogtreecommitdiff
path: root/scene/resources/capsule_shape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/capsule_shape.cpp')
-rw-r--r--scene/resources/capsule_shape.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp
index 2633b132cf..67ceed6be0 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape.cpp
@@ -30,6 +30,46 @@
#include "servers/physics_server.h"
+Vector<Vector3> CapsuleShape::_gen_debug_mesh_lines() {
+
+
+ float radius = get_radius();
+ float height = get_height();
+
+
+ Vector<Vector3> points;
+
+ Vector3 d(0,0,height*0.5);
+ for(int i=0;i<360;i++) {
+
+ float ra=Math::deg2rad(i);
+ float rb=Math::deg2rad(i+1);
+ Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
+ Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
+
+ points.push_back(Vector3(a.x,a.y,0)+d);
+ points.push_back(Vector3(b.x,b.y,0)+d);
+
+ points.push_back(Vector3(a.x,a.y,0)-d);
+ points.push_back(Vector3(b.x,b.y,0)-d);
+
+ if (i%90==0) {
+
+ points.push_back(Vector3(a.x,a.y,0)+d);
+ points.push_back(Vector3(a.x,a.y,0)-d);
+ }
+
+ Vector3 dud = i<180?d:-d;
+
+ points.push_back(Vector3(0,a.y,a.x)+dud);
+ points.push_back(Vector3(0,b.y,b.x)+dud);
+ points.push_back(Vector3(a.y,0,a.x)+dud);
+ points.push_back(Vector3(b.y,0,b.x)+dud);
+
+ }
+
+ return points;
+}
void CapsuleShape::_update_shape() {
@@ -65,7 +105,6 @@ float CapsuleShape::get_height() const {
return height;
}
-
void CapsuleShape::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CapsuleShape::set_radius);