diff --git a/scripts/__bone/__bone.gml b/scripts/__bone/__bone.gml index 978d6ca8a..8c4338fe2 100644 --- a/scripts/__bone/__bone.gml +++ b/scripts/__bone/__bone.gml @@ -291,7 +291,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = childs[i].setPoseTransform(_position, pose_angle, pose_scale); } - static setIKconstrain = function() { + static setIKconstrain = function() { if(IKlength > 0 && IKTarget != noone) { var points = array_create(IKlength + 1); var lengths = array_create(IKlength); @@ -321,7 +321,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = lengths[i] = point_distance(p0.x, p0.y, p1.x, p1.y); } - var p = parent.getPoint(0, 0); + var p = parent.getPoint(0); p.x += lengthdir_x(distance, direction); p.y += lengthdir_y(distance, direction); @@ -334,7 +334,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = FABRIK_result = []; static FABRIK = function(bones, points, lengths, dx, dy) { - var threshold = 0.1; + var threshold = 0.01; var _bo = array_create(array_length(points)); for( var i = 0, n = array_length(points); i < n; i++ ) _bo[i] = { x: points[i].x, y: points[i].y }; @@ -354,7 +354,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = } _bo = _bn; - if(++itr >= 32) break; + if(++itr >= 64) break; } until(delta <= threshold); for( var i = 0, n = array_length(points) - 1; i < n; i++ ) { @@ -379,7 +379,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = var p1 = points[i]; var p0 = points[i - 1]; var len = lengths[i - 1]; - var dir = point_direction(p0.x, p0.y, tx, ty); + var dir = point_direction(tx, ty, p0.x, p0.y); p1.x = tx; p1.y = ty; diff --git a/scripts/color_function/color_function.gml b/scripts/color_function/color_function.gml index 0cffd8d75..68e2c2cc8 100644 --- a/scripts/color_function/color_function.gml +++ b/scripts/color_function/color_function.gml @@ -13,10 +13,10 @@ function colorArrayFromReal(clr) { return [color_get_red(clr) / 255, color_get_green(clr) / 255, color_get_blue(clr) / 255 ]; } -function colorBrightness(clr) { - var r2 = color_get_red(clr) / 255; - var g2 = color_get_green(clr) / 255; - var b2 = color_get_blue(clr) / 255; +function colorBrightness(clr, normalize = true) { + var r2 = color_get_red(clr) / (normalize? 255 : 1); + var g2 = color_get_green(clr) / (normalize? 255 : 1); + var b2 = color_get_blue(clr) / (normalize? 255 : 1); return 0.299 * r2 + 0.587 * g2 + 0.224 * b2; } @@ -64,7 +64,7 @@ function color_diff(c1, c2, fast = false) { #region sorting functions function __valHSV(c, h, s, v) { return color_get_hue(c) * h + color_get_saturation(c) * s + color_get_value(c) * v; } function __valRGB(c, r, g, b) { return color_get_red(c) * r + color_get_green(c) * g + color_get_blue(c) * b; } - + function __sortBright(c1, c2) { var l1 = 0.299 * color_get_red(c1) + 0.587 * color_get_green(c1) + 0.114 * color_get_blue(c1); var l2 = 0.299 * color_get_red(c2) + 0.587 * color_get_green(c2) + 0.114 * color_get_blue(c2); diff --git a/scripts/node_armature/node_armature.gml b/scripts/node_armature/node_armature.gml index 57bf6b9b1..0fd70d13c 100644 --- a/scripts/node_armature/node_armature.gml +++ b/scripts/node_armature/node_armature.gml @@ -80,6 +80,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var _y0 = ty + 14; var cc = bone.apply_scale? COLORS._main_icon : COLORS._main_value_negative; if(point_in_circle(_m[0], _m[1], _x0, _y0, 16)) { + TOOLTIP = "Apply scale"; draw_sprite_ui(THEME.bone, 3, _x0, _y0,,,, cc, 0.75); if(mouse_press(mb_left, _focus)) @@ -90,6 +91,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo _x0 += 20; var cc = bone.apply_rotation? COLORS._main_icon : COLORS._main_value_negative; if(point_in_circle(_m[0], _m[1], _x0, _y0, 16)) { + TOOLTIP = "Apply rotation"; draw_sprite_ui(THEME.bone, 4, _x0, _y0,,,, cc, 0.75); if(mouse_press(mb_left, _focus)) @@ -270,7 +272,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var reachable = false; var _bone = ik_dragging.parent; - var len = 1; + var len = 0; while(_bone != noone) { if(_bone == anc.parent) { @@ -293,8 +295,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var IKbone = new __Bone(anc, _len, _ang, ik_dragging.angle + 90, 0, self); anc.addChild(IKbone); - IKbone.IKlength = len; - IKbone.IKTargetID = ik_dragging; + IKbone.IKlength = len; + IKbone.IKTargetID = ik_dragging.ID; IKbone.name = "IK handle"; IKbone.parent_anchor = false; @@ -422,7 +424,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo } } } else if(isUsingTool("Add bones")) { // builder - anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); + if(builder_bone == noone) + anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); if(mouse_press(mb_left, active)) { if(anchor_selecting == noone) { @@ -483,7 +486,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo if(anchor_selecting != noone) draw_sprite_ext(THEME.bone_tool_remove, 1, _mx + 24, _my + 24, 1, 1, 0, c_white, 1); } else if(isUsingTool("Detach bones")) { //detach - anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); + if(builder_bone == noone) + anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); if(anchor_selecting != noone && anchor_selecting[1] == 2 && mouse_press(mb_left, active)) { builder_bone = anchor_selecting[0]; @@ -503,13 +507,15 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo UNDO_HOLDING = true; } } else if(isUsingTool("IK")) { //IK - anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); + if(ik_dragging == noone) + anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); if(anchor_selecting != noone && anchor_selecting[1] == 2 && mouse_press(mb_left, active)) { ik_dragging = anchor_selecting[0]; } } else { //mover - anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); + if(builder_bone == noone) + anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); if(anchor_selecting != noone && mouse_press(mb_left, active)) { builder_bone = anchor_selecting[0]; diff --git a/scripts/node_armature_bind/node_armature_bind.gml b/scripts/node_armature_bind/node_armature_bind.gml index ab81e604f..0659a24d6 100644 --- a/scripts/node_armature_bind/node_armature_bind.gml +++ b/scripts/node_armature_bind/node_armature_bind.gml @@ -822,10 +822,10 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr _b = boneMap[? _b]; var _tran = use_data? _bind[i].transform : _data[datInd + 1]; - var _aang = _data[datInd + 2]; - var _pang = _data[datInd + 3]; - var _asca = _data[datInd + 4]; - var _psca = _data[datInd + 5]; + 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]; var _rot = _aang * (_pang? _b.angle : _b.pose_local_angle) + _tran[TRANSFORM.rot]; var _anc = _b.getPoint(0.5); @@ -851,9 +851,13 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr array_push(atlas_data, new SurfaceAtlas(_s, _pos, _rot, _sca)); array_push(bind_data, { - surface: new Surface(_s), - bone: _b.ID, - transform: _tran + surface: new Surface(_s), + bone: _b.ID, + transform: _tran, + applyRot: _aang, + applyRotl: _pang, + applySca: _asca, + applyScal: _psca, }); draw_surface_ext_safe(_s, _pos[0], _pos[1], _sca[0], _sca[1], _rot); } diff --git a/scripts/node_palette_sort/node_palette_sort.gml b/scripts/node_palette_sort/node_palette_sort.gml index e2d9f216d..ceadc8397 100644 --- a/scripts/node_palette_sort/node_palette_sort.gml +++ b/scripts/node_palette_sort/node_palette_sort.gml @@ -14,11 +14,19 @@ function Node_Palette_Sort(_x, _y, _group = noone) : Node(_x, _y, _group) constr inputs[| 2] = nodeValue("Reverse", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); - inputs[| 3] = nodeValue("Sort Order", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "RGB"); + inputs[| 3] = nodeValue("Sort Order", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "RGB", @"Compose sorting algorithm using string. + - RGB: Red/Green/Blur channel + - HSV: Hue/Saturation/Value + - L: Brightness + - Use small letter for ascending, capital letter for descending order."); outputs[| 0] = nodeValue("Sorted palette", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, []) .setDisplay(VALUE_DISPLAY.palette); + input_display_list = [ + 0, 1, 3, 2, + ] + static step = function() { var _typ = inputs[| 1].getValue(); @@ -28,19 +36,29 @@ function Node_Palette_Sort(_x, _y, _group = noone) : Node(_x, _y, _group) constr sort_string = ""; static customSort = function(c) { var len = string_length(sort_string); - var val = power(256, len); + var val = power(256, len - 1); + var res = 0; for( var i = 1; i <= len; i++ ) { - var ch = string_lower(string_char_at(sort_string, i)); + var ch = string_char_at(sort_string, i); + var _v = 0; - switch(ch) { - case "r" : return + switch(string_lower(ch)) { + case "r" : _v += color_get_red(c); break; + case "g" : _v += color_get_green(c); break; + case "b" : _v += color_get_blue(c); break; + case "h" : _v += color_get_hue(c); break; + case "s" : _v += color_get_saturation(c); break; + case "v" : _v += color_get_value(c); break; + case "l" : _v += colorBrightness(c, false); break; } + if(ord(ch) <= ord("Z")) res += _v * val; + else res += (256 - _v) * val; val /= 256; } - return c; + return res; } static update = function(frame = PROJECT.animator.current_frame) { @@ -63,7 +81,7 @@ function Node_Palette_Sort(_x, _y, _group = noone) : Node(_x, _y, _group) constr case 7 : array_sort(_pal, __sortGreen); break; case 8 : array_sort(_pal, __sortBlue); break; - case 10 : array_sort(_pal, function(c1, c2) { return customSort(c1) - customSort(c2); }); break; + case 10 : array_sort(_pal, function(c1, c2) { return customSort(c2) - customSort(c1); }); break; } if(_rev) _pal = array_reverse(_pal); diff --git a/scripts/struct_functions/struct_functions.gml b/scripts/struct_functions/struct_functions.gml index 75d870444..9060a2d3f 100644 --- a/scripts/struct_functions/struct_functions.gml +++ b/scripts/struct_functions/struct_functions.gml @@ -12,6 +12,7 @@ function struct_override(original, override) { } function struct_try_get(struct, key, def = 0) { + gml_pragma("forceinline"); if(struct[$ key] != undefined) return struct[$ key]; key = string_replace_all(key, "_", " ");