Closed ohlidalp closed 1 year ago
While looking at the debug view I created, I figured an optimization. Most often, many vertices bind to the same REF/VX/VY nodes, so for optimal CPU cache usage, they should be processed together. However, currently they are processed in the order of vertices in the mesh, which is random, depending on the modelling tool and exporter. I wanted to actually see it, so I created a visualization:
Next step - defragment the memory! Meaning: reorder vertices in the mesh (it's possible on runtime, I've already done it once) to match the nodes. The result will be visible in this diagram.
I implemented the "defragmentation" of flexbody vertex locators. Figuring out a sensible sorting algorithm was a challenge, and I'm still not happy with the result. Figuring out how to fix the mesh for the reordered vertices was another challenge, and coding it was extremely hard because I kept mixing things together. Don't touch the "Invert index lookup" checkbox! 😄
In the image below, the vertex locators are reordered but texcoords aren't (checkbox is off), resulting in an artistic effect.
Vehicle on display: Ford Tudor Army https://forum.rigsofrods.org/resources/1949-ford.283/
No crashes or errors to report.
A minor thing, but when inspecting vertices and picking some with your mouse you can immediately deselect them. However, when unchecking the "Vertices" box after selecting a few vertices, the vertices can no longer be unselected (after rechecking the "Vertices" box) without browsing through the vertex locator table and unselecting them there.
The defragmentation tool works without issue with the defaults, unselecting any or all of the 3 optimizations results in some interesting effects as you've noted in your previous reply. Not sure if this is intended or not.
Purpose: To visually explain how flexbodies work and help modders diagnose them.
Estimate: 1 man day. It all works.
Is the "hide others" option meant to show only the selected flexbody? if so it doesn't work:
Upon testing to see if it works with
nodes2
, I found an extreme use case: the high poly count of the 1971 DI Banger Brambler Package causes the frame rate to plummet when activating the debug views:
This most likely can't be "fixed" but could be an easy way to test further optimization.
Otherwise it seems to work fine. The per-material wireframe mode is neat.
@CuriousMike Is the "hide others" option meant to show only the selected flexbody? if so it doesn't work: (Desperado buggy)
It actually works perfectly, but what you're looking at aren't flexbodies
but props
:smile: But I admit it's confusing, so I added props to the list, too:
Yes, there's a glitch - props outside of
props
(like wheel rims) aren't accounted for, but I'll fix that after this PR.
@CuriousMike56 the high poly count ... causes the frame rate to plummet when activating the debug views
That's because I'm drawing all those as circles using DearIMGUI (circa 6 triangles each, antialiased). Using raw vertex buffer would be much faster and would look pretty much equivalent in this case. But presently all our debug views work like this, I'll deal with this in the future if it troubles users.
@CuriousMike56 Anyway, thanks for the thorough testing!
Still can't get the hide others option to work, tried multiple vehicles with plenty of flexbodies 😕
@CuriousMike56 Looks like it doesn't work at all for you... very strange. Try disabling PSSM, Envmap, and setting all visuals to lowest levels.
@only-a-ptr Turns out realtime reflections breaks it, works fine with it disabled:
@CuriousMike56 Turns out realtime reflections breaks it, works fine with it disabled
Makes sense, all meshes must be hidden when rendering the reflections, otherwise they would obscure the view for the reflection-cameras. I fixed it by pausing reflections while "Hide all" is active, test once more please.
Now enabling "hide other" on the first entry on the list causes all flexbodies to disappear, leaving only the props:
All other flexbodies appear as normal:
Occurs with reflections enabled or disabled.
First flexbody not appearing still persists (showing N/B view as the vehicle becomes completely invisible)
@CuriousMike56 First flexbody not appearing still persists
Fixed.
This tool lets you inspect individual vertices and their generated bindings. Just hover mouse pointer over a vertex and see. Click the vertex to toggle persistent visibility. Closes #2923.
Vehicle on display: https://forum.rigsofrods.org/resources/honda-accord.281/