mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user