Fix T97375: changing node tree from Python is very slow
The issue was that the `NodeTreeRef` acceleration data structure was rebuild much more often than necessary. That happened because the Map Range node accidentally tagged the node tree for change even though it did not actually change. Differential Revision: https://developer.blender.org/D14842
This commit is contained in:
@@ -66,24 +66,32 @@ static void node_shader_update_map_range(bNodeTree *ntree, bNode *node)
|
|||||||
const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type);
|
const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type);
|
||||||
const int type = (data_type == CD_PROP_FLOAT) ? SOCK_FLOAT : SOCK_VECTOR;
|
const int type = (data_type == CD_PROP_FLOAT) ? SOCK_FLOAT : SOCK_VECTOR;
|
||||||
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
Array<bool> new_input_availability(BLI_listbase_count(&node->inputs));
|
||||||
nodeSetSocketAvailability(ntree, socket, socket->type == type);
|
Array<bool> new_output_availability(BLI_listbase_count(&node->outputs));
|
||||||
}
|
|
||||||
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
|
int index;
|
||||||
nodeSetSocketAvailability(ntree, socket, socket->type == type);
|
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->inputs, index) {
|
||||||
|
new_input_availability[index] = socket->type == type;
|
||||||
|
}
|
||||||
|
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->outputs, index) {
|
||||||
|
new_output_availability[index] = socket->type == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storage.interpolation_type != NODE_MAP_RANGE_STEPPED) {
|
if (storage.interpolation_type != NODE_MAP_RANGE_STEPPED) {
|
||||||
if (type == SOCK_FLOAT) {
|
if (type == SOCK_FLOAT) {
|
||||||
bNodeSocket *sockSteps = (bNodeSocket *)BLI_findlink(&node->inputs, 5);
|
new_input_availability[5] = false;
|
||||||
nodeSetSocketAvailability(ntree, sockSteps, false);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bNodeSocket *sockSteps = (bNodeSocket *)BLI_findlink(&node->inputs, 11);
|
new_input_availability[11] = false;
|
||||||
nodeSetSocketAvailability(ntree, sockSteps, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->inputs, index) {
|
||||||
|
nodeSetSocketAvailability(ntree, socket, new_input_availability[index]);
|
||||||
|
}
|
||||||
|
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &node->outputs, index) {
|
||||||
|
nodeSetSocketAvailability(ntree, socket, new_output_availability[index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_shader_init_map_range(bNodeTree *UNUSED(ntree), bNode *node)
|
static void node_shader_init_map_range(bNodeTree *UNUSED(ntree), bNode *node)
|
||||||
|
|||||||
Reference in New Issue
Block a user