[Bf-blender-cvs] [5045219ca97] functions: separate BParticles Output modifier
Jacques Lucke
noreply at git.blender.org
Fri Sep 6 16:56:10 CEST 2019
Commit: 5045219ca978dbadd4644dfe9c43d101e792416f
Author: Jacques Lucke
Date: Fri Sep 6 16:34:21 2019 +0200
Branches: functions
https://developer.blender.org/rB5045219ca978dbadd4644dfe9c43d101e792416f
separate BParticles Output modifier
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
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
M source/blender/modifiers/intern/MOD_bparticles.c
A source/blender/modifiers/intern/MOD_bparticles.h
A source/blender/modifiers/intern/MOD_bparticles_output.c
M source/blender/modifiers/intern/MOD_util.c
M source/blender/simulations/BParticles.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index aaa5d872f3d..374fd656e55 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1662,20 +1662,19 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
props.modifier_name = md.name
def BPARTICLES(self, layout, ob, md):
- layout.prop(md, "mode")
- if md.mode == 'SIMULATOR':
- row = layout.row(align=True)
- row.prop(md, "bparticles_tree")
- props = row.operator("bp.new_bparticles_tree", text="", icon="ADD")
- props.object_name = ob.name
- props.modifier_name = md.name
+ row = layout.row(align=True)
+ row.prop(md, "bparticles_tree")
+ props = row.operator("bp.new_bparticles_tree", text="", icon="ADD")
+ props.object_name = ob.name
+ props.modifier_name = md.name
+
+ layout.operator("object.bparticles_clear_cache", text="Clear Cache")
- layout.operator("object.bparticles_clear_cache", text="Clear Cache")
+ layout.prop(md, "output_type")
- layout.prop(md, "output_type")
- elif md.mode == 'PASSIVE':
- layout.prop(md, "source_object")
- layout.prop(md, "source_particle_type")
+ def BPARTICLES_OUTPUT(self, layout, ob, md):
+ layout.prop(md, "source_object")
+ layout.prop(md, "source_particle_type")
class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 32436af598f..84125a5ee00 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2184,6 +2184,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case eModifierType_FunctionDeform:
case eModifierType_FunctionPoints:
case eModifierType_BParticles:
+ case eModifierType_BParticlesOutput:
case NUM_MODIFIER_TYPES:
data.icon = ICON_DOT;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 36a80b51926..d843994c6d0 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -89,6 +89,7 @@ typedef enum ModifierType {
eModifierType_FunctionDeform = 55,
eModifierType_FunctionPoints = 56,
eModifierType_BParticles = 57,
+ eModifierType_BParticlesOutput = 58,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -1988,27 +1989,19 @@ typedef enum eBParticlesOutputType {
MOD_BPARTICLES_OUTPUT_NONE,
} eBParticlesOutputType;
-typedef enum eBParticlesModifierMode {
- MOD_BPARTICLES_MODE_SIMULATOR,
- MOD_BPARTICLES_MODE_PASSIVE,
-} eBParticlesModifierMode;
-
typedef struct BParticlesModifierData {
ModifierData modifier;
- unsigned int mode;
- /* Simulator Settings */
unsigned int output_type;
- struct bNodeTree *bparticles_tree;
-
unsigned int num_cached_frames;
- char _pad[4];
+ struct bNodeTree *bparticles_tree;
BParticlesFrameCache *cached_frames;
+} BParticlesModifierData;
- /* Passive Settings */
+typedef struct BParticlesOutputModifierData {
+ ModifierData modifier;
struct Object *source_object;
char source_particle_type[64];
-
-} BParticlesModifierData;
+} BParticlesOutputModifierData;
#endif /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 63b01af8b62..22246d5a8dd 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -148,6 +148,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
{eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
{eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""},
{eModifierType_BParticles, "BPARTICLES", ICON_NONE, "BParticles", ""},
+ {eModifierType_BParticlesOutput, "BPARTICLES_OUTPUT", ICON_NONE, "BParticles Output", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -582,6 +583,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_FunctionPointsModifier;
case eModifierType_BParticles:
return &RNA_BParticlesModifier;
+ case eModifierType_BParticlesOutput:
+ return &RNA_BParticlesOutputModifier;
/* Default */
case eModifierType_None:
case eModifierType_ShapeKey:
@@ -6049,32 +6052,10 @@ static void rna_def_modifier_bparticles(BlenderRNA *brna)
PropertyRNA *prop;
srna = RNA_def_struct(brna, "BParticlesModifier", "Modifier");
- RNA_def_struct_ui_text(srna, "Node Particles Modifier", "");
+ RNA_def_struct_ui_text(srna, "BParticles Modifier", "");
RNA_def_struct_sdna(srna, "BParticlesModifierData");
RNA_def_struct_ui_icon(srna, ICON_NONE);
- const static EnumPropertyItem mode_types[] = {
- {MOD_BPARTICLES_MODE_SIMULATOR,
- "SIMULATOR",
- 0,
- "Simulator",
- "Use this modifier as main simulator"},
- {MOD_BPARTICLES_MODE_PASSIVE,
- "PASSIVE",
- 0,
- "Passive",
- "This modifiers only copies particle data from another object"},
- {0, NULL, 0, NULL, NULL},
- };
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, mode_types);
- RNA_def_property_ui_text(
- prop, "Mode", "Use the modifier as active simulator or only copy data from other modifier");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- /* Simulator Mode */
-
prop = RNA_def_property(srna, "bparticles_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "BParticles Tree", "BParticles node tree");
@@ -6100,8 +6081,17 @@ static void rna_def_modifier_bparticles(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Output Type", "Method for creating the output mesh from the particle data");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
+static void rna_def_modifier_bparticles_output(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
- /* Passive Mode */
+ srna = RNA_def_struct(brna, "BParticlesOutputModifier", "Modifier");
+ RNA_def_struct_ui_text(srna, "BParticles Output Modifier", "");
+ RNA_def_struct_sdna(srna, "BParticlesOutputModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_NONE);
prop = RNA_def_property(srna, "source_object", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -6242,6 +6232,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_function_deform(brna);
rna_def_modifier_function_points(brna);
rna_def_modifier_bparticles(brna);
+ rna_def_modifier_bparticles_output(brna);
}
#endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 8d18488d234..e508e38546e 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -45,6 +45,8 @@ set(SRC
intern/MOD_array.c
intern/MOD_bevel.c
intern/MOD_boolean.c
+ intern/MOD_bparticles.c
+ intern/MOD_bparticles_output.c
intern/MOD_build.c
intern/MOD_cast.c
intern/MOD_cloth.c
@@ -74,7 +76,6 @@ set(SRC
intern/MOD_meshsequencecache.c
intern/MOD_mirror.c
intern/MOD_multires.c
- intern/MOD_bparticles.c
intern/MOD_none.c
intern/MOD_normal_edit.c
intern/MOD_ocean.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 58f70520b90..10f8d83b5bc 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -84,6 +84,7 @@ extern ModifierTypeInfo modifierType_WeightedNormal;
extern ModifierTypeInfo modifierType_FunctionDeform;
extern ModifierTypeInfo modifierType_FunctionPoints;
extern ModifierTypeInfo modifierType_BParticles;
+extern ModifierTypeInfo modifierType_BParticlesOutput;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_bparticles.c b/source/blender/modifiers/intern/MOD_bparticles.c
index 003cf4220d3..4dab2611dd7 100644
--- a/source/blender/modifiers/intern/MOD_bparticles.c
+++ b/source/blender/modifiers/intern/MOD_bparticles.c
@@ -41,19 +41,18 @@
#include "BLI_math.h"
+#include "MOD_bparticles.h"
#include "MOD_util.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
-#include "BParticles.h"
-
typedef struct RuntimeData {
BParticlesSimulationState simulation_state;
float last_simulated_frame;
} RuntimeData;
-static RuntimeData *get_runtime_struct(BParticlesModifierData *bpmd)
+static RuntimeData *get_or_create_runtime_struct(BParticlesModifierData *bpmd)
{
if (bpmd->modifier.runtime == NULL) {
RuntimeData *runtime = MEM_callocN(sizeof(RuntimeData), __func__);
@@ -65,6 +64,11 @@ static RuntimeData *get_runtime_struct(BParticlesModifierData *bpmd)
return bpmd->modifier.runtime;
}
+static RuntimeData *get_runtime_struct(BParticlesModifierData *bpmd)
+{
+ return bpmd->modifier.runtime;
+}
+
static void free_runtime_data(RuntimeData *runtime)
{
BParticles_simulation_free(runtime->simulation_state);
@@ -80,17 +84,33 @@ static void free_modifier_runtime_data(BParticlesModifierData *bpmd)
}
}
-static Mesh *apply_modifier__simulator(BParticlesModifierData *bpmd,
- const struct ModifierEvalContext *ctx,
- Mesh *UNUSED(mesh))
+BParticlesSimulationState MOD_bparticles_find_simulation_state(Object *object)
{
+ BLI_assert(object != NULL);
+ BParticlesModifierData *bpmd = (BParticlesModifierData *)modifiers_findByType(
+ object, eModifierType_BParticles);
+ if (bpmd == NULL) {
+ return NULL;
+ }
+ RuntimeData *runtime = get_runtime_struct(bpmd);
+ if (runtime == NULL) {
+ return NULL;
+ }
+ return runtime->simulation_state;
+}
+
+static Mesh *applyModifier(ModifierData *md,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list