diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 9ebd1b973..837581c3a 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -723,6 +723,7 @@ {"name":"node_armature_sample","order":13,"path":"scripts/node_armature_sample/node_armature_sample.yy",}, {"name":"node_armature","order":9,"path":"scripts/node_armature/node_armature.yy",}, {"name":"node_array_add","order":6,"path":"scripts/node_array_add/node_array_add.yy",}, + {"name":"node_array_boolean_opr","order":23,"path":"scripts/node_array_boolean_opr/node_array_boolean_opr.yy",}, {"name":"node_array_composite","order":17,"path":"scripts/node_array_composite/node_array_composite.yy",}, {"name":"node_array_convolute","order":16,"path":"scripts/node_array_convolute/node_array_convolute.yy",}, {"name":"node_array_copy","order":14,"path":"scripts/node_array_copy/node_array_copy.yy",}, @@ -1929,6 +1930,7 @@ {"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",}, {"name":"s_node_armature","order":16,"path":"sprites/s_node_armature/s_node_armature.yy",}, {"name":"s_node_array_add","order":1,"path":"sprites/s_node_array_add/s_node_array_add.yy",}, + {"name":"s_node_array_boolean_opr","order":23,"path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",}, {"name":"s_node_array_composite","order":2,"path":"sprites/s_node_array_composite/s_node_array_composite.yy",}, {"name":"s_node_array_convolute","order":3,"path":"sprites/s_node_array_convolute/s_node_array_convolute.yy",}, {"name":"s_node_array_copy","order":4,"path":"sprites/s_node_array_copy/s_node_array_copy.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index d1157f590..06a791749 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1101,6 +1101,7 @@ {"$GMIncludedFile":"","%Name":"tooltip_spr.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Transform/Node_Warp","name":"tooltip_spr.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Transform/Node_Wrap_Area","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Add","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Composite","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Convolute","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -1109,7 +1110,6 @@ {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Get","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Insert","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Length","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Range copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Range","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Rearrange","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Remove","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -1120,6 +1120,7 @@ {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Shuffle","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Sort","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Split","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Zip","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -1883,6 +1884,7 @@ {"id":{"name":"node_armature_sample","path":"scripts/node_armature_sample/node_armature_sample.yy",},}, {"id":{"name":"node_armature","path":"scripts/node_armature/node_armature.yy",},}, {"id":{"name":"node_array_add","path":"scripts/node_array_add/node_array_add.yy",},}, + {"id":{"name":"node_array_boolean_opr","path":"scripts/node_array_boolean_opr/node_array_boolean_opr.yy",},}, {"id":{"name":"node_array_composite","path":"scripts/node_array_composite/node_array_composite.yy",},}, {"id":{"name":"node_array_convolute","path":"scripts/node_array_convolute/node_array_convolute.yy",},}, {"id":{"name":"node_array_copy","path":"scripts/node_array_copy/node_array_copy.yy",},}, @@ -3253,6 +3255,7 @@ {"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},}, {"id":{"name":"s_node_armature","path":"sprites/s_node_armature/s_node_armature.yy",},}, {"id":{"name":"s_node_array_add","path":"sprites/s_node_array_add/s_node_array_add.yy",},}, + {"id":{"name":"s_node_array_boolean_opr","path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",},}, {"id":{"name":"s_node_array_composite","path":"sprites/s_node_array_composite/s_node_array_composite.yy",},}, {"id":{"name":"s_node_array_convolute","path":"sprites/s_node_array_convolute/s_node_array_convolute.yy",},}, {"id":{"name":"s_node_array_copy","path":"sprites/s_node_array_copy/s_node_array_copy.yy",},}, diff --git a/datafiles/data/Nodes/Internal.zip b/datafiles/data/Nodes/Internal.zip index 1a857ae48..b4a1b8f37 100644 Binary files a/datafiles/data/Nodes/Internal.zip and b/datafiles/data/Nodes/Internal.zip differ diff --git a/datafiles/data/Nodes/Internal/Color/Node_Color_to_HSV/info.json b/datafiles/data/Nodes/Internal/Color/Node_Color_to_HSV/info.json index c7637302f..be36ed671 100644 --- a/datafiles/data/Nodes/Internal/Color/Node_Color_to_HSV/info.json +++ b/datafiles/data/Nodes/Internal/Color/Node_Color_to_HSV/info.json @@ -6,4 +6,5 @@ "io":[ "color" ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Color/Node_Color_to_OKLCH/info.json b/datafiles/data/Nodes/Internal/Color/Node_Color_to_OKLCH/info.json index 0acfda138..18022fe77 100644 --- a/datafiles/data/Nodes/Internal/Color/Node_Color_to_OKLCH/info.json +++ b/datafiles/data/Nodes/Internal/Color/Node_Color_to_OKLCH/info.json @@ -6,4 +6,5 @@ "io":[ "color" ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Color/Node_Color_to_RGB/info.json b/datafiles/data/Nodes/Internal/Color/Node_Color_to_RGB/info.json index fcd51336c..a4c6bd142 100644 --- a/datafiles/data/Nodes/Internal/Color/Node_Color_to_RGB/info.json +++ b/datafiles/data/Nodes/Internal/Color/Node_Color_to_RGB/info.json @@ -6,4 +6,5 @@ "io":[ "color" ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json new file mode 100644 index 000000000..78c45d789 --- /dev/null +++ b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json @@ -0,0 +1,10 @@ +{ + "name":"Array Boolean Opr", + "baseNode":"Node_Array_Boolean_Opr", + "tooltip":"Apply a boolean operation bewteen two arrays.", + "spr":"s_node_array_boolean_opr", + "io":[ + "float" + ], + "pxc_version":118069, +} \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique/info.json b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique/info.json index ef9a03422..1d6546ee6 100644 --- a/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique/info.json +++ b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique/info.json @@ -6,4 +6,5 @@ "io":[ "float" ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix/info.json index eb8913cb7..30e92b8ca 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Color_Apply/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Color_Apply/info.json index 8a56fe698..f71ff04f7 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Color_Apply/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Color_Apply/info.json @@ -7,4 +7,5 @@ "float", "surface" ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Det/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Det/info.json index 88410d9a9..0ef0b6b0f 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Det/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Det/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Invert/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Invert/info.json index fb00e319d..872a55f44 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Invert/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Invert/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Math/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Math/info.json index 2dd116446..3f1410fee 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Math/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Math/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Multiply_Vector/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Multiply_Vector/info.json index 567e627c2..d436de058 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Multiply_Vector/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Multiply_Vector/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Set/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Set/info.json index 0b79e7a05..4ab795e75 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Set/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Set/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_To_Array/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_To_Array/info.json index 4cdab309e..d14bf6c24 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_To_Array/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_To_Array/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Transpose/info.json b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Transpose/info.json index 964769984..a374600d8 100644 --- a/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Transpose/info.json +++ b/datafiles/data/Nodes/Internal/Values/Matrix/Node_Matrix_Transpose/info.json @@ -6,4 +6,5 @@ "io":[ "float", ], + "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Nodes/display_data.json b/datafiles/data/Nodes/display_data.json index b4ee30ea2..8a5173f08 100644 --- a/datafiles/data/Nodes/display_data.json +++ b/datafiles/data/Nodes/display_data.json @@ -748,6 +748,7 @@ "Node_Array_Composite", "Node_Array_Shuffle", "Node_Array_Unique", + "Node_Array_Boolean_Opr", { "label": "/Group Operators" }, "Node_Array_Sort", "Node_Iterate_Each_Inline", diff --git a/scripts/array_functions/array_functions.gml b/scripts/array_functions/array_functions.gml index 9f79b776b..a64e1d2d5 100644 --- a/scripts/array_functions/array_functions.gml +++ b/scripts/array_functions/array_functions.gml @@ -1,390 +1,433 @@ -function array_create_2d(_x, _y, val = 0) { - var _arr = array_create(_x); - for( var i = 0; i < _x; i++ ) - _arr[i] = array_create(_y, val); - return _arr; -} - -function array_create_from_list(list) { - if(list == undefined) return []; - if(!ds_exists(list, ds_type_list)) return []; - - var arr = array_create(ds_list_size(list)); - for( var i = 0; i < ds_list_size(list); i++ ) - arr[i] = list[| i]; - return arr; -} - -function array_safe_set(arr, index, value, fill = 0) { - if(!is_array(arr)) return arr; - if(is_array(index)) return arr; - - if(index < 0) return arr; - if(index >= array_length(arr)) { - var i = array_length(arr); - for(; i <= index; i++ ) - arr[i] = fill; - arr[index] = value; - return arr; - } - - array_set(arr, index, value); - return arr; -} - -function array_safe_length(arr) { - INLINE - return is_array(arr)? array_length(arr) : 0; -} - -function array_fill(arr, startIndex, endIndex, value = 0) { - INLINE - - for( var i = max(0, startIndex); i < endIndex; i++ ) - arr[i] = value; -} - -function array_resize_fill(arr, size, fill = 0) { - if(size < array_length(arr)) { - array_resize(arr, size); - return arr; - } - - var i = array_length(arr); - for(; i < size; i++) - arr[i] = fill; - return arr; -} - -enum ARRAY_OVERFLOW { - _default, - loop, - pingpong, - clamp -} - -#macro aGetF array_safe_get_fast -function array_safe_get_fast(arr, index, def = 0) { - INLINE - - return is_array(arr) && index >= 0 && index < array_length(arr)? arr[index] : def; -} - -function array_safe_get(arr, index, def = 0, overflow = ARRAY_OVERFLOW._default) { - INLINE - - if(!is_array(arr)) return def; - if(is_array(index)) return def; - - var len = array_length(arr); - if(len == 0) return def; - - if(overflow == ARRAY_OVERFLOW.clamp) { - index = clamp(index, 0, len - 1); - - } else if(overflow == ARRAY_OVERFLOW.loop) { - if(index < 0) - index = len - safe_mod(abs(index), len); - index = index % len; - - } else if(overflow == ARRAY_OVERFLOW.pingpong) { - if(index < 0) index = len - safe_mod(abs(index), len); - - var _plen = len * 2 - 1; - index = index % _plen; - - if(index >= len) - index = _plen - index; - } - - if(index < 0) return def; - if(index >= len) return def; - return arr[index] == undefined? def : arr[index]; -} - -function array_push_create(arr, val) { - INLINE - - if(!is_array(arr)) return [ val ]; - array_push(arr, val); - return arr; -} - -function array_get_decimal(arr, index, color = false) { - INLINE - - if(!is_array(arr)) return 0; - if(frac(index) == 0) return array_safe_get_fast(arr, index); - - var v0 = array_safe_get_fast(arr, floor(index)); - var v1 = array_safe_get_fast(arr, floor(index) + 1); - - return color? - merge_color(v0, v1, frac(index)) : - lerp(v0, v1, frac(index)); -} - -function array_exists(arr, val) { - INLINE - self.__temp_val = val; - - if(!is_array(arr)) return false; - var _a = array_any(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); }); - - self.__temp_val = 0; - return _a; -} - -function array_overlap(arr0, arr1) { - INLINE - self.__temp_arr = arr1; - - if(!is_array(arr0)) return false; - if(!is_array(arr1)) return false; - - var _a = array_any(arr0, function(_val, _ind) { return array_exists(self.__temp_arr, _val); }); - - self.__temp_arr = 0; - return _a; -} - -function array_empty(arr) { INLINE return is_array(arr) && array_length(arr) == 0; } -function array_valid(arr) { INLINE return is_array(arr) && array_length(arr) > 0; } -function array_invalid(arr) { INLINE return !is_array(arr) || array_length(arr) == 0; } - -function array_find(arr, val) { - INLINE - self.__temp_val = val; - - if(!is_array(arr)) return -1; - var _a = array_find_index(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); }); - - self.__temp_val = 0; - return _a; -} - -function array_find_string(arr, val) { - INLINE - self.__temp_val = string_lower(val); - - if(!is_array(arr)) return -1; - var _a = array_find_index(arr, function(_val, _ind) { return string_lower(_val) == self.__temp_val; }); - - self.__temp_val = 0; - return _a; -} - -function array_remove(arr, val) { - INLINE - - if(!is_array(arr)) return; - if(!array_exists(arr, val)) return; - var ind = array_find(arr, val); - array_delete(arr, ind, 1); -} - -function array_push_unique(arr, val) { - INLINE - - if(!is_array(arr)) return; - if(array_exists(arr, val)) return; - array_push(arr, val); -} - -function array_insert_unique(arr, ind, val) { - INLINE - - if(!is_array(arr)) return; - if(array_exists(arr, val)) return; - array_insert(arr, ind, val); -} - -function array_append(arr, arr0) { - INLINE - - if(is_undefined(arr0)) return arr; - if(!is_array(arr)) return arr; - if(!is_array(arr0)) { array_push(arr, arr0); return arr; } - - for( var i = 0, n = array_length(arr0); i < n; i++ ) - array_push(arr, arr0[i]); - return arr; -} - -function array_merge() { - INLINE - - var arr = []; - for( var i = 0; i < argument_count; i++ ) - array_append(arr, argument[i]); - - return arr; -} - -function array_clone(arr, _depth = -1) { - INLINE - - if(_depth == 0) return arr; - if(!is_array(arr)) return arr; - - var _res = []; - for( var i = 0, n = array_length(arr); i < n; i++ ) - _res[i] = array_clone(arr[i], _depth--); - - return _res; -} - -function array_min(arr) { - INLINE - - if(!is_array(arr) || array_length(arr) == 0) return 0; - - var mn = arr[0]; - for( var i = 0, n = array_length(arr); i < n; i++ ) - mn = min(mn, arr[i]); - return mn; -} - -function array_max(arr) { - INLINE - - if(!is_array(arr) || array_length(arr) == 0) return 0; - - var mx = arr[0]; - for( var i = 0, n = array_length(arr); i < n; i++ ) - mx = max(mx, arr[i]); - return mx; -} - -function array_get_dimension(arr) { - INLINE - - return is_array(arr)? array_length(arr) : 1; -} - -function array_shape(arr, first = true, isSurface = false) { - if(!is_array(arr)) { - if(isSurface && is_surface(arr)) - return (first? "" : " x ") + string(surface_get_width_safe(arr)) + " x " + string(surface_get_height_safe(arr)) + " px"; - return ""; - } - - var dim = string(array_length(arr)); - - if(array_length(arr)) - dim += array_shape(arr[0], false, isSurface); - - return (first? "" : " x ") + dim; -} - -function __array_get_depth(arr) { // Read all member, slower - INLINE - - if(!is_array(arr)) return 0; - var dep = 0; - for (var i = 0, n = array_length(arr); i < n; i++) - dep = max(dep, __array_get_depth(arr[i])); - return 1 + dep; -} - -function array_get_depth(arr) { // Read only the first member, faster - INLINE - - if(!is_array(arr)) return 0; - var d = 0; - var p = arr; - - while(is_array(p) && !array_empty(p)) { - d++; - p = p[0]; - } - - return d; -} - -function array_spread(arr, _arr = [], _minDepth = 0) { - INLINE - - if(array_get_depth(arr) == _minDepth) { - array_push(_arr, arr); +#region creation + function array_create_2d(_x, _y, val = 0) { + var _arr = array_create(_x); + for( var i = 0; i < _x; i++ ) + _arr[i] = array_create(_y, val); return _arr; } - for( var i = 0, n = array_length(arr); i < n; i++ ) - array_spread(arr[i], _arr, _minDepth); + function array_create_from_list(list) { + if(list == undefined) return []; + if(!ds_exists(list, ds_type_list)) return []; - return _arr; -} + var arr = array_create(ds_list_size(list)); + for( var i = 0; i < ds_list_size(list); i++ ) + arr[i] = list[| i]; + return arr; + } + + function array_clone(arr, _depth = -1) { + INLINE + + if(_depth == 0) return arr; + if(!is_array(arr)) return arr; + + var _res = []; + for( var i = 0, n = array_length(arr); i < n; i++ ) + _res[i] = array_clone(arr[i], _depth--); + + return _res; + } +#endregion -function array_verify_new(arr, length) { - INLINE +#region check + function array_empty(arr) { INLINE return is_array(arr) && array_length(arr) == 0; } + function array_valid(arr) { INLINE return is_array(arr) && array_length(arr) > 0; } + function array_invalid(arr) { INLINE return !is_array(arr) || array_length(arr) == 0; } - if(!is_array(arr)) return array_create(length); - if(array_length(arr) == length) return arr; + function array_verify_new(arr, length) { + INLINE + + if(!is_array(arr)) return array_create(length); + if(array_length(arr) == length) return arr; + + arr = array_clone(arr, 1); + array_resize(arr, length); + return arr; + } - arr = array_clone(arr, 1); - array_resize(arr, length); - return arr; -} + function array_verify(arr, length) { + INLINE + + if(!is_array(arr)) return array_create(length); + if(array_length(arr) == length) return arr; + + array_resize(arr, length); + return arr; + } + + function array_verify_ext(arr, length, generator) { + INLINE + + if(!is_array(arr)) return array_create_ext(length, generator); + + var _len = array_length(arr); + if(_len == length) return arr; + + array_resize(arr, length); + var i = _len; + + repeat(length - _len) + arr[i++] = generator(); + + return arr; + } -function array_verify(arr, length) { - INLINE - - if(!is_array(arr)) return array_create(length); - if(array_length(arr) == length) return arr; - - array_resize(arr, length); - return arr; -} +#endregion -function array_verify_ext(arr, length, generator) { - INLINE +#region get set - if(!is_array(arr)) return array_create_ext(length, generator); + enum ARRAY_OVERFLOW { + _default, + loop, + pingpong, + clamp + } - var _len = array_length(arr); - if(_len == length) return arr; + #macro aGetF array_safe_get_fast + function array_safe_get_fast(arr, index, def = 0) { + INLINE + + return is_array(arr) && index >= 0 && index < array_length(arr)? arr[index] : def; + } - array_resize(arr, length); - var i = _len; + function array_safe_get(arr, index, def = 0, overflow = ARRAY_OVERFLOW._default) { + INLINE + + if(!is_array(arr)) return def; + if(is_array(index)) return def; + + var len = array_length(arr); + if(len == 0) return def; + + if(overflow == ARRAY_OVERFLOW.clamp) { + index = clamp(index, 0, len - 1); + + } else if(overflow == ARRAY_OVERFLOW.loop) { + if(index < 0) + index = len - safe_mod(abs(index), len); + index = index % len; + + } else if(overflow == ARRAY_OVERFLOW.pingpong) { + if(index < 0) index = len - safe_mod(abs(index), len); + + var _plen = len * 2 - 1; + index = index % _plen; + + if(index >= len) + index = _plen - index; + } + + if(index < 0) return def; + if(index >= len) return def; + return arr[index] == undefined? def : arr[index]; + } - repeat(length - _len) - arr[i++] = generator(); + function array_get_decimal(arr, index, color = false) { + INLINE + + if(!is_array(arr)) return 0; + if(frac(index) == 0) return array_safe_get_fast(arr, index); + + var v0 = array_safe_get_fast(arr, floor(index)); + var v1 = array_safe_get_fast(arr, floor(index) + 1); + + return color? + merge_color(v0, v1, frac(index)) : + lerp(v0, v1, frac(index)); + } - return arr; -} + function array_safe_length(arr) { + INLINE + return is_array(arr)? array_length(arr) : 0; + } -function array_insert_after(arr, before, values) { - INLINE + function array_get_dimension(arr) { + INLINE + + return is_array(arr)? array_length(arr) : 1; + } - var _ind = array_find(arr, before) + 1; + function array_shape(arr, first = true, isSurface = false) { + if(!is_array(arr)) { + if(isSurface && is_surface(arr)) + return (first? "" : " x ") + string(surface_get_width_safe(arr)) + " x " + string(surface_get_height_safe(arr)) + " px"; + return ""; + } + + var dim = string(array_length(arr)); + + if(array_length(arr)) + dim += array_shape(arr[0], false, isSurface); + + return (first? "" : " x ") + dim; + } - for( var i = 0, n = array_length(values); i < n; i++ ) - array_insert(arr, _ind + i, values[i]); -} + function __array_get_depth(arr) { // Read all member, slower + INLINE + + if(!is_array(arr)) return 0; + var dep = 0; + for (var i = 0, n = array_length(arr); i < n; i++) + dep = max(dep, __array_get_depth(arr[i])); + return 1 + dep; + } -function array_insert_before(arr, before, values) { - INLINE - - var _ind = array_find(arr, before); - - for( var i = 0, n = array_length(values); i < n; i++ ) - array_insert(arr, _ind + i, values[i]); -} + function array_get_depth(arr) { // Read only the first member, faster + INLINE + + if(!is_array(arr)) return 0; + var d = 0; + var p = arr; + + while(is_array(p) && !array_empty(p)) { + d++; + p = p[0]; + } + + return d; + } -function array_push_to_back(arr, value) { - if(!array_exists(arr, value)) return; + function array_safe_set(arr, index, value, fill = 0) { + if(!is_array(arr)) return arr; + if(is_array(index)) return arr; + + if(index < 0) return arr; + if(index >= array_length(arr)) { + var i = array_length(arr); + for(; i <= index; i++ ) + arr[i] = fill; + arr[index] = value; + return arr; + } + + array_set(arr, index, value); + return arr; + } - array_remove(arr, value); - array_push(arr, value); -} + function array_fill(arr, startIndex, endIndex, value = 0) { + INLINE + + for( var i = max(0, startIndex); i < endIndex; i++ ) + arr[i] = value; + } -#macro array_equals array_equals_overwrite -#macro __array_equals array_equals +#endregion -function array_equals_overwrite(arr1, arr2) { - if(!is_array(arr1) && is_array(arr2)) return false; - if( is_array(arr1) && !is_array(arr2)) return false; - if(!is_array(arr1) && !is_array(arr2)) return arr1 == arr2; - return __array_equals(arr1, arr2) -} \ No newline at end of file +#region find + + function array_exists(arr, val) { + INLINE + self.__temp_val = val; + + if(!is_array(arr)) return false; + var _a = array_any(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); }); + + self.__temp_val = 0; + return _a; + } + + function array_find(arr, val) { + INLINE + self.__temp_val = val; + + if(!is_array(arr)) return -1; + var _a = array_find_index(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); }); + + self.__temp_val = 0; + return _a; + } + + function array_find_string(arr, val) { + INLINE + self.__temp_val = string_lower(val); + + if(!is_array(arr)) return -1; + var _a = array_find_index(arr, function(_val, _ind) { return string_lower(_val) == self.__temp_val; }); + + self.__temp_val = 0; + return _a; + } + + function array_min(arr) { + INLINE + + if(!is_array(arr) || array_length(arr) == 0) return 0; + + var mn = arr[0]; + for( var i = 0, n = array_length(arr); i < n; i++ ) + mn = min(mn, arr[i]); + return mn; + } + + function array_max(arr) { + INLINE + + if(!is_array(arr) || array_length(arr) == 0) return 0; + + var mx = arr[0]; + for( var i = 0, n = array_length(arr); i < n; i++ ) + mx = max(mx, arr[i]); + return mx; + } + +#endregion + +#region modify + + function array_resize_fill(arr, size, fill = 0) { + if(size < array_length(arr)) { + array_resize(arr, size); + return arr; + } + + var i = array_length(arr); + for(; i < size; i++) + arr[i] = fill; + return arr; + } + + function array_push_create(arr, val) { + INLINE + + if(!is_array(arr)) return [ val ]; + array_push(arr, val); + return arr; + } + + function array_remove(arr, val) { + INLINE + + if(!is_array(arr)) return; + if(!array_exists(arr, val)) return; + var ind = array_find(arr, val); + array_delete(arr, ind, 1); + } + + function array_push_unique(arr, val) { + INLINE + + if(!is_array(arr)) return; + if(array_exists(arr, val)) return; + array_push(arr, val); + } + + function array_insert_unique(arr, ind, val) { + INLINE + + if(!is_array(arr)) return; + if(array_exists(arr, val)) return; + array_insert(arr, ind, val); + } + + function array_insert_after(arr, before, values) { + INLINE + + var _ind = array_find(arr, before) + 1; + + for( var i = 0, n = array_length(values); i < n; i++ ) + array_insert(arr, _ind + i, values[i]); + } + + function array_insert_before(arr, before, values) { + INLINE + + var _ind = array_find(arr, before); + + for( var i = 0, n = array_length(values); i < n; i++ ) + array_insert(arr, _ind + i, values[i]); + } + + function array_push_to_back(arr, value) { + if(!array_exists(arr, value)) return; + + array_remove(arr, value); + array_push(arr, value); + } + + function array_spread(arr, _arr = [], _minDepth = 0) { + INLINE + + if(array_get_depth(arr) == _minDepth) { + array_push(_arr, arr); + return _arr; + } + + for( var i = 0, n = array_length(arr); i < n; i++ ) + array_spread(arr[i], _arr, _minDepth); + + return _arr; + } +#endregion + +#region binary opr + + function array_overlap(arr0, arr1) { + INLINE + self.__temp_arr = arr1; + + if(!is_array(arr0)) return false; + if(!is_array(arr1)) return false; + + var _a = array_any(arr0, function(_val, _ind) { return array_exists(self.__temp_arr, _val); }); + + self.__temp_arr = 0; + return _a; + } + + function array_append(arr, arr0) { + INLINE + + if(is_undefined(arr0)) return arr; + if(!is_array(arr)) return arr; + if(!is_array(arr0)) { array_push(arr, arr0); return arr; } + + for( var i = 0, n = array_length(arr0); i < n; i++ ) + array_push(arr, arr0[i]); + return arr; + } + + function array_merge() { + INLINE + + var arr = []; + for( var i = 0; i < argument_count; i++ ) + array_append(arr, argument[i]); + + return arr; + } + + #macro array_equals array_equals_overwrite + #macro __array_equals array_equals + + function array_equals_overwrite(arr1, arr2) { + if(!is_array(arr1) && is_array(arr2)) return false; + if( is_array(arr1) && !is_array(arr2)) return false; + if(!is_array(arr1) && !is_array(arr2)) return arr1 == arr2; + return __array_equals(arr1, arr2) + } + + function array_substract(arr1, arr2) { + if(!is_array(arr1) || !is_array(arr2)) return; + + var _hsh = {}; + var _arr = []; + + for( var i = 0, n = array_length(arr2); i < n; i++ ) + _hsh[$ arr2[i]] = (_hsh[$ arr2[i]] ?? 0) + 1; + + for( var i = 0, n = array_length(arr1); i < n; i++ ) { + if(!struct_has(_hsh, arr1[i]) || _hsh[$ arr1[i]]-- <= 0) + array_push(_arr, arr1[i]); + } + + return _arr; + } + + function array_xor(arr1, arr2) { + if(!is_array(arr1) || !is_array(arr2)) return; + + var _arr = array_union(array_substract(arr1, arr2), array_substract(arr2, arr1)); + return _arr; + } +#endregion diff --git a/scripts/node_array_boolean_opr/node_array_boolean_opr.gml b/scripts/node_array_boolean_opr/node_array_boolean_opr.gml new file mode 100644 index 000000000..62e75b345 --- /dev/null +++ b/scripts/node_array_boolean_opr/node_array_boolean_opr.gml @@ -0,0 +1,62 @@ +function Node_Array_Boolean_Opr(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Array Boolean Opr"; + setDimension(96, 32 + 24); + + newInput(0, nodeValue("Array 1", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) + .setVisible(true, true); + + newInput(1, nodeValue("Array 2", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0)) + .setVisible(true, true); + + newInput(2, nodeValue_Enum_Scroll("Operation", self, 0, [ "Union", "Subtract", "Intersect", "XOR" ])) + .setVisible(true, true); + + newOutput(0, nodeValue_Output("Array out", self, VALUE_TYPE.any, [])); + + input_display_list = [ 2, 0, 1 ]; + + static update = function(frame = CURRENT_FRAME) { + var arr1 = getInputData(0); + var arr2 = getInputData(1); + var opr = getInputData(2); + + inputs[0].setType(VALUE_TYPE.any); + inputs[1].setType(VALUE_TYPE.any); + outputs[0].setType(VALUE_TYPE.any); + + if(inputs[0].value_from != noone) { + inputs[0].setType(inputs[0].value_from.type); + inputs[1].setType(inputs[1].value_from.type); + outputs[0].setType(inputs[0].value_from.type); + } + + if(!is_array(arr1) || !is_array(arr2)) return; + + var _arr; + + switch(opr) { + case 0 : _arr = array_union(arr1, arr2); break; + case 1 : _arr = array_substract(arr1, arr2); break; + case 2 : _arr = array_intersection(arr1, arr2); break; + case 3 : _arr = array_xor(arr1, arr2); break; + } + + outputs[0].setValue(_arr); + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + var bbox = drawGetBbox(xx, yy, _s); + var opr = getInputData(2); + var str = ""; + + switch(opr) { + case 0 : str = "union" break; + case 1 : str = "substract" break; + case 2 : str = "intersection" break; + case 3 : str = "xor" break; + } + + draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); + draw_text_bbox(bbox, str); + } +} \ No newline at end of file diff --git a/scripts/node_array_boolean_opr/node_array_boolean_opr.yy b/scripts/node_array_boolean_opr/node_array_boolean_opr.yy new file mode 100644 index 000000000..83f2e888b --- /dev/null +++ b/scripts/node_array_boolean_opr/node_array_boolean_opr.yy @@ -0,0 +1,14 @@ +{ + "$GMScript":"v1", + "%Name":"node_array_boolean_opr", + "isCompatibility":false, + "isDnD":false, + "name":"node_array_boolean_opr", + "parent":{ + "name":"array", + "path":"folders/nodes/data/value/array.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", + "tags":[], +} \ No newline at end of file diff --git a/scripts/node_value_float/node_value_float.gml b/scripts/node_value_float/node_value_float.gml index 92ed2df2f..dd9212f89 100644 --- a/scripts/node_value_float/node_value_float.gml +++ b/scripts/node_value_float/node_value_float.gml @@ -18,8 +18,8 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam var dis = nod.display_type; if(typ != VALUE_TYPE.surface) { - if(typ == VALUE_TYPE.text) val = toNumber(val); - if(struct_has(val, "to_real")) val = val.to_real(); + if(typ == VALUE_TYPE.text) val = toNumber(val); + if(is_struct(val) && struct_has(val, "to_real")) val = val.to_real(); return valueProcess(val, nod, applyUnit); } diff --git a/scripts/node_value_int/node_value_int.gml b/scripts/node_value_int/node_value_int.gml index 16767e6a7..fc7529632 100644 --- a/scripts/node_value_int/node_value_int.gml +++ b/scripts/node_value_int/node_value_int.gml @@ -20,7 +20,7 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name, if(typ != VALUE_TYPE.surface) { if(typ == VALUE_TYPE.text) val = toNumber(val); - if(struct_has(val, "to_real")) val = val.to_real(); + if(is_struct(val) && struct_has(val, "to_real")) val = val.to_real(); return valueProcess(val, nod, applyUnit); } diff --git a/sprites/s_node_array_boolean_opr/3f6813f5-0553-4de8-96d6-c7d745fffe40.png b/sprites/s_node_array_boolean_opr/3f6813f5-0553-4de8-96d6-c7d745fffe40.png new file mode 100644 index 000000000..bd987487d Binary files /dev/null and b/sprites/s_node_array_boolean_opr/3f6813f5-0553-4de8-96d6-c7d745fffe40.png differ diff --git a/sprites/s_node_array_boolean_opr/layers/3f6813f5-0553-4de8-96d6-c7d745fffe40/8b6cb694-da18-4679-b77a-1770cc5ebe4f.png b/sprites/s_node_array_boolean_opr/layers/3f6813f5-0553-4de8-96d6-c7d745fffe40/8b6cb694-da18-4679-b77a-1770cc5ebe4f.png new file mode 100644 index 000000000..bd987487d Binary files /dev/null and b/sprites/s_node_array_boolean_opr/layers/3f6813f5-0553-4de8-96d6-c7d745fffe40/8b6cb694-da18-4679-b77a-1770cc5ebe4f.png differ diff --git a/sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy b/sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy new file mode 100644 index 000000000..28193c791 --- /dev/null +++ b/sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy @@ -0,0 +1,90 @@ +{ + "$GMSprite":"", + "%Name":"s_node_array_boolean_opr", + "bboxMode":0, + "bbox_bottom":63, + "bbox_left":0, + "bbox_right":63, + "bbox_top":0, + "collisionKind":1, + "collisionTolerance":0, + "DynamicTexturePage":false, + "edgeFiltering":false, + "For3D":false, + "frames":[ + {"$GMSpriteFrame":"","%Name":"3f6813f5-0553-4de8-96d6-c7d745fffe40","name":"3f6813f5-0553-4de8-96d6-c7d745fffe40","resourceType":"GMSpriteFrame","resourceVersion":"2.0",}, + ], + "gridX":0, + "gridY":0, + "height":64, + "HTile":false, + "layers":[ + {"$GMImageLayer":"","%Name":"8b6cb694-da18-4679-b77a-1770cc5ebe4f","blendMode":0,"displayName":"default","isLocked":false,"name":"8b6cb694-da18-4679-b77a-1770cc5ebe4f","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,}, + ], + "name":"s_node_array_boolean_opr", + "nineSlice":null, + "origin":4, + "parent":{ + "name":"array", + "path":"folders/nodes/icons/value/array.yy", + }, + "preMultiplyAlpha":false, + "resourceType":"GMSprite", + "resourceVersion":"2.0", + "sequence":{ + "$GMSequence":"", + "%Name":"s_node_array_boolean_opr", + "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_array_boolean_opr", + "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":"3f6813f5-0553-4de8-96d6-c7d745fffe40","path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",}, + },"Disabled":false,"id":"dd4a2d62-327f-4cc6-856a-909eead3e7d3","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