| 349 | } |
| 350 | |
| 351 | void Client::Draw() |
| 352 | { |
| 353 | if( cutscene_player_ != nullptr ) |
| 354 | { |
| 355 | cutscene_player_->Draw(); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | if( map_state_ != nullptr ) |
| 360 | { |
| 361 | PC_ASSERT( current_map_data_ != nullptr ); |
| 362 | |
| 363 | camera_controller_.UpdateParams(); |
| 364 | |
| 365 | m_Vec3 pos= player_position_; |
| 366 | const float z_shift= camera_controller_.GetEyeZShift(); |
| 367 | |
| 368 | if( player_state_.health > 0u ) |
| 369 | pos.z+= GameConstants::player_eyes_level + z_shift; |
| 370 | else |
| 371 | pos.z= std::min( pos.z + GameConstants::player_deathcam_level, GameConstants::walls_height ); |
| 372 | |
| 373 | m_Mat4 view_rotation_and_projection_matrix, projection_matrix; |
| 374 | camera_controller_.GetViewRotationAndProjectionMatrix( view_rotation_and_projection_matrix ); |
| 375 | camera_controller_.GetViewProjectionMatrix( projection_matrix ); |
| 376 | |
| 377 | ViewClipPlanes view_clip_planes; |
| 378 | camera_controller_.GetViewClipPlanes( pos, view_clip_planes ); |
| 379 | |
| 380 | map_drawer_->Draw( |
| 381 | *map_state_, |
| 382 | view_rotation_and_projection_matrix, |
| 383 | pos, |
| 384 | view_clip_planes, |
| 385 | player_state_.health > 0u ? player_monster_id_ : 0u /* draw body, if death */ ); |
| 386 | |
| 387 | // Draw weapon, if alive. |
| 388 | if( player_state_.health > 0u ) |
| 389 | { |
| 390 | const float c_weapon_shift_scale= 0.25f; |
| 391 | const float c_weapon_angle_scale= 0.75f; |
| 392 | const float weapon_angle_for_shift= camera_controller_.GetViewAngleX() * c_weapon_angle_scale; |
| 393 | const float weapon_shift_z= c_weapon_shift_scale * z_shift * std::cos( weapon_angle_for_shift ); |
| 394 | const float weapon_shift_y= c_weapon_shift_scale * z_shift * std::sin( weapon_angle_for_shift ); |
| 395 | |
| 396 | m_Mat4 weapon_shift_matrix; |
| 397 | weapon_shift_matrix.Translate( m_Vec3( 0.0f, weapon_shift_y, weapon_shift_z ) ); |
| 398 | |
| 399 | map_drawer_->DrawWeapon( |
| 400 | weapon_state_, |
| 401 | weapon_shift_matrix * projection_matrix, |
| 402 | pos, |
| 403 | camera_controller_.GetViewAngleX(), |
| 404 | camera_controller_.GetViewAngleZ(), |
| 405 | player_state_.is_invisible ); |
| 406 | } |
| 407 | |
| 408 | map_drawer_->DoFullscreenPostprocess( *map_state_ ); |
no test coverage detected