Geometry Nodes: Node error messages
This patch adds icons to the right side of nodes when they encounter a a problem. When hovered, a tooltip displays describing the encountered while evaluating the node. Some examples are: attribute doesn't exist, mesh has no faces, incorrect attribute type, etc. Exposing more messages to the system will be an ongoing process. Multiple warnings per node are supported. The system is implemented somewhat generically so that the basic structure can also be used to store more information from evaluation for the interface, like a list of available attributes. Currently the messages are just button tooltips. They could be styled differently in the future. Another limitation is that every instance of a node group in a parent node tree will have the same error messages, the "evaluation context" used to decide when to display the tooltips must be extended to support node tree paths. Differential Revision: https://developer.blender.org/D10290
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_node_ui_storage.hh"
|
||||
#include "BKE_pointcloud.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_simulation.h"
|
||||
@@ -244,6 +245,7 @@ class GeometryNodesEvaluator {
|
||||
const blender::nodes::DataTypeConversions &conversions_;
|
||||
const PersistentDataHandleMap &handle_map_;
|
||||
const Object *self_object_;
|
||||
const ModifierData *modifier_;
|
||||
Depsgraph *depsgraph_;
|
||||
|
||||
public:
|
||||
@@ -252,12 +254,14 @@ class GeometryNodesEvaluator {
|
||||
blender::nodes::MultiFunctionByNode &mf_by_node,
|
||||
const PersistentDataHandleMap &handle_map,
|
||||
const Object *self_object,
|
||||
const ModifierData *modifier,
|
||||
Depsgraph *depsgraph)
|
||||
: group_outputs_(std::move(group_outputs)),
|
||||
mf_by_node_(mf_by_node),
|
||||
conversions_(blender::nodes::get_implicit_type_conversions()),
|
||||
handle_map_(handle_map),
|
||||
self_object_(self_object),
|
||||
modifier_(modifier),
|
||||
depsgraph_(depsgraph)
|
||||
{
|
||||
for (auto item : group_input_data.items()) {
|
||||
@@ -359,7 +363,7 @@ class GeometryNodesEvaluator {
|
||||
/* Execute the node. */
|
||||
GValueMap<StringRef> node_outputs_map{allocator_};
|
||||
GeoNodeExecParams params{
|
||||
node, node_inputs_map, node_outputs_map, handle_map_, self_object_, depsgraph_};
|
||||
node, node_inputs_map, node_outputs_map, handle_map_, self_object_, modifier_, depsgraph_};
|
||||
this->execute_node(node, params);
|
||||
|
||||
/* Forward computed outputs to linked input sockets. */
|
||||
@@ -946,6 +950,19 @@ static void fill_data_handle_map(const NodesModifierSettings &settings,
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_tree_ui_storage(Span<const blender::nodes::NodeTreeRef *> trees,
|
||||
const Object &object,
|
||||
const ModifierData &modifier)
|
||||
{
|
||||
const NodeTreeEvaluationContext context = {object, modifier};
|
||||
|
||||
for (const blender::nodes::NodeTreeRef *tree : trees) {
|
||||
bNodeTree *btree_cow = tree->btree();
|
||||
bNodeTree *btree_original = (bNodeTree *)DEG_get_original_id((ID *)btree_cow);
|
||||
BKE_nodetree_ui_storage_free_for_context(*btree_original, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate a node group to compute the output geometry.
|
||||
* Currently, this uses a fairly basic and inefficient algorithm that might compute things more
|
||||
@@ -992,8 +1009,14 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
|
||||
Vector<const DInputSocket *> group_outputs;
|
||||
group_outputs.append(&socket_to_compute);
|
||||
|
||||
GeometryNodesEvaluator evaluator{
|
||||
group_inputs, group_outputs, mf_by_node, handle_map, ctx->object, ctx->depsgraph};
|
||||
GeometryNodesEvaluator evaluator{group_inputs,
|
||||
group_outputs,
|
||||
mf_by_node,
|
||||
handle_map,
|
||||
ctx->object,
|
||||
(ModifierData *)nmd,
|
||||
ctx->depsgraph};
|
||||
|
||||
Vector<GMutablePointer> results = evaluator.execute();
|
||||
BLI_assert(results.size() == 1);
|
||||
GMutablePointer result = results[0];
|
||||
@@ -1091,6 +1114,8 @@ static void modifyGeometry(ModifierData *md,
|
||||
return;
|
||||
}
|
||||
|
||||
reset_tree_ui_storage(tree.used_node_tree_refs(), *ctx->object, *md);
|
||||
|
||||
geometry_set = compute_geometry(
|
||||
tree, group_inputs, *group_outputs[0], std::move(geometry_set), nmd, ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user