Fix #110328: Clay Strip symmetry does not mirror rotation
Caused by 351034891e
This change is a partial revert of the change.
The SCULPT_cube_tip_init() does not deal with the symmetry passes.
Additionally, the commit changed the way how the Z component of
the matrix was constructed: displaced vs. non-displaced area
coordinate.
While the code duplication is often to be avoided, sometimes it is
more clear than a centralized place with a lot of arguments passed
to a function. We can have a pass of de-duplication later on, and
make a better decision, but for now restore user level behavior to
what it is expected to be.
Pull Request: https://projects.blender.org/blender/blender/pulls/111425
This commit is contained in:
committed by
Sergey Sharybin
parent
7bb693581f
commit
beaf4854b1
@@ -2964,9 +2964,7 @@ static void calc_local_y(ViewContext *vc, const float center[3], float y[3])
|
||||
static void calc_brush_local_mat(const float rotation,
|
||||
Object *ob,
|
||||
float local_mat[4][4],
|
||||
float local_mat_inv[4][4],
|
||||
const float *co,
|
||||
const float *no)
|
||||
float local_mat_inv[4][4])
|
||||
{
|
||||
const StrokeCache *cache = ob->sculpt->cache;
|
||||
float tmat[4][4];
|
||||
@@ -2975,13 +2973,6 @@ static void calc_brush_local_mat(const float rotation,
|
||||
float angle, v[3];
|
||||
float up[3];
|
||||
|
||||
if (!co) {
|
||||
co = cache->location;
|
||||
}
|
||||
if (!no) {
|
||||
no = cache->sculpt_normal;
|
||||
}
|
||||
|
||||
/* Ensure `ob->world_to_object` is up to date. */
|
||||
invert_m4_m4(ob->world_to_object, ob->object_to_world);
|
||||
|
||||
@@ -2992,20 +2983,20 @@ static void calc_brush_local_mat(const float rotation,
|
||||
mat[3][3] = 1.0f;
|
||||
|
||||
/* Get view's up vector in object-space. */
|
||||
calc_local_y(cache->vc, co, up);
|
||||
calc_local_y(cache->vc, cache->location, up);
|
||||
|
||||
/* Calculate the X axis of the local matrix. */
|
||||
cross_v3_v3v3(v, up, no);
|
||||
cross_v3_v3v3(v, up, cache->sculpt_normal);
|
||||
/* Apply rotation (user angle, rake, etc.) to X axis. */
|
||||
angle = rotation - cache->special_rotation;
|
||||
rotate_v3_v3v3fl(mat[0], v, no, angle);
|
||||
rotate_v3_v3v3fl(mat[0], v, cache->sculpt_normal, angle);
|
||||
|
||||
/* Get other axes. */
|
||||
cross_v3_v3v3(mat[1], no, mat[0]);
|
||||
copy_v3_v3(mat[2], no);
|
||||
cross_v3_v3v3(mat[1], cache->sculpt_normal, mat[0]);
|
||||
copy_v3_v3(mat[2], cache->sculpt_normal);
|
||||
|
||||
/* Set location. */
|
||||
copy_v3_v3(mat[3], co);
|
||||
copy_v3_v3(mat[3], cache->location);
|
||||
|
||||
/* Scale by brush radius. */
|
||||
float radius = cache->radius;
|
||||
@@ -3050,8 +3041,7 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob)
|
||||
if (cache->mirror_symmetry_pass == 0 && cache->radial_symmetry_pass == 0) {
|
||||
const Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
calc_brush_local_mat(
|
||||
mask_tex->rot, ob, cache->brush_local_mat, cache->brush_local_mat_inv, nullptr, nullptr);
|
||||
calc_brush_local_mat(mask_tex->rot, ob, cache->brush_local_mat, cache->brush_local_mat_inv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6393,8 +6383,7 @@ void SCULPT_topology_islands_ensure(Object *ob)
|
||||
ss->islands_valid = true;
|
||||
}
|
||||
|
||||
void SCULPT_cube_tip_init(
|
||||
Sculpt * /*sd*/, Object *ob, Brush *brush, float mat[4][4], const float *co, const float *no)
|
||||
void SCULPT_cube_tip_init(Sculpt * /*sd*/, Object *ob, Brush *brush, float mat[4][4])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
float scale[4][4];
|
||||
@@ -6402,7 +6391,7 @@ void SCULPT_cube_tip_init(
|
||||
float unused[4][4];
|
||||
|
||||
zero_m4(mat);
|
||||
calc_brush_local_mat(0.0, ob, unused, mat, co, no);
|
||||
calc_brush_local_mat(0.0, ob, unused, mat);
|
||||
|
||||
/* Note: we ignore the radius scaling done inside of calc_brush_local_mat to
|
||||
* duplicate prior behavior.
|
||||
|
||||
@@ -1119,6 +1119,8 @@ void SCULPT_do_clay_strips_brush(Sculpt *sd, Object *ob, Span<PBVHNode *> nodes)
|
||||
|
||||
float temp[3];
|
||||
float mat[4][4];
|
||||
float scale[4][4];
|
||||
float tmat[4][4];
|
||||
|
||||
SCULPT_calc_brush_plane(sd, ob, nodes, area_no_sp, area_co);
|
||||
SCULPT_tilt_apply_to_normal(area_no_sp, ss->cache, brush->tilt_strength_factor);
|
||||
@@ -1130,6 +1132,10 @@ void SCULPT_do_clay_strips_brush(Sculpt *sd, Object *ob, Span<PBVHNode *> nodes)
|
||||
copy_v3_v3(area_no, area_no_sp);
|
||||
}
|
||||
|
||||
if (is_zero_v3(ss->cache->grab_delta_symmetry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
|
||||
mul_v3_fl(temp, displace);
|
||||
add_v3_v3(area_co, temp);
|
||||
@@ -1145,21 +1151,6 @@ void SCULPT_do_clay_strips_brush(Sculpt *sd, Object *ob, Span<PBVHNode *> nodes)
|
||||
float area_co_displaced[3];
|
||||
madd_v3_v3v3fl(area_co_displaced, area_co, area_no, -radius * 0.7f);
|
||||
|
||||
/* Initialize brush local-space matrix. */
|
||||
SCULPT_cube_tip_init(sd, ob, brush, mat, area_co, area_no);
|
||||
|
||||
/* Deform the local space in Z to scale the test cube. As the test cube does not have falloff in
|
||||
* Z this does not produce artifacts in the falloff cube and allows to deform extra vertices
|
||||
* during big deformation while keeping the surface as uniform as possible. */
|
||||
invert_m4(mat);
|
||||
mul_v3_fl(mat[2], 1.25f);
|
||||
invert_m4(mat);
|
||||
|
||||
#if 0 /* The original matrix construction code, preserved here for reference. */
|
||||
if (is_zero_v3(ss->cache->grab_delta_symmetry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
|
||||
mat[0][3] = 0.0f;
|
||||
cross_v3_v3v3(mat[1], area_no, mat[0]);
|
||||
@@ -1174,8 +1165,14 @@ void SCULPT_do_clay_strips_brush(Sculpt *sd, Object *ob, Span<PBVHNode *> nodes)
|
||||
scale_m4_fl(scale, ss->cache->radius);
|
||||
mul_m4_m4m4(tmat, mat, scale);
|
||||
|
||||
mul_v3_fl(tmat[1], brush->tip_scale_x);
|
||||
|
||||
/* Deform the local space in Z to scale the test cube. As the test cube does not have falloff in
|
||||
* Z this does not produce artifacts in the falloff cube and allows to deform extra vertices
|
||||
* during big deformation while keeping the surface as uniform as possible. */
|
||||
mul_v3_fl(tmat[2], 1.25f);
|
||||
|
||||
invert_m4_m4(mat, tmat);
|
||||
#endif
|
||||
|
||||
SculptThreadedTaskData data{};
|
||||
data.sd = sd;
|
||||
|
||||
@@ -1260,12 +1260,7 @@ SculptBrushTestFn SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
|
||||
char falloff_shape);
|
||||
const float *SCULPT_brush_frontface_normal_from_falloff_shape(SculptSession *ss,
|
||||
char falloff_shape);
|
||||
void SCULPT_cube_tip_init(Sculpt *sd,
|
||||
Object *ob,
|
||||
Brush *brush,
|
||||
float mat[4][4],
|
||||
const float *co = nullptr, /* Custom brush center. */
|
||||
const float *no = nullptr); /* Custom brush normal. */
|
||||
void SCULPT_cube_tip_init(Sculpt *sd, Object *ob, Brush *brush, float mat[4][4]);
|
||||
|
||||
/**
|
||||
* Return a multiplier for brush strength on a particular vertex.
|
||||
|
||||
Reference in New Issue
Block a user