Merge pull request #1446 from cedeel/patch-1
Made it compile with clang
This commit is contained in:
commit
b9b45e8287
@ -260,7 +260,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
|
|||||||
void cEntity::SetYawFromSpeed(void)
|
void cEntity::SetYawFromSpeed(void)
|
||||||
{
|
{
|
||||||
const double EPS = 0.0000001;
|
const double EPS = 0.0000001;
|
||||||
if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS))
|
if ((std::abs(m_Speed.x) < EPS) && (std::abs(m_Speed.z) < EPS))
|
||||||
{
|
{
|
||||||
// atan2() may overflow or is undefined, pick any number
|
// atan2() may overflow or is undefined, pick any number
|
||||||
SetYaw(0);
|
SetYaw(0);
|
||||||
@ -277,7 +277,7 @@ void cEntity::SetPitchFromSpeed(void)
|
|||||||
{
|
{
|
||||||
const double EPS = 0.0000001;
|
const double EPS = 0.0000001;
|
||||||
double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
|
double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
|
||||||
if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS))
|
if ((std::abs(xz) < EPS) && (std::abs(m_Speed.y) < EPS))
|
||||||
{
|
{
|
||||||
// atan2() may overflow or is undefined, pick any number
|
// atan2() may overflow or is undefined, pick any number
|
||||||
SetPitch(0);
|
SetPitch(0);
|
||||||
|
@ -876,7 +876,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
|
|||||||
Vector3d Distance = MinecartCollisionCallback.GetCollidedEntityPosition() - Vector3d(GetPosX(), 0, GetPosZ());
|
Vector3d Distance = MinecartCollisionCallback.GetCollidedEntityPosition() - Vector3d(GetPosX(), 0, GetPosZ());
|
||||||
|
|
||||||
// Prevent division by small numbers
|
// Prevent division by small numbers
|
||||||
if (abs(Distance.z) < 0.001)
|
if (std::abs(Distance.z) < 0.001)
|
||||||
{
|
{
|
||||||
Distance.z = 0.001;
|
Distance.z = 0.001;
|
||||||
}
|
}
|
||||||
@ -925,7 +925,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
|
|||||||
Vector3d Distance = MinecartCollisionCallback.GetCollidedEntityPosition() - Vector3d(GetPosX(), 0, GetPosZ());
|
Vector3d Distance = MinecartCollisionCallback.GetCollidedEntityPosition() - Vector3d(GetPosX(), 0, GetPosZ());
|
||||||
|
|
||||||
// Prevent division by small numbers
|
// Prevent division by small numbers
|
||||||
if (abs(Distance.z) < 0.001)
|
if (std::abs(Distance.z) < 0.001)
|
||||||
{
|
{
|
||||||
Distance.z = 0.001;
|
Distance.z = 0.001;
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc)
|
|||||||
float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
|
float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
|
||||||
float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
|
float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
|
||||||
float n4 = m_Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
|
float n4 = m_Noise2.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
|
||||||
if ((abs(n1 + n3) * abs(n2 + n4)) > m_Threshold)
|
if ((std::abs(n1 + n3) * std::abs(n2 + n4)) > m_Threshold)
|
||||||
{
|
{
|
||||||
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
|
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT
|
|||||||
m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
|
m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
|
||||||
for (size_t i = 0; i < ARRAYCOUNT(Height); i++)
|
for (size_t i = 0; i < ARRAYCOUNT(Height); i++)
|
||||||
{
|
{
|
||||||
Height[i] = abs(Height[i]) * m_HeightAmplification + 1;
|
Height[i] = std::abs(Height[i]) * m_HeightAmplification + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify the noise by height data:
|
// Modify the noise by height data:
|
||||||
@ -395,7 +395,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
|
|||||||
for (int x = 0; x < 17; x += UPSCALE_X)
|
for (int x = 0; x < 17; x += UPSCALE_X)
|
||||||
{
|
{
|
||||||
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
|
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
|
||||||
NOISE_DATATYPE val = abs(m_Noise1.CubicNoise2D(NoiseX / 5, NoiseZ / 5)) * m_HeightAmplification + 1;
|
NOISE_DATATYPE val = std::abs(m_Noise1.CubicNoise2D(NoiseX / 5, NoiseZ / 5)) * m_HeightAmplification + 1;
|
||||||
Height[x + 17 * z] = val * val * val;
|
Height[x + 17 * z] = val * val * val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ bool cLineBlockTracer::MoveToNextBlock(void)
|
|||||||
dirY,
|
dirY,
|
||||||
dirZ,
|
dirZ,
|
||||||
} Direction = dirNONE;
|
} Direction = dirNONE;
|
||||||
if (abs(m_DiffX) > EPS)
|
if (std::abs(m_DiffX) > EPS)
|
||||||
{
|
{
|
||||||
double DestX = (m_DirX > 0) ? (m_CurrentX + 1) : m_CurrentX;
|
double DestX = (m_DirX > 0) ? (m_CurrentX + 1) : m_CurrentX;
|
||||||
Coeff = (DestX - m_StartX) / m_DiffX;
|
Coeff = (DestX - m_StartX) / m_DiffX;
|
||||||
@ -155,7 +155,7 @@ bool cLineBlockTracer::MoveToNextBlock(void)
|
|||||||
Direction = dirX;
|
Direction = dirX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abs(m_DiffY) > EPS)
|
if (std::abs(m_DiffY) > EPS)
|
||||||
{
|
{
|
||||||
double DestY = (m_DirY > 0) ? (m_CurrentY + 1) : m_CurrentY;
|
double DestY = (m_DirY > 0) ? (m_CurrentY + 1) : m_CurrentY;
|
||||||
double CoeffY = (DestY - m_StartY) / m_DiffY;
|
double CoeffY = (DestY - m_StartY) / m_DiffY;
|
||||||
@ -165,7 +165,7 @@ bool cLineBlockTracer::MoveToNextBlock(void)
|
|||||||
Direction = dirY;
|
Direction = dirY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abs(m_DiffZ) > EPS)
|
if (std::abs(m_DiffZ) > EPS)
|
||||||
{
|
{
|
||||||
double DestZ = (m_DirZ > 0) ? (m_CurrentZ + 1) : m_CurrentZ;
|
double DestZ = (m_DirZ > 0) ? (m_CurrentZ + 1) : m_CurrentZ;
|
||||||
double CoeffZ = (DestZ - m_StartZ) / m_DiffZ;
|
double CoeffZ = (DestZ - m_StartZ) / m_DiffZ;
|
||||||
|
@ -250,7 +250,7 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float
|
|||||||
// float linx, liny;
|
// float linx, liny;
|
||||||
|
|
||||||
float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2);
|
float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2);
|
||||||
if (abs(d)<0.001) {return 0;}
|
if (std::abs(d)<0.001) {return 0;}
|
||||||
float AB=((y0-y2)*(x3-x2)-(x0-x2)*(y3-y2))/d;
|
float AB=((y0-y2)*(x3-x2)-(x0-x2)*(y3-y2))/d;
|
||||||
if (AB>=0.0 && AB<=1.0)
|
if (AB>=0.0 && AB<=1.0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user