From aee11d6c820bdb044ff45e5d5c2c0f33b6e34a5e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 25 Dec 2024 10:52:25 +0700 Subject: [PATCH] [VFX Attract] Fix crash on update. --- PixelComposer.resource_order | 19 ++- .../__node_VFX_effector.gml | 131 +++++++++++------- .../node_VFX_accelerate.gml | 19 ++- scripts/node_VFX_attract/node_VFX_attract.gml | 37 +++-- scripts/node_VFX_destroy/node_VFX_destroy.gml | 5 +- .../node_VFX_oscillate/node_VFX_oscillate.gml | 27 ++-- scripts/node_VFX_repel/node_VFX_repel.gml | 24 ++-- .../node_VFX_turbulence.gml | 36 ++--- scripts/node_VFX_vortex/node_VFX_vortex.gml | 46 +++--- scripts/node_VFX_wind/node_VFX_wind.gml | 19 ++- scripts/node_registry/node_registry.gml | 6 +- 11 files changed, 200 insertions(+), 169 deletions(-) diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index d24bb675a..0f2326e26 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -128,8 +128,8 @@ {"name":"Shaders","order":14,"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",}, {"name":"strandSim","order":5,"path":"folders/nodes/data/simulation/strandSim.yy",}, {"name":"VFX","order":6,"path":"folders/nodes/data/simulation/VFX.yy",}, - {"name":"__legacy","order":12,"path":"folders/nodes/data/simulation/VFX/__legacy.yy",}, - {"name":"generators","order":1,"path":"folders/nodes/data/simulation/VFX/generators.yy",}, + {"name":"affector","order":1,"path":"folders/nodes/data/simulation/VFX/affector.yy",}, + {"name":"generators","order":2,"path":"folders/nodes/data/simulation/VFX/generators.yy",}, {"name":"tiler","order":18,"path":"folders/nodes/data/tiler.yy",}, {"name":"shaders","order":1,"path":"folders/nodes/data/tiler/shaders.yy",}, {"name":"sprites","order":2,"path":"folders/nodes/data/tiler/sprites.yy",}, @@ -429,7 +429,6 @@ {"name":"__node_template","order":20,"path":"scripts/__node_template/__node_template.yy",}, {"name":"__node_value_object","order":3,"path":"scripts/__node_value_object/__node_value_object.yy",}, {"name":"__node_value_processor","order":5,"path":"scripts/__node_value_processor/__node_value_processor.yy",}, - {"name":"__node_VFX_effector","order":8,"path":"scripts/__node_VFX_effector/__node_VFX_effector.yy",}, {"name":"__node","order":7,"path":"scripts/__node/__node.yy",}, {"name":"__panel_empty","order":7,"path":"scripts/__panel_empty/__panel_empty.yy",}, {"name":"__panel_linear_setting","order":8,"path":"scripts/__panel_linear_setting/__panel_linear_setting.yy",}, @@ -450,13 +449,13 @@ {"name":"__vec3","order":8,"path":"scripts/__vec3/__vec3.yy",}, {"name":"__vec4","order":9,"path":"scripts/__vec4/__vec4.yy",}, {"name":"__vector","order":10,"path":"scripts/__vector/__vector.yy",}, - {"name":"__VFX","order":2,"path":"scripts/__VFX/__VFX.yy",}, + {"name":"__VFX","order":3,"path":"scripts/__VFX/__VFX.yy",}, {"name":"_3d_rotation","order":6,"path":"scripts/_3d_rotation/_3d_rotation.yy",}, {"name":"_draw_defines","order":15,"path":"scripts/_draw_defines/_draw_defines.yy",}, {"name":"_line_drawer","order":18,"path":"scripts/_line_drawer/_line_drawer.yy",}, {"name":"_node_smoke","order":8,"path":"scripts/_node_smoke/_node_smoke.yy",}, {"name":"_node_strand_affector","order":10,"path":"scripts/_node_strand_affector/_node_strand_affector.yy",}, - {"name":"_node_VFX_spawner","order":3,"path":"scripts/_node_VFX_spawner/_node_VFX_spawner.yy",}, + {"name":"_node_VFX_spawner","order":4,"path":"scripts/_node_VFX_spawner/_node_VFX_spawner.yy",}, {"name":"_smokeSim_domain","order":16,"path":"scripts/_smokeSim_domain/_smokeSim_domain.yy",}, {"name":"action_loader","order":15,"path":"scripts/action_loader/action_loader.yy",}, {"name":"addon_function","order":3,"path":"scripts/addon_function/addon_function.yy",}, @@ -981,7 +980,7 @@ {"name":"node_palette_shrink","order":15,"path":"scripts/node_palette_shrink/node_palette_shrink.yy",}, {"name":"node_palette_sort","order":9,"path":"scripts/node_palette_sort/node_palette_sort.yy",}, {"name":"node_palette","order":4,"path":"scripts/node_palette/node_palette.yy",}, - {"name":"node_particle","order":11,"path":"scripts/node_particle/node_particle.yy",}, + {"name":"node_particle","order":10,"path":"scripts/node_particle/node_particle.yy",}, {"name":"node_path_3d","order":1,"path":"scripts/node_path_3d/node_path_3d.yy",}, {"name":"node_path_anchor","order":15,"path":"scripts/node_path_anchor/node_path_anchor.yy",}, {"name":"node_path_array","order":13,"path":"scripts/node_path_array/node_path_array.yy",}, @@ -1240,18 +1239,18 @@ {"name":"node_vector4","order":6,"path":"scripts/node_vector4/node_vector4.yy",}, {"name":"node_VFX_accelerate","order":1,"path":"scripts/node_VFX_accelerate/node_VFX_accelerate.yy",}, {"name":"node_VFX_attract","order":2,"path":"scripts/node_VFX_attract/node_VFX_attract.yy",}, - {"name":"node_VFX_boids","order":10,"path":"scripts/node_VFX_boids/node_VFX_boids.yy",}, + {"name":"node_VFX_boids","order":9,"path":"scripts/node_VFX_boids/node_VFX_boids.yy",}, {"name":"node_VFX_destroy","order":3,"path":"scripts/node_VFX_destroy/node_VFX_destroy.yy",}, {"name":"node_VFX_group_inline","order":5,"path":"scripts/node_VFX_group_inline/node_VFX_group_inline.yy",}, - {"name":"node_VFX_oscillate","order":9,"path":"scripts/node_VFX_oscillate/node_VFX_oscillate.yy",}, + {"name":"node_VFX_oscillate","order":8,"path":"scripts/node_VFX_oscillate/node_VFX_oscillate.yy",}, {"name":"node_VFX_override","order":6,"path":"scripts/node_VFX_override/node_VFX_override.yy",}, {"name":"node_VFX_renderer_output","order":1,"path":"scripts/node_VFX_renderer_output/node_VFX_renderer_output.yy",}, {"name":"node_VFX_renderer","order":7,"path":"scripts/node_VFX_renderer/node_VFX_renderer.yy",}, {"name":"node_VFX_repel","order":4,"path":"scripts/node_VFX_repel/node_VFX_repel.yy",}, - {"name":"node_VFX_spawner","order":9,"path":"scripts/node_VFX_spawner/node_VFX_spawner.yy",}, + {"name":"node_VFX_spawner","order":8,"path":"scripts/node_VFX_spawner/node_VFX_spawner.yy",}, {"name":"node_VFX_triangulate","order":1,"path":"scripts/node_VFX_triangulate/node_VFX_triangulate.yy",}, {"name":"node_VFX_turbulence","order":5,"path":"scripts/node_VFX_turbulence/node_VFX_turbulence.yy",}, - {"name":"node_VFX_variable","order":10,"path":"scripts/node_VFX_variable/node_VFX_variable.yy",}, + {"name":"node_VFX_variable","order":9,"path":"scripts/node_VFX_variable/node_VFX_variable.yy",}, {"name":"node_VFX_vortex","order":6,"path":"scripts/node_VFX_vortex/node_VFX_vortex.yy",}, {"name":"node_VFX_wind","order":7,"path":"scripts/node_VFX_wind/node_VFX_wind.yy",}, {"name":"node_vignette","order":18,"path":"scripts/node_vignette/node_vignette.yy",}, diff --git a/scripts/__node_VFX_effector/__node_VFX_effector.gml b/scripts/__node_VFX_effector/__node_VFX_effector.gml index cfd8faaea..b05ae2776 100644 --- a/scripts/__node_VFX_effector/__node_VFX_effector.gml +++ b/scripts/__node_VFX_effector/__node_VFX_effector.gml @@ -18,7 +18,6 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr node_draw_icon = s_node_vfx_accel; setDimension(96, 48); - seed = 1; newInput(0, nodeValue_Particle("Particles", self, -1 )) .setVisible(true, true); @@ -41,7 +40,7 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr newInput(6, nodeValue_Rotation_Range("Rotate particle", self, [ 0, 0 ] )) .rejectArray(); - newInput(7, nodeValue_Vec2_Range("Scale particle", self, [ 0, 0, 0, 0 ] , { linked : true })) + newInput(7, nodeValue_Vec2_Range("Scale particle", self, [ 0, 0, 0, 0 ], { linked : true })) .rejectArray(); newInput(8, nodeValueSeed(self)) @@ -58,6 +57,33 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr UPDATE_PART_FORWARD + ////////////////////////////////////////////////// + + falloff = CURVE_DEF_01; + fallDist = 0; + + area_x = 0; area_y = 0; + area_w = 0; area_h = 0; + area_t = 0; + + area_x0 = 0; area_x1 = 0; + area_y0 = 0; area_y1 = 0; + + strength = 0; + effectVec = [ 0, 0 ]; + effectVx = 0; effectVy = 0; + + rotate = [ 0, 0 ]; + rotateX = 0; rotateY = 0; + + scale = [ 0, 0, 0, 0 ]; + scaleX0 = 0; scaleX1 = 0; + scaleY0 = 0; scaleY1 = 0; + + seed = 1; + + ////////////////////////////////////////////////// + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { inputs[1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); @@ -100,76 +126,85 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr } } - function reset() { - resetSeed(); - } + function reset() { resetSeed(); } - static resetSeed = function() { - seed = getInputData(8); - } + static resetSeed = function() { seed = getInputData(8); } function onAffect(part, str) {} - function affect(part) { if(!part.active) return; - var _area = getInputData(1); - var _fall = getInputData(2); - var _fads = getInputData(3); - - var _area_x = _area[0]; - var _area_y = _area[1]; - var _area_w = _area[2]; - var _area_h = _area[3]; - var _area_t = _area[4]; - - var _area_x0 = _area_x - _area_w; - var _area_x1 = _area_x + _area_w; - var _area_y0 = _area_y - _area_h; - var _area_y1 = _area_y + _area_h; - - random_set_seed(part.seed + seed); - - var str = 0, in, _dst; + var _in, _dst; var pv = part.getPivot(); - if(_area_t == AREA_SHAPE.rectangle) { - in = point_in_rectangle(pv[0], pv[1], _area_x0, _area_y0, _area_x1, _area_y1) - _dst = min( distance_to_line(pv[0], pv[1], _area_x0, _area_y0, _area_x1, _area_y0), - distance_to_line(pv[0], pv[1], _area_x0, _area_y1, _area_x1, _area_y1), - distance_to_line(pv[0], pv[1], _area_x0, _area_y0, _area_x0, _area_y1), - distance_to_line(pv[0], pv[1], _area_x1, _area_y0, _area_x1, _area_y1)); - } else if(_area_t == AREA_SHAPE.elipse) { - var _dirr = point_direction(_area_x, _area_y, pv[0], pv[1]); - var _epx = _area_x + lengthdir_x(_area_w, _dirr); - var _epy = _area_y + lengthdir_y(_area_h, _dirr); + if(area_t == AREA_SHAPE.rectangle) { + _in = point_in_rectangle(pv[0], pv[1], area_x0, area_y0, area_x1, area_y1) + _dst = min( distance_to_line(pv[0], pv[1], area_x0, area_y0, area_x1, area_y0), + distance_to_line(pv[0], pv[1], area_x0, area_y1, area_x1, area_y1), + distance_to_line(pv[0], pv[1], area_x0, area_y0, area_x0, area_y1), + distance_to_line(pv[0], pv[1], area_x1, area_y0, area_x1, area_y1)); + + } else if(area_t == AREA_SHAPE.elipse) { + var _dirr = point_direction(area_x, area_y, pv[0], pv[1]); + var _epx = area_x + lengthdir_x(area_w, _dirr); + var _epy = area_y + lengthdir_y(area_h, _dirr); - in = point_distance(_area_x, _area_y, pv[0], pv[1]) < point_distance(_area_x, _area_y, _epx, _epy); + _in = point_distance(area_x, area_y, pv[0], pv[1]) < point_distance(area_x, area_y, _epx, _epy); _dst = point_distance(pv[0], pv[1], _epx, _epy); } - if(_dst <= _fads) { - var inf = in? 0.5 + _dst / _fads : 0.5 - _dst / _fads; - str = eval_curve_x(_fall, clamp(inf, 0., 1.)); - } else if(in) - str = 1; - - if(str == 0) return; + var str = bool(_in); + if(_dst <= fallDist) { + var inf = _in? 0.5 + _dst / fallDist : 0.5 - _dst / fallDist; + str = eval_curve_x(falloff, clamp(inf, 0., 1.)); + } + if(str <= 0) return; + random_set_seed(part.seed + seed); onAffect(part, str); } static update = function(frame = CURRENT_FRAME) { var val = getInputData(0); outputs[0].setValue(val); + if(val == -1) return; + var _area = getInputData(1); + falloff = getInputData(2); + fallDist = getInputData(3); + + effectVec = getInputData(4); + strength = getInputData(5); + rotate = getInputData(6); + scale = getInputData(7); + + area_x = _area[0]; + area_y = _area[1]; + area_w = _area[2]; + area_h = _area[3]; + area_t = _area[4]; + + area_x0 = area_x - area_w; + area_x1 = area_x + area_w; + area_y0 = area_y - area_h; + area_y1 = area_y + area_h; + + effectVx = effectVec[0]; effectVy = effectVec[1]; + rotateX = rotate[0]; rotateY = rotate[1]; + scaleX0 = scale[0]; scaleX1 = scale[1]; + scaleY0 = scale[2]; scaleY1 = scale[3]; + + onVFXUpdate(frame); + + //////////////////////////////////////////////////////////////// + if(!is_array(val) || array_length(val) == 0) return; if(!is_array(val[0])) val = [ val ]; + for( var i = 0, n = array_length(val); i < n; i++ ) - for( var j = 0; j < array_length(val[i]); j++ ) { + for( var j = 0; j < array_length(val[i]); j++ ) affect(val[i][j]); - } var jun = outputs[0]; for(var j = 0; j < array_length(jun.value_to); j++) { @@ -178,6 +213,8 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr } } + static onVFXUpdate = function(frame = CURRENT_FRAME) {} + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(node_draw_icon, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); diff --git a/scripts/node_VFX_accelerate/node_VFX_accelerate.gml b/scripts/node_VFX_accelerate/node_VFX_accelerate.gml index a192712f5..0a005048e 100644 --- a/scripts/node_VFX_accelerate/node_VFX_accelerate.gml +++ b/scripts/node_VFX_accelerate/node_VFX_accelerate.gml @@ -3,22 +3,21 @@ function Node_VFX_Accelerate(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, node_draw_icon = s_node_vfx_accel; function onAffect(part, str) { - var _vect = getInputData(4); - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); - part.speedx = part.speedx + _vect[0] * str * _sten; - part.speedy = part.speedy + _vect[1] * str * _sten; + part.speedx = part.speedx + effectVx * str * strength; + part.speedy = part.speedy + effectVy * str * strength; part.rot += _rot * str; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; + if(scx_s < 0) part.scx = lerp_linear(part.scx, 0, abs(scx_s)); else part.scx += sign(part.scx) * scx_s; + if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s)); else part.scy += sign(part.scy) * scy_s; } diff --git a/scripts/node_VFX_attract/node_VFX_attract.gml b/scripts/node_VFX_attract/node_VFX_attract.gml index 0b2e8a0e7..59e263103 100644 --- a/scripts/node_VFX_attract/node_VFX_attract.gml +++ b/scripts/node_VFX_attract/node_VFX_attract.gml @@ -8,35 +8,34 @@ function Node_VFX_Attract(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _g array_push(input_display_list, effector_input_length + 0); + destroyMiddle = false; + + static onVFXUpdate = function(frame = CURRENT_FRAME) { + destroyMiddle = getInputData(effector_input_length + 0); + } + function onAffect(part, str) { - var _area = getInputData(1); - var _area_x = _area[0]; - var _area_y = _area[1]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; - - var _dest = getInputData(effector_input_length + 2); - - var pv = part.getPivot(); - var dirr = point_direction(pv[0], pv[1], _area_x, _area_y); - part.x = part.x + lengthdir_x(_sten * str, dirr); - part.y = part.y + lengthdir_y(_sten * str, dirr); - + var pv = part.getPivot(); + var dirr = point_direction(pv[0], pv[1], area_x, area_y); + part.x = part.x + lengthdir_x(strength * str, dirr); + part.y = part.y + lengthdir_y(strength * str, dirr); part.rot += _rot * str; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; if(scx_s < 0) part.sc_sx = lerp_linear(part.sc_sx, 0, abs(scx_s)); else part.sc_sx += sign(part.sc_sx) * scx_s; + if(scy_s < 0) part.sc_sy = lerp_linear(part.sc_sy, 0, abs(scy_s)); else part.sc_sy += sign(part.sc_sy) * scy_s; - if(_dest && point_distance(part.x, part.y, _area_x, _area_y) <= _sten) + if(!destroyMiddle) return; + if(point_distance(part.x, part.y, area_x, area_y) <= strength) part.kill(); } } \ No newline at end of file diff --git a/scripts/node_VFX_destroy/node_VFX_destroy.gml b/scripts/node_VFX_destroy/node_VFX_destroy.gml index 2a1168e21..3f0424a28 100644 --- a/scripts/node_VFX_destroy/node_VFX_destroy.gml +++ b/scripts/node_VFX_destroy/node_VFX_destroy.gml @@ -7,9 +7,6 @@ function Node_VFX_Destroy(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _g inputs[7].setVisible(false, false); function onAffect(part, str) { - var _sten = getInputData(5); - - if(random(1) < str * _sten) - part.kill(); + if(random(1) < str * strength) part.kill(); } } \ No newline at end of file diff --git a/scripts/node_VFX_oscillate/node_VFX_oscillate.gml b/scripts/node_VFX_oscillate/node_VFX_oscillate.gml index 704cf5eb3..4ea778136 100644 --- a/scripts/node_VFX_oscillate/node_VFX_oscillate.gml +++ b/scripts/node_VFX_oscillate/node_VFX_oscillate.gml @@ -14,23 +14,24 @@ function Node_VFX_Oscillate(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, array_push(input_display_list, effector_input_length + 0, effector_input_length + 1, effector_input_length + 2); + amplitude = 0; + frequency = 0; + mulpSpd = false; + + static onVFXUpdate = function(frame = CURRENT_FRAME) { + amplitude = getInputData(effector_input_length + 0); + frequency = getInputData(effector_input_length + 1); + mulpSpd = getInputData(effector_input_length + 2); + } + function onAffect(part, str) { - var _sten = getInputData(5); - - var _amp = getInputData(effector_input_length + 0); - var _fre = getInputData(effector_input_length + 1); - var _mls = getInputData(effector_input_length + 2); - var _lif = part.life; var _dir = part.spVec[1] + 90; - var _aamp = sin(part.seed + _lif * _fre) * _amp; - if(_mls) _aamp *= part.spVec[0]; + var _aamp = sin(part.seed + _lif * frequency) * amplitude; + if(mulpSpd) _aamp *= part.spVec[0]; - var _dx = lengthdir_x(_aamp, _dir); - var _dy = lengthdir_y(_aamp, _dir); - - part.drawx += _dx; - part.drawy += _dy; + part.drawx += lengthdir_x(_aamp, _dir); + part.drawy += lengthdir_y(_aamp, _dir); } } \ No newline at end of file diff --git a/scripts/node_VFX_repel/node_VFX_repel.gml b/scripts/node_VFX_repel/node_VFX_repel.gml index a58c508fd..5c1988df1 100644 --- a/scripts/node_VFX_repel/node_VFX_repel.gml +++ b/scripts/node_VFX_repel/node_VFX_repel.gml @@ -5,27 +5,23 @@ function Node_VFX_Repel(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _gro inputs[4].setVisible(false, false); function onAffect(part, str) { - var _area = getInputData(1); - var _area_x = _area[0]; - var _area_y = _area[1]; - - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); var pv = part.getPivot(); - var dirr = point_direction(_area_x, _area_y, pv[0], pv[1]); - part.x = part.x + lengthdir_x(_sten * str, dirr); - part.y = part.y + lengthdir_y(_sten * str, dirr); + var dirr = point_direction(area_x, area_y, pv[0], pv[1]); + part.x = part.x + lengthdir_x(strength * str, dirr); + part.y = part.y + lengthdir_y(strength * str, dirr); part.rot += _rot * str; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; + if(scx_s < 0) part.scx = lerp_linear(part.scx, 0, abs(scx_s)); else part.scx += sign(part.scx) * scx_s; + if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s)); else part.scy += sign(part.scy) * scy_s; } diff --git a/scripts/node_VFX_turbulence/node_VFX_turbulence.gml b/scripts/node_VFX_turbulence/node_VFX_turbulence.gml index b9eca3c16..0b5749ff3 100644 --- a/scripts/node_VFX_turbulence/node_VFX_turbulence.gml +++ b/scripts/node_VFX_turbulence/node_VFX_turbulence.gml @@ -10,30 +10,32 @@ function Node_VFX_Turbulence(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, array_push(input_display_list, effector_input_length + 0, effector_input_length + 1); + tscale = 1; + conspd = false; + + static onVFXUpdate = function(frame = CURRENT_FRAME) { + tscale = getInputData(effector_input_length + 0); + conspd = getInputData(effector_input_length + 1); + } + function onAffect(part, str) { - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); - var pv = part.getPivot(); + var pv = part.getPivot(); + var _seed = conspd? seed : part.seed; - var t_scale = getInputData(effector_input_length + 0); - var con_sed = getInputData(effector_input_length + 1); + var perx = (perlin_noise(pv[0] / tscale, pv[1] / tscale, 1, _seed) - 0.5) * 2; + var pery = (perlin_noise(pv[0] / tscale, pv[1] / tscale, 1, _seed + 100) - 0.5) * 2; - var _seed = con_sed? seed : part.seed; - - var perx = (perlin_noise(pv[0] / t_scale, pv[1] / t_scale, 1, _seed) - 0.5) * 2; - var pery = (perlin_noise(pv[0] / t_scale, pv[1] / t_scale, 1, _seed + 100) - 0.5) * 2; - - part.x += perx * str * _sten; - part.y += pery * str * _sten; + part.x += perx * str * strength; + part.y += pery * str * strength; part.rot += _rot * perx; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; if(scx_s < 0) part.scx = lerp_linear(part.scx, 0, abs(scx_s)); else if(scx_s > 0) part.scx += sign(part.scx) * scx_s; diff --git a/scripts/node_VFX_vortex/node_VFX_vortex.gml b/scripts/node_VFX_vortex/node_VFX_vortex.gml index 780563e32..ee5accae1 100644 --- a/scripts/node_VFX_vortex/node_VFX_vortex.gml +++ b/scripts/node_VFX_vortex/node_VFX_vortex.gml @@ -12,41 +12,43 @@ function Node_VFX_Vortex(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _gr array_push(input_display_list, effector_input_length + 0, effector_input_length + 1, effector_input_length + 2); + attraction = 0; + clockwise = 0; + destroydis = false; + + static onVFXUpdate = function(frame = CURRENT_FRAME) { + attraction = getInputData(effector_input_length + 0); + clockwise = getInputData(effector_input_length + 1); + destroydis = getInputData(effector_input_length + 2); + } + function onAffect(part, str) { - var _area = getInputData(1); - var _area_x = _area[0]; - var _area_y = _area[1]; - - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _attr = getInputData(effector_input_length + 0); - var _clkw = getInputData(effector_input_length + 1); - var _dest = getInputData(effector_input_length + 2); - - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); var pv = part.getPivot(); - var dirr = point_direction(_area_x, _area_y, pv[0], pv[1]) + (_clkw? 90 : -90); - part.x += lengthdir_x(_sten * str, dirr); - part.y += lengthdir_y(_sten * str, dirr); + var dirr = point_direction(area_x, area_y, pv[0], pv[1]) + (clockwise? 90 : -90); + part.x += lengthdir_x(strength * str, dirr); + part.y += lengthdir_y(strength * str, dirr); - var dirr = point_direction(pv[0], pv[1], _area_x, _area_y); - part.x += lengthdir_x(_attr * str, dirr); - part.y += lengthdir_y(_attr * str, dirr); + var dirr = point_direction(pv[0], pv[1], area_x, area_y); + part.x += lengthdir_x(attraction * str, dirr); + part.y += lengthdir_y(attraction * str, dirr); part.rot += _rot * str; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; + if(scx_s < 0) part.scx = lerp_linear(part.scx, 0, abs(scx_s)); else part.scx += sign(part.scx) * scx_s; + if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s)); else part.scy += sign(part.scy) * scy_s; - if(_dest && point_distance(pv[0], pv[1], _area_x, _area_y) <= 1) + if(destroydis && point_distance(pv[0], pv[1], area_x, area_y) <= 1) part.kill(); } } \ No newline at end of file diff --git a/scripts/node_VFX_wind/node_VFX_wind.gml b/scripts/node_VFX_wind/node_VFX_wind.gml index 1d7c04773..0bd59d723 100644 --- a/scripts/node_VFX_wind/node_VFX_wind.gml +++ b/scripts/node_VFX_wind/node_VFX_wind.gml @@ -3,22 +3,21 @@ function Node_VFX_Wind(_x, _y, _group = noone) : Node_VFX_effector(_x, _y, _grou node_draw_icon = s_node_vfx_wind; function onAffect(part, str) { - var _vect = getInputData(4); - var _sten = getInputData(5); - var _rot_range = getInputData(6); - var _sca_range = getInputData(7); - var _rot = random_range(_rot_range[0], _rot_range[1]); - var _sca = [ random_range(_sca_range[0], _sca_range[1]), random_range(_sca_range[2], _sca_range[3]) ]; + var _rot = random_range(rotateX, rotateY); + var _scX = random_range(scaleX0, scaleX1); + var _scY = random_range(scaleY0, scaleY1); - part.x = part.x + _vect[0] * _sten * str; - part.y = part.y + _vect[1] * _sten * str; + part.x = part.x + effectVx * strength * str; + part.y = part.y + effectVy * strength * str; part.rot += _rot * str; - var scx_s = _sca[0] * str; - var scy_s = _sca[1] * str; + var scx_s = _scX * str; + var scy_s = _scY * str; + if(scx_s < 0) part.scx = lerp_linear(part.scx, 0, abs(scx_s)); else part.scx += sign(part.scx) * scx_s; + if(scy_s < 0) part.scy = lerp_linear(part.scy, 0, abs(scy_s)); else part.scy += sign(part.scy) * scy_s; } diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 5810913ae..b0a2ee036 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -414,7 +414,7 @@ function __initNodes() { addNodeObject(vfx, "VFX Trail", s_node_vfx_trail, "Node_VFX_Trail", [1, Node_VFX_Trail],, "Generate path from particle movement.").hideRecent().setVersion(11560); addNodeObject(vfx, "VFX Triangulate", s_node_vfx_triangulate, "Node_VFX_Triangulate", [1, Node_VFX_Triangulate],, "Render line between particles.").hideRecent().setVersion(11670); - ds_list_add(vfx, "Instance control"); + ds_list_add(vfx, "Variables"); addNodeObject(vfx, "VFX Variable", s_node_vfx_variable, "Node_VFX_Variable", [1, Node_VFX_Variable],, "Extract variable from particle objects.").hideRecent().setVersion(1120); addNodeObject(vfx, "VFX Override", s_node_vfx_override, "Node_VFX_Override", [1, Node_VFX_Override],, "Replace particle variable with a new one.").hideRecent().setVersion(1120); #endregion @@ -434,9 +434,9 @@ function __initNodes() { addNodeObject(rigidSim, "Wall", s_node_rigidSim_wall, "Node_Rigid_Wall", [1, Node_Rigid_Wall]).hideRecent().setVersion(11680); addNodeObject(rigidSim, "Render", s_node_rigidSim_renderer, "Node_Rigid_Render", [1, Node_Rigid_Render],, "Render rigidbody object to surface.").hideRecent().setVersion(1110); addNodeObject(rigidSim, "Apply Force", s_node_rigidSim_force, "Node_Rigid_Force_Apply", [1, Node_Rigid_Force_Apply],, "Apply force to objects.").hideRecent().setVersion(1110); + addNodeObject(rigidSim, "Activate Physics", s_node_rigidSim_activate, "Node_Rigid_Activate", [1, Node_Rigid_Activate],, "Enable or disable rigidbody object.").hideRecent().setVersion(1110); - ds_list_add(rigidSim, "Instance control"); - addNodeObject(rigidSim, "Activate Physics", s_node_rigidSim_activate, "Node_Rigid_Activate", [1, Node_Rigid_Activate],, "Enable or disable rigidbody object.").hideRecent().setVersion(1110); + ds_list_add(rigidSim, "Variables"); addNodeObject(rigidSim, "Rigidbody Variable", s_node_rigid_variable, "Node_Rigid_Variable", [1, Node_Rigid_Variable],, "Extract veriable from rigidbody object.").hideRecent().setVersion(1120); addNodeObject(rigidSim, "Rigidbody Override", s_node_rigid_override, "Node_Rigid_Override", [1, Node_Rigid_Override],, "Replace rigidbody object variable with a new one.").hideRecent().setVersion(1120); #endregion