gamnit: fix parsing .obj models without an explicit object declaration
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 22 Dec 2017 00:14:02 +0000 (19:14 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 4 Jan 2018 21:28:27 +0000 (16:28 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/model_parsers/obj.nit

index 069c653..62f1488 100644 (file)
@@ -80,7 +80,11 @@ class ObjFileParser
                                geometry.params.add vec
                        else if token == "f" then # Faces
                                var face = read_face
-                               if obj_obj != null then obj_obj.faces.add face
+                               if obj_obj == null then
+                                       obj_obj = new ObjObj("")
+                                       geometry.objects.add obj_obj
+                               end
+                               obj_obj.faces.add face
                        else if token == "mtllib" then
                                current_material_lib = read_until_eol_or_comment
                        else if token == "usemtl" then