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
This commit is contained in:
parent
c26f46cb95
commit
c55b578c9e
Notes:
blender-bot
2023-02-14 00:09:06 +01:00
Referenced by issue #84142, Crash when using Mirror with Source set to Verts in particle edit mode
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue