[Mono] Rename LinearInterpolate to Lerp
This commit is contained in:
parent
10273e9de6
commit
ad3c3e1bbb
5 changed files with 51 additions and 23 deletions
|
@ -306,16 +306,26 @@ namespace Godot
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color LinearInterpolate(Color c, float t)
|
public Color Lerp(Color to, float weight)
|
||||||
{
|
{
|
||||||
var res = this;
|
return new Color
|
||||||
|
(
|
||||||
|
Mathf.Lerp(r, to.r, weight),
|
||||||
|
Mathf.Lerp(g, to.g, weight),
|
||||||
|
Mathf.Lerp(b, to.b, weight),
|
||||||
|
Mathf.Lerp(a, to.a, weight)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
res.r += t * (c.r - r);
|
public Color Lerp(Color to, Color weight)
|
||||||
res.g += t * (c.g - g);
|
{
|
||||||
res.b += t * (c.b - b);
|
return new Color
|
||||||
res.a += t * (c.a - a);
|
(
|
||||||
|
Mathf.Lerp(r, to.r, weight.r),
|
||||||
return res;
|
Mathf.Lerp(g, to.g, weight.g),
|
||||||
|
Mathf.Lerp(b, to.b, weight.b),
|
||||||
|
Mathf.Lerp(a, to.a, weight.a)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint ToAbgr32()
|
public uint ToAbgr32()
|
||||||
|
|
|
@ -104,8 +104,8 @@ namespace Godot
|
||||||
Vector3 destinationLocation = transform.origin;
|
Vector3 destinationLocation = transform.origin;
|
||||||
|
|
||||||
var interpolated = new Transform();
|
var interpolated = new Transform();
|
||||||
interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c));
|
interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.Lerp(destinationScale, c));
|
||||||
interpolated.origin = sourceLocation.LinearInterpolate(destinationLocation, c);
|
interpolated.origin = sourceLocation.Lerp(destinationLocation, c);
|
||||||
|
|
||||||
return interpolated;
|
return interpolated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace Godot
|
||||||
if (dot > 0.9995f)
|
if (dot > 0.9995f)
|
||||||
{
|
{
|
||||||
// Linearly interpolate to avoid numerical precision issues
|
// Linearly interpolate to avoid numerical precision issues
|
||||||
v = v1.LinearInterpolate(v2, c).Normalized();
|
v = v1.Lerp(v2, c).Normalized();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -186,8 +186,8 @@ namespace Godot
|
||||||
Vector2 p2 = m.origin;
|
Vector2 p2 = m.origin;
|
||||||
|
|
||||||
// Construct matrix
|
// Construct matrix
|
||||||
var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c));
|
var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.Lerp(p2, c));
|
||||||
Vector2 scale = s1.LinearInterpolate(s2, c);
|
Vector2 scale = s1.Lerp(s2, c);
|
||||||
res.x *= scale;
|
res.x *= scale;
|
||||||
res.y *= scale;
|
res.y *= scale;
|
||||||
|
|
||||||
|
|
|
@ -186,14 +186,22 @@ namespace Godot
|
||||||
return x * x + y * y;
|
return x * x + y * y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 LinearInterpolate(Vector2 b, real_t t)
|
public Vector2 Lerp(Vector2 to, real_t weight)
|
||||||
{
|
{
|
||||||
var res = this;
|
return new Vector2
|
||||||
|
(
|
||||||
|
Mathf.Lerp(x, to.x, weight),
|
||||||
|
Mathf.Lerp(y, to.y, weight)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
res.x += t * (b.x - x);
|
public Vector2 Lerp(Vector2 to, Vector2 weight)
|
||||||
res.y += t * (b.y - y);
|
{
|
||||||
|
return new Vector2
|
||||||
return res;
|
(
|
||||||
|
Mathf.Lerp(x, to.x, weight.x),
|
||||||
|
Mathf.Lerp(y, to.y, weight.y)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 MoveToward(Vector2 to, real_t delta)
|
public Vector2 MoveToward(Vector2 to, real_t delta)
|
||||||
|
|
|
@ -184,13 +184,23 @@ namespace Godot
|
||||||
return x2 + y2 + z2;
|
return x2 + y2 + z2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 LinearInterpolate(Vector3 b, real_t t)
|
public Vector3 Lerp(Vector3 to, real_t weight)
|
||||||
{
|
{
|
||||||
return new Vector3
|
return new Vector3
|
||||||
(
|
(
|
||||||
x + t * (b.x - x),
|
Mathf.Lerp(x, to.x, weight),
|
||||||
y + t * (b.y - y),
|
Mathf.Lerp(y, to.y, weight),
|
||||||
z + t * (b.z - z)
|
Mathf.Lerp(z, to.z, weight)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 Lerp(Vector3 to, Vector3 weight)
|
||||||
|
{
|
||||||
|
return new Vector3
|
||||||
|
(
|
||||||
|
Mathf.Lerp(x, to.x, weight.x),
|
||||||
|
Mathf.Lerp(y, to.y, weight.y),
|
||||||
|
Mathf.Lerp(z, to.z, weight.z)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue