[Bf-blender-cvs] [c55b578c9e1] master: Fix T84142: crash when mirroring hair emitted from vertices

Jacques Lucke noreply at git.blender.org
Thu Jan 7 13:33:20 CET 2021


Commit: c55b578c9e1f4f5d03fbac01c7efa070e1d6970d
Author: Jacques Lucke
Date:   Thu Jan 7 13:32:36 2021 +0100
Branches: master
https://developer.blender.org/rBc55b578c9e1f4f5d03fbac01c7efa070e1d6970d

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

===================================================================

M	source/blender/editors/physics/particle_edit.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list