mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-23 11:28:06 +01:00
Inline strand
This commit is contained in:
parent
4960e55cc4
commit
ad8abab3de
35 changed files with 385 additions and 142 deletions
|
@ -1236,6 +1236,7 @@
|
|||
{"name":"s_node_rigidSim_force","order":2,"path":"sprites/s_node_rigidSim_force/s_node_rigidSim_force.yy",},
|
||||
{"name":"s_node_vec2","order":7,"path":"sprites/s_node_vec2/s_node_vec2.yy",},
|
||||
{"name":"node_twirl","order":4,"path":"scripts/node_twirl/node_twirl.yy",},
|
||||
{"name":"node_collection_inline","order":16,"path":"scripts/node_collection_inline/node_collection_inline.yy",},
|
||||
{"name":"s_node_fluidSim_update_paused","order":7,"path":"sprites/s_node_fluidSim_update_paused/s_node_fluidSim_update_paused.yy",},
|
||||
{"name":"s_node_decorner","order":17,"path":"sprites/s_node_decorner/s_node_decorner.yy",},
|
||||
{"name":"s_node_text_combine","order":3,"path":"sprites/s_node_text_combine/s_node_text_combine.yy",},
|
||||
|
@ -1461,6 +1462,7 @@
|
|||
{"name":"fd_rectangle_get_acceleration_b","order":1,"path":"scripts/fd_rectangle_get_acceleration_b/fd_rectangle_get_acceleration_b.yy",},
|
||||
{"name":"surface_draw_functions","order":7,"path":"scripts/surface_draw_functions/surface_draw_functions.yy",},
|
||||
{"name":"s_node_region_fill","order":29,"path":"sprites/s_node_region_fill/s_node_region_fill.yy",},
|
||||
{"name":"__node_controller","order":15,"path":"scripts/__node_controller/__node_controller.yy",},
|
||||
{"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",},
|
||||
{"name":"BBMOD_Matrix","order":2,"path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",},
|
||||
{"name":"pack_shelf","order":1,"path":"scripts/pack_shelf/pack_shelf.yy",},
|
||||
|
|
|
@ -1560,6 +1560,7 @@
|
|||
{"id":{"name":"fd_rectangle_set_acceleration","path":"scripts/fd_rectangle_set_acceleration/fd_rectangle_set_acceleration.yy",},},
|
||||
{"id":{"name":"s_node_vec2","path":"sprites/s_node_vec2/s_node_vec2.yy",},},
|
||||
{"id":{"name":"node_twirl","path":"scripts/node_twirl/node_twirl.yy",},},
|
||||
{"id":{"name":"node_collection_inline","path":"scripts/node_collection_inline/node_collection_inline.yy",},},
|
||||
{"id":{"name":"s_node_fluidSim_update_paused","path":"sprites/s_node_fluidSim_update_paused/s_node_fluidSim_update_paused.yy",},},
|
||||
{"id":{"name":"s_node_decorner","path":"sprites/s_node_decorner/s_node_decorner.yy",},},
|
||||
{"id":{"name":"s_node_text_combine","path":"sprites/s_node_text_combine/s_node_text_combine.yy",},},
|
||||
|
@ -1822,6 +1823,7 @@
|
|||
{"id":{"name":"fd_rectangle_get_acceleration_b","path":"scripts/fd_rectangle_get_acceleration_b/fd_rectangle_get_acceleration_b.yy",},},
|
||||
{"id":{"name":"surface_draw_functions","path":"scripts/surface_draw_functions/surface_draw_functions.yy",},},
|
||||
{"id":{"name":"s_node_region_fill","path":"sprites/s_node_region_fill/s_node_region_fill.yy",},},
|
||||
{"id":{"name":"__node_controller","path":"scripts/__node_controller/__node_controller.yy",},},
|
||||
{"id":{"name":"sh_default","path":"shaders/sh_default/sh_default.yy",},},
|
||||
{"id":{"name":"BBMOD_Matrix","path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",},},
|
||||
{"id":{"name":"pack_shelf","path":"scripts/pack_shelf/pack_shelf.yy",},},
|
||||
|
|
|
@ -25,12 +25,9 @@ event_inherited();
|
|||
anchor = ANCHOR.left | ANCHOR.top;
|
||||
node_menu_selecting = noone;
|
||||
|
||||
var _con = PANEL_GRAPH.getCurrentContext();
|
||||
var context = _con == noone? "" : instanceof(_con);
|
||||
|
||||
#region ---- category ----
|
||||
category = NODE_CATEGORY;
|
||||
switch(context) {
|
||||
switch(instanceof(context)) {
|
||||
case "Node_Pixel_Builder" : category = NODE_PB_CATEGORY; break;
|
||||
case "Node_DynaSurf" : category = NODE_PCX_CATEGORY; break;
|
||||
}
|
||||
|
@ -40,7 +37,7 @@ event_inherited();
|
|||
for(var i = 0; i < ds_list_size(category); i++) {
|
||||
var cat = category[| i];
|
||||
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, context))
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
||||
continue;
|
||||
|
||||
var name = __txt(cat.name);
|
||||
|
@ -164,6 +161,9 @@ event_inherited();
|
|||
array_pop(global.RECENT_NODES);
|
||||
}
|
||||
|
||||
if(is_instanceof(context, Node_Collection_Inline))
|
||||
context.addNode(_new_node);
|
||||
|
||||
_inputs = _new_node.inputs;
|
||||
_outputs = _new_node.outputs;
|
||||
} else if(is_instanceof(_node, NodeAction)) {
|
||||
|
@ -184,6 +184,9 @@ event_inherited();
|
|||
for( var i = 0; i < ds_list_size(_new_list); i++ ) {
|
||||
tx = min(tx, _new_list[| i].x);
|
||||
ty = min(tx, _new_list[| i].y);
|
||||
|
||||
if(is_instanceof(context, Node_Collection_Inline))
|
||||
context.addNode(_new_list[| i]);
|
||||
}
|
||||
|
||||
var shx = tx - node_target_x;
|
||||
|
@ -259,8 +262,6 @@ event_inherited();
|
|||
|
||||
var hh = 0;
|
||||
var hg = ui(28);
|
||||
var context = PANEL_GRAPH.getCurrentContext();
|
||||
context = context == noone? "" : instanceof(context);
|
||||
|
||||
var start = category == NODE_CATEGORY? -2 : 0;
|
||||
|
||||
|
@ -274,7 +275,7 @@ event_inherited();
|
|||
name = cat.name;
|
||||
|
||||
if(array_length(cat.filter)) {
|
||||
if(!array_exists(cat.filter, context)) {
|
||||
if(!array_exists(cat.filter, instanceof(context))) {
|
||||
if(ADD_NODE_PAGE == i)
|
||||
setPage(NODE_PAGE_DEFAULT);
|
||||
continue;
|
||||
|
@ -345,13 +346,10 @@ event_inherited();
|
|||
var hh = 0;
|
||||
|
||||
if(ADD_NODE_PAGE == -2) { #region
|
||||
var context = PANEL_GRAPH.getCurrentContext();
|
||||
context = context == noone? "" : instanceof(context);
|
||||
|
||||
_list = ds_list_create();
|
||||
for(var i = 0; i < ds_list_size(category); i++) {
|
||||
var cat = category[| i];
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, context))
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
||||
continue;
|
||||
|
||||
for( var j = 0; j < ds_list_size(cat.list); j++ ) {
|
||||
|
@ -375,8 +373,7 @@ event_inherited();
|
|||
));
|
||||
}
|
||||
|
||||
var _cont = PANEL_GRAPH.getCurrentContext();
|
||||
if(_cont != noone) array_append(sug, nodeReleatedQuery("context", instanceof(_cont)));
|
||||
array_append(sug, nodeReleatedQuery("context", instanceof(context)));
|
||||
|
||||
if(!array_empty(sug)) {
|
||||
ds_list_add(_list, "Related");
|
||||
|
@ -687,8 +684,6 @@ event_inherited();
|
|||
ds_list_clear(search_list);
|
||||
var pr_list = ds_priority_create();
|
||||
|
||||
var cnt = PANEL_GRAPH.getCurrentContext();
|
||||
var context = cnt == noone? "" : instanceof(cnt);
|
||||
var search_lower = string_lower(search_string);
|
||||
var search_map = ds_map_create();
|
||||
|
||||
|
@ -697,7 +692,7 @@ event_inherited();
|
|||
|
||||
if(!struct_has(cat, "list"))
|
||||
continue;
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, context))
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
||||
continue;
|
||||
|
||||
var _content = cat.list;
|
||||
|
|
3
scripts/__node_controller/__node_controller.gml
Normal file
3
scripts/__node_controller/__node_controller.gml
Normal file
|
@ -0,0 +1,3 @@
|
|||
function __Node_Controller(parent) constructor {
|
||||
|
||||
}
|
11
scripts/__node_controller/__node_controller.yy
Normal file
11
scripts/__node_controller/__node_controller.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "__node_controller",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "__base__",
|
||||
"path": "folders/nodes/data/__base__.yy",
|
||||
},
|
||||
}
|
|
@ -37,10 +37,10 @@ function StrandPoint(x, y) constructor {
|
|||
static clone = function() { return new StrandPoint(x, y); }
|
||||
}
|
||||
|
||||
function Strand(sx = 0, sy = 0, amount = 5, length = 8, direct = 0, curlFreq = 4, curlSize = 8) constructor {
|
||||
function Strand(sx = 0, sy = 0, amount = 5, _length = 8, direct = 0, curlFreq = 4, curlSize = 8) constructor {
|
||||
points = [];
|
||||
id = irandom_range(10000, 99999);
|
||||
self.length = array_create(amount, length);
|
||||
self.length = array_create(amount, _length);
|
||||
self.direct = direct;
|
||||
curl_freq = curlFreq;
|
||||
curl_size = curlSize;
|
||||
|
|
|
@ -2,7 +2,7 @@ function dialogCall(_dia, _x = noone, _y = noone, param = {}, create = false) {
|
|||
if(_x == noone) _x = WIN_SW / 2;
|
||||
if(_y == noone) _y = WIN_SH / 2;
|
||||
|
||||
var dia = !create && instance_exists(_dia)? instance_find(_dia, 0) : instance_create_depth(_x, _y, 0, _dia);
|
||||
var dia = !create && instance_exists(_dia)? instance_find(_dia, 0) : instance_create_depth(_x, _y, 0, _dia, param);
|
||||
|
||||
dia.x = _x;
|
||||
dia.y = _y;
|
||||
|
|
|
@ -162,10 +162,6 @@
|
|||
DEF_SURFACE_RESET();
|
||||
#endregion
|
||||
|
||||
#region PATCH
|
||||
#macro PATCH_STATIC static _doUpdate = function() { doUpdate() };
|
||||
#endregion
|
||||
|
||||
#region debug
|
||||
global.FLAG = {};
|
||||
#endregion
|
|
@ -22,6 +22,4 @@ function Node_VFX_Accelerate(_x, _y, _group = noone) : Node_VFX_effector(_x, _y,
|
|||
if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s));
|
||||
else part.scy += sign(part.scy) * scy_s;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -39,6 +39,4 @@ function Node_VFX_Attract(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _g
|
|||
if(_dest && point_distance(part.x, part.y, _area_x, _area_y) <= _sten)
|
||||
part.kill();
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -12,6 +12,4 @@ function Node_VFX_Destroy(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _g
|
|||
if(random(1) < str * _sten)
|
||||
part.kill();
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -33,6 +33,4 @@ function Node_VFX_Oscillate(_x, _y, _group = noone) : Node_VFX_effector(_x, _y,
|
|||
part.drawx += _dx;
|
||||
part.drawy += _dy;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -29,6 +29,4 @@ function Node_VFX_Repel(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _gro
|
|||
if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s));
|
||||
else part.scy += sign(part.scy) * scy_s;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -41,6 +41,4 @@ function Node_VFX_Turbulence(_x, _y, _group = noone) : Node_VFX_effector(_x, _y,
|
|||
if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s));
|
||||
else if(scy_s > 0) part.scy += sign(part.scy) * scy_s;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -49,6 +49,4 @@ function Node_VFX_Vortex(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _gr
|
|||
if(_dest && point_distance(pv[0], pv[1], _area_x, _area_y) <= 1)
|
||||
part.kill();
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -22,6 +22,4 @@ function Node_VFX_Wind(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _grou
|
|||
if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s));
|
||||
else part.scy += sign(part.scy) * scy_s;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -4,6 +4,24 @@ enum COLLECTION_TAG {
|
|||
}
|
||||
|
||||
function groupNodes(nodeArray, _group = noone, record = true, check_connect = true) { #region
|
||||
var _ctx_nodes = [];
|
||||
|
||||
for(var i = 0; i < array_length(nodeArray); i++) {
|
||||
var node = nodeArray[i];
|
||||
|
||||
for( var j = 0, m = array_length(node.context_data); j < m; j++ ) {
|
||||
var _cnt = node.context_data[i];
|
||||
array_push_unique(_ctx_nodes, _cnt);
|
||||
|
||||
for( var k = 0, n = array_length(_cnt.members); k < n; k++ ) {
|
||||
if(!array_exists(nodeArray, _cnt.members[k])) {
|
||||
noti_warning("Grouping incomplete inline group is not allowed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(_group == noone) {
|
||||
|
@ -27,6 +45,11 @@ function groupNodes(nodeArray, _group = noone, record = true, check_connect = tr
|
|||
_content[i] = nodeArray[i];
|
||||
}
|
||||
|
||||
for( var i = 0, n = array_length(_ctx_nodes); i < n; i++ ) {
|
||||
_group.add(_ctx_nodes[i]);
|
||||
_content[i] = _ctx_nodes[i];
|
||||
}
|
||||
|
||||
var _io = [];
|
||||
if(check_connect)
|
||||
for(var i = 0; i < array_length(nodeArray); i++)
|
||||
|
|
228
scripts/node_collection_inline/node_collection_inline.gml
Normal file
228
scripts/node_collection_inline/node_collection_inline.gml
Normal file
|
@ -0,0 +1,228 @@
|
|||
function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
attributes.members = [];
|
||||
members = [];
|
||||
group_vertex = [];
|
||||
group_dragging = false;
|
||||
group_adding = false;
|
||||
group_alpha = 0;
|
||||
vertex_hash = "";
|
||||
|
||||
group_hovering = false;
|
||||
|
||||
static removeNode = function(node) { #region
|
||||
array_remove(attributes.members, node.node_id);
|
||||
array_remove(members, node);
|
||||
|
||||
array_remove(node.context_data, self);
|
||||
} #endregion
|
||||
|
||||
static addNode = function(node) { #region
|
||||
array_push(attributes.members, node.node_id);
|
||||
array_push(members, node);
|
||||
|
||||
array_push_unique(node.context_data, self);
|
||||
} #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 getNodeBorder = function(_i, _vertex, _node) { #region
|
||||
var _rad = 4;
|
||||
var _stp = 15;
|
||||
|
||||
var _nx0 = _node.x - 32 + _rad;
|
||||
var _ny0 = _node.y - 32 + _rad;
|
||||
var _nx1 = _node.x + (_node == self? _node.w / 2 : _node.w + 32 - _rad);
|
||||
var _ny1 = _node.y + _node.h + 32 - _rad;
|
||||
|
||||
var _ind = 0;
|
||||
for( var i = 0; i <= 90; i += _stp ) _vertex[_i * 7 * 4 + _ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ];
|
||||
for( var i = 90; i <= 180; i += _stp ) _vertex[_i * 7 * 4 + _ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ];
|
||||
for( var i = 180; i <= 270; i += _stp ) _vertex[_i * 7 * 4 + _ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ];
|
||||
for( var i = 270; i <= 360; i += _stp ) _vertex[_i * 7 * 4 + _ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ];
|
||||
} #endregion
|
||||
|
||||
static refreshMember = function() { #region
|
||||
members = [];
|
||||
|
||||
for( var i = 0, n = array_length(attributes.members); i < n; i++ ) {
|
||||
if(!ds_map_exists(PROJECT.nodeMap, attributes.members[i])) {
|
||||
print($"Node not found {attributes.members[i]}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var _node = PROJECT.nodeMap[? attributes.members[i]];
|
||||
array_push(members, _node);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static refreshGroupBG = function() { #region
|
||||
var _hash = "";
|
||||
var _ind = 0;
|
||||
|
||||
for( var i = 0, n = array_length(members); i < n; i++ ) {
|
||||
var _node = members[i];
|
||||
if(!_node.active) continue;
|
||||
_hash += $"{_node.x},{_node.y},{_node.w},{_node.h}|";
|
||||
_ind++;
|
||||
}
|
||||
if(_hash == "") {
|
||||
nodeDelete(self);
|
||||
return;
|
||||
}
|
||||
_hash = md5_string_utf8(_hash);
|
||||
|
||||
if(vertex_hash == _hash) return;
|
||||
vertex_hash = _hash;
|
||||
|
||||
group_vertex = [];
|
||||
|
||||
if(_ind == 0) return;
|
||||
var _vtrx = array_create(_ind * 4 * 7);
|
||||
|
||||
var _ind = 0;
|
||||
for( var i = 0, n = array_length(members); i < n; i++ ) {
|
||||
var _node = members[i];
|
||||
if(!_node.active) continue;
|
||||
getNodeBorder(_ind, _vtrx, _node);
|
||||
_ind++;
|
||||
}
|
||||
|
||||
__temp_minP = [ x, y ];
|
||||
__temp_minI = 0;
|
||||
|
||||
for( var i = 0, n = array_length(_vtrx); i < n; i++ ) {
|
||||
var _v = _vtrx[i];
|
||||
|
||||
if(_v[1] > __temp_minP[1] || (_v[1] == __temp_minP[1] && _v[0] < __temp_minP[0])) {
|
||||
__temp_minP = _v;
|
||||
__temp_minI = i;
|
||||
}
|
||||
}
|
||||
|
||||
_vtrx = array_map( _vtrx, function(a, i) { return [ a[0], a[1], i == __temp_minI? -999 : point_direction(__temp_minP[0], __temp_minP[1], a[0], a[1]) + 360 ] });
|
||||
array_sort(_vtrx, function(a0, a1) { return a0[2] == a1[2]? sign(a0[0] - a1[0]) : sign(a0[2] - a1[2]); });
|
||||
|
||||
var _linS = 0;
|
||||
for( var i = 1, n = array_length(_vtrx); i < n; i++ ) {
|
||||
if(_vtrx[i][1] != _vtrx[0][1]) break;
|
||||
_linS = i;
|
||||
}
|
||||
|
||||
array_delete(_vtrx, 1, _linS - 1);
|
||||
|
||||
group_vertex = [ _vtrx[0], _vtrx[1] ];
|
||||
|
||||
for( var i = 2, n = array_length(_vtrx); i < n; i++ ) {
|
||||
var _v = _vtrx[i];
|
||||
|
||||
while( array_length(group_vertex) >= 2 && ccw( group_vertex[array_length(group_vertex) - 2], group_vertex[array_length(group_vertex) - 1], _v ) >= 0 )
|
||||
array_pop(group_vertex);
|
||||
array_push(group_vertex, _v);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static groupCheck = function(_x, _y, _s, _mx, _my) { #region
|
||||
if(array_length(group_vertex) < 3) return;
|
||||
var _inGroup = true;
|
||||
var _m = [ _mx / _s - _x, _my / _s - _y ];
|
||||
|
||||
group_adding = false;
|
||||
|
||||
if(PANEL_GRAPH.node_dragging && key_mod_press(SHIFT)) {
|
||||
var side = undefined;
|
||||
for( var i = 1, n = array_length(group_vertex); i < n; i++ ) {
|
||||
var a = group_vertex[i - 1];
|
||||
var b = group_vertex[i - 0];
|
||||
|
||||
var _side = sign(ccw(a, b, _m));
|
||||
if(side == undefined) side = _side;
|
||||
else if(side != _side) _inGroup = false;
|
||||
}
|
||||
|
||||
var _list = PANEL_GRAPH.nodes_selecting;
|
||||
|
||||
if(_inGroup) {
|
||||
group_adding = true;
|
||||
for( var i = 0, n = array_length(_list); i < n; i++ )
|
||||
array_push_unique(attributes.members, _list[i].node_id);
|
||||
} else {
|
||||
for( var i = 0, n = array_length(_list); i < n; i++ )
|
||||
array_remove(attributes.members, _list[i].node_id);
|
||||
}
|
||||
|
||||
if(!group_dragging) {
|
||||
for( var i = 0, n = array_length(_list); i < n; i++ )
|
||||
array_remove(attributes.members, _list[i].node_id);
|
||||
refreshMember();
|
||||
refreshGroupBG();
|
||||
}
|
||||
group_dragging = true;
|
||||
}
|
||||
|
||||
if(group_dragging && mouse_release(mb_left)) {
|
||||
refreshMember();
|
||||
refreshGroupBG();
|
||||
|
||||
group_dragging = false;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static drawNodeBG = function(_x, _y, _mx, _my, _s) { #region
|
||||
refreshGroupBG();
|
||||
if(array_length(group_vertex) < 3) return false;
|
||||
|
||||
var _hov = false;
|
||||
var _color = getColor();
|
||||
|
||||
draw_set_color(_color);
|
||||
group_alpha = lerp_float(group_alpha, group_adding, 4);
|
||||
draw_set_alpha(0.025 + 0.025 * group_alpha + 0.025 * group_hovering);
|
||||
draw_primitive_begin(pr_trianglelist);
|
||||
var a = group_vertex[0];
|
||||
var b = group_vertex[1];
|
||||
var c;
|
||||
|
||||
for( var i = 2, n = array_length(group_vertex); i < n; i++ ) {
|
||||
c = group_vertex[i];
|
||||
|
||||
var v0x = _x + a[0] * _s;
|
||||
var v0y = _y + a[1] * _s;
|
||||
var v1x = _x + b[0] * _s;
|
||||
var v1y = _y + b[1] * _s;
|
||||
var v2x = _x + c[0] * _s;
|
||||
var v2y = _y + c[1] * _s;
|
||||
|
||||
draw_vertex(v0x, v0y);
|
||||
draw_vertex(v1x, v1y);
|
||||
draw_vertex(v2x, v2y);
|
||||
|
||||
if(!_hov && point_in_triangle(_mx, _my, v0x, v0y, v1x, v1y, v2x, v2y))
|
||||
_hov = true;
|
||||
|
||||
b = group_vertex[i];
|
||||
}
|
||||
draw_primitive_end();
|
||||
|
||||
draw_set_alpha(0.3);
|
||||
draw_primitive_begin(pr_linestrip);
|
||||
for( var i = 0, n = array_length(group_vertex); i < n; i++ ) {
|
||||
var a = group_vertex[i];
|
||||
draw_vertex(_x + a[0] * _s, _y + a[1] * _s);
|
||||
}
|
||||
|
||||
a = group_vertex[0];
|
||||
draw_vertex(_x + a[0] * _s, _y + a[1] * _s);
|
||||
draw_primitive_end();
|
||||
|
||||
draw_set_alpha(1);
|
||||
|
||||
group_hovering = _hov;
|
||||
return _hov;
|
||||
} #endregion
|
||||
|
||||
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) {}
|
||||
|
||||
static postDeserialize = function() { #region
|
||||
refreshMember();
|
||||
} #endregion
|
||||
}
|
11
scripts/node_collection_inline/node_collection_inline.yy
Normal file
11
scripts/node_collection_inline/node_collection_inline.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_collection_inline",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "__base__",
|
||||
"path": "folders/nodes/data/__base__.yy",
|
||||
},
|
||||
}
|
|
@ -41,6 +41,4 @@ function Node_Color_Data(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
|||
|
||||
return _n? val / 255 : val;
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -19,7 +19,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
|||
renderActive = true;
|
||||
|
||||
node_id = UUID_generate();
|
||||
|
||||
group = _group;
|
||||
manual_deletable = true;
|
||||
destroy_when_upgroup = false;
|
||||
|
@ -29,6 +28,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
|||
active_range = [ 0, TOTAL_FRAMES - 1 ];
|
||||
|
||||
array_push(PROJECT.nodeArray, self);
|
||||
|
||||
context_data = [];
|
||||
#endregion
|
||||
|
||||
static resetInternalName = function() { #region
|
||||
|
|
|
@ -23,6 +23,4 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y,
|
|||
}
|
||||
|
||||
outputs[| 1] = nodeValue("Feedback loop", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, 0).nonForward();
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -116,6 +116,4 @@ function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro
|
|||
if(outputNode == noone) return false;
|
||||
return outputNode.cacheExist(frame);
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -2,6 +2,4 @@ function Node_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) co
|
|||
name = "Group";
|
||||
color = COLORS.node_blend_collection;
|
||||
icon = THEME.group_s;
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -366,8 +366,6 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
}
|
||||
} #endregion
|
||||
|
||||
PATCH_STATIC
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) { #region
|
||||
if(is_undefined(inParent)) return;
|
||||
} #endregion
|
||||
|
|
|
@ -158,6 +158,4 @@ function Node_Iterate_Sort(_x, _y, _group = noone) : Node_Collection(_x, _y, _gr
|
|||
quickSort(arrOut, 0, array_length(arrOut) - 1);
|
||||
outputs[| 0].setValue(arrOut);
|
||||
} #endregion
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -35,6 +35,4 @@ function Node_Iterator_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y,
|
|||
|
||||
outputs[| 1] = nodeValue("Loop entrance", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, 0)
|
||||
.nonForward();
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -31,6 +31,4 @@ function Node_Rigid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro
|
|||
if(CURRENT_FRAME == 0)
|
||||
reset();
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -70,6 +70,7 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
groomed = new StrandMesh();
|
||||
strands = new StrandMesh();
|
||||
|
||||
#region ---- tools ----
|
||||
tool_push = new NodeTool( "Push", THEME.strand_push )
|
||||
.addSetting("Radius", VALUE_TYPE.float, function(val) { tool_push.attribute.radius = val; }, "radius", 6)
|
||||
.addSetting("Strength", VALUE_TYPE.float, function(val) { tool_push.attribute.strength = val; }, "strength", 0.2)
|
||||
|
@ -114,8 +115,9 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
tool_dir_to = 0;
|
||||
|
||||
tool_grabbing = [];
|
||||
#endregion
|
||||
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
var _typ = getInputData(0);
|
||||
var _pre = getInputData(16);
|
||||
if(!attributes.use_groom)
|
||||
|
@ -418,9 +420,9 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
tool_dmx = __mx;
|
||||
tool_dmy = __my;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static step = function() {
|
||||
static step = function() { #region
|
||||
var _typ = getInputData(0);
|
||||
|
||||
inputs[| 5].setVisible(_typ == 1, _typ == 1);
|
||||
|
@ -430,9 +432,9 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
inputs[| 15].editWidget.text = attributes.use_groom? "Unbake" : "Bake";
|
||||
inputs[| 15].editWidget.blend = attributes.use_groom? COLORS._main_value_negative : COLORS._main_value_positive;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static strandUpdate = function(willReset = false) {
|
||||
static strandUpdate = function(willReset = false) { #region
|
||||
var _typ = getInputData(0);
|
||||
var _den = getInputData(1);
|
||||
var _len = getInputData(2);
|
||||
|
@ -531,28 +533,28 @@ function Node_Strand_Create(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
ind++;
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
static update = function(frame = CURRENT_FRAME) { #region
|
||||
strandUpdate(CURRENT_FRAME == 0);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
draw_sprite_fit(s_node_strandSim_create, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static attributeSerialize = function() {
|
||||
static attributeSerialize = function() { #region
|
||||
var att = {};
|
||||
att.use_groom = attributes.use_groom;
|
||||
att.fixStrand = groomed.serialize();
|
||||
return att;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static attributeDeserialize = function(attr) {
|
||||
static attributeDeserialize = function(attr) { #region
|
||||
if(struct_has(attr, "fixStrand"))
|
||||
groomed.deserialize(attr.fixStrand);
|
||||
|
||||
attributes.use_groom = struct_try_get(attr, "use_groom", false);
|
||||
}
|
||||
} #endregion
|
||||
}
|
|
@ -23,9 +23,11 @@ function Node_Strand_Render(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
inputs[| 7] = nodeValue("Child", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0, "Render extra strands between the real strands.");
|
||||
|
||||
inputs[| 8] = nodeValue("Update quality", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4);
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [ 6,
|
||||
input_display_list = [ 6, 8,
|
||||
["Output", false], 0,
|
||||
["Strand", false], 7, 1, 2, 3,
|
||||
["Color", false], 4, 5,
|
||||
|
@ -36,14 +38,14 @@ function Node_Strand_Render(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
static onInspector2Update = function() { clearCache(); }
|
||||
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
var _str = getInputData(1);
|
||||
if(_str == noone) return;
|
||||
if(!is_array(_str)) _str = [ _str ];
|
||||
|
||||
for( var i = 0, n = array_length(_str); i < n; i++ )
|
||||
_str[i].draw(_x, _y, _s);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
if(!PROJECT.animator.is_playing && recoverCache()) return;
|
||||
|
@ -56,6 +58,7 @@ function Node_Strand_Render(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
var _col = getInputData(5);
|
||||
var _sed = getInputData(6);
|
||||
var _chd = getInputData(7);
|
||||
var _stp = getInputData(8);
|
||||
|
||||
var _surf = outputs[| 0].getValue();
|
||||
_surf = surface_verify(_surf, _dim[0], _dim[1]);
|
||||
|
@ -75,6 +78,8 @@ function Node_Strand_Render(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
var _strand = _str[h];
|
||||
var hairs = _strand.hairs;
|
||||
|
||||
if(_stp) _strand.step(_stp);
|
||||
|
||||
for( var i = 0, n = array_length(hairs); i < n; i++ ) {
|
||||
var hair = hairs[i];
|
||||
var os, ns, ot, nt;
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
function Node_Strand_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor {
|
||||
function Node_Strand_Group(_x, _y, _group = noone) : Node_Collection_Inline(_x, _y, _group) constructor {
|
||||
name = "StrandSim";
|
||||
color = COLORS.node_blend_strand;
|
||||
icon = THEME.strandSim;
|
||||
|
||||
ungroupable = false;
|
||||
update_on_frame = true;
|
||||
|
||||
if(!LOADING && !APPENDING && !CLONING) {
|
||||
var _create = nodeBuild("Node_Strand_Create", -384, -32, self);
|
||||
var _update = nodeBuild("Node_Strand_Update", 0, -32, self);
|
||||
var _render = nodeBuild("Node_Strand_Render", 128, -32, self);
|
||||
var _output = nodeBuild("Node_Group_Output", 384, -32, self);
|
||||
var _create = nodeBuild("Node_Strand_Create", x, y);
|
||||
var _render = nodeBuild("Node_Strand_Render", x + 256, y);
|
||||
|
||||
_output.inputs[| 0].setFrom(_render.outputs[| 0]);
|
||||
_render.inputs[| 1].setFrom(_update.outputs[| 0]);
|
||||
_update.inputs[| 0].setFrom(_create.outputs[| 0]);
|
||||
_render.inputs[| 1].setFrom(_create.outputs[| 0]);
|
||||
|
||||
addNode(_create);
|
||||
addNode(_render);
|
||||
}
|
||||
|
||||
static onStep = function() {
|
||||
RETURN_ON_REST
|
||||
|
||||
setRenderStatus(false);
|
||||
RENDER_ALL
|
||||
}
|
||||
|
||||
PATCH_STATIC
|
||||
}
|
|
@ -104,6 +104,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
value_focus = noone;
|
||||
value_dragging = noone;
|
||||
value_draggings = [];
|
||||
|
||||
frame_hovering = noone;
|
||||
#endregion
|
||||
|
||||
#region ---- minimap ----
|
||||
|
@ -729,7 +731,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
var t = get_timer();
|
||||
printIf(log, "============ Draw start ============");
|
||||
|
||||
var frame_hovering = noone;
|
||||
frame_hovering = noone;
|
||||
|
||||
for(var i = 0; i < ds_list_size(nodes_list); i++) {
|
||||
nodes_list[| i].cullCheck(gr_x, gr_y, graph_s, -32, -32, w + 32, h + 64);
|
||||
|
@ -870,7 +872,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(array_length(nodes_selecting)));
|
||||
array_push(menu, menuItem(__txt("Paste"), function() { doPaste(); }, THEME.paste, ["Graph", "Paste"]).setActive(clipboard_get_text() != ""));
|
||||
|
||||
callAddDialog();
|
||||
var ctx = is_instanceof(frame_hovering, Node_Collection_Inline)? frame_hovering : getCurrentContext();
|
||||
callAddDialog(ctx);
|
||||
|
||||
menuCall("graph_node_selected_menu", o_dialog_add_node.dialog_x - ui(8), o_dialog_add_node.dialog_y + ui(4), menu, fa_right );
|
||||
setFocus(o_dialog_add_node.id, "Dialog");
|
||||
}
|
||||
|
@ -1187,7 +1191,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
value_dragging.node.triggerRender();
|
||||
|
||||
if(value_focus != value_dragging) {
|
||||
with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8)) {
|
||||
var ctx = is_instanceof(frame_hovering, Node_Collection_Inline)? frame_hovering : getCurrentContext();
|
||||
with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx })) {
|
||||
node_target_x = other.mouse_grid_x;
|
||||
node_target_y = other.mouse_grid_y;
|
||||
node_called = other.value_dragging;
|
||||
|
@ -1261,8 +1266,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
#endregion
|
||||
} #endregion
|
||||
|
||||
function callAddDialog() { #region
|
||||
with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8)) {
|
||||
function callAddDialog(ctx = getCurrentContext()) { #region
|
||||
|
||||
with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx })) {
|
||||
node_target_x = other.mouse_grid_x;
|
||||
node_target_y = other.mouse_grid_y;
|
||||
junction_hovering = other.junction_hovering;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
animator = new AnimationManager();
|
||||
globalNode = new Node_Global();
|
||||
nodeController = new __Node_Controller(self);
|
||||
|
||||
previewGrid = { #region
|
||||
show : false,
|
||||
|
|
Loading…
Reference in a new issue