mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Refactor Curve3D::_bake() method
The main change is to caculate tangent directly from bezier curve, without going through discretized polyline, avoiding pitfalls of discretization. Other changes are: 1. Add an bezier_derivative() method for Vector3, Vector2, and Math; 2. Add an tesselate_even_length() method to Curve3D, which tesselate bezier curve to even length segments adaptively; 3. Cache the tangent vectors in baked_tangent_vector_cache;
This commit is contained in:
@@ -392,6 +392,10 @@ struct VariantUtilityFunctions {
|
||||
return Math::bezier_interpolate(p_start, p_control_1, p_control_2, p_end, p_t);
|
||||
}
|
||||
|
||||
static inline double bezier_derivative(double p_start, double p_control_1, double p_control_2, double p_end, double p_t) {
|
||||
return Math::bezier_derivative(p_start, p_control_1, p_control_2, p_end, p_t);
|
||||
}
|
||||
|
||||
static inline double lerp_angle(double from, double to, double weight) {
|
||||
return Math::lerp_angle(from, to, weight);
|
||||
}
|
||||
@@ -1440,6 +1444,7 @@ void Variant::_register_variant_utility_functions() {
|
||||
FUNCBINDR(cubic_interpolate_in_time, sarray("from", "to", "pre", "post", "weight", "to_t", "pre_t", "post_t"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(cubic_interpolate_angle_in_time, sarray("from", "to", "pre", "post", "weight", "to_t", "pre_t", "post_t"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(bezier_interpolate, sarray("start", "control_1", "control_2", "end", "t"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(bezier_derivative, sarray("start", "control_1", "control_2", "end", "t"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(lerp_angle, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(inverse_lerp, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
FUNCBINDR(remap, sarray("value", "istart", "istop", "ostart", "ostop"), Variant::UTILITY_FUNC_TYPE_MATH);
|
||||
|
||||
Reference in New Issue
Block a user