mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 22:46:19 +01:00
cache group
This commit is contained in:
parent
cb39f44bab
commit
6e336452c5
9 changed files with 84 additions and 32 deletions
|
@ -334,6 +334,7 @@
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_not_found_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_not_found_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache_group.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_chat.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_chat.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_checkbox_on_start.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_checkbox_on_start.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor {
|
function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor {
|
||||||
name = "Cache";
|
name = "Cache";
|
||||||
use_cache = CACHE_USE.auto;
|
use_cache = CACHE_USE.auto;
|
||||||
|
|
||||||
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) const
|
||||||
|
|
||||||
var _surf = getInputData(0);
|
var _surf = getInputData(0);
|
||||||
cacheCurrentFrame(_surf);
|
cacheCurrentFrame(_surf);
|
||||||
|
|
||||||
|
disableNodeGroup();
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||||
|
@ -55,17 +57,4 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) const
|
||||||
cache_loading_progress = 0;
|
cache_loading_progress = 0;
|
||||||
cache_loading = true;
|
cache_loading = true;
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static attributeDeserialize = function(attr) { #region
|
|
||||||
struct_override(attributes, attr);
|
|
||||||
cache_group_members = [];
|
|
||||||
|
|
||||||
if(struct_has(attributes, "cache_group")) {
|
|
||||||
for( var i = 0, n = array_length(attributes.cache_group); i < n; i++ ) {
|
|
||||||
var _node = attributes.cache_group[i];
|
|
||||||
if(ds_map_exists(PROJECT.nodeMap, _node))
|
|
||||||
array_push(cache_group_members, PROJECT.nodeMap[? _node]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} #endregion
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor {
|
function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor {
|
||||||
name = "Cache Array";
|
name = "Cache Array";
|
||||||
use_cache = CACHE_USE.manual;
|
use_cache = CACHE_USE.manual;
|
||||||
|
|
||||||
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group)
|
||||||
|
|
||||||
cache_loading = false;
|
cache_loading = false;
|
||||||
cache_content = "";
|
cache_content = "";
|
||||||
cache_loading_progress = 0;
|
cache_loading_progress = 0;
|
||||||
|
|
||||||
insp2UpdateTooltip = "Clear cache";
|
insp2UpdateTooltip = "Clear cache";
|
||||||
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
|
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
|
||||||
|
@ -63,6 +63,8 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group)
|
||||||
if(cacheExist(i)) array_push(ss, cached_output[i]);
|
if(cacheExist(i)) array_push(ss, cached_output[i]);
|
||||||
|
|
||||||
outputs[| 0].setValue(ss);
|
outputs[| 0].setValue(ss);
|
||||||
|
|
||||||
|
disableNodeGroup();
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Cache";
|
name = "Cache";
|
||||||
clearCacheOnChange = false;
|
clearCacheOnChange = false;
|
||||||
update_on_frame = true;
|
update_on_frame = true;
|
||||||
|
|
||||||
|
@ -9,13 +9,46 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
vertex_hash = "";
|
vertex_hash = "";
|
||||||
|
|
||||||
insp1UpdateTooltip = "Generate cache group";
|
insp1UpdateTooltip = "Generate cache group";
|
||||||
insp1UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
|
insp1UpdateIcon = [ THEME.cache_group, 0, COLORS._main_icon ];
|
||||||
|
|
||||||
|
if(NOT_LOAD) run_in(1, function() { onInspector1Update(); });
|
||||||
|
|
||||||
|
static removeNode = function(node) { #region
|
||||||
|
if(node.cache_group == noone) return;
|
||||||
|
|
||||||
|
array_remove(attributes.cache_group, node.node_id);
|
||||||
|
node.cache_group = noone;
|
||||||
|
refreshCacheGroup();
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
static addNode = function(node) { #region
|
||||||
|
array_push_unique(attributes.cache_group, node.node_id);
|
||||||
|
refreshCacheGroup();
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
static enableNodeGroup = function() { #region
|
||||||
|
for( var i = 0, n = array_length(cache_group_members); i < n; i++ )
|
||||||
|
cache_group_members[i].renderActive = true;
|
||||||
|
clearCache(true);
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
static disableNodeGroup = function() { #region
|
||||||
|
if(IS_PLAYING && CURRENT_FRAME == TOTAL_FRAMES - 1)
|
||||||
|
for( var i = 0, n = array_length(cache_group_members); i < n; i++ )
|
||||||
|
cache_group_members[i].renderActive = false;
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
static refreshCacheGroup = function() { #region
|
||||||
|
cache_group_members = array_create(array_length(attributes.cache_group));
|
||||||
|
for( var i = 0, n = array_length(attributes.cache_group); i < n; i++ ) {
|
||||||
|
cache_group_members[i] = PROJECT.nodeMap[? attributes.cache_group[i]];
|
||||||
|
cache_group_members[i].cache_group = self;
|
||||||
|
}
|
||||||
|
} #endregion
|
||||||
|
|
||||||
static getCacheGroup = function(node) { #region
|
static getCacheGroup = function(node) { #region
|
||||||
if(node != self) {
|
if(node != self)
|
||||||
array_push(attributes.cache_group, node.node_id);
|
array_push(attributes.cache_group, node.node_id);
|
||||||
array_push(cache_group_members, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
for( var i = 0, n = ds_list_size(node.inputs); i < n; i++ ) {
|
for( var i = 0, n = ds_list_size(node.inputs); i < n; i++ ) {
|
||||||
var _from = node.inputs[| i].value_from;
|
var _from = node.inputs[| i].value_from;
|
||||||
|
@ -32,6 +65,7 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
cache_group_members = [];
|
cache_group_members = [];
|
||||||
|
|
||||||
getCacheGroup(self);
|
getCacheGroup(self);
|
||||||
|
refreshCacheGroup();
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static ccw = function(a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); }
|
static ccw = function(a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); }
|
||||||
|
@ -149,4 +183,9 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
|
|
||||||
draw_set_alpha(1);
|
draw_set_alpha(1);
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
|
static attributeDeserialize = function(attr) { #region
|
||||||
|
struct_override(attributes, attr);
|
||||||
|
refreshCacheGroup();
|
||||||
|
} #endregion
|
||||||
}
|
}
|
|
@ -70,8 +70,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
instanceBase = noone;
|
instanceBase = noone;
|
||||||
|
|
||||||
input_display_list_def = [];
|
input_display_list_def = [];
|
||||||
custom_input_index = 0;
|
custom_input_index = 0;
|
||||||
custom_output_index = 0;
|
custom_output_index = 0;
|
||||||
|
|
||||||
metadata = new MetaDataManager();
|
metadata = new MetaDataManager();
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
attributes.w = 128;
|
attributes.w = 128;
|
||||||
attributes.h = 128;
|
attributes.h = 128;
|
||||||
|
|
||||||
|
managedRenderOrder = false;
|
||||||
|
|
||||||
input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0);
|
input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0);
|
||||||
draw_dummy = false;
|
draw_dummy = false;
|
||||||
|
|
||||||
managedRenderOrder = false;
|
|
||||||
|
|
||||||
input_dummy.onSetFrom = function(juncFrom) {
|
input_dummy.onSetFrom = function(juncFrom) {
|
||||||
ds_list_remove(juncFrom.value_to, input_dummy);
|
ds_list_remove(juncFrom.value_to, input_dummy);
|
||||||
input_dummy.value_from = noone;
|
input_dummy.value_from = noone;
|
||||||
|
|
|
@ -222,6 +222,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
||||||
is_3D = false;
|
is_3D = false;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ---- cache ----
|
||||||
|
cache_group = noone;
|
||||||
|
#endregion
|
||||||
|
|
||||||
static createNewInput = noone;
|
static createNewInput = noone;
|
||||||
|
|
||||||
static initTooltip = function() { #region
|
static initTooltip = function() { #region
|
||||||
|
@ -581,6 +585,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
||||||
error_noti_update = noti_error(getFullName() + " node require manual execution.",, self);
|
error_noti_update = noti_error(getFullName() + " node require manual execution.",, self);
|
||||||
|
|
||||||
onValueUpdate(index);
|
onValueUpdate(index);
|
||||||
|
if(cache_group) cache_group.enableNodeGroup();
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
static valueFromUpdate = function(index) { #region
|
||||||
|
onValueFromUpdate(index);
|
||||||
|
if(cache_group) cache_group.enableNodeGroup();
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static onValueUpdate = function(index = 0) {}
|
static onValueUpdate = function(index = 0) {}
|
||||||
|
|
|
@ -1840,7 +1840,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
|
|
||||||
node.valueUpdate(index, _o);
|
node.valueUpdate(index, _o);
|
||||||
if(_update && connect_type == JUNCTION_CONNECT.input) {
|
if(_update && connect_type == JUNCTION_CONNECT.input) {
|
||||||
node.onValueFromUpdate(index);
|
node.valueFromUpdate(index);
|
||||||
node.triggerRender();
|
node.triggerRender();
|
||||||
node.clearCacheForward();
|
node.clearCacheForward();
|
||||||
|
|
||||||
|
@ -1871,7 +1871,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
value_from = noone;
|
value_from = noone;
|
||||||
|
|
||||||
if(connect_type == JUNCTION_CONNECT.input)
|
if(connect_type == JUNCTION_CONNECT.input)
|
||||||
node.onValueFromUpdate(index);
|
node.valueFromUpdate(index);
|
||||||
node.clearCacheForward();
|
node.clearCacheForward();
|
||||||
|
|
||||||
PROJECT.modified = true;
|
PROJECT.modified = true;
|
||||||
|
|
|
@ -1021,6 +1021,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
||||||
|
|
||||||
node_dragging.move(nx, ny, graph_s);
|
node_dragging.move(nx, ny, graph_s);
|
||||||
|
|
||||||
|
if(key_mod_press(SHIFT) && node_dragging.cache_group != noone)
|
||||||
|
node_dragging.cache_group.removeNode(node_dragging);
|
||||||
|
|
||||||
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
|
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
|
||||||
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sx, "x", "node x position" ]);
|
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sx, "x", "node x position" ]);
|
||||||
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sy, "y", "node y position" ]);
|
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sy, "y", "node y position" ]);
|
||||||
|
@ -1058,6 +1061,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
||||||
node_drag_oy = ny;
|
node_drag_oy = ny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(key_mod_press(SHIFT)) {
|
||||||
|
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
|
||||||
|
var _node = nodes_select_list[| i];
|
||||||
|
if(_node.cache_group != noone)
|
||||||
|
_node.cache_group.removeNode(_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
|
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
|
||||||
var shfx = node_drag_sx - nx;
|
var shfx = node_drag_sx - nx;
|
||||||
var shfy = node_drag_sy - ny;
|
var shfy = node_drag_sy - ny;
|
||||||
|
@ -2069,7 +2080,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
||||||
ds_list_add(nodes_list, node);
|
ds_list_add(nodes_list, node);
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
function close() { #region
|
function close() { #region
|
||||||
var panels = findPanels("Panel_Graph");
|
var panels = findPanels("Panel_Graph");
|
||||||
for( var i = 0, n = array_length(panels); i < n; i++ ) {
|
for( var i = 0, n = array_length(panels); i < n; i++ ) {
|
||||||
if(panels[i] == self) continue;
|
if(panels[i] == self) continue;
|
||||||
|
|
Loading…
Reference in a new issue