2024-03-22 09:44:11 +01:00
|
|
|
function Node_FLIP_Repel(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Repel";
|
|
|
|
color = COLORS.node_blend_fluid;
|
|
|
|
icon = THEME.fluid_sim;
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 96);
|
2024-03-22 09:44:11 +01:00
|
|
|
|
|
|
|
manual_ungroupable = false;
|
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(0, nodeValue_Fdomain("Domain", self, noone ))
|
2024-03-22 09:44:11 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(1, nodeValue_Vec2("Position", self, [ 0, 0 ] ))
|
2024-03-22 09:44:11 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(); });
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Float("Radius", self, 4 ));
|
2024-03-22 09:44:11 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(3, nodeValue_Float("Strength", self, 4 ))
|
2024-03-22 09:44:11 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 16, 0.1 ] });
|
|
|
|
|
|
|
|
input_display_list = [ 0,
|
|
|
|
["Repel", false], 1, 2, 3,
|
|
|
|
]
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.fdomain, noone ));
|
2024-03-22 09:44:11 +01:00
|
|
|
|
|
|
|
static getDimension = function() { #region
|
|
|
|
var domain = getInputData(0);
|
|
|
|
if(!instance_exists(domain)) return [ 1, 1 ];
|
|
|
|
|
|
|
|
return [ domain.width, domain.height ];
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
|
|
|
var _posit = getInputData(1);
|
|
|
|
var _rad = getInputData(2);
|
|
|
|
|
|
|
|
var _px = _x + _posit[0] * _s;
|
|
|
|
var _py = _y + _posit[1] * _s;
|
|
|
|
|
|
|
|
var _r = _rad * _s;
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_circle_prec(_px, _py, _r, true, 32);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
if(inputs[1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny)) { hover = false; active = false; }
|
2024-03-22 09:44:11 +01:00
|
|
|
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static step = function() { #region
|
|
|
|
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
|
|
|
var domain = getInputData(0);
|
|
|
|
if(!instance_exists(domain)) return;
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(domain);
|
2024-03-22 09:44:11 +01:00
|
|
|
|
|
|
|
var _posit = getInputData(1);
|
|
|
|
var _rad = getInputData(2);
|
|
|
|
var _str = getInputData(3);
|
|
|
|
|
|
|
|
FLIP_Repel(domain.domain, _posit[0], _posit[1], _rad, _str * 8);
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_fluidSim_repulse, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static getPreviewValues = function() { var domain = getInputData(0); return instance_exists(domain)? domain.domain_preview : noone; }
|
|
|
|
}
|