[Bf-blender-cvs] [8f5deb0] hair_system: Cleanup: Re-enabled old particle hair code using the cloth modifier.

Lukas Tönne noreply at git.blender.org
Sun Oct 5 14:56:44 CEST 2014


Commit: 8f5deb034bc10a036de96a6ba69df3298e43e6b2
Author: Lukas Tönne
Date:   Wed Sep 24 19:25:44 2014 +0200
Branches: hair_system
https://developer.blender.org/rB8f5deb034bc10a036de96a6ba69df3298e43e6b2

Cleanup: Re-enabled old particle hair code using the cloth modifier.

The new system works next to the old one, changes to the old code should
be minimal.

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

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_particle.c

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

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 6c1317a..00c19c9 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -252,8 +252,9 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
 
 
 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
-    bl_label = "Hair Simulation"
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'CYCLES'}
+    bl_label = "Hair dynamics"
+    bl_options = {'DEFAULT_CLOSED'}
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
 
     @classmethod
     def poll(cls, context):
@@ -271,22 +272,28 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
+
         psys = context.particle_system
 
-        if not psys.params:
+        if not psys.cloth:
             return
 
-        params = psys.params
         cloth_md = psys.cloth
         cloth = cloth_md.settings
         result = cloth_md.solver_result
 
-        layout.enabled = psys.use_hair_dynamics
+        layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
 
         split = layout.split()
 
         col = split.column()
-        col.prop(params, "substeps_forces")
+        col.label(text="Material:")
+        sub = col.column(align=True)
+        sub.prop(cloth, "pin_stiffness", text="Stiffness")
+        sub.prop(cloth, "mass")
+        sub.prop(cloth, "bending_stiffness", text="Bending")
+        sub.prop(cloth, "internal_friction", slider=True)
+        sub.prop(cloth, "collider_friction", slider=True)
         sub.prop(cloth, "pressure", slider=True)
         sub.prop(cloth, "pressure_threshold", slider=True)
 
@@ -295,20 +302,15 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
         sub.prop(cloth, "voxel_resolution")
 
         col = split.column()
-        col.prop(params, "substeps_damping")
-
-        split = layout.split()
-
-        col = split.column()
-        col.prop(params, "stretch_stiffness")
-        col.prop(params, "bend_stiffness")
-        col.prop(params, "bend_smoothing")
+        col.label(text="Damping:")
+        sub = col.column(align=True)
+        sub.prop(cloth, "spring_damping", text="Spring")
+        sub.prop(cloth, "air_damping", text="Air")
 
-        col = split.column()
-        col.prop(params, "stretch_damping")
-        col.prop(params, "bend_damping")
+        col.label(text="Quality:")
+        col.prop(cloth, "quality", text="Steps", slider=True)
 
-        layout.prop(cloth_md, "show_debug_data", text="Debug")
+        col.prop(cloth_md, "show_debug_data", text="Debug")
 
         if result:
             box = layout.box()
@@ -330,36 +332,6 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
             box.label("Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error))
 
 
-class PARTICLE_PT_hair_collision(ParticleButtonsPanel, Panel):
-    bl_label = "Hair Collision"
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'CYCLES'}
-
-    @classmethod
-    def poll(cls, context):
-        psys = context.particle_system
-        engine = context.scene.render.engine
-        if psys is None:
-            return False
-        if psys.settings is None:
-            return False
-        return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES) and psys.use_hair_dynamics
-
-    def draw(self, context):
-        layout = self.layout
-        psys = context.particle_system
-        params = psys.params
-
-        split = layout.split()
-
-        col = split.column()
-        col.prop(params, "restitution")
-        col.prop(params, "friction")
-        col.prop(params, "margin")
-
-        col = split.column()
-        col.prop(params, "drag")
-
-
 class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
     bl_label = "Cache"
     bl_options = {'DEFAULT_CLOSED'}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 89dc918..20c6667 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -390,7 +390,7 @@ void BKE_particlesettings_free(ParticleSettings *part)
 	}
 }
 
-void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int UNUSED(dynamics))
+void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
 {
 	PARTICLE_P;
 
@@ -403,7 +403,6 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int UNUSED(dynamics))
 
 	psys->flag &= ~PSYS_HAIR_DONE;
 
-#if 0
 	if (psys->clmd) {
 		if (dynamics) {
 			BKE_ptcache_free_list(&psys->ptcaches);
@@ -419,7 +418,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int UNUSED(dynamics))
 			cloth_free_modifier(psys->clmd);
 		}
 	}
-#endif
+
 	if (psys->hair_in_dm)
 		psys->hair_in_dm->release(psys->hair_in_dm);
 	psys->hair_in_dm = NULL;
@@ -428,7 +427,6 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int UNUSED(dynamics))
 		psys->hair_out_dm->release(psys->hair_out_dm);
 	psys->hair_out_dm = NULL;
 }
-
 void free_keyed_keys(ParticleSystem *psys)
 {
 	PARTICLE_P;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 57e4520..1260820 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -48,7 +48,6 @@
 
 #include "DNA_anim_types.h"
 #include "DNA_boid_types.h"
-#include "DNA_hair_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -56,7 +55,6 @@
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
 #include "DNA_curve_types.h"
-#include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_listBase.h"
@@ -78,7 +76,6 @@
 #include "BKE_cdderivedmesh.h"
 #include "BKE_collision.h"
 #include "BKE_effect.h"
-#include "BKE_hair.h"
 #include "BKE_particle.h"
 #include "BKE_global.h"
 
@@ -4052,7 +4049,6 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 	float (*deformedVerts)[3];
 	float max_length;
 
-#if 0
 	if (!psys->clmd) {
 		psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
 		psys->clmd->sim_parms->goalspring = 0.0f;
@@ -4071,8 +4067,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 				max_length = length;
 		}
 	}
-#endif
-	
+
 	/* create a dm from hair vertices */
 	LOOP_PARTICLES
 		totpoint += pa->totkey;
@@ -4101,11 +4096,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 	medge = CDDM_get_edges(dm);
 	dvert = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
 
-/* not supported yet for new solver */
-#if 0
 	psys->clmd->sim_parms->vgroup_mass = 1;
-#endif
-	
+
 	/* make vgroup for pin roots etc.. */
 	psys->particles->hair_index = 1;
 	LOOP_PARTICLES {
@@ -4168,26 +4160,21 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 	if (psys->hair_out_dm)
 		psys->hair_out_dm->release(psys->hair_out_dm);
 
-#if 0
 	psys->clmd->point_cache = psys->pointcache;
 	psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
-#endif
-	
+
 	deformedVerts = MEM_mallocN(sizeof(*deformedVerts) * dm->getNumVerts(dm), "do_hair_dynamics vertexCos");
 	psys->hair_out_dm = CDDM_copy(dm);
 	psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
 
-	//clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, deformedVerts);
+	clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, deformedVerts);
 
 	CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts);
 
 	MEM_freeN(deformedVerts);
 
-#if 0
 	psys->clmd->sim_parms->effector_weights = NULL;
-#endif
 }
-
 static void hair_step(ParticleSimulationData *sim, float cfra)
 {
 	ParticleSystem *psys = sim->psys;
@@ -4209,6 +4196,9 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
 	if (psys->recalc & PSYS_RECALC_RESET) {
 		/* need this for changing subsurf levels */
 		psys_calc_dmcache(sim->ob, sim->psmd->dm, psys);
+
+		if (psys->clmd)
+			cloth_free_modifier(psys->clmd);
 	}
 
 	/* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index c59b967b..063a81e 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2890,7 +2890,6 @@ int  BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
 			skip = 1;
 		/* Baked cloth hair has to be checked too, because we don't want to reset */
 		/* particles or cloth in that case -jahka */
-#if 0
 		else if (psys->clmd) {
 			BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd);
 			if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) 
@@ -2898,7 +2897,7 @@ int  BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
 			else
 				skip = 1;
 		}
-#endif
+
 		if (skip == 0 && psys->part) {
 			BKE_ptcache_id_from_particles(&pid, ob, psys);
 			reset |= BKE_ptcache_id_reset(scene, &pid, mode);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 923c2e9..e409ea2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3813,8 +3813,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
 			
 			psys->parent = newlibadr(fd, id->lib, psys->parent);
 			psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
-
-#if 0			
+			
 			if (psys->clmd) {
 				/* XXX - from reading existing code this seems correct but intended usage of
 				 * pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
@@ -3825,7 +3824,6 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
 				
 				psys->clmd->debug_data = NULL;
 			}
-#endif
 		}
 		else {
 			/* particle modifier must be removed before particle system */
@@ -3890,7 +3888,6 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
 		
 		direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache, 0);
 		
-#if 0
 		i

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list