Merge pull request #107666 from Sch1nken/add-physics-interpolation-multimesh2d

Add MultiMesh physics interpolation for 2D transforms (MultiMeshInstance2D)
This commit is contained in:
Thaddeus Crews
2025-10-03 12:01:07 -05:00
4 changed files with 53 additions and 2 deletions

View File

@ -42,8 +42,24 @@
Callable MultiMeshInstance2D::_navmesh_source_geometry_parsing_callback;
RID MultiMeshInstance2D::_navmesh_source_geometry_parser;
void MultiMeshInstance2D::_refresh_interpolated() {
if (is_inside_tree() && multimesh.is_valid()) {
bool interpolated = is_physics_interpolated_and_enabled();
multimesh->set_physics_interpolated(interpolated);
}
}
void MultiMeshInstance2D::_physics_interpolated_changed() {
CanvasItem::_physics_interpolated_changed();
_refresh_interpolated();
}
void MultiMeshInstance2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_refresh_interpolated();
break;
}
case NOTIFICATION_DRAW: {
if (multimesh.is_valid()) {
draw_multimesh(multimesh, texture);
@ -75,6 +91,7 @@ void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
// Connect to the multimesh so the AABB can update when instance transforms are changed.
if (multimesh.is_valid()) {
multimesh->connect_changed(callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw));
_refresh_interpolated();
}
queue_redraw();
}

View File

@ -43,7 +43,10 @@ class MultiMeshInstance2D : public Node2D {
Ref<Texture2D> texture;
void _refresh_interpolated();
protected:
virtual void _physics_interpolated_changed() override;
void _notification(int p_what);
static void _bind_methods();