From 69d4500c0dcd3c41783118d576dfed0883062b43 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 19 Sep 2019 12:36:08 +0200 Subject: [PATCH] Fix object mask for fill layers --- Sources/arm/Layers.hx | 27 +++++++++++++-------------- Sources/arm/ui/TabLayers.hx | 10 +++++++++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Sources/arm/Layers.hx b/Sources/arm/Layers.hx index 191d102c..795e30a4 100644 --- a/Sources/arm/Layers.hx +++ b/Sources/arm/Layers.hx @@ -79,25 +79,24 @@ class Layers { Context.ddirty = 3; } - public static function clearLastLayer(g:kha.graphics4.Graphics) { + public static function clearSelectedLayer(g:kha.graphics4.Graphics) { g.end(); - var layers = Project.layers; - var i = layers.length - 1; - layers[i].texpaint.g4.begin(); - layers[i].texpaint.g4.clear(kha.Color.fromFloats(0.0, 0.0, 0.0, 0.0)); // Base - layers[i].texpaint.g4.end(); + var l = Context.layer; + l.texpaint.g4.begin(); + l.texpaint.g4.clear(kha.Color.fromFloats(0.0, 0.0, 0.0, 0.0)); // Base + l.texpaint.g4.end(); - layers[i].texpaint_nor.g4.begin(); - layers[i].texpaint_nor.g4.clear(kha.Color.fromFloats(0.5, 0.5, 1.0, 0.0)); // Nor - layers[i].texpaint_nor.g4.end(); + l.texpaint_nor.g4.begin(); + l.texpaint_nor.g4.clear(kha.Color.fromFloats(0.5, 0.5, 1.0, 0.0)); // Nor + l.texpaint_nor.g4.end(); - layers[i].texpaint_pack.g4.begin(); - layers[i].texpaint_pack.g4.clear(kha.Color.fromFloats(1.0, 0.0, 0.0, 0.0)); // Occ, rough, met - layers[i].texpaint_pack.g4.end(); + l.texpaint_pack.g4.begin(); + l.texpaint_pack.g4.clear(kha.Color.fromFloats(1.0, 0.0, 0.0, 0.0)); // Occ, rough, met + l.texpaint_pack.g4.end(); g.begin(); - iron.App.removeRender(clearLastLayer); + iron.App.removeRender(clearSelectedLayer); #if krom_linux Context.layerPreviewDirty = true; @@ -389,7 +388,7 @@ class Layers { var l = new LayerSlot(); Project.layers.push(l); Context.setLayer(l); - if (clear) iron.App.notifyOnRender(Layers.clearLastLayer); + if (clear) iron.App.notifyOnRender(Layers.clearSelectedLayer); Context.layerPreviewDirty = true; return l; } diff --git a/Sources/arm/ui/TabLayers.hx b/Sources/arm/ui/TabLayers.hx index 2b83eec9..33a5fdf0 100644 --- a/Sources/arm/ui/TabLayers.hx +++ b/Sources/arm/ui/TabLayers.hx @@ -310,7 +310,15 @@ class TabLayers { l.objectMask = ui.combo(h, ar, "Object"); if (h.changed) { Context.setLayer(l); - Layers.updateFillLayers(4); + if (l.material_mask != null) { // Fill layer + iron.App.notifyOnRender(Layers.clearSelectedLayer); + iron.App.notifyOnRender(function(_){ + Layers.updateFillLayers(4); + }); + } + else { + Layers.updateFillLayers(4); + } } @:privateAccess ui.endElement(); }