Pixel-Composer/scripts/node_wrap_mesh/node_wrap_mesh.gml

534 lines
14 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2023-01-25 06:49:00 +01:00
name = "Mesh Warp";
2022-01-13 05:24:03 +01:00
data = {
points : [[]],
2023-03-26 07:13:36 +02:00
tris : [],
links : []
2022-01-13 05:24:03 +01:00
}
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Sample", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8, "Amount of grid subdivision. Higher number means more grid, detail.")
2022-09-21 06:09:40 +02:00
.setDisplay(VALUE_DISPLAY.slider, [ 2, 32, 1 ] );
2022-01-13 05:24:03 +01:00
2023-05-22 20:31:55 +02:00
inputs[| 2] = nodeValue("Spring Force", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
2022-01-13 05:24:03 +01:00
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ] );
2023-03-28 06:58:28 +02:00
inputs[| 3] = nodeValue("Mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.trigger, 0)
.setDisplay(VALUE_DISPLAY.button, [ function() { setTriangle(); doUpdate(); }, "Generate"] );
2022-01-13 05:24:03 +01:00
2023-05-22 20:31:55 +02:00
inputs[| 4] = nodeValue("Diagonal Link", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, "Include diagonal link to prevent drastic grid deformation.");
2022-09-23 13:28:42 +02:00
2023-02-14 05:32:32 +01:00
inputs[| 5] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 5;
2023-03-26 07:13:36 +02:00
2023-05-22 20:31:55 +02:00
inputs[| 6] = nodeValue("Link Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0, "Link length preservation, setting it to 1 will prevent any stretching, contraction.")
2023-03-26 07:13:36 +02:00
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ] );
2023-02-14 05:32:32 +01:00
2023-05-22 20:31:55 +02:00
inputs[| 7] = nodeValue("Full Mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
2022-01-13 05:24:03 +01:00
control_index = ds_list_size(inputs);
function createControl() {
var index = ds_list_size(inputs);
2023-03-28 06:58:28 +02:00
inputs[| index] = nodeValue("Control point", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ PUPPET_FORCE_MODE.move, 16, 16, 8, 0, 8, 8 ])
2022-01-13 05:24:03 +01:00
.setDisplay(VALUE_DISPLAY.puppet_control)
2022-09-23 13:28:42 +02:00
array_push(input_display_list, index);
2022-01-13 05:24:03 +01:00
return inputs[| index];
}
2023-02-14 05:32:32 +01:00
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
outputs[| 1] = nodeValue("Mesh data", self, JUNCTION_CONNECT.output, VALUE_TYPE.object, data);
2022-01-13 05:24:03 +01:00
2023-02-14 05:32:32 +01:00
input_display_list = [ 5,
2023-06-04 12:38:40 +02:00
["Mesh", false], 0, 1, 7,
2023-03-26 07:13:36 +02:00
["Link", false], 4, 6,
2022-09-23 13:28:42 +02:00
["Control points", false],
];
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2023-03-21 03:01:53 +01:00
attribute_interpolation();
2023-03-19 09:17:39 +01:00
2022-09-23 13:28:42 +02:00
input_display_index = array_length(input_display_list);
2023-03-28 06:58:28 +02:00
points = [];
2022-09-23 13:28:42 +02:00
2023-06-04 12:38:40 +02:00
array_push(attributeEditors, "Warp");
2023-06-13 14:42:06 +02:00
attributes.iteration = 4;
2023-07-14 20:34:35 +02:00
array_push(attributeEditors, ["Iteration", function() { return attributes.iteration; },
2023-04-11 20:29:20 +02:00
new textBox(TEXTBOX_INPUT.number, function(val) {
2023-06-13 14:42:06 +02:00
attributes.iteration = val;
2023-04-11 20:29:20 +02:00
triggerRender();
})]);
2023-03-19 09:17:39 +01:00
2022-01-13 05:24:03 +01:00
tools = [
2023-03-11 01:40:17 +01:00
new NodeTool( "Add / Remove (+ Shift) control point", THEME.control_add ),
new NodeTool( "Pin / unpin (+ Shift) mesh", THEME.control_pin )
2022-01-13 05:24:03 +01:00
];
2023-06-04 12:38:40 +02:00
insp1UpdateTooltip = "Generate";
insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ];
static onInspector1Update = function() {
setTriangle();
}
2023-01-09 03:14:20 +01:00
static onValueFromUpdate = function(index) {
2023-03-28 06:58:28 +02:00
if(index == 0 && array_empty(data.tris))
2023-01-09 03:14:20 +01:00
setTriangle();
}
2023-03-30 07:54:25 +02:00
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
2023-03-26 07:13:36 +02:00
for(var i = 0; i < array_length(data.links); i++)
data.links[i].draw(_x, _y, _s);
for(var i = 0; i < array_length(data.tris); i++)
data.tris[i].drawPoints(_x, _y, _s);
2022-01-13 05:24:03 +01:00
var hover = -1;
for(var i = control_index; i < ds_list_size(inputs); i++) {
2022-12-19 13:35:30 +01:00
if(inputs[| i].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny))
2022-01-13 05:24:03 +01:00
hover = i;
}
2022-12-12 09:08:03 +01:00
if(!active) return;
2023-03-11 01:40:17 +01:00
if(isUsingTool(0)) {
2023-02-14 05:32:32 +01:00
if(key_mod_press(SHIFT))
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
else
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16);
2022-12-10 05:06:01 +01:00
if(mouse_press(mb_left)) {
2022-01-13 05:24:03 +01:00
if(hover == -1) {
var i = createControl();
2023-03-28 06:58:28 +02:00
i.setValue( [ PUPPET_FORCE_MODE.move, value_snap(_mx - _x, _snx) / _s, value_snap(_my - _y, _sny) / _s, 0, 0, 8, 8 ] );
2022-01-13 05:24:03 +01:00
i.drag_type = 2;
i.drag_sx = 0;
i.drag_sy = 0;
i.drag_mx = _mx;
i.drag_my = _my;
2023-02-14 05:32:32 +01:00
} else if(key_mod_press(SHIFT)) {
2022-01-13 05:24:03 +01:00
ds_list_delete(inputs, hover);
2022-09-23 13:28:42 +02:00
array_delete(input_display_list, input_display_index + hover - control_index, 1);
2022-01-13 05:24:03 +01:00
}
reset();
2022-09-23 13:28:42 +02:00
control(input_display_list);
}
2023-03-11 01:40:17 +01:00
} else if(isUsingTool(1)) {
2023-02-14 05:32:32 +01:00
draw_sprite_ui_uniform(key_mod_press(SHIFT)? THEME.cursor_path_remove : THEME.cursor_path_add, 0, _mx + 16, _my + 16);
2022-11-18 03:20:31 +01:00
draw_set_color(COLORS._main_accent);
2022-09-23 13:28:42 +02:00
var rad = 16;
2023-06-17 14:30:49 +02:00
draw_circle_prec(_mx, _my, rad, true);
2022-09-23 13:28:42 +02:00
var _xx = (_mx - _x) / _s;
var _yy = (_my - _y) / _s;
2022-12-10 05:06:01 +01:00
if(mouse_click(mb_left)) {
2023-03-26 07:13:36 +02:00
for(var j = 0; j < array_length(data.tris); j++) {
var t = data.tris[j];
2022-09-23 13:28:42 +02:00
if(point_in_circle(t.p0.x, t.p0.y, _xx, _yy, rad / _s))
2023-02-14 05:32:32 +01:00
t.p0.setPin(!key_mod_press(SHIFT));
2022-09-23 13:28:42 +02:00
if(point_in_circle(t.p1.x, t.p1.y, _xx, _yy, rad / _s))
2023-02-14 05:32:32 +01:00
t.p1.setPin(!key_mod_press(SHIFT));
2022-09-23 13:28:42 +02:00
if(point_in_circle(t.p2.x, t.p2.y, _xx, _yy, rad / _s))
2023-02-14 05:32:32 +01:00
t.p2.setPin(!key_mod_press(SHIFT));
2022-09-23 13:28:42 +02:00
}
2022-01-13 05:24:03 +01:00
}
}
}
2023-03-19 09:17:39 +01:00
function _Point(node, index, _x, _y) constructor {
2022-09-23 13:28:42 +02:00
self.index = index;
self.node = node;
2023-03-28 06:58:28 +02:00
x = _x;
y = _y;
2022-01-13 05:24:03 +01:00
xp = x;
yp = y;
2023-03-28 06:58:28 +02:00
node.points[index] = self;
2022-09-23 13:28:42 +02:00
ndx = 0;
ndy = 0;
2023-03-28 06:58:28 +02:00
sx = x;
sy = y;
pin = false;
2022-01-13 05:24:03 +01:00
static reset = function() {
x = sx;
y = sy;
xp = x;
yp = y;
}
2022-09-23 13:28:42 +02:00
static draw = function(_x, _y, _s) {
if(pin) {
2022-11-18 03:20:31 +01:00
draw_set_color(COLORS._main_accent);
2023-06-17 14:30:49 +02:00
draw_circle_prec(_x + x * _s, _y + y * _s, 3, false);
2022-09-23 13:28:42 +02:00
} else {
2022-11-18 03:20:31 +01:00
draw_set_color(COLORS.node_overlay_gizmo_inactive);
2023-06-17 14:30:49 +02:00
draw_circle_prec(_x + x * _s, _y + y * _s, 2, false);
2022-09-23 13:28:42 +02:00
}
2022-01-13 05:24:03 +01:00
}
u = 0;
v = 0;
static mapTexture = function(ww, hh) {
u = x / ww;
v = y / hh;
}
2022-09-23 13:28:42 +02:00
static move = function(dx, dy) {
if(pin) return;
x += dx;
y += dy;
}
static planMove = function(dx, dy) {
if(pin) return;
ndx += dx;
ndy += dy;
}
static stepMove = function(rat) {
if(pin) return;
move(ndx * rat, ndy * rat);
}
static clearMove = function(rat) {
if(pin) return;
ndx = 0;
ndy = 0;
}
static setPin = function(pin) {
self.pin = pin;
}
2022-01-13 05:24:03 +01:00
}
function link(_p0, _p1) constructor {
p0 = _p0;
p1 = _p1;
k = 1;
len = point_distance(p0.x, p0.y, p1.x, p1.y);
2023-03-26 07:13:36 +02:00
static resolve = function(strength = 1) {
2022-01-13 05:24:03 +01:00
var _len = point_distance(p0.x, p0.y, p1.x, p1.y);
var _dir = point_direction(p0.x, p0.y, p1.x, p1.y);
2023-03-26 07:13:36 +02:00
var _slen = lerp(_len, len, strength);
var f = k * (_len - _slen);
2022-01-13 05:24:03 +01:00
var dx = lengthdir_x(f, _dir);
var dy = lengthdir_y(f, _dir);
2022-09-23 13:28:42 +02:00
p0.move( dx / 2, dy / 2);
p1.move(-dx / 2, -dy / 2);
2022-01-13 05:24:03 +01:00
}
2022-01-29 14:25:18 +01:00
static draw = function(_x, _y, _s) {
draw_set_color(c_red);
draw_line(_x + p0.x * _s, _y + p0.y * _s, _x + p1.x * _s, _y + p1.y * _s);
}
2022-01-13 05:24:03 +01:00
}
2023-03-19 09:17:39 +01:00
function _Triangle(_p0, _p1, _p2) constructor {
2022-01-13 05:24:03 +01:00
p0 = _p0;
p1 = _p1;
p2 = _p2;
static reset = function() {
p0.reset();
p1.reset();
p2.reset();
}
static initSurface = function(surf) {
p0.mapTexture(surface_get_width(surf), surface_get_height(surf));
p1.mapTexture(surface_get_width(surf), surface_get_height(surf));
p2.mapTexture(surface_get_width(surf), surface_get_height(surf));
}
static drawSurface = function(surf) {
draw_set_color(c_white);
draw_set_alpha(1);
draw_primitive_begin_texture(pr_trianglelist, surface_get_texture(surf));
draw_vertex_texture(p0.x, p0.y, p0.u, p0.v);
draw_vertex_texture(p1.x, p1.y, p1.u, p1.v);
draw_vertex_texture(p2.x, p2.y, p2.u, p2.v);
draw_primitive_end();
}
static drawPoints = function(_x, _y, _s) {
2022-12-10 05:06:01 +01:00
//draw_set_color(c_white);
//draw_triangle(_x + p0.x * _s, _y + p0.y * _s, _x + p1.x * _s, _y + p1.y * _s, _x + p2.x * _s, _y + p2.y * _s, false)
2022-09-23 13:28:42 +02:00
p0.draw(_x, _y, _s);
p1.draw(_x, _y, _s);
p2.draw(_x, _y, _s);
2022-01-13 05:24:03 +01:00
}
static contain = function(p) {
return p == p0 || p == p1 || p == p2;
}
}
static regularTri = function(surf) {
var sample = inputs[| 1].getValue();
var spring = inputs[| 2].getValue();
2022-09-23 13:28:42 +02:00
var diagon = inputs[| 4].getValue();
2022-01-13 05:24:03 +01:00
if(!inputs[| 0].value_from) return;
2022-12-22 03:09:55 +01:00
var useArray = is_array(surf);
var ww = useArray? surface_get_width(surf[0]) : surface_get_width(surf);
var hh = useArray? surface_get_height(surf[0]) : surface_get_height(surf);
2022-01-13 05:24:03 +01:00
2023-06-17 14:30:49 +02:00
var fullmh = inputs[| 7].getValue();
if(is_array(fullmh)) fullmh = false;
fullmh |= useArray;
2022-12-10 05:06:01 +01:00
var gw = ww / sample;
var gh = hh / sample;
2023-06-04 12:38:40 +02:00
var cont = noone;
2022-01-13 05:24:03 +01:00
2023-05-22 20:31:55 +02:00
if(!fullmh) {
2023-06-04 12:38:40 +02:00
cont = surface_create_valid(ww, hh);
2023-01-25 06:49:00 +01:00
2022-12-22 03:09:55 +01:00
surface_set_target(cont);
shader_set(sh_content_sampler);
var uniform_dim = shader_get_uniform(sh_content_sampler, "dimension");
var uniform_sam = shader_get_uniform(sh_content_sampler, "sampler");
2022-09-21 06:09:40 +02:00
2023-02-14 05:32:32 +01:00
shader_set_uniform_f_array_safe(uniform_dim, [ww, hh]);
shader_set_uniform_f_array_safe(uniform_sam, [gw, gh]);
2022-12-22 03:09:55 +01:00
draw_surface_safe(surf, 0, 0);
shader_reset();
surface_reset_target();
}
2022-01-13 05:24:03 +01:00
2023-03-28 06:58:28 +02:00
points = [];
2022-01-13 05:24:03 +01:00
data.points = [[]];
2023-03-28 06:58:28 +02:00
data.tris = [];
data.links = [];
2022-01-13 05:24:03 +01:00
2022-09-23 13:28:42 +02:00
var ind = 0;
2022-12-10 05:06:01 +01:00
for(var i = 0; i <= sample; i++)
for(var j = 0; j <= sample; j++) {
2022-12-22 03:09:55 +01:00
var fill = false;
2023-05-22 20:31:55 +02:00
if(fullmh) {
2022-12-22 03:09:55 +01:00
fill = true;
} else {
2023-05-22 20:31:55 +02:00
var _i = i * gh;
var _j = j * gw;
fill |= surface_get_pixel(cont, _j - 1, _i - 1);
fill |= surface_get_pixel(cont, _j - 1, _i);
fill |= surface_get_pixel(cont, _j - 1, _i + 1);
fill |= surface_get_pixel(cont, _j, _i - 1);
fill |= surface_get_pixel(cont, _j, _i);
fill |= surface_get_pixel(cont, _j, _i + 1);
fill |= surface_get_pixel(cont, _j + 1, _i - 1);
fill |= surface_get_pixel(cont, _j + 1, _i);
fill |= surface_get_pixel(cont, _j + 1, _i + 1);
2022-12-22 03:09:55 +01:00
}
2022-01-13 05:24:03 +01:00
2022-12-22 03:09:55 +01:00
if(fill) {
2023-03-19 09:17:39 +01:00
data.points[i][j] = new _Point(self, ind++, min(j * gw, ww), min(i * gh, hh));
2022-12-10 05:06:01 +01:00
if(i == 0) continue;
if(j && data.points[i - 1][j] != 0 && data.points[i][j - 1] != 0)
2023-03-28 06:58:28 +02:00
array_push(data.tris, new _Triangle(data.points[i - 1][j], data.points[i][j - 1], data.points[i][j]));
2022-12-10 05:06:01 +01:00
if(j < sample && data.points[i - 1][j] != 0 && data.points[i - 1][j + 1] != 0)
2023-03-28 06:58:28 +02:00
array_push(data.tris, new _Triangle(data.points[i - 1][j], data.points[i - 1][j + 1], data.points[i][j]));
2022-01-13 05:24:03 +01:00
} else
data.points[i][j] = 0;
}
2022-12-10 05:06:01 +01:00
for(var i = 0; i <= sample; i++)
for(var j = 0; j <= sample; j++) {
2022-01-13 05:24:03 +01:00
if(data.points[i][j] == 0) continue;
if(i && data.points[i - 1][j] != 0) {
2023-03-28 06:58:28 +02:00
array_push(data.links, new link(data.points[i][j], data.points[i - 1][j]));
2022-01-13 05:24:03 +01:00
}
if(j && data.points[i][j - 1] != 0) {
2023-03-28 06:58:28 +02:00
array_push(data.links, new link(data.points[i][j], data.points[i][j - 1]));
2022-01-13 05:24:03 +01:00
}
2022-09-23 13:28:42 +02:00
if(diagon) {
if(i && j && data.points[i - 1][j - 1] != 0) {
var l = new link(data.points[i][j], data.points[i - 1][j - 1]);
l.k = spring;
2023-03-28 06:58:28 +02:00
array_push(data.links, l);
2022-09-23 13:28:42 +02:00
}
2022-12-10 05:06:01 +01:00
if(i && j < sample && data.points[i - 1][j + 1] != 0) {
2022-09-23 13:28:42 +02:00
var l = new link(data.points[i][j], data.points[i - 1][j + 1]);
l.k = spring;
2023-03-28 06:58:28 +02:00
array_push(data.links, l);
2022-09-23 13:28:42 +02:00
}
2022-01-13 05:24:03 +01:00
}
}
2023-06-04 12:38:40 +02:00
if(is_surface(cont)) surface_free(cont);
2022-01-13 05:24:03 +01:00
}
static reset = function() {
2023-03-26 07:13:36 +02:00
for(var i = 0; i < array_length(data.tris); i++)
data.tris[i].reset();
2022-01-13 05:24:03 +01:00
}
static setTriangle = function() {
2023-03-26 07:13:36 +02:00
var _inSurf = inputs[| 0].getValue();
2022-01-13 05:24:03 +01:00
regularTri(_inSurf);
2023-01-25 06:49:00 +01:00
2023-03-26 07:13:36 +02:00
for(var i = 0; i < array_length(data.tris); i++)
data.tris[i].initSurface(is_array(_inSurf)? _inSurf[0] : _inSurf);
2022-01-13 05:24:03 +01:00
}
static affectPoint = function(c, p) {
2022-09-23 13:28:42 +02:00
var mode = c[PUPPET_CONTROL.mode];
var cx = c[PUPPET_CONTROL.cx];
var cy = c[PUPPET_CONTROL.cy];
var fx = c[PUPPET_CONTROL.fx];
var fy = c[PUPPET_CONTROL.fy];
var cw = c[PUPPET_CONTROL.width];
var ch = c[PUPPET_CONTROL.height];
switch(mode) {
case PUPPET_FORCE_MODE.move:
var dis = point_distance(cx, cy, p.x, p.y);
var inf = clamp(1 - dis / cw, 0, 1);
inf = ease_cubic_inout(inf);
p.planMove(fx * inf, fy * inf);
break;
case PUPPET_FORCE_MODE.wind:
var lx0 = cx + lengthdir_x(1000, fy);
var ly0 = cy + lengthdir_y(1000, fy);
var lx1 = cx - lengthdir_x(1000, fy);
var ly1 = cy - lengthdir_y(1000, fy);
var dist = distance_to_line(p.x, p.y, lx0, ly0, lx1, ly1);
var inf = clamp(1 - dist / cw, 0, 1);
inf = ease_cubic_inout(inf);
p.planMove(lengthdir_x(fx * inf, fy), lengthdir_y(fx * inf, fy));
break;
}
2022-01-13 05:24:03 +01:00
}
static control = function() {
2023-03-26 07:13:36 +02:00
var lStr = inputs[| 6].getValue();
2022-01-13 05:24:03 +01:00
for(var i = control_index; i < ds_list_size(inputs); i++) {
var c = inputs[| i].getValue();
2023-03-26 07:13:36 +02:00
for( var j = 0; j < array_length(data.points); j++ )
for( var k = 0; k < array_length(data.points[j]); k++ ) {
if(data.points[j][k] == 0) continue;
affectPoint(c, data.points[j][k]);
2022-01-13 05:24:03 +01:00
}
}
2023-06-13 14:42:06 +02:00
var it = attributes.iteration;
2023-03-26 07:13:36 +02:00
var _rat = 1 / it;
2022-09-23 13:28:42 +02:00
repeat(it) {
2023-03-26 07:13:36 +02:00
for( var j = 0; j < array_length(data.points); j++ )
for( var k = 0; k < array_length(data.points[j]); k++ ) {
if(data.points[j][k] == 0) continue;
data.points[j][k].stepMove(_rat);
2022-09-23 13:28:42 +02:00
}
2023-03-26 07:13:36 +02:00
if(lStr > 0)
repeat(it) {
for(var i = 0; i < array_length(data.links); i++)
data.links[i].resolve(lStr);
2022-09-23 13:28:42 +02:00
}
}
2023-03-26 07:13:36 +02:00
for( var j = 0; j < array_length(data.points); j++ )
for( var k = 0; k < array_length(data.points[j]); k++ ) {
if(data.points[j][k] == 0) continue;
data.points[j][k].clearMove();
2022-09-23 13:28:42 +02:00
}
2022-01-13 05:24:03 +01:00
}
2023-01-01 02:06:02 +01:00
static process_data = function(_outSurf, _data, _output_index, _array_index) {
2022-12-22 03:09:55 +01:00
var _inSurf = _data[0];
2023-01-09 03:14:20 +01:00
if(!is_surface(_inSurf)) return _outSurf;
2022-01-13 05:24:03 +01:00
reset();
control();
2023-03-19 09:17:39 +01:00
_outSurf = surface_verify(_outSurf, surface_get_width(_inSurf), surface_get_height(_inSurf), attrDepth());
2023-01-09 03:14:20 +01:00
2023-03-21 03:01:53 +01:00
surface_set_shader(_outSurf);
shader_set_interpolation(_outSurf);
2023-05-16 21:28:16 +02:00
if(array_length(data.tris) == 0) {
draw_surface_safe(_inSurf);
} else {
for(var i = 0; i < array_length(data.tris); i++)
data.tris[i].drawSurface(_inSurf);
}
2023-03-21 03:01:53 +01:00
surface_reset_shader();
2022-12-22 03:09:55 +01:00
return _outSurf;
2022-01-13 05:24:03 +01:00
}
2022-01-18 05:31:19 +01:00
static postDeserialize = function() {
2023-06-13 14:42:06 +02:00
var _inputs = load_map.inputs;
2022-01-13 05:24:03 +01:00
2023-06-13 14:42:06 +02:00
for(var i = control_index; i < array_length(_inputs); i++) {
2023-03-28 06:58:28 +02:00
var inp = createControl();
2023-06-13 14:42:06 +02:00
inp.applyDeserialize(_inputs[i]);
2022-01-13 05:24:03 +01:00
}
}
2022-09-23 13:28:42 +02:00
static attributeSerialize = function() {
2023-06-13 14:42:06 +02:00
var att = {};
2023-03-28 06:58:28 +02:00
2023-06-13 14:42:06 +02:00
var pinList = [];
2023-03-28 06:58:28 +02:00
for( var j = 0; j < array_length(data.points); j++ )
for( var k = 0; k < array_length(data.points[j]); k++ ) {
var p = data.points[j][k];
if(p == 0) continue;
2023-06-13 14:42:06 +02:00
if(p.pin) array_push(pinList, p.index);
2023-03-28 06:58:28 +02:00
}
2023-06-13 14:42:06 +02:00
att.pin = pinList;
2022-09-23 13:28:42 +02:00
return att;
}
2023-03-28 06:58:28 +02:00
loadPin = noone;
2022-09-23 13:28:42 +02:00
static attributeDeserialize = function(attr) {
2023-06-13 14:42:06 +02:00
if(struct_has(attr, "pin"))
loadPin = attr.pin;
2023-03-28 06:58:28 +02:00
}
static postConnect = function() {
setTriangle();
2023-06-17 14:30:49 +02:00
if(loadPin == noone) return;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(loadPin); i < n; i++ ) {
2023-06-17 14:30:49 +02:00
var ind = loadPin[i];
if(ind < array_length(points))
points[ind].pin = true;
2023-03-28 06:58:28 +02:00
}
2023-06-17 14:30:49 +02:00
loadPin = noone;
2022-09-23 13:28:42 +02:00
}
2022-01-13 05:24:03 +01:00
}