fixed bug on empty mesh
This commit is contained in:
parent
d91bb25e52
commit
0f827e0e78
wrap/io_trimesh
|
@ -167,32 +167,34 @@ 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));
|
{
|
||||||
WedgeAttribute wa;
|
vcg::tri::Allocator<OpenMeshType>::AddFaces(m,face_size / (nfcatt * 3));
|
||||||
FindStandardWedgeAttributes(wa,tripatch.at(tript),*(info->dae->doc));
|
WedgeAttribute wa;
|
||||||
|
FindStandardWedgeAttributes(wa,tripatch.at(tript),*(info->dae->doc));
|
||||||
|
|
||||||
int jj = 0;
|
int jj = 0;
|
||||||
//int dd = m.face.size();
|
//int dd = m.face.size();
|
||||||
for(int ff = offsetface;ff < (int) m.face.size();++ff)
|
for(int ff = offsetface;ff < (int) m.face.size();++ff)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(unsigned int tt = 0;tt < 3;++tt)
|
for(unsigned int tt = 0;tt < 3;++tt)
|
||||||
{
|
|
||||||
int indvt = face.at(jj).toInt();
|
|
||||||
assert(indvt + offset < m.vert.size());
|
|
||||||
m.face[ff].V(tt) = &(m.vert[indvt + offset]);
|
|
||||||
|
|
||||||
if(tri::HasPerWedgeNormal(m))
|
|
||||||
WedgeNormalAttribute(m,face,wa.wn,wa.wnsrc,ff,jj + wa.offnm,tt);
|
|
||||||
if(tri::HasPerWedgeTexCoord(m) && ind_txt != -1)
|
|
||||||
{
|
{
|
||||||
WedgeTextureAttribute(m,face,ind_txt,wa.wt,wa.wtsrc,ff,jj + wa.offtx,tt,wa.stride);
|
int indvt = face.at(jj).toInt();
|
||||||
}
|
assert(indvt + offset < m.vert.size());
|
||||||
if(tri::HasPerWedgeColor(m))
|
m.face[ff].V(tt) = &(m.vert[indvt + offset]);
|
||||||
WedgeColorAttribute(m,face,wa.wc,wa.wcsrc,ff,jj + wa.offcl,tt);
|
|
||||||
|
|
||||||
jj += nfcatt;
|
if(tri::HasPerWedgeNormal(m))
|
||||||
|
WedgeNormalAttribute(m,face,wa.wn,wa.wnsrc,ff,jj + wa.offnm,tt);
|
||||||
|
if(tri::HasPerWedgeTexCoord(m) && ind_txt != -1)
|
||||||
|
{
|
||||||
|
WedgeTextureAttribute(m,face,ind_txt,wa.wt,wa.wtsrc,ff,jj + wa.offtx,tt,wa.stride);
|
||||||
|
}
|
||||||
|
if(tri::HasPerWedgeColor(m))
|
||||||
|
WedgeColorAttribute(m,face,wa.wc,wa.wcsrc,ff,jj + wa.offcl,tt);
|
||||||
|
|
||||||
|
jj += nfcatt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue