mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2024-11-27 16:10:48 +01:00
Added Visible Only
option to the PSK collection exporter
This commit is contained in:
parent
e1f0fc7e89
commit
7cc5cbe667
@ -25,9 +25,12 @@ 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':
|
||||
if obj.type != 'MESH':
|
||||
continue
|
||||
if should_exclude_hidden_meshes and obj.visible_get() is False:
|
||||
continue
|
||||
yield obj
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user