-> FLT import bug (loose vertices)

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
This commit is contained in:
Geoffrey Bantle 2008-05-15 19:35:17 +00:00
parent ba6c6854ed
commit ad397fa16b
2 changed files with 41 additions and 7 deletions

@ -44,6 +44,8 @@ from flt_filewalker import FltOut
from flt_filewalker import FileFinder from flt_filewalker import FileFinder
from flt_properties import * from flt_properties import *
import shutil import shutil
import trace
import sys
FF = FileFinder() FF = FileFinder()
records = process_recordDefs() records = process_recordDefs()
@ -1460,6 +1462,9 @@ FLTXAPPChooser = None
FLTAttrib = None FLTAttrib = None
FLTWarn = None
def setshadingangle(ID,val): def setshadingangle(ID,val):
global options global options
options.state['shading_default'] = val options.state['shading_default'] = val
@ -1523,6 +1528,8 @@ def but_event(evt):
global FLTAttrib global FLTAttrib
global FLTWarn
#choose base path for export #choose base path for export
if evt == 4: if evt == 4:
Blender.Window.FileSelector(setBpath, "DB Root", options.state['basepath']) Blender.Window.FileSelector(setBpath, "DB Root", options.state['basepath'])
@ -1557,8 +1564,13 @@ def but_event(evt):
#Export DB #Export DB
if evt == 1: 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 #exit
if evt == 2: if evt == 2:
Draw.Exit() Draw.Exit()

@ -61,6 +61,7 @@ FLTDoXRef = None
FLTScale = None FLTScale = None
FLTShadeImport = None FLTShadeImport = None
FLTAttrib = None FLTAttrib = None
FLTWarn = None
Vector= Blender.Mathutils.Vector Vector= Blender.Mathutils.Vector
FLOAT_TOLERANCE = 0.01 FLOAT_TOLERANCE = 0.01
@ -890,6 +891,17 @@ class InterNode(Node):
return weldmesh return weldmesh
def weldFuseFaces(self,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 #slight modification here: we need to walk around the mesh as many times as it takes to have no more matches
done = 0 done = 0
while not done: while not done:
@ -937,7 +949,7 @@ class InterNode(Node):
vertuse[vert] += 1 vertuse[vert] += 1
delverts = list() delverts = list()
for vert in self.mesh.verts: 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) delverts.append(vert)
self.mesh.verts.delete(delverts) self.mesh.verts.delete(delverts)
@ -2405,6 +2417,10 @@ def setBpath(fname):
def event(evt,val): def event(evt,val):
pass pass
from Blender.BGL import *
from Blender import Draw
def but_event(evt): def but_event(evt):
global FLTBaseLabel global FLTBaseLabel
@ -2418,6 +2434,8 @@ def but_event(evt):
global FLTShadeImport global FLTShadeImport
global FLTAttrib global FLTAttrib
global FLTWarn
#Import DB #Import DB
if evt == 1: if evt == 1:
if global_prefs['verbose'] >= 1: if global_prefs['verbose'] >= 1:
@ -2429,7 +2447,14 @@ def but_event(evt):
print print
GRR = GlobalResourceRepository() 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 #choose base path for export
if evt == 4: if evt == 4:
Blender.Window.FileSelector(setBpath, "DB Root", global_prefs['fltfile']) Blender.Window.FileSelector(setBpath, "DB Root", global_prefs['fltfile'])
@ -2450,10 +2475,7 @@ def but_event(evt):
for key in global_prefs: for key in global_prefs:
d[key] = global_prefs[key] d[key] = global_prefs[key]
Blender.Registry.SetKey('flt_import', d, 1) Blender.Registry.SetKey('flt_import', d, 1)
from Blender.BGL import *
from Blender import Draw
def gui(): def gui():
global FLTBaseLabel global FLTBaseLabel