From 58ef84bcb8d884bb09c186cf8d4f21fd1e2f5679 Mon Sep 17 00:00:00 2001 From: Spiderguy-F Date: Wed, 20 Mar 2024 10:23:14 +0100 Subject: [PATCH] Conformed Style --- .../components/definitions/audio_params.py | 2 +- .../components/definitions/media_frame.py | 4 ++-- addons/io_hubs_addon/components/handlers.py | 2 +- addons/io_hubs_addon/components/utils.py | 2 +- addons/io_hubs_addon/io/gltf_exporter.py | 8 +------- addons/io_hubs_addon/io/utils.py | 10 +++++----- addons/io_hubs_addon/nodes/lightmap.py | 15 ++++++++++++--- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/addons/io_hubs_addon/components/definitions/audio_params.py b/addons/io_hubs_addon/components/definitions/audio_params.py index f174bc5a..d25991c5 100644 --- a/addons/io_hubs_addon/components/definitions/audio_params.py +++ b/addons/io_hubs_addon/components/definitions/audio_params.py @@ -114,7 +114,7 @@ def migrate(self, migration_type, panel_type, instance_version, host, migration_ self.coneOuterAngle = radians( self.coneOuterAngle) - if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) == bpy.types.Armature: + if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) is bpy.types.Armature: host_reference = get_host_reference_message(panel_type, host, ob=ob) migration_report.append( f"Warning: The Media Cone angles may not have migrated correctly for the Audio Params component on the {panel_type.value} {host_reference}") diff --git a/addons/io_hubs_addon/components/definitions/media_frame.py b/addons/io_hubs_addon/components/definitions/media_frame.py index 0ff901ac..8b6c9d76 100644 --- a/addons/io_hubs_addon/components/definitions/media_frame.py +++ b/addons/io_hubs_addon/components/definitions/media_frame.py @@ -11,7 +11,7 @@ def is_bone(ob): - return type(ob) == EditBone or type(ob) == Bone + return type(ob) is EditBone or type(ob) is Bone class MediaFrameGizmo(Gizmo): @@ -157,7 +157,7 @@ def migrate(self, migration_type, panel_type, instance_version, host, migration_ bounds = Vector((bounds.x, bounds.z, bounds.y)) self.bounds = bounds - if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) == bpy.types.Armature: + if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) is bpy.types.Armature: host_reference = get_host_reference_message(panel_type, host, ob=ob) migration_report.append( f"Warning: The Media Frame component's Y and Z bounds on the {panel_type.value} {host_reference} may not have migrated correctly") diff --git a/addons/io_hubs_addon/components/handlers.py b/addons/io_hubs_addon/components/handlers.py index 9c476454..dabeba54 100644 --- a/addons/io_hubs_addon/components/handlers.py +++ b/addons/io_hubs_addon/components/handlers.py @@ -25,7 +25,7 @@ def migrate(component, migration_type, panel_type, host, migration_report, ob=No was_migrated = component.migrate( migration_type, panel_type, instance_version, host, migration_report, ob=ob) - if type(was_migrated) != bool: + if type(was_migrated) is not bool: print(f"Warning: the {component.get_display_name()} component didn't return whether a migration occurred.") # Fall back to assuming there was a migration since the version increased. was_migrated = True diff --git a/addons/io_hubs_addon/components/utils.py b/addons/io_hubs_addon/components/utils.py index 92483d5f..702d8110 100644 --- a/addons/io_hubs_addon/components/utils.py +++ b/addons/io_hubs_addon/components/utils.py @@ -297,7 +297,7 @@ def display_wrapped_text(layout, wrapped_text, *, heading_icon='NONE'): def get_host_reference_message(panel_type, host, ob=None): '''The ob argument is used for bone hosts and is the armature object, but will fall back to the armature if the armature object isn't available.''' if panel_type == PanelType.BONE: - ob_type = "armature" if type(ob) == bpy.types.Armature else "object" + ob_type = "armature" if type(ob) is bpy.types.Armature else "object" host_reference = f"\"{host.name}\" in {ob_type} \"{ob.name_full}\"" else: host_reference = f"\"{host.name_full}\"" diff --git a/addons/io_hubs_addon/io/gltf_exporter.py b/addons/io_hubs_addon/io/gltf_exporter.py index dff64488..09b9eb43 100644 --- a/addons/io_hubs_addon/io/gltf_exporter.py +++ b/addons/io_hubs_addon/io/gltf_exporter.py @@ -149,28 +149,22 @@ def gather_node_hook(self, gltf2_object, blender_object, export_settings): self.add_hubs_components(gltf2_object, blender_object, export_settings) def gather_material_hook(self, gltf2_object, blender_material, export_settings): - print("Gathering material:", blender_material.name) - if blender_material.name == "WithLightmap": - print("export_settings:", export_settings) if not self.properties.enabled: - print("Not enabled") return self.add_hubs_components( gltf2_object, blender_material, export_settings) - print("added components") from .utils import gather_lightmap_texture_info if blender_material.node_tree and blender_material.use_nodes: lightmap_texture_info = gather_lightmap_texture_info( blender_material, export_settings) - print("gathered lightmap texture info:", lightmap_texture_info) if lightmap_texture_info: gltf2_object.extensions["MOZ_lightmap"] = self.Extension( name="MOZ_lightmap", extension=lightmap_texture_info, required=False, ) - print("Hook done") + def gather_material_unlit_hook(self, gltf2_object, blender_material, export_settings): self.gather_material_hook( gltf2_object, blender_material, export_settings) diff --git a/addons/io_hubs_addon/io/utils.py b/addons/io_hubs_addon/io/utils.py index dcaf9f9d..b4f77432 100644 --- a/addons/io_hubs_addon/io/utils.py +++ b/addons/io_hubs_addon/io/utils.py @@ -77,7 +77,7 @@ def gather_image(blender_image, export_settings): mime_type = "image/jpeg" d1 = HubsExportImage.from_blender_image(blender_image) data = d1.encode(mime_type, export_settings) - if type(data) == tuple: + if type(data) is tuple: data = data[0] if export_settings['gltf_format'] == 'GLTF_SEPARATE': @@ -157,13 +157,13 @@ def gather_property(export_settings, blender_object, target, property_name): return gather_vec_property(export_settings, blender_object, target, property_name) elif (property_definition.bl_rna.identifier == 'PointerProperty'): - if type(property_value) == bpy.types.Object: + if type(property_value) is bpy.types.Object: return gather_node_property(export_settings, blender_object, target, property_name) - elif type(property_value) == bpy.types.Material: + elif type(property_value) is bpy.types.Material: return gather_material_property(export_settings, blender_object, target, property_name) - elif type(property_value) == bpy.types.Image: + elif type(property_value) is bpy.types.Image: return gather_image_property(export_settings, blender_object, target, property_name) - elif type(property_value) == bpy.types.Texture: + elif type(property_value) is bpy.types.Texture: return gather_texture_property(export_settings, blender_object, target, property_name) return gltf2_blender_extras.__to_json_compatible(property_value) diff --git a/addons/io_hubs_addon/nodes/lightmap.py b/addons/io_hubs_addon/nodes/lightmap.py index 88a90a66..86007c01 100644 --- a/addons/io_hubs_addon/nodes/lightmap.py +++ b/addons/io_hubs_addon/nodes/lightmap.py @@ -17,7 +17,9 @@ def poll(cls, context): ]), ] + class NODE_MT_mozilla_hubs_nodes(bpy.types.Menu): + """Add node menu for Blender 4.x""" bl_label = "Hubs" bl_idname = "NODE_MT_mozilla_hubs_nodes" @@ -25,6 +27,7 @@ def draw(self, context): layout = self.layout layout.operator("node.add_node", text="MOZ_lightmap settings").type = "moz_lightmap.node" + class MozLightmapNode(Node): """MOZ_lightmap settings node""" bl_idname = 'moz_lightmap.node' @@ -51,40 +54,46 @@ def draw_buttons(self, context, layout): def draw_label(self): return "MOZ_lightmap" + def create_node_categories(): return [NodeCategory("MOZ_NODES", "Moz Nodes", items=node_categories)] + def menu_func(self, context): self.layout.menu("NODE_MT_mozilla_hubs_nodes") + def register_blender_4(): - print("Using Blender 4x") bpy.utils.register_class(NODE_MT_mozilla_hubs_nodes) bpy.types.NODE_MT_shader_node_add_all.append(menu_func) bpy.utils.register_class(MozLightmapNode) + def unregister_blender_4(): bpy.types.NODE_MT_shader_node_add_all.remove(menu_func) bpy.utils.unregister_class(NODE_MT_mozilla_hubs_nodes) bpy.utils.unregister_class(MozLightmapNode) + def register_blender_3(): - print("Using Blender 3x") bpy.utils.register_class(MozLightmapNode) nodeitems_utils.register_node_categories("MOZ_NODES", node_categories) + def unregister_blender_3(): bpy.utils.unregister_class(MozLightmapNode) nodeitems_utils.unregister_node_categories("MOZ_NODES", node_categories) + def register(): if bpy.app.version < (4, 0, 0): register_blender_3() else: register_blender_4() + def unregister(): if bpy.app.version < (4, 0, 0): unregister_blender_3() else: - unregister_blender_4() \ No newline at end of file + unregister_blender_4()