Fixed a load of PEP8 warnings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from typing import Type
|
||||
|
||||
from bpy.props import BoolProperty, StringProperty, CollectionProperty, IntProperty, EnumProperty, PointerProperty
|
||||
from bpy.types import Operator, PropertyGroup, UIList, Material
|
||||
from bpy.props import BoolProperty, StringProperty, CollectionProperty, IntProperty, EnumProperty
|
||||
from bpy.types import Operator, PropertyGroup, UIList
|
||||
from bpy_extras.io_utils import ExportHelper
|
||||
|
||||
from .builder import build_psk, PskBuildOptions, get_psk_input_objects
|
||||
@@ -70,7 +70,7 @@ def is_bone_filter_mode_item_available(context, identifier):
|
||||
class PSK_UL_MaterialList(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||
row = layout.row()
|
||||
row.label(text=str(item.material_name), icon='MATERIAL')
|
||||
row.label(text=str(getattr(item, 'material_name')), icon='MATERIAL')
|
||||
|
||||
|
||||
class MaterialListItem(PropertyGroup):
|
||||
@@ -108,11 +108,11 @@ class PskMaterialListItemMoveUp(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
pg = context.scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
return pg.material_list_index > 0
|
||||
|
||||
def execute(self, context):
|
||||
pg = context.scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
pg.material_list.move(pg.material_list_index, pg.material_list_index - 1)
|
||||
pg.material_list_index -= 1
|
||||
return {"FINISHED"}
|
||||
@@ -126,11 +126,11 @@ class PskMaterialListItemMoveDown(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
pg = context.scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
return pg.material_list_index < len(pg.material_list) - 1
|
||||
|
||||
def execute(self, context):
|
||||
pg = context.scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
pg.material_list.move(pg.material_list_index, pg.material_list_index + 1)
|
||||
pg.material_list_index += 1
|
||||
return {"FINISHED"}
|
||||
@@ -157,7 +157,7 @@ class PskExportOperator(Operator, ExportHelper):
|
||||
self.report({'ERROR_INVALID_CONTEXT'}, str(e))
|
||||
return {'CANCELLED'}
|
||||
|
||||
pg = context.scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
|
||||
# Populate bone groups list.
|
||||
populate_bone_group_list(input_objects.armature_object, pg.bone_group_list)
|
||||
@@ -178,8 +178,7 @@ class PskExportOperator(Operator, ExportHelper):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
pg = scene.psk_export
|
||||
pg = getattr(context.scene, 'psk_export')
|
||||
|
||||
layout.prop(pg, 'use_raw_mesh_data')
|
||||
|
||||
@@ -220,6 +219,7 @@ class PskExportOperator(Operator, ExportHelper):
|
||||
try:
|
||||
psk = build_psk(context, options)
|
||||
export_psk(psk, self.filepath)
|
||||
self.report({'INFO'}, f'PSK export successful')
|
||||
except RuntimeError as e:
|
||||
self.report({'ERROR_INVALID_CONTEXT'}, str(e))
|
||||
return {'CANCELLED'}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
from math import inf
|
||||
from typing import Optional
|
||||
from typing import Optional, List
|
||||
|
||||
import bmesh
|
||||
import bpy
|
||||
import numpy as np
|
||||
from bpy.props import BoolProperty, EnumProperty, FloatProperty, StringProperty
|
||||
from bpy.types import Operator, PropertyGroup
|
||||
from bpy.types import Operator, PropertyGroup, VertexGroup
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from mathutils import Quaternion, Vector, Matrix
|
||||
|
||||
@@ -28,6 +28,24 @@ class PskImportOptions(object):
|
||||
self.bone_length = 1.0
|
||||
|
||||
|
||||
class ImportBone(object):
|
||||
"""
|
||||
Intermediate bone type for the purpose of construction.
|
||||
"""
|
||||
def __init__(self, index: int, psk_bone: Psk.Bone):
|
||||
self.index: int = index
|
||||
self.psk_bone: Psk.Bone = psk_bone
|
||||
self.parent: Optional[ImportBone] = None
|
||||
self.local_rotation: Quaternion = Quaternion()
|
||||
self.local_translation: Vector = Vector()
|
||||
self.world_rotation_matrix: Matrix = Matrix()
|
||||
self.world_matrix: Matrix = Matrix()
|
||||
self.vertex_group = None
|
||||
self.orig_quat: Quaternion = Quaternion()
|
||||
self.orig_loc: Vector = Vector()
|
||||
self.post_quat: Quaternion = Quaternion()
|
||||
|
||||
|
||||
def import_psk(psk: Psk, context, options: PskImportOptions):
|
||||
armature_object = None
|
||||
|
||||
@@ -49,21 +67,6 @@ def import_psk(psk: Psk, context, options: PskImportOptions):
|
||||
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
# Intermediate bone type for the purpose of construction.
|
||||
class ImportBone(object):
|
||||
def __init__(self, index: int, psk_bone: Psk.Bone):
|
||||
self.index: int = index
|
||||
self.psk_bone: Psk.Bone = psk_bone
|
||||
self.parent: Optional[ImportBone] = None
|
||||
self.local_rotation: Quaternion = Quaternion()
|
||||
self.local_translation: Vector = Vector()
|
||||
self.world_rotation_matrix: Matrix = Matrix()
|
||||
self.world_matrix: Matrix = Matrix()
|
||||
self.vertex_group = None
|
||||
self.orig_quat: Quaternion = Quaternion()
|
||||
self.orig_loc: Vector = Vector()
|
||||
self.post_quat: Quaternion = Quaternion()
|
||||
|
||||
import_bones = []
|
||||
|
||||
for bone_index, psk_bone in enumerate(psk.bones):
|
||||
@@ -213,7 +216,7 @@ def import_psk(psk: Psk, context, options: PskImportOptions):
|
||||
|
||||
# Get a list of all bones that have weights associated with them.
|
||||
vertex_group_bone_indices = set(map(lambda weight: weight.bone_index, psk.weights))
|
||||
vertex_groups = [None] * len(psk.bones)
|
||||
vertex_groups: List[Optional[VertexGroup]] = [None] * len(psk.bones)
|
||||
for bone_index, psk_bone in map(lambda x: (x, psk.bones[x]), vertex_group_bone_indices):
|
||||
vertex_groups[bone_index] = mesh_object.vertex_groups.new(name=psk_bone.name.decode('windows-1252'))
|
||||
|
||||
@@ -234,16 +237,19 @@ def import_psk(psk: Psk, context, options: PskImportOptions):
|
||||
pass
|
||||
|
||||
|
||||
empty_set = set()
|
||||
|
||||
|
||||
class PskImportPropertyGroup(PropertyGroup):
|
||||
should_import_vertex_colors: BoolProperty(
|
||||
default=True,
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
name='Vertex Colors',
|
||||
description='Import vertex colors from PSKX files, if available'
|
||||
)
|
||||
vertex_color_space: EnumProperty(
|
||||
name='Vertex Color Space',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='The source vertex color space',
|
||||
default='SRGBA',
|
||||
items=(
|
||||
@@ -254,25 +260,25 @@ class PskImportPropertyGroup(PropertyGroup):
|
||||
should_import_vertex_normals: BoolProperty(
|
||||
default=True,
|
||||
name='Vertex Normals',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='Import vertex normals from PSKX files, if available'
|
||||
)
|
||||
should_import_extra_uvs: BoolProperty(
|
||||
default=True,
|
||||
name='Extra UVs',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='Import extra UV maps from PSKX files, if available'
|
||||
)
|
||||
should_import_mesh: BoolProperty(
|
||||
default=True,
|
||||
name='Import Mesh',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='Import mesh'
|
||||
)
|
||||
should_import_skeleton: BoolProperty(
|
||||
default=True,
|
||||
name='Import Skeleton',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='Import skeleton'
|
||||
)
|
||||
bone_length: FloatProperty(
|
||||
@@ -281,7 +287,7 @@ class PskImportPropertyGroup(PropertyGroup):
|
||||
step=100,
|
||||
soft_min=1.0,
|
||||
name='Bone Length',
|
||||
options=set(),
|
||||
options=empty_set,
|
||||
description='Length of the bones'
|
||||
)
|
||||
|
||||
@@ -300,7 +306,7 @@ class PskImportOperator(Operator, ImportHelper):
|
||||
default='')
|
||||
|
||||
def execute(self, context):
|
||||
pg = context.scene.psk_import
|
||||
pg = getattr(context.scene, 'psk_import')
|
||||
|
||||
psk = read_psk(self.filepath)
|
||||
|
||||
@@ -319,7 +325,7 @@ class PskImportOperator(Operator, ImportHelper):
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
pg = context.scene.psk_import
|
||||
pg = getattr(context.scene, 'psk_import')
|
||||
layout = self.layout
|
||||
layout.prop(pg, 'should_import_mesh')
|
||||
row = layout.column()
|
||||
|
||||
@@ -3,7 +3,7 @@ import ctypes
|
||||
from .data import *
|
||||
|
||||
|
||||
def _read_types(fp, data_class: ctypes.Structure, section: Section, data):
|
||||
def _read_types(fp, data_class, section: Section, data):
|
||||
buffer_length = section.data_size * section.data_count
|
||||
buffer = fp.read(buffer_length)
|
||||
offset = 0
|
||||
|
||||
Reference in New Issue
Block a user