diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-10-13 05:01:54 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-10-13 05:01:54 +0300 |
commit | 29caf2bb5be061cd1ab014cf938f2c71d0bd2663 (patch) | |
tree | 859a0c3d2805198672c1e22d4780c3eb68f55a57 /scene/resources/segment_shape_2d.cpp | |
parent | c5f574b914b3cb11d97ae616df4a0bced45bb17c (diff) | |
parent | 79e5ced7e668fa53567ac6aaf5a26393cea6c9a2 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'scene/resources/segment_shape_2d.cpp')
-rw-r--r-- | scene/resources/segment_shape_2d.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index b8bd3de552..88f7adcd9b 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -29,6 +29,7 @@ #include "segment_shape_2d.h" #include "servers/physics_2d_server.h" +#include "servers/visual_server.h" void SegmentShape2D::_update_shape() { @@ -62,6 +63,23 @@ Vector2 SegmentShape2D::get_b() const { return b; } +void SegmentShape2D::draw(const RID& p_to_rid,const Color& p_color) { + + VisualServer::get_singleton()->canvas_item_add_line(p_to_rid,a,b,p_color,3); +} + +Rect2 SegmentShape2D::get_rect() const{ + + Rect2 rect; + rect.pos=a; + rect.expand_to(b); + return rect; + +} + + + + void SegmentShape2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a); @@ -94,6 +112,37 @@ void RayShape2D::_update_shape() { } + +void RayShape2D::draw(const RID& p_to_rid,const Color& p_color) { + + + Vector2 tip = Vector2(0,get_length()); + VS::get_singleton()->canvas_item_add_line(p_to_rid,Vector2(),tip,p_color,3); + Vector<Vector2> pts; + float tsize=4; + pts.push_back(tip+Vector2(0,tsize)); + pts.push_back(tip+Vector2(0.707*tsize,0)); + pts.push_back(tip+Vector2(-0.707*tsize,0)); + Vector<Color> cols; + for(int i=0;i<3;i++) + cols.push_back(p_color); + + VS::get_singleton()->canvas_item_add_primitive(p_to_rid,pts,cols,Vector<Point2>(),RID()); + + + +} + +Rect2 RayShape2D::get_rect() const { + + Rect2 rect; + rect.pos=Vector2(); + rect.expand_to(Vector2(0,length)); + rect=rect.grow(0.707*4); + return rect; +} + + void RayShape2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length); |