Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-03-07 17:27:31 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-03-07 18:09:15 +0300
commit967d82d9b9489aa9f08270a4fafc8415158690ea (patch)
tree561ee39d17833217c2cecffc73714d32e38e7b1b /source
parent594f2b80165d1fa750150d32f9c9dfd344b497e3 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_paint.h3
-rw-r--r--source/blender/blenkernel/intern/paint.c17
-rw-r--r--source/blender/draw/modes/sculpt_mode.c1
3 files changed, 20 insertions, 1 deletions
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);