Update LocalWorld.cpp
cleanup
This commit is contained in:
@@ -46,33 +46,24 @@ namespace CaveGame::Client {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LocalWorld::CheckCachedChunkSprites()
|
||||
{
|
||||
void LocalWorld::CheckCachedChunkSprites() {
|
||||
for (auto& [chunk_pos, chunk] : loaded_chunks) {
|
||||
if (IsChunkCellWithinViewport(chunk_pos))
|
||||
{
|
||||
// No rendertarget for this chunk.
|
||||
if (!cached_chunk_sprites.contains(chunk_pos))
|
||||
{
|
||||
chunk->touched = false;
|
||||
auto* target = new JGL::RenderTarget(
|
||||
{Core::Chunk::ChunkSize, Core::Chunk::ChunkSize},
|
||||
{0,0,0,0}, // TODO: Side effect when try to pass Colors::Transparent
|
||||
false,
|
||||
JGL::SampleRate::NONE,
|
||||
JGL::FilteringMode::MIPMAP_NEAREST);
|
||||
RenderChunkTexture(chunk_pos, target, chunk);
|
||||
cached_chunk_sprites.insert({chunk_pos, target});
|
||||
}
|
||||
// rendertarget needs updating.
|
||||
else if (chunk->touched) {
|
||||
chunk->touched = false;
|
||||
auto* target = cached_chunk_sprites[chunk_pos];
|
||||
RenderChunkTexture(chunk_pos, target, chunk);
|
||||
}
|
||||
if (!IsChunkCellWithinViewport(chunk_pos))
|
||||
continue;
|
||||
|
||||
auto it = cached_chunk_sprites.find(chunk_pos);
|
||||
if (it != cached_chunk_sprites.end()) {
|
||||
if (!chunk->touched)
|
||||
continue;
|
||||
|
||||
chunk->touched = false;
|
||||
RenderChunkTexture(chunk_pos, it->second, chunk);
|
||||
}
|
||||
|
||||
auto* chunk_sprite = new RenderTarget(Vector2i(Chunk::ChunkSize), Colors::Transparent,false,
|
||||
SampleRate::NONE, FilteringMode::MIPMAP_NEAREST);
|
||||
RenderChunkTexture(chunk_pos, chunk_sprite, chunk);
|
||||
cached_chunk_sprites.insert({chunk_pos, chunk_sprite});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +78,7 @@ namespace CaveGame::Client {
|
||||
|
||||
return Color4::Lerp(color_low, color_high, delta);
|
||||
}
|
||||
|
||||
Color4 LocalWorld::GetSkyColorBaseForTimeOfDay(float time) {
|
||||
if (time >= 23*60)
|
||||
return Colors::Black;
|
||||
|
Reference in New Issue
Block a user