mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Add Lerp() method to script Rotation class
This commit is contained in:
parent
6ef9675bcb
commit
f1c1fd2f63
6 changed files with 24 additions and 8 deletions
|
@ -28,6 +28,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
|
|||
- You must use this version: https://github.com/TombEngine/Resources/raw/refs/heads/main/Wad2%20Objects/Interactables/TEN_Waterfall_Emitter.wad2
|
||||
|
||||
### Lua API changes
|
||||
* Added Lerp() function to the Rotation object to allow linear interpolation between rotations.
|
||||
* Added diary module.
|
||||
* Added Effects.EmitAirBubble() function to spawn air bubbles.
|
||||
* Added additional arguments for Sprite object slot and starting rotation value for EmitParticle function.
|
||||
|
|
|
@ -456,6 +456,7 @@ constexpr char ScriptReserved_StaticShatter[] = "Shatter";
|
|||
|
||||
constexpr char ScriptReserved_Rotation[] = "Rotation";
|
||||
constexpr char ScriptReserved_RotationDirection[] = "Direction";
|
||||
constexpr char ScriptReserved_RotationLerp[] = "Lerp";
|
||||
|
||||
// Vec2
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ using namespace TEN::Math;
|
|||
|
||||
namespace TEN::Scripting
|
||||
{
|
||||
/// Represents a degree-based 3D rotation.
|
||||
/// Represents a 3D rotation.
|
||||
// All angle components are in degrees clamped to the range [0.0, 360.0].
|
||||
// @tenprimitive Rotation
|
||||
// @pragma nostrip
|
||||
|
@ -21,11 +21,13 @@ namespace TEN::Scripting
|
|||
// Register type.
|
||||
parent.new_usertype<Rotation>(
|
||||
ScriptReserved_Rotation,
|
||||
ctors(),
|
||||
sol::call_constructor, ctors(),
|
||||
ctors(), sol::call_constructor, ctors(),
|
||||
|
||||
// Meta functions
|
||||
sol::meta_function::to_string, &Rotation::ToString,
|
||||
|
||||
// Utilities
|
||||
ScriptReserved_RotationLerp, &Rotation::Lerp,
|
||||
ScriptReserved_RotationDirection, &Rotation::Direction,
|
||||
|
||||
/// (float) X angle component in degrees.
|
||||
|
@ -68,6 +70,17 @@ namespace TEN::Scripting
|
|||
z = TO_DEGREES(eulers.z);
|
||||
}
|
||||
|
||||
/// Get the linearly interpolated Rotation between this Rotation and the input Rotation according to the input alpha.
|
||||
// @tparam Rotation rot Interpolation target.
|
||||
// @tparam float alpha Interpolation alpha in the range [0, 1].
|
||||
// @treturn Rotation Linearly interpolated rotation.
|
||||
Rotation Rotation::Lerp(const Rotation& rot, float alpha) const
|
||||
{
|
||||
auto orientFrom = ToEulerAngles();
|
||||
auto orientTo = rot.ToEulerAngles();
|
||||
return Rotation(EulerAngles::Lerp(orientFrom, orientTo, alpha));
|
||||
}
|
||||
|
||||
/// Get the normalized direction vector of this Rotation.
|
||||
// @function Direction
|
||||
// @treturn Vec3 Normalized direction vector.
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace TEN::Scripting
|
|||
|
||||
// Utilities
|
||||
|
||||
Rotation Lerp(const Rotation& rot, float alpha) const;
|
||||
Vec3 Direction() const;
|
||||
|
||||
// Converters
|
||||
|
|
|
@ -148,9 +148,9 @@ Vec2 Vec2::Rotate(float rot) const
|
|||
|
||||
/// Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha.
|
||||
// @function Vec2:Lerp
|
||||
// @tparam Vec2 vector Target interpolation vector.
|
||||
// @tparam Vec2 vector Interpolation target.
|
||||
// @tparam float alpha Interpolation alpha in the range [0, 1].
|
||||
// @treturn Vec2 Linearly interpolated vector
|
||||
// @treturn Vec2 Linearly interpolated vector.
|
||||
Vec2 Vec2::Lerp(const Vec2& vector, float alpha) const
|
||||
{
|
||||
auto vector0 = ToVector2();
|
||||
|
|
|
@ -150,9 +150,9 @@ Vec3 Vec3::Rotate(const Rotation& rot) const
|
|||
|
||||
/// Get the linearly interpolated Vec3 between this Vec3 and the input Vec3 according to the input interpolation alpha.
|
||||
// @function Vec3:Lerp
|
||||
// @tparam Vec3 vector Target interpolation vector.
|
||||
// @tparam Vec3 vector Interpolation target.
|
||||
// @tparam float alpha Interpolation alpha in the range [0, 1].
|
||||
// @treturn Vec3 Linearly interpolated vector
|
||||
// @treturn Vec3 Linearly interpolated vector.
|
||||
Vec3 Vec3::Lerp(const Vec3& vector, float alpha) const
|
||||
{
|
||||
auto vector0 = ToVector3();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue