Skip to content

Commit

Permalink
Add a new Locs option to disable Loc loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed May 4, 2024
1 parent b0478a8 commit 0d8616d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/mapviewer/webgl/WebGLMapViewerRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
msaaEnabled: boolean = false;
fxaaEnabled: boolean = false;

loadObjs: boolean = true;
loadNpcs: boolean = true;
loadObjs: boolean = false;
loadNpcs: boolean = false;
loadLocs: boolean = false;

// State
lastClientTick: number = 0;
Expand Down Expand Up @@ -618,6 +619,12 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
this.setLoadNpcs(v);
},
},
Locs: {
value: this.loadLocs,
onChange: (v: boolean) => {
this.setLoadLocs(v);
},
},
},
{ collapsed: true },
),
Expand All @@ -635,6 +642,7 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
maxLevel: this.maxLevel,
loadObjs: this.loadObjs,
loadNpcs: this.loadNpcs,
loadLocs: this.loadLocs,
smoothTerrain: this.smoothTerrain,
minimizeDrawCalls: !this.hasMultiDraw,
loadedTextureIds: this.loadedTextureIds,
Expand Down Expand Up @@ -699,6 +707,7 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
mapData.maxLevel === this.maxLevel &&
mapData.loadObjs === this.loadObjs &&
mapData.loadNpcs === this.loadNpcs &&
mapData.loadLocs === this.loadLocs &&
mapData.smoothTerrain === this.smoothTerrain
);
}
Expand Down Expand Up @@ -758,6 +767,13 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
}
}

setLoadLocs(enabled: boolean): void {
const updated = this.loadLocs !== enabled;
this.loadLocs = enabled;
if (updated) {
this.clearMaps();
}
}
override onResize(width: number, height: number): void {
this.app.resize(width, height);
}
Expand Down
1 change: 1 addition & 0 deletions src/mapviewer/webgl/loader/SdMapData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type SdMapData = {
maxLevel: number;
loadObjs: boolean;
loadNpcs: boolean;
loadLocs: boolean;

smoothTerrain: boolean;

Expand Down
14 changes: 10 additions & 4 deletions src/mapviewer/webgl/loader/SdMapDataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { createNpcDatas } from "../npc/NpcData";
import { NpcSpawnGroup } from "../npc/NpcSpawnGroup";
import { SdMapData } from "./SdMapData";
import { SdMapLoaderInput } from "./SdMapLoaderInput";
import { LocAnimatedData } from "../loc/LocAnimatedData";

function loadHeightMapTextureData(scene: Scene): Int16Array {
const heightMapTextureData = new Int16Array(Scene.MAX_LEVELS * scene.sizeX * scene.sizeY);
Expand Down Expand Up @@ -557,6 +558,7 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
maxLevel,
loadObjs,
loadNpcs,
loadLocs,
smoothTerrain,
minimizeDrawCalls,
loadedTextureIds,
Expand Down Expand Up @@ -614,11 +616,14 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
createObjSceneModels(objModelLoader, sceneModels, scene, borderSize, objSpawns);
}

addSceneModels(this.modelHashBuf!, textureLoader, sceneBuf, sceneModels, minimizeDrawCalls);
let locsAnimated: LocAnimatedData[] = [];
if (loadLocs) {
addSceneModels(this.modelHashBuf!, textureLoader, sceneBuf, sceneModels, minimizeDrawCalls);

// Animated locs
const locsAnimated = sceneBuf.addLocAnimatedGroups(locAnimatedGroups);
console.log(`animated locs: ${locsAnimated.length}`);
// Animated locs
locsAnimated = sceneBuf.addLocAnimatedGroups(locAnimatedGroups);
console.log(`animated locs: ${locsAnimated.length}`);
}

// Npcs

Expand Down Expand Up @@ -784,6 +789,7 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
maxLevel,
loadObjs,
loadNpcs,
loadLocs,

smoothTerrain,

Expand Down
1 change: 1 addition & 0 deletions src/mapviewer/webgl/loader/SdMapLoaderInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type SdMapLoaderInput = {
maxLevel: number;
loadObjs: boolean;
loadNpcs: boolean;
loadLocs: boolean;

smoothTerrain: boolean;

Expand Down

0 comments on commit 0d8616d

Please sign in to comment.