Browse Source

debuggers/magnum.natvis: display when a Vector2/3/4 is a unit vector

Added Float & Double overrides, so the other variants (Half & integer variants) are effectively untouched.
Added Dot() & IsNormalized() intrinsic functions for each entry.
The reason we need separate entries for Float & Double is because the epsilon values used for Dot() are different.
Epsilon values are taken directly from Magnum::Math::TypeTraits & they are added to & subtracted from 1.0, in order to avoid using abs(), which is prohibited in .natvis.
pull/623/head
fauder 3 years ago
parent
commit
37b8a8c1cb
  1. 48
      src/debuggers/natvis/magnum.natvis

48
src/debuggers/natvis/magnum.natvis

@ -38,16 +38,64 @@
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} }}</DisplayString>
<DisplayString ExcludeView="simple">{{ x={_data[0],g} y={_data[1],g} }}</DisplayString>
</Type>
<!-- Math::Vector2< Float > -->
<Type Name="Magnum::Math::Vector&lt;2,float&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99980000000500002&amp;Dot()&lt;1.0001999999950000"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} }}</DisplayString>
</Type>
<!-- Math::Vector2< Double > -->
<Type Name="Magnum::Math::Vector&lt;2,double&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99999999999998002&amp;Dot()&lt;1.0000000000000200"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} }}</DisplayString>
</Type>
<!-- Math::Vector3 -->
<Type Name="Magnum::Math::Vector&lt;3,*&gt;">
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g}, {_data[2],g} }}</DisplayString>
<DisplayString ExcludeView="simple">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} }}</DisplayString>
</Type>
<!-- Math::Vector3< Float > -->
<Type Name="Magnum::Math::Vector&lt;3,float&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]+_data[2]*_data[2]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99980000000500002&amp;Dot()&lt;1.0001999999950000"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} {_data[2],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} z={_data[2],g} }}</DisplayString>
</Type>
<!-- Math::Vector3< Double > -->
<Type Name="Magnum::Math::Vector&lt;3,double&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]+_data[2]*_data[2]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99999999999998002&amp;Dot()&lt;1.0000000000000200"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} {_data[2],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} z={_data[2],g} }}</DisplayString>
</Type>
<!-- Math::Vector4 -->
<Type Name="Magnum::Math::Vector&lt;4,*&gt;">
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g}, {_data[2],g}, {_data[3],g} }}</DisplayString>
<DisplayString ExcludeView="simple">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} w={_data[3],g} }}</DisplayString>
</Type>
<!-- Math::Vector4< Float > -->
<Type Name="Magnum::Math::Vector&lt;4,float&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]+_data[2]*_data[2]+_data[3]*_data[3]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99980000000500002&amp;Dot()&lt;1.0001999999950000"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} {_data[2],g} {_data[3],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} w={_data[3],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} z={_data[2],g} w={_data[3],g} }}</DisplayString>
</Type>
<!-- Math::Vector4< Double > -->
<Type Name="Magnum::Math::Vector&lt;4,double&gt;">
<Intrinsic Name="Dot" Expression="_data[0]*_data[0]+_data[1]*_data[1]+_data[2]*_data[2]+_data[3]*_data[3]"></Intrinsic>
<Intrinsic Name="IsNormalized" Expression="Dot()&gt;0.99999999999998002&amp;Dot()&lt;1.0000000000000200"></Intrinsic>
<DisplayString IncludeView="simple">{{ {_data[0],g}, {_data[1],g} {_data[2],g} {_data[3],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="!IsNormalized()">{{ x={_data[0],g} y={_data[1],g} z={_data[2],g} w={_data[3],g} }}</DisplayString>
<DisplayString ExcludeView="simple" Condition="IsNormalized()">{{ UNIT VECTOR x={_data[0],g} y={_data[1],g} z={_data[2],g} w={_data[3],g} }}</DisplayString>
</Type>
<!-- Math::BitVector2 -->
<Type Name="Magnum::Math::BitVector&lt;2&gt;">
<Intrinsic Name="at" Category="Method" Expression="(bool)((_data[0] &gt;&gt; i) &amp; 1)">

Loading…
Cancel
Save