Added Visible Only option to the PSK collection exporter
This commit is contained in:
@@ -25,10 +25,13 @@ class PskBuildOptions(object):
|
|||||||
self.should_enforce_bone_name_restrictions = False
|
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:
|
for obj in collection.all_objects:
|
||||||
if obj.type == 'MESH':
|
if obj.type != 'MESH':
|
||||||
yield obj
|
continue
|
||||||
|
if should_exclude_hidden_meshes and obj.visible_get() is False:
|
||||||
|
continue
|
||||||
|
yield obj
|
||||||
|
|
||||||
|
|
||||||
def get_mesh_objects_for_context(context: Context):
|
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)
|
return _get_psk_input_objects(mesh_objects)
|
||||||
|
|
||||||
|
|
||||||
def get_psk_input_objects_for_collection(collection: Collection) -> PskInputObjects:
|
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))
|
mesh_objects = list(get_mesh_objects_for_collection(collection, should_exclude_hidden_meshes))
|
||||||
return _get_psk_input_objects(mesh_objects)
|
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'
|
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'
|
'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):
|
def execute(self, context):
|
||||||
collection = bpy.data.collections.get(self.collection)
|
collection = bpy.data.collections.get(self.collection)
|
||||||
|
|
||||||
try:
|
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:
|
except RuntimeError as e:
|
||||||
self.report({'ERROR_INVALID_CONTEXT'}, str(e))
|
self.report({'ERROR_INVALID_CONTEXT'}, str(e))
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
@@ -144,6 +149,7 @@ class PSK_OT_export_collection(Operator, ExportHelper):
|
|||||||
flow.use_property_split = True
|
flow.use_property_split = True
|
||||||
flow.use_property_decorate = False
|
flow.use_property_decorate = False
|
||||||
flow.prop(self, 'object_eval_state', text='Data')
|
flow.prop(self, 'object_eval_state', text='Data')
|
||||||
|
flow.prop(self, 'should_exclude_hidden_meshes')
|
||||||
|
|
||||||
# BONES
|
# BONES
|
||||||
bones_header, bones_panel = layout.panel('Bones', default_closed=False)
|
bones_header, bones_panel = layout.panel('Bones', default_closed=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user