[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28452] branches/render25: = Hair Dampening and Collision=

Joseph Eagar joeedh at gmail.com
Tue Apr 27 04:30:41 CEST 2010


Revision: 28452
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28452
Author:   joeedh
Date:     2010-04-27 04:30:41 +0200 (Tue, 27 Apr 2010)

Log Message:
-----------
=Hair Dampening and Collision=

Some durian features; added a new dampening mode to hair (and cloth, since
they shared the same dynamics code), that blends velocities with what the velocity
would be if the hair or cloth was a stiff rigid body.  It's called "flexibility dampening"
for now.  Note that the code doesn't go through the solver directly, but this *is* an implicit
solver, and integrating this sort of outside stuff is the whole point of implicit systems.

Plus it works better for solving durian issues as quickly as possible (jahka: pin stiffness for hair is totally unusable btw).

Also added collision for hair, extending the existing collision code.  I have more reliable
code then this, but it'd b a bit of work to have it co-exist with the existing collision 
code (the other code replaces all of the collision code, so I'd have to rework it to coexist instead).

Modified Paths:
--------------
    branches/render25/release/scripts/ui/properties_particle.py
    branches/render25/release/scripts/ui/properties_physics_cloth.py
    branches/render25/release/scripts/ui/properties_physics_common.py
    branches/render25/release/scripts/ui/space_sequencer.py
    branches/render25/source/blender/blenkernel/BKE_cloth.h
    branches/render25/source/blender/blenkernel/intern/cloth.c
    branches/render25/source/blender/blenkernel/intern/collision.c
    branches/render25/source/blender/blenkernel/intern/implicit.c
    branches/render25/source/blender/blenkernel/intern/particle_system.c
    branches/render25/source/blender/blenlib/BLI_math_geom.h
    branches/render25/source/blender/blenlib/intern/math_geom.c
    branches/render25/source/blender/makesdna/DNA_cloth_types.h
    branches/render25/source/blender/makesrna/intern/rna_cloth.c

Modified: branches/render25/release/scripts/ui/properties_particle.py
===================================================================
--- branches/render25/release/scripts/ui/properties_particle.py	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/release/scripts/ui/properties_particle.py	2010-04-27 02:30:41 UTC (rev 28452)
@@ -24,8 +24,8 @@
 from properties_physics_common import effector_weights_ui
 from properties_physics_common import basic_force_field_settings_ui
 from properties_physics_common import basic_force_field_falloff_ui
+from properties_physics_cloth import PHYSICS_PT_cloth_collision
 
-
 def particle_panel_enabled(context, psys):
     return (psys.point_cache.baked is False) and (not psys.edited) and (not context.particle_system_editable)
 
@@ -36,9 +36,30 @@
         return False
     if psys.settings is None:
         return False
+    
     return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR')
 
+class PARTICLE_PT_cloth_collision (PHYSICS_PT_cloth_collision):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "particle"
 
+    def poll(self, context):
+        print(particle_panel_poll(context))
+        if not particle_panel_poll(context):
+            return False
+        
+        return True
+
+    def get_cloth(self, context):
+        if context.particle_system is None:
+            return False
+        
+        if context.particle_system.cloth is None:
+            return False
+            
+        return context.particle_system.cloth
+
 class ParticleButtonsPanel(bpy.types.Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -47,7 +68,6 @@
     def poll(self, context):
         return particle_panel_poll(context)
 
-
 class PARTICLE_PT_context_particles(ParticleButtonsPanel):
     bl_label = ""
     bl_show_header = False
@@ -75,7 +95,7 @@
 
             col = split.column()
             col.label(text="Name:")
-            col.label(text="Settings:")
+            col.label(text="Settindgs:")
 
             col = split.column()
             col.prop(psys, "name", text="")
@@ -232,7 +252,8 @@
         sub.prop(cloth, "bending_stiffness", text="Bending")
         sub.prop(cloth, "internal_friction", slider=True)
         sub.prop(cloth, "collider_friction", slider=True)
-
+        sub.prop(cloth, "flexibility_damping", slider=True)
+        
         col = split.column()
 
         col.label(text="Damping:")
@@ -1052,6 +1073,7 @@
 classes = [
     PARTICLE_PT_context_particles,
     PARTICLE_PT_hair_dynamics,
+	PARTICLE_PT_cloth_collision,
     PARTICLE_PT_cache,
     PARTICLE_PT_emission,
     PARTICLE_PT_velocity,
@@ -1067,7 +1089,6 @@
 
     PARTICLE_PT_custom_props]
 
-
 def register():
     register = bpy.types.register
     for cls in classes:

Modified: branches/render25/release/scripts/ui/properties_physics_cloth.py
===================================================================
--- branches/render25/release/scripts/ui/properties_physics_cloth.py	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/release/scripts/ui/properties_physics_cloth.py	2010-04-27 02:30:41 UTC (rev 28452)
@@ -105,6 +105,7 @@
             col.label(text="Damping:")
             col.prop(cloth, "spring_damping", text="Spring")
             col.prop(cloth, "air_damping", text="Air")
+            col.prop(cloth, "flexibility_damping", text="Flexibility")
 
             col.prop(cloth, "pin_cloth", text="Pinning")
             sub = col.column()
@@ -150,19 +151,26 @@
     bl_default_closed = True
 
     def poll(self, context):
+        return self.get_cloth(context)
+    
+    def get_cloth(self, context):
         return context.cloth
 
     def draw_header(self, context):
-        cloth = context.cloth.collision_settings
+        cloth = self.get_cloth(context).collision_settings
 
-        self.layout.active = cloth_panel_enabled(context.cloth)
+        self.layout.active = cloth_panel_enabled(self.get_cloth(context))
         self.layout.prop(cloth, "enable_collision", text="")
 
     def draw(self, context):
         layout = self.layout
-
-        cloth = context.cloth.collision_settings
-        md = context.cloth
+        
+        cloth = self.get_cloth(context)
+        if not cloth: return
+        
+        cloth = cloth.collision_settings
+        md = self.get_cloth(context)
+        
         wide_ui = context.region.width > narrowui
 
         layout.active = cloth.enable_collision and cloth_panel_enabled(md)

Modified: branches/render25/release/scripts/ui/properties_physics_common.py
===================================================================
--- branches/render25/release/scripts/ui/properties_physics_common.py	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/release/scripts/ui/properties_physics_common.py	2010-04-27 02:30:41 UTC (rev 28452)
@@ -134,12 +134,12 @@
     wide_ui = context.region.width > narrowui
 
     split = layout.split()
-
+    
     if not field or field.type == 'NONE':
         return
 
     col = split.column()
-
+    
     if field.type == 'DRAG':
         col.prop(field, "linear_drag", text="Linear")
     else:

Modified: branches/render25/release/scripts/ui/space_sequencer.py
===================================================================
--- branches/render25/release/scripts/ui/space_sequencer.py	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/release/scripts/ui/space_sequencer.py	2010-04-27 02:30:41 UTC (rev 28452)
@@ -217,7 +217,6 @@
         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
-        layout.operator("sequencer.effect_strip_add", text="Multicam Selector").type = 'MULTICAM'
 
 
 class SEQUENCER_MT_strip(bpy.types.Menu):
@@ -403,8 +402,7 @@
         return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
                               'PLUGIN',
-                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED',
-                              'MULTICAM')
+                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
 
     def draw(self, context):
         layout = self.layout
@@ -447,10 +445,8 @@
 
         elif strip.type == 'TRANSFORM':
             self.draw_panel_transform(strip)
-            
-        elif strip.type == "MULTICAM":
-            layout.prop(strip, "multicam_source")
 
+
         col = layout.column(align=True)
         if strip.type == 'SPEED':
             col.prop(strip, "speed_fader", text="Speed fader")
@@ -505,8 +501,7 @@
                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
                               'PLUGIN',
-                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
-                              'MULTICAM','SPEED')
+                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
 
     def draw_filename(self, context):
         pass
@@ -688,8 +683,7 @@
                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
                               'PLUGIN',
-                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
-                              'MULTICAM', 'SPEED')
+                              'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
 
     def draw(self, context):
         layout = self.layout
@@ -744,7 +738,7 @@
         if not strip:
             return False
 
-        return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META', 'MULTICAM')
+        return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
 
     def draw_header(self, context):
         strip = act_strip(context)

Modified: branches/render25/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_cloth.h	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/source/blender/blenkernel/BKE_cloth.h	2010-04-27 02:30:41 UTC (rev 28452)
@@ -102,6 +102,7 @@
 	unsigned char 		old_solver_type;	/* unused, only 1 solver here */
 	unsigned char 		pad2;
 	short 			pad3;
+	struct BVHTree		*bvhspringtree;			/* collision tree for wire edges, e.g. hair */
 	struct BVHTree		*bvhtree;			/* collision tree for this cloth object */
 	struct BVHTree 		*bvhselftree;			/* collision tree for this cloth object */
 	struct MFace 		*mfaces;
@@ -133,6 +134,7 @@
 	float	bend_stiff;
 	float 	shear_stiff;
 	int 	spring_count; /* how many springs attached? */
+	int isolated; /*does not belon to any *face*, but *may* belong to an edge*/
 }
 ClothVertex;
 

Modified: branches/render25/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/cloth.c	2010-04-27 02:20:40 UTC (rev 28451)
+++ branches/render25/source/blender/blenkernel/intern/cloth.c	2010-04-27 02:30:41 UTC (rev 28452)
@@ -37,6 +37,7 @@
 
 #include "BKE_pointcache.h"
 
+#include "BLI_ghash.h"
 
 #ifdef _WIN32
 void tstart ( void )
@@ -193,9 +194,10 @@
 static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon)
 {
 	unsigned int i;
-	BVHTree *bvhtree;
+	BVHTree *bvhtree, *bvhspringtree = NULL;
+	GHash *gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
 	Cloth *cloth;
-	ClothVertex *verts;
+	ClothVertex *verts, *v;
 	MFace *mfaces;
 	float co[12];
 
@@ -210,8 +212,8 @@
 	verts = cloth->verts;
 	mfaces = cloth->mfaces;
 	
-	// in the moment, return zero if no faces there
-	if(!cloth->numfaces)
+	// in the moment, return zero if nothing there
+	if(!cloth->numfaces && !cloth->numverts)
 		return NULL;
 	
 	// create quadtree with k=26
@@ -220,19 +222,48 @@
 	// fill tree
 	for(i = 0; i < cloth->numfaces; i++, mfaces++)
 	{
+		BLI_ghash_insert(gh, &verts[mfaces->v1], NULL);
+		BLI_ghash_insert(gh, &verts[mfaces->v2], NULL);
+		BLI_ghash_insert(gh, &verts[mfaces->v3], NULL);
+
 		VECCOPY(&co[0*3], verts[mfaces->v1].xold);
 		VECCOPY(&co[1*3], verts[mfaces->v2].xold);
 		VECCOPY(&co[2*3], verts[mfaces->v3].xold);
 		
-		if(mfaces->v4)
+		if(mfaces->v4) {
 			VECCOPY(&co[3*3], verts[mfaces->v4].xold);
-		

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list