Fix repeated updates of PathFollow3D Transform
Add optional parameter to specify whether applying rotation to the
PathFollow3D's Transform is necessary, preventing erroneous updates.
(cherry picked from commit be3a1769fe
)
This commit is contained in:
parent
c55e68d311
commit
76a43c93cd
|
@ -93,7 +93,7 @@ Path::Path() {
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
|
||||||
void PathFollow::_update_transform() {
|
void PathFollow::_update_transform(bool p_update_xyz_rot) {
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
|
@ -163,6 +163,7 @@ void PathFollow::_update_transform() {
|
||||||
|
|
||||||
t.origin = pos;
|
t.origin = pos;
|
||||||
|
|
||||||
|
if (p_update_xyz_rot) { // Only update rotation if some parameter has changed - i.e. not on addition to scene tree
|
||||||
Vector3 t_prev = (pos - c->interpolate_baked(offset - delta_offset, cubic)).normalized();
|
Vector3 t_prev = (pos - c->interpolate_baked(offset - delta_offset, cubic)).normalized();
|
||||||
Vector3 t_cur = (c->interpolate_baked(offset + delta_offset, cubic) - pos).normalized();
|
Vector3 t_cur = (c->interpolate_baked(offset + delta_offset, cubic) - pos).normalized();
|
||||||
|
|
||||||
|
@ -204,6 +205,7 @@ void PathFollow::_update_transform() {
|
||||||
t.rotate_basis(tilt_axis.normalized(), tilt_angle);
|
t.rotate_basis(tilt_axis.normalized(), tilt_angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t.translate(Vector3(h_offset, v_offset, 0));
|
t.translate(Vector3(h_offset, v_offset, 0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,7 +225,7 @@ void PathFollow::_notification(int p_what) {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
path = Object::cast_to<Path>(parent);
|
path = Object::cast_to<Path>(parent);
|
||||||
if (path) {
|
if (path) {
|
||||||
_update_transform();
|
_update_transform(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
bool loop;
|
bool loop;
|
||||||
RotationMode rotation_mode;
|
RotationMode rotation_mode;
|
||||||
|
|
||||||
void _update_transform();
|
void _update_transform(bool p_update_xyz_rot = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _validate_property(PropertyInfo &property) const;
|
virtual void _validate_property(PropertyInfo &property) const;
|
||||||
|
|
Loading…
Reference in New Issue