From fe87aed445e8187ec9a635fd77ba0ad0833aa6ad Mon Sep 17 00:00:00 2001 From: Sushi Date: Mon, 29 Jun 2009 18:55:20 +0000 Subject: [PATCH] Added "$nocollide_this_only" and "$collide_invisible" submodel flags. The first one is like $no_collisions, but not recursive on submodels. The second one allows weapon impacts on the special "invisible" texture (normally only ship collisions are allowed). These two flags can be combined to implement invisible collision meshes, which can save a lot of FPS for complex models. --- code/model/model.h | 2 ++ code/model/modelcollide.cpp | 5 ++++- code/model/modelread.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code/model/model.h b/code/model/model.h index c898a8fa8f..9b003d75eb 100644 --- a/code/model/model.h +++ b/code/model/model.h @@ -308,6 +308,8 @@ typedef struct bsp_info { int use_render_box; //0==do nothing, 1==only render this object if you are inside the box, -1==only if your out bool gun_rotation;//for animated weapon models bool no_collisions; // for $no_collisions property - kazan + bool nocollide_this_only; //SUSHI: Like no_collisions, but not recursive. For the "replacement" collision model scheme. + bool collide_invisible; //SUSHI: If set, this submodel should allow collisions for invisible textures. For the "replacement" collision model scheme. float dumb_turn_rate; } bsp_info; diff --git a/code/model/modelcollide.cpp b/code/model/modelcollide.cpp index 6c515feee1..a43f5d0a53 100644 --- a/code/model/modelcollide.cpp +++ b/code/model/modelcollide.cpp @@ -421,7 +421,9 @@ void model_collide_tmappoly(ubyte * p) if ( (!(Mc->flags & MC_CHECK_INVISIBLE_FACES)) && (Mc_pm->maps[tmap_num].textures[TM_BASE_TYPE].GetTexture() < 0) ) { // Don't check invisible polygons. - return; + //SUSHI: Unless $collide_invisible is set. + if (!(Mc_pm->submodel[Mc_submodel].collide_invisible)) + return; } verts = (model_tmap_vert *)(p+44); @@ -668,6 +670,7 @@ void mc_check_subobj( int mn ) sm = &Mc_pm->submodel[mn]; if (sm->no_collisions) return; // don't do collisions + if (sm->nocollide_this_only) goto NoHit; // Don't collide for this model, but keep checking others // Rotate the world check points into the current subobject's // frame of reference. diff --git a/code/model/modelread.cpp b/code/model/modelread.cpp index 5c39c8837e..9df3ebb419 100644 --- a/code/model/modelread.cpp +++ b/code/model/modelread.cpp @@ -1279,6 +1279,16 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs else pm->submodel[n].no_collisions = false; + if (strstr(props, "$nocollide_this_only") != NULL ) + pm->submodel[n].nocollide_this_only = true; + else + pm->submodel[n].nocollide_this_only = false; + + if (strstr(props, "$collide_invisible") != NULL ) + pm->submodel[n].collide_invisible = true; + else + pm->submodel[n].collide_invisible = false; + if ( (p = strstr(props, "$gun_rotation:")) == NULL ) pm->submodel[n].gun_rotation = true; else