summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-05-05 22:45:36 +0200
committerGitHub <noreply@github.com>2017-05-05 22:45:36 +0200
commit9437d610e18965a5a75d073a8ce8a04c60d736c3 (patch)
treef9edab959d84e1f48f931724d85d72dd9fdc871b /editor/import
parent1f9266cbff83e611b3178f5c62fc512f91a7f94a (diff)
parent3cdfac7ed2698fbd80e764cb190d775ac97bde97 (diff)
Merge pull request #8556 from ippan/obj_import
support obj with negative indices
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/resource_importer_obj.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 19fd1208b9..21c2ae6eb3 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -168,18 +168,23 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
if (face[idx].size() == 3) {
int norm = face[idx][2].to_int() - 1;
+ if (norm < 0)
+ norm += normals.size() + 1;
ERR_FAIL_INDEX_V(norm, normals.size(), ERR_PARSE_ERROR);
surf_tool->add_normal(normals[norm]);
}
if (face[idx].size() >= 2 && face[idx][1] != String()) {
-
int uv = face[idx][1].to_int() - 1;
+ if (uv < 0)
+ uv += uvs.size() + 1;
ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_PARSE_ERROR);
surf_tool->add_uv(uvs[uv]);
}
int vtx = face[idx][0].to_int() - 1;
+ if (vtx < 0)
+ vtx += vertices.size() + 1;
ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_PARSE_ERROR);
Vector3 vertex = vertices[vtx];