internal void UpdateBezierPoints() { if (IsNodeSlotDragging == false) { return; } var srcPos = _parent.SourceNodeSlotConnecting.MakeSlotPos(); BezierPoints[0] = srcPos; if (_parent.TargetNodeSlotConnecting.IsNull) { var handleLength = srcPos.Distance(_mousePos) * 0.5d; BezierPoints[1] = BiaNodeEditorHelper.MakeBezierControlPoint(srcPos, _parent.SourceNodeSlotConnecting.Slot.Dir, handleLength); BezierPoints[2] = _mousePos; BezierPoints[3] = _mousePos; } else { var targetSlotPos = _parent.TargetNodeSlotConnecting.MakeSlotPos(); var handleLength = srcPos.Distance(targetSlotPos) * 0.5d; BezierPoints[1] = BiaNodeEditorHelper.MakeBezierControlPoint(srcPos, _parent.SourceNodeSlotConnecting.Slot.Dir, handleLength); BezierPoints[2] = BiaNodeEditorHelper.MakeBezierControlPoint(targetSlotPos, _parent.TargetNodeSlotConnecting.Slot.Dir, handleLength); BezierPoints[3] = targetSlotPos; } }
public static ValueTuple <ImmutableVec2_double, ImmutableVec2_double, ImmutableVec2_double, ImmutableVec2_double> MakeBezierCurve(this IBiaNodeLink self) { var item1 = self.ItemSlot1.Item ?? throw new NullReferenceException(); var item2 = self.ItemSlot2.Item ?? throw new NullReferenceException(); var pos1 = item1.MakeSlotPosDefault(self.InternalData().Slot1 !); var pos2 = item2.MakeSlotPosDefault(self.InternalData().Slot2 !); var pos1C = BiaNodeEditorHelper.MakeBezierControlPoint(pos1, self.InternalData().Slot1 !.Dir); var pos2C = BiaNodeEditorHelper.MakeBezierControlPoint(pos2, self.InternalData().Slot2 !.Dir); return(pos1, pos1C, pos2C, pos2); }
public static void MakeBezierCurve(this IBiaNodeLink self, Span <ImmutableVec2_float> result) { var item1 = self.ItemSlot1.Item ?? throw new NullReferenceException(); var item2 = self.ItemSlot2.Item ?? throw new NullReferenceException(); var pos1 = item1.MakeSlotPosDefault(self.InternalData().Slot1 !); var pos2 = item2.MakeSlotPosDefault(self.InternalData().Slot2 !); var pos1C = BiaNodeEditorHelper.MakeBezierControlPoint(pos1, self.InternalData().Slot1 !.Dir); var pos2C = BiaNodeEditorHelper.MakeBezierControlPoint(pos2, self.InternalData().Slot2 !.Dir); result[0] = new ImmutableVec2_float((float)pos1.X, (float)pos1.Y); result[1] = new ImmutableVec2_float((float)pos1C.X, (float)pos1C.Y); result[2] = new ImmutableVec2_float((float)pos2C.X, (float)pos2C.Y); result[3] = new ImmutableVec2_float((float)pos2.X, (float)pos2.Y); }