diff --git a/fast64_internal/f3d/glTF/f3d_gltf.py b/fast64_internal/f3d/glTF/f3d_gltf.py index 661583a12..1d5eccb41 100644 --- a/fast64_internal/f3d/glTF/f3d_gltf.py +++ b/fast64_internal/f3d/glTF/f3d_gltf.py @@ -1,11 +1,16 @@ -import copy from dataclasses import dataclass from math import ceil, floor +import copy import bpy -from bpy.types import NodeTree, Object, Mesh, Material, Context, Panel, PropertyGroup, UILayout -from bpy.props import BoolProperty import numpy as np +from io_scene_gltf2.io.com import gltf2_io # pylint: disable=import-error +from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage # pylint: disable=import-error +from io_scene_gltf2.io.com.gltf2_io_constants import TextureFilter, TextureWrap # pylint: disable=import-error + +from bpy.types import NodeTree, Mesh, Material, Context, Panel, PropertyGroup, UILayout +from bpy.props import BoolProperty + from ...utility import ( json_to_prop_group, multilineLabel, @@ -46,10 +51,6 @@ from ..f3d_writer import cel_shading_checks, check_face_materials, getColorLayer from ..f3d_texture_writer import UVtoSTLarge -from io_scene_gltf2.io.com import gltf2_io # pylint: disable=import-error -from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage # pylint: disable=import-error -from io_scene_gltf2.io.com.gltf2_io_constants import TextureFilter, TextureWrap # pylint: disable=import-error - MATERIAL_EXTENSION_NAME = "FAST64_materials_n64" F3D_MATERIAL_EXTENSION_NAME = "FAST64_materials_f3d" EX1_MATERIAL_EXTENSION_NAME = "FAST64_materials_f3dlx" diff --git a/fast64_internal/gltf_utility.py b/fast64_internal/gltf_utility.py index fb998658c..e3480ca9e 100644 --- a/fast64_internal/gltf_utility.py +++ b/fast64_internal/gltf_utility.py @@ -1,6 +1,6 @@ from pprint import pprint -import functools from typing import Callable +import functools import addon_utils import bpy @@ -8,11 +8,10 @@ def find_glTF2_addon(): - for mod in addon_utils.modules(): + for mod in addon_utils.modules(): # pylint: disable=not-an-iterable if mod.__name__ == "io_scene_gltf2": return mod - else: - raise ValueError("glTF2 addon not found") + raise ValueError("glTF2 addon not found") GLTF2_ADDDON = find_glTF2_addon() @@ -20,9 +19,9 @@ def find_glTF2_addon(): if GLTF2_ADDON_VERSION >= (3, 6, 0): if GLTF2_ADDON_VERSION: - from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_image import ( + from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_image import ( # pylint: disable=import-error __is_blender_image_a_webp, - ) # pylint: disable=import-error + ) from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_image import ( # pylint: disable=import-error __gather_name, __make_image, @@ -30,9 +29,9 @@ def find_glTF2_addon(): __gather_buffer_view, __is_blender_image_a_jpeg, ) - from io_scene_gltf2.blender.exp.material.extensions.gltf2_blender_image import ( + from io_scene_gltf2.blender.exp.material.extensions.gltf2_blender_image import ( # pylint: disable=import-error ExportImage, - ) # pylint: disable=import-error + ) else: from io_scene_gltf2.blender.exp.gltf2_blender_gather_image import ( # pylint: disable=import-error __gather_name, @@ -134,38 +133,38 @@ def is_import_context(context): return context.space_data.active_operator.bl_idname == "IMPORT_SCENE_OT_gltf" -def prefix_function(function: Callable, prefunction: Callable): - function = getattr(function, "fast64_og_func", function) +def prefix_function(original: Callable, prefix: Callable): + original = getattr(original, "fast64_og_func", original) - @functools.wraps(function) + @functools.wraps(original) def run(*args, **kwargs): - prefunction(*args, **kwargs) - return function(*args, **kwargs) + prefix(*args, **kwargs) + return original(*args, **kwargs) - setattr(run, "fast64_og_func", function) + setattr(run, "fast64_og_func", original) return run -def suffix_function(function: Callable, suffix_function: Callable): +def suffix_function(original: Callable, suffix: Callable): """Passes in result as the first arg""" - function = getattr(function, "fast64_og_func", function) + original = getattr(original, "fast64_og_func", original) - @functools.wraps(function) + @functools.wraps(original) def run(*args, **kwargs): - results = function(*args, **kwargs) - return suffix_function(results, *args, **kwargs) + results = original(*args, **kwargs) + return suffix(results, *args, **kwargs) - setattr(run, "fast64_og_func", function) + setattr(run, "fast64_og_func", original) return run -def swap_function(function: Callable, new_function: Callable): +def swap_function(original: Callable, new: Callable): """Passes in the original function as the first arg""" - function = getattr(function, "fast64_og_func", function) + original = getattr(original, "fast64_og_func", original) - @functools.wraps(function) + @functools.wraps(original) def run(*args, **kwargs): - return new_function(function, *args, **kwargs) + return new(original, *args, **kwargs) - setattr(run, "fast64_og_func", function) + setattr(run, "fast64_og_func", original) return run