- fbx: also support reading binary arrays of UNSIGNED data.

pull/14/head
Alexander Gessler 2012-08-11 04:48:08 +02:00
parent 96033e9fc0
commit eb16c193ea
1 changed files with 36 additions and 4 deletions

View File

@ -848,9 +848,9 @@ void ParseVectorDataArray(std::vector<int>& out, const Element& el)
out.reserve(count);
const uint32_t* ip = reinterpret_cast<const uint32_t*>(&buff[0]);
const int32_t* ip = reinterpret_cast<const int32_t*>(&buff[0]);
for (unsigned int i = 0; i < count; ++i, ++ip) {
BE_NCONST uint32_t val = *ip;
BE_NCONST int32_t val = *ip;
AI_SWAP4(val);
out.push_back(val);
}
@ -946,8 +946,40 @@ void ParseVectorDataArray(std::vector<unsigned int>& out, const Element& el)
}
if(tok[0]->IsBinary()) {
// XXX don't think we need this - there is no special type sign for unsigned ints in the binary encoding
ParseError("feature not implemented",&el);
const char* data = tok[0]->begin(), *end = tok[0]->end();
char type;
uint32_t count;
ReadBinaryDataArrayHead(data, end, type, count, el);
if(!count) {
return;
}
if (type != 'i') {
ParseError("expected (u)int array (binary)",&el);
}
std::vector<char> buff;
ReadBinaryDataArray(type, count, data, end, buff, el);
ai_assert(data == end);
ai_assert(buff.size() == count * 4);
out.reserve(count);
const int32_t* ip = reinterpret_cast<const int32_t*>(&buff[0]);
for (unsigned int i = 0; i < count; ++i, ++ip) {
BE_NCONST int32_t val = *ip;
if(val < 0) {
ParseError("encountered negative integer index (binary)");
}
AI_SWAP4(val);
out.push_back(val);
}
return;
}
const size_t dim = ParseTokenAsDim(*tok[0]);