mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 19:38:15 +00:00
[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:

committed by
GitHub

parent
27645e16ab
commit
c133fee286
@@ -494,19 +494,19 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
|
|||||||
{
|
{
|
||||||
length = sqrtf(length);
|
length = sqrtf(length);
|
||||||
|
|
||||||
|
float scale = 1; // By default, 1 as the neutral element.
|
||||||
if (length < min)
|
if (length < min)
|
||||||
{
|
{
|
||||||
float scale = min/length;
|
scale = min/length;
|
||||||
result.x = v.x*scale;
|
|
||||||
result.y = v.y*scale;
|
|
||||||
}
|
}
|
||||||
else if (length > max)
|
else if (length > max)
|
||||||
{
|
{
|
||||||
float scale = max/length;
|
scale = max/length;
|
||||||
|
}
|
||||||
|
|
||||||
result.x = v.x*scale;
|
result.x = v.x*scale;
|
||||||
result.y = v.y*scale;
|
result.y = v.y*scale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1080,21 +1080,20 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
|
|||||||
{
|
{
|
||||||
length = sqrtf(length);
|
length = sqrtf(length);
|
||||||
|
|
||||||
|
float scale = 1; // By default, 1 as the neutral element.
|
||||||
if (length < min)
|
if (length < min)
|
||||||
{
|
{
|
||||||
float scale = min/length;
|
scale = min/length;
|
||||||
result.x = v.x*scale;
|
|
||||||
result.y = v.y*scale;
|
|
||||||
result.z = v.z*scale;
|
|
||||||
}
|
}
|
||||||
else if (length > max)
|
else if (length > max)
|
||||||
{
|
{
|
||||||
float scale = max/length;
|
scale = max/length;
|
||||||
|
}
|
||||||
|
|
||||||
result.x = v.x*scale;
|
result.x = v.x*scale;
|
||||||
result.y = v.y*scale;
|
result.y = v.y*scale;
|
||||||
result.z = v.z*scale;
|
result.z = v.z*scale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user