2024-03-19 09:49:29 +01:00
|
|
|
function Node_Smoke_Repulse(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) constructor {
|
2023-02-14 02:48:33 +01:00
|
|
|
name = "Repulse";
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 96);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2023-12-22 08:42:02 +01:00
|
|
|
manual_ungroupable = false;
|
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(0, nodeValue("Domain", self, CONNECT_TYPE.input, VALUE_TYPE.sdomain, noone))
|
2023-02-14 02:48:33 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Vec2("Position", self, [0, 0]));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Float("Radius", self, 8));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(3, nodeValue_Float("Strength", self, 0.10))
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] });
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-11-22 09:43:50 +01:00
|
|
|
newInput(4, nodeValue_Float("Spokes", self, 0));
|
|
|
|
|
|
|
|
newInput(5, nodeValue_Rotation("Twist", self, 0));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
input_display_list = [
|
|
|
|
["Domain", false], 0,
|
2024-11-22 09:43:50 +01:00
|
|
|
["Repulse", false], 1, 2, 3, 4, 5,
|
2023-02-14 02:48:33 +01:00
|
|
|
];
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-11-22 09:43:50 +01:00
|
|
|
temp_surface = [ 0 ];
|
|
|
|
|
2024-03-14 14:35:19 +01:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _pos = getInputData(1);
|
|
|
|
var _rad = getInputData(2);
|
2023-02-14 02:48:33 +01:00
|
|
|
var px = _x + _pos[0] * _s;
|
|
|
|
var py = _y + _pos[1] * _s;
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
2023-06-17 14:30:49 +02:00
|
|
|
draw_circle_prec(px, py, _rad * _s, true);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
|
|
|
inputs[2].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny);
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) {
|
2024-08-06 14:04:41 +02:00
|
|
|
var _dom = getInputData(0);
|
|
|
|
var _pos = getInputData(1);
|
|
|
|
var _rad = getInputData(2);
|
|
|
|
var _str = getInputData(3);
|
2024-11-22 09:43:50 +01:00
|
|
|
var _spk = getInputData(4);
|
|
|
|
var _spk_r = getInputData(5);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-11-21 12:07:07 +01:00
|
|
|
SMOKE_DOMAIN_CHECK
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(_dom);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
_rad = max(_rad, 1);
|
2024-11-22 09:43:50 +01:00
|
|
|
temp_surface[0] = surface_verify(temp_surface[0], _dom.width, _dom.height, surface_rgba32float);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-11-22 09:43:50 +01:00
|
|
|
surface_set_shader(temp_surface[0], sh_fd_repulse);
|
2023-03-25 12:27:04 +01:00
|
|
|
shader_set_f("strength", _str);
|
2024-11-22 09:43:50 +01:00
|
|
|
shader_set_f("spokes", _spk);
|
|
|
|
shader_set_f("rotate", degtorad(_spk_r));
|
|
|
|
shader_set_f("radius", max(_rad /_dom.width, _rad / _dom.height));
|
|
|
|
shader_set_f("center", _pos[0] / _dom.width, _pos[1] / _dom.height);
|
|
|
|
draw_empty();
|
|
|
|
surface_reset_shader();
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-11-22 09:43:50 +01:00
|
|
|
_dom.addVelocity(temp_surface[0]);
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-02-14 02:48:33 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
|
2023-11-10 11:32:46 +01:00
|
|
|
draw_sprite_fit(s_node_smokeSim_repulse, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
}
|