Browse Source

Use an internal skin unless one is supplied by user, fixes #32766
Even though this fixes the issue, the broken Skin resource in the inherited scene mesh will remain, it needs to be erased manually.

Juan Linietsky 5 years ago
parent
commit
21dec856f2
2 changed files with 5 additions and 3 deletions
  1. 4 3
      scene/3d/mesh_instance.cpp
  2. 1 0
      scene/3d/mesh_instance.h

+ 4 - 3
scene/3d/mesh_instance.cpp

@@ -154,10 +154,10 @@ void MeshInstance::_resolve_skeleton_path() {
 	if (!skeleton_path.is_empty()) {
 	if (!skeleton_path.is_empty()) {
 		Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path));
 		Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path));
 		if (skeleton) {
 		if (skeleton) {
-			new_skin_reference = skeleton->register_skin(skin);
-			if (skin.is_null()) {
+			new_skin_reference = skeleton->register_skin(skin_internal);
+			if (skin_internal.is_null()) {
 				//a skin was created for us
 				//a skin was created for us
-				skin = new_skin_reference->get_skin();
+				skin_internal = new_skin_reference->get_skin();
 				_change_notify();
 				_change_notify();
 			}
 			}
 		}
 		}
@@ -173,6 +173,7 @@ void MeshInstance::_resolve_skeleton_path() {
 }
 }
 
 
 void MeshInstance::set_skin(const Ref<Skin> &p_skin) {
 void MeshInstance::set_skin(const Ref<Skin> &p_skin) {
+	skin_internal = p_skin;
 	skin = p_skin;
 	skin = p_skin;
 	if (!is_inside_tree())
 	if (!is_inside_tree())
 		return;
 		return;

+ 1 - 0
scene/3d/mesh_instance.h

@@ -43,6 +43,7 @@ class MeshInstance : public GeometryInstance {
 protected:
 protected:
 	Ref<Mesh> mesh;
 	Ref<Mesh> mesh;
 	Ref<Skin> skin;
 	Ref<Skin> skin;
+	Ref<Skin> skin_internal;
 	Ref<SkinReference> skin_ref;
 	Ref<SkinReference> skin_ref;
 	NodePath skeleton_path;
 	NodePath skeleton_path;