Returns the number of faces that are approximately within the specified radius
| 1915 | |
| 1916 | // Returns the number of faces that are approximately within the specified radius |
| 1917 | int fvi_QuickDistFaceList(int init_room_index, vector *pos, float rad, fvi_face_room_list *quick_fr_list, |
| 1918 | int max_elements) { |
| 1919 | int num_faces = 0; |
| 1920 | room *cur_room; |
| 1921 | vector min_xyz, max_xyz; |
| 1922 | int next_rooms[MAX_QUICK_ROOMS]; |
| 1923 | int highest_next_room_index; |
| 1924 | int cur_next_room_index; |
| 1925 | int i; |
| 1926 | |
| 1927 | // ASSERT(quick_fr_list != NULL); |
| 1928 | ASSERT(pos != nullptr); |
| 1929 | ASSERT(init_room_index >= 0 && init_room_index <= Highest_room_index && Rooms[init_room_index].used != 0); |
| 1930 | ASSERT(rad >= 0.0f); |
| 1931 | |
| 1932 | // Quick volume |
| 1933 | min_xyz = max_xyz = *pos; |
| 1934 | |
| 1935 | min_xyz.x -= rad; |
| 1936 | min_xyz.y -= rad; |
| 1937 | min_xyz.z -= rad; |
| 1938 | max_xyz.x += rad; |
| 1939 | max_xyz.y += rad; |
| 1940 | max_xyz.z += rad; |
| 1941 | |
| 1942 | // Initially this is the only room in the list |
| 1943 | next_rooms[0] = init_room_index; |
| 1944 | highest_next_room_index = 0; |
| 1945 | cur_next_room_index = 0; |
| 1946 | |
| 1947 | // Use standard fvi list_array / bool list |
| 1948 | fvi_visit_list[init_room_index >> 3] |= 0x01 << (init_room_index % 8); |
| 1949 | fvi_rooms_visited[0] = init_room_index; |
| 1950 | fvi_num_rooms_visited = 1; |
| 1951 | |
| 1952 | while (num_faces < max_elements && cur_next_room_index <= highest_next_room_index) { |
| 1953 | cur_room = &Rooms[next_rooms[cur_next_room_index]]; |
| 1954 | |
| 1955 | // sort shit |
| 1956 | uint8_t msector = 0; |
| 1957 | |
| 1958 | if (min_xyz.x <= cur_room->bbf_min_xyz.x) { |
| 1959 | msector |= 0x01; |
| 1960 | } |
| 1961 | if (min_xyz.y <= cur_room->bbf_min_xyz.y) { |
| 1962 | msector |= 0x02; |
| 1963 | } |
| 1964 | if (min_xyz.z <= cur_room->bbf_min_xyz.z) { |
| 1965 | msector |= 0x04; |
| 1966 | } |
| 1967 | if (max_xyz.x >= cur_room->bbf_max_xyz.x) { |
| 1968 | msector |= 0x08; |
| 1969 | } |
| 1970 | if (max_xyz.y >= cur_room->bbf_max_xyz.y) { |
| 1971 | msector |= 0x10; |
| 1972 | } |
| 1973 | if (max_xyz.z >= cur_room->bbf_max_xyz.z) { |
| 1974 | msector |= 0x20; |
no test coverage detected