1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-23 22:40:59 +01:00

Added Visible Only option to the PSK collection exporter

This commit is contained in:
Colin Basnett 2024-09-09 15:59:13 -07:00
parent e1f0fc7e89
commit 7cc5cbe667
2 changed files with 15 additions and 6 deletions

View File

@ -25,10 +25,13 @@ class PskBuildOptions(object):
self.should_enforce_bone_name_restrictions = False
def get_mesh_objects_for_collection(collection: Collection):
def get_mesh_objects_for_collection(collection: Collection, should_exclude_hidden_meshes: bool = True):
for obj in collection.all_objects:
if obj.type == 'MESH':
yield obj
if obj.type != 'MESH':
continue
if should_exclude_hidden_meshes and obj.visible_get() is False:
continue
yield obj
def get_mesh_objects_for_context(context: Context):
@ -79,8 +82,8 @@ def get_psk_input_objects_for_context(context: Context) -> PskInputObjects:
return _get_psk_input_objects(mesh_objects)
def get_psk_input_objects_for_collection(collection: Collection) -> PskInputObjects:
mesh_objects = list(get_mesh_objects_for_collection(collection))
def get_psk_input_objects_for_collection(collection: Collection, should_exclude_hidden_meshes: bool = True) -> PskInputObjects:
mesh_objects = list(get_mesh_objects_for_collection(collection, should_exclude_hidden_meshes))
return _get_psk_input_objects(mesh_objects)

View File

@ -102,12 +102,17 @@ class PSK_OT_export_collection(Operator, ExportHelper):
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,
name='Visible Only',
description='Export only visible meshes'
)
def execute(self, context):
collection = bpy.data.collections.get(self.collection)
try:
input_objects = get_psk_input_objects_for_collection(collection)
input_objects = get_psk_input_objects_for_collection(collection, self.should_exclude_hidden_meshes)
except RuntimeError as e:
self.report({'ERROR_INVALID_CONTEXT'}, str(e))
return {'CANCELLED'}
@ -144,6 +149,7 @@ class PSK_OT_export_collection(Operator, ExportHelper):
flow.use_property_split = True
flow.use_property_decorate = False
flow.prop(self, 'object_eval_state', text='Data')
flow.prop(self, 'should_exclude_hidden_meshes')
# BONES
bones_header, bones_panel = layout.panel('Bones', default_closed=False)