fixed bug on empty mesh

This commit is contained in:
granzuglia 2008-02-04 23:50:07 +00:00
parent d91bb25e52
commit 0f827e0e78
1 changed files with 40 additions and 29 deletions

View File

@ -167,7 +167,8 @@ namespace io {
valueStringList(face,tripatch.at(tript),"p"); valueStringList(face,tripatch.at(tript),"p");
int face_size = face.size(); int face_size = face.size();
int offsetface = (int)m.face.size(); int offsetface = (int)m.face.size();
if (face_size == 0) return E_NOMESH; if (face_size != 0)
{
vcg::tri::Allocator<OpenMeshType>::AddFaces(m,face_size / (nfcatt * 3)); vcg::tri::Allocator<OpenMeshType>::AddFaces(m,face_size / (nfcatt * 3));
WedgeAttribute wa; WedgeAttribute wa;
FindStandardWedgeAttributes(wa,tripatch.at(tript),*(info->dae->doc)); FindStandardWedgeAttributes(wa,tripatch.at(tript),*(info->dae->doc));
@ -196,6 +197,7 @@ namespace io {
} }
} }
} }
}
return E_NOERROR; return E_NOERROR;
} }
@ -304,7 +306,8 @@ namespace io {
else else
if (polylist_size != 0) if (polylist_size != 0)
err = LoadPolygonalListMesh(polylist,m,offset,info); err = LoadPolygonalListMesh(polylist,m,offset,info);
if (err != E_NOERROR) return err; if (err != E_NOERROR)
return err;
} }
return E_NOERROR; return E_NOERROR;
} }
@ -353,6 +356,8 @@ namespace io {
if (scn_size == 0) if (scn_size == 0)
return E_NO3DSCENE; return E_NO3DSCENE;
int problem = E_NOERROR;
bool found_a_mesh = false;
//Is there geometry in the file? //Is there geometry in the file?
bool geoinst_found = false; bool geoinst_found = false;
//for each scene in COLLADA FILE //for each scene in COLLADA FILE
@ -377,7 +382,6 @@ namespace io {
QDomNodeList visscn_child = visscn.childNodes(); QDomNodeList visscn_child = visscn.childNodes();
//for each direct child of a libscn_url visual scene find if there is some geometry instance //for each direct child of a libscn_url visual scene find if there is some geometry instance
int problem = 0;
for(int chdind = 0; chdind < visscn_child.size();++chdind) for(int chdind = 0; chdind < visscn_child.size();++chdind)
{ {
QDomNodeList geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry"); QDomNodeList geoinst = visscn_child.at(chdind).toElement().elementsByTagName("instance_geometry");
@ -389,7 +393,6 @@ namespace io {
QDomNodeList geolib = inf->dae->doc->elementsByTagName("library_geometries"); QDomNodeList geolib = inf->dae->doc->elementsByTagName("library_geometries");
assert(geolib.size() == 1); assert(geolib.size() == 1);
//!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!here will be the code for geometry transformations!!!!!!!!!!!!!!!!!!!!!!
for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind) for(int geoinst_ind = 0;geoinst_ind < geoinst_size;++geoinst_ind)
{ {
QString geo_url; QString geo_url;
@ -402,10 +405,16 @@ namespace io {
tr.SetIdentity(); tr.SetIdentity();
TransfMatrix(visscn,geoinst.at(geoinst_ind),tr); TransfMatrix(visscn,geoinst.at(geoinst_ind),tr);
problem |= LoadMesh(m,inf,geo,tr); problem |= LoadMesh(m,inf,geo,tr);
if (problem) return problem; if (problem & E_NOMESH)
found_a_mesh |= false;
else
found_a_mesh = true;
} }
} }
} }
//if there is at least a mesh I clean the problem status variable from E_NOMESH ERROR
if ((problem & E_NOMESH) && (found_a_mesh))
problem = problem & ~E_NOMESH;
} }
} }
@ -421,11 +430,13 @@ namespace io {
vcg::Matrix44f tmp; vcg::Matrix44f tmp;
tmp.SetIdentity(); tmp.SetIdentity();
problem |= LoadMesh(m,inf,geochild.at(chd),tmp); problem |= LoadMesh(m,inf,geochild.at(chd),tmp);
if (problem) return problem;
} }
} }
//if there is at least a mesh I clean the problem status variable from E_NOMESH ERROR
if ((problem & E_NOMESH) && (found_a_mesh))
problem = problem & ~E_NOMESH;
info = inf; info = inf;
return E_NOERROR; return problem;
} }
static bool LoadMask(const char * filename, AdditionalInfoDAE*& addinfo) static bool LoadMask(const char * filename, AdditionalInfoDAE*& addinfo)