Browse Source

Merge pull request #62211 from lawnjelly/fti_fix_unmoving_updates

Physics Interpolation - fix continuous updating in unmoving objects
Rémi Verschelde 3 years ago
parent
commit
fcf0dd1e33
1 changed files with 9 additions and 0 deletions
  1. 9 0
      servers/visual/visual_server_scene.cpp

+ 9 - 0
servers/visual/visual_server_scene.cpp

@@ -1159,6 +1159,15 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
 		_interpolation_data.instance_interpolate_update_list.push_back(p_instance);
 		instance->on_interpolate_list = true;
 		_instance_queue_update(instance, true);
+
+		// We must also place on the transform update list for a tick, so the system
+		// can auto-detect if the instance is no longer moving, and remove from the interpolate lists again.
+		// If this step is ignored, an unmoving instance could remain on the interpolate lists indefinitely
+		// (or rather until the object is deleted) and cause unnecessary updates and drawcalls.
+		if (!instance->on_interpolate_transform_list) {
+			_interpolation_data.instance_transform_update_list_curr->push_back(p_instance);
+			instance->on_interpolate_transform_list = true;
+		}
 	}
 
 	// give the opportunity for the spatial partitioning scene to use a special implementation of visibility