Skip to content

Commit cb38193

Browse files
authored
Make sunglows respect detail boxes (#7141)
* Add flag to respect detailboxes in model collide checks * Don't check detailboxes that are invisible for sunglare checks * Use local coords * Actualyl also run the check for cockpits & show ship * Be less stupid
1 parent 8fb0cbe commit cb38193

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

code/model/model.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,7 @@ typedef struct mc_info {
13161316
#define MC_CHECK_INVISIBLE_FACES (1<<8) // Check the invisible faces.
13171317
#define MC_COLLIDE_ALL (1<<9) // Returns ALL hits via hit_points_all, including backfacing polies hits
13181318

1319+
#define MC_RESPECT_DETAIL_BOX_SPHERE (1<<10) //Skip a submodel if it is an invisible detailbox
13191320

13201321
/*
13211322
Checks to see if a vector from p0 to p0 collides with a model of

code/model/modelcollide.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#include "math/fvi.h"
1818
#include "math/vecmat.h"
1919
#include "model/model.h"
20+
#include "model/modelrender.h"
2021
#include "model/modelsinc.h"
21-
#include "tracing/tracing.h"
22+
#include "render/3d.h"
2223
#include "tracing/Monitor.h"
23-
24-
24+
#include "tracing/tracing.h"
2525

2626
#define TOL 1E-4
2727
#define DIST_TOL 1.0
@@ -976,6 +976,14 @@ void mc_check_subobj( int mn )
976976
if (sm->flags[Model::Submodel_flags::No_collisions]) return; // don't do collisions
977977
if (sm->flags[Model::Submodel_flags::Nocollide_this_only]) goto NoHit; // Don't collide for this model, but keep checking others
978978

979+
if (Mc->flags & MC_RESPECT_DETAIL_BOX_SPHERE) {
980+
vec3d local;
981+
vm_vec_sub(&local, &Eye_position, Mc->pos);
982+
vm_vec_rotate(&local, &local, Mc->orient);
983+
if (!model_render_check_detail_box(&local, Mc_pm, mn, MR_NORMAL))
984+
goto NoHit; //This submodel is a detail box that is not displayed, skip it
985+
}
986+
979987
// Rotate the world check points into the current subobject's
980988
// frame of reference.
981989
// After this block, Mc_p0, Mc_p1, Mc_direction, and Mc_mag are correct

code/ship/shipfx.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
834834
mc.pos = &objp->pos;
835835
mc.p0 = &rp0;
836836
mc.p1 = &rp1;
837-
mc.flags = MC_CHECK_MODEL;
837+
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;
838838

839839
if (model_collide(&mc)) {
840840
return true;
@@ -887,7 +887,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
887887
mc.pos = &pos;
888888
mc.p0 = &rp0;
889889
mc.p1 = &rp1;
890-
mc.flags = MC_CHECK_MODEL;
890+
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;
891891

892892
int mc_result = model_collide(&mc);
893893
mc.pos = NULL;
@@ -936,7 +936,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
936936
mc.pos = &Viewer_obj->pos;
937937
mc.p0 = &rp0;
938938
mc.p1 = &rp1;
939-
mc.flags = MC_CHECK_MODEL;
939+
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;
940940

941941
if( model_collide(&mc) ) {
942942
if ( mc.t_poly ) {

0 commit comments

Comments
 (0)