5 namespace UnityEditor.VFX.Operator
7 [VFXInfo(category = "Math/Geometry")]
8 class DistanceToPlane : VFXOperator
10 public class InputProperties
12 [Tooltip("The plane used for the distance calculation.")]
13 public Plane plane = new Plane();
14 [Tooltip("The position used for the distance calculation.")]
15 public Position position = new Position();
18 public class OutputProperties
20 [Tooltip("The closest point on the plane to the supplied position.")]
21 public Vector3 closestPosition;
22 [Tooltip("The signed distance from the plane.")]
23 public float distance;
26 override public string name { get { return "Distance (Plane)"; } }
28 protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
30 VFXExpression planeDistance = VFXOperatorUtility.SignedDistanceToPlane(inputExpression[0], inputExpression[1], inputExpression[2]);
31 VFXExpression pointOnPlane = (inputExpression[2] - inputExpression[1] * VFXOperatorUtility.CastFloat(planeDistance, inputExpression[1].valueType));
32 return new VFXExpression[] { pointOnPlane, planeDistance };