Skip to content

Commit b93719c

Browse files
committed
Merge pull request #107886 from lawnjelly/fti_global_setting_static
`FTI` - Change `SceneTree` global setting to static
2 parents e5ece3c + 583c72f commit b93719c

File tree

11 files changed

+30
-17
lines changed

11 files changed

+30
-17
lines changed

scene/2d/light_2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void Light2D::_notification(int p_what) {
216216
} break;
217217

218218
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
219-
if (is_visible_in_tree() && is_physics_interpolated()) {
219+
if (is_visible_in_tree() && is_physics_interpolated_and_enabled()) {
220220
// Explicitly make sure the transform is up to date in RenderingServer before
221221
// resetting. This is necessary because NOTIFICATION_TRANSFORM_CHANGED
222222
// is normally deferred, and a client change to transform will not always be sent

scene/2d/light_occluder_2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void LightOccluder2D::_notification(int p_what) {
206206
} break;
207207

208208
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
209-
if (is_visible_in_tree() && is_physics_interpolated()) {
209+
if (is_visible_in_tree() && is_physics_interpolated_and_enabled()) {
210210
// Explicitly make sure the transform is up to date in RenderingServer before
211211
// resetting. This is necessary because NOTIFICATION_TRANSFORM_CHANGED
212212
// is normally deferred, and a client change to transform will not always be sent

scene/2d/physics/physics_body_2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
173173
PackedStringArray PhysicsBody2D::get_configuration_warnings() const {
174174
PackedStringArray warnings = CollisionObject2D::get_configuration_warnings();
175175

176-
if (!is_physics_interpolated()) {
176+
if (SceneTree::is_fti_enabled_in_project() && !is_physics_interpolated()) {
177177
warnings.push_back(RTR("PhysicsBody2D will not work correctly on a non-interpolated branch of the SceneTree.\nCheck the node's inherited physics_interpolation_mode."));
178178
}
179179

scene/2d/tile_map_layer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void TileMapLayer::_rendering_update(bool p_force_cleanup) {
239239
}
240240

241241
// Update all dirty quadrants.
242-
bool needs_set_not_interpolated = is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && !is_physics_interpolated();
242+
bool needs_set_not_interpolated = SceneTree::is_fti_enabled() && !is_physics_interpolated();
243243
for (SelfList<RenderingQuadrant> *quadrant_list_element = dirty_rendering_quadrant_list.first(); quadrant_list_element;) {
244244
SelfList<RenderingQuadrant> *next_quadrant_list_element = quadrant_list_element->next(); // "Hack" to clear the list while iterating.
245245

@@ -593,7 +593,7 @@ void TileMapLayer::_rendering_occluders_update_cell(CellData &r_cell_data) {
593593
bool transpose = (r_cell_data.cell.alternative_tile & TileSetAtlasSource::TRANSFORM_TRANSPOSE);
594594

595595
// Create, update or clear occluders.
596-
bool needs_set_not_interpolated = is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && !is_physics_interpolated();
596+
bool needs_set_not_interpolated = SceneTree::is_fti_enabled() && !is_physics_interpolated();
597597
for (uint32_t occlusion_layer_index = 0; occlusion_layer_index < r_cell_data.occluders.size(); occlusion_layer_index++) {
598598
LocalVector<RID> &occluders = r_cell_data.occluders[occlusion_layer_index];
599599

scene/3d/node_3d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ Transform3D Node3D::get_global_transform_interpolated() {
509509
// Pass through if physics interpolation is switched off.
510510
// This is a convenience, as it allows you to easy turn off interpolation
511511
// without changing any code.
512-
if (is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && !Engine::get_singleton()->is_in_physics_frame()) {
512+
if (SceneTree::is_fti_enabled() && is_inside_tree() && !Engine::get_singleton()->is_in_physics_frame()) {
513513
// Note that with SceneTreeFTI, we may want to calculate interpolated transform for a node
514514
// with physics interpolation set to OFF, if it has a parent that is ON.
515515

scene/3d/physics/physics_body_3d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ real_t PhysicsBody3D::get_inverse_mass() const {
213213
PackedStringArray PhysicsBody3D::get_configuration_warnings() const {
214214
PackedStringArray warnings = CollisionObject3D::get_configuration_warnings();
215215

216-
if (!is_physics_interpolated()) {
216+
if (SceneTree::is_fti_enabled_in_project() && !is_physics_interpolated()) {
217217
warnings.push_back(RTR("PhysicsBody3D will not work correctly on a non-interpolated branch of the SceneTree.\nCheck the node's inherited physics_interpolation_mode."));
218218
}
219219

scene/3d/xr/xr_nodes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ PackedStringArray XRCamera3D::get_configuration_warnings() const {
9292
warnings.push_back(RTR("XRCamera3D may not function as expected without an XROrigin3D node as its parent."));
9393
};
9494

95-
if (is_physics_interpolated()) {
95+
if (SceneTree::is_fti_enabled_in_project() && is_physics_interpolated()) {
9696
warnings.push_back(RTR("XRCamera3D should have physics_interpolation_mode set to OFF in order to avoid jitter."));
9797
}
9898
}
@@ -501,7 +501,7 @@ PackedStringArray XRNode3D::get_configuration_warnings() const {
501501
warnings.push_back(RTR("No pose is set."));
502502
}
503503

504-
if (is_physics_interpolated()) {
504+
if (SceneTree::is_fti_enabled_in_project() && is_physics_interpolated()) {
505505
warnings.push_back(RTR("XRNode3D should have physics_interpolation_mode set to OFF in order to avoid jitter."));
506506
}
507507
}

scene/main/canvas_item.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void CanvasItem::_notification(int p_what) {
405405
} break;
406406

407407
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
408-
if (is_visible_in_tree() && is_physics_interpolated()) {
408+
if (is_visible_in_tree() && is_physics_interpolated_and_enabled()) {
409409
RenderingServer::get_singleton()->canvas_item_reset_physics_interpolation(canvas_item);
410410
}
411411
} break;

scene/main/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ class Node : public Object {
711711
void set_physics_interpolation_mode(PhysicsInterpolationMode p_mode);
712712
PhysicsInterpolationMode get_physics_interpolation_mode() const { return data.physics_interpolation_mode; }
713713
_FORCE_INLINE_ bool is_physics_interpolated() const { return data.physics_interpolated; }
714-
_FORCE_INLINE_ bool is_physics_interpolated_and_enabled() const { return is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && is_physics_interpolated(); }
714+
_FORCE_INLINE_ bool is_physics_interpolated_and_enabled() const { return SceneTree::is_fti_enabled() && is_physics_interpolated(); }
715715
void reset_physics_interpolation();
716716

717717
bool is_enabled() const;

scene/main/scene_tree.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ void SceneTree::ClientPhysicsInterpolation::physics_process() {
137137
}
138138
#endif // _3D_DISABLED
139139

140+
bool SceneTree::_physics_interpolation_enabled = false;
141+
bool SceneTree::_physics_interpolation_enabled_in_project = false;
142+
140143
void SceneTree::tree_changed() {
141144
emit_signal(tree_changed_name);
142145
}
@@ -566,6 +569,9 @@ void SceneTree::initialize() {
566569
}
567570

568571
void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
572+
// This version is for use in editor.
573+
_physics_interpolation_enabled_in_project = p_enabled;
574+
569575
// We never want interpolation in the editor.
570576
if (Engine::get_singleton()->is_editor_hint()) {
571577
p_enabled = false;
@@ -586,10 +592,6 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
586592
}
587593
}
588594

589-
bool SceneTree::is_physics_interpolation_enabled() const {
590-
return _physics_interpolation_enabled;
591-
}
592-
593595
#ifndef _3D_DISABLED
594596
void SceneTree::client_physics_interpolation_add_node_3d(SelfList<Node3D> *p_elem) {
595597
// This ensures that _update_physics_interpolation_data() will be called at least once every

0 commit comments

Comments
 (0)