Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distance math node #1333

Merged
merged 14 commits into from
May 23, 2023
13 changes: 13 additions & 0 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,19 @@
<output name="out" type="stringarray" defaultinput="in1" />
</nodedef>

<!--
Node: <Distance>
Measures the distance between two point in (X, Y).
-->

<nodedef name="ND_Distance_float" node="Distance" nodegroup="math">
<input name="x1" type="float" uiname="x1" value="0" />
<input name="x2" type="float" uiname="x2" value="0" />
<input name="y1" type="float" uiname="y1" value="0" />
<input name="y2" type="float" uiname="y2" value="0" />
<output name="out" type="float" />
</nodedef>

<!-- ======================================================================== -->
<!-- Adjustment nodes -->
<!-- ======================================================================== -->
Expand Down
32 changes: 32 additions & 0 deletions libraries/stdlib/stdlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,38 @@
<output name="out" type="vector2" nodename="N_switch_operationorder" />
</nodegraph>

<!--
Node: <Distance>
Measures the distance between two point in (X, Y).
-->

<nodegraph name="NG_Distance_float" nodedef="ND_Distance_float">
<sqrt name="N_mtlxsqrt" type="float">
<input name="in" type="float" nodename="N_mtlxadd" />
</sqrt>
<add name="N_mtlxadd" type="float">
<input name="in1" type="float" nodename="N_mtlxmultiply" />
<input name="in2" type="float" nodename="N_mtlxmultiply1" />
</add>
<multiply name="N_mtlxmultiply" type="float">
<input name="in1" type="float" nodename="N_mtlxsubtract" />
<input name="in2" type="float" nodename="N_mtlxsubtract" />
</multiply>
<multiply name="N_mtlxmultiply1" type="float">
<input name="in1" type="float" nodename="N_mtlxsubtract1" />
<input name="in2" type="float" nodename="N_mtlxsubtract1" />
</multiply>
<subtract name="N_mtlxsubtract" type="float">
<input name="in1" type="float" interfacename="x2" />
<input name="in2" type="float" interfacename="x1" />
</subtract>
<subtract name="N_mtlxsubtract1" type="float">
<input name="in1" type="float" interfacename="y2" />
<input name="in2" type="float" interfacename="y1" />
</subtract>
<output name="out" type="float" nodename="N_mtlxsqrt" />
</nodegraph>

<!-- ======================================================================== -->
<!-- Adjustment nodes -->
<!-- ======================================================================== -->
Expand Down