diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 11ef6d20a..1f46e47e2 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -728,17 +728,18 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene * } //------------------------------------------------------------------------------------------------ -static void getColorRGB( aiColor3D *pColor, Value *data ) { - if( NULL == pColor || NULL == data ) { +static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) { + if( NULL == pColor || NULL == colList ) { return; } - - pColor->r = data->getFloat(); - data = data->getNext(); - pColor->g = data->getFloat(); - data = data->getNext(); - pColor->b = data->getFloat(); - data = data->getNext(); + + ai_assert( 3, colList->m_numItems ); + Value *val( colList->m_dataList ); + pColor->r = val->getFloat(); + val = val->getNext(); + pColor->g = val->getFloat(); + val = val->getNext(); + pColor->b = val->getFloat(); } //------------------------------------------------------------------------------------------------ @@ -780,8 +781,12 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen Property *prop = node->findPropertyByName( "attrib" ); if( NULL != prop ) { if( NULL != prop->m_value ) { + DataArrayList *colList( node->getDataArrayList() ); + if( NULL == colList ) { + return; + } aiColor3D col; - getColorRGB( &col, prop->m_value ); + getColorRGB( &col, colList ); const ColorType colType( getColorType( prop->m_key ) ); if( DiffuseColor == colType ) { m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE ); diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h index ef8d1dceb..3e8455bcc 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h @@ -107,6 +107,12 @@ bool isNumeric( const T in ) { return false;*/ } +template +inline +bool isNotEndOfToken( T *in, T *end ) { + return ( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ); +} + template inline bool isInteger( T *in, T *end ) { @@ -117,7 +123,8 @@ bool isInteger( T *in, T *end ) { } bool result( false ); - while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) { + while( isNotEndOfToken( in, end ) ) { + //while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) { result = isNumeric( *in ); if( !result ) { break; @@ -139,7 +146,9 @@ bool isFloat( T *in, T *end ) { // check for <1>.0f bool result( false ); - while( !isSpace( *in ) && in != end ) { + while( isNotEndOfToken( in, end ) ) { + +// while( !isSpace( *in ) && in != end ) { if( *in == '.' ) { result = true; break; @@ -159,7 +168,9 @@ bool isFloat( T *in, T *end ) { } // check for 1.<0>f - while( !isSpace( *in ) && in != end && *in != ',' ) { + while( isNotEndOfToken( in, end ) ) { + +// while( !isSpace( *in ) && in != end && *in != ',' && *in != '}' ) { result = isNumeric( *in ); if( !result ) { return false;