From e1f96d5ee8546c38ca5c0cf4a1fce8ebe43a3289 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 10 Jan 2022 17:19:47 +0800 Subject: [PATCH] Fix crash on importing FBX file (cherry picked from commit af67e4c2919cb12ec257ca6bc3bb264933e4e2a4) --- core/set.h | 3 +++ modules/fbx/data/fbx_mesh_data.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/set.h b/core/set.h index eb2014f36d1..d0eeb8a0f90 100644 --- a/core/set.h +++ b/core/set.h @@ -509,6 +509,9 @@ public: } Element *lower_bound(const T &p_value) const { + if (!_data._root) { + return nullptr; + } return _lower_bound(p_value); } diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 75755efeaf7..ac883bafc96 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -1104,7 +1104,7 @@ HashMap FBXMeshData::extract_per_vertex_data( const int vertex_index = get_vertex_from_polygon_vertex(p_mesh_indices, polygon_vertex_index); ERR_FAIL_COND_V_MSG(vertex_index < 0, (HashMap()), "FBX file corrupted: #ERR05"); ERR_FAIL_COND_V_MSG(vertex_index >= p_vertex_count, (HashMap()), "FBX file corrupted: #ERR06"); - const int index_to_direct = p_mapping_data.index[polygon_vertex_index]; + const int index_to_direct = get_vertex_from_polygon_vertex(p_mapping_data.index, polygon_vertex_index); T value = p_mapping_data.data[index_to_direct]; aggregate_vertex_data[vertex_index].push_back({ polygon_id, value }); } @@ -1309,7 +1309,7 @@ HashMap FBXMeshData::extract_per_polygon( } else { ERR_FAIL_INDEX_V_MSG(polygon_index, (int)p_fbx_data.index.size(), (HashMap()), "FBX file is corrupted: #ERR62"); - const int index_to_direct = p_fbx_data.index[polygon_index]; + const int index_to_direct = get_vertex_from_polygon_vertex(p_fbx_data.index, polygon_index); T value = p_fbx_data.data[index_to_direct]; aggregate_polygon_data[polygon_index].push_back(value); }