diff options
| author | Juan Linietsky | 2015-09-20 13:03:46 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-09-20 13:03:46 -0300 |
| commit | 83d9a692be648668b5b363f2424c619e15639843 (patch) | |
| tree | 387b30810994b282c795fdd011f53f0b7eb93ace /scene/resources/convex_polygon_shape_2d.cpp | |
| parent | 3f9e5afe68df1e3b4bcf34a21468ed55a57a7973 (diff) | |
| parent | 889d21e0049a0e84d6d44db9b80193f93fd62f17 (diff) | |
| download | godot-83d9a692be648668b5b363f2424c619e15639843.tar.gz godot-83d9a692be648668b5b363f2424c619e15639843.tar.zst godot-83d9a692be648668b5b363f2424c619e15639843.zip | |
Diffstat (limited to 'scene/resources/convex_polygon_shape_2d.cpp')
| -rw-r--r-- | scene/resources/convex_polygon_shape_2d.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 74506f860..dac39fc84 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -29,7 +29,7 @@ #include "convex_polygon_shape_2d.h" #include "servers/physics_2d_server.h" - +#include "servers/visual_server.h" void ConvexPolygonShape2D::_update_shape() { Physics2DServer::get_singleton()->shape_set_data(get_rid(),points); @@ -66,6 +66,29 @@ void ConvexPolygonShape2D::_bind_methods() { } +void ConvexPolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) { + + + Vector<Color> col; + col.push_back(p_color); + VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid,points,col); +} + +Rect2 ConvexPolygonShape2D::get_rect() const { + + + Rect2 rect; + for(int i=0;i<points.size();i++) { + if (i==0) + rect.pos=points[i]; + else + rect.expand_to(points[i]); + } + + return rect; + +} + ConvexPolygonShape2D::ConvexPolygonShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) { |
