Skip to content

Commit

Permalink
Region update fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenguin committed Jan 7, 2022
1 parent e9e6f36 commit 20a840d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/renderer/src/renderer/scene/rust/RustRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void RustRenderer::map_destroy()

void RustRenderer::map_request_update(const Rect& region)
{
std::cout << "RustRenderer::map_request_update" << std::endl;
std::cout << "RustRenderer::map_request_update. region=" << region << std::endl;
rv_rect v_rect {
.x = region.x,
.y = region.y,
Expand Down
8 changes: 1 addition & 7 deletions src/terra/siderend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,6 @@ void regRender(int LowX,int LowY,int HiX,int HiY,int changed)
int SizeX = (0 == XCYCL(HiX - LowX)) ? H_SIZE : XCYCL(HiX - LowX);


vMap->request_region_update({
.x = LowX,
.y = LowY,
.width = SizeX,
.height = SizeY,
});

int BackScanLen = 0;
int j;
for(j = 0;j < SizeY;j++){
Expand Down Expand Up @@ -634,6 +627,7 @@ void regRender(int LowX,int LowY,int HiX,int HiY,int changed)
if(CurrScanLenght > BackScanLen) BackScanLen = CurrScanLenght;
}
}
vMap->request_region_update(LowX, LowY, LowX + SizeX, LowY + SizeY);
}

//znfo render
Expand Down
19 changes: 13 additions & 6 deletions src/terra/vmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,6 @@ void vrtMap::accept(int up,int down)
uchar* p;
int off;

auto& r = renderer::scene::RenderingContext::renderer();

if(!isCompressed)
do {
freeMax--;
Expand All @@ -1162,7 +1160,6 @@ void vrtMap::accept(int up,int down)
lineTcolor[i] = use_c();
//TODO: Move LINE_render to the SoftwareRenderer implementation
LINE_render(i);
request_region_update({0, i, H_SIZE, 1});
i = YCYCL(i + 1);
} while(i != max);
else
Expand All @@ -1188,10 +1185,10 @@ void vrtMap::accept(int up,int down)
#endif
//TODO: Move LINE_render to the SoftwareRenderer implementation
LINE_render(i);
request_region_update({0, i, H_SIZE, 1});
i = YCYCL(i + 1);
} while(i != max);

request_region_update(0, up, H_SIZE, down);
upLine = up;
downLine = down;
preViewY = ViewY;
Expand Down Expand Up @@ -1440,8 +1437,18 @@ void vrtMap::quant(void)
change(ytop,ybottom);
}

void vrtMap::request_region_update(const renderer::Rect &rect)
void vrtMap::request_region_update(int32_t left, int32_t bottom, int32_t right, int32_t top)
{
renderer::Rect rect {
.x = left,
.y = bottom,
.width = right - left,
.height = top - bottom,
};

rect.width = std::ceil(rect.width / 256.0) * 256;
rect.height = std::floor(rect.height / 4.0) * 4;

renderer::scene::RenderingContext::renderer()->map_request_update(rect);
}

Expand Down Expand Up @@ -1602,12 +1609,12 @@ if (NetworkON && zMod_flood_level_delta!=0) {

lineT[i] = p; //znfo lineT compressed //догрузка
lineTcolor[i] = use_c();
request_region_update({0, i, H_SIZE, 1});
LINE_render(i);
#endif
}
i = YCYCL(i + d);
} while(i != max);
request_region_update(0, up, H_SIZE, down);
}

void vrtMap::delink(int up, int down)
Expand Down
2 changes: 1 addition & 1 deletion src/terra/vmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct vrtMap {
void quant(void);

// TODO: merge with void request(int up,int down,int left, int right)
void request_region_update(const renderer::Rect& rect);
void request_region_update(int32_t left, int32_t bottom, int32_t right, int32_t top);
void link(int up,int down,int d);
void linkC(int up,int down,int d);
void delink(int up,int down);
Expand Down

0 comments on commit 20a840d

Please sign in to comment.