From 0c94e5d166027ff29a9d4027da2e5353e500c3ae Mon Sep 17 00:00:00 2001 From: Aleksi Juvani Date: Tue, 11 Jan 2022 13:02:49 +0100 Subject: Fix `PSYS_GLOBAL_HAIR` stripped even if connecting the hair fails After disconnecting hair on an object, if you then hide the particle system, and try connecting the hair again, the operator is cancelled due to `remap_hair_emitter` returning `false` because `target_psmd->mesh_final` is NULL, but `connect_hair` will still strip the `PSYS_GLOBAL_HAIR` flag, which will cause the hair in the hidden particle system to be positioned incorrectly. The correct behavior is to strip the flag only if `remap_hair_emitter` succeeds. Differential Revision: https://developer.blender.org/D13703 --- source/blender/editors/physics/particle_object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/physics') diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 896a37c3984..987b9e49057 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -939,7 +939,9 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); - psys->flag &= ~PSYS_GLOBAL_HAIR; + if (ok) { + psys->flag &= ~PSYS_GLOBAL_HAIR; + } return ok; } -- cgit v1.2.3