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

New UI panel: CollisionsDebug (top menubar > tools) #2939

Merged
merged 12 commits into from
Sep 19, 2022

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Sep 16, 2022

Current "Debug Collisions" overlay (cvar 'diag_debug_collisions') is non-interactive, laggy and with hard-to-read text labels.

The new CollisionsDebugUI allows enabling/disabling the overlays interactively and draws labels using DearIMGUI (like net labels.)
obrazek

Changes:

  • created the new GUI window, with all visibility/hover/update mechanics (it's getting convoluted).
  • ported the eventbox visiualization code from Collisions.cpp to the new GUI window. Boxes remain meshed, labels are DearIMGUI.
  • ported collision mesh view. Collision triangles are visualized as orange objects, same as before. Labels are drawn by DearIMGUI. Unlike before, the triangles aren't one mega-mesh covering whole map, but individual meshes. Visibility range can be adjusted in UI.
  • ported lookup grid view. Reused old code in Collisions.cpp, just added root node to control visibility and fixed drawing distance.

Current "Debug Collisions" overlay (cvar 'diag_debug_collisions') is non-interactive, laggy and with unreadable text labels.

The new CollisionsDebugUI allows enabling/disabling the overlays interactively and draws labels using DearIMGUI (like net labels.)

Changes in this commit:
* created the new GUI window, with all visibility/hover/update mechanics (it's getting convoluted).
* ported the eventbox visiualization code from Collisions.cpp to the new GUI window. Boxes remain meshed, labels are DearIMGUI.
Collision triangles are visualized as orange objects, same as before. Labels are drawn by DearIMGUI. Unlike before, the triangles aren't one mega-mesh covering whole map, but individual meshes. Visibility range can be adjusted in UI.
@ohlidalp
Copy link
Member Author

ohlidalp commented Sep 17, 2022

The grid visualization debug view is amusing because it neatly visualizes how inefficient the grid system is. Map is dividied into 2x2meter blocks (works only horizontally! height is unlimited!), each having an unlimited capacity for collision triangles. The shade of green/yellow/red indicates occupancy (green = 0, red=CELL_BLOCKSIZE(146)). Naturally, a much better system would be a search tree where collision triangles are distributed evenly.
Screenshot shows an unfinished UI.
obrazek

Reused old code in Collisions.cpp, just added root node to control visibility and fixed drawing distance.

This debug view is amusing because it documents how useless the grid system is. Map is dividied into 2x2meter blocks (works only horizontally! height is unlimited!), each having an unlimited capacity for collision triangles. The shade of green/yellow/red indicates occupancy (green = 0, red=CELL_BLOCKSIZE(146)). Naturally, a much better system would be a search tree where collision triangles are distributed evenly.
@ohlidalp ohlidalp requested a review from tritonas00 September 17, 2022 09:17
@ohlidalp ohlidalp marked this pull request as ready for review September 17, 2022 09:17
@AnotherFoxGuy
Copy link
Member

A few bugs I've noticed while testing this:

  • Show lookup cells crashes if you switch terrains
  • The checkboxes don't reset on terrain switch

@ohlidalp
Copy link
Member Author

ohlidalp commented Sep 17, 2022

obrazek
Fixes and retouches:

  • CollisionsDebug: factored out funcs SetDrawFoo(), ClearFooVisuals().
  • Collisions.cpp: material gen code moved to CollisionsDebugUI, with duplication check.
  • Fixed missing cleanup of cell meshes.
  • Added "dump debug meshes" rescue buttons - especially important for cells.
  • Fixed cleanup on terrain unload.
  • Added auto-hide on UI close.

Added constant DEFAULT_DRAWDIST=200 for all debug meshes.
CollisionsDebug: factored out funcs `SetDrawFoo()`, `ClearFooVisuals()`.
Collisions.cpp: material gen code moved to CollisionsDebugUI, with duplication check.
Fixed missing cleanup of cell meshes.
Added "dump debug meshes" rescue buttons - especially important for cells.
@ohlidalp
Copy link
Member Author

ohlidalp commented Sep 17, 2022

Final version: procedural roads are included, and there are additional display options for labels.
obrazek

@tritonas00
Copy link
Collaborator

Works fine and looks great. Only "Show look up cells" crashes here, no segfault just:

COLL: Creating collision debug visualization ...
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Maybe my machine can't handle it.

@ohlidalp
Copy link
Member Author

@tritonas00 That looks like you're out of memory, try on smaller map and I'll add exception-check code to make sure.

Copy link
Member

@AnotherFoxGuy AnotherFoxGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work fine

@tritonas00
Copy link
Collaborator

tritonas00 commented Sep 18, 2022

@tritonas00 That looks like you're out of memory, try on smaller map and I'll add exception-check code to make sure.

Ok cells show fine in auriga, can you try on f1 testtrack?

Probably im out of gpu memory

0x00007ffff3714cea in ?? () from /usr/lib/dri/crocus_dri.so
(gdb) bt
#0  0x00007ffff3714cea in ?? () from /usr/lib/dri/crocus_dri.so
#1  0x00007ffff3715f6e in ?? () from /usr/lib/dri/crocus_dri.so
#2  0x00007ffff534047b in Ogre::GLHardwareVertexBuffer::GLHardwareVertexBuffer (this=this@entry=0x5555678cc0f0, mgr=mgr@entry=0x555555f52890, 
    vertexSize=vertexSize@entry=20, numVertices=numVertices@entry=6, usage=usage@entry=Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
    useShadowBuffer=useShadowBuffer@entry=false)
    at /home/babis/Downloads/ror-dependencies/Source/ogre/RenderSystems/GL/src/OgreGLHardwareVertexBuffer.cpp:51
#3  0x00007ffff533a5b9 in Ogre::GLHardwareBufferManager::createVertexBuffer (this=0x555555f52890, vertexSize=20, numVerts=6, 
    usage=Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY, useShadowBuffer=<optimized out>)
    at /home/babis/Downloads/ror-dependencies/Source/ogre/RenderSystems/GL/src/OgreGLHardwareBufferManager.cpp:81
#4  0x00007ffff7826c95 in Ogre::ManualObject::end (this=0x5555678cb820)
    at /home/babis/Downloads/ror-dependencies/Source/ogre/OgreMain/src/OgreManualObject.cpp:682
#5  0x00005555558b816e in RoR::Collisions::createCollisionDebugVisualization (this=<optimized out>, root_node=<optimized out>, 
    out_nodes=std::vector of length 64423, capacity 65536 = {...})
    at /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/physics/collision/Collisions.cpp:1337
#6  0x00005555557b2470 in RoR::GUI::CollisionsDebug::SetDrawCollisionCells (this=0x55555656a6f8, val=<optimized out>)
    at /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/gui/panels/GUI_CollisionsDebug.cpp:463
#7  0x00005555557b3687 in RoR::GUI::CollisionsDebug::Draw (this=this@entry=0x55555656a6f8)
    at /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/gui/panels/GUI_CollisionsDebug.cpp:122
#8  0x0000555555719d7e in RoR::GUIManager::DrawSimulationGui (this=0x55555656a6f0, dt=dt@entry=0.00567517569)
    at /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/gui/GUIManager.cpp:145
#9  0x00005555555f2983 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/main.cpp:929

@ohlidalp
Copy link
Member Author

@tritonas00 can you try on f1 testtrack?

Well, duh, it's a meshed map, so it's covered entirely in debug meshes.
obrazek

Heck, I'll stop being lazy and do the thing in DearIMGUI.

@tritonas00
Copy link
Collaborator

tritonas00 commented Sep 18, 2022

@tritonas00 can you try on f1 testtrack?

Well, duh, it's a meshed map, so it's covered entirely in debug meshes. ![obrazek](https://user-

Heck, I'll stop being lazy and do the thing in DearIMGUI.

Meh its fine, my integrated intel gpu just can't handle it

@ohlidalp
Copy link
Member Author

Laziness wins... I curbed the collision cell problem by clamping it to area around rorbot.
obrazek

@tritonas00
Copy link
Collaborator

No crash now 👍

@ohlidalp ohlidalp merged commit 5709944 into RigsOfRods:master Sep 19, 2022
@ohlidalp ohlidalp deleted the debug-collisions branch September 19, 2022 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants