Skip to content

Commit

Permalink
Remove unused import and run format.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
Exairnous committed Apr 5, 2024
1 parent 79f20bd commit 5991ed6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 18 deletions.
2 changes: 2 additions & 0 deletions addons/io_hubs_addon/components/components_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion addons/io_hubs_addon/components/definitions/billboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 8 additions & 8 deletions addons/io_hubs_addon/components/definitions/media_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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].")
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion addons/io_hubs_addon/components/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 7 additions & 4 deletions addons/io_hubs_addon/io/gltf_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion addons/io_hubs_addon/io/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ def unregister_panels():
bpy.utils.unregister_class(HubsGLTFExportPanel)
except Exception:
pass

0 comments on commit 5991ed6

Please sign in to comment.