Review new functions formatting
This commit is contained in:
parent
52befa0815
commit
be3ae71aec
1 changed files with 42 additions and 45 deletions
|
@ -449,7 +449,7 @@ RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)
|
||||||
|
|
||||||
// Clamp the magnitude of the vector between two
|
// Clamp the magnitude of the vector between two
|
||||||
// given min and max values
|
// 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 };
|
Vector2 result = { 0 };
|
||||||
|
|
||||||
|
@ -458,15 +458,15 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float minMag, float maxMag)
|
||||||
{
|
{
|
||||||
length = sqrtf(length);
|
length = sqrtf(length);
|
||||||
|
|
||||||
if (length < minMag)
|
if (length < min)
|
||||||
{
|
{
|
||||||
float scale = minMag / length;
|
float scale = min/length;
|
||||||
result.x = v.x*scale;
|
result.x = v.x*scale;
|
||||||
result.y = v.y*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.x = v.x*scale;
|
||||||
result.y = v.y*scale;
|
result.y = v.y*scale;
|
||||||
}
|
}
|
||||||
|
@ -993,22 +993,19 @@ RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r)
|
||||||
Vector3 result = { 0 };
|
Vector3 result = { 0 };
|
||||||
|
|
||||||
float dot = v.x*n.x + v.y*n.y + v.z*n.z;
|
float dot = v.x*n.x + v.y*n.y + v.z*n.z;
|
||||||
|
|
||||||
float d = 1.0f - r*r*(1.0f - dot*dot);
|
float d = 1.0f - r*r*(1.0f - dot*dot);
|
||||||
if (d < 0.0f)
|
|
||||||
{
|
if (d >= 0.0f)
|
||||||
// Total internal reflection
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
d = sqrtf(d);
|
d = sqrtf(d);
|
||||||
v.x = r*v.x - (r*dot + d)*n.x;
|
v.x = r*v.x - (r*dot + d)*n.x;
|
||||||
v.y = r*v.y - (r*dot + d)*n.y;
|
v.y = r*v.y - (r*dot + d)*n.y;
|
||||||
v.z = r*v.z - (r*dot + d)*n.z;
|
v.z = r*v.z - (r*dot + d)*n.z;
|
||||||
|
|
||||||
return result;
|
result = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue