From 7b86a50b749d638cfd871537020fa698e47637ca Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 18 Mar 2020 21:32:26 +0100 Subject: [PATCH] Improve live brush cache --- Sources/arm/render/Inc.hx | 24 +++++++++++++++++++----- Sources/arm/render/RenderPathPaint.hx | 12 ------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Sources/arm/render/Inc.hx b/Sources/arm/render/Inc.hx index 969dcc4e..9cdbc301 100644 --- a/Sources/arm/render/Inc.hx +++ b/Sources/arm/render/Inc.hx @@ -8,6 +8,7 @@ import iron.system.Input; import iron.RenderPath; import iron.Scene; import arm.ui.UISidebar; +import arm.ui.UIView2D; import arm.Enums; class Inc { @@ -167,12 +168,25 @@ class Inc { public static function isCached(): Bool { #if (!arm_creator) + var mouse = Input.getMouse(); + var mx = lastX; + var my = lastY; + lastX = mouse.viewX; + lastY = mouse.viewY; + + if (UISidebar.inst.brushLive) { + var inViewport = UISidebar.inst.paintVec.x < 1 && UISidebar.inst.paintVec.x > 0 && + UISidebar.inst.paintVec.y < 1 && UISidebar.inst.paintVec.y > 0; + var in2dView = UIView2D.inst.show && UIView2D.inst.type == View2DLayer && + mx > UIView2D.inst.wx && mx < UIView2D.inst.wx + UIView2D.inst.ww && + my > UIView2D.inst.wy && my < UIView2D.inst.wy + UIView2D.inst.wh; + if ((mx != lastX || my != lastY) && (inViewport || in2dView)) { + Context.rdirty = 2; + UISidebar.inst.sub = 0; + } + } + if (Context.ddirty <= 0 && Context.rdirty <= 0 && (Context.pdirty <= 0 || UISidebar.inst.worktab.position == SpaceScene)) { - var mouse = Input.getMouse(); - var mx = lastX; - var my = lastY; - lastX = mouse.viewX; - lastY = mouse.viewY; if (mx != lastX || my != lastY || mouse.locked) Context.ddirty = 0; if (Context.ddirty > -2) { path.setTarget(""); diff --git a/Sources/arm/render/RenderPathPaint.hx b/Sources/arm/render/RenderPathPaint.hx index ee415fff..4962a744 100644 --- a/Sources/arm/render/RenderPathPaint.hx +++ b/Sources/arm/render/RenderPathPaint.hx @@ -295,16 +295,6 @@ class RenderPathPaint { if (liveLayerLocked) return; - // var mouse = Input.getMouse(); - // var mx = mouse.x; - // var my = mouse.y; - // var inViewport = UISidebar.inst.paintVec.x < 1 && UISidebar.inst.paintVec.x > 0 && - // UISidebar.inst.paintVec.y < 1 && UISidebar.inst.paintVec.y > 0; - // var in2dView = UIView2D.inst.show && UIView2D.inst.type == View2DLayer && - // mx > UIView2D.inst.wx && mx < UIView2D.inst.wx + UIView2D.inst.ww && - // my > UIView2D.inst.wy && my < UIView2D.inst.wy + UIView2D.inst.wh; - // if (!inViewport && !in2dView) return; - if (liveLayer == null) { liveLayer = new arm.data.LayerSlot("_live"); liveLayer.createMask(0x00000000); @@ -345,8 +335,6 @@ class RenderPathPaint { UISidebar.inst.lastPaintVecY = UISidebar.inst.lastPaintY; } Context.pdirty = 2; - Context.rdirty = 2; - UISidebar.inst.sub = 0; commandsSymmetry(); commandsPaint();