1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

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:
Ricardo Buring
2024-02-17 00:57:32 +01:00
parent fe01776f05
commit 2ed2ccc2d8
39 changed files with 1040 additions and 75 deletions

View File

@@ -51,9 +51,12 @@ public:
};
struct Light {
bool enabled;
bool enabled : 1;
bool on_interpolate_transform_list : 1;
bool interpolated : 1;
Color color;
Transform2D xform;
Transform2D xform_curr;
Transform2D xform_prev;
float height;
float energy;
float scale;
@@ -97,6 +100,8 @@ public:
Light() {
version = 0;
enabled = true;
on_interpolate_transform_list = false;
interpolated = true;
color = Color(1, 1, 1);
shadow_color = Color(0, 0, 0, 0);
height = 0;
@@ -307,11 +312,17 @@ public:
Rect2 rect;
};
Transform2D xform;
bool clip;
bool visible;
bool behind;
bool update_when_visible;
// For interpolation we store the current local xform,
// and the previous xform from the previous tick.
Transform2D xform_curr;
Transform2D xform_prev;
bool clip : 1;
bool visible : 1;
bool behind : 1;
bool update_when_visible : 1;
bool on_interpolate_transform_list : 1;
bool interpolated : 1;
struct CanvasGroup {
RS::CanvasGroupMode mode;
@@ -472,6 +483,8 @@ public:
texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
repeat_source = false;
on_interpolate_transform_list = false;
interpolated = true;
}
virtual ~Item() {
clear();
@@ -487,12 +500,15 @@ public:
virtual void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingMethod::RenderInfo *r_render_info = nullptr) = 0;
struct LightOccluderInstance {
bool enabled;
bool enabled : 1;
bool on_interpolate_transform_list : 1;
bool interpolated : 1;
RID canvas;
RID polygon;
RID occluder;
Rect2 aabb_cache;
Transform2D xform;
Transform2D xform_curr;
Transform2D xform_prev;
Transform2D xform_cache;
int light_mask;
bool sdf_collision;
@@ -502,6 +518,8 @@ public:
LightOccluderInstance() {
enabled = true;
on_interpolate_transform_list = false;
interpolated = false;
sdf_collision = false;
next = nullptr;
light_mask = 1;