Merge pull request #80955 from lawnjelly/fti2d_more_resets
[3.x] Physics Interpolation - automatic resets for Camera2D and TileMap
This commit is contained in:
commit
1b4bae595e
2 changed files with 26 additions and 0 deletions
|
@ -318,6 +318,14 @@ void Camera2D::_notification(int p_what) {
|
||||||
first = true;
|
first = true;
|
||||||
_set_current(current);
|
_set_current(current);
|
||||||
|
|
||||||
|
// Note that NOTIFICATION_RESET_PHYSICS_INTERPOLATION
|
||||||
|
// is automatically called before this because Camera2D is inherited
|
||||||
|
// from CanvasItem. However, the camera transform is not up to date
|
||||||
|
// until this point, so we do an extra manual reset.
|
||||||
|
if (is_physics_interpolated_and_enabled()) {
|
||||||
|
_interpolation_data.xform_curr = get_camera_transform();
|
||||||
|
_interpolation_data.xform_prev = _interpolation_data.xform_curr;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
const bool viewport_valid = !custom_viewport || ObjectDB::get_instance(custom_viewport_id);
|
const bool viewport_valid = !custom_viewport || ObjectDB::get_instance(custom_viewport_id);
|
||||||
|
|
|
@ -132,6 +132,17 @@ void TileMap::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
|
||||||
|
if (is_visible_in_tree() && is_physics_interpolated_and_enabled()) {
|
||||||
|
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
|
||||||
|
Quadrant &q = E->get();
|
||||||
|
for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) {
|
||||||
|
VisualServer::get_singleton()->canvas_item_reset_physics_interpolation(F->get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,6 +755,13 @@ void TileMap::update_dirty_quadrants() {
|
||||||
VisualServerCanvasHelper::tilemap_end();
|
VisualServerCanvasHelper::tilemap_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset physics interpolation for any recreated canvas items.
|
||||||
|
if (is_physics_interpolated_and_enabled() && is_visible_in_tree()) {
|
||||||
|
for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) {
|
||||||
|
VisualServer::get_singleton()->canvas_item_reset_physics_interpolation(F->get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dirty_quadrant_list.remove(dirty_quadrant_list.first());
|
dirty_quadrant_list.remove(dirty_quadrant_list.first());
|
||||||
quadrant_order_dirty = true;
|
quadrant_order_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue