stick-the-quick/util/ext_math.gd

15 lines
394 B
GDScript

class_name ExtMath extends StaticClass
static func multilerp(control_points: Array, weight: float) -> Variant:
if control_points.is_empty():
return null
elif control_points.size() == 1:
return control_points[0]
else:
var offset: float = weight*(control_points.size() - 1)
return lerp(
control_points[floori(offset)],
control_points[ceili(offset)],
fposmod(offset, 1.0)
)