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.

32 lines
1.2 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. namespace AmplifyShaderEditor
  5. {
  6. [Serializable]
  7. [NodeAttributes( "Distance", "Vector Operators", "Euclidean distance between two points" )]
  8. public sealed class DistanceOpNode : DynamicTypeNode
  9. {
  10. protected override void CommonInit( int uniqueId )
  11. {
  12. base.CommonInit( uniqueId );
  13. m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
  14. m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false );
  15. m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false );
  16. m_dynamicOutputType = false;
  17. m_useInternalPortData = true;
  18. m_previewShaderGUID = "3be9a95031c0cb740ae982e465dfc242";
  19. }
  20. public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  21. {
  22. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  23. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  24. base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
  25. string result = "distance( " + m_inputA + " , " + m_inputB + " )";
  26. return CreateOutputLocalVariable( 0, result, ref dataCollector );
  27. }
  28. }
  29. }