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:
Yusarina
2025-11-19 06:35:06 +00:00
parent f0bda259d3
commit a929f68ad4
38 changed files with 4479 additions and 2709 deletions
+20 -30
View File
@@ -1,90 +1,82 @@
# -*- 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.
# This file is part of MMD Tools.
import bpy
from typing import Optional, Set, Dict, Any, List, Tuple, Union, Type
from .. import utils
from ..core import material
from ..core.material import FnMaterial
from ..core.model import FnModel
from . import patch_library_overridable
from ....core.logging_setup import logger
def _mmd_material_update_ambient_color(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_ambient_color(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_ambient_color()
def _mmd_material_update_diffuse_color(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_diffuse_color(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_diffuse_color()
def _mmd_material_update_alpha(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_alpha(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_alpha()
def _mmd_material_update_specular_color(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_specular_color(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_specular_color()
def _mmd_material_update_shininess(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_shininess(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_shininess()
def _mmd_material_update_is_double_sided(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_is_double_sided(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_is_double_sided()
def _mmd_material_update_sphere_texture_type(prop: "MMDMaterial", context: bpy.types.Context) -> None:
def _mmd_material_update_sphere_texture_type(prop: "MMDMaterial", context):
FnMaterial(prop.id_data).update_sphere_texture_type(context.active_object)
def _mmd_material_update_toon_texture(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_toon_texture(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_toon_texture()
def _mmd_material_update_enabled_drop_shadow(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_enabled_drop_shadow(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_drop_shadow()
def _mmd_material_update_enabled_self_shadow_map(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_enabled_self_shadow_map(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_self_shadow_map()
def _mmd_material_update_enabled_self_shadow(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_enabled_self_shadow(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_self_shadow()
def _mmd_material_update_enabled_toon_edge(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_enabled_toon_edge(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_enabled_toon_edge()
def _mmd_material_update_edge_color(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_edge_color(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_edge_color()
def _mmd_material_update_edge_weight(prop: "MMDMaterial", _context: bpy.types.Context) -> None:
def _mmd_material_update_edge_weight(prop: "MMDMaterial", _context):
FnMaterial(prop.id_data).update_edge_weight()
def _mmd_material_get_name_j(prop: "MMDMaterial") -> str:
def _mmd_material_get_name_j(prop: "MMDMaterial"):
return prop.get("name_j", "")
def _mmd_material_set_name_j(prop: "MMDMaterial", value: str) -> None:
def _mmd_material_set_name_j(prop: "MMDMaterial", value: str):
prop_value = value
if prop_value and prop_value != prop.get("name_j"):
root = FnModel.find_root_object(bpy.context.active_object)
if root is None:
logger.debug(f"No root object found, using unique name for material: {value}")
prop_value = utils.unique_name(value, {mat.mmd_material.name_j for mat in bpy.data.materials})
else:
logger.debug(f"Root object found, using unique name for material within model: {value}")
prop_value = utils.unique_name(value, {mat.mmd_material.name_j for mat in FnModel.iterate_materials(root)})
prop["name_j"] = prop_value
@@ -279,15 +271,13 @@ class MMDMaterial(bpy.types.PropertyGroup):
description="Comment",
)
def is_id_unique(self) -> bool:
def is_id_unique(self):
return self.material_id < 0 or not next((m for m in bpy.data.materials if m.mmd_material != self and m.mmd_material.material_id == self.material_id), None)
@staticmethod
def register() -> None:
logger.debug("Registering MMD material properties")
def register():
bpy.types.Material.mmd_material = patch_library_overridable(bpy.props.PointerProperty(type=MMDMaterial))
@staticmethod
def unregister() -> None:
logger.debug("Unregistering MMD material properties")
def unregister():
del bpy.types.Material.mmd_material