- fixed "if there is color both vertex/face colors are enabled even if there is just one of them" bug

This commit is contained in:
Guido Ranzuglia 2016-10-13 04:28:00 +02:00
parent 8b90ba72a3
commit 20fa52181f
2 changed files with 708 additions and 703 deletions

View File

@ -111,7 +111,7 @@ static void WedgeTexFromVertexTex(ComputeMeshType &m)
{
(*fi).WT(i).U() = (*fi).V(i)->T().U();
(*fi).WT(i).V() = (*fi).V(i)->T().V();
//(*fi).WT(i).N() = 0;
(*fi).WT(i).N() = 0;
}
}
}

View File

@ -53,9 +53,11 @@ public:
typedef typename MESH_TYPE::ScalarType ScalarType;
// OFF codes
enum OFFCodes {NoError=0, CantOpen, InvalidFile,
enum OFFCodes {
NoError = 0, CantOpen, InvalidFile,
InvalidFile_MissingOFF,
UnsupportedFormat, ErrorNotTriangularFace,ErrorHighDimension,ErrorDegenerateFace};
UnsupportedFormat, ErrorNotTriangularFace, ErrorHighDimension, ErrorDegenerateFace
};
/*!
* Standard call for knowing the meaning of an error code
@ -166,11 +168,16 @@ public:
{ // the OFF string is in the header go on parsing it.
for (int u = static_cast<int>(header.rfind("OFF") - 1); u >= 0; u--)
{
if (header[u] == 'C') isColorDefined = true;
else if (header[u] == 'N') isNormalDefined = true;
else if (u>0 && header[u-1] == 'S' && header[u] == 'T') isTexCoordDefined = true;
else if (header[u] == '4') homogeneousComponents = true;
else if (header[u] == 'n') return ErrorHighDimension;
if (header[u] == 'C')
isColorDefined = true;
else if (header[u] == 'N')
isNormalDefined = true;
else if (u > 0 && header[u - 1] == 'S' && header[u] == 'T')
isTexCoordDefined = true;
else if (header[u] == '4')
homogeneousComponents = true;
else if (header[u] == 'n')
return ErrorHighDimension;
}
}
else return InvalidFile_MissingOFF;
@ -187,7 +194,7 @@ public:
if (isNormalDefined) loadmask |= Mask::IOM_VERTNORMAL;
if (isTexCoordDefined) loadmask |= Mask::IOM_VERTTEXCOORD;
if (isColorDefined) { loadmask |= Mask::IOM_VERTCOLOR;loadmask |= Mask::IOM_FACECOLOR;}
//if (isColorDefined) { loadmask |= Mask::IOM_VERTCOLOR;loadmask |= Mask::IOM_FACECOLOR;}
//if(onlyMaskFlag) return NoError;
@ -521,17 +528,15 @@ public:
// (otherwise it is impossible to parse color information since
// color components can vary)
size_t color_elements = tokens.size() - vert_per_face - 1;
isColorDefined |= (color_elements>0);
if(isColorDefined) loadmask |= Mask::IOM_FACECOLOR;
//isColorDefined |= (color_elements>0);
//if(isColorDefined) loadmask |= Mask::IOM_FACECOLOR;
if( (color_elements>0) && tri::HasPerFaceColor(mesh) )
{
// set per-face color attribute
if (color_elements > 0)
{
loadmask |= Mask::IOM_FACECOLOR;
if (tri::HasPerFaceColor(mesh))
{
switch (color_elements)
{
case 0:
@ -593,6 +598,7 @@ public:
break;
}
} //end switch
}
} // end if (isColorDefined)
} // end of for f=...
}
@ -630,8 +636,7 @@ protected:
tokens.push_back(line.substr(from, to - from).c_str());
from = to;
}
}
while (from<length);
} while (from < length);
} // end Tokenize
/*!