[Bf-blender-cvs] [b334d3a] hair_system: Hook up new solver settings to old particle code.

Antony Riakiotakis noreply at git.blender.org
Thu Aug 21 15:09:46 CEST 2014


Commit: b334d3a104b06bd2a507fa74ad82ad6d2acdfe1b
Author: Antony Riakiotakis
Date:   Thu Aug 21 15:09:33 2014 +0200
Branches: hair_system
https://developer.blender.org/rBb334d3a104b06bd2a507fa74ad82ad6d2acdfe1b

Hook up new solver settings to old particle code.

New settings are now exposed in UI and saved/loaded in blend files.
However the solver is not yet hooked up.

To make this work, all references to the old clothmodifier code have
been ifdefed out. This means that the particle simulation will currently
not do anything.

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

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/blenkernel/BKE_hair.h
M	source/blender/blenkernel/intern/hair.c
M	source/blender/blenkernel/intern/object.c
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/hair/HAIR_capi.h
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesrna/SConscript
M	source/blender/makesrna/intern/CMakeLists.txt
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 30fc3a9..4eb68a9 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -252,9 +252,8 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
 
 
 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
-    bl_label = "Hair dynamics"
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_RENDER'}
+    bl_label = "Hair Simulation"
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'CYCLES'}
 
     @classmethod
     def poll(cls, context):
@@ -272,35 +271,63 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-
         psys = context.particle_system
 
-        if not psys.cloth:
+        if not psys.params:
             return
 
-        cloth = psys.cloth.settings
+        params = psys.params
 
-        layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
+        layout.enabled = psys.use_hair_dynamics
 
         split = layout.split()
 
         col = split.column()
-        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)
+        col.prop(params, "substeps_forces")
 
         col = split.column()
-        col.label(text="Damping:")
-        sub = col.column(align=True)
-        sub.prop(cloth, "spring_damping", text="Spring")
-        sub.prop(cloth, "air_damping", text="Air")
+        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 = split.column()
+        col.prop(params, "stretch_damping")
+        col.prop(params, "bend_damping")
+
 
-        col.label(text="Quality:")
-        col.prop(cloth, "quality", text="Steps", slider=True)
+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):
diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index 1066e6a..06e577a 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -35,11 +35,14 @@ struct HairSystem;
 struct HairCurve;
 struct HairPoint;
 struct HairDebugData;
+struct HairParams;
 
 struct HairSystem *BKE_hairsys_new(void);
 void BKE_hairsys_free(struct HairSystem *hsys);
 struct HairSystem *BKE_hairsys_copy(struct HairSystem *hsys);
 
+void BKE_hairparams_init(struct HairParams *params);
+
 void BKE_hairsys_clear(struct HairSystem *hsys);
 
 struct HairCurve *BKE_hair_curve_add(struct HairSystem *hsys);
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 26bb68f..8eda84b 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -44,19 +44,23 @@
 
 #include "HAIR_capi.h"
 
-HairSystem *BKE_hairsys_new(void)
+void BKE_hairparams_init(HairParams *params)
 {
-	HairSystem *hsys = MEM_callocN(sizeof(HairSystem), "hair system");
-	HairParams *params = &hsys->params;
-	HairRenderSettings *render = &params->render;
-	
 	params->substeps_forces = 30;
 	params->substeps_damping = 10;
 	params->stretch_stiffness = 2000.0f;
 	params->stretch_damping = 10.0f;
 	params->bend_stiffness = 40.0f;
 	params->bend_damping = 10.0f;
+}
+
+HairSystem *BKE_hairsys_new(void)
+{
+	HairSystem *hsys = MEM_callocN(sizeof(HairSystem), "hair system");
+	HairParams *params = &hsys->params;
+	HairRenderSettings *render = &params->render;
 	
+	BKE_hairparams_init(params);
 	render->flag = HAIR_RENDER_CLOSE_TIP;
 	render->num_render_hairs = 100;
 	render->interpolation_steps = 4;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 4f2c3c0..8b3dde9 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1271,12 +1271,17 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
 		}
 	}
 
+#if 0
 	if (psys->clmd) {
 		psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
 		modifier_copyData((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd);
 		psys->hair_in_dm = psys->hair_out_dm = NULL;
 	}
+#endif
 
+	psysn->solver = NULL;
+	*psysn->params = *psys->params;
+	
 	BLI_duplicatelist(&psysn->targets, &psys->targets);
 
 	psysn->pathcache = NULL;
@@ -1295,9 +1300,11 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
 
 	/* XXX - from reading existing code this seems correct but intended usage of
 	 * pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
+#if 0
 	if (psysn->clmd) {
 		psysn->clmd->point_cache = psysn->pointcache;
 	}
+#endif
 
 	id_us_plus((ID *)psysn->part);
 
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index ecefec5..f598c59 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -82,6 +82,8 @@
 #include "BKE_scene.h"
 #include "BKE_deform.h"
 
+#include "HAIR_capi.h"
+
 #include "RE_render_ext.h"
 
 unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
@@ -403,6 +405,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
 
 	psys->flag &= ~PSYS_HAIR_DONE;
 
+#if 0
 	if (psys->clmd) {
 		if (dynamics) {
 			BKE_ptcache_free_list(&psys->ptcaches);
@@ -418,7 +421,17 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
 			cloth_free_modifier(psys->clmd);
 		}
 	}
-
+#endif
+	if (psys->solver) {
+		HAIR_solver_free(psys->solver);
+		psys->solver = NULL;
+	}
+	
+	if (psys->params) {
+		MEM_freeN(psys->params);
+		psys->params = NULL;
+	}
+	
 	if (psys->hair_in_dm)
 		psys->hair_in_dm->release(psys->hair_in_dm);
 	psys->hair_in_dm = NULL;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index e32b46f..8a47d24 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -48,6 +48,7 @@
 
 #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"
@@ -76,6 +77,7 @@
 #include "BKE_cdderivedmesh.h"
 #include "BKE_collision.h"
 #include "BKE_effect.h"
+#include "BKE_hair.h"
 #include "BKE_particle.h"
 #include "BKE_global.h"
 
@@ -90,6 +92,8 @@
 #include "BKE_scene.h"
 #include "BKE_bvhutils.h"
 
+#include "HAIR_capi.h"
+
 #include "PIL_time.h"
 
 #include "RE_shader_ext.h"
@@ -4009,12 +4013,23 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 	float hairmat[4][4];
 	float (*deformedVerts)[3];
 
+#if 0
 	if (!psys->clmd) {
 		psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
 		psys->clmd->sim_parms->goalspring = 0.0f;
 		psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
 		psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
 	}
+#endif
+	
+	if (!psys->solver) {
+		psys->solver = HAIR_solver_new();
+		
+		if (!psys->params) {
+			psys->params = MEM_callocN(sizeof(HairParams), "hair_params_particle");
+			BKE_hairparams_init(psys->params);
+		}
+	}
 
 	/* create a dm from hair vertices */
 	LOOP_PARTICLES
@@ -4037,8 +4052,11 @@ 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 {
@@ -4098,21 +4116,26 @@ 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;
@@ -4135,8 +4158,10 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
 		/* need this for changing subsurf levels */
 		psys_calc_dmcache(sim->ob, sim->psmd->dm, psys);
 
-		if (psys->clmd)
-			cloth_free_modifier(psys->clmd);
+		if (psys->solver) {
+			HAIR_solver_free(psys->solver);
+			psys->solver = NULL;
+		}
 	}
 
 	/* dynamics with clo

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list