2.5: Added first particle panel, and an RNA property to retrieve

the active particle system.
This commit is contained in:
Brecht Van Lommel 2009-06-01 11:39:11 +00:00
parent 41963d9e4e
commit 0e02fef8b4
3 changed files with 41 additions and 2 deletions

@ -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)

@ -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);

@ -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");