-
Notifications
You must be signed in to change notification settings - Fork 15
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
TileMapDual v5 #16
Comments
I added the "help wanted" label because I am afraid I do not have enough experience with hex grids, and sadly I am too busy these weeks to figure it out... |
Ok so the main problem here is that the Dual Layer is Hexagonal, but the Display Layer is Triangular/Square with different dimensions. This essentially means we have to store 2 separate TileSets, and... sync them... Things like changing the Z-Axis of specific tiles might be important to someone later on, among other things in whatever data layers there are. I'll have to figure out how to deep copy a TileSet before anything else can be done. Edit: praise be |
@pablogila I basically had to rewrite the whole grid system for this... Hex Grid Github branch here. The grid now automatically creates Terrains for any given TileSet if it recognizes the layout. This works for Square, Isometric, and most importantly Hexagonal templates, and supports multiple atlases too. I'm currently rewriting the whole Dual Grid system itself, as well. By the end of this patch, 80 to 90% of the code will look entirely different... auto.hex.terrain.mp4Most of the code is now very modular. I have a Grids.gd file that stores all the important information about each kind of tiling. Templates, offsets, and neighbors for Square, Isometric, Half Offset Squares and Hexagonal grids with Vertical and Horizontal axes... but not all of the data are filled in yet. The different layouts (Stacked, Stacked Offset, Stairs Right/Down, etc...) are different coordinate systems where the x,y positions have quirky logic for each one, which means I can't easily fake the dual grid with a smaller rectangular grid. So now I will resort to storing 2 separate display grids for Hex (and later Half Offset Square) As for the update logic, I don't have anything yet, but that will come next. Basically it will:
|
This is super cool! I ported the code into a regular addon to make it easier to work with a modular structure, I really love seeing contributions go this way! At this point, it might be interesting to create a state machine to handle each grid layout. This would definitely make them easier to implement and, most importantly, much easier to maintain. One of my biggest fears now is touching a line of code for square tiles that breaks the hex implementation and so on. A state machine might be a solution for this. What should be the logic behind it is definitely a thing to check. I might be a bit lost in the hex part of the implementation, but I can definitely work on the square and iso stuff! I'm upgrading my laptop this weekend, so I don't have my usual tools yet, but I'll get into it as soon as I can. You are introducing some really cool ideas, that is so nice! |
This is very ambitious... I'll just call it what it is. I initially just wanted to implement hex grids, but now this project will probably have to stay as a fork. I'm not sure if making a pull request would make sense, since it's entirely different. Repo branch here: |
It makes sense as long as the end user does not notice the difference. For now, it is definitely wiser to work in a fork. I will check the code and try to contribute what I can. Let's see what comes of it! |
@pablogila This took 10 whole days... The reason this is so complicated is because of all the custom terrain auto-generation stuff. It's actually probably slower than your code because it stores a whole mapping for every valid combination of tiles. I think it's way too complicated for a simple 2-tile terrain, but it's able to support an unlimited number of different terrains. Dirt with grass, sand, and water in the same atlas, for example. But you'll have to set up the terrain connections manually, for every terrain combination you need. Unfortunately I'll be busy soon, and there's still a lot of unreliable parts with this system. I don't completely understand how the signal system works. It can't really replace the current TileMapDual, since it works so differently, but... It works. That's a huge win in my book. Details on how to set it up are in a video in the latest README of the current branch: https://github.com/raffimolero/TileMapDual/tree/dev 2024-12-22_19-09-15.mp42024-12-22_19-31-31.mp4Right now all Grid Shapes and Offset Axes are supported:
Reactivity is currently janky. See the issues in my repo for more info. |
I don't think I understood just how flexible the terrain configuration system was: label.configuration.mp4terrain.swapping.mp4This engine is quite powerful; it's able to produce live feedback and control multiple TileMapLayers at once using a single World layer. It's also internally capable of recognizing terrain patterns from further away. Given time and effort (which I won't spend) it's possible to configure it so that it can control all of a map's visuals in real time, based on only some world layers. All they'd need to do is configure |
Wow, this work is amazing! First of all, thanks for sharing! Godot is about to implement an I have no clue what is going on in your last video, I will definitely have to check it out as it seems so useful. |
Practically all of the functionality I want has been implemented in the fork! terrain.autogen.mp4From terrain auto-generation, to supporting multiple different atlases in the same It's not perfect, but I'm happy with how most of it turned out. It's just as easy to set up as your current version, too. Once the documentation is updated, it could even be good enough to merge, if you want. |
This is such a great piece of code! Thanks a lot for sharing your huge contribution with everyone. Just want to ask, how compatible is this fork with the use of shaders? Cause I have been trying some implementations here, and it was such a pain... Some of these modifications could be imported to the new version, but I want to go slow and steady not to break anything... And if I can help you with the documentation, I am willing to do so as well :D I will do some checks these days before doing a merge into a new branch if that's ok. Again, thanks Raffimolero for sharing! |
Thanks for asking - shaders should be no problem. All relevant The codebase is getting pretty large. I've documented most of the technical details, so only the README demos, showcases, and examples are left. Should be easy enough for a user to do, maybe you could test the system to see if it's intuitive. The Terrain System itself will have to be explained in a later post. I'll give a rundown of how the classes interact at the moment:
Only the The
When any The signal is detected by Here's how the "left" Put 2 of them together, and you get a full grid. Any shaders or other properties will only apply to the |
I am liking it so far, this is really well designed! If you want, push to a v5.0.0-dev branch, I will give you edit access. Thanks for this summary, it was really useful to understand it! |
I've created and pushed the changes into the dev branch, but I'm afraid I won't be around to maintain this when class starts. I tried doing a pull request, but the merge conflicts were too much, so I cloned it locally, attempted a merge, and just... manually dumped my current files into the branch to overwrite all the conflicting files. Yes, this means losing progress on the current issues, but we can take a look at the history between my fork and the merge, and try to go from there. To quote my (now closed) pull request
In the meantime, do play around with it! You can start by reconstructing all the examples. This branch needs a lot of testing, and I can't catch most bugs since I mainly use the program only as intended. |
Great! It's ok, we can try to port some additions later down the line. Let's treat this as a v5-dev for now. If anybody wants to test the new version and include modifications or report bugs, of course it is more than welcome :D |
I don't plan on implementing this unless necessary, but I've figured out how to make the child nodes show up. Inspired by godotengine/godot-proposals#10572, here's a little proof of concept, where I showed the internal Display node: 2025-01-08_16-51-56.mp4 |
Really interesting. Indeed, some people was asking how to see these layers. |
I'm not sure. It's definitely useful, but very likely fragile and would need careful work. It will probably need a note that says "These display layers are read-only" and a "Refresh" button somewhere in case the user modifies something on accident. Being able to see the nodes means being able to edit them, but only the main TileMapDual node's properties are followed. It might surprise users if they try to edit properties on Layer 0 and 1, but then they get overwritten later. I'm going to be busy with other projects very soon, too. I might come back now and then, but progress will slow down. It's been a fun month, and there's been a lot of progress, but the work isn't done. Feel free to ask me about anything and everything. I'm active on Discord, and I have a Slack account, so I could send you my username via email if you'd like to chat. |
I fixed the undo/redo issue with terrain autogen, after a long while... things should be more stable than usual now. We still have to fix the other bugs with shaders and such. I've already managed to pass in the parent
and that should fix them the same way it did in v4. Maybe v5.1 or .2 could have the separate, visible world layer. Maybe it'll be much later. Maybe it should be in Godot itself, heh. But contributing directly to the engine is hard when solutions are still supposed to be under discussion. |
Okay, I introduced some changes. I added the I am a bit worried about single cell updates. Creating a medium-sized map had my pc fans at full speed, since the full map is being updated at |
Since the legacy version is already bundled with the v5 version, I think it is time to merge branches. We need more eyes on this and making v5 the default branch seems a reasonable tradeoff... We can keep this issue opened for further discussion. |
Supporting hex grids is a huge task. It requires having 2 separate TileSet resources for the parent and child. But I've got ideas.
I manually cropped and assembled this tileset from https://youtu.be/Uxeo9c-PX-w?t=428 (the same frame used in the readme) which I hope could help develop triangular and hex grids further. It's a bit complicated since it's a "tall" tileset, so I'll be looking for a simpler one for now.

Each triangle sprite is 64x83, and when pieced together they become 85x72 hex tiles. I don't know how the math works yet.
Unfortunately, Godot does not support triangular grids. Fortunately, they're just square grids with extra steps.
I think the geometry of the
display_tilemap
can be computed as follows:But you'd need
display_tilemap
to have a differenttile_set
for this to work. It can't reuse the parent's.The text was updated successfully, but these errors were encountered: