mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Fix many issues reported by clang-tidy (#7189)
* Fix many issues reported by clang-tidy We have many issues in code related to some performance to float <-> double. Clang-tidy reported it in performance-type-promotion-in-math-fn I fixed many of them. It's not ready for a promote to blocking Also fix some value which should be const-ref
This commit is contained in:
parent
e98fd934ce
commit
2481ea27ce
14 changed files with 61 additions and 52 deletions
|
@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
|
||||
#include "mapgen.h"
|
||||
#include <cmath>
|
||||
#include "voxel.h"
|
||||
#include "noise.h"
|
||||
#include "mapblock.h"
|
||||
|
@ -306,45 +307,45 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z)
|
|||
break;
|
||||
case 6: // 3D "Christmas Tree"
|
||||
// Altering the formula here is necessary to avoid division by zero
|
||||
if (fabs(oz) < 0.000000001f) {
|
||||
if (std::fabs(oz) < 0.000000001f) {
|
||||
nx = ox * ox - oy * oy - oz * oz + cx;
|
||||
ny = 2.0f * oy * ox + cy;
|
||||
nz = 4.0f * oz * ox + cz;
|
||||
} else {
|
||||
float a = (2.0f * ox) / (sqrt(oy * oy + oz * oz));
|
||||
float a = (2.0f * ox) / (std::sqrt(oy * oy + oz * oz));
|
||||
nx = ox * ox - oy * oy - oz * oz + cx;
|
||||
ny = a * (oy * oy - oz * oz) + cy;
|
||||
nz = a * 2.0f * oy * oz + cz;
|
||||
}
|
||||
break;
|
||||
case 7: // 3D "Mandelbulb"
|
||||
if (fabs(oy) < 0.000000001f) {
|
||||
if (std::fabs(oy) < 0.000000001f) {
|
||||
nx = ox * ox - oz * oz + cx;
|
||||
ny = cy;
|
||||
nz = -2.0f * oz * sqrt(ox * ox) + cz;
|
||||
nz = -2.0f * oz * std::sqrt(ox * ox) + cz;
|
||||
} else {
|
||||
float a = 1.0f - (oz * oz) / (ox * ox + oy * oy);
|
||||
nx = (ox * ox - oy * oy) * a + cx;
|
||||
ny = 2.0f * ox * oy * a + cy;
|
||||
nz = -2.0f * oz * sqrt(ox * ox + oy * oy) + cz;
|
||||
nz = -2.0f * oz * std::sqrt(ox * ox + oy * oy) + cz;
|
||||
}
|
||||
break;
|
||||
case 8: // 3D "Cosine Mandelbulb"
|
||||
if (fabs(oy) < 0.000000001f) {
|
||||
if (std::fabs(oy) < 0.000000001f) {
|
||||
nx = 2.0f * ox * oz + cx;
|
||||
ny = 4.0f * oy * oz + cy;
|
||||
nz = oz * oz - ox * ox - oy * oy + cz;
|
||||
} else {
|
||||
float a = (2.0f * oz) / sqrt(ox * ox + oy * oy);
|
||||
float a = (2.0f * oz) / std::sqrt(ox * ox + oy * oy);
|
||||
nx = (ox * ox - oy * oy) * a + cx;
|
||||
ny = 2.0f * ox * oy * a + cy;
|
||||
nz = oz * oz - ox * ox - oy * oy + cz;
|
||||
}
|
||||
break;
|
||||
case 9: // 4D "Mandelbulb"
|
||||
float rxy = sqrt(ox * ox + oy * oy);
|
||||
float rxyz = sqrt(ox * ox + oy * oy + oz * oz);
|
||||
if (fabs(ow) < 0.000000001f && fabs(oz) < 0.000000001f) {
|
||||
float rxy = std::sqrt(ox * ox + oy * oy);
|
||||
float rxyz = std::sqrt(ox * ox + oy * oy + oz * oz);
|
||||
if (std::fabs(ow) < 0.000000001f && std::fabs(oz) < 0.000000001f) {
|
||||
nx = (ox * ox - oy * oy) + cx;
|
||||
ny = 2.0f * ox * oy + cy;
|
||||
nz = -2.0f * rxy * oz + cz;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue