X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmesh.cpp;h=208126ef26c477ed5adf8ca61f357400ca44ee73;hb=e70662d7812464159f2e47f4bebb69d88f89ae93;hp=b5628eb10c860bbc758b17e08b7db045bea7b65c;hpb=5fa69268fa051ce8d74d30bb3d7eecc1b00cff15;p=libs%2Fgl.git diff --git a/source/core/mesh.cpp b/source/core/mesh.cpp index b5628eb1..208126ef 100644 --- a/source/core/mesh.cpp +++ b/source/core/mesh.cpp @@ -14,6 +14,22 @@ Mesh::Mesh(const VertexFormat &f) storage(f); } +Mesh::Mesh(Mesh &&other): + Resource(move(other)), + vertices(move(other.vertices)), + batches(move(other.batches)), + vbuf(other.vbuf), + ibuf(other.ibuf), + vtx_setup(move(other.vtx_setup)), + dirty(other.dirty), + disallow_rendering(other.disallow_rendering), + face_winding(other.face_winding), + debug_name(move(other.debug_name)) +{ + other.vbuf = 0; + other.ibuf = 0; +} + Mesh::~Mesh() { set_manager(0); @@ -94,11 +110,11 @@ char *Mesh::modify_vertex(size_t i) return vertices.modify(i); } -void Mesh::add_batch(const Batch &b) +void Mesh::add_batch(Batch &&b) { if(batches.empty()) { - batches.push_back(b); + batches.emplace_back(move(b)); if(ibuf) batches.back().use_buffer(ibuf); } @@ -114,7 +130,7 @@ void Mesh::add_batch(const Batch &b) } Batch *prev = &batches.back(); - batches.push_back(b); + batches.emplace_back(move(b)); if(reallocate) { prev = 0; @@ -281,7 +297,7 @@ void Mesh::Loader::batch(PrimitiveType p) { Batch btc(p); load_sub(btc); - obj.add_batch(btc); + obj.add_batch(move(btc)); }