| 2935 | } |
| 2936 | |
| 2937 | Map::HitResult Map::ProcessShot( |
| 2938 | const m_Vec3& shot_start_point, |
| 2939 | const m_Vec3& shot_direction_normalized, |
| 2940 | const float max_distance, |
| 2941 | const EntityId skip_monster_id ) const |
| 2942 | { |
| 2943 | HitResult result; |
| 2944 | float nearest_shot_point_square_distance= max_distance * max_distance; |
| 2945 | |
| 2946 | const auto process_candidate_shot_pos= |
| 2947 | [&]( const m_Vec3& candidate_pos, const HitResult::ObjectType object_type, const unsigned int object_index ) |
| 2948 | { |
| 2949 | const float square_distance= ( candidate_pos - shot_start_point ).SquareLength(); |
| 2950 | if( square_distance < nearest_shot_point_square_distance ) |
| 2951 | { |
| 2952 | result.pos= candidate_pos; |
| 2953 | nearest_shot_point_square_distance= square_distance; |
| 2954 | |
| 2955 | result.object_type= object_type; |
| 2956 | result.object_index= object_index; |
| 2957 | } |
| 2958 | }; |
| 2959 | |
| 2960 | const auto func= |
| 2961 | [&]( const MapData::IndexElement& element ) -> bool |
| 2962 | { |
| 2963 | if( element.type == MapData::IndexElement::StaticWall ) |
| 2964 | { |
| 2965 | PC_ASSERT( element.index < map_data_->static_walls.size() ); |
| 2966 | const MapData::Wall& wall= map_data_->static_walls[ element.index ]; |
| 2967 | |
| 2968 | const MapData::WallTextureDescription& wall_texture= map_data_->walls_textures[ wall.texture_id ]; |
| 2969 | if( wall_texture.gso[1] ) |
| 2970 | return false; |
| 2971 | |
| 2972 | m_Vec3 candidate_pos; |
| 2973 | if( RayIntersectWall( |
| 2974 | wall.vert_pos[0], wall.vert_pos[1], |
| 2975 | 0.0f, 2.0f, |
| 2976 | shot_start_point, shot_direction_normalized, |
| 2977 | candidate_pos ) ) |
| 2978 | { |
| 2979 | process_candidate_shot_pos( candidate_pos, HitResult::ObjectType::StaticWall, &wall - map_data_->static_walls.data() ); |
| 2980 | } |
| 2981 | } |
| 2982 | else if( element.type == MapData::IndexElement::StaticModel ) |
| 2983 | { |
| 2984 | PC_ASSERT( element.index < static_models_.size() ); |
| 2985 | const StaticModel& model= static_models_[ element.index ]; |
| 2986 | |
| 2987 | if( model.model_id >= map_data_->models_description.size() ) |
| 2988 | return false; |
| 2989 | |
| 2990 | const MapData::ModelDescription& model_description= map_data_->models_description[ model.model_id ]; |
| 2991 | if( model_description.radius <= 0.0f ) |
| 2992 | return false; |
| 2993 | |
| 2994 | const Model& model_data= map_data_->models[ model.model_id ]; |
nothing calls this directly
no test coverage detected