Skip to content

Make MeshLibrary use PropertyListHelper#116736

Open
YeldhamDev wants to merge 1 commit intogodotengine:masterfrom
YeldhamDev:mesh_library_list_helper
Open

Make MeshLibrary use PropertyListHelper#116736
YeldhamDev wants to merge 1 commit intogodotengine:masterfrom
YeldhamDev:mesh_library_list_helper

Conversation

@YeldhamDev
Copy link
Member

This PR ports from the old way MeshLibrary uses to show (common properties in the inspector) and manipulate (options inside a dropdown in the toolbar) its data, to instead using PropertyListHelper (already used in stuff like PopupMenu, TileMap, etc). Allowing to easily create, delete, and move items.

Screenshot_20260224_173242

@KoBeWi
Copy link
Member

KoBeWi commented Feb 24, 2026

Uh... #115281
(I should've mentioned PropertyListHelper somewhere I guess)

@YeldhamDev
Copy link
Member Author

YeldhamDev commented Feb 24, 2026

Well, shit...

But hey, due to mine being more recent, there are no file conflicts at least... 🫠

EDIT: Testing your version, I actually can't add nor remove elements, and the dropdown options for that are still present.

@YeldhamDev YeldhamDev force-pushed the mesh_library_list_helper branch from 28a9c26 to 497a6e4 Compare February 24, 2026 22:28
@YeldhamDev YeldhamDev requested a review from a team as a code owner February 24, 2026 22:28
@YeldhamDev YeldhamDev marked this pull request as draft February 24, 2026 22:58
@YeldhamDev

This comment was marked as resolved.

@YeldhamDev YeldhamDev force-pushed the mesh_library_list_helper branch from 497a6e4 to a695d14 Compare February 25, 2026 00:33
@YeldhamDev YeldhamDev marked this pull request as ready for review February 25, 2026 00:35
@YeldhamDev
Copy link
Member Author

Alright, good news: it can now handle the gaps between indexes.
Bad news: It does by filling the gaps with empty items. Not ideal.

It's in a state where it could be merged, but the ideal solution would be that when a library with gaps is detected, it would be shrunk, and any GridMap that uses it would be updated with the new indexes.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

When deleting an element, all elements after it will be shifted, causing the GridMaps to become scrambled. I suppose this is the reason why MeshLibrary is using a sparse array. Your PR ignores that completely, my PR tries to keep this characteristic, albeit with limited results.

tbh the MeshLibrary as it is now reminds me of the old TileSet. Each tile is a separate entity in a very loose list. The main problem is that there is no proper editor for MeshLibrary at all and editing the properties in the inspector is a workaround, and not a very friendly one. The MeshLibrary properties should not be in the inspector at all, but right now there is no better way to edit them.

That said, if we ever want to add a dedicated editor, adding PropertyListHelper does not conflict with it (see #92472), so this PR should be fine (if we accept GridMap scrambling xd). It's also more functional than my one.

uint32_t navigation_layers = 1;
};

RBMap<int, Item> item_map;
Copy link
Member

Choose a reason for hiding this comment

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

This should be probably changed to LocalVector, since the structure can no longer have holes.

Comment on lines +47 to +49
if (!item_map.has(idx)) {
set_item_count(idx + 1);
}
Copy link
Member

Choose a reason for hiding this comment

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

This is technically unsafe. If the missing index is a hole, the further items will get erased if they were already assigned. Unlikely to happen with normal usage though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been testing this PR with this project: https://github.com/Nodragem/top-down-action-adventure-starter-kit

It has a library with separate gaps across it, and it didn't result in any data loss while manipulating it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, they'd need to be loaded out of order, which can only happen if you manually reorder them or due to some bug.

@YeldhamDev YeldhamDev force-pushed the mesh_library_list_helper branch 2 times, most recently from 2d06a87 to 25b0207 Compare February 25, 2026 19:20
@YeldhamDev
Copy link
Member Author

I introduced a little hack to avoid polluting the GridMap editor: items that are created to fill gaps have a new property called hide_from_list set to true. As the name implies, it hides those items from get_item_list(), which is what GridMap editor uses.


The main problem is that there is no proper editor for MeshLibrary at all and editing the properties in the inspector is a workaround, and not a very friendly one. The MeshLibrary properties should not be in the inspector at all, but right now there is no better way to edit them.

You bring a good point. Maybe the way to go would simply be creating a proper editor for MeshLibrary. It wouldn't need to be too complex, just a grid of items to the left, and an inspector for them to the right, with a toolbar at the top for item creation/deletion.

@YeldhamDev YeldhamDev force-pushed the mesh_library_list_helper branch from 25b0207 to c4b3207 Compare February 25, 2026 19:46
@YeldhamDev YeldhamDev force-pushed the mesh_library_list_helper branch from c4b3207 to b40e9ae Compare February 25, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants