Skip to content

Commit 650b8d4

Browse files
authored
Disable uneccesary raycast (#6811)
1 parent dbe0af1 commit 650b8d4

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

code/ai/aibig.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ void ai_bpap(const object *objp, const vec3d *attacker_objp_pos, const vec3d *at
146146

147147
*attack_point = best_point;
148148

149+
//The following raycast tends to make up 10%(!) of total AI-frametime for basically no benefit, especially in the common case for turrets where the normal isn't even queried.
150+
if (surface_normal == nullptr && Disable_expensive_turret_target_check)
151+
return;
152+
149153
// Cast from attack_objp_pos to local_attack_pos and check for nearest collision.
150154
// If no collision, cast to (0,0,0) [center of big ship]** [best_point initialized to 000]
151155

code/mod_table/mod_table.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ EscapeKeyBehaviorInOptions escape_key_behavior_in_options;
171171
bool Fix_asteroid_bounding_box_check;
172172
bool Disable_intro_movie;
173173
bool Show_locked_status_scramble_missions;
174+
bool Disable_expensive_turret_target_check;
174175

175176

176177
#ifdef WITH_DISCORD
@@ -1534,6 +1535,10 @@ void parse_mod_table(const char *filename)
15341535
stuff_boolean(&Show_locked_status_scramble_missions);
15351536
}
15361537

1538+
if (optional_string("$Disable expensive turret target check:")) {
1539+
stuff_boolean(&Disable_expensive_turret_target_check);
1540+
}
1541+
15371542
// end of options ----------------------------------------
15381543

15391544
// if we've been through once already and are at the same place, force a move
@@ -1769,6 +1774,7 @@ void mod_table_reset()
17691774
Fix_asteroid_bounding_box_check = false;
17701775
Disable_intro_movie = false;
17711776
Show_locked_status_scramble_missions = false;
1777+
Disable_expensive_turret_target_check = false;
17721778
}
17731779

17741780
void mod_table_set_version_flags()
@@ -1794,5 +1800,6 @@ void mod_table_set_version_flags()
17941800
Use_model_eyepoint_for_set_camera_host = true;
17951801
Use_model_eyepoint_normals = true;
17961802
Fix_asteroid_bounding_box_check = true;
1803+
Disable_expensive_turret_target_check = true;
17971804
}
17981805
}

code/mod_table/mod_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ extern EscapeKeyBehaviorInOptions escape_key_behavior_in_options;
186186
extern bool Fix_asteroid_bounding_box_check;
187187
extern bool Disable_intro_movie;
188188
extern bool Show_locked_status_scramble_missions;
189+
extern bool Disable_expensive_turret_target_check;
189190

190191
void mod_table_init();
191192
void mod_table_post_process();

0 commit comments

Comments
 (0)