[Bf-blender-cvs] [cf2c09002fa] master: Fix T69488: Hair particles: rekey disolves the hair then crashes

Philipp Oeser noreply at git.blender.org
Thu Sep 26 17:33:46 CEST 2019


Commit: cf2c09002fae1e5b11acc0f21b67ffb29212ad7a
Author: Philipp Oeser
Date:   Thu Sep 26 17:24:29 2019 +0200
Branches: master
https://developer.blender.org/rBcf2c09002fae1e5b11acc0f21b67ffb29212ad7a

Fix T69488: Hair particles: rekey disolves the hair then crashes

Caused by rB914427afd512.

Since above commit 'pe_get_current' checks for an active depsgraph. This
caused the skipping of handling
`PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL`for everything calling
`PE_get_current` (this passes a NULL depsgraph as opposed to
`PE_create_current`). So we now pass a depsgraph here as well...

Note there are two RNA cases where we pass NULL, namely
- rna_ParticleEdit_editable_get
- rna_ParticleEdit_hair_get
I guess these should be fine though (no functional change to current
master)

Reviewers: sergey

Maniphest Tasks: T69488

Differential Revision: https://developer.blender.org/D5752

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

M	source/blender/editors/include/ED_particle.h
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/physics/particle_edit_undo.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert_particle.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 3ef3c0ba937..0c973f4ca88 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -40,12 +40,18 @@ int PE_start_edit(struct PTCacheEdit *edit);
 
 /* access */
 struct PTCacheEdit *PE_get_current_from_psys(struct ParticleSystem *psys);
-struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
+struct PTCacheEdit *PE_get_current(struct Depsgraph *depsgraph,
+                                   struct Scene *scene,
+                                   struct Object *ob);
 struct PTCacheEdit *PE_create_current(struct Depsgraph *depsgraph,
                                       struct Scene *scene,
                                       struct Object *ob);
 void PE_current_changed(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
-int PE_minmax(struct Scene *scene, struct ViewLayer *view_layer, float min[3], float max[3]);
+int PE_minmax(struct Depsgraph *depsgraph,
+              struct Scene *scene,
+              struct ViewLayer *view_layer,
+              float min[3],
+              float max[3]);
 struct ParticleEditSettings *PE_settings(struct Scene *scene);
 
 /* update calls */
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 6e0470a636b..1e6ff163225 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -93,6 +93,7 @@
 
 bool PE_poll(bContext *C)
 {
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   Scene *scene = CTX_data_scene(C);
   Object *ob = CTX_data_active_object(C);
 
@@ -100,7 +101,7 @@ bool PE_poll(bContext *C)
     return false;
   }
 
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   if (edit == NULL) {
     return false;
   }
@@ -113,6 +114,7 @@ bool PE_poll(bContext *C)
 
 bool PE_hair_poll(bContext *C)
 {
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   Scene *scene = CTX_data_scene(C);
   Object *ob = CTX_data_active_object(C);
 
@@ -120,7 +122,7 @@ bool PE_hair_poll(bContext *C)
     return false;
   }
 
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   if (edit == NULL || edit->psys == NULL) {
     return false;
   }
@@ -356,9 +358,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
   return edit;
 }
 
-PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
+PTCacheEdit *PE_get_current(Depsgraph *depsgraph, Scene *scene, Object *ob)
 {
-  return pe_get_current(NULL, scene, ob, 0);
+  return pe_get_current(depsgraph, scene, ob, 0);
 }
 
 PTCacheEdit *PE_create_current(Depsgraph *depsgraph, Scene *scene, Object *ob)
@@ -466,7 +468,7 @@ static void PE_set_data(bContext *C, PEData *data)
   data->view_layer = CTX_data_view_layer(C);
   data->ob = CTX_data_active_object(C);
   data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  data->edit = PE_get_current(data->scene, data->ob);
+  data->edit = PE_get_current(data->depsgraph, data->scene, data->ob);
 }
 
 static void PE_set_view3d_data(bContext *C, PEData *data)
@@ -1462,7 +1464,7 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
 
 static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
 {
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   HairKey *hkey;
   POINT_P;
   KEY_K;
@@ -1597,7 +1599,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
   /* use this to do partial particle updates, not usable when adding or
    * removing, then a full redo is necessary and calling this may crash */
   ParticleEditSettings *pset = PE_settings(scene);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   POINT_P;
 
   if (!edit) {
@@ -1787,7 +1789,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   Object *ob = CTX_data_active_object(C);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   POINT_P;
   KEY_K;
   int action = RNA_enum_get(op->ptr, "action");
@@ -1848,7 +1850,7 @@ bool PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool desele
   PEData data;
   Scene *scene = CTX_data_scene(C);
   Object *ob = CTX_data_active_object(C);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(data.depsgraph, scene, ob);
   POINT_P;
   KEY_K;
 
@@ -2036,6 +2038,7 @@ static const EnumPropertyItem select_random_type_items[] = {
 
 static int select_random_exec(bContext *C, wmOperator *op)
 {
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   PEData data;
   int type;
 
@@ -2055,7 +2058,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
 
   PE_set_data(C, &data);
   data.select_action = SEL_SELECT;
-  edit = PE_get_current(data.scene, data.ob);
+  edit = PE_get_current(depsgraph, data.scene, data.ob);
 
   rng = BLI_rng_new_srandom(seed);
 
@@ -2189,9 +2192,10 @@ bool PE_deselect_all_visible_ex(PTCacheEdit *edit)
 
 bool PE_deselect_all_visible(bContext *C)
 {
+  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(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   if (!PE_start_edit(edit)) {
     return false;
   }
@@ -2200,9 +2204,10 @@ bool PE_deselect_all_visible(bContext *C)
 
 bool PE_box_select(bContext *C, const rcti *rect, const int sel_op)
 {
+  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(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   PEData data;
 
   if (!PE_start_edit(edit)) {
@@ -2236,9 +2241,10 @@ bool PE_box_select(bContext *C, const rcti *rect, const int sel_op)
 bool PE_circle_select(bContext *C, const int sel_op, const int mval[2], float rad)
 {
   BLI_assert(ELEM(sel_op, SEL_OP_SET, SEL_OP_ADD, SEL_OP_SUB));
+  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(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   PEData data;
 
   if (!PE_start_edit(edit)) {
@@ -2267,11 +2273,12 @@ bool PE_circle_select(bContext *C, const int sel_op, const int mval[2], float ra
 
 int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const int sel_op)
 {
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   Scene *scene = CTX_data_scene(C);
   Object *ob = CTX_data_active_object(C);
   ARegion *ar = CTX_wm_region(C);
   ParticleEditSettings *pset = PE_settings(scene);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   ParticleSystem *psys = edit->psys;
   ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
   POINT_P;
@@ -2357,7 +2364,7 @@ static int hide_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
 
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   POINT_P;
   KEY_K;
 
@@ -2417,7 +2424,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
   Object *ob = CTX_data_active_object(C);
   Scene *scene = CTX_data_scene(C);
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   const bool select = RNA_boolean_get(op->ptr, "select");
   POINT_P;
   KEY_K;
@@ -2701,7 +2708,8 @@ void PARTICLE_OT_rekey(wmOperatorType *ot)
 static void rekey_particle_to_time(
     const bContext *C, Scene *scene, Object *ob, int pa_index, float path_time)
 {
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   ParticleSystem *psys;
   ParticleSimulationData sim = {0};
   ParticleData *pa;
@@ -2716,7 +2724,7 @@ static void rekey_particle_to_time(
 
   psys = edit->psys;
 
-  sim.depsgraph = CTX_data_depsgraph_pointer(C);
+  sim.depsgraph = depsgraph;
   sim.scene = scene;
   sim.ob = ob;
   sim.psys = psys;
@@ -3069,9 +3077,10 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot)
 
 static int remove_doubles_exec(bContext *C, wmOperator *op)
 {
+  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(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   ParticleSystem *psys = edit->psys;
   ParticleSystemModifierData *psmd_eval;
   KDTree_3d *tree;
@@ -3173,10 +3182,11 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot)
 
 static int weight_set_exec(bContext *C, wmOperator *op)
 {
+  Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   Scene *scene = CTX_data_scene(C);
   ParticleEditSettings *pset = PE_settings(scene);
   Object *ob = CTX_data_active_object(C);
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob);
   ParticleSystem *psys = edit->psys;
   POINT_P;
   KEY_K;
@@ -3354,11 +3364,11 @@ void PARTICLE_OT_delete(wmOperatorType *ot)
 
 /*************************** mirror operator **************************/
 
-static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
+static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagged)
 {
   Mesh *me = (Mesh *)(ob->data);
   ParticleSystemModifierData *psmd_eval;
-  PTCacheEdit *edit = PE_get_current(scene, ob);
+  PTCacheEdit *edit = PE_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list