Simplified method used to put armature in bind pose for PSK export
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
from collections import OrderedDict
|
import bmesh
|
||||||
from typing import Dict, List
|
import bpy
|
||||||
|
|
||||||
from .data import *
|
from .data import *
|
||||||
from ..helpers import *
|
from ..helpers import *
|
||||||
import bmesh
|
|
||||||
import bpy
|
|
||||||
|
|
||||||
|
|
||||||
class PskInputObjects(object):
|
class PskInputObjects(object):
|
||||||
@@ -135,16 +133,17 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
|||||||
# MATERIALS
|
# MATERIALS
|
||||||
material_indices = [material_names.index(material.name) for material in input_mesh_object.data.materials]
|
material_indices = [material_names.index(material.name) for material in input_mesh_object.data.materials]
|
||||||
|
|
||||||
|
# MESH DATA
|
||||||
if options.use_raw_mesh_data:
|
if options.use_raw_mesh_data:
|
||||||
mesh_object = input_mesh_object
|
mesh_object = input_mesh_object
|
||||||
mesh_data = input_mesh_object.data
|
mesh_data = input_mesh_object.data
|
||||||
else:
|
else:
|
||||||
# Create a copy of the mesh object after non-armature modifiers are applied.
|
# Create a copy of the mesh object after non-armature modifiers are applied.
|
||||||
|
|
||||||
# Temporarily deactivate any armature modifiers on the input mesh object.
|
# Temporarily force the armature into the rest position.
|
||||||
active_armature_modifiers = [x for x in filter(lambda x: x.type == 'ARMATURE' and x.is_active, input_mesh_object.modifiers)]
|
# We will undo this later.
|
||||||
for modifier in active_armature_modifiers:
|
old_pose_position = armature_object.data.pose_position
|
||||||
modifier.show_viewport = False
|
armature_object.data.pose_position = 'REST'
|
||||||
|
|
||||||
depsgraph = context.evaluated_depsgraph_get()
|
depsgraph = context.evaluated_depsgraph_get()
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
@@ -159,9 +158,8 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
|||||||
for vertex_group in input_mesh_object.vertex_groups:
|
for vertex_group in input_mesh_object.vertex_groups:
|
||||||
mesh_object.vertex_groups.new(name=vertex_group.name)
|
mesh_object.vertex_groups.new(name=vertex_group.name)
|
||||||
|
|
||||||
# Reactivate previously active armature modifiers
|
# Restore the previous pose position on the armature.
|
||||||
for modifier in active_armature_modifiers:
|
armature_object.data.pose_position = old_pose_position
|
||||||
modifier.show_viewport = True
|
|
||||||
|
|
||||||
vertex_offset = len(psk.points)
|
vertex_offset = len(psk.points)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user