2023-06-17 14:30:49 +02:00
|
|
|
function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-06-23 15:39:24 +02:00
|
|
|
name = "Armature Bind";
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
2023-06-17 14:30:49 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
inputs[| 1] = nodeValue("Armature", self, JUNCTION_CONNECT.input, VALUE_TYPE.armature, noone)
|
|
|
|
.setVisible(true, true)
|
|
|
|
.rejectArray();
|
2023-06-25 20:12:17 +02:00
|
|
|
|
|
|
|
inputs[| 2] = nodeValue("Bind data", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, noone)
|
|
|
|
.setVisible(true, true)
|
2023-07-05 15:09:52 +02:00
|
|
|
.setArrayDepth(1);
|
2023-07-14 20:34:35 +02:00
|
|
|
|
|
|
|
inputs[| 3] = nodeValue("Bone transform", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 4] = nodeValue("Bone scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.1, 2, 0.01 ] });
|
2023-06-23 15:39:24 +02:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
2023-10-06 11:51:11 +02:00
|
|
|
outputs[| 1] = nodeValue("Atlas data", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, [])
|
2023-06-23 15:39:24 +02:00
|
|
|
.rejectArrayProcess();
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
outputs[| 2] = nodeValue("Bind data", self, JUNCTION_CONNECT.output, VALUE_TYPE.struct, [])
|
|
|
|
.setArrayDepth(1);
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
attribute_surface_depth();
|
|
|
|
attribute_interpolation();
|
|
|
|
|
2023-07-10 20:14:10 +02:00
|
|
|
attributes.layer_visible = [];
|
2023-06-17 14:30:49 +02:00
|
|
|
attributes.layer_selectable = [];
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
attributes.display_name = true;
|
2023-06-23 15:39:24 +02:00
|
|
|
attributes.display_bone = 0;
|
2023-07-05 15:09:52 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
anchor_selecting = noone;
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
array_push(attributeEditors, "Display");
|
2023-07-14 20:34:35 +02:00
|
|
|
array_push(attributeEditors, ["Display name", function() { return attributes.display_name; },
|
2023-07-05 15:09:52 +02:00
|
|
|
new checkBox(function() {
|
|
|
|
attributes.display_name = !attributes.display_name;
|
|
|
|
})]);
|
2023-07-14 20:34:35 +02:00
|
|
|
array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; },
|
2023-07-05 15:09:52 +02:00
|
|
|
new scrollBox(["Octahedral", "Stick"], function(ind) {
|
2023-06-23 15:39:24 +02:00
|
|
|
attributes.display_bone = ind;
|
|
|
|
})]);
|
|
|
|
|
|
|
|
boneMap = ds_map_create();
|
|
|
|
surfMap = ds_map_create();
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
hold_visibility = true;
|
2023-06-23 15:39:24 +02:00
|
|
|
hold_select = true;
|
|
|
|
layer_dragging = noone;
|
|
|
|
layer_remove = -1;
|
|
|
|
|
|
|
|
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region
|
|
|
|
ds_map_clear(surfMap);
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var index = -1;
|
2023-08-13 09:51:36 +02:00
|
|
|
var amo = min(ds_list_size(inputs) - data_length, array_length(current_data));
|
|
|
|
|
|
|
|
for(var i = input_fix_len; i < amo; i += data_length) {
|
2023-06-25 20:12:17 +02:00
|
|
|
index++;
|
2023-06-23 15:39:24 +02:00
|
|
|
var _surf = current_data[i];
|
2023-10-02 08:57:44 +02:00
|
|
|
var _id = inputs[| i].display_data.bone_id;
|
2023-06-23 15:39:24 +02:00
|
|
|
if(_id == "") continue;
|
|
|
|
|
|
|
|
if(ds_map_exists(surfMap, _id))
|
2023-06-25 20:12:17 +02:00
|
|
|
array_push(surfMap[? _id], [ index, _surf ]);
|
2023-06-23 15:39:24 +02:00
|
|
|
else
|
2023-06-25 20:12:17 +02:00
|
|
|
surfMap[? _id] = [ [ index, _surf ] ];
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
//print($"Add {_surf} to {_id}");
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#region draw bones
|
2023-07-14 20:34:35 +02:00
|
|
|
var _b = bone;
|
2023-06-25 20:12:17 +02:00
|
|
|
if(_b == noone) return 0;
|
2023-06-23 15:39:24 +02:00
|
|
|
var amo = _b.childCount();
|
|
|
|
var _hh = ui(28);
|
|
|
|
var bh = ui(32 + 16) + amo * _hh;
|
|
|
|
var ty = _y;
|
|
|
|
|
|
|
|
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
|
2023-09-28 15:10:41 +02:00
|
|
|
draw_text_add(_x + ui(16), ty + ui(4), __txt("Bones"));
|
2023-06-23 15:39:24 +02:00
|
|
|
|
|
|
|
ty += ui(32);
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
var _ty = ty;
|
2023-06-23 15:39:24 +02:00
|
|
|
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, bh - ui(32), COLORS.node_composite_bg_blend, 1);
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
draw_set_color(COLORS.node_composite_separator);
|
|
|
|
draw_line(_x + 16, ty + ui(8), _x + _w - 16, ty + ui(8));
|
|
|
|
|
|
|
|
ty += ui(8);
|
|
|
|
|
|
|
|
var hovering = noone;
|
|
|
|
var _bst = ds_stack_create();
|
|
|
|
ds_stack_push(_bst, [ _b, _x, _w ]);
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
anchor_selecting = noone;
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
while(!ds_stack_empty(_bst)) {
|
2023-07-14 20:34:35 +02:00
|
|
|
var _st = ds_stack_pop(_bst);
|
|
|
|
var _bone = _st[0];
|
|
|
|
var __x = _st[1];
|
|
|
|
var __w = _st[2];
|
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(_bone.childs); i < n; i++ )
|
2023-07-14 20:34:35 +02:00
|
|
|
ds_stack_push(_bst, [ _bone.childs[i], __x + 16, __w - 16 ]);
|
|
|
|
|
|
|
|
if(_bone.is_main) continue;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(_bone.parent_anchor)
|
|
|
|
draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 14,,,, COLORS._main_icon);
|
|
|
|
else if(_bone.IKlength)
|
|
|
|
draw_sprite_ui(THEME.bone, 2, __x + 12, ty + 14,,,, COLORS._main_icon);
|
|
|
|
else
|
|
|
|
draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 14,,,, COLORS._main_icon);
|
2023-06-26 18:55:41 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
|
|
|
draw_text(__x + 24, ty + 12, _bone.name);
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(ds_map_exists(surfMap, _bone.ID)) {
|
|
|
|
var _sdata = surfMap[? _bone.ID];
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
var _sx = __x + 24 + string_width(_bone.name) + 8;
|
|
|
|
var _sy = ty + 4;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(_sdata); i < n; i++ ) {
|
2023-07-14 20:34:35 +02:00
|
|
|
var _sid = _sdata[i][0];
|
|
|
|
var _surf = _sdata[i][1];
|
2023-09-08 21:37:36 +02:00
|
|
|
var _sw = surface_get_width_safe(_surf);
|
|
|
|
var _sh = surface_get_height_safe(_surf);
|
2023-07-14 20:34:35 +02:00
|
|
|
var _ss = (_hh - 8) / _sh;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
draw_surface_ext_safe(_surf, _sx, _sy, _ss, _ss, 0, c_white, 1);
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(_hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss)) {
|
2023-08-08 18:45:00 +02:00
|
|
|
TOOLTIP = [ _surf, VALUE_TYPE.surface ];
|
2023-07-14 20:34:35 +02:00
|
|
|
if(mouse_press(mb_left, _focus)) {
|
|
|
|
layer_dragging = _sid;
|
2023-10-02 08:57:44 +02:00
|
|
|
inputs[| input_fix_len + _sid * data_length].display_data.bone_id = "";
|
2023-07-14 20:34:35 +02:00
|
|
|
}
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
} else
|
|
|
|
draw_set_color(COLORS.node_composite_bg);
|
|
|
|
draw_rectangle(_sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss, true);
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
_sx += _sw * _ss + 4;
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
}
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(point_in_rectangle(_m[0], _m[1], _x, ty, _x + _w, ty + _hh - 1)) {
|
|
|
|
if(layer_dragging != noone) {
|
2023-06-23 15:39:24 +02:00
|
|
|
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, ty, _w, _hh, COLORS._main_accent, 1);
|
2023-07-14 20:34:35 +02:00
|
|
|
hovering = _bone;
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-07-17 19:58:33 +02:00
|
|
|
|
|
|
|
anchor_selecting = [ _bone, 2 ];
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
|
|
|
ty += _hh;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
draw_set_color(COLORS.node_composite_separator);
|
|
|
|
draw_line(_x + 16, ty, _x + _w - 16, ty);
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-07-17 19:58:33 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
ds_stack_destroy(_bst);
|
2023-07-17 19:58:33 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
if(layer_dragging != noone && hovering && mouse_release(mb_left)) {
|
|
|
|
var _lind = input_fix_len + layer_dragging * data_length;
|
2023-10-02 08:57:44 +02:00
|
|
|
inputs[| _lind].display_data.bone_id = hovering.ID;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
|
|
|
layer_dragging = noone;
|
2023-07-05 15:09:52 +02:00
|
|
|
triggerRender();
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
|
|
|
if(layer_dragging != noone && !hovering)
|
|
|
|
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _ty, _w, bh - ui(32), COLORS._main_accent, 1);
|
2023-06-23 15:39:24 +02:00
|
|
|
#endregion
|
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
var amo = floor((ds_list_size(inputs) - input_fix_len) / data_length) - 1;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(array_length(current_data) != ds_list_size(inputs)) return 0;
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
var ty = _y + bh + ui(8);
|
|
|
|
|
|
|
|
//draw_set_color(COLORS.node_composite_separator);
|
|
|
|
//draw_line(_x + 16, ty - ui(4), _x + _w - 16, ty - ui(4));
|
|
|
|
|
|
|
|
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
|
2023-09-28 15:10:41 +02:00
|
|
|
draw_text_add(_x + ui(16), ty + ui(4), __txt("Surfaces"));
|
2023-06-23 15:39:24 +02:00
|
|
|
|
|
|
|
ty += ui(32);
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
#region draw surface
|
|
|
|
var lh = 32;
|
|
|
|
var sh = 8 + max(1, amo) * (lh + 4) + 8;
|
|
|
|
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, sh, COLORS.node_composite_bg_blend, 1);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var _vis = attributes.layer_visible;
|
|
|
|
var _sel = attributes.layer_selectable;
|
|
|
|
var ly = ty + 8;
|
|
|
|
var ssh = lh - 6;
|
|
|
|
var hoverIndex = noone;
|
|
|
|
draw_set_color(COLORS.node_composite_separator);
|
|
|
|
draw_line(_x + 16, ly, _x + _w - 16, ly);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
layer_remove = -1;
|
2023-08-08 20:33:17 +02:00
|
|
|
var index = amo;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
var _inp = input_fix_len + (amo - i - 1) * data_length;
|
|
|
|
var _surf = current_data[_inp];
|
|
|
|
|
2023-08-08 20:33:17 +02:00
|
|
|
index--;
|
2023-06-25 20:12:17 +02:00
|
|
|
var _bx = _x + _w - 24;
|
|
|
|
var _cy = ly + index * (lh + 4);
|
2023-09-14 16:29:39 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
|
|
|
|
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_value_negative);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_press(mb_left, _focus))
|
|
|
|
layer_remove = index;
|
|
|
|
} else
|
|
|
|
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon);
|
2023-08-02 19:11:57 +02:00
|
|
|
|
|
|
|
_bx -= 32;
|
|
|
|
|
|
|
|
//if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
|
|
|
|
// draw_sprite_ui_uniform(THEME.reset_16, 3, _bx, _cy + lh / 2, 1, COLORS._main_value_negative);
|
|
|
|
|
|
|
|
// if(mouse_press(mb_left, _focus))
|
|
|
|
// resetTransform(i);
|
|
|
|
//} else
|
|
|
|
// draw_sprite_ui_uniform(THEME.reset_16, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon);
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(!is_surface(_surf)) continue;
|
2023-08-02 19:11:57 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var aa = (index != layer_dragging || layer_dragging == noone)? 1 : 0.5;
|
|
|
|
var vis = _vis[index];
|
|
|
|
var sel = _sel[index];
|
|
|
|
var hover = point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
draw_set_color(COLORS.node_composite_separator);
|
|
|
|
draw_line(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var _bx = _x + 24 * 2 + 8;
|
|
|
|
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
|
|
|
|
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, c_white);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_press(mb_left, _focus))
|
|
|
|
hold_visibility = !_vis[index];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_click(mb_left, _focus) && _vis[index] != hold_visibility) {
|
2023-09-14 16:29:39 +02:00
|
|
|
_vis[index] = hold_visibility;
|
2023-06-25 20:12:17 +02:00
|
|
|
doUpdate();
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * vis);
|
2023-09-14 16:29:39 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
_bx += 24 + 8;
|
|
|
|
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
|
|
|
|
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, c_white);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_press(mb_left, _focus))
|
|
|
|
hold_select = !_sel[index];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_click(mb_left, _focus) && _sel[index] != hold_select)
|
2023-09-14 16:29:39 +02:00
|
|
|
_sel[index] = hold_select;
|
2023-06-25 20:12:17 +02:00
|
|
|
} else
|
|
|
|
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * sel);
|
|
|
|
|
|
|
|
draw_set_color(COLORS.node_composite_bg);
|
|
|
|
var _sx0 = _bx + 24;
|
|
|
|
var _sx1 = _sx0 + ssh;
|
|
|
|
var _sy0 = _cy + 3;
|
|
|
|
var _sy1 = _sy0 + ssh;
|
|
|
|
draw_rectangle(_sx0, _sy0, _sx1, _sy1, true);
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var _ssw = surface_get_width_safe(_surf);
|
|
|
|
var _ssh = surface_get_height_safe(_surf);
|
2023-06-25 20:12:17 +02:00
|
|
|
var _sss = min(ssh / _ssw, ssh / _ssh);
|
|
|
|
draw_surface_ext_safe(_surf, _sx0, _sy0, _sss, _sss, 0, c_white, 1);
|
|
|
|
|
|
|
|
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text : COLORS._main_text);
|
|
|
|
draw_set_alpha(aa);
|
2023-08-08 20:33:17 +02:00
|
|
|
draw_text(_sx1 + 12, _cy + lh / 2, inputs[| _inp].name);
|
2023-06-25 20:12:17 +02:00
|
|
|
draw_set_alpha(1);
|
|
|
|
|
|
|
|
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
|
|
|
|
hoverIndex = index;
|
|
|
|
if(layer_dragging != noone) {
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
if(layer_dragging > index)
|
|
|
|
draw_line_width(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2, 2);
|
|
|
|
else if(layer_dragging < index)
|
|
|
|
draw_line_width(_x + 16, _cy - 2, _x + _w - 16, _cy - 2, 2);
|
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var binded = inputs[| _inp].display_data.bone_id != "";
|
2023-07-14 20:34:35 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(layer_dragging == noone || layer_dragging == index) {
|
|
|
|
var _bx = _x + 24;
|
|
|
|
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
|
2023-07-14 20:34:35 +02:00
|
|
|
draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, c_white);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
if(mouse_press(mb_left, _focus))
|
|
|
|
layer_dragging = index;
|
2023-07-14 20:34:35 +02:00
|
|
|
} else {
|
|
|
|
if(!binded) {
|
|
|
|
var cc = merge_color(COLORS._main_icon, COLORS._main_accent, 0.5 + 0.5 * (sin(current_time / 100) * 0.5 + 0.5));
|
|
|
|
draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, cc);
|
|
|
|
} else
|
|
|
|
draw_sprite_ui_uniform(THEME.hamburger_s, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon);
|
|
|
|
}
|
2023-06-25 20:12:17 +02:00
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-06-25 20:12:17 +02:00
|
|
|
#endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
if(layer_dragging != noone && mouse_release(mb_left)) { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
if(layer_dragging != hoverIndex && hoverIndex != noone) {
|
|
|
|
var index = input_fix_len + layer_dragging * data_length;
|
|
|
|
var targt = input_fix_len + hoverIndex * data_length;
|
2023-08-02 19:11:57 +02:00
|
|
|
var _vis = attributes.layer_visible;
|
|
|
|
var _sel = attributes.layer_selectable;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
var ext = [];
|
|
|
|
var vis = _vis[layer_dragging];
|
|
|
|
array_delete(_vis, layer_dragging, 1);
|
|
|
|
array_insert(_vis, hoverIndex, vis);
|
|
|
|
|
|
|
|
var sel = _sel[layer_dragging];
|
|
|
|
array_delete(_sel, layer_dragging, 1);
|
|
|
|
array_insert(_sel, hoverIndex, sel);
|
|
|
|
|
|
|
|
for( var i = 0; i < data_length; i++ ) {
|
|
|
|
ext[i] = inputs[| index];
|
|
|
|
ds_list_delete(inputs, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
for( var i = 0; i < data_length; i++ ) {
|
|
|
|
ds_list_insert(inputs, targt + i, ext[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
doUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_dragging = noone;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
layer_renderer.h = bh + ui(40) + sh;
|
|
|
|
return layer_renderer.h;
|
|
|
|
#endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
});
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
input_display_list = [ 1, 2,
|
2023-06-23 15:39:24 +02:00
|
|
|
["Output", true], 0,
|
2023-07-14 20:34:35 +02:00
|
|
|
["Armature", false], 3, 4, layer_renderer,
|
2023-06-23 15:39:24 +02:00
|
|
|
["Surfaces", true],
|
2023-06-17 14:30:49 +02:00
|
|
|
];
|
|
|
|
input_display_list_len = array_length(input_display_list);
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
function deleteLayer(index) { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
var idx = input_fix_len + index * data_length;
|
|
|
|
for( var i = 0; i < data_length; i++ ) {
|
|
|
|
ds_list_delete(inputs, idx);
|
|
|
|
array_remove(input_display_list, idx + i);
|
|
|
|
}
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
for( var i = input_display_list_len; i < array_length(input_display_list); i++ ) {
|
|
|
|
if(input_display_list[i] > idx)
|
|
|
|
input_display_list[i] = input_display_list[i] - data_length;
|
|
|
|
}
|
2023-06-25 20:12:17 +02:00
|
|
|
|
|
|
|
if(ds_list_size(inputs) == input_fix_len)
|
2023-08-05 14:00:33 +02:00
|
|
|
createNewInput();
|
2023-06-17 14:30:49 +02:00
|
|
|
doUpdate();
|
2023-06-23 15:39:24 +02:00
|
|
|
#endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-05 14:00:33 +02:00
|
|
|
static createNewInput = function() { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
var index = ds_list_size(inputs);
|
|
|
|
var _s = floor((index - input_fix_len) / data_length);
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
inputs[| index + 0] = nodeValue("Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
2023-06-17 14:30:49 +02:00
|
|
|
inputs[| index + 0].surface_index = index;
|
|
|
|
inputs[| index + 0].hover_effect = 0;
|
2023-10-02 08:57:44 +02:00
|
|
|
inputs[| index + 0].display_data.bone_id = "";
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
inputs[| index + 1] = nodeValue("Transform", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0, 1, 1 ] )
|
|
|
|
.setDisplay(VALUE_DISPLAY.transform);
|
2023-08-01 19:21:51 +02:00
|
|
|
inputs[| index + 2] = nodeValue("Inherit Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true );
|
2023-08-08 18:45:00 +02:00
|
|
|
inputs[| index + 3] = nodeValue("Apply Bone Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
|
2023-08-01 19:21:51 +02:00
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
inputs[| index + 4] = nodeValue("Inherit Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
|
|
|
|
inputs[| index + 5] = nodeValue("Apply Bone Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
|
2023-08-02 19:11:57 +02:00
|
|
|
|
2023-08-01 19:21:51 +02:00
|
|
|
for( var i = 0; i < data_length; i++ )
|
|
|
|
array_push(input_display_list, index + i);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
while(_s >= array_length(attributes.layer_visible))
|
|
|
|
array_push(attributes.layer_visible, true);
|
|
|
|
while(_s >= array_length(attributes.layer_selectable))
|
|
|
|
array_push(attributes.layer_selectable, true);
|
2023-06-23 15:39:24 +02:00
|
|
|
#endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
setIsDynamicInput(6);
|
2023-08-01 19:21:51 +02:00
|
|
|
|
2023-08-05 14:00:33 +02:00
|
|
|
if(!LOADING && !APPENDING) createNewInput();
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-05 06:29:20 +02:00
|
|
|
temp_surface = [ surface_create(1, 1), surface_create(1, 1), surface_create(1, 1) ];
|
|
|
|
blend_temp_surface = temp_surface[2];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
surf_dragging = -1;
|
2023-09-14 16:29:39 +02:00
|
|
|
drag_type = 0;
|
2023-06-17 14:30:49 +02:00
|
|
|
dragging_sx = 0;
|
|
|
|
dragging_sy = 0;
|
|
|
|
dragging_mx = 0;
|
|
|
|
dragging_my = 0;
|
|
|
|
|
|
|
|
rot_anc_x = 0;
|
|
|
|
rot_anc_y = 0;
|
|
|
|
|
|
|
|
overlay_w = 0;
|
|
|
|
overlay_h = 0;
|
|
|
|
|
|
|
|
atlas_data = [];
|
2023-06-25 20:12:17 +02:00
|
|
|
bind_data = [];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
bone = noone;
|
2023-07-05 15:09:52 +02:00
|
|
|
surface_selecting = noone;
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static getInputAmount = function() { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
return input_fix_len + (ds_list_size(inputs) - input_fix_len) / data_length;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static getInputIndex = function(index) { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
if(index < input_fix_len) return index;
|
|
|
|
return input_fix_len + (index - input_fix_len) * data_length;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static setHeight = function() { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
var _hi = ui(32);
|
|
|
|
var _ho = ui(32);
|
|
|
|
|
|
|
|
for( var i = 0; i < getInputAmount(); i++ )
|
|
|
|
if(inputs[| getInputIndex(i)].isVisible())
|
|
|
|
_hi += 24;
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ )
|
|
|
|
if(outputs[| i].isVisible())
|
|
|
|
_ho += 24;
|
|
|
|
|
|
|
|
h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho);
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
static onValueFromUpdate = function(index) { #region
|
|
|
|
if(LOADING || APPENDING) return;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
if(index + data_length >= ds_list_size(inputs))
|
2023-08-05 14:00:33 +02:00
|
|
|
createNewInput();
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
static setBone = function() { #region
|
|
|
|
ds_map_clear(boneMap);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _b = getInputData(1);
|
2023-08-01 19:21:51 +02:00
|
|
|
bone = _b;
|
|
|
|
if(bone == noone) return;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
var _bst = ds_stack_create();
|
2023-07-14 20:34:35 +02:00
|
|
|
ds_stack_push(_bst, bone);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
while(!ds_stack_empty(_bst)) {
|
2023-07-14 20:34:35 +02:00
|
|
|
var _bone = ds_stack_pop(_bst);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(_bone.childs); i < n; i++ ) {
|
2023-07-14 20:34:35 +02:00
|
|
|
var child_bone = _bone.childs[i];
|
2023-07-05 15:09:52 +02:00
|
|
|
boneMap[? child_bone.ID] = child_bone;
|
2023-06-25 20:12:17 +02:00
|
|
|
ds_stack_push(_bst, child_bone);
|
2023-06-23 15:39:24 +02:00
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
ds_stack_destroy(_bst);
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var dim = getInputData(0);
|
|
|
|
var _bind = getInputData(2);
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _dpos = getInputData(3);
|
|
|
|
var _dsca = getInputData(4);
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(bone == noone) return;
|
|
|
|
|
|
|
|
bone.draw(attributes, false, _x + _dpos[0] * _s, _y + _dpos[1] * _s, _s * _dsca, _mx, _my, anchor_selecting);
|
|
|
|
inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
|
|
|
//inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-08-01 19:21:51 +02:00
|
|
|
var mx = (_mx - _x) / _s;
|
|
|
|
var my = (_my - _y) / _s;
|
|
|
|
|
|
|
|
var smx = value_snap(mx, _snx);
|
|
|
|
var smy = value_snap(my, _sny);
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(_bind != noone)
|
|
|
|
return;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
var ww = dim[0];
|
|
|
|
var hh = dim[1];
|
|
|
|
|
|
|
|
var x0 = _x;
|
|
|
|
var x1 = _x + ww * _s;
|
|
|
|
var y0 = _y;
|
|
|
|
var y1 = _y + hh * _s;
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
if(surf_dragging > -1) { #region
|
2023-08-08 18:45:00 +02:00
|
|
|
var _surf = current_data[surf_dragging + 0];
|
|
|
|
var _tran = current_data[surf_dragging + 1];
|
|
|
|
var _aang = current_data[surf_dragging + 2];
|
|
|
|
var _pang = current_data[surf_dragging + 3];
|
|
|
|
var _asca = current_data[surf_dragging + 4];
|
|
|
|
var _psca = current_data[surf_dragging + 5];
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
_tran = array_clone(_tran);
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _bone = inputs[| surf_dragging].display_data.bone_id;
|
2023-06-23 15:39:24 +02:00
|
|
|
_bone = boneMap[? _bone];
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(drag_type == NODE_COMPOSE_DRAG.move) {
|
2023-08-01 19:21:51 +02:00
|
|
|
var _dx = smx - dragging_mx;
|
|
|
|
var _dy = smy - dragging_my;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
var _p = point_rotate(_dx, _dy, 0, 0, -_bone.angle);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
var pos_x = dragging_sx + _p[0];
|
|
|
|
var pos_y = dragging_sy + _p[1];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
_tran[TRANSFORM.pos_x] = pos_x;
|
|
|
|
_tran[TRANSFORM.pos_y] = pos_y;
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(drag_type == NODE_COMPOSE_DRAG.rotate) {
|
|
|
|
var aa = point_direction(rot_anc_x, rot_anc_y, _mx, _my);
|
|
|
|
var da = angle_difference(dragging_mx, aa);
|
|
|
|
var sa;
|
|
|
|
|
|
|
|
if(key_mod_press(CTRL))
|
|
|
|
sa = round((dragging_sx - da) / 15) * 15;
|
|
|
|
else
|
|
|
|
sa = dragging_sx - da;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
|
|
|
_tran[TRANSFORM.rot] = sa;
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(drag_type == NODE_COMPOSE_DRAG.scale) {
|
2023-08-08 18:45:00 +02:00
|
|
|
var _rot = _aang * (_pang? _bone.angle : _bone.pose_local_angle) + _tran[TRANSFORM.rot];
|
2023-09-08 21:37:36 +02:00
|
|
|
var _sw = surface_get_width_safe(_surf);
|
|
|
|
var _sh = surface_get_height_safe(_surf);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
var _p = point_rotate(_mx - dragging_mx, _my - dragging_my, 0, 0, -_rot);
|
|
|
|
var sca_x = _p[0] / _s / _sw * 2;
|
|
|
|
var sca_y = _p[1] / _s / _sh * 2;
|
|
|
|
|
|
|
|
if(key_mod_press(SHIFT)) {
|
|
|
|
sca_x = min(sca_x, sca_y);
|
2023-06-23 15:39:24 +02:00
|
|
|
sca_y = sca_x;
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
if(_asca) {
|
2023-08-08 18:45:00 +02:00
|
|
|
sca_x /= _psca? _bone.pose_scale : _bone.pose_local_scale;
|
|
|
|
sca_y /= _psca? _bone.pose_scale : _bone.pose_local_scale;
|
2023-08-02 19:11:57 +02:00
|
|
|
}
|
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
_tran[TRANSFORM.sca_x] = sca_x;
|
|
|
|
_tran[TRANSFORM.sca_y] = sca_y;
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
if(inputs[| surf_dragging + 1].setValue(_tran))
|
2023-06-23 15:39:24 +02:00
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(mouse_release(mb_left)) {
|
2023-06-25 20:12:17 +02:00
|
|
|
surf_dragging = -1;
|
2023-06-17 14:30:49 +02:00
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
var hovering = noone;
|
|
|
|
var hovering_type = noone;
|
2023-06-17 14:30:49 +02:00
|
|
|
var _vis = attributes.layer_visible;
|
|
|
|
var _sel = attributes.layer_selectable;
|
|
|
|
|
|
|
|
var amo = (ds_list_size(inputs) - input_fix_len) / data_length;
|
2023-07-05 15:09:52 +02:00
|
|
|
var anchors = array_create(ds_list_size(inputs));
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
for(var i = 0; i < amo; i++) { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
var index = input_fix_len + i * data_length;
|
2023-06-25 20:12:17 +02:00
|
|
|
var _surf = array_safe_get(current_data, index);
|
|
|
|
if(!_surf || is_array(_surf)) continue;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _bone = inputs[| index].display_data.bone_id;
|
2023-06-25 20:12:17 +02:00
|
|
|
if(!ds_map_exists(boneMap, _bone)) {
|
|
|
|
//print($"Bone not found {_bone}");
|
|
|
|
continue;
|
|
|
|
}
|
2023-06-23 15:39:24 +02:00
|
|
|
_bone = boneMap[? _bone];
|
|
|
|
|
|
|
|
var _tran = current_data[index + 1];
|
2023-08-01 19:21:51 +02:00
|
|
|
var _aang = current_data[index + 2];
|
2023-08-08 18:45:00 +02:00
|
|
|
var _pang = current_data[index + 3];
|
|
|
|
var _asca = current_data[index + 4];
|
|
|
|
var _psca = current_data[index + 5];
|
2023-08-01 19:21:51 +02:00
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
var _rot = _aang * (_pang? _bone.angle : _bone.pose_local_angle) + _tran[TRANSFORM.rot];
|
2023-06-25 20:12:17 +02:00
|
|
|
var _anc = _bone.getPoint(0.5);
|
|
|
|
var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _bone.angle);
|
2023-06-23 15:39:24 +02:00
|
|
|
var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ];
|
2023-08-02 19:11:57 +02:00
|
|
|
if(_asca) {
|
2023-08-08 18:45:00 +02:00
|
|
|
_sca[0] *= _psca? _bone.pose_scale : _bone.pose_local_scale;
|
|
|
|
_sca[1] *= _psca? _bone.pose_scale : _bone.pose_local_scale;
|
2023-08-02 19:11:57 +02:00
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var _ww = surface_get_width_safe(_surf);
|
|
|
|
var _hh = surface_get_height_safe(_surf);
|
2023-06-17 14:30:49 +02:00
|
|
|
var _sw = _ww * _sca[0];
|
|
|
|
var _sh = _hh * _sca[1];
|
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
var _cx = (_anc.x * _dsca) + _mov[0] + _dpos[0];
|
|
|
|
var _cy = (_anc.y * _dsca) + _mov[1] + _dpos[1];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
var _d0 = point_rotate(_cx - _sw / 2, _cy - _sh / 2, _cx, _cy, _rot);
|
|
|
|
var _d1 = point_rotate(_cx - _sw / 2, _cy + _sh / 2, _cx, _cy, _rot);
|
|
|
|
var _d2 = point_rotate(_cx + _sw / 2, _cy - _sh / 2, _cx, _cy, _rot);
|
|
|
|
var _d3 = point_rotate(_cx + _sw / 2, _cy + _sh / 2, _cx, _cy, _rot);
|
|
|
|
var _rr = point_rotate(_cx, _cy - _sh / 2 - 4, _cx, _cy, _rot);
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
_d0[0] = overlay_x(_d0[0], _x, _s); _d0[1] = overlay_y(_d0[1], _y, _s);
|
|
|
|
_d1[0] = overlay_x(_d1[0], _x, _s); _d1[1] = overlay_y(_d1[1], _y, _s);
|
|
|
|
_d2[0] = overlay_x(_d2[0], _x, _s); _d2[1] = overlay_y(_d2[1], _y, _s);
|
|
|
|
_d3[0] = overlay_x(_d3[0], _x, _s); _d3[1] = overlay_y(_d3[1], _y, _s);
|
|
|
|
_rr[0] = overlay_x(_rr[0], _x, _s); _rr[1] = overlay_y(_rr[1], _y, _s);
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
anchors[index] = {
|
|
|
|
cx: _cx,
|
|
|
|
cy: _cy,
|
|
|
|
d0: _d0,
|
|
|
|
d1: _d1,
|
|
|
|
d2: _d2,
|
|
|
|
d3: _d3,
|
|
|
|
rr: _rr,
|
|
|
|
|
|
|
|
rot: _rot,
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
for(var i = 0; i < amo; i++) { #region
|
2023-07-05 15:09:52 +02:00
|
|
|
var vis = array_safe_get(_vis, i);
|
|
|
|
var sel = array_safe_get(_sel, i);
|
|
|
|
if(!vis) continue;
|
|
|
|
if(!sel) continue;
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
var index = input_fix_len + i * data_length;
|
|
|
|
var _surf = array_safe_get(current_data, index);
|
|
|
|
if(!_surf || is_array(_surf)) continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _bone = inputs[| index].display_data.bone_id;
|
2023-07-05 15:09:52 +02:00
|
|
|
if(!ds_map_exists(boneMap, _bone))
|
|
|
|
continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
var a = anchors[index];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
if(surface_selecting == index) {
|
|
|
|
var _ri = 0;
|
|
|
|
var _si = 0;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
if(point_in_circle(_mx, _my, a.d3[0], a.d3[1], 12)) {
|
|
|
|
hovering = index;
|
|
|
|
hovering_type = NODE_COMPOSE_DRAG.scale;
|
|
|
|
_si = 1;
|
|
|
|
} else if(point_in_rectangle_points(_mx, _my, a.d0[0], a.d0[1], a.d1[0], a.d1[1], a.d2[0], a.d2[1], a.d3[0], a.d3[1])) {
|
|
|
|
hovering = index;
|
|
|
|
hovering_type = NODE_COMPOSE_DRAG.move;
|
|
|
|
} else if(point_in_circle(_mx, _my, a.rr[0], a.rr[1], 12)) {
|
|
|
|
hovering = index;
|
|
|
|
hovering_type = NODE_COMPOSE_DRAG.rotate;
|
|
|
|
_ri = 1;
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-07-05 15:09:52 +02:00
|
|
|
|
|
|
|
draw_sprite_colored(THEME.anchor_rotate, _ri, a.rr[0], a.rr[1],, a.rot);
|
|
|
|
draw_sprite_colored(THEME.anchor_scale, _si, a.d3[0], a.d3[1],, a.rot);
|
2023-08-02 19:11:57 +02:00
|
|
|
} else if(point_in_rectangle_points(_mx, _my, a.d0[0], a.d0[1], a.d1[0], a.d1[1], a.d2[0], a.d2[1], a.d3[0], a.d3[1]) &&
|
|
|
|
(surface_selecting != hovering || surface_selecting == noone)) {
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
hovering = index;
|
|
|
|
hovering_type = NODE_COMPOSE_DRAG.move;
|
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-07-05 15:09:52 +02:00
|
|
|
|
|
|
|
if(mouse_press(mb_left, active))
|
|
|
|
surface_selecting = hovering;
|
2023-08-11 21:08:02 +02:00
|
|
|
if(surface_selecting != noone) {
|
|
|
|
var a = array_safe_get(anchors, surface_selecting, noone);
|
|
|
|
if(!is_struct(a)) surface_selecting = noone;
|
|
|
|
}
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
if(hovering != noone) {
|
|
|
|
var a = anchors[hovering];
|
|
|
|
|
|
|
|
draw_set_color(COLORS.node_composite_overlay_border);
|
|
|
|
draw_line(a.d0[0], a.d0[1], a.d1[0], a.d1[1]);
|
|
|
|
draw_line(a.d0[0], a.d0[1], a.d2[0], a.d2[1]);
|
|
|
|
draw_line(a.d3[0], a.d3[1], a.d1[0], a.d1[1]);
|
|
|
|
draw_line(a.d3[0], a.d3[1], a.d2[0], a.d2[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(surface_selecting != noone) {
|
|
|
|
var a = anchors[surface_selecting];
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_line(a.d0[0], a.d0[1], a.d1[0], a.d1[1]);
|
|
|
|
draw_line(a.d0[0], a.d0[1], a.d2[0], a.d2[1]);
|
|
|
|
draw_line(a.d3[0], a.d3[1], a.d1[0], a.d1[1]);
|
|
|
|
draw_line(a.d3[0], a.d3[1], a.d2[0], a.d2[1]);
|
|
|
|
}
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
if(hovering != noone && hovering_type != noone && mouse_press(mb_left, active)) { #region
|
2023-08-02 19:11:57 +02:00
|
|
|
var _tran = current_data[hovering + 1];
|
|
|
|
var _aang = current_data[hovering + 2];
|
|
|
|
var _asca = current_data[hovering + 3];
|
|
|
|
|
2023-07-05 15:09:52 +02:00
|
|
|
var a = anchors[hovering];
|
|
|
|
|
|
|
|
if(hovering_type == NODE_COMPOSE_DRAG.move) { //move
|
|
|
|
surf_dragging = hovering;
|
|
|
|
drag_type = hovering_type;
|
|
|
|
dragging_sx = _tran[TRANSFORM.pos_x];
|
|
|
|
dragging_sy = _tran[TRANSFORM.pos_y];
|
2023-08-01 19:21:51 +02:00
|
|
|
dragging_mx = mx;
|
|
|
|
dragging_my = my;
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(hovering_type == NODE_COMPOSE_DRAG.rotate) { //rot
|
2023-07-05 15:09:52 +02:00
|
|
|
surf_dragging = hovering;
|
|
|
|
drag_type = hovering_type;
|
|
|
|
dragging_sx = _tran[TRANSFORM.rot];
|
|
|
|
rot_anc_x = overlay_x(a.cx, _x, _s);
|
|
|
|
rot_anc_y = overlay_y(a.cy, _y, _s);
|
|
|
|
dragging_mx = point_direction(rot_anc_x, rot_anc_y, _mx, _my);
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(hovering_type == NODE_COMPOSE_DRAG.scale) { //sca
|
2023-07-05 15:09:52 +02:00
|
|
|
surf_dragging = hovering;
|
|
|
|
drag_type = hovering_type;
|
|
|
|
dragging_mx = (a.d0[0] + a.d3[0]) / 2;
|
|
|
|
dragging_my = (a.d0[1] + a.d3[1]) / 2;
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
if(layer_remove > -1) {
|
|
|
|
deleteLayer(layer_remove);
|
|
|
|
layer_remove = -1;
|
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static step = function() { #region
|
2023-06-23 15:39:24 +02:00
|
|
|
var _dim_type = getSingleValue(1);
|
2023-06-17 14:30:49 +02:00
|
|
|
inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
|
2023-08-08 20:33:17 +02:00
|
|
|
|
|
|
|
for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) {
|
|
|
|
inputs[| i + 3].setVisible(current_data[i + 2]);
|
|
|
|
inputs[| i + 5].setVisible(current_data[i + 4]);
|
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
if(_output_index == 1) return atlas_data;
|
2023-06-25 20:12:17 +02:00
|
|
|
if(_output_index == 2) return bind_data;
|
|
|
|
if(_output_index == 0 && _array_index == 0) {
|
|
|
|
atlas_data = [];
|
|
|
|
bind_data = [];
|
|
|
|
}
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
var _dim = _data[0];
|
|
|
|
var _bone = _data[1];
|
2023-06-25 20:12:17 +02:00
|
|
|
var _bind = _data[2];
|
2023-07-14 20:34:35 +02:00
|
|
|
|
|
|
|
var _dpos = _data[3];
|
|
|
|
var _dsca = _data[4];
|
2023-06-25 20:12:17 +02:00
|
|
|
var cDep = attrDepth();
|
|
|
|
|
2023-08-01 19:21:51 +02:00
|
|
|
setBone();
|
2023-07-14 20:34:35 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-06-23 15:39:24 +02:00
|
|
|
overlay_w = _dim[0];
|
|
|
|
overlay_h = _dim[1];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-05 06:29:20 +02:00
|
|
|
for(var i = 0; i < 3; i++) {
|
2023-08-11 21:08:02 +02:00
|
|
|
temp_surface[i] = surface_verify(temp_surface[i], _dim[0], _dim[1], cDep);
|
|
|
|
surface_clear(temp_surface[i]);
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var use_data = _bind != noone;
|
|
|
|
var res_index = 0;
|
|
|
|
var bg = 0;
|
|
|
|
var imageAmo = use_data? array_length(_bind) : (ds_list_size(inputs) - input_fix_len) / data_length;
|
|
|
|
var _vis = attributes.layer_visible;
|
2023-08-11 21:08:02 +02:00
|
|
|
var _bg = 0;
|
2023-06-17 14:30:49 +02:00
|
|
|
|
|
|
|
for(var i = 0; i < imageAmo; i++) {
|
2023-06-25 20:12:17 +02:00
|
|
|
var vis = array_safe_get(_vis, i, true);
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!vis) continue;
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var datInd = input_fix_len + i * data_length;
|
2023-10-06 11:51:11 +02:00
|
|
|
var _s = use_data? _bind[i].getSurface() : _data[datInd];
|
2023-06-25 20:12:17 +02:00
|
|
|
if(!is_surface(_s)) continue;
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _b = use_data? _bind[i].bone : inputs[| datInd].display_data.bone_id;
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-07-14 20:34:35 +02:00
|
|
|
if(!ds_map_exists(boneMap, _b)) {
|
2023-06-25 20:12:17 +02:00
|
|
|
//print($"Bone not exist {_bone} from map {ds_map_size(boneMap)}")
|
|
|
|
continue;
|
|
|
|
}
|
2023-07-14 20:34:35 +02:00
|
|
|
_b = boneMap[? _b];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var _tran = use_data? _bind[i].transform : _data[datInd + 1];
|
2023-08-09 15:41:35 +02:00
|
|
|
var _aang = use_data? _bind[i].applyRot : _data[datInd + 2];
|
|
|
|
var _pang = use_data? _bind[i].applyRotl : _data[datInd + 3];
|
|
|
|
var _asca = use_data? _bind[i].applySca : _data[datInd + 4];
|
|
|
|
var _psca = use_data? _bind[i].applyScal : _data[datInd + 5];
|
2023-08-02 19:11:57 +02:00
|
|
|
|
2023-08-08 18:45:00 +02:00
|
|
|
var _rot = _aang * (_pang? _b.angle : _b.pose_local_angle) + _tran[TRANSFORM.rot];
|
2023-07-14 20:34:35 +02:00
|
|
|
var _anc = _b.getPoint(0.5);
|
|
|
|
var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _b.angle);
|
2023-06-23 15:39:24 +02:00
|
|
|
var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ];
|
2023-08-02 19:11:57 +02:00
|
|
|
if(_asca) {
|
2023-08-08 18:45:00 +02:00
|
|
|
_sca[0] *= _psca? _b.pose_scale : _b.pose_local_scale;
|
|
|
|
_sca[1] *= _psca? _b.pose_scale : _b.pose_local_scale;
|
2023-08-02 19:11:57 +02:00
|
|
|
}
|
2023-06-23 15:39:24 +02:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var _ww = surface_get_width_safe(_s);
|
|
|
|
var _hh = surface_get_height_safe(_s);
|
2023-06-17 14:30:49 +02:00
|
|
|
var _sw = _ww * _sca[0];
|
|
|
|
var _sh = _hh * _sca[1];
|
|
|
|
|
2023-06-25 20:12:17 +02:00
|
|
|
var _cen = point_rotate(-_sw / 2, -_sh / 2, 0, 0, _rot);
|
|
|
|
var _pos = [
|
2023-07-14 20:34:35 +02:00
|
|
|
(_anc.x * _dsca) + _cen[0] + _mov[0] + _dpos[0],
|
|
|
|
(_anc.y * _dsca) + _cen[1] + _mov[1] + _dpos[1]
|
2023-06-25 20:12:17 +02:00
|
|
|
];
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-10-06 11:51:11 +02:00
|
|
|
array_push(atlas_data, new SurfaceAtlas(_s, _pos[0], _pos[1], _rot, _sca[0], _sca[1]));
|
2023-06-25 20:12:17 +02:00
|
|
|
array_push(bind_data, {
|
2023-08-09 15:41:35 +02:00
|
|
|
surface: new Surface(_s),
|
|
|
|
bone: _b.ID,
|
|
|
|
transform: _tran,
|
|
|
|
applyRot: _aang,
|
|
|
|
applyRotl: _pang,
|
|
|
|
applySca: _asca,
|
|
|
|
applyScal: _psca,
|
2023-06-25 20:12:17 +02:00
|
|
|
});
|
2023-08-11 21:08:02 +02:00
|
|
|
|
2023-12-15 12:56:36 +01:00
|
|
|
surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.alphamulp);
|
2023-10-05 06:29:20 +02:00
|
|
|
blend_temp_surface = temp_surface[2];
|
2023-08-11 21:08:02 +02:00
|
|
|
draw_surface_blend_ext(temp_surface[!_bg], _s, _pos[0], _pos[1], _sca[0], _sca[1], _rot);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
_bg = !_bg;
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-08-11 21:08:02 +02:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep);
|
|
|
|
|
|
|
|
surface_set_shader(_outSurf);
|
|
|
|
draw_surface_safe(temp_surface[!_bg]);
|
2023-06-17 14:30:49 +02:00
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
return _outSurf;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static resetTransform = function(surfIndex) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _bind = getInputData(2);
|
2023-08-02 19:11:57 +02:00
|
|
|
var use_data = _bind != noone;
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _surf = getInputData(surfIndex + 0);
|
|
|
|
var _tran = getInputData(surfIndex + 1);
|
|
|
|
var _arot = getInputData(surfIndex + 2);
|
2023-08-02 19:11:57 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _b = use_data? _bind[i].bone : inputs[| surfIndex].display_data.bone_id;
|
2023-08-02 19:11:57 +02:00
|
|
|
if(!ds_map_exists(boneMap, _b)) return;
|
|
|
|
|
|
|
|
_b = boneMap[? _b];
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var _cx = surface_get_width_safe(_surf) / 2;
|
|
|
|
var _cy = surface_get_height_safe(_surf) / 2;
|
2023-08-02 19:11:57 +02:00
|
|
|
|
|
|
|
var _anc = _b.getPoint(0.5);
|
|
|
|
var _rot = _arot? -_b.angle : 0;
|
|
|
|
|
|
|
|
var _tr = [ _cx - _anc.x, _cy - _anc.y, _rot, 1, 1 ];
|
|
|
|
inputs[| surfIndex + 1].setValue(_tr);
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-08-02 19:11:57 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static attributeSerialize = function() { #region
|
2023-06-17 14:30:49 +02:00
|
|
|
var att = {};
|
|
|
|
att.layer_visible = attributes.layer_visible;
|
|
|
|
att.layer_selectable = attributes.layer_selectable;
|
|
|
|
|
|
|
|
return att;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static attributeDeserialize = function(attr) { #region
|
2023-11-09 04:36:03 +01:00
|
|
|
if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension"))
|
|
|
|
attributes.use_project_dimension = false;
|
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(struct_has(attr, "layer_visible"))
|
|
|
|
attributes.layer_visible = attr.layer_visible;
|
|
|
|
|
|
|
|
if(struct_has(attr, "layer_selectable"))
|
|
|
|
attributes.layer_selectable = attr.layer_selectable;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-25 20:12:17 +02:00
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static doApplyDeserialize = function() { #region
|
2023-06-25 20:12:17 +02:00
|
|
|
setBone();
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2023-06-17 14:30:49 +02:00
|
|
|
}
|
|
|
|
|