Page MenuHome
Paste P1906

Masterwork From Distant Lands
ActivePublic

Authored by Dalai Felinto (dfelinto) on Jan 22 2021, 3:55 PM.
commit e341923430e3fe23e171a76df66cde50e8846364
Author: Dalai Felinto <dalai@blender.org>
Date: Fri Jan 22 12:48:08 2021 +0100
Mockup of UI
[ ] Use the same data for socket and socketless
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 130ea430ecd..cc99434aa80 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3207,9 +3207,22 @@ static void node_geometry_buts_point_instance(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
+ const bool use_whole_collection = RNA_boolean_get(ptr, "use_whole_collection");
+ const bool use_collection_count = !use_whole_collection &&
+ RNA_boolean_get(ptr, "use_collection_count");
+
uiItemR(layout, ptr, "instance_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
if (RNA_enum_get(ptr, "instance_type") == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION) {
uiItemR(layout, ptr, "use_whole_collection", DEFAULT_FLAGS, NULL, ICON_NONE);
+
+ uiLayout *col = uiLayoutColumn(layout, false);
+ uiLayoutSetActive(col, !use_whole_collection);
+
+ uiItemR(col, ptr, "use_collection_count", DEFAULT_FLAGS, NULL, ICON_NONE);
+ if (use_collection_count) {
+ uiItemR(col, ptr, "instance_collection", DEFAULT_FLAGS, NULL, ICON_NONE);
+ }
}
}
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 4dba856b87b..7d9ff4f48c6 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1175,6 +1175,7 @@ typedef struct NodeGeometryObjectInfo {
} NodeGeometryObjectInfo;
typedef struct NodeGeometryPointInstance {
+ struct Collection *collection;
/* GeometryNodePointInstanceType. */
uint8_t instance_type;
/* GeometryNodePointInstanceFlag. */
@@ -1597,6 +1598,7 @@ typedef enum GeometryNodePointInstanceType {
typedef enum GeometryNodePointInstanceFlag {
GEO_NODE_POINT_INSTANCE_WHOLE_COLLECTION = (1 << 0),
+ GEO_NODE_POINT_INSTANCE_COLLECTION_COUNT = (1 << 1),
} GeometryNodePointInstanceFlag;
typedef enum GeometryNodeAttributeInputMode {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 355b1360ab0..92abe706626 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4155,6 +4155,12 @@ void rna_ShaderNodePointDensity_density_minmax(bNode *self,
RE_point_density_minmax(depsgraph, pd, r_min, r_max);
}
+static void rna_NodeGeometryPointInstance_count(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ /* TODO: copy rna_Particle_redo_count. */
+ rna_Node_socket_update(bmain, scene, ptr);
+}
+
#else
static const EnumPropertyItem prop_image_layer_items[] = {
@@ -8657,10 +8663,43 @@ static void def_geo_point_instance(StructRNA *srna)
RNA_def_property_ui_text(prop, "Instance Type", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
+ prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "collection");
+ RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
+ RNA_def_property_ui_text(
+ prop, "Collection", "Show Objects in this collection in place of particles");
+ RNA_def_property_update(prop, 0, "rna_NodeGeometryPointInstance_count");
+
+# if 0
+ prop = RNA_def_property(srna, "instance_weights", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "instance_weights", NULL);
+ RNA_def_property_struct_type(prop, "ParticleDupliWeight");
+ RNA_def_property_ui_text(
+ prop, "Dupli Collection Weights", "Weights for all of the objects in the dupli collection");
+
+ prop = RNA_def_property(srna, "active_instanceweight", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ParticleDupliWeight");
+ RNA_def_property_pointer_funcs(prop, "rna_ParticleDupliWeight_active_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Active Dupli Object", "");
+
+ prop = RNA_def_property(srna, "active_instanceweight_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_funcs(prop,
+ "rna_ParticleDupliWeight_active_index_get",
+ "rna_ParticleDupliWeight_active_index_set",
+ "rna_ParticleDupliWeight_active_index_range");
+ RNA_def_property_ui_text(prop, "Active Dupli Object Index", "");
+# endif
+
prop = RNA_def_property(srna, "use_whole_collection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GEO_NODE_POINT_INSTANCE_WHOLE_COLLECTION);
RNA_def_property_ui_text(prop, "Whole Collection", "Instance entire collection on each point");
RNA_def_property_update(prop, 0, "rna_Node_socket_update");
+
+ prop = RNA_def_property(srna, "use_collection_count", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GEO_NODE_POINT_INSTANCE_COLLECTION_COUNT);
+ RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same collection");
+ RNA_def_property_update(prop, 0, "rna_NodeGeometryPointInstance_count");
}
static void def_geo_attribute_mix(StructRNA *srna)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
index 54d37661d35..273943d6940 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
@@ -27,10 +27,10 @@
#include "node_geometry_util.hh"
static bNodeSocketTemplate geo_node_point_instance_in[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
{SOCK_OBJECT, N_("Object")},
{SOCK_COLLECTION, N_("Collection")},
{SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000},
+ {SOCK_GEOMETRY, N_("Geometry")},
{-1, ""},
};
@@ -43,7 +43,7 @@ namespace blender::nodes {
static void geo_node_point_instance_update(bNodeTree *UNUSED(tree), bNode *node)
{
- bNodeSocket *object_socket = (bNodeSocket *)BLI_findlink(&node->inputs, 1);
+ bNodeSocket *object_socket = (bNodeSocket *)BLI_findlink(&node->inputs, 0);
bNodeSocket *collection_socket = object_socket->next;
bNodeSocket *seed_socket = collection_socket->next;
@@ -51,9 +51,14 @@ static void geo_node_point_instance_update(bNodeTree *UNUSED(tree), bNode *node)
GeometryNodePointInstanceType type = (GeometryNodePointInstanceType)node_storage->instance_type;
const bool use_whole_collection = (node_storage->flag &
GEO_NODE_POINT_INSTANCE_WHOLE_COLLECTION) != 0;
+ const bool use_collection_count = !use_whole_collection &&
+ (node_storage->flag &
+ GEO_NODE_POINT_INSTANCE_COLLECTION_COUNT) != 0;
+ const bool collection_socket_availibility = type == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION &&
+ !use_collection_count;
nodeSetSocketAvailability(object_socket, type == GEO_NODE_POINT_INSTANCE_TYPE_OBJECT);
- nodeSetSocketAvailability(collection_socket, type == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION);
+ nodeSetSocketAvailability(collection_socket, collection_socket_availibility);
nodeSetSocketAvailability(
seed_socket, type == GEO_NODE_POINT_INSTANCE_TYPE_COLLECTION && !use_whole_collection);
}
@@ -83,15 +88,26 @@ static void get_instanced_data__collection(
const bNode &node = params.node();
NodeGeometryPointInstance *node_storage = (NodeGeometryPointInstance *)node.storage;
- bke::PersistentCollectionHandle collection_handle =
- params.get_input<bke::PersistentCollectionHandle>("Collection");
- Collection *collection = params.handle_map().lookup(collection_handle);
+ const bool use_whole_collection = (node_storage->flag &
+ GEO_NODE_POINT_INSTANCE_WHOLE_COLLECTION) != 0;
+ const bool use_collection_count = !use_whole_collection &&
+ (node_storage->flag &
+ GEO_NODE_POINT_INSTANCE_COLLECTION_COUNT) != 0;
+
+ Collection *collection;
+ if (!use_collection_count) {
+ bke::PersistentCollectionHandle collection_handle =
+ params.get_input<bke::PersistentCollectionHandle>("Collection");
+ collection = params.handle_map().lookup(collection_handle);
+ }
+ else {
+ collection = node_storage->collection;
+ }
+
if (collection == nullptr) {
return;
}
- const bool use_whole_collection = (node_storage->flag &
- GEO_NODE_POINT_INSTANCE_WHOLE_COLLECTION) != 0;
if (use_whole_collection) {
InstancedData instance;
instance.type = INSTANCE_DATA_TYPE_COLLECTION;