Skip to content

Commit

Permalink
Merge pull request ddnet#9494 from Chairn/pr_cbrt
Browse files Browse the repository at this point in the history
Replace Cubicroot function with std::cbrt
  • Loading branch information
Robyt3 authored Jan 8, 2025
2 parents a518529 + 0666d4c commit 694b1d8
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/game/client/render_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ const CEnvPointBezier *CMapBasedEnvelopePointAccess::GetBezier(int Index) const
return nullptr;
}

static double CubicRoot(double x)
{
if(x == 0.0)
return 0.0;
else if(x < 0.0)
return -std::exp(std::log(-x) / 3.0);
else
return std::exp(std::log(x) / 3.0);
}

static float SolveBezier(float x, float p0, float p1, float p2, float p3)
{
const double x3 = -p0 + 3.0 * p1 - 3.0 * p2 + p3;
Expand Down Expand Up @@ -193,12 +183,12 @@ static float SolveBezier(float x, float p0, float p1, float p2, float p3)
{
// only one 'real' solution
const double s = std::sqrt(D);
return CubicRoot(s - q) - CubicRoot(s + q) - sub;
return std::cbrt(s - q) - std::cbrt(s + q) - sub;
}
else if(D == 0.0)
{
// one single, one double solution or triple solution
const double s = CubicRoot(-q);
const double s = std::cbrt(-q);
const double t = 2.0 * s - sub;

if(0.0 <= t && t <= 1.0001)
Expand Down

0 comments on commit 694b1d8

Please sign in to comment.