Fix #114102: Node tool data-block inputs broken #114347
|
@ -236,11 +236,22 @@ static Depsgraph *build_depsgraph_from_indirect_ids(Main &bmain,
|
|||
Scene &scene,
|
||||
ViewLayer &view_layer,
|
||||
const bNodeTree &node_tree_orig,
|
||||
const Span<const Object *> objects)
|
||||
const Span<const Object *> objects,
|
||||
const IDProperty &properties)
|
||||
{
|
||||
Set<ID *> ids_for_relations;
|
||||
bool needs_own_transform_relation = false;
|
||||
nodes::find_node_tree_dependencies(node_tree_orig, ids_for_relations, needs_own_transform_relation);
|
||||
nodes::find_node_tree_dependencies(
|
||||
node_tree_orig, ids_for_relations, needs_own_transform_relation);
|
||||
IDP_foreach_property(
|
||||
&const_cast<IDProperty &>(properties),
|
||||
IDP_TYPE_FILTER_ID,
|
||||
[](IDProperty *property, void *user_data) {
|
||||
if (ID *id = IDP_Id(property)) {
|
||||
static_cast<Set<ID *> *>(user_data)->add(id);
|
||||
}
|
||||
},
|
||||
&ids_for_relations);
|
||||
|
||||
Vector<const ID *> ids;
|
||||
ids.append(&node_tree_orig.id);
|
||||
|
@ -252,6 +263,24 @@ static Depsgraph *build_depsgraph_from_indirect_ids(Main &bmain,
|
|||
return depsgraph;
|
||||
}
|
||||
|
||||
static IDProperty *replace_inputs_evaluated_data_blocks(const IDProperty &op_properties,
|
||||
const Depsgraph &depsgraph)
|
||||
{
|
||||
/* We just create a temporary copy, so don't adjust data-block user count. */
|
||||
HooglyBoogly marked this conversation as resolved
Outdated
|
||||
IDProperty *properties = IDP_CopyProperty_ex(&op_properties, LIB_ID_CREATE_NO_USER_REFCOUNT);
|
||||
IDP_foreach_property(
|
||||
properties,
|
||||
IDP_TYPE_FILTER_ID,
|
||||
[](IDProperty *property, void *user_data) {
|
||||
if (ID *id = IDP_Id(property)) {
|
||||
Depsgraph *depsgraph = static_cast<Depsgraph *>(user_data);
|
||||
Jacques Lucke
commented
Can this use Can this use `IDP_Id` as well?
Hans Goudey
commented
Seemed like it should work to me too, but apparently not.
Seemed like it should work to me too, but apparently not.
```
/home/hans/blender-git/blender/source/blender/blenkernel/BKE_idprop.h:268:25: error: lvalue required as left operand of assignment
268 | # define IDP_Id(prop) ((ID *)(prop)->data.pointer)
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hans/blender-git/blender/source/blender/editors/geometry/node_group_operator.cc:277:11: note: in expansion of macro ‘IDP_Id’
277 | IDP_Id(property) = DEG_get_evaluated_id(depsgraph, id);
| ^~~~~~
```
Jacques Lucke
commented
Should be possible to fix This can be cleaned up separately though. Should be possible to fix `IDP_Id` for this like so (note that it is defined in two places):
`#define IDP_Id(prop) (*(ID **)&(prop)->data.pointer)`
This can be cleaned up separately though.
|
||||
property->data.pointer = DEG_get_evaluated_id(depsgraph, id);
|
||||
}
|
||||
},
|
||||
&const_cast<Depsgraph &>(depsgraph));
|
||||
return properties;
|
||||
}
|
||||
|
||||
static int run_node_group_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
@ -277,7 +306,7 @@ static int run_node_group_exec(bContext *C, wmOperator *op)
|
|||
BLI_SCOPED_DEFER([&]() { MEM_SAFE_FREE(objects); });
|
||||
|
||||
Depsgraph *depsgraph = build_depsgraph_from_indirect_ids(
|
||||
*bmain, *scene, *view_layer, *node_tree_orig, {objects, objects_len});
|
||||
*bmain, *scene, *view_layer, *node_tree_orig, {objects, objects_len}, *op->properties);
|
||||
DEG_evaluate_on_refresh(depsgraph);
|
||||
BLI_SCOPED_DEFER([&]() { DEG_graph_free(depsgraph); });
|
||||
|
||||
|
@ -296,6 +325,9 @@ static int run_node_group_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
IDProperty *properties = replace_inputs_evaluated_data_blocks(*op->properties, *depsgraph);
|
||||
BLI_SCOPED_DEFER([&]() { IDP_FreeProperty_ex(properties, false); });
|
||||
|
||||
OperatorComputeContext compute_context(op->type->idname);
|
||||
|
||||
for (Object *object : Span(objects, objects_len)) {
|
||||
|
@ -311,7 +343,7 @@ static int run_node_group_exec(bContext *C, wmOperator *op)
|
|||
|
||||
bke::GeometrySet new_geometry = nodes::execute_geometry_nodes_on_geometry(
|
||||
*node_tree,
|
||||
op->properties,
|
||||
properties,
|
||||
compute_context,
|
||||
std::move(geometry_orig),
|
||||
[&](nodes::GeoNodesLFUserData &user_data) {
|
||||
|
|
Loading…
Reference in New Issue
Haven't tried it myself now, please double check and maybe add a comment for how user counting is handled here.