From c0ada8b6ca3ce8ef4ff0a81b8c1e881c7d1af884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20K=C3=B6hler?= Date: Sat, 13 Oct 2018 00:24:23 +0200 Subject: [PATCH] Fix: Joints and Rigidbodies now get deleted correctly, 0.11.2 ready! --- README.md | 6 +++++- __init__.py | 2 +- tools/armature.py | 16 ++++++++++++---- tools/common.py | 26 ++++++++++++++------------ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index be939d67..c02d200d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Cats Blender Plugin (0.11.1) +# Cats Blender Plugin (0.11.2) A tool designed to shorten steps needed to import and optimize models into VRChat. Compatible models are: MMD, XNALara, Mixamo, Source Engine, Unreal Engine, DAZ/Poser, Blender Rigify, Sims 2, Motion Builder, 3DS Max and potentially more @@ -335,6 +335,10 @@ It checks for a new version automatically once every day. ## Changelog +#### 0.11.2 +- **Model**: + - Fix: Joints and Rigidbodies now get deleted correctly + #### 0.11.1 - **Export**: - Embed Textures is not longer enabled by default, but can now be enabled in the settings diff --git a/__init__.py b/__init__.py index 0ef948db..aaf77c9d 100644 --- a/__init__.py +++ b/__init__.py @@ -112,7 +112,7 @@ 'author': 'GiveMeAllYourCats', 'location': 'View 3D > Tool Shelf > CATS', 'description': 'A tool designed to shorten steps needed to import and optimize MMD models into VRChat', - 'version': [0, 11, 1], # Only change this version and the dev branch var right before publishing the new update! + 'version': [0, 11, 2], # Only change this version and the dev branch var right before publishing the new update! 'blender': (2, 79, 0), 'wiki_url': 'https://github.com/michaeldegroot/cats-blender-plugin', 'tracker_url': 'https://github.com/michaeldegroot/cats-blender-plugin/issues', diff --git a/tools/armature.py b/tools/armature.py index f52b021a..41acbc1a 100644 --- a/tools/armature.py +++ b/tools/armature.py @@ -202,7 +202,7 @@ def execute(self, context): tools.common.delete_hierarchy(mesh) # Reset to default - tools.common.set_default_stage() + armature = tools.common.set_default_stage() # Set better bone view armature.data.draw_type = 'OCTAHEDRAL' @@ -216,9 +216,17 @@ def execute(self, context): context.area.spaces[0].show_backface_culling = False # Remove Rigidbodies and joints - for obj in bpy.data.objects: - if 'rigidbodies' in obj.name or 'joints' in obj.name: - tools.common.delete_hierarchy(obj) + to_delete = [] + for child in tools.common.get_top_parent(armature).children: + if 'rigidbodies' in child.name or 'joints' in child.name: + to_delete.append(child.name) + continue + for child2 in child.children: + if 'rigidbodies' in child2.name or 'joints' in child2.name: + to_delete.append(child2.name) + continue + for obj_name in to_delete: + tools.common.delete_hierarchy(bpy.data.objects[obj_name]) # Remove objects from different layers and things that are not meshes for child in armature.children: diff --git a/tools/common.py b/tools/common.py index 840a46b7..903ba816 100644 --- a/tools/common.py +++ b/tools/common.py @@ -76,10 +76,18 @@ def get_armature_objects(): return armatures -def unhide_all(everything=False): - armature = get_armature() +def get_top_parent(child): + if child.parent: + return get_top_parent(child.parent) + return child + + +def unhide_all(everything=False, obj_to_unhide=None): + if not obj_to_unhide: + obj_to_unhide = get_armature() + if version_2_79_or_older(): - if everything or not armature: + if everything or not obj_to_unhide: for obj in bpy.data.objects: obj.hide = False else: @@ -88,15 +96,9 @@ def unhide_children(parent): child.hide = False unhide_children(child) - def unhide_parents(child): - parent = child.parent - if parent: - parent.hide = False - unhide_parents(parent) - - armature.hide = False - unhide_children(armature) - unhide_parents(armature) + top_parent = get_top_parent(obj_to_unhide) + top_parent.hide = False + unhide_children(top_parent) else: for obj in bpy.data.collections: obj.hide_viewport = False