Holy shit this was a pain
- Truly fixes PMX Import lol, i messed up completely - Updated MMD Tools to use Cats One
This commit is contained in:
+13
-23
@@ -1,23 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 MMD Tools authors
|
||||
# This file was originally part of the MMD Tools add-on for Blender
|
||||
# You can find MMD Tools here: https://github.com/MMD-Blender/blender_mmd_tools
|
||||
# Neoneko has modified this file to work with Avatar Toolkit and may of made changes or improvements.
|
||||
# MMD Tools is licensed under the terms of the GNU General Public License version 3 (GPLv3) same as Avatar Toolkit.
|
||||
# Copyright 2018 MMD Tools authors
|
||||
# This file is part of MMD Tools.
|
||||
|
||||
from typing import Set, Tuple
|
||||
from typing import Set
|
||||
|
||||
import bpy
|
||||
from bpy.types import Operator, Context, Object
|
||||
from bpy.types import Operator
|
||||
|
||||
from ..core.model import FnModel
|
||||
from ..core.sdef import FnSDEF
|
||||
from ....core.logging_setup import logger
|
||||
|
||||
|
||||
def _get_target_objects(context: Context) -> Tuple[Set[Object], Set[Object]]:
|
||||
root_objects: Set[Object] = set()
|
||||
selected_objects: Set[Object] = set()
|
||||
def _get_target_objects(context):
|
||||
root_objects: Set[bpy.types.Object] = set()
|
||||
selected_objects: Set[bpy.types.Object] = set()
|
||||
for i in context.selected_objects:
|
||||
if i.type == "MESH":
|
||||
selected_objects.add(i)
|
||||
@@ -41,13 +36,11 @@ class ResetSDEFCache(Operator):
|
||||
bl_description = "Reset MMD SDEF cache of selected objects and clean unused cache"
|
||||
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
||||
|
||||
def execute(self, context: Context) -> Set[str]:
|
||||
def execute(self, context):
|
||||
target_meshes, _ = _get_target_objects(context)
|
||||
logger.info(f"Resetting SDEF cache for {len(target_meshes)} objects")
|
||||
for i in target_meshes:
|
||||
FnSDEF.clear_cache(i)
|
||||
FnSDEF.clear_cache(unused_only=True)
|
||||
logger.debug("SDEF cache reset completed")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -78,20 +71,19 @@ class BindSDEF(Operator):
|
||||
default=False,
|
||||
)
|
||||
|
||||
def invoke(self, context: Context, event: bpy.types.Event) -> Set[str]:
|
||||
def invoke(self, context, event):
|
||||
vm = context.window_manager
|
||||
return vm.invoke_props_dialog(self)
|
||||
|
||||
def execute(self, context: Context) -> Set[str]:
|
||||
# TODO: Utility Functionalize
|
||||
def execute(self, context):
|
||||
target_meshes, root_objects = _get_target_objects(context)
|
||||
logger.info(f"Binding SDEF for {len(target_meshes)} objects with mode={self.mode}, skip={self.use_skip}, scale={self.use_scale}")
|
||||
|
||||
for r in root_objects:
|
||||
r.mmd_root.use_sdef = True
|
||||
|
||||
param = ((None, False, True)[int(self.mode)], self.use_skip, self.use_scale)
|
||||
count = sum(FnSDEF.bind(i, *param) for i in target_meshes)
|
||||
logger.info(f"Successfully bound SDEF for {count} of {len(target_meshes)} meshes")
|
||||
self.report({"INFO"}, f"Binded {count} of {len(target_meshes)} selected mesh(es)")
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -102,15 +94,13 @@ class UnbindSDEF(Operator):
|
||||
bl_description = "Unbind MMD SDEF data of selected objects"
|
||||
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
||||
|
||||
def execute(self, context: Context) -> Set[str]:
|
||||
# TODO: Utility Functionalize
|
||||
def execute(self, context):
|
||||
target_meshes, root_objects = _get_target_objects(context)
|
||||
logger.info(f"Unbinding SDEF for {len(target_meshes)} objects")
|
||||
|
||||
for i in target_meshes:
|
||||
FnSDEF.unbind(i)
|
||||
|
||||
for r in root_objects:
|
||||
r.mmd_root.use_sdef = False
|
||||
|
||||
logger.debug("SDEF unbinding completed")
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user