Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ typedef struct mc_info {
#define MC_CHECK_INVISIBLE_FACES (1<<8) // Check the invisible faces.
#define MC_COLLIDE_ALL (1<<9) // Returns ALL hits via hit_points_all, including backfacing polies hits

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

/*
Checks to see if a vector from p0 to p0 collides with a model of
Expand Down
14 changes: 11 additions & 3 deletions code/model/modelcollide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#include "math/fvi.h"
#include "math/vecmat.h"
#include "model/model.h"
#include "model/modelrender.h"
#include "model/modelsinc.h"
#include "tracing/tracing.h"
#include "render/3d.h"
#include "tracing/Monitor.h"


#include "tracing/tracing.h"

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

if (Mc->flags & MC_RESPECT_DETAIL_BOX_SPHERE) {
vec3d local;
vm_vec_sub(&local, &Eye_position, Mc->pos);
vm_vec_rotate(&local, &local, Mc->orient);
if (!model_render_check_detail_box(&local, Mc_pm, mn, MR_NORMAL))
goto NoHit; //This submodel is a detail box that is not displayed, skip it
}

// Rotate the world check points into the current subobject's
// frame of reference.
// After this block, Mc_p0, Mc_p1, Mc_direction, and Mc_mag are correct
Expand Down
6 changes: 3 additions & 3 deletions code/ship/shipfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
mc.pos = &objp->pos;
mc.p0 = &rp0;
mc.p1 = &rp1;
mc.flags = MC_CHECK_MODEL;
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;

if (model_collide(&mc)) {
return true;
Expand Down Expand Up @@ -887,7 +887,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
mc.pos = &pos;
mc.p0 = &rp0;
mc.p1 = &rp1;
mc.flags = MC_CHECK_MODEL;
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;

int mc_result = model_collide(&mc);
mc.pos = NULL;
Expand Down Expand Up @@ -936,7 +936,7 @@ bool shipfx_eye_in_shadow( vec3d *eye_pos, object * src_obj, int light_n )
mc.pos = &Viewer_obj->pos;
mc.p0 = &rp0;
mc.p1 = &rp1;
mc.flags = MC_CHECK_MODEL;
mc.flags = MC_CHECK_MODEL | MC_RESPECT_DETAIL_BOX_SPHERE;

if( model_collide(&mc) ) {
if ( mc.t_poly ) {
Expand Down
Loading