X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbatch.cpp;h=102b6487281244457950b6e0625b262e2ac3408e;hb=c48cb5362edb16c33ed5f6862a908bb9a754c85a;hp=228ff20bf7a0d395d6fbec42c3cf938d13dbd3fa;hpb=083578c2ca0aabfa60e8872e23d53e9101795dff;p=libs%2Fgl.git diff --git a/source/batch.cpp b/source/batch.cpp index 228ff20b..102b6487 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -119,9 +119,42 @@ Batch &Batch::append(unsigned i) void Batch::append(const vector &ind) { - data.reserve(data.size()+ind.size()*get_index_size()); + if(ind.empty()) + return; + + if(data.empty()) + min_index = max_index = ind.front(); + for(vector::const_iterator i=ind.begin(); i!=ind.end(); ++i) - append(*i); + { + min_index = min(min_index, *i); + max_index = max(max_index, *i); + } + + if((data_type==UNSIGNED_BYTE || data_type==UNSIGNED_SHORT) && max_index>0xFFFE) + set_data_type(UNSIGNED_INT); + else if(data_type==UNSIGNED_BYTE && max_index>0xFE) + set_data_type(UNSIGNED_SHORT); + + unsigned base = data.size(); + data.resize(data.size()+ind.size()*get_index_size()); + if(data_type==UNSIGNED_SHORT) + { + unsigned short *ptr = reinterpret_cast(&data[base]); + for(unsigned i=0; i(&data[base]); + for(unsigned i=0; i