godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Support triangle grids for `GridMap` #4375

Open octetdev2 opened 2 years ago

octetdev2 commented 2 years ago

Describe the project you are working on

Godot engine improvements.

Describe the problem or limitation you are having in your project

There is no built-in support for triangle shaped tiles in GridMap.

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

Builds on https://github.com/godotengine/godot-proposals/issues/4337 and adds triangle as a new shape.

Triangle grids are interesting in that you need a lot less variations in the tileset to implement say marching squares/cubes and other procedural generation routines.

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

Cell shape is extended to include triangles

enum CellShape {
  CELL_SHAPE_TRIANGLE,
  CELL_SHAPE_SQUARE,
  CELL_SHAPE_HEXAGON,
};

Editor and layouts gets updated accordingly.

image

The get_cell_orientation should be made additive, in that there's an intrinsic orientation for the cell then whatever the stored rotation is, gets added to that.

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

It cannot, this is fundamental to what GridMap's capabilities.

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

Fundamental shape that can tile the plane and GridMap is in core.

JoNax97 commented 2 years ago

Just a minor detail (you probably are aware of this): the triangle layout shown in your mockup doesn't allow building hexagons; every other row should be mirrored.

Do you expect to support both layouts or only one?

octetdev2 commented 2 years ago

Do you expect to support both layouts

Yup, I expect to support multiple layouts. We have an enum for that so natural extension as needed.

octetdev2 commented 2 years ago

This is what the grids are supposed to look like by the way @JoNax97, updated the main screen shot accordingly. Couple of math oopses in the original one.

image

image