From 5991ed628fc5012b8329f6fdb9dffb1d4ec7c9d3 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Fri, 5 Apr 2024 04:20:20 -0400 Subject: [PATCH] Remove unused import and run format.py. --- .../components/components_registry.py | 2 ++ .../components/definitions/billboard.py | 4 +++- .../components/definitions/media_frame.py | 16 ++++++++-------- .../components/definitions/particle_emitter.py | 1 - .../components/definitions/spoke/box_collider.py | 3 +-- addons/io_hubs_addon/components/operators.py | 3 ++- addons/io_hubs_addon/io/gltf_importer.py | 11 +++++++---- addons/io_hubs_addon/io/panels.py | 1 - 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/addons/io_hubs_addon/components/components_registry.py b/addons/io_hubs_addon/components/components_registry.py index f2fe6b5d..cb4a1307 100644 --- a/addons/io_hubs_addon/components/components_registry.py +++ b/addons/io_hubs_addon/components/components_registry.py @@ -42,10 +42,12 @@ def get_component_definitions(): for name in component_module_names ] + def get_component_module_name(component_class): relative_module_name = component_class.__module__.replace(f"{__package__}.definitions.", "") return ".".join(relative_module_name.split(".")[:-1]) + def register_component(component_class): component_module_name = get_component_module_name(component_class) if component_module_name: diff --git a/addons/io_hubs_addon/components/definitions/billboard.py b/addons/io_hubs_addon/components/definitions/billboard.py index a8b3b4d2..601b2286 100644 --- a/addons/io_hubs_addon/components/definitions/billboard.py +++ b/addons/io_hubs_addon/components/definitions/billboard.py @@ -15,4 +15,6 @@ class Billboard(HubsComponent): } onlyY: BoolProperty( - name="Vertical Axis Only", description="Locks the Vertical Axis to enable only side to side movement in world space and removes any other rotational transforms", default=False) + name="Vertical Axis Only", + description="Locks the Vertical Axis to enable only side to side movement in world space and removes any other rotational transforms", + default=False) diff --git a/addons/io_hubs_addon/components/definitions/media_frame.py b/addons/io_hubs_addon/components/definitions/media_frame.py index 46db9769..6743c9ac 100644 --- a/addons/io_hubs_addon/components/definitions/media_frame.py +++ b/addons/io_hubs_addon/components/definitions/media_frame.py @@ -219,14 +219,14 @@ def gather_import(cls, gltf, blender_host, component_name, component_value, impo property_value['y'], property_value['z'] = property_value['z'], property_value['y'] assign_property(gltf.vnodes, blender_component, - property_name, property_value) + property_name, property_value) elif property_name == 'align': align = { - 'x':property_value['x'], - 'y':property_value['y'], - 'z':property_value['z'] - } + 'x': property_value['x'], + 'y': property_value['y'], + 'z': property_value['z'] + } if gltf_yup: align['y'] = "min" if property_value['z'] == "max" else "max" if property_value['z'] == "min" else property_value['z'] align['z'] = property_value['y'] @@ -235,10 +235,10 @@ def gather_import(cls, gltf, blender_host, component_name, component_value, impo blender_component.alignY = align['y'] blender_component.alignZ = align['z'] - else: assign_property(gltf.vnodes, blender_component, - property_name, property_value) + property_name, property_value) if get_host_or_parents_scaled(blender_host): - import_report.append(f"The media-frame {blender_host.name} or one of its parents' scales isn't [1,1,1]. If this file is being imported from Spoke, then you may need to multiply the bounds parameter by the parents' scale before resetting the scale to [1,1,1].") + import_report.append( + f"The media-frame {blender_host.name} or one of its parents' scales isn't [1,1,1]. If this file is being imported from Spoke, then you may need to multiply the bounds parameter by the parents' scale before resetting the scale to [1,1,1].") diff --git a/addons/io_hubs_addon/components/definitions/particle_emitter.py b/addons/io_hubs_addon/components/definitions/particle_emitter.py index 3e904f6b..84c64e79 100644 --- a/addons/io_hubs_addon/components/definitions/particle_emitter.py +++ b/addons/io_hubs_addon/components/definitions/particle_emitter.py @@ -175,4 +175,3 @@ def gather_import(cls, gltf, blender_host, component_name, component_value, impo assign_property(gltf.vnodes, blender_component, property_name, property_value) - diff --git a/addons/io_hubs_addon/components/definitions/spoke/box_collider.py b/addons/io_hubs_addon/components/definitions/spoke/box_collider.py index 9fed272c..16292188 100644 --- a/addons/io_hubs_addon/components/definitions/spoke/box_collider.py +++ b/addons/io_hubs_addon/components/definitions/spoke/box_collider.py @@ -1,6 +1,5 @@ from ...types import NodeType from ...hubs_component import HubsComponent -from ...utils import add_component from ....io.utils import assign_property, import_component import bpy @@ -17,7 +16,7 @@ def gather_import(cls, gltf, blender_host, component_name, component_value, impo "type", 'box') assign_property(gltf.vnodes, blender_component, "fit", 'manual') - + # These settings don't get applied when set as normal here, so use a timer to set them later. def set_half_extents_and_offsets(): loc, _, scale = blender_host.matrix_world.decompose() diff --git a/addons/io_hubs_addon/components/operators.py b/addons/io_hubs_addon/components/operators.py index 7fa9ca29..2907e0cb 100644 --- a/addons/io_hubs_addon/components/operators.py +++ b/addons/io_hubs_addon/components/operators.py @@ -644,7 +644,8 @@ def execute(self, context): old_img = getattr(self.target, self.target_property) # 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(self.directory, self.files[0].name) # self.files is sorted alphabetically by Blender, self.files[0] is the 1. of the selection in alphabetical order + # self.files is sorted alphabetically by Blender, self.files[0] is the 1. of the selection in alphabetical order + primary_filepath = os.path.join(self.directory, self.files[0].name) primary_img = bpy.data.images.load( filepath=primary_filepath, check_existing=True) primary_img.reload() diff --git a/addons/io_hubs_addon/io/gltf_importer.py b/addons/io_hubs_addon/io/gltf_importer.py index 3f4e7c37..47b36cca 100644 --- a/addons/io_hubs_addon/io/gltf_importer.py +++ b/addons/io_hubs_addon/io/gltf_importer.py @@ -39,12 +39,14 @@ def import_hubs_components(gltf_node, blender_host, gltf, blender_ob=None): except Exception: traceback.print_exc() print(f"Failed to import {component_name} component on {blender_host.name} continuing on...") - import_report.append(f"Failed to import {component_name} component on {blender_host.name}. See the console for details.") + import_report.append( + f"Failed to import {component_name} component on {blender_host.name}. See the console for details.") else: if component_name != "heightfield": # heightfield is a Spoke-only component and not needed in Blender. print(f'Could not import unsupported component "{component_name}"') - import_report.append(f"Could not import unsupported component {component_name} component on {blender_host.name}.") + import_report.append( + f"Could not import unsupported component {component_name} component on {blender_host.name}.") def add_lightmap(gltf_material, blender_mat, gltf): @@ -101,12 +103,14 @@ def store_bones_for_import(gltf, vnode): armatures[vnode.blender_object.name] = { 'armature': vnode.blender_object, 'gltf_bones': gltf_bones} + def show_import_report(): global import_report if not import_report: return title = "Import Report" + def report_import(): bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=title, report_string='\n\n'.join(import_report)) bpy.app.timers.register(report_import) @@ -209,7 +213,6 @@ def patched_BlenderNode_create_object(gltf, vnode_id): else: print("Couldn't find the equivalent node for the vnode.") - else: node = gltf.data.nodes[vnode_id] if node.name != vnode.name: @@ -221,7 +224,7 @@ def patched_BlenderNode_create_object(gltf, vnode_id): import_hubs_components(node, vnode.blender_object, gltf, blender_ob=vnode.blender_object) - # Node hooks are not called for bones. Bones are created together with their armature. + #  Node hooks are not called for bones. Bones are created together with their armature. # Unfortunately the bones are created after this hook is called so we need to wait until all nodes have been created. if vnode.is_arma: store_bones_for_import(gltf, vnode) diff --git a/addons/io_hubs_addon/io/panels.py b/addons/io_hubs_addon/io/panels.py index 325cde3c..1b86b3f7 100644 --- a/addons/io_hubs_addon/io/panels.py +++ b/addons/io_hubs_addon/io/panels.py @@ -19,4 +19,3 @@ def unregister_panels(): bpy.utils.unregister_class(HubsGLTFExportPanel) except Exception: pass -