| 644 | } |
| 645 | |
| 646 | bool Map::CanSee( const m_Vec3& from, const m_Vec3& to ) const |
| 647 | { |
| 648 | if( from == to ) |
| 649 | return true; |
| 650 | |
| 651 | m_Vec3 direction= to - from; |
| 652 | const float max_see_distance= direction.Length(); |
| 653 | direction.Normalize(); |
| 654 | |
| 655 | bool can_see= true; |
| 656 | const auto try_set_occluder= |
| 657 | [&]( const m_Vec3& intersection_point ) -> bool |
| 658 | { |
| 659 | if( ( intersection_point - from ).SquareLength() <= max_see_distance * max_see_distance ) |
| 660 | { |
| 661 | can_see= false; |
| 662 | return true; |
| 663 | } |
| 664 | return false; |
| 665 | }; |
| 666 | |
| 667 | const auto element_process_func= |
| 668 | [&]( const MapData::IndexElement& element ) -> bool |
| 669 | { |
| 670 | if( element.type == MapData::IndexElement::StaticWall ) |
| 671 | { |
| 672 | PC_ASSERT( element.index < map_data_->static_walls.size() ); |
| 673 | const MapData::Wall& wall= map_data_->static_walls[ element.index ]; |
| 674 | |
| 675 | const MapData::WallTextureDescription& wall_texture= map_data_->walls_textures[ wall.texture_id ]; |
| 676 | if( wall_texture.gso[1] ) |
| 677 | return false; |
| 678 | |
| 679 | m_Vec3 candidate_pos; |
| 680 | if( RayIntersectWall( |
| 681 | wall.vert_pos[0], wall.vert_pos[1], |
| 682 | 0.0f, 2.0f, |
| 683 | from, direction, |
| 684 | candidate_pos ) ) |
| 685 | { |
| 686 | if( try_set_occluder( candidate_pos ) ) |
| 687 | return true; |
| 688 | } |
| 689 | } |
| 690 | else if( element.type == MapData::IndexElement::StaticModel ) |
| 691 | { |
| 692 | PC_ASSERT( element.index < static_models_.size() ); |
| 693 | const StaticModel& model= static_models_[ element.index ]; |
| 694 | |
| 695 | if( model.model_id >= map_data_->models_description.size() ) |
| 696 | return false; |
| 697 | |
| 698 | const MapData::ModelDescription& model_description= map_data_->models_description[ model.model_id ]; |
| 699 | if( model_description.radius <= 0.0f ) |
| 700 | return false; |
| 701 | |
| 702 | const Model& model_data= map_data_->models[ model.model_id ]; |
| 703 |
nothing calls this directly
no test coverage detected