From 22d44588f0aaf8c7a241f16937d81bc992ae6800 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 16 Jul 2024 10:08:51 +0700 Subject: [PATCH] - [Bake Path] Fix baking looped path not loop properly. --- PixelComposer.resource_order | 1 + PixelComposer.yyp | 1 + scripts/node_line/node_line.gml | 3 +- scripts/node_path_bake/node_path_bake.gml | 7 +- scripts/node_registry/node_registry.gml | 1 + .../node_segment_filter.gml | 90 ++++++++++++++++-- .../c1b657e5-c3da-43e5-b1e1-c9faa02ff38d.png | Bin 0 -> 1730 bytes .../10094d74-f749-4689-86f0-27a6c21d9e46.png | Bin 0 -> 1730 bytes .../s_node_segment_filter.yy | 90 ++++++++++++++++++ 9 files changed, 180 insertions(+), 13 deletions(-) create mode 100644 sprites/s_node_segment_filter/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d.png create mode 100644 sprites/s_node_segment_filter/layers/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d/10094d74-f749-4689-86f0-27a6c21d9e46.png create mode 100644 sprites/s_node_segment_filter/s_node_segment_filter.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 12e70a52d..f668b11fc 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -2043,6 +2043,7 @@ {"name":"s_node_scatter_point","order":9,"path":"sprites/s_node_scatter_point/s_node_scatter_point.yy",}, {"name":"s_node_scatter","order":19,"path":"sprites/s_node_scatter/s_node_scatter.yy",}, {"name":"s_node_sdf","order":47,"path":"sprites/s_node_sdf/s_node_sdf.yy",}, + {"name":"s_node_segment_filter","order":21,"path":"sprites/s_node_segment_filter/s_node_segment_filter.yy",}, {"name":"s_node_separate_file_path","order":14,"path":"sprites/s_node_separate_file_path/s_node_separate_file_path.yy",}, {"name":"s_node_sepearte_shape","order":48,"path":"sprites/s_node_sepearte_shape/s_node_sepearte_shape.yy",}, {"name":"s_node_shadow_cast","order":50,"path":"sprites/s_node_shadow_cast/s_node_shadow_cast.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index f017e1860..2aee9abef 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -2589,6 +2589,7 @@ {"id":{"name":"s_node_scatter_point","path":"sprites/s_node_scatter_point/s_node_scatter_point.yy",},}, {"id":{"name":"s_node_scatter","path":"sprites/s_node_scatter/s_node_scatter.yy",},}, {"id":{"name":"s_node_sdf","path":"sprites/s_node_sdf/s_node_sdf.yy",},}, + {"id":{"name":"s_node_segment_filter","path":"sprites/s_node_segment_filter/s_node_segment_filter.yy",},}, {"id":{"name":"s_node_separate_file_path","path":"sprites/s_node_separate_file_path/s_node_separate_file_path.yy",},}, {"id":{"name":"s_node_sepearte_shape","path":"sprites/s_node_sepearte_shape/s_node_sepearte_shape.yy",},}, {"id":{"name":"s_node_shadow_cast","path":"sprites/s_node_shadow_cast/s_node_shadow_cast.yy",},}, diff --git a/scripts/node_line/node_line.gml b/scripts/node_line/node_line.gml index fa754f3de..7ca7fdd1c 100644 --- a/scripts/node_line/node_line.gml +++ b/scripts/node_line/node_line.gml @@ -72,7 +72,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons inputs[| 28] = nodeValue("Segments", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [[]]) .setDisplay(VALUE_DISPLAY.vector) - .setArrayDepth(1); + .setArrayDepth(2); input_display_list = [ ["Output", true], 0, 1, @@ -191,7 +191,6 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons if(_dtype == 1 && _pat == noone) return _outData; if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0]))) return _outData; - if(IS_FIRST_FRAME || inputs[| 11].is_anim) ds_map_clear(widthMap); diff --git a/scripts/node_path_bake/node_path_bake.gml b/scripts/node_path_bake/node_path_bake.gml index f3d370e23..cefa89eb3 100644 --- a/scripts/node_path_bake/node_path_bake.gml +++ b/scripts/node_path_bake/node_path_bake.gml @@ -11,7 +11,7 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct outputs[| 0] = nodeValue("Segments", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [[]]) .setDisplay(VALUE_DISPLAY.vector) - .setArrayDepth(1); + .setArrayDepth(2); path_amount = 1; @@ -50,6 +50,7 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct if(_path == noone) return; if(_dist <= 0) return; + var _loop = struct_try_get(_path, "path_loop", false); var _amo = _path.getLineCount(); path_amount = _amo; var _segs = array_create(_amo); @@ -67,6 +68,8 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct _p = _path.getPointDistance(j, i, _p); array_push(_seg, [ _p.x, _p.y, j / _len ]); } + + if(_loop) array_push(_seg, [ _seg[0][0], _seg[0][1], 1 ]); } if(_sped && _amo == 1) _segs = _segs[0]; @@ -75,6 +78,6 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); - draw_sprite_fit(THEME.node_draw_path, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); + draw_sprite_bbox_uniform(THEME.node_draw_path, 0, bbox); } } \ No newline at end of file diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 4bae9c859..bca5bd79d 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -914,6 +914,7 @@ function __initNodes() { addNodeObject(values, "Map Path", s_node_path_mapp, "Node_Path_Map", [1, Node_Path_Map]).setVersion(11640); addNodeObject(values, "Scatter Path", s_node_path_scatter, "Node_Path_Scatter", [1, Node_Path_Scatter]).setVersion(11740); addNodeObject(values, "3D Path", s_node_path_3d, "Node_Path_3D", [1, Node_Path_3D], [ "path 3d" ]).setVersion(11750); + addNodeObject(values, "Filter Segments",s_node_segment_filter, "Node_Segment_Filter", [1, Node_Segment_Filter]).setVersion(11780); ds_list_add(values, "Boolean"); addNodeObject(values, "Boolean", s_node_boolean, "Node_Boolean", [1, Node_Boolean]); diff --git a/scripts/node_segment_filter/node_segment_filter.gml b/scripts/node_segment_filter/node_segment_filter.gml index c7ee45ed3..6569d25ef 100644 --- a/scripts/node_segment_filter/node_segment_filter.gml +++ b/scripts/node_segment_filter/node_segment_filter.gml @@ -1,42 +1,114 @@ function Node_Segment_Filter(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Segment Filter"; + name = "Filter Segment"; setDimension(96, 48); inputs[| 0] = nodeValue("Segments", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [[]]) .setDisplay(VALUE_DISPLAY.vector) + .setVisible(true, true) .setArrayDepth(1); - inputs[| 1] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + inputs[| 1] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.rotation); + inputs[| 2] = nodeValue("Spread", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 15); + + inputs[| 3] = nodeValue("Both side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); + outputs[| 0] = nodeValue("Segments", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [[]]) - .setVisible(false) - .setArrayDepth(1); + .setDisplay(VALUE_DISPLAY.vector) + .setArrayDepth(2); input_display_list = [ ["Segments", false], 0, - ["Filter", false], 1, + ["Filter", false], 1, 2, 3, ]; path_preview_surface = noone; static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { + var _segs = outputs[| 0].getValue(); + var ox, oy, nx, ny; + if(array_invalid(_segs) || array_invalid(_segs[0])) return; + if(!is_array(_segs[0][0])) _segs = [ _segs ]; + + draw_set_color(COLORS._main_icon); + + for( var i = 0, n = array_length(_segs); i < n; i++ ) { + var _seg = _segs[i]; + var ox = _x + _seg[0][0] * _s; + var oy = _y + _seg[0][1] * _s; + + for( var j = 1, m = array_length(_seg); j < m; j++ ) { + nx = _x + _seg[j][0] * _s; + ny = _y + _seg[j][1] * _s; + + draw_line_width(ox, oy, nx, ny, 3); + + ox = nx; + oy = ny; + } + } } static update = function(frame = CURRENT_FRAME) { - var _segments = getInputData(0); - - if(!is_array(_segments) || array_empty(_segments) || !is_array(_segments[0])) return; + var _segments = getInputData(0); + var _angle = getInputData(1); + var _spread = getInputData(2); + var _both = getInputData(3); + if(array_invalid(_segments) || array_invalid(_segments[0])) return; if(!is_array(_segments[0][0])) //spreaded single path _segments = [ _segments ]; + var _amo = array_length(_segments); + var _segOut = []; + for(var i = 0; i < _amo; i++) { + var _segIn = _segments[i]; + if(array_empty(_segIn)) continue; + + var _ox = _segIn[0][0], _oy = _segIn[0][1], _nx, _ny; + var _inc = false; + var _dir, _drv; + var _seg = []; + + for (var j = 1, n = array_length(_segIn); j < n; j++) { + _nx = _segIn[j][0]; + _ny = _segIn[j][1]; + + _dir = point_direction(_ox, _oy, _nx, _ny); + _drv = abs(angle_difference(_dir, _angle)); + if(_both) _drv = min(_drv, abs(angle_difference(_dir, _angle + 180))); + + if(_drv < _spread) { + if(!_inc) array_push(_seg, [ _ox, _oy ]); + + array_push(_seg, [ _nx, _ny ]); + _inc = true; + + } else { + if(!array_empty(_seg)) { + array_push(_segOut, _seg); + _seg = []; + } + + _inc = false; + } + + _ox = _nx; + _oy = _ny; + } + + if(!array_empty(_seg)) array_push(_segOut, _seg); + } + + outputs[| 0].setValue(_segOut); } static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); - + draw_sprite_bbox_uniform(s_node_segment_filter, 0, bbox); } } \ No newline at end of file diff --git a/sprites/s_node_segment_filter/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d.png b/sprites/s_node_segment_filter/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d.png new file mode 100644 index 0000000000000000000000000000000000000000..ce51e2bef61ec3adb5e9470c993b0f4218e11bc2 GIT binary patch literal 1730 zcmZ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W zcMd@$_iR)SuWDU1hZf{FM##7gTNJd@Y8_GBgryCbzmT^hYMs%``uQNAO^VV;9cX$B zlXguFS5e%eXU|u*S@?V8no9$lPI)yO=t=-thD^O@=YDPDC(ek@qim}`pa;cd&55{v zvcgso+^7uI7=%xEV`{=T-TkvYb@7nD4zH?>?U)ur(7&DId1#lka7wZ?ms?c#O=)LB z#%8u^y7oe!Gn+8112rfo^VUUf$4GvUKD*41hg&I=4~ntOHowgXH!E)|cvJi0aqgwI zNGRjx0xM(70tzpa;CHziVxsSc&Tt`Stw~Pjl(BChQ5|PL$=-++h|;It`Q6_q!*Hec zf0>yE#+?84WP-7>cIM-?yk`cD(Li+E2+rkYHNCQ7)b_^5!0_sC*XZfglu<7?xU|Ot zuTj)n=hXH`9cFm$gUrBpO4Hqrk248~m)PCU`dE)#zF0%Icllu`5MpR8Y`;m{KNkGc zhV&sc1S^?cq^6diG1knQzL39$RoGe0r-uNhO|bnL>^nU?HRk!-*I)rZar7VDQX%=d z^WSFn)h8V4y)&oA6h1(CVa6f3ZKR!o{CnEJlfS#P8R}}J3dIRfrB;38h($ literal 0 HcmV?d00001 diff --git a/sprites/s_node_segment_filter/layers/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d/10094d74-f749-4689-86f0-27a6c21d9e46.png b/sprites/s_node_segment_filter/layers/c1b657e5-c3da-43e5-b1e1-c9faa02ff38d/10094d74-f749-4689-86f0-27a6c21d9e46.png new file mode 100644 index 0000000000000000000000000000000000000000..ce51e2bef61ec3adb5e9470c993b0f4218e11bc2 GIT binary patch literal 1730 zcmZ{kc~FyA7slTtB!MJAAP|CVVG{w7urERk7(n(A7Na7>Mr08*LJXin61HMkDvc;0 zVNt6XDuxyTWeWwNtS%MH7=%cRVnB=Hh8F1Cf4-UTkIp^!J~Q{s@408@+&O1yVFBu> zEhqp0)C2cW>7Y{n-Kq%ilq8>+1%=4kLk|UjQ(FOmUjP7Kz$^YD0GuQNfRYISo>c&# z$F98_;RPlT-vkFxfz5w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f$4GvUKD*41hg&I=4~ntOHowgXH!E)|cvJi0aqgwI zNGRjx0xM(70tzpa;CHziVxsSc&Tt`Stw~Pjl(BChQ5|PL$=-++h|;It`Q6_q!*Hec zf0>yE#+?84WP-7>cIM-?yk`cD(Li+E2+rkYHNCQ7)b_^5!0_sC*XZfglu<7?xU|Ot zuTj)n=hXH`9cFm$gUrBpO4Hqrk248~m)PCU`dE)#zF0%Icllu`5MpR8Y`;m{KNkGc zhV&sc1S^?cq^6diG1knQzL39$RoGe0r-uNhO|bnL>^nU?HRk!-*I)rZar7VDQX%=d z^WSFn)h8V4y)&oA6h1(CVa6f3ZKR!o{CnEJlfS#P8R}}J3dIRfrB;38h($ literal 0 HcmV?d00001 diff --git a/sprites/s_node_segment_filter/s_node_segment_filter.yy b/sprites/s_node_segment_filter/s_node_segment_filter.yy new file mode 100644 index 000000000..c8a3b7b56 --- /dev/null +++ b/sprites/s_node_segment_filter/s_node_segment_filter.yy @@ -0,0 +1,90 @@ +{ + "$GMSprite":"", + "%Name":"s_node_segment_filter", + "bboxMode":0, + "bbox_bottom":59, + "bbox_left":6, + "bbox_right":57, + "bbox_top":5, + "collisionKind":1, + "collisionTolerance":0, + "DynamicTexturePage":false, + "edgeFiltering":false, + "For3D":false, + "frames":[ + {"$GMSpriteFrame":"","%Name":"c1b657e5-c3da-43e5-b1e1-c9faa02ff38d","name":"c1b657e5-c3da-43e5-b1e1-c9faa02ff38d","resourceType":"GMSpriteFrame","resourceVersion":"2.0",}, + ], + "gridX":0, + "gridY":0, + "height":64, + "HTile":false, + "layers":[ + {"$GMImageLayer":"","%Name":"10094d74-f749-4689-86f0-27a6c21d9e46","blendMode":0,"displayName":"default","isLocked":false,"name":"10094d74-f749-4689-86f0-27a6c21d9e46","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,}, + ], + "name":"s_node_segment_filter", + "nineSlice":null, + "origin":4, + "parent":{ + "name":"path", + "path":"folders/nodes/icons/value/path.yy", + }, + "preMultiplyAlpha":false, + "resourceType":"GMSprite", + "resourceVersion":"2.0", + "sequence":{ + "$GMSequence":"", + "%Name":"s_node_segment_filter", + "autoRecord":true, + "backdropHeight":768, + "backdropImageOpacity":0.5, + "backdropImagePath":"", + "backdropWidth":1366, + "backdropXOffset":0.0, + "backdropYOffset":0.0, + "events":{ + "$KeyframeStore":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "eventStubScript":null, + "eventToFunction":{}, + "length":1.0, + "lockOrigin":false, + "moments":{ + "$KeyframeStore":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "name":"s_node_segment_filter", + "playback":1, + "playbackSpeed":30.0, + "playbackSpeedType":0, + "resourceType":"GMSequence", + "resourceVersion":"2.0", + "showBackdrop":true, + "showBackdropImage":false, + "timeUnits":1, + "tracks":[ + {"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore":"","Keyframes":[ + {"$Keyframe":"","Channels":{ + "0":{"$SpriteFrameKeyframe":"","Id":{"name":"c1b657e5-c3da-43e5-b1e1-c9faa02ff38d","path":"sprites/s_node_segment_filter/s_node_segment_filter.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",}, + },"Disabled":false,"id":"7040ce2f-17fc-4079-8d86-f936121cdeab","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe","resourceVersion":"2.0","Stretch":false,}, + ],"resourceType":"KeyframeStore","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,}, + ], + "visibleRange":null, + "volume":1.0, + "xorigin":32, + "yorigin":32, + }, + "swatchColours":null, + "swfPrecision":0.5, + "textureGroupId":{ + "name":"Default", + "path":"texturegroups/Default", + }, + "type":0, + "VTile":false, + "width":64, +} \ No newline at end of file