You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -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() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a);
|
||||
ObjectTypeDB::bind_method(_MD("get_a"),&SegmentShape2D::get_a);
|
||||
ObjectTypeDB::bind_method(_MD("set_a", "a"), &SegmentShape2D::set_a);
|
||||
ObjectTypeDB::bind_method(_MD("get_a"), &SegmentShape2D::get_a);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_b","b"),&SegmentShape2D::set_b);
|
||||
ObjectTypeDB::bind_method(_MD("get_b"),&SegmentShape2D::get_b);
|
||||
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),_SCS("set_a"),_SCS("get_a") );
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"b"),_SCS("set_b"),_SCS("get_b") );
|
||||
ObjectTypeDB::bind_method(_MD("set_b", "b"), &SegmentShape2D::set_b);
|
||||
ObjectTypeDB::bind_method(_MD("get_b"), &SegmentShape2D::get_b);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "a"), _SCS("set_a"), _SCS("get_a"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "b"), _SCS("set_b"), _SCS("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() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length);
|
||||
ObjectTypeDB::bind_method(_MD("get_length"),&RayShape2D::get_length);
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),_SCS("set_length"),_SCS("get_length") );
|
||||
ObjectTypeDB::bind_method(_MD("set_length", "length"), &RayShape2D::set_length);
|
||||
ObjectTypeDB::bind_method(_MD("get_length"), &RayShape2D::get_length);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), _SCS("set_length"), _SCS("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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user