FluidSim destroy

This commit is contained in:
Tanasart 2024-03-21 19:57:44 +07:00
parent 258a8bef27
commit 0a7802759f
24 changed files with 337 additions and 91 deletions

View file

@ -584,6 +584,7 @@
{"name":"sh_fd_advect_material_rgba_16_glsl","order":4,"path":"shaders/sh_fd_advect_material_rgba_16_glsl/sh_fd_advect_material_rgba_16_glsl.yy",}, {"name":"sh_fd_advect_material_rgba_16_glsl","order":4,"path":"shaders/sh_fd_advect_material_rgba_16_glsl/sh_fd_advect_material_rgba_16_glsl.yy",},
{"name":"node_padding","order":9,"path":"scripts/node_padding/node_padding.yy",}, {"name":"node_padding","order":9,"path":"scripts/node_padding/node_padding.yy",},
{"name":"node_VFX_group","order":3,"path":"scripts/node_VFX_group/node_VFX_group.yy",}, {"name":"node_VFX_group","order":3,"path":"scripts/node_VFX_group/node_VFX_group.yy",},
{"name":"node_FLIP_destroy","order":11,"path":"scripts/node_FLIP_destroy/node_FLIP_destroy.yy",},
{"name":"libborderless","order":1,"path":"extensions/libborderless/libborderless.yy",}, {"name":"libborderless","order":1,"path":"extensions/libborderless/libborderless.yy",},
{"name":"node_dynasurf_in","order":4,"path":"scripts/node_dynasurf_in/node_dynasurf_in.yy",}, {"name":"node_dynasurf_in","order":4,"path":"scripts/node_dynasurf_in/node_dynasurf_in.yy",},
{"name":"s_node_vfx_attract","order":8,"path":"sprites/s_node_vfx_attract/s_node_vfx_attract.yy",}, {"name":"s_node_vfx_attract","order":8,"path":"sprites/s_node_vfx_attract/s_node_vfx_attract.yy",},
@ -1981,6 +1982,7 @@
{"name":"sh_solid","order":5,"path":"shaders/sh_solid/sh_solid.yy",}, {"name":"sh_solid","order":5,"path":"shaders/sh_solid/sh_solid.yy",},
{"name":"panel_animation_scaler","order":1,"path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",}, {"name":"panel_animation_scaler","order":1,"path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",},
{"name":"wav_file_object","order":2,"path":"scripts/wav_file_object/wav_file_object.yy",}, {"name":"wav_file_object","order":2,"path":"scripts/wav_file_object/wav_file_object.yy",},
{"name":"s_node_fluidSim_destroy_fluid","order":14,"path":"sprites/s_node_fluidSim_destroy_fluid/s_node_fluidSim_destroy_fluid.yy",},
{"name":"node_pb_fx_intersect","order":5,"path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",}, {"name":"node_pb_fx_intersect","order":5,"path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",},
{"name":"fd_rectangle_get_material_time_step","order":13,"path":"scripts/fd_rectangle_get_material_time_step/fd_rectangle_get_material_time_step.yy",}, {"name":"fd_rectangle_get_material_time_step","order":13,"path":"scripts/fd_rectangle_get_material_time_step/fd_rectangle_get_material_time_step.yy",},
{"name":"node_vector3","order":17,"path":"scripts/node_vector3/node_vector3.yy",}, {"name":"node_vector3","order":17,"path":"scripts/node_vector3/node_vector3.yy",},

View file

@ -816,6 +816,7 @@
{"id":{"name":"panel_inspector","path":"scripts/panel_inspector/panel_inspector.yy",},}, {"id":{"name":"panel_inspector","path":"scripts/panel_inspector/panel_inspector.yy",},},
{"id":{"name":"node_padding","path":"scripts/node_padding/node_padding.yy",},}, {"id":{"name":"node_padding","path":"scripts/node_padding/node_padding.yy",},},
{"id":{"name":"node_VFX_group","path":"scripts/node_VFX_group/node_VFX_group.yy",},}, {"id":{"name":"node_VFX_group","path":"scripts/node_VFX_group/node_VFX_group.yy",},},
{"id":{"name":"node_FLIP_destroy","path":"scripts/node_FLIP_destroy/node_FLIP_destroy.yy",},},
{"id":{"name":"libborderless","path":"extensions/libborderless/libborderless.yy",},}, {"id":{"name":"libborderless","path":"extensions/libborderless/libborderless.yy",},},
{"id":{"name":"node_dynasurf_in","path":"scripts/node_dynasurf_in/node_dynasurf_in.yy",},}, {"id":{"name":"node_dynasurf_in","path":"scripts/node_dynasurf_in/node_dynasurf_in.yy",},},
{"id":{"name":"s_node_vfx_attract","path":"sprites/s_node_vfx_attract/s_node_vfx_attract.yy",},}, {"id":{"name":"s_node_vfx_attract","path":"sprites/s_node_vfx_attract/s_node_vfx_attract.yy",},},
@ -2410,6 +2411,7 @@
{"id":{"name":"sh_solid","path":"shaders/sh_solid/sh_solid.yy",},}, {"id":{"name":"sh_solid","path":"shaders/sh_solid/sh_solid.yy",},},
{"id":{"name":"panel_animation_scaler","path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",},}, {"id":{"name":"panel_animation_scaler","path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",},},
{"id":{"name":"wav_file_object","path":"scripts/wav_file_object/wav_file_object.yy",},}, {"id":{"name":"wav_file_object","path":"scripts/wav_file_object/wav_file_object.yy",},},
{"id":{"name":"s_node_fluidSim_destroy_fluid","path":"sprites/s_node_fluidSim_destroy_fluid/s_node_fluidSim_destroy_fluid.yy",},},
{"id":{"name":"node_pb_fx_intersect","path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",},}, {"id":{"name":"node_pb_fx_intersect","path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",},},
{"id":{"name":"timer_function","path":"scripts/timer_function/timer_function.yy",},}, {"id":{"name":"timer_function","path":"scripts/timer_function/timer_function.yy",},},
{"id":{"name":"fd_rectangle_get_material_time_step","path":"scripts/fd_rectangle_get_material_time_step/fd_rectangle_get_material_time_step.yy",},}, {"id":{"name":"fd_rectangle_get_material_time_step","path":"scripts/fd_rectangle_get_material_time_step/fd_rectangle_get_material_time_step.yy",},},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -34,7 +34,7 @@
function init(width, height, particleSize, density, maxParticles) { #region domain init function init(width, height, particleSize, density, maxParticles) { #region domain init
particlePos = array_create(maxParticles * 2); particlePos = array_create(maxParticles * 2);
particleHist = array_create(maxParticles * 2); particleHist = array_create(maxParticles * 2 * TOTAL_FRAMES);
particleLife = array_create(maxParticles); particleLife = array_create(maxParticles);
obstracles = []; obstracles = [];
numParticles = 0; numParticles = 0;
@ -73,7 +73,7 @@ function update() { #region
FLIP_setQuality( domain, iteration, numPressureIters, numParticleIters); FLIP_setQuality( domain, iteration, numPressureIters, numParticleIters);
FLIP_setGravity( domain, g); FLIP_setGravity( domain, g);
FLIP_setViscosity( domain, viscosity); FLIP_setViscosity( domain, viscosity);
FLIP_setFriction( domain, power(1 - friction, 0.025)); FLIP_setFriction( domain, friction);
FLIP_setFlipRatio( domain, flipRatio); FLIP_setFlipRatio( domain, flipRatio);
FLIP_setVelocityDamping( domain, velocityDamping); FLIP_setVelocityDamping( domain, velocityDamping);
FLIP_setOverRelaxation( domain, overRelaxation); FLIP_setOverRelaxation( domain, overRelaxation);
@ -94,16 +94,28 @@ function step() { #region
//FLIP_simulate_solveIncompressibility(domain); //FLIP_simulate_solveIncompressibility(domain);
//FLIP_simulate_transferVelocities(domain, 0); //FLIP_simulate_transferVelocities(domain, 0);
} }
} else } else {
FLIP_simulate(domain, dt); FLIP_simulate(domain, dt);
//FLIP_setTimeStep(domain, dt);
//repeat(iteration) {
// FLIP_simulate_integrateParticles(domain);
// FLIP_simulate_pushParticlesApart(domain);
// FLIP_simulate_handleParticleCollisions(domain);
// FLIP_simulate_transferVelocities(domain, 1);
// FLIP_simulate_updateParticleDensity(domain);
// FLIP_simulate_solveIncompressibility(domain);
// FLIP_simulate_transferVelocities(domain, 0);
//}
}
FLIP_setParticleBuffer(domain, aPosBuff, aLifeBuff); FLIP_setParticleBuffer(domain, aPosBuff, aLifeBuff);
buffer_seek(particlePosBuff, buffer_seek_start, 0); buffer_seek(particlePosBuff, buffer_seek_start, 0);
buffer_seek(particleLifeBuff, buffer_seek_start, 0); buffer_seek(particleLifeBuff, buffer_seek_start, 0);
for(var i = 0; i < maxParticles * 2; i++) { for(var i = 0; i < maxParticles * 2; i++) {
particleHist[i] = particlePos[i]; particleHist[maxParticles * 2 * CURRENT_FRAME + i] = particlePos[i];
particlePos[i] = buffer_read(particlePosBuff, buffer_f64); particlePos[i] = buffer_read(particlePosBuff, buffer_f64);
} }

View file

@ -6,7 +6,7 @@ function draw_line_feedback(x0, y0, x1, y1, th, c1, c0, _s) { #region
var cr = 12 / 2 * _s; var cr = 12 / 2 * _s;
var cx = max(x0, x1); var cx = max(x0, x1);
var cy = y0 - cr; var cy = (cx == x0? y0 : y1) - cr;
var ox, oy, nx, ny; var ox, oy, nx, ny;
draw_set_color(c0); draw_set_color(c0);
@ -24,7 +24,7 @@ function draw_line_feedback(x0, y0, x1, y1, th, c1, c0, _s) { #region
} }
var cx = min(x0, x1); var cx = min(x0, x1);
var cy = y1 - cr; var cy = (cx == x0? y0 : y1) - cr;
draw_set_color(c1); draw_set_color(c1);

View file

@ -28,10 +28,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION; globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11600; LATEST_VERSION = 11600;
VERSION = 11670; VERSION = 11680;
SAVE_VERSION = 11670; SAVE_VERSION = 11680;
VERSION_STRING = "1.16.7"; VERSION_STRING = "1.16.8";
BUILD_NUMBER = 11670; BUILD_NUMBER = 11680;
globalvar APPEND_MAP; globalvar APPEND_MAP;
APPEND_MAP = ds_map_create(); APPEND_MAP = ds_map_create();

View file

@ -15,7 +15,7 @@ function FLIP_Obstracle() constructor {
} }
function Node_FLIP_Apply_Force(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_FLIP_Apply_Force(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Apply Force"; name = "Add Collider";
color = COLORS.node_blend_fluid; color = COLORS.node_blend_fluid;
icon = THEME.fluid_sim; icon = THEME.fluid_sim;
w = 96; w = 96;
@ -27,7 +27,8 @@ function Node_FLIP_Apply_Force(_x, _y, _group = noone) : Node(_x, _y, _group) co
.setVisible(true, true); .setVisible(true, true);
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(); });
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 ) inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 )
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] }); .setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
@ -51,6 +52,13 @@ function Node_FLIP_Apply_Force(_x, _y, _group = noone) : Node(_x, _y, _group) co
index = 0; index = 0;
toReset = true; toReset = true;
static getDimension = function() {
var domain = getInputData(0);
if(!instance_exists(domain)) return [ 1, 1 ];
return [ domain.width, domain.height ];
}
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _posit = getInputData(1); var _posit = getInputData(1);
var _rad = getInputData(2); var _rad = getInputData(2);

View file

@ -11,7 +11,8 @@ function Node_FLIP_Apply_Velocity(_x, _y, _group = noone) : Node(_x, _y, _group)
.setVisible(true, true); .setVisible(true, true);
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(); });
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 ) inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 )
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] }); .setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
@ -31,6 +32,13 @@ function Node_FLIP_Apply_Velocity(_x, _y, _group = noone) : Node(_x, _y, _group)
outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone ); outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone );
static getDimension = function() {
var domain = getInputData(0);
if(!instance_exists(domain)) return [ 1, 1 ];
return [ domain.width, domain.height ];
}
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _posit = getInputData(1); var _posit = getInputData(1);
var _rad = getInputData(2); var _rad = getInputData(2);
@ -57,8 +65,8 @@ function Node_FLIP_Apply_Velocity(_x, _y, _group = noone) : Node(_x, _y, _group)
draw_line_width2(_px, _py, _vx, _vy, 6, 2); draw_line_width2(_px, _py, _vx, _vy, 6, 2);
draw_set_alpha(1); draw_set_alpha(1);
if(inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false; if(inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny)) { hover = false; active = false; }
if(inputs[| 3].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny)) active = false; //if(inputs[| 3].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny)) { hover = false; active = false; }
} #endregion } #endregion

View file

@ -0,0 +1,79 @@
function Node_FLIP_Destroy(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Destroy Fluid";
color = COLORS.node_blend_fluid;
icon = THEME.fluid_sim;
w = 96;
min_h = 96;
manual_ungroupable = false;
inputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.fdomain, noone )
.setVisible(true, true);
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(); });
inputs[| 2] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ new scrollItem("Circle", s_node_shape_type, 1), new scrollItem("Rectangle", s_node_shape_type, 0), ]);
inputs[| 3] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 )
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
inputs[| 4] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ] )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 5] = nodeValue("Ratio", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 )
.setDisplay(VALUE_DISPLAY.slider);
outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone );
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _pos = getInputData(1);
var _shp = getInputData(2);
var _rad = getInputData(3);
var _siz = getInputData(4);
var _px = _x + _pos[0] * _s;
var _py = _y + _pos[1] * _s;
var _r = _rad * _s;
var _w = _siz[0] * _s;
var _h = _siz[1] * _s;
draw_set_color(COLORS._main_accent);
if(_shp == 0) draw_circle(_px, _py, _r, true);
else if(_shp == 1) draw_rectangle(_px - _w, _py - _h, _px + _w, _py + _h, true);
if(inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
} #endregion
static step = function() { #region
var _shp = getInputData(2);
inputs[| 3].setVisible(_shp == 0);
inputs[| 4].setVisible(_shp == 1);
} #endregion
static update = function() { #region
var domain = getInputData(0);
if(!instance_exists(domain)) return;
outputs[| 0].setValue(domain);
var _pos = getInputData(1);
var _shp = getInputData(2);
var _rad = getInputData(3);
var _siz = getInputData(4);
var _rat = getInputData(5);
if(_shp == 0) FLIP_deleteParticle_circle(domain.domain, _pos[0], _pos[1], _rad, _rat);
else if(_shp == 1) FLIP_deleteParticle_rectangle(domain.domain, _pos[0], _pos[1], _siz[0], _siz[1], _rat);
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_fluidSim_destroy_fluid, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_FLIP_destroy",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "FLIP",
"path": "folders/nodes/data/simulation/FLIP.yy",
},
}

View file

@ -30,7 +30,7 @@ function Node_FLIP_Domain(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| 8] = nodeValue("Time Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.05); inputs[| 8] = nodeValue("Time Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.05);
inputs[| 9] = nodeValue("Wall type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1) inputs[| 9] = nodeValue("Wall type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "None", "Surround", "Ground only" ]); .setDisplay(VALUE_DISPLAY.enum_button, [ "None", "Surround", "Ground only" ]);
inputs[| 10] = nodeValue("Viscosity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.) inputs[| 10] = nodeValue("Viscosity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.)
.setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }); .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] });
@ -42,9 +42,9 @@ function Node_FLIP_Domain(_x, _y, _group = noone) : Node(_x, _y, _group) constru
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] }); .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
input_display_list = [ input_display_list = [
["Domain", false], 0, 1, 2, 9, 12, ["Domain", false], 0, 1, 9, 12,
["Solver", false], 3, 8, ["Solver", true], 3, 8,
["Physics", false], 6, 7, 10, 11, ["Physics", false], 7, 10, 11,
] ]
outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone); outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone);
@ -97,6 +97,12 @@ function Node_FLIP_Domain(_x, _y, _group = noone) : Node(_x, _y, _group) constru
domain = instance_create(0, 0, FLIP_Domain); domain = instance_create(0, 0, FLIP_Domain);
toReset = true; toReset = true;
static step = function() {
var _col = getInputData(9);
inputs[| 12].setVisible(_col);
}
static update = function(frame = CURRENT_FRAME) { static update = function(frame = CURRENT_FRAME) {
var _dim = getInputData(0); var _dim = getInputData(0);
var _siz = getInputData(1); _siz = max(_siz, 1); var _siz = getInputData(1); _siz = max(_siz, 1);
@ -142,7 +148,7 @@ function Node_FLIP_Domain(_x, _y, _group = noone) : Node(_x, _y, _group) constru
domain.flipRatio = _flp; domain.flipRatio = _flp;
domain.overRelaxation = _ovr; domain.overRelaxation = _ovr;
domain.viscosity = _vis; domain.viscosity = _vis;
domain.friction = _fric; domain.friction = power(1 - _fric, 0.025);
domain.wallCollide = _col; domain.wallCollide = _col;
domain.wallElasticity = _ela; domain.wallElasticity = _ela;

View file

@ -11,7 +11,8 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| 1] = nodeValue("Merge threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75) inputs[| 1] = nodeValue("Merge threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75)
.setDisplay(VALUE_DISPLAY.slider); .setDisplay(VALUE_DISPLAY.slider);
inputs[| 2] = nodeValue("Vaporize", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0); inputs[| 2] = nodeValue("Lifespan", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.range, { linked : true });
inputs[| 3] = nodeValue("Particle expansion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10); inputs[| 3] = nodeValue("Particle expansion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10);
@ -30,8 +31,10 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| 9] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ]) inputs[| 9] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ])
.setDisplay(VALUE_DISPLAY.range); .setDisplay(VALUE_DISPLAY.range);
inputs[| 10] = nodeValue("Segments", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1);
input_display_list = [ 0, 5, input_display_list = [ 0, 5,
["Rendering", false], 6, 3, 4, 9, ["Rendering", false], 6, 10, 3, 4, 9,
["Effect", false], 2, ["Effect", false], 2,
["Post Processing", false], 8, 7, 1, ["Post Processing", false], 8, 7, 1,
]; ];
@ -50,6 +53,24 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
triggerRender(); triggerRender();
})]); })]);
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var domain = getInputData(0);
if(!instance_exists(domain)) return;
if(domain.domain == noone) return;
var _m = min(array_length(domain.particlePos) / 2 - 1, domain.numParticles);
draw_set_color(COLORS._main_accent);
for( var i = 0; i < _m; i++ ) {
var _px = domain.particlePos[i * 2 + 0];
var _py = domain.particlePos[i * 2 + 1];
draw_circle(_x + _px * _s, _y + _py * _s, 1, false);
}
} #endregion
static step = function() { static step = function() {
var _typ = getInputData(6); var _typ = getInputData(6);
var _thr = getInputData(7); var _thr = getInputData(7);
@ -57,6 +78,7 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[| 1].setVisible(_typ == 0 && _thr); inputs[| 1].setVisible(_typ == 0 && _thr);
inputs[| 3].setVisible(_typ == 0); inputs[| 3].setVisible(_typ == 0);
inputs[| 5].setVisible(_typ == 0, _typ == 0); inputs[| 5].setVisible(_typ == 0, _typ == 0);
inputs[| 10].setVisible(_typ == 1);
} }
static update = function(frame = CURRENT_FRAME) { static update = function(frame = CURRENT_FRAME) {
@ -75,8 +97,10 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var _thr = getInputData(7); var _thr = getInputData(7);
var _add = getInputData(8); var _add = getInputData(8);
var _alp = getInputData(9); var _alp = getInputData(9);
var _seg = getInputData(10);
var _outSurf = outputs[| 0].getValue(); var _outSurf = outputs[| 0].getValue();
var _maxpart = domain.maxParticles;
var _padd = domain.particleSize; var _padd = domain.particleSize;
var _ww = domain.width - _padd * 2; var _ww = domain.width - _padd * 2;
var _hh = domain.height - _padd * 2; var _hh = domain.height - _padd * 2;
@ -86,7 +110,7 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
outputs[| 0].setValue(_outSurf); outputs[| 0].setValue(_outSurf);
var _x, _y, _px, _py, _r, _l, _a; var _x, _y, _px, _py, _r, _l, _a, _v;
var _rad = domain.particleRadius * _exp; var _rad = domain.particleRadius * _exp;
var _mx = min(array_length(domain.particlePos) / 2 - 1, domain.numParticles); var _mx = min(array_length(domain.particlePos) / 2 - 1, domain.numParticles);
@ -120,9 +144,10 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
_y -= _padd; _y -= _padd;
_r = 1; _r = 1;
_a = random_range(_alp[0], _alp[1]); _a = random_range(_alp[0], _alp[1]);
_v = irandom_range(_vap[0], _vap[1]);
if(_vap) { if(_v) {
_r = (_vap - _l) / _vap; _r = (_v - _l) / _v;
if(_r * _rad < 0.5) continue; if(_r * _rad < 0.5) continue;
} }
@ -136,32 +161,42 @@ function Node_FLIP_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constru
} }
} }
} else if(_typ == 1) { } else if(_typ == 1) {
for( var i = 0; i < _mx; i++ ) { var _segg = min(_seg, CURRENT_FRAME);
_x = domain.particlePos[i * 2 + 0];
_y = domain.particlePos[i * 2 + 1];
_px = domain.particleHist[i * 2 + 0];
_py = domain.particleHist[i * 2 + 1];
_l = domain.particleLife[i];
if(_x == 0 && _y == 0) continue;
if(_px == 0 && _py == 0) continue;
if(_vap) {
if(_l >= _vap) continue;
_r = (_vap - _l) / _vap;
_px = _x + (_px - _x) * _r;
_py = _y + (_py - _y) * _r;
}
_x -= _padd;
_y -= _padd;
_px -= _padd;
_py -= _padd;
var _ox, _oy, _nx, _ny;
draw_set_color(c_white); draw_set_color(c_white);
draw_line(_px, _py, _x, _y);
for( var i = 0; i < _mx; i++ ) {
_l = domain.particleLife[i];
_v = irandom_range(_vap[0], _vap[1]);
var fstFr = max(0, CURRENT_FRAME - _segg);
var lstFr = _v? min(CURRENT_FRAME, CURRENT_FRAME - _l + _v) : CURRENT_FRAME;
if(lstFr <= fstFr) continue;
_ox = lstFr == CURRENT_FRAME? domain.particlePos[i * 2 + 0] : domain.particleHist[(lstFr + 1) * _maxpart * 2 + i * 2 + 0];
_oy = lstFr == CURRENT_FRAME? domain.particlePos[i * 2 + 1] : domain.particleHist[(lstFr + 1) * _maxpart * 2 + i * 2 + 1];
if(_ox == 0 && _oy == 0) continue;
_ox -= _padd;
_oy -= _padd;
for( var j = lstFr; j > fstFr; j-- ) {
_nx = domain.particleHist[j * _maxpart * 2 + i * 2 + 0];
_ny = domain.particleHist[j * _maxpart * 2 + i * 2 + 1];
if(_nx == 0 && _ny == 0) continue;
_nx -= _padd;
_ny -= _padd;
draw_line(_ox, _oy, _nx, _ny);
_ox = _nx;
_oy = _ny;
}
} }
} }

View file

@ -10,37 +10,40 @@ function Node_FLIP_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group) constr
inputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.fdomain, noone ) inputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.fdomain, noone )
.setVisible(true, true); .setVisible(true, true);
inputs[| 1] = nodeValue("Spawn shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) inputs[| 1] = nodeValue("Spawn Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Circle", "Surface" ]); .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Circle", "Surface" ]);
inputs[| 2] = nodeValue("Spawn position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) inputs[| 2] = nodeValue("Spawn Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(); });
inputs[| 3] = nodeValue("Spawn type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) inputs[| 3] = nodeValue("Spawn Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Stream", "Splash" ]); .setDisplay(VALUE_DISPLAY.enum_button, [ "Stream", "Splash" ]);
inputs[| 4] = nodeValue("Spawn frame", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ); inputs[| 4] = nodeValue("Spawn Frame", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 );
inputs[| 5] = nodeValue("Spawn amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 8 ); inputs[| 5] = nodeValue("Spawn Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 8 );
inputs[| 6] = nodeValue("Spawn velocity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] ) inputs[| 6] = nodeValue("Spawn Velocity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.range); .setDisplay(VALUE_DISPLAY.range);
inputs[| 7] = nodeValue("Spawn surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); inputs[| 7] = nodeValue("Spawn Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| 8] = nodeValue("Spawn radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 2 ) inputs[| 8] = nodeValue("Spawn Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 2 )
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] }); .setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
inputs[| 9] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom_range(100000, 999999) ); inputs[| 9] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom_range(100000, 999999) );
inputs[| 10] = nodeValue("Spawn direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 45, 135, 0, 0 ] ) inputs[| 10] = nodeValue("Spawn Direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 45, 135, 0, 0 ] )
.setDisplay(VALUE_DISPLAY.rotation_random); .setDisplay(VALUE_DISPLAY.rotation_random);
inputs[| 11] = nodeValue("Inherit velocity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) inputs[| 11] = nodeValue("Inherit Velocity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 )
.setDisplay(VALUE_DISPLAY.slider); .setDisplay(VALUE_DISPLAY.slider);
inputs[| 12] = nodeValue("Spawn Duration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 );
input_display_list = [ 0, 9, input_display_list = [ 0, 9,
["Spawner", false], 1, 7, 8, 2, 3, 4, 5, ["Spawner", false], 1, 7, 8, 2, 3, 4, 12, 5,
["Physics", false], 10, 6, 11, ["Physics", false], 10, 6, 11,
] ]
@ -76,11 +79,19 @@ function Node_FLIP_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} #endregion } #endregion
static getDimension = function() {
var domain = getInputData(0);
if(!instance_exists(domain)) return [ 1, 1 ];
return [ domain.width, domain.height ];
}
static step = function() { #region static step = function() { #region
var _shp = getInputData(1); var _shp = getInputData(1);
var _typ = getInputData(3); var _typ = getInputData(3);
inputs[| 4].setVisible(_typ == 1); inputs[| 4].setVisible(_typ == 1);
inputs[| 12].setVisible(_typ == 1);
inputs[| 7].setVisible(_shp == 1, _shp == 1); inputs[| 7].setVisible(_shp == 1, _shp == 1);
inputs[| 8].setVisible(_shp == 0); inputs[| 8].setVisible(_shp == 0);
} #endregion } #endregion
@ -103,6 +114,7 @@ function Node_FLIP_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _vel = getInputData( 6); var _vel = getInputData( 6);
var _dirr = getInputData(10); var _dirr = getInputData(10);
var _ivel = getInputData(11); var _ivel = getInputData(11);
var _sdur = getInputData(12);
if(IS_FIRST_FRAME || toReset) spawn_amo = 0; if(IS_FIRST_FRAME || toReset) spawn_amo = 0;
toReset = false; toReset = false;
@ -111,7 +123,7 @@ function Node_FLIP_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group) constr
spawn_amo += _amo; spawn_amo += _amo;
if(spawn_amo < 1) return; if(spawn_amo < 1) return;
if(_type == 1 && frame != _fra) return; if(_type == 1 && (frame < _fra || frame >= _fra + _sdur)) return;
if(_shape == 1 && !is_surface(_surf)) return; if(_shape == 1 && !is_surface(_surf)) return;
var _samo = floor(spawn_amo); var _samo = floor(spawn_amo);

View file

@ -60,12 +60,16 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con
} #endregion } #endregion
static drawConnections = function(params = {}) { #region static drawConnections = function(params = {}) { #region
if(!active) return; if(!active) return noone;
if(!junc_in || !junc_out) return; if(!junc_in || !junc_out) return noone;
if(!junc_in.node.active || !junc_out.node.active) return; if(!junc_in.node.active || !junc_out.node.active) return noone;
if(drawJuncConnection(junc_out, junc_in, params)) params.dashed = true;
return self; var sel = drawJuncConnection(junc_out, junc_in, params);
params.dashed = false;
if(sel) return self;
return noone;
} #endregion } #endregion
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) {} static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) {}

View file

@ -1,13 +1,10 @@
function Node_Flip(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Flip(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Flip"; name = "Flip";
shader = sh_flip;
uniform_axs = shader_get_uniform(shader, "axis");
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) inputs[| 1] = nodeValue("Axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, ["x", "y"]); .setDisplay(VALUE_DISPLAY.enum_button, [ "x", "y" ]);
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 2; active_index = 2;
@ -23,17 +20,12 @@ function Node_Flip(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var _axis = _data[1]; var _axis = _data[1];
surface_set_target(_outSurf);
DRAW_CLEAR
BLEND_OVERRIDE;
shader_set(shader); surface_set_shader(_outSurf, sh_flip);
shader_set_uniform_i(uniform_axs, _axis); shader_set_i("axis", _axis);
draw_surface_safe(_data[0], 0, 0);
shader_reset();
BLEND_NORMAL; draw_surface_safe(_data[0]);
surface_reset_target(); surface_reset_shader();
return _outSurf; return _outSurf;
} }

View file

@ -442,8 +442,9 @@ function __initNodes() {
ds_list_add(flipSim, "Fluid"); ds_list_add(flipSim, "Fluid");
addNodeObject(flipSim, "Spawner", s_node_fluidSim_add_fluid, "Node_FLIP_Spawner", [1, Node_FLIP_Spawner]).hideRecent().setVersion(11620); addNodeObject(flipSim, "Spawner", s_node_fluidSim_add_fluid, "Node_FLIP_Spawner", [1, Node_FLIP_Spawner]).hideRecent().setVersion(11620);
addNodeObject(flipSim, "Destroy", s_node_fluidSim_destroy_fluid, "Node_FLIP_Destroy", [1, Node_FLIP_Destroy]).hideRecent().setVersion(11680);
addNodeObject(flipSim, "Apply Velocity", s_node_fluidSim_apply_velocity, "Node_FLIP_Apply_Velocity", [1, Node_FLIP_Apply_Velocity]).hideRecent().setVersion(11620); addNodeObject(flipSim, "Apply Velocity", s_node_fluidSim_apply_velocity, "Node_FLIP_Apply_Velocity", [1, Node_FLIP_Apply_Velocity]).hideRecent().setVersion(11620);
addNodeObject(flipSim, "Apply Force", s_node_fluidSim_force, "Node_FLIP_Apply_Force", [1, Node_FLIP_Apply_Force]).hideRecent().setVersion(11620); addNodeObject(flipSim, "Add Collider", s_node_fluidSim_force, "Node_FLIP_Apply_Force", [1, Node_FLIP_Apply_Force]).hideRecent().setVersion(11620);
#endregion #endregion
var strandSim = ds_list_create(); #region var strandSim = ds_list_create(); #region

View file

@ -2777,7 +2777,7 @@ function drawJuncConnection(from, to, params) { #region
var corner = PREFERENCES.connection_line_corner * _s; var corner = PREFERENCES.connection_line_corner * _s;
var ty = LINE_STYLE.solid; var ty = LINE_STYLE.solid;
if(to.type == VALUE_TYPE.node) if(to.type == VALUE_TYPE.node || struct_try_get(params, "dashed"))
ty = LINE_STYLE.dashed; ty = LINE_STYLE.dashed;
var c0, c1; var c0, c1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,74 @@
{
"resourceType": "GMSprite",
"resourceVersion": "1.0",
"name": "s_node_fluidSim_destroy_fluid",
"bbox_bottom": 61,
"bbox_left": 8,
"bbox_right": 61,
"bbox_top": 11,
"bboxMode": 0,
"collisionKind": 1,
"collisionTolerance": 0,
"DynamicTexturePage": false,
"edgeFiltering": false,
"For3D": false,
"frames": [
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"f1313810-96c4-4ec6-b05c-b073b68eb467",},
],
"gridX": 0,
"gridY": 0,
"height": 64,
"HTile": false,
"layers": [
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"8668c7d8-2c84-465a-8b92-1f35bdb84b04","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
],
"nineSlice": null,
"origin": 4,
"parent": {
"name": "fluidSim",
"path": "folders/nodes/icons/fluidSim.yy",
},
"preMultiplyAlpha": false,
"sequence": {
"resourceType": "GMSequence",
"resourceVersion": "1.4",
"name": "s_node_fluidSim_destroy_fluid",
"autoRecord": true,
"backdropHeight": 768,
"backdropImageOpacity": 0.5,
"backdropImagePath": "",
"backdropWidth": 1366,
"backdropXOffset": 0.0,
"backdropYOffset": 0.0,
"events": {"resourceType":"KeyframeStore<MessageEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
"eventStubScript": null,
"eventToFunction": {},
"length": 1.0,
"lockOrigin": false,
"moments": {"resourceType":"KeyframeStore<MomentsEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
"playback": 1,
"playbackSpeed": 30.0,
"playbackSpeedType": 0,
"showBackdrop": true,
"showBackdropImage": false,
"timeUnits": 1,
"tracks": [
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"f1313810-96c4-4ec6-b05c-b073b68eb467","path":"sprites/s_node_fluidSim_destroy_fluid/s_node_fluidSim_destroy_fluid.yy",},},},"Disabled":false,"id":"e522dfff-694e-47f8-a460-e7fa969d9da4","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange": null,
"volume": 1.0,
"xorigin": 32,
"yorigin": 32,
},
"swatchColours": null,
"swfPrecision": 2.525,
"textureGroupId": {
"name": "Default",
"path": "texturegroups/Default",
},
"type": 0,
"VTile": false,
"width": 64,
}