RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.01k stars 175 forks source link

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

Closed ohlidalp closed 1 year ago

ohlidalp commented 1 year ago

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:

ohlidalp commented 1 year ago

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

AnotherFoxGuy commented 1 year ago

A few bugs I've noticed while testing this:

ohlidalp commented 1 year ago

obrazek Fixes and retouches:

ohlidalp commented 1 year ago

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

tritonas00 commented 1 year ago

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 commented 1 year ago

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

tritonas00 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

tritonas00 commented 1 year ago

No crash now :+1: