| 3084 | } |
| 3085 | |
| 3086 | bool Map::FindNearestPlayerPos( const m_Vec3& pos, m_Vec3& out_pos ) const |
| 3087 | { |
| 3088 | if( players_.empty() ) |
| 3089 | return false; |
| 3090 | |
| 3091 | float min_square_distance= Constants::max_float; |
| 3092 | m_Vec3 nearest_player_pos; |
| 3093 | |
| 3094 | const m_Vec2 z_minmax= players_.begin()->second->GetZMinMax(); |
| 3095 | const float dz= ( z_minmax.x + z_minmax.y ) * 0.5f; |
| 3096 | |
| 3097 | for( const PlayersContainer::value_type& player_value : players_ ) |
| 3098 | { |
| 3099 | const Player& player= *player_value.second; |
| 3100 | const m_Vec3 player_pos_corrected= m_Vec3( player.Position().x, player.Position().y, player.Position().z + dz ); |
| 3101 | |
| 3102 | const float square_distance= ( player_pos_corrected - pos ).SquareLength(); |
| 3103 | if( square_distance < min_square_distance ) |
| 3104 | { |
| 3105 | nearest_player_pos= player_pos_corrected; |
| 3106 | min_square_distance= square_distance; |
| 3107 | } |
| 3108 | } |
| 3109 | |
| 3110 | out_pos= nearest_player_pos; |
| 3111 | return true; |
| 3112 | } |
| 3113 | |
| 3114 | float Map::GetFloorLevel( const m_Vec2& pos, const float radius ) const |
| 3115 | { |
nothing calls this directly
no test coverage detected