Rigidbody

This commit is contained in:
MakhamDev 2023-10-09 12:36:20 +07:00
parent 68bdb32f92
commit 20073fd98c
24 changed files with 508 additions and 132 deletions

View file

@ -569,6 +569,7 @@
{"name":"s_node_vec3","order":8,"path":"sprites/s_node_vec3/s_node_vec3.yy",}, {"name":"s_node_vec3","order":8,"path":"sprites/s_node_vec3/s_node_vec3.yy",},
{"name":"s_node_strandSim_create","order":2,"path":"sprites/s_node_strandSim_create/s_node_strandSim_create.yy",}, {"name":"s_node_strandSim_create","order":2,"path":"sprites/s_node_strandSim_create/s_node_strandSim_create.yy",},
{"name":"node_gradient_shift","order":10,"path":"scripts/node_gradient_shift/node_gradient_shift.yy",}, {"name":"node_gradient_shift","order":10,"path":"scripts/node_gradient_shift/node_gradient_shift.yy",},
{"name":"s_node_rigidSim_render_output","order":10,"path":"sprites/s_node_rigidSim_render_output/s_node_rigidSim_render_output.yy",},
{"name":"sh_vertex_normal_pass","order":3,"path":"shaders/sh_vertex_normal_pass/sh_vertex_normal_pass.yy",}, {"name":"sh_vertex_normal_pass","order":3,"path":"shaders/sh_vertex_normal_pass/sh_vertex_normal_pass.yy",},
{"name":"node_vector_cross3D","order":10,"path":"scripts/node_vector_cross3D/node_vector_cross3D.yy",}, {"name":"node_vector_cross3D","order":10,"path":"scripts/node_vector_cross3D/node_vector_cross3D.yy",},
{"name":"s_node_pack_sprite","order":5,"path":"sprites/s_node_pack_sprite/s_node_pack_sprite.yy",}, {"name":"s_node_pack_sprite","order":5,"path":"sprites/s_node_pack_sprite/s_node_pack_sprite.yy",},
@ -837,6 +838,7 @@
{"name":"sh_glow","order":34,"path":"shaders/sh_glow/sh_glow.yy",}, {"name":"sh_glow","order":34,"path":"shaders/sh_glow/sh_glow.yy",},
{"name":"sh_clean_shape","order":37,"path":"shaders/sh_clean_shape/sh_clean_shape.yy",}, {"name":"sh_clean_shape","order":37,"path":"shaders/sh_clean_shape/sh_clean_shape.yy",},
{"name":"fd_rectangle_update","order":20,"path":"scripts/fd_rectangle_update/fd_rectangle_update.yy",}, {"name":"fd_rectangle_update","order":20,"path":"scripts/fd_rectangle_update/fd_rectangle_update.yy",},
{"name":"node_rigid_render_output","order":10,"path":"scripts/node_rigid_render_output/node_rigid_render_output.yy",},
{"name":"sh_posterize","order":19,"path":"shaders/sh_posterize/sh_posterize.yy",}, {"name":"sh_posterize","order":19,"path":"shaders/sh_posterize/sh_posterize.yy",},
{"name":"s_node_mirror","order":3,"path":"sprites/s_node_mirror/s_node_mirror.yy",}, {"name":"s_node_mirror","order":3,"path":"sprites/s_node_mirror/s_node_mirror.yy",},
{"name":"s_node_blur_simple","order":43,"path":"sprites/s_node_blur_simple/s_node_blur_simple.yy",}, {"name":"s_node_blur_simple","order":43,"path":"sprites/s_node_blur_simple/s_node_blur_simple.yy",},
@ -1584,6 +1586,7 @@
{"name":"fd_rectangle_set_material_dissipation_value","order":5,"path":"scripts/fd_rectangle_set_material_dissipation_value/fd_rectangle_set_material_dissipation_value.yy",}, {"name":"fd_rectangle_set_material_dissipation_value","order":5,"path":"scripts/fd_rectangle_set_material_dissipation_value/fd_rectangle_set_material_dissipation_value.yy",},
{"name":"node_iterator_output","order":2,"path":"scripts/node_iterator_output/node_iterator_output.yy",}, {"name":"node_iterator_output","order":2,"path":"scripts/node_iterator_output/node_iterator_output.yy",},
{"name":"panel_graph_export_image_dialog","order":5,"path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",}, {"name":"panel_graph_export_image_dialog","order":5,"path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",},
{"name":"s_node_fluidSim_render_output","order":11,"path":"sprites/s_node_fluidSim_render_output/s_node_fluidSim_render_output.yy",},
{"name":"debug","order":10,"path":"scripts/debug/debug.yy",}, {"name":"debug","order":10,"path":"scripts/debug/debug.yy",},
{"name":"node_shadow_cast","order":15,"path":"scripts/node_shadow_cast/node_shadow_cast.yy",}, {"name":"node_shadow_cast","order":15,"path":"scripts/node_shadow_cast/node_shadow_cast.yy",},
{"name":"node_strand_render","order":5,"path":"scripts/node_strand_render/node_strand_render.yy",}, {"name":"node_strand_render","order":5,"path":"scripts/node_strand_render/node_strand_render.yy",},

View file

@ -1151,6 +1151,7 @@
{"id":{"name":"s_node_vec3","path":"sprites/s_node_vec3/s_node_vec3.yy",},}, {"id":{"name":"s_node_vec3","path":"sprites/s_node_vec3/s_node_vec3.yy",},},
{"id":{"name":"s_node_strandSim_create","path":"sprites/s_node_strandSim_create/s_node_strandSim_create.yy",},}, {"id":{"name":"s_node_strandSim_create","path":"sprites/s_node_strandSim_create/s_node_strandSim_create.yy",},},
{"id":{"name":"node_gradient_shift","path":"scripts/node_gradient_shift/node_gradient_shift.yy",},}, {"id":{"name":"node_gradient_shift","path":"scripts/node_gradient_shift/node_gradient_shift.yy",},},
{"id":{"name":"s_node_rigidSim_render_output","path":"sprites/s_node_rigidSim_render_output/s_node_rigidSim_render_output.yy",},},
{"id":{"name":"sh_vertex_normal_pass","path":"shaders/sh_vertex_normal_pass/sh_vertex_normal_pass.yy",},}, {"id":{"name":"sh_vertex_normal_pass","path":"shaders/sh_vertex_normal_pass/sh_vertex_normal_pass.yy",},},
{"id":{"name":"node_vector_cross3D","path":"scripts/node_vector_cross3D/node_vector_cross3D.yy",},}, {"id":{"name":"node_vector_cross3D","path":"scripts/node_vector_cross3D/node_vector_cross3D.yy",},},
{"id":{"name":"s_node_pack_sprite","path":"sprites/s_node_pack_sprite/s_node_pack_sprite.yy",},}, {"id":{"name":"s_node_pack_sprite","path":"sprites/s_node_pack_sprite/s_node_pack_sprite.yy",},},
@ -1463,6 +1464,7 @@
{"id":{"name":"sh_glow","path":"shaders/sh_glow/sh_glow.yy",},}, {"id":{"name":"sh_glow","path":"shaders/sh_glow/sh_glow.yy",},},
{"id":{"name":"sh_clean_shape","path":"shaders/sh_clean_shape/sh_clean_shape.yy",},}, {"id":{"name":"sh_clean_shape","path":"shaders/sh_clean_shape/sh_clean_shape.yy",},},
{"id":{"name":"fd_rectangle_update","path":"scripts/fd_rectangle_update/fd_rectangle_update.yy",},}, {"id":{"name":"fd_rectangle_update","path":"scripts/fd_rectangle_update/fd_rectangle_update.yy",},},
{"id":{"name":"node_rigid_render_output","path":"scripts/node_rigid_render_output/node_rigid_render_output.yy",},},
{"id":{"name":"sh_posterize","path":"shaders/sh_posterize/sh_posterize.yy",},}, {"id":{"name":"sh_posterize","path":"shaders/sh_posterize/sh_posterize.yy",},},
{"id":{"name":"s_node_mirror","path":"sprites/s_node_mirror/s_node_mirror.yy",},}, {"id":{"name":"s_node_mirror","path":"sprites/s_node_mirror/s_node_mirror.yy",},},
{"id":{"name":"draw_enable_alphablend","path":"scripts/draw_enable_alphablend/draw_enable_alphablend.yy",},}, {"id":{"name":"draw_enable_alphablend","path":"scripts/draw_enable_alphablend/draw_enable_alphablend.yy",},},
@ -2324,6 +2326,7 @@
{"id":{"name":"node_iterator_output","path":"scripts/node_iterator_output/node_iterator_output.yy",},}, {"id":{"name":"node_iterator_output","path":"scripts/node_iterator_output/node_iterator_output.yy",},},
{"id":{"name":"panel_graph_export_image_dialog","path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",},}, {"id":{"name":"panel_graph_export_image_dialog","path":"scripts/panel_graph_export_image_dialog/panel_graph_export_image_dialog.yy",},},
{"id":{"name":"node_PCX_array_get","path":"scripts/node_PCX_array_get/node_PCX_array_get.yy",},}, {"id":{"name":"node_PCX_array_get","path":"scripts/node_PCX_array_get/node_PCX_array_get.yy",},},
{"id":{"name":"s_node_fluidSim_render_output","path":"sprites/s_node_fluidSim_render_output/s_node_fluidSim_render_output.yy",},},
{"id":{"name":"debug","path":"scripts/debug/debug.yy",},}, {"id":{"name":"debug","path":"scripts/debug/debug.yy",},},
{"id":{"name":"node_shadow_cast","path":"scripts/node_shadow_cast/node_shadow_cast.yy",},}, {"id":{"name":"node_shadow_cast","path":"scripts/node_shadow_cast/node_shadow_cast.yy",},},
{"id":{"name":"node_strand_render","path":"scripts/node_strand_render/node_strand_render.yy",},}, {"id":{"name":"node_strand_render","path":"scripts/node_strand_render/node_strand_render.yy",},},

View file

@ -33,15 +33,6 @@ function __part(_node) constructor {
accel = 0; accel = 0;
spVec = [ 0, 0 ]; spVec = [ 0, 0 ];
//wig_psx = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
//wig_psy = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
//wig_scx = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
//wig_scy = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
//wig_rot = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
//wig_dir = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
grav = 0; grav = 0;
gravDir = -90; gravDir = -90;
gravX = 0; gravX = 0;
@ -49,8 +40,8 @@ function __part(_node) constructor {
scx = 1; scx = 1;
scy = 1; scy = 1;
sc_sx = 1; sc_sx = 1;
sc_sy = 1; sc_sy = 1;
sct = CURVE_DEF_11; sct = CURVE_DEF_11;
rot = 0; rot = 0;
@ -118,13 +109,6 @@ function __part(_node) constructor {
static setWiggle = function(wiggle_maps) { #region static setWiggle = function(wiggle_maps) { #region
gml_pragma("forceinline"); gml_pragma("forceinline");
//wig_psx.check(_wig_pos[0], _wig_pos[1], seed + 10);
//wig_psy.check(_wig_pos[0], _wig_pos[1], seed + 20);
//wig_rot.check(_wig_rot[0], _wig_rot[1], seed + 30);
//wig_scx.check(_wig_sca[0], _wig_sca[1], seed + 40);
//wig_scy.check(_wig_sca[0], _wig_sca[1], seed + 50);
//wig_dir.check(_wig_dir[0], _wig_dir[1], seed + 60);
wig_psx = wiggle_maps.wig_psx; wig_psx = wiggle_maps.wig_psx;
wig_psy = wiggle_maps.wig_psy; wig_psy = wiggle_maps.wig_psy;
wig_rot = wiggle_maps.wig_rot; wig_rot = wiggle_maps.wig_rot;

View file

@ -108,10 +108,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER; globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 11540; VERSION = 11541;
SAVE_VERSION = 11530; SAVE_VERSION = 11530;
VERSION_STRING = "1.15.4"; VERSION_STRING = "1.15.4.1";
BUILD_NUMBER = 11540; BUILD_NUMBER = 11541;
globalvar APPEND_MAP; globalvar APPEND_MAP;
APPEND_MAP = ds_map_create(); APPEND_MAP = ds_map_create();

View file

@ -1004,31 +1004,25 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var cDep = attrDepth(); var cDep = attrDepth();
apply_surfaces(); apply_surfaces();
var _outSurf = outputs[| 0].getValue(); var _frames = attributes.frames;
if(attributes.frames == 1) { if(!is_array(output_surface)) output_surface = array_create(_frames);
if(is_array(_outSurf)) { else if(array_length(output_surface) != _frames)
if(!array_empty(_outSurf)) _outSurf = _outSurf[0]; array_resize(output_surface, _frames);
else _outSurf = noone;
}
if(_frames == 1) {
var _canvas_surface = getCanvasSurface(0); var _canvas_surface = getCanvasSurface(0);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep); output_surface[0] = surface_verify(output_surface[0], _dim[0], _dim[1], cDep);
surface_set_shader(_outSurf, noone,, BLEND.alpha); surface_set_shader(output_surface[0], noone,, BLEND.alpha);
if(_bgr && is_surface(_bg)) if(_bgr && is_surface(_bg))
draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga);
draw_surface_safe(_canvas_surface, 0, 0); draw_surface_safe(_canvas_surface, 0, 0);
surface_reset_shader(); surface_reset_shader();
outputs[| 0].setValue(_outSurf); outputs[| 0].setValue(output_surface[0]);
} else { } else {
if(!is_array(output_surface)) for( var i = 0; i < _frames; i++ ) {
output_surface = array_create(attributes.frames);
else if(array_length(output_surface) != attributes.frames)
array_resize(output_surface, attributes.frames);
for( var i = 0; i < attributes.frames; i++ ) {
var _canvas_surface = getCanvasSurface(i); var _canvas_surface = getCanvasSurface(i);
output_surface[i] = surface_verify(output_surface[i], _dim[0], _dim[1], cDep); output_surface[i] = surface_verify(output_surface[i], _dim[0], _dim[1], cDep);
@ -1041,7 +1035,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} }
if(_anim) { if(_anim) {
var _fr_index = safe_mod(PROJECT.animator.current_frame * _anims, attributes.frames); var _fr_index = safe_mod(PROJECT.animator.current_frame * _anims, _frames);
outputs[| 0].setValue(output_surface[_fr_index]); outputs[| 0].setValue(output_surface[_fr_index]);
} else } else
outputs[| 0].setValue(output_surface); outputs[| 0].setValue(output_surface);

View file

@ -438,7 +438,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
inputs_data = array_create(ds_list_size(inputs), undefined); inputs_data = array_create(ds_list_size(inputs), undefined);
for(var i = 0; i < ds_list_size(inputs); i++) for(var i = 0; i < ds_list_size(inputs); i++)
inputs_data[i] = inputs[| i].getValue(,,, true); inputs_data[i] = inputs[| i].getValue(,,, false);
} #endregion } #endregion
static forceUpdate = function() { #region static forceUpdate = function() { #region

View file

@ -60,19 +60,8 @@ function Node_Fluid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
outParent.name = display_name; outParent.name = display_name;
} #endregion } #endregion
static recoverCache = function(frame = PROJECT.animator.current_frame) { #region
if(!is_instanceof(outParent, NodeValue)) return false;
if(!cacheExist(frame)) return false;
var _s = cached_output[PROJECT.animator.current_frame];
outParent.setValue(_s);
return true;
} #endregion
static update = function(frame = PROJECT.animator.current_frame) { #region static update = function(frame = PROJECT.animator.current_frame) { #region
if(!is_instanceof(outParent, NodeValue)) return noone; if(!is_instanceof(outParent, NodeValue)) return noone;
if(recoverCache() || !PROJECT.animator.is_playing) return;
var _dim = inputs[| 1].getValue(frame); var _dim = inputs[| 1].getValue(frame);
var _outSurf = outParent.getValue(); var _outSurf = outParent.getValue();
@ -102,7 +91,17 @@ function Node_Fluid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
surface_reset_shader(); surface_reset_shader();
group.outputNode = self; group.outputNode = self;
var frm = cacheCurrentFrame(_outSurf); cacheCurrentFrame(_outSurf);
} #endregion
static recoverCache = function(frame = PROJECT.animator.current_frame) { #region
if(!is_instanceof(outParent, NodeValue)) return false;
if(!cacheExist(frame)) return false;
var _s = cached_output[PROJECT.animator.current_frame];
outParent.setValue(_s);
return true;
} #endregion } #endregion
static getGraphPreviewSurface = function() { #region static getGraphPreviewSurface = function() { #region

View file

@ -24,7 +24,7 @@ function Node_create_Math(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", ""); var query = struct_try_get(_param, "query", "");
var node = new Node_Math(_x, _y, _group); var node = new Node_Math(_x, _y, _group);
switch(query) { switch(query) { #region
case "add" : node.inputs[| 0].setValue(MATH_OPERATOR.add); break; case "add" : node.inputs[| 0].setValue(MATH_OPERATOR.add); break;
case "subtract" : node.inputs[| 0].setValue(MATH_OPERATOR.subtract); break; case "subtract" : node.inputs[| 0].setValue(MATH_OPERATOR.subtract); break;
case "multiply" : node.inputs[| 0].setValue(MATH_OPERATOR.multiply); break; case "multiply" : node.inputs[| 0].setValue(MATH_OPERATOR.multiply); break;
@ -44,7 +44,7 @@ function Node_create_Math(_x, _y, _group = noone, _param = {}) {
case "lerp" : node.inputs[| 0].setValue(MATH_OPERATOR.lerp); break; case "lerp" : node.inputs[| 0].setValue(MATH_OPERATOR.lerp); break;
case "abs" : node.inputs[| 0].setValue(MATH_OPERATOR.abs); break; case "abs" : node.inputs[| 0].setValue(MATH_OPERATOR.abs); break;
} } #endregion
return node; return node;
} }
@ -83,7 +83,7 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
use_mod = 0; use_mod = 0;
use_deg = false; use_deg = false;
static _eval = function(a, b, c = 0) { static _eval = function(a, b, c = 0) { #region
switch(use_mod) { switch(use_mod) {
case MATH_OPERATOR.add : return a + b; case MATH_OPERATOR.add : return a + b;
case MATH_OPERATOR.subtract : return a - b; case MATH_OPERATOR.subtract : return a - b;
@ -106,9 +106,9 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
case MATH_OPERATOR.abs : return abs(a); case MATH_OPERATOR.abs : return abs(a);
} }
return 0; return 0;
} } #endregion
static step = function() { static step = function() { #region
var mode = getInputData(0); var mode = getInputData(0);
switch(mode) { switch(mode) {
@ -170,9 +170,9 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
break; break;
default: return; default: return;
} }
} } #endregion
function evalArray(a, b, c = 0) { function evalArray(a, b, c = 0) { #region
var as = is_array(a); var as = is_array(a);
var bs = is_array(b); var bs = is_array(b);
var cs = is_array(c); var cs = is_array(c);
@ -199,9 +199,9 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
); );
return val; return val;
} } #endregion
static update = function(frame = PROJECT.animator.current_frame) { static update = function(frame = PROJECT.animator.current_frame) { #region
use_mod = getInputData(0); use_mod = getInputData(0);
var a = getInputData(1); var a = getInputData(1);
var b = getInputData(2); var b = getInputData(2);
@ -210,9 +210,9 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var val = evalArray(a, b, c); var val = evalArray(a, b, c);
outputs[| 0].setValue(val); outputs[| 0].setValue(val);
} } #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)) {
@ -240,5 +240,5 @@ function Node_Math(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
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

@ -183,14 +183,15 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
var rigidSim = ds_list_create(); #region var rigidSim = ds_list_create(); #region
addNodeCatagory("RigidSim", rigidSim, ["Node_Rigid_Group"]); addNodeCatagory("RigidSim", rigidSim, ["Node_Rigid_Group"]);
ds_list_add(rigidSim, "Group"); ds_list_add(rigidSim, "Group");
addNodeObject(rigidSim, "Input", s_node_group_input, "Node_Group_Input", [1, Node_Group_Input]); addNodeObject(rigidSim, "Input", s_node_group_input, "Node_Group_Input", [1, Node_Group_Input]);
addNodeObject(rigidSim, "Output", s_node_group_output,"Node_Group_Output", [1, Node_Group_Output]); addNodeObject(rigidSim, "Output", s_node_group_output, "Node_Group_Output", [1, Node_Group_Output]);
addNodeObject(rigidSim, "Render", s_node_rigidSim_render_output, "Node_Rigid_Render_Output", [1, Node_Rigid_Render_Output]);
ds_list_add(rigidSim, "RigidSim"); ds_list_add(rigidSim, "RigidSim");
addNodeObject(rigidSim, "Object", s_node_rigidSim_object, "Node_Rigid_Object", [1, Node_Rigid_Object]).setVersion(1110); addNodeObject(rigidSim, "Object", s_node_rigidSim_object, "Node_Rigid_Object", [1, Node_Rigid_Object]).setVersion(1110);
addNodeObject(rigidSim, "Object Spawner", s_node_rigidSim_object_spawner, "Node_Rigid_Object_Spawner", [1, Node_Rigid_Object_Spawner]).setVersion(1110); addNodeObject(rigidSim, "Object Spawner", s_node_rigidSim_object_spawner, "Node_Rigid_Object_Spawner", [1, Node_Rigid_Object_Spawner]).setVersion(1110);
addNodeObject(rigidSim, "Render", s_node_rigidSim_renderer, "Node_Rigid_Render", [1, Node_Rigid_Render]).setVersion(1110); addNodeObject(rigidSim, "Render", s_node_rigidSim_renderer, "Node_Rigid_Render", [1, Node_Rigid_Render]).setVersion(1110);
addNodeObject(rigidSim, "Apply Force", s_node_rigidSim_force, "Node_Rigid_Force_Apply", [1, Node_Rigid_Force_Apply]).setVersion(1110); addNodeObject(rigidSim, "Apply Force", s_node_rigidSim_force, "Node_Rigid_Force_Apply", [1, Node_Rigid_Force_Apply]).setVersion(1110);
ds_list_add(rigidSim, "Instance control"); ds_list_add(rigidSim, "Instance control");
addNodeObject(rigidSim, "Activate Physics", s_node_rigidSim_activate, "Node_Rigid_Activate", [1, Node_Rigid_Activate]).setVersion(1110); addNodeObject(rigidSim, "Activate Physics", s_node_rigidSim_activate, "Node_Rigid_Activate", [1, Node_Rigid_Activate]).setVersion(1110);
@ -201,9 +202,9 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
var fluidSim = ds_list_create(); #region var fluidSim = ds_list_create(); #region
addNodeCatagory("FluidSim", fluidSim, ["Node_Fluid_Group"]); addNodeCatagory("FluidSim", fluidSim, ["Node_Fluid_Group"]);
ds_list_add(fluidSim, "Group"); ds_list_add(fluidSim, "Group");
addNodeObject(fluidSim, "Input", s_node_group_input, "Node_Group_Input", [1, Node_Group_Input]); addNodeObject(fluidSim, "Input", s_node_group_input, "Node_Group_Input", [1, Node_Group_Input]);
addNodeObject(fluidSim, "Output", s_node_group_output, "Node_Group_Output", [1, Node_Group_Output]); addNodeObject(fluidSim, "Output", s_node_group_output, "Node_Group_Output", [1, Node_Group_Output]);
addNodeObject(fluidSim, "Render Domain", s_node_fluidSim_render, "Node_Fluid_Render_Output", [1, Node_Fluid_Render_Output]).setVersion(11540); addNodeObject(fluidSim, "Render Domain", s_node_fluidSim_render_output, "Node_Fluid_Render_Output", [1, Node_Fluid_Render_Output]).setVersion(11540);
ds_list_add(fluidSim, "Domain"); ds_list_add(fluidSim, "Domain");
addNodeObject(fluidSim, "Fluid Domain", s_node_fluidSim_domain, "Node_Fluid_Domain", [1, Node_Fluid_Domain]).setVersion(1120); addNodeObject(fluidSim, "Fluid Domain", s_node_fluidSim_domain, "Node_Fluid_Domain", [1, Node_Fluid_Domain]).setVersion(1120);

View file

@ -44,19 +44,27 @@ 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, "Display");
attributes.show_objects = true;
array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; }, array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; },
new checkBox(function() { new checkBox(function() {
attributes.show_objects = !attributes.show_objects; attributes.show_objects = !attributes.show_objects;
})]); })]);
attributes.display_scale = 512;
array_push(attributeEditors, ["Display scale", function() { return attributes.display_scale; },
new textBox(TEXTBOX_INPUT.number, function(val) {
attributes.display_scale = val;
})]);
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) if(attributes.show_objects)
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i]; var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue; if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); var _hov = _node.drawOverlayPreview(active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= !_hov;
} }
var _typ = getInputData(1); var _typ = getInputData(1);
@ -67,8 +75,8 @@ function Node_Rigid_Force_Apply(_x, _y, _group = noone) : Node(_x, _y, _group) c
if(_typ == 0 || _typ == 1) { if(_typ == 0 || _typ == 1) {
var _for = getInputData(5); var _for = getInputData(5);
var fx = px + _for[0] * 4 * _s; var fx = px + _for[0] * attributes.display_scale * _s;
var fy = py + _for[1] * 4 * _s; var fy = py + _for[1] * attributes.display_scale * _s;
draw_set_color(COLORS._main_accent); draw_set_color(COLORS._main_accent);
draw_set_alpha(0.5); draw_set_alpha(0.5);
@ -76,7 +84,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 * 4, _mx, _my, _snx, _sny, THEME.anchor, 10); inputs[| 5].drawOverlay(active, px, py, _s * attributes.display_scale, _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

@ -9,10 +9,7 @@ function Node_Rigid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro
collIndex = irandom_range(1, 9999); collIndex = irandom_range(1, 9999);
if(!LOADING && !APPENDING && !CLONING) { if(!LOADING && !APPENDING && !CLONING) {
var _render = nodeBuild("Node_Rigid_Render", 256, -32, self); var _output = nodeBuild("Node_Rigid_Render_Output", 256, -32, self);
var _output = nodeBuild("Node_Group_Output", 416, -32, self);
_output.inputs[| 0].setFrom(_render.outputs[| 0]);
} }
static reset = function() { static reset = function() {

View file

@ -10,45 +10,59 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
attributes.mesh = []; attributes.mesh = [];
inputs[| 0] = nodeValue("Affect by force", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true) inputs[| 0] = nodeValue("Affect by force", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 1] = nodeValue("Weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5) inputs[| 1] = nodeValue("Weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 2] = nodeValue("Contact friction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2) inputs[| 2] = nodeValue("Contact friction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 3] = nodeValue("Air resistance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2) inputs[| 3] = nodeValue("Air resistance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 4] = nodeValue("Rotation resistance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2) inputs[| 4] = nodeValue("Rotation resistance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 5] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) inputs[| 5] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Box", "Circle", "Custom" ]) .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Box", "Circle", "Custom" ])
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 6] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); inputs[| 6] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone)
.setAnimable(false);
inputs[| 7] = nodeValue("Start position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16 ]) inputs[| 7] = nodeValue("Start position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16 ])
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector)
.setAnimable(false);
inputs[| 8] = nodeValue("Spawn", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Make object spawn when start.") inputs[| 8] = nodeValue("Spawn", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Make object spawn when start.")
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 9] = nodeValue("Generate mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.trigger, 0) inputs[| 9] = nodeValue("Generate mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.trigger, 0)
.setDisplay(VALUE_DISPLAY.button, { name: "Generate", onClick: function() { generateAllMesh(); } }); .setDisplay(VALUE_DISPLAY.button, { name: "Generate", onClick: function() { generateAllMesh(); } });
inputs[| 10] = nodeValue("Mesh expansion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) inputs[| 10] = nodeValue("Mesh expansion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider, { range: [ -2, 2, 0.1 ] }) .setDisplay(VALUE_DISPLAY.slider, { range: [ -2, 2, 0.1 ] })
.rejectArray(); .rejectArray()
.setAnimable(false);
inputs[| 11] = nodeValue("Add pixel collider", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
.rejectArray()
.setAnimable(false);
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], 6, ["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, 11,
]; ];
static newMesh = function(index) { static newMesh = function(index) {
@ -130,7 +144,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_surface_ext_safe(_tex, _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 } #endregion
static drawOverlayPreview = function(_x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlayPreview = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _pos = getInputData(7); var _pos = getInputData(7);
var _tex = getInputData(6); var _tex = getInputData(6);
@ -142,7 +156,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
drawOverlayPreviewSingle(i, _x, _y, _s, _pr_x, _pr_y, _tex[i]); drawOverlayPreviewSingle(i, _x, _y, _s, _pr_x, _pr_y, _tex[i]);
} else } else
drawOverlayPreviewSingle(0, _x, _y, _s, _pr_x, _pr_y, _tex); drawOverlayPreviewSingle(0, _x, _y, _s, _pr_x, _pr_y, _tex);
inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); return 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
@ -150,13 +164,14 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i]; var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue; if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); var _hov = _node.drawOverlayPreview(active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= _hov;
} }
return; return active;
} }
var _shp = getInputData(5); var _shp = getInputData(5);
if(_shp != 2) return; if(_shp != 2) return active;
var meshes = attributes.mesh; var meshes = attributes.mesh;
var _hover = -1, _side = 0; var _hover = -1, _side = 0;
@ -224,10 +239,10 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(mouse_release(mb_left)) if(mouse_release(mb_left))
anchor_dragging = -1; anchor_dragging = -1;
return; return active;
} }
if(hover == -1) return; if(hover == -1) return active;
if(frac(hover) == 0) { if(frac(hover) == 0) {
if(mouse_click(mb_left, active)) { if(mouse_click(mb_left, active)) {
@ -255,11 +270,14 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
anchor_drag_my = _my; anchor_drag_my = _my;
} }
} }
return active;
} #endregion } #endregion
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 _pix = getInputData(11);
if(is_array(_tex)) _tex = array_safe_get(_tex, index); if(is_array(_tex)) _tex = array_safe_get(_tex, index);
@ -324,25 +342,30 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var cc = buffer_read(surface_buffer, buffer_u32); var cc = buffer_read(surface_buffer, buffer_u32);
var _a = (cc & (0b11111111 << 24)) >> 24; var _a = (cc & (0b11111111 << 24)) >> 24;
if(_a > 0) if(_a > 0) _pm[? point_direction_positive(cmX, cmY, i, j)] = [ i, j ];
_pm[? point_direction_positive(cmX, cmY, i, j)] = [i, j];
} }
if(ds_map_size(_pm)) { if(ds_map_size(_pm)) {
var keys = ds_map_keys_to_array(_pm); var keys = ds_map_keys_to_array(_pm);
array_sort(keys, false); array_sort(keys, false);
for( var i = 0, n = array_length(keys); i < n; i++ ) { var _minx = ww, _maxx = 0;
//print($"Getting key {keys[i]} - {_pm[? keys[i]]}"); var _miny = hh, _maxy = 0;
for( var i = 0, n = array_length(keys); i < n; 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];
_minx = min(_minx, px + 0.5);
_maxx = max(_maxx, px + 0.5);
_miny = min(_miny, py + 0.5);
_maxy = max(_maxy, py + 0.5);
if(px > cmX) px++; if(px > cmX) px++;
if(py > cmY) py++; if(py > cmY) py++;
if(_exp != 0) { if(_exp != 0) {
var dist = point_distance(cmX, cmY, px, py) + _exp; var dist = max(0.5, point_distance(cmX, cmY, px, py) + _exp);
var dirr = point_direction(cmX, cmY, px, py); var dirr = point_direction(cmX, cmY, px, py);
px = cmX + lengthdir_x(dist, dirr); px = cmX + lengthdir_x(dist, dirr);
@ -357,8 +380,10 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _sm = ds_map_create(); var _sm = ds_map_create();
for( var i = 0, n = array_length(mesh); i < n; i++ ) if(array_length(mesh)) {
_sm[? point_direction_positive(cmX, cmY, mesh[i][0], mesh[i][1])] = [ mesh[i][0], mesh[i][1] ]; for( var i = 0, n = array_length(mesh); i < n; i++ )
_sm[? point_direction_positive(cmX, cmY, mesh[i][0], mesh[i][1])] = [ mesh[i][0], mesh[i][1] ];
}
var keys = ds_map_keys_to_array(_sm); var keys = ds_map_keys_to_array(_sm);
mesh = []; mesh = [];
@ -375,6 +400,15 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
ds_map_destroy(_sm); ds_map_destroy(_sm);
} }
if(_pix && array_empty(mesh)) {
mesh = [
[ _minx - 0.5, _minx - 0.5 ],
[ _maxx + 0.5, _minx - 0.5 ],
[ _maxx + 0.5, _maxy + 0.5 ],
[ _minx - 0.5, _maxy + 0.5 ],
];
}
ds_map_destroy(_pm); ds_map_destroy(_pm);
surface_free(temp); surface_free(temp);
buffer_delete(surface_buffer); buffer_delete(surface_buffer);
@ -629,6 +663,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr
inputs[| 9].setVisible(_shp == 2); inputs[| 9].setVisible(_shp == 2);
inputs[| 10].setVisible(_shp == 2); inputs[| 10].setVisible(_shp == 2);
inputs[| 11].setVisible(_shp == 2);
var _tex = getInputData(6); var _tex = getInputData(6);

View file

@ -52,7 +52,8 @@ function Node_Rigid_Object_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i]; var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue; if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); var _hov = _node.drawOverlayPreview(active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= !_hov;
} }
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);

View file

@ -47,14 +47,24 @@ function Node_Rigid_Override(_x, _y, _group = noone) : Node(_x, _y, _group) cons
if(obj == noone || !instance_exists(obj)) continue; if(obj == noone || !instance_exists(obj)) continue;
if(is_undefined(obj.phy_active)) continue; if(is_undefined(obj.phy_active)) continue;
if(is_array(_pos) && array_length(_pos) > i && is_array(_pos[i])) { if(is_array(_pos) && array_length(_pos)) {
obj.x = _pos[i][0]; if(is_array(_pos[0])) {
obj.y = _pos[i][1]; obj.x = _pos[i][0];
obj.y = _pos[i][1];
} else {
obj.x = _pos[0];
obj.y = _pos[1];
}
} }
if(is_array(_sca) && array_length(_sca) > i && is_array(_sca[i])) { if(is_array(_sca) && array_length(_sca)) {
obj.xscale = _sca[i][0]; if(is_array(_sca[0])) {
obj.yscale = _sca[i][1]; obj.xscale = _sca[i][0];
obj.yscale = _sca[i][1];
} else {
obj.xscale = _sca[0];
obj.yscale = _sca[1];
}
} }
if(is_array(_rot) && array_length(_rot) > i) if(is_array(_rot) && array_length(_rot) > i)

View file

@ -25,19 +25,18 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
attributes.show_objects = !attributes.show_objects; attributes.show_objects = !attributes.show_objects;
})]); })]);
static createNewInput = function() {
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone )
.setVisible(true, true);
}
if(!LOADING && !APPENDING) createNewInput();
insp2UpdateTooltip = "Clear cache"; insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ]; insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static onInspector2Update = function() { clearCache(); } static onInspector2Update = function() { clearCache(); }
static refreshDynamicInput = function() { static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone )
.setVisible(true, true);
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static refreshDynamicInput = function() { #region
var _l = ds_list_create(); var _l = ds_list_create();
for( var i = 0; i < ds_list_size(inputs); i++ ) { for( var i = 0; i < ds_list_size(inputs); i++ ) {
if(i < input_fix_len || inputs[| i].value_from) if(i < input_fix_len || inputs[| i].value_from)
@ -53,14 +52,14 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
inputs = _l; inputs = _l;
createNewInput(); createNewInput();
} } #endregion
static onValueFromUpdate = function(index) { static onValueFromUpdate = function(index) { #region
if(index < input_fix_len) return; if(index < input_fix_len) return;
if(LOADING || APPENDING) return; if(LOADING || APPENDING) return;
refreshDynamicInput(); refreshDynamicInput();
} } #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
if(!is_instanceof(group, Node_Rigid_Group)) return; if(!is_instanceof(group, Node_Rigid_Group)) return;
@ -69,19 +68,20 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) {
var _node = group.nodes[| i]; var _node = group.nodes[| i];
if(!is_instanceof(_node, Node_Rigid_Object)) continue; if(!is_instanceof(_node, Node_Rigid_Object)) continue;
_node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); var _hov = _node.drawOverlayPreview(active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= !_hov;
} }
} #endregion } #endregion
static step = function() { static step = function() { #region
var _dim = getInputData(0); var _dim = getInputData(0);
var _outSurf = outputs[| 0].getValue(); var _outSurf = outputs[| 0].getValue();
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
outputs[| 0].setValue(_outSurf); outputs[| 0].setValue(_outSurf);
} } #endregion
static update = function(frame = PROJECT.animator.current_frame) { static update = function(frame = PROJECT.animator.current_frame) { #region
if(recoverCache() || !PROJECT.animator.is_playing) if(recoverCache() || !PROJECT.animator.is_playing)
return; return;
@ -138,5 +138,5 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
surface_reset_target(); surface_reset_target();
cacheCurrentFrame(_outSurf); cacheCurrentFrame(_outSurf);
} } #endregion
} }

View file

@ -0,0 +1,176 @@
function Node_Rigid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x, _y, _group) constructor {
name = "Render";
color = COLORS.node_blend_simulation;
icon = THEME.rigidSim;
use_cache = CACHE_USE.auto;
w = 128;
h = 128;
min_h = h;
previewable = true;
inputs[| 0] = nodeValue("Render dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, DEF_SURF)
.setDisplay(VALUE_DISPLAY.vector)
.rejectArray();
inputs[| 1] = nodeValue("Round position", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
setIsDynamicInput(1);
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;
})]);
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static onInspector2Update = function() { clearCache(); }
static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone )
.setVisible(true, true);
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static createOutput = function(override_order = true) { #region
if(group == noone) return;
if(!is_struct(group)) return;
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);
outParent = nodeValue("Value", group, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone)
.uncache()
.setVisible(true, true);
outParent.from = self;
ds_list_add(group.outputs, outParent);
group.setHeight();
group.sortIO();
} if(!LOADING && !APPENDING) createOutput(); #endregion
static refreshDynamicInput = function() { #region
var _l = ds_list_create();
for( var i = 0; i < ds_list_size(inputs); i++ ) {
if(i < input_fix_len || inputs[| i].value_from)
ds_list_add(_l, inputs[| i]);
else
delete inputs[| i];
}
for( var i = 0; i < ds_list_size(_l); i++ )
_l[| i].index = i;
ds_list_destroy(inputs);
inputs = _l;
createNewInput();
} #endregion
static onValueFromUpdate = function(index) { #region
if(index < input_fix_len) return;
if(LOADING || APPENDING) return;
refreshDynamicInput();
} #endregion
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;
var _hov = _node.drawOverlayPreview(active, _x, _y, _s, _mx, _my, _snx, _sny);
active &= !_hov;
}
} #endregion
static step = function() { #region
var _dim = getInputData(0);
var _outSurf = outParent.getValue();
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
outParent.setValue(_outSurf);
} #endregion
static update = function(frame = PROJECT.animator.current_frame) { #region
if(!is_instanceof(outParent, NodeValue)) return noone;
var _dim = getInputData(0);
var _rnd = getInputData(1);
var _outSurf = outParent.getValue();
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
outParent.setValue(_outSurf);
surface_set_target(_outSurf);
DRAW_CLEAR
if(TESTING && keyboard_check(ord("D"))) {
var flag = phy_debug_render_shapes | phy_debug_render_coms;
draw_set_color(c_white);
physics_world_draw_debug(flag);
} else {
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i++ ) {
var objNode = getInputData(i);
if(!is_array(objNode)) objNode = [ objNode ];
for( var j = 0; j < array_length(objNode); j++ ) {
if(!variable_struct_exists(objNode[j], "object")) continue;
var obj = objNode[j].object;
if(!is_array(obj)) obj = [ obj ];
for( var k = 0; k < array_length(obj); k++ ) {
var _o = obj[k];
if(_o == noone || !instance_exists(_o)) continue;
if(is_undefined(_o.phy_active)) continue;
var ixs = max(0, _o.xscale);
var iys = max(0, _o.yscale);
var xx = _rnd? round(_o.phy_position_x) : _o.phy_position_x;
var yy = _rnd? round(_o.phy_position_y) : _o.phy_position_y;
draw_surface_ext_safe(_o.surface, xx, yy, ixs, iys, _o.image_angle, _o.image_blend, _o.image_alpha);
}
}
}
}
draw_set_color(c_white);
physics_draw_debug();
surface_reset_target();
cacheCurrentFrame(_outSurf);
} #endregion
static recoverCache = function(frame = PROJECT.animator.current_frame) { #region
if(!is_instanceof(outParent, NodeValue)) return false;
if(!cacheExist(frame)) return false;
var _s = cached_output[PROJECT.animator.current_frame];
outParent.setValue(_s);
return true;
} #endregion
static getGraphPreviewSurface = function() { #region
if(!is_instanceof(outParent, NodeValue)) return noone;
return outParent.getValue();
} #endregion
static getPreviewValues = function() { #region
if(!is_instanceof(outParent, NodeValue)) return noone;
return outParent.getValue();
} #endregion
}

View file

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

View file

@ -505,6 +505,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
is_anim = false; is_anim = false;
sep_axis = false; sep_axis = false;
animable = true;
sepable = is_array(_value) && array_length(_value) > 1; sepable = is_array(_value) && array_length(_value) > 1;
animator = new valueAnimator(_value, self, false); animator = new valueAnimator(_value, self, false);
animators = []; animators = [];
@ -651,6 +652,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return self; return self;
} #endregion } #endregion
static setAnimable = function(_anim) { #region
animable = _anim;
return self;
} #endregion
static rejectArray = function() { #region static rejectArray = function() { #region
accept_array = false; accept_array = false;
return self; return self;
@ -694,7 +700,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static isAnimable = function() { #region static isAnimable = function() { #region
if(type == VALUE_TYPE.PCXnode) return false; if(type == VALUE_TYPE.PCXnode) return false;
if(display_type == VALUE_DISPLAY.text_array) return false; if(display_type == VALUE_DISPLAY.text_array) return false;
return true; return animable;
} #endregion } #endregion
static setDropKey = function() { #region static setDropKey = function() { #region

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,74 @@
{
"resourceType": "GMSprite",
"resourceVersion": "1.0",
"name": "s_node_fluidSim_render_output",
"bbox_bottom": 63,
"bbox_left": 0,
"bbox_right": 63,
"bbox_top": 0,
"bboxMode": 0,
"collisionKind": 1,
"collisionTolerance": 0,
"DynamicTexturePage": false,
"edgeFiltering": false,
"For3D": false,
"frames": [
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"e3712691-a029-4014-b645-05675c1d23af",},
],
"gridX": 0,
"gridY": 0,
"height": 64,
"HTile": false,
"layers": [
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"cebdd350-03e7-45e6-b841-b870b73cec4f","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_render_output",
"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":"e3712691-a029-4014-b645-05675c1d23af","path":"sprites/s_node_fluidSim_render_output/s_node_fluidSim_render_output.yy",},},},"Disabled":false,"id":"c6097872-13e3-4cd6-bba3-9e024832c223","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,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,74 @@
{
"resourceType": "GMSprite",
"resourceVersion": "1.0",
"name": "s_node_rigidSim_render_output",
"bbox_bottom": 63,
"bbox_left": 0,
"bbox_right": 63,
"bbox_top": 0,
"bboxMode": 0,
"collisionKind": 1,
"collisionTolerance": 0,
"DynamicTexturePage": false,
"edgeFiltering": false,
"For3D": false,
"frames": [
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"500ef202-e0fc-4db9-8bec-586945c2c5b2",},
],
"gridX": 0,
"gridY": 0,
"height": 64,
"HTile": false,
"layers": [
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"e212d156-4bd8-4075-b75e-1352f801d09c","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
],
"nineSlice": null,
"origin": 4,
"parent": {
"name": "rigidSim",
"path": "folders/nodes/icons/rigidSim.yy",
},
"preMultiplyAlpha": false,
"sequence": {
"resourceType": "GMSequence",
"resourceVersion": "1.4",
"name": "s_node_rigidSim_render_output",
"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":"500ef202-e0fc-4db9-8bec-586945c2c5b2","path":"sprites/s_node_rigidSim_render_output/s_node_rigidSim_render_output.yy",},},},"Disabled":false,"id":"21236896-2671-4f95-9567-2143272f765d","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,
}