[Bf-blender-cvs] [cb38233f6c3] temp-geometry-nodes-expandable-geometry-socket-prototype: improve automatic array source detection in expander
Jacques Lucke
noreply at git.blender.org
Fri Aug 6 16:46:32 CEST 2021
Commit: cb38233f6c3dd35c2e25eea11c6b7ea79a6220f8
Author: Jacques Lucke
Date: Fri Aug 6 16:46:24 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rBcb38233f6c3dd35c2e25eea11c6b7ea79a6220f8
improve automatic array source detection in expander
===================================================================
M source/blender/editors/space_node/node_edit.cc
M source/blender/makesdna/DNA_node_types.h
M source/blender/nodes/geometry/nodes/node_geo_extrude.cc
M source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
M source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
===================================================================
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index 25786ba503a..66047aa76bb 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -2999,7 +2999,7 @@ static void foreach_available_attribute(
if (group_input->type == SOCK_STRING) {
GeometryExpanderOutput attribute;
attribute.type = GEOMETRY_EXPANDER_OUTPUT_TYPE_INPUT;
- attribute.array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_MESH_VERTICES;
+ attribute.array_source = (eGeometryExpanderArraySource)group_input->output_array_source;
STRNCPY(attribute.input_identifier, group_input->identifier);
attribute.socket_type = SOCK_FLOAT;
callback(attribute);
@@ -3012,7 +3012,7 @@ static void foreach_available_attribute(
GeometryExpanderOutput attribute;
attribute.type = GEOMETRY_EXPANDER_OUTPUT_TYPE_LOCAL;
attribute.socket_type = (eNodeSocketDatatype)node_output->type;
- attribute.array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_MESH_VERTICES;
+ attribute.array_source = (eGeometryExpanderArraySource)node_output->output_array_source;
STRNCPY(attribute.local_node_name, node->name);
STRNCPY(attribute.local_socket_identifier, node_output->identifier);
callback(attribute);
@@ -3031,7 +3031,7 @@ static void foreach_available_attribute(
GeometryExpanderOutput attribute;
attribute.type = GEOMETRY_EXPANDER_OUTPUT_TYPE_BUILTIN;
attribute.socket_type = SOCK_INT;
- attribute.array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_MESH_VERTICES;
+ attribute.array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_MESH_FACES;
STRNCPY(attribute.builtin_identifier, "material_index");
callback(attribute);
}
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 982811ff34a..99072e48081 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -149,6 +149,10 @@ typedef struct bNodeSocket {
* kept for forward compatibility */
/** Custom data for inputs, only UI writes in this. */
bNodeStack ns DNA_DEPRECATED;
+
+ /* eGeometryExpanderArraySource. */
+ int output_array_source;
+ char _pad2[4];
} bNodeSocket;
/* sock->type */
@@ -1446,7 +1450,7 @@ typedef enum eGeometryExpanderArraySource {
GEOMETRY_EXPANDER_ARRAY_SOURCE_POINT_CLOUD_POINTS = 4,
GEOMETRY_EXPANDER_ARRAY_SOURCE_CURVE_POINTS = 5,
GEOMETRY_EXPANDER_ARRAY_SOURCE_CURVE_SPLINES = 6,
-} AttributeArraySource;
+} eGeometryExpanderArraySource;
typedef struct GeometryExpanderOutput {
struct GeometryExpanderOutput *next, *prev;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude.cc
index 69099d88397..49e42bfb2c3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_extrude.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_extrude.cc
@@ -46,6 +46,15 @@ static bNodeSocketTemplate geo_node_extrude_out[] = {
using blender::Span;
+static void geo_node_extrude_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+ if (socket->type != SOCK_GEOMETRY) {
+ socket->output_array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_MESH_FACES;
+ }
+ }
+}
+
static Mesh *extrude_mesh(const Mesh *mesh,
const Span<bool> selection,
const Span<float> distance,
@@ -198,6 +207,7 @@ void register_node_type_geo_extrude()
geo_node_type_base(&ntype, GEO_NODE_EXTRUDE, "Extrude", NODE_CLASS_GEOMETRY, 0);
node_type_socket_templates(&ntype, geo_node_extrude_in, geo_node_extrude_out);
+ node_type_init(&ntype, geo_node_extrude_init);
ntype.geometry_node_execute = blender::nodes::geo_node_extrude_exec;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc b/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
index 820370ef562..ec1b1f4ea2d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_geometry_expander.cc
@@ -65,7 +65,7 @@ static bool geo_node_geometry_expander_socket_layout(const bContext *UNUSED(C),
&ntree->id, &RNA_GeometryExpanderOutput, expander_output, &expander_output_ptr);
uiLayout *row = uiLayoutRow(layout, true);
- uiLayout *split = uiLayoutSplit(row, 0.7, false);
+ uiLayout *split = uiLayoutSplit(row, 0.6, false);
uiItemL(split, expander_output->display_name_cache, ICON_NONE);
uiLayout *subrow = uiLayoutRow(split, true);
if (expander_output->is_outdated) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 234bd820074..f521c157d22 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -62,6 +62,15 @@ static void geo_node_point_distribute_layout(uiLayout *layout,
uiItemR(layout, ptr, "distribute_method", 0, "", ICON_NONE);
}
+static void geo_node_point_distribute_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+ if (socket->type != SOCK_GEOMETRY) {
+ socket->output_array_source = GEOMETRY_EXPANDER_ARRAY_SOURCE_POINT_CLOUD_POINTS;
+ }
+ }
+}
+
static void node_point_distribute_update(bNodeTree *UNUSED(ntree), bNode *node)
{
bNodeSocket *sock_min_dist = (bNodeSocket *)BLI_findlink(&node->inputs, 1);
@@ -672,6 +681,7 @@ void register_node_type_geo_point_distribute()
&ntype, GEO_NODE_POINT_DISTRIBUTE, "Point Distribute", NODE_CLASS_GEOMETRY, 0);
node_type_socket_templates(&ntype, geo_node_point_distribute_in, geo_node_point_distribute_out);
node_type_update(&ntype, node_point_distribute_update);
+ node_type_init(&ntype, geo_node_point_distribute_init);
ntype.geometry_node_execute = blender::nodes::geo_node_point_distribute_exec;
ntype.draw_buttons = geo_node_point_distribute_layout;
nodeRegisterType(&ntype);
More information about the Bf-blender-cvs
mailing list