Skip to content

Commit

Permalink
recycle VBO for Light Level Overlays whenever the count "goes down" .
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Aug 11, 2024
1 parent 86f76fc commit 27bff45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ author = masa
mod_file_name = minihud-fabric

# Current mod version
mod_version = 0.31.999-sakura.22
mod_version = 0.31.999-sakura.23

# Required malilib version
malilib_version = 0.20.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ public void update(Vec3d cameraPos, Entity entity, MinecraftClient mc)
this.allocateGlResources();
this.wasEmpty = false;
}
else if (lastSize - this.lightInfos.size() > 0)
{
// A bit extreme, but this gets rid of the VBO when the count goes down; so there are no more 'Ghost' renders.
// I believe this happens whenever we use STATIC VBO buffers.
this.deleteGlResources();
this.allocateGlResources();
}

RenderObjectBase renderQuads = this.renderObjects.get(0);
RenderObjectBase renderLines = this.renderObjects.get(1);
Expand All @@ -129,8 +136,8 @@ public void update(Vec3d cameraPos, Entity entity, MinecraftClient mc)
this.wasEmpty = true;
}

//long pre = System.nanoTime();
//System.out.printf("LL markers: %d, time: %.3f s\n", this.lightInfos.size(), (double) (System.nanoTime() - pre) / 1000000000D);
long pre = System.nanoTime();
System.out.printf("LL markers: %d, time: %.3f s\n", this.lightInfos.size(), (double) (System.nanoTime() - pre) / 1000000000D);

this.lastUpdatePos = pos;
this.lastDirection = entity.getHorizontalFacing();
Expand Down Expand Up @@ -488,7 +495,7 @@ private boolean updateLightLevels(World world, BlockPos center)
}
}

return this.lightInfos.isEmpty() == false && this.lightInfos.size() > 0;
return this.lightInfos.isEmpty() == false;
}

private boolean canSpawnAtWrapper(int x, int y, int z, Chunk chunk, World world, boolean skipBlockCheck)
Expand Down Expand Up @@ -573,10 +580,10 @@ else if (state.isIn(BlockTags.PREVENT_MOB_SPAWNING_INSIDE))

public static class LightLevelInfo
{
public final long pos;
public final byte block;
public final byte sky;
public final float y;
public long pos;
public byte block;
public byte sky;
public float y;

public LightLevelInfo(long pos, float y, int block, int sky)
{
Expand Down

0 comments on commit 27bff45

Please sign in to comment.