1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2025-01-31 11:53:47 +01:00

Removed should_enforce_bone_name_restrictions option as it was too fiddly and not all that useful

This commit is contained in:
Colin Basnett 2024-11-29 20:37:24 -08:00
parent 77dc4e5d50
commit 79ea131f64
7 changed files with 5 additions and 59 deletions

View File

@ -1,6 +1,6 @@
from typing import Optional
from bpy.types import Armature, Bone, Action, PoseBone
from bpy.types import Bone, Action, PoseBone
from .data import *
from ..shared.helpers import *
@ -27,7 +27,6 @@ class PsaBuildOptions:
self.sequences: List[PsaBuildSequence] = []
self.bone_filter_mode: str = 'ALL'
self.bone_collection_indices: List[int] = []
self.should_enforce_bone_name_restrictions: bool = False
self.sequence_name_prefix: str = ''
self.sequence_name_suffix: str = ''
self.root_motion: bool = False
@ -83,10 +82,6 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
# No bones are going to be exported.
if len(bones) == 0:
raise RuntimeError('No bones available for export')
# Check that all bone names are valid.
if options.should_enforce_bone_name_restrictions:
check_bone_names(map(lambda bone: bone.name, bones))
# Build list of PSA bones.
for bone in bones:

View File

@ -300,11 +300,6 @@ class PSA_OT_export(Operator, ExportHelper):
bones_panel.template_list('PSX_UL_bone_collection_list', '', pg, 'bone_collection_list', pg, 'bone_collection_list_index',
rows=rows)
flow = bones_panel.grid_flow()
flow.use_property_split = True
flow.use_property_decorate = False
flow.prop(pg, 'should_enforce_bone_name_restrictions')
# ADVANCED
advanced_header, advanced_panel = layout.panel('Advanced', default_closed=False)
advanced_header.label(text='Advanced')
@ -410,7 +405,6 @@ class PSA_OT_export(Operator, ExportHelper):
options.sequences = export_sequences
options.bone_filter_mode = pg.bone_filter_mode
options.bone_collection_indices = [x.index for x in pg.bone_collection_list if x.is_selected]
options.should_ignore_bone_name_restrictions = pg.should_enforce_bone_name_restrictions
options.sequence_name_prefix = pg.sequence_name_prefix
options.sequence_name_suffix = pg.sequence_name_suffix
options.root_motion = pg.root_motion

View File

@ -160,12 +160,6 @@ class PSA_PG_export(PropertyGroup):
)
bone_collection_list: CollectionProperty(type=PSX_PG_bone_collection_list_item)
bone_collection_list_index: IntProperty(default=0, name='', description='')
should_enforce_bone_name_restrictions: BoolProperty(
default=False,
name='Enforce Bone Name Restrictions',
description='Bone names restrictions will be enforced. Note that bone names without properly formatted names '
'may not be able to be referenced in-engine'
)
sequence_name_prefix: StringProperty(name='Prefix', options=empty_set)
sequence_name_suffix: StringProperty(name='Suffix', options=empty_set)
sequence_filter_name: StringProperty(

View File

@ -24,7 +24,6 @@ class PskBuildOptions(object):
self.bone_collection_indices: List[int] = []
self.object_eval_state = 'EVALUATED'
self.materials: List[Material] = []
self.should_enforce_bone_name_restrictions = False
self.scale = 1.0
self.export_space = 'WORLD'
@ -131,10 +130,6 @@ def build_psk(context, input_objects: PskInputObjects, options: PskBuildOptions)
armature_data = typing.cast(Armature, armature_object.data)
bones = [armature_data.bones[bone_name] for bone_name in bone_names]
# Check that all bone names are valid.
if options.should_enforce_bone_name_restrictions:
check_bone_names(map(lambda x: x.name, bones))
for bone in bones:
psk_bone = Psk.Bone()
try:

View File

@ -137,14 +137,8 @@ class PSK_OT_export_collection(Operator, ExportHelper):
name='Object Evaluation State',
default='EVALUATED'
)
should_enforce_bone_name_restrictions: BoolProperty(
default=False,
name='Enforce Bone Name Restrictions',
description='Enforce that bone names must only contain letters, numbers, spaces, hyphens and underscores.\n\n'
'Depending on the engine, improper bone names might not be referenced correctly by scripts'
)
should_exclude_hidden_meshes: BoolProperty(
default=True,
default=False,
name='Visible Only',
description='Export only visible meshes'
)
@ -183,7 +177,6 @@ class PSK_OT_export_collection(Operator, ExportHelper):
options = PskBuildOptions()
options.object_eval_state = self.object_eval_state
options.materials = get_materials_for_mesh_objects([x.obj for x in input_objects.mesh_objects])
options.should_enforce_bone_name_restrictions = self.should_enforce_bone_name_restrictions
options.scale = self.scale
options.export_space = self.export_space
options.bone_filter_mode = self.bone_filter_mode
@ -228,17 +221,11 @@ class PSK_OT_export_collection(Operator, ExportHelper):
bones_header, bones_panel = layout.panel('Bones', default_closed=False)
bones_header.label(text='Bones', icon='BONE_DATA')
if bones_panel:
bones_panel.operator(PSK_OT_populate_bone_collection_list.bl_idname, icon='FILE_REFRESH')
draw_bone_filter_mode(bones_panel, self)
row = bones_panel.row(align=True)
if self.bone_filter_mode == 'BONE_COLLECTIONS':
rows = max(3, min(len(self.bone_collection_list), 10))
row.template_list('PSX_UL_bone_collection_list', '', self, 'bone_collection_list', self, 'bone_collection_list_index', rows=rows)
col = row.column()
col.operator(PSK_OT_populate_bone_collection_list.bl_idname, text='', icon='FILE_REFRESH')
bones_panel.prop(self, 'should_enforce_bone_name_restrictions')
bones_panel.template_list('PSX_UL_bone_collection_list', '', self, 'bone_collection_list', self, 'bone_collection_list_index', rows=rows)
class PSK_OT_export(Operator, ExportHelper):
@ -304,8 +291,6 @@ class PSK_OT_export(Operator, ExportHelper):
rows = max(3, min(len(pg.bone_collection_list), 10))
row.template_list('PSX_UL_bone_collection_list', '', pg, 'bone_collection_list', pg, 'bone_collection_list_index', rows=rows)
bones_panel.prop(pg, 'should_enforce_bone_name_restrictions')
# MATERIALS
materials_header, materials_panel = layout.panel('Materials', default_closed=False)
materials_header.label(text='Materials', icon='MATERIAL')
@ -327,7 +312,6 @@ class PSK_OT_export(Operator, ExportHelper):
options.bone_collection_indices = [x.index for x in pg.bone_collection_list if x.is_selected]
options.object_eval_state = pg.object_eval_state
options.materials = [m.material for m in pg.material_list]
options.should_enforce_bone_name_restrictions = pg.should_enforce_bone_name_restrictions
options.scale = pg.scale
options.export_space = pg.export_space

View File

@ -1,4 +1,4 @@
from bpy.props import EnumProperty, CollectionProperty, IntProperty, BoolProperty, PointerProperty, FloatProperty
from bpy.props import EnumProperty, CollectionProperty, IntProperty, PointerProperty, FloatProperty
from bpy.types import PropertyGroup, Material
from ...shared.types import PSX_PG_bone_collection_list_item
@ -37,12 +37,6 @@ class PSK_PG_export(PropertyGroup):
)
material_list: CollectionProperty(type=PSK_PG_material_list_item)
material_list_index: IntProperty(default=0)
should_enforce_bone_name_restrictions: BoolProperty(
default=False,
name='Enforce Bone Name Restrictions',
description='Enforce that bone names must only contain letters, numbers, spaces, hyphens and underscores.\n\n'
'Depending on the engine, improper bone names might not be referenced correctly by scripts'
)
scale: FloatProperty(
name='Scale',
default=1.0,

View File

@ -1,4 +1,3 @@
import re
from typing import List, Iterable, cast
import bpy
@ -72,15 +71,6 @@ def populate_bone_collection_list(armature_object: Object, bone_collection_list:
item.is_selected = bone_collection.name in selected_assigned_collection_names if has_selected_collections else True
def check_bone_names(bone_names: Iterable[str]):
pattern = re.compile(r'^[a-zA-Z\d_\- ]+$')
invalid_bone_names = [x for x in bone_names if pattern.match(x) is None]
if len(invalid_bone_names) > 0:
raise RuntimeError(f'The following bone names are invalid: {invalid_bone_names}.\n'
f'Bone names must only contain letters, numbers, spaces, hyphens and underscores.\n'
f'You can bypass this by disabling "Enforce Bone Name Restrictions" in the export settings.')
def get_export_bone_names(armature_object: Object, bone_filter_mode: str, bone_collection_indices: Iterable[int]) -> List[str]:
"""
Returns a sorted list of bone indices that should be exported for the given bone filter mode and bone collections.