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
This commit is contained in:
Aleksi Juvani 2022-01-11 13:02:49 +01:00 committed by Philipp Oeser
parent 9dc9692b09
commit 0c94e5d166
Notes: blender-bot 2023-02-14 08:40:26 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 3 additions and 1 deletions

View File

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