-
Notifications
You must be signed in to change notification settings - Fork 19
SurfaceTracker cleanup (WIP) #100
base: MC_1.17
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 |
---|---|---|
|
@@ -224,7 +224,13 @@ public void onEnteringFeaturesStatus() { | |
} | ||
} | ||
|
||
lightHeightmap.loadCube(((CubicServerLevel) this.levelHeightAccessor).getHeightmapStorage(), this); | ||
SurfaceTrackerLeaf lightLeaf = lightHeightmap.loadCube(((CubicServerLevel) this.levelHeightAccessor).getHeightmapStorage(), this, null); | ||
int heightmapIndex = dx + dz * DIAMETER_IN_SECTIONS; | ||
|
||
if (lightLeaf == null) | ||
System.out.println("!"); | ||
|
||
this.lightHeightmaps[heightmapIndex] = lightLeaf; | ||
|
||
for (int z = 0; z < SECTION_DIAMETER; z++) { | ||
for (int x = 0; x < SECTION_DIAMETER; x++) { | ||
|
@@ -240,19 +246,6 @@ public void onEnteringFeaturesStatus() { | |
} | ||
} | ||
|
||
@Override | ||
public void sectionLoaded(@Nonnull SurfaceTrackerLeaf surfaceTrackerLeaf, int localSectionX, int localSectionZ) { | ||
int idx = localSectionX + localSectionZ * DIAMETER_IN_SECTIONS; | ||
|
||
if (surfaceTrackerLeaf.getRawType() == -1) { //light | ||
this.lightHeightmaps[idx] = surfaceTrackerLeaf; | ||
} else { // normal heightmap | ||
this.heightmaps.computeIfAbsent(surfaceTrackerLeaf.getType(), | ||
type -> new SurfaceTrackerLeaf[DIAMETER_IN_SECTIONS * DIAMETER_IN_SECTIONS] | ||
)[idx] = surfaceTrackerLeaf; | ||
} | ||
} | ||
|
||
@Override | ||
public void unloadNode(@Nonnull HeightmapStorage storage) { | ||
for (SurfaceTrackerLeaf[] heightmapLeaves : this.heightmaps.values()) { | ||
|
@@ -368,11 +361,9 @@ private SurfaceTrackerLeaf[] getHeightmapSections(Heightmap.Types type) { | |
for (int dx = 0; dx < CubeAccess.DIAMETER_IN_SECTIONS; dx++) { | ||
for (int dz = 0; dz < CubeAccess.DIAMETER_IN_SECTIONS; dz++) { | ||
int idx = dx + dz * CubeAccess.DIAMETER_IN_SECTIONS; | ||
SurfaceTrackerLeaf leaf = new SurfaceTrackerLeaf(cubePos.getY(), null, (byte) type.ordinal()); | ||
leaf.loadCube(dx, dz, ((CubicServerLevel) ((ServerLevelAccessor) this.levelHeightAccessor).getLevel()).getHeightmapStorage(), this); | ||
SurfaceTrackerLeaf leaf = new SurfaceTrackerLeaf(this, null, (byte) type.ordinal()); | ||
// On creation of a new node for a cube, both the node and its parents must be marked dirty | ||
leaf.setAllDirty(); | ||
leaf.markAncestorsDirty(); | ||
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. leaf is an unattached SurfaceTrackerLeaf. There is no point in calling "markAncestorsDirty" as it does not have any. 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. iirc this is used elsewhere too. It's really a "mark any positions dirty if they are below the new height in myself and ancestors" 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. setAllDirty() already sets everything within the leaf dirty without any checks. markAncestorsDirty() doesn't have any additional effect. |
||
surfaceTrackerLeaves[idx] = leaf; | ||
} | ||
} | ||
|
@@ -539,6 +530,10 @@ public int getHighestLight(int x, int z) { | |
int zSection = blockToCubeLocalSection(z); | ||
|
||
int idx = xSection + zSection * DIAMETER_IN_SECTIONS; | ||
|
||
if (this.lightHeightmaps[idx] == null) | ||
System.out.println("!"); | ||
|
||
SurfaceTrackerLeaf sectionAbove = this.lightHeightmaps[idx].getSectionAbove(); | ||
|
||
int dy = CubeAccess.DIAMETER_IN_BLOCKS - 1; | ||
|
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.
This logic was partly duplicated between the promotion constructor and postLoad. I moved all of it into the promotion constructor for now.