BlueGit

timfa questward

Skip spell cast and impact dynamic lighting on the client.

Avoid lightmap rebakes from cast flashes and tile spell lights; projectiles and lantern light are unchanged.

timfa Tim Falken · pushed by timfa

Authored 2026-08-28 · 2 months ago

Hash
6addf874184502f2ef9fde215ef4684af6525603
Parent
4c807ba3
2 files changed +2 −58
client/src/play/main.js +0 −4
@@ -1348,14 +1348,10 @@ async function main ()
1348 1348 { toasts?.show("Failed to cast spell"); }
1349 1349 break;
1350 1350 case MessageType.spellCastFlash:
1351 view?.spawnSpellCastFlash(message);
1352 1351 break;
1353 1352 case MessageType.spellLightAppear:
1354 1353 case MessageType.spellLightUpdate:
1355 view?.setSpellLight(message);
1356 break;
1357 1354 case MessageType.spellLightRemove:
1358 view?.removeSpellLight(message);
1359 1355 break;
1360 1356 case MessageType.stamina:
1361 1357 staminaUi?.apply(message);
@@ -1348,14 +1348,10 @@ async function main ()
1348 { toasts?.show("Failed to cast spell"); }
1348 { toasts?.show("Failed to cast spell"); }
1349 break;
1349 break;
1350 case MessageType.spellCastFlash:
1350 case MessageType.spellCastFlash:
1351 view?.spawnSpellCastFlash(message);
1352 break;
1351 break;
1353 case MessageType.spellLightAppear:
1352 case MessageType.spellLightAppear:
1354 case MessageType.spellLightUpdate:
1353 case MessageType.spellLightUpdate:
1355 view?.setSpellLight(message);
1356 break;
1357 case MessageType.spellLightRemove:
1354 case MessageType.spellLightRemove:
1358 view?.removeSpellLight(message);
1359 break;
1355 break;
1360 case MessageType.stamina:
1356 case MessageType.stamina:
1361 staminaUi?.apply(message);
1357 staminaUi?.apply(message);
client/src/render/worldView.js +2 −54
@@ -413,7 +413,6 @@ export class WorldView
413 413 this.nightPreview = null;
414 414 this.followPlayer = true;
415 415 this.dynamicLights = [];
416 this.spellLights = new Map();
417 416 this.swipes = [];
418 417 this.damageFloats = [];
419 418 this.damageNumbersEl = document.getElementById("damage-numbers");
@@ -1503,44 +1502,9 @@ export class WorldView
1503 1502 });
1504 1503 }
1505 1504
1506 spawnSpellFizzleFx (payload)
1505 spawnSpellFizzleFx (_payload)
1507 1506 {
1508 this.spawnSpellCastFlash({
1509 tileX: payload.tileX,
1510 tileY: payload.tileY,
1511 radiusTiles: 0.5,
1512 durationMs: 220,
1513 tier: 1
1514 });
1515 }
1516
1517 spawnSpellCastFlash (payload)
1518 {
1519 const pivot = tilePivot(payload.tileX, payload.tileY, this.tileSize());
1520 this.addDynamicLight({
1521 worldX: pivot.x,
1522 worldY: pivot.y,
1523 radiusTiles: payload.radiusTiles ?? 1,
1524 intensity: 0.55 + (payload.tier ?? 1) * 0.12,
1525 durationMs: payload.durationMs ?? 500
1526 });
1527 }
1528
1529 setSpellLight (payload)
1530 {
1531 const key = `${payload.tileX},${payload.tileY}`;
1532 this.spellLights.set(key, {
1533 tileX: payload.tileX,
1534 tileY: payload.tileY,
1535 until: performance.now() + Math.max(0, payload.remainingMs ?? 0),
1536 range: payload.rangeTiles ?? 6,
1537 intensity: payload.intensity ?? 0.88
1538 });
1539 }
1540
1541 removeSpellLight (payload)
1542 {
1543 this.spellLights.delete(`${payload.tileX},${payload.tileY}`);
1507 // Visual-only fizzle; no dynamic light (too expensive for lightmap rebakes).
1544 1508 }
1545 1509
1546 1510 #spellProjectileImage (baseSprite, frameIndex)
@@ -3053,22 +3017,6 @@ export class WorldView
3053 3017 this.dynamicLights = this.dynamicLights.filter((light) => light.until > now);
3054 3018
3055 3019 const activeLights = [...this.dynamicLights];
3056 for (const light of this.spellLights.values())
3057 {
3058 if (light.until <= now)
3059 { continue; }
3060 activeLights.push({
3061 tileX: light.tileX,
3062 tileY: light.tileY,
3063 range: light.range,
3064 intensity: light.intensity
3065 });
3066 }
3067 for (const key of [...this.spellLights.keys()])
3068 {
3069 if (this.spellLights.get(key).until <= now)
3070 { this.spellLights.delete(key); }
3071 }
3072 3020 const tileSize = this.tileSize();
3073 3021 const blindLight = this.#blindVisionLight();
3074 3022 if (blindLight)
@@ -413,7 +413,6 @@ export class WorldView
413 this.nightPreview = null;
413 this.nightPreview = null;
414 this.followPlayer = true;
414 this.followPlayer = true;
415 this.dynamicLights = [];
415 this.dynamicLights = [];
416 this.spellLights = new Map();
417 this.swipes = [];
416 this.swipes = [];
418 this.damageFloats = [];
417 this.damageFloats = [];
419 this.damageNumbersEl = document.getElementById("damage-numbers");
418 this.damageNumbersEl = document.getElementById("damage-numbers");
@@ -1503,44 +1502,9 @@ export class WorldView
1503 });
1502 });
1504 }
1503 }
1505
1504
1506 spawnSpellFizzleFx (payload)
1505 spawnSpellFizzleFx (_payload)
1507 {
1506 {
1508 this.spawnSpellCastFlash({
1507 // Visual-only fizzle; no dynamic light (too expensive for lightmap rebakes).
1509 tileX: payload.tileX,
1510 tileY: payload.tileY,
1511 radiusTiles: 0.5,
1512 durationMs: 220,
1513 tier: 1
1514 });
1515 }
1516
1517 spawnSpellCastFlash (payload)
1518 {
1519 const pivot = tilePivot(payload.tileX, payload.tileY, this.tileSize());
1520 this.addDynamicLight({
1521 worldX: pivot.x,
1522 worldY: pivot.y,
1523 radiusTiles: payload.radiusTiles ?? 1,
1524 intensity: 0.55 + (payload.tier ?? 1) * 0.12,
1525 durationMs: payload.durationMs ?? 500
1526 });
1527 }
1528
1529 setSpellLight (payload)
1530 {
1531 const key = `${payload.tileX},${payload.tileY}`;
1532 this.spellLights.set(key, {
1533 tileX: payload.tileX,
1534 tileY: payload.tileY,
1535 until: performance.now() + Math.max(0, payload.remainingMs ?? 0),
1536 range: payload.rangeTiles ?? 6,
1537 intensity: payload.intensity ?? 0.88
1538 });
1539 }
1540
1541 removeSpellLight (payload)
1542 {
1543 this.spellLights.delete(`${payload.tileX},${payload.tileY}`);
1544 }
1508 }
1545
1509
1546 #spellProjectileImage (baseSprite, frameIndex)
1510 #spellProjectileImage (baseSprite, frameIndex)
@@ -3053,22 +3017,6 @@ export class WorldView
3053 this.dynamicLights = this.dynamicLights.filter((light) => light.until > now);
3017 this.dynamicLights = this.dynamicLights.filter((light) => light.until > now);
3054
3018
3055 const activeLights = [...this.dynamicLights];
3019 const activeLights = [...this.dynamicLights];
3056 for (const light of this.spellLights.values())
3057 {
3058 if (light.until <= now)
3059 { continue; }
3060 activeLights.push({
3061 tileX: light.tileX,
3062 tileY: light.tileY,
3063 range: light.range,
3064 intensity: light.intensity
3065 });
3066 }
3067 for (const key of [...this.spellLights.keys()])
3068 {
3069 if (this.spellLights.get(key).until <= now)
3070 { this.spellLights.delete(key); }
3071 }
3072 const tileSize = this.tileSize();
3020 const tileSize = this.tileSize();
3073 const blindLight = this.#blindVisionLight();
3021 const blindLight = this.#blindVisionLight();
3074 if (blindLight)
3022 if (blindLight)