Commit 2f7dca91 authored by Martin Schultz's avatar Martin Schultz

* faster obj parsing for tabs

parent 468672ea
......@@ -73,29 +73,26 @@ namespace
const char * nextObject(const char* _position, const char* _end)
{
return std::find_if(_position,
_end,
[](char _value)
while(_position < _end)
{
return (_value == ' ' || _value == '\t');
if(*_position == ' ' || *_position == '\t')
return _position;
++_position;
}
);
return _position;
}
// Parses a string of space-separated numbers into a packed floating-point vector (_data) with a maximum number of _maxDimension elements
void parseVector(const char* _start , const char* _end, int _maxDimension, int& _dimension, float* _data)
void parseVector(const char* _it , const char* _end, int _maxDimension, int& _dimension, float* _data)
{
const char* it = _start;
const char* end = _end;
const char* found;
_dimension = 0;
while (_dimension < _maxDimension && it < end)
while (_dimension < _maxDimension && _it < _end)
{
trim(it);
found = nextObject(it,end);
_data[_dimension++] = fastAtof(it,found-1);
it = found == end ? end : found + 1;
trim(_it);
found = nextObject(_it,_end);
_data[_dimension++] = fastAtof(_it,found-1);
_it = found == _end ? _end : found + 1;
}
}
......@@ -418,6 +415,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
data->setStrideSize(strideSize);
data->setSize(abDataElements * sizeof(GLfloat));
data->setData((GLubyte*)abData);
return data;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment