-> FLT import bug (loose vertices)
authorGeoffrey Bantle <hairbat@yahoo.com>
Thu, 15 May 2008 19:35:17 +0000 (19:35 +0000)
committerGeoffrey Bantle <hairbat@yahoo.com>
Thu, 15 May 2008 19:35:17 +0000 (19:35 +0000)
New faceweld code broke the import of meshes with loose
vertices. Also added exception handling to the importer
and exporter so that UI doesnt quite when errors are encountered.
Instead traceback is printed to stderr and control returns to
the script UI

release/scripts/flt_export.py
release/scripts/flt_import.py

index 5a89c58a375b07b29532602311ffd0e0752aebdf..2b9db74c77076a38d5c9642f879259fb9e3fdbb5 100644 (file)
@@ -44,6 +44,8 @@ from flt_filewalker import FltOut
 from flt_filewalker import FileFinder
 from flt_properties import *
 import shutil
+import trace
+import sys
 
 FF = FileFinder()
 records = process_recordDefs()
@@ -1460,6 +1462,9 @@ FLTXAPPChooser = None
 
 FLTAttrib = None
 
+
+FLTWarn = None
+
 def setshadingangle(ID,val):
        global options
        options.state['shading_default'] = val
@@ -1523,6 +1528,8 @@ def but_event(evt):
 
        global FLTAttrib
        
+       global FLTWarn
+       
        #choose base path for export
        if evt == 4:
                Blender.Window.FileSelector(setBpath, "DB Root", options.state['basepath'])
@@ -1557,8 +1564,13 @@ def but_event(evt):
        
        #Export DB
        if evt == 1:
-               dbexport()
-       
+               try:
+                       dbexport()              
+               except Exception, inst:
+                       import traceback
+                       FLTWarn = Draw.PupBlock("Export Error", ["See console for output!"])
+                       traceback.print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)
+
        #exit
        if evt == 2:
                Draw.Exit()
index c924194f44b282559bfbd7cb5fbcb100e1150f22..74cd4c036a8c7d132cfee10be6074fde4d8dc35a 100644 (file)
@@ -61,6 +61,7 @@ FLTDoXRef = None
 FLTScale = None
 FLTShadeImport = None
 FLTAttrib = None
+FLTWarn = None
 
 Vector= Blender.Mathutils.Vector
 FLOAT_TOLERANCE = 0.01
@@ -890,6 +891,17 @@ class InterNode(Node):
                return weldmesh                 
 
        def weldFuseFaces(self,weldmesh):
+
+               #retain original loose vertices
+               looseverts = dict()
+               for vert in self.mesh.verts:
+                       looseverts[vert] = 0
+               for edge in self.mesh.edges:
+                       looseverts[edge.v1] += 1
+                       looseverts[edge.v2] += 1
+
+
+
                #slight modification here: we need to walk around the mesh as many times as it takes to have no more matches
                done = 0
                while not done:
@@ -937,7 +949,7 @@ class InterNode(Node):
                                vertuse[vert] += 1
                delverts = list()
                for vert in self.mesh.verts:
-                       if not vertuse[vert] and vert.index != 0:
+                       if not vertuse[vert] and vert.index != 0 and looseverts[vert]:
                                delverts.append(vert)
                
                self.mesh.verts.delete(delverts)        
@@ -2405,6 +2417,10 @@ def setBpath(fname):
 
 def event(evt,val):
        pass
+
+from Blender.BGL import *
+from Blender import Draw
+
 def but_event(evt):
        
        global FLTBaseLabel
@@ -2418,6 +2434,8 @@ def but_event(evt):
        global FLTShadeImport
        global FLTAttrib
        
+       global FLTWarn
+       
        #Import DB
        if evt == 1:
                if global_prefs['verbose'] >= 1:
@@ -2429,7 +2447,14 @@ def but_event(evt):
                        print
                
                GRR = GlobalResourceRepository()
-               select_file(global_prefs['fltfile'], GRR)
+               
+               try:
+                       select_file(global_prefs['fltfile'], GRR)
+               except:
+                       import traceback
+                       FLTWarn = Draw.PupBlock("Export Error", ["See console for output!"])
+                       traceback.print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)
+       
        #choose base path for export
        if evt == 4:
                Blender.Window.FileSelector(setBpath, "DB Root", global_prefs['fltfile'])
@@ -2450,10 +2475,7 @@ def but_event(evt):
        for key in global_prefs:
                d[key] = global_prefs[key]
                Blender.Registry.SetKey('flt_import', d, 1) 
-       
 
-from Blender.BGL import *
-from Blender import Draw
 def gui():
        
        global FLTBaseLabel