Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scene/3d/camera_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void Camera3D::_update_camera() {

void Camera3D::_physics_interpolated_changed() {
_update_process_mode();
Node3D::_physics_interpolated_changed();
}

void Camera3D::set_desired_process_modes(bool p_process_internal, bool p_physics_process_internal) {
Expand Down
16 changes: 15 additions & 1 deletion scene/3d/node_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,21 @@ Vector3 Node3D::to_global(Vector3 p_local) const {
return get_global_transform().xform(p_local);
}

void Node3D::_physics_interpolated_changed() {
ERR_THREAD_GUARD;
data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled());
}

void Node3D::_set_notify_transform_when_fti_off(bool p_enable) {
ERR_THREAD_GUARD;
data.notify_transform_when_fti_off = p_enable;
data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled());
}

void Node3D::set_notify_transform(bool p_enabled) {
ERR_THREAD_GUARD;
data.notify_transform = p_enabled;
data.notify_transform_requested = p_enabled;
data.notify_transform = data.notify_transform_requested || (data.notify_transform_when_fti_off && !is_physics_interpolated_and_enabled());
}

bool Node3D::is_transform_notification_enabled() const {
Expand Down Expand Up @@ -1441,6 +1453,8 @@ Node3D::Node3D() :
data.ignore_notification = false;
data.notify_local_transform = false;
data.notify_transform = false;
data.notify_transform_requested = false;
data.notify_transform_when_fti_off = false;

data.visible = true;
data.disable_scale = false;
Expand Down
6 changes: 6 additions & 0 deletions scene/3d/node_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class Node3D : public Node {
bool notify_local_transform : 1;
bool notify_transform : 1;

bool notify_transform_requested : 1;
bool notify_transform_when_fti_off : 1;

bool visible : 1;
bool disable_scale : 1;

Expand Down Expand Up @@ -199,6 +202,9 @@ class Node3D : public Node {
// (e.g. changing Camera zoom even if position hasn't changed).
void fti_notify_node_changed(bool p_transform_changed = true);

void _set_notify_transform_when_fti_off(bool p_enable);
virtual void _physics_interpolated_changed() override;

// Opportunity after FTI to update the servers
// with global_transform_interpolated,
// and any custom interpolated data in derived classes.
Expand Down
6 changes: 4 additions & 2 deletions scene/3d/visual_instance_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ void VisualInstance3D::_notification(int p_what) {
} break;

case NOTIFICATION_TRANSFORM_CHANGED: {
// ToDo : Can we turn off notify transform for physics interpolated cases?
// NOTIFICATION normally turned off for physics interpolated cases (via
// `notify_transform_when_fti_off`), however derived classes can still turn this back on,
// so always wrap with is_physics_interpolation_enabled().
if (_is_vi_visible() && !(is_inside_tree() && get_tree()->is_physics_interpolation_enabled()) && !_is_using_identity_transform()) {
// Physics interpolation global off, always send.
RenderingServer::get_singleton()->instance_set_transform(instance, get_global_transform());
Expand Down Expand Up @@ -204,7 +206,7 @@ RID VisualInstance3D::get_base() const {
VisualInstance3D::VisualInstance3D() {
instance = RenderingServer::get_singleton()->instance_create();
RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
set_notify_transform(true);
_set_notify_transform_when_fti_off(true);
}

VisualInstance3D::~VisualInstance3D() {
Expand Down