mrwonko / Blender-Jedi-Academy-Tools

Blender Importer and Exporter for the Ghoul2 model/animation format (.gla/.glm) by Raven Software, created with Jedi Knight: Jedi Academy in mind.
14 stars 5 forks source link

Try `bpy.context.view_layer.update()` #56

Open mrwonko opened 4 months ago

mrwonko commented 4 months ago

Maybe that way repeatedly switching out of pose mode during gla import can be avoided?

mrwonko commented 4 months ago
for frameNum, frame in enumerate(self.frames):
            # show progress bar / remaining time
            if time.time() >= nextProgressDisplayTime:
                ....
                nextProgressDisplayTime = time.time() + PROGRESS_UPDATE_INTERVAL

            # absolute offset matrices by bone index
            offsets: Dict[int, mathutils.Matrix] = {}
            for index in hierarchyOrder:
                ....
                pose_bone = bones[index]
                # pose_bone.matrix = transformation * scaleMatrix
                pose_bone.matrix = transformation
                bpy.context.view_layer.update()
                # in the _humanoid face, the scale gets changed. that messes the re-export up. FIXME: understand why. Is there a problem?
                pose_bone.scale = [1, 1, 1]
                pose_bone.keyframe_insert('location', frame = frameNum)
                pose_bone.keyframe_insert('rotation_quaternion', frame = frameNum)

        scene.frame_current = 1

https://discord.com/channels/200934142278369281/1103343134160728144/1225545235652935821