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.
 
 
 
 
 

46 lines
1.6 KiB

using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.VFX.Operator
{
class SafeNormalizationVariantProvider : VariantProvider
{
public override IEnumerable<Variant> GetVariants()
{
yield return new Variant("Safe Normalize", "Math/Vector", typeof(Normalize), new[] {new KeyValuePair<string, object>("safeNormalize", true)});
yield return new Variant("Normalize", "Math/Vector", typeof(Normalize), new[] {new KeyValuePair<string, object>("safeNormalize", false)});
}
}
[VFXHelpURL("Operator-Normalize")]
[VFXInfo(variantProvider = typeof(SafeNormalizationVariantProvider))]
class Normalize : VFXOperatorNumericUniform
{
public class InputProperties
{
public Vector3 x = Vector3.one;
}
[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), SerializeField, Tooltip("Specifies if the operator should check if the vector to be normalized is a vero vector.")]
bool safeNormalize = false;
protected override sealed string operatorName { get { return safeNormalize ? "Safe Normalize" : "Normalize"; } }
protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
{
if (safeNormalize)
return new[] { VFXOperatorUtility.SafeNormalize(inputExpression[0]) };
else
return new[] { VFXOperatorUtility.Normalize(inputExpression[0]) };
}
protected override sealed ValidTypeRule typeFilter
{
get
{
return ValidTypeRule.allowVectorType;
}
}
}
}