Fix paint bounds for 2d view
This commit is contained in:
+4
-1
@@ -217,6 +217,9 @@ class App {
|
||||
if (UISidebar.inst != null && Context.viewIndex > -1) {
|
||||
res = Std.int(res / 2);
|
||||
}
|
||||
if (Context.paint2dView) {
|
||||
res = UIView2D.inst.ww;
|
||||
}
|
||||
|
||||
return res > 0 ? res : 1; // App was minimized, force render path resize
|
||||
}
|
||||
@@ -555,7 +558,7 @@ class App {
|
||||
}
|
||||
else {
|
||||
if (Context.splitView) {
|
||||
Context.viewIndex = Input.getMouse().viewX > arm.App.w() / 2 ? 1 : 0;
|
||||
Context.viewIndex = mouse.viewX > arm.App.w() / 2 ? 1 : 0;
|
||||
}
|
||||
|
||||
Context.lastPaintVecX = mouse.viewX / iron.App.w();
|
||||
|
||||
@@ -7,6 +7,7 @@ import iron.data.Data;
|
||||
#if arm_painter
|
||||
import arm.ui.UISidebar;
|
||||
import arm.ui.UINodes;
|
||||
import arm.ui.UIView2D;
|
||||
import arm.ui.UIStatus;
|
||||
import arm.render.Inc;
|
||||
import arm.sys.Path;
|
||||
@@ -239,12 +240,13 @@ class Config {
|
||||
}
|
||||
|
||||
public static function initLayout() {
|
||||
var show2d = (UINodes.inst != null && UINodes.inst.show) || (UIView2D.inst != null && UIView2D.inst.show);
|
||||
raw.layout = [
|
||||
Std.int(UISidebar.defaultWindowW * raw.window_scale),
|
||||
Std.int(kha.System.windowHeight() / 3),
|
||||
Std.int(kha.System.windowHeight() / 3),
|
||||
Std.int(kha.System.windowHeight() / 3),
|
||||
(UINodes.inst != null && UINodes.inst.show) ? Std.int((iron.App.w() + raw.layout[LayoutNodesW]) / 2) : Std.int(iron.App.w() / 2),
|
||||
show2d ? Std.int((iron.App.w() + raw.layout[LayoutNodesW]) / 2) : Std.int(iron.App.w() / 2),
|
||||
Std.int(iron.App.h() / 2),
|
||||
Std.int(UIStatus.defaultStatusH * raw.window_scale)
|
||||
];
|
||||
|
||||
@@ -215,6 +215,7 @@ class Context {
|
||||
public static var prevPaintVecY = -1.0;
|
||||
public static var frame = 0;
|
||||
public static var paint2d = false;
|
||||
public static var paint2dView = false;
|
||||
|
||||
public static var lockStartedX = -1.0;
|
||||
public static var lockStartedY = -1.0;
|
||||
|
||||
@@ -60,11 +60,11 @@ class BrushOutputNode extends LogicNode {
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
var left = 0;
|
||||
var right = 1;
|
||||
var left = 0.0;
|
||||
var right = 1.0;
|
||||
if (Context.paint2d) {
|
||||
left = 1;
|
||||
right = 2;
|
||||
left = 1.0;
|
||||
right = 1.0 + UIView2D.inst.ww / App.w();
|
||||
}
|
||||
|
||||
// First time init
|
||||
@@ -80,8 +80,10 @@ class BrushOutputNode extends LogicNode {
|
||||
var groupLayer = Context.layer.getChildren() != null;
|
||||
|
||||
// Paint bounds
|
||||
if (Context.paintVec.x < right && Context.paintVec.x > left &&
|
||||
Context.paintVec.y < 1 && Context.paintVec.y > 0 &&
|
||||
if (Context.paintVec.x > left &&
|
||||
Context.paintVec.x < right &&
|
||||
Context.paintVec.y > 0 &&
|
||||
Context.paintVec.y < 1 &&
|
||||
!UISidebar.inst.ui.isHovered &&
|
||||
!UISidebar.inst.ui.isScrolling &&
|
||||
!fillLayer &&
|
||||
|
||||
@@ -499,6 +499,7 @@ class RenderPathPaint {
|
||||
|
||||
// 2D paint
|
||||
if (Context.paint2d) {
|
||||
Context.paint2dView = true;
|
||||
// Set plane mesh
|
||||
painto = Context.paintObject;
|
||||
visibles = [];
|
||||
@@ -523,7 +524,7 @@ class RenderPathPaint {
|
||||
cam.buildMatrix();
|
||||
|
||||
var tw = 0.95 * UIView2D.inst.panScale;
|
||||
var tx = UIView2D.inst.panX / iron.App.w();
|
||||
var tx = UIView2D.inst.panX / UIView2D.inst.ww;
|
||||
var ty = UIView2D.inst.panY / iron.App.h();
|
||||
|
||||
m.setIdentity();
|
||||
@@ -666,6 +667,7 @@ class RenderPathPaint {
|
||||
}
|
||||
|
||||
if (Context.paint2d) {
|
||||
Context.paint2dView = false;
|
||||
// Restore paint mesh
|
||||
planeo.visible = false;
|
||||
for (i in 0...Project.paintObjects.length) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import iron.RenderPath;
|
||||
import iron.Scene;
|
||||
#if arm_painter
|
||||
import arm.ui.UISidebar;
|
||||
import arm.ui.UIView2D;
|
||||
import arm.util.UVUtil;
|
||||
import arm.shader.MaterialParser;
|
||||
import arm.Enums;
|
||||
@@ -304,7 +305,7 @@ class Uniforms {
|
||||
var y = Context.paintVec.y;
|
||||
var lastx = Context.prevPaintVecX;
|
||||
var lasty = Context.prevPaintVecY;
|
||||
if (Context.paint2d) { x -= 1.0; lastx -= 1.0; }
|
||||
if (Context.paint2d) { x = vec2d(x); lastx = vec2d(lastx); }
|
||||
var angle = Math.atan2(-y + lasty, x - lastx) - Math.PI / 2;
|
||||
v.set(Math.cos(angle), Math.sin(angle), allowPaint ? 1 : 0);
|
||||
Context.prevPaintVecX = Context.lastPaintVecX;
|
||||
@@ -322,24 +323,32 @@ class Uniforms {
|
||||
return v;
|
||||
}
|
||||
|
||||
static function vec2d(x: Float) {
|
||||
// Transform from 3d viewport coord to 2d view coord
|
||||
Context.paint2dView = false;
|
||||
var res = (x * App.w() - App.w()) / UIView2D.inst.ww;
|
||||
Context.paint2dView = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
public static function linkVec4(object: Object, mat: MaterialData, link: String): iron.math.Vec4 {
|
||||
#if arm_painter
|
||||
switch (link) {
|
||||
case "_inputBrush": {
|
||||
var down = Input.getMouse().down() || Input.getPen().down();
|
||||
vec.set(Context.paintVec.x, Context.paintVec.y, down ? 1.0 : 0.0, 0.0);
|
||||
if (Context.paint2d) vec.x -= 1.0;
|
||||
if (Context.paint2d) vec.x = vec2d(vec.x);
|
||||
return vec;
|
||||
}
|
||||
case "_inputBrushLast": {
|
||||
var down = Input.getMouse().down() || Input.getPen().down();
|
||||
vec.set(Context.lastPaintVecX, Context.lastPaintVecY, down ? 1.0 : 0.0, 0.0);
|
||||
if (Context.paint2d) vec.x -= 1.0;
|
||||
if (Context.paint2d) vec.x = vec2d(vec.x);
|
||||
return vec;
|
||||
}
|
||||
case "_stencilTransform": {
|
||||
vec.set(Context.brushStencilX, Context.brushStencilY, Context.brushStencilScale, Context.brushStencilAngle);
|
||||
if (Context.paint2d) vec.x -= 1.0;
|
||||
if (Context.paint2d) vec.x = vec2d(vec.x);
|
||||
return vec;
|
||||
}
|
||||
case "_envmapData": {
|
||||
|
||||
@@ -255,7 +255,7 @@ class UISidebar {
|
||||
}
|
||||
|
||||
var right = iron.App.w();
|
||||
if (UIView2D.inst.show) right = iron.App.w() * 2;
|
||||
if (UIView2D.inst.show) right += UIView2D.inst.ww;
|
||||
|
||||
// Viewport shortcuts
|
||||
if (mouse.viewX > 0 && mouse.viewX < right &&
|
||||
@@ -500,10 +500,16 @@ class UISidebar {
|
||||
if (down) {
|
||||
var mx = mouse.viewX;
|
||||
var my = mouse.viewY;
|
||||
if (Context.paint2d) mx -= iron.App.w();
|
||||
var ww = iron.App.w();
|
||||
if (Context.paint2d) {
|
||||
mx -= iron.App.w();
|
||||
ww = UIView2D.inst.ww;
|
||||
}
|
||||
|
||||
if (mx < iron.App.w() && mx > iron.App.x() &&
|
||||
my < iron.App.h() && my > iron.App.y()) {
|
||||
if (mx < ww &&
|
||||
mx > iron.App.x() &&
|
||||
my < iron.App.h() &&
|
||||
my > iron.App.y()) {
|
||||
|
||||
if (setCloneSource) {
|
||||
Context.cloneStartX = mx;
|
||||
@@ -523,7 +529,7 @@ class UISidebar {
|
||||
|
||||
History.pushUndo = true;
|
||||
if (Context.tool == ToolClone && Context.cloneStartX >= 0.0) { // Clone delta
|
||||
Context.cloneDeltaX = (Context.cloneStartX - mx) / iron.App.w();
|
||||
Context.cloneDeltaX = (Context.cloneStartX - mx) / ww;
|
||||
Context.cloneDeltaY = (Context.cloneStartY - my) / iron.App.h();
|
||||
Context.cloneStartX = -1;
|
||||
}
|
||||
@@ -741,7 +747,7 @@ class UISidebar {
|
||||
Context.decalX = Context.paintVec.x;
|
||||
Context.decalY = Context.paintVec.y;
|
||||
}
|
||||
var decalX = App.x() + Context.decalX * App.w() - psizex / 2;
|
||||
var decalX = App.x() + Context.decalX * iron.App.w() - psizex / 2;
|
||||
var decalY = App.y() + Context.decalY * App.h() - psizey / 2;
|
||||
|
||||
// Radius being scaled
|
||||
|
||||
@@ -68,8 +68,8 @@ class UIView2D {
|
||||
|
||||
if (Context.pdirty >= 0) hwnd.redraws = 2; // Paint was active
|
||||
|
||||
var tw = iron.App.w() * 0.95 * panScale;
|
||||
var tx = iron.App.w() / 2 - tw / 2 + panX;
|
||||
var tw = ww * 0.95 * panScale;
|
||||
var tx = ww / 2 - tw / 2 + panX;
|
||||
var ty = iron.App.h() / 2 - tw / 2 + panY;
|
||||
|
||||
g.end();
|
||||
|
||||
Reference in New Issue
Block a user