Merge pull request #62018 from lawnjelly/fti_fix_unhiding_stale

This commit is contained in:
Rémi Verschelde 2022-06-14 12:28:08 +02:00 committed by GitHub
commit 54a4806a06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1151,6 +1151,16 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
instance->visible = p_visible;
// Special case for physics interpolation, we want to ensure the interpolated data is up to date
if (_interpolation_data.interpolation_enabled && p_visible && instance->interpolated && instance->scenario && !instance->on_interpolate_list) {
// Do all the extra work we normally do on instance_set_transform(), because this is optimized out for hidden instances.
// This prevents a glitch of stale interpolation transform data when unhiding before the next physics tick.
instance->interpolation_method = TransformInterpolator::find_method(instance->transform_prev.basis, instance->transform_curr.basis);
_interpolation_data.instance_interpolate_update_list.push_back(p_instance);
instance->on_interpolate_list = true;
_instance_queue_update(instance, true);
}
// give the opportunity for the spatial partitioning scene to use a special implementation of visibility
// for efficiency (supported in BVH but not octree)