diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/render.cc | 24 | ||||
-rw-r--r-- | src/render/render.h | 5 |
2 files changed, 19 insertions, 10 deletions
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(); diff --git a/src/render/render.h b/src/render/render.h index 97880cc..53a40dc 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -34,6 +34,9 @@ void reset(); /// load game render data void load(); +/// load all models referenced by info records +void load_info_models(); + /// unload game render data void unload(); @@ -75,7 +78,7 @@ inline RenderExt *ext_render(const core::Entity *entity) { return static_cast<RenderExt *>(entity->extension((size_t)core::Extension::Render)); } -} +} // namespace render #endif // __INCLUDED_RENDER_H__ |