mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-05 05:39:18 -05:00
Review new functions formatting
This commit is contained in:
@ -449,7 +449,7 @@ RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)
|
||||
|
||||
// Clamp the magnitude of the vector between two
|
||||
// given min and max values
|
||||
RMAPI Vector2 Vector2ClampValue(Vector2 v, float minMag, float maxMag)
|
||||
RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -458,15 +458,15 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float minMag, float maxMag)
|
||||
{
|
||||
length = sqrtf(length);
|
||||
|
||||
if (length < minMag)
|
||||
if (length < min)
|
||||
{
|
||||
float scale = minMag / length;
|
||||
float scale = min/length;
|
||||
result.x = v.x*scale;
|
||||
result.y = v.y*scale;
|
||||
}
|
||||
else if (length > maxMag)
|
||||
else if (length > max)
|
||||
{
|
||||
float scale = maxMag / length;
|
||||
float scale = max/length;
|
||||
result.x = v.x*scale;
|
||||
result.y = v.y*scale;
|
||||
}
|
||||
@ -993,22 +993,19 @@ RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r)
|
||||
Vector3 result = { 0 };
|
||||
|
||||
float dot = v.x*n.x + v.y*n.y + v.z*n.z;
|
||||
|
||||
float d = 1.0f - r*r*(1.0f - dot*dot);
|
||||
if (d < 0.0f)
|
||||
{
|
||||
// Total internal reflection
|
||||
return result;
|
||||
}
|
||||
else
|
||||
|
||||
if (d >= 0.0f)
|
||||
{
|
||||
d = sqrtf(d);
|
||||
v.x = r*v.x - (r*dot + d)*n.x;
|
||||
v.y = r*v.y - (r*dot + d)*n.y;
|
||||
v.z = r*v.z - (r*dot + d)*n.z;
|
||||
|
||||
return result;
|
||||
result = v;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user