#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"
namespace Msp {
namespace GL {
-Matrix Object::identity_matrix;
+const Matrix Object::identity_matrix;
Object::Object():
lods(1),
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;
points.reserve(points.size()+n_vertices);
for(unsigned j=0; j<n_vertices; ++j)
{
- const float *v = vertices[j];
- points.push_back(Vector3(v[offset], v[offset+1], (three ? v[offset+2] : 0.0f)));
+ const float *v = reinterpret_cast<const float *>(vertices[j]+offset);
+ points.push_back(Vector3(v[0], v[1], (three ? v[2] : 0.0f)));
}
}
}
-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);