MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / fvi_QuickDistObjectList

Function fvi_QuickDistObjectList

physics/findintersection.cpp:2108–2307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2106}
2107
2108int fvi_QuickDistObjectList(vector *pos, int init_room_index, float rad, int16_t *object_index_list, int max_elements,
2109 bool f_lightmap_only, bool f_only_players_and_ais, bool f_include_non_collide_objects,
2110 bool f_stop_at_closed_doors) {
2111 int num_objects = 0;
2112 int x; //, y;
2113 vector delta;
2114
2115 // Quick volume
2116 delta.x = delta.y = delta.z = rad;
2117 fvi_min_xyz = fvi_max_xyz = *pos;
2118
2119 fvi_min_xyz -= delta;
2120 fvi_max_xyz += delta;
2121
2122 fvi_wall_min_xyz = fvi_min_xyz;
2123 fvi_wall_max_xyz = fvi_max_xyz;
2124
2125 if (ROOMNUM_OUTSIDE(init_room_index)) {
2126 int num_cells = 0;
2127 int next_y_delta;
2128 int xstart, xend, ystart, yend;
2129 int check_x, check_y;
2130 int xcounter, ycounter;
2131 int cur_node;
2132
2133 cur_node = CELLNUM(init_room_index);
2134
2135 // Check worst-case collisions. This includes all nodes within a radius edge of the current node
2136 check_x = rad / TERRAIN_SIZE + 1;
2137 check_y = rad / TERRAIN_SIZE + 1;
2138
2139 xstart = cur_node % TERRAIN_WIDTH - check_x;
2140 xend = cur_node % TERRAIN_WIDTH + check_x;
2141 ystart = cur_node / TERRAIN_WIDTH - check_y;
2142 yend = cur_node / TERRAIN_WIDTH + check_y;
2143
2144 if (xstart < 0)
2145 xstart = 0;
2146 if (xend >= TERRAIN_WIDTH)
2147 xend = TERRAIN_WIDTH - 1;
2148 if (ystart < 0)
2149 ystart = 0;
2150 if (yend >= TERRAIN_DEPTH)
2151 yend = TERRAIN_DEPTH - 1;
2152
2153 // This should be a faster interative why to do a square with center at original position
2154 cur_node = TERRAIN_WIDTH * ystart + xstart;
2155 next_y_delta = TERRAIN_WIDTH - (xend - xstart) - 1;
2156
2157 for (ycounter = ystart; ycounter <= yend; ycounter++) {
2158 for (xcounter = xstart; xcounter <= xend; xcounter++) {
2159 // Do object stuff
2160 int cur_obj_index = Terrain_seg[cur_node].objects;
2161
2162 while (cur_obj_index > -1) {
2163 if (num_objects >= max_elements)
2164 break;
2165

Callers 7

ApplyLightingToObjectsFunction · 0.85
osipf_AIGetNearbyObjsFunction · 0.85
AINotifyFunction · 0.85
AIDoTrackFrameFunction · 0.85
ai_moveFunction · 0.85
AIDetermineTargetFunction · 0.85
AIDoMemFrameFunction · 0.85

Calls 2

object_movement_AABBFunction · 0.85
room_movement_AABBFunction · 0.85

Tested by

no test coverage detected