| 3112 | } |
| 3113 | |
| 3114 | float Map::GetFloorLevel( const m_Vec2& pos, const float radius ) const |
| 3115 | { |
| 3116 | float max_dz= 0.0f; |
| 3117 | |
| 3118 | const float c_max_floor_level= GameConstants::walls_height - GameConstants::player_height - 0.05f; |
| 3119 | const float c_min_ceiling_level= GameConstants::player_height + 0.05f; |
| 3120 | |
| 3121 | const auto func= |
| 3122 | [&]( const MapData::IndexElement& index_element ) -> bool |
| 3123 | { |
| 3124 | if( index_element.type == MapData::IndexElement::StaticModel ) |
| 3125 | { |
| 3126 | const MapData::StaticModel& map_model= map_data_->static_models[ index_element.index ]; |
| 3127 | if( map_model.is_dynamic ) |
| 3128 | return false; |
| 3129 | |
| 3130 | if( map_model.model_id >= map_data_->models_description.size() ) |
| 3131 | return false; |
| 3132 | |
| 3133 | const MapData::ModelDescription& model_description= map_data_->models_description[ map_model.model_id ]; |
| 3134 | if( model_description.ac != 0u ) |
| 3135 | return false; |
| 3136 | |
| 3137 | const float model_radius= model_description.radius; |
| 3138 | if( model_radius <= 0.0f ) |
| 3139 | return false; |
| 3140 | |
| 3141 | const Model& model= map_data_->models[ map_model.model_id ]; |
| 3142 | if( model.z_max >= c_max_floor_level || // There is no space abowe. |
| 3143 | model.z_min >= c_min_ceiling_level ) // Enought space below. |
| 3144 | return false; |
| 3145 | |
| 3146 | if( CollideWithSquare( model_description ) ) |
| 3147 | { |
| 3148 | m_Vec2 collide_pos; |
| 3149 | if( CollideCircleWithSquare( |
| 3150 | map_model.pos, map_model.angle, model_radius, |
| 3151 | pos, radius, collide_pos ) ) |
| 3152 | max_dz= std::max( max_dz, model.z_max ); |
| 3153 | } |
| 3154 | else |
| 3155 | { |
| 3156 | const float square_distance= ( pos - map_model.pos ).SquareLength(); |
| 3157 | const float collision_distance= model_radius + radius; |
| 3158 | if( square_distance > collision_distance * collision_distance ) |
| 3159 | return false; |
| 3160 | |
| 3161 | max_dz= std::max( max_dz, model.z_max ); |
| 3162 | } |
| 3163 | } |
| 3164 | return false; |
| 3165 | }; |
| 3166 | |
| 3167 | collision_index_.ProcessElementsInRadius( pos, radius, func ); |
| 3168 | |
| 3169 | return max_dz; |
| 3170 | } |
| 3171 |
nothing calls this directly
no test coverage detected