2.5: Added first particle panel, and an RNA property to retrieve
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 1 Jun 2009 11:39:11 +0000 (11:39 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 1 Jun 2009 11:39:11 +0000 (11:39 +0000)
the active particle system.

release/ui/buttons_particle.py [new file with mode: 0644]
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_particle.c

diff --git a/release/ui/buttons_particle.py b/release/ui/buttons_particle.py
new file mode 100644 (file)
index 0000000..52e20b0
--- /dev/null
@@ -0,0 +1,26 @@
+
+import bpy
+
+class ParticleButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "particle"
+
+       def poll(self, context):
+               ob = context.active_object
+               return (ob and ob.active_particle_system)
+
+class PARTICLE_PT_particles(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_particles"
+       __label__ = "Particles"
+
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.active_object.active_particle_system
+               part = psys.settings
+
+               layout.itemR(part, "amount")
+
+bpy.types.register(PARTICLE_PT_particles)
+
index 86df2935f799667aa97d7028b7d39f459dcc7f4e..6baf5083d312295e7aa1be55cbf938b52a291b89 100644 (file)
@@ -42,6 +42,7 @@
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_material.h"
+#include "BKE_particle.h"
 
 static void rna_Object_update(bContext *C, PointerRNA *ptr)
 {
@@ -202,6 +203,13 @@ static void rna_Object_active_material_link_set(PointerRNA *ptr, int value)
                ob->colbits &= ~(1<<(ob->actcol));
 }
 
+static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
+{
+       Object *ob= (Object*)ptr->id.data;
+       ParticleSystem *psys= psys_get_current(ob);
+       return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
+}
+
 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
 {
        return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
@@ -720,6 +728,11 @@ static StructRNA *rna_def_object(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "ParticleSystem");
        RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object.");
 
+       prop= RNA_def_property(srna, "active_particle_system", PROP_POINTER, PROP_NONE);
+       RNA_def_property_struct_type(prop, "ParticleSystem");
+       RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL);
+       RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
+
        /* restrict */
 
        prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE);
index 95c5c90b304d558893485c127e9bbe1b3b146a3b..36a1992670ad18c27efacc0f7f960e6c9054749e 100644 (file)
@@ -838,10 +838,10 @@ static void rna_def_particle_settings(BlenderRNA *brna)
 
        //float rt; TODO:find where rt is used - can't find it in UI
 
-       prop= RNA_def_property(srna, "total_particles", PROP_INT, PROP_UNSIGNED);
+       prop= RNA_def_property(srna, "amount", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "totpart");
        RNA_def_property_range(prop, 0, 100000);
-       RNA_def_property_ui_text(prop, "Particle Amount", "The total number of particles.");
+       RNA_def_property_ui_text(prop, "Amount", "Total number of particles.");
 
        prop= RNA_def_property(srna, "userjit", PROP_INT, PROP_UNSIGNED);//TODO: can we get a better name for userjit?
        RNA_def_property_int_sdna(prop, NULL, "userjit");