+ if(other.data.empty())
+ return;
+
+ if(prim_type==POINTS || prim_type==LINES || prim_type==TRIANGLES || prim_type==QUADS)
+ ;
+ else if(MSP_primitive_restart || NV_primitive_restart)
+ {
+ restart = true;
+ if(data_type==UNSIGNED_SHORT)
+ ::append<unsigned short>(data, 0xFFFF);
+ else if(data_type==UNSIGNED_INT)
+ ::append<unsigned>(data, 0xFFFFFFFF);
+ else
+ data.push_back(0xFF);
+ }
+ else if(prim_type==TRIANGLE_STRIP)
+ {
+ append(get_index(size()-1));
+ append(other.get_index(0));
+ if(size()&1)
+ append(other.get_index(0));
+ }
+ else if(prim_type==QUAD_STRIP)
+ {
+ append(get_index(size()-1));
+ append(get_index(size()-1));
+ append(other.get_index(0));
+ append(other.get_index(0));
+ }
+
+ unsigned count = other.size();
+ for(unsigned i=0; i<count; ++i)
+ append_index(other.get_index(i));
+
+ update_offset();
+ dirty = true;
+}
+
+void Batch::append_index(unsigned i)
+{
+ if(data.empty())
+ min_index = max_index = i;
+ else
+ {
+ 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);
+
+ if(data_type==UNSIGNED_SHORT)
+ ::append<unsigned short>(data, i);
+ else if(data_type==UNSIGNED_INT)
+ ::append<unsigned>(data, i);
+ else
+ data.push_back(i);
+}
+
+unsigned Batch::get_index_size() const
+{
+ if(data_type==UNSIGNED_SHORT)
+ return sizeof(unsigned short);
+ else if(data_type==UNSIGNED_INT)
+ return sizeof(unsigned);
+ return sizeof(unsigned char);