diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2021-02-01 20:55:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-01 20:55:25 +0100 |
| commit | d2e121650476af0a91bc24ea38253428e97f9695 (patch) | |
| tree | 22b120a76f0430faa9e4a9383f7c0c83557616b6 /editor/plugins/editor_preview_plugins.cpp | |
| parent | 264504d76d2c1ea374d5508e6a2634e2b5002d84 (diff) | |
| parent | 1d5042c9e265219dec8da7311879f12ef3ef698b (diff) | |
| download | redot-engine-d2e121650476af0a91bc24ea38253428e97f9695.tar.gz | |
Merge pull request #37547 from aaronfranke/tau
Use Math_TAU and deg2rad/etc in more places and optimize code
Diffstat (limited to 'editor/plugins/editor_preview_plugins.cpp')
| -rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index bdf88b82e4..63bb785c5e 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -382,7 +382,9 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { int lats = 32; int lons = 32; - float radius = 1.0; + const double lat_step = Math_TAU / lats; + const double lon_step = Math_TAU / lons; + real_t radius = 1.0; Vector<Vector3> vertices; Vector<Vector3> normals; @@ -391,20 +393,20 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5); for (int i = 1; i <= lats; i++) { - double lat0 = Math_PI * (-0.5 + (double)(i - 1) / 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 / lats); + double lat1 = lat_step * i - Math_TAU / 4; double z1 = Math::sin(lat1); double zr1 = Math::cos(lat1); for (int j = lons; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / lons; + double lng0 = lon_step * (j - 1); double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); - double lng1 = 2 * Math_PI * (double)(j) / lons; + double lng1 = lon_step * j; double x1 = Math::cos(lng1); double y1 = Math::sin(lng1); |
