[raymath.h] Small code refactor (#3753)

* [raymath.h] Small refactor to avoid duplicated code

* Fixing some blank spaces to match same syle convention
This commit is contained in:
Idir Carlos Aliane
2024-01-22 19:48:18 +01:00
committed by GitHub
parent 27645e16ab
commit c133fee286

View File

@@ -494,19 +494,19 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
{
length = sqrtf(length);
float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
float scale = min/length;
result.x = v.x*scale;
result.y = v.y*scale;
scale = min/length;
}
else if (length > max)
{
float scale = max/length;
scale = max/length;
}
result.x = v.x*scale;
result.y = v.y*scale;
}
}
return result;
}
@@ -1080,21 +1080,20 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
{
length = sqrtf(length);
float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
float scale = min/length;
result.x = v.x*scale;
result.y = v.y*scale;
result.z = v.z*scale;
scale = min/length;
}
else if (length > max)
{
float scale = max/length;
scale = max/length;
}
result.x = v.x*scale;
result.y = v.y*scale;
result.z = v.z*scale;
}
}
return result;
}