Custom asset build tools in Godot 3.1 / GDScript?

Started by
1 comment, last by hplus0603 4 years, 4 months ago

I am using godot 3.1.2 on Windows, currently targeting Windows but eventually targeting Android.


I am loading a 2D image as a "world map." This has "height data" in red, and various "features/resources" data in green and blue channels. I have a custom shader that renders this texture as a top-down sprite by swapping out height-dependent texture images for terrain types, and marking up the special features. This works great! Even with GLES 2.0!


I would like to pre-process the data from this image to build a navigation grid, probably not using navmesh, but instead some new cell based system, because navgrid doesn't have things like feature points, agent/agent blocking, or agent size.


Preferrably, I would do this in a tool, as part of level building, rather than on level load, because it takes a while (especially on lower end CPUs.)


I can't figure out how to do this, though. I can see how to create addon/plugin tools, and how to add custom nodes to a scene, but I don't see any way to do the following things:


1. Allocate a packed byte or word array (Similar to PoolByteArray, I suppose?) of a given size

2. Register some function that gets called on project build to update the data in this array if the underlying image data has changed (or that gets called on build, and can somehow check a checksum of the underlying image data)

3. Marshal this array data out on build, and in again on scene load


Also, the image processing part in GDScript is ludicrously slow right now because creating a new class for each little data structure I want to use, and box-allocating it on the heap, and stuffing it in a variant-storing Array(), gets slow after tens of thousands of such data structures ... Anything I can do to improve this would be good, too.


I am not interested in writing C# code, or C++ code. I know how to do all this in Unreal Engine, (or from scratch,) so if I wanted to deal with C++, I would do it there.


What advice should I read?

enum Bool { True, False, FileNotFound };
Advertisement

Well, the one thing I learned was that I can create the hard-coded Pool-type arrays by using nothing as the initializer:

var myPool : PoolColorArray

It's also the case that anything marked "export" in the class will be visible in the editor, and read/write by the serializer. This means that "editing" and "saving for game" are one and the same thing, which ... is a choice. This also means that all my building code can be marked "editor" and thus run inside the IDE, and thus build the values of these properties when appropriate. It's not clean, but it might get me where I need to go.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement