|
1 | 1 | package com.jme3.scene.plugins.gltf; |
2 | 2 |
|
| 3 | +import com.jme3.asset.AssetLoadException; |
3 | 4 | import com.jme3.math.*; |
4 | 5 |
|
5 | 6 | import java.util.*; |
@@ -119,9 +120,19 @@ public void update() { |
119 | 120 | } |
120 | 121 | } |
121 | 122 |
|
| 123 | + checkTimesConsistantcy(); |
| 124 | + |
122 | 125 | length = times[times.length - 1]; |
123 | 126 | } |
124 | 127 |
|
| 128 | + public void checkTimesConsistantcy() { |
| 129 | + if ((translations != null && times.length != translations.length) |
| 130 | + || (rotations != null && times.length != rotations.length) |
| 131 | + || (scales != null && times.length != scales.length)) { |
| 132 | + throw new AssetLoadException("Inconsistent animation sampling "); |
| 133 | + } |
| 134 | + } |
| 135 | + |
125 | 136 | private void populateTransform(Type type, int index, List<KeyFrame> keyFrames, KeyFrame currentKeyFrame, TransformIndices transformIndices) { |
126 | 137 | Object transform = getTransform(type, currentKeyFrame); |
127 | 138 | if (transform != null) { |
@@ -178,14 +189,8 @@ private int findNext(List<KeyFrame> keyFrames, Type type, int fromIndex) { |
178 | 189 | } |
179 | 190 |
|
180 | 191 | public int getNbKeyFrames(){ |
181 | | - if(translations != null){ |
182 | | - return translations.length; |
183 | | - } |
184 | | - if(rotations != null){ |
185 | | - return rotations.length; |
186 | | - } |
187 | | - if(scales != null){ |
188 | | - return scales.length; |
| 192 | + if (times != null) { |
| 193 | + return times.length; |
189 | 194 | } |
190 | 195 | return 0; |
191 | 196 | } |
@@ -234,13 +239,13 @@ private Object getTransform(Type type, KeyFrame kf) { |
234 | 239 | } |
235 | 240 |
|
236 | 241 | private void ensureArraysLength() { |
237 | | - if (translations != null && translations.length < times.length) { |
| 242 | + if (translations != null && translations.length != times.length) { |
238 | 243 | translations = new Vector3f[times.length]; |
239 | 244 | } |
240 | | - if (rotations != null && rotations.length < times.length) { |
| 245 | + if (rotations != null && rotations.length != times.length) { |
241 | 246 | rotations = new Quaternion[times.length]; |
242 | 247 | } |
243 | | - if (scales != null && scales.length < times.length) { |
| 248 | + if (scales != null && scales.length != times.length) { |
244 | 249 | scales = new Vector3f[times.length]; |
245 | 250 | } |
246 | 251 | } |
|
0 commit comments