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:
authorPhilipp Oeser <info@graphics-engineer.com>2022-01-03 15:25:45 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-01-11 16:29:49 +0300
commit3a79c1d8f5987375df0aaa796d684f54b0791ea7 (patch)
tree66edd9c8002e4626e86f7ff9941a2aea4d4bead6
parent8a901d4925de6c1966b0df12104cdda1543ee02b (diff)
Fix T94564: Mirror clipping is not properly placed in sculpt mode
If a mirror object is used in a mirror modifier, sculptmode did not take this into account (and instead always clipped on the sculpt objects local axis). Now take this into account by storing a matrix in the preparation function `sculpt_init_mirror_clipping` and use that later in `SCULPT_clip`. Maniphest Tasks: T94564 Differential Revision: https://developer.blender.org/D13711
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c29
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h1
2 files changed, 27 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 964e5bdaa90..06c300108ec 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2642,9 +2642,23 @@ void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
continue;
}
- if (ss->cache && (ss->cache->flag & (CLIP_X << i)) &&
- (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) {
- co[i] = 0.0f;
+ bool do_clip = false;
+ float co_clip[3];
+ if (ss->cache && (ss->cache->flag & (CLIP_X << i))) {
+ /* Take possible mirror object into account. */
+ mul_v3_m4v3(co_clip, ss->cache->clip_mirror_mtx, co);
+
+ if (fabsf(co_clip[i]) <= ss->cache->clip_tolerance[i]) {
+ co_clip[i] = 0.0f;
+ float imtx[4][4];
+ invert_m4_m4(imtx, ss->cache->clip_mirror_mtx);
+ mul_m4_v3(imtx, co_clip);
+ do_clip = true;
+ }
+ }
+
+ if (do_clip) {
+ co[i] = co_clip[i];
}
else {
co[i] = val[i];
@@ -6715,6 +6729,8 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
{
ModifierData *md;
+ unit_m4(ss->cache->clip_mirror_mtx);
+
for (md = ob->modifiers.first; md; md = md->next) {
if (!(md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime))) {
continue;
@@ -6736,6 +6752,13 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
if (mmd->tolerance > ss->cache->clip_tolerance[i]) {
ss->cache->clip_tolerance[i] = mmd->tolerance;
}
+
+ /* Store matrix for mirror object clipping. */
+ if (mmd->mirror_ob) {
+ float imtx_mirror_ob[4][4];
+ invert_m4_m4(imtx_mirror_ob, mmd->mirror_ob->obmat);
+ mul_m4_m4m4(ss->cache->clip_mirror_mtx, imtx_mirror_ob, ob->obmat);
+ }
}
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 087cb6dd94a..2ba183a9280 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -912,6 +912,7 @@ typedef struct StrokeCache {
float scale[3];
int flag;
float clip_tolerance[3];
+ float clip_mirror_mtx[4][4];
float initial_mouse[2];
/* Variants */