- [3D extrude] Fix error when inputting invalid surface.

This commit is contained in:
Tanasart 2023-11-24 17:55:26 +07:00
parent 17c7effa3d
commit b6f7088dbd
6 changed files with 17 additions and 9 deletions

View file

@ -151,7 +151,7 @@ function __3dObject() constructor {
var _tex = _mat == noone? -1 : _mat.getTexture(); var _tex = _mat == noone? -1 : _mat.getTexture();
if(_shader == sh_d3d_default) { if(_shader == sh_d3d_default) {
if(_mat == noone) { if(!is_instanceof(_mat, __d3dMaterial)) {
shader_set_f("mat_diffuse", 1); shader_set_f("mat_diffuse", 1);
shader_set_f("mat_specular", 0); shader_set_f("mat_specular", 0);
shader_set_f("mat_shine", 1); shader_set_f("mat_shine", 1);
@ -162,7 +162,7 @@ function __3dObject() constructor {
vertex_submit(VB[i], render_type, _tex); vertex_submit(VB[i], render_type, _tex);
} else if(_shader == sh_d3d_geometry) { } else if(_shader == sh_d3d_geometry) {
if(_mat == noone) if(!is_instanceof(_mat, __d3dMaterial))
shader_set_i("use_normal", 0); shader_set_i("use_normal", 0);
else else
_mat.submitGeometry(); _mat.submitGeometry();

View file

@ -83,7 +83,7 @@ function __3dObjectInstancer() : __3dObject() constructor {
for( var i = 0, n = array_length(VB); i < n; i++ ) { for( var i = 0, n = array_length(VB); i < n; i++ ) {
var _ind = array_safe_get(material_index, i, i); var _ind = array_safe_get(material_index, i, i);
var _mat = array_safe_get(materials, _ind, noone); var _mat = array_safe_get(materials, _ind, noone);
var _tex = _mat == noone? -1 : _mat.getTexture(); var _tex = is_instanceof(_mat, __d3dMaterial)? _mat.getTexture() : -1;
vertex_submit_instanced(VB[i], render_type, _tex, object_counts); vertex_submit_instanced(VB[i], render_type, _tex, object_counts);
} }

View file

@ -63,12 +63,13 @@ function Node_3D_Material(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
var _mat = outputs[| 0].getValue(); var _mat = outputs[| 0].getValue();
if(_mat == noone) return; if(_mat == noone) return;
if(is_array(_mat)) { if(is_array(_mat)) {
if(array_empty(_mat)) return; if(array_empty(_mat)) return;
_mat = _mat[0]; _mat = _mat[0];
} }
if(is_surface(_mat.surface)) if(is_instanceof(_mat, __d3dMaterial) && is_surface(_mat.surface))
draw_surface_bbox(_mat.surface, bbox); draw_surface_bbox(_mat.surface, bbox);
} }
} }

View file

@ -20,7 +20,7 @@ function Node_3D_Mesh_Extrude(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
static processData = function(_output, _data, _output_index, _array_index = 0) { #region static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _mat = _data[in_mesh + 0]; var _mat = _data[in_mesh + 0];
if(_mat == noone) return noone; if(!is_instanceof(_mat, __d3dMaterial)) return noone;
var _hght = _data[in_mesh + 1]; var _hght = _data[in_mesh + 1];
var _smt = _data[in_mesh + 2]; var _smt = _data[in_mesh + 2];

View file

@ -1375,10 +1375,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion } #endregion
if(typeFrom == VALUE_TYPE.surface && type == VALUE_TYPE.d3Material) { #region if(typeFrom == VALUE_TYPE.surface && type == VALUE_TYPE.d3Material) { #region
if(!is_array(value)) return new __d3dMaterial(value); if(!is_array(value)) return is_surface(value)? new __d3dMaterial(value) : noone;
var _val = array_create(array_length(value)); var _val = array_create(array_length(value));
for( var i = 0, n = array_length(value); i < n; i++ ) for( var i = 0, n = array_length(value); i < n; i++ )
_val[i] = new __d3dMaterial(value[i]); _val[i] = is_surface(value[i])? new __d3dMaterial(value[i]) : noone;
return _val; return _val;
} #endregion } #endregion

View file

@ -1280,6 +1280,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_selecting = []; nodes_selecting = [];
PANEL_PREVIEW.resetNodePreview(); PANEL_PREVIEW.resetNodePreview();
setContextFrame(true, node_context[| i + 1]); setContextFrame(true, node_context[| i + 1]);
var _nodeFocus = node_context[| i + 1];
if(i == -1) if(i == -1)
resetContext(); resetContext();
@ -1287,9 +1288,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for(var j = ds_list_size(node_context) - 1; j > i; j--) for(var j = ds_list_size(node_context) - 1; j > i; j--)
ds_list_delete(node_context, j); ds_list_delete(node_context, j);
nodes_list = node_context[| i].getNodeList(); nodes_list = node_context[| i].getNodeList();
toCenterNode();
break;
} }
nodes_selecting = [ _nodeFocus ];
var _l = ds_list_create_from_array(nodes_selecting)
print(ds_list_size(_l));
toCenterNode(_l);
ds_list_destroy(_l);
break;
} }
draw_sprite_ui_uniform(THEME.arrow, 0, xx + tw + ui(16), tbh, 1, COLORS._main_icon); draw_sprite_ui_uniform(THEME.arrow, 0, xx + tw + ui(16), tbh, 1, COLORS._main_icon);