godot icon indicating copy to clipboard operation
godot copied to clipboard

Add new methods to `AABB` and `Rect2` classes

Open mateuseap opened this issue 1 year ago • 12 comments

What I did

  • Added the following methods to AABB and Rect2 classes: lerp(), cubic_interpolate() and cubic_interpolate_in_time();
  • Modified the source code of following methods of Animation class: _cubic_interpolate_in_time() and interpolate_variant().

Closes: #80627

mateuseap avatar Aug 28 '23 21:08 mateuseap

In the future please be aware of when people have already said they wanted to solve an issue like this case, first ask if they are still working on it, otherwise you might cost someone a lot of lost time when you grab the issue

AThousandShips avatar Aug 28 '23 21:08 AThousandShips

This doesn't solve the linked issue unless you also integrate these methods with the animation

AThousandShips avatar Aug 28 '23 21:08 AThousandShips

In the future please be aware of when people have already said they wanted to solve an issue like this case, first ask if they are still working on it, otherwise you might cost someone a lot of lost time when you grab the issue

Alright, I'll pay more attention next time. For sure isn't nice to waste someone's time!

mateuseap avatar Aug 28 '23 21:08 mateuseap

This doesn't solve the linked issue unless you also integrate these methods with the animation

@AThousandShips can you please give me more info of how can I do it?

mateuseap avatar Aug 28 '23 22:08 mateuseap

I'll try find the relevant code later today

AThousandShips avatar Aug 29 '23 07:08 AThousandShips

Thanks, really appreciate it! I'll come back to this later as well, I'll keep looking further into the code trying to understand what else is needed to implement/modify.

mateuseap avatar Aug 29 '23 08:08 mateuseap

I'd suggest looking at scene/resources/animation.cpp, look at lines:

  • 2357
  • 2396
  • 5664

Also might be good to look into adding the same to AABB for completeness

AThousandShips avatar Aug 29 '23 08:08 AThousandShips

The missing function is not the only problem, but the substance of the problem is the need to force a positive value with abs() at the end of the interpolation function.

TokageItLab avatar Aug 29 '23 09:08 TokageItLab

@AThousandShips @TokageItLab I've implemented the following methods for AABB and Rect2 classes: lerp(), cubic_interpolate() and cubic_interpolate_in_time(). Also I started using these new methods in the source code of the following Animation class methods: _cubic_interpolate_in_time() and interpolate_variant().

mateuseap avatar Aug 31 '23 17:08 mateuseap

Please use clang-format locally instead of depending on the CI status to check your code style

AThousandShips avatar Sep 12 '23 11:09 AThousandShips

@TokageItLab can you take a look in this PR? I've made the requested changes

mateuseap avatar Sep 30 '23 04:09 mateuseap

@AThousandShips I've modified what you've pointed out. I've also solved the conflicts.

mateuseap avatar Mar 24 '24 06:03 mateuseap