From b7950af5171493dee483ec7780381f329e5d364a Mon Sep 17 00:00:00 2001 From: tefusion Date: Thu, 8 Sep 2022 12:01:14 +0200 Subject: [PATCH] Make set_blend_shape_value virtual --- scene/3d/mesh_instance_3d.cpp | 7 +++++-- scene/3d/mesh_instance_3d.h | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index a76f4dd0d59b..b38537d6596f 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -157,7 +157,9 @@ void MeshInstance3D::set_blend_shape_value(int p_blend_shape, float p_value) { ERR_FAIL_COND(mesh.is_null()); ERR_FAIL_INDEX(p_blend_shape, (int)blend_shape_tracks.size()); blend_shape_tracks[p_blend_shape] = p_value; - RenderingServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), p_blend_shape, p_value); + if (!GDVIRTUAL_CALL(set_blend_shape_value, p_blend_shape, p_value)) { + RenderingServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), p_blend_shape, p_value); + } } void MeshInstance3D::_resolve_skeleton_path() { @@ -492,11 +494,12 @@ void MeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &MeshInstance3D::get_blend_shape_count); ClassDB::bind_method(D_METHOD("find_blend_shape_by_name", "name"), &MeshInstance3D::find_blend_shape_by_name); ClassDB::bind_method(D_METHOD("get_blend_shape_value", "blend_shape_idx"), &MeshInstance3D::get_blend_shape_value); - ClassDB::bind_method(D_METHOD("set_blend_shape_value", "blend_shape_idx", "value"), &MeshInstance3D::set_blend_shape_value); ClassDB::bind_method(D_METHOD("create_debug_tangents"), &MeshInstance3D::create_debug_tangents); ClassDB::set_method_flags("MeshInstance3D", "create_debug_tangents", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR); + GDVIRTUAL_BIND(set_blend_shape_value, "p_blend_shape", "p_value"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); ADD_GROUP("Skeleton", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin"); diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index 48d76b9a8897..381c2e0fdfa7 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -74,7 +74,8 @@ class MeshInstance3D : public GeometryInstance3D { int get_blend_shape_count() const; int find_blend_shape_by_name(const StringName &p_name); float get_blend_shape_value(int p_blend_shape) const; - void set_blend_shape_value(int p_blend_shape, float p_value); + virtual void set_blend_shape_value(int p_blend_shape, float p_value); + GDVIRTUAL2(set_blend_shape_value, int, float); int get_surface_override_material_count() const; void set_surface_override_material(int p_surface, const Ref &p_material);