Skip to content

Commit

Permalink
general clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Sep 20, 2024
1 parent 2d0592b commit cd3853d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
14 changes: 7 additions & 7 deletions fast64_internal/f3d/glTF/f3d_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
get_gltf_settings,
is_import_context,
prefix_function,
GLTF2_ADDON_VERSION,
swap_function,
suffix_function,
GLTF2_ADDON_VERSION,
)
from ..f3d_gbi import F3D, get_F3D_GBI
from ..f3d_material import (
Expand All @@ -38,9 +38,9 @@
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
from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage
from io_scene_gltf2.io.com.gltf2_io_constants import TextureFilter, TextureWrap
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_f3d"
EX1_MATERIAL_EXTENSION_NAME = "FAST64_materials_f3dlx"
Expand Down Expand Up @@ -961,15 +961,15 @@ def gather_mesh_hook(blender_mesh: Mesh, *args):
color_layer.foreach_set("color", color)


import io_scene_gltf2.blender.exp.gltf2_blender_gather_mesh as gather_mesh_owner
import io_scene_gltf2.blender.exp.gltf2_blender_gather_mesh as gather_mesh_owner # pylint: disable=import-error

gather_mesh_owner.gather_mesh = prefix_function(gather_mesh_owner.gather_mesh, gather_mesh_hook)

# 3.2 hack

if GLTF2_ADDON_VERSION == (3, 2, 40):
import io_scene_gltf2.blender.exp.gltf2_blender_extract as extract_primitives_owner
import io_scene_gltf2.blender.exp.gltf2_blender_gather_primitive_attributes as __gather_colors_owner
import io_scene_gltf2.blender.exp.gltf2_blender_extract as extract_primitives_owner # pylint: disable=import-error
import io_scene_gltf2.blender.exp.gltf2_blender_gather_primitive_attributes as __gather_colors_owner # pylint: disable=import-error
from io_scene_gltf2.blender.exp.gltf2_blender_extract import ( # pylint: disable=import-error
__get_positions,
__get_bone_data,
Expand Down
16 changes: 10 additions & 6 deletions fast64_internal/gltf_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@ 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 __is_blender_image_a_webp
from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_image import (
from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_image import (
__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,
__gather_uri,
__gather_buffer_view,
__is_blender_image_a_jpeg,
)
from io_scene_gltf2.blender.exp.material.extensions.gltf2_blender_image import ExportImage
from io_scene_gltf2.blender.exp.material.extensions.gltf2_blender_image import (
ExportImage,
) # pylint: disable=import-error
else:
from io_scene_gltf2.blender.exp.gltf2_blender_gather_image import (
from io_scene_gltf2.blender.exp.gltf2_blender_gather_image import ( # pylint: disable=import-error
__gather_name,
__make_image,
__gather_uri,
__gather_buffer_view,
__is_blender_image_a_jpeg,
)
from io_scene_gltf2.blender.exp.gltf2_blender_image import ExportImage
from io_scene_gltf2.blender.exp.gltf2_blender_image import ExportImage # pylint: disable=import-error


def is_blender_image_a_webp(image: Image) -> bool:
Expand Down Expand Up @@ -98,7 +102,7 @@ def print_verbose(self, content):
if self.extension.verbose:
pprint(content)

def append_extension(self, gltf_prop, name: str, data: dict = None, required=False, skip_if_empty=True):
def append_extension(self, gltf_prop, name: str, data: dict | None = None, required=False, skip_if_empty=True):
if skip_if_empty and not data and data is not None: # If none, assume it shouldn´t skip
return
self.print_verbose(f"Appending {name} extension")
Expand Down
12 changes: 10 additions & 2 deletions gltf_extension.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import traceback

import bpy
from bpy.types import PropertyGroup, UILayout, Panel, Context
from bpy.props import BoolProperty, PointerProperty
Expand All @@ -24,6 +25,7 @@
# Importing
# Better and more extensive errors


def glTF2_pre_export_callback(_gltf):
modify_f3d_nodes_for_export(False)

Expand Down Expand Up @@ -63,7 +65,7 @@ def call_hooks(self, hook: str, message_template: str, *args):
# TODO: Force glTF exports and imports to fail somehow?

def __init__(self):
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension # pylint: disable=import-error

self.Extension = Extension

Expand Down Expand Up @@ -123,7 +125,13 @@ def gather_import_node_after_hook(self, vnode, gltf_node, blender_object, gltf):
)

def gather_import_mesh_after_hook(self, gltf_mesh, blender_mesh, gltf):
self.call_hooks("gather_import_mesh_after_hook", 'Mesh "{args[1].name}"', gltf_mesh, blender_mesh, gltf)
self.call_hooks(
"gather_import_mesh_after_hook",
'Mesh "{args[1].name}"',
gltf_mesh,
blender_mesh,
gltf,
)


class Fast64GlTFSettings(PropertyGroup):
Expand Down

0 comments on commit cd3853d

Please sign in to comment.