Skip to content

Commit

Permalink
Make lods appear immediately in all sections
Browse files Browse the repository at this point in the history
  • Loading branch information
semyon422 committed May 30, 2024
1 parent 4d4f39b commit c0ce829
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.20.4+build.1
loader_version=0.15.1

# Mod Properties
mod_version = 0.1.5-alpha-29052024-1
mod_version = 0.1.5-alpha-30052024
maven_group = me.cortex
archives_base_name = voxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.cortex.voxy.common.world.WorldSection;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Direction;
import me.cortex.voxy.client.core.util.AbyssUtil;

import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -163,21 +164,32 @@ public void add(int lvl, int x, int y, int z) {

//Called by the world engine when a section gets dirtied
public void sectionUpdated(WorldSection section) {
if (this.contains(section.key)) {
int lvl = section.lvl;
int x = section.x;
int y = section.y;
int z = section.z;

int section_n = AbyssUtil.getSection(x * 32);
x -= section_n * 512;
y -= section_n * 16;

long key = WorldEngine.getWorldSectionId(lvl, x, y, z);

if (this.contains(key)) {
//TODO:FIXME: if the section gets updated, that means that its neighbors might need to be updated aswell
// (due to block occlusion)

//TODO: FIXME: REBUILDING THE ENTIRE NEIGHBORS when probably only the internal layout changed is NOT SMART
this.renderGen.clearCache(section.lvl, section.x, section.y, section.z);
this.renderGen.clearCache(section.lvl, section.x-1, section.y, section.z);
this.renderGen.clearCache(section.lvl, section.x+1, section.y, section.z);
this.renderGen.clearCache(section.lvl, section.x, section.y, section.z-1);
this.renderGen.clearCache(section.lvl, section.x, section.y, section.z+1);
this.renderGen.enqueueTask(section.lvl, section.x, section.y, section.z, this::shouldStillBuild);
this.renderGen.enqueueTask(section.lvl, section.x-1, section.y, section.z, this::shouldStillBuild);
this.renderGen.enqueueTask(section.lvl, section.x+1, section.y, section.z, this::shouldStillBuild);
this.renderGen.enqueueTask(section.lvl, section.x, section.y, section.z-1, this::shouldStillBuild);
this.renderGen.enqueueTask(section.lvl, section.x, section.y, section.z+1, this::shouldStillBuild);
this.renderGen.clearCache(lvl, x, y, z);
this.renderGen.clearCache(lvl, x-1, y, z);
this.renderGen.clearCache(lvl, x+1, y, z);
this.renderGen.clearCache(lvl, x, y, z-1);
this.renderGen.clearCache(lvl, x, y, z+1);
this.renderGen.enqueueTask(lvl, x, y, z, this::shouldStillBuild);
this.renderGen.enqueueTask(lvl, x-1, y, z, this::shouldStillBuild);
this.renderGen.enqueueTask(lvl, x+1, y, z, this::shouldStillBuild);
this.renderGen.enqueueTask(lvl, x, y, z-1, this::shouldStillBuild);
this.renderGen.enqueueTask(lvl, x, y, z+1, this::shouldStillBuild);
}
//this.renderGen.enqueueTask(section);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MixinClientChunkManager {
private void injectUnload(ChunkPos pos, CallbackInfo ci, int index, WorldChunk worldChunk) {
var core = ((IGetVoxelCore)(world.worldRenderer)).getVoxelCore();
if (core != null && VoxyConfig.CONFIG.ingestEnabled) {
core.enqueueIngest(worldChunk);
// core.enqueueIngest(worldChunk);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
public class MixinRenderSectionManager {
@Shadow @Final private ClientWorld world;

@Inject(method = "onChunkRemoved", at = @At("HEAD"))
@Inject(method = "onChunkAdded", at = @At("HEAD"))
private void injectIngest(int x, int z, CallbackInfo ci) {
var core = ((IGetVoxelCore)(world.worldRenderer)).getVoxelCore();
if (core != null && VoxyConfig.CONFIG.ingestEnabled) {
// core.enqueueIngest(world.getChunk(x, z));
core.enqueueIngest(world.getChunk(x, z));
}
}
}

0 comments on commit c0ce829

Please sign in to comment.