amethyst / specs

Specs - Parallel ECS
https://amethyst.github.io/specs/
Apache License 2.0
2.49k stars 219 forks source link

How to visualize the storage while debugging? #715

Open selvavm opened 3 years ago

selvavm commented 3 years ago

First of all, this is a wonderful crate. I loved working on it and it forces me to follow the ECS principles. Thanks for your contribution,

My Setup: I have N entities and I modify components using couple of systems independently using Dispatchers. Once it is completed, I have to pick some entities and derive some metrics (see below).

 // For example, after dispatcher I wanted to get the total heath and then end the program
 let health_storage = world.read_component::<Health>();
 let pl1_health = health_storage.get(pl1).unwrap(); // I want to avoid this
 let pl2_health = health_storage.get(pl2).unwrap(); // I want to avoid this
 let total_health = pl1_health + pl2_health;
 println!("{}", total_health);
 // Since I am working with multiple entities, I didnt do these lines as a system
 // When I set breakpoint, health_storage is shown as pointers

Now the challenge is, if I debug this using Visual C++ or llvm in VSCode, the health_storage is not showing the values. It only shows pointers and I have to use get(Entity) to visualise. I would have been happy if I can execute the command directly while debugging (like watch commands) but Rust has issues with calling trait functions.

Recently, I came to know about NatViz which help in improving visualisation while using Visual C++ debugger. In fact, I modified it to support NDArray and it works like a charm. I wanted to do the same with Storage but don't know how to list the entities-component pair. Can you help me?

image

One more question, how do you guys debug? Do you use println!?