X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmesh.cpp;h=360d588f97659d9a3e2d395fa876029a4d84a337;hb=e1be82a4dfce8d90358c506f65be09da4dc9d5ec;hp=b5628eb10c860bbc758b17e08b7db045bea7b65c;hpb=5fa69268fa051ce8d74d30bb3d7eecc1b00cff15;p=libs%2Fgl.git diff --git a/source/core/mesh.cpp b/source/core/mesh.cpp index b5628eb1..360d588f 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; @@ -195,9 +211,9 @@ void Mesh::draw(Renderer &renderer, const VertexSetup *vs, unsigned count) const void Mesh::resize_buffers() const { if(dirty&VERTEX_BUFFER) - vbuf->storage(vertices.get_required_buffer_size()); + vbuf->storage(vertices.get_required_buffer_size(), STATIC); if((dirty&INDEX_BUFFER) && !batches.empty()) - ibuf->storage(batches.front().get_required_buffer_size()); + ibuf->storage(batches.front().get_required_buffer_size(), STATIC); dirty = 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)); }