Commit: 7289f36a59df013e0238684bfeb11954c1cca3ba
Author: Lukas Tönne
Date:   Fri Nov 14 16:48:01 2014 +0100
Branches: hair_immediate_fixes
https://developer.blender.org/rB7289f36a59df013e0238684bfeb11954c1cca3ba

Use dedicated debug values in cloth settings instead of abusing unused
other values.

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

M       release/scripts/startup/bl_ui/properties_particle.py
M       source/blender/makesdna/DNA_cloth_types.h
M       source/blender/makesrna/intern/rna_cloth.c
M       source/blender/physics/intern/BPH_mass_spring.cpp
M       source/blender/physics/intern/hair_volume.cpp
M       source/blender/physics/intern/implicit.h

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

diff --git a/release/scripts/startup/bl_ui/properties_particle.py 
b/release/scripts/startup/bl_ui/properties_particle.py
index 7e42ad9..0bb779a 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -308,6 +308,11 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, 
Panel):
         sub.prop(cloth, "density_target", text="Density Target")
         sub.prop(cloth, "density_strength", slider=True, text="Strength")
         col.prop(cloth, "voxel_cell_size")
+        sub = col.column(align=True)
+        sub.prop(cloth, "debug1")
+        sub.prop(cloth, "debug2")
+        sub.prop(cloth, "debug3")
+        sub.prop(cloth, "debug4")
 
         split.separator()
 
diff --git a/source/blender/makesdna/DNA_cloth_types.h 
b/source/blender/makesdna/DNA_cloth_types.h
index 3144dad..a665c22 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -76,6 +76,12 @@ typedef struct ClothSimSettings {
        float   shrink_min;  /* min amount to shrink cloth by 0.0f (no shrink) 
- 1.0f (shrink to nothing) */
        float   shrink_max;  /* max amount to shrink cloth by 0.0f (no shrink) 
- 1.0f (shrink to nothing) */
        
+       /* XXX generic debug values, could be done nicer as id props */
+       float debug1;
+       float debug2;
+       int debug3;
+       int debug4;
+       
        /* XXX various hair stuff
         * should really be separate, this struct is a horrible mess already
         */
diff --git a/source/blender/makesrna/intern/rna_cloth.c 
b/source/blender/makesrna/intern/rna_cloth.c
index c312870..dced2e8 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -397,6 +397,26 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Target Density Strength", "Influence of 
target density on the simulation");
        RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+       prop = RNA_def_property(srna, "debug1", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0.0f, 1000000.0f);
+       RNA_def_property_ui_text(prop, "Debug1", "");
+       RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+       prop = RNA_def_property(srna, "debug2", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0.0f, 1000000.0f);
+       RNA_def_property_ui_text(prop, "Debug2", "");
+       RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+       prop = RNA_def_property(srna, "debug3", PROP_INT, PROP_NONE);
+       RNA_def_property_range(prop, 0.0f, 1000000.0f);
+       RNA_def_property_ui_text(prop, "Debug3", "");
+       RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+       prop = RNA_def_property(srna, "debug4", PROP_INT, PROP_NONE);
+       RNA_def_property_range(prop, 0.0f, 1000000.0f);
+       RNA_def_property_ui_text(prop, "Debug4", "");
+       RNA_def_property_update(prop, 0, "rna_cloth_update");
+
        /* mass */
 
        prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index c4407d2..39998fe 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -869,7 +869,9 @@ static void cloth_continuum_step(ClothModifierData *clmd, 
float dt)
        /* gather velocities & density */
        if (smoothfac > 0.0f || densfac > 0.0f) {
                HairGrid *grid = 
BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, 
gmax);
+               
                BPH_hair_volume_set_debug_data(grid, clmd->debug_data);
+               BPH_hair_volume_set_debug_value(grid, parms->debug1, 
parms->debug2, parms->debug3, parms->debug4);
                
 //             BPH_hair_volume_set_debug_value(grid, (int)(spring2->ij == 
clmd->sim_parms->density_target));
                cloth_continuum_fill_grid(grid, cloth);
diff --git a/source/blender/physics/intern/hair_volume.cpp 
b/source/blender/physics/intern/hair_volume.cpp
index 5b885cd..4f2f6a3 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -93,7 +93,8 @@ typedef struct HairGrid {
        float cellsize, inv_cellsize;
        
        struct SimDebugData *debug_data;
-       int debug_value;
+       float debug1, debug2;
+       int debug3, debug4;
 } HairGrid;
 
 #define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) ( min_ii( max_ii( 
(int)((vec[axis] - gmin[axis]) * scale), 0), res[axis]-2 ) )
@@ -371,11 +372,6 @@ BLI_INLINE int major_axis_v3(const float v[3])
        return a > b ? (a > c ? 0 : 2) : (b > c ? 1 : 2);
 }
 
-void BPH_hair_volume_set_debug_value(HairGrid *grid, int debug_value)
-{
-       grid->debug_value = debug_value;
-}
-
 BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
                                            const float UNUSED(x1[3]), const 
float UNUSED(v1[3]), const float x2[3], const float v2[3],
                                            const float x3[3], const float 
v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
@@ -855,11 +851,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, 
float dt, float target_den
                                                
                                                float pressure = p[u];
                                                if (pressure > 0.0f) {
-                                                       fac = CLAMPIS(pressure 
* target_strength, 0.0, 1.0);
+                                                       fac = CLAMPIS(pressure 
* grid->debug1, 0.0, 1.0);
                                                        interp_v3_v3v3(col, 
col0, colp, fac);
                                                }
                                                else {
-                                                       fac = CLAMPIS(-pressure 
* target_strength, 0.0, 1.0);
+                                                       fac = CLAMPIS(-pressure 
* grid->debug1, 0.0, 1.0);
                                                        interp_v3_v3v3(col, 
col0, coln, fac);
                                                }
                                                if (fac > 0.05f)
@@ -868,11 +864,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, 
float dt, float target_den
                                                if (!is_margin) {
                                                        float dvel[3];
                                                        sub_v3_v3v3(dvel, 
vert->velocity_smooth, vert->velocity);
-                                                       
BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 
hash_int_2d(5566, hash_int_2d(i, hash_int_2d(j, k))));
+//                                                     
BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 
hash_int_2d(5566, hash_int_2d(i, hash_int_2d(j, k))));
                                                }
                                                
                                                if (!is_margin) {
-                                                       float d = 
CLAMPIS(vert->density * target_density, 0.0f, 1.0f);
+                                                       float d = 
CLAMPIS(vert->density * grid->debug2, 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];
@@ -1039,6 +1035,14 @@ void BPH_hair_volume_set_debug_data(HairGrid *grid, 
SimDebugData *debug_data)
        BKE_sim_debug_data_clear_category(grid->debug_data, "grid");
 }
 
+void BPH_hair_volume_set_debug_value(HairGrid *grid, float debug1, float 
debug2, int debug3, int debug4)
+{
+       grid->debug1 = debug1;
+       grid->debug2 = debug2;
+       grid->debug3 = debug3;
+       grid->debug4 = debug4;
+}
+
 void BPH_hair_volume_grid_geometry(HairGrid *grid, float *cellsize, int 
res[3], float gmin[3], float gmax[3])
 {
        if (cellsize) *cellsize = grid->cellsize;
diff --git a/source/blender/physics/intern/implicit.h 
b/source/blender/physics/intern/implicit.h
index 246b916..e4c90c2 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -174,9 +174,9 @@ struct VoxelData;
 
 struct HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const 
float gmin[3], const float gmax[3]);
 void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid);
-void BPH_hair_volume_set_debug_data(struct HairGrid *grid, struct SimDebugData 
*debug_data);
 void BPH_hair_volume_grid_geometry(struct HairGrid *grid, float *cellsize, int 
res[3], float gmin[3], float gmax[3]);
-void BPH_hair_volume_set_debug_value(struct HairGrid *grid, int debug_value);
+void BPH_hair_volume_set_debug_data(struct HairGrid *grid, struct SimDebugData 
*debug_data);
+void BPH_hair_volume_set_debug_value(struct HairGrid *grid, float debug1, 
float debug2, int debug3, int debug4);
 
 void BPH_hair_volume_grid_clear(struct HairGrid *grid);
 void BPH_hair_volume_add_vertex(struct HairGrid *grid, const float x[3], const 
float v[3]);

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

Reply via email to