Explorar o código

[shgraph] Semi straights lines in shader graph

Clément Espeute hai 1 ano
pai
achega
615d9af8ae
Modificáronse 3 ficheiros con 26 adicións e 3 borrados
  1. 20 0
      hide/comp/SVG.hx
  2. 3 3
      hide/view/GraphEditor.hx
  3. 3 0
      hide/view/shadereditor/Box.hx

+ 20 - 0
hide/comp/SVG.hx

@@ -49,6 +49,26 @@ class SVG extends Component {
 		return make(parent, "path", {d : 'M ${x1} ${y1} Q ${xTurn} ${yTurn}, ${x1 + (x2-x1)/2} ${y1 + (y2-y1)/2}, T ${x2} ${y2}'}, style);
 	}
 
+	public function straightCurve(?parent: Element, x1: Float, y1: Float, x2: Float, y2: Float, advance: Float, round: Float, ?style:Dynamic) {
+
+		var dx = (x2 - advance) - (x1 + advance);
+		var dy = y2 - y1;
+		var len = hxd.Math.distance(dx, dy);
+
+		var diagXOffset = dx/len * advance * round;
+		var diagYOffset = dy/len * advance * round;
+
+		return make(parent, "path",
+			{d : '
+				M ${x1} ${y1}
+				L ${x1+advance * (1.0-round)} ${y1}
+				Q ${x1+advance} ${y1}, ${x1+advance+diagXOffset} ${y1+diagYOffset}
+				L ${x2-advance-diagXOffset} ${y2-diagYOffset}
+				Q ${x2-advance} ${y2}, ${x2-advance * (1.0-round)} ${y2}
+				L ${x2} ${y2}
+				'}, style);
+	}
+
 	public function foreignObject(?parent: Element, x:Float, y:Float, width:Float, height:Float, ?style:Dynamic) {
 		return make(parent, "foreignObject", {x:x, y:y, width:width, height:height}, style);
 	}

+ 3 - 3
hide/view/GraphEditor.hx

@@ -1554,13 +1554,13 @@ class GraphEditor extends hide.comp.Component {
 		var valueCurveY = 1;
 		var maxDistanceY = 900;
 
-		var curve = editorDisplay.curve(null,
+		var curve = editorDisplay.straightCurve(null,
 							startX,
 							startY,
 							endX,
 							endY,
-							startX + valueCurveX * (Math.min(maxDistanceY, diffDistanceY)/maxDistanceY),
-							startY + signCurveY * valueCurveY * (Math.min(maxDistanceY, diffDistanceY)/maxDistanceY),
+							18,
+							0.25,
 							{})
 							.addClass("edge");
 		editorMatrix.prepend(curve);

+ 3 - 0
hide/view/shadereditor/Box.hx

@@ -48,7 +48,10 @@ class Box {
 	public function new(editor : GraphEditor, parent : JQuery, node : IGraphNode) {
 		this.node = node;
 		info = node.getInfo();
+
+
 		width = info.width ?? 150;
+		width = Std.int(hxd.Math.ceil(width / NODE_MARGIN) * NODE_MARGIN);
 
 		//var metas = haxe.rtti.Meta.getType(Type.getClass(node));
 		//if (metas.width != null) {