Fixed problem with loading interleaved arrays in the .osg loader, and corrected

a spelling mistake in osg::GeoSet.
This commit is contained in:
Robert Osfield
2001-12-12 12:55:01 +00:00
parent 363d1d9d70
commit 05e4a0b4ce
4 changed files with 58 additions and 10 deletions

View File

@@ -296,6 +296,7 @@ bool FieldReaderIterator::matchSequence(const char* str)
{
if (str==NULL) return false;
if (*str==0) return false;
int fieldCount = 0;
const char* end = str;
while((*end)!=0 && (*end)==' ') ++end;
@@ -333,6 +334,7 @@ bool FieldReaderIterator::matchSequence(const char* str)
if (!field(fieldCount).isQuotedString()) return false;
break;
}
case('w') :
default :// expecting an word
{
if (!field(fieldCount).isWord()) return false;

View File

@@ -480,8 +480,8 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
fieldAdvanced = true;
}
if (matchFirst=fr.matchSequence("InterleavedArray %s {") ||
fr.matchSequence("InterleavedArray %s %i {"))
if ((matchFirst=fr.matchSequence("InterleavedArray %w {")) ||
fr.matchSequence("InterleavedArray %w %i {"))
{
// set up coordinates.
@@ -515,7 +515,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
else
{
fr[3].getInt(capacity);
fr[2].getInt(capacity);
fr += 4;
}
@@ -530,7 +530,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
// now read the data rows between the {}.
const char* rowComp = GeoSet_getInterleavedRowComposition(iaType);
int rowLength = GeoSet_getInterleavedRowLength(iaType);
int size = 0;
unsigned char* dataList = new unsigned char[capacity*rowLength];
@@ -544,11 +544,10 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
unsigned char* itrRowData = rowData;
const char* itrRowComp = rowComp;
int rn = 0;
while (*itrRowComp!=0)
while (*itrRowComp!=0 && !fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
if (*itrRowComp=='f')
{
if (!fr[rn].getFloat(floatData)) break;
*(float*)itrRowData = floatData;
itrRowData += 4;
@@ -559,6 +558,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
*itrRowData = (unsigned char)intData;
itrRowData += 1;
}
++itrRowComp;
++rn;
}
if (*itrRowComp==0)
@@ -579,10 +579,12 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
else
{
++fr;
if (!fr.eof() && fr[0].getNoNestedBrackets()>entry) ++fr;
}
}
delete [] rowData;
interleavedArray = (float*)dataList;
}
@@ -829,10 +831,10 @@ bool GeoSet_writeLocalData(const Object& obj, Output& fw)
if (geoset.getInterleavedArray())
{
// write out the interleaved arrays.
const char* rowComp = GeoSet_getInterleavedRowComposition(geoset.getInterleavedFromat());
const char* rowComp = GeoSet_getInterleavedRowComposition(geoset.getInterleavedFormat());
fw.indent() << "InterleavedArray ";
switch(geoset.getInterleavedFromat())
switch(geoset.getInterleavedFormat())
{
case(GeoSet::IA_OFF): fw << "IA_OFF"; break;
case(GeoSet::IA_V2F): fw << "IA_V2F"; break;