From 9f1c9694199969e1cd1fb9bf731d0e8ef2d8c184 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 17 Nov 2010 23:37:52 +0000 Subject: Removed core::Info.model(), info record models must be referenced through Info::modelname(). Prevent the loading of all info record models in render::load(). Added r_loadmodels engine function, which can be used to load all referenced models at once. --- src/render/render.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/render/render.cc') diff --git a/src/render/render.cc b/src/render/render.cc index 1b0d90e..2a325e9 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -60,6 +60,11 @@ void func_list_particles(std::string const &args) ParticleScript::list(); } +void func_load_info_models(std::string const &args) +{ + load_info_models(); +} + void init(int width, int height) { con_print << "^BInitializing renderer..." << std::endl; @@ -148,6 +153,9 @@ void init(int width, int height) func = core::Func::add("list_particles", func_list_particles); func->set_info("list registered particle scripts"); + + func = core::Func::add("r_loadmodels", func_load_info_models); + func->set_info("load all models referenced by info record"); load(); } @@ -198,12 +206,6 @@ void clear() } } - // clear info models - for (core::Info::Registry::iterator it = core::Info::registry().begin(); it != core::Info::registry().end(); it++) { - core::Info *info = (*it); - info->set_model(0); - } - // clear model registry model::Model::clear(); @@ -225,16 +227,19 @@ void load() entity->set_model(model::Model::load(entity->modelname())); } } +} +// load all models referenced by info records +void load_info_models() +{ // load info models for (core::Info::Registry::iterator it = core::Info::registry().begin(); it != core::Info::registry().end(); it++) { core::Info *info = (*it); if (info->modelname().size()) { - info->set_model(model::Model::load(info->modelname())); - } else { - info->set_model(0); + model::Model::load(info->modelname()); } } + } // reset render subsystem (module disconnect) @@ -265,6 +270,7 @@ void shutdown() core::Func::remove("list_materials"); core::Func::remove("list_particles"); core::Func::remove("list_textures"); + core::Func::remove("r_loadmodels"); clear(); -- cgit v1.2.3