Skip to content

Commit

Permalink
Remove unsupported legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
UuuNyaa committed Dec 7, 2023
1 parent 1bac95d commit 32345bb
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 484 deletions.
353 changes: 46 additions & 307 deletions mmd_tools/core/material.py

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions mmd_tools/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,26 +472,6 @@ def update_mmd_tools_version():
root_object["mmd_tools_version"] = "2.8.0"


# SUPPORT_UNTIL: 4.3 LTS
def isRigidBodyObject(obj):
return FnModel.is_rigid_body_object(obj)


# SUPPORT_UNTIL: 4.3 LTS
def isJointObject(obj):
return FnModel.is_joint_object(obj)


# SUPPORT_UNTIL: 4.3 LTS
def isTemporaryObject(obj):
return FnModel.is_temporary_object(obj)


# SUPPORT_UNTIL: 4.3 LTS
def getRigidBodySize(obj):
return FnModel.get_rigid_body_size(obj)


class Model:
def __init__(self, root_obj):
if root_obj.mmd_type != "ROOT":
Expand Down
2 changes: 1 addition & 1 deletion mmd_tools/core/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mmd_tools.bpyutils import ObjectOp, SceneOp, TransformConstraintOp


class FnMorph(object):
class FnMorph:
def __init__(self, morph, model):
self.__morph = morph
self.__rig = model
Expand Down
2 changes: 1 addition & 1 deletion mmd_tools/operators/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def execute(self, context):
return {"FINISHED"}


class _OpenTextureBase(object):
class _OpenTextureBase:
"""Create a texture for mmd model material."""

bl_options = {"REGISTER", "UNDO", "INTERNAL"}
Expand Down
2 changes: 1 addition & 1 deletion mmd_tools/operators/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def __configure_rig(self, context, rig):

FnMaterial.set_nodes_are_readonly(not self.convert_material_nodes)
try:
for m in {x for mesh in meshes for x in mesh.data.materials if x}:
for m in (x for mesh in meshes for x in mesh.data.materials if x):
FnMaterial.convert_to_mmd_material(m, context)
mmd_material = m.mmd_material
if self.ambient_color_source == "MIRROR" and hasattr(m, "mirror_color"):
Expand Down
34 changes: 16 additions & 18 deletions mmd_tools/operators/rigid_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import bpy

import mmd_tools.core.model as mmd_model
from mmd_tools import utils
from mmd_tools.bpyutils import Props, activate_layer_collection
from mmd_tools.core import rigid_body
from mmd_tools.core.model import FnModel, Model


class SelectRigidBody(bpy.types.Operator):
Expand Down Expand Up @@ -44,17 +44,16 @@ def invoke(self, context, event):

@classmethod
def poll(cls, context):
return mmd_model.isRigidBodyObject(context.active_object)
return FnModel.is_rigid_body_object(context.active_object)

def execute(self, context):
obj = context.active_object
root = mmd_model.Model.findRoot(obj)
root = FnModel.find_root(obj)
if root is None:
self.report({"ERROR"}, "The model root can't be found")
return {"CANCELLED"}

rig = mmd_model.Model(root)
selection = set(rig.rigidBodies())
selection = set(FnModel.iterate_rigid_body_objects(root))

for prop_name in self.properties:
prop_value = getattr(obj.mmd_rigid, prop_name)
Expand Down Expand Up @@ -222,8 +221,8 @@ def __add_rigid_body(self, rig, arm_obj=None, pose_bone=None):

def execute(self, context):
obj = context.active_object
root = mmd_model.Model.findRoot(obj)
rig = mmd_model.Model(root)
root = FnModel.find_root(obj)
rig = Model(root)
arm = rig.armature()
if obj != arm:
utils.selectAObject(root)
Expand Down Expand Up @@ -272,11 +271,11 @@ class RemoveRigidBody(bpy.types.Operator):

@classmethod
def poll(cls, context):
return mmd_model.isRigidBodyObject(context.active_object)
return FnModel.is_rigid_body_object(context.active_object)

def execute(self, context):
obj = context.active_object
root = mmd_model.Model.findRoot(obj)
root = FnModel.find_root(obj)
utils.selectAObject(obj) # ensure this is the only one object select
bpy.ops.object.delete(use_global=True)
if root:
Expand Down Expand Up @@ -415,13 +414,13 @@ def __add_joint(self, rig, rigid_pair, bone_map):

def execute(self, context):
obj = context.active_object
root = mmd_model.Model.findRoot(obj)
rig = mmd_model.Model(root)
root = FnModel.find_root(obj)
rig = Model(root)

arm = rig.armature()
bone_map = {}
for i in context.selected_objects:
if mmd_model.isRigidBodyObject(i):
if FnModel.is_rigid_body_object(i):
bone_map[i] = arm.data.bones.get(i.mmd_rigid.bone, None)

if len(bone_map) < 2:
Expand Down Expand Up @@ -452,11 +451,11 @@ class RemoveJoint(bpy.types.Operator):

@classmethod
def poll(cls, context):
return mmd_model.isJointObject(context.active_object)
return FnModel.is_joint_object(context.active_object)

def execute(self, context):
obj = context.active_object
root = mmd_model.Model.findRoot(obj)
root = FnModel.find_root(obj)
utils.selectAObject(obj) # ensure this is the only one object select
bpy.ops.object.delete(use_global=True)
if root:
Expand Down Expand Up @@ -508,7 +507,6 @@ def _references(obj):
if getattr(obj, "override_library", None):
yield from _references(obj.override_library.reference)

_find_root = mmd_model.FnModel.find_root
need_rebuild_physics = scene.rigidbody_world is None or scene.rigidbody_world.collection is None or scene.rigidbody_world.constraints is None
rb_objs, rbc_objs = self.__get_rigid_body_world_objects()
objects = bpy.data.objects
Expand All @@ -523,7 +521,7 @@ def _references(obj):
if not _update_group(i, rb_objs):
continue

rb_map = table.setdefault(_find_root(i), {})
rb_map = table.setdefault(FnModel.find_root(i), {})
if i in rb_map: # means rb_map[i] will replace i
rb_objs.unlink(i)
continue
Expand All @@ -537,7 +535,7 @@ def _references(obj):
if not _update_group(i, rbc_objs):
continue

rbc, root = i.rigid_body_constraint, _find_root(i)
rbc, root = i.rigid_body_constraint, FnModel.find_root(i)
rb_map = table.get(root, {})
rbc.object1 = rb_map.get(rbc.object1, rbc.object1)
rbc.object2 = rb_map.get(rbc.object2, rbc.object2)
Expand All @@ -549,7 +547,7 @@ def _references(obj):
if not root.mmd_root.is_built:
continue
with activate_layer_collection(root):
mmd_model.Model(root).build()
Model(root).build()
# After rebuild. First play. Will be crash!
# But saved it before. Reload after crash. The play can be work.

Expand Down
11 changes: 4 additions & 7 deletions mmd_tools/panels/prop_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@

import bpy

import mmd_tools.core.model as mmd_model
from mmd_tools.core.model import FnModel


class _PanelBase(object):
class MMDModelObjectPanel(bpy.types.Panel):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"


class MMDModelObjectPanel(_PanelBase, bpy.types.Panel):
bl_idname = "OBJECT_PT_mmd_tools_root_object"
bl_label = "MMD Model Information"

@classmethod
def poll(cls, context):
return mmd_model.FnModel.find_root(context.active_object)
return FnModel.find_root(context.active_object)

def draw(self, context):
layout = self.layout
obj = context.active_object

root = mmd_model.FnModel.find_root(obj)
root = FnModel.find_root(obj)

c = layout.column()
c.prop(root.mmd_root, "name")
Expand Down
5 changes: 3 additions & 2 deletions mmd_tools/panels/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from mmd_tools.bpyutils import SceneOp
from mmd_tools.utils import ItemOp

class _PanelBase(object):

class _PanelBase:
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "MMD"
Expand Down Expand Up @@ -595,7 +596,7 @@ def _draw_group_data(self, context, rig, col, morph):
row.prop(item, "morph_type", text="")


class UL_ObjectsMixIn(object):
class UL_ObjectsMixIn:
model_filter: bpy.props.EnumProperty(
name="Model Filter",
description="Show items of active model or all models",
Expand Down
17 changes: 0 additions & 17 deletions mmd_tools/panels/view_header.py

This file was deleted.

103 changes: 0 additions & 103 deletions mmd_tools/panels/view_prop.py

This file was deleted.

6 changes: 3 additions & 3 deletions mmd_tools/properties/rigid_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from mmd_tools import bpyutils
from mmd_tools.core import rigid_body
from mmd_tools.core.model import FnModel, getRigidBodySize
from mmd_tools.core.model import FnModel


def _updateCollisionGroup(prop, context):
Expand Down Expand Up @@ -74,7 +74,7 @@ def _set_bone(prop, value):
def _get_size(prop):
if prop.id_data.mmd_type != "RIGID_BODY":
return (0, 0, 0)
return getRigidBodySize(prop.id_data)
return FnModel.get_rigid_body_size(prop.id_data)


def _set_size(prop, value):
Expand Down Expand Up @@ -122,7 +122,7 @@ def _set_size(prop, value):
z0 = -z if z0 < 0 else z
v.co = [x0, y0, z0]
elif shape == "CAPSULE":
r0, h0, xx = getRigidBodySize(prop.id_data)
r0, h0, xx = FnModel.get_rigid_body_size(prop.id_data)
h0 *= 0.5
radius = max(value[0], 1e-3)
height = max(value[1], 1e-3) * 0.5
Expand Down
Loading

0 comments on commit 32345bb

Please sign in to comment.