Commit: 967d82d9b9489aa9f08270a4fafc8415158690ea
Author: Sergey Sharybin
Date: Thu Mar 7 15:27:31 2019 +0100
Branches: master
https://developer.blender.org/rB967d82d9b9489aa9f08270a4fafc8415158690ea
Fix T62271: Particles with multires crash on sculpt
In fact, any modifier on top of multires would lead to crash.
Was missing pointer update.
Basically, bring the control flow closer to 2.7.
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/paint.c
M source/blender/draw/modes/sculpt_mode.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h
b/source/blender/blenkernel/BKE_paint.h
index 25fb55011b2..cc445413f61 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -56,6 +56,7 @@ struct UnifiedPaintSettings;
struct ViewLayer;
struct bContext;
struct bToolRef;
+struct SubdivCCG;
enum eOverlayFlags;
@@ -287,6 +288,8 @@ void BKE_sculpt_toolsettings_data_ensure(struct Scene
*scene);
struct PBVH *BKE_sculpt_object_pbvh_ensure(struct Depsgraph *depsgraph, struct
Object *ob);
+void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, struct SubdivCCG
*subdiv_ccg);
+
enum {
SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1),
diff --git a/source/blender/blenkernel/intern/paint.c
b/source/blender/blenkernel/intern/paint.c
index b3999e61216..be0d176dddc 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1381,7 +1381,16 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph
*depsgraph, Object *ob)
}
PBVH *pbvh = ob->sculpt->pbvh;
if (pbvh != NULL) {
- /* Nothing to do, PBVH is already up to date. */
+ /* NOTE: It is possible that grids were re-allocated due to
modifier
+ * stack. Need to update those pointers. */
+ if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) {
+ Object *object_eval =
DEG_get_evaluated_object(depsgraph, ob);
+ Mesh *mesh_eval = object_eval->data;
+ SubdivCCG *subdiv_ccg = mesh_eval->runtime.subdiv_ccg;
+ if (subdiv_ccg != NULL) {
+ BKE_sculpt_bvh_update_from_ccg(pbvh,
subdiv_ccg);
+ }
+ }
return pbvh;
}
@@ -1405,3 +1414,9 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph,
Object *ob)
ob->sculpt->pbvh = pbvh;
return pbvh;
}
+
+void BKE_sculpt_bvh_update_from_ccg(PBVH *pbvh, SubdivCCG *subdiv_ccg)
+{
+ BKE_pbvh_grids_update(pbvh, subdiv_ccg->grids, (void
**)subdiv_ccg->grid_faces,
+ subdiv_ccg->grid_flag_mats,
subdiv_ccg->grid_hidden);
+}
diff --git a/source/blender/draw/modes/sculpt_mode.c
b/source/blender/draw/modes/sculpt_mode.c
index 1a525f24349..a0ae5d0754a 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -164,6 +164,7 @@ static void sculpt_update_pbvh_normals(Object *object)
if (pbvh == NULL || subdiv_ccg == NULL) {
return;
}
+ BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg);
struct CCGFace **faces;
int num_faces;
BKE_pbvh_get_grid_updates(pbvh, 1, (void ***)&faces, &num_faces);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs