You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

49 lines
1.5 KiB

using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.VFX.Operator
{
[VFXHelpURL("Operator-SquaredDistance")]
[VFXInfo(category = "Math/Vector")]
class SquaredDistance : VFXOperatorNumericUniform
{
public class InputProperties
{
[Tooltip("The first operand.")]
public Vector3 a = Vector3.zero;
[Tooltip("The second operand.")]
public Vector3 b = Vector3.zero;
}
protected override sealed Type GetExpectedOutputTypeOfOperation(IEnumerable<Type> inputTypes)
{
var type = inputTypes.First(); //derive from VFXOperatorNumericUniform, First is suitable
return VFXExpression.GetMatchingScalar(type);
}
protected sealed override string expectedOutputName
{
get
{
return "d";
}
}
protected override sealed VFXPropertyAttributes expectedOutputAttributes
{
get
{
return new VFXPropertyAttributes(new TooltipAttribute("The squared distance between a and b."));
}
}
protected override sealed string operatorName { get { return "Squared Distance"; } }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
{
return new[] { VFXOperatorUtility.SqrDistance(inputExpression[0], inputExpression[1]) };
}
}
}