Made the voxel grid size for hair interaction configurable and increased

the default to 32.

Conflicts:
	source/blender/blenloader/intern/versioning_270.c
This commit is contained in:
Lukas Tönne 2014-09-17 14:21:06 +02:00
parent be016daf15
commit bbae8f88b8
8 changed files with 36 additions and 8 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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;
}
}
}
}
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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];

View File

@ -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;

View File

@ -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]);