Skip to content
Draft
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
8 changes: 8 additions & 0 deletions code/cmdline/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Flag exe_params[] =
{ "-reparse_mainhall", "Reparse mainhall.tbl when loading halls", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-reparse_mainhall", },
{ "-noninteractive", "Disables interactive dialogs", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noninteractive", },
{ "-benchmark_mode", "Puts the game into benchmark mode", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-benchmark_mode", },
{ "-collision_bench", "Benchmark N frames of collision", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-collision_bench", },
{ "-profile_frame_time","Profile frame time", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_frame_time", },
{ "-profile_write_file", "Write profiling information to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_write_file", },
{ "-json_profiling", "Generate JSON profiling output", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-json_profiling", },
Expand Down Expand Up @@ -522,6 +523,7 @@ cmdline_parm frame_profile_write_file("-profile_write_file", NULL, AT_NONE); //
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL, AT_NONE); //Cmdline_no_unfocus_pause
cmdline_parm retail_time_compression_range_arg("-orig_speedx_range", NULL, AT_NONE); //Cmdline_retail_time_compression_range
cmdline_parm benchmark_mode_arg("-benchmark_mode", NULL, AT_NONE); //Cmdline_benchmark_mode
cmdline_parm collision_bench_arg("-collision_bench", NULL, AT_INT); //Cmdline_collision_bench
cmdline_parm pilot_arg("-pilot", nullptr, AT_STRING); //Cmdline_pilot
cmdline_parm noninteractive_arg("-noninteractive", NULL, AT_NONE); //Cmdline_noninteractive
cmdline_parm json_profiling("-json_profiling", NULL, AT_NONE); //Cmdline_json_profiling
Expand Down Expand Up @@ -564,6 +566,7 @@ bool Cmdline_profile_write_file = false;
bool Cmdline_no_unfocus_pause = false;
bool Cmdline_retail_time_compression_range = false;
bool Cmdline_benchmark_mode = false;
int Cmdline_collision_bench = 0;
const char *Cmdline_pilot = nullptr;
bool Cmdline_noninteractive = false;
bool Cmdline_json_profiling = false;
Expand Down Expand Up @@ -2308,6 +2311,11 @@ bool SetCmdlineParams()
Cmdline_benchmark_mode = true;
}

if (collision_bench_arg.found())
{
Cmdline_collision_bench = collision_bench_arg.get_int();
}

if (pilot_arg.found())
{
Cmdline_pilot = pilot_arg.str();
Expand Down
1 change: 1 addition & 0 deletions code/cmdline/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ extern bool Cmdline_profile_write_file;
extern bool Cmdline_no_unfocus_pause;
extern bool Cmdline_retail_time_compression_range;
extern bool Cmdline_benchmark_mode;
extern int Cmdline_collision_bench;
extern const char *Cmdline_pilot;
extern bool Cmdline_noninteractive;
extern bool Cmdline_json_profiling;
Expand Down
13 changes: 9 additions & 4 deletions code/debris/debris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ void debris_hit(object *debris_obj, object * /*other_obj*/, vec3d *hitpos, float
* NOTE: debris_hit_info pointer NULL for debris:weapon collision, otherwise debris:ship collision.
* @return true if hit, else return false.
*/
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info, vec3d* hitNormal)
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info, vec3d* hitNormal, mc_info* out_mc)
{
mc_info mc;

Expand Down Expand Up @@ -956,9 +956,14 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
}

weapon *wp = &Weapons[other_obj->instance];
wp->collisionInfo = new mc_info; // The weapon will free this memory later
*wp->collisionInfo = mc;
if (out_mc != nullptr) {
// Caller wants the result to stash on the weapon itself, on the main thread.
*out_mc = mc;
} else {
weapon *wp = &Weapons[other_obj->instance];
wp->collisionInfo = new mc_info; // The weapon will free this memory later
*wp->collisionInfo = mc;
}

return mc.num_hits;
}
Expand Down
6 changes: 5 additions & 1 deletion code/debris/debris.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef struct debris {
extern SCP_vector<debris> Debris;

struct collision_info_struct;
struct mc_info;

void debris_init();
void debris_render(object * obj, model_draw_list *scene);
Expand All @@ -88,7 +89,10 @@ void debris_create_set_velocity(const debris *db, const ship *source_shipp, cons
// Fire scripting hook after debris creation
void debris_create_fire_hook(object *obj, object *source_obj);

int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL, vec3d* hitnormal = NULL );
// out_mc, when given, receives the raw model collision result instead of it being stashed
// directly on the weapon. The threaded collision path needs that write deferred to the main
// thread, so the caller does it during post-processing.
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL, vec3d* hitnormal = NULL, mc_info* out_mc = nullptr );
void debris_hit( object * debris_obj, object * other_obj, vec3d * hitpos, float damage, vec3d* force );

void debris_add_to_hull_list(debris *db);
Expand Down
7 changes: 7 additions & 0 deletions code/model/modelcollide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "model/model.h"
#include "model/modelrender.h"
#include "model/modelsinc.h"
#include "object/collideprofile.h"
#include "render/3d.h"
#include "tracing/Monitor.h"
#include "tracing/tracing.h"
Expand Down Expand Up @@ -306,6 +307,7 @@ static void mc_check_sphereline_face( int nv, vec3d ** verts, vec3d * plane_pnt,
// check each edge to see if we hit, find the closest edge
// Mc->hit_dist stores the best edge time of *all* faces
float sphere_time;
COLLISION_PROF_INC(sphereline_edge_tests);
if ( fvi_polyedge_sphereline(&hit_point, &Mc_p0, &Mc_direction, Mc->radius, nv, verts, &sphere_time)) {
Assert( sphere_time >= 0.0f );
/*
Expand Down Expand Up @@ -389,6 +391,8 @@ void model_collide_bsp_poly(bsp_collision_tree *tree, int leaf_index)
vec3d *points[TMAP_MAX_VERTS];

while ( tested_leaf >= 0 ) {
COLLISION_PROF_INC(bsp_leaf_tests);

bsp_collision_leaf *leaf = &tree->leaf_list[tested_leaf];

bool flat_poly = false;
Expand Down Expand Up @@ -439,6 +443,8 @@ void model_collide_bsp(bsp_collision_tree *tree, int node_index)
return;
}

COLLISION_PROF_INC(bsp_node_visits);

bsp_collision_node *node = &tree->node_list[node_index];
vec3d hitpos;

Expand Down Expand Up @@ -1127,6 +1133,7 @@ int model_collide(mc_info *mc_info_obj)
Mc = mc_info_obj;

MONITOR_INC(NumFVI,1);
COLLISION_PROF_INC(model_collide_calls);

Mc->num_hits = 0; // How many collisions were found
Mc->shield_hit_tri = -1; // Assume we won't hit any shield polygons
Expand Down
Loading
Loading