<commit_before># -*- coding: utf-8 -*-

import bpy
from bpy.types import Operator
import mathutils

from . import pmx
from . import bpyutils

import re
import math
import logging
import time


#####################
# Rigging Oparators #
#####################
class CleanRiggingObjects(Operator):
    bl_idname = 'mmd_tools.clean_rig'
    bl_label = 'Clean'
    bl_description = 'Clean temporary objects of rigging'
    bl_options = {'PRESET'}

    def execute(self, context):
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.clean()
        return {'FINISHED'}

class BuildRig(Operator):
    bl_idname = 'mmd_tools.build_rig'
    bl_label = 'Build'
    bl_description = ''
    bl_options = {'PRESET'}

    def execute(self, context):
        obj = context.active_object
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.build()
        context.scene.objects.active = obj
        return {'FINISHED'}

class ApplyAdditionalTransformConstraints(Operator):
    bl_idname = 'mmd_tools.apply_additioinal_transform'
    bl_label = 'Apply Additional Transform'
    bl_description = ''
    bl_options = {'PRESET'}

    def execute(self, context):
        obj = context.active_object
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.applyAdditionalTransformConstraints()
        context.scene.objects.active = obj
        return {'FINISHED'}


def isRigidBodyObject(obj):
    return obj.mmd_type == 'RIGID_BODY'

def isJointObject(obj):
    return obj.mmd_type == 'JOINT'

def isTemporaryObject(obj):
    return obj.mmd_type in ['TRACK_TARGET', 'NON_COLLISION_CONSTRAINT', 'SPRING_CONSTRAINT', 'SPRING_GOAL']

def findRelationalBone(rigid_body):
    relation = rigid_body.constraints.get('mmd_tools_rigid_parent')
    if relation is not None:
        return (relation.target, relation.subtarget)
    else:
        arm = getArmatureObject(rigid_body)
        track = None
        for i in filter(lambda x: x.mmd_type == 'TRACK_TARGET', rigid_body.children):
            track = i
        if track is None:
            return (arm, '')

        for bone in arm.pose.bones:
            c = bone.constraints.get('mmd_tools_rigid_track')
            if c is not None and c.target == track:
                return (arm, bone.name)
        return (arm, '')

def getRigidBodySize(obj):
    if not isRigidBodyObject(obj):
        raise ValueError

    if obj.mmd_rigid.shape == 'SPHERE':
        max_z = 0
        for v in obj.data.vertices:
            vc = v.co
            if vc.z > max_z:
                max_z = vc.z
        return (max_z, 0.0, 0.0)
    elif obj.mmd_rigid.shape == 'BOX':
        v = obj.data.vertices[0].co
        x, y, z = map(abs, v)
        return (x, y, z)<commit_msg>不要コード削除<commit_after># -*- coding: utf-8 -*-

import bpy
from bpy.types import Operator
import mathutils

from . import pmx
from . import bpyutils

import re
import math
import logging
import time


#####################
# Rigging Oparators #
#####################
class CleanRiggingObjects(Operator):
    bl_idname = 'mmd_tools.clean_rig'
    bl_label = 'Clean'
    bl_description = 'Clean temporary objects of rigging'
    bl_options = {'PRESET'}

    def execute(self, context):
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.clean()
        return {'FINISHED'}

class BuildRig(Operator):
    bl_idname = 'mmd_tools.build_rig'
    bl_label = 'Build'
    bl_description = ''
    bl_options = {'PRESET'}

    def execute(self, context):
        obj = context.active_object
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.build()
        context.scene.objects.active = obj
        return {'FINISHED'}

class ApplyAdditionalTransformConstraints(Operator):
    bl_idname = 'mmd_tools.apply_additioinal_transform'
    bl_label = 'Apply Additional Transform'
    bl_description = ''
    bl_options = {'PRESET'}

    def execute(self, context):
        obj = context.active_object
        root = Rig.findRoot(context.active_object)
        rig = Rig(root)
        rig.applyAdditionalTransformConstraints()
        context.scene.objects.active = obj
        return {'FINISHED'}


def isRigidBodyObject(obj):
    return obj.mmd_type == 'RIGID_BODY'

def isJointObject(obj):
    return obj.mmd_type == 'JOINT'

def isTemporaryObject(obj):
    return obj.mmd_type in ['TRACK_TARGET', 'NON_COLLISION_CONSTRAINT', 'SPRING_CONSTRAINT', 'SPRING_GOAL']


def getRigidBodySize(obj):
    if not isRigidBodyObject(obj):
        raise ValueError

    if obj.mmd_rigid.shape == 'SPHERE':
        max_z = 0
        for v in obj.data.vertices:
            vc = v.co
            if vc.z > max_z:
                max_z = vc.z
        return (max_z, 0.0, 0.0)
    elif obj.mmd_rigid.shape == 'BOX':
        v = obj.data.vertices[0].co
        x, y, z = map(abs, v)
        return (x, y, z)
{'fraction_non_alphanumeric': 0.12119983785974868, 'fraction_numerical': 0.002837454398054317, 'mean_word_length': 2.6636971046770603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2807878', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1593, 'n_words': 369}