Review new functions formatting

This commit is contained in:
Ray 2022-04-23 23:24:13 +02:00
parent 52befa0815
commit be3ae71aec

View file

@ -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;
}
//----------------------------------------------------------------------------------