mirror of
https://github.com/Relintai/pandemonium_engine_minimal.git
synced 2024-11-17 22:17:19 +01:00
Removed physics interpolation support.
This commit is contained in:
parent
9634de59ec
commit
d42e99ecde
@ -32,8 +32,8 @@
|
||||
|
||||
#include "core/config/engine.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/main/scene_string_names.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
void Camera2D::_update_scroll() {
|
||||
@ -52,12 +52,7 @@ void Camera2D::_update_scroll() {
|
||||
if (is_current()) {
|
||||
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
|
||||
|
||||
Transform2D xform;
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
xform = _interpolation_data.xform_prev.interpolate_with(_interpolation_data.xform_curr, Engine::get_singleton()->get_physics_interpolation_fraction());
|
||||
} else {
|
||||
xform = get_camera_transform();
|
||||
}
|
||||
Transform2D xform = get_camera_transform();
|
||||
viewport->set_canvas_transform(xform);
|
||||
|
||||
Size2 screen_size = viewport->get_visible_rect().size;
|
||||
@ -68,24 +63,13 @@ void Camera2D::_update_scroll() {
|
||||
}
|
||||
|
||||
void Camera2D::_update_process_mode() {
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
set_process_internal(is_current());
|
||||
set_physics_process_internal(is_current());
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (process_mode == CAMERA2D_PROCESS_IDLE) {
|
||||
WARN_PRINT_ONCE("Camera2D overridden to physics process mode due to use of physics interpolation.");
|
||||
}
|
||||
#endif
|
||||
// Smoothing can be enabled in the editor but will never be active.
|
||||
if (process_mode == CAMERA2D_PROCESS_IDLE) {
|
||||
set_process_internal(smoothing_active);
|
||||
set_physics_process_internal(false);
|
||||
} else {
|
||||
// Smoothing can be enabled in the editor but will never be active.
|
||||
if (process_mode == CAMERA2D_PROCESS_IDLE) {
|
||||
set_process_internal(smoothing_active);
|
||||
set_physics_process_internal(false);
|
||||
} else {
|
||||
set_process_internal(false);
|
||||
set_physics_process_internal(smoothing_active);
|
||||
}
|
||||
set_process_internal(false);
|
||||
set_physics_process_internal(smoothing_active);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +184,7 @@ Transform2D Camera2D::get_camera_transform() {
|
||||
if (smoothing_active) {
|
||||
// Note that if we are using physics interpolation,
|
||||
// processing will always be physics based (it ignores the process mode set in the UI).
|
||||
bool physics_process = (process_mode == CAMERA2D_PROCESS_PHYSICS) || is_physics_interpolated_and_enabled();
|
||||
bool physics_process = process_mode == CAMERA2D_PROCESS_PHYSICS;
|
||||
float delta = physics_process ? get_physics_process_delta_time() : get_process_delta_time();
|
||||
float c = smoothing * delta;
|
||||
smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
|
||||
@ -257,23 +241,6 @@ Transform2D Camera2D::get_camera_transform() {
|
||||
return (xform).affine_inverse();
|
||||
}
|
||||
|
||||
void Camera2D::_ensure_update_interpolation_data() {
|
||||
// The curr -> previous update can either occur
|
||||
// on the INTERNAL_PHYSICS_PROCESS OR
|
||||
// on NOTIFICATION_TRANSFORM_CHANGED,
|
||||
// if NOTIFICATION_TRANSFORM_CHANGED takes place
|
||||
// earlier than INTERNAL_PHYSICS_PROCESS on a tick.
|
||||
// This is to ensure that the data keeps flowing, but the new data
|
||||
// doesn't overwrite before prev has been set.
|
||||
|
||||
// Keep the data flowing.
|
||||
uint64_t tick = Engine::get_singleton()->get_physics_frames();
|
||||
if (_interpolation_data.last_update_physics_tick != tick) {
|
||||
_interpolation_data.xform_prev = _interpolation_data.xform_curr;
|
||||
_interpolation_data.last_update_physics_tick = tick;
|
||||
}
|
||||
}
|
||||
|
||||
void Camera2D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
@ -281,29 +248,12 @@ void Camera2D::_notification(int p_what) {
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
_ensure_update_interpolation_data();
|
||||
_interpolation_data.xform_curr = get_camera_transform();
|
||||
} else {
|
||||
_update_scroll();
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
|
||||
// Force the limits etc to update.
|
||||
_interpolation_data.xform_curr = get_camera_transform();
|
||||
_interpolation_data.xform_prev = _interpolation_data.xform_curr;
|
||||
_update_scroll();
|
||||
} break;
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
if (!smoothing_active && !is_physics_interpolated_and_enabled()) {
|
||||
if (!smoothing_active) {
|
||||
_update_scroll();
|
||||
}
|
||||
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
_ensure_update_interpolation_data();
|
||||
if (Engine::get_singleton()->is_in_physics_frame()) {
|
||||
_interpolation_data.xform_curr = get_camera_transform();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
ERR_FAIL_COND(!is_inside_tree());
|
||||
@ -316,15 +266,6 @@ void Camera2D::_notification(int p_what) {
|
||||
make_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;
|
||||
}
|
||||
|
||||
first = true;
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
@ -84,7 +84,6 @@ protected:
|
||||
void _update_process_mode();
|
||||
void _update_scroll();
|
||||
void _setup_viewport();
|
||||
void _ensure_update_interpolation_data();
|
||||
|
||||
void _make_current(Object *p_which);
|
||||
|
||||
@ -94,12 +93,6 @@ protected:
|
||||
|
||||
Camera2DProcessMode process_mode;
|
||||
|
||||
struct InterpolationData {
|
||||
Transform2D xform_curr;
|
||||
Transform2D xform_prev;
|
||||
uint32_t last_update_physics_tick = 0;
|
||||
} _interpolation_data;
|
||||
|
||||
protected:
|
||||
virtual Transform2D get_camera_transform();
|
||||
void _notification(int p_what);
|
||||
|
@ -1092,14 +1092,15 @@ void CPUParticles2D::_refresh_interpolation_state() {
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
bool interpolated = is_physics_interpolated_and_enabled();
|
||||
|
||||
bool interpolated = false;
|
||||
|
||||
// The logic for whether to do an interpolated follow.
|
||||
// This is rather complex, but basically:
|
||||
// If project setting interpolation is ON but this particle system is switched OFF,
|
||||
// and in global mode, we will follow the INTERPOLATED position rather than the actual position.
|
||||
// This is so that particles aren't generated AHEAD of the interpolated parent.
|
||||
bool follow = !interpolated && !local_coords && get_tree()->is_physics_interpolation_enabled();
|
||||
bool follow = !interpolated && !local_coords;
|
||||
|
||||
if ((_interpolated == interpolated) && (follow == _interpolation_data.interpolated_follow)) {
|
||||
return;
|
||||
@ -1180,13 +1181,6 @@ void CPUParticles2D::_notification(int p_what) {
|
||||
if (_interpolated) {
|
||||
_update_internal(true);
|
||||
}
|
||||
|
||||
// If we are interpolated following, then reset physics interpolation
|
||||
// when first appearing. This won't be called by canvas item, as in
|
||||
// following mode, is_interpolated() is actually FALSE.
|
||||
if (_interpolation_data.interpolated_follow) {
|
||||
notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
@ -1271,11 +1265,6 @@ void CPUParticles2D::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p_what == NOTIFICATION_RESET_PHYSICS_INTERPOLATION) {
|
||||
// Make sure current is up to date with any pending global transform changes.
|
||||
_interpolation_data.global_xform_curr = get_global_transform_const();
|
||||
_interpolation_data.global_xform_prev = _interpolation_data.global_xform_curr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1546,12 +1535,6 @@ CPUParticles2D::CPUParticles2D() {
|
||||
set_color(Color(1, 1, 1, 1));
|
||||
|
||||
_update_mesh_texture();
|
||||
|
||||
// CPUParticles2D defaults to interpolation off.
|
||||
// This is because the result often looks better when the particles are updated every frame.
|
||||
// Note that children will need to explicitly turn back on interpolation if they want to use it,
|
||||
// rather than relying on inherit mode.
|
||||
set_physics_interpolation_mode(Node::PHYSICS_INTERPOLATION_MODE_OFF);
|
||||
}
|
||||
|
||||
CPUParticles2D::~CPUParticles2D() {
|
||||
|
@ -163,7 +163,4 @@ void ParallaxLayer::_bind_methods() {
|
||||
|
||||
ParallaxLayer::ParallaxLayer() {
|
||||
motion_scale = Size2(1, 1);
|
||||
|
||||
// ParallaxLayer is always updated every frame so there is no need to interpolate.
|
||||
set_physics_interpolation_mode(Node::PHYSICS_INTERPOLATION_MODE_OFF);
|
||||
}
|
||||
|
@ -583,10 +583,6 @@ void CanvasItem::_exit_canvas() {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItem::_physics_interpolated_changed() {
|
||||
RenderingServer::get_singleton()->canvas_item_set_interpolated(canvas_item, is_physics_interpolated());
|
||||
}
|
||||
|
||||
void CanvasItem::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
@ -605,19 +601,6 @@ void CanvasItem::_notification(int p_what) {
|
||||
get_tree()->xform_change_list.add(&xform_change);
|
||||
}
|
||||
|
||||
// If using physics interpolation, reset for this node only,
|
||||
// as a helper, as in most cases, users will want items reset when
|
||||
// adding to the tree.
|
||||
// In cases where they move immediately after adding,
|
||||
// there will be little cost in having two resets as these are cheap,
|
||||
// and it is worth it for convenience.
|
||||
// Do not propagate to children, as each child of an added branch
|
||||
// receives its own NOTIFICATION_ENTER_TREE, and this would
|
||||
// cause unnecessary duplicate resets.
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
|
||||
if (get_viewport()) {
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->canvas_parent_mark_dirty, varray(get_parent()), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
@ -637,11 +620,6 @@ void CanvasItem::_notification(int p_what) {
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->canvas_parent_mark_dirty);
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
|
||||
if (is_visible_in_tree() && is_physics_interpolated()) {
|
||||
RenderingServer::get_singleton()->canvas_item_reset_physics_interpolation(canvas_item);
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_DRAW:
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
} break;
|
||||
|
@ -214,7 +214,6 @@ private:
|
||||
void _exit_canvas();
|
||||
|
||||
void _notify_transform(CanvasItem *p_node);
|
||||
virtual void _physics_interpolated_changed();
|
||||
|
||||
static CanvasItem *current_item_drawn;
|
||||
|
||||
|
@ -3077,8 +3077,6 @@ Control::Control() {
|
||||
data.modal_prev_focus_owner = ObjectID();
|
||||
data.shortcut_context = ObjectID();
|
||||
data.shortcut_context_path_cache = ObjectID();
|
||||
|
||||
set_physics_interpolation_mode(Node::PHYSICS_INTERPOLATION_MODE_OFF);
|
||||
}
|
||||
|
||||
Control::~Control() {
|
||||
|
@ -102,14 +102,6 @@ void Node::_notification(int p_notification) {
|
||||
data.pause_owner = this;
|
||||
}
|
||||
|
||||
if (data.physics_interpolation_mode == PHYSICS_INTERPOLATION_MODE_INHERIT) {
|
||||
bool interpolate = true; // Root node default is for interpolation to be on
|
||||
if (data.parent) {
|
||||
interpolate = data.parent->is_physics_interpolated();
|
||||
}
|
||||
_propagate_physics_interpolated(interpolate);
|
||||
}
|
||||
|
||||
if (get_process_group()) {
|
||||
if (data.process_group_physics_process) {
|
||||
get_process_group()->register_node_physics_process(this);
|
||||
@ -287,48 +279,6 @@ void Node::_propagate_ready() {
|
||||
}
|
||||
}
|
||||
|
||||
void Node::_propagate_physics_interpolated(bool p_interpolated) {
|
||||
switch (data.physics_interpolation_mode) {
|
||||
case PHYSICS_INTERPOLATION_MODE_INHERIT:
|
||||
// keep the parent p_interpolated
|
||||
break;
|
||||
case PHYSICS_INTERPOLATION_MODE_OFF: {
|
||||
p_interpolated = false;
|
||||
} break;
|
||||
case PHYSICS_INTERPOLATION_MODE_ON: {
|
||||
p_interpolated = true;
|
||||
} break;
|
||||
}
|
||||
|
||||
// no change? no need to propagate further
|
||||
if (data.physics_interpolated == p_interpolated) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.physics_interpolated = p_interpolated;
|
||||
|
||||
// allow a call to the RenderingServer etc in derived classes
|
||||
_physics_interpolated_changed();
|
||||
|
||||
data.blocked++;
|
||||
for (HashMap<StringName, Node *>::Element *E = data.children.front(); E; E = E->next) {
|
||||
E->value()->_propagate_physics_interpolated(p_interpolated);
|
||||
}
|
||||
data.blocked--;
|
||||
}
|
||||
|
||||
void Node::_propagate_physics_interpolation_reset_requested() {
|
||||
if (is_physics_interpolated()) {
|
||||
data.physics_interpolation_reset_requested = true;
|
||||
}
|
||||
|
||||
data.blocked++;
|
||||
for (HashMap<StringName, Node *>::Element *E = data.children.front(); E; E = E->next) {
|
||||
E->value()->_propagate_physics_interpolation_reset_requested();
|
||||
}
|
||||
data.blocked--;
|
||||
}
|
||||
|
||||
void Node::_propagate_enter_tree() {
|
||||
// this needs to happen to all children before any enter_tree
|
||||
|
||||
@ -540,8 +490,6 @@ void Node::move_child_notify(Node *p_child) {
|
||||
void Node::owner_changed_notify() {
|
||||
}
|
||||
|
||||
void Node::_physics_interpolated_changed() {}
|
||||
|
||||
void Node::set_physics_process(bool p_process) {
|
||||
if (data.physics_process == p_process) {
|
||||
return;
|
||||
@ -1128,42 +1076,6 @@ bool Node::can_process() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Node::set_physics_interpolation_mode(PhysicsInterpolationMode p_mode) {
|
||||
if (data.physics_interpolation_mode == p_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.physics_interpolation_mode = p_mode;
|
||||
|
||||
bool interpolate = true; // default for root node
|
||||
|
||||
switch (p_mode) {
|
||||
case PHYSICS_INTERPOLATION_MODE_INHERIT: {
|
||||
if (is_inside_tree() && data.parent) {
|
||||
interpolate = data.parent->is_physics_interpolated();
|
||||
}
|
||||
} break;
|
||||
case PHYSICS_INTERPOLATION_MODE_OFF: {
|
||||
interpolate = false;
|
||||
} break;
|
||||
case PHYSICS_INTERPOLATION_MODE_ON: {
|
||||
interpolate = true;
|
||||
} break;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
_propagate_physics_interpolated(interpolate);
|
||||
}
|
||||
|
||||
void Node::reset_physics_interpolation() {
|
||||
propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
|
||||
float Node::get_physics_process_delta_time() const {
|
||||
if (data.tree) {
|
||||
return data.tree->get_physics_process_time();
|
||||
@ -1443,14 +1355,6 @@ bool Node::is_processing_unhandled_key_input() const {
|
||||
return data.unhandled_key_input;
|
||||
}
|
||||
|
||||
void Node::_set_physics_interpolated_client_side(bool p_enable) {
|
||||
data.physics_interpolated_client_side = p_enable;
|
||||
}
|
||||
|
||||
void Node::_set_physics_interpolation_reset_requested(bool p_enable) {
|
||||
data.physics_interpolation_reset_requested = p_enable;
|
||||
}
|
||||
|
||||
void Node::_set_use_identity_transform(bool p_enable) {
|
||||
data.use_identity_transform = p_enable;
|
||||
}
|
||||
@ -1703,12 +1607,6 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
|
||||
add_child_notify(p_child);
|
||||
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
|
||||
emit_signal(SceneStringNames::get_singleton()->child_order_changed);
|
||||
|
||||
// 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) {
|
||||
@ -3523,12 +3421,6 @@ void Node::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_physics_process_internal", "enable"), &Node::set_physics_process_internal);
|
||||
ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_physics_interpolation_mode", "mode"), &Node::set_physics_interpolation_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_physics_interpolation_mode"), &Node::get_physics_interpolation_mode);
|
||||
ClassDB::bind_method(D_METHOD("is_physics_interpolated"), &Node::is_physics_interpolated);
|
||||
ClassDB::bind_method(D_METHOD("is_physics_interpolated_and_enabled"), &Node::is_physics_interpolated_and_enabled);
|
||||
ClassDB::bind_method(D_METHOD("reset_physics_interpolation"), &Node::reset_physics_interpolation);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
|
||||
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
|
||||
|
||||
@ -3630,7 +3522,6 @@ void Node::_bind_methods() {
|
||||
BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS);
|
||||
BIND_CONSTANT(NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
|
||||
BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE);
|
||||
BIND_CONSTANT(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_EDITOR_PRE_SAVE);
|
||||
BIND_CONSTANT(NOTIFICATION_EDITOR_POST_SAVE);
|
||||
@ -3674,8 +3565,6 @@ void Node::_bind_methods() {
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode");
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "physics_interpolation_mode", PROPERTY_HINT_ENUM, "Inherit,Off,On"), "set_physics_interpolation_mode", "get_physics_interpolation_mode");
|
||||
|
||||
#ifdef ENABLE_DEPRECATED
|
||||
//no longer exists, but remains for compatibility (keep previous scenes folded
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor/display_folded", PROPERTY_HINT_NONE, "", 0), "set_display_folded", "is_displayed_folded");
|
||||
@ -3734,9 +3623,6 @@ Node::Node() {
|
||||
data.process_group_idle_process_internal = false;
|
||||
data.inside_tree = false;
|
||||
data.ready_notified = false;
|
||||
data.physics_interpolated = true;
|
||||
data.physics_interpolation_reset_requested = false;
|
||||
data.physics_interpolated_client_side = false;
|
||||
data.use_identity_transform = false;
|
||||
|
||||
data.owner = nullptr;
|
||||
@ -3746,7 +3632,6 @@ Node::Node() {
|
||||
data.unhandled_input = false;
|
||||
data.unhandled_key_input = false;
|
||||
data.pause_mode = PAUSE_MODE_INHERIT;
|
||||
data.physics_interpolation_mode = PHYSICS_INTERPOLATION_MODE_INHERIT;
|
||||
data.pause_owner = nullptr;
|
||||
data.network_master = 1; //server by default
|
||||
data.path_cache = nullptr;
|
||||
|
@ -142,7 +142,6 @@ private:
|
||||
|
||||
// Keep bitpacked values together to get better packing
|
||||
PauseMode pause_mode : 2;
|
||||
PhysicsInterpolationMode physics_interpolation_mode : 2;
|
||||
|
||||
// variables used to properly sort the node when processing, ignored otherwise
|
||||
//should move all the stuff below to bits
|
||||
@ -163,21 +162,6 @@ private:
|
||||
bool process_group_physics_process_internal : 1;
|
||||
bool process_group_idle_process_internal : 1;
|
||||
|
||||
// Physics interpolation can be turned on and off on a per node basis.
|
||||
// This only takes effect when the SceneTree (or project setting) physics interpolation
|
||||
// is switched on.
|
||||
bool physics_interpolated : 1;
|
||||
|
||||
// We can auto-reset physics interpolation when e.g. adding a node for the first time
|
||||
bool physics_interpolation_reset_requested : 1;
|
||||
|
||||
// Most nodes need not be interpolated in the scene tree, physics interpolation
|
||||
// is normally only needed in the RenderingServer. However if we need to read the
|
||||
// interpolated transform of a node in the SceneTree, it is necessary to duplicate
|
||||
// the interpolation logic client side, in order to prevent stalling the RenderingServer
|
||||
// by reading back.
|
||||
bool physics_interpolated_client_side : 1;
|
||||
|
||||
// For certain nodes (e.g. CPU Particles in global mode)
|
||||
// It can be useful to not send the instance transform to the
|
||||
// RenderingServer, and specify the mesh in world space.
|
||||
@ -216,7 +200,6 @@ private:
|
||||
void _propagate_ready();
|
||||
void _propagate_exit_tree();
|
||||
void _propagate_after_exit_branch(bool p_exiting_tree);
|
||||
void _propagate_physics_interpolated(bool p_interpolated);
|
||||
void _propagate_physics_interpolation_reset_requested();
|
||||
void _print_stray_nodes();
|
||||
void _propagate_pause_owner(Node *p_owner);
|
||||
@ -269,8 +252,6 @@ protected:
|
||||
virtual void _name_changed_notify();
|
||||
#endif
|
||||
|
||||
virtual void _physics_interpolated_changed();
|
||||
|
||||
void _propagate_replace_owner(Node *p_owner, Node *p_by_owner);
|
||||
|
||||
static void _bind_methods();
|
||||
@ -282,21 +263,6 @@ protected:
|
||||
void _set_owner_nocheck(Node *p_owner);
|
||||
void _set_name_nocheck(const StringName &p_name);
|
||||
|
||||
void set_physics_interpolation_mode(PhysicsInterpolationMode p_mode);
|
||||
PhysicsInterpolationMode get_physics_interpolation_mode() const {
|
||||
return data.physics_interpolation_mode;
|
||||
}
|
||||
|
||||
void _set_physics_interpolated_client_side(bool p_enable);
|
||||
bool _is_physics_interpolated_client_side() const {
|
||||
return data.physics_interpolated_client_side;
|
||||
}
|
||||
|
||||
void _set_physics_interpolation_reset_requested(bool p_enable);
|
||||
bool _is_physics_interpolation_reset_requested() const {
|
||||
return data.physics_interpolation_reset_requested;
|
||||
}
|
||||
|
||||
void _set_use_identity_transform(bool p_enable);
|
||||
bool _is_using_identity_transform() const {
|
||||
return data.use_identity_transform;
|
||||
@ -324,7 +290,6 @@ public:
|
||||
NOTIFICATION_INTERNAL_PROCESS = 25,
|
||||
NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26,
|
||||
NOTIFICATION_POST_ENTER_TREE = 27,
|
||||
NOTIFICATION_RESET_PHYSICS_INTERPOLATION = 28,
|
||||
//keep these linked to node
|
||||
NOTIFICATION_WM_MOUSE_ENTER = MainLoop::NOTIFICATION_WM_MOUSE_ENTER,
|
||||
NOTIFICATION_WM_MOUSE_EXIT = MainLoop::NOTIFICATION_WM_MOUSE_EXIT,
|
||||
@ -536,15 +501,6 @@ public:
|
||||
bool can_process() const;
|
||||
bool can_process_notification(int p_what) const;
|
||||
|
||||
void set_physics_interpolated(bool p_interpolated);
|
||||
_FORCE_INLINE_ bool is_physics_interpolated() const {
|
||||
return data.physics_interpolated;
|
||||
}
|
||||
_FORCE_INLINE_ bool is_physics_interpolated_and_enabled() const {
|
||||
return is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && is_physics_interpolated();
|
||||
}
|
||||
void reset_physics_interpolation();
|
||||
|
||||
void request_ready();
|
||||
|
||||
static void print_stray_nodes();
|
||||
|
@ -41,23 +41,22 @@
|
||||
#include "core/string/print_string.h"
|
||||
#include "core/variant/variant_parser.h"
|
||||
#include "main/input_default.h"
|
||||
#include "modules/modules_enabled.gen.h" // For freetype.
|
||||
#include "node.h"
|
||||
#include "scene/animation/scene_tree_tween.h"
|
||||
#include "scene/debugger/script_debugger_remote.h"
|
||||
#include "scene/main/control.h"
|
||||
#include "scene/main/scene_string_names.h"
|
||||
#include "scene/resources/font/dynamic_font.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/main/scene_string_names.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "servers/audio_server.h"
|
||||
#include "servers/navigation_server.h"
|
||||
#include "servers/physics_2d_server.h"
|
||||
#include "viewport.h"
|
||||
#include "modules/modules_enabled.gen.h" // For freetype.
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -549,39 +548,7 @@ void SceneTree::init() {
|
||||
MainLoop::init();
|
||||
}
|
||||
|
||||
void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
|
||||
ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "set_physics_interpolation_enabled can only be set from the main thread.");
|
||||
|
||||
// disallow interpolation in editor
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
p_enabled = false;
|
||||
}
|
||||
|
||||
if (p_enabled == _physics_interpolation_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
_physics_interpolation_enabled = p_enabled;
|
||||
|
||||
RenderingServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool SceneTree::is_physics_interpolation_enabled() const {
|
||||
return _physics_interpolation_enabled;
|
||||
}
|
||||
|
||||
void SceneTree::iteration_prepare() {
|
||||
if (_physics_interpolation_enabled) {
|
||||
RenderingServer::get_singleton()->tick();
|
||||
}
|
||||
}
|
||||
|
||||
void SceneTree::iteration_end() {
|
||||
// When physics interpolation is active, we want all pending transforms
|
||||
// to be flushed to the RenderingServer before finishing a physics tick.
|
||||
if (_physics_interpolation_enabled) {
|
||||
flush_transform_notifications();
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneTree::iteration(float p_time) {
|
||||
@ -623,6 +590,9 @@ bool SceneTree::iteration(float p_time) {
|
||||
return _quit;
|
||||
}
|
||||
|
||||
void SceneTree::iteration_end() {
|
||||
}
|
||||
|
||||
void SceneTree::_update_font_oversampling(float p_ratio) {
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
if (use_font_oversampling) {
|
||||
@ -751,10 +721,6 @@ bool SceneTree::idle(float p_time) {
|
||||
|
||||
#endif
|
||||
|
||||
if (_physics_interpolation_enabled) {
|
||||
RenderingServer::get_singleton()->pre_draw(true);
|
||||
}
|
||||
|
||||
return _quit;
|
||||
}
|
||||
|
||||
@ -1800,9 +1766,6 @@ void SceneTree::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize", "scale"), &SceneTree::set_screen_stretch, DEFVAL(1));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_physics_interpolation_enabled", "enabled"), &SceneTree::set_physics_interpolation_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_physics_interpolation_enabled"), &SceneTree::is_physics_interpolation_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("queue_delete", "obj"), &SceneTree::queue_delete);
|
||||
|
||||
MethodInfo mi;
|
||||
@ -2013,7 +1976,6 @@ SceneTree::SceneTree() {
|
||||
call_lock = 0;
|
||||
root_lock = 0;
|
||||
node_count = 0;
|
||||
_physics_interpolation_enabled = false;
|
||||
|
||||
//create with mainloop
|
||||
|
||||
@ -2021,14 +1983,6 @@ SceneTree::SceneTree() {
|
||||
root->set_name("root");
|
||||
root->set_handle_input_locally(false);
|
||||
|
||||
set_physics_interpolation_enabled(GLOBAL_DEF("physics/common/physics_interpolation", false));
|
||||
// Always disable jitter fix if physics interpolation is enabled -
|
||||
// Jitter fix will interfere with interpolation, and is not necessary
|
||||
// when interpolation is active.
|
||||
if (is_physics_interpolation_enabled()) {
|
||||
Engine::get_singleton()->set_physics_jitter_fix(0);
|
||||
}
|
||||
|
||||
// Initialize network state
|
||||
multiplayer_poll = true;
|
||||
set_multiplayer(Ref<MultiplayerAPI>(memnew(MultiplayerAPI)));
|
||||
|
@ -121,7 +121,6 @@ private:
|
||||
bool _quit;
|
||||
bool initialized;
|
||||
bool input_handled;
|
||||
bool _physics_interpolation_enabled;
|
||||
|
||||
Size2 last_screen_size;
|
||||
StringName tree_changed_name;
|
||||
@ -404,9 +403,6 @@ public:
|
||||
void set_refuse_new_network_connections(bool p_refuse);
|
||||
bool is_refusing_new_network_connections() const;
|
||||
|
||||
void set_physics_interpolation_enabled(bool p_enabled);
|
||||
bool is_physics_interpolation_enabled() const;
|
||||
|
||||
static void add_idle_callback(IdleCallback p_callback);
|
||||
SceneTree();
|
||||
~SceneTree();
|
||||
|
@ -1565,26 +1565,6 @@ void RenderingServerCanvas::canvas_item_set_skeleton_relative_xform(RID p_item,
|
||||
}
|
||||
}
|
||||
|
||||
// Useful especially for origin shifting.
|
||||
void RenderingServerCanvas::canvas_item_transform_physics_interpolation(RID p_item, Transform2D p_transform) {
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
canvas_item->xform_prev = p_transform * canvas_item->xform_prev;
|
||||
canvas_item->xform_curr = p_transform * canvas_item->xform_curr;
|
||||
}
|
||||
|
||||
void RenderingServerCanvas::canvas_item_reset_physics_interpolation(RID p_item) {
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
canvas_item->xform_prev = canvas_item->xform_curr;
|
||||
}
|
||||
|
||||
void RenderingServerCanvas::canvas_item_set_interpolated(RID p_item, bool p_interpolated) {
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
canvas_item->interpolated = p_interpolated;
|
||||
}
|
||||
|
||||
void RenderingServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
|
||||
}
|
||||
|
||||
|
@ -241,10 +241,6 @@ public:
|
||||
Rect2 _debug_canvas_item_get_rect(RID p_item);
|
||||
Rect2 _debug_canvas_item_get_local_bound(RID p_item);
|
||||
|
||||
void canvas_item_set_interpolated(RID p_item, bool p_interpolated);
|
||||
void canvas_item_reset_physics_interpolation(RID p_item);
|
||||
void canvas_item_transform_physics_interpolation(RID p_item, Transform2D p_transform);
|
||||
|
||||
void _canvas_item_invalidate_local_bound(RID p_item);
|
||||
void _canvas_item_remove_references(RID p_item, RID p_rid);
|
||||
|
||||
|
@ -387,10 +387,6 @@ public:
|
||||
BIND1R(Rect2, _debug_canvas_item_get_rect, RID)
|
||||
BIND1R(Rect2, _debug_canvas_item_get_local_bound, RID)
|
||||
|
||||
BIND2(canvas_item_set_interpolated, RID, bool)
|
||||
BIND1(canvas_item_reset_physics_interpolation, RID)
|
||||
BIND2(canvas_item_transform_physics_interpolation, RID, Transform2D)
|
||||
|
||||
/* BLACK BARS */
|
||||
|
||||
virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);
|
||||
|
@ -311,10 +311,6 @@ public:
|
||||
FUNC1R(Rect2, _debug_canvas_item_get_rect, RID)
|
||||
FUNC1R(Rect2, _debug_canvas_item_get_local_bound, RID)
|
||||
|
||||
FUNC2(canvas_item_set_interpolated, RID, bool)
|
||||
FUNC1(canvas_item_reset_physics_interpolation, RID)
|
||||
FUNC2(canvas_item_transform_physics_interpolation, RID, Transform2D)
|
||||
|
||||
/* BLACK BARS */
|
||||
|
||||
FUNC4(black_bars_set_margins, int, int, int, int)
|
||||
|
@ -1901,8 +1901,6 @@ void RenderingServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);
|
||||
ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &RenderingServer::viewport_set_hide_canvas);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &RenderingServer::viewport_set_disable_environment);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disabled"), &RenderingServer::viewport_set_disable_3d);
|
||||
ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);
|
||||
ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);
|
||||
@ -1952,9 +1950,6 @@ void RenderingServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_interpolated", "item", "interpolated"), &RenderingServer::canvas_item_set_interpolated);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_reset_physics_interpolation", "item"), &RenderingServer::canvas_item_reset_physics_interpolation);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_transform_physics_interpolation", "item", "xform"), &RenderingServer::canvas_item_transform_physics_interpolation);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);
|
||||
|
@ -571,10 +571,6 @@ public:
|
||||
virtual Rect2 _debug_canvas_item_get_rect(RID p_item) = 0;
|
||||
virtual Rect2 _debug_canvas_item_get_local_bound(RID p_item) = 0;
|
||||
|
||||
virtual void canvas_item_set_interpolated(RID p_item, bool p_interpolated) = 0;
|
||||
virtual void canvas_item_reset_physics_interpolation(RID p_item) = 0;
|
||||
virtual void canvas_item_transform_physics_interpolation(RID p_item, Transform2D p_transform) = 0;
|
||||
|
||||
/* BLACK BARS */
|
||||
|
||||
virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user