]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/object.cpp
Use constructor delegation instead of init functions when possible
[libs/gl.git] / source / render / object.cpp
index 067686d205cee62f8b117ce429c75f58c2e1b21a..34eebec782472880484179df7cf2175303086bab 100644 (file)
@@ -2,12 +2,9 @@
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
 #include "error.h"
-#include "material.h"
 #include "mesh.h"
 #include "object.h"
 #include "objectinstance.h"
-#include "program.h"
-#include "programdata.h"
 #include "renderer.h"
 #include "resourcemanager.h"
 #include "technique.h"
@@ -17,7 +14,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Matrix Object::identity_matrix;
+const Matrix Object::identity_matrix;
 
 Object::Object():
        lods(1),
@@ -76,12 +73,12 @@ void Object::set_mesh(unsigned i, const Mesh *m)
 void Object::update_bounding_sphere()
 {
        vector<Vector3> points;
-       for(vector<LevelOfDetail>::const_iterator i=lods.begin(); i!=lods.end(); ++i)
+       for(const LevelOfDetail &l: lods)
        {
-               if(!i->mesh || !i->mesh->is_loaded())
+               if(!l.mesh || !l.mesh->is_loaded())
                        continue;
 
-               const VertexArray &vertices = i->mesh->get_vertices();
+               const VertexArray &vertices = l.mesh->get_vertices();
 
                int offset = vertices.get_format().offset(VERTEX3);
                bool three = true;
@@ -191,19 +188,8 @@ void Object::resource_removed(Resource &res)
 }
 
 
-Object::Loader::Loader(Object &o):
-       LodLoader(o, 0, 0)
-{
-       init();
-}
-
-Object::Loader::Loader(Object &o, Collection &c):
-       LodLoader(o, 0, &c)
-{
-       init();
-}
-
-void Object::Loader::init()
+Object::Loader::Loader(Object &o, Collection *c):
+       LodLoader(o, 0, c)
 {
        add("bounding_sphere_hint", &Loader::bounding_sphere_hint);
        add("level_of_detail", &Loader::level_of_detail);