From 946fe9a4c5d45ddfd116e1207c7cc3aeaa1f0b1e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Oct 2019 21:36:22 -0400 Subject: [PATCH] Fix #160. --- korman/exporter/material.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 8a2cc94..f3ecfe4 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -14,6 +14,7 @@ # along with Korman. If not, see . import bpy +import functools import math from pathlib import Path from PyHSPlasma import * @@ -454,10 +455,12 @@ class MaterialConverter: fps = bpy.context.scene.render.fps atc = layer_animation.timeConvert - if tex_action is not None: - start, end = tex_action.frame_range - else: - start, end = mat_action.frame_range + + # Since we are harvesting from the material action but are exporting to a layer, the + # action's range is relatively useless. We'll figure our own. + start, end = functools.reduce(lambda x, y: (min(x[0], y[0]), max(x[1], y[1])), + (fcurve.range() for fcurve in fcurves)) + atc.begin = start / fps atc.end = end / fps