浏览代码

Physics Interpolation - fix continuous updating in unmoving objects

Adds instances to the transform update list as well as the interpolate update list when unhiding them. This ensures that the system auto-detects non-moving objects, and removes them from the interpolate update list on the next tick, preventing unnecessary updates.
lawnjelly 3 年之前
父节点
当前提交
e4f252d94f
共有 1 个文件被更改,包括 9 次插入0 次删除
  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