Fix #108198: Particle hair crash when using Hair Dynamics #108480

Merged
Hans Goudey merged 2 commits from Chao-Li/blender:fix-hair-dynamics into blender-v3.6-release 2023-06-06 18:46:40 +02:00
2 changed files with 8 additions and 2 deletions

View File

@ -367,6 +367,10 @@ void clothModifier_do(ClothModifierData *clmd,
return;
}
/* Since implicit sharing is introduced, mesh data can be moved to other places.
* Therefore some fields in simulation data need to be updated accordingly */
clmd->clothObject->edges = reinterpret_cast<const vec2i *>(mesh->edges().data());
/* try to read from cache */
bool can_simulate = (framenr == clmd->clothObject->last_frame + 1) &&
!(cache->flag & PTCACHE_BAKED);

View File

@ -3491,12 +3491,14 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
}
}
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh);
/* Free hair_out_mesh before modifying hair_in_mesh in hair_create_input_mesh() to avoid copying
* on write since they share some data */
if (psys->hair_out_mesh) {
BKE_id_free(NULL, psys->hair_out_mesh);
}
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh);
psys->clmd->point_cache = psys->pointcache;
/* for hair sim we replace the internal cloth effector weights temporarily
* to use the particle settings