Catch models that are marked as bones but still have geometry
This commit is contained in:
		| @@ -221,19 +221,26 @@ def extract_scene(filepath: str, scene: Scene): | |||||||
|  |  | ||||||
|             # Parent the object to a bone if necessary |             # Parent the object to a bone if necessary | ||||||
|             else: |             else: | ||||||
|                 if curr_model.parent in armature.data.bones and curr_model.name not in armature.data.bones: |                 parent_bone_name = "" | ||||||
|  |                 if curr_model.name in armature.data.bones and curr_model.geometry: | ||||||
|  |                     parent_bone_name = curr_model.name | ||||||
|  |                 elif curr_model.parent in armature.data.bones and curr_model.name not in armature.data.bones: | ||||||
|  |                     parent_bone_name = curr_model.parent | ||||||
|  |  | ||||||
|  |                 if parent_bone_name: | ||||||
|                     # Not sure what the different mats do, but saving the worldmat and  |                     # Not sure what the different mats do, but saving the worldmat and  | ||||||
|                     # applying it after clearing the other mats yields correct results... |                     # applying it after clearing the other mats yields correct results... | ||||||
|                     worldmat = curr_obj.matrix_world |                     worldmat = curr_obj.matrix_world | ||||||
|  |  | ||||||
|                     curr_obj.parent = armature |                     curr_obj.parent = armature | ||||||
|                     curr_obj.parent_type = 'BONE' |                     curr_obj.parent_type = 'BONE' | ||||||
|                     curr_obj.parent_bone = curr_model.parent |                     curr_obj.parent_bone = parent_bone_name | ||||||
|                     # '' |                     # '' | ||||||
|                     curr_obj.matrix_basis = Matrix() |                     curr_obj.matrix_basis = Matrix() | ||||||
|                     curr_obj.matrix_parent_inverse = Matrix() |                     curr_obj.matrix_parent_inverse = Matrix() | ||||||
|                     curr_obj.matrix_world = worldmat |                     curr_obj.matrix_world = worldmat | ||||||
|  |  | ||||||
|  |  | ||||||
|         ''' |         ''' | ||||||
|         Sometimes skins are parented to other skins.  We need to find the skin highest in the hierarchy and |         Sometimes skins are parented to other skins.  We need to find the skin highest in the hierarchy and | ||||||
|         parent all skins to its parent (armature_reparent_obj). |         parent all skins to its parent (armature_reparent_obj). | ||||||
| @@ -264,7 +271,7 @@ def extract_scene(filepath: str, scene: Scene): | |||||||
|         # object counterpart (as created in extract_models) |         # object counterpart (as created in extract_models) | ||||||
|         for bone in skel: |         for bone in skel: | ||||||
|             model_to_remove = model_map[bone.name] |             model_to_remove = model_map[bone.name] | ||||||
|             if model_to_remove: |             if model_to_remove and model_to_remove.parent_bone == "": | ||||||
|                 bpy.data.objects.remove(model_to_remove, do_unlink=True) |                 bpy.data.objects.remove(model_to_remove, do_unlink=True) | ||||||
|                 model_map.pop(bone.name) |                 model_map.pop(bone.name) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 William Herald Snyder
					William Herald Snyder