mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Fix RemoteTransform2D could fail to update AnimatableBody2D's position or rotation
Configure the transform per condition, and then only set it once to prevent multiple `NOTIFICATION_LOCAL_TRANSFORM_CHANGED` notifications from being sent.
This commit is contained in:
parent
c29866dbc0
commit
100b4b1f28
@ -60,54 +60,51 @@ void RemoteTransform2D::_update_remote() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(update_remote_position || update_remote_rotation || update_remote_scale)) {
|
||||
return; // The transform data of the RemoteTransform2D is not used at all.
|
||||
}
|
||||
|
||||
//todo make faster
|
||||
if (use_global_coordinates) {
|
||||
if (update_remote_position && update_remote_rotation && update_remote_scale) {
|
||||
n->set_global_transform(get_global_transform());
|
||||
} else {
|
||||
Transform2D n_trans = n->get_global_transform();
|
||||
Transform2D our_trans = get_global_transform();
|
||||
Vector2 n_scale = n->get_scale();
|
||||
|
||||
if (!update_remote_position) {
|
||||
our_trans.set_origin(n_trans.get_origin());
|
||||
}
|
||||
if (!update_remote_rotation) {
|
||||
our_trans.set_rotation(n_trans.get_rotation());
|
||||
}
|
||||
|
||||
n->set_global_transform(our_trans);
|
||||
|
||||
if (update_remote_scale) {
|
||||
n->set_scale(get_global_scale());
|
||||
} else {
|
||||
n->set_scale(n_scale);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D n_trans = n->get_global_transform();
|
||||
Transform2D our_trans = get_global_transform();
|
||||
|
||||
// There are more steps in the operation of set_rotation, so avoid calling it.
|
||||
Transform2D trans = update_remote_rotation ? our_trans : n_trans;
|
||||
|
||||
if (update_remote_rotation ^ update_remote_position) {
|
||||
trans.set_origin(update_remote_position ? our_trans.get_origin() : n_trans.get_origin());
|
||||
}
|
||||
if (update_remote_rotation ^ update_remote_scale) {
|
||||
trans.set_scale(update_remote_scale ? our_trans.get_scale() : n_trans.get_scale());
|
||||
}
|
||||
|
||||
n->set_global_transform(trans);
|
||||
} else {
|
||||
if (update_remote_position && update_remote_rotation && update_remote_scale) {
|
||||
n->set_transform(get_transform());
|
||||
} else {
|
||||
Transform2D n_trans = n->get_transform();
|
||||
Transform2D our_trans = get_transform();
|
||||
Vector2 n_scale = n->get_scale();
|
||||
|
||||
if (!update_remote_position) {
|
||||
our_trans.set_origin(n_trans.get_origin());
|
||||
}
|
||||
if (!update_remote_rotation) {
|
||||
our_trans.set_rotation(n_trans.get_rotation());
|
||||
}
|
||||
|
||||
n->set_transform(our_trans);
|
||||
|
||||
if (update_remote_scale) {
|
||||
n->set_scale(get_scale());
|
||||
} else {
|
||||
n->set_scale(n_scale);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D n_trans = n->get_transform();
|
||||
Transform2D our_trans = get_transform();
|
||||
|
||||
// There are more steps in the operation of set_rotation, so avoid calling it.
|
||||
Transform2D trans = update_remote_rotation ? our_trans : n_trans;
|
||||
|
||||
if (update_remote_rotation ^ update_remote_position) {
|
||||
trans.set_origin(update_remote_position ? our_trans.get_origin() : n_trans.get_origin());
|
||||
}
|
||||
if (update_remote_rotation ^ update_remote_scale) {
|
||||
trans.set_scale(update_remote_scale ? our_trans.get_scale() : n_trans.get_scale());
|
||||
}
|
||||
|
||||
n->set_transform(trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user