Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/model.cc')
-rw-r--r--src/model/model.cc103
1 files changed, 49 insertions, 54 deletions
diff --git a/src/model/model.cc b/src/model/model.cc
index 2e9f0ba..5becc82 100644
--- a/src/model/model.cc
+++ b/src/model/model.cc
@@ -12,78 +12,67 @@
namespace model
{
-std::map<std::string, Model*> Model::registry;
+// static model registry
+Model::Registry Model::model_registry;
Model::Model(std::string const & name) :
model_name(name)
{
- model_first_vertex = 0;
- model_first_evertex = 0;
- model_first_lvertex = 0;
-
- model_vertex_count = 0;
- model_vertex_countdetail = 0;
- model_evertex_count = 0;
- model_evertex_countdetail = 0;
- model_lvertex_count = 0;
- model_lvertex_countdetail = 0;
-
model_radius = 0.5f;
model_enginesound = 0;
+
+ model_tris_detail_count = 0;
+ model_tris_count = 0;
+ model_quad_detail_count = 0;
+ model_quad_count = 0;
}
Model::~Model()
{
+ // delete all fragments
+ for (Fragments::iterator fragit = model_fragments.begin(); fragit != model_fragments.end(); fragit++) {
+ delete(*fragit);
+ }
+ model_fragments.clear();
+
// delete all engines
- for (std::list<Engine *>::iterator eit = model_engine.begin(); eit != model_engine.end(); eit++) {
+ for (Engines::iterator eit = model_engines.begin(); eit != model_engines.end(); eit++) {
delete(*eit);
}
- model_engine.clear();
+ model_engines.clear();
// delete all lights
- for (std::list<Light *>::iterator lit = model_light.begin(); lit != model_light.end(); lit++) {
- delete (*lit);
+ for (Lights::iterator lit = model_lights.begin(); lit != model_lights.end(); lit++) {
+ delete(*lit);
}
- model_light.clear();
-
+ model_lights.clear();
+
// delete all flares
- for (std::list<Flare *>::iterator flit = model_flare.begin(); flit != model_flare.end(); flit++) {
- delete (*flit);
+ for (Flares::iterator flit = model_flares.begin(); flit != model_flares.end(); flit++) {
+ delete(*flit);
}
- model_flare.clear();
-}
-
-size_t Model::tris() const
-{
- return ((model_vertex_count + model_vertex_countdetail +
- model_evertex_count + model_evertex_countdetail +
- model_lvertex_count + model_lvertex_countdetail)/3);
-}
-
-size_t Model::details() const
-{
- return ((model_vertex_countdetail + model_evertex_countdetail + model_lvertex_countdetail)/3);
+ model_flares.clear();
}
void Model::add_engine(Engine *engine)
{
- model_engine.push_back(engine);
+ model_engines.push_back(engine);
}
void Model::add_light(Light *light)
{
- model_light.push_back(light);
+ model_lights.push_back(light);
}
void Model::add_flare(Flare *flare)
{
- model_flare.push_back(flare);
+ model_flares.push_back(flare);
}
Model *Model::find(std::string const & name)
{
- std::map<std::string, Model*>::iterator it = registry.find(name);
- if (it == registry.end())
+ Registry::iterator it = model_registry.find(name);
+ if (it == model_registry.end())
return 0;
else
return (*it).second;
@@ -94,40 +83,46 @@ Model *Model::load(std::string const & name)
Model *model = find(name);
if (!model) {
model = Map::load(name);
- if (model)
- registry[model->name()] = model;
+ if (model) {
+ model_registry[model->name()] = model;
+ }
}
-
+
return model;
}
void Model::clear()
{
// delete all models in the registry
- for (std::map<std::string, Model*>::iterator mit = registry.begin(); mit != registry.end(); mit++) {
+ for (Registry::iterator mit = model_registry.begin(); mit != model_registry.end(); mit++) {
delete(*mit).second;
}
- registry.clear();
-
+ model_registry.clear();
+
// clear the vertex array
if (VertexArray::instance())
VertexArray::instance()->clear();
}
+void Model::list_model(Model *model)
+{
+ con_print << " " << model->name() << " " <<
+ model->model_tris_count << "/" << model->model_tris_detail_count << " tris/detail " <<
+ model->model_quad_count << "/" << model->model_quad_detail_count << " quads/detail "
+ << model->fragments().size() << " frags "<< std::endl;
+}
+
void Model::list()
{
- for (std::map<std::string, Model*>::iterator mit = registry.begin(); mit != registry.end(); mit++) {
- con_print << " " << (*mit).second->name() << " "
- << (*mit).second->tris() << " triangles ("
- << (*mit).second->details() << " detail) "
- << (*mit).second->model_engine.size() << " engines "
- << (*mit).second->model_light.size() << " lights "
- << (*mit).second->model_flare.size() << " flares ";
+ for (Registry::iterator mit = model_registry.begin(); mit != model_registry.end(); mit++) {
+ list_model((*mit).second);
+
}
- con_print << registry.size() << " registered models" << std::endl;
+
+ con_print << model_registry.size() << " registered models" << std::endl;
if (VertexArray::instance())
- con_print << "vertex array " << (VertexArray::instance()->index() * 100 / VertexArray::instance()->size())
- << "% used" << std::endl;
+ con_print << "vertex array " << (VertexArray::instance()->index() * 100 / VertexArray::instance()->size())
+ << "% of " << VertexArray::instance()->size() << " used" << std::endl;
}
}