IsNanNode.cs 788 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Reflection;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. [Title("Utility", "Logic", "Is NaN")]
  6. class IsNanNode : CodeFunctionNode
  7. {
  8. public IsNanNode()
  9. {
  10. name = "Is NaN";
  11. }
  12. public override bool hasPreview
  13. {
  14. get { return false; }
  15. }
  16. protected override MethodInfo GetFunctionToConvert()
  17. {
  18. return GetType().GetMethod("Unity_IsNaN", BindingFlags.Static | BindingFlags.NonPublic);
  19. }
  20. static string Unity_IsNaN(
  21. [Slot(0, Binding.None)] Vector1 In,
  22. [Slot(1, Binding.None)] out Boolean Out)
  23. {
  24. return
  25. @"
  26. {
  27. Out = (In < 0.0 || In > 0.0 || In == 0.0) ? 0 : 1;
  28. }
  29. ";
  30. }
  31. }
  32. }