Commit: 63663f00dc0eb75e9ed046a5e364789daf0a3d10
Author: Lukas Tönne
Date:   Fri Nov 14 14:45:46 2014 +0100
Branches: hair_immediate_fixes
https://developer.blender.org/rB63663f00dc0eb75e9ed046a5e364789daf0a3d10

A bunch of debug drawing changes.

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

M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/physics/intern/BPH_mass_spring.cpp
M       source/blender/physics/intern/hair_volume.cpp

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

diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 53fdf03..25d6de3 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -569,7 +569,7 @@ typedef struct ClothModifierData {
        float hair_grid_min[3];
        float hair_grid_max[3];
        int hair_grid_res[3];
-       int pad;
+       float hair_grid_cellsize;
        
        struct ClothSolverResult *solver_result;
        
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index bdc4ced..61122a1 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -884,6 +884,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, 
float dt)
        zero_v3_int(clmd->hair_grid_res);
        zero_v3(clmd->hair_grid_min);
        zero_v3(clmd->hair_grid_max);
+       clmd->hair_grid_cellsize = 0.0f;
        
        hair_get_boundbox(clmd, gmin, gmax);
        
@@ -917,7 +918,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, 
float dt)
                }
                
                /* store basic grid info in the modifier data */
-               BPH_hair_volume_grid_geometry(grid, NULL, clmd->hair_grid_res, 
clmd->hair_grid_min, clmd->hair_grid_max);
+               BPH_hair_volume_grid_geometry(grid, &clmd->hair_grid_cellsize, 
clmd->hair_grid_res, clmd->hair_grid_min, clmd->hair_grid_max);
                
 #if 0 /* DEBUG hair velocity vector field */
                {
@@ -925,13 +926,13 @@ static void cloth_continuum_step(ClothModifierData *clmd, 
float dt)
                        int i, j;
                        float offset[3], a[3], b[3];
                        const int axis = 0;
-                       const float shift = 0.45f;
+                       const float shift = 0.0f;
                        
                        copy_v3_v3(offset, clmd->hair_grid_min);
                        zero_v3(a);
                        zero_v3(b);
                        
-                       offset[axis] = interpf(clmd->hair_grid_max[axis], 
clmd->hair_grid_min[axis], shift);
+                       offset[axis] = shift * clmd->hair_grid_cellsize;
                        a[(axis+1) % 3] = clmd->hair_grid_max[(axis+1) % 3] - 
clmd->hair_grid_min[(axis+1) % 3];
                        b[(axis+2) % 3] = clmd->hair_grid_max[(axis+2) % 3] - 
clmd->hair_grid_min[(axis+2) % 3];
                        
@@ -948,10 +949,23 @@ static void cloth_continuum_step(ClothModifierData *clmd, 
float dt)
                                        
 //                                     
BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity, 0.7, 0.3, 1, "grid 
density", hash_int_2d(hash_int_2d(i, j), 3111));
                                        if (!is_zero_v3(gvel) || 
!is_zero_v3(gvel_smooth)) {
-                                               
BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel, 0.4, 0, 1, "grid 
velocity", hash_int_2d(hash_int_2d(i, j), 3112));
-                                               
BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel_smooth, 0.6, 4, 1, 
"grid velocity", hash_int_2d(hash_int_2d(i, j), 3113));
-                                               if (gdensity > 0.0f)
-                                                       
BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * 
clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", hash_int_2d(354, 
hash_int_2d(i, j)));
+                                               float dvel[3];
+                                               sub_v3_v3v3(dvel, gvel_smooth, 
gvel);
+//                                             
BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel, 0.4, 0, 1, "grid 
velocity", hash_int_2d(hash_int_2d(i, j), 3112));
+//                                             
BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel_smooth, 0.6, 1, 1, 
"grid velocity", hash_int_2d(hash_int_2d(i, j), 3113));
+                                               
BKE_sim_debug_data_add_vector(clmd->debug_data, x, dvel, 0.4, 1, 0.7, "grid 
velocity", hash_int_2d(hash_int_2d(i, j), 3114));
+#if 0
+                                               if (gdensity > 0.0f) {
+                                                       float col0[3] = {0.0, 
0.0, 0.0};
+                                                       float col1[3] = {0.0, 
1.0, 0.0};
+                                                       float col[3];
+                                                       
+                                                       interp_v3_v3v3(col, 
col0, col1, CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
+//                                                     
BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * 
clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", 
hash_int_2d(hash_int_2d(i, j), 3115));
+//                                                     
BKE_sim_debug_data_add_dot(clmd->debug_data, x, col[0], col[1], col[2], "grid 
velocity", hash_int_2d(hash_int_2d(i, j), 3115));
+                                                       
BKE_sim_debug_data_add_circle(clmd->debug_data, x, 0.01f, col[0], col[1], 
col[2], "grid velocity", hash_int_2d(hash_int_2d(i, j), 3115));
+                                               }
+#endif
                                        }
                                }
                        }
diff --git a/source/blender/physics/intern/hair_volume.cpp 
b/source/blender/physics/intern/hair_volume.cpp
index 49b8af4..972571a 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -384,7 +384,6 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
                                            HairGridVert *vert, int stride_j, 
int stride_k, const float loc[3], int axis_j, int axis_k,
                                            int debug_i)
 {
-       SimDebugData *debug_data = grid->debug_data;
        const float radius = 1.5f;
        const float dist_scale = grid->inv_cellsize;
        
@@ -408,22 +407,23 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
                        
                        hair_volume_eval_grid_vertex(vert_k, loc_k, radius, 
dist_scale, x2, v2, x3, v3);
                        
-#if 1
+#if 0
                        {
+                               SimDebugData *debug_data = grid->debug_data;
                                float wloc[3], x2w[3], x3w[3];
                                grid_to_world(grid, wloc, loc_k);
                                grid_to_world(grid, x2w, x2);
                                grid_to_world(grid, x3w, x3);
                                
                                if (vert_k->samples > 0)
-                                       
BKE_sim_debug_data_add_circle(debug_data, wloc, 0.01f, 1.0, 1.0, 0.3, "blah", 
hash_vertex(2525, hash_int_2d(debug_i, hash_int_2d(j, k))));
+                                       
BKE_sim_debug_data_add_circle(debug_data, wloc, 0.01f, 1.0, 1.0, 0.3, "grid", 
hash_vertex(2525, hash_int_2d(debug_i, hash_int_2d(j, k))));
                                
                                if (grid->debug_value) {
-                                       BKE_sim_debug_data_add_dot(debug_data, 
wloc, 1, 0, 0, "blah", hash_vertex(93, hash_int_2d(debug_i, hash_int_2d(j, 
k))));
-                                       BKE_sim_debug_data_add_dot(debug_data, 
x2w, 0.1, 0.1, 0.7, "blah", hash_vertex(649, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
-                                       BKE_sim_debug_data_add_line(debug_data, 
wloc, x2w, 0.3, 0.8, 0.3, "blah", hash_vertex(253, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
-                                       BKE_sim_debug_data_add_line(debug_data, 
wloc, x3w, 0.8, 0.3, 0.3, "blah", hash_vertex(254, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
-//                                     
BKE_sim_debug_data_add_circle(debug_data, x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 
0.2, "blah", hash_vertex(255, hash_int_2d(i, hash_int_2d(j, k))));
+                                       BKE_sim_debug_data_add_dot(debug_data, 
wloc, 1, 0, 0, "grid", hash_vertex(93, hash_int_2d(debug_i, hash_int_2d(j, 
k))));
+                                       BKE_sim_debug_data_add_dot(debug_data, 
x2w, 0.1, 0.1, 0.7, "grid", hash_vertex(649, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
+                                       BKE_sim_debug_data_add_line(debug_data, 
wloc, x2w, 0.3, 0.8, 0.3, "grid", hash_vertex(253, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
+                                       BKE_sim_debug_data_add_line(debug_data, 
wloc, x3w, 0.8, 0.3, 0.3, "grid", hash_vertex(254, hash_int_2d(debug_i, 
hash_int_2d(j, k))));
+//                                     
BKE_sim_debug_data_add_circle(debug_data, x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 
0.2, "grid", hash_vertex(255, hash_int_2d(i, hash_int_2d(j, k))));
                                }
                        }
 #endif
@@ -687,6 +687,33 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, 
float dt, float target_den
                                 * however, this is already included in the 
weighting of hair velocities on the grid!
                                 */
                                B[u] = divergence + target;
+                               
+#if 0
+                               {
+                                       float wloc[3], loc[3];
+                                       float col0[3] = {0.0, 0.0, 0.0};
+                                       float colp[3] = {0.0, 1.0, 1.0};
+                                       float coln[3] = {1.0, 0.0, 1.0};
+                                       float col[3];
+                                       float fac;
+                                       
+                                       loc[0] = (float)(i - 1);
+                                       loc[1] = (float)(j - 1);
+                                       loc[2] = (float)(k - 1);
+                                       grid_to_world(grid, wloc, loc);
+                                       
+                                       if (divergence > 0.0f) {
+                                               fac = CLAMPIS(divergence * 
target_strength, 0.0, 1.0);
+                                               interp_v3_v3v3(col, col0, colp, 
fac);
+                                       }
+                                       else {
+                                               fac = CLAMPIS(-divergence * 
target_strength, 0.0, 1.0);
+                                               interp_v3_v3v3(col, col0, coln, 
fac);
+                                       }
+                                       if (fac > 0.05f)
+                                               
BKE_sim_debug_data_add_circle(grid->debug_data, wloc, 0.01f, col[0], col[1], 
col[2], "grid", hash_int_2d(5522, hash_int_2d(i, hash_int_2d(j, k))));
+                               }
+#endif
                        }
                }
        }
@@ -762,6 +789,63 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, 
float dt, float target_den
        lVector p = cg.solve(B);
        
        if (cg.info() == Eigen::Success) {
+#if 0
+               {
+                       int axis = 0;
+                       float offset = 0.0f;
+                       
+                       int slice = (offset - grid->gmin[axis]) / 
grid->cellsize;
+                       
+                       for (k = 0; k < resA[2]; ++k) {
+                               for (j = 0; j < resA[1]; ++j) {
+                                       for (i = 0; i < resA[0]; ++i) {
+                                               int u = i * strideA0 + j * 
strideA1 + k * strideA2;
+                                               bool is_margin = MARGIN_i0 || 
MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
+//                                             if (i != slice)
+//                                                     continue;
+                                               
+                                               vert = vert_start + i * stride0 
+ j * stride1 + k * stride2;
+                                               
+                                               float wloc[3], loc[3];
+                                               float col0[3] = {0.0, 0.0, 0.0};
+                                               float colp[3] = {0.0, 1.0, 1.0};
+                                               float coln[3] = {1.0, 0.0, 1.0};
+                                               float col[3];
+                                               float fac;
+                                               
+                                               loc[0] = (float)(i - 1);
+                                               loc[1] = (float)(j - 1);
+                                               loc[2] = (float)(k - 1);
+                                               grid_to_world(grid, wloc, loc);
+                                               
+                                               float pressure = p[u];
+                                               if (pressure > 0.0f) {
+                                                       fac = CLAMPIS(pressure 
* target_strength, 0.0, 1.0);
+                                                       interp_v3_v3v3(col, 
col0, colp, fac);
+                                               }
+                                               else {
+                                                       fac = CLAMPIS(-pressure 
* target_strength, 0.0, 1.0);
+                                                       interp_v3_v3v3(col, 
col0, coln, fac);
+                                               }
+                                               if (fac > 0.05f)
+                                                       
BKE_sim_debug_data_add_circle(grid->debug_data, wloc, 0.01f, col[0], col[1], 
col[2], "grid", hash_int_2d(5533, hash_int_2d(i, hash_int_2d(j, k))));
+                                               
+                                               if (!is_margin) {
+                                                       float d = 
CLAMPIS(vert->density * target_density, 0.0f, 1.0f);
+                                                       float col0[3] = {0.3, 
0.3, 0.3};
+                                                       float colp[3] = {0.0, 
0.0, 1.0};
+                                                       float col[3];
+                                                       
+                                                       interp_v3_v3v3(col, 
col0, colp, d);
+                                                       if (d > 0.05f)
+                                                               
BKE_sim_debug_data_add_dot(grid->debug_data, wloc, col[0], col[1], col[2], 
"grid", hash_int_2d(5544, hash_int_2d(i, hash_int_2d(j, k))));
+                                               }
+                                       }
+                               }
+                       }
+               }
+#endif
+               
                /* Calculate velocity = grad(p) */
                for (k = 0; k < resA[2]; ++k) {
                        for (j = 0; j < resA[1]; ++j) {
@@ -946,6 +1030,7 @@ void BPH_hair_volume_free_vertex_grid(HairGrid *grid)
 void BPH_hair_volume_set_debug_data(HairGrid *grid, SimDebugData *debug_data)
 {
        grid->debug_data = debug_data;
+       BKE_sim_debug_data_

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to