[Bf-blender-cvs] [9b7d06b255b] fluid-mantaflow: added particle UI tab

Sebastián Barschkis noreply at git.blender.org
Sat Jul 1 00:51:47 CEST 2017


Commit: 9b7d06b255b4584c989eac6da5f46a8efcce3e38
Author: Sebastián Barschkis
Date:   Mon Jun 26 21:20:50 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB9b7d06b255b4584c989eac6da5f46a8efcce3e38

added particle UI tab

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

M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
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 d04248cbebf..cefbfeb0c2a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -278,7 +278,7 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
         col.prop(domain, "adapt_threshold")
 
 
-class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
+class PHYSICS_PT_smoke_quality(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Quality"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 
@@ -342,6 +342,36 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
             sub.prop(domain, "noise_pos_scale")
             sub.prop(domain, "noise_time_anim")
 
+class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, Panel):
+    bl_label = "Fluid Particles"
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+    @classmethod
+    def poll(cls, context):
+        md = context.smoke
+        rd = context.scene.render
+        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+        domain = context.smoke.domain_settings
+
+        split = layout.split()
+
+        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_float_particles", text="Floats")
+        #col.prop(domain, "use_tracer_particles", text="Tracer")
+
+        col = split.column()
+        col.label(text="")
+        sub = col.column()
+        sub.active = domain.use_drop_particles
+        sub.prop(domain, "particle_velocity_threshold", text="Threshold")
+
 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Groups"
     bl_options = {'DEFAULT_CLOSED'}
@@ -446,7 +476,7 @@ class OBJECT_OT_RunMantaButton(bpy.types.Operator):
         bpy.ops.manta.make_file()
         return{'FINISHED'}
 
-class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
+class PHYSICS_PT_smoke_export_manta(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Export"
     bl_options = {'DEFAULT_CLOSED'}
 
@@ -525,12 +555,13 @@ classes = (
     PHYSICS_PT_smoke,
     PHYSICS_PT_smoke_flow_advanced,
     PHYSICS_PT_smoke_adaptive_domain,
-    PHYSICS_PT_smoke_highres,
+    PHYSICS_PT_smoke_quality,
+    PHYSICS_PT_smoke_particles,
     PHYSICS_PT_smoke_groups,
     PHYSICS_PT_smoke_cache,
     PHYSICS_PT_smoke_field_weights,
     OBJECT_OT_RunMantaButton,
-    PHYSICS_PT_smoke_manta_settings,
+    PHYSICS_PT_smoke_export_manta,
     PHYSICS_PT_smoke_display_settings,
 )
 
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 196982d46d8..3bd22dd8420 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -542,6 +542,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->particle_number = 2;
 			smd->domain->particle_radius = 1.0f;
 			smd->domain->particle_band_width = 3.0f;
+			smd->domain->particle_velocity_threshold = 2.0f;
+			smd->domain->particle_type = 0;
 
 			/*mantaflow settings*/
 			smd->domain->manta_solver_res = 3;
@@ -666,6 +668,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->particle_number = smd->domain->particle_number;
 		tsmd->domain->particle_radius = smd->domain->particle_radius;
 		tsmd->domain->particle_band_width = smd->domain->particle_band_width;
+		tsmd->domain->particle_velocity_threshold = smd->domain->particle_velocity_threshold;
 
 		tsmd->domain->manta_solver_res = smd->domain->manta_solver_res;
 		tsmd->domain->noise_pos_scale = smd->domain->noise_pos_scale;
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 0405cf2d716..17899b0c359 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -247,6 +247,8 @@ typedef struct SmokeDomainSettings {
 	int particle_number;
 	float particle_radius;
 	float particle_band_width;
+	float particle_velocity_threshold;
+	int particle_type;
 
 	/* Display settings */
 	char slice_method, axis_slice_method;
@@ -297,6 +299,10 @@ typedef struct SmokeDomainSettings {
 #define MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO 0
 #define MOD_SMOKE_FLOW_TEXTURE_MAP_UV 1
 
+/* particle types */
+#define MOD_SMOKE_PARTICLE_FLIP (1<<0)
+#define MOD_SMOKE_PARTICLE_SND (1<<1)
+
 /* flags */
 #define MOD_SMOKE_FLOW_ABSOLUTE (1<<1) /*old style emission*/
 #define MOD_SMOKE_FLOW_INITVELOCITY (1<<2) /* passes particles speed to the smoke */
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index e4ee21fa7a7..54b68c109c5 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -107,7 +107,7 @@ static void rna_Smoke_viewport_set(struct PointerRNA *ptr, int value)
 	}
 }
 
-static void rna_Smoke_update_volume_format(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Smoke_flip_parts_set(struct PointerRNA *ptr, int value)
 {
 	Object *ob = (Object *)ptr->id.data;
 	SmokeModifierData *smd;
@@ -117,32 +117,26 @@ static void rna_Smoke_update_volume_format(Main *bmain, Scene *scene, PointerRNA
 
 	smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
 
-	/* TODO (sebbas): for now, only liquid domains hold particle systems */
-	if (smd->domain->type != MOD_SMOKE_DOMAIN_TYPE_LIQUID) {
-		rna_Smoke_resetCache(bmain, scene, ptr);
-		return;
-	}
-
 	/* remove fluidsim particle system */
-	if (smd && smd->domain && smd->domain->flags & MOD_SMOKE_USE_VOLUME_CACHE) {
+	if (value && smd && smd->domain) {
 		for (psys = ob->particlesystem.first; psys; psys = psys->next)
 			if (psys->part->type == PART_MANTA)
 				break;
 
 		if (ob->type == OB_MESH && !psys) {
 			/* add particle system */
-			part = psys_new_settings("ParticleSettings", bmain);
+			part = psys_new_settings("ParticleSettings", NULL);
 			psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
 
 			part->type = PART_MANTA;
 			psys->part = part;
 			psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
-			BLI_strncpy(psys->name, "FlipParticles", sizeof(psys->name));
+			BLI_strncpy(psys->name, "Secondary Particles", sizeof(psys->name));
 			BLI_addtail(&ob->particlesystem, psys);
 
 			/* add modifier */
 			psmd = (ParticleSystemModifierData *)modifier_new(eModifierType_ParticleSystem);
-			BLI_strncpy(psmd->modifier.name, "FLIPParticleSystem", sizeof(psmd->modifier.name));
+			BLI_strncpy(psmd->modifier.name, "Secondary Particle System", sizeof(psmd->modifier.name));
 			psmd->psys = psys;
 			BLI_addtail(&ob->modifiers, psmd);
 			modifier_unique_name(&ob->modifiers, (ModifierData *)psmd);
@@ -167,7 +161,18 @@ static void rna_Smoke_update_volume_format(Main *bmain, Scene *scene, PointerRNA
 		/* solid mode more convenient for meshes */
 		ob->dt = OB_SOLID;
 	}
-	rna_Smoke_resetCache(bmain, scene, ptr);
+
+	if (value == 1) {
+		smd->domain->particle_type |= MOD_SMOKE_PARTICLE_SND;
+	}
+	else {
+		/* Clear old caches. */
+		PTCacheID id;
+		BKE_ptcache_id_from_smoke(&id, ob, smd);
+		BKE_ptcache_id_clear(&id, PTCACHE_CLEAR_ALL, 0);
+
+		smd->domain->particle_type &= ~MOD_SMOKE_PARTICLE_SND;
+	}
 }
 
 static void rna_Smoke_use_surface_format_set(struct PointerRNA *ptr, int value)
@@ -1072,7 +1077,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_USE_VOLUME_CACHE);
 	RNA_def_property_boolean_funcs(prop, NULL, "rna_Smoke_use_volume_format_set");
 	RNA_def_property_ui_text(prop, "Volumetric cache", "Enable volume cache");
-	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update_volume_format");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
 
 	prop = RNA_def_property(srna, "cache_surface_format", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "cache_surface_format");
@@ -1137,6 +1142,26 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
 	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
 
+	prop = RNA_def_property(srna, "use_flip_particles", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "particle_type", MOD_SMOKE_PARTICLE_FLIP);
+	RNA_def_property_boolean_funcs(prop, NULL, "rna_Smoke_flip_parts_set");
+	RNA_def_property_ui_text(prop, "FLIP", "Create FLIP particle system");
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+	prop = RNA_def_property(srna, "use_drop_particles", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "particle_type", MOD_SMOKE_PARTICLE_SND);
+	RNA_def_property_boolean_funcs(prop, NULL, "rna_Smoke_flip_parts_set");
+	RNA_def_property_ui_text(prop, "FLIP", "Create secondary particle system");
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+	prop = RNA_def_property(srna, "particle_velocity_threshold", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0, 10.0);
+	RNA_def_property_ui_range(prop, 0.0, 10.0, 0.02, 5);
+	RNA_def_property_ui_text(prop, "Threshold", "Velocity threshold for drop particle generation (higher value results in fewer drops)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
 	/* display settings */
 
 	prop = RNA_def_property(srna, "slice_method", PROP_ENUM, PROP_NONE);




More information about the Bf-blender-cvs mailing list