From dba1b9891c9dc5eeff94bd55199eff97b3f1c4e6 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Mon, 11 Dec 2023 06:18:54 -0500 Subject: [PATCH] Display forced export parameters and support Blender versions under 3.2. Display the forced glTF export parameters with their values in the UI of the scene debugger and include the reasoning on why they are forced to that state in their tooltips. Do not add `use_active_scene` to the export parameters or show it in the UI for Blender versions below 3.2 because these versions don't support it. --- addons/io_hubs_addon/debugger.py | 53 +++++++++++++++++++++++--------- addons/io_hubs_addon/utils.py | 10 +++--- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/addons/io_hubs_addon/debugger.py b/addons/io_hubs_addon/debugger.py index 4c7718f2..fd17ef4d 100644 --- a/addons/io_hubs_addon/debugger.py +++ b/addons/io_hubs_addon/debugger.py @@ -54,8 +54,10 @@ def export_scene(context): 'use_active_collection': context.scene.hubs_scene_debugger_room_export_prefs.use_active_collection, 'export_apply': context.scene.hubs_scene_debugger_room_export_prefs.export_apply, 'export_force_sampling': False, - 'use_active_scene': True } + if bpy.app.version >= (3, 2, 0): + args['use_active_scene'] = True + bpy.ops.export_scene.gltf(**args) @@ -96,7 +98,8 @@ def is_user_in_room(): def get_room_name(): - return web_driver.execute_script('try { return APP?.hub?.name || APP?.hub?.slug || APP?.hub?.hub_id; } catch(e) { return ""; }') + return web_driver.execute_script( + 'try { return APP?.hub?.name || APP?.hub?.slug || APP?.hub?.hub_id; } catch(e) { return ""; }') def bring_to_front(context): @@ -140,10 +143,8 @@ def execute(self, context): return {'FINISHED'} except Exception as err: print(err) - bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title="Hubs scene debugger report", - report_string='\n\n'.join(["The scene export has failed", - "Check the export logs or quit the browser instance and try again", - f'{err}'])) + bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title="Hubs scene debugger report", report_string='\n\n'.join( + ["The scene export has failed", "Check the export logs or quit the browser instance and try again", f'{err}'])) return {'CANCELLED'} @@ -425,6 +426,11 @@ def draw(self, context: Context): "use_renderable") col.prop(context.scene.hubs_scene_debugger_room_export_prefs, "use_active_collection") + if bpy.app.version >= (3, 2, 0): + col_row = col.row() + col_row.enabled = False + col_row.prop(context.scene.hubs_scene_debugger_room_export_prefs, + "use_active_scene") row = box.row() col = row.column(heading="Data:") col.use_property_split = True @@ -438,6 +444,13 @@ def draw(self, context: Context): col.prop(context.scene.hubs_scene_debugger_room_export_prefs, "export_apply") row = box.row() + col = row.column(heading="Animation:") + col.use_property_split = True + col_row = col.row() + col_row.enabled = False + col_row.prop(context.scene.hubs_scene_debugger_room_export_prefs, + "export_force_sampling") + row = box.row() row.operator(HubsUpdateSceneOperator.bl_idname, text='Update') @@ -678,22 +691,26 @@ class HubsSceneDebuggerRoomCreatePrefs(bpy.types.PropertyGroup): vr_entry_type: bpy.props.BoolProperty(name="Skip Entry", default=True, description="Omits the entry setup panel and goes straight into the room", options=set()) - debug_local_scene: bpy.props.BoolProperty(name="Debug Local Scene", default=True, - description="Allows scene override. Use this if you want to update the scene. If you just want to spawn an object disable it.", - options=set()) + debug_local_scene: bpy.props.BoolProperty( + name="Debug Local Scene", default=True, + description="Allows scene override. Use this if you want to update the scene. If you just want to spawn an object disable it.", + options=set()) class HubsSceneDebuggerRoomExportPrefs(bpy.types.PropertyGroup): export_cameras: bpy.props.BoolProperty(name="Export Cameras", default=True, description="Export cameras", options=set()) - export_lights: bpy.props.BoolProperty(name="Export Lights", - default=True, description="Punctual Lights, Export directional, point, and spot lights. Uses \"KHR_lights_punctual\" glTF extension", options=set()) + export_lights: bpy.props.BoolProperty( + name="Export Lights", default=True, + description="Punctual Lights, Export directional, point, and spot lights. Uses \"KHR_lights_punctual\" glTF extension", + options=set()) use_selection: bpy.props.BoolProperty(name="Selection Only", default=False, description="Selection Only, Export selected objects only.", options=set()) - export_apply: bpy.props.BoolProperty(name="Apply Modifiers", default=True, - description="Apply Modifiers, Apply modifiers (excluding Armatures) to mesh objects -WARNING: prevents exporting shape keys.", - options=set()) + export_apply: bpy.props.BoolProperty( + name="Apply Modifiers", default=True, + description="Apply Modifiers, Apply modifiers (excluding Armatures) to mesh objects -WARNING: prevents exporting shape keys.", + options=set()) use_visible: bpy.props.BoolProperty( name='Visible Objects', description='Export visible objects only', @@ -714,6 +731,14 @@ class HubsSceneDebuggerRoomExportPrefs(bpy.types.PropertyGroup): default=False, options=set() ) + use_active_scene: bpy.props.BoolProperty( + name='Active Scene', + description='Export objects in the active scene only. This has been forced ON because Hubs can only use one scene anyway', + default=True, options=set()) + export_force_sampling: bpy.props.BoolProperty( + name='Sampling Animations', + description='Apply sampling to all animations. This has been forced OFF because it can break animations in Hubs', + default=False, options=set()) @persistent diff --git a/addons/io_hubs_addon/utils.py b/addons/io_hubs_addon/utils.py index 018a8d75..eab23e33 100644 --- a/addons/io_hubs_addon/utils.py +++ b/addons/io_hubs_addon/utils.py @@ -119,8 +119,9 @@ def save_prefs(context): except Exception as err: import bpy - bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title="Hubs scene debugger report", - report_string=f'An error happened while saving the preferences from {out_path}: {err}') + bpy.ops.wm.hubs_report_viewer( + 'INVOKE_DEFAULT', title="Hubs scene debugger report", + report_string=f'An error happened while saving the preferences from {out_path}: {err}') def load_prefs(context): @@ -141,8 +142,9 @@ def load_prefs(context): except Exception as err: import bpy - bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title="Hubs scene debugger report", - report_string=f'An error happened while loading the preferences from {out_path}: {err}') + bpy.ops.wm.hubs_report_viewer( + 'INVOKE_DEFAULT', title="Hubs scene debugger report", + report_string=f'An error happened while loading the preferences from {out_path}: {err}') if not data: return