summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/remote_transform_2d.cpp61
1 files changed, 29 insertions, 32 deletions
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index c6730f7ab2..cd0d9f3750 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -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();
+ return;
+ }
- if (!update_remote_position) {
- our_trans.set_origin(n_trans.get_origin());
- }
- if (!update_remote_rotation) {
- our_trans.set_rotation(n_trans.get_rotation());
- }
+ Transform2D n_trans = n->get_global_transform();
+ Transform2D our_trans = get_global_transform();
- n->set_global_transform(our_trans);
+ // 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_scale) {
- n->set_scale(get_global_scale());
- } else {
- n->set_scale(n_scale);
- }
+ 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();
+ return;
+ }
- if (!update_remote_position) {
- our_trans.set_origin(n_trans.get_origin());
- }
- if (!update_remote_rotation) {
- our_trans.set_rotation(n_trans.get_rotation());
- }
+ Transform2D n_trans = n->get_transform();
+ Transform2D our_trans = get_transform();
- n->set_transform(our_trans);
+ // 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_scale) {
- n->set_scale(get_scale());
- } else {
- n->set_scale(n_scale);
- }
+ 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);
}
}