bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.4k stars 3.59k forks source link

Use normal constructors for EasingCurve, FunctionCurve, ConstantCurve #16367

Closed cart closed 1 week ago

cart commented 1 week ago

Objective

We currently use special "floating" constructors for EasingCurve, FunctionCurve, and ConstantCurve (ex: easing_curve). This erases the type being created (and in general "what is happening" structurally), for very minimal ergonomics improvements. With rare exceptions, we prefer normal X::new() constructors over floating x() constructors in Bevy. I don't think this use case merits special casing here.

Solution

Add EasingCurve::new(), use normal constructors everywhere, and remove the floating constructors.

I think this should land in 0.15 in the interest of not breaking people later.

mweatherley commented 1 week ago

I don't feel particularly strongly about this either way, but some notes here about why these are this way:

  1. When the Curve API was first conceived, most of the curve return types of adaptor methods were erased. I moved away from that later for various reasons, but this is sort of a vestige of that.
  2. The return types of these library functions are not really "worth knowing" in a meaningful way; all of their useful methods just derive from them being curves. That is, the EasingCurve/FunctionCurve/ConstantCurve namespaces are effectively otherwise useless.
  3. It's significantly fewer keystrokes :)