diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-04-03 05:50:40 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-01-09 03:47:14 -0500 |
commit | 1d5042c9e265219dec8da7311879f12ef3ef698b (patch) | |
tree | 9456ab509bbcaf26cad8dca32dbe18a3cca9277d /servers/rendering_server.cpp | |
parent | 98ccaa1bad97bdb83b2afd6a4df6f7a392745592 (diff) | |
download | redot-engine-1d5042c9e265219dec8da7311879f12ef3ef698b.tar.gz |
Use Math_TAU and deg2rad/rad2deg in more places and optimize code
Diffstat (limited to 'servers/rendering_server.cpp')
-rw-r--r-- | servers/rendering_server.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index b87171dc5e..85fc6a2ea2 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -242,22 +242,24 @@ RID RenderingServer::_make_test_cube() { RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) { Vector<Vector3> vertices; Vector<Vector3> normals; + const double lat_step = Math_TAU / p_lats; + const double lon_step = Math_TAU / p_lons; for (int i = 1; i <= p_lats; i++) { - double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats); + double lat0 = lat_step * (i - 1) - Math_TAU / 4; double z0 = Math::sin(lat0); double zr0 = Math::cos(lat0); - double lat1 = Math_PI * (-0.5 + (double)i / p_lats); + double lat1 = lat_step * i - Math_TAU / 4; double z1 = Math::sin(lat1); double zr1 = Math::cos(lat1); for (int j = p_lons; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons; + double lng0 = lon_step * (j - 1); double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); - double lng1 = 2 * Math_PI * (double)(j) / p_lons; + double lng1 = lon_step * j; double x1 = Math::cos(lng1); double y1 = Math::sin(lng1); |