aboutsummaryrefslogtreecommitdiff
path: root/scene/resources/sphere_shape.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2017-03-05 16:44:50 +0100
committerRémi Verschelde2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/resources/sphere_shape.cpp
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
downloadgodot-5dbf180.tar.gz
godot-5dbf180.tar.zst
godot-5dbf180.zip
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/sphere_shape.cpp')
-rw-r--r--scene/resources/sphere_shape.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp
index 302962592..c242e748a 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape.cpp
@@ -31,24 +31,23 @@
Vector<Vector3> SphereShape::_gen_debug_mesh_lines() {
- float r=get_radius();
+ float r = get_radius();
Vector<Vector3> points;
- for(int i=0;i<=360;i++) {
+ for (int i = 0; i <= 360; i++) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
-
- points.push_back(Vector3(a.x,0,a.y));
- points.push_back(Vector3(b.x,0,b.y));
- points.push_back(Vector3(0,a.x,a.y));
- points.push_back(Vector3(0,b.x,b.y));
- points.push_back(Vector3(a.x,a.y,0));
- points.push_back(Vector3(b.x,b.y,0));
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)i + 1);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
+ points.push_back(Vector3(a.x, 0, a.y));
+ points.push_back(Vector3(b.x, 0, b.y));
+ points.push_back(Vector3(0, a.x, a.y));
+ points.push_back(Vector3(0, b.x, b.y));
+ points.push_back(Vector3(a.x, a.y, 0));
+ points.push_back(Vector3(b.x, b.y, 0));
}
return points;
@@ -56,12 +55,12 @@ Vector<Vector3> SphereShape::_gen_debug_mesh_lines() {
void SphereShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),radius);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), radius);
}
void SphereShape::set_radius(float p_radius) {
- radius=p_radius;
+ radius = p_radius;
_update_shape();
notify_change_to_owners();
_change_notify("radius");
@@ -72,17 +71,16 @@ float SphereShape::get_radius() const {
return radius;
}
-
void SphereShape::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius","radius"),&SphereShape::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"),&SphereShape::get_radius);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0,4096,0.01"), "set_radius", "get_radius");
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape::get_radius);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_radius", "get_radius");
}
-SphereShape::SphereShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) {
+SphereShape::SphereShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) {
set_radius(1.0);
}