Resize mask

This commit is contained in:
luboslenco
2019-03-12 23:20:48 +01:00
parent 24681f6e98
commit 6c44755eac
4 changed files with 16 additions and 7 deletions
+11 -1
View File
@@ -84,13 +84,23 @@ class Layers {
public static function resizeLayers(g:kha.graphics4.Graphics) {
var C = UITrait.inst.C;
if (UITrait.inst.resHandle.position >= 4) { // Save memory for >=16k
C.undo_steps = 0;// No undo for 16k+
C.undo_steps = 1;
if (UITrait.inst.undoHandle != null) UITrait.inst.undoHandle.value = C.undo_steps;
while (UITrait.inst.undoLayers.length > C.undo_steps) { var l = UITrait.inst.undoLayers.pop(); l.unload(); }
}
g.end();
for (l in UITrait.inst.layers) resizeLayer(l);
for (l in UITrait.inst.undoLayers) resizeLayer(l);
var rts = RenderPath.active.renderTargets;
rts.get("texpaint_mask0").image.unload();
rts.get("texpaint_mask0").raw.width = Config.getTextureRes();
rts.get("texpaint_mask0").raw.height = Config.getTextureRes();
rts.get("texpaint_mask0").image = kha.Image.createRenderTarget(Config.getTextureRes(), Config.getTextureRes(), kha.graphics4.TextureFormat.L8, kha.graphics4.DepthStencilFormat.NoDepthAndStencil);
rts.get("texpaint_mask1").image.unload();
rts.get("texpaint_mask1").raw.width = Config.getTextureRes();
rts.get("texpaint_mask1").raw.height = Config.getTextureRes();
rts.get("texpaint_mask1").image = kha.Image.createRenderTarget(Config.getTextureRes(), Config.getTextureRes(), kha.graphics4.TextureFormat.L8, kha.graphics4.DepthStencilFormat.NoDepthAndStencil);
UITrait.inst.maskDirty = true;
g.begin();
UITrait.inst.ddirty = 2;
iron.App.removeRender(resizeLayers);
-1
View File
@@ -116,7 +116,6 @@ class Uniforms {
return UITrait.inst.decalMaskImage;
}
else if (link == "_texpaint_undo") {
// if (UITrait.inst.pushUndo && UITrait.inst.C.undo_steps > 0)
var i = UITrait.inst.undoI - 1 < 0 ? UITrait.inst.C.undo_steps - 1 : UITrait.inst.undoI - 1;
return iron.RenderPath.active.renderTargets.get("texpaint_undo" + i).image;
}
+1 -1
View File
@@ -161,7 +161,7 @@ class RenderPathDeferred {
var tid = UITrait.inst.selectedLayer.id;
if (UITrait.inst.pushUndo && UITrait.inst.C.undo_steps > 0) {
if (UITrait.inst.pushUndo) {
var i = UITrait.inst.undoI;
path.setTarget("texpaint_undo" + i, ["texpaint_nor_undo" + i, "texpaint_pack_undo" + i]);
path.bindTarget("texpaint" + tid, "tex0");
+4 -4
View File
@@ -608,7 +608,7 @@ class UITrait extends iron.Trait {
}
public function doUndo() {
if (undos > 0 && C.undo_steps > 0) {
if (undos > 0) {
undoI = undoI - 1 < 0 ? C.undo_steps - 1 : undoI - 1;
var lay = undoLayers[undoI];
var opos = paintObjects.indexOf(lay.targetObject);
@@ -626,7 +626,7 @@ class UITrait extends iron.Trait {
}
public function doRedo() {
if (redos > 0 && C.undo_steps > 0) {
if (redos > 0) {
var lay = undoLayers[undoI];
var opos = paintObjects.indexOf(lay.targetObject);
var lpos = layers.indexOf(lay.targetLayer);
@@ -665,7 +665,7 @@ class UITrait extends iron.Trait {
cloneStartY = mouse.y;
}
else {
if (brushTime == 0 && C.undo_steps > 0) { // Paint started
if (brushTime == 0) { // Paint started
pushUndo = true;
if (projectPath != "") {
kha.Window.get(0).title = arm.App.filenameHandle.text + "* - ArmorPaint";
@@ -2224,7 +2224,7 @@ class UITrait extends iron.Trait {
ui.separator();
if (ui.panel(Id.handle({selected: true}), "Usage", 1)) {
undoHandle = Id.handle({value: C.undo_steps});
C.undo_steps = Std.int(ui.slider(undoHandle, "Undo Steps", 0, 64, false, 1));
C.undo_steps = Std.int(ui.slider(undoHandle, "Undo Steps", 1, 64, false, 1));
if (undoHandle.changed) {
ui.g.end();
while (undoLayers.length < C.undo_steps) undoLayers.push(new LayerSlot("_undo" + undoLayers.length));