OSDN Git Service

Added Assets for main menu
[mindgames/Mindgames_main.git] / Mindgames / Library / PackageCache / com.unity.visualeffectgraph@6.9.0-preview / Editor / Models / Operators / Implementations / DistanceToPlane.cs
1 using System;
2 using System.Linq;
3 using UnityEngine;
4
5 namespace UnityEditor.VFX.Operator
6 {
7     [VFXInfo(category = "Math/Geometry")]
8     class DistanceToPlane : VFXOperator
9     {
10         public class InputProperties
11         {
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();
16         }
17
18         public class OutputProperties
19         {
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;
24         }
25
26         override public string name { get { return "Distance (Plane)"; } }
27
28         protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
29         {
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 };
33         }
34     }
35 }