[Bf-blender-cvs] [3ad7e5c] alembic: Optional force and jacobian return values from angular bending springs, for occasional debugging.

Lukas Tönne noreply at git.blender.org
Sun Apr 12 14:40:34 CEST 2015


Commit: 3ad7e5c1f2f4bc2d8c09e452a9c7790e37341fc3
Author: Lukas Tönne
Date:   Sat Apr 11 21:50:03 2015 +0200
Branches: alembic
https://developer.blender.org/rB3ad7e5c1f2f4bc2d8c09e452a9c7790e37341fc3

Optional force and jacobian return values from angular bending springs,
for occasional debugging.

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

M	source/blender/physics/intern/BPH_mass_spring.cpp
M	source/blender/physics/intern/implicit.h
M	source/blender/physics/intern/implicit_blender.c

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

diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index e0ec2c4..304e99e 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -420,7 +420,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
 		cb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
 		
 		/* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */
-		BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->target, kb, cb);
+		BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->target, kb, cb, NULL, NULL, NULL);
 		
 #if 0
 		{
@@ -1219,7 +1219,8 @@ static void strands_calc_curve_stretch_forces(Strands *strands, float UNUSED(spa
 		
 		float stiffness = params->stretch_stiffness;
 		float damping = stiffness * params->stretch_damping;
-		BPH_mass_spring_force_spring_linear(data, vi, vj, restlen, stiffness, damping, true, 0.0f, NULL, NULL, NULL);
+		float f[3];
+		BPH_mass_spring_force_spring_linear(data, vi, vj, restlen, stiffness, damping, true, 0.0f, f, NULL, NULL);
 	}
 }
 
@@ -1321,7 +1322,8 @@ static void strands_calc_curve_bending_forces(Strands *strands, float space[4][4
 			int vi = BKE_strand_bend_iter_vertex0_offset(strands, &it_bend);
 			int vj = BKE_strand_bend_iter_vertex1_offset(strands, &it_bend);
 			int vk = BKE_strand_bend_iter_vertex2_offset(strands, &it_bend);
-			BPH_mass_spring_force_spring_bending_angular(data, vi, vj, vk, target_state, stiffness, damping);
+			float f[3];
+			BPH_mass_spring_force_spring_bending_angular(data, vi, vj, vk, target_state, stiffness, damping, f, NULL, NULL);
 			
 #if 0 /* debug */
 			{
@@ -1393,7 +1395,8 @@ static void strands_calc_vertex_goal_forces(Strands *strands, float space[4][4],
 		float goal[3];
 		mul_v3_m4v3(goal, space, it_edge.vertex1->co);
 		
-		BPH_mass_spring_force_spring_goal(data, vj, goal, rootvel, stiffness, damping, NULL, NULL, NULL);
+		float f[3];
+		BPH_mass_spring_force_spring_goal(data, vj, goal, rootvel, stiffness, damping, f, NULL, NULL);
 	}
 }
 
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index fa3b642..6ef86d6 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -123,7 +123,8 @@ bool BPH_mass_spring_force_spring_bending(struct Implicit_Data *data, int i, int
                                           float r_f[3], float r_dfdx[3][3], float r_dfdv[3][3]);
 /* Angular bending force based on local target vectors */
 bool BPH_mass_spring_force_spring_bending_angular(struct Implicit_Data *data, int i, int j, int k,
-                                                  const float target[3], float stiffness, float damping);
+                                                  const float target[3], float stiffness, float damping,
+                                                  float r_f[3], float r_dfdx[3][3], float r_dfdv[3][3]);
 /* Global goal spring */
 bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3],
                                        float stiffness, float damping,
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 76adfe6..2b961b4 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -1857,7 +1857,8 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data, int i, int j,
  * See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
  */
 bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, int j, int k,
-                                                  const float target[3], float stiffness, float damping)
+                                                  const float target[3], float stiffness, float damping,
+                                                  float r_f[3], float r_dfdx[3][3], float r_dfdv[3][3])
 {
 	float goal[3];
 	float fj[3], fk[3];
@@ -1994,6 +1995,13 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, in
 	add_m3_m3m3(data->dFdX[block_ik].m, data->dFdX[block_ik].m, dfk_dxi);
 #endif
 	
+	if (r_f)
+		copy_v3_v3(r_f, fj);
+	if (r_dfdx)
+		copy_m3_m3(r_dfdx, dfj_dxj);
+	if (r_dfdv)
+		copy_m3_m3(r_dfdx, dfj_dvj);
+	
 	return true;
 }




More information about the Bf-blender-cvs mailing list