[Bf-blender-cvs] [a70010f78be] temp-node-error-messages: Merge branch 'master' into temp-node-error-messages

Hans Goudey noreply at git.blender.org
Tue Feb 16 04:49:24 CET 2021


Commit: a70010f78be443c21ff64bb782948eb419a044a0
Author: Hans Goudey
Date:   Mon Feb 15 12:09:50 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rBa70010f78be443c21ff64bb782948eb419a044a0

Merge branch 'master' into temp-node-error-messages

===================================================================



===================================================================

diff --cc source/blender/editors/space_node/node_draw.c
index 473583c8beb,c7be5f848f7..70bd1432b1b
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@@ -1119,80 -1152,30 +1154,102 @@@ void node_draw_sockets(const View2D *v2
  
    GPU_program_point_size(false);
    GPU_blend(GPU_BLEND_NONE);
+ 
+   /* Draw multi-input sockets after the others because they are drawn with `UI_draw_roundbox`
+    * rather than with `GL_POINT`. */
+   LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+     if (nodeSocketIsHidden(socket)) {
+       continue;
+     }
+     if (!(socket->flag & SOCK_MULTI_INPUT)) {
+       continue;
+     }
+ 
+     const bool is_node_hidden = (node->flag & NODE_HIDDEN);
+     const float width = NODE_SOCKSIZE;
+     float height = is_node_hidden ? width : node_socket_calculate_height(socket) - width;
+ 
+     float color[4];
+     float outline_color[4];
+     node_socket_color_get((bContext *)C, ntree, &node_ptr, socket, color);
+     node_socket_outline_color_get(selected, outline_color);
+ 
+     node_socket_draw_multi_input(color, outline_color, width, height, socket->locx, socket->locy);
+   }
  }
  
 +static int node_error_type_to_icon(const eNodeWarningType type)
 +{
 +  switch (type) {
 +    case NODE_WARNING_ERROR:
 +      return ICON_ERROR;
 +    case NODE_WARNING_INFO:
 +      return ICON_INFO;
 +  }
 +
 +  BLI_assert(false);
 +  return ICON_ERROR;
 +}
 +
 +static char *node_errros_tooltip_fn(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
 +{
 +  NodeWarning *message = (NodeWarning *)argN;
 +
 +  return BLI_strdup(message->message);
 +}
 +
 +#define NODE_HEADER_ICON_SIZE 0.8f * U.widget_unit
 +
 +static int node_add_error_message_button(
 +    const bContext *C, bNodeTree *ntree, bNode *node, const rctf *rect, int icon_offset)
 +{
 +  const NodeWarning *message = BKE_nodetree_error_message_get(ntree, node);
 +  if (message == NULL) {
 +    return icon_offset;
 +  }
 +
 +  // /* The same node tree can be used for multiple objects, only display
 +  //  * messages for the evaluations corresponding to the active object. */
 +  // const Object *active_object = CTX_data_active_object(C);
 +  // if (message->object != active_object) {
 +  //   return icon_offset;
 +  // }
 +
 +  // /* The same node tree can be used for multiple modifiers on the same object. Only display
 +  //  * messages for the active modifier, which will also be displayed in the node tree. */
 +  // ModifierData *active_modifier = BKE_object_active_modifier(message->object);
 +  // if (!STREQ(message->modifier_name, active_modifier->name)) {
 +  //   return icon_offset;
 +  // }
 +
 +  icon_offset -= NODE_HEADER_ICON_SIZE;
 +
 +  UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
 +  /* The only reason to allocate this is that the ownership of
 +   * #UI_but_func_tooltip_set's argument is transferred to the button. */
 +  NodeWarning *warning_alloc = MEM_mallocN(sizeof(NodeWarning), __func__);
 +  warning_alloc->type = message->type;
 +  warning_alloc->message = message->message;
 +  uiBut *but = uiDefIconBut(node->block,
 +                            UI_BTYPE_BUT,
 +                            0,
 +                            node_error_type_to_icon(message->type),
 +                            icon_offset,
 +                            rect->ymax - NODE_DY,
 +                            NODE_HEADER_ICON_SIZE,
 +                            UI_UNIT_Y,
 +                            NULL,
 +                            0,
 +                            0,
 +                            0,
 +                            0,
 +                            NULL);
 +  UI_but_func_tooltip_set(but, node_errros_tooltip_fn, warning_alloc);
 +  UI_block_emboss_set(node->block, UI_EMBOSS);
 +
 +  return icon_offset;
 +}
 +
  static void node_draw_basis(const bContext *C,
                              const View2D *v2d,
                              const SpaceNode *snode,
diff --cc source/blender/modifiers/intern/MOD_nodes.cc
index 16f7c22700c,0fec7cfe937..ac29bbb2958
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@@ -214,9 -237,8 +237,9 @@@ static bool isDisabled(const struct Sce
  
  class GeometryNodesEvaluator {
   private:
 +  bNodeTree &btree_;
    blender::LinearAllocator<> allocator_;
-   Map<const DInputSocket *, GMutablePointer> value_by_input_;
+   Map<std::pair<const DInputSocket *, const DOutputSocket *>, GMutablePointer> value_by_input_;
    Vector<const DInputSocket *> group_outputs_;
    blender::nodes::MultiFunctionByNode &mf_by_node_;
    const blender::nodes::DataTypeConversions &conversions_;
@@@ -250,13 -267,10 +273,13 @@@
  
    Vector<GMutablePointer> execute()
    {
 +    bNodeTree *original_ntree = (bNodeTree *)DEG_get_original_id(&(ID &)btree_);
 +    BKE_nodetree_error_messages_clear(original_ntree);
 +
      Vector<GMutablePointer> results;
      for (const DInputSocket *group_output : group_outputs_) {
-       GMutablePointer result = this->get_input_value(*group_output);
-       results.append(result);
+       Vector<GMutablePointer> result = this->get_input_values(*group_output);
+       results.append(result[0]);
      }
      for (GMutablePointer value : value_by_input_.values()) {
        value.destruct();
diff --cc source/blender/nodes/intern/node_geometry_exec.cc
index 85868350153,6ddeb73e31f..3ff3855fbe8
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@@ -21,18 -17,10 +21,20 @@@
  #include "NOD_geometry_exec.hh"
  #include "NOD_type_callbacks.hh"
  
+ #include "node_geometry_util.hh"
+ 
  namespace blender::nodes {
  
 +void GeoNodeExecParams::error_message_add(const eNodeWarningType type,
 +                                          const std::string &message) const
 +{
 +  bNodeTree *original_ntree = (bNodeTree *)DEG_get_original_id(&(ID &)ntree_);
 +  if (original_ntree != nullptr) {
 +    BKE_nodetree_error_message_add(
 +        original_ntree, self_object_, modifier_->name, &node_, type, message.data());
 +  }
 +}
 +
  const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef name) const
  {
    LISTBASE_FOREACH (const bNodeSocket *, socket, &node_.inputs) {



More information about the Bf-blender-cvs mailing list