2024-10-27 03:36:17 +01:00
|
|
|
enum AUTOTERRAIN_TYPE {
|
2024-10-21 11:50:45 +02:00
|
|
|
box9,
|
|
|
|
side15,
|
|
|
|
top48,
|
2024-10-24 12:40:14 +02:00
|
|
|
top55,
|
2024-10-21 11:50:45 +02:00
|
|
|
}
|
|
|
|
|
2024-10-27 03:36:17 +01:00
|
|
|
global.autoterrain_amount = [ 9, 15, 48, 55, ];
|
|
|
|
|
|
|
|
function tiler_brush_autoterrain(_type, _index) constructor {
|
|
|
|
name = "autoterrain";
|
2024-10-19 12:35:47 +02:00
|
|
|
index = _index;
|
|
|
|
|
|
|
|
mask_surface = noone;
|
|
|
|
update_surface = noone;
|
|
|
|
drawing_surface = noone;
|
|
|
|
target_surface = noone;
|
|
|
|
eraseMode = false;
|
|
|
|
|
2024-10-24 12:40:14 +02:00
|
|
|
preview_surface = noone;
|
|
|
|
preview_surface_tile = noone;
|
|
|
|
|
|
|
|
open = false;
|
2024-10-19 12:35:47 +02:00
|
|
|
|
2024-10-27 03:36:17 +01:00
|
|
|
sc_type = new scrollBox(["Simple box (3x3)", "Side platform (5x3)", "Godot tile (12x4)", "Gamemaker tileset (11x5)"], function(ind) /*=>*/ { setType(ind); });
|
|
|
|
sc_type.font = f_p3;
|
|
|
|
|
|
|
|
static setType = function(_type) {
|
|
|
|
type = _type;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 0 : index = array_verify_ext(index, 9, function() /*=>*/ {return -1}); break;
|
|
|
|
case 1 : index = array_verify_ext(index, 15, function() /*=>*/ {return -1}); break;
|
|
|
|
case 2 : index = array_verify_ext(index, 48, function() /*=>*/ {return -1}); break;
|
|
|
|
case 3 : index = array_verify_ext(index, 55, function() /*=>*/ {return -1}); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} setType(_type);
|
|
|
|
|
2024-10-19 12:35:47 +02:00
|
|
|
static drawing_start = function(surface, _erase = false) {
|
|
|
|
target_surface = surface;
|
|
|
|
eraseMode = _erase;
|
|
|
|
|
|
|
|
var _dim = surface_get_dimension(surface);
|
|
|
|
drawing_surface = surface_verify(drawing_surface, _dim[0], _dim[1], surface_r8unorm);
|
|
|
|
|
2024-10-25 13:02:52 +02:00
|
|
|
//print($"Drawing start {surface} | {drawing_surface}");
|
|
|
|
|
2024-10-19 12:35:47 +02:00
|
|
|
draw_set_color(c_white);
|
|
|
|
surface_set_target(drawing_surface);
|
|
|
|
DRAW_CLEAR
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawing_end = function() {
|
|
|
|
surface_reset_target();
|
|
|
|
apply_drawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
static apply_drawing = function() {
|
|
|
|
var _dim = surface_get_dimension(target_surface);
|
|
|
|
mask_surface = surface_verify(mask_surface, _dim[0], _dim[1], surface_r8unorm);
|
2024-10-24 12:40:14 +02:00
|
|
|
update_surface = surface_verify(update_surface, _dim[0], _dim[1], surface_rgba16float);
|
2024-10-19 12:35:47 +02:00
|
|
|
|
2024-10-27 03:36:17 +01:00
|
|
|
// autoterrain mask
|
|
|
|
// #000000 : not part of autoterrain
|
|
|
|
// #808080 : part of autoterrain, read only
|
|
|
|
// #FFFFFF : part of autoterrain, writable
|
2024-10-19 12:35:47 +02:00
|
|
|
|
2024-10-27 03:36:17 +01:00
|
|
|
surface_set_shader(mask_surface, sh_tiler_autoterrain_mask);
|
2024-10-19 12:35:47 +02:00
|
|
|
shader_set_surface("drawSurface", drawing_surface);
|
|
|
|
shader_set_i("indexes", index);
|
|
|
|
shader_set_i("indexSize", array_length(index));
|
|
|
|
|
|
|
|
draw_surface(target_surface, 0, 0);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
2024-10-27 03:36:17 +01:00
|
|
|
surface_set_shader(update_surface, sh_tiler_autoterrain_apply);
|
2024-10-19 12:35:47 +02:00
|
|
|
shader_set_2("dimension", _dim);
|
|
|
|
|
|
|
|
shader_set_surface("maskSurface", mask_surface);
|
2024-10-21 11:50:45 +02:00
|
|
|
shader_set_i("bitmaskType", type);
|
2024-10-19 12:35:47 +02:00
|
|
|
|
|
|
|
shader_set_i("indexes", index);
|
|
|
|
shader_set_i("indexSize", array_length(index));
|
|
|
|
shader_set_i("erase", eraseMode);
|
|
|
|
|
|
|
|
draw_surface(target_surface, 0, 0);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
surface_set_target(target_surface);
|
|
|
|
DRAW_CLEAR
|
|
|
|
|
|
|
|
BLEND_OVERRIDE
|
|
|
|
draw_surface(update_surface, 0, 0);
|
|
|
|
BLEND_NORMAL
|
|
|
|
surface_reset_target();
|
|
|
|
}
|
|
|
|
}
|