X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fobject.cpp;h=65e9a7ef083fc52db1f899906b7febaed96264a5;hp=9a9f759ccf4b53a2c255617b01ade7e12cbc0b42;hb=5871764de7aa23d2c40cac03ad9d07088fb57e06;hpb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14 diff --git a/source/render/object.cpp b/source/render/object.cpp index 9a9f759c..65e9a7ef 100644 --- a/source/render/object.cpp +++ b/source/render/object.cpp @@ -27,7 +27,21 @@ Object::Object(const Mesh *m, const Technique *t): set_technique(t); } -// TODO should have copy-c'tor to set watch on lod0 mesh if necessary +Object::Object(const Object &other): + lods(other.lods), + bounding_sphere(other.bounding_sphere) +{ + if(other.lod0_watched) + watch_lod0(); +} + +Object::Object(Object &&other): + lods(move(other.lods)), + bounding_sphere(move(other.bounding_sphere)) +{ + if(other.lod0_watched) + watch_lod0(); +} Object::~Object() { @@ -59,15 +73,20 @@ void Object::set_mesh(unsigned i, const Mesh *m) lod0_watched = false; if(i==0 && m) - if(ResourceManager *rm = m->get_manager()) - { - rm->observe_resource(*m, *this); - lod0_watched = true; - } + watch_lod0(); update_bounding_sphere(); } +void Object::watch_lod0() +{ + if(ResourceManager *rm = lods[0].mesh->get_manager()) + { + rm->observe_resource(*lods[0].mesh, *this); + lod0_watched = true; + } +} + void Object::update_bounding_sphere() { vector points; @@ -93,7 +112,7 @@ void Object::update_bounding_sphere() for(unsigned j=0; j(vertices[j]+offset); - points.push_back(Vector3(v[0], v[1], (three ? v[2] : 0.0f))); + points.emplace_back(v[0], v[1], (three ? v[2] : 0.0f)); } }