-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from 4J-company/feature/debug-visualizers
Add debug visualization for structs (Visual Studio)
- Loading branch information
Showing
6 changed files
with
260 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#ifndef __MR_DEBUG_HPP_ | ||
#define __MR_DEBUG_HPP_ | ||
|
||
// This file provides template instantiations used by debug visualizers | ||
// and is intended for debug builds only | ||
|
||
#include "vec.hpp" | ||
|
||
namespace mr { | ||
namespace debug { | ||
|
||
// following functions instantiate methods of template structs desired in debug visualization | ||
|
||
inline namespace row { | ||
|
||
void instantiate_row_get(const auto& row) { | ||
volatile auto x = row.get(0); (void)x; | ||
} | ||
|
||
#define MR_INSTANTIATE_ROW2(T) template void instantiate_row_get(const Row<T, 2>&) | ||
#define MR_INSTANTIATE_ROW3(T) template void instantiate_row_get(const Row<T, 3>&) | ||
#define MR_INSTANTIATE_ROW4(T) template void instantiate_row_get(const Row<T, 4>&) | ||
#define MR_INSTANTIATE_ROW2_ROW3_ROW4(T) MR_INSTANTIATE_ROW2(T); MR_INSTANTIATE_ROW3(T); MR_INSTANTIATE_ROW4(T) | ||
|
||
// instantiate types | ||
MR_INSTANTIATE_ROW2_ROW3_ROW4(float); | ||
MR_INSTANTIATE_ROW2_ROW3_ROW4(double); | ||
MR_INSTANTIATE_ROW2_ROW3_ROW4(int); | ||
MR_INSTANTIATE_ROW2_ROW3_ROW4(uint32_t); | ||
|
||
} // namespace row | ||
|
||
inline namespace vec { | ||
|
||
void instantiate_vec_x_y_length(const auto& vec) { | ||
volatile auto x = vec.x(); (void)x; | ||
volatile auto y = vec.y(); (void)y; | ||
volatile auto l = vec.length(); (void)l; | ||
} | ||
|
||
void instantiate_vec_x_y_z_length(const auto& vec) { | ||
instantiate_vec_x_y_length(vec); | ||
volatile auto z = vec.z(); (void)z; | ||
} | ||
|
||
void instantiate_vec_x_y_z_w_length(const auto& vec) { | ||
instantiate_vec_x_y_z_length(vec); | ||
volatile auto w = vec.w(); (void)w; | ||
} | ||
|
||
#define MR_INSTANTIATE_VEC2(T) template void instantiate_vec_x_y_length(const Vec2<T>&) | ||
#define MR_INSTANTIATE_VEC3(T) template void instantiate_vec_x_y_z_length(const Vec3<T>&) | ||
#define MR_INSTANTIATE_VEC4(T) template void instantiate_vec_x_y_z_w_length(const Vec4<T>&) | ||
#define MR_INSTANTIATE_VEC2_VEC3_VEC4(T) MR_INSTANTIATE_VEC2(T); MR_INSTANTIATE_VEC3(T); MR_INSTANTIATE_VEC4(T) | ||
|
||
// instantiate types | ||
MR_INSTANTIATE_VEC2_VEC3_VEC4(float); | ||
MR_INSTANTIATE_VEC2_VEC3_VEC4(double); | ||
MR_INSTANTIATE_VEC2_VEC3_VEC4(int); | ||
MR_INSTANTIATE_VEC2_VEC3_VEC4(uint32_t); | ||
|
||
} // namespace vec | ||
|
||
inline namespace norm { | ||
|
||
void instantiate_norm_x_y(const auto& norm) { | ||
volatile auto x = norm.x(); (void)x; | ||
volatile auto y = norm.y(); (void)y; | ||
} | ||
|
||
void instantiate_norm_x_y_z(const auto& norm) { | ||
instantiate_norm_x_y(norm); | ||
volatile auto z = norm.z(); (void)z; | ||
} | ||
|
||
void instantiate_norm_x_y_z_w(const auto& norm) { | ||
instantiate_norm_x_y_z(norm); | ||
volatile auto w = norm.w(); (void)w; | ||
} | ||
|
||
#define MR_INSTANTIATE_NORM2(T) template void instantiate_norm_x_y(const Norm2<T>&) | ||
#define MR_INSTANTIATE_NORM3(T) template void instantiate_norm_x_y_z(const Norm3<T>&) | ||
#define MR_INSTANTIATE_NORM4(T) template void instantiate_norm_x_y_z_w(const Norm4<T>&) | ||
#define MR_INSTANTIATE_NORM2_NORM3_NORM4(T) MR_INSTANTIATE_NORM2(T); MR_INSTANTIATE_NORM3(T); MR_INSTANTIATE_NORM4(T) | ||
|
||
// instantiate types | ||
MR_INSTANTIATE_NORM2_NORM3_NORM4(float); | ||
MR_INSTANTIATE_NORM2_NORM3_NORM4(double); | ||
MR_INSTANTIATE_NORM2_NORM3_NORM4(int); | ||
MR_INSTANTIATE_NORM2_NORM3_NORM4(uint32_t); | ||
|
||
} // namespace norm | ||
|
||
inline namespace bounb_box { | ||
|
||
void instantiate_aabb_dimensions(const auto& aabb) { | ||
volatile auto d = aabb.dimensions(); (void)d; | ||
} | ||
|
||
#define MR_INSTANTIATE_AABB(T) template void instantiate_aabb_dimensions(const AABB<T>&) | ||
|
||
// instantiate types | ||
MR_INSTANTIATE_AABB(float); | ||
MR_INSTANTIATE_AABB(double); | ||
MR_INSTANTIATE_AABB(int); | ||
MR_INSTANTIATE_AABB(uint32_t); | ||
|
||
} // namespace norm | ||
|
||
} // namespace debug | ||
} // namespace mr | ||
|
||
#endif // __MR_DEBUG_HPP_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> | ||
|
||
<!-- mr::Row2 --> | ||
<Type Name="mr::Row<*, 2>"> | ||
<DisplayString>{{{get(0)}, {get(1)}}}</DisplayString> | ||
<Expand> | ||
<Item Name="[0]">get(0)</Item> | ||
<Item Name="[1]">get(1)</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Row3 --> | ||
<Type Name="mr::Row<*, 3>"> | ||
<DisplayString>{{{get(0)}, {get(1)}, {get(2)}}}</DisplayString> | ||
<Expand> | ||
<Item Name="[0]">get(0)</Item> | ||
<Item Name="[1]">get(1)</Item> | ||
<Item Name="[2]">get(2)</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Row4 --> | ||
<Type Name="mr::Row<*, 4>"> | ||
<DisplayString>{{{get(0)}, {get(1)}, {get(2)}, {get(3)}}}</DisplayString> | ||
<Expand> | ||
<Item Name="[0]">get(0)</Item> | ||
<Item Name="[1]">get(1)</Item> | ||
<Item Name="[2]">get(2)</Item> | ||
<Item Name="[3]">get(3)</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Vec2 --> | ||
<Type Name="mr::Vec<*, 2>"> | ||
<DisplayString>{{{x()}, {y()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
<Item Name="Length">length()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Vec3 --> | ||
<Type Name="mr::Vec<*, 3>"> | ||
<DisplayString>{{{x()}, {y()}, {z()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
<Item Name="Z">z()</Item> | ||
<Item Name="Length">length()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Vec4 --> | ||
<Type Name="mr::Vec<*, 4>"> | ||
<DisplayString>{{{x()}, {y()}, {z()}, {w()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
<Item Name="Z">z()</Item> | ||
<Item Name="W">w()</Item> | ||
<Item Name="Length">length()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Norm2 --> | ||
<Type Name="mr::Norm<*, 2>"> | ||
<DisplayString>{{{x()}, {y()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Norm3 --> | ||
<Type Name="mr::Norm<*, 3>"> | ||
<DisplayString>{{{x()}, {y()}, {z()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
<Item Name="Z">z()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Norm4 --> | ||
<Type Name="mr::Norm<*, 4>"> | ||
<DisplayString>{{{x()}, {y()}, {z()}, {w()}}}</DisplayString> | ||
<Expand> | ||
<Item Name="X">x()</Item> | ||
<Item Name="Y">y()</Item> | ||
<Item Name="Z">z()</Item> | ||
<Item Name="W">w()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Radians --> | ||
<Type Name="mr::Radians<*>"> | ||
<DisplayString>{_data} rad</DisplayString> | ||
</Type> | ||
|
||
<!-- mr::Degrees --> | ||
<Type Name="mr::Degrees<*>"> | ||
<DisplayString>{_data} deg</DisplayString> | ||
</Type> | ||
|
||
<!-- mr::Color --> | ||
<Type Name="mr::Color"> | ||
<DisplayString>R={r()}, G={g()}, B={b()}, A={a()}}</DisplayString> | ||
<Expand> | ||
<Item Name="R">r()</Item> | ||
<Item Name="G">g()</Item> | ||
<Item Name="B">b()</Item> | ||
<Item Name="A">a()</Item> | ||
<Item Name="Hex">(uint32_t(r() * 255) << 24) + (uint32_t(g() * 255) << 16) + (uint32_t(b() * 255) << 8) + (uint32_t(a() * 255)), Xb</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::AABB --> | ||
<Type Name="mr::AABB<*>"> | ||
<DisplayString>{min} : {max}</DisplayString> | ||
<Expand> | ||
<Item Name="Min">min</Item> | ||
<Item Name="Max">max</Item> | ||
<Item Name="Dimensions">dimensions()</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<!-- mr::Matr --> | ||
<Type Name="mr::Matr<*, *>"> | ||
<DisplayString>{_data[0]} ...</DisplayString> | ||
<Expand> | ||
<Item Name="Rows">_data</Item> | ||
</Expand> | ||
</Type> | ||
|
||
</AutoVisualizer> |