Updated BDK repository support to match bdk_addon
This commit is contained in:
@@ -101,6 +101,12 @@ class PSK_OT_import(Operator, ImportHelper):
|
|||||||
default=1.0,
|
default=1.0,
|
||||||
soft_min=0.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):
|
def execute(self, context):
|
||||||
psk = read_psk(self.filepath)
|
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.should_import_shape_keys = self.should_import_shape_keys
|
||||||
options.scale = self.scale
|
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:
|
if not options.should_import_mesh and not options.should_import_skeleton:
|
||||||
self.report({'ERROR'}, 'Nothing to import')
|
self.report({'ERROR'}, 'Nothing to import')
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class PskImportOptions:
|
|||||||
self.bone_length = 1.0
|
self.bone_length = 1.0
|
||||||
self.should_import_materials = True
|
self.should_import_materials = True
|
||||||
self.scale = 1.0
|
self.scale = 1.0
|
||||||
|
self.bdk_repository_id = None
|
||||||
|
|
||||||
|
|
||||||
class ImportBone:
|
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.
|
# Material does not yet exist, and we have the BDK addon installed.
|
||||||
# Attempt to load it using BDK addon's operator.
|
# Attempt to load it using BDK addon's operator.
|
||||||
material_reference = psk.material_references[material_index]
|
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]
|
material = bpy.data.materials[material_name]
|
||||||
else:
|
else:
|
||||||
# Just create a blank material.
|
# Just create a blank material.
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import re
|
|||||||
import typing
|
import typing
|
||||||
from typing import List, Iterable
|
from typing import List, Iterable
|
||||||
|
|
||||||
import addon_utils
|
|
||||||
import bpy.types
|
import bpy.types
|
||||||
from bpy.types import NlaStrip, Object, AnimData
|
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():
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user