summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-21 22:09:08 +0100
committerGitHub <noreply@github.com>2019-11-21 22:09:08 +0100
commit28613ab8c9f48c5d0cb5c1f23df6d1b662872f51 (patch)
tree7bd035fddcfaba0536ceaca81ac99cb022fcd9de /editor/import
parent1dc110fe7bb574f771ce19560d14a44b5550ac80 (diff)
parente949665489416ef948a5ead7e12d3691d78af6f4 (diff)
Merge pull request #33794 from nekomatata/gltf-morph-shapes-crash2
Error instead of crash in gltf import with more than one morph target
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index bb4f950674..10af25bfcf 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -2357,6 +2357,7 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
const int output = s["output"];
GLTFAnimation::Interpolation interp = GLTFAnimation::INTERP_LINEAR;
+ int output_count = 1;
if (s.has("interpolation")) {
const String &in = s["interpolation"];
if (in == "STEP") {
@@ -2365,8 +2366,10 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
interp = GLTFAnimation::INTERP_LINEAR;
} else if (in == "CATMULLROMSPLINE") {
interp = GLTFAnimation::INTERP_CATMULLROMSPLINE;
+ output_count = 3;
} else if (in == "CUBICSPLINE") {
interp = GLTFAnimation::INTERP_CUBIC_SPLINE;
+ output_count = 3;
}
}
@@ -2396,6 +2399,9 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
track->weight_tracks.resize(wc);
+ const int expected_value_count = times.size() * output_count * wc;
+ ERR_FAIL_COND_V_MSG(weights.size() != expected_value_count, ERR_PARSE_ERROR, "Invalid weight data, expected " + itos(expected_value_count) + " weight values, got " + itos(weights.size()) + " instead.");
+
const int wlen = weights.size() / wc;
PoolVector<float>::Read r = weights.read();
for (int k = 0; k < wc; k++) { //separate tracks, having them together is not such a good idea