From 5f3bfc0ff3cf415d5237d2800b681e8b7ad3e361 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Thu, 6 Feb 2025 21:10:13 -0800 Subject: [PATCH] Fix for error when exporting mesh with no armature --- io_scene_psk_psa/psk/builder.py | 2 +- io_scene_psk_psa/shared/data.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/io_scene_psk_psa/psk/builder.py b/io_scene_psk_psa/psk/builder.py index c485c3f..e7347e4 100644 --- a/io_scene_psk_psa/psk/builder.py +++ b/io_scene_psk_psa/psk/builder.py @@ -130,7 +130,7 @@ def build_psk(context, input_objects: PskInputObjects, options: PskBuildOptions) psk_bone.children_count = 0 psk_bone.parent_index = 0 psk_bone.location = Vector3.zero() - psk_bone.rotation = coordinate_system_default_rotation + psk_bone.rotation = Quaternion.from_bpy_quaternion(coordinate_system_default_rotation) psk.bones.append(psk_bone) else: bone_names = get_export_bone_names(armature_object, options.bone_filter_mode, options.bone_collection_indices) diff --git a/io_scene_psk_psa/shared/data.py b/io_scene_psk_psa/shared/data.py index f96cd77..ab0ccc2 100644 --- a/io_scene_psk_psa/shared/data.py +++ b/io_scene_psk_psa/shared/data.py @@ -2,7 +2,7 @@ from ctypes import * from typing import Tuple from bpy.props import EnumProperty -from mathutils import Vector, Matrix +from mathutils import Vector, Matrix, Quaternion as BpyQuaternion class Color(Structure): @@ -84,6 +84,15 @@ class Quaternion(Structure): def identity(cls): return Quaternion(0, 0, 0, 1) + @classmethod + def from_bpy_quaternion(cls, other: BpyQuaternion) -> BpyQuaternion: + quaternion = Quaternion() + quaternion.x = other.x + quaternion.y = other.y + quaternion.z = other.z + quaternion.w = other.w + return quaternion + class Section(Structure): _fields_ = [