Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions src/main/java/rs117/hd/opengl/GLState.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package rs117.hd.opengl;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import rs117.hd.utils.collection.IntHashSet;

public abstract class GLState {
protected boolean hasValue;
Expand Down Expand Up @@ -134,7 +133,7 @@ void internalApply() {
}

public abstract static class IntSet extends GLState {
private final Set<Integer> targets = new HashSet<>();
private final IntHashSet targets = new IntHashSet();

public void add(int target) {
hasValue = true;
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/rs117/hd/renderer/legacy/LegacySceneUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,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 @@ -708,23 +708,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.vertexIsWater.contains(swVertexKey) && sceneContext.vertexIsLand.contains(swVertexKey))
swColor = 0;
if (sceneContext.vertexIsWater.containsKey(seVertexKey) && sceneContext.vertexIsLand.containsKey(seVertexKey))
if (sceneContext.vertexIsWater.contains(seVertexKey) && sceneContext.vertexIsLand.contains(seVertexKey))
seColor = 0;
if (sceneContext.vertexIsWater.containsKey(nwVertexKey) && sceneContext.vertexIsLand.containsKey(nwVertexKey))
if (sceneContext.vertexIsWater.contains(nwVertexKey) && sceneContext.vertexIsLand.contains(nwVertexKey))
nwColor = 0;
if (sceneContext.vertexIsWater.containsKey(neVertexKey) && sceneContext.vertexIsLand.containsKey(neVertexKey))
if (sceneContext.vertexIsWater.contains(neVertexKey) && sceneContext.vertexIsLand.contains(neVertexKey))
neColor = 0;
}

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


Expand Down Expand Up @@ -1065,19 +1065,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.vertexIsWater.contains(vertexKeyA) && sceneContext.vertexIsLand.contains(vertexKeyA))
colorA = 0;
if (sceneContext.vertexIsWater.containsKey(vertexKeyB) && sceneContext.vertexIsLand.containsKey(vertexKeyB))
if (sceneContext.vertexIsWater.contains(vertexKeyB) && sceneContext.vertexIsLand.contains(vertexKeyB))
colorB = 0;
if (sceneContext.vertexIsWater.containsKey(vertexKeyC) && sceneContext.vertexIsLand.containsKey(vertexKeyC))
if (sceneContext.vertexIsWater.contains(vertexKeyC) && sceneContext.vertexIsLand.contains(vertexKeyC))
colorC = 0;
}

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

for (int i = 0; i < 3; i++)
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/rs117/hd/renderer/zone/SceneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
Expand All @@ -32,6 +30,7 @@
import rs117.hd.scene.areas.Area;
import rs117.hd.utils.NpcDisplacementCache;
import rs117.hd.utils.RenderState;
import rs117.hd.utils.collection.Int2IntHashMap;
import rs117.hd.utils.jobs.GenericJob;

import static net.runelite.api.Constants.*;
Expand Down Expand Up @@ -86,14 +85,13 @@ public class SceneManager {
private RenderState renderState;
private UBOWorldViews uboWorldViews;

private final Int2IntHashMap nextRoofChanges = new Int2IntHashMap();
@Getter
private final WorldViewContext root = new WorldViewContext(null, null, null);
private final WorldViewContext[] subs = new WorldViewContext[MAX_WORLDVIEWS];

private final Map<Integer, Integer> nextRoofChanges = new HashMap<>();
private final List<SortedZone> sortedZones = new ArrayList<>();
private ZoneSceneContext nextSceneContext;
private Zone[][] nextZones;
private final List<SortedZone> sortedZones = new ArrayList<>();
private boolean reloadRequested;

public boolean isZoneStreamingEnabled() {
Expand Down Expand Up @@ -324,7 +322,7 @@ private static boolean isEdgeTile(Zone[][] zones, int zx, int zz) {
@Getter
private final GenericJob generateSceneDataTask = GenericJob.build(
"ProceduralGenerator::generateSceneData",
(task) -> proceduralGenerator.generateSceneData(nextSceneContext != null ? nextSceneContext : root.sceneContext)
(task) -> proceduralGenerator.generateSceneData(nextSceneContext != null ? nextSceneContext : root.sceneContext, root.sceneContext)
);

@Getter
Expand Down Expand Up @@ -359,11 +357,14 @@ private static boolean isEdgeTile(Zone[][] zones, int zx, int zz) {
int prid = prids[level][ox][oz];
int nrid = nrids[level][x][z];
if (prid > 0 && nrid > 0 && prid != nrid) {
Integer old = nextRoofChanges.putIfAbsent(prid, nrid);
if (old == null) {
boolean hasExisting = nextRoofChanges.putIfAbsent(prid, nrid);
if(hasExisting) {
int old = nextRoofChanges.getOrDefault(prid, nrid);
if (old != nrid) {
log.debug("Roof change mismatch: {} -> {} vs {}", prid, nrid, old);
}
} else {
log.trace("Roof change: {} -> {}", prid, nrid);
} else if (old != nrid) {
log.debug("Roof change mismatch: {} -> {} vs {}", prid, nrid, old);
}
}
}
Expand Down Expand Up @@ -704,7 +705,7 @@ private void loadSubScene(WorldView worldView, Scene scene) {
}

var sceneContext = new ZoneSceneContext(client, worldView, scene, plugin.getExpandedMapLoadingChunks(), null);
proceduralGenerator.generateSceneData(sceneContext);
proceduralGenerator.generateSceneData(sceneContext, null);

final WorldViewContext ctx = new WorldViewContext(worldView, sceneContext, uboWorldViews);
ctx.initialize(renderState, injector);
Expand Down
Loading