-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Rework MeshLibary previews #80787
base: master
Are you sure you want to change the base?
Rework MeshLibary previews #80787
Conversation
The UX of these file dialogs with checkboxes at the bottom is really subpar. We should maybe see if we can reach consensus on whether #79313 is a good approach (Blender-like), and use this here too and in the project export dialog. Not blocking for this PR though, we can improve all these dialogs later on. |
After a bit of testing, this feels really good on small mesh libraries 👍 However, when selecting the scene where my GridMaps are used, after the initial opening, I get spammed with this type of errors:
It does not seem to affect anything however. Just curious, I'm pretty sure I was not getting those error before. The speedup improvement feels almost magical, I wonder how you pulled this off? The size diminution of the MeshLibraries is also very nice! |
EditorInterface's |
I might have found a regression with the preview: I have a MeshLibrary generated from this (messy) scene, where all the meshes are piled onto one another: With the new on-the-fly preview mode I get this result: Whereas, with the baked previews, I get this: EDIT: The bug disappeared after reopening the project... 🤔 |
Can't reproduce it. Can you share your scene?
Can you share the problematic mesh? |
Ok I can reliably reproduce this by:
By doing this, I also get the error message:
Test project (it's a big chuncky sorry, I did not clean it up) In this project, there are two meshlibs: floors.tres (with embedded previews) and floors2.tres with no custom previews EDIT: I also got a segfault while playing with this but I forgot to make a dump and I can't reproduce it right now |
I think I know what caused it. I'll make a fix. |
3c36cd3
to
76f0df6
Compare
I can reproduce the preview bug, but no idea why it happens. As for the crash, it might happen when you have GridMap selected and close the scene tab. But it seems to have existed before my PR. EDIT: |
76f0df6
to
7f9af2c
Compare
Sorry no luck reproducing the segfault... I'm getting another bug: The first time I select the GridMap, the panel is filled with empty textures. Probably from here? It disappears when I deselect, then re-select it. It does not seem that this happens on the embedded previews. EDIT: Call stack suggest there is a loop updatePalette() -> setItemPreview() -> emit_changed() -> update_palette() It does finish though. When I select one of the undefined textures, it seems to paint the first item of the mesh library (id 0 probably). It only happens once when you open the scene with the GridMap being unselected (so you have to save the scene with the root selected, for instance) and then select the GridMap. |
7f9af2c
to
1dfb62d
Compare
@geowarin Can you test again? I think I fixed the crash/empty items bug (they were related). |
@@ -1163,10 +1181,6 @@ void GridMapEditor::_item_selected_cbk(int idx) { | |||
} | |||
|
|||
void GridMapEditor::_floor_changed(float p_value) { | |||
if (updating) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I repurposed this bool for something else. It wasn't needed here anyway.
Got a backtrace for the segfault, it's exactly what you said it was:
GridMapEditor::edit(GridMap *p_gridmap) with p_gridmap being NULL |
Everything seems to be working fine! I'm still getting this harmless error after re-exporting a MeshLibrary and selecting the associated GridMap node for the first time but it is no longer spammed (only happens once):
Otherwise, previews are working fine. The tradeoff seems fine to me. On this example, generating the previews is near instantaneous and it only happens once, when loading the MeshLibrary. People using very big mesh libraries still have the option to bake the previews. My only concern is what happens when you are working on a MeshLibrary generated with version 4.1. For people to benefit from it, they will have to re-export their MeshLibraries is that correct? |
MeshLibraries from 4.1 have their previews stored inside the library and they will stay. |
Would it be possible to add an option to show the preview as only the flat texture of the material ? Like I have planes in 3D spaces placed as walls and floors and my previews are cut off, thus not being able to properly distinguish them from another.. |
That's out of scope of this PR. |
Fixes #76429
Depends on #80782
This PR adds a new property to MeshLibrary items:
use_custom_preview
. If disabled (default), thepreview
will not be saved with the resource. Instead the editor will auto-generate the previews every time the library is loaded and when it changes. This makes MeshLibrary resources much smaller, as the preview textures no longer get embedded 😬HxdZn1tdeU.mp4
It's not perfect, because when you change the mesh's material, not the mesh itself, the change will not be detected. You can however clear the preview manually and it will get auto-generated again.
godot.windows.editor.dev.x86_64_prlIl4xT81.mp4
Using
set_item_preview()
(bound) will automatically enable theuse_custom_preview
. Also I added an option that preserves the previous behavior of embedding previews:While this PR preserves API compatibility, if someone had custom previews in their MeshLibrary they need to enable
use_custom_preview
property for each item, otherwise the previews will be lost.Also this PR needs testing with large MeshLibrary with complex meshes. I reworked preview generation to be much faster, but I don't know if it's sufficiently fast.