Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c249472
Reduce Allocations & Unnecessary repeated calculations
RuffledPlume Apr 24, 2026
1e89ba8
Formatting & Improvements
RuffledPlume Apr 24, 2026
80f0786
Swapped HashMap out for Primitive Versions
RuffledPlume Apr 24, 2026
bf18d87
Further Allocation Reduction
RuffledPlume Apr 24, 2026
6a0005d
Combine tileIsWater & skipTile into a flags array
RuffledPlume Apr 24, 2026
4abcf19
Use Primitive Types instead to avoid allocations
RuffledPlume Apr 24, 2026
3a12c9d
ReadCache isn't thread safe, remove it
RuffledPlume Apr 24, 2026
a2d4252
calculateSurfaceNormals performs a cross, out cannot be the same as a…
RuffledPlume Apr 24, 2026
c0254dd
Use PrimitveMap
RuffledPlume Apr 24, 2026
bc70990
Fixed Terrain Normal Calculation
RuffledPlume Apr 24, 2026
f1fa6f8
Calculate worldPos in generateDataForTile for both TilePaint & TileModel
RuffledPlume Apr 24, 2026
1da28ca
Calculate areaBounds which encompasses all aabbs that make up the are…
RuffledPlume Apr 24, 2026
6671e1a
When there are more than 4 AABBs we can sort based on distance from a…
RuffledPlume Apr 24, 2026
e864137
Use prebuild TileOverrides from SceneContext instead of looking up pe…
RuffledPlume Apr 24, 2026
f8291e1
Early out on tiles which aren't marked as water
RuffledPlume Apr 24, 2026
bcb0ab8
Pass tileExX, tileExY & tileZ into uploadStaticModel to avoid recalcu…
RuffledPlume Apr 24, 2026
7517d08
Store GameObjects since calling the getter allocates
RuffledPlume Apr 24, 2026
028f89f
Switch from HashSet to IntHashSet
RuffledPlume Apr 24, 2026
10430fe
Init SceneContext based of PreviousSceneContext Capacity if present
RuffledPlume Apr 24, 2026
8a4fa09
Reuse previous Scene context tileOverrides to speed up proc gen
RuffledPlume Apr 24, 2026
93523bc
Only Clear required amount
RuffledPlume Apr 24, 2026
72d4f2d
CopyTo is overkill for only 3 elements, so do it manually
RuffledPlume Apr 24, 2026
0df3ed9
Handle Bridges when calculating Tile Overrides during proc gen
RuffledPlume Apr 25, 2026
83f4060
Use Vertex Write Cache for more of the Static Zone Upload
RuffledPlume Apr 25, 2026
04c9ae0
Remove Vertex Functions from GPUIntBuffer
RuffledPlume Apr 25, 2026
174243a
Store Underlay/Overlay along with the Main override of Tiles
RuffledPlume Apr 25, 2026
5f2ee78
Reduce memory allocations when iterating through Int2Object KeyVauePairs
RuffledPlume Apr 25, 2026
885e436
Improve MainTileOverridesGenerator further by reducing duplicated cod…
RuffledPlume Apr 25, 2026
7d1ba53
Calculate min/max ranges when calculating water tiles
RuffledPlume Apr 25, 2026
383810d
Remove Redundant arrays
RuffledPlume Apr 25, 2026
b96aa57
Switch From HashMap to Int2Object to reduce allocations
RuffledPlume Apr 25, 2026
ad79353
Track HighTide/LowTide to avoid clearing the whole array unnecessarily
RuffledPlume Apr 26, 2026
acb73bd
Ignore Tiles along the edge of the scene
RuffledPlume Apr 26, 2026
dc623ab
Avoid Allocating GPUIntBuffer
RuffledPlume Apr 26, 2026
423f888
Fixed getTileOverride not using renderLevel
RuffledPlume Apr 26, 2026
914dbbc
Combine the 4 HashSets into a Int2Int Map that contains VertexFlag data
RuffledPlume Apr 26, 2026
c178e83
Merge Underwater Vertex Depth into VertexDepth HashMap
RuffledPlume Apr 26, 2026
e4b25dd
Added compute to Int2InthashMap
RuffledPlume Apr 26, 2026
391b827
Switch to IntPrimitive Collections instead of HashSet & HashMap
RuffledPlume Apr 26, 2026
6002990
Optimizations
RuffledPlume Apr 26, 2026
7e9947b
Reduce Memory Access whilst building underwater terrain
RuffledPlume Apr 26, 2026
46baf26
Convert Terrain normals into short[]
RuffledPlume Apr 26, 2026
b3f5315
Formatting
RuffledPlume Apr 26, 2026
776d533
Fixes
RuffledPlume Apr 26, 2026
6a7d6c6
Remove work around for tileoverride reuse
RuffledPlume Apr 26, 2026
7983bc5
Switch Roof Changes to Int2Int to avoid Integer Allocations
RuffledPlume Apr 26, 2026
f49ec87
Remove GameObject Cache
RuffledPlume Apr 26, 2026
ff9509f
Copy Rebuild flag from previous zone to new zone
RuffledPlume Apr 26, 2026
eb37da4
Tweaks
RuffledPlume Apr 26, 2026
c2d659a
Ignore edge tiles
RuffledPlume Apr 26, 2026
c730e66
Fix getRandomMaterial causing allocations
RuffledPlume Apr 26, 2026
e14cd2b
Micro Optimizations
RuffledPlume Apr 26, 2026
170ae41
ZoneSceneContext doesn't need to store the waterDepthLevels, so moved…
RuffledPlume Apr 26, 2026
6b4e2cf
Micro Optimizations
RuffledPlume Apr 26, 2026
a2035b2
Optimised Undo Vanilla Shading on tiles
RuffledPlume Apr 26, 2026
53bf095
Use a specific Top Level GeneratorContext
RuffledPlume Apr 27, 2026
47b4094
Flatten List<int[]> int a single int[] to avoid fragmenting the heap …
RuffledPlume Apr 27, 2026
4025861
Trim lightspawns once processed to free memory
RuffledPlume Apr 27, 2026
38e2331
Flatten 3D to 1D Arrays to prevent heap fragmentation
RuffledPlume Apr 27, 2026
3afea66
Formatting
RuffledPlume Apr 27, 2026
1f6030e
Optimise tileVerticies & faceVertices
RuffledPlume Apr 28, 2026
fe3179a
Rework TileOverrides to store Indices instead of Object References
RuffledPlume Apr 28, 2026
db29ce9
Moved more Legacy only fields into LegeacySceneContext
RuffledPlume Apr 28, 2026
e32d984
Reduce VertexWriteCache from 128 KB to 8 KB
RuffledPlume Apr 28, 2026
d038d99
Switch to a CharPrimitiveArray for Faces
RuffledPlume Apr 28, 2026
a1f1c25
First Pass on ArrayType Pooling
RuffledPlume Apr 29, 2026
e014bb0
Split ArrayType & FieldDef
RuffledPlume Apr 29, 2026
1642f7d
Refactored inner enum ArrayType to its own file: PooledArrayType
RuffledPlume Apr 29, 2026
b0b4ec6
Tweaks
RuffledPlume Apr 29, 2026
5eadbd5
Use PooledArrayType for TerrainNormals
RuffledPlume Apr 29, 2026
af5b942
Tweaks
RuffledPlume Apr 29, 2026
8ba26ef
Use Pooled Arrays for Visibility, Projected Vertexes and Face Distances
RuffledPlume Apr 29, 2026
1c87530
Improve TileOverride Reuse
RuffledPlume Apr 30, 2026
303605f
Fix PooledArrayType
RuffledPlume Apr 30, 2026
c8eb448
Removed FieldDef
RuffledPlume Apr 30, 2026
f0e79bd
asserts
RuffledPlume Apr 30, 2026
0ccde0f
Fixes
RuffledPlume Apr 30, 2026
fd381f1
Sync
RuffledPlume Apr 30, 2026
0e50d42
Borrow OrderedFaces instead of allocating the max possible value
RuffledPlume Apr 30, 2026
aab6a4b
fix orderedFaces over requesting
RuffledPlume Apr 30, 2026
648bebe
Optimize FacePriorityStorter
RuffledPlume Apr 30, 2026
141230e
Race Condition Fixes + Cache Size Stats on FrameTimer
RuffledPlume Apr 30, 2026
97b20e1
Rolled back TouchedBuckets & Stamps
RuffledPlume Apr 30, 2026
47cb329
Tweak
RuffledPlume May 1, 2026
7d25178
Fixed Redundant bitmask
RuffledPlume May 1, 2026
27d7e8d
Implemented PooledObjectArray
RuffledPlume May 1, 2026
4388c70
FacePriority LinkedList now uses PooledArrays rather than being a fix…
RuffledPlume May 1, 2026
0a2d3fa
Tweaks
RuffledPlume May 1, 2026
aa93314
Reduced Thread Contention with the Pool by using Stripes indexed base…
RuffledPlume May 1, 2026
7c90b53
Tweak
RuffledPlume May 1, 2026
c6d658d
Tweaks
RuffledPlume May 1, 2026
82dfccd
Clear PooledArrayType on shutdown
RuffledPlume May 1, 2026
e31bf81
Formatting
RuffledPlume May 1, 2026
0171140
Fixed Legacy
RuffledPlume May 2, 2026
d28cf6a
SetVertexIsOverlay should be a or not setBits
RuffledPlume May 2, 2026
5fed50d
Force a PooledArray cleanup to free space for Scene Load
RuffledPlume May 2, 2026
3e7c711
Force Collection & Print Stats before/after + diff
RuffledPlume May 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/rs117/hd/HdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
import rs117.hd.utils.ResourcePath;
import rs117.hd.utils.ShaderRecompile;
import rs117.hd.utils.buffer.GLBuffer;
import rs117.hd.utils.collections.PooledArrayType;
import rs117.hd.utils.jobs.GenericJob;
import rs117.hd.utils.jobs.JobSystem;

Expand Down Expand Up @@ -790,6 +791,7 @@ protected void shutDown() {
materialManager.shutDown();
textureManager.shutDown();

PooledArrayType.shutdown();
DestructibleHandler.flushPendingDestruction(true);

if (awtContext != null)
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/rs117/hd/overlays/FrameTimerOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import rs117.hd.renderer.zone.ZoneRenderer;
import rs117.hd.utils.FrameTimingsRecorder;
import rs117.hd.utils.NpcDisplacementCache;
import rs117.hd.utils.collections.PooledArrayType;
import rs117.hd.utils.jobs.JobSystem;

import static rs117.hd.renderer.zone.SceneManager.MAX_WORLDVIEWS;
Expand Down Expand Up @@ -151,6 +152,11 @@ public Dimension render(Graphics2D g) {
.right(format("%d ns", frameTimer.errorCompensation))
.build());

children.add(LineComponent.builder()
.left("Pooled Array Size:")
.right(formatBytes(PooledArrayType.getCurrentTotalCacheSize()))
.build());

children.add(LineComponent.builder()
.left("Garbage collection count:")
.right(String.valueOf(plugin.getGarbageCollectionCount()))
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/rs117/hd/renderer/legacy/LegacyModelPusher.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class LegacyModelPusher {

private static final int[] ZEROED_INTS = new int[12];

private final int[] tzHaarRecolored = new int[3];
private ModelCache modelCache;

public void startUp() {
Expand Down Expand Up @@ -387,7 +388,7 @@ public void pushModel(
sceneContext.modelPusherResults[1] = texturedFaceCount;
}

private void getNormalDataForFace(SceneContext sceneContext, Model model, @Nonnull ModelOverride modelOverride, int face) {
private void getNormalDataForFace(LegacySceneContext sceneContext, Model model, @Nonnull ModelOverride modelOverride, int face) {
assert packTerrainData(false, 0, WaterType.NONE, 0) == 0;
if (modelOverride.flatNormals || !plugin.configPreserveVanillaNormals && model.getFaceColors3()[face] == -1) {
Arrays.fill(sceneContext.modelFaceNormals, 0);
Expand Down Expand Up @@ -424,7 +425,7 @@ private void getNormalDataForFace(SceneContext sceneContext, Model model, @Nonnu

@SuppressWarnings({ "ReassignedVariable" })
private int[] getFaceVertices(
SceneContext sceneContext,
LegacySceneContext sceneContext,
Tile tile,
int uuid,
Model model,
Expand Down Expand Up @@ -587,13 +588,14 @@ private int[] getFaceVertices(
}

if (plugin.configLegacyTzHaarReskin && modelOverride.tzHaarRecolorType != TzHaarRecolorType.NONE) {
int[] tzHaarRecolored = ProceduralGenerator.recolorTzHaar(
ProceduralGenerator.recolorTzHaar(
modelOverride,
model,
face,
color1,
color2,
color3
color3,
tzHaarRecolored
);
color1 = tzHaarRecolored[0];
color2 = tzHaarRecolored[1];
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/rs117/hd/renderer/legacy/LegacySceneContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import rs117.hd.utils.buffer.GpuFloatBuffer;
import rs117.hd.utils.buffer.GpuIntBuffer;

import static net.runelite.api.Constants.*;
import static rs117.hd.utils.MathUtils.*;

public class LegacySceneContext extends SceneContext {
Expand All @@ -14,11 +15,28 @@ public class LegacySceneContext extends SceneContext {
public boolean isPrepared;
public boolean forceDisableAreaHiding;

public byte[][][] underwaterDepthLevels;

public GpuIntBuffer staticUnorderedModelBuffer;
public GpuIntBuffer stagingBufferVertices;
public GpuFloatBuffer stagingBufferUvs;
public GpuFloatBuffer stagingBufferNormals;

public int staticVertexCount = 0;
public int staticGapFillerTilesOffset;
public int staticGapFillerTilesVertexCount;
public int staticCustomTilesOffset;
public int staticCustomTilesVertexCount;

// Statistics
public int uniqueModels;

// Model pusher arrays, to avoid simultaneous usage from different threads
public final int[] modelFaceVertices = new int[12];
public final float[] modelFaceUvs = new float[12];
public final float[] modelFaceNormals = new float[12];
public final int[] modelPusherResults = new int[2];

public LegacySceneContext(
Client client,
Scene scene,
Expand All @@ -27,6 +45,8 @@ public LegacySceneContext(
) {
super(client, scene, expandedMapLoadingChunks);

underwaterDepthLevels = new byte[MAX_Z][EXTENDED_SCENE_SIZE][EXTENDED_SCENE_SIZE];

if (previous == null) {
staticUnorderedModelBuffer = new GpuIntBuffer();
stagingBufferVertices = new GpuIntBuffer();
Expand Down
98 changes: 50 additions & 48 deletions src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
import static net.runelite.api.Constants.*;
import static net.runelite.api.Constants.SCENE_SIZE;
import static net.runelite.api.Perspective.*;
import static rs117.hd.scene.SceneContext.TILE_SKIP_FLAG;
import static rs117.hd.scene.SceneContext.TILE_WATER_FLAG;
import static rs117.hd.scene.tile_overrides.TileOverride.NONE;
import static rs117.hd.scene.tile_overrides.TileOverride.OVERLAY_FLAG;
import static rs117.hd.utils.HDUtils.HIDDEN_HSL;
Expand All @@ -68,7 +70,7 @@ public class LegacySceneUploader {
public static final int SCENE_ID_MASK = 0xFFFF;
public static final int EXCLUDED_FROM_SCENE_BUFFER = 0xFFFFFFFF;

private static final int[] UP_NORMAL = { 0, -1, 0 };
private static final short[] UP_NORMAL = { 0, -1, 0 };

@Inject
private Client client;
Expand Down Expand Up @@ -98,7 +100,7 @@ public class LegacySceneUploader {
private LegacyModelPusher modelPusher;

public void upload(LegacySceneContext sceneContext) {
proceduralGenerator.generateSceneData(sceneContext);
proceduralGenerator.generateSceneData(sceneContext, null);

Stopwatch stopwatch = Stopwatch.createStarted();

Expand Down Expand Up @@ -643,10 +645,10 @@ private int[] uploadHDTilePaintSurface(
Material neMaterial = Material.NONE;
Material nwMaterial = Material.NONE;

int[] swNormals = UP_NORMAL;
int[] seNormals = UP_NORMAL;
int[] neNormals = UP_NORMAL;
int[] nwNormals = UP_NORMAL;
short[] swNormals = UP_NORMAL;
short[] seNormals = UP_NORMAL;
short[] neNormals = UP_NORMAL;
short[] nwNormals = UP_NORMAL;

if (waterType == WaterType.NONE) {
if (textureId != -1) {
Expand All @@ -657,10 +659,10 @@ private int[] uploadHDTilePaintSurface(
swMaterial = seMaterial = neMaterial = nwMaterial = material;
}

swNormals = sceneContext.vertexTerrainNormals.getOrDefault(swVertexKey, swNormals);
seNormals = sceneContext.vertexTerrainNormals.getOrDefault(seVertexKey, seNormals);
neNormals = sceneContext.vertexTerrainNormals.getOrDefault(neVertexKey, neNormals);
nwNormals = sceneContext.vertexTerrainNormals.getOrDefault(nwVertexKey, nwNormals);
swNormals = sceneContext.getVertexNormalOrDefault(swVertexKey, new short[3], UP_NORMAL);
seNormals = sceneContext.getVertexNormalOrDefault(seVertexKey, new short[3], UP_NORMAL);
neNormals = sceneContext.getVertexNormalOrDefault(neVertexKey, new short[3], UP_NORMAL);
nwNormals = sceneContext.getVertexNormalOrDefault(nwVertexKey, new short[3], UP_NORMAL);

boolean useBlendedMaterialAndColor =
plugin.configGroundBlending &&
Expand Down Expand Up @@ -707,23 +709,23 @@ private int[] uploadHDTilePaintSurface(
// set colors for the shoreline to create a foam effect in the water shader
swColor = seColor = nwColor = neColor = 127;

if (sceneContext.vertexIsWater.containsKey(swVertexKey) && sceneContext.vertexIsLand.containsKey(swVertexKey))
if (sceneContext.isVertexWater(swVertexKey) && sceneContext.isVertexLand(swVertexKey))
swColor = 0;
if (sceneContext.vertexIsWater.containsKey(seVertexKey) && sceneContext.vertexIsLand.containsKey(seVertexKey))
if (sceneContext.isVertexWater(seVertexKey) && sceneContext.isVertexLand(seVertexKey))
seColor = 0;
if (sceneContext.vertexIsWater.containsKey(nwVertexKey) && sceneContext.vertexIsLand.containsKey(nwVertexKey))
if (sceneContext.isVertexWater(nwVertexKey) && sceneContext.isVertexLand(nwVertexKey))
nwColor = 0;
if (sceneContext.vertexIsWater.containsKey(neVertexKey) && sceneContext.vertexIsLand.containsKey(neVertexKey))
if (sceneContext.isVertexWater(neVertexKey) && sceneContext.isVertexLand(neVertexKey))
neColor = 0;
}

if (sceneContext.vertexIsOverlay.containsKey(neVertexKey) && sceneContext.vertexIsUnderlay.containsKey(neVertexKey))
if (sceneContext.isVertexOverlay(neVertexKey) && sceneContext.isVertexUnderlay(neVertexKey))
neVertexIsOverlay = true;
if (sceneContext.vertexIsOverlay.containsKey(nwVertexKey) && sceneContext.vertexIsUnderlay.containsKey(nwVertexKey))
if (sceneContext.isVertexOverlay(nwVertexKey) && sceneContext.isVertexUnderlay(nwVertexKey))
nwVertexIsOverlay = true;
if (sceneContext.vertexIsOverlay.containsKey(seVertexKey) && sceneContext.vertexIsUnderlay.containsKey(seVertexKey))
if (sceneContext.isVertexOverlay(seVertexKey) && sceneContext.isVertexUnderlay(seVertexKey))
seVertexIsOverlay = true;
if (sceneContext.vertexIsOverlay.containsKey(swVertexKey) && sceneContext.vertexIsUnderlay.containsKey(swVertexKey))
if (sceneContext.isVertexOverlay(swVertexKey) && sceneContext.isVertexUnderlay(swVertexKey))
swVertexIsOverlay = true;

swHeight -= override.heightOffset;
Expand Down Expand Up @@ -829,23 +831,23 @@ private int[] uploadHDTilePaintUnderwater(LegacySceneContext sceneContext, Tile
int nwVertexKey = vertexKeys[2];
int neVertexKey = vertexKeys[3];

if (sceneContext.tileIsWater[tileZ][tileExX][tileExY]) {
if (sceneContext.isTileFlagSet(tileZ, tileExX, tileExY, TILE_WATER_FLAG)) {
// underwater terrain

underwaterTerrain = 1;

int swColor, seColor, neColor, nwColor;
swColor = seColor = neColor = nwColor = UNDERWATER_HSL;

int swDepth = sceneContext.vertexUnderwaterDepth.getOrDefault(swVertexKey, 0);
int seDepth = sceneContext.vertexUnderwaterDepth.getOrDefault(seVertexKey, 0);
int nwDepth = sceneContext.vertexUnderwaterDepth.getOrDefault(nwVertexKey, 0);
int neDepth = sceneContext.vertexUnderwaterDepth.getOrDefault(neVertexKey, 0);
int swDepth = sceneContext.getVertexUnderwaterDepth(swVertexKey);
int seDepth = sceneContext.getVertexUnderwaterDepth(seVertexKey);
int nwDepth = sceneContext.getVertexUnderwaterDepth(nwVertexKey);
int neDepth = sceneContext.getVertexUnderwaterDepth(neVertexKey);

int[] swNormals = sceneContext.vertexTerrainNormals.getOrDefault(swVertexKey, UP_NORMAL);
int[] seNormals = sceneContext.vertexTerrainNormals.getOrDefault(seVertexKey, UP_NORMAL);
int[] nwNormals = sceneContext.vertexTerrainNormals.getOrDefault(nwVertexKey, UP_NORMAL);
int[] neNormals = sceneContext.vertexTerrainNormals.getOrDefault(neVertexKey, UP_NORMAL);
short[] swNormals = sceneContext.getVertexNormalOrDefault(swVertexKey, new short[3], UP_NORMAL);
short[] seNormals = sceneContext.getVertexNormalOrDefault(seVertexKey, new short[3], UP_NORMAL);
short[] nwNormals = sceneContext.getVertexNormalOrDefault(nwVertexKey, new short[3], UP_NORMAL);
short[] neNormals = sceneContext.getVertexNormalOrDefault(neVertexKey, new short[3], UP_NORMAL);

Material swMaterial = Material.NONE;
Material seMaterial = Material.NONE;
Expand Down Expand Up @@ -943,7 +945,7 @@ private int[] uploadHDTileModelSurface(
final int tileExY = tileY + sceneContext.sceneOffset;
final int tileZ = tile.getRenderLevel();

if (!fillGaps && sceneContext.skipTile[tileZ][tileExX][tileExY])
if (!fillGaps && sceneContext.isTileFlagSet(tileZ, tileExX, tileExY, TILE_SKIP_FLAG))
return new int[3];

int bufferLength = 0;
Expand Down Expand Up @@ -985,9 +987,9 @@ private int[] uploadHDTileModelSurface(
int uvOrientation = 0;
float uvScale = 1;

int[] normalsA = UP_NORMAL;
int[] normalsB = UP_NORMAL;
int[] normalsC = UP_NORMAL;
short[] normalsA = UP_NORMAL;
short[] normalsB = UP_NORMAL;
short[] normalsC = UP_NORMAL;

WaterType waterType = WaterType.NONE;

Expand All @@ -1013,9 +1015,9 @@ private int[] uploadHDTileModelSurface(
materialA = materialB = materialC = material;
}

normalsA = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyA, normalsA);
normalsB = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyB, normalsB);
normalsC = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyC, normalsC);
normalsA = sceneContext.getVertexNormalOrDefault(vertexKeyA, new short[3], UP_NORMAL);
normalsB = sceneContext.getVertexNormalOrDefault(vertexKeyB, new short[3], UP_NORMAL);
normalsC = sceneContext.getVertexNormalOrDefault(vertexKeyC, new short[3], UP_NORMAL);

GroundMaterial groundMaterial = null;

Expand Down Expand Up @@ -1068,19 +1070,19 @@ private int[] uploadHDTileModelSurface(
} else {
// set colors for the shoreline to create a foam effect in the water shader
colorA = colorB = colorC = 127;
if (sceneContext.vertexIsWater.containsKey(vertexKeyA) && sceneContext.vertexIsLand.containsKey(vertexKeyA))
if (sceneContext.isVertexWater(vertexKeyA) && sceneContext.isVertexLand(vertexKeyA))
colorA = 0;
if (sceneContext.vertexIsWater.containsKey(vertexKeyB) && sceneContext.vertexIsLand.containsKey(vertexKeyB))
if (sceneContext.isVertexWater(vertexKeyB) && sceneContext.isVertexLand(vertexKeyB))
colorB = 0;
if (sceneContext.vertexIsWater.containsKey(vertexKeyC) && sceneContext.vertexIsLand.containsKey(vertexKeyC))
if (sceneContext.isVertexWater(vertexKeyC) && sceneContext.isVertexLand(vertexKeyC))
colorC = 0;
}

if (sceneContext.vertexIsOverlay.containsKey(vertexKeyA) && sceneContext.vertexIsUnderlay.containsKey(vertexKeyA))
if (sceneContext.isVertexOverlay(vertexKeyA) && sceneContext.isVertexUnderlay(vertexKeyA))
vertexAIsOverlay = true;
if (sceneContext.vertexIsOverlay.containsKey(vertexKeyB) && sceneContext.vertexIsUnderlay.containsKey(vertexKeyB))
if (sceneContext.isVertexOverlay(vertexKeyB) && sceneContext.isVertexUnderlay(vertexKeyB))
vertexBIsOverlay = true;
if (sceneContext.vertexIsOverlay.containsKey(vertexKeyC) && sceneContext.vertexIsUnderlay.containsKey(vertexKeyC))
if (sceneContext.isVertexOverlay(vertexKeyC) && sceneContext.isVertexUnderlay(vertexKeyC))
vertexCIsOverlay = true;

for (int i = 0; i < 3; i++)
Expand Down Expand Up @@ -1144,7 +1146,7 @@ private int[] uploadHDTileModelUnderwater(LegacySceneContext sceneContext, Tile
int uvBufferLength = 0;
int underwaterTerrain = 0;

if (sceneContext.skipTile[tileZ][tileExX][tileExY])
if (sceneContext.isTileFlagSet(tileZ, tileExX, tileExY, TILE_SKIP_FLAG))
return new int[] { bufferLength, uvBufferLength, underwaterTerrain };

final int[] faceColorA = model.getTriangleColorA();
Expand All @@ -1159,7 +1161,7 @@ private int[] uploadHDTileModelUnderwater(LegacySceneContext sceneContext, Tile
return new int[] { bufferLength, uvBufferLength, underwaterTerrain };
}

if (sceneContext.tileIsWater[tileZ][tileExX][tileExY]) {
if (sceneContext.isTileFlagSet(tileZ, tileExX, tileExY, TILE_WATER_FLAG)) {
underwaterTerrain = 1;

int overlayId = OVERLAY_FLAG | scene.getOverlayIds()[tileZ][tileExX][tileExY];
Expand Down Expand Up @@ -1188,9 +1190,9 @@ private int[] uploadHDTileModelUnderwater(LegacySceneContext sceneContext, Tile
int vertexKeyB = vertexKeys[1];
int vertexKeyC = vertexKeys[2];

int depthA = sceneContext.vertexUnderwaterDepth.getOrDefault(vertexKeyA, 0);
int depthB = sceneContext.vertexUnderwaterDepth.getOrDefault(vertexKeyB, 0);
int depthC = sceneContext.vertexUnderwaterDepth.getOrDefault(vertexKeyC, 0);
int depthA = sceneContext.getVertexUnderwaterDepth(vertexKeyA);
int depthB = sceneContext.getVertexUnderwaterDepth(vertexKeyB);
int depthC = sceneContext.getVertexUnderwaterDepth(vertexKeyC);

if (plugin.configGroundTextures) {
GroundMaterial groundMaterial = GroundMaterial.UNDERWATER_GENERIC;
Expand All @@ -1211,9 +1213,9 @@ private int[] uploadHDTileModelUnderwater(LegacySceneContext sceneContext, Tile
);
}

int[] normalsA = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyA, UP_NORMAL);
int[] normalsB = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyB, UP_NORMAL);
int[] normalsC = sceneContext.vertexTerrainNormals.getOrDefault(vertexKeyC, UP_NORMAL);
short[] normalsA = sceneContext.getVertexNormalOrDefault(vertexKeyA, new short[3], UP_NORMAL);
short[] normalsB = sceneContext.getVertexNormalOrDefault(vertexKeyB, new short[3], UP_NORMAL);
short[] normalsC = sceneContext.getVertexNormalOrDefault(vertexKeyC, new short[3], UP_NORMAL);

int textureId = faceTextures == null ? -1 : faceTextures[face];
WaterType waterType = proceduralGenerator.seasonalWaterType(override, textureId);
Expand Down
Loading