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