Commit: bbae8f88b8f305a8ed85cab718d2a66b476da3c1
Author: Lukas Tönne
Date:   Wed Sep 17 14:21:06 2014 +0200
Branches: master
https://developer.blender.org/rBbbae8f88b8f305a8ed85cab718d2a66b476da3c1

Made the voxel grid size for hair interaction configurable and increased
the default to 32.

Conflicts:
        source/blender/blenloader/intern/versioning_270.c

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

M       release/scripts/startup/bl_ui/properties_particle.py
M       source/blender/blenkernel/intern/cloth.c
M       source/blender/blenloader/intern/versioning_270.c
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.c
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 87a772e..8afd2d0 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -320,6 +320,10 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, 
Panel):
         sub.prop(cloth, "pressure", slider=True)
         sub.prop(cloth, "pressure_threshold", slider=True)
 
+        sub.separator()
+        
+        sub.prop(cloth, "voxel_resolution")
+
         col = split.column()
         col.label(text="Damping:")
         sub = col.column(align=True)
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index 9fb42d5..4132fc8 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -132,6 +132,8 @@ void cloth_init(ClothModifierData *clmd )
        clmd->sim_parms->goalfrict = 0.0f;
        clmd->sim_parms->velocity_smooth = 0.0f;
 
+       clmd->sim_parms->voxel_res = 32;
+
        if (!clmd->sim_parms->effector_weights)
                clmd->sim_parms->effector_weights = 
BKE_add_effector_weights(NULL);
 
diff --git a/source/blender/blenloader/intern/versioning_270.c 
b/source/blender/blenloader/intern/versioning_270.c
index bde3f0f..3ffde3f 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -472,4 +472,23 @@ void blo_do_versions_270(FileData *fd, Library 
*UNUSED(lib), Main *main)
                        }
                }
        }
+
+       if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "int", 
"voxel_res")) {
+               Object *ob;
+               ModifierData *md;
+               for (ob = main->object.first; ob; ob = ob->id.next) {
+                       for (md = ob->modifiers.first; md; md = md->next) {
+                               if (md->type == eModifierType_Cloth) {
+                                       ClothModifierData *clmd = 
(ClothModifierData*) md;
+                                       clmd->sim_parms->voxel_res = 32;
+                               }
+                               else if (md->type == 
eModifierType_ParticleSystem) {
+                                       ParticleSystemModifierData *pmd = 
(ParticleSystemModifierData*) md;
+                                       if (pmd->psys->clmd) {
+                                               
pmd->psys->clmd->sim_parms->voxel_res = 32;
+                                       }
+                               }
+                       }
+               }
+       }
 }
diff --git a/source/blender/makesdna/DNA_cloth_types.h 
b/source/blender/makesdna/DNA_cloth_types.h
index 4d862e4..c7eee96 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -75,6 +75,7 @@ typedef struct ClothSimSettings {
        float   vel_damping; /* damp the velocity to speed up getting to the 
resting position */
        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) */
+       int             voxel_res;   /* resolution of voxel grid for 
interaction */
 
        int     stepsPerFrame;  /* Number of time steps per frame.              
*/
        int     flags;          /* flags, see CSIMSETT_FLAGS enum above.        
*/
@@ -88,7 +89,6 @@ typedef struct ClothSimSettings {
        short   shapekey_rest;  /* vertex group for scaling structural 
stiffness */
        short   presets; /* used for presets on GUI */
        short   reset;
-       char    pad[4];
 
        struct EffectorWeights *effector_weights;
 } ClothSimSettings;
diff --git a/source/blender/makesrna/intern/rna_cloth.c 
b/source/blender/makesrna/intern/rna_cloth.c
index 5d911dd..8528a66 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -410,6 +410,13 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Shrink Factor Max", "Max amount to 
shrink cloth by");
        RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+       prop = RNA_def_property(srna, "voxel_resolution", PROP_INT, 
PROP_UNSIGNED);
+       RNA_def_property_int_sdna(prop, NULL, "voxel_res");
+       RNA_def_property_range(prop, 1, 128);
+       RNA_def_property_int_default(prop, 32);
+       RNA_def_property_ui_text(prop, "Voxel Grid Resolution", "Resolution of 
the voxel grid for interaction effects");
+       RNA_def_property_update(prop, 0, "rna_cloth_update");
+
        /* springs */
 
        prop = RNA_def_property(srna, "use_stiffness_scale", PROP_BOOLEAN, 
PROP_NONE);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index e910739..0fa14fa 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -421,7 +421,7 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
        
        /* gather velocities & density */
        if (smoothfac > 0.0f || pressfac > 0.0f) {
-               HairVertexGrid *vertex_grid = 
BPH_hair_volume_create_vertex_grid(gmin, gmax);
+               HairVertexGrid *vertex_grid = 
BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_res, gmin, gmax);
                
                for (i = 0; i < numverts; i++) {
                        float x[3], v[3];
diff --git a/source/blender/physics/intern/hair_volume.c 
b/source/blender/physics/intern/hair_volume.c
index c129f02..2d5efa8 100644
--- a/source/blender/physics/intern/hair_volume.c
+++ b/source/blender/physics/intern/hair_volume.c
@@ -57,9 +57,6 @@
 
 static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
 
-/* 10x10x10 grid gives nice initial results */
-static const int hair_grid_res = 10;
-
 static int hair_grid_size(int res)
 {
        return res * res * res;
@@ -296,9 +293,8 @@ void BPH_hair_volume_normalize_vertex_grid(HairVertexGrid 
*grid)
        }
 }
 
-HairVertexGrid *BPH_hair_volume_create_vertex_grid(const float gmin[3], const 
float gmax[3])
+HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float 
gmin[3], const float gmax[3])
 {
-       int res = hair_grid_res;
        int size = hair_grid_size(res);
        HairVertexGrid *grid;
        int                 i = 0;
diff --git a/source/blender/physics/intern/implicit.h 
b/source/blender/physics/intern/implicit.h
index 66ee92f..28c4cbc 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -150,7 +150,7 @@ bool BPH_mass_spring_force_spring_goal(struct Implicit_Data 
*data, int i, int sp
 struct HairVertexGrid;
 struct HairColliderGrid;
 
-struct HairVertexGrid *BPH_hair_volume_create_vertex_grid(const float gmin[3], 
const float gmax[3]);
+struct HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float 
gmin[3], const float gmax[3]);
 void BPH_hair_volume_free_vertex_grid(struct HairVertexGrid *grid);
 
 void BPH_hair_volume_add_vertex(struct HairVertexGrid *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