mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03: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:
@@ -101,6 +101,12 @@ void Node::_notification(int p_notification) {
|
||||
get_tree()->node_count++;
|
||||
orphan_node_count--;
|
||||
|
||||
// Allow physics interpolated nodes to automatically reset when added to the tree
|
||||
// (this is to save the user doing this manually each time).
|
||||
if (get_tree()->is_physics_interpolation_enabled()) {
|
||||
_set_physics_interpolation_reset_requested(true);
|
||||
}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
ERR_FAIL_COND(!get_viewport());
|
||||
@@ -221,14 +227,14 @@ void Node::_propagate_physics_interpolated(bool p_interpolated) {
|
||||
data.blocked--;
|
||||
}
|
||||
|
||||
void Node::_propagate_physics_interpolation_reset_requested() {
|
||||
void Node::_propagate_physics_interpolation_reset_requested(bool p_requested) {
|
||||
if (is_physics_interpolated()) {
|
||||
data.physics_interpolation_reset_requested = true;
|
||||
data.physics_interpolation_reset_requested = p_requested;
|
||||
}
|
||||
|
||||
data.blocked++;
|
||||
for (int i = 0; i < data.children.size(); i++) {
|
||||
data.children[i]->_propagate_physics_interpolation_reset_requested();
|
||||
data.children[i]->_propagate_physics_interpolation_reset_requested(p_requested);
|
||||
}
|
||||
data.blocked--;
|
||||
}
|
||||
@@ -885,15 +891,23 @@ void Node::set_physics_interpolation_mode(PhysicsInterpolationMode p_mode) {
|
||||
|
||||
// if swapping from interpolated to non-interpolated, use this as
|
||||
// an extra means to cause a reset
|
||||
if (is_physics_interpolated() && !interpolate) {
|
||||
reset_physics_interpolation();
|
||||
if (is_physics_interpolated() && !interpolate && is_inside_tree()) {
|
||||
propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
|
||||
_propagate_physics_interpolated(interpolate);
|
||||
}
|
||||
|
||||
void Node::reset_physics_interpolation() {
|
||||
propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
if (is_inside_tree()) {
|
||||
propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
|
||||
// If `reset_physics_interpolation()` is called explicitly by the user
|
||||
// (e.g. from scripts) then we prevent deferred auto-resets taking place.
|
||||
// The user is trusted to call reset in the right order, and auto-reset
|
||||
// will interfere with their control of prev / curr, so should be turned off.
|
||||
_propagate_physics_interpolation_reset_requested(false);
|
||||
}
|
||||
}
|
||||
|
||||
float Node::get_physics_process_delta_time() const {
|
||||
@@ -1297,12 +1311,6 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
|
||||
//recognize children created in this node constructor
|
||||
p_child->data.parent_owned = data.in_constructor;
|
||||
add_child_notify(p_child);
|
||||
|
||||
// Allow physics interpolated nodes to automatically reset when added to the tree
|
||||
// (this is to save the user doing this manually each time)
|
||||
if (is_inside_tree() && get_tree()->is_physics_interpolation_enabled()) {
|
||||
p_child->_propagate_physics_interpolation_reset_requested();
|
||||
}
|
||||
}
|
||||
|
||||
void Node::add_child(Node *p_child, bool p_force_readable_name) {
|
||||
|
||||
Reference in New Issue
Block a user