godotengine / godot-proposals

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

TileSet Editor: Add more copy and paste functions #265

Open norton-corbett opened 4 years ago

norton-corbett commented 4 years ago

Describe the project you are working on: No project, just experiments

Describe the problem or limitation you are having in your project: Setting up complex autotiles is very time consuming, largely due to the absence of sensible copy and paste functions.

In a recent project for example, I set up the collision polygons for a large 3x3 autotile.

Describe how this feature / enhancement will help you overcome this problem or limitation: It would greatly reduce the work and time cost of configuring tilesets.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work: A good start would be to duplicate the Copy/Paste/Erase functions from the Bitmask editing page to Collision, Occlusion and Navigation pages:

image

Copying from one page to another should be supported.

When it comes to copying polygons to and from individual tiles, the interface already theoretically supports this, but it just doesn't work. (Selecting a polygon and attempting to "Paste" in the property inspector currently results in a "This property can't be changed" alert box).

image

image

Describe implementation detail for your proposal (in code), if possible: Not sure I haven't had a proper look at the code yet. I am assuming the logic will be similar to the existing Bitmask copy/paste function. Copying to and from the different types of polygon I assume will be straightforward as they all use PoolVector2Array for the underlying data.

As for the property inspector issue I have no idea (perhaps this counts as a separate issue entirely?)

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

Is there a reason why this should be core and not an add-on in the asset library?: Copy and paste is already supported on the Bitmask page, so it's expected that it would be available on the other pages.

TheHarvard commented 4 years ago

Just want to note that i have the exact same issue.

My tileset consists of autotiles composed of 256 tiles each (Fully populated 3X3 bitmask). My current workflow is to draw 256 colliders (that are all identical), 256 occluders (all copies of the same 8) and 256 Bitmasks for each tile. in the end i imagine i will have around 30-50 tiles.

I have tried to wrangle with the files themselves as they are text based, though there is no simple way to copy paste data. One could probably write a script that ran through it to make copy/paste actions, but why do that when you could add it to the editor itself.

Functionality that would be needed: ability to copy and paste colliders, Occluders, and bitmasks in the same texture/atlas. copy colliders, occluders and bitmasks from texture to texture (if you have multible atlases)

same functionality would be usefull for all aspects of the tileset, navigation, Z index and so on.

Pawel-Gargulinski commented 2 years ago

Is this something difficult to implement? I have the exact same issue in Godot 3.4.2 and it feels bizarre to see such useful functionality only in the Bitmask editor. The idea of drawing my 24-point collider 256 times seems... wrong.

Calinou commented 2 years ago

Is this something difficult to implement? I have the exact same issue in Godot 3.4.2 and it feels bizarre to see such useful functionality only in the Bitmask editor. The idea of drawing my 24-point collider 256 times seems... wrong.

This proposal is likely implemented in the new TileSet editor already. However, this new editor is backwards-incompatible, so it can't be backported to 3.x.

For 3.x, a difference implementation is needed. It's probably not very difficult to implement from scratch, but I don't have time to look into it.

The idea of drawing my 24-point collider 256 times seems... wrong.

You could probably use a tool script to automate this.

blipk commented 2 years ago

For anyone else that comes across this you can use the following to save the collision polygons as a str(PoolVector2Array) to a file:

    for shape in tilemap.tile_set.tile_get_shapes(16):
        print(var2str(shape.shape.points))
        var file = File.new()
        file.open("res://world/"+str(shape.shape.resource_name)+str(i)+".collision.dat", File.WRITE)
        file.store_string(var2str(shape.shape.points))
        file.close()
        i += 1

For this to work, you need to first go to Project -> Export... and set up at least one export. Then go to the Resources tab on the export and add *.dat (or your file extension/s) to the 'Filters to export' entry It makes sense but it's a little unintuitive.