RigidSim fixes

This commit is contained in:
MakhamDev 2023-10-07 14:09:18 +07:00
parent 147329f3d4
commit fde7c7c3b1
41 changed files with 844 additions and 409 deletions

View file

@ -176,22 +176,21 @@
{"name":"sprites","order":3,"path":"folders/panels/preview/sprites.yy",}, {"name":"sprites","order":3,"path":"folders/panels/preview/sprites.yy",},
{"name":"what?","order":10,"path":"folders/panels/what?.yy",}, {"name":"what?","order":10,"path":"folders/panels/what?.yy",},
{"name":"shader","order":8,"path":"folders/shader.yy",}, {"name":"shader","order":8,"path":"folders/shader.yy",},
{"name":"_helper","order":49,"path":"folders/shader/_helper.yy",}, {"name":"_helper","order":12,"path":"folders/shader/_helper.yy",},
{"name":"3d","order":29,"path":"folders/shader/3d.yy",}, {"name":"3d","order":3,"path":"folders/shader/3d.yy",},
{"name":"2d effect","order":14,"path":"folders/shader/3d/2d effect.yy",}, {"name":"2d effect","order":14,"path":"folders/shader/3d/2d effect.yy",},
{"name":"legacy","order":13,"path":"folders/shader/3d/legacy.yy",}, {"name":"legacy","order":13,"path":"folders/shader/3d/legacy.yy",},
{"name":"ssao","order":24,"path":"folders/shader/3d/ssao.yy",}, {"name":"ssao","order":24,"path":"folders/shader/3d/ssao.yy",},
{"name":"blend","order":18,"path":"folders/shader/blend.yy",}, {"name":"blur","order":6,"path":"folders/shader/blur.yy",},
{"name":"blur","order":38,"path":"folders/shader/blur.yy",}, {"name":"channels","order":9,"path":"folders/shader/channels.yy",},
{"name":"channels","order":42,"path":"folders/shader/channels.yy",}, {"name":"color picker","order":19,"path":"folders/shader/color picker.yy",},
{"name":"color picker","order":56,"path":"folders/shader/color picker.yy",}, {"name":"color selector","order":14,"path":"folders/shader/color selector.yy",},
{"name":"color selector","order":51,"path":"folders/shader/color selector.yy",}, {"name":"draw","order":7,"path":"folders/shader/draw.yy",},
{"name":"draw","order":39,"path":"folders/shader/draw.yy",}, {"name":"filter","order":4,"path":"folders/shader/filter.yy",},
{"name":"filter","order":30,"path":"folders/shader/filter.yy",},
{"name":"color","order":53,"path":"folders/shader/filter/color.yy",}, {"name":"color","order":53,"path":"folders/shader/filter/color.yy",},
{"name":"shadow caster","order":46,"path":"folders/shader/filter/shadow caster.yy",}, {"name":"shadow caster","order":46,"path":"folders/shader/filter/shadow caster.yy",},
{"name":"flood fill","order":47,"path":"folders/shader/flood fill.yy",}, {"name":"flood fill","order":11,"path":"folders/shader/flood fill.yy",},
{"name":"generator","order":19,"path":"folders/shader/generator.yy",}, {"name":"generator","order":1,"path":"folders/shader/generator.yy",},
{"name":"blinker","order":30,"path":"folders/shader/generator/blinker.yy",}, {"name":"blinker","order":30,"path":"folders/shader/generator/blinker.yy",},
{"name":"cell","order":31,"path":"folders/shader/generator/cell.yy",}, {"name":"cell","order":31,"path":"folders/shader/generator/cell.yy",},
{"name":"grid","order":32,"path":"folders/shader/generator/grid.yy",}, {"name":"grid","order":32,"path":"folders/shader/generator/grid.yy",},
@ -199,15 +198,15 @@
{"name":"noise","order":33,"path":"folders/shader/generator/noise.yy",}, {"name":"noise","order":33,"path":"folders/shader/generator/noise.yy",},
{"name":"random shape","order":29,"path":"folders/shader/generator/random shape.yy",}, {"name":"random shape","order":29,"path":"folders/shader/generator/random shape.yy",},
{"name":"region","order":34,"path":"folders/shader/generator/region.yy",}, {"name":"region","order":34,"path":"folders/shader/generator/region.yy",},
{"name":"mask","order":45,"path":"folders/shader/mask.yy",}, {"name":"mask","order":10,"path":"folders/shader/mask.yy",},
{"name":"misc","order":50,"path":"folders/shader/misc.yy",}, {"name":"misc","order":13,"path":"folders/shader/misc.yy",},
{"name":"morph","order":54,"path":"folders/shader/morph.yy",}, {"name":"morph","order":17,"path":"folders/shader/morph.yy",},
{"name":"pixel builder","order":55,"path":"folders/shader/pixel builder.yy",}, {"name":"pixel builder","order":18,"path":"folders/shader/pixel builder.yy",},
{"name":"shape seperator","order":35,"path":"folders/shader/shape seperator.yy",}, {"name":"shape seperator","order":5,"path":"folders/shader/shape seperator.yy",},
{"name":"sprites","order":20,"path":"folders/shader/sprites.yy",}, {"name":"sprites","order":2,"path":"folders/shader/sprites.yy",},
{"name":"surface replace","order":53,"path":"folders/shader/surface replace.yy",}, {"name":"surface replace","order":16,"path":"folders/shader/surface replace.yy",},
{"name":"transition","order":52,"path":"folders/shader/transition.yy",}, {"name":"transition","order":15,"path":"folders/shader/transition.yy",},
{"name":"warp","order":41,"path":"folders/shader/warp.yy",}, {"name":"warp","order":8,"path":"folders/shader/warp.yy",},
{"name":"sprites","order":11,"path":"folders/sprites.yy",}, {"name":"sprites","order":11,"path":"folders/sprites.yy",},
{"name":"bs","order":4,"path":"folders/sprites/bs.yy",}, {"name":"bs","order":4,"path":"folders/sprites/bs.yy",},
{"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",}, {"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",},
@ -216,6 +215,7 @@
{"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",}, {"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",},
{"name":"widget","order":3,"path":"folders/VCT/widget.yy",}, {"name":"widget","order":3,"path":"folders/VCT/widget.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",}, {"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"fluid","order":20,"path":"folders/shader/fluid.yy",},
], ],
"ResourceOrderSettings": [ "ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",}, {"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},

View file

@ -249,6 +249,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"fluid","folderPath":"folders/shader/fluid.yy",},
], ],
"IncludedFiles": [ "IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -308,6 +309,8 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_function.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_function.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_node.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_node.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_action_history.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_action_history.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_20.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_32.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_32.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_addon_setting.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_addon_setting.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -395,6 +398,8 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loading.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loading.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_lock.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_lock.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loop_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loop_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_20.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_name.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_name.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_new_line_shift.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_new_line_shift.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -1422,6 +1427,7 @@
{"id":{"name":"fd_rectangle_set_material_size","path":"scripts/fd_rectangle_set_material_size/fd_rectangle_set_material_size.yy",},}, {"id":{"name":"fd_rectangle_set_material_size","path":"scripts/fd_rectangle_set_material_size/fd_rectangle_set_material_size.yy",},},
{"id":{"name":"fd_rectangle_shift_content","path":"scripts/fd_rectangle_shift_content/fd_rectangle_shift_content.yy",},}, {"id":{"name":"fd_rectangle_shift_content","path":"scripts/fd_rectangle_shift_content/fd_rectangle_shift_content.yy",},},
{"id":{"name":"sh_texture_remap","path":"shaders/sh_texture_remap/sh_texture_remap.yy",},}, {"id":{"name":"sh_texture_remap","path":"shaders/sh_texture_remap/sh_texture_remap.yy",},},
{"id":{"name":"sh_fluid_bleach","path":"shaders/sh_fluid_bleach/sh_fluid_bleach.yy",},},
{"id":{"name":"__node_3d_mesh_modifier","path":"scripts/__node_3d_mesh_modifier/__node_3d_mesh_modifier.yy",},}, {"id":{"name":"__node_3d_mesh_modifier","path":"scripts/__node_3d_mesh_modifier/__node_3d_mesh_modifier.yy",},},
{"id":{"name":"obj_fd_rectangle","path":"objects/obj_fd_rectangle/obj_fd_rectangle.yy",},}, {"id":{"name":"obj_fd_rectangle","path":"objects/obj_fd_rectangle/obj_fd_rectangle.yy",},},
{"id":{"name":"node_noise_simplex","path":"scripts/node_noise_simplex/node_noise_simplex.yy",},}, {"id":{"name":"node_noise_simplex","path":"scripts/node_noise_simplex/node_noise_simplex.yy",},},

Binary file not shown.

View file

@ -79,19 +79,28 @@ if(!ready) exit;
var _spr = noone, _ind = 0; var _spr = noone, _ind = 0;
var _sprs = _submenu[0]; var _sprs = _submenu[0];
var _tlp = array_safe_get(_submenu, 2, ""); var _tlp = array_safe_get(_submenu, 2, "");
var _str = "";
if(is_array(_sprs)) { var _sw = ui(28);
_spr = _sprs[0]; var _sh = ui(28);
_ind = _sprs[1];
if(is_string(_sprs)) {
_str = _sprs;
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text);
_sw = string_width(_str) + ui(12);
_sh = string_height(_str) + ui(8);
} else { } else {
_spr = _sprs; if(is_array(_sprs)) {
_ind = 0; _spr = _sprs[0];
_ind = _sprs[1];
} else _spr = _sprs;
} }
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _bx - ui(14), _by - ui(14), _bx + ui(14), _by + ui(14))) { if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _bx - _sw / 2, _by - _sh / 2, _bx + _sw / 2, _by + _sh / 2)) {
if(_tlp != "") TOOLTIP = _tlp; if(_tlp != "") TOOLTIP = _tlp;
draw_sprite_stretched_ext(THEME.textbox, 3, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1); draw_sprite_stretched_ext(THEME.textbox, 3, _bx - _sw / 2, _by - _sh / 2, _sw, _sh, COLORS.dialog_menubox_highlight, 1);
draw_sprite_stretched_ext(THEME.textbox, 1, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1); draw_sprite_stretched_ext(THEME.textbox, 1, _bx - _sw / 2, _by - _sh / 2, _sw, _sh, COLORS.dialog_menubox_highlight, 1);
if(mouse_press(mb_left, sFOCUS)) { if(mouse_press(mb_left, sFOCUS)) {
_submenu[1](); _submenu[1]();
@ -99,7 +108,11 @@ if(!ready) exit;
} }
} }
draw_sprite_ui_uniform(_spr, _ind, _bx, _by); if(_spr != noone)
draw_sprite_ui_uniform(_spr, _ind, _bx, _by);
if(_str != "")
draw_text(_bx, _by, _str);
} }
} else { } else {
var tx = dialog_x + show_icon * ui(32) + ui(16); var tx = dialog_x + show_icon * ui(32) + ui(16);

View file

@ -32,6 +32,7 @@ function SurfaceAtlas(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend =
static setSurface = function(surface) { static setSurface = function(surface) {
gml_pragma("forceinline"); gml_pragma("forceinline");
self.surface.set(surface); self.surface.set(surface);
w = surface_get_width_safe(surface); w = surface_get_width_safe(surface);

View file

@ -67,6 +67,7 @@
function menuItemGroup(name, group) { function menuItemGroup(name, group) {
return new MenuItemGroup(name, group); return new MenuItemGroup(name, group);
} }
function MenuItemGroup(name, group) constructor { function MenuItemGroup(name, group) constructor {
active = true; active = true;
self.name = name; self.name = name;

View file

@ -4,15 +4,34 @@ function curveBox(_onModify) : widget() constructor {
curve_surface = surface_create(1, 1); curve_surface = surface_create(1, 1);
node_dragging = -1; node_dragging = -1;
node_drag_typ = -1; node_drag_typ = -1;
zoom_level = 1;
zoom_level_to = 1;
zoom_min = 1;
zoom_max = 3;
zooming = false;
miny = 0; miny = 0;
maxy = 1; maxy = 1;
progress_draw = -1;
display_pos_x = 0;
display_pos_y = 0;
display_sel = false;
grid_snap = false;
grid_step = 0.05;
grid_show = false;
static get_x = function(val, _x, _w) { return _x + _w * val; } static get_x = function(val, _x, _w) { return _x + _w * val; }
static get_y = function(val, _y, _h) { return _y + _h * (1 - (val - miny) / (maxy - miny)); } static get_y = function(val, _y, _h) { return _y + _h * (1 - (val - miny) / (maxy - miny)); }
static register = function() {} static register = function() {}
static drawParam = function(params) { static drawParam = function(params) {
rx = params.rx;
ry = params.ry;
return draw(params.x, params.y, params.w, params.h, params.data, params.m); return draw(params.x, params.y, params.w, params.h, params.data, params.m);
} }
@ -22,19 +41,33 @@ function curveBox(_onModify) : widget() constructor {
w = _w; w = _w;
h = _h; h = _h;
var cw = _w - ui(32);
if(!is_array(_data) || array_length(_data) == 0) return 0; if(!is_array(_data) || array_length(_data) == 0) return 0;
if(is_array(_data[0])) return 0; if(is_array(_data[0])) return 0;
var points = array_length(_data) / 6; var points = array_length(_data) / 6;
curve_surface = surface_verify(curve_surface, _w, _h); #region display
zoom_level = lerp_float(zoom_level, zoom_level_to, 2);
miny = 0.5 - 0.5 * zoom_level;
maxy = 0.5 + 0.5 * zoom_level;
display_pos_x = clamp((_m[0] - _x) / cw, 0, 1);
display_pos_y = lerp(miny, maxy, 1 - (_m[1] - _y) / _h);
display_sel = false;
#endregion
curve_surface = surface_verify(curve_surface, cw, _h);
if(node_dragging != -1) { #region editing if(node_dragging != -1) { #region editing
if(node_drag_typ == 0) { if(node_drag_typ == 0) {
var node_point = (node_dragging - 2) / 6; var node_point = (node_dragging - 2) / 6;
if(node_point > 0 && node_point < points - 1) { if(node_point > 0 && node_point < points - 1) {
var _mx = (_m[0] - _x) / _w; var _mx = (_m[0] - _x) / cw;
_mx = clamp(_mx, 0, 1); _mx = clamp(_mx, 0, 1);
if(key_mod_press(CTRL) || grid_snap)
_mx = value_snap(_mx, grid_step);
var bfx = _data[node_dragging - 6]; var bfx = _data[node_dragging - 6];
var afx = _data[node_dragging + 6]; var afx = _data[node_dragging + 6];
@ -46,8 +79,13 @@ function curveBox(_onModify) : widget() constructor {
var _my = 1 - (_m[1] - _y) / _h; var _my = 1 - (_m[1] - _y) / _h;
_my = clamp(_my * (maxy - miny) + miny, 0, 1); _my = clamp(_my * (maxy - miny) + miny, 0, 1);
if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step);
_data[node_dragging + 1] = _my; _data[node_dragging + 1] = _my;
display_pos_x = _data[node_dragging + 0];
display_pos_y = _data[node_dragging + 1];
display_sel = 1;
//sort by x //sort by x
var _xindex = []; var _xindex = [];
var _pindex = []; var _pindex = [];
@ -81,16 +119,22 @@ function curveBox(_onModify) : widget() constructor {
var _px = _data[node_dragging + 0]; var _px = _data[node_dragging + 0];
var _py = _data[node_dragging + 1]; var _py = _data[node_dragging + 1];
var _mx = (_m[0] - _x) / _w; var _mx = (_m[0] - _x) / cw;
_mx = clamp(_mx, 0, 1); _mx = clamp(_mx, 0, 1);
if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step);
_data[node_dragging - 2] = (_px - _mx) * node_drag_typ; _data[node_dragging - 2] = (_px - _mx) * node_drag_typ;
_data[node_dragging + 2] = (_mx - _px) * node_drag_typ; _data[node_dragging + 2] = (_mx - _px) * node_drag_typ;
var _my = 1 - (_m[1] - _y) / _h; var _my = 1 - (_m[1] - _y) / _h;
_my = _my * (maxy - miny) + miny; _my = lerp(miny, maxy, _my);
if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step);
_data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ; _data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ;
_data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ; _data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ;
display_pos_x = node_drag_typ? _data[node_dragging - 2] : _data[node_dragging + 2];
display_pos_y = node_drag_typ? _data[node_dragging - 1] : _data[node_dragging + 3];
display_sel = 2;
if(onModify(_data)) if(onModify(_data))
UNDO_HOLDING = true; UNDO_HOLDING = true;
} }
@ -116,12 +160,34 @@ function curveBox(_onModify) : widget() constructor {
DRAW_CLEAR DRAW_CLEAR
draw_set_color(COLORS.widget_curve_line); draw_set_color(COLORS.widget_curve_line);
draw_set_alpha(0.75); draw_set_alpha(0.75);
if(grid_show) {
var st = max(grid_step, 0.02);
for( var i = st; i < 1; i += st ) {
var y0 = _h - _h * (i - miny) / (maxy - miny);
draw_line(0, y0, cw, y0);
var x0 = cw * i;
draw_line(x0, 0, x0, _h);
}
}
draw_set_alpha(0.9);
var y0 = _h - _h * (0 - miny) / (maxy - miny); var y0 = _h - _h * (0 - miny) / (maxy - miny);
draw_line(0, y0, _w, y0); draw_line(0, y0, cw, y0);
var y1 = _h - _h * (1 - miny) / (maxy - miny); var y1 = _h - _h * (1 - miny) / (maxy - miny);
draw_line(0, y1, _w, y1); draw_line(0, y1, cw, y1);
draw_set_alpha(1); draw_set_alpha(1);
if(progress_draw > -1) {
var _prg = clamp(progress_draw, 0, 1);
var _px = cw * _prg;
draw_set_color(COLORS.widget_curve_line);
draw_line(_px, 0, _px, _h);
}
for( var i = 0; i < points; i++ ) { for( var i = 0; i < points; i++ ) {
var ind = i * 6; var ind = i * 6;
var _x0 = _data[ind + 2]; var _x0 = _data[ind + 2];
@ -131,11 +197,11 @@ function curveBox(_onModify) : widget() constructor {
var ax0 = _x0 + _data[ind + 4]; var ax0 = _x0 + _data[ind + 4];
var ay0 = _y0 + _data[ind + 5]; var ay0 = _y0 + _data[ind + 5];
bx0 = get_x(bx0, 0, _w); bx0 = get_x(bx0, 0, cw);
by0 = get_y(by0, 0, _h); by0 = get_y(by0, 0, _h);
_x0 = get_x(_x0, 0, _w); _x0 = get_x(_x0, 0, cw);
_y0 = get_y(_y0, 0, _h); _y0 = get_y(_y0, 0, _h);
ax0 = get_x(ax0, 0, _w); ax0 = get_x(ax0, 0, cw);
ay0 = get_y(ay0, 0, _h); ay0 = get_y(ay0, 0, _h);
draw_set_color(COLORS.widget_curve_line); draw_set_color(COLORS.widget_curve_line);
@ -147,6 +213,10 @@ function curveBox(_onModify) : widget() constructor {
draw_circle_prec(bx0, by0, 5, false); draw_circle_prec(bx0, by0, 5, false);
node_hovering = ind + 2; node_hovering = ind + 2;
node_hover_typ = -1; node_hover_typ = -1;
display_pos_x = _data[ind + 0];
display_pos_y = _data[ind + 1];
display_sel = 2;
} }
} }
@ -158,6 +228,10 @@ function curveBox(_onModify) : widget() constructor {
draw_circle_prec(ax0, ay0, 5, false); draw_circle_prec(ax0, ay0, 5, false);
node_hovering = ind + 2; node_hovering = ind + 2;
node_hover_typ = 1; node_hover_typ = 1;
display_pos_x = _data[ind + 4];
display_pos_y = _data[ind + 5];
display_sel = 2;
} }
} }
@ -167,6 +241,10 @@ function curveBox(_onModify) : widget() constructor {
draw_circle_prec(_x0, _y0, 5, false); draw_circle_prec(_x0, _y0, 5, false);
node_hovering = ind + 2; node_hovering = ind + 2;
node_hover_typ = 0; node_hover_typ = 0;
display_pos_x = _data[ind + 2];
display_pos_y = _data[ind + 3];
display_sel = 1;
} }
if(msx >= _x1 && msy <= _x0) if(msx >= _x1 && msy <= _x0)
@ -175,65 +253,109 @@ function curveBox(_onModify) : widget() constructor {
} }
draw_set_color(COLORS._main_accent); draw_set_color(COLORS._main_accent);
draw_curve(0, 0, _w, -_h, _data, miny, maxy); draw_curve(0, 0, cw, -_h, _data, miny, maxy);
surface_reset_target(); surface_reset_target();
#endregion #endregion
#region ==== buttons ==== #region ==== buttons ====
var bx = _x + _w - ui(6 + 24); var bs = ui(20);
var by = _y + _h - ui(6 + 24);
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.add) == 2) { var bxF = _x + cw + ui(8);
miny = 0; var bx = bxF + ui(0);
maxy = 1;
var by0 = _y;
var by1 = _y + _h - bs + ui(2);
var byF = _y + (bs + ui(6));
var byH = _h + ui(2) - (bs + ui(6)) * 2;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, bxF, byF, bs, byH, COLORS.assetbox_current_bg, 1);
var zH = ui(16);
var zy = byF + zH / 2 + (byH - zH) * (zoom_level_to - zoom_min) / (zoom_max - zoom_min);
if(zooming) {
zoom_level_to = lerp(zoom_min, zoom_max, clamp((_m[1] - byF - zH / 2) / (byH - zH), 0, 1));
if(mouse_release(mb_left))
zooming = false;
} }
bx -= ui(24 + 4); var cc = merge_color(COLORS._main_icon, COLORS._main_icon_dark, 0.5);
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.minus) == 2) { if(point_in_rectangle(_m[0], _m[1], bxF, byF, _x + _w, byF + byH)) {
miny = -1; cc = COLORS._main_icon;
maxy = 2; if(mouse_click(mb_left, active))
zooming = true;
} }
draw_sprite_stretched_ext(THEME.timeline_dopesheet_bg, 0, bxF, zy - zH / 2, bs, zH, cc, 1);
if(buttonInstant(THEME.button_hide, bx, by0, bs, bs, _m, active, hover,, THEME.add_16) == 2)
zoom_level_to = clamp(zoom_level_to - 1, zoom_min, zoom_max);
if(buttonInstant(THEME.button_hide, bx, by1, bs, bs, _m, active, hover,, THEME.minus_16) == 2)
zoom_level_to = clamp(zoom_level_to + 1, zoom_min, zoom_max);
#endregion #endregion
if(hover) { #region if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + _h)) { #region
if(point_in_rectangle(_m[0], _m[1], _x + _w - ui(6 + 24 * 2 + 4), _y + _h - ui(6 + 24), _x + _w + ui(5), _y + _h + ui(5))) { if(mouse_press(mb_left, active)) {
} else if(point_in_rectangle(msx, msy, -ui(5), -ui(5), _w + ui(5), _h + ui(5))) { if(node_hovering == -1) {
if(mouse_press(mb_left, active)) { var _ind = point_insert * 6;
if(node_hovering == -1) { var _px = (_m[0] - _x) / cw;
var _ind = point_insert * 6; var _py = 1 - (_m[1] - _y) / _h;
var _px = (_m[0] - _x) / _w;
var _py = 1 - (_m[1] - _y) / _h;
array_insert(_data, _ind + 0, -0.1); array_insert(_data, _ind + 0, -0.1);
array_insert(_data, _ind + 1, 0); array_insert(_data, _ind + 1, 0);
array_insert(_data, _ind + 2, _px); array_insert(_data, _ind + 2, _px);
array_insert(_data, _ind + 3, _py); array_insert(_data, _ind + 3, _py);
array_insert(_data, _ind + 4, 0.1); array_insert(_data, _ind + 4, 0.1);
array_insert(_data, _ind + 5, 0); array_insert(_data, _ind + 5, 0);
if(onModify(_data)) if(onModify(_data))
UNDO_HOLDING = true; UNDO_HOLDING = true;
node_dragging = _ind + 2; node_dragging = _ind + 2;
node_drag_typ = 0; node_drag_typ = 0;
} else { } else {
node_dragging = node_hovering; node_dragging = node_hovering;
node_drag_typ = node_hover_typ; node_drag_typ = node_hover_typ;
}
} else if(mouse_press(mb_right, active)) {
var node_point = (node_hovering - 2) / 6;
if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) {
array_delete(_data, node_point * 6, 6);
if(onModify(_data))
UNDO_HOLDING = true;
}
} }
} else if(mouse_press(mb_right, active)) {
var node_point = (node_hovering - 2) / 6;
if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) {
array_delete(_data, node_point * 6, 6);
if(onModify(_data))
UNDO_HOLDING = true;
}
}
if(mouse_press(mb_right, active)) {
menuCall("widget_curve", rx + _m[0], ry + _m[1], [
menuItem(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }),
menuItem(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ),
menuItemGroup("Grid size", [
[ "1%", function() { grid_step = 0.01; } ],
[ "5%", function() { grid_step = 0.05; } ],
[ "10%", function() { grid_step = 0.10; } ],
[ "25%", function() { grid_step = 0.25; } ],
])
]);
} }
} #endregion } #endregion
draw_surface(curve_surface, _x, _y); draw_surface(curve_surface, _x, _y);
draw_set_color(COLORS.widget_curve_outline); draw_set_color(COLORS.widget_curve_outline);
draw_rectangle(_x, _y, _x + _w, _y + _h, true); draw_rectangle(_x, _y, _x + cw, _y + _h, true);
var tx = _x + cw - ui(6);
var ty = _y + _h - ui(6);
draw_set_text(f_p2, fa_right, fa_bottom, display_sel? COLORS._main_text: COLORS._main_text_sub);
draw_text_add(tx, ty, $"{display_sel == 2? "dy" : "y"}: {string_format(display_pos_y * 100, -1, 2)}%");
ty -= line_get_height();
draw_text_add(tx, ty, $"{display_sel == 2? "dx" : "x"}: {string_format(display_pos_x * 100, -1, 2)}%");
resetFocus(); resetFocus();

View file

@ -12,8 +12,10 @@ function fd_rectangle_add_velocity_surface(domain, surface, _x, _y, xscale, ysca
// blend linearly. The parameter values should be kept between -2 and 2. // blend linearly. The parameter values should be kept between -2 and 2.
with (domain) { with (domain) {
fd_rectangle_set_target(id, FD_TARGET_TYPE.ADD_VELOCITY); fd_rectangle_set_target(id, FD_TARGET_TYPE.ADD_VELOCITY);
var color = make_color_rgb(ceil((clamp(xvelo, -1, 1) * 0.125 + 0.5) * 255), ceil((clamp(yvelo, -1, 1) * 0.125 + 0.5) * 255), 0); var color = make_color_rgb(ceil((clamp(xvelo, -1, 1) * 0.125 + 0.5) * 255), ceil((clamp(yvelo, -1, 1) * 0.125 + 0.5) * 255), 0);
//print($"Applying velocity {xvelo}, {yvelo} = {ceil((clamp(xvelo, -1, 1) * 0.125 + 0.5) * 255)}, {ceil((clamp(yvelo, -1, 1) * 0.125 + 0.5) * 255)}");
draw_surface_ext_safe(surface, _x, _y, xscale, yscale, 0, color, 1); draw_surface_ext_safe(surface, _x, _y, xscale, yscale, 0, color, 1);
fd_rectangle_reset_target(id); fd_rectangle_reset_target(id);
} }

View file

@ -9,7 +9,4 @@ function fd_rectangle_clear(domain) {
surface_free(sf_material_0); surface_free(sf_material_1); surface_free(sf_material_0); surface_free(sf_material_1);
surface_free(sf_world); surface_free(sf_world);
} }
} }

View file

@ -41,6 +41,7 @@ function fd_rectangle_set_target(domain, type) {
surface_set_target(sf_velocity_temporary); surface_set_target(sf_velocity_temporary);
draw_enable_alphablend(false); draw_enable_alphablend(false);
draw_surface(sf_velocity, 0, 0); draw_surface(sf_velocity, 0, 0);
shader_set(sh_fd_add_velocity_glsl); shader_set(sh_fd_add_velocity_glsl);
shader_set_uniform_f(shader_get_uniform(sh_fd_add_velocity_glsl, "addend"), 0.5 + 0.5 * sf_velocity_texel_width, 0.5 + 0.5 * sf_velocity_texel_height); shader_set_uniform_f(shader_get_uniform(sh_fd_add_velocity_glsl, "addend"), 0.5 + 0.5 * sf_velocity_texel_width, 0.5 + 0.5 * sf_velocity_texel_height);
texture_set_stage(shader_get_sampler_index(sh_fd_add_velocity_glsl, "texture_velocity"), surface_get_texture(sf_velocity)); texture_set_stage(shader_get_sampler_index(sh_fd_add_velocity_glsl, "texture_velocity"), surface_get_texture(sf_velocity));

View file

@ -129,7 +129,7 @@
function __txt_junction_data(node, type, index, def = []) { function __txt_junction_data(node, type, index, def = []) {
gml_pragma("forceinline"); gml_pragma("forceinline");
if(TESTING) return def; return def;
if(!struct_has(LOCALE.node, node)) if(!struct_has(LOCALE.node, node))
return def; return def;

View file

@ -256,8 +256,10 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
case VALUE_TYPE.curve : case VALUE_TYPE.curve :
param.h = ui(160); param.h = ui(160);
if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + editBoxH)) if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + param.h)) {
mbRight = false; mbRight = false;
//_scrollPane.scroll_lock = true; // Not good UX-wise
}
break; break;
} }

View file

@ -12,15 +12,27 @@ function Node_Anim_Curve(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
inputs[| 2] = nodeValue("Minimum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0); inputs[| 2] = nodeValue("Minimum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 3] = nodeValue("Maximum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1); inputs[| 3] = nodeValue("Maximum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 4] = nodeValue("Animated", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
outputs[| 0] = nodeValue("Curve", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []); outputs[| 0] = nodeValue("Curve", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []);
input_display_list = [ 0, 4, 1, 2, 3 ];
static step = function() {
var _anim = getSingleValue(4);
inputs[| 1].setVisible(!_anim);
}
static processData = function(_output, _data, _output_index, _array_index = 0) { static processData = function(_output, _data, _output_index, _array_index = 0) {
var curve = _data[0]; var curve = _data[0];
var time = _data[1]; var time = _data[4]? PROJECT.animator.current_frame / (PROJECT.animator.frames_total - 1) : _data[1];
var _min = _data[2]; var _min = _data[2];
var _max = _data[3]; var _max = _data[3];
var val = eval_curve_x(curve, time) * (_max - _min) + _min; var val = eval_curve_x(curve, time) * (_max - _min) + _min;
inputs[| 0].editWidget.progress_draw = time;
return val; return val;
} }

View file

@ -51,11 +51,24 @@ function Node_Atlas_Set(_x, _y, _group = noone) : Node(_x, _y, _group) construct
for( var i = 0, n = array_length(atl); i < n; i++ ) { for( var i = 0, n = array_length(atl); i < n; i++ ) {
natl[i] = atl[i].clone(); natl[i] = atl[i].clone();
if(use[1]) natl[i].surface.set(array_safe_get(surf, i)); if(use[1]) natl[i].setSurface(array_safe_get(surf, i));
if(use[2]) natl[i].position = array_safe_get(posi, i);
if(use[2]) {
var pos = array_safe_get(posi, i);
natl[i].x = array_safe_get(pos, 0);
natl[i].y = array_safe_get(pos, 1);
}
if(use[3]) natl[i].rotation = array_safe_get(rota, i); if(use[3]) natl[i].rotation = array_safe_get(rota, i);
if(use[4]) natl[i].scale = array_safe_get(scal, i);
if(use[4]) {
var sca = array_safe_get(scal, i);
natl[i].sx = array_safe_get(sca, 0, 1);
natl[i].sy = array_safe_get(sca, 1, 1);
}
if(use[5]) natl[i].blend = array_safe_get(blns, i); if(use[5]) natl[i].blend = array_safe_get(blns, i);
if(use[6]) natl[i].alpha = array_safe_get(alph, i); if(use[6]) natl[i].alpha = array_safe_get(alph, i);
} }

View file

@ -61,7 +61,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
var _atlas = is_instanceof(_fore, SurfaceAtlas); var _atlas = is_instanceof(_fore, SurfaceAtlas);
inputs[| 5].editWidget.data_list = _atlas? [ "None", "Stretch" ] : [ "None", "Stretch", "Tile" ]; inputs[| 5].setVisible(!_atlas);
inputs[| 6].editWidget.data_list = _atlas? [ "Background", "Forground" ] : [ "Background", "Forground", "Mask", "Maximum", "Constant" ]; inputs[| 6].editWidget.data_list = _atlas? [ "Background", "Forground" ] : [ "Background", "Forground", "Mask", "Maximum", "Constant" ];
inputs[| 7].setVisible(_outp == 4); inputs[| 7].setVisible(_outp == 4);
@ -114,7 +114,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
break; break;
} }
if(_fill == 0) { // Direct placement if(_fill == 0 || _atlas) { // Direct placement
for( var i = 0; i < 2; i++ ) for( var i = 0; i < 2; i++ )
temp_surface[i] = surface_verify(temp_surface[i], ww, hh, cDep); temp_surface[i] = surface_verify(temp_surface[i], ww, hh, cDep);
@ -174,7 +174,13 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
if(_atlas) { if(_atlas) {
var _newAtl = _fore.clone(); var _newAtl = _fore.clone();
_newAtl.surface.set(_output);
if(_outp == 0) {
_newAtl.x = 0;
_newAtl.y = 0;
}
_newAtl.setSurface(_output);
return _newAtl; return _newAtl;
} }

View file

@ -69,6 +69,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
isInstancer = false; isInstancer = false;
instanceBase = noone; instanceBase = noone;
input_display_list_def = [];
custom_input_index = 0; custom_input_index = 0;
custom_output_index = 0; custom_output_index = 0;
@ -78,6 +79,27 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
attributes.w = 128; attributes.w = 128;
attributes.h = 128; attributes.h = 128;
input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0);
draw_dummy = false;
input_dummy.onSetFrom = function(juncFrom) {
ds_list_remove(juncFrom.value_to, input_dummy);
input_dummy.value_from = noone;
var input = nodeBuild("Node_Group_Input", 0, 0, self);
var _type = juncFrom.type;
var _tind = array_find(input.data_type_map, juncFrom.type);
//input.attributes.inherit_name = false;
//input.setDisplayName(juncFrom.name);
input.attributes.inherit_type = false;
if(_tind != -1)
input.inputs[| 2].setValue(_tind);
input.inParent.setFrom(juncFrom);
}
tool_node = noone; tool_node = noone;
draw_input_overlay = true; draw_input_overlay = true;
@ -120,6 +142,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
for( var i = 0; i < ds_list_size(inputs); i++ ) for( var i = 0; i < ds_list_size(inputs); i++ )
if(inputs[| i].isVisible()) _hi += 24; if(inputs[| i].isVisible()) _hi += 24;
if(active_draw_index == 1) _hi += 24;
draw_dummy = active_draw_index == 1;
for( var i = 0; i < ds_list_size(outputs); i++ ) for( var i = 0; i < ds_list_size(outputs); i++ )
if(outputs[| i].isVisible()) _ho += 24; if(outputs[| i].isVisible()) _ho += 24;
@ -154,6 +178,10 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
return nodes; return nodes;
} #endregion } #endregion
static getInput = function(junc = noone) { #region
return input_dummy;
} #endregion
static getNextNodes = function() { #region //get node inside the group static getNextNodes = function() { #region //get node inside the group
LOG_BLOCK_START(); LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group"); LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group");
@ -324,14 +352,31 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
PATCH_STATIC PATCH_STATIC
static onPreDraw = function(_x, _y, _s, _iny, _outy) { #region
var xx = x * _s + _x;
var yy = y * _s + _y;
input_dummy.x = xx;
input_dummy.y = _iny;
} #endregion
static preConnect = function() { #region static preConnect = function() { #region
sortIO(); sortIO();
deserialize(load_map, load_scale); deserialize(load_map, load_scale);
} #endregion } #endregion
static sortIO = function() { #region static onDrawJunctions = function(_x, _y, _mx, _my, _s) { #region
input_display_list = []; input_dummy.visible = false;
if(draw_dummy) {
input_dummy.visible = true;
input_dummy.drawJunction(_s, _mx, _my);
}
draw_dummy = false;
} #endregion
static sortIO = function() { #region
var sep = attributes.separator; var sep = attributes.separator;
array_sort(sep, function(a0, a1) { return a0[0] - a1[0]; }); array_sort(sep, function(a0, a1) { return a0[0] - a1[0]; });
var siz = ds_list_size(inputs); var siz = ds_list_size(inputs);
@ -347,8 +392,13 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
for( var i = siz - 1; i >= custom_input_index; i-- ) for( var i = siz - 1; i >= custom_input_index; i-- )
ds_list_delete(inputs, i); ds_list_delete(inputs, i);
for( var i = 0; i < custom_input_index; i++ ) if(array_empty(input_display_list_def)) {
array_push(input_display_list, i); input_display_list = [];
for( var i = 0; i < custom_input_index; i++ )
array_push(input_display_list, i);
} else {
input_display_list = array_clone(input_display_list_def);
}
for( var i = custom_input_index; i < siz; i++ ) { for( var i = custom_input_index; i < siz; i++ ) {
var _jin = ds_priority_delete_min(ar); var _jin = ds_priority_delete_min(ar);
@ -357,9 +407,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
array_push(input_display_list, i); array_push(input_display_list, i);
} }
for( var i = array_length(sep) - 1; i >= 0; i-- ) { for( var i = array_length(sep) - 1; i >= 0; i-- )
array_insert(input_display_list, sep[i][0], [ sep[i][1], false, i ]); array_insert(input_display_list, array_length(input_display_list_def) + sep[i][0], [ sep[i][1], false, i ]);
}
ds_priority_destroy(ar); ds_priority_destroy(ar);
@ -469,6 +518,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
_output_junc = nodes[| i].inputs[| 0]; _output_junc = nodes[| i].inputs[| 0];
} }
if(!is_instanceof(_output_junc, NodeValue)) return noone;
switch(_output_junc.type) { switch(_output_junc.type) {
case VALUE_TYPE.surface : case VALUE_TYPE.surface :
case VALUE_TYPE.dynaSurface : case VALUE_TYPE.dynaSurface :

View file

@ -667,7 +667,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
updatedOutTrigger.y = yy + 10; updatedOutTrigger.y = yy + 10;
var inamo = (input_display_list == -1 || !use_display_list)? ds_list_size(inputs) : array_length(input_display_list); var inamo = (input_display_list == -1 || !use_display_list)? ds_list_size(inputs) : array_length(input_display_list);
var _in = yy + ui(junction_draw_pad_y) * _s; var _iny = yy + ui(junction_draw_pad_y) * _s;
for(var i = 0; i < inamo; i++) { for(var i = 0; i < inamo; i++) {
var idx = getInputJunctionIndex(i); var idx = getInputJunctionIndex(i);
@ -676,24 +676,28 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
jun = ds_list_get(inputs, idx, noone); jun = ds_list_get(inputs, idx, noone);
if(jun == noone || is_undefined(jun)) continue; if(jun == noone || is_undefined(jun)) continue;
jun.x = xx; jun.x = xx;
jun.y = _in; jun.y = _iny;
_in += 24 * _s * jun.isVisible(); _iny += 24 * _s * jun.isVisible();
} }
var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list); var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list);
xx = xx + w * _s; xx = xx + w * _s;
_in = yy + ui(junction_draw_pad_y) * _s; var _outy = yy + ui(junction_draw_pad_y) * _s;
for(var i = 0; i < outamo; i++) { for(var i = 0; i < outamo; i++) {
var idx = getOutputJunctionIndex(i); var idx = getOutputJunctionIndex(i);
jun = outputs[| idx]; jun = outputs[| idx];
jun.x = xx; jun.x = xx;
jun.y = _in; jun.y = _outy;
_in += 24 * _s * jun.isVisible(); _outy += 24 * _s * jun.isVisible();
} }
onPreDraw(_x, _y, _s, _iny, _outy);
} #endregion } #endregion
static onPreDraw = function(_x, _y, _s, _iny, _outy) {}
static drawNodeBase = function(xx, yy, _s) { #region static drawNodeBase = function(xx, yy, _s) { #region
if(draw_graph_culled) return; if(draw_graph_culled) return;
if(!active) return; if(!active) return;
@ -792,9 +796,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(updatedOutTrigger.drawJunction(_s, _mx, _my)) hover = updatedOutTrigger; if(updatedOutTrigger.drawJunction(_s, _mx, _my)) hover = updatedOutTrigger;
} }
onDrawJunctions(_x, _y, _mx, _my, _s);
return hover; return hover;
} #endregion } #endregion
static onDrawJunctions = function(_x, _y, _mx, _my, _s) {}
static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region
if(draw_graph_culled) return; if(draw_graph_culled) return;
if(!active) return; if(!active) return;

View file

@ -36,6 +36,8 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con
outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone); outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone);
temp_surface = [ surface_create(1, 1) ];
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _mat = getInputData(1); var _mat = getInputData(1);
var _pos = getInputData(2); var _pos = getInputData(2);
@ -62,7 +64,7 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con
var _msk = inputs[| 6].getValue(frame); var _msk = inputs[| 6].getValue(frame);
var _vel = inputs[| 7].getValue(frame); var _vel = inputs[| 7].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
if(!_act) return; if(!_act) return;
@ -79,16 +81,21 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con
dy += (_pos[1] - _prevPos[1]) * _inh; dy += (_pos[1] - _prevPos[1]) * _inh;
} }
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fluid_bleach);
draw_surface_safe(_mat);
surface_reset_shader();
if(dx != 0 || dy != 0) { if(dx != 0 || dy != 0) {
if(_msk == 0) if(_msk == 0)
fd_rectangle_add_velocity_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, dx, dy); fd_rectangle_add_velocity_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, dx, dy);
else { else {
var _vw = sw + max(0, _msk * 2); var _vw = sw + max(0, _msk * 2);
var _vh = sh + max(0, _msk * 2); var _vh = sh + max(0, _msk * 2);
var _vmask = surface_create(_vw, _vh); var _vmask = surface_create(_vw, _vh);
surface_set_shader(_vmask,,, BLEND.over); surface_set_shader(_vmask,,, BLEND.over);
draw_surface_safe(_mat, max(0, _msk), max(0, _msk)); draw_surface_safe(temp_surface[0], max(0, _msk), max(0, _msk));
surface_reset_shader(); surface_reset_shader();
var vel_mask = surface_create(_vw, _vh); var vel_mask = surface_create(_vw, _vh);
@ -105,7 +112,7 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con
} }
} }
fd_rectangle_add_material_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, c_white, _den); fd_rectangle_add_material_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, c_white, _den);
_prevPos[0] = _pos[0]; _prevPos[0] = _pos[0];
_prevPos[1] = _pos[1]; _prevPos[1] = _pos[1];

View file

@ -38,9 +38,10 @@ function Node_Fluid_Add_Collider(_x, _y, _group = noone) : Node_Fluid(_x, _y, _g
var _dom = inputs[| 0].getValue(frame); var _dom = inputs[| 0].getValue(frame);
var _mat = inputs[| 1].getValue(frame); var _mat = inputs[| 1].getValue(frame);
var _area = inputs[| 2].getValue(frame); var _area = inputs[| 2].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return;
FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
if(!is_surface(_mat)) return; if(!is_surface(_mat)) return;
if(!is_surface(_dom.sf_world)) return; if(!is_surface(_dom.sf_world)) return;

View file

@ -46,7 +46,7 @@ function Node_Fluid_Apply_Velocity(_x, _y, _group = noone) : Node_Fluid(_x, _y,
var _vel = inputs[| 3].getValue(frame); var _vel = inputs[| 3].getValue(frame);
var _act = inputs[| 4].getValue(frame); var _act = inputs[| 4].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
if(!_act) return; if(!_act) return;
@ -55,7 +55,12 @@ function Node_Fluid_Apply_Velocity(_x, _y, _group = noone) : Node_Fluid(_x, _y,
var sw = surface_get_width_safe(_mat); var sw = surface_get_width_safe(_mat);
var sh = surface_get_height_safe(_mat); var sh = surface_get_height_safe(_mat);
fd_rectangle_add_velocity_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0], _vel[1]); temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fluid_bleach);
draw_surface_safe(_mat);
surface_reset_shader();
fd_rectangle_add_velocity_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0], _vel[1]);
} }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -31,16 +31,14 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
inputs[| 8] = nodeValue("Initial pressure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75) inputs[| 8] = nodeValue("Initial pressure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75)
.setDisplay(VALUE_DISPLAY.slider); .setDisplay(VALUE_DISPLAY.slider);
inputs[| 9] = nodeValue("Material maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) inputs[| 9] = nodeValue("Material Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider); .setDisplay(VALUE_DISPLAY.slider);
inputs[| 10] = nodeValue("Velocity maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) inputs[| 10] = nodeValue("Velocity Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider); .setDisplay(VALUE_DISPLAY.slider);
inputs[| 11] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); inputs[| 11] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 12] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone); outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone);
input_display_list = [ input_display_list = [
@ -53,7 +51,7 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
domain = fd_rectangle_create(256, 256); domain = fd_rectangle_create(256, 256);
_dim_old = [0, 0]; _dim_old = [0, 0];
static update = function(frame = PROJECT.animator.current_frame) { static update = function(frame = PROJECT.animator.current_frame) { #region
RETURN_ON_REST RETURN_ON_REST
var _dim = inputs[| 0].getValue(frame); var _dim = inputs[| 0].getValue(frame);
@ -68,7 +66,6 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
var mMac = inputs[| 9].getValue(frame); var mMac = inputs[| 9].getValue(frame);
var vMac = inputs[| 10].getValue(frame); var vMac = inputs[| 10].getValue(frame);
var wrap = inputs[| 11].getValue(frame); var wrap = inputs[| 11].getValue(frame);
//var loop = inputs[| 12].getValue(frame);
if(PROJECT.animator.current_frame == 0 || !is_surface(domain.sf_world)) { if(PROJECT.animator.current_frame == 0 || !is_surface(domain.sf_world)) {
fd_rectangle_clear(domain); fd_rectangle_clear(domain);
@ -84,15 +81,6 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
fd_rectangle_set_initial_value_pressure(domain, inPress); fd_rectangle_set_initial_value_pressure(domain, inPress);
} }
if(_dim[0] != _dim_old[0] || _dim[1] != _dim_old[1]) {
fd_rectangle_set_pressure_size(domain, _dim[0], _dim[1]);
fd_rectangle_set_velocity_size(domain, _dim[0], _dim[1]);
fd_rectangle_set_material_size(domain, _dim[0], _dim[1]);
_dim_old[0] = _dim[0];
_dim_old[1] = _dim[1];
}
surface_set_target(domain.sf_world); surface_set_target(domain.sf_world);
draw_clear_alpha($00FFFF, 0); draw_clear_alpha($00FFFF, 0);
if(is_surface(coll)) if(is_surface(coll))
@ -113,13 +101,7 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
fd_rectangle_set_repeat(domain, wrap); fd_rectangle_set_repeat(domain, wrap);
outputs[| 0].setValue(domain); outputs[| 0].setValue(domain);
} #region
//if(!loop) return;
//if(PROJECT.animator.current_frame != 0) return;
//for( var i = 0; i < PROJECT.animator.frames_total; i++ )
// updateForward(i, false);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);

View file

@ -14,9 +14,11 @@ function Node_Fluid_Render(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
inputs[| 3] = nodeValue("Draw Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); inputs[| 3] = nodeValue("Draw Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 4] = nodeValue("Auto Update", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [ input_display_list = [
["Domain", false], 0, ["Domain", false], 0,
["Render", false], 1, 2, 3, ["Render", false], 4, 1, 2, 3,
]; ];
outputs[| 0] = nodeValue("Fluid", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Fluid", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -51,11 +53,16 @@ function Node_Fluid_Render(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
var _dom = inputs[| 0].getValue(frame); var _dom = inputs[| 0].getValue(frame);
var _int = inputs[| 2].getValue(frame); var _int = inputs[| 2].getValue(frame);
var _drw = inputs[| 3].getValue(frame); var _drw = inputs[| 3].getValue(frame);
var _upd = inputs[| 4].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
var fSurf = _dom.sf_material_0; var fSurf = _dom.sf_material_0;
if(!is_surface(fSurf)) return; if(!is_surface(fSurf)) return;
if(_upd) fd_rectangle_update(_dom);
texture_set_interpolation(false);
outputs[| 1].setValue(_dom.sf_world); outputs[| 1].setValue(_dom.sf_world);
surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl); surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl);

View file

@ -44,7 +44,7 @@ function Node_Fluid_Repulse(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
var _str = inputs[| 3].getValue(frame); var _str = inputs[| 3].getValue(frame);
var _mod = inputs[| 4].getValue(frame); var _mod = inputs[| 4].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
_rad = max(_rad, 1); _rad = max(_rad, 1);

View file

@ -1,3 +1,5 @@
#macro FLUID_DOMAIN_CHECK if(!is_instanceof(group, Node_Fluid_Group)) return; if(!instance_exists(_dom)) _dom = group.domain; if(_dom == noone || !instance_exists(_dom)) return;
function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor { function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor {
name = "FluidSim"; name = "FluidSim";
color = COLORS.node_blend_fluid; color = COLORS.node_blend_fluid;
@ -6,15 +8,60 @@ function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro
ungroupable = false; ungroupable = false;
update_on_frame = true; update_on_frame = true;
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue("Collision", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 2] = nodeValue("Material dissipation type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Multiply", "Subtract" ]);
inputs[| 3] = nodeValue("Material dissipation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.02)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 0.1, 0.01 ] });
inputs[| 4] = nodeValue("Velocity dissipation type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Multiply", "Subtract" ]);
inputs[| 5] = nodeValue("Velocity dissipation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.00)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 0.1, 0.01 ] });
inputs[| 6] = nodeValue("Acceleration", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 7] = nodeValue("Material intertia", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, -0.2 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 8] = nodeValue("Initial pressure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 9] = nodeValue("Material Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 10] = nodeValue("Velocity Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 11] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
input_display_list_def = [
["Domain", false], 0, 11, 1,
["Properties", false], 8, 6, 7,
["Dissipation", false], 2, 3, 4, 5,
["Huh?", true], 9, 10,
["Inputs", false],
];
custom_input_index = ds_list_size(inputs);
domain = fd_rectangle_create(PROJECT.attributes.surface_dimension[0], PROJECT.attributes.surface_dimension[1]);
//_dim_old = [0, 0];
if(!LOADING && !APPENDING && !CLONING) { if(!LOADING && !APPENDING && !CLONING) {
var _domain = nodeBuild("Node_Fluid_Domain", -384, -32, self); //var _domain = nodeBuild("Node_Fluid_Domain", -384, -32, self);
var _update = nodeBuild("Node_Fluid_Update", 0, -32, self);
var _render = nodeBuild("Node_Fluid_Render", 128, -32, self); var _render = nodeBuild("Node_Fluid_Render", 128, -32, self);
var _output = nodeBuild("Node_Group_Output", 384, -32, self); var _output = nodeBuild("Node_Group_Output", 384, -32, self);
_output.inputs[| 0].setFrom(_render.outputs[| 0]); _output.inputs[| 0].setFrom(_render.outputs[| 0]);
_render.inputs[| 0].setFrom(_update.outputs[| 0]); //_render.inputs[| 0].setFrom(_domain.outputs[| 0]);
_update.inputs[| 0].setFrom(_domain.outputs[| 0]);
} }
static update = function() { static update = function() {
@ -24,6 +71,51 @@ function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro
if(!is_instanceof(node, Node_Fluid_Render)) continue; if(!is_instanceof(node, Node_Fluid_Render)) continue;
if(node.cacheExist()) node.cachedPropagate(); if(node.cacheExist()) node.cachedPropagate();
} }
var _dim = getInputData( 0);
var coll = getInputData( 1);
var mdisTyp = getInputData( 2);
var mdis = getInputData( 3);
var vdisTyp = getInputData( 4);
var vdis = getInputData( 5);
var acc = getInputData( 6);
var matInr = getInputData( 7);
var inPress = getInputData( 8);
var mMac = getInputData( 9);
var vMac = getInputData(10);
var wrap = getInputData(11);
if(PROJECT.animator.current_frame == 0 || !is_surface(domain.sf_world)) {
fd_rectangle_clear(domain);
fd_rectangle_destroy(domain);
domain = fd_rectangle_create(_dim[0], _dim[1]);
fd_rectangle_set_visualization_shader(domain, FD_VISUALIZATION_SHADER.COLORIZE);
fd_rectangle_set_material_type(domain, FD_MATERIAL_TYPE.A_16);
fd_rectangle_set_velocity_time_step(domain, 1);
fd_rectangle_set_material_time_step(domain, 1);
fd_rectangle_set_pressure_iteration_type(domain, -2);
fd_rectangle_set_initial_value_pressure(domain, inPress);
}
surface_set_target(domain.sf_world);
draw_clear_alpha($00FFFF, 0);
if(is_surface(coll)) draw_surface_stretched_safe(coll, 0, 0, _dim[0], _dim[1]);
surface_reset_target();
fd_rectangle_set_material_dissipation_type(domain, mdisTyp);
fd_rectangle_set_material_dissipation_value(domain, mdis);
fd_rectangle_set_velocity_dissipation_type(domain, vdisTyp);
fd_rectangle_set_velocity_dissipation_value(domain, vdis);
fd_rectangle_set_acceleration(domain, acc[0], acc[1], matInr[0], matInr[1]);
fd_rectangle_set_velocity_maccormack_weight(domain, vMac);
fd_rectangle_set_material_maccormack_weight(domain, mMac);
fd_rectangle_set_repeat(domain, wrap);
} }
PATCH_STATIC PATCH_STATIC

View file

@ -39,7 +39,7 @@ function Node_Fluid_Turbulence(_x, _y, _group = noone) : Node_Fluid(_x, _y, _gro
var _sed = inputs[| 4].getValue(frame); var _sed = inputs[| 4].getValue(frame);
var _mod = inputs[| 5].getValue(frame); var _mod = inputs[| 5].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
var vSurface = surface_create_size(_dom.sf_velocity); var vSurface = surface_create_size(_dom.sf_velocity);

View file

@ -22,7 +22,8 @@ function Node_Fluid_Update(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
var _dom = inputs[| 0].getValue(frame); var _dom = inputs[| 0].getValue(frame);
var _act = inputs[| 1].getValue(frame); var _act = inputs[| 1].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return;
FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
if(!_act) return; if(!_act) return;

View file

@ -49,7 +49,7 @@ function Node_Fluid_Vortex(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group)
var _aio = inputs[| 4].getValue(frame); var _aio = inputs[| 4].getValue(frame);
var _mod = inputs[| 5].getValue(frame); var _mod = inputs[| 5].getValue(frame);
if(_dom == noone || !instance_exists(_dom)) return; FLUID_DOMAIN_CHECK
outputs[| 0].setValue(_dom); outputs[| 0].setValue(_dom);
_rad = max(_rad, 1); _rad = max(_rad, 1);

View file

@ -40,7 +40,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
/*Surface*/ [ "Default", ], /*Surface*/ [ "Default", ],
/*Path*/ [ "Default", ], /*Path*/ [ "Default", ],
/*Curve*/ [ "Default", ], /*Curve*/ [ "Curve", ],
/*Text*/ [ "Default", ], /*Text*/ [ "Default", ],
/*Object*/ [ "Default", ], /*Object*/ [ "Default", ],
/*Node*/ [ "Default", ], /*Node*/ [ "Default", ],
@ -60,10 +60,9 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
#endregion #endregion
inputs[| 0] = nodeValue("Display type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) inputs[| 0] = nodeValue("Display type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, display_list[0]) .setDisplay(VALUE_DISPLAY.enum_scroll, { data: display_list[0], update_hover: false })
.uncache() .uncache()
.rejectArray(); .rejectArray();
inputs[| 0].editWidget.update_hover = false;
inputs[| 1] = nodeValue("Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 1]) inputs[| 1] = nodeValue("Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 1])
.setDisplay(VALUE_DISPLAY.range) .setDisplay(VALUE_DISPLAY.range)
@ -71,11 +70,10 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
.setVisible(false) .setVisible(false)
.rejectArray(); .rejectArray();
inputs[| 2] = nodeValue("Input type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) inputs[| 2] = nodeValue("Input type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 11)
.setDisplay(VALUE_DISPLAY.enum_scroll, { data: data_type_list, update_hover: false }) .setDisplay(VALUE_DISPLAY.enum_scroll, { data: data_type_list, update_hover: false })
.uncache() .uncache()
.rejectArray(); .rejectArray();
inputs[| 2].editWidget.update_hover = false;
inputs[| 3] = nodeValue("Enum label", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "") inputs[| 3] = nodeValue("Enum label", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "")
.setVisible(false) .setVisible(false)
@ -115,12 +113,26 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
.uncache(); .uncache();
attributes.inherit_name = !LOADING && !APPENDING; attributes.inherit_name = !LOADING && !APPENDING;
attributes.inherit_type = !LOADING && !APPENDING;
doTrigger = 0; doTrigger = 0;
_onSetDisplayName = function() { _onSetDisplayName = function() {
attributes.inherit_name = false; attributes.inherit_name = false;
} }
outputs[| 0].onSetTo = function(juncTo) {
if(!attributes.inherit_type) return;
attributes.inherit_type = false;
var ind = array_find(data_type_map, juncTo.type);
if(ind == -1) return;
if(ind == inputs[| 2].getValue()) return;
outputs[| 0].type = juncTo.type;
inputs[| 2].setValue(ind);
}
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
if(inParent.isArray()) return; if(inParent.isArray()) return;
inParent.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inParent.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
@ -138,14 +150,17 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var _step = getInputData(7); var _step = getInputData(7);
if(index == 2) { if(index == 2) {
var _o = outputs[| 0]; if(outputs[| 0].type != _val_type) {
for(var j = 0; j < ds_list_size(_o.value_to); j++) { var _o = outputs[| 0];
var _to = _o.value_to[| j]; for(var j = 0; j < ds_list_size(_o.value_to); j++) {
if(_to.value_from == _o) var _to = _o.value_to[| j];
_to.removeFrom(); if(_to.value_from == _o)
_to.removeFrom();
}
} }
inputs[| 0].setValue(0); inputs[| 0].setValue(0);
attributes.inherit_type = false;
} }
_dtype = array_safe_get(array_safe_get(display_list, _val_type, []), _dtype); _dtype = array_safe_get(array_safe_get(display_list, _val_type, []), _dtype);
@ -227,6 +242,11 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inParent.setDisplay(VALUE_DISPLAY._default); inParent.setDisplay(VALUE_DISPLAY._default);
break; break;
case "Curve":
inParent.animator = new valueAnimator(CURVE_DEF_11, inParent);
inParent.setDisplay(VALUE_DISPLAY.curve);
break;
default: default:
inParent.setDisplay(VALUE_DISPLAY._default); inParent.setDisplay(VALUE_DISPLAY._default);
break; break;

View file

@ -14,7 +14,7 @@ function Node_Iterate_Filter(_x, _y, _group = noone) : Node_Iterator(_x, _y, _gr
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone ); outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone );
custom_input_index = ds_list_size(inputs); custom_input_index = ds_list_size(inputs);
custom_output_index = ds_list_size(inputs); custom_output_index = ds_list_size(inputs);
loop_start_time = 0; loop_start_time = 0;
ALWAYS_FULL = true; ALWAYS_FULL = true;

View file

@ -44,7 +44,21 @@ function Node_Rigid_Force_Apply(_x, _y, _group = noone) : Node(_x, _y, _group) c
["Force", false], 1, 6, 4, 2, 3, 5, 8, 7, ["Force", false], 1, 6, 4, 2, 3, 5, 8, 7,
] ]
attributes.show_objects = true;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; },
new checkBox(function() {
attributes.show_objects = !attributes.show_objects;
})]);
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(attributes.show_objects)
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny);
}
var _typ = getInputData(1); var _typ = getInputData(1);
var _pos = getInputData(2); var _pos = getInputData(2);
var px = _x + _pos[0] * _s; var px = _x + _pos[0] * _s;
@ -62,7 +76,7 @@ function Node_Rigid_Force_Apply(_x, _y, _group = noone) : Node(_x, _y, _group) c
draw_set_alpha(1); draw_set_alpha(1);
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 5].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny, THEME.anchor, 10); inputs[| 5].drawOverlay(active, px, py, _s * 10, _mx, _my, _snx, _sny, THEME.anchor, 10);
} else if(_typ == 3) { } else if(_typ == 3) {
var _rad = getInputData(8); var _rad = getInputData(8);

View file

@ -43,16 +43,10 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
.setDisplay(VALUE_DISPLAY.slider, { range: [ -2, 2, 0.1 ] }) .setDisplay(VALUE_DISPLAY.slider, { range: [ -2, 2, 0.1 ] })
.rejectArray(); .rejectArray();
inputs[| 11] = nodeValue("Texture type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Surface", "Atlas" ])
.rejectArray();
inputs[| 12] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, []);
outputs[| 0] = nodeValue("Object", self, JUNCTION_CONNECT.output, VALUE_TYPE.rigid, self); outputs[| 0] = nodeValue("Object", self, JUNCTION_CONNECT.output, VALUE_TYPE.rigid, self);
input_display_list = [ 8, input_display_list = [ 8,
["Texture", false], 11, 6, 12, ["Texture", false], 6,
["Physical", false], 0, 1, 2, 3, 4, ["Physical", false], 0, 1, 2, 3, 4,
["Shape", false], 7, 5, 9, 10, ["Shape", false], 7, 5, 9, 10,
]; ];
@ -72,23 +66,6 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
new NodeTool( "Anchor remove", THEME.mesh_tool_delete ), new NodeTool( "Anchor remove", THEME.mesh_tool_delete ),
]; ];
static getPreviewValues = function() {
var _typ = getInputData(11);
return _typ? getInputData(12) : getInputData(6);
}
static generateAllMesh = function() {
var _typ = getInputData(11);
var _tex = _typ? getInputData(12) : getInputData(6);
if(is_array(_tex)) {
for( var i = 0, n = array_length(_tex); i < n; i++ )
generateMesh(i);
} else
generateMesh();
doUpdate();
}
is_convex = true; is_convex = true;
hover = -1; hover = -1;
anchor_dragging = -1; anchor_dragging = -1;
@ -97,20 +74,36 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
anchor_drag_mx = -1; anchor_drag_mx = -1;
anchor_drag_my = -1; anchor_drag_my = -1;
static drawOverlayPreview = function(_i, _x, _y, _s, _pr_x, _pr_y, _atl_s, _tex_s) { #region static getPreviewValues = function() { #region
return getInputData(6);
} #endregion
static generateAllMesh = function() { #region
var _tex = getInputData(6);
if(is_array(_tex)) {
for( var i = 0, n = array_length(_tex); i < n; i++ )
generateMesh(i);
} else
generateMesh();
doUpdate();
} #endregion
static drawOverlayPreviewSingle = function(_i, _x, _y, _s, _pr_x, _pr_y, _tex_s) { #region
var meshes = attributes.mesh; var meshes = attributes.mesh;
var _shp = getInputData(5); var _shp = getInputData(5);
var _typ = getInputData(11);
var ww = max(1, surface_get_width_safe(_tex_s)); var ww = surface_get_width_safe(_tex_s);
var hh = max(1, surface_get_height_safe(_tex_s)); var hh = surface_get_height_safe(_tex_s);
var _tex = _tex_s;
if(_typ == 0) { if(is_instanceof(_tex_s, SurfaceAtlas)) {
_tex = _tex_s.getSurface();
_pr_x += _tex_s.x * _s;
_pr_y += _tex_s.y * _s;
} else {
_pr_x -= ww * _s / 2; _pr_x -= ww * _s / 2;
_pr_y -= hh * _s / 2; _pr_y -= hh * _s / 2;
} else if(_typ == 1) {
_pr_x += _atl_s.x * _s;
_pr_y += _atl_s.y * _s;
} }
if(_shp == 2 && array_length(meshes) > _i) { if(_shp == 2 && array_length(meshes) > _i) {
@ -134,55 +127,35 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} }
} }
draw_surface_ext_safe(_tex_s, _pr_x, _pr_y, _s, _s, 0, c_white, 0.5); draw_surface_ext_safe(_tex, _pr_x, _pr_y, _s, _s, 0, c_white, 0.5);
} #endregion
static drawOverlayPreview = function(_x, _y, _s, _mx, _my, _snx, _sny) { #region
var _pos = getInputData(7);
var _tex = getInputData(6);
var _pr_x = _x + _pos[0] * _s;
var _pr_y = _y + _pos[1] * _s;
if(is_array(_tex)) {
for( var i = 0, n = array_length(_tex); i < n; i++ )
drawOverlayPreviewSingle(i, _x, _y, _s, _pr_x, _pr_y, _tex[i]);
} else
drawOverlayPreviewSingle(0, _x, _y, _s, _pr_x, _pr_y, _tex);
inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
} #endregion } #endregion
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _shp = getInputData(5); if(previewing == 0 && is_instanceof(group, Node_Rigid_Group)) {
var _pos = getInputData(7); for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _typ = getInputData(11); var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue;
var _typ = getInputData(11); _node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny);
var _atl = getInputData(12);
var _tex = getInputData(6);
var _atl_s = _atl;
var _tex_s = _tex;
var _isArr = false;
if(_typ == 0) {
if(is_array(_tex)) {
_tex_s = array_safe_get(_tex, preview_index);
_isArr = true;
} }
} else if(_typ == 1) {
if(is_array(_atl)) {
_atl_s = array_safe_get(_atl, preview_index);
_isArr = true;
}
if(_atl_s == 0) return;
_tex_s = _atl_s.getSurface();
}
if(previewing == 0) {
var _pr_x = _x + _pos[0] * _s;
var _pr_y = _y + _pos[1] * _s;
if(_isArr) {
if(_typ == 0) {
for( var i = 0, n = array_length(_tex); i < n; i++ )
drawOverlayPreview(i, _x, _y, _s, _pr_x, _pr_y, noone, _tex[i]);
} else {
for( var i = 0, n = array_length(_atl); i < n; i++ )
drawOverlayPreview(i, _x, _y, _s, _pr_x, _pr_y, _atl[i], _atl[i].getSurface());
}
} else
drawOverlayPreview(0, _x, _y, _s, _pr_x, _pr_y, _atl, _tex);
inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
return; return;
} }
var _shp = getInputData(5);
if(_shp != 2) return; if(_shp != 2) return;
var meshes = attributes.mesh; var meshes = attributes.mesh;
@ -287,16 +260,11 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
static generateMesh = function(index = 0) { #region static generateMesh = function(index = 0) { #region
var _tex = getInputData(6); var _tex = getInputData(6);
var _exp = getInputData(10); var _exp = getInputData(10);
var _typ = getInputData(11);
var _atl = getInputData(12);
if(_typ == 0) { if(is_array(_tex)) _tex = array_safe_get(_tex, index);
if(is_array(_tex)) _tex = array_safe_get(_tex, index);
} else if(_typ == 1) { if(is_instanceof(_tex, SurfaceAtlas))
if(is_array(_atl)) _atl = array_safe_get(_atl, index); _tex = _tex.getSurface();
if(_atl == 0) return;
_tex = _atl.getSurface();
}
if(!is_surface(_tex)) return; if(!is_surface(_tex)) return;
@ -326,6 +294,8 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} }
} }
if(cmA == 0) return;
cmX /= cmA; cmX /= cmA;
cmY /= cmA; cmY /= cmA;
@ -363,6 +333,8 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
array_sort(keys, false); array_sort(keys, false);
for( var i = 0, n = array_length(keys); i < n; i++ ) { for( var i = 0, n = array_length(keys); i < n; i++ ) {
//print($"Getting key {keys[i]} - {_pm[? keys[i]]}");
var px = _pm[? keys[i]][0]; var px = _pm[? keys[i]][0];
var py = _pm[? keys[i]][1]; var py = _pm[? keys[i]][1];
@ -532,32 +504,29 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} #endregion } #endregion
static spawn = function(index = 0, object = noone) { #region static spawn = function(index = 0, object = noone) { #region
var _shp = getInputData(5); var _shp = getInputData(5);
var _tex = getInputData(6); var _tex = getInputData(6);
var _typ = getInputData(11); var _spos = getInputData(7);
var _atl = getInputData(12);
if(_typ == 0 && is_array(_tex)) { index = safe_mod(index, array_length(_tex)); _tex = array_safe_get(_tex, index); } if(is_array(_tex)) {
if(_typ == 1 && is_array(_atl)) { index = safe_mod(index, array_length(_atl)); _atl = array_safe_get(_atl, index); } index = safe_mod(index, array_length(_tex));
if(_typ == 1) { _tex = array_safe_get(_tex, index);
if(_atl == 0) return;
_tex = _atl.getSurface();
} }
var _spos = getInputData(7); var ww = surface_get_width_safe(_tex);
var hh = surface_get_height_safe(_tex);
var ww = max(1, surface_get_width_safe(_tex));
var hh = max(1, surface_get_height_safe(_tex));
var sw = ww, sh = hh; var sw = ww, sh = hh;
var ox = _spos[0]; var ox = _spos[0];
var oy = _spos[1]; var oy = _spos[1];
if(_typ == 1) { if(is_instanceof(_tex, SurfaceAtlas)) {
ox += _atl.x; ox += _tex.x;
oy += _atl.y; oy += _tex.y;
sw = 0; sw = 0;
sh = 0; sh = 0;
_tex = _tex.getSurface();
} }
if(object == noone) { if(object == noone) {
@ -657,10 +626,6 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
static step = function() { #region static step = function() { #region
var _shp = getInputData(5); var _shp = getInputData(5);
var _tex = getInputData(11);
inputs[| 6].setVisible(_tex == 0, _tex == 0);
inputs[| 12].setVisible(_tex == 1, _tex == 1);
inputs[| 9].setVisible(_shp == 2); inputs[| 9].setVisible(_shp == 2);
@ -675,8 +640,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} #endregion } #endregion
static reset = function() { #region static reset = function() { #region
var _typ = getInputData(11); var _tex = getInputData(6);
var _tex = _typ? getInputData(12) : getInputData(6);
for( var i = 0, n = array_length(object); i < n; i++ ) { for( var i = 0, n = array_length(object); i < n; i++ ) {
if(instance_exists(object[i])) if(instance_exists(object[i]))
@ -696,15 +660,14 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var _typ = getInputData(11); var _tex = getInputData(6);
var _tex = _typ? getInputData(12) : getInputData(6);
if(is_array(_tex)) { if(is_array(_tex)) {
if(array_empty(_tex)) return; if(array_empty(_tex)) return;
_tex = _tex[0]; _tex = _tex[0];
} }
draw_surface_bbox(_typ? _tex.getSurface() : _tex, bbox); draw_surface_bbox(_tex, bbox);
} #endregion } #endregion
static attributeSerialize = function() { #region static attributeSerialize = function() { #region

View file

@ -40,7 +40,21 @@ function Node_Rigid_Object_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group
spawn_index = 0; spawn_index = 0;
attributes.show_objects = true;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; },
new checkBox(function() {
attributes.show_objects = !attributes.show_objects;
})]);
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(attributes.show_objects)
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny);
}
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
} }

View file

@ -18,6 +18,13 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
attribute_surface_depth(); attribute_surface_depth();
attributes.show_objects = true;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; },
new checkBox(function() {
attributes.show_objects = !attributes.show_objects;
})]);
static createNewInput = function() { static createNewInput = function() {
var index = ds_list_size(inputs); var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone ) inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone )
@ -55,6 +62,17 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
refreshDynamicInput(); refreshDynamicInput();
} }
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
if(!is_instanceof(group, Node_Rigid_Group)) return;
if(!attributes.show_objects) return;
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny);
}
} #endregion
static step = function() { static step = function() {
var _dim = getInputData(0); var _dim = getInputData(0);
var _outSurf = outputs[| 0].getValue(); var _outSurf = outputs[| 0].getValue();

View file

@ -35,16 +35,16 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct
setIsDynamicInput(1); setIsDynamicInput(1);
static createNewInput = function() { static createNewInput = function() { #region
var index = ds_list_size(inputs); var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Input", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, -1 ) inputs[| index] = nodeValue("Input", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, -1 )
.setVisible(true, true); .setVisible(false, true);
} } #endregion
if(!LOADING && !APPENDING) createNewInput(); if(!LOADING && !APPENDING) createNewInput();
outputs[| 0] = nodeValue("Statistic", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, -1); outputs[| 0] = nodeValue("Statistic", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, -1);
static refreshDynamicInput = function() { static refreshDynamicInput = function() { #region
var _l = ds_list_create(); var _l = ds_list_create();
for( var i = 0; i < input_fix_len; i++ ) { for( var i = 0; i < input_fix_len; i++ ) {
@ -54,6 +54,7 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct
for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) { for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) {
if(inputs[| i].value_from) { if(inputs[| i].value_from) {
ds_list_add(_l, inputs[| i]); ds_list_add(_l, inputs[| i]);
inputs[| i].setVisible(true, true);
} else { } else {
delete inputs[| i]; delete inputs[| i];
} }
@ -67,18 +68,23 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct
inputs = _l; inputs = _l;
createNewInput(); createNewInput();
} } #endregion
static onValueFromUpdate = function(index) { static onValueFromUpdate = function(index) { #region
if(LOADING || APPENDING) return; if(LOADING || APPENDING) return;
refreshDynamicInput(); refreshDynamicInput();
} } #endregion
static update = function(frame = PROJECT.animator.current_frame) { static update = function(frame = PROJECT.animator.current_frame) { #region
var type = getInputData(0); var type = getInputData(0);
var res = 0; var res = 0;
if(ds_list_size(inputs) - 1 == input_fix_len) {
outputs[| 0].setValue(0);
return;
}
switch(type) { switch(type) {
case STAT_OPERATOR._sum : case STAT_OPERATOR._sum :
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i++ ) { for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i++ ) {
@ -171,9 +177,9 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} }
outputs[| 0].setValue(res); outputs[| 0].setValue(res);
} } #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text); draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text);
var str = ""; var str = "";
switch(getInputData(0)) { switch(getInputData(0)) {
@ -187,5 +193,5 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} } #endregion
} }

View file

@ -495,6 +495,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
array_depth = 0; array_depth = 0;
auto_connect = true; auto_connect = true;
setFrom_condition = -1; setFrom_condition = -1;
onSetFrom = noone;
onSetTo = noone;
#endregion #endregion
#region ---- animation ---- #region ---- animation ----
@ -533,6 +536,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
fullUpdate = false; fullUpdate = false;
attributes = {}; attributes = {};
node.inputs_data[index] = _value;
#endregion #endregion
#region ---- draw ---- #region ---- draw ----
@ -1743,6 +1748,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} }
UPDATE_RENDER_ORDER = true; UPDATE_RENDER_ORDER = true;
if(onSetFrom != noone) onSetFrom(_valueFrom);
if(_valueFrom.onSetTo != noone) _valueFrom.onSetTo(self);
return true; return true;
} #endregion } #endregion

View file

@ -1118,7 +1118,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
} }
if(target != noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input) if(key_mod_press(CTRL) && target != noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input)
_addInput = true; _addInput = true;
var _mmx = target != noone? target.x : _mx; var _mmx = target != noone? target.x : _mx;
@ -1637,7 +1637,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var txt = clipboard_get_text(); var txt = clipboard_get_text();
var _map = json_try_parse(txt, noone); var _map = json_try_parse(txt, noone);
if(_map != noone) { if(txt == "") return;
if(is_struct(_map)) {
ds_map_clear(APPEND_MAP); ds_map_clear(APPEND_MAP);
APPENDING = true; APPENDING = true;
CLONING = true; CLONING = true;

View file

@ -77,7 +77,8 @@ function Panel_Inspector() : PanelContent() constructor {
meta_display = [ meta_display = [
[ __txt("Project Settings"), false ], [ __txt("Project Settings"), false ],
[ __txt("Metadata"), true ], [ __txt("Metadata"), true ],
[ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ] [ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ],
[ __txt("Group Properties"), true ],
]; ];
#endregion #endregion
@ -162,6 +163,11 @@ function Panel_Inspector() : PanelContent() constructor {
var ry = y + top_bar_h; var ry = y + top_bar_h;
for( var i = 0, n = array_length(meta_display); i < n; i++ ) { for( var i = 0, n = array_length(meta_display); i < n; i++ ) {
if(i == 3) {
var context = PANEL_GRAPH.getCurrentContext();
if(context == noone) continue;
}
var _meta = meta_display[i]; var _meta = meta_display[i];
var _txt = array_safe_get(_meta, 0); var _txt = array_safe_get(_meta, 0);
var _b = array_safe_get(_meta, 2, noone); var _b = array_safe_get(_meta, 2, noone);
@ -194,122 +200,130 @@ function Panel_Inspector() : PanelContent() constructor {
continue; continue;
} }
if(i == 0) { switch(i) {
var _edt = PROJECT.attributeEditor; case 0 :
for( var j = 0; j < array_length(_edt); j++ ) { var _edt = PROJECT.attributeEditor;
var title = _edt[j][0]; for( var j = 0; j < array_length(_edt); j++ ) {
var param = _edt[j][1]; var title = _edt[j][0];
var editW = _edt[j][2]; var param = _edt[j][1];
var editW = _edt[j][2];
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner);
draw_text_add(ui(16), yy, __txt(title)); draw_text_add(ui(16), yy, __txt(title));
yy += line_get_height() + ui(6); yy += line_get_height() + ui(6);
hh += line_get_height() + ui(6); hh += line_get_height() + ui(6);
editW.setFocusHover(pFOCUS, _hover); editW.setFocusHover(pFOCUS, _hover);
if(pFOCUS) editW.register(contentPane); if(pFOCUS) editW.register(contentPane);
var wh = 0; var wh = 0;
var _data = PROJECT.attributes[$ param]; var _data = PROJECT.attributes[$ param];
wh = editW.drawParam(new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry)); wh = editW.drawParam(new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry));
yy += wh + ui(8); yy += wh + ui(8);
hh += wh + ui(8); hh += wh + ui(8);
} }
} else if(i == 1) { break;
for( var j = 0; j < array_length(meta.displays); j++ ) { case 1 :
var display = meta.displays[j]; for( var j = 0; j < array_length(meta.displays); j++ ) {
var display = meta.displays[j];
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner);
draw_text_add(ui(16), yy, __txt(display[0])); draw_text_add(ui(16), yy, __txt(display[0]));
yy += line_get_height() + ui(6); yy += line_get_height() + ui(6);
hh += line_get_height() + ui(6); hh += line_get_height() + ui(6);
meta_tb[j].setFocusHover(pFOCUS, _hover); meta_tb[j].setFocusHover(pFOCUS, _hover);
if(pFOCUS) meta_tb[j].register(contentPane); if(pFOCUS) meta_tb[j].register(contentPane);
var wh = 0; var wh = 0;
var _dataFunc = display[1]; var _dataFunc = display[1];
var _data = _dataFunc(meta); var _data = _dataFunc(meta);
switch(instanceof(meta_tb[j])) { switch(instanceof(meta_tb[j])) {
case "textArea" : case "textArea" :
wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m); wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m);
break; break;
case "textArrayBox" : case "textArrayBox" :
meta_tb[j].arraySet = current_meta.tags; meta_tb[j].arraySet = current_meta.tags;
wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry); wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry);
break; break;
}
yy += wh + ui(8);
hh += wh + ui(8);
}
break;
case 2 :
if(findPanel("Panel_Globalvar")) {
yy += ui(4);
hh += ui(4);
continue;
} }
yy += wh + ui(8); var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y);
hh += wh + ui(8); yy += gvh + ui(8);
} hh += gvh + ui(8);
} else if (i == 2) {
if(findPanel("Panel_Globalvar")) {
yy += ui(4);
hh += ui(4);
continue;
}
var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y); var bh = ui(36);
yy += gvh + ui(8); var bx = ui(16);
hh += gvh + ui(8); var by = yy;
var bbw = contentPane.surface_w - ui(24);
var bh = ui(36); if(var_editing) {
var bx = ui(16); var bw = bbw / 2 - ui(4);
var by = yy;
var bbw = contentPane.surface_w - ui(24);
if(var_editing) { if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
var bw = bbw / 2 - ui(4); var_editing = !var_editing;
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) var txt = __txt("Apply");
var_editing = !var_editing; var icon = THEME.accept;
var colr = COLORS._main_value_positive;
var txt = __txt("Apply"); draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon)
var icon = THEME.accept; var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var colr = COLORS._main_value_positive; var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) bx += bw + ui(4);
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
bx += bw + ui(4); if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
PROJECT.globalNode.createValue();
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) var txt = __txt("Add");
PROJECT.globalNode.createValue(); var icon = THEME.add;
var txt = __txt("Add"); draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon)
var icon = THEME.add; var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
} else {
var bw = bbw;
draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2)
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; var_editing = !var_editing;
var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
} else {
var bw = bbw;
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) var txt = __txt("Edit");
var_editing = !var_editing; var icon = THEME.gear;
var colr = COLORS._main_icon;
var txt = __txt("Edit"); draw_set_text(f_p0b, fa_left, fa_center, colr)
var icon = THEME.gear; var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2;
var colr = COLORS._main_icon; var byc = by + bh / 2;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
}
break;
case 3 :
var context = PANEL_GRAPH.getCurrentContext();
var _h = drawNodeProperties(yy, _m, context);
draw_set_text(f_p0b, fa_left, fa_center, colr) yy += _h;
var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; hh += _h;
var byc = by + bh / 2; break;
draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr);
draw_text_add(bxc + ui(48), byc, txt);
}
yy += bh + ui(16);
hh += bh + ui(16);
} }
yy += ui(8); yy += ui(8);
@ -319,23 +333,15 @@ function Panel_Inspector() : PanelContent() constructor {
return hh; return hh;
} #endregion } #endregion
contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region static drawNodeProperties = function(_y, _m, _inspecting = inspecting) { #region
var con_w = contentPane.surface_w - ui(4); var con_w = contentPane.surface_w - ui(4);
var _hover = pHOVER && contentPane.hover; var _hover = pHOVER && contentPane.hover;
draw_clear_alpha(COLORS.panel_bg_clear, 0); _inspecting.inspecting = true;
if(point_in_rectangle(_m[0], _m[1], 0, 0, con_w, content_h) && mouse_press(mb_left, pFOCUS))
prop_selecting = noone;
if(inspecting == noone) // metadata
return drawMeta(_y, _m);
inspecting.inspecting = true;
prop_hover = noone; prop_hover = noone;
var jun = noone; var jun = noone;
var amoIn = inspecting.input_display_list == -1? ds_list_size(inspecting.inputs) : array_length(inspecting.input_display_list); var amoIn = _inspecting.input_display_list == -1? ds_list_size(_inspecting.inputs) : array_length(_inspecting.input_display_list);
var amoOut = ds_list_size(inspecting.outputs); var amoOut = ds_list_size(_inspecting.outputs);
var amo = amoIn + 1 + amoOut; var amo = amoIn + 1 + amoOut;
var hh = ui(40); var hh = ui(40);
@ -357,8 +363,8 @@ function Panel_Inspector() : PanelContent() constructor {
var ww = max(ui(180), con_w / 3); var ww = max(ui(180), con_w / 3);
var wx0 = wx1 - ww; var wx0 = wx1 - ww;
for( var i = 0, n = array_length(inspecting.attributeEditors); i < n; i++ ) { for( var i = 0, n = array_length(_inspecting.attributeEditors); i < n; i++ ) {
var edt = inspecting.attributeEditors[i]; var edt = _inspecting.attributeEditors[i];
if(is_string(edt)) { if(is_string(edt)) {
var lby = yy + ui(12); var lby = yy + ui(12);
@ -410,11 +416,11 @@ function Panel_Inspector() : PanelContent() constructor {
var yy = hh + _y; var yy = hh + _y;
if(i < amoIn) { #region inputs if(i < amoIn) { #region inputs
if(inspecting.input_display_list == -1) { if(_inspecting.input_display_list == -1) {
jun = inspecting.inputs[| i]; jun = _inspecting.inputs[| i];
} else { } else {
if(i >= array_length(inspecting.input_display_list)) break; if(i >= array_length(_inspecting.input_display_list)) break;
var jun_disp = inspecting.input_display_list[i]; var jun_disp = _inspecting.input_display_list[i];
if(is_array(jun_disp)) { if(is_array(jun_disp)) {
var txt = __txt(jun_disp[0]); var txt = __txt(jun_disp[0]);
var coll = jun_disp[1] && filter_text == ""; var coll = jun_disp[1] && filter_text == "";
@ -425,7 +431,7 @@ function Panel_Inspector() : PanelContent() constructor {
if(mouse_press(mb_left, pFOCUS)) if(mouse_press(mb_left, pFOCUS))
jun_disp[@ 1] = !coll; jun_disp[@ 1] = !coll;
if(mouse_press(mb_right, pFOCUS)) if(mouse_press(mb_right, pFOCUS))
menuCall("inspector_group_menu",,, group_menu,, inspecting); menuCall("inspector_group_menu",,, group_menu,, _inspecting);
} else } else
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, con_w, ui(32), COLORS.panel_inspector_group_bg, 1); draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, con_w, ui(32), COLORS.panel_inspector_group_bg, 1);
@ -440,10 +446,10 @@ function Panel_Inspector() : PanelContent() constructor {
if(coll) { if(coll) {
var j = i + 1; var j = i + 1;
var _len = array_length(inspecting.input_display_list); var _len = array_length(_inspecting.input_display_list);
while(j < _len) { while(j < _len) {
var j_jun = inspecting.input_display_list[j]; var j_jun = _inspecting.input_display_list[j];
if(is_array(j_jun)) if(is_array(j_jun))
break; break;
j++; j++;
@ -461,7 +467,7 @@ function Panel_Inspector() : PanelContent() constructor {
hh += jun_disp.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8); hh += jun_disp.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8);
continue; continue;
} }
jun = inspecting.inputs[| inspecting.input_display_list[i]]; jun = _inspecting.inputs[| _inspecting.input_display_list[i]];
} }
#endregion #endregion
} else if(i == amoIn) { #region output label } else if(i == amoIn) { #region output label
@ -474,7 +480,7 @@ function Panel_Inspector() : PanelContent() constructor {
#endregion #endregion
} else { #region outputs } else { #region outputs
var outInd = i - amoIn - 1; var outInd = i - amoIn - 1;
jun = inspecting.outputs[| outInd]; jun = _inspecting.outputs[| outInd];
#endregion #endregion
} }
@ -654,6 +660,19 @@ function Panel_Inspector() : PanelContent() constructor {
#endregion #endregion
return hh; return hh;
} #endregion
contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region
var con_w = contentPane.surface_w - ui(4);
draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(point_in_rectangle(_m[0], _m[1], 0, 0, con_w, content_h) && mouse_press(mb_left, pFOCUS))
prop_selecting = noone;
if(inspecting == noone) // metadata
return drawMeta(_y, _m);
return drawNodeProperties(_y, _m);
}); #endregion }); #endregion
function propSelectCopy() { #region function propSelectCopy() { #region

View file

@ -155,6 +155,7 @@ function surface_get_width_safe(s, crop = true) {
if(is_struct(s)) { if(is_struct(s)) {
if(is_instanceof(s, dynaSurf)) return s.getWidth(); if(is_instanceof(s, dynaSurf)) return s.getWidth();
else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_width(s.getSurface()) : s.oriSurf_w; else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_width(s.getSurface()) : s.oriSurf_w;
else return 1;
} }
return surface_get_width(s); return surface_get_width(s);
@ -166,6 +167,7 @@ function surface_get_height_safe(s, crop = true) {
if(is_struct(s)) { if(is_struct(s)) {
if(is_instanceof(s, dynaSurf)) return s.getHeight(); if(is_instanceof(s, dynaSurf)) return s.getHeight();
else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_height(s.getSurface()) : s.oriSurf_h; else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_height(s.getSurface()) : s.oriSurf_h;
else return 1;
} }
return surface_get_height(s); return surface_get_height(s);

View file

@ -0,0 +1,10 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(vec3(1.), samp.a);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
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;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_fluid_bleach",
"parent": {
"name": "fluid",
"path": "folders/shader/fluid.yy",
},
"type": 1,
}