You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Physics Interpolation - refactor Camera and fix get_camera_transform()
* Moves 3D Camera interpolation scene side. * Automatically switches `get_camera_transform()` to report interpolated transform during `_process()`. * Fixes `ClippedCamera` to work with physics interpolation.
This commit is contained in:
@@ -99,12 +99,11 @@ void VisualInstance::_notification(int p_what) {
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
if (_is_vi_visible() || is_physics_interpolated_and_enabled()) {
|
||||
if (!_is_using_identity_transform()) {
|
||||
Transform gt = get_global_transform();
|
||||
VisualServer::get_singleton()->instance_set_transform(instance, gt);
|
||||
VisualServer::get_singleton()->instance_set_transform(instance, get_global_transform());
|
||||
|
||||
// For instance when first adding to the tree, when the previous transform is
|
||||
// unset, to prevent streaking from the origin.
|
||||
if (_is_physics_interpolation_reset_requested()) {
|
||||
if (_is_physics_interpolation_reset_requested() && is_physics_interpolated_and_enabled() && is_inside_tree()) {
|
||||
if (_is_vi_visible()) {
|
||||
_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
@@ -114,7 +113,14 @@ void VisualInstance::_notification(int p_what) {
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
|
||||
if (_is_vi_visible() && is_physics_interpolated()) {
|
||||
if (_is_vi_visible() && is_physics_interpolated() && is_inside_tree()) {
|
||||
// We must ensure the VisualServer transform is up to date before resetting.
|
||||
// This is because NOTIFICATION_TRANSFORM_CHANGED is deferred,
|
||||
// and cannot be relied to be called in order before NOTIFICATION_RESET_PHYSICS_INTERPOLATION.
|
||||
if (!_is_using_identity_transform()) {
|
||||
VisualServer::get_singleton()->instance_set_transform(instance, get_global_transform());
|
||||
}
|
||||
|
||||
VisualServer::get_singleton()->instance_reset_physics_interpolation(instance);
|
||||
}
|
||||
} break;
|
||||
|
||||
Reference in New Issue
Block a user