Setup callbacks so tiles are notified when a light is removed
A secondary callback is setup so the tile it's also removed from the activeTiles, because it's freed in a "non standard" way.
This commit is contained in:
parent
69207a6289
commit
614385ea7b
|
@ -583,6 +583,11 @@ class ShadowMapAtlas {
|
|||
return false;
|
||||
// push main tile to active tiles
|
||||
atlas.activeTiles.push(mainTile);
|
||||
// notify the tile on light remove
|
||||
light.tileNotifyOnRemove = mainTile.notifyOnLightRemove;
|
||||
// notify atlas when this tile is freed
|
||||
mainTile.notifyOnFree = atlas.freeActiveTile;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -731,6 +736,10 @@ class ShadowMapAtlas {
|
|||
}
|
||||
#end
|
||||
}
|
||||
|
||||
function freeActiveTile(tile: ShadowMapTile) {
|
||||
activeTiles.remove(tile);
|
||||
}
|
||||
}
|
||||
|
||||
class ShadowMapTile {
|
||||
|
@ -950,6 +959,11 @@ class ShadowMapTile {
|
|||
}
|
||||
}
|
||||
|
||||
public function notifyOnLightRemove() {
|
||||
unlockLight = true;
|
||||
freeTile();
|
||||
}
|
||||
|
||||
inline function lockTile(light: LightObject): Void {
|
||||
if (this.light != null)
|
||||
return;
|
||||
|
@ -963,6 +977,7 @@ class ShadowMapTile {
|
|||
}
|
||||
|
||||
public var unlockLight: Bool = false;
|
||||
public var notifyOnFree: ShadowMapTile -> Void;
|
||||
|
||||
public function freeTile(): Void {
|
||||
// prevent duplicates
|
||||
|
@ -988,6 +1003,11 @@ class ShadowMapTile {
|
|||
tempTile.linkedTile = null;
|
||||
tempTile = linkedTile;
|
||||
}
|
||||
// notify atlas that this tile has been freed
|
||||
if (notifyOnFree != null) {
|
||||
notifyOnFree(this);
|
||||
notifyOnFree = null;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function forEachTileLinked(action: ShadowMapTile->Void): Void {
|
||||
|
|
Loading…
Reference in a new issue