Directional brush

This commit is contained in:
luboslenco
2020-03-16 22:07:24 +01:00
parent 16fc75fa98
commit 2afe3f703e
11 changed files with 95 additions and 39 deletions
+11 -1
View File
@@ -56,7 +56,7 @@ class Uniforms {
if (link == "_brushScale") {
var nodesScale = UITrait.inst.brushNodesScale;
var fill = Context.layer.material_mask != null;
var val = (fill ? Context.layer.uvScale : UITrait.inst.brushScale) * nodesScale;
var val = (fill ? Context.layer.scale : UITrait.inst.brushScale) * nodesScale;
return val;
}
if (link == "_texpaintSize") {
@@ -134,6 +134,16 @@ class Uniforms {
vec2.set(UITrait.inst.cloneDeltaX, UITrait.inst.cloneDeltaY, 0);
return vec2;
}
if (link == "_brushDirection") {
var x = UITrait.inst.paintVec.x;
var y = UITrait.inst.paintVec.y;
var lastx = UITrait.inst.lastPaintVecX;
var lasty = UITrait.inst.lastPaintVecY;
if (UITrait.inst.paint2d) { x -= 1.0; lastx -= 1.0; }
var angle = Math.atan2(-y + lasty, x - lastx) - Math.PI / 2;
vec2.set(Math.cos(angle), Math.sin(angle), 0);
return vec2;
}
#end
return null;
}