From 5e2eb0a3525e4e0b6bec255e8110f075ea101138 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 2 Jul 2024 14:15:42 +0700 Subject: [PATCH] - [3D Object] Fix weird behaviour on other noeds when created. --- scripts/__node_3d/__node_3d.gml | 3 ++- scripts/node_3d_camera/node_3d_camera.gml | 4 ++++ scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml | 4 ++-- scripts/node_posterize/node_posterize.gml | 11 +++++++++-- scripts/node_value/node_value.gml | 1 - 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/__node_3d/__node_3d.gml b/scripts/__node_3d/__node_3d.gml index 2864048cd..000cd7d4c 100644 --- a/scripts/__node_3d/__node_3d.gml +++ b/scripts/__node_3d/__node_3d.gml @@ -1,7 +1,6 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "3D"; is_3D = NODE_3D.polygon; - surface_depth_disable(false); mesh_prev_surface = surface_create(64, 64); @@ -35,6 +34,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr static refreshPreview = function() { #region var _prev_obj = getPreviewObjects(); + surface_depth_disable(false); mesh_prev_surface = surface_verify(mesh_prev_surface, PREFERENCES.node_3d_preview_size, PREFERENCES.node_3d_preview_size); surface_set_target(mesh_prev_surface); DRAW_CLEAR @@ -63,6 +63,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr D3D_GLOBAL_PREVIEW.submitUI(_prev); } surface_reset_target(); + surface_depth_disable(true); D3D_GLOBAL_PREVIEW.camera.resetCamera(); } #endregion diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index 448f4eb9a..c10ad682b 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -242,6 +242,8 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) var _qi3 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); #endregion + surface_depth_disable(false); + switch(_posm) { #region ++++ camera positioning ++++ case 0 : camera.useFocus = false; @@ -377,6 +379,8 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) surface_free(_render); #endregion + surface_depth_disable(true); + return [ _finalRender, _normal, _depth ]; } #endregion diff --git a/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml b/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml index cf766bce0..e165d8b13 100644 --- a/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml +++ b/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml @@ -42,7 +42,7 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group inputs[| in_mesh + 6].setVisible(_mat_side, _mat_side); } #endregion - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { var _mat_side = _data[in_mesh + 0]; var _mat_1 = _data[in_mesh + 1]; var _mat_2 = _data[in_mesh + 2]; @@ -63,7 +63,7 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group setTransform(object, _data); return object; - } #endregion + } static getPreviewValues = function() { return array_safe_get_fast(all_inputs, in_mesh + 1, noone); } } \ No newline at end of file diff --git a/scripts/node_posterize/node_posterize.gml b/scripts/node_posterize/node_posterize.gml index dcb0a0c29..b48dbddb8 100644 --- a/scripts/node_posterize/node_posterize.gml +++ b/scripts/node_posterize/node_posterize.gml @@ -118,11 +118,13 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _ssh = surface_get_height(_sMax); var _max = [ 0, 0, 0 ]; var _min = [ 1, 1, 1 ]; + var _bMax = buffer_from_surface(_sMax, false); var _bMin = buffer_from_surface(_sMin, false); - buffer_seek(_bMax, buffer_seek_start, 0); - buffer_seek(_bMin, buffer_seek_start, 0); + buffer_to_start(_bMax); + buffer_to_start(_bMin); + repeat(_ssw * _ssh) { var _cc = buffer_read(_bMax, buffer_u32); _max[0] = max(_max[0], _color_get_red(_cc)); @@ -135,6 +137,7 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) _min[2] = min(_min[2], _color_get_blue(_cc)); } + buffer_delete(_bMax); buffer_delete(_bMin); #endregion @@ -148,6 +151,10 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) draw_surface_safe(_surf); surface_reset_shader(); + + // surface_set_shader(_outSurf); + // draw_surface_safe(_sMax); + // surface_reset_shader(); } return _outSurf; diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 56227f005..7483e61f8 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1140,7 +1140,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(connect_type == JUNCTION_CONNECT.output) return val; - if(type == VALUE_TYPE.integer || type == VALUE_TYPE.float) print($"{typ == VALUE_TYPE.surface}"); if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { #region Dimension conversion if(is_array(val)) { var eqSize = true;