Skip to content

Commit

Permalink
Display forced export parameters and support Blender versions under 3.2.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Exairnous committed Dec 12, 2023
1 parent d44cc83 commit 4478ee0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
53 changes: 39 additions & 14 deletions addons/io_hubs_addon/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def export_scene(context):
'use_active_collection': export_prefs.use_active_collection,
'export_apply': 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)


Expand Down Expand Up @@ -109,7 +111,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):
Expand Down Expand Up @@ -153,10 +156,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'}


Expand Down Expand Up @@ -454,6 +455,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
Expand All @@ -467,6 +473,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()

update_mode = "Update Scene" if context.scene.hubs_scene_debugger_room_create_prefs.debug_local_scene else "Spawn as object"
if isWebdriverAlive():
Expand Down Expand Up @@ -736,22 +749,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',
Expand All @@ -772,6 +789,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
Expand Down
10 changes: 6 additions & 4 deletions addons/io_hubs_addon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,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):
Expand All @@ -150,8 +151,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
Expand Down

0 comments on commit 4478ee0

Please sign in to comment.