Skip to content

Commit

Permalink
Optimized biomes invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Dec 5, 2023
1 parent 1983a02 commit a2e8cbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/electron.renderer/EditorTypes.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum GlobalEvent {
LayerInstanceChangedGlobally(li:data.inst.LayerInstance);
LayerInstanceVisiblityChanged(li:data.inst.LayerInstance);
LayerInstancesRestoredFromHistory(lis:Array<data.inst.LayerInstance>);
AutoLayerRenderingChanged;
AutoLayerRenderingChanged(lis:Array<data.inst.LayerInstance>);
LayerInstanceTilesetChanged(li:data.inst.LayerInstance);

TilesetImageLoaded(td:data.def.TilesetDef, isInitial:Bool);
Expand Down
6 changes: 3 additions & 3 deletions src/electron.renderer/display/LevelRender.hx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class LevelRender extends dn.Process {
case LayerInstanceVisiblityChanged(li):
applyLayerVisibility(li);

case AutoLayerRenderingChanged:
for(li in editor.curLevel.layerInstances)
case AutoLayerRenderingChanged(lis):
for(li in lis)
if( li.def.isAutoLayer() )
invalidateLayer(li);

Expand Down Expand Up @@ -303,7 +303,7 @@ class LevelRender extends dn.Process {

public function setAutoLayerRendering(v:Bool) {
autoLayerRendering = v;
editor.ge.emit( AutoLayerRenderingChanged );
editor.ge.emit( AutoLayerRenderingChanged(editor.curLevel.layerInstances) );
}

public inline function toggleAutoLayerRendering() {
Expand Down
8 changes: 4 additions & 4 deletions src/electron.renderer/page/Editor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ class Editor extends Page {
for(li in lis)
extra+=li.layerDefUid;
case LayerInstanceTilesetChanged(li): extra = li.layerDefUid;
case AutoLayerRenderingChanged:
case AutoLayerRenderingChanged(lis): extra = lis.map( li->li.def.identifier ).join(",");
case TilesetDefChanged(td): extra = td.uid;
case TilesetDefAdded(td): extra = td.uid;
case TilesetDefRemoved(td): extra = td.uid;
Expand Down Expand Up @@ -2027,7 +2027,7 @@ class Editor extends Page {
case LayerInstancesRestoredFromHistory(lis):
for(li in lis)
invalidateLevelCache(li.level);
case AutoLayerRenderingChanged:
case AutoLayerRenderingChanged(lis):
case LayerInstanceTilesetChanged(li): invalidateLevelCache(li.level);
case TilesetDefChanged(td): invalidateAllLevelsCache();
case TilesetImageLoaded(td, init):
Expand Down Expand Up @@ -2080,7 +2080,7 @@ class Editor extends Page {
case LayerInstanceSelected:
case LevelSelected(_):
case WorldSelected(_):
case AutoLayerRenderingChanged:
case AutoLayerRenderingChanged(lis):
case ToolOptionChanged:
case ToolValueSelected:
case BeforeProjectSaving:
Expand Down Expand Up @@ -2164,7 +2164,7 @@ class Editor extends Page {
updateLayerList();
updateGuide();

case AutoLayerRenderingChanged:
case AutoLayerRenderingChanged(lis):

case LayerInstanceVisiblityChanged(li):
selectionTool.clear();
Expand Down
10 changes: 5 additions & 5 deletions src/electron.renderer/ui/LevelInstanceForm.hx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ class LevelInstanceForm {
updateFieldsForm();

// Biome field changed
var anyAutoLayerInvalidated = false;
var invalidatedLis = [];
for( ld in project.defs.layers )
if( ld.biomeFieldUid==fi.defUid ) {
l.getLayerInstance(ld).autoTilesCache = null;
anyAutoLayerInvalidated = true;
var li = l.getLayerInstance(ld);
invalidatedLis.push(li);
}
if( anyAutoLayerInvalidated )
editor.ge.emit(AutoLayerRenderingChanged);
if( invalidatedLis.length>0 )
editor.ge.emit( AutoLayerRenderingChanged(invalidatedLis) );

case _:
}
Expand Down

0 comments on commit a2e8cbf

Please sign in to comment.