-
Notifications
You must be signed in to change notification settings - Fork 123
fix: prioritize tracked world map tile requests #5747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -608,98 +608,117 @@ void LLWorldMap::updateRegions(S32 x0, S32 y0, S32 x1, S32 y1) | |
| constexpr S32 MAX_TOTAL_BLOCKS = MAX_REQUEST_REGIONS / REGIONS_PER_BLOCK; // 64 / 16 = 4 blocks total | ||
| constexpr S32 MAX_BLOCKS_PER_SIDE = MAX_TOTAL_BLOCKS; // Can have up to 4 blocks in one dimension (e.g., 4x1, 1x4, 2x2) | ||
|
|
||
| // Convert region coordinates to block coordinates | ||
| // We use fixed sized blocks for ease of storage and lookup, | ||
| // but the requests can be of variable size of up to | ||
| // MAX_REQUEST_REGIONS. | ||
| S32 block_x0 = x0 / MAP_BLOCK_SIZE; | ||
| S32 block_x1 = x1 / MAP_BLOCK_SIZE; | ||
| S32 block_y0 = y0 / MAP_BLOCK_SIZE; | ||
| S32 block_y1 = y1 / MAP_BLOCK_SIZE; | ||
|
|
||
| // Clamp to valid range | ||
| block_x0 = llmax(block_x0, 0); | ||
| block_x1 = llmin(block_x1, MAP_BLOCK_RES - 1); | ||
| block_y0 = llmax(block_y0, 0); | ||
| block_y1 = llmin(block_y1, MAP_BLOCK_RES - 1); | ||
|
|
||
| // Process blocks, grouping unloaded blocks into larger requests up to MAX_TOTAL_BLOCKS | ||
| for (S32 block_y = block_y0; block_y <= block_y1; ) | ||
| S32 block_x0 = llclamp(x0 / MAP_BLOCK_SIZE, 0, MAP_BLOCK_RES - 1); | ||
| S32 block_x1 = llclamp(x1 / MAP_BLOCK_SIZE, 0, MAP_BLOCK_RES - 1); | ||
| S32 block_y0 = llclamp(y0 / MAP_BLOCK_SIZE, 0, MAP_BLOCK_RES - 1); | ||
| S32 block_y1 = llclamp(y1 / MAP_BLOCK_SIZE, 0, MAP_BLOCK_RES - 1); | ||
|
|
||
| const S32 tracked_region_x = llclamp((S32)(mTrackingLocation.mdV[VX] / REGION_WIDTH_UNITS), 0, MAP_MAX_SIZE - 1); | ||
| const S32 tracked_region_y = llclamp((S32)(mTrackingLocation.mdV[VY] / REGION_WIDTH_UNITS), 0, MAP_MAX_SIZE - 1); | ||
| const S32 tracked_block_x = tracked_region_x / MAP_BLOCK_SIZE; | ||
| const S32 tracked_block_y = tracked_region_y / MAP_BLOCK_SIZE; | ||
| const bool tracked_block_visible = isTracking() && | ||
| tracked_block_x >= block_x0 && tracked_block_x <= block_x1 && | ||
| tracked_block_y >= block_y0 && tracked_block_y <= block_y1; | ||
|
|
||
| if (tracked_block_visible) | ||
| { | ||
| const S32 tracked_offset = tracked_block_x | (tracked_block_y * MAP_BLOCK_RES); | ||
| if (!mMapBlockLoaded[tracked_offset]) | ||
| { | ||
| const S32 min_x = tracked_block_x * MAP_BLOCK_SIZE; | ||
| const S32 min_y = tracked_block_y * MAP_BLOCK_SIZE; | ||
| const S32 max_x = min_x + MAP_BLOCK_SIZE - 1; | ||
| const S32 max_y = min_y + MAP_BLOCK_SIZE - 1; | ||
|
|
||
| LL_DEBUGS("WorldMap") << "Loading tracked block first (" << tracked_block_x << "," << tracked_block_y | ||
| << ") [" << REGIONS_PER_BLOCK << " regions]" << LL_ENDL; | ||
|
|
||
| LLWorldMapMessage::getInstance()->sendMapBlockRequest(min_x, min_y, max_x, max_y); | ||
| mMapBlockLoaded[tracked_offset] = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After checking the code I'm not sure if this ticket actually needs fixing or if #5558 fixed it and it just needs to go through QA first to make sure issue is gone. |
||
| } | ||
| } | ||
|
|
||
| for (S32 block_y = block_y0; block_y <= block_y1; ++block_y) | ||
| { | ||
| for (S32 block_x = block_x0; block_x <= block_x1; ) | ||
| { | ||
| S32 offset = block_x | (block_y * MAP_BLOCK_RES); | ||
| if (tracked_block_visible && block_x == tracked_block_x && block_y == tracked_block_y) | ||
| { | ||
| ++block_x; | ||
| continue; | ||
| } | ||
|
|
||
| const S32 offset = block_x | (block_y * MAP_BLOCK_RES); | ||
| if (!mMapBlockLoaded[offset]) | ||
| { | ||
| // Find the maximum contiguous unloaded rectangle starting at this block | ||
| S32 request_width = 1; | ||
| S32 request_height = 1; | ||
|
|
||
| // Expand width (check horizontal contiguous unloaded blocks) | ||
| while (request_width < MAX_BLOCKS_PER_SIDE && | ||
| (block_x + request_width) <= block_x1) | ||
| { | ||
| // request_height is 1, can add blocks one by one. | ||
| S32 check_offset = (block_x + request_width) | (block_y * MAP_BLOCK_RES); | ||
| if (mMapBlockLoaded[check_offset]) | ||
| const S32 check_block_x = block_x + request_width; | ||
| const S32 check_offset = check_block_x | (block_y * MAP_BLOCK_RES); | ||
| if (mMapBlockLoaded[check_offset] || | ||
| (tracked_block_visible && check_block_x == tracked_block_x && block_y == tracked_block_y)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the point of checking this? Wouldn't mMapBlockLoaded[offset] already be true? |
||
| { | ||
| break; | ||
| } | ||
| ++request_width; | ||
| } | ||
|
|
||
| // Expand height (check vertical contiguous unloaded blocks) | ||
| while (request_height < MAX_BLOCKS_PER_SIDE && | ||
| (block_y + request_height) <= block_y1 && | ||
| (request_width * (request_height + 1) <= MAX_TOTAL_BLOCKS)) // Don't exceed 64 total regions | ||
| (request_width * (request_height + 1) <= MAX_TOTAL_BLOCKS)) | ||
| { | ||
| bool can_expand = true; | ||
| // Width can be >1, loop over blocks in the line | ||
| for (S32 x = 0; x < request_width; ++x) | ||
| { | ||
| S32 check_offset = (block_x + x) | ((block_y + request_height) * MAP_BLOCK_RES); | ||
| if (mMapBlockLoaded[check_offset]) | ||
| const S32 check_block_x = block_x + x; | ||
| const S32 check_block_y = block_y + request_height; | ||
| const S32 check_offset = check_block_x | (check_block_y * MAP_BLOCK_RES); | ||
| if (mMapBlockLoaded[check_offset] || | ||
| (tracked_block_visible && check_block_x == tracked_block_x && check_block_y == tracked_block_y)) | ||
| { | ||
| can_expand = false; | ||
| break; | ||
| } | ||
| } | ||
| if (!can_expand) break; | ||
| if (!can_expand) | ||
| { | ||
| break; | ||
| } | ||
| ++request_height; | ||
| } | ||
|
|
||
| // Send request for the contiguous rectangle | ||
| S32 min_x = block_x * MAP_BLOCK_SIZE; | ||
| S32 min_y = block_y * MAP_BLOCK_SIZE; | ||
| S32 max_x = (block_x + request_width) * MAP_BLOCK_SIZE - 1; | ||
| S32 max_y = (block_y + request_height) * MAP_BLOCK_SIZE - 1; | ||
| const S32 min_x = block_x * MAP_BLOCK_SIZE; | ||
| const S32 min_y = block_y * MAP_BLOCK_SIZE; | ||
| const S32 max_x = (block_x + request_width) * MAP_BLOCK_SIZE - 1; | ||
| const S32 max_y = (block_y + request_height) * MAP_BLOCK_SIZE - 1; | ||
|
|
||
| LL_DEBUGS("WorldMap") << "Loading Block rectangle (" << block_x << "," << block_y | ||
| << ") to (" << (block_x + request_width - 1) << "," << (block_y + request_height - 1) | ||
| << ") [" << (request_width * request_height * MAP_BLOCK_SIZE * MAP_BLOCK_SIZE) << " regions]" << LL_ENDL; | ||
|
|
||
| LLWorldMapMessage::getInstance()->sendMapBlockRequest(min_x, min_y, max_x, max_y); | ||
|
|
||
| // Mark all blocks in the requested rectangle as loaded | ||
| for (S32 y = 0; y < request_height; ++y) | ||
| { | ||
| for (S32 x = 0; x < request_width; ++x) | ||
| { | ||
| S32 mark_offset = (block_x + x) | ((block_y + y) * MAP_BLOCK_RES); | ||
| const S32 mark_offset = (block_x + x) | ((block_y + y) * MAP_BLOCK_RES); | ||
| mMapBlockLoaded[mark_offset] = true; | ||
| } | ||
| } | ||
|
|
||
| // Skip over the width of blocks we just requested | ||
| block_x += request_width; | ||
| } | ||
| else | ||
| { | ||
| // This block is already loaded, move to next | ||
| ++block_x; | ||
| } | ||
| } | ||
| ++block_y; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove comments. This logic is complicated to parse without having at least some idea of what to expect.