Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for scene debugger #249

Merged
merged 94 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
ff068b8
Scene viewer
keianhzo Jan 13, 2023
e1052b9
Add selenium install support and move the view panel to the right panel
keianhzo Jan 13, 2023
2b396e0
Remove unused code
keianhzo Jan 13, 2023
719a586
Make viewer url configurable in preferences
keianhzo Jan 13, 2023
df2b5ec
fixes
keianhzo Jan 16, 2023
65f0a51
Update python packages paths
keianhzo Jan 16, 2023
dce2fab
Reuse the same tmp file
keianhzo Jan 16, 2023
05c6579
Revert "Reuse the same tmp file"
keianhzo Jan 16, 2023
4a18341
Websockets WIP
keianhzo Jan 31, 2023
8933674
Update viewer properties
keianhzo Feb 2, 2023
6b32fbf
Remove WS support
keianhzo Nov 23, 2023
52d59ba
Revert rebase change
keianhzo Nov 23, 2023
2958d01
Linter and format updates
keianhzo Nov 23, 2023
a1ae92d
Bring browser window to the front when updating
keianhzo Nov 23, 2023
a74e2f2
profiles and binary location updates
keianhzo Nov 23, 2023
df22244
Fix the glb output dire
keianhzo Nov 24, 2023
cd2457a
Remove leftover line
keianhzo Nov 24, 2023
fa9bf89
Delete browser profile
keianhzo Nov 24, 2023
d4ec7d8
Fix Firefox profile
keianhzo Nov 24, 2023
f78df78
Check if user logged in
keianhzo Nov 24, 2023
3125779
Safeguard when creating the web driver
keianhzo Nov 24, 2023
6f04034
Check also if user is in the room to allow updating the scene
keianhzo Nov 24, 2023
f5ae360
Add room create and update buttons descriptions
keianhzo Nov 24, 2023
50cacd7
Add status information
keianhzo Nov 24, 2023
05cc1ce
Fix parenthesis typo
keianhzo Nov 27, 2023
42e8579
Removed duplicate import
keianhzo Nov 30, 2023
f69ca0d
Remove unnecessary globals
keianhzo Nov 30, 2023
e7493f2
Make scene debugger panel child of the Hubs tools panel
keianhzo Nov 30, 2023
9ded6fc
Remove pip upgrade
keianhzo Nov 30, 2023
70e937a
Remove hardcoded dep string in uninstall operator
keianhzo Nov 30, 2023
5592960
Add profile warning
keianhzo Nov 30, 2023
475c914
scene debugger prefs reorg
keianhzo Nov 30, 2023
8abc683
Move debugLocalScene to flag
keianhzo Nov 30, 2023
8c8d837
Better error report and stability
keianhzo Nov 30, 2023
928e841
Check if the local store object exits before querying
keianhzo Nov 30, 2023
6a0f5a9
Disable the create properties after creation
keianhzo Nov 30, 2023
48f335c
Better error handling
keianhzo Nov 30, 2023
b22afdc
Refactor debugger code to its own file
keianhzo Nov 30, 2023
5a4c243
Remove isWebdriverAlive parameter
keianhzo Nov 30, 2023
63516d5
Add support for default export flags
keianhzo Nov 30, 2023
41f00cb
Fix lint error
keianhzo Nov 30, 2023
6eceaf6
Add feedback for modules install
keianhzo Dec 1, 2023
d2c56f3
Fix typo
keianhzo Dec 1, 2023
1904be7
Add visual cues for room status
keianhzo Dec 1, 2023
f90b287
Add close room button
keianhzo Dec 1, 2023
67167b9
Move Create/Update to subpanels
keianhzo Dec 1, 2023
e97433d
Fix double box in the status panel
keianhzo Dec 1, 2023
5bb1110
Better signed in check
keianhzo Dec 1, 2023
052d0be
Hubs instances management
keianhzo Dec 1, 2023
e8284bb
Provide a default instance if none
keianhzo Dec 1, 2023
402f28c
Support for room management
keianhzo Dec 1, 2023
7040de8
Allow parameters in room actions
keianhzo Dec 4, 2023
b25e4b3
Fix saving a local room url
keianhzo Dec 4, 2023
b99f05f
Remove unused import
keianhzo Dec 5, 2023
ec97419
String updates
keianhzo Dec 5, 2023
a3bf152
Remove unused code
keianhzo Dec 5, 2023
e8e0eee
Remove atexit
keianhzo Dec 5, 2023
f84e9e5
Remove unused property
keianhzo Dec 5, 2023
1ba2fde
Make all buttons enabled all the time and force https
keianhzo Dec 5, 2023
0532621
Better module install/uninstall error handling
keianhzo Dec 5, 2023
f0d53b7
More string updates
keianhzo Dec 5, 2023
83778e7
Do not require signin if not using debugLocalScene
keianhzo Dec 5, 2023
c0c46bc
Show room name
keianhzo Dec 5, 2023
0f7e2fc
Remove unused import
keianhzo Dec 5, 2023
4a26ec4
HubsRoomUrl -> HubsUrl
keianhzo Dec 5, 2023
d361eb9
Add more export options
keianhzo Dec 5, 2023
8557f5c
Hack for Firefox bring to front
keianhzo Dec 5, 2023
f14dff4
switch to front hack for windows
keianhzo Dec 5, 2023
ab38b01
linter
keianhzo Dec 5, 2023
3a53729
Fix tests
keianhzo Dec 5, 2023
c9126f6
Force quit on exit
keianhzo Dec 6, 2023
0c82c0f
Move preferences to a json file
keianhzo Dec 7, 2023
8a35613
Restore accidentally removed class register
keianhzo Dec 7, 2023
30335bc
Check if prefs file exists before opening
keianhzo Dec 7, 2023
5d2ddd7
Use scene room when adding a room if available
keianhzo Dec 8, 2023
6fe239d
Save instance/room index when selected
keianhzo Dec 8, 2023
c93c126
Bring window to front when already alive
keianhzo Dec 8, 2023
f550e36
Add a default instance if empty
keianhzo Dec 8, 2023
42b02af
Reorg folder file/structure
keianhzo Dec 8, 2023
f510d4e
Enable shared array buffers for physics debugging
keianhzo Dec 8, 2023
d56903d
Handle browser switching properly
keianhzo Dec 8, 2023
e36457a
Keep relative position when deleting room/instances
keianhzo Dec 8, 2023
52d7678
Fix drag&drop issues in old loader
keianhzo Dec 8, 2023
782f0b9
Persist HubsUrl updates
keianhzo Dec 11, 2023
4ff6a45
cache user python path
keianhzo Dec 12, 2023
226cc73
better module availability detection
keianhzo Dec 12, 2023
7569fd9
Unload modules when uninstalling deps
keianhzo Dec 12, 2023
9f00e29
cache export prefs
keianhzo Dec 12, 2023
ce8cc9f
Selenium instance close fix for Windows
keianhzo Dec 12, 2023
0cf9e22
Show active room flags
keianhzo Dec 12, 2023
1f09e2e
Change Update button text based on debugLocalScene
keianhzo Dec 12, 2023
d44cc83
Add link to room flags help
keianhzo Dec 12, 2023
27f1611
Use bultin url opener
keianhzo Dec 12, 2023
7754ad4
Improve room flags UI
keianhzo Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ CMakeFiles
cmake_install.cmake
CMakeCache.txt
Makefile
lib

#Selenium
__hubs_selenium_profile
13 changes: 13 additions & 0 deletions addons/io_hubs_addon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from .utils import create_prefs_dir
from .utils import get_user_python_path
import sys
import bpy
from .io import gltf_exporter
from . import (nodes, components)
from . import preferences
from . import third_party
from . import debugger
from . import icons
bl_info = {
"name": "Hubs Blender Addon",
"author": "Mozilla Hubs",
Expand All @@ -17,13 +22,19 @@
"category": "Generic"
}

sys.path.insert(0, get_user_python_path())

create_prefs_dir()


def register():
icons.register()
preferences.register()
nodes.register()
components.register()
gltf_exporter.register()
third_party.register()
debugger.register()

# Migrate components if the add-on is enabled in the middle of a session.
if bpy.context.preferences.is_dirty:
Expand All @@ -40,6 +51,8 @@ def unregister():
components.unregister()
nodes.unregister()
preferences.unregister()
debugger.unregister()
icons.unregister()


# called by gltf-blender-io after it has loaded
Expand Down
28 changes: 0 additions & 28 deletions addons/io_hubs_addon/components/components_registry.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from .types import NodeType
import bpy.utils.previews
import bpy
from bpy.props import BoolProperty, StringProperty, CollectionProperty, PointerProperty
from bpy.types import PropertyGroup

import importlib
import inspect
import os
from os import listdir
from os.path import join, isfile, isdir, dirname, realpath

from .hubs_component import HubsComponent
Expand Down Expand Up @@ -125,25 +123,6 @@ def unload_components_registry():
module.unregister_module()


def load_icons():
global __component_icons
__component_icons = {}
pcoll = bpy.utils.previews.new()
icons_dir = os.path.join(os.path.dirname(__file__), "icons")
icons = [f for f in listdir(icons_dir) if isfile(join(icons_dir, f))]
for icon in icons:
pcoll.load(icon, os.path.join(icons_dir, icon), 'IMAGE')
print("Loading icon: " + icon)
__component_icons["hubs"] = pcoll


def unload_icons():
global __component_icons
__component_icons["hubs"].close()
del __component_icons


__component_icons = {}
__components_registry = {}


Expand All @@ -152,11 +131,6 @@ def get_components_registry():
return __components_registry


def get_components_icons():
global __component_icons
return __component_icons["hubs"]


def get_component_by_name(component_name):
global __components_registry
return next(
Expand All @@ -166,7 +140,6 @@ def get_component_by_name(component_name):


def register():
load_icons()
load_components_registry()

bpy.utils.register_class(HubsComponentName)
Expand Down Expand Up @@ -201,7 +174,6 @@ def unregister():
glTF2ExportUserExtension.remove_excluded_property("hubs_component_list")

unload_components_registry()
unload_icons()

global __components_registry
del __components_registry
81 changes: 53 additions & 28 deletions addons/io_hubs_addon/components/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

from .types import PanelType, MigrationType
from .utils import get_object_source, has_component, add_component, remove_component, wrap_text, display_wrapped_text, is_dep_required, update_image_editors
from .components_registry import get_components_registry, get_components_icons, get_component_by_name
from .components_registry import get_components_registry, get_component_by_name
from ..preferences import get_addon_pref
from .handlers import migrate_components
from .gizmos import update_gizmos
from .utils import is_linked, redraw_component_ui
from ..icons import get_hubs_icons
import os


Expand All @@ -30,22 +31,26 @@ def poll(cls, context):
if panel_type == PanelType.SCENE:
if is_linked(context.scene):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot add components to linked scenes")
cls.poll_message_set(
"Cannot add components to linked scenes")
return False
elif panel_type == PanelType.OBJECT:
if is_linked(context.active_object):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot add components to linked objects")
cls.poll_message_set(
"Cannot add components to linked objects")
return False
elif panel_type == PanelType.MATERIAL:
if is_linked(context.active_object.active_material):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot add components to linked materials")
cls.poll_message_set(
"Cannot add components to linked materials")
return False
elif panel_type == PanelType.BONE:
if is_linked(context.active_bone):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot add components to linked bones")
cls.poll_message_set(
"Cannot add components to linked bones")
return False

return True
Expand All @@ -72,7 +77,7 @@ def filter_source_type(cmp):
return not component_class.is_dep_only() and PanelType(panel_type) in component_class.get_panel_type() and component_class.poll(PanelType(panel_type), host, ob=context.object)

components_registry = get_components_registry()
components_icons = get_components_icons()
hubs_icons = get_hubs_icons()
filtered_components = dict(
filter(filter_source_type, components_registry.items()))

Expand Down Expand Up @@ -152,11 +157,11 @@ def draw(self, context):
if icon.find('.') != -1:
if has_component(obj, component_name):
op = column.label(
text=component_display_name, icon_value=components_icons[icon].icon_id)
text=component_display_name, icon_value=hubs_icons[icon].icon_id)
else:
op = column.operator(
AddHubsComponent.bl_idname, text=component_display_name,
icon_value=components_icons[icon].icon_id)
icon_value=hubs_icons[icon].icon_id)
op.component_name = component_name
op.panel_type = panel_type
else:
Expand Down Expand Up @@ -214,22 +219,26 @@ def poll(cls, context):
if panel_type == PanelType.SCENE:
if is_linked(context.scene):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot remove components from linked scenes")
cls.poll_message_set(
"Cannot remove components from linked scenes")
return False
elif panel_type == PanelType.OBJECT:
if is_linked(context.active_object):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot remove components from linked objects")
cls.poll_message_set(
"Cannot remove components from linked objects")
return False
elif panel_type == PanelType.MATERIAL:
if is_linked(context.active_object.active_material):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot remove components from linked materials")
cls.poll_message_set(
"Cannot remove components from linked materials")
return False
elif panel_type == PanelType.BONE:
if is_linked(context.active_bone):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot add components to linked bones")
cls.poll_message_set(
"Cannot add components to linked bones")
return False

return True
Expand Down Expand Up @@ -257,7 +266,8 @@ class MigrateHubsComponents(Operator):

def execute(self, context):
if self.is_registration:
migrate_components(MigrationType.REGISTRATION, do_beta_versioning=True)
migrate_components(MigrationType.REGISTRATION,
do_beta_versioning=True)
else:
migrate_components(MigrationType.LOCAL, do_beta_versioning=True)

Expand Down Expand Up @@ -288,7 +298,8 @@ def execute(self, context):
wm = context.window_manager
title = wm.hubs_report_last_title
report_string = wm.hubs_report_last_report_string
bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=title, report_string=report_string)
bpy.ops.wm.hubs_report_viewer(
'INVOKE_DEFAULT', title=title, report_string=report_string)
return {'FINISHED'}


Expand All @@ -314,12 +325,15 @@ def highlight_info_report(self):
while bpy.ops.info.select_pick(
context_override, report_index=index, extend=False) != {'CANCELLED'}:
index += 1
bpy.ops.info.select_pick(context_override, report_index=index, extend=False)
bpy.ops.info.select_pick(
context_override, report_index=index, extend=False)

def execute(self, context):
messages = split_and_prefix_report_messages(self.report_string)
info_report_string = '\n'.join([message.replace('\n', ' ') for message in messages])
self.report({'INFO'}, f"Hubs {self.title}\n{info_report_string}\nEnd of Hubs {self.title}")
info_report_string = '\n'.join(
[message.replace('\n', ' ') for message in messages])
self.report(
{'INFO'}, f"Hubs {self.title}\n{info_report_string}\nEnd of Hubs {self.title}")
bpy.ops.screen.info_log_show()
bpy.app.timers.register(self.highlight_info_report)
return {'FINISHED'}
Expand Down Expand Up @@ -403,13 +417,15 @@ def draw(self, context):

scroll_up = scroll_column.row()
scroll_up.enabled = start_index > 0
op = scroll_up.operator(ReportScroller.bl_idname, text="", icon="TRIA_UP")
op = scroll_up.operator(ReportScroller.bl_idname,
text="", icon="TRIA_UP")
op.increment = -1
op.maximum = maximum_scrolling

scroll_down = scroll_column.row()
scroll_down.enabled = start_index < maximum_scrolling
op = scroll_down.operator(ReportScroller.bl_idname, text="", icon="TRIA_DOWN")
op = scroll_down.operator(
ReportScroller.bl_idname, text="", icon="TRIA_DOWN")
op.increment = 1
op.maximum = maximum_scrolling

Expand All @@ -419,7 +435,8 @@ def draw(self, context):

scroll_percentage = column.row()
scroll_percentage.enabled = False
scroll_percentage.prop(wm, "hubs_report_scroll_percentage", slider=True)
scroll_percentage.prop(
wm, "hubs_report_scroll_percentage", slider=True)

layout.separator()

Expand Down Expand Up @@ -457,7 +474,8 @@ def init_report_display_blocks(self):
if last_message is None:
final_block = True

current_block_lines = sum([len(message) for message in block_messages])
current_block_lines = sum([len(message)
for message in block_messages])
needed_padding_lines = self.lines_to_show - current_block_lines

message_iter = iter(block_messages)
Expand Down Expand Up @@ -506,7 +524,8 @@ class CopyHubsComponent(Operator):
def poll(cls, context):
if is_linked(context.scene):
if bpy.app.version >= (3, 0, 0):
cls.poll_message_set("Cannot copy components when in linked scenes")
cls.poll_message_set(
"Cannot copy components when in linked scenes")
return False

if hasattr(context, "panel"):
Expand All @@ -518,14 +537,17 @@ def poll(cls, context):

def get_selected_bones(self, context):
selected_bones = context.selected_pose_bones if context.mode == "POSE" else context.selected_editable_bones
selected_armatures = [sel_ob for sel_ob in context.selected_objects if sel_ob.type == "ARMATURE"]
selected_armatures = [
sel_ob for sel_ob in context.selected_objects if sel_ob.type == "ARMATURE"]
selected_hosts = []
for armature in selected_armatures:
armature_bones = armature.pose.bones if context.mode == "POSE" else armature.data.edit_bones
target_armature_bones = armature.data.bones if context.mode == "POSE" else armature.data.edit_bones
target_bones = [bone for bone in armature_bones if bone in selected_bones]
target_bones = [
bone for bone in armature_bones if bone in selected_bones]
for target_bone in target_bones:
selected_hosts.extend([bone for bone in target_armature_bones if target_bone.name == bone.name])
selected_hosts.extend(
[bone for bone in target_armature_bones if target_bone.name == bone.name])
return selected_hosts

def get_selected_hosts(self, context):
Expand Down Expand Up @@ -628,12 +650,14 @@ def execute(self, context):

# Load/Reload the first image and assign it to the target property, then load the rest of the images if they're not already loaded. This mimics Blender's default open files behavior.
primary_filepath = os.path.join(dirname, self.files[0].name)
primary_img = bpy.data.images.load(filepath=primary_filepath, check_existing=True)
primary_img = bpy.data.images.load(
filepath=primary_filepath, check_existing=True)
primary_img.reload()
self.hubs_component[self.target_property] = primary_img

for f in self.files[1:]:
bpy.data.images.load(filepath=os.path.join(dirname, f.name), check_existing=True)
bpy.data.images.load(filepath=os.path.join(
dirname, f.name), check_existing=True)

update_image_editors(old_img, primary_img)
redraw_component_ui(context)
Expand All @@ -657,7 +681,8 @@ def register():
bpy.utils.register_class(ViewReportInInfoEditor)
bpy.utils.register_class(CopyHubsComponent)
bpy.utils.register_class(OpenImage)
bpy.types.WindowManager.hubs_report_scroll_index = IntProperty(default=0, min=0)
bpy.types.WindowManager.hubs_report_scroll_index = IntProperty(
default=0, min=0)
bpy.types.WindowManager.hubs_report_scroll_percentage = IntProperty(
name="Scroll Position", default=0, min=0, max=100, subtype='PERCENTAGE')
bpy.types.WindowManager.hubs_report_last_title = StringProperty()
Expand Down
14 changes: 14 additions & 0 deletions addons/io_hubs_addon/components/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ def draw(self, context):
draw_components_list(self, context)


class HUBS_PT_ToolsPanel(bpy.types.Panel):
bl_idname = "HUBS_PT_ToolsPanel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Hubs"
bl_category = "Hubs"
bl_context = 'objectmode'

def draw(self, context):
pass


class HubsScenePanel(bpy.types.Panel):
bl_label = 'Hubs'
bl_idname = "SCENE_PT_hubs"
Expand Down Expand Up @@ -217,6 +229,7 @@ def register():
bpy.utils.register_class(HubsMaterialPanel)
bpy.utils.register_class(HubsBonePanel)
bpy.utils.register_class(TooltipLabel)
bpy.utils.register_class(HUBS_PT_ToolsPanel)

bpy.types.TOPBAR_MT_window.append(window_menu_addition)
bpy.types.VIEW3D_MT_object.append(object_menu_addition)
Expand All @@ -229,6 +242,7 @@ def unregister():
bpy.utils.unregister_class(HubsMaterialPanel)
bpy.utils.unregister_class(HubsBonePanel)
bpy.utils.unregister_class(TooltipLabel)
bpy.utils.unregister_class(HUBS_PT_ToolsPanel)

bpy.types.TOPBAR_MT_window.remove(window_menu_addition)
bpy.types.VIEW3D_MT_object.remove(object_menu_addition)
Expand Down
Loading