[Bf-blender-cvs] [b4a8488] temp_hair_modifiers: Basic UI elements and RNA option properties for particle modifiers.
Lukas Tönne
noreply at git.blender.org
Mon Feb 9 14:25:40 CET 2015
Commit: b4a8488c6f98f7605026800fe5884f7c6c28c165
Author: Lukas Tönne
Date: Tue Feb 3 17:24:47 2015 +0100
Branches: temp_hair_modifiers
https://developer.blender.org/rBb4a8488c6f98f7605026800fe5884f7c6c28c165
Basic UI elements and RNA option properties for particle modifiers.
===================================================================
M release/scripts/startup/bl_ui/properties_particle.py
M source/blender/blenkernel/BKE_particle.h
M source/blender/blenkernel/intern/particle_modifier.c
M source/blender/makesdna/DNA_particle_types.h
M source/blender/makesrna/intern/rna_particle.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 470c29e..cd6c8d7 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1539,6 +1539,25 @@ class PARTICLE_PT_modifiers(ParticleButtonsPanel, Panel):
bl_label = "Modifiers"
bl_options = {'HIDE_HEADER'}
+ def make_modifier_layout(self, context, layout, md):
+ box = layout.box()
+ box.context_pointer_set("particle_modifier", md)
+
+ row = box.row()
+ row.prop(md, "show_expanded", icon_only=True, emboss=False)
+
+ row.label(icon_value=row.icon(md))
+ row.alert = md.is_disabled
+ row.label(md.name)
+ row.alert = False
+
+ sub = row.row(align=True)
+ sub.prop(md, "show_viewport", icon_only=True)
+ sub.prop(md, "show_render", icon_only=True)
+ sub.prop(md, "show_in_editmode", icon_only=True)
+
+ return box
+
def draw(self, context):
layout = self.layout
@@ -1548,8 +1567,7 @@ class PARTICLE_PT_modifiers(ParticleButtonsPanel, Panel):
layout.operator_menu_enum("particle.modifier_add", "type")
for md in psys.modifiers:
- #box = layout.template_modifier(md)
- box = layout.box()
+ box = self.make_modifier_layout(context, layout, md)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, md.type)(box, ob, psys, md)
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index ccdcb47..946c172 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -309,6 +309,16 @@ typedef struct ParticleModifierTypeInfo {
*/
void (*freeData)(struct ParticleModifierData *md);
+ /* Return a boolean value indicating if this modifier is able to be
+ * calculated based on the modifier data. This is *not* regarding the
+ * md->flag, that is tested by the system, this is just if the data
+ * validates (for example, a lattice will return false if the lattice
+ * object is not defined).
+ *
+ * This function is optional (assumes never disabled if not present).
+ */
+ bool (*isDisabled)(struct ParticleModifierData *md, bool userRenderParams);
+
/* Should call the given walk function with a pointer to each ID
* pointer (i.e. each datablock pointer) that the modifier data
* stores. This is used for linking on file load and for
@@ -360,6 +370,7 @@ struct ParticleModifierData *particle_modifier_new(int type);
void particle_modifier_free(struct ParticleModifierData *md);
void particle_modifier_unique_name(struct ListBase *modifiers, struct ParticleModifierData *md);
struct ParticleModifierData *particle_modifier_findByName(struct Object *ob, struct ParticleSystem *psys, const char *name);
+bool particle_modifier_isEnabled(struct ParticleModifierData *md, int required_mode);
int count_particles(struct ParticleSystem *psys);
int count_particles_mod(struct ParticleSystem *psys, int totgr, int cur);
diff --git a/source/blender/blenkernel/intern/particle_modifier.c b/source/blender/blenkernel/intern/particle_modifier.c
index 3ee43bc..760796d 100644
--- a/source/blender/blenkernel/intern/particle_modifier.c
+++ b/source/blender/blenkernel/intern/particle_modifier.c
@@ -126,3 +126,13 @@ ParticleModifierData *particle_modifier_findByName(Object *UNUSED(ob), ParticleS
{
return BLI_findstring(&(psys->modifiers), name, offsetof(ParticleModifierData, name));
}
+
+bool particle_modifier_isEnabled(ParticleModifierData *md, int required_mode)
+{
+ ParticleModifierTypeInfo *mti = particle_modifier_type_info_get(md->type);
+
+ if ((md->mode & required_mode) != required_mode) return false;
+ if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return false;
+
+ return true;
+}
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 228b6ac..8d9d397 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -164,11 +164,17 @@ typedef enum ParticleModifierType {
NUM_PARTICLE_MODIFIER_TYPES
} ParticleModifierType;
+typedef enum ParticleModifierMode {
+ eParticleModifierMode_Realtime = (1 << 0),
+ eParticleModifierMode_Render = (1 << 1),
+ eParticleModifierMode_Editmode = (1 << 2),
+ eParticleModifierMode_Expanded = (1 << 3),
+} ParticleModifierMode;
+
typedef struct ParticleModifierData {
struct ParticleModifierData *next, *prev;
- int type;
- int flag;
+ int type, mode;
char name[64]; /* MAX_NAME */
char *error;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 2202dc0..d8c196f 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -266,6 +266,12 @@ static void rna_ParticleSystem_modifier_clear(ID *id, ParticleSystem *psys, bCon
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_REMOVED, object);
}
+static int rna_ParticleModifier_is_disabled_get(PointerRNA *ptr)
+{
+ ParticleModifierData *md = ptr->data;
+ return particle_modifier_isEnabled(md, 0);
+}
+
/* use for object space hair get/set */
static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSystemModifierData **psmd_pt,
ParticleData **pa_pt)
@@ -3465,6 +3471,36 @@ static void rna_def_particle_modifier(BlenderRNA *brna)
RNA_def_property_enum_items(prop, particle_modifier_type_items);
RNA_def_property_ui_text(prop, "Type", "");
+ /* flags */
+ prop = RNA_def_property(srna, "show_viewport", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", eParticleModifierMode_Realtime);
+ RNA_def_property_ui_text(prop, "Realtime", "Display modifier in viewport");
+ RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
+ RNA_def_property_update(prop, 0, "rna_ParticleModifier_update");
+ RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 0);
+
+ prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", eParticleModifierMode_Render);
+ RNA_def_property_ui_text(prop, "Render", "Use modifier during render");
+ RNA_def_property_ui_icon(prop, ICON_SCENE, 0);
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
+
+ prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", eParticleModifierMode_Editmode);
+ RNA_def_property_ui_text(prop, "Edit Mode", "Display modifier in Edit mode");
+ RNA_def_property_update(prop, 0, "rna_ParticleModifier_update");
+ RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
+
+ prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "mode", eParticleModifierMode_Expanded);
+ RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
+ RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
+
+ prop = RNA_def_property(srna, "is_disabled", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleModifier_is_disabled_get", NULL);
+ RNA_def_property_ui_text(prop, "Disabled", "Modifier is disabled due to internal state");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
/* types */
rna_def_particle_modifier_meshdeform(brna);
}
More information about the Bf-blender-cvs
mailing list