diff options
author | Jacques Lucke <jacques@blender.org> | 2021-01-07 15:32:36 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-01-07 15:32:36 +0300 |
commit | c55b578c9e1f4f5d03fbac01c7efa070e1d6970d (patch) | |
tree | c12fe9aa58078a398edd1d728a15dc03e9e878f9 /source/blender/editors | |
parent | c26f46cb9521c4d3603a5502dce0fd8444fbe408 (diff) |
Fix T84142: crash when mirroring hair emitted from vertices
The hair mirroring code seems to expect that hair is emitted from faces.
The PE_mirror_x contains the following expression: mirrorfaces[pa->num * 2].
This only makes sense when pa->num is a face index.
The simplest short term solution is to disable the mirror operator when
the particles haven't been emitted from faces.
Diffferential Revision: https://developer.blender.org/D10002
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index ff36197c61e..8ab25fa74b8 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3496,6 +3496,21 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +static bool mirror_poll(bContext *C) +{ + if (!PE_hair_poll(C)) { + return false; + } + + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); + + /* The operator only works for hairs emitted from faces. */ + return edit->psys->part->from == PART_FROM_FACE; +} + void PARTICLE_OT_mirror(wmOperatorType *ot) { /* identifiers */ @@ -3505,7 +3520,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) /* api callbacks */ ot->exec = mirror_exec; - ot->poll = PE_hair_poll; + ot->poll = mirror_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |