Jump to content

C++ Leadwerks 5 showing only needed variables for Entities in debug


In Leaderks 5 debugger shows 2-3 times more variables for Entity based class instances that you screen can show without scrolling. Luckily i found a way to change it via .natvis files:

https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022

Example natvis xml code for Pivot:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

<Type Name="Leadwerks::Light">
    <DisplayString>
      name={name}
    </DisplayString>
    <Expand>
      <Item Name="name">name</Item>
      <Item Name="uuid" Condition="uuid.size()>0">uuid</Item>
      <Item Name="tags" Condition="tags._Mypair._Myval2._Myval2._Mysize!=0">tags</Item>

      <Item Name="position">position</Item>
      <Item Name="rotation">rotation</Item>

      <Item Name="parent" Condition="parent._Ptr != nullptr">parent</Item>
      <Item Name="kids" Condition="kids.size()>1">kids</Item>
      <Item Name="kid" Condition="kids.size()==1">kids[0]</Item>
      <Item Name="components" Condition="components.size()>1">components</Item>
      <Item Name="component" Condition="components.size()==1">components[0]</Item>

      <Item Name="color">color</Item>
      <Item Name="is hidden">hidestate</Item>
      <Item Name="render layers">renderlayers</Item>

      <Item Name="range">range</Item>
      <Item Name="cone angles">coneangles</Item>
      <Item Name="shadow map size">shadowmapsize</Item>

    </Expand>
  </Type>

</AutoVisualizer>

Display string - what you see as value of object without expanding it

Item - field for expanded object. With Condition it may or not be shown.

For String and Vectors you can use size() function, but for std::Set you need to use "_Mypair._Myval2._Myval2._Mysize"

For shared_ptr "_Ptr != nullptr"

Order in this file will decide order in debug.

To show parent class as expandable object you can use:

<Item Name="[Entity]">(Leadwerks::Entity&amp;)*this</Item>

 

Just make .natvis file and include it to Project to make it work. You can change it while debugging to see changes immediately. If you did something wrong then usual fields will be shown.

I made these files for all entities and Vec[2,3,3], iVec[2,3,3] classes: Visualizers.zip

You can also just put .natvis files to %UserProfile%\Documents\Visual Studio 2022\Visualizers folder and it will work for every project.

This is how entity vars will look:

image.thumb.png.fbda4ba98a02a808609a5a46039a285e.png

  • Like 1

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...