Sfoglia il codice sorgente

Merge pull request #81 from sdfgeoff/master

Fix for issue #80 (failing to export single-vert mesh)
sdfgeoff 7 anni fa
parent
commit
a1761d0183

+ 8 - 1
io_scene_godot/converters/mesh.py

@@ -158,7 +158,14 @@ class MeshResourceExporter:
 
         if mesh.uv_textures:
             self.has_tangents = True
-            mesh.calc_tangents()
+            try:
+                mesh.calc_tangents()
+            except RuntimeError:
+                # This fails if the mesh is a single vertex (and presumably an
+                # edge). Since this won't be rendered by visualserver (the only
+                # user of the tangents), we'll just disable tangents and hope
+                # for the best....
+                self.has_tangents = False
         else:
             mesh.calc_normals_split()
             self.has_tangents = False

+ 21 - 0
tests/reference_exports/mesh/single_edge_and_vertex.escn

@@ -0,0 +1,21 @@
+[gd_scene load_steps=1 format=2]
+
+[sub_resource id=1 type="ArrayMesh"]
+
+
+[sub_resource id=2 type="ArrayMesh"]
+
+[node type="Spatial" name="Scene"]
+
+
+[node name="SingleEdge" type="MeshInstance" parent="."]
+
+mesh = SubResource(1)
+visible = true
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0)
+
+[node name="SingleVert" type="MeshInstance" parent="."]
+
+mesh = SubResource(2)
+visible = true
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)

BIN
tests/test_scenes/mesh/single_edge_and_vertex.blend