Fix T73304: Crash using force fields and hair dynamics
This implements a better heuristic for identifying if cloth or hair is being dealt with (checking hairdata, instead of primitive_num). The issue was caused by a change in primitive counting in rBd42a7bbd6ea5 I'm also adding some safeguards to avoid ever computing pressure for hair. This shouldn't really be necessary, but it's good to be sure.
This commit is contained in:
@@ -82,6 +82,11 @@ static float cloth_calc_volume(ClothModifierData *clmd)
|
||||
Implicit_Data *data = cloth->implicit;
|
||||
float vol = 0;
|
||||
|
||||
/* Early exit for hair, as it never has volume. */
|
||||
if (clmd->hairdata) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (clmd->sim_parms->vgroup_pressure > 0) {
|
||||
for (unsigned int i = 0; i < cloth->primitive_num; i++) {
|
||||
bool skip_face = false;
|
||||
@@ -547,8 +552,8 @@ static void cloth_calc_force(
|
||||
#ifdef CLOTH_FORCE_DRAG
|
||||
BPH_mass_spring_force_drag(data, drag);
|
||||
#endif
|
||||
/* handle pressure forces */
|
||||
if (parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) {
|
||||
/* handle pressure forces (making sure that this never gets computed for hair). */
|
||||
if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == NULL)) {
|
||||
/* The difference in pressure between the inside and outside of the mesh.*/
|
||||
float pressure_difference = 0.0f;
|
||||
|
||||
@@ -634,13 +639,14 @@ static void cloth_calc_force(
|
||||
effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < cloth->primitive_num; i++) {
|
||||
const MVertTri *vt = &tri[i];
|
||||
BPH_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec);
|
||||
/* Hair has only edges. */
|
||||
if ((clmd->hairdata == NULL) && (cloth->primitive_num > 0)) {
|
||||
for (i = 0; i < cloth->primitive_num; i++) {
|
||||
const MVertTri *vt = &tri[i];
|
||||
BPH_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec);
|
||||
}
|
||||
}
|
||||
|
||||
/* Hair has only edges */
|
||||
if (cloth->primitive_num == 0) {
|
||||
else {
|
||||
#if 0
|
||||
ClothHairData *hairdata = clmd->hairdata;
|
||||
ClothHairData *hair_ij, *hair_kl;
|
||||
|
||||
Reference in New Issue
Block a user