colladaloader now skips over empty data arrays.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@736 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2010-05-25 14:37:28 +00:00
parent 188aa3da37
commit 9d978918d1
1 changed files with 33 additions and 31 deletions

View File

@ -1595,45 +1595,47 @@ void ColladaParser::ReadDataArray()
std::string id = mReader->getAttributeValue( indexID); std::string id = mReader->getAttributeValue( indexID);
int indexCount = GetAttribute( "count"); int indexCount = GetAttribute( "count");
unsigned int count = (unsigned int) mReader->getAttributeValueAsInt( indexCount); unsigned int count = (unsigned int) mReader->getAttributeValueAsInt( indexCount);
const char* content = GetTextContent(); const char* content = TestTextContent();
if (content) { // some exporters write empty data arrays, silently skip over them
// read values and store inside an array in the data library // read values and store inside an array in the data library
mDataLibrary[id] = Data(); mDataLibrary[id] = Data();
Data& data = mDataLibrary[id]; Data& data = mDataLibrary[id];
data.mIsStringArray = isStringArray; data.mIsStringArray = isStringArray;
if( isStringArray) if( isStringArray)
{
data.mStrings.reserve( count);
std::string s;
for( unsigned int a = 0; a < count; a++)
{ {
if( *content == 0) data.mStrings.reserve( count);
ThrowException( "Expected more values while reading IDREF_array contents."); std::string s;
s.clear(); for( unsigned int a = 0; a < count; a++)
while( !IsSpaceOrNewLine( *content)) {
s += *content++; if( *content == 0)
data.mStrings.push_back( s); ThrowException( "Expected more values while reading IDREF_array contents.");
SkipSpacesAndLineEnd( &content); s.clear();
} while( !IsSpaceOrNewLine( *content))
} else s += *content++;
{ data.mStrings.push_back( s);
data.mValues.reserve( count);
for( unsigned int a = 0; a < count; a++) SkipSpacesAndLineEnd( &content);
}
} else
{ {
if( *content == 0) data.mValues.reserve( count);
ThrowException( "Expected more values while reading float_array contents.");
float value; for( unsigned int a = 0; a < count; a++)
// read a number {
content = fast_atof_move( content, value); if( *content == 0)
data.mValues.push_back( value); ThrowException( "Expected more values while reading float_array contents.");
// skip whitespace after it
SkipSpacesAndLineEnd( &content); float value;
// read a number
content = fast_atof_move( content, value);
data.mValues.push_back( value);
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
} }
} }