[Bf-blender-cvs] [62b94e2] hair_system: Skeleton solver update function (most parts disabled).

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


Commit: 62b94e25779a6b81c14da4423e9f0815c7b79396
Author: Lukas Tönne
Date:   Sat Oct 4 12:54:00 2014 +0200
Branches: hair_system
https://developer.blender.org/rB62b94e25779a6b81c14da4423e9f0815c7b79396

Skeleton solver update function (most parts disabled).

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

M	release/scripts/startup/bl_ui/properties_physics_hair.py
M	source/blender/blenkernel/intern/hair.c
M	source/blender/makesdna/DNA_hair_types.h
M	source/blender/makesrna/intern/rna_hair.c
M	source/blender/physics/intern/BPH_mass_spring.cpp

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_hair.py b/release/scripts/startup/bl_ui/properties_physics_hair.py
index 8ed57a8..763c489 100644
--- a/release/scripts/startup/bl_ui/properties_physics_hair.py
+++ b/release/scripts/startup/bl_ui/properties_physics_hair.py
@@ -59,11 +59,7 @@ class PHYSICS_PT_hair_simulation(PhysicButtonsPanel, Panel):
 
         split = layout.split()
 
-        col = split.column()
-        col.prop(params, "substeps_forces")
-
-        col = split.column()
-        col.prop(params, "substeps_damping")
+        split.prop(params, "substeps")
 
         split = layout.split()
 
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index fffe778..67c1bee 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -47,8 +47,7 @@
 
 void BKE_hair_params_init(HairParams *params)
 {
-	params->substeps_forces = 30;
-	params->substeps_damping = 10;
+	params->substeps = 5;
 	params->stretch_stiffness = 2000.0f;
 	params->stretch_damping = 10.0f;
 	params->bend_stiffness = 40.0f;
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index 6d67ee6..ff1ce0a 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -76,8 +76,7 @@ typedef enum eHairRenderSettings_Flag {
 } eHairRenderSettings_Flag;
 
 typedef struct HairParams {
-	int substeps_forces;
-	int substeps_damping;
+	int substeps;
 	
 	float stretch_stiffness;
 	float stretch_damping;
@@ -91,7 +90,6 @@ typedef struct HairParams {
 	float restitution;
 	float friction;
 	float margin;
-	int pad;
 	
 	struct EffectorWeights *effector_weights;
 	
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index eab255a..abb5813 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -224,19 +224,12 @@ static void rna_def_hair_params(BlenderRNA *brna)
 	srna = RNA_def_struct(brna, "HairParams", NULL);
 	RNA_def_struct_ui_text(srna, "Hair Parameters", "Hair simulation parameters");
 
-	prop = RNA_def_property(srna, "substeps_forces", PROP_INT, PROP_UNSIGNED);
-	RNA_def_property_int_sdna(prop, NULL, "substeps_forces");
+	prop = RNA_def_property(srna, "substeps", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_int_sdna(prop, NULL, "substeps");
 	RNA_def_property_range(prop, 1, 1000);
 	RNA_def_property_ui_range(prop, 1, 120, 1, 1);
-	RNA_def_property_int_default(prop, 30);
-	RNA_def_property_ui_text(prop, "Substeps Forces", "Substeps for force integration");
-
-	prop = RNA_def_property(srna, "substeps_damping", PROP_INT, PROP_UNSIGNED);
-	RNA_def_property_int_sdna(prop, NULL, "substeps_damping");
-	RNA_def_property_range(prop, 1, 100);
-	RNA_def_property_ui_range(prop, 1, 30, 1, 1);
-	RNA_def_property_int_default(prop, 10);
-	RNA_def_property_ui_text(prop, "Substeps Damping", "Substeps for damping force integration (on top of force substeps)");
+	RNA_def_property_int_default(prop, 5);
+	RNA_def_property_ui_text(prop, "Substeps", "Substeps per frame");
 
 	prop = RNA_def_property(srna, "stretch_stiffness", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "stretch_stiffness");
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index fd79639..3487aa9 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -836,7 +836,83 @@ void BPH_hair_solver_set_positions(HairSolverData *data, Scene *scene, Object *o
 
 void BPH_hair_solve(struct HairSolverData *data, HairParams *params, float time, float timestep, SimDebugData *debug_data)
 {
-	// XXX TODO
+	float dt = timestep / (float)params->substeps;
+	int s;
+	ColliderContacts *contacts = NULL;
+	int totcolliders = 0;
+	
+//	BPH_mass_spring_solver_debug_data(id, clmd->debug_data);
+	
+//	BKE_sim_debug_data_clear_category(clmd->debug_data, "collision");
+	
+//	if (!clmd->solver_result)
+//		clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result");
+//	cloth_clear_result(clmd);
+	
+#if 0
+	if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */
+		for (i = 0; i < numverts; i++) {
+			// update velocities with constrained velocities from pinned verts
+			if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
+				float v[3];
+				sub_v3_v3v3(v, verts[i].xconst, verts[i].xold);
+				// mul_v3_fl(v, clmd->sim_parms->stepsPerFrame);
+				BPH_mass_spring_set_velocity(id, i, v);
+			}
+		}
+	}
+#endif
+	
+	for (s = 0; s < params->substeps; ++s, time += dt) {
+		ImplicitSolverResult result;
+		
+		/* initialize forces to zero */
+		BPH_mass_spring_clear_forces(data->id);
+		BPH_mass_spring_clear_constraints(data->id);
+		
+#if 0
+		/* determine contact points */
+		if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
+			if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_POINTS) {
+				cloth_find_point_contacts(ob, clmd, 0.0f, tf, &contacts, &totcolliders);
+			}
+		}
+		
+		/* setup vertex constraints for pinned vertices and contacts */
+		cloth_setup_constraints(clmd, contacts, totcolliders, dt);
+#endif
+		
+		// calculate forces
+//		cloth_calc_force(clmd, frame, effectors, step);
+		
+		// calculate new velocity and position
+		BPH_mass_spring_solve(data->id, dt, &result);
+//		cloth_record_result(clmd, &result, clmd->sim_parms->stepsPerFrame);
+		
+		BPH_mass_spring_apply_result(data->id);
+		
+#if 0
+		/* move pinned verts to correct position */
+		for (i = 0; i < numverts; i++) {
+			if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) {
+				if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
+					float x[3];
+					interp_v3_v3v3(x, verts[i].xold, verts[i].xconst, step + dt);
+					BPH_mass_spring_set_position(id, i, x);
+				}
+			}
+			
+			BPH_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
+		}
+#endif
+		
+		/* free contact points */
+		if (contacts) {
+			cloth_free_contacts(contacts, totcolliders);
+		}
+	}
+	
+//	BPH_mass_spring_solver_debug_data(id, NULL);
 }
 
 void BPH_hair_solver_apply_positions(HairSolverData *data, Scene *scene, Object *ob, HairSystem *hsys)




More information about the Bf-blender-cvs mailing list