osgDB::OutputStream write array optimization

I've made a change to osgDB::OutputStream::writeArrayImplementation so that it writes the array data in a single write operation for binary files. This significantly speeds up writing out osgb files for large data sets (e.g. point clouds). osgDB::InputStream already performs a similar optimization when reading array data from binary files.
This commit is contained in:
flashk
2018-10-03 14:12:54 -07:00
committed by Robert Osfield
parent 273dd046c2
commit ce90a9b2da

View File

@@ -925,24 +925,31 @@ template<typename T>
void OutputStream::writeArrayImplementation( const T* a, int write_size, unsigned int numInRow )
{
*this << write_size << BEGIN_BRACKET;
if ( numInRow>1 )
if ( isBinary() )
{
for ( int i=0; i<write_size; ++i )
{
if ( !(i%numInRow) )
{
*this << std::endl << (*a)[i];
}
else
*this << (*a)[i];
}
*this << std::endl;
if (write_size) writeCharArray((char*)&((*a)[0]), write_size * sizeof((*a)[0]));
}
else
{
*this << std::endl;
for ( int i=0; i<write_size; ++i )
*this << (*a)[i] << std::endl;
if ( numInRow>1 )
{
for ( int i=0; i<write_size; ++i )
{
if ( !(i%numInRow) )
{
*this << std::endl << (*a)[i];
}
else
*this << (*a)[i];
}
*this << std::endl;
}
else
{
*this << std::endl;
for ( int i=0; i<write_size; ++i )
*this << (*a)[i] << std::endl;
}
}
*this << END_BRACKET << std::endl;
}