Commit: 47056f2b3a4ffd2c302e3bf7474764b208686948
Author: Sebastián Barschkis
Date:   Wed Jul 5 19:13:37 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB47056f2b3a4ffd2c302e3bf7474764b208686948

refactoring in rna particle setup

made particle system creation / deletion more modular. this will be helpful 
when adding floats and tracer particles.

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

M       release/scripts/startup/bl_ui/properties_physics_smoke.py
M       source/blender/blenkernel/intern/dynamicpaint.c
M       source/blender/blenkernel/intern/particle_system.c
M       source/blender/makesdna/DNA_particle_types.h
M       source/blender/makesdna/DNA_smoke_types.h
M       source/blender/makesrna/intern/rna_particle.c
M       source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py 
b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index dee198c0d97..313a0c3c436 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -360,15 +360,13 @@ class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, 
Panel):
 
         col = split.column()
         col.enabled = not domain.point_cache.is_baked
-        col.label(text="Type:")
         col.prop(domain, "use_flip_particles", text="FLIP")
-        col.prop(domain, "use_drop_particles", text="Secondary")
+        col.prop(domain, "use_drop_particles", text="Drop")
         #col.prop(domain, "use_float_particles", text="Floats")
         #col.prop(domain, "use_tracer_particles", text="Tracer")
 
         col = split.column()
         col.enabled = not domain.point_cache.is_baked
-        col.label(text="")
         sub = col.column()
         sub.active = domain.use_drop_particles
         sub.label()
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c 
b/source/blender/blenkernel/intern/dynamicpaint.c
index 22692750a45..98470c92b88 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -5847,7 +5847,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, 
DynamicPaintSurface *su
                                        /* Particle brush: */
                                        if (brush->collision == 
MOD_DPAINT_COL_PSYS) {
                                                if (brush->psys && 
brush->psys->part &&
-                                                   
ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID, PART_MANTA_FLIP, 
PART_MANTA_SND) &&
+                                                   
ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID, PART_MANTA_FLIP, 
PART_MANTA_DROP) &&
                                                    
psys_check_enabled(brushObj, brush->psys, G.is_rendering))
                                                {
                                                        /* Paint a particle 
system */
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index 49a6b36d779..76c32273985 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -549,7 +549,7 @@ static void 
initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
        case PART_FLUID:
                break;
        case PART_MANTA_FLIP:
-       case PART_MANTA_SND:
+       case PART_MANTA_DROP:
                break;
        }
 }
@@ -3778,7 +3778,7 @@ static void particles_manta_step(ParticleSimulationData 
*sim, int UNUSED(cfra),
 
                        if (part->type == PART_MANTA_FLIP)
                                totpart = 
liquid_get_num_flip_particles(sds->fluid);
-                       if (part->type == PART_MANTA_SND)
+                       if (part->type == PART_MANTA_DROP)
                                totpart = 
liquid_get_num_snd_particles(sds->fluid);
 
                        // Sanity check: no particle files present yet
@@ -4405,7 +4405,7 @@ void particle_system_update(Scene *scene, Object *ob, 
ParticleSystem *psys, cons
                        break;
                }
                case PART_MANTA_FLIP:
-               case PART_MANTA_SND:
+               case PART_MANTA_DROP:
                {
                        particles_manta_step(&sim, (int)cfra, 
use_render_params);
                        break;
diff --git a/source/blender/makesdna/DNA_particle_types.h 
b/source/blender/makesdna/DNA_particle_types.h
index 7d4647ea172..338806368b7 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -357,7 +357,7 @@ typedef enum eParticleDrawFlag {
 #define PART_HAIR                      2
 #define PART_FLUID                     3
 #define PART_MANTA_FLIP                4
-#define PART_MANTA_SND         5
+#define PART_MANTA_DROP                5
 
 /* part->flag */
 #define PART_REACT_STA_END     1
diff --git a/source/blender/makesdna/DNA_smoke_types.h 
b/source/blender/makesdna/DNA_smoke_types.h
index 17899b0c359..43172078933 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -300,8 +300,9 @@ typedef struct SmokeDomainSettings {
 #define MOD_SMOKE_FLOW_TEXTURE_MAP_UV 1
 
 /* particle types */
-#define MOD_SMOKE_PARTICLE_FLIP (1<<0)
-#define MOD_SMOKE_PARTICLE_SND (1<<1)
+#define MOD_SMOKE_PARTICLE_NONE (1<<0)
+#define MOD_SMOKE_PARTICLE_FLIP (1<<1)
+#define MOD_SMOKE_PARTICLE_DROP (1<<2)
 
 /* flags */
 #define MOD_SMOKE_FLOW_ABSOLUTE (1<<1) /*old style emission*/
diff --git a/source/blender/makesrna/intern/rna_particle.c 
b/source/blender/makesrna/intern/rna_particle.c
index 81e876e7924..62e816be33c 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -885,7 +885,7 @@ static int rna_PartSettings_is_manta_get(PointerRNA *ptr)
 {
        ParticleSettings *part = (ParticleSettings *)ptr->data;
 
-       return (part->type == PART_MANTA_FLIP) || (part->type == 
PART_MANTA_SND);
+       return (part->type == PART_MANTA_FLIP) || (part->type == 
PART_MANTA_DROP);
 }
 
 static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene 
*scene, PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_smoke.c 
b/source/blender/makesrna/intern/rna_smoke.c
index 50f79a3ce5d..d97ad6c5dff 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -107,140 +107,114 @@ static void rna_Smoke_viewport_set(struct PointerRNA 
*ptr, int value)
        }
 }
 
-static void rna_Smoke_flip_parts_set(struct PointerRNA *ptr, int value)
+static void rna_Smoke_parts_create(PointerRNA *ptr, char *pset_name, char* 
parts_name, char* psys_name, int psys_type)
 {
        Object *ob = (Object *)ptr->id.data;
-       SmokeModifierData *smd;
        ParticleSystemModifierData *psmd;
-       ParticleSystem *psys, *next_psys;
+       ParticleSystem *psys;
        ParticleSettings *part;
 
-       smd = (SmokeModifierData *)modifiers_findByType(ob, 
eModifierType_Smoke);
+       /* add particle system */
+       part = psys_new_settings(pset_name, NULL);
+       psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
+
+       part->type = psys_type;
+       psys->part = part;
+       psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
+       BLI_strncpy(psys->name, parts_name, sizeof(psys->name));
+       BLI_addtail(&ob->particlesystem, psys);
+
+       /* add modifier */
+       psmd = (ParticleSystemModifierData 
*)modifier_new(eModifierType_ParticleSystem);
+       BLI_strncpy(psmd->modifier.name, psys_name, 
sizeof(psmd->modifier.name));
+       psmd->psys = psys;
+       BLI_addtail(&ob->modifiers, psmd);
+       modifier_unique_name(&ob->modifiers, (ModifierData *)psmd);
+}
 
-       /* remove fluidsim particle system */
-       if (value && smd && smd->domain) {
-               for (psys = ob->particlesystem.first; psys; psys = psys->next)
-                       if (psys->part->type == PART_MANTA_FLIP)
-                               break;
-
-               if (ob->type == OB_MESH && !psys) {
-                       /* add particle system */
-                       part = psys_new_settings("FlipParticleSettings", NULL);
-                       psys = MEM_callocN(sizeof(ParticleSystem), 
"particle_system");
-
-                       part->type = PART_MANTA_FLIP;
-                       psys->part = part;
-                       psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
-                       BLI_strncpy(psys->name, "FLIP Particles", 
sizeof(psys->name));
-                       BLI_addtail(&ob->particlesystem, psys);
-
-                       /* add modifier */
-                       psmd = (ParticleSystemModifierData 
*)modifier_new(eModifierType_ParticleSystem);
-                       BLI_strncpy(psmd->modifier.name, "FLIP Particle 
System", sizeof(psmd->modifier.name));
-                       psmd->psys = psys;
-                       BLI_addtail(&ob->modifiers, psmd);
-                       modifier_unique_name(&ob->modifiers, (ModifierData 
*)psmd);
-               }
-               /* wire mode more convenient for particles */
-               ob->dt = OB_WIRE;
-       }
-       else {
-               for (psys = ob->particlesystem.first; psys; psys = next_psys) {
-                       next_psys = psys->next;
-                       if (psys->part->type == PART_MANTA_FLIP) {
-                               /* clear modifier */
-                               psmd = psys_get_modifier(ob, psys);
-                               BLI_remlink(&ob->modifiers, psmd);
-                               modifier_free((ModifierData *)psmd);
-
-                               /* clear particle system */
-                               BLI_remlink(&ob->particlesystem, psys);
-                               psys_free(ob, psys);
-                       }
+static void rna_Smoke_parts_delete(PointerRNA *ptr, int ptype)
+{
+       Object *ob = (Object *)ptr->id.data;
+       ParticleSystemModifierData *psmd;
+       ParticleSystem *psys, *next_psys;
+
+       for (psys = ob->particlesystem.first; psys; psys = next_psys) {
+               next_psys = psys->next;
+               if (psys && psys->part && psys->part->type == ptype) {
+                       /* clear modifier */
+                       psmd = psys_get_modifier(ob, psys);
+                       BLI_remlink(&ob->modifiers, psmd);
+                       modifier_free((ModifierData *)psmd);
+
+                       /* clear particle system */
+                       BLI_remlink(&ob->particlesystem, psys);
+                       psys_free(ob, psys);
                }
-               /* solid mode more convenient for meshes (only set if snd parts 
not enabled) */
-               if (!(smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLIP)) 
ob->dt = OB_SOLID;
        }
+}
 
-       if (value == 1) {
-               smd->domain->particle_type |= MOD_SMOKE_PARTICLE_FLIP;
+static bool rna_Smoke_parts_exists(PointerRNA *ptr, int ptype)
+{
+       Object *ob = (Object *)ptr->id.data;
+       ParticleSystem *psys;
+
+       for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+               if (psys->part->type == ptype) return true;
        }
-       else {
-               /* Clear old caches. */
-               PTCacheID id;
-               BKE_ptcache_id_from_smoke(&id, ob, smd);
-               BKE_ptcache_id_clear(&id, PTCACHE_CLEAR_ALL, 0);
+       return false;
+}
 
-               smd->domain->particle_type &= ~MOD_SMOKE_PARTICLE_FLIP;
+static void rna_Smoke_draw_type_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), struct PointerRNA *ptr)
+{
+       Object *ob = (Object *)ptr->id.data;
+       SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
+
+       /* Solid mode more convenient for meshes if no parts present */
+       if (settings->particle_type & MOD_SMOKE_PARTICLE_NONE) {
+               ob->dt = OB_SOLID;
+       } else {
+               ob->dt = OB_WIRE;
        }
 }
 
-static void rna_Smoke_snd_parts_set(struct PointerRNA *ptr, int value)
+static void rna_Smoke_flip_parts_set(struct PointerRNA *ptr, int value)
 {
        Object *ob = (Object *)ptr->id.data;
        SmokeModifierData *smd;
-       ParticleSystemModifierData *psmd;
-       ParticleSystem *psys, *next_psys;
-       ParticleSettings *part;
-
        smd = (SmokeModifierData *)modifiers_findByType(ob, 
eModifierType_Smoke);
+       bool exists = rna_Smoke_parts_exists(ptr, PART_MANTA_FLIP);
 
-       /* remove fluidsim particle system */
-       if (value && smd && smd->domain) {
-               for (psys = ob->particlesystem.first; psys; psys = psys->next)
-                       if (psys->part->type == PART_MANTA_SND)
-                               break;
-
-               if (ob->type == OB_MESH && !psys) {
-                       /* add particle system */
-                       part = psys_new_settings("SecondaryParticleSettings", 
NULL);
-                       psys = MEM_callocN(sizeof(ParticleSystem), 
"particle_system");
-
-                       part->type = P

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to