Skip to content
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

Add a Brush Spacing property to GridMap to control spacing between tiles when using paint/fill tools #9612

Open
Nodragem opened this issue Apr 27, 2024 · 4 comments

Comments

@Nodragem
Copy link

Nodragem commented Apr 27, 2024

Describe the project you are working on

Top Down Twin Shooter:
image
See Github project here:
https://github.com/Nodragem/twin-stick-shooter-starter-kit

Describe the problem or limitation you are having in your project

Gridmap was designed to use "Classic" modular kits where we place 3D tiles of 1x1x1 unit on a grid of 1x1x1 unit (as seen in Bethesda's Skyrim's GDC presentation ).
image

Nowaday, we tend to use more granular modular kits: basically we separate the wall pieces from the floor pieces (as seen in Fallout 4's GDC presentation.
image

When using this new paradigm, the asset are made on a 2x2 grid units base, and the Gridmap is set at 1x1 unit. This allows to place a wall at the edge of a floor piece basically.

Based on this new paradigm, the Gridmap "brush" is not working very well. It will paint one 2x2 piece every 1 unit:
gridmap
We would like the brush to place 1 piece every 2 units (as show on the lower row).

(Note that the kit used in this example are from KayKit Prototype Bits)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

We would like to have a spacing parameter, so that the brush tool and the fill tool know that they need to place a floor/wall piece every X units (1, 2 or more).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In inspector, add a category "Brush" above "Cell", and an entry "spacing size".
Based on this value, we use a modulo when filling areas with an asset.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It should be used often by 3D games with interiors and buildings.

Is there a reason why this should be core and not an add-on in the asset library?

It improves a tool (Gridmap) that is already core.

@Calinou Calinou changed the title Gridmap and Modern Modular Kits: Add Brush Spacing Add a Brush Spacing property to GridMap to control spacing between tiles when using paint/fill tools Apr 27, 2024
@badsectoracula
Copy link

Adding brush spacing would certainly help with tiles that are not exactly one "cell" size - and it should be possible to define separate X and Z values (or whatever plane you are working on), potentially with some setting to do this automatically based on the bounding box of the tile you are working on as that can also help with non-square tiles too.

That said, from the description i'm not sure how that'd help with modular tiles made out of floor/wall/column/etc pieces. With this feature gridmap would still only use tiles that cover "everything" per cell area, you wont be able to combine them anyway. And without this feature you can still use the pieces "manually" by creating multiple gridmaps:

Image

You could also put the 2x2 or 4x4 pieces in their own gridmap.

As for the modular tiles, there are two approaches i can see for improving support without having multiple gridmaps (or at least reducing them):

  • Have each cell allow for additional "edge" and "corner" instances. As an example this video from an editor i wrote some time ago that uses exactly this modular approach (floor, wall, column - note that the editor places the columns automatically, but they are still separate pieces). This would allow for better UX for this particular use case, but it'd really be limited for this particular use case too.
  • Alternatively, add support for cell layers (like in Blender, not like in Krita) so that a single cell can have multiple layers (or more accurately, the same grid position can have multiple cells in conceptually different layers). This would allow mixing the pieces as long as they are in different layers while at the same time allowing for other uses that combine different meshes (e.g. trims, window frames, furniture, etc).

Personally i'm in favor of the second one because i think it is both more flexible and support more use cases even if the first one could allow for a little better UX.

I did a quick proof-of-concept for layer support in Gridmap to check this out:

Godot.Gridmap.Layers.webm

You can try the functionality from this branch:

https://github.com/badsectoracula/godot/tree/gridmap-layers

I haven't done a PR because it needs more work, especially on the editor where i just added a spinbox to specify the working layer - and i'm not 100% sure if this approach would be something to add in the first place.

@Nodragem
Copy link
Author

Nodragem commented Nov 21, 2024

Thank you for your feedback!

To have layers could be very useful indeed, but I see it more for complex decorations (e.g. adding curtains or boards to some walls, adding a fountain in the middle of a room, etc).
Would you like to open a proposal for it with the link to your branch? this way we can continue the conversation there, and I can link your proposal to my meta-proposal there: #10992
There have been suggestions for layers in that thread already, so that's very exciting to see a first proof of concept implemented!

In terms of the modular asset workflow, you can achieve it using 1 layer/gridmap like this:
Image

To make it work you need to:

  • set the cell size to half the standard size of your assets: here I set the cell size to 2, because my asset are 4 units wide.
  • untick Center X, Center Y, Center Z so that the asset's origins are snapping on the grid intersections

Below I drew another example, with the assets being 2 units wide and the grid's cell size being 1 unit. In this example, I show where the asset's origins are placed and how they snap to the grid:
Image

Using this setup, you don't need to switch between layers, and as contributors we can more easily implement a "clever fill tool" where the end user would select an area and Godot would fill it with floor, wall and corners.

However, using this setup means that the paint tool brush needs to paint every 2 cells; which is why I want to implement this proposal.
I'm thinking to write some documentation about this workflow if we get this feature in.

@badsectoracula
Copy link

Ah i see, in my mind (and the assets i made in the shot/video above :-P) i had that grid, floor and wall origins are at the corner, not the center (only the column has the origin at the center). Yeah, now that i see how the walls are placed in relation to the floor i understand the setup.

However (and this assuming i'm still not missing something) as this is purely about the editing side (i.e. how/where the editor would place stuff) i think the "Spacing" value should be controlled by the editor panel itself and not a property in GridMap - like next to the buttons where you control rotation.

@Nodragem
Copy link
Author

Nodragem commented Nov 21, 2024

"Spacing" value should be controlled by the editor panel itself and not a property in GridMap - like next to the buttons where you control rotation.

Very happy to hear that, as this is what I had in mind! (Note that this proposal was made before I implemented the bottom panel 😅)

I should probably open a proposal for a tool settings panel as in the bottom right of this mockup:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants