| 82 | } |
| 83 | |
| 84 | void Flares::DrawFlare(int which) { |
| 85 | Flare* flare = flares[which]; |
| 86 | if (flare->tex_opac[0] <= 0.0f && |
| 87 | flare->tex_opac[1] <= 0.0f && |
| 88 | flare->tex_opac[2] <= 0.0f) { |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | if (flare->visible == 0.0f && |
| 93 | flare->slow_visible == 0.0f) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | Graphics* graphics = Graphics::Instance(); |
| 98 | Textures* textures = Textures::Instance(); |
| 99 | Shaders* shaders = Shaders::Instance(); |
| 100 | Camera* cam = ActiveCameras::Get(); |
| 101 | |
| 102 | vec3 cam_to_flare; |
| 103 | vec3 cam_pos = cam->GetPos(); |
| 104 | |
| 105 | if (flare->distant) { |
| 106 | cam_to_flare = flare->position; |
| 107 | } else { |
| 108 | cam_to_flare = flare->position - cam_pos; |
| 109 | } |
| 110 | cam_to_flare = normalize(cam_to_flare); |
| 111 | float dot_prod = dot(cam_to_flare, cam->GetFacing()); |
| 112 | if (dot_prod < 0.0f) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | float zoom = graphics->config_.screen_height() / 1100.0f; |
| 117 | |
| 118 | glm::mat4 model_view; |
| 119 | |
| 120 | vec3 flare_pos; |
| 121 | vec3 interp_pos = mix(flare->old_position, flare->position, game_timer.GetInterpWeight()); |
| 122 | if (flare->distant) { |
| 123 | flare_pos = interp_pos + cam_pos; |
| 124 | } else { |
| 125 | flare_pos = interp_pos; |
| 126 | } |
| 127 | vec3 projected = cam->ProjectPoint(flare_pos); |
| 128 | float size = 512 * zoom * flare->size_mult; |
| 129 | model_view = glm::translate(model_view, glm::vec3(projected[0], projected[1], 0.0f)); |
| 130 | |
| 131 | // Draw flare itself |
| 132 | glm::mat4 model_view2 = glm::scale(model_view, glm::vec3(size * 0.5f, size * 0.5f, 1.0f)); |
| 133 | shaders->SetUniformMat4("modelview_mat", (const GLfloat*)&model_view2); |
| 134 | float color_alpha; |
| 135 | float total_opac = flare->tex_opac[0] + |
| 136 | flare->tex_opac[1]; |
| 137 | total_opac = max(0.0f, min(1.0f, total_opac)); |
| 138 | float mult = powf(Graphics::Instance()->hdr_white_point, 2.2f); |
| 139 | if (total_opac > 0.0f) { |
| 140 | float base_alpha = flare->slow_visible + |
| 141 | max(0.0f, (flare->slow_visible - flare->visible)); |
nothing calls this directly
no test coverage detected