From 5827f747673ad37e951a8b5e23979aa3ca00e379 Mon Sep 17 00:00:00 2001 From: Silc Renew Date: Wed, 8 Feb 2023 02:48:33 +0900 Subject: [PATCH] Rename PathFollow method --- doc/classes/PathFollow2D.xml | 2 +- doc/classes/PathFollow3D.xml | 2 +- scene/2d/path_2d.cpp | 30 ++++++++++++++++++++++++------ scene/2d/path_2d.h | 8 ++++++-- scene/3d/path_3d.cpp | 30 ++++++++++++++++++++++++------ scene/3d/path_3d.h | 8 ++++++-- 6 files changed, 62 insertions(+), 18 deletions(-) diff --git a/doc/classes/PathFollow2D.xml b/doc/classes/PathFollow2D.xml index 09d6872e10bb..850accaafdf5 100644 --- a/doc/classes/PathFollow2D.xml +++ b/doc/classes/PathFollow2D.xml @@ -10,7 +10,7 @@ - + If [code]true[/code], the position between two cached points is interpolated cubically, and linearly otherwise. The points along the [Curve2D] of the [Path2D] are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough. There are two answers to this problem: either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations. diff --git a/doc/classes/PathFollow3D.xml b/doc/classes/PathFollow3D.xml index 01275471d075..763c0b5ae940 100644 --- a/doc/classes/PathFollow3D.xml +++ b/doc/classes/PathFollow3D.xml @@ -20,7 +20,7 @@ - + If [code]true[/code], the position between two cached points is interpolated cubically, and linearly otherwise. The points along the [Curve3D] of the [Path3D] are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough. There are two answers to this problem: either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations. diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 5036dd30b169..1f910be84696 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -268,11 +268,11 @@ void PathFollow2D::_notification(int p_what) { } } -void PathFollow2D::set_cubic_interpolation(bool p_enable) { - cubic = p_enable; +void PathFollow2D::set_cubic_interpolation(bool p_enabled) { + cubic = p_enabled; } -bool PathFollow2D::get_cubic_interpolation() const { +bool PathFollow2D::is_cubic_interpolation_enabled() const { return cubic; } @@ -299,6 +299,24 @@ PackedStringArray PathFollow2D::get_configuration_warnings() const { return warnings; } +#ifndef DISABLE_DEPRECATED +bool PathFollow2D::_set(const StringName &p_name, const Variant &p_value) { + if ((p_name == SNAME("cubic_interp"))) { + set_cubic_interpolation(p_value); + return true; + } + return false; +} +bool PathFollow2D::_get(const StringName &p_name, Variant &r_ret) const { + String name = p_name; + if ((p_name == SNAME("cubic_interp"))) { + r_ret = is_cubic_interpolation_enabled(); + } else { + return false; + } + return true; +} +#endif void PathFollow2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_progress", "progress"), &PathFollow2D::set_progress); ClassDB::bind_method(D_METHOD("get_progress"), &PathFollow2D::get_progress); @@ -315,8 +333,8 @@ void PathFollow2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotates", "enable"), &PathFollow2D::set_rotates); ClassDB::bind_method(D_METHOD("is_rotating"), &PathFollow2D::is_rotating); - ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enable"), &PathFollow2D::set_cubic_interpolation); - ClassDB::bind_method(D_METHOD("get_cubic_interpolation"), &PathFollow2D::get_cubic_interpolation); + ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enabled"), &PathFollow2D::set_cubic_interpolation); + ClassDB::bind_method(D_METHOD("is_cubic_interpolation_enabled"), &PathFollow2D::is_cubic_interpolation_enabled); ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow2D::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow2D::has_loop); @@ -329,7 +347,7 @@ void PathFollow2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "h_offset"), "set_h_offset", "get_h_offset"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "v_offset"), "set_v_offset", "get_v_offset"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotates"), "set_rotates", "is_rotating"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interp"), "set_cubic_interpolation", "get_cubic_interpolation"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interpolation"), "set_cubic_interpolation", "is_cubic_interpolation_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lookahead", PROPERTY_HINT_RANGE, "0.001,1024.0,0.001"), "set_lookahead", "get_lookahead"); } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 89c77c49ebf3..5adec7e73151 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -78,6 +78,10 @@ class PathFollow2D : public Node2D { void _update_transform(); protected: +#ifndef DISABLE_DEPRECATED + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; +#endif void _validate_property(PropertyInfo &p_property) const; void _notification(int p_what); @@ -107,8 +111,8 @@ class PathFollow2D : public Node2D { void set_rotates(bool p_rotates); bool is_rotating() const; - void set_cubic_interpolation(bool p_enable); - bool get_cubic_interpolation() const; + void set_cubic_interpolation(bool p_enabled); + bool is_cubic_interpolation_enabled() const; PackedStringArray get_configuration_warnings() const override; diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 04ac01a08588..936901a86096 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -229,11 +229,11 @@ void PathFollow3D::_notification(int p_what) { } } -void PathFollow3D::set_cubic_interpolation(bool p_enable) { - cubic = p_enable; +void PathFollow3D::set_cubic_interpolation(bool p_enabled) { + cubic = p_enabled; } -bool PathFollow3D::get_cubic_interpolation() const { +bool PathFollow3D::is_cubic_interpolation_enabled() const { return cubic; } @@ -297,6 +297,24 @@ Transform3D PathFollow3D::correct_posture(Transform3D p_transform, PathFollow3D: return t; } +#ifndef DISABLE_DEPRECATED +bool PathFollow3D::_set(const StringName &p_name, const Variant &p_value) { + if ((p_name == SNAME("cubic_interp"))) { + set_cubic_interpolation(p_value); + return true; + } + return false; +} +bool PathFollow3D::_get(const StringName &p_name, Variant &r_ret) const { + String name = p_name; + if ((p_name == SNAME("cubic_interp"))) { + r_ret = is_cubic_interpolation_enabled(); + } else { + return false; + } + return true; +} +#endif void PathFollow3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_progress", "progress"), &PathFollow3D::set_progress); ClassDB::bind_method(D_METHOD("get_progress"), &PathFollow3D::get_progress); @@ -313,8 +331,8 @@ void PathFollow3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotation_mode", "rotation_mode"), &PathFollow3D::set_rotation_mode); ClassDB::bind_method(D_METHOD("get_rotation_mode"), &PathFollow3D::get_rotation_mode); - ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enable"), &PathFollow3D::set_cubic_interpolation); - ClassDB::bind_method(D_METHOD("get_cubic_interpolation"), &PathFollow3D::get_cubic_interpolation); + ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enabled"), &PathFollow3D::set_cubic_interpolation); + ClassDB::bind_method(D_METHOD("is_cubic_interpolation_enabled"), &PathFollow3D::is_cubic_interpolation_enabled); ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow3D::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow3D::has_loop); @@ -329,7 +347,7 @@ void PathFollow3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "h_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_h_offset", "get_h_offset"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "v_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_v_offset", "get_v_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ,Oriented"), "set_rotation_mode", "get_rotation_mode"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interp"), "set_cubic_interpolation", "get_cubic_interpolation"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interpolation"), "set_cubic_interpolation", "is_cubic_interpolation_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tilt_enabled"), "set_tilt_enabled", "is_tilt_enabled"); diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index 9fdcc0f0ef32..006091e90899 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -87,6 +87,10 @@ class PathFollow3D : public Node3D { void _update_transform(bool p_update_xyz_rot = true); protected: +#ifndef DISABLE_DEPRECATED + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; +#endif void _validate_property(PropertyInfo &p_property) const; void _notification(int p_what); @@ -114,8 +118,8 @@ class PathFollow3D : public Node3D { void set_rotation_mode(RotationMode p_rotation_mode); RotationMode get_rotation_mode() const; - void set_cubic_interpolation(bool p_enable); - bool get_cubic_interpolation() const; + void set_cubic_interpolation(bool p_enabled); + bool is_cubic_interpolation_enabled() const; PackedStringArray get_configuration_warnings() const override;