2022-01-25 04:05:30 +01:00
|
|
|
enum RENDER_TYPE {
|
|
|
|
none = 0,
|
|
|
|
partial = 1,
|
|
|
|
full = 2
|
|
|
|
}
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
#region globalvar
|
2023-06-01 10:32:21 +02:00
|
|
|
global.FLAG.render = false;
|
2023-03-28 06:58:28 +02:00
|
|
|
global.group_inputs = [ "Node_Group_Input", "Node_Feedback_Input", "Node_Iterator_Input", "Node_Iterator_Each_Input" ];
|
|
|
|
#endregion
|
2022-12-13 09:20:36 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
function __nodeLeafList(_list) {
|
|
|
|
var nodes = [];
|
2023-06-01 10:32:21 +02:00
|
|
|
var nodeNames = [];
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2022-01-24 02:21:25 +01:00
|
|
|
for( var i = 0; i < ds_list_size(_list); i++ ) {
|
|
|
|
var _node = _list[| i];
|
2022-12-13 09:20:36 +01:00
|
|
|
if(!_node.active) continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!_node.isRenderActive()) continue;
|
2022-12-13 09:20:36 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
var _startNode = _node.isRenderable();
|
2022-12-13 09:20:36 +01:00
|
|
|
if(_startNode) {
|
2023-03-28 06:58:28 +02:00
|
|
|
array_push(nodes, _node);
|
2023-06-01 10:32:21 +02:00
|
|
|
array_push(nodeNames, _node.internalName);
|
2022-01-24 02:21:25 +01:00
|
|
|
}
|
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_LINE_IF(global.FLAG.render, $"Push node {nodeNames} to stack");
|
2023-03-28 06:58:28 +02:00
|
|
|
return nodes;
|
2022-01-24 02:21:25 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 11:40:24 +01:00
|
|
|
function __nodeIsLoop(_node) {
|
|
|
|
switch(instanceof(_node)) {
|
|
|
|
case "Node_Iterate" :
|
|
|
|
case "Node_Iterate_Each" :
|
2023-03-24 05:55:34 +01:00
|
|
|
case "Node_Iterate_Filter" :
|
|
|
|
case "Node_Feedback" :
|
2023-02-14 11:40:24 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
function __nodeInLoop(_node) {
|
|
|
|
var gr = _node.group;
|
2023-02-28 09:43:01 +01:00
|
|
|
while(gr != noone) {
|
2023-02-14 11:40:24 +01:00
|
|
|
if(__nodeIsLoop(gr)) return true;
|
2022-12-16 09:18:09 +01:00
|
|
|
gr = gr.group;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-17 18:59:20 +02:00
|
|
|
function Render(partial = false, runAction = false) {
|
2023-03-28 06:58:28 +02:00
|
|
|
var t = current_time;
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_START();
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render,
|
2023-07-06 19:49:16 +02:00
|
|
|
$"============================== RENDER START [frame {string(PROJECT.animator.current_frame)}] ==============================");
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
try {
|
|
|
|
var rendering = noone;
|
2023-06-01 10:32:21 +02:00
|
|
|
var error = 0;
|
|
|
|
var reset_all = !partial || ALWAYS_FULL;
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
if(reset_all) {
|
2023-07-06 19:49:16 +02:00
|
|
|
var _key = ds_map_find_first(PROJECT.nodeMap);
|
|
|
|
var amo = ds_map_size(PROJECT.nodeMap);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
repeat(amo) {
|
2023-07-06 19:49:16 +02:00
|
|
|
var _node = PROJECT.nodeMap[? _key];
|
2023-02-14 02:51:14 +01:00
|
|
|
_node.setRenderStatus(false);
|
2023-07-06 19:49:16 +02:00
|
|
|
_key = ds_map_find_next(PROJECT.nodeMap, _key);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
// get leaf node
|
2023-06-01 10:32:21 +02:00
|
|
|
RENDER_QUEUE.clear();
|
2023-07-06 19:49:16 +02:00
|
|
|
var key = ds_map_find_first(PROJECT.nodeMap);
|
|
|
|
var amo = ds_map_size(PROJECT.nodeMap);
|
2023-02-14 02:51:14 +01:00
|
|
|
repeat(amo) {
|
2023-07-06 19:49:16 +02:00
|
|
|
var _node = PROJECT.nodeMap[? key];
|
|
|
|
key = ds_map_find_next(PROJECT.nodeMap, key);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(is_undefined(_node)) continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!is_struct(_node)) continue;
|
2023-02-14 11:40:24 +01:00
|
|
|
if(array_exists(global.group_inputs, instanceof(_node))) continue;
|
2023-04-03 11:55:45 +02:00
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!_node.active) continue;
|
|
|
|
if(!_node.isRenderActive()) continue;
|
2023-03-29 15:02:03 +02:00
|
|
|
if(_node.rendered) {
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Skip rendered {_node.internalName}");
|
2023-03-29 15:02:03 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
//if(__nodeInLoop(_node)) continue;
|
|
|
|
if(_node.group != noone) continue;
|
2023-03-29 15:02:03 +02:00
|
|
|
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_START();
|
|
|
|
|
2023-05-22 20:31:55 +02:00
|
|
|
var _startNode = _node.isRenderable(global.FLAG.render);
|
2023-03-28 06:58:28 +02:00
|
|
|
if(_startNode) {
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Found leaf {_node.internalName}");
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
if(!reset_all) _node.triggerRender();
|
|
|
|
RENDER_QUEUE.enqueue(_node);
|
2023-03-29 15:02:03 +02:00
|
|
|
} else
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Skip non-leaf {_node.internalName}");
|
2023-04-03 11:55:45 +02:00
|
|
|
|
|
|
|
LOG_BLOCK_END();
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
2023-04-03 11:55:45 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Get leaf complete: found {RENDER_QUEUE.size()} leaves.");
|
|
|
|
LOG_IF(global.FLAG.render, "================== Start rendering ==================");
|
2022-01-24 02:21:25 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
// render forward
|
2023-06-01 10:32:21 +02:00
|
|
|
while(!RENDER_QUEUE.empty()) {
|
|
|
|
LOG_BLOCK_START();
|
|
|
|
LOG_IF(global.FLAG.render, $"➤➤➤➤➤➤ CURRENT RENDER QUEUE {RENDER_QUEUE}");
|
|
|
|
rendering = RENDER_QUEUE.dequeue();
|
2023-04-04 13:44:37 +02:00
|
|
|
var renderable = rendering.isRenderable();
|
2023-04-03 11:55:45 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
|
2023-03-29 15:02:03 +02:00
|
|
|
|
2023-04-04 13:44:37 +02:00
|
|
|
if(renderable) {
|
2023-03-02 07:59:14 +01:00
|
|
|
rendering.doUpdate();
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var nextNodes = rendering.getNextNodes();
|
2023-03-29 15:02:03 +02:00
|
|
|
for( var i = 0; i < array_length(nextNodes); i++ )
|
2023-06-01 10:32:21 +02:00
|
|
|
RENDER_QUEUE.enqueue(nextNodes[i]);
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
if(runAction && rendering.hasInspector1Update())
|
|
|
|
rendering.inspector1Update();
|
2023-06-13 14:42:06 +02:00
|
|
|
}
|
2023-03-29 15:02:03 +02:00
|
|
|
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_END();
|
2023-03-02 07:59:14 +01:00
|
|
|
}
|
2023-05-08 10:50:42 +02:00
|
|
|
} catch(e) {
|
2023-03-02 07:59:14 +01:00
|
|
|
noti_warning(exception_print(e));
|
2023-05-08 10:50:42 +02:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-05-22 20:31:55 +02:00
|
|
|
LOG_IF(global.FLAG.render, "=== RENDER COMPLETE IN {" + string(current_time - t) + "ms} ===\n");
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_END();
|
2023-03-02 07:59:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function __renderListReset(list) {
|
|
|
|
for( var i = 0; i < ds_list_size(list); i++ ) {
|
|
|
|
list[| i].setRenderStatus(false);
|
2023-03-24 05:55:34 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
if(struct_has(list[| i], "nodes"))
|
|
|
|
__renderListReset(list[| i].nodes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-23 16:47:33 +02:00
|
|
|
function RenderList(list) {
|
|
|
|
LOG_BLOCK_START();
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, "=============== RENDER LIST START ===============");
|
2023-04-23 16:47:33 +02:00
|
|
|
var queue = ds_queue_create();
|
|
|
|
|
|
|
|
try {
|
|
|
|
var rendering = noone;
|
|
|
|
var error = 0;
|
|
|
|
var t = current_time;
|
|
|
|
|
|
|
|
__renderListReset(list);
|
|
|
|
|
|
|
|
// get leaf node
|
|
|
|
for( var i = 0; i < ds_list_size(list); i++ ) {
|
|
|
|
var _node = list[| i];
|
|
|
|
|
|
|
|
if(is_undefined(_node)) continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!is_struct(_node)) continue;
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!_node.active) continue;
|
|
|
|
if(!_node.isRenderActive()) continue;
|
|
|
|
if(_node.rendered) continue;
|
2023-04-23 16:47:33 +02:00
|
|
|
|
|
|
|
if(_node.isRenderable())
|
|
|
|
ds_queue_enqueue(queue, _node);
|
|
|
|
}
|
|
|
|
|
2023-05-22 20:31:55 +02:00
|
|
|
LOG_IF(global.FLAG.render, "Get leaf complete: found " + string(ds_queue_size(queue)) + " leaves.");
|
2023-06-01 10:32:21 +02:00
|
|
|
LOG_IF(global.FLAG.render, "=== Start rendering ===");
|
2023-04-23 16:47:33 +02:00
|
|
|
|
|
|
|
// render forward
|
|
|
|
while(!ds_queue_empty(queue)) {
|
2023-06-13 14:42:06 +02:00
|
|
|
LOG_BLOCK_START();
|
|
|
|
LOG_IF(global.FLAG.render, $"➤➤➤➤➤➤ CURRENT RENDER QUEUE {RENDER_QUEUE}");
|
|
|
|
rendering = RENDER_QUEUE.dequeue();
|
|
|
|
if(!ds_list_exist(list, rendering)) continue;
|
|
|
|
var renderable = rendering.isRenderable();
|
|
|
|
|
|
|
|
LOG_IF(global.FLAG.render, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
if(renderable) {
|
|
|
|
rendering.doUpdate();
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
var nextNodes = rendering.getNextNodes();
|
|
|
|
for( var i = 0; i < array_length(nextNodes); i++ )
|
|
|
|
RENDER_QUEUE.enqueue(nextNodes[i]);
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
if(runAction && rendering.hasInspector1Update())
|
|
|
|
rendering.inspector1Update();
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(rendering.isRenderActive()) {
|
2023-06-13 14:42:06 +02:00
|
|
|
RENDER_QUEUE.enqueue(rendering);
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_BLOCK_END();
|
2023-04-23 16:47:33 +02:00
|
|
|
}
|
|
|
|
|
2023-05-08 10:50:42 +02:00
|
|
|
} catch(e) {
|
2023-04-23 16:47:33 +02:00
|
|
|
noti_warning(exception_print(e));
|
2023-05-08 10:50:42 +02:00
|
|
|
}
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-05-22 20:31:55 +02:00
|
|
|
LOG_IF(global.FLAG.render, "=== RENDER COMPLETE ===\n");
|
2023-04-23 16:47:33 +02:00
|
|
|
LOG_END();
|
|
|
|
|
|
|
|
ds_queue_destroy(queue);
|
|
|
|
}
|
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
function RenderListAction(list, context = PANEL_GRAPH.getCurrentContext()) {
|
2023-07-06 19:49:16 +02:00
|
|
|
printIf(global.FLAG.render, "=== RENDER LIST ACTION START [frame " + string(PROJECT.animator.current_frame) + "] ===");
|
2023-03-24 05:55:34 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
try {
|
|
|
|
var rendering = noone;
|
2023-03-24 05:55:34 +01:00
|
|
|
var error = 0;
|
|
|
|
var t = current_time;
|
2023-03-02 07:59:14 +01:00
|
|
|
|
|
|
|
__renderListReset(list);
|
|
|
|
|
|
|
|
// get leaf node
|
2023-06-01 10:32:21 +02:00
|
|
|
RENDER_QUEUE.clear();
|
2023-03-02 07:59:14 +01:00
|
|
|
for( var i = 0; i < ds_list_size(list); i++ ) {
|
|
|
|
var _node = list[| i];
|
|
|
|
|
|
|
|
if(is_undefined(_node)) continue;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!is_struct(_node)) continue;
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!_node.active) continue;
|
|
|
|
if(!_node.isRenderActive()) continue;
|
|
|
|
if(_node.rendered) continue;
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-03-24 05:55:34 +01:00
|
|
|
if(_node.isRenderable()) {
|
2023-06-01 10:32:21 +02:00
|
|
|
RENDER_QUEUE.enqueue(_node);
|
|
|
|
printIf(global.FLAG.render, $" > Push {_node.internalName} node to stack");
|
2023-03-02 07:59:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// render forward
|
2023-06-01 10:32:21 +02:00
|
|
|
while(!RENDER_QUEUE.empty()) {
|
2023-06-13 14:42:06 +02:00
|
|
|
LOG_BLOCK_START();
|
|
|
|
LOG_IF(global.FLAG.render, $"➤➤➤➤➤➤ CURRENT RENDER QUEUE {RENDER_QUEUE}");
|
2023-06-01 10:32:21 +02:00
|
|
|
rendering = RENDER_QUEUE.dequeue();
|
2023-06-13 14:42:06 +02:00
|
|
|
if(!ds_list_exist(list, rendering)) continue;
|
|
|
|
var renderable = rendering.isRenderable();
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
LOG_IF(global.FLAG.render, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
|
2023-03-29 15:02:03 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
if(renderable) {
|
2023-02-14 02:51:14 +01:00
|
|
|
rendering.doUpdate();
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
var nextNodes = rendering.getNextNodes();
|
2023-06-13 14:42:06 +02:00
|
|
|
for( var i = 0; i < array_length(nextNodes); i++ )
|
2023-06-01 10:32:21 +02:00
|
|
|
RENDER_QUEUE.enqueue(nextNodes[i]);
|
2023-06-13 14:42:06 +02:00
|
|
|
|
|
|
|
if(runAction && rendering.hasInspector1Update())
|
|
|
|
rendering.inspector1Update();
|
2023-06-17 14:30:49 +02:00
|
|
|
} else if(rendering.isRenderActive()) {
|
2023-06-13 14:42:06 +02:00
|
|
|
RENDER_QUEUE.enqueue(rendering);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
2023-03-29 15:02:03 +02:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
LOG_BLOCK_END();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-05-22 20:31:55 +02:00
|
|
|
printIf(global.FLAG.render, "=== RENDER COMPLETE IN {" + string(current_time - t) + "ms} ===\n");
|
2023-05-08 10:50:42 +02:00
|
|
|
} catch(e) {
|
2023-07-14 20:34:35 +02:00
|
|
|
noti_warning(exception_print(e));
|
2023-05-08 10:50:42 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|