Skip to content

Commit 381f9fd

Browse files
authored
Mod Specific Visual Culling Size for Lasers (#6729)
* Mod Specific Visual Culling Size for Lasers Currently, lasers will not render if the length or both head and tail radii are < `0.0001`. This is very small, and in many mods the smallest visual size is `0.01`, so this PR exposes that culling size value to allow mods to optimize and tune visual culling of lasers, which can be quite useful especially in laser heavy missions. * update names * actually push all files
1 parent 61b3d82 commit 381f9fd

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

code/mod_table/mod_table.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ float Min_pixel_size_beam;
133133
float Min_pizel_size_muzzleflash;
134134
float Min_pixel_size_trail;
135135
float Min_pixel_size_laser;
136+
float Do_not_render_lasers_below_length;
137+
float Do_not_render_lasers_below_radius;
136138
bool Supernova_hits_at_zero;
137139
bool Show_subtitle_uses_pixels;
138140
int Show_subtitle_screen_base_res[2];
@@ -930,6 +932,14 @@ void parse_mod_table(const char *filename)
930932
stuff_float(&Min_pixel_size_laser);
931933
}
932934

935+
if (optional_string("$Do Not Render Lasers Below Length:")) {
936+
stuff_float(&Do_not_render_lasers_below_length);
937+
}
938+
939+
if (optional_string("$Do Not Render Lasers Below Radius:")) {
940+
stuff_float(&Do_not_render_lasers_below_radius);
941+
}
942+
933943
if (optional_string("$Thruster easing value:")) {
934944
stuff_float(&Thruster_easing);
935945
if (Thruster_easing <= 0.0f) {
@@ -1692,6 +1702,8 @@ void mod_table_reset()
16921702
Min_pizel_size_muzzleflash = 0.0f;
16931703
Min_pixel_size_trail = 0.0f;
16941704
Min_pixel_size_laser = 0.0f;
1705+
Do_not_render_lasers_below_length = 0.0001f;
1706+
Do_not_render_lasers_below_radius = 0.0001f;
16951707
Supernova_hits_at_zero = false;
16961708
Show_subtitle_uses_pixels = false;
16971709
Show_subtitle_screen_base_res[0] = -1;

code/mod_table/mod_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ extern float Min_pixel_size_beam;
146146
extern float Min_pizel_size_muzzleflash;
147147
extern float Min_pixel_size_trail;
148148
extern float Min_pixel_size_laser;
149+
extern float Do_not_render_lasers_below_length;
150+
extern float Do_not_render_lasers_below_radius;
149151
extern bool Supernova_hits_at_zero;
150152
extern bool Show_subtitle_uses_pixels;
151153
extern int Show_subtitle_screen_base_res[];

code/weapon/weapons.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9215,17 +9215,19 @@ void weapon_render(object* obj, model_draw_list *scene)
92159215
head_radius *= head_radius_mult * radius_mult;
92169216
tail_radius *= tail_radius_mult * radius_mult;
92179217

9218-
if (laser_length < 0.0001f)
9218+
if (laser_length < Do_not_render_lasers_below_length) {
92199219
return;
9220+
}
92209221

9221-
if (head_radius < 0.0001f && tail_radius < 0.0001f)
9222+
if (head_radius < Do_not_render_lasers_below_radius && tail_radius < Do_not_render_lasers_below_radius) {
92229223
return;
9224+
}
92239225

9224-
if (head_radius <= 0.0001f) {
9225-
head_radius = 0.0001f;
9226+
if (head_radius <= Do_not_render_lasers_below_radius) {
9227+
head_radius = Do_not_render_lasers_below_radius;
92269228
}
9227-
if (tail_radius <= 0.0001f) {
9228-
tail_radius = 0.0001f;
9229+
if (tail_radius <= Do_not_render_lasers_below_radius) {
9230+
tail_radius = Do_not_render_lasers_below_radius;
92299231
}
92309232

92319233

0 commit comments

Comments
 (0)