Fixed Timestep Interpolation (2D)
Adds fixed timestep interpolation to the rendering server (2D only). Switchable on and off with a project setting (default is off). Co-authored-by: lawnjelly <lawnjelly@gmail.com>
This commit is contained in:
parent
fe01776f05
commit
2ed2ccc2d8
39 changed files with 1040 additions and 75 deletions
|
|
@ -1012,6 +1012,7 @@
|
|||
Distance between the node's top edge and its parent control, based on [member anchor_top].
|
||||
Offsets are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Offsets update automatically when you move or resize the node.
|
||||
</member>
|
||||
<member name="physics_interpolation_mode" type="int" setter="set_physics_interpolation_mode" getter="get_physics_interpolation_mode" overrides="Node" enum="Node.PhysicsInterpolationMode" default="2" />
|
||||
<member name="pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2(0, 0)">
|
||||
By default, the node's pivot is its top-left corner. When you change its [member rotation] or [member scale], it will rotate or scale around this pivot. Set this property to [member size] / 2 to pivot around the Control's center.
|
||||
</member>
|
||||
|
|
|
|||
|
|
@ -619,6 +619,21 @@
|
|||
[method request_ready] resets it back to [code]false[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_physics_interpolated" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if physics interpolation is enabled for this node (see [member physics_interpolation_mode]).
|
||||
[b]Note:[/b] Interpolation will only be active if both the flag is set [b]and[/b] physics interpolation is enabled within the [SceneTree]. This can be tested using [method is_physics_interpolated_and_enabled].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_physics_interpolated_and_enabled" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if physics interpolation is enabled (see [member physics_interpolation_mode]) [b]and[/b] enabled in the [SceneTree].
|
||||
This is a convenience version of [method is_physics_interpolated] that also checks whether physics interpolation is enabled globally.
|
||||
See [member SceneTree.physics_interpolation] and [member ProjectSettings.physics/common/physics_interpolation].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_physics_processing" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
|
@ -793,6 +808,15 @@
|
|||
[b]Note:[/b] This method only affects the current node. If the node's children also need to request ready, this method needs to be called for each one of them. When the node and its children enter the tree again, the order of [method _ready] callbacks will be the same as normal.
|
||||
</description>
|
||||
</method>
|
||||
<method name="reset_physics_interpolation">
|
||||
<return type="void" />
|
||||
<description>
|
||||
When physics interpolation is active, moving a node to a radically different transform (such as placement within a level) can result in a visible glitch as the object is rendered moving from the old to new position over the physics tick.
|
||||
That glitch can be prevented by calling this method, which temporarily disables interpolation until the physics tick is complete.
|
||||
The notification [constant NOTIFICATION_RESET_PHYSICS_INTERPOLATION] will be received by the node and all children recursively.
|
||||
[b]Note:[/b] This function should be called [b]after[/b] moving the node, rather than before.
|
||||
</description>
|
||||
</method>
|
||||
<method name="rpc" qualifiers="vararg">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="method" type="StringName" />
|
||||
|
|
@ -964,6 +988,10 @@
|
|||
The owner of this node. The owner must be an ancestor of this node. When packing the owner node in a [PackedScene], all the nodes it owns are also saved with it.
|
||||
[b]Note:[/b] In the editor, nodes not owned by the scene root are usually not displayed in the Scene dock, and will [b]not[/b] be saved. To prevent this, remember to set the owner after calling [method add_child]. See also (see [member unique_name_in_owner])
|
||||
</member>
|
||||
<member name="physics_interpolation_mode" type="int" setter="set_physics_interpolation_mode" getter="get_physics_interpolation_mode" enum="Node.PhysicsInterpolationMode" default="0">
|
||||
Allows enabling or disabling physics interpolation per node, offering a finer grain of control than turning physics interpolation on and off globally. See [member ProjectSettings.physics/common/physics_interpolation] and [member SceneTree.physics_interpolation] for the global setting.
|
||||
[b]Note:[/b] When teleporting a node to a distant position you should temporarily disable interpolation with [method Node.reset_physics_interpolation].
|
||||
</member>
|
||||
<member name="process_mode" type="int" setter="set_process_mode" getter="get_process_mode" enum="Node.ProcessMode" default="0">
|
||||
The node's processing behavior (see [enum ProcessMode]). To check if the node can process in its current mode, use [method can_process].
|
||||
</member>
|
||||
|
|
@ -1122,6 +1150,9 @@
|
|||
<constant name="NOTIFICATION_ENABLED" value="29">
|
||||
Notification received when the node is enabled again after being disabled. See [constant PROCESS_MODE_DISABLED].
|
||||
</constant>
|
||||
<constant name="NOTIFICATION_RESET_PHYSICS_INTERPOLATION" value="2001">
|
||||
Notification received when [method reset_physics_interpolation] is called on the node or its ancestors.
|
||||
</constant>
|
||||
<constant name="NOTIFICATION_EDITOR_PRE_SAVE" value="9001">
|
||||
Notification received right before the scene with the node is saved in the editor. This notification is only sent in the Godot editor and will not occur in exported projects.
|
||||
</constant>
|
||||
|
|
@ -1237,6 +1268,15 @@
|
|||
<constant name="FLAG_PROCESS_THREAD_MESSAGES_ALL" value="3" enum="ProcessThreadMessages" is_bitfield="true">
|
||||
Allows this node to process threaded messages created with [method call_deferred_thread_group] right before either [method _process] or [method _physics_process] are called.
|
||||
</constant>
|
||||
<constant name="PHYSICS_INTERPOLATION_MODE_INHERIT" value="0" enum="PhysicsInterpolationMode">
|
||||
Inherits [member physics_interpolation_mode] from the node's parent. This is the default for any newly created node.
|
||||
</constant>
|
||||
<constant name="PHYSICS_INTERPOLATION_MODE_ON" value="1" enum="PhysicsInterpolationMode">
|
||||
Enables physics interpolation for this node and for children set to [constant PHYSICS_INTERPOLATION_MODE_INHERIT]. This is the default for the root node.
|
||||
</constant>
|
||||
<constant name="PHYSICS_INTERPOLATION_MODE_OFF" value="2" enum="PhysicsInterpolationMode">
|
||||
Disables physics interpolation for this node and for children set to [constant PHYSICS_INTERPOLATION_MODE_INHERIT].
|
||||
</constant>
|
||||
<constant name="DUPLICATE_SIGNALS" value="1" enum="DuplicateFlags">
|
||||
Duplicate the node's signal connections.
|
||||
</constant>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<member name="limit_end" type="Vector2" setter="set_limit_end" getter="get_limit_end" default="Vector2(1e+07, 1e+07)">
|
||||
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the [Parallax2D] will stop scrolling. Must be higher than [member limit_begin] and the viewport size combined to work.
|
||||
</member>
|
||||
<member name="physics_interpolation_mode" type="int" setter="set_physics_interpolation_mode" getter="get_physics_interpolation_mode" overrides="Node" enum="Node.PhysicsInterpolationMode" default="2" />
|
||||
<member name="repeat_size" type="Vector2" setter="set_repeat_size" getter="get_repeat_size" default="Vector2(0, 0)">
|
||||
Repeats the [Texture2D] of each of this node's children and offsets them by this value. When scrolling, the node's position loops, giving the illusion of an infinite scrolling background if the values are larger than the screen size. If an axis is set to [code]0[/code], the [Texture2D] will not be repeated.
|
||||
</member>
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@
|
|||
<member name="motion_scale" type="Vector2" setter="set_motion_scale" getter="get_motion_scale" default="Vector2(1, 1)">
|
||||
Multiplies the ParallaxLayer's motion. If an axis is set to [code]0[/code], it will not scroll.
|
||||
</member>
|
||||
<member name="physics_interpolation_mode" type="int" setter="set_physics_interpolation_mode" getter="get_physics_interpolation_mode" overrides="Node" enum="Node.PhysicsInterpolationMode" default="2" />
|
||||
</members>
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -2266,9 +2266,15 @@
|
|||
Controls the maximum number of physics steps that can be simulated each rendered frame. The default value is tuned to avoid "spiral of death" situations where expensive physics simulations trigger more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than [code]1 / max_physics_steps_per_frame[/code] of [member physics/common/physics_ticks_per_second]. This occurs even if [code]delta[/code] is consistently used in physics calculations. To avoid this, increase [member physics/common/max_physics_steps_per_frame] if you have increased [member physics/common/physics_ticks_per_second] significantly above its default value.
|
||||
[b]Note:[/b] This property is only read when the project starts. To change the maximum number of simulated physics steps per frame at runtime, set [member Engine.max_physics_steps_per_frame] instead.
|
||||
</member>
|
||||
<member name="physics/common/physics_interpolation" type="bool" setter="" getter="" default="false">
|
||||
If [code]true[/code], the renderer will interpolate the transforms of physics objects between the last two transforms, so that smooth motion is seen even when physics ticks do not coincide with rendered frames. See also [member Node.physics_interpolation_mode] and [method Node.reset_physics_interpolation].
|
||||
[b]Note:[/b] If [code]true[/code], the physics jitter fix should be disabled by setting [member physics/common/physics_jitter_fix] to [code]0.0[/code].
|
||||
[b]Note:[/b] This property is only read when the project starts. To toggle physics interpolation at runtime, set [member SceneTree.physics_interpolation] instead.
|
||||
[b]Note:[/b] This feature is currently only implemented in the 2D renderer.
|
||||
</member>
|
||||
<member name="physics/common/physics_jitter_fix" type="float" setter="" getter="" default="0.5">
|
||||
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be good enough for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
|
||||
[b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics/common/physics_jitter_fix] to [code]0[/code].
|
||||
[b]Note:[/b] When using a physics interpolation solution (such as enabling [member physics/common/physics_interpolation] or using a custom solution), the physics jitter fix should be disabled by setting [member physics/common/physics_jitter_fix] to [code]0.0[/code].
|
||||
[b]Note:[/b] This property is only read when the project starts. To change the physics jitter fix at runtime, set [member Engine.physics_jitter_fix] instead.
|
||||
</member>
|
||||
<member name="physics/common/physics_ticks_per_second" type="int" setter="" getter="" default="60">
|
||||
|
|
|
|||
|
|
@ -424,6 +424,14 @@
|
|||
[b]Note:[/b] The equivalent node is [CanvasItem].
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_reset_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="RID" />
|
||||
<description>
|
||||
Prevents physics interpolation for the current physics tick.
|
||||
This is useful when moving a canvas item to a new location, to give an instantaneous change rather than interpolation from the previous location.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_set_canvas_group_mode">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="RID" />
|
||||
|
|
@ -504,6 +512,14 @@
|
|||
Sets the index for the [CanvasItem].
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_set_interpolated">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="RID" />
|
||||
<param index="1" name="interpolated" type="bool" />
|
||||
<description>
|
||||
If [param interpolated] is [code]true[/code], turns on physics interpolation for the canvas item.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_set_light_mask">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="RID" />
|
||||
|
|
@ -612,6 +628,15 @@
|
|||
Sets the [CanvasItem]'s Z index, i.e. its draw order (lower indexes are drawn first).
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_item_transform_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="RID" />
|
||||
<param index="1" name="transform" type="Transform2D" />
|
||||
<description>
|
||||
Transforms both the current and previous stored transform for a canvas item.
|
||||
This allows transforming a canvas item without creating a "glitch" in the interpolation, which is particularly useful for large worlds utilising a shifting origin.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_attach_to_canvas">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
|
|
@ -644,6 +669,14 @@
|
|||
[b]Note:[/b] The equivalent node is [LightOccluder2D].
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_occluder_reset_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="occluder" type="RID" />
|
||||
<description>
|
||||
Prevents physics interpolation for the current physics tick.
|
||||
This is useful when moving an occluder to a new location, to give an instantaneous change rather than interpolation from the previous location.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_occluder_set_as_sdf_collision">
|
||||
<return type="void" />
|
||||
<param index="0" name="occluder" type="RID" />
|
||||
|
|
@ -659,6 +692,14 @@
|
|||
Enables or disables light occluder.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_occluder_set_interpolated">
|
||||
<return type="void" />
|
||||
<param index="0" name="occluder" type="RID" />
|
||||
<param index="1" name="interpolated" type="bool" />
|
||||
<description>
|
||||
If [param interpolated] is [code]true[/code], turns on physics interpolation for the light occluder.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_occluder_set_light_mask">
|
||||
<return type="void" />
|
||||
<param index="0" name="occluder" type="RID" />
|
||||
|
|
@ -683,6 +724,23 @@
|
|||
Sets a light occluder's [Transform2D].
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_occluder_transform_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="occluder" type="RID" />
|
||||
<param index="1" name="transform" type="Transform2D" />
|
||||
<description>
|
||||
Transforms both the current and previous stored transform for a light occluder.
|
||||
This allows transforming an occluder without creating a "glitch" in the interpolation, which is particularly useful for large worlds utilising a shifting origin.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_reset_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
<description>
|
||||
Prevents physics interpolation for the current physics tick.
|
||||
This is useful when moving a canvas item to a new location, to give an instantaneous change rather than interpolation from the previous location.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_set_blend_mode">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
|
|
@ -723,6 +781,14 @@
|
|||
Sets a canvas light's height.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_set_interpolated">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
<param index="1" name="interpolated" type="bool" />
|
||||
<description>
|
||||
If [param interpolated] is [code]true[/code], turns on physics interpolation for the canvas light.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_set_item_cull_mask">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
|
|
@ -829,6 +895,15 @@
|
|||
Sets the Z range of objects that will be affected by this light. Equivalent to [member Light2D.range_z_min] and [member Light2D.range_z_max].
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_light_transform_physics_interpolation">
|
||||
<return type="void" />
|
||||
<param index="0" name="light" type="RID" />
|
||||
<param index="1" name="transform" type="Transform2D" />
|
||||
<description>
|
||||
Transforms both the current and previous stored transform for a canvas light.
|
||||
This allows transforming a light without creating a "glitch" in the interpolation, which is is particularly useful for large worlds utilising a shifting origin.
|
||||
</description>
|
||||
</method>
|
||||
<method name="canvas_occluder_polygon_create">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
|
|
|
|||
|
|
@ -264,6 +264,10 @@
|
|||
- 2D and 3D physics will be stopped, as well as collision detection and related signals.
|
||||
- Depending on each node's [member Node.process_mode], their [method Node._process], [method Node._physics_process] and [method Node._input] callback methods may not called anymore.
|
||||
</member>
|
||||
<member name="physics_interpolation" type="bool" setter="set_physics_interpolation_enabled" getter="is_physics_interpolation_enabled" default="false">
|
||||
If [code]true[/code], the renderer will interpolate the transforms of physics objects between the last two transforms, so that smooth motion is seen even when physics ticks do not coincide with rendered frames.
|
||||
The default value of this property is controlled by [member ProjectSettings.physics/common/physics_interpolation].
|
||||
</member>
|
||||
<member name="quit_on_go_back" type="bool" setter="set_quit_on_go_back" getter="is_quit_on_go_back" default="true">
|
||||
If [code]true[/code], the application quits automatically when navigating back (e.g. using the system "Back" button on Android).
|
||||
To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue