summaryrefslogtreecommitdiffstats
path: root/scene/resources/segment_shape_2d.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/resources/segment_shape_2d.cpp
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
downloadredot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'scene/resources/segment_shape_2d.cpp')
-rw-r--r--scene/resources/segment_shape_2d.cpp101
1 files changed, 41 insertions, 60 deletions
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index fbe1efe5d1..7a1114f895 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -34,138 +34,119 @@
void SegmentShape2D::_update_shape() {
Rect2 r;
- r.pos=a;
- r.size=b;
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),r);
+ r.pos = a;
+ r.size = b;
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), r);
emit_changed();
-
}
-void SegmentShape2D::set_a(const Vector2& p_a) {
+void SegmentShape2D::set_a(const Vector2 &p_a) {
- a=p_a;
+ a = p_a;
_update_shape();
-
}
Vector2 SegmentShape2D::get_a() const {
return a;
}
-void SegmentShape2D::set_b(const Vector2& p_b) {
+void SegmentShape2D::set_b(const Vector2 &p_b) {
- b=p_b;
+ b = p_b;
_update_shape();
-
}
Vector2 SegmentShape2D::get_b() const {
return b;
}
-void SegmentShape2D::draw(const RID& p_to_rid,const Color& p_color) {
+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);
+ VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3);
}
-Rect2 SegmentShape2D::get_rect() const{
+Rect2 SegmentShape2D::get_rect() const {
Rect2 rect;
- rect.pos=a;
+ rect.pos = a;
rect.expand_to(b);
return rect;
-
}
-
-
-
void SegmentShape2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_a","a"),&SegmentShape2D::set_a);
- ClassDB::bind_method(D_METHOD("get_a"),&SegmentShape2D::get_a);
-
- ClassDB::bind_method(D_METHOD("set_b","b"),&SegmentShape2D::set_b);
- ClassDB::bind_method(D_METHOD("get_b"),&SegmentShape2D::get_b);
-
+ ClassDB::bind_method(D_METHOD("set_a", "a"), &SegmentShape2D::set_a);
+ ClassDB::bind_method(D_METHOD("get_a"), &SegmentShape2D::get_a);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),"set_a","get_a") ;
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"b"),"set_b","get_b") ;
+ ClassDB::bind_method(D_METHOD("set_b", "b"), &SegmentShape2D::set_b);
+ ClassDB::bind_method(D_METHOD("get_b"), &SegmentShape2D::get_b);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "a"), "set_a", "get_a");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "b"), "set_b", "get_b");
}
-SegmentShape2D::SegmentShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) {
+SegmentShape2D::SegmentShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) {
- a=Vector2();
- b=Vector2(0,10);
+ a = Vector2();
+ b = Vector2(0, 10);
_update_shape();
}
-
////////////////////////////////////////////////////////////
-
void RayShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),length);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), length);
emit_changed();
-
}
+void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-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);
+ 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));
+ 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++)
+ 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());
-
-
-
+ 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);
+ rect.pos = Vector2();
+ rect.expand_to(Vector2(0, length));
+ rect = rect.grow(0.707 * 4);
return rect;
}
-
void RayShape2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_length","length"),&RayShape2D::set_length);
- ClassDB::bind_method(D_METHOD("get_length"),&RayShape2D::get_length);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),"set_length","get_length") ;
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
}
void RayShape2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
_update_shape();
}
real_t RayShape2D::get_length() const {
return length;
-
-
}
-RayShape2D::RayShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) {
+RayShape2D::RayShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) {
- length=20;
+ length = 20;
_update_shape();
}