[Bf-extensions-cvs] [ef984a9] temp-x3d_import-T44758: Fix crash with (broken?) https://savage.nps.edu/Savage/Locations/Hawaii/_pages/page02.html

Bastien Montagne noreply at git.blender.org
Sat Sep 19 16:55:06 CEST 2015


Commit: ef984a976590fd619c35e898cbcc16cf9f947645
Author: Bastien Montagne
Date:   Sat Sep 19 16:53:52 2015 +0200
Branches: temp-x3d_import-T44758
https://developer.blender.org/rBAef984a976590fd619c35e898cbcc16cf9f947645

Fix crash with (broken?) https://savage.nps.edu/Savage/Locations/Hawaii/_pages/page02.html

Note that issue is probably in parser in fact... But at least, do not add void faces -
and do validate mesh before calling update() on them!

===================================================================

M	io_scene_x3d/import_x3d.py

===================================================================

diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index 31125e1..0c53759 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -1867,7 +1867,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
             coord.parsed = points
     index = geom.getFieldAsArray('coordIndex', 0, ancestry)
 
-    while index[-1] == -1:
+    while index and index[-1] == -1:
         del index[-1]
 
     if len(points) >= 2 * len(index):  # Need to cull
@@ -1883,7 +1883,8 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
     # Generate faces. Cull the vertices if necessary,
     for i in index:
         if i == -1:
-            faces.append(flip(face, ccw))
+            if face:
+                faces.append(flip(face, ccw))
             face = []
         else:
             if cull is not None:
@@ -1896,7 +1897,8 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
                 else:
                     i = cull[i]
             face.append(i)
-    faces.append(flip(face, ccw))  # The last face
+    if face:
+        faces.append(flip(face, ccw))  # The last face
 
     if cull:
         points = culled_points
@@ -2009,6 +2011,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
 
         importMesh_ApplyTextureToLoops(bpymesh, bpyima, loops)
 
+    bpymesh.validate()
     bpymesh.update()
     return bpymesh



More information about the Bf-extensions-cvs mailing list