[Bf-blender-cvs] [c4aeabe07d4] temp-modifiers-instancing: create temporary instances component in nodes modifier
Jacques Lucke
noreply at git.blender.org
Tue Nov 10 16:39:12 CET 2020
Commit: c4aeabe07d4a29bc3b3a6256ecba6e05ae693773
Author: Jacques Lucke
Date: Tue Nov 10 13:01:12 2020 +0100
Branches: temp-modifiers-instancing
https://developer.blender.org/rBc4aeabe07d4a29bc3b3a6256ecba6e05ae693773
create temporary instances component in nodes modifier
===================================================================
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_nodes.cc
===================================================================
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index d7ad1d59002..7386665381c 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2229,6 +2229,7 @@ typedef struct NodesModifierData {
ModifierData modifier;
struct bNodeTree *node_group;
struct NodesModifierSettings settings;
+ struct Object *instance_object_temp;
} NodesModifierData;
typedef struct MeshToVolumeModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 349b6327ecb..66cf1ea4782 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -6965,6 +6965,11 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Settings", "Settings that are passed into the node group");
+ prop = RNA_def_property(srna, "instance_object_temp", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Instance Object Temp", "Object to instance");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
+
RNA_define_lib_overridable(false);
rna_def_modifier_nodes_settings(brna);
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 5f9873f7545..a2dbcc1ce8b 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -89,6 +89,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (nmd->node_group != nullptr) {
DEG_add_node_tree_relation(ctx->node, nmd->node_group, "Nodes Modifier");
}
+ if (nmd->instance_object_temp) {
+ DEG_add_object_relation(
+ ctx->node, nmd->instance_object_temp, DEG_OB_COMP_ANY, "nodes modifier");
+ }
/* TODO: Add relations for IDs in settings. */
}
@@ -97,6 +101,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
walk(userData, ob, (ID **)&nmd->node_group, IDWALK_CB_USER);
+ walk(userData, ob, (ID **)&nmd->instance_object_temp, IDWALK_CB_USER);
struct ForeachSettingData {
IDWalkFunc walk;
@@ -784,8 +789,21 @@ static GeometrySetC *modifyPointCloud(ModifierData *md,
const ModifierEvalContext *ctx,
GeometrySetC *geometry_set_c)
{
+ NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
+
GeometrySetPtr input_geometry_set = unwrap(geometry_set_c);
GeometrySetPtr output_geometry_set = modifyGeometry(md, ctx, std::move(input_geometry_set));
+
+ make_geometry_set_mutable(output_geometry_set);
+ InstancesComponent &component =
+ output_geometry_set->get_component_for_write<InstancesComponent>();
+ Vector<float3> positions;
+ positions.append({1, 2, 3});
+ positions.append({-1, 2, 3});
+ positions.append({-1, -2, 3});
+ positions.append({-1, -2, -3});
+ component.replace(positions, nmd->instance_object_temp);
+
return wrap(output_geometry_set.release());
}
@@ -827,6 +845,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropDecorate(layout, false);
uiItemR(layout, ptr, "node_group", 0, nullptr, ICON_MESH_DATA);
+ uiItemR(layout, ptr, "instance_object_temp", 0, nullptr, ICON_NONE);
if (nmd->node_group != nullptr && nmd->settings.properties != nullptr) {
PointerRNA settings_ptr;
More information about the Bf-blender-cvs
mailing list