Physics Interpolation - add interpolation mode property to node

Exposes the "interpolated" flag on nodes via a property, physics_interpolation_mode.

Mode can be INHERIT, OFF and ON. This makes it easy to turn off interpolation for nodes in the editor, versus via code.
This commit is contained in:
lawnjelly
2022-05-07 13:16:38 +01:00
parent 0ddecccd01
commit 0ab077fcef
3 changed files with 88 additions and 19 deletions

View File

@@ -55,6 +55,13 @@ public:
PAUSE_MODE_PROCESS
};
enum PhysicsInterpolationMode {
PHYSICS_INTERPOLATION_MODE_INHERIT,
PHYSICS_INTERPOLATION_MODE_OFF,
PHYSICS_INTERPOLATION_MODE_ON
};
enum DuplicateFlags {
DUPLICATE_SIGNALS = 1,
@@ -115,7 +122,6 @@ private:
List<Node *>::Element *OW; // owned element
List<Node *> owned;
PauseMode pause_mode;
Node *pause_owner;
int network_master;
@@ -124,6 +130,10 @@ private:
int process_priority;
// 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
bool physics_process : 1;
@@ -424,7 +434,8 @@ public:
bool can_process() const;
bool can_process_notification(int p_what) const;
void set_physics_interpolated(bool p_interpolated);
void set_physics_interpolation_mode(PhysicsInterpolationMode p_mode);
PhysicsInterpolationMode get_physics_interpolation_mode() const { return data.physics_interpolation_mode; }
_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();