Эх сурвалжийг харах

Fix for issue #80 (failing to export single-vert mesh)

The failure is inside a blender function that is relatively
opaque, so we just catch the error and continue.
Geoffrey Irons 7 жил өмнө
parent
commit
83b177b440

+ 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