godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Expand lerp function to include Transform2D and Transform3D #10579

Closed TheYellowArchitect closed 2 months ago

TheYellowArchitect commented 3 months ago

Describe the project you are working on

Online action game with rollback

Describe the problem or limitation you are having in your project

Supported types: int, float, Vector2, Vector3, Vector4, Color, Quaternion, Basis.

It doesn't work with Transform3D and Transform2D. But Transform2D and Transform3D have the following lerp functions which should be invoked for their type:

Transform3D interpolate_with(xform: Transform3D, weight: float)

https://docs.godotengine.org/en/stable/classes/class_transform3d.html#class-transform3d-method-interpolate-with

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It fills a minor oversight of the Variant types valid for this function.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

lerp also includes Transform2D and Transform3D

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, by writing your own singleton lerp wrapper class. Not important really, but would make the code cleaner by cutting off 1 class.

Is there a reason why this should be core and not an add-on in the asset library?

it expands an existing engine function

kleonc commented 3 months ago

Given that lerp(Variant, Variant) already performs Basis.slerp / Quaternion.slerp (which could be argued to be non-trivial linear interpolations) I see no reason for it to not perform Transform2D.interpolate_with / Transform3D.interpolate_with as well.

So I'd say feel free to open a PR whoever wants to tackle it. Here's relevant source.

akien-mga commented 2 months ago

Implemented by https://github.com/godotengine/godot/pull/96496.