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

* faster obj parsing for tabs

parent 468672ea
...@@ -73,29 +73,26 @@ namespace ...@@ -73,29 +73,26 @@ namespace
const char * nextObject(const char* _position, const char* _end) const char * nextObject(const char* _position, const char* _end)
{ {
return std::find_if(_position, while(_position < _end)
_end,
[](char _value)
{ {
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 // 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; const char* found;
_dimension = 0; _dimension = 0;
while (_dimension < _maxDimension && it < end) while (_dimension < _maxDimension && _it < _end)
{ {
trim(it); trim(_it);
found = nextObject(it,end); found = nextObject(_it,_end);
_data[_dimension++] = fastAtof(it,found-1); _data[_dimension++] = fastAtof(_it,found-1);
it = found == end ? end : found + 1; _it = found == _end ? _end : found + 1;
} }
} }
...@@ -418,6 +415,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c ...@@ -418,6 +415,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
data->setStrideSize(strideSize); data->setStrideSize(strideSize);
data->setSize(abDataElements * sizeof(GLfloat)); data->setSize(abDataElements * sizeof(GLfloat));
data->setData((GLubyte*)abData); data->setData((GLubyte*)abData);
return data; return data;
} }
......
Supports Markdown
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