X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmodel%2Fmodel.cxx;h=edb91f27a8e1bae88fc28c3072f612d530b899a2;hb=f72b3882c36c83f3f83c9523a82f7d0c5ed519da;hp=fe3c5c5b71f49da2e88d2915a26b2a5ef6d6ba67;hpb=359a8c4a81323544180b7ccec3d6df45e4b4c8b8;p=simgear.git diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index fe3c5c5b..edb91f27 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -7,8 +7,6 @@ #include #endif -#include - #include // for strcmp() #include @@ -236,6 +234,12 @@ static void makeDList( ssgBranch *b, const set &ignore ) } } +class sgLoaderOptions : public ssgLoaderOptions { +public: + void endLoad() {} // Avoid clearing the texture cache after every model load +}; + +static sgLoaderOptions loaderOptions; //////////////////////////////////////////////////////////////////////// @@ -282,7 +286,7 @@ sgLoad3DModel( const string &fg_root, const string &path, texturepath = texturepath.dir(); ssgTexturePath((char *)texturepath.c_str()); - model = (ssgBranch *)ssgLoad((char *)modelpath.c_str()); + model = (ssgBranch *)ssgLoad((char *)modelpath.c_str(), &loaderOptions); if (model == 0) throw sg_io_exception("Failed to load 3D model", sg_location(modelpath.str())); @@ -319,8 +323,15 @@ sgLoad3DModel( const string &fg_root, const string &path, node->getFloatValue("offsets/z-m", 0.0)); align->setTransform(res_matrix); - ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"), - prop_root, sim_time_sec, load_panel ); + ssgBranch * kid; + const char * submodel = node->getStringValue("path"); + try { + kid = sgLoad3DModel( fg_root, submodel, prop_root, sim_time_sec, load_panel ); + + } catch (const sg_throwable &t) { + SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage()); + throw; + } align->addKid(kid); align->setName(node->getStringValue("name", "")); model->addKid(align); @@ -339,8 +350,8 @@ sgLoad3DModel( const string &fg_root, const string &path, } if (data) { - data->modelLoaded(path, &props, model); - model->setUserData(data); + alignmainmodel->setUserData(data); + data->modelLoaded(path, &props, alignmainmodel); } // Load animations set ignore_branches;