diff options
author | Marios Staikopoulos <marios@staik.net> | 2019-12-24 15:03:24 -0800 |
---|---|---|
committer | Marios Staikopoulos <marios@staik.net> | 2019-12-24 15:03:24 -0800 |
commit | d3cf8cfb7d33816ae69eb45728088baae9a3195b (patch) | |
tree | 4c7638376a896f3d1bb1fd53bcd6acfb10efe419 /editor/import | |
parent | d711c57d767734887fbf0955a7b9902c54498a0d (diff) |
Fix Hard Crash on glTF Color Accessor Import
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index be066e15a5..796b950444 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -855,25 +855,24 @@ PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState & const int type = state.accessors[p_accessor].type; ERR_FAIL_COND_V(!(type == TYPE_VEC3 || type == TYPE_VEC4), ret); - int components; - if (type == TYPE_VEC3) { - components = 3; - } else { // TYPE_VEC4 - components = 4; + int vec_len = 3; + if (type == TYPE_VEC4) { + vec_len = 4; } - ERR_FAIL_COND_V(attribs.size() % components != 0, ret); + ERR_FAIL_COND_V(attribs.size() % vec_len != 0, ret); const double *attribs_ptr = attribs.ptr(); - const int ret_size = attribs.size() / components; + const int ret_size = attribs.size() / vec_len; ret.resize(ret_size); { PoolVector<Color>::Write w = ret.write(); for (int i = 0; i < ret_size; i++) { - w[i] = Color(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], components == 4 ? attribs_ptr[i * 4 + 3] : 1.0); + w[i] = Color(attribs_ptr[i * vec_len + 0], attribs_ptr[i * vec_len + 1], attribs_ptr[i * vec_len + 2], vec_len == 4 ? attribs_ptr[i * 4 + 3] : 1.0); } } return ret; } + Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); |