mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 22:46:19 +01:00
Armature rotation fix
This commit is contained in:
parent
0dfcbce2ce
commit
d249134988
12 changed files with 131 additions and 35 deletions
|
@ -1135,6 +1135,7 @@
|
||||||
{"name":"node_scale_algo","order":12,"path":"scripts/node_scale_algo/node_scale_algo.yy",},
|
{"name":"node_scale_algo","order":12,"path":"scripts/node_scale_algo/node_scale_algo.yy",},
|
||||||
{"name":"s_node_image_replace","order":55,"path":"sprites/s_node_image_replace/s_node_image_replace.yy",},
|
{"name":"s_node_image_replace","order":55,"path":"sprites/s_node_image_replace/s_node_image_replace.yy",},
|
||||||
{"name":"node_alpha_hash","order":11,"path":"scripts/node_alpha_hash/node_alpha_hash.yy",},
|
{"name":"node_alpha_hash","order":11,"path":"scripts/node_alpha_hash/node_alpha_hash.yy",},
|
||||||
|
{"name":"toggleGroup","order":31,"path":"scripts/toggleGroup/toggleGroup.yy",},
|
||||||
{"name":"mouse_input","order":1,"path":"scripts/mouse_input/mouse_input.yy",},
|
{"name":"mouse_input","order":1,"path":"scripts/mouse_input/mouse_input.yy",},
|
||||||
{"name":"string_cut","order":2,"path":"scripts/string_cut/string_cut.yy",},
|
{"name":"string_cut","order":2,"path":"scripts/string_cut/string_cut.yy",},
|
||||||
{"name":"node_3d_prim_cylinder","order":2,"path":"scripts/node_3d_prim_cylinder/node_3d_prim_cylinder.yy",},
|
{"name":"node_3d_prim_cylinder","order":2,"path":"scripts/node_3d_prim_cylinder/node_3d_prim_cylinder.yy",},
|
||||||
|
|
|
@ -1784,6 +1784,7 @@
|
||||||
{"id":{"name":"node_scale_algo","path":"scripts/node_scale_algo/node_scale_algo.yy",},},
|
{"id":{"name":"node_scale_algo","path":"scripts/node_scale_algo/node_scale_algo.yy",},},
|
||||||
{"id":{"name":"s_node_image_replace","path":"sprites/s_node_image_replace/s_node_image_replace.yy",},},
|
{"id":{"name":"s_node_image_replace","path":"sprites/s_node_image_replace/s_node_image_replace.yy",},},
|
||||||
{"id":{"name":"node_alpha_hash","path":"scripts/node_alpha_hash/node_alpha_hash.yy",},},
|
{"id":{"name":"node_alpha_hash","path":"scripts/node_alpha_hash/node_alpha_hash.yy",},},
|
||||||
|
{"id":{"name":"toggleGroup","path":"scripts/toggleGroup/toggleGroup.yy",},},
|
||||||
{"id":{"name":"mouse_input","path":"scripts/mouse_input/mouse_input.yy",},},
|
{"id":{"name":"mouse_input","path":"scripts/mouse_input/mouse_input.yy",},},
|
||||||
{"id":{"name":"string_cut","path":"scripts/string_cut/string_cut.yy",},},
|
{"id":{"name":"string_cut","path":"scripts/string_cut/string_cut.yy",},},
|
||||||
{"id":{"name":"node_3d_prim_cylinder","path":"scripts/node_3d_prim_cylinder/node_3d_prim_cylinder.yy",},},
|
{"id":{"name":"node_3d_prim_cylinder","path":"scripts/node_3d_prim_cylinder/node_3d_prim_cylinder.yy",},},
|
||||||
|
|
|
@ -111,7 +111,7 @@ event_inherited();
|
||||||
if(i < red) _yc = yy + ui(6);
|
if(i < red) _yc = yy + ui(6);
|
||||||
else _yc = yy + hh;
|
else _yc = yy + hh;
|
||||||
|
|
||||||
draw_sprite_ui(THEME.arrow, i < red? 3 : 1, ui(16), _yc, 1.5, 1.5, 0, cc, 1);
|
draw_sprite_ui(THEME.scroll_box_arrow, 0, ui(16), _yc, 1, 1 - (i > red) * 2, 0, cc, 1);
|
||||||
BLEND_NORMAL;
|
BLEND_NORMAL;
|
||||||
|
|
||||||
if(i == hovering)
|
if(i == hovering)
|
||||||
|
|
|
@ -7,6 +7,9 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
|
||||||
self.length = length;
|
self.length = length;
|
||||||
self.node = node;
|
self.node = node;
|
||||||
|
|
||||||
|
init_length = length;
|
||||||
|
init_angle = angle;
|
||||||
|
|
||||||
pose_angle = 0;
|
pose_angle = 0;
|
||||||
pose_scale = 1;
|
pose_scale = 1;
|
||||||
pose_posit = [ 0, 0 ];
|
pose_posit = [ 0, 0 ];
|
||||||
|
@ -95,22 +98,25 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
|
||||||
return noone;
|
return noone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPoint = function(progress) {
|
static getPoint = function(progress, pose = true) {
|
||||||
var len = length * progress;
|
var _len = pose? length : init_length;
|
||||||
|
var _ang = pose? angle : init_angle;
|
||||||
|
|
||||||
|
var len = _len * progress;
|
||||||
|
|
||||||
if(parent == noone)
|
if(parent == noone)
|
||||||
return new Point(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
|
return new Point(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
|
||||||
.add(lengthdir_x(len, angle), lengthdir_y(len, angle));
|
.add(lengthdir_x(len, _ang), lengthdir_y(len, _ang));
|
||||||
|
|
||||||
if(parent_anchor) {
|
if(parent_anchor) {
|
||||||
var p = parent.getPoint(1)
|
var p = parent.getPoint(1, pose)
|
||||||
.add(lengthdir_x(len, angle), lengthdir_y(len, angle))
|
.add(lengthdir_x(len, _ang), lengthdir_y(len, _ang))
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = parent.getPoint(0)
|
var p = parent.getPoint(0, pose)
|
||||||
.add(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
|
.add(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
|
||||||
.add(lengthdir_x(len, angle), lengthdir_y(len, angle))
|
.add(lengthdir_x(len, _ang), lengthdir_y(len, _ang))
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,30 +267,28 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pose_local_angle = pose_angle;
|
|
||||||
pose_local_scale = pose_scale;
|
|
||||||
pose_local_posit = pose_posit;
|
|
||||||
|
|
||||||
pose_posit[0] += _position[0];
|
pose_posit[0] += _position[0];
|
||||||
pose_posit[1] += _position[1];
|
pose_posit[1] += _position[1];
|
||||||
if(apply_rotation) pose_angle += _angle;
|
if(apply_rotation) pose_angle += _angle;
|
||||||
if(apply_scale) pose_scale *= _scale;
|
if(apply_scale) pose_scale *= _scale;
|
||||||
|
|
||||||
|
pose_local_angle = pose_angle;
|
||||||
|
pose_local_scale = pose_scale;
|
||||||
|
pose_local_posit = pose_posit;
|
||||||
|
|
||||||
var _x = lengthdir_x(distance, direction) + pose_posit[0];
|
var _x = lengthdir_x(distance, direction) + pose_posit[0];
|
||||||
var _y = lengthdir_y(distance, direction) + pose_posit[1];
|
var _y = lengthdir_y(distance, direction) + pose_posit[1];
|
||||||
|
|
||||||
direction = point_direction(0, 0, _x, _y) + _angle;
|
direction = point_direction(0, 0, _x, _y) + _angle;
|
||||||
distance = point_distance(0, 0, _x, _y) * _scale;
|
distance = point_distance(0, 0, _x, _y) * _scale;
|
||||||
|
|
||||||
|
init_length = length;
|
||||||
|
init_angle = angle;
|
||||||
angle += pose_angle;
|
angle += pose_angle;
|
||||||
length *= pose_scale;
|
length *= pose_scale;
|
||||||
|
|
||||||
for( var i = 0, n = array_length(childs); i < n; i++ ) {
|
for( var i = 0, n = array_length(childs); i < n; i++ )
|
||||||
if(childs[i].parent_anchor)
|
childs[i].setPoseTransform(_position, pose_angle, pose_scale);
|
||||||
childs[i].setPoseTransform(_position, pose_angle, pose_scale);
|
|
||||||
else
|
|
||||||
childs[i].setPoseTransform(_position, pose_angle, pose_scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setIKconstrain = function() {
|
static setIKconstrain = function() {
|
||||||
|
|
|
@ -17,6 +17,8 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
|
||||||
activate_on_press = false;
|
activate_on_press = false;
|
||||||
clicked = false;
|
clicked = false;
|
||||||
|
|
||||||
|
toggled = false;
|
||||||
|
|
||||||
static setLua = function(_lua_thread, _lua_key, _lua_func) {
|
static setLua = function(_lua_thread, _lua_key, _lua_func) {
|
||||||
lua_thread = _lua_thread;
|
lua_thread = _lua_thread;
|
||||||
lua_thread_key = _lua_key;
|
lua_thread_key = _lua_key;
|
||||||
|
@ -70,7 +72,7 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
|
||||||
var b = colorMultiply(self.blend, blend);
|
var b = colorMultiply(self.blend, blend);
|
||||||
|
|
||||||
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) {
|
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) {
|
||||||
draw_sprite_stretched_ext(spr, 1, _x, _y, _w, _h, b, 1);
|
draw_sprite_stretched_ext(spr, toggled? 2 : 1, _x, _y, _w, _h, b, 1);
|
||||||
if(!activate_on_press && mouse_release(mb_left, active))
|
if(!activate_on_press && mouse_release(mb_left, active))
|
||||||
trigger();
|
trigger();
|
||||||
if(activate_on_press && mouse_press(mb_left, active))
|
if(activate_on_press && mouse_press(mb_left, active))
|
||||||
|
@ -82,7 +84,7 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
|
||||||
}
|
}
|
||||||
if(tooltip != "") TOOLTIP = tooltip;
|
if(tooltip != "") TOOLTIP = tooltip;
|
||||||
} else {
|
} else {
|
||||||
draw_sprite_stretched_ext(spr, 0, _x, _y, _w, _h, b, 1);
|
draw_sprite_stretched_ext(spr, toggled? 2 : 0, _x, _y, _w, _h, b, 1);
|
||||||
if(mouse_press(mb_left)) deactivate();
|
if(mouse_press(mb_left)) deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,13 +208,13 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
draw_line(_x + 16, ly, _x + _w - 16, ly);
|
draw_line(_x + 16, ly, _x + _w - 16, ly);
|
||||||
|
|
||||||
layer_remove = -1;
|
layer_remove = -1;
|
||||||
var index = -1;
|
var index = amo;
|
||||||
|
|
||||||
for(var i = 0; i < amo; i++) {
|
for(var i = 0; i < amo; i++) {
|
||||||
var _inp = input_fix_len + (amo - i - 1) * data_length;
|
var _inp = input_fix_len + (amo - i - 1) * data_length;
|
||||||
var _surf = current_data[_inp];
|
var _surf = current_data[_inp];
|
||||||
|
|
||||||
index++;
|
index--;
|
||||||
var _bx = _x + _w - 24;
|
var _bx = _x + _w - 24;
|
||||||
var _cy = ly + index * (lh + 4);
|
var _cy = ly + index * (lh + 4);
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
|
|
||||||
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text : COLORS._main_text);
|
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text : COLORS._main_text);
|
||||||
draw_set_alpha(aa);
|
draw_set_alpha(aa);
|
||||||
draw_text(_sx1 + 12, _cy + lh / 2, inputs[| i].name);
|
draw_text(_sx1 + 12, _cy + lh / 2, inputs[| _inp].name);
|
||||||
draw_set_alpha(1);
|
draw_set_alpha(1);
|
||||||
|
|
||||||
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
|
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
|
||||||
|
@ -757,6 +757,11 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
static step = function() {
|
static step = function() {
|
||||||
var _dim_type = getSingleValue(1);
|
var _dim_type = getSingleValue(1);
|
||||||
inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
|
inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
||||||
|
|
|
@ -219,7 +219,6 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
||||||
|
|
||||||
posing_mx = mx;
|
posing_mx = mx;
|
||||||
posing_my = my;
|
posing_my = my;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1412,8 +1412,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
||||||
|
|
||||||
for( var i = _dynamic_inputs; i >= 1; i-- ) {
|
for( var i = _dynamic_inputs; i >= 1; i-- ) {
|
||||||
var _ind = _input_fix_len + i * _data_length;
|
var _ind = _input_fix_len + i * _data_length;
|
||||||
repeat(_pad_dyna)
|
if(_pad_dyna > 0)
|
||||||
array_insert(load_map.inputs, _ind, noone);
|
repeat(_pad_dyna) array_insert(load_map.inputs, _ind, noone);
|
||||||
|
else
|
||||||
|
array_delete(load_map.inputs, _ind + _pad_dyna, -_pad_dyna);
|
||||||
}
|
}
|
||||||
|
|
||||||
var _pad_fix = input_fix_len - _input_fix_len;
|
var _pad_fix = input_fix_len - _input_fix_len;
|
||||||
|
|
|
@ -62,6 +62,7 @@ enum VALUE_DISPLAY {
|
||||||
kernel,
|
kernel,
|
||||||
transform,
|
transform,
|
||||||
corner,
|
corner,
|
||||||
|
toggle,
|
||||||
|
|
||||||
//Curve
|
//Curve
|
||||||
curve,
|
curve,
|
||||||
|
@ -789,6 +790,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
|
|
||||||
extract_node = "Node_Transform_Array";
|
extract_node = "Node_Transform_Array";
|
||||||
break;
|
break;
|
||||||
|
case VALUE_DISPLAY.toggle :
|
||||||
|
editWidget = new toggleGroup(display_data, function(val) {
|
||||||
|
return setValueDirect(val);
|
||||||
|
} );
|
||||||
|
|
||||||
|
rejectConnect();
|
||||||
|
extract_node = "";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE.boolean :
|
case VALUE_TYPE.boolean :
|
||||||
|
@ -1305,12 +1314,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
static setValueDirect = function(val = 0, index = noone, record = true, time = PROJECT.animator.current_frame, _update = true) {
|
static setValueDirect = function(val = 0, index = noone, record = true, time = PROJECT.animator.current_frame, _update = true) {
|
||||||
var updated = false;
|
var updated = false;
|
||||||
|
|
||||||
//if(display_type == VALUE_DISPLAY.area) {
|
|
||||||
// print($"===== Set: {index} = {val} =====");
|
|
||||||
// printCallStack();
|
|
||||||
// print("");
|
|
||||||
//}
|
|
||||||
|
|
||||||
if(sep_axis) {
|
if(sep_axis) {
|
||||||
if(index == noone) {
|
if(index == noone) {
|
||||||
for( var i = 0, n = array_length(animators); i < n; i++ )
|
for( var i = 0, n = array_length(animators); i < n; i++ )
|
||||||
|
|
|
@ -110,7 +110,7 @@ function Panel_History() : PanelContent() constructor {
|
||||||
if(i < red) _yc = yy + ui(6);
|
if(i < red) _yc = yy + ui(6);
|
||||||
else _yc = yy + hh;
|
else _yc = yy + hh;
|
||||||
|
|
||||||
draw_sprite_ui(THEME.arrow, i < red? 3 : 1, ui(16), _yc, 1.5, 1.5, 0, cc, 1);
|
draw_sprite_ui(THEME.scroll_box_arrow, 0, ui(16), _yc, 1, 1 - (i > red) * 2, 0, cc, 1);
|
||||||
BLEND_NORMAL;
|
BLEND_NORMAL;
|
||||||
|
|
||||||
if(i == hovering)
|
if(i == hovering)
|
||||||
|
@ -151,7 +151,7 @@ function Panel_History() : PanelContent() constructor {
|
||||||
hovering = -1;
|
hovering = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _h;
|
return _h + ui(64);
|
||||||
})
|
})
|
||||||
|
|
||||||
function drawContent(panel) {
|
function drawContent(panel) {
|
||||||
|
|
68
scripts/toggleGroup/toggleGroup.gml
Normal file
68
scripts/toggleGroup/toggleGroup.gml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
function toggleGroup(_data, _onClick) : widget() constructor {
|
||||||
|
data = _data;
|
||||||
|
onClick = _onClick;
|
||||||
|
buttonSpr = [ THEME.button_left, THEME.button_middle, THEME.button_right ];
|
||||||
|
font = f_p0;
|
||||||
|
fColor = COLORS._main_text;
|
||||||
|
value = 0;
|
||||||
|
|
||||||
|
for(var i = 0; i < array_length(data); i++)
|
||||||
|
buttons[i] = button(-1);
|
||||||
|
|
||||||
|
static trigger = function() {}
|
||||||
|
|
||||||
|
static setInteract = function(interactable = noone) {
|
||||||
|
self.interactable = interactable;
|
||||||
|
for(var i = 0; i < array_length(data); i++)
|
||||||
|
buttons[i].interactable = interactable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static register = function(parent = noone) {
|
||||||
|
array_push(WIDGET_ACTIVE, self);
|
||||||
|
self.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static drawParam = function(params) {
|
||||||
|
return draw(params.x, params.y, params.w, params.h, params.data, params.m, params.rx, params.ry);
|
||||||
|
}
|
||||||
|
|
||||||
|
static draw = function(_x, _y, _w, _h, _data, _m, _rx = 0, _ry = 0) {
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
w = _w;
|
||||||
|
h = _h;
|
||||||
|
value = _data;
|
||||||
|
|
||||||
|
var amo = array_length(data);
|
||||||
|
var ww = _w / amo;
|
||||||
|
|
||||||
|
for(var i = 0; i < amo; i++) {
|
||||||
|
buttons[i].setFocusHover(active, hover);
|
||||||
|
|
||||||
|
var bx = _x + ww * i;
|
||||||
|
var spr = i == 0 ? buttonSpr[0] : (i == amo - 1? buttonSpr[2] : buttonSpr[1]);
|
||||||
|
var tog = _data & (1 << i);
|
||||||
|
|
||||||
|
buttons[i].toggled = tog;
|
||||||
|
buttons[i].draw(bx, _y, ww, _h, _m, spr);
|
||||||
|
if(buttons[i].clicked) {
|
||||||
|
value ^= (1 << i);
|
||||||
|
onClick(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_string(data[i])) {
|
||||||
|
draw_set_text(font, fa_center, fa_center, fColor);
|
||||||
|
draw_text(bx + ww / 2, _y + _h / 2, data[i]);
|
||||||
|
} else if(sprite_exists(data[i])) {
|
||||||
|
draw_sprite_ui_uniform(data[i], i, bx + ww / 2, _y + _h / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(WIDGET_CURRENT == self)
|
||||||
|
draw_sprite_stretched_ext(THEME.widget_selecting, 0, x - ui(3), y - ui(3), w + ui(6), h + ui(6), COLORS._main_accent, 1);
|
||||||
|
|
||||||
|
resetFocus();
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
}
|
11
scripts/toggleGroup/toggleGroup.yy
Normal file
11
scripts/toggleGroup/toggleGroup.yy
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"resourceType": "GMScript",
|
||||||
|
"resourceVersion": "1.0",
|
||||||
|
"name": "toggleGroup",
|
||||||
|
"isCompatibility": false,
|
||||||
|
"isDnD": false,
|
||||||
|
"parent": {
|
||||||
|
"name": "widgets",
|
||||||
|
"path": "folders/widgets.yy",
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in a new issue