Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename odd PathFollow2D/3D methods #72851

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/classes/PathFollow2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<tutorials>
</tutorials>
<members>
<member name="cubic_interp" type="bool" setter="set_cubic_interpolation" getter="get_cubic_interpolation" default="true">
<member name="cubic_interpolation" type="bool" setter="set_cubic_interpolation" getter="is_cubic_interpolation_enabled" default="true">
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.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PathFollow3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</method>
</methods>
<members>
<member name="cubic_interp" type="bool" setter="set_cubic_interpolation" getter="get_cubic_interpolation" default="true">
<member name="cubic_interpolation" type="bool" setter="set_cubic_interpolation" getter="is_cubic_interpolation_enabled" default="true">
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.
Expand Down
30 changes: 24 additions & 6 deletions scene/2d/path_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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");
}
Expand Down
8 changes: 6 additions & 2 deletions scene/2d/path_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
30 changes: 24 additions & 6 deletions scene/3d/path_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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");

Expand Down
8 changes: 6 additions & 2 deletions scene/3d/path_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down