Skip to content

Commit

Permalink
Merge pull request scp-fs2open#6149 from Kestrellius/fix-headon-discr…
Browse files Browse the repository at this point in the history
…epancies

Make headon transition behavior consistent between laser and glow bitmaps
  • Loading branch information
Goober5000 authored Jun 1, 2024
2 parents b1d4e0a + e710b65 commit e4b5d5f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions code/weapon/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8819,6 +8819,8 @@ void weapon_render(object* obj, model_draw_list *scene)
vm_vec_scale_add(&tailp, &obj->pos, &rotated_offset, laser_length);
vm_vec_scale_add(&headp, &tailp, &obj->orient.vec.fvec, laser_length);

float main_bitmap_alpha_mult = 1.0;

if (wip->laser_bitmap.first_frame >= 0) {
gr_set_color_fast(&wip->laser_color_1);

Expand Down Expand Up @@ -8851,16 +8853,16 @@ void weapon_render(object* obj, model_draw_list *scene)
float scaled_head_radius = model_render_get_diameter_clamped_to_min_pixel_size(&headp, wip->laser_head_radius * radius_mult, wip->laser_min_pixel_size);
float scaled_tail_radius = model_render_get_diameter_clamped_to_min_pixel_size(&tailp, wip->laser_tail_radius * radius_mult, wip->laser_min_pixel_size);

int alpha = static_cast<int>(alphaf * 255.0f);
int alpha = fl2i(alphaf * 255.0f);

// render the head-on bitmap if appropriate and maybe adjust the main bitmap's alpha
if (wip->laser_headon_bitmap.first_frame >= 0) {
float main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp, &tailp,
main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp, &tailp,
wip->laser_headon_bitmap.first_frame + headon_framenum,
scaled_head_radius,
scaled_tail_radius,
alpha, alpha, alpha);
alpha = static_cast<int>(alphaf * main_bitmap_alpha_mult * 255.0);
alpha = fl2i(alphaf * main_bitmap_alpha_mult * 255.0);
}

batching_add_laser(
Expand Down Expand Up @@ -8944,20 +8946,26 @@ void weapon_render(object* obj, model_draw_list *scene)
float scaled_head_radius = model_render_get_diameter_clamped_to_min_pixel_size(&headp2, wip->laser_head_radius * radius_mult, wip->laser_min_pixel_size);
float scaled_tail_radius = model_render_get_diameter_clamped_to_min_pixel_size(&tailp2, wip->laser_tail_radius * radius_mult, wip->laser_min_pixel_size);

int r = static_cast<int>(static_cast<float>(c.red) * alphaf);
int g = static_cast<int>(static_cast<float>(c.green) * alphaf);
int b = static_cast<int>(static_cast<float>(c.blue) * alphaf);
int r = fl2i(i2fl(c.red) * alphaf);
int g = fl2i(i2fl(c.green) * alphaf);
int b = fl2i(i2fl(c.blue) * alphaf);

// render the head-on bitmap if appropriate and maybe adjust the main bitmap's alpha
if (wip->laser_glow_headon_bitmap.first_frame >= 0) {
float main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp2, &tailp2,
float head_alpha = 1.0 - main_bitmap_alpha_mult;

r = (int)(r * head_alpha); g = (int)(g * head_alpha); b = (int)(b * head_alpha);

batching_add_laser(
wip->laser_glow_headon_bitmap.first_frame + headon_framenum,
&headp2,
scaled_head_radius * wip->laser_glow_head_scale,
&tailp2,
scaled_tail_radius * wip->laser_glow_tail_scale,
r, g, b);
r = static_cast<int>(static_cast<float>(c.red) * alphaf * main_bitmap_alpha_mult);
g = static_cast<int>(static_cast<float>(c.green) * alphaf * main_bitmap_alpha_mult);
b = static_cast<int>(static_cast<float>(c.blue) * alphaf * main_bitmap_alpha_mult);
r = fl2i(i2fl(c.red) * alphaf * main_bitmap_alpha_mult);
g = fl2i(i2fl(c.green) * alphaf * main_bitmap_alpha_mult);
b = fl2i(i2fl(c.blue) * alphaf * main_bitmap_alpha_mult);
}

batching_add_laser(
Expand Down

0 comments on commit e4b5d5f

Please sign in to comment.