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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-04-02 11:10:13 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-04-02 17:32:33 +0300
commit3dad6294dae2f13ca1b9e8b08933ba32bf0f3bed (patch)
tree802210d1b495db67a22ec34775d1583406d09934
parentf868d51bdd3ed56cbf4ec74846b54caa8fe1fa1d (diff)
Sculpt: Store explicit value for multires sculpt level
Allows to know what level sculpting has been done after the value has been changed in the MultiresModifierData. No functional changes, just preparing code to have everything needed for propagation undo. Differential Revision: https://developer.blender.org/D7307
-rw-r--r--source/blender/blenkernel/BKE_paint.h6
-rw-r--r--source/blender/blenkernel/intern/multires.c5
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_smooth.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c8
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c4
6 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index f4b485ae53a..012188bed96 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -283,7 +283,11 @@ typedef struct SculptClothSimulation {
typedef struct SculptSession {
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
- struct MultiresModifierData *multires; /* Special handling for multires meshes */
+ struct { /* Special handling for multires meshes */
+ bool active;
+ struct MultiresModifierData *modifier;
+ int level;
+ } multires;
struct MVert *mvert;
struct MPoly *mpoly;
struct MLoop *mloop;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 6ccfabcb5d2..69cd338e15f 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -473,7 +473,8 @@ void multires_flush_sculpt_updates(Object *object)
}
SculptSession *sculpt_session = object->sculpt;
- if (BKE_pbvh_type(sculpt_session->pbvh) != PBVH_GRIDS || sculpt_session->multires == NULL) {
+ if (BKE_pbvh_type(sculpt_session->pbvh) != PBVH_GRIDS || !sculpt_session->multires.active ||
+ sculpt_session->multires.modifier == NULL) {
return;
}
@@ -488,7 +489,7 @@ void multires_flush_sculpt_updates(Object *object)
Mesh *mesh = object->data;
multiresModifier_reshapeFromCCG(
- sculpt_session->multires->totlvl, mesh, sculpt_session->subdiv_ccg);
+ sculpt_session->multires.modifier->totlvl, mesh, sculpt_session->subdiv_ccg);
subdiv_ccg->dirty.coords = false;
subdiv_ccg->dirty.hidden = false;
diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c
index 8b10d729901..fad5004ff4b 100644
--- a/source/blender/blenkernel/intern/multires_reshape_smooth.c
+++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c
@@ -400,7 +400,7 @@ static char get_effective_edge_crease_char(
const MultiresReshapeSmoothContext *reshape_smooth_context, const MEdge *base_edge)
{
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
- if (reshape_context->mmd->simple) {
+ if (reshape_context->subdiv->settings.is_simple) {
return 255;
}
return base_edge->crease;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index f52ec5f568f..5224fa3f8f6 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1522,7 +1522,9 @@ static void sculpt_update_object(
/* NOTE: Weight pPaint require mesh info for loop lookup, but it never uses multires code path,
* so no extra checks is needed here. */
if (mmd) {
- ss->multires = mmd;
+ ss->multires.active = true;
+ ss->multires.modifier = mmd;
+ ss->multires.level = mmd->sculptlvl;
ss->totvert = me_eval->totvert;
ss->totpoly = me_eval->totpoly;
ss->totfaces = me->totpoly;
@@ -1537,7 +1539,9 @@ static void sculpt_update_object(
ss->mvert = me->mvert;
ss->mpoly = me->mpoly;
ss->mloop = me->mloop;
- ss->multires = NULL;
+ ss->multires.active = false;
+ ss->multires.modifier = NULL;
+ ss->multires.level = 0;
ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 91c8262dd67..d734d2fec8b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5083,7 +5083,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(val, offset, *disp);
- if (!ss->multires && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+ if (!ss->multires.active && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
int index = vd.vert_indices[vd.i];
/* Persistent base. */
@@ -6758,7 +6758,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) {
+ if (ss->multires.active && mtex->tex && mtex->tex->type == TEX_NOISE) {
multires_stitch_grids(ob);
}
}
@@ -7096,7 +7096,7 @@ static void sculpt_update_cache_invariants(
/* Initialize layer brush displacements and persistent coords. */
if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* Not supported yet for multires or dynamic topology. */
- if (!ss->multires && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+ if (!ss->multires.active && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
if (!ss->layer_co) {
ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy");
}
@@ -7862,7 +7862,7 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags)
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
- MultiresModifierData *mmd = ss->multires;
+ MultiresModifierData *mmd = ss->multires.modifier;
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index ad8e0a9f259..f9d53d08c2e 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -211,7 +211,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (ctx->object->sculpt != NULL) {
SculptSession *sculpt_session = ctx->object->sculpt;
sculpt_session->subdiv_ccg = result->runtime.subdiv_ccg;
- sculpt_session->multires = mmd;
+ sculpt_session->multires.active = true;
+ sculpt_session->multires.modifier = mmd;
+ sculpt_session->multires.level = mmd->sculptlvl;
sculpt_session->totvert = mesh->totvert;
sculpt_session->totpoly = mesh->totpoly;
sculpt_session->mvert = NULL;