[Bf-blender-cvs] [0ba4bf7ec54] simulation-access-modifier: initial simulation access modifier
Jacques Lucke
noreply at git.blender.org
Wed Apr 22 16:28:54 CEST 2020
Commit: 0ba4bf7ec5439c125333d9d063620cf9170dfd36
Author: Jacques Lucke
Date: Wed Apr 22 15:52:15 2020 +0200
Branches: simulation-access-modifier
https://developer.blender.org/rB0ba4bf7ec5439c125333d9d063620cf9170dfd36
initial simulation access modifier
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/CMakeLists.txt
M source/blender/modifiers/MOD_modifiertypes.h
A source/blender/modifiers/intern/MOD_simulation_access.cc
M source/blender/modifiers/intern/MOD_util.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 03debee4384..df6281646b4 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1341,7 +1341,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
if md.mode == 'VOXEL':
layout.prop(md, "voxel_size")
layout.prop(md, "adaptivity")
- else:
+ else:
row.prop(md, "octree_depth")
row.prop(md, "scale")
@@ -1812,6 +1812,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "thresh", text="Threshold")
col.prop(md, "face_influence")
+ def SIMULATION_ACCESS(self, layout, ob, md):
+ layout.prop(md, "simulation")
+ layout.prop(md, "data_path")
+
class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
bl_label = "Modifiers"
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 0c0cc8ebc97..eb7006056e1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1710,6 +1710,11 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
add_id_node(&simulation->id);
build_animdata(&simulation->id);
build_parameters(&simulation->id);
+
+ add_operation_node(&simulation->id,
+ NodeType::GENERIC_DATABLOCK,
+ OperationCode::GENERIC_DATABLOCK_UPDATE,
+ [](struct ::Depsgraph *UNUSED(depsgraph)) { printf("Hello World\n"); });
}
void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index d5a3d5ee121..00fdc2b71b4 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2519,6 +2519,11 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
}
build_animdata(&simulation->id);
build_parameters(&simulation->id);
+
+ OperationKey simulation_update_key(
+ &simulation->id, NodeType::GENERIC_DATABLOCK, OperationCode::GENERIC_DATABLOCK_UPDATE);
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, simulation_update_key, "TimeSrc -> Simulation");
}
void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 6eba41982a7..d8d9e1189c6 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2191,6 +2191,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case eModifierType_WeightedNormal:
data.icon = ICON_MOD_NORMALEDIT;
break;
+ case eModifierType_SimulationAccess:
+ data.icon = ICON_PHYSICS; /* TODO: Use correct icon. */
+ break;
/* Default */
case eModifierType_None:
case eModifierType_ShapeKey:
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 9e58d7df042..9cb01632003 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -94,6 +94,7 @@ typedef enum ModifierType {
eModifierType_WeightedNormal = 54,
eModifierType_Weld = 55,
eModifierType_Fluid = 56,
+ eModifierType_SimulationAccess = 57,
NUM_MODIFIER_TYPES,
} ModifierType;
@@ -2117,6 +2118,13 @@ enum {
#define MOD_MESHSEQ_READ_ALL \
(MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)
+typedef struct SimulationAccessModifierData {
+ ModifierData modifier;
+
+ struct Simulation *simulation;
+ char data_path[64];
+} SimulationAccessModifierData;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index ccc141c1bb2..e831599f4c2 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -289,6 +289,11 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
"Spawn particles from the shape"},
{eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
{eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""},
+ {eModifierType_SimulationAccess,
+ "SIMULATION_ACCESS",
+ ICON_PHYSICS,
+ "Simulation Access",
+ ""}, /* TODO: Use correct icon. */
{0, NULL, 0, NULL, NULL},
};
@@ -716,6 +721,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_SurfaceDeformModifier;
case eModifierType_WeightedNormal:
return &RNA_WeightedNormalModifier;
+ case eModifierType_SimulationAccess:
+ return &RNA_SimulationAccessModifier;
/* Default */
case eModifierType_Fluidsim: /* deprecated */
case eModifierType_None:
@@ -6546,6 +6553,27 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
+static void rna_def_modifier_simulation_access(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "SimulationAccessModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "Simulation Access Modifier", "");
+ RNA_def_struct_sdna(srna, "SimulationAccessModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
+
+ prop = RNA_def_property(srna, "simulation", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Simulation", "Simulation to access");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
+
+ prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(
+ prop, "Data Path", "Identifier of the simulation component that should be accessed");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@@ -6671,6 +6699,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_meshseqcache(brna);
rna_def_modifier_surfacedeform(brna);
rna_def_modifier_weightednormal(brna);
+ rna_def_modifier_simulation_access(brna);
}
#endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 48acbdc17f3..c31f5b3ff46 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -78,6 +78,7 @@ set(SRC
intern/MOD_shapekey.c
intern/MOD_shrinkwrap.c
intern/MOD_simpledeform.c
+ intern/MOD_simulation_access.cc
intern/MOD_skin.c
intern/MOD_smooth.c
intern/MOD_softbody.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 5dc4adf4393..5e596841787 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -86,6 +86,7 @@ extern ModifierTypeInfo modifierType_CorrectiveSmooth;
extern ModifierTypeInfo modifierType_MeshSequenceCache;
extern ModifierTypeInfo modifierType_SurfaceDeform;
extern ModifierTypeInfo modifierType_WeightedNormal;
+extern ModifierTypeInfo modifierType_SimulationAccess;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_simulation_access.cc b/source/blender/modifiers/intern/MOD_simulation_access.cc
new file mode 100644
index 00000000000..5acb1e0e480
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_simulation_access.cc
@@ -0,0 +1,110 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 by the Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_pointcloud_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_simulation_types.h"
+
+#include "BKE_customdata.h"
+#include "BKE_lib_query.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "MOD_modifiertypes.h"
+
+static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+{
+ SimulationAccessModifierData *samd = (SimulationAccessModifierData *)md;
+ if (samd->simulation) {
+ DEG_add_generic_id_relation(ctx->node, &samd->simulation->id, "Accessed Simulation");
+ }
+}
+
+static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
+{
+ SimulationAccessModifierData *samd = (SimulationAccessModifierData *)md;
+ if (samd->simulation) {
+ walk(userData, ob, (ID **)&samd->simulation, IDWALK_CB_USER);
+ }
+}
+
+static bool isDisabled(const struct Scene *UNUSED(scene),
+ ModifierData *md,
+ bool UNUSED(useRenderParams))
+{
+ SimulationAccessModifierData *samd = (SimulationAccessModifierData *)md;
+ return samd->simulation
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list