summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2017-07-27 10:04:14 +0200
committerSean Harmer <sean.harmer@kdab.com>2017-08-18 19:57:05 +0000
commit91690c3ddacb8077956029666dd0152bf378200e (patch)
tree113802354548a8ce8cd654cfdeeed606f49fda25 /tools
parent78569895236c4f82dba212d49ab57373682be4d5 (diff)
qt3d_animation_export.py: fix crash
Do the fCurveIndex lookup in the right code branch which otherwise could lead to out of range access (euler to quaternion case) Change-Id: Ib3da1186ec2b20021436434c54a26f13969c49d2 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/utils/exporters/blender/qt3d_animation_export.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/utils/exporters/blender/qt3d_animation_export.py b/tools/utils/exporters/blender/qt3d_animation_export.py
index 2d6575198..b1987ea95 100644
--- a/tools/utils/exporters/blender/qt3d_animation_export.py
+++ b/tools/utils/exporters/blender/qt3d_animation_export.py
@@ -165,8 +165,8 @@ class PropertyData:
def generateKeyframesData(self, outputComponentIndex):
outputKeyframes = []
+ print("generateKeyframesData: fcurveIndices: " + str(self.m_fcurveIndices) + " curve index: " + str(outputComponentIndex))
# Lookup fcurve index for this component
- fcurveIndex = self.m_fcurveIndices[outputComponentIndex]
# Invert the sign of the 2nd component of quaternions for rotations
# We already swap the Y and Z components in the componentSuffix function
@@ -175,6 +175,7 @@ class PropertyData:
axisOrientationfactor = -1.0
if self.m_dataType == self.m_outputDataType:
+ fcurveIndex = self.m_fcurveIndices[outputComponentIndex]
# We can take easy route if no data type conversion is needed
# Iterate over keyframes
fcurve = self.m_action.fcurves[fcurveIndex]
@@ -300,7 +301,7 @@ class Qt3DAnimationConverter:
lastTitle = ""
property = PropertyData()
- for fcurveIndex,fcurve in enumerate(action.fcurves):
+ for fcurveIndex, fcurve in enumerate(action.fcurves):
title = fcurve.data_path.title()
# For debugging
@@ -310,12 +311,6 @@ class Qt3DAnimationConverter:
dataPath = fcurve.data_path
type = resolveDataType(resolverObject, dataPath)
labelSuffix = componentSuffix("Vector", fcurve.array_index)
- print(" " + str(fcurveIndex) + ": Group: " + groupName \
- + ", Title = " + title \
- + ", Component:" + str(fcurve.array_index) \
- + ", Data Path: " + dataPath \
- + ", Data Type: " + type \
- + ", Label: " + labelSuffix)
# Create a new PropertyData if this fcurve is for a new property
if title != lastTitle:
@@ -332,11 +327,19 @@ class Qt3DAnimationConverter:
property.m_componentIndices.append(fcurve.array_index)
property.m_fcurveIndices.append(fcurveIndex)
+ print(" " + str(fcurveIndex) + ": Group: " + groupName \
+ + ", Title = " + title \
+ + ", Component:" + str(fcurve.array_index) \
+ + ", Data Path: " + dataPath \
+ + ", Data Type: " + type \
+ + ", Label: " + labelSuffix \
+ + ", fCurveIndices: " + str(property.m_fcurveIndices))
+
lastTitle = title
print("")
# For debugging
- print("Pass 1 - Collected data for " + str(len(propertyDataMap)) + " actions")
+ print("animationsToJson: Pass 1 - Collected data for " + str(len(propertyDataMap)) + " actions")
actionIndex = 0
for key in propertyDataMap:
print(str(actionIndex) + ": " + key + " has " + str(len(propertyDataMap[key])) + " properties")
@@ -345,6 +348,7 @@ class Qt3DAnimationConverter:
actionIndex = actionIndex + 1
# Pass 2
+ print("animationsToJson: Pass 2")
# The data structure that will be exported
output = {"animations": []}
@@ -370,6 +374,7 @@ class Qt3DAnimationConverter:
output["animations"].append(outputAction)
actionIndex = actionIndex + 1
+ print("animationsToJson: Generating JSON data")
jsonData = json.dumps(output, indent=2, sort_keys=True, separators=(',', ': '))
return jsonData