diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_particle.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 131 |
1 files changed, 118 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 453b5f9f91a..2c81bda121f 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -105,6 +105,7 @@ EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_pointcache.h" #include "BLI_arithb.h" +#include "BLI_listbase.h" /* property update functions */ static void particle_recalc(bContext *C, PointerRNA *ptr, short flag) @@ -433,6 +434,71 @@ static int rna_ParticleSystem_edited_get(PointerRNA *ptr) else return (psys->pointcache->edit && psys->pointcache->edit->edited); } +static PointerRNA rna_ParticleDupliWeight_active_get(PointerRNA *ptr) +{ + ParticleSettings *part= (ParticleSettings*)ptr->id.data; + ParticleDupliWeight *dw = part->dupliweights.first; + + for(; dw; dw=dw->next) { + if(dw->flag & PART_DUPLIW_CURRENT) + return rna_pointer_inherit_refine(ptr, &RNA_ParticleDupliWeight, dw); + } + return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, NULL); +} +static void rna_ParticleDupliWeight_active_index_range(PointerRNA *ptr, int *min, int *max) +{ + ParticleSettings *part= (ParticleSettings*)ptr->id.data; + *min= 0; + *max= BLI_countlist(&part->dupliweights)-1; + *max= MAX2(0, *max); +} + +static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr) +{ + ParticleSettings *part= (ParticleSettings*)ptr->id.data; + ParticleDupliWeight *dw = part->dupliweights.first; + int i=0; + + for(; dw; dw=dw->next, i++) + if(dw->flag & PART_DUPLIW_CURRENT) + return i; + + return 0; +} + +static void rna_ParticleDupliWeight_active_index_set(struct PointerRNA *ptr, int value) +{ + ParticleSettings *part= (ParticleSettings*)ptr->id.data; + ParticleDupliWeight *dw = part->dupliweights.first; + int i=0; + + for(; dw; dw=dw->next, i++) { + if(i==value) + dw->flag |= PART_DUPLIW_CURRENT; + else + dw->flag &= ~PART_DUPLIW_CURRENT; + } +} + +static int rna_ParticleDupliWeight_name_length(PointerRNA *ptr) +{ + ParticleDupliWeight *dw= ptr->data; + + if(dw->ob) + return strlen(dw->ob->id.name+2) + 7; + else + return 9 + 7; +} + +static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str) +{ + ParticleDupliWeight *dw= ptr->data; + + if(dw->ob) + sprintf(str, "%s: %i", dw->ob->id.name+2, dw->count); + else + strcpy(str, "No object"); +} EnumPropertyItem from_items[] = { {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, {PART_FROM_FACE, "FACE", 0, "Faces", ""}, @@ -726,6 +792,27 @@ static void rna_def_particle(BlenderRNA *brna) // short rt2; } +static void rna_def_particle_dupliweight(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ParticleDupliWeight", NULL); + RNA_def_struct_ui_text(srna, "Particle Dupliobject Weight", "Weight of a particle dupliobject in a group."); + RNA_def_struct_sdna(srna, "ParticleDupliWeight"); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_ParticleDupliWeight_name_get", "rna_ParticleDupliWeight_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Particle dupliobject name."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + + prop= RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Count", "The number of times this object is repeated with respect to other objects."); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); +} + static void rna_def_particle_settings(BlenderRNA *brna) { StructRNA *srna; @@ -1069,6 +1156,16 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from group randomly"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); + prop= RNA_def_property(srna, "use_group_count", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COUNT_GR); + RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same group"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); + + prop= RNA_def_property(srna, "use_global_dupli", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GLOBAL_OB); + RNA_def_property_ui_text(prop, "Use Global", "Use object's global coordinates for duplication."); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); + prop= RNA_def_property(srna, "render_adaptive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT); RNA_def_property_ui_text(prop, "Adaptive render", "Draw steps of the particle path"); @@ -1374,6 +1471,13 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Reactor", "Let the vector away from the target particles location give the particle a starting speed."); RNA_def_property_update(prop, 0, "rna_Particle_reset"); + prop= RNA_def_property(srna, "object_aligned_factor", PROP_FLOAT, PROP_VELOCITY); + RNA_def_property_float_sdna(prop, NULL, "ob_vel"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, -200.0f, 200.0f); + RNA_def_property_ui_text(prop, "Object Aligned", "Let the emitter object orientation give the particle a starting speed"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + prop= RNA_def_property(srna, "angular_velocity_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "avefac"); RNA_def_property_range(prop, -200.0f, 200.0f); @@ -1426,19 +1530,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) /* global physical properties */ - prop= RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "acc"); - RNA_def_property_array(prop, 3); - RNA_def_property_range(prop, -200.0f, 200.0f); - RNA_def_property_ui_text(prop, "Acceleration", "Constant acceleration"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "acc[2]"); - RNA_def_property_range(prop, -200.0f, 200.0f); - RNA_def_property_ui_text(prop, "Gravity", "Constant acceleration in global Z axis direction"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dragfac"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -1665,6 +1756,19 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Group", "Show Objects in this Group in place of particles"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); + prop= RNA_def_property(srna, "dupliweights", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "ParticleDupliWeight"); + RNA_def_property_ui_text(prop, "Dupli Group Weights", "Weights for all of the objects in the dupli group."); + + prop= RNA_def_property(srna, "active_dupliweight", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ParticleDupliWeight"); + RNA_def_property_pointer_funcs(prop, "rna_ParticleDupliWeight_active_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Active Dupli Object", ""); + + prop= RNA_def_property(srna, "active_dupliweight_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_ParticleDupliWeight_active_index_get", "rna_ParticleDupliWeight_active_index_set", "rna_ParticleDupliWeight_active_index_range"); + RNA_def_property_ui_text(prop, "Active Dupli Object Index", ""); + prop= RNA_def_property(srna, "dupli_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "dup_ob"); RNA_def_property_struct_type(prop, "Object"); @@ -2024,6 +2128,7 @@ void RNA_def_particle(BlenderRNA *brna) rna_def_child_particle(brna); rna_def_particle(brna); + rna_def_particle_dupliweight(brna); rna_def_particle_system(brna); rna_def_particle_settings(brna); } |