File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ void Camera::_update_camera() {
168168
169169void Camera::_physics_interpolated_changed () {
170170 _update_process_mode ();
171+ Spatial::_physics_interpolated_changed ();
171172}
172173
173174void Camera::set_desired_process_modes (bool p_process_internal, bool p_physics_process_internal) {
Original file line number Diff line number Diff line change @@ -943,8 +943,18 @@ Vector3 Spatial::to_global(Vector3 p_local) const {
943943 return get_global_transform ().xform (p_local);
944944}
945945
946+ void Spatial::_physics_interpolated_changed () {
947+ data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled ());
948+ }
949+
950+ void Spatial::_set_notify_transform_when_fti_off (bool p_enable) {
951+ data.notify_transform_when_fti_off = p_enable;
952+ data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled ());
953+ }
954+
946955void Spatial::set_notify_transform (bool p_enable) {
947- data.notify_transform = p_enable;
956+ data.notify_transform_requested = p_enable;
957+ data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled ());
948958}
949959
950960bool Spatial::is_transform_notification_enabled () const {
@@ -1144,6 +1154,9 @@ Spatial::Spatial() :
11441154#endif
11451155 data.notify_local_transform = false ;
11461156 data.notify_transform = false ;
1157+ data.notify_transform_requested = false ;
1158+ data.notify_transform_when_fti_off = false ;
1159+
11471160 data.parent = nullptr ;
11481161 data.C = nullptr ;
11491162}
Original file line number Diff line number Diff line change @@ -120,6 +120,9 @@ class Spatial : public Node {
120120 bool notify_local_transform : 1 ;
121121 bool notify_transform : 1 ;
122122
123+ bool notify_transform_requested : 1 ;
124+ bool notify_transform_when_fti_off : 1 ;
125+
123126 bool visible : 1 ;
124127 bool disable_scale : 1 ;
125128
@@ -174,6 +177,9 @@ class Spatial : public Node {
174177 // (e.g. changing Camera zoom even if position hasn't changed).
175178 void fti_notify_node_changed (bool p_transform_changed = true );
176179
180+ void _set_notify_transform_when_fti_off (bool p_enable);
181+ virtual void _physics_interpolated_changed ();
182+
177183 // Opportunity after FTI to update the servers
178184 // with global_transform_interpolated,
179185 // and any custom interpolated data in derived classes.
Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ void VisualInstance::_notification(int p_what) {
103103
104104 } break ;
105105 case NOTIFICATION_TRANSFORM_CHANGED: {
106- // ToDo : Can we turn off notify transform for physics interpolated cases?
106+ // NOTIFICATION normally turned off for physics interpolated cases (via
107+ // `notify_transform_when_fti_off`), however derived classes can still turn this back on,
108+ // so always wrap with is_physics_interpolation_enabled().
107109 if (_is_vi_visible () && !(is_inside_tree () && get_tree ()->is_physics_interpolation_enabled ()) && !_is_using_identity_transform ()) {
108110 // Physics interpolation global off, always send.
109111 VisualServer::get_singleton ()->instance_set_transform (instance, get_global_transform ());
@@ -211,7 +213,7 @@ VisualInstance::VisualInstance() {
211213 layers = 1 ;
212214 sorting_offset = 0 .0f ;
213215 sorting_use_aabb_center = true ;
214- set_notify_transform (true );
216+ _set_notify_transform_when_fti_off (true );
215217}
216218
217219VisualInstance::~VisualInstance () {
You can’t perform that action at this time.
0 commit comments