inline group rendering fix

This commit is contained in:
Tanasart 2024-06-25 16:53:40 +07:00
parent ce9c4b0715
commit f057bf63d9
8 changed files with 78 additions and 101 deletions

View file

@ -38,7 +38,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11750; VERSION = 11750;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.5.003"; VERSION_STRING = "1.17.5.004";
BUILD_NUMBER = 11750; BUILD_NUMBER = 11750;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;

View file

@ -52,8 +52,8 @@ function Node_VFX_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group
if(IS_PLAYING) if(IS_PLAYING)
for( var i = 0; i < TOTAL_FRAMES; i++ ) for( var i = 0; i < TOTAL_FRAMES; i++ )
for( var j = 0, m = ds_list_size(topoList); j < m; j++ ) { for( var j = 0, m = array_length(topoList); j < m; j++ ) {
var node = topoList[| j]; var node = topoList[j];
var _ins = instanceof(node); var _ins = instanceof(node);
if(!string_pos("Node_VFX", _ins)) if(!string_pos("Node_VFX", _ins))
@ -74,7 +74,7 @@ function Node_VFX_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group
static update = function() { #region static update = function() { #region
if(IS_FIRST_FRAME) if(IS_FIRST_FRAME)
NodeListSort(topoList, nodes); topoList = NodeListSort(nodes);
allCached = true; allCached = true;
for( var i = 0, n = array_length(nodes); i < n; i++ ) { for( var i = 0, n = array_length(nodes); i < n; i++ ) {

View file

@ -48,8 +48,8 @@ function Node_VFX_Group_Inline(_x, _y, _group = noone) : Node_Collection_Inline(
if(!loop) return; if(!loop) return;
for( var i = 0; i < TOTAL_FRAMES; i++ ) for( var i = 0; i < TOTAL_FRAMES; i++ )
for( var j = 0, m = ds_list_size(topoList); j < m; j++ ) { for( var j = 0, m = array_length(topoList); j < m; j++ ) {
var node = topoList[| j]; var node = topoList[j];
var _ins = instanceof(node); var _ins = instanceof(node);
if(!string_pos("Node_VFX", _ins)) if(!string_pos("Node_VFX", _ins))
@ -70,7 +70,7 @@ function Node_VFX_Group_Inline(_x, _y, _group = noone) : Node_Collection_Inline(
static update = function() { #region static update = function() { #region
if(IS_FIRST_FRAME) { if(IS_FIRST_FRAME) {
NodeListSort(topoList, nodes); topoList = NodeListSort(nodes);
reset(); reset();
} }
} #endregion } #endregion

View file

@ -32,10 +32,13 @@ function Node_Bloom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[| 12] = nodeValue("Direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) inputs[| 12] = nodeValue("Direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.rotation); .setDisplay(VALUE_DISPLAY.rotation);
// inputs[| 13] = nodeValue("Types", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
// .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Gaussian" ]);
input_display_list = [ 7, 8, input_display_list = [ 7, 8,
["Surfaces", true], 0, 5, 6, 9, 10, ["Surfaces", true], 0, 5, 6, 9, 10,
["Bloom", false], 1, 2, 3, 4, ["Bloom", false], 1, 2, 3, 4,
["Directional", true], 11, 12, ["Blur", true], 11, 12,
] ]
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);

View file

@ -50,7 +50,7 @@ function Node_Iterate_Sort(_x, _y, _group = noone) : Node_Collection(_x, _y, _gr
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) { #region
if(IS_FIRST_FRAME) { if(IS_FIRST_FRAME) {
NodeListSort(topoList, nodes); topoList = NodeListSort(nodes);
inputNodes = [ noone, noone ]; inputNodes = [ noone, noone ];
outputNode = noone; outputNode = noone;

View file

@ -86,7 +86,7 @@ function Node_Iterate_Sort_Inline(_x, _y, _group = noone) : Node_Collection_Inli
} }
if(IS_FIRST_FRAME) toSort = true; if(IS_FIRST_FRAME) toSort = true;
if(toSort) NodeListSort(topoList, nodes); if(toSort) topoList = NodeListSort(nodes);
toSort = false; toSort = false;
input_node.startSort = true; input_node.startSort = true;

View file

@ -19,12 +19,12 @@ function readObj_init(_scale = 1, _yneg = false) {
use_material = false; use_material = false;
use_normal = true; use_normal = true;
v = ds_list_create(); v = [];
vt = ds_list_create(); vt = [];
vn = ds_list_create(); vn = [];
f = ds_list_create(); f = [];
ft = ds_list_create(); ft = [];
fn = ds_list_create(); fn = [];
tri = 0; tri = 0;
} }
@ -41,33 +41,33 @@ function readObj_file() {
switch(sep[0]) { switch(sep[0]) {
case "v" : case "v" :
if(obj_reading_yneg) { if(obj_reading_yneg) {
ds_list_add(v, [ array_push(v, [
toNumber(sep[1]) * obj_reading_scale, real(sep[1]) * obj_reading_scale,
toNumber(sep[3]) * obj_reading_scale, real(sep[3]) * obj_reading_scale,
-toNumber(sep[2]) * obj_reading_scale, -real(sep[2]) * obj_reading_scale,
]); ]);
} else { } else {
ds_list_add(v, [ array_push(v, [
toNumber(sep[1]) * obj_reading_scale, real(sep[1]) * obj_reading_scale,
toNumber(sep[2]) * obj_reading_scale, real(sep[2]) * obj_reading_scale,
toNumber(sep[3]) * obj_reading_scale, real(sep[3]) * obj_reading_scale,
]); ]);
} }
break; break;
case "vt" : case "vt" :
var _u = toNumber(sep[1]); var _u = real(sep[1]);
var _v = toNumber(sep[2]); var _v = real(sep[2]);
ds_list_add(vt, [ _u, _v ]); array_push(vt, [ _u, _v ]);
break; break;
case "vn" : case "vn" :
var _nx = toNumber(sep[1]); var _nx = real(sep[1]);
var _ny = toNumber(sep[2]); var _ny = real(sep[2]);
var _nz = toNumber(sep[3]); var _nz = real(sep[3]);
ds_list_add(vn, [ _nx, _ny, _nz ]); array_push(vn, [ _nx, _ny, _nz ]);
break; break;
case "f" : case "f" :
@ -80,17 +80,17 @@ function readObj_file() {
var _sp = string_split(sep[i], "/"); var _sp = string_split(sep[i], "/");
if(array_length(_sp) < 3) continue; if(array_length(_sp) < 3) continue;
_f[i - 1] = toNumber(_sp[0]); _f[i - 1] = real(_sp[0]) - 1;
_ft[i - 1] = toNumber(_sp[1]); _ft[i - 1] = real(_sp[1]) - 1;
_fn[i - 1] = toNumber(_sp[2]); _fn[i - 1] = real(_sp[2]) - 1;
use_normal = array_length(_sp) >= 4; use_normal = array_length(_sp) >= 4;
} }
tri += _len - 2; tri += _len - 2;
ds_list_add(f, _f ); //get position array_push(f, _f ); //get position
ds_list_add(ft, _ft); //get texture map array_push(ft, _ft); //get texture map
ds_list_add(fn, _fn); //get normal array_push(fn, _fn); //get normal
break; break;
case "usemtl" : case "usemtl" :
@ -103,14 +103,14 @@ function readObj_file() {
array_push_unique(mats, mname); array_push_unique(mats, mname);
array_push(matIndex, array_find(mats, mname)); array_push(matIndex, array_find(mats, mname));
if(!ds_list_empty(f)) { if(!array_empty(f)) {
array_push(_VB, f); array_push(_VB, f);
array_push(_VBT, ft); array_push(_VBT, ft);
array_push(_VBN, fn); array_push(_VBN, fn);
array_push(tris, tri); array_push(tris, tri);
f = ds_list_create(); f = [];
ft = ds_list_create(); ft = [];
fn = ds_list_create(); fn = [];
} }
tri = 0; tri = 0;
@ -131,7 +131,7 @@ function readObj_file() {
if(current_time - _time > 30) return; if(current_time - _time > 30) return;
} #endregion } #endregion
if(!ds_list_empty(f)) { if(!array_empty(f)) {
array_push(_VB, f); array_push(_VB, f);
array_push(_VBT, ft); array_push(_VBT, ft);
array_push(_VBN, fn); array_push(_VBN, fn);
@ -139,23 +139,15 @@ function readObj_file() {
} }
file_text_close(obj_read_file); file_text_close(obj_read_file);
if(use_normal) vn[| 0] = [ 0, 0, 0 ]; if(use_normal) vn[0] = [ 0, 0, 0 ];
obj_read_progress = 1; obj_read_progress = 1;
obj_read_prog_sub = 0; obj_read_prog_sub = 0;
//var txt = "OBJ summary";
//txt += $"\n\tVerticies : {ds_list_size(v)}";
//txt += $"\n\tTexture Verticies : {ds_list_size(vt)}";
//txt += $"\n\tNormal Verticies : {ds_list_size(vn)}";
//txt += $"\n\tVertex groups : {array_length(_VB)}";
//txt += $"\n\tTriangles : {tris}";
//print(txt);
} }
function readObj_cent() { function readObj_cent() {
#region centralize vertex #region centralize vertex
var _v0 = v[| 0]; var _v0 = v[0];
var _bminx = _v0[0]; var _bminx = _v0[0];
var _bminy = _v0[1]; var _bminy = _v0[1];
var _bminz = _v0[2]; var _bminz = _v0[2];
@ -168,10 +160,10 @@ function readObj_cent() {
var cvy = 0; var cvy = 0;
var cvz = 0; var cvz = 0;
vertex = ds_list_size(v); vertex = array_length(v);
for( var i = 0; i < vertex; i++ ) { for( var i = 0; i < vertex; i++ ) {
var _v = v[| i]; var _v = v[i];
var _v0 = _v[0]; var _v0 = _v[0];
var _v1 = _v[1]; var _v1 = _v[1];
var _v2 = _v[2]; var _v2 = _v[2];
@ -200,7 +192,7 @@ function readObj_cent() {
); );
for( var i = 0; i < vertex; i++ ) { for( var i = 0; i < vertex; i++ ) {
var _v = v[| i]; var _v = v[i];
_v[0] = _v[0] - cvx; _v[0] = _v[0] - cvx;
_v[1] = _v[1] - cvy; _v[1] = _v[1] - cvy;
@ -225,13 +217,13 @@ function readObj_buff() {
var facet = _VBT[i]; var facet = _VBT[i];
var facen = _VBN[i]; var facen = _VBN[i];
var _flen = ds_list_size(face); var _flen = array_length(face);
var _v = ds_list_create(); var _v = [];
for(var j = 0; j < _flen; j++) { for(var j = 0; j < _flen; j++) {
var _f = face[| j]; var _f = face[j];
var _ft = facet[| j]; var _ft = facet[j];
var _fn = facen[| j]; var _fn = facen[j];
var _vlen = array_length(_f); var _vlen = array_length(_f);
var _pf = array_create(_vlen); var _pf = array_create(_vlen);
@ -239,29 +231,24 @@ function readObj_buff() {
var _pfn = array_create(_vlen); var _pfn = array_create(_vlen);
for( var k = 0; k < _vlen; k++ ) { for( var k = 0; k < _vlen; k++ ) {
var _vPindex = _f[k] - 1; _pf[k] = v[_f[k]];
_pf[k] = v[| _vPindex]; _pfn[k] = vn[_fn[k]];
_pft[k] = vt[_ft[k]];
var _vNindex = _fn[k] - 1;
_pfn[k] = vn[| _vNindex];
var _vTindex = _ft[k] - 1;
_pft[k] = vt[| _vTindex];
} }
var _pf0 = _pf[0], _pf1 = _pf[1], _pf2 = _pf[2]; var _pf0 = _pf[0], _pf1 = _pf[1], _pf2 = _pf[2];
var _pfn0 = _pfn[0], _pfn1 = _pfn[1], _pfn2 = _pfn[2]; var _pfn0 = _pfn[0], _pfn1 = _pfn[1], _pfn2 = _pfn[2];
var _pft0 = _pft[0], _pft1 = _pft[1], _pft2 = _pft[2]; var _pft0 = _pft[0], _pft1 = _pft[1], _pft2 = _pft[2];
if(_vlen >= 3) { // if(_vlen >= 3) {
vertex_add_pntc(VB, _pf0, _pfn0, _pft0); vertex_add_pntc(VB, _pf0, _pfn0, _pft0);
vertex_add_pntc(VB, _pf2, _pfn2, _pft2); vertex_add_pntc(VB, _pf2, _pfn2, _pft2);
vertex_add_pntc(VB, _pf1, _pfn1, _pft1); vertex_add_pntc(VB, _pf1, _pfn1, _pft1);
ds_list_add(_v, new __vertex(_pf0[0], _pf0[1], _pf0[2]).setNormal(_pfn0[0], _pfn0[1]).setUV(_pft0[0], _pft0[1])); array_push(_v, new __vertex(_pf0[0], _pf0[1], _pf0[2]).setNormal(_pfn0[0], _pfn0[1]).setUV(_pft0[0], _pft0[1]));
ds_list_add(_v, new __vertex(_pf2[0], _pf2[1], _pf2[2]).setNormal(_pfn2[0], _pfn2[1]).setUV(_pft2[0], _pft2[1])); array_push(_v, new __vertex(_pf2[0], _pf2[1], _pf2[2]).setNormal(_pfn2[0], _pfn2[1]).setUV(_pft2[0], _pft2[1]));
ds_list_add(_v, new __vertex(_pf1[0], _pf1[1], _pf1[2]).setNormal(_pfn1[0], _pfn1[1]).setUV(_pft1[0], _pft1[1])); array_push(_v, new __vertex(_pf1[0], _pf1[1], _pf1[2]).setNormal(_pfn1[0], _pfn1[1]).setUV(_pft1[0], _pft1[1]));
} // }
if(_vlen >= 4) { if(_vlen >= 4) {
var _pf3 = _pf[3]; var _pf3 = _pf[3];
@ -272,31 +259,19 @@ function readObj_buff() {
vertex_add_pntc(VB, _pf3, _pfn3, _pft3); vertex_add_pntc(VB, _pf3, _pfn3, _pft3);
vertex_add_pntc(VB, _pf2, _pfn2, _pft2); vertex_add_pntc(VB, _pf2, _pfn2, _pft2);
ds_list_add(_v, new __vertex(_pf0[0], _pf0[1], _pf0[2]).setNormal(_pfn0[0], _pfn0[1]).setUV(_pft0[0], _pft0[1])); array_push(_v, new __vertex(_pf0[0], _pf0[1], _pf0[2]).setNormal(_pfn0[0], _pfn0[1]).setUV(_pft0[0], _pft0[1]));
ds_list_add(_v, new __vertex(_pf3[0], _pf3[1], _pf3[2]).setNormal(_pfn3[0], _pfn3[1]).setUV(_pft3[0], _pft3[1])); array_push(_v, new __vertex(_pf3[0], _pf3[1], _pf3[2]).setNormal(_pfn3[0], _pfn3[1]).setUV(_pft3[0], _pft3[1]));
ds_list_add(_v, new __vertex(_pf2[0], _pf2[1], _pf2[2]).setNormal(_pfn2[0], _pfn2[1]).setUV(_pft2[0], _pft2[1])); array_push(_v, new __vertex(_pf2[0], _pf2[1], _pf2[2]).setNormal(_pfn2[0], _pfn2[1]).setUV(_pft2[0], _pft2[1]));
} }
} }
vertex_end(VB); vertex_end(VB);
// vertex_freeze(VB);
VBS[i] = VB; VBS[i] = VB;
V[i] = ds_list_to_array(_v); V[i] = _v;
ds_list_destroy(_v);
} }
#endregion #endregion
#region clean
array_foreach(_VB, function(val, ind) { ds_list_destroy(val); });
array_foreach(_VBT, function(val, ind) { ds_list_destroy(val); });
array_foreach(_VBN, function(val, ind) { ds_list_destroy(val); });
ds_list_destroy(v);
ds_list_destroy(vn);
ds_list_destroy(vt);
#endregion
obj_read_progress = 3; obj_read_progress = 3;
obj_read_prog_sub = 0; obj_read_prog_sub = 0;

View file

@ -44,16 +44,15 @@ function NodeTopoSort() { #region
LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {array_length(PROJECT.nodeTopo)}/{amo} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++"); LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {array_length(PROJECT.nodeTopo)}/{amo} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++");
} #endregion } #endregion
function NodeListSort(_list, _nodeList) { #region function NodeListSort(_nodeList) { #region
array_foreach(_nodeList, function(node) { array_foreach(_nodeList, function(node) {
node.clearTopoSorted(); node.clearTopoSorted();
return 0; return 0;
}); });
// print($"===================== NODE LIST SORT =====================") var _arr = [];
__topoSort(_arr, _nodeList);
ds_list_clear(_list); return _arr;
__topoSort(_list, _nodeList);
} #endregion } #endregion
function __sortNode(_arr, _node) { #region function __sortNode(_arr, _node) { #region
@ -263,10 +262,10 @@ function Render(partial = false, runAction = false) { #region
function __renderListReset(arr) { #region function __renderListReset(arr) { #region
for( var i = 0; i < array_length(arr); i++ ) { for( var i = 0; i < array_length(arr); i++ ) {
list[i].setRenderStatus(false); arr[i].setRenderStatus(false);
if(struct_has(list[i], "nodes")) if(struct_has(arr[i], "nodes"))
__renderListReset(list[i].nodes); __renderListReset(arr[i].nodes);
} }
} #endregion } #endregion
@ -316,7 +315,7 @@ function RenderList(arr) { #region
var nextNodes = rendering.getNextNodes(); var nextNodes = rendering.getNextNodes();
for( var i = 0, n = array_length(nextNodes); i < n; i++ ) { for( var i = 0, n = array_length(nextNodes); i < n; i++ ) {
var _node = nextNodes[i]; var _node = nextNodes[i];
if(ds_list_exist(list, _node) && _node.isRenderable()) if(array_exists(arr, _node) && _node.isRenderable())
ds_queue_enqueue(queue, _node); ds_queue_enqueue(queue, _node);
} }
} }