Feature Request: Create bitmasks for all meshinstance3d children
I think it'd be really handy if there was a fast way to set up an imported tilegrid that created and then set bitmasks for you. Lemme show you what I mean.
Here you can see I've added a button to the AutoGrid panel called "Quick Setup". All it does is iterate through children and add bitmasks.
func fast_setup() -> void:
if( editMode == false ):
print( "--- AUTOGRID ERROR --- Turn Edit Mode on." )
return
var children = get_editor_interface().get_edited_scene_root().get_children()
if children.size() == 0:
print("--- AUTOGRID ERROR --- Empty scene!")
return
for child in children:
if child.name.ends_with("_agrid"):
print( "--- AUTOGRID ERROR --- Autotile already generated." )
return
# End defensive returns
for child in children:
if( child.has_node("AutoGrid_Bitmask") == false ):
activateButton.create_bitmask( child )
child.get_node( "AutoGrid_Bitmask" ).hide()
child.get_node( "AutoGrid_Bitmask" ).deactivate()
There are a few additional features that I think would be good for this tool.
- Generating Trimesh static bodies for each mesh. I can't seem to find the function to do this, but you can select all the nodes and then select the option to generate the mesh for all of them. Still, that button would be great for expediting the process.
- Setting the bitmasks if it detects a valid name. You'll notice that my scene has nodes that are named binary numbers representing a bitmask. It's not a long enough name for a full bitmask, of course, but we could make an exception case where if the name is "eight binary digits long", then we'd assign bitmasks according to the currently selected AutoTile Axes in that right edge tab.
The only reason that I didn't move forward with implementing feature 2 myself is because apparently you represent bitmasks differently from how I learned on the web. A resource I found online taught me about starting from the top left corner (0x01) and proceeding left-to-right, row-by-row, until I arrive at the bottom-right corner (0x80). Your bitmasks sort of "spiral" upward, instead, it seems? If I'm understanding that right, I'd love to learn more about how it works!
By the way, are you interested in including collaborators on this plugin? If you prefer I stick with a fork, I can certainly do that, instead.
Thanks for the feature request. I have made this plugin to just have an autotile implementation of TileMap node. I am still missing some extra features but I don't know how to do them yet. With that in mind, let's continue with your feature requests:
- Quick Setup: I will implement this feature, it would be very boring job to create bitmasks for each tile. Creating bitmasks for each tile in demo project was tiring. I think instead of creating a new button, it will be easy to create bitmasks for every selected mesh instance nodes otherwise we have to force the user to have only tiles in that scene.
- Generating Trimesh static bodies: I have never used this before and as I can understand you can already select multiple mesh instance nodes and click once to generate a static body for each mesh instance node. As I said at the start, this plugin's goal is implement and possibly expand TileMap's autotile system. If I implement this feature there will be a button or some control node which not everyone will use, this feature is great for some users but not for everyone. And when qucik setup feature implemented you can click quick setup and then click generate trimesh to create both bitmasks and trimeshes for every selected mesh instances.
- Setting the bitmasks by name: I don't think it is a good idea to change tile names while creating auto grid information (or otherwise). The user might have a tile name specific codes and it will be hard to distinguish tiles when multiple tileset have same names. And it is hard to find a tile that way (when your "top-left grass" tile renames to binary). But I like the idea of automatically setting the bitmasks, I was thinking of implementing something like this but I think I couldn't find a signal which fires when scene changes in editor. I will look into this again.
I made bitmasks the way it came to my mind. I am sorry for this, it will make things a little hard. I am struggling to remember the bit order but you are right, it goes sort of spiral. Actually, bit value calculated by children order of the "AutoGrid_Bitmask" node. If you check "bitmask_holder.gd" script, calculate_bit_value() function, you can see top most child is the right most bit. Autotile algorithm is the same as TileMap node's autotile algorithm, I just extended it for 3D.
I will be grateful for collaborations, it will make things easier and faster.
In new version (v1.3) I have added quick setup feature. You just need to select MeshInstance nodes then AutoGrid/Create Bitmask to create bitmasks for each selected MeshInstance, same goes for removing.
I implemented automatically reloading autotile info with scene changes but then removed it because it reloads everytime, this can cause some trouble if you are switching scenes and didn't save autotile info, all your painted bitmasks will revert itself.
I will be waiting for your feedback on new version, if there won't any response in a month, I will consider this done and close the issue.