[Bf-blender-cvs] [eedfae8] temp_hair_modifiers: RNA for the modifiers list in ParticleSystem and basic UI code.

Lukas Tönne noreply at git.blender.org
Tue Feb 3 17:25:23 CET 2015


Commit: eedfae856838a418da410503e6bb471c014abfad
Author: Lukas Tönne
Date:   Tue Feb 3 15:41:30 2015 +0100
Branches: temp_hair_modifiers
https://developer.blender.org/rBeedfae856838a418da410503e6bb471c014abfad

RNA for the modifiers list in ParticleSystem and basic UI code.

===================================================================

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/editors/include/ED_particle.h
M	source/blender/editors/physics/particle_modifier.c
M	source/blender/makesrna/intern/rna_particle.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index dfa6999..9a62ffb 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1532,6 +1532,60 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
         # row.prop(psys, "invert_vertex_group_field", text="")
 
 
+class PARTICLE_PT_modifiers(ParticleButtonsPanel, Panel):
+    bl_label = "Modifiers"
+    bl_options = {'HIDE_HEADER'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        ob = context.object
+        psys = context.particle_system
+
+        layout.operator_menu_enum("particle.modifier_add", "type")
+
+        for md in psys.modifiers:
+            #box = layout.template_modifier(md)
+            box = layout.box()
+            if box:
+                # match enum type to our functions, avoids a lookup table.
+                getattr(self, md.type)(box, ob, psys, md)
+
+    # the mt.type enum is (ab)used for a lookup on function names
+    # ...to avoid lengthy if statements
+    # so each type must have a function here.
+
+    def MESH_DEFORM(self, layout, ob, psys, md):
+        split = layout.split()
+
+'''
+        col = split.column()
+        col.active = not md.is_bound
+        col.label(text="Object:")
+        col.prop(md, "object", text="")
+
+        col = split.column()
+        col.label(text="Vertex Group:")
+
+        row = col.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        sub = row.row(align=True)
+        sub.active = bool(md.vertex_group)
+        sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
+
+        layout.separator()
+
+        if md.is_bound:
+            layout.operator("object.meshdeform_bind", text="Unbind")
+        else:
+            layout.operator("object.meshdeform_bind", text="Bind")
+
+            row = layout.row()
+            row.prop(md, "precision")
+            row.prop(md, "use_dynamic_bind")
+'''
+
+
 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER'}
     _context_path = "particle_system.settings"
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 85fe5c0..9ec917f 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -32,6 +32,10 @@
 #ifndef __ED_PARTICLE_H__
 #define __ED_PARTICLE_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct bContext;
 struct Object;
 struct ParticleEditSettings;
@@ -85,5 +89,9 @@ int PE_undo_valid(struct Scene *scene);
 void PE_undo_number(struct Scene *scene, int nr);
 const char *PE_undo_get_name(struct Scene *scene, int nr, int *active);
 
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
 #endif /* __ED_PARTICLE_H__ */
 
diff --git a/source/blender/editors/physics/particle_modifier.c b/source/blender/editors/physics/particle_modifier.c
index cf2d064..f79869e 100644
--- a/source/blender/editors/physics/particle_modifier.c
+++ b/source/blender/editors/physics/particle_modifier.c
@@ -241,7 +241,7 @@ void PARTICLE_OT_modifier_add(wmOperatorType *ot)
 	/* identifiers */
 	ot->name = "Add Modifier";
 	ot->description = "Add a modifier to the active object";
-	ot->idname = "OBJECT_OT_modifier_add";
+	ot->idname = "PARTICLE_OT_modifier_add";
 	
 	/* api callbacks */
 	ot->invoke = WM_menu_invoke;
@@ -343,7 +343,7 @@ void PARTICLE_OT_modifier_remove(wmOperatorType *ot)
 {
 	ot->name = "Remove Particle Modifier";
 	ot->description = "Remove a particle modifier from the active object";
-	ot->idname = "OBJECT_OT_particle_modifier_remove";
+	ot->idname = "PARTICLE_OT_modifier_remove";
 
 	ot->invoke = particle_modifier_remove_invoke;
 	ot->exec = particle_modifier_remove_exec;
@@ -383,7 +383,7 @@ void PARTICLE_OT_modifier_move_up(wmOperatorType *ot)
 {
 	ot->name = "Move Up Particle Modifier";
 	ot->description = "Move particle modifier up in the stack";
-	ot->idname = "OBJECT_OT_particle_modifier_move_up";
+	ot->idname = "PARTICLE_OT_modifier_move_up";
 
 	ot->invoke = particle_modifier_move_up_invoke;
 	ot->exec = particle_modifier_move_up_exec;
@@ -423,7 +423,7 @@ void PARTICLE_OT_modifier_move_down(wmOperatorType *ot)
 {
 	ot->name = "Move Down Particle Modifier";
 	ot->description = "Move particle modifier down in the stack";
-	ot->idname = "OBJECT_OT_particle_modifier_move_down";
+	ot->idname = "PARTICLE_OT_modifier_move_down";
 
 	ot->invoke = particle_modifier_move_down_invoke;
 	ot->exec = particle_modifier_move_down_exec;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 005f3d9..5176772 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -43,11 +43,12 @@
 #include "DNA_boid_types.h"
 #include "DNA_texture_types.h"
 
+#include "BLF_translation.h"
+
+#include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
-#include "BLF_translation.h"
-
 #include "rna_internal.h"
 
 #include "WM_types.h"
@@ -157,8 +158,6 @@ static EnumPropertyItem part_hair_ren_as_items[] = {
 #include "BKE_pointcache.h"
 #include "BKE_texture.h"
 
-#include "RNA_access.h"
-
 #include "ED_particle.h"
 
 static StructRNA *rna_ParticleModifier_refine(struct PointerRNA *ptr)
@@ -238,6 +237,35 @@ static void rna_ParticleModifier_dependency_update(Main *bmain, Scene *scene, Po
 	DAG_relations_tag_update(bmain);
 }
 
+static ParticleModifierData *rna_ParticleSystem_modifier_new(ID *id, ParticleSystem *psys, bContext *C, ReportList *reports,
+                                                             const char *name, int type)
+{
+	Object *object = (Object *)id;
+	return ED_particle_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, psys, name, type);
+}
+
+static void rna_ParticleSystem_modifier_remove(ID *id, ParticleSystem *psys, bContext *C, ReportList *reports, PointerRNA *md_ptr)
+{
+	Object *object = (Object *)id;
+	ParticleModifierData *md = md_ptr->data;
+	if (ED_particle_modifier_remove(reports, CTX_data_main(C), object, psys, md) == false) {
+		/* error is already set */
+		return;
+	}
+
+	RNA_POINTER_INVALIDATE(md_ptr);
+
+	WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_REMOVED, object);
+}
+
+static void rna_ParticleSystem_modifier_clear(ID *id, ParticleSystem *psys, bContext *C)
+{
+	Object *object = (Object *)id;
+	ED_particle_modifier_clear(CTX_data_main(C), object, psys);
+
+	WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_REMOVED, object);
+}
+
 /* use for object space hair get/set */
 static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSystemModifierData **psmd_pt,
                                                      ParticleData **pa_pt)
@@ -3427,6 +3455,47 @@ static void rna_def_particle_modifier(BlenderRNA *brna)
 	rna_def_particle_modifier_meshdeform(brna);
 }
 
+/* object.modifiers */
+static void rna_def_particle_system_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+	StructRNA *srna;
+
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	RNA_def_property_srna(cprop, "ParticleSystemModifiers");
+	srna = RNA_def_struct(brna, "ParticleSystemModifiers", NULL);
+	RNA_def_struct_sdna(srna, "ParticleSystem");
+	RNA_def_struct_ui_text(srna, "Particle System Modifiers", "Collection of particle system modifiers");
+
+	/* add modifier */
+	func = RNA_def_function(srna, "new", "rna_ParticleSystem_modifier_new");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
+	RNA_def_function_ui_description(func, "Add a new modifier to the particle system");
+	parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	/* modifier to add */
+	parm = RNA_def_enum(func, "type", particle_modifier_type_items, 1, "", "Modifier type to add");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	/* return type */
+	parm = RNA_def_pointer(func, "modifier", "ParticleModifier", "", "Newly created modifier");
+	RNA_def_function_return(func, parm);
+
+	/* remove modifier */
+	func = RNA_def_function(srna, "remove", "rna_ParticleSystem_modifier_remove");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
+	RNA_def_function_ui_description(func, "Remove an existing modifier from the particle system");
+	/* modifier to remove */
+	parm = RNA_def_pointer(func, "modifier", "ParticleModifier", "", "Modifier to remove");
+	RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+	RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+
+	/* clear all modifiers */
+	func = RNA_def_function(srna, "clear", "rna_ParticleSystem_modifier_clear");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_SELF_ID);
+	RNA_def_function_ui_description(func, "Remove all modifiers from the particle system");
+}
+
 static void rna_def_particle_system(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -3514,6 +3583,12 @@ static void rna_def_particle_system(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
 	RNA_def_property_update(prop, 0, "rna_Particle_active_shape_update");
 
+	/* modifiers */
+	prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_struct_type(prop, "ParticleModifier");
+	RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the particle data");
+	rna_def_particle_system_modifiers(brna, prop);
+
 	prop = RNA_def_property(srna, "cloth", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "clmd");
 	RNA_def_property_struct_type(prop, "ClothModifier");
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 9f0042f..f99e28a 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -82,6 +82,7 @@ struct HookModifierData;
 struct NodeBlurData;
 struct Nurb;
 struct Object;
+struct ParticleModifierData;
 struct ParticleSystem;
 struct PBVHNode;
 struct PyOb

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list