1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-23 22:40:59 +01:00

Updated BDK repository support to match bdk_addon

This commit is contained in:
Colin Basnett 2024-06-22 23:44:43 -07:00
parent 3863e4edcc
commit 5cfb37d1a2
3 changed files with 14 additions and 3 deletions

View File

@ -101,6 +101,12 @@ class PSK_OT_import(Operator, ImportHelper):
default=1.0,
soft_min=0.0,
)
bdk_repository_id: StringProperty(
name='BDK Repository ID',
default='',
options=empty_set,
description='The ID of the BDK repository to use for loading materials'
)
def execute(self, context):
psk = read_psk(self.filepath)
@ -118,6 +124,9 @@ class PSK_OT_import(Operator, ImportHelper):
options.should_import_shape_keys = self.should_import_shape_keys
options.scale = self.scale
if self.bdk_repository_id:
options.bdk_repository_id = self.bdk_repository_id
if not options.should_import_mesh and not options.should_import_skeleton:
self.report({'ERROR'}, 'Nothing to import')
return {'CANCELLED'}

View File

@ -25,6 +25,7 @@ class PskImportOptions:
self.bone_length = 1.0
self.should_import_materials = True
self.scale = 1.0
self.bdk_repository_id = None
class ImportBone:
@ -130,7 +131,7 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
# Material does not yet exist, and we have the BDK addon installed.
# Attempt to load it using BDK addon's operator.
material_reference = psk.material_references[material_index]
if material_reference and bpy.ops.bdk.link_material(reference=material_reference) == {'FINISHED'}:
if material_reference and bpy.ops.bdk.link_material(reference=material_reference, repository_id=options.bdk_repository_id) == {'FINISHED'}:
material = bpy.data.materials[material_name]
else:
# Just create a blank material.

View File

@ -2,7 +2,6 @@ import re
import typing
from typing import List, Iterable
import addon_utils
import bpy.types
from bpy.types import NlaStrip, Object, AnimData
@ -165,4 +164,6 @@ def get_export_bone_names(armature_object: Object, bone_filter_mode: str, bone_c
def is_bdk_addon_loaded():
return addon_utils.check('bdk_addon')[1]
# TODO: this does not work anymore for *reasons*. Just check if bpy.ops.bdk.link_material exists.
# return addon_utils.check('bdk_addon')[1]
return bpy.ops.bdk.link_material is not None