summaryrefslogtreecommitdiff
path: root/scene/resources/convex_polygon_shape_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/convex_polygon_shape_2d.cpp')
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 74506f8600..a1137ba614 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -29,10 +29,11 @@
#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);
+ emit_changed();
}
@@ -62,7 +63,30 @@ void ConvexPolygonShape2D::_bind_methods() {
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"points"),_SCS("set_points"),_SCS("get_points") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"points"),_SCS("set_points"),_SCS("get_points") );
+
+}
+
+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;
}