BrushOutputNode.hx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package arm.brushnode;
  2. import armory.logicnode.LogicNode;
  3. import armory.logicnode.LogicTree;
  4. @:keep
  5. class BrushOutputNode extends LogicNode {
  6. public function new(tree:LogicTree) {
  7. super(tree);
  8. arm.UITrait.inst.notifyOnBrush(run);
  9. }
  10. override function run(from:Int) {
  11. arm.UITrait.inst.paintVec = inputs[0].get();
  12. arm.UITrait.inst.brushNodesRadius = inputs[1].get();
  13. arm.UITrait.inst.brushNodesOpacity = inputs[2].get();
  14. arm.UITrait.inst.brushNodesStrength = inputs[3].get();
  15. arm.UITrait.inst.brushNodesScale = inputs[4].get();
  16. // Paint bounds
  17. if (arm.UITrait.inst.paintVec.x < 1 && arm.UITrait.inst.paintVec.x > 0) {
  18. // Set color pick
  19. var down = iron.system.Input.getMouse().down() || iron.system.Input.getPen().down();
  20. if (arm.UITrait.inst.brushType == 4 && arm.UITrait.inst.assets.length > 0 && down) {
  21. arm.UITrait.inst.colorIdPicked = true;
  22. }
  23. // Prevent painting the same spot - save perf & reduce projection paint jittering caused by _sub offset
  24. if (down && arm.UITrait.inst.paintVec.x == arm.UITrait.inst.lastPaintX && arm.UITrait.inst.paintVec.y == arm.UITrait.inst.lastPaintY) {
  25. arm.UITrait.inst.painted++;
  26. }
  27. else {
  28. arm.UITrait.inst.painted = 0;
  29. }
  30. arm.UITrait.inst.lastPaintX = arm.UITrait.inst.paintVec.x;
  31. arm.UITrait.inst.lastPaintY = arm.UITrait.inst.paintVec.y;
  32. if (arm.UITrait.inst.painted <= 8) {
  33. arm.UITrait.inst.pdirty = 1;
  34. arm.UITrait.inst.rdirty = 2;
  35. }
  36. }
  37. runOutput(0);
  38. }
  39. }