mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Do not defer PathFollow3D transform updates
Co-authored-by: Yaohua Xiong <xiongyaohua@gmail.com>
This commit is contained in:
@@ -216,24 +216,7 @@ void Path3D::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("curve_changed"));
|
||||
}
|
||||
|
||||
// Update transform, in deferred mode by default to avoid superfluity.
|
||||
void PathFollow3D::update_transform(bool p_immediate) {
|
||||
transform_dirty = true;
|
||||
|
||||
if (p_immediate) {
|
||||
_update_transform();
|
||||
} else {
|
||||
callable_mp(this, &PathFollow3D::_update_transform).call_deferred();
|
||||
}
|
||||
}
|
||||
|
||||
// Update transform immediately .
|
||||
void PathFollow3D::_update_transform() {
|
||||
if (!transform_dirty) {
|
||||
return;
|
||||
}
|
||||
transform_dirty = false;
|
||||
|
||||
void PathFollow3D::update_transform() {
|
||||
if (!path) {
|
||||
return;
|
||||
}
|
||||
@@ -286,9 +269,7 @@ void PathFollow3D::_notification(int p_what) {
|
||||
Node *parent = get_parent();
|
||||
if (parent) {
|
||||
path = Object::cast_to<Path3D>(parent);
|
||||
if (path) {
|
||||
update_transform();
|
||||
}
|
||||
update_transform();
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -414,6 +395,9 @@ void PathFollow3D::_bind_methods() {
|
||||
|
||||
void PathFollow3D::set_progress(real_t p_progress) {
|
||||
ERR_FAIL_COND(!isfinite(p_progress));
|
||||
if (progress == p_progress) {
|
||||
return;
|
||||
}
|
||||
progress = p_progress;
|
||||
|
||||
if (path) {
|
||||
@@ -435,10 +419,11 @@ void PathFollow3D::set_progress(real_t p_progress) {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_h_offset(real_t p_h_offset) {
|
||||
h_offset = p_h_offset;
|
||||
if (path) {
|
||||
update_transform();
|
||||
if (h_offset == p_h_offset) {
|
||||
return;
|
||||
}
|
||||
h_offset = p_h_offset;
|
||||
update_transform();
|
||||
}
|
||||
|
||||
real_t PathFollow3D::get_h_offset() const {
|
||||
@@ -446,10 +431,11 @@ real_t PathFollow3D::get_h_offset() const {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_v_offset(real_t p_v_offset) {
|
||||
v_offset = p_v_offset;
|
||||
if (path) {
|
||||
update_transform();
|
||||
if (v_offset == p_v_offset) {
|
||||
return;
|
||||
}
|
||||
v_offset = p_v_offset;
|
||||
update_transform();
|
||||
}
|
||||
|
||||
real_t PathFollow3D::get_v_offset() const {
|
||||
@@ -476,6 +462,9 @@ real_t PathFollow3D::get_progress_ratio() const {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
|
||||
if (rotation_mode == p_rotation_mode) {
|
||||
return;
|
||||
}
|
||||
rotation_mode = p_rotation_mode;
|
||||
|
||||
update_configuration_warnings();
|
||||
@@ -487,6 +476,9 @@ PathFollow3D::RotationMode PathFollow3D::get_rotation_mode() const {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_use_model_front(bool p_use_model_front) {
|
||||
if (use_model_front == p_use_model_front) {
|
||||
return;
|
||||
}
|
||||
use_model_front = p_use_model_front;
|
||||
update_transform();
|
||||
}
|
||||
@@ -496,6 +488,9 @@ bool PathFollow3D::is_using_model_front() const {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_loop(bool p_loop) {
|
||||
if (loop == p_loop) {
|
||||
return;
|
||||
}
|
||||
loop = p_loop;
|
||||
update_transform();
|
||||
}
|
||||
@@ -505,6 +500,9 @@ bool PathFollow3D::has_loop() const {
|
||||
}
|
||||
|
||||
void PathFollow3D::set_tilt_enabled(bool p_enabled) {
|
||||
if (tilt_enabled == p_enabled) {
|
||||
return;
|
||||
}
|
||||
tilt_enabled = p_enabled;
|
||||
update_transform();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user