- [Graph Panel] Fix view context not resetting when close project.

- [Inspector Panel] Fix error when displaying disconnected array value in some nodes.
- Fix error when closing project while previewing some node.
This commit is contained in:
Tanasart 2023-09-19 20:43:02 +02:00
parent fc7f9c28a9
commit d07b2ab601
9 changed files with 65 additions and 58 deletions

View file

@ -72,11 +72,17 @@
static cleanup = function() {
if(!ds_map_empty(nodeMap))
array_map(ds_map_keys_to_array(nodeMap), function(_key, _ind) { nodeMap[? _key].active = false; });
array_map(ds_map_keys_to_array(nodeMap), function(_key, _ind) {
var _node = nodeMap[? _key];
_node.active = false;
_node.cleanUp();
});
ds_list_destroy(nodes);
ds_map_destroy(nodeMap);
ds_map_destroy(nodeNameMap);
gc_collect();
}
}

View file

@ -45,70 +45,67 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _arr = is_array(_inSurf);
if(!_arr) _inSurf = [ _inSurf ];
var _amo = array_length(_inSurf);
var minx = 99999;
var miny = 99999;
var maxx = 0;
var maxy = 0;
var minx = _array? array_create(_amo) : 999999;
var miny = _array? array_create(_amo) : 999999;
var maxx = _array? array_create(_amo) : 0;
var maxy = _array? array_create(_amo) : 0;
var cDep = attrDepth();
for( var j = 0; j < array_length(_inSurf); j++ ) {
for( var j = 0; j < _amo; j++ ) {
var _surf = _inSurf[j];
var _dim = [ surface_get_width_safe(_surf), surface_get_height_safe(_surf) ];
var s = surface_create(_dim[0], _dim[1], surface_r8unorm);
surface_set_target(s);
DRAW_CLEAR
draw_surface_safe(_surf, 0, 0);
surface_reset_target();
var _dim = [ surface_get_width_safe(_surf), surface_get_height_safe(_surf) ];
var _minx = 0, _miny = 0, _maxx = _dim[0], _maxy = _dim[1];
temp_surface[0] = surface_verify(temp_surface[0], 1, 1, surface_r32float);
shader_set(sh_find_boundary);
shader_set_f("dimension", _dim);
shader_set_surface("texture", s);
for( var i = 0; i < 4; i++ ) {
shader_set_i("mode", i);
shader_set_f("bbox", [ _minx, _miny, _maxx, _maxy ]);
surface_set_target(temp_surface[0]);
shader_set(sh_find_boundary);
shader_set_f("dimension", _dim);
shader_set_surface("texture", _surf);
shader_set_i("mode", i);
shader_set_f("bbox", [ _minx, _miny, _maxx, _maxy ]);
DRAW_CLEAR
BLEND_OVERRIDE;
draw_surface_safe(s, 0, 0);
BLEND_NORMAL;
BLEND_OVERRIDE
draw_sprite(s_fx_pixel, 0, 0, 0);
BLEND_NORMAL
shader_reset();
surface_reset_target();
var px = surface_getpixel(temp_surface[0], 0, 0);
px = px[0];
switch(i) {
case 0 : _minx = surface_getpixel(temp_surface[0], 0, 0)[0]; break;
case 1 : _miny = surface_getpixel(temp_surface[0], 0, 0)[0]; break;
case 2 : _maxx = surface_getpixel(temp_surface[0], 0, 0)[0]; break;
case 3 : _maxy = surface_getpixel(temp_surface[0], 0, 0)[0]; break;
case 0 : _minx = px; break;
case 1 : _miny = px; break;
case 2 : _maxx = px; break;
case 3 : _maxy = px; break;
}
}
shader_reset();
surface_free(s);
if(_array == 0) {
minx = min(minx, _minx);
miny = min(miny, _miny);
maxx = max(maxx, _maxx);
maxy = max(maxy, _maxy);
} else if(_array == 1) {
if(_array) {
minx[j] = _minx;
miny[j] = _miny;
maxx[j] = _maxx;
maxy[j] = _maxy;
} else {
minx = min(minx, _minx);
miny = min(miny, _miny);
maxx = max(maxx, _maxx);
maxy = max(maxy, _maxy);
}
}
var res = [];
var res = [];
for( var i = 0, n = array_length(_inSurf); i < n; i++ ) {
for( var i = 0, n = _amo; i < n; i++ ) {
var _surf = _inSurf[i];
if(_array == 0) {

View file

@ -1001,9 +1001,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(!active) return;
disable();
if(PANEL_GRAPH.node_hover == self) PANEL_GRAPH.node_hover = noone;
if(PANEL_GRAPH.node_focus == self) PANEL_GRAPH.node_focus = noone;
if(PANEL_INSPECTOR.inspecting == self) PANEL_INSPECTOR.inspecting = noone;
if(PANEL_GRAPH.node_hover == self) PANEL_GRAPH.node_hover = noone;
if(PANEL_GRAPH.node_focus == self) PANEL_GRAPH.node_focus = noone;
if(PANEL_INSPECTOR.inspecting == self) PANEL_INSPECTOR.inspecting = noone;
PANEL_PREVIEW.removeNodePreview(self);
PANEL_ANIMATION.updatePropertyList();

View file

@ -1398,7 +1398,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var val = getValue(, false, 0, useCache, true);
if(isArray()) {
if(isArray(val)) {
if(array_length(val) == 0) return 0;
var v = val[safe_mod(node.preview_index, array_length(val))];
if(array_length(v) >= 100) return $"[{array_length(v)}]";

View file

@ -435,7 +435,7 @@ function Panel_Animation() : PanelContent() constructor {
var bar_w = timeline_w;
var bar_h = timeline_h;
var bar_total_w = PROJECT.animator.frames_total * ui(timeline_scale);
var inspecting = PANEL_INSPECTOR.inspecting;
var inspecting = PANEL_INSPECTOR.getInspecting();
resetTimelineMask();
timeline_surface = surface_verify(timeline_surface, timeline_w, timeline_h);
@ -1082,7 +1082,7 @@ function Panel_Animation() : PanelContent() constructor {
} else
draw_sprite_stretched_ext(THEME.ui_label_bg, 0, 0, _node_y - ui(10), lable_w, ui(20), COLORS.panel_animation_dope_bg, aa);
if(_node == PANEL_INSPECTOR.inspecting)
if(_node == PANEL_INSPECTOR.getInspecting())
draw_sprite_stretched_ext(THEME.node_active, 0, 0, _node_y - ui(10), lable_w, ui(20), COLORS._main_accent, 1);
var tx = tool_width - ui(10);

View file

@ -42,7 +42,7 @@ function Panel_Collection() : PanelContent() constructor {
var _path = filename_dir(_menu_node.path);
var _name = filename_name(_menu_node.path);
saveCollection(PANEL_INSPECTOR.inspecting, _path, _name, false, _menu_node.meta);
saveCollection(PANEL_INSPECTOR.getInspecting(), _path, _name, false, _menu_node.meta);
}),
menuItem(__txtx("panel_collection_edit_meta", "Edit metadata") + "...", function() {
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(-320));
@ -50,7 +50,7 @@ function Panel_Collection() : PanelContent() constructor {
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.inspecting;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.updating = _menu_node;
dia.doExpand();
@ -80,7 +80,7 @@ function Panel_Collection() : PanelContent() constructor {
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.inspecting;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.ugc = 1;
dia.updating = _menu_node;
@ -94,7 +94,7 @@ function Panel_Collection() : PanelContent() constructor {
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.inspecting;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.ugc = 2;
dia.updating = _menu_node;
@ -414,12 +414,12 @@ function Panel_Collection() : PanelContent() constructor {
if(context != root) {
var txt = __txtx("panel_collection_add_node", "Add selecting node as collection");
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.add, 0, COLORS._main_value_positive) == 2) {
if(PANEL_INSPECTOR.inspecting != noone) {
if(PANEL_INSPECTOR.getInspecting() != noone) {
data_path = context.path;
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(8));
if(PANEL_INSPECTOR.inspecting) {
dia.meta.name = PANEL_INSPECTOR.inspecting.display_name;
dia.node = PANEL_INSPECTOR.inspecting;
if(PANEL_INSPECTOR.getInspecting()) {
dia.meta.name = PANEL_INSPECTOR.getInspecting().display_name;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
}
}

View file

@ -132,6 +132,11 @@ function Panel_Inspector() : PanelContent() constructor {
picker_index = 0;
} #endregion
function getInspecting() { #region
if(inspecting == noone) return noone;
return inspecting.active? inspecting : noone;
} #endregion
function onFocusBegin() { PANEL_INSPECTOR = self; }
function onResize() { #region

View file

@ -912,7 +912,7 @@ function Panel_Preview() : PanelContent() constructor {
#endregion
#region outline
var inspect_node = PANEL_INSPECTOR.inspecting;
var inspect_node = PANEL_INSPECTOR.getInspecting();
if(inspect_node && inspect_node.is_3D) {
var _inspect_obj = inspect_node.getPreviewObjectOutline();
@ -1413,7 +1413,7 @@ function Panel_Preview() : PanelContent() constructor {
drawPreviewOverlay();
var inspect_node = PANEL_INSPECTOR.inspecting;
var inspect_node = PANEL_INSPECTOR.getInspecting();
var tool = noone;
if(inspect_node) {

View file

@ -9,8 +9,7 @@ attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
void main() {
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;