diff options
author | Ricardo Buring <ricardo.buring@gmail.com> | 2024-05-11 01:22:50 +0200 |
---|---|---|
committer | Ricardo Buring <ricardo.buring@gmail.com> | 2024-08-18 17:14:59 +0200 |
commit | 1728f80e7cd6d8ed4dd5068f7bd5da64b9c6edfa (patch) | |
tree | 1746729a8905252460f43a4392b4265b134c147e /scene/3d/multimesh_instance_3d.cpp | |
parent | a7598679cff6daffbec8f16314b853d87268fff5 (diff) | |
download | redot-engine-1728f80e7cd6d8ed4dd5068f7bd5da64b9c6edfa.tar.gz |
Fixed Timestep Interpolation: MultiMesh
Adds fixed timestep interpolation to multimeshes.
Co-authored-by: lawnjelly <lawnjelly@gmail.com>
Diffstat (limited to 'scene/3d/multimesh_instance_3d.cpp')
-rw-r--r-- | scene/3d/multimesh_instance_3d.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/3d/multimesh_instance_3d.cpp b/scene/3d/multimesh_instance_3d.cpp index 55d6e49e6c..2eef1dbbf4 100644 --- a/scene/3d/multimesh_instance_3d.cpp +++ b/scene/3d/multimesh_instance_3d.cpp @@ -30,16 +30,35 @@ #include "multimesh_instance_3d.h" +void MultiMeshInstance3D::_refresh_interpolated() { + if (is_inside_tree() && multimesh.is_valid()) { + bool interpolated = is_physics_interpolated_and_enabled(); + multimesh->set_physics_interpolated(interpolated); + } +} + +void MultiMeshInstance3D::_physics_interpolated_changed() { + VisualInstance3D::_physics_interpolated_changed(); + _refresh_interpolated(); +} + void MultiMeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance3D::set_multimesh); ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance3D::get_multimesh); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh"); } +void MultiMeshInstance3D::_notification(int p_what) { + if (p_what == NOTIFICATION_ENTER_TREE) { + _refresh_interpolated(); + } +} + void MultiMeshInstance3D::set_multimesh(const Ref<MultiMesh> &p_multimesh) { multimesh = p_multimesh; if (multimesh.is_valid()) { set_base(multimesh->get_rid()); + _refresh_interpolated(); } else { set_base(RID()); } |