Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Rood <dev@lucarood.com>2020-01-26 17:15:02 +0300
committerLuca Rood <dev@lucarood.com>2020-01-26 17:19:42 +0300
commit96339c4cef104a007bafcc38a788a04e6b263ec8 (patch)
treee8e024790e1ef5be4cc6284d14023f4745eb2e82 /source/blender/physics
parent36f713e216f95c876d4d909c3f9da3baac6c2ddd (diff)
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.
Diffstat (limited to 'source/blender/physics')
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 94eaffd1f91..fcfd713e6be 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -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;