mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 22:16:17 +01:00
Armature view, movement bug
This commit is contained in:
parent
1623e8fc1b
commit
c81ba8c88d
9 changed files with 113 additions and 26 deletions
|
@ -143,8 +143,8 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
|
|||
if(attributes.display_bone == 0) {
|
||||
var _ppx = lerp(p0.x, p1.x, 0.2);
|
||||
var _ppy = lerp(p0.y, p1.y, 0.2);
|
||||
draw_line_width2(p0.x, p0.y, _ppx, _ppy, 2, 12);
|
||||
draw_line_width2(_ppx, _ppy, p1.x, p1.y, 12, 2);
|
||||
draw_line_width2(p0.x, p0.y, _ppx, _ppy, 2 * pose_scale, 12 * pose_scale);
|
||||
draw_line_width2(_ppx, _ppy, p1.x, p1.y, 12 * pose_scale, 2 * pose_scale);
|
||||
|
||||
if((edit & 0b100) && distance_to_line(_mx, _my, p0.x, p0.y, p1.x, p1.y) <= 12) //drag bone
|
||||
hover = [ self, 2 ];
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
alpha: 0.5,
|
||||
on_top: true,
|
||||
};
|
||||
|
||||
static cleanup = function() {
|
||||
ds_list_destroy(nodes);
|
||||
ds_map_destroy(nodeMap);
|
||||
ds_map_destroy(nodeNameMap);
|
||||
}
|
||||
}
|
||||
|
||||
globalvar PROJECTS, PROJECT;
|
||||
|
@ -64,7 +70,7 @@
|
|||
|
||||
VERSION = 1147;
|
||||
SAVE_VERSION = 1440;
|
||||
VERSION_STRING = "1.14.6n2";
|
||||
VERSION_STRING = "1.14.6n3";
|
||||
BUILD_NUMBER = 114600;
|
||||
|
||||
globalvar APPEND_MAP;
|
||||
|
|
|
@ -374,6 +374,39 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
|
|||
outputs[| 0].setValue(attributes.bones);
|
||||
}
|
||||
|
||||
static getPreviewBoundingBox = function() {
|
||||
var minx = 9999999;
|
||||
var miny = 9999999;
|
||||
var maxx = -9999999;
|
||||
var maxy = -9999999;
|
||||
|
||||
var _b = attributes.bones;
|
||||
var _bst = ds_stack_create();
|
||||
ds_stack_push(_bst, _b);
|
||||
|
||||
while(!ds_stack_empty(_bst)) {
|
||||
var __b = ds_stack_pop(_bst);
|
||||
|
||||
for( var i = 0; i < array_length(__b.childs); i++ ) {
|
||||
var p0 = __b.childs[i].getPoint(0);
|
||||
var p1 = __b.childs[i].getPoint(1);
|
||||
|
||||
minx = min(minx, p0.x); miny = min(miny, p0.y);
|
||||
maxx = max(maxx, p0.x); maxy = max(maxy, p0.y);
|
||||
|
||||
minx = min(minx, p1.x); miny = min(miny, p1.y);
|
||||
maxx = max(maxx, p1.x); maxy = max(maxy, p1.y);
|
||||
|
||||
ds_stack_push(_bst, __b.childs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ds_stack_destroy(_bst);
|
||||
|
||||
if(minx == 9999999) return noone;
|
||||
return BBOX().fromPoints(minx, miny, maxx, maxy);
|
||||
}
|
||||
|
||||
static attributeSerialize = function() { return {}; }
|
||||
static attributeDeserialize = function(attr) {}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
input_fix_len = ds_list_size(inputs);
|
||||
data_length = 2;
|
||||
|
||||
attributes.layer_visible = [];
|
||||
attributes.layer_visible = [];
|
||||
attributes.layer_selectable = [];
|
||||
|
||||
attributes.display_name = true;
|
||||
|
|
|
@ -125,8 +125,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
var my = (_my - _y) / _s;
|
||||
|
||||
if(posing_bone) {
|
||||
if(posing_type == 0) { //move
|
||||
var ang = posing_bone.pose_angle;
|
||||
if(posing_type == 0 && posing_bone.parent) { //move
|
||||
var ang = posing_bone.parent.pose_angle;
|
||||
var pp = point_rotate(mx - posing_mx, my - posing_my, 0, 0, -ang);
|
||||
var bx = posing_sx + pp[0];
|
||||
var by = posing_sy + pp[1];
|
||||
|
@ -274,6 +274,39 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
outputs[| 0].setValue(_bone_pose);
|
||||
}
|
||||
|
||||
static getPreviewBoundingBox = function() {
|
||||
var minx = 9999999;
|
||||
var miny = 9999999;
|
||||
var maxx = -9999999;
|
||||
var maxy = -9999999;
|
||||
|
||||
var _b = attributes.bones;
|
||||
var _bst = ds_stack_create();
|
||||
ds_stack_push(_bst, _b);
|
||||
|
||||
while(!ds_stack_empty(_bst)) {
|
||||
var __b = ds_stack_pop(_bst);
|
||||
|
||||
for( var i = 0; i < array_length(__b.childs); i++ ) {
|
||||
var p0 = __b.childs[i].getPoint(0);
|
||||
var p1 = __b.childs[i].getPoint(1);
|
||||
|
||||
minx = min(minx, p0.x); miny = min(miny, p0.y);
|
||||
maxx = max(maxx, p0.x); maxy = max(maxy, p0.y);
|
||||
|
||||
minx = min(minx, p1.x); miny = min(miny, p1.y);
|
||||
maxx = max(maxx, p1.x); maxy = max(maxy, p1.y);
|
||||
|
||||
ds_stack_push(_bst, __b.childs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ds_stack_destroy(_bst);
|
||||
|
||||
if(minx == 9999999) return noone;
|
||||
return BBOX().fromPoints(minx, miny, maxx, maxy);
|
||||
}
|
||||
|
||||
static postDeserialize = function() {
|
||||
var _inputs = load_map.inputs;
|
||||
|
||||
|
|
|
@ -1320,6 +1320,18 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
|||
}
|
||||
}
|
||||
|
||||
static getPreviewBoundingBox = function() {
|
||||
var _node = outputs[| preview_channel];
|
||||
if(_node.type != VALUE_TYPE.surface) return noone;
|
||||
|
||||
var _surf = _node.getValue();
|
||||
if(is_array(_surf))
|
||||
_surf = array_safe_get(_surf, preview_index, noone);
|
||||
if(!is_surface(_surf)) return noone;
|
||||
|
||||
return BBOX().fromWH(preview_x, preview_y, surface_get_width(_surf), surface_get_height(_surf));
|
||||
}
|
||||
|
||||
static serialize = function(scale = false, preset = false) {
|
||||
var _map = {};
|
||||
//print(" > Serializing: " + name);
|
||||
|
|
|
@ -511,7 +511,12 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
|
|||
draw_sprite_stretched_ext(THEME.ui_panel_tab, 0, _tbx, tby, tbw, _tdh, cc, 1);
|
||||
}
|
||||
|
||||
if(HOVER == self && _hov) {
|
||||
var aa = 0.5;
|
||||
if(point_in_rectangle(msx, msy, _tbx + tbw - ui(16), tby, _tbx + tbw, tab_height)) {
|
||||
aa = 1;
|
||||
if(mouse_press(mb_left, FOCUS == self))
|
||||
rem = i;
|
||||
} else if(HOVER == self && _hov) {
|
||||
if(mouse_press(mb_left, FOCUS == self)) {
|
||||
setTab(i);
|
||||
|
||||
|
@ -537,12 +542,6 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
|
|||
setTab(i);
|
||||
}
|
||||
|
||||
var aa = 0.5;
|
||||
if(point_in_rectangle(msx, msy, _tbx + tbw - ui(16), tby, _tbx + tbw, tab_height)) {
|
||||
aa = 1;
|
||||
if(mouse_press(mb_left, FOCUS == self))
|
||||
rem = i;
|
||||
}
|
||||
draw_sprite_ui(THEME.tab_exit, 0, _tbx + tbw - ui(12), tab_height / 2 + 1,,,, foc? COLORS.panel_tab_icon : COLORS._main_text_sub, aa);
|
||||
|
||||
if(icn != noone) {
|
||||
|
|
|
@ -271,26 +271,26 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
}
|
||||
|
||||
function fullView() {
|
||||
var prevS = getNodePreviewSurface();
|
||||
if(!is_surface(prevS)) {
|
||||
var node = getNodePreview();
|
||||
if(node == noone) {
|
||||
canvas_s = 1;
|
||||
canvas_x = w / 2;
|
||||
canvas_y = (h - toolbar_height * 2) / 2;
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_w = surface_get_width(prevS);
|
||||
canvas_h = surface_get_height(prevS);
|
||||
|
||||
var ss = min((w - 32) / canvas_w, (h - 32 - toolbar_height * 2) / canvas_h);
|
||||
canvas_s = ss;
|
||||
canvas_x = w / 2 - canvas_w * canvas_s / 2;
|
||||
canvas_y = h / 2 - canvas_h * canvas_s / 2;
|
||||
|
||||
if(PANEL_GRAPH.node_focus) {
|
||||
canvas_x -= PANEL_GRAPH.node_focus.preview_x * canvas_s;
|
||||
canvas_y -= PANEL_GRAPH.node_focus.preview_y * canvas_s;
|
||||
var bbox = node.getPreviewBoundingBox();
|
||||
if(bbox == noone) {
|
||||
canvas_s = 1;
|
||||
canvas_x = w / 2;
|
||||
canvas_y = (h - toolbar_height * 2) / 2;
|
||||
return;
|
||||
}
|
||||
|
||||
var ss = min((w - 32) / bbox.w, (h - 32 - toolbar_height * 2) / bbox.h);
|
||||
canvas_s = ss;
|
||||
canvas_x = w / 2 - bbox.w * canvas_s / 2 - bbox.x0 * canvas_s;
|
||||
canvas_y = h / 2 - bbox.h * canvas_s / 2 - bbox.y0 * canvas_s;
|
||||
}
|
||||
|
||||
sbChannel = new scrollBox([], function(index) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/// @desc Function Description
|
||||
/// @param {Struct.Project} project Description
|
||||
function closeProject(project) {
|
||||
array_remove(PROJECTS, project);
|
||||
if(array_length(PROJECTS) == 0)
|
||||
|
@ -15,4 +17,6 @@ function closeProject(project) {
|
|||
|
||||
if(array_length(panels) == 0)
|
||||
setPanel();
|
||||
|
||||
project.cleanup();
|
||||
}
|
Loading…
Reference in a new issue