[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48610] branches/soc-2012-fried_chicken: Added a new force field type: "Smoke Flow".

Miika Hamalainen miika.hamalainen at kolumbus.fi
Wed Jul 4 21:30:31 CEST 2012


Revision: 48610
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48610
Author:   miikah
Date:     2012-07-04 19:30:30 +0000 (Wed, 04 Jul 2012)
Log Message:
-----------
Added a new force field type: "Smoke Flow".

It applies smoke simulation air flow velocity as a force to other Blender simulations that use force fields. To use it you need to add a "Smoke Flow" force field and select domain object for it.

To get an idea of what this is about, here is a video of it being used on particles: http://www.youtube.com/watch?v=lqRIxVQuVno

Modified Paths:
--------------
    branches/soc-2012-fried_chicken/release/datafiles/blender_icons.png
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_particle.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_cloth.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_common.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_field.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_smoke.py
    branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_softbody.py
    branches/soc-2012-fried_chicken/source/blender/blenkernel/BKE_smoke.h
    branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/depsgraph.c
    branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/effect.c
    branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/smoke.c
    branches/soc-2012-fried_chicken/source/blender/blenloader/intern/readfile.c
    branches/soc-2012-fried_chicken/source/blender/editors/datafiles/blender_icons.png.c
    branches/soc-2012-fried_chicken/source/blender/editors/include/UI_icons.h
    branches/soc-2012-fried_chicken/source/blender/editors/object/object_add.c
    branches/soc-2012-fried_chicken/source/blender/makesdna/DNA_object_force.h
    branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_object_force.c
    branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_smoke.c
    branches/soc-2012-fried_chicken/source/blender/modifiers/intern/MOD_smoke.c

Modified: branches/soc-2012-fried_chicken/release/datafiles/blender_icons.png
===================================================================
(Binary files differ)

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_particle.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_particle.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -1123,7 +1123,7 @@
 
     def draw(self, context):
         part = particle_get_settings(context)
-        effector_weights_ui(self, context, part.effector_weights)
+        effector_weights_ui(self, context, part.effector_weights, 'PSYS')
 
         if part.type == 'HAIR':
             row = self.layout.row()

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_cloth.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_cloth.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_cloth.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -199,7 +199,7 @@
 
     def draw(self, context):
         cloth = context.cloth.settings
-        effector_weights_ui(self, context, cloth.effector_weights)
+        effector_weights_ui(self, context, cloth.effector_weights, 'CLOTH')
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_common.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_common.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_common.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -179,7 +179,7 @@
         col.operator("ptcache.bake_all", text="Update All To Frame").bake = False
 
 
-def effector_weights_ui(self, context, weights):
+def effector_weights_ui(self, context, weights, weight_type):
     layout = self.layout
 
     layout.prop(weights, "group")
@@ -203,6 +203,8 @@
     col.prop(weights, "wind", slider=True)
     col.prop(weights, "curve_guide", slider=True)
     col.prop(weights, "texture", slider=True)
+    if weight_type != 'SMOKE':
+        col.prop(weights, "smokeflow", slider=True)
 
     col = split.column()
     col.prop(weights, "harmonic", slider=True)

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -350,7 +350,7 @@
 
             col = layout.column()
             col.active = surface.use_drip
-            effector_weights_ui(self, context, surface.effector_weights)
+            effector_weights_ui(self, context, surface.effector_weights, 'DYNAMIC_PAINT')
 
             layout.label(text="Surface Movement:")
             row = layout.row()

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_field.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_field.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_field.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -113,6 +113,14 @@
             col = split.column()
             col.prop(field, "use_object_coords")
             col.prop(field, "use_2d_force")
+        elif field.type == 'SMOKE_FLOW':
+            col = split.column()
+            col.prop(field, "strength")
+            col.prop(field, "flow")
+            col = split.column()
+            col.label(text="Domain Object:")
+            col.prop(field, "source_object", "")
+            col.prop(field, "use_smoke_density")
         else:
             basic_force_field_settings_ui(self, context, field)
 

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_smoke.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_smoke.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_smoke.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -281,7 +281,7 @@
 
     def draw(self, context):
         domain = context.smoke.domain_settings
-        effector_weights_ui(self, context, domain.effector_weights)
+        effector_weights_ui(self, context, domain.effector_weights, 'SMOKE')
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_softbody.py
===================================================================
--- branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_softbody.py	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_softbody.py	2012-07-04 19:30:30 UTC (rev 48610)
@@ -233,7 +233,7 @@
         md = context.soft_body
         softbody = md.settings
 
-        effector_weights_ui(self, context, softbody.effector_weights)
+        effector_weights_ui(self, context, softbody.effector_weights, 'SOFTBODY')
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: branches/soc-2012-fried_chicken/source/blender/blenkernel/BKE_smoke.h
===================================================================
--- branches/soc-2012-fried_chicken/source/blender/blenkernel/BKE_smoke.h	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/source/blender/blenkernel/BKE_smoke.h	2012-07-04 19:30:30 UTC (rev 48610)
@@ -46,5 +46,6 @@
 void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData *tsmd);
 
 long long smoke_get_mem_req(int xres, int yres, int zres, int amplify);
+float smoke_get_velocity_at(struct Object *ob, float position[3], float velocity[3]);
 
 #endif /* __BKE_SMOKE_H__ */

Modified: branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/depsgraph.c	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/depsgraph.c	2012-07-04 19:30:30 UTC (rev 48610)
@@ -390,8 +390,7 @@
 	}
 }
 
-static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node)
-{
+static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield){
 	Base *base;
 	DagNode *node2;
 
@@ -401,6 +400,8 @@
 		if ((base->lay & ob->lay) && base->object->pd) {
 			Object *ob1 = base->object;
 			if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
+				if (skip_forcefield && ob1->pd->forcefield == skip_forcefield)
+					continue;
 				node2 = dag_get_node(dag, ob1);					
 				dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision");
 			}
@@ -561,10 +562,11 @@
 	if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) {
 		if (modifiers_isModifierEnabled(ob, eModifierType_Softbody) 
 			|| modifiers_isModifierEnabled(ob, eModifierType_Cloth)
-			|| modifiers_isModifierEnabled(ob, eModifierType_Smoke)
 			|| modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint)
 			|| ob->particlesystem.first)
-			dag_add_collision_field_relation(dag, scene, ob, node);  /* TODO: use effectorweight->group */
+			dag_add_collision_field_relation(dag, scene, ob, node, 0);  /* TODO: use effectorweight->group */
+		else if (modifiers_isModifierEnabled(ob, eModifierType_Smoke))
+			dag_add_collision_field_relation(dag, scene, ob, node, PFIELD_SMOKEFLOW);
 	}
 	
 	/* object data drivers */

Modified: branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/effect.c
===================================================================
--- branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/effect.c	2012-07-04 18:49:09 UTC (rev 48609)
+++ branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/effect.c	2012-07-04 19:30:30 UTC (rev 48610)
@@ -85,6 +85,7 @@
 #include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
+#include "BKE_smoke.h"
 
 
 #include "RE_render_ext.h"
@@ -140,6 +141,9 @@
 		case PFIELD_TEXTURE:
 			pd->f_size = 1.0f;
 			break;
+		case PFIELD_SMOKEFLOW:
+			pd->f_flow = 1.0f;
+			break;
 	}
 	pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION;
 
@@ -925,12 +929,27 @@
 
 			mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
 			break;
+		case PFIELD_SMOKEFLOW:
+			zero_v3(force);
+			if (pd->f_source) {
+				float density;
+				if ((density = smoke_get_velocity_at(pd->f_source, point->loc, force)) >= 0.0f) {
+					float influence = strength * efd->falloff;
+					if (pd->flag & PFIELD_SMOKE_DENSITY)
+						influence *= density;
+					mul_v3_fl(force, influence);
+					/* apply flow */
+					madd_v3_v3fl(total_force, point->vel, -pd->f_flow * influence);
+				}
+			}
+			break;
+
 	}
 
 	if (pd->flag & PFIELD_DO_LOCATION) {
 		madd_v3_v3fl(total_force, force, 1.0f/point->vel_to_sec);
 
-		if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG)==0 && pd->f_flow != 0.0f) {
+		if (ELEM3(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_SMOKEFLOW)==0 && pd->f_flow != 0.0f) {
 			madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);
 		}
 	}

Modified: branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/smoke.c
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list