diff --git a/code/graphics/color.cpp b/code/graphics/color.cpp index f959a7c2a3d..45e3601bd20 100644 --- a/code/graphics/color.cpp +++ b/code/graphics/color.cpp @@ -70,6 +70,16 @@ void hdr_color::set_rgb(int new_r, int new_g, int new_b) this->blue = i2fl(new_b) / 255.0f; } +/** + * @brief Sets RGB values from three 0.0-1.0 floats + */ +void hdr_color::set_rgb(float new_r, float new_g, float new_b) +{ + this->red = new_r; + this->green = new_g; + this->blue = new_b; +} + /** * @brief Sets RGBA values from an old style color object */ diff --git a/code/graphics/color.h b/code/graphics/color.h index 923fc3ea6c7..8b0909cbca3 100644 --- a/code/graphics/color.h +++ b/code/graphics/color.h @@ -18,6 +18,7 @@ class hdr_color{ void set_vecf(const SCP_vector& input); void set_rgb(const int new_r,const int new_g,const int new_b); + void set_rgb(const float new_r,const float new_g,const float new_b); void set_rgb(const color* const new_rgb); void set_rgb(const int* const new_rgb); diff --git a/code/object/object.cpp b/code/object/object.cpp index c5ed672e975..afd4cd1501a 100644 --- a/code/object/object.cpp +++ b/code/object/object.cpp @@ -1266,18 +1266,15 @@ void obj_move_all_post(object *objp, float frametime) // If there is no specific color set in the table, laser render weapons have a dynamic color. if (!wi->light_color_set && wi->render_type == WRT_LASER) { - // intensity is stored in the light color even if no user setting is done. - light_color = hdr_color(&wi->light_color); // Classic dynamic laser color is handled with an old color object color c; weapon_get_laser_color(&c, objp); - light_color.set_rgb(&c); - light_color.set_rgb(fl2i(i2fl(light_color.r()) * r_mult), fl2i(i2fl(light_color.g()) * g_mult), fl2i(i2fl(light_color.b()) * b_mult)); - light_color.i(light_color.i() * intensity_mult); + light_color.set_rgb((c.red/255.f) * r_mult, (c.green/255.f) * g_mult, (c.blue/255.f) * b_mult); + // intensity is stored in the light color even if no user setting is done. + light_color.i(wi->light_color.i() * intensity_mult); } else { // If not a laser then all default information needed is stored in the weapon light color - light_color = hdr_color(&wi->light_color); - light_color.set_rgb(fl2i(i2fl(light_color.r()) * r_mult), fl2i(i2fl(light_color.g()) * g_mult), fl2i(i2fl(light_color.b()) * b_mult)); + light_color.set_rgb(wi->light_color.r() * r_mult, wi->light_color.g() * g_mult, wi->light_color.b() * b_mult); } //handles both defaults and adjustments. float light_radius = wi->light_radius; @@ -1290,7 +1287,7 @@ void obj_move_all_post(object *objp, float frametime) source_radius *= 0.05f; light_radius = lp->missile_light_radius.handle(light_radius) * radius_mult; light_color.i(lp->missile_light_brightness.handle(light_color.i()) * intensity_mult); - light_color.set_rgb(fl2i(i2fl(light_color.r()) * r_mult), fl2i(i2fl(light_color.g()) * g_mult), fl2i(i2fl(light_color.b()) * b_mult)); + light_color.set_rgb(light_color.r() * r_mult, light_color.g() * g_mult, light_color.b() * b_mult); } if(light_radius > 0.0f && intensity_mult > 0.0f && light_color.i() > 0.0f) light_add_point(&objp->pos, light_radius, light_radius, &light_color, source_radius);