Sculpt: fix rotate brush
This commit is contained in:
parent
8dda36655e
commit
47cbb9b1ac
|
@ -1547,11 +1547,11 @@ void BKE_builtin_apply_hard_edge_mode(BrushChannelSet *chset, bool do_apply)
|
|||
}
|
||||
}
|
||||
|
||||
ATTR_NO_OPT void BKE_builtin_commandlist_create(Brush *brush,
|
||||
BrushChannelSet *chset,
|
||||
BrushCommandList *cl,
|
||||
int tool,
|
||||
BrushMappingData *mapdata)
|
||||
void BKE_builtin_commandlist_create(Brush *brush,
|
||||
BrushChannelSet *chset,
|
||||
BrushCommandList *cl,
|
||||
int tool,
|
||||
BrushMappingData *mapdata)
|
||||
{
|
||||
BrushCommand *cmd;
|
||||
BrushChannel *ch;
|
||||
|
|
|
@ -5155,7 +5155,7 @@ void pbvh_bmesh_do_cache_test()
|
|||
}
|
||||
|
||||
/* saves all bmesh references to internal indices, to be restored later */
|
||||
ATTR_NO_OPT void BKE_pbvh_bmesh_save_indices(PBVH *pbvh)
|
||||
void BKE_pbvh_bmesh_save_indices(PBVH *pbvh)
|
||||
{
|
||||
BM_mesh_elem_index_ensure(pbvh->bm, BM_VERT | BM_EDGE | BM_FACE);
|
||||
|
||||
|
@ -5242,7 +5242,7 @@ ATTR_NO_OPT void BKE_pbvh_bmesh_save_indices(PBVH *pbvh)
|
|||
}
|
||||
|
||||
/* restore bmesh references from previously indices saved by BKE_pbvh_bmesh_save_indices */
|
||||
ATTR_NO_OPT void BKE_pbvh_bmesh_from_saved_indices(PBVH *pbvh)
|
||||
void BKE_pbvh_bmesh_from_saved_indices(PBVH *pbvh)
|
||||
{
|
||||
BM_mesh_elem_table_ensure(pbvh->bm, BM_VERT | BM_EDGE | BM_FACE);
|
||||
BM_mesh_elem_index_ensure(pbvh->bm, BM_VERT | BM_EDGE | BM_FACE);
|
||||
|
|
|
@ -292,7 +292,7 @@ typedef struct BMFlagLayer {
|
|||
|
||||
struct RangeTreeUInt;
|
||||
|
||||
#define WITH_BM_ID_FREELIST
|
||||
//#define WITH_BM_ID_FREELIST
|
||||
|
||||
typedef struct BMesh {
|
||||
int totvert, totedge, totloop, totface;
|
||||
|
|
|
@ -322,6 +322,23 @@ float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
return BKE_PBVH_DYNVERT(ss->cd_dyn_vert, v)->origno;
|
||||
}
|
||||
|
||||
case PBVH_GRIDS:
|
||||
case PBVH_FACES: {
|
||||
return ss->mdyntopo_verts[vertex.i].origno;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const float *SCULPT_vertex_co_get(SculptSession *ss, SculptVertRef index)
|
||||
{
|
||||
if (ss->bm) {
|
||||
|
@ -3391,7 +3408,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
|
|||
|
||||
distsq = len_squared_v3v3(mirror, cache->true_location);
|
||||
|
||||
if (distsq <= 4.0f * (cache->radius_squared)) {
|
||||
if (cache->radius > 0.0f && distsq <= 4.0f * (cache->radius_squared)) {
|
||||
return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius));
|
||||
}
|
||||
return 0.0f;
|
||||
|
@ -3432,7 +3449,9 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
|
|||
overlap += calc_radial_symmetry_feather(sd, cache, i, 'Y');
|
||||
overlap += calc_radial_symmetry_feather(sd, cache, i, 'Z');
|
||||
}
|
||||
return 1.0f / overlap;
|
||||
|
||||
/* mathwise divice by zero is infinity, so use maximum value (1) in that case? */
|
||||
return overlap != 0.0f ? 1.0f / overlap : 1.0f;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -4105,7 +4124,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
|
|||
}
|
||||
|
||||
/* Test AABB against sphere. */
|
||||
ATTR_NO_OPT bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v)
|
||||
bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v)
|
||||
{
|
||||
SculptSearchSphereData *data = data_v;
|
||||
const float *center;
|
||||
|
@ -6826,12 +6845,9 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
|
|||
const float angle = data->angle;
|
||||
|
||||
PBVHVertexIter vd;
|
||||
SculptOrigVertData orig_data;
|
||||
float(*proxy)[3];
|
||||
const float bstrength = ss->cache->bstrength;
|
||||
|
||||
SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
|
||||
|
||||
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
|
||||
|
||||
SculptBrushTest test;
|
||||
|
@ -6840,33 +6856,39 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
|
|||
const int thread_id = BLI_task_parallel_thread_id(tls);
|
||||
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
|
||||
SCULPT_orig_vert_data_update(&orig_data, vd.vertex);
|
||||
SCULPT_vertex_check_origdata(ss, vd.vertex);
|
||||
|
||||
if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) {
|
||||
float *co = SCULPT_vertex_origco_get(ss, vd.vertex);
|
||||
float *no = SCULPT_vertex_origno_get(ss, vd.vertex);
|
||||
|
||||
if (!sculpt_brush_test_sq_fn(&test, co)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float vec[3], rot[3][3];
|
||||
const float fade = bstrength * SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
orig_data.co,
|
||||
co,
|
||||
sqrtf(test.dist),
|
||||
orig_data.no,
|
||||
NULL,
|
||||
no,
|
||||
vd.mask ? *vd.mask : 0.0f,
|
||||
vd.vertex,
|
||||
thread_id);
|
||||
|
||||
sub_v3_v3v3(vec, orig_data.co, ss->cache->location);
|
||||
sub_v3_v3v3(vec, co, ss->cache->location);
|
||||
axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade);
|
||||
mul_v3_m3v3(proxy[vd.i], rot, vec);
|
||||
add_v3_v3(proxy[vd.i], ss->cache->location);
|
||||
sub_v3_v3(proxy[vd.i], orig_data.co);
|
||||
sub_v3_v3(proxy[vd.i], co);
|
||||
|
||||
if (vd.mvert) {
|
||||
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
|
||||
}
|
||||
}
|
||||
BKE_pbvh_vertex_iter_end;
|
||||
|
||||
BKE_pbvh_node_mark_update(data->nodes[n]);
|
||||
}
|
||||
|
||||
static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
||||
|
|
|
@ -121,7 +121,7 @@ static void sculpt_array_datalayers_add(SculptArray *array, SculptSession *ss, M
|
|||
}
|
||||
}
|
||||
|
||||
ATTR_NO_OPT void SCULPT_array_datalayers_free(SculptArray *array, Object *ob)
|
||||
void SCULPT_array_datalayers_free(SculptArray *array, Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
|
@ -286,9 +286,7 @@ static BMesh *sculpt_array_source_build(Object *ob, Brush *brush, SculptArray *a
|
|||
return srcbm;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT void sculpt_array_source_datalayer_update(BMesh *bm,
|
||||
const int symm_pass,
|
||||
const int copy_index)
|
||||
void sculpt_array_source_datalayer_update(BMesh *bm, const int symm_pass, const int copy_index)
|
||||
{
|
||||
const int cd_array_instance_index = CustomData_get_named_layer_index(
|
||||
&bm->vdata, CD_PROP_INT32, array_instance_cd_name);
|
||||
|
@ -326,10 +324,8 @@ static void sculpt_array_final_mesh_write(Object *ob, BMesh *final_mesh)
|
|||
ss->needs_pbvh_rebuild = true;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void sculpt_array_ensure_geometry_indices(Object *ob, SculptArray *array)
|
||||
static void sculpt_array_ensure_geometry_indices(Object *ob, SculptArray *array)
|
||||
{
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
if (array->copy_index) {
|
||||
return;
|
||||
}
|
||||
|
@ -361,7 +357,7 @@ ATTR_NO_OPT static void sculpt_array_ensure_geometry_indices(Object *ob, SculptA
|
|||
SCULPT_array_datalayers_free(array, ob);
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void sculpt_array_mesh_build(Sculpt *sd, Object *ob, SculptArray *array)
|
||||
static void sculpt_array_mesh_build(Sculpt *sd, Object *ob, SculptArray *array)
|
||||
{
|
||||
bool have_bmesh = ob->sculpt->bm && ob->sculpt->pbvh &&
|
||||
BKE_pbvh_type(ob->sculpt->pbvh) == PBVH_BMESH;
|
||||
|
@ -566,7 +562,6 @@ static void sculpt_array_update_copy(StrokeCache *cache,
|
|||
Brush *brush)
|
||||
{
|
||||
|
||||
float copy_position[3];
|
||||
unit_m4(copy->mat);
|
||||
|
||||
float scale = 1.0f;
|
||||
|
@ -663,16 +658,14 @@ static void sculpt_array_update(Object *ob, Brush *brush, SculptArray *array)
|
|||
}
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void do_array_deform_task_cb_ex(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict tls)
|
||||
static void do_array_deform_task_cb_ex(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict tls)
|
||||
{
|
||||
SculptThreadedTaskData *data = userdata;
|
||||
SculptSession *ss = data->ob->sculpt;
|
||||
SculptArray *array = ss->array;
|
||||
|
||||
Mesh *mesh = BKE_object_get_original_mesh(data->ob);
|
||||
|
||||
bool any_modified = false;
|
||||
|
||||
PBVHVertexIter vd;
|
||||
|
@ -711,7 +704,6 @@ ATTR_NO_OPT static void do_array_deform_task_cb_ex(void *__restrict userdata,
|
|||
static void sculpt_array_deform(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
||||
{
|
||||
/* Threaded loop over nodes. */
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptThreadedTaskData data = {
|
||||
.sd = sd,
|
||||
.ob = ob,
|
||||
|
@ -731,8 +723,6 @@ static void do_array_smooth_task_cb_ex(void *__restrict userdata,
|
|||
SculptSession *ss = data->ob->sculpt;
|
||||
SculptArray *array = ss->array;
|
||||
|
||||
Mesh *mesh = BKE_object_get_original_mesh(data->ob);
|
||||
|
||||
bool any_modified = false;
|
||||
|
||||
bool check_fsets = ss->cache->brush->flag2 & BRUSH_SMOOTH_PRESERVE_FACE_SETS;
|
||||
|
@ -821,7 +811,6 @@ static void sculpt_array_smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
|
|||
static void sculpt_array_ensure_original_coordinates(Object *ob, SculptArray *array)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *sculpt_mesh = BKE_object_get_original_mesh(ob);
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
if (array->orco) {
|
||||
|
@ -841,8 +830,6 @@ static void sculpt_array_ensure_base_transform(Sculpt *sd, Object *ob, SculptArr
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
Mesh *sculpt_mesh = BKE_object_get_original_mesh(ob);
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
if (array->source_mat_valid) {
|
||||
return;
|
||||
|
@ -921,7 +908,7 @@ static void sculpt_array_stroke_sample_add(Object *ob, SculptArray *array)
|
|||
array->path.tot_points++;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
||||
void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
|
|
|
@ -235,6 +235,8 @@ void SCULPT_vertex_neighbors_get(const struct SculptSession *ss,
|
|||
SculptVertRef SCULPT_active_vertex_get(SculptSession *ss);
|
||||
const float *SCULPT_active_vertex_co_get(SculptSession *ss);
|
||||
float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex);
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex);
|
||||
|
||||
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
|
||||
MDynTopoVert *SCULPT_vertex_get_mdyntopo(SculptSession *ss, SculptVertRef vertex);
|
||||
|
||||
|
@ -1826,7 +1828,7 @@ int SCULPT_get_symmetry_pass(const SculptSession *ss);
|
|||
void SCULPT_on_sculptsession_bmesh_free(SculptSession *ss);
|
||||
void SCULPT_reorder_bmesh(SculptSession *ss);
|
||||
|
||||
static inline void *SCULPT_temp_cdata_get(SculptVertRef vertex, SculptCustomLayer *scl)
|
||||
static inline void *SCULPT_temp_cdata_get(const SculptVertRef vertex, const SculptCustomLayer *scl)
|
||||
{
|
||||
if (scl->data) {
|
||||
char *p = (char *)scl->data;
|
||||
|
@ -1848,7 +1850,8 @@ static inline void *SCULPT_temp_cdata_get(SculptVertRef vertex, SculptCustomLaye
|
|||
}
|
||||
|
||||
// arg, duplicate functions!
|
||||
static inline void *SCULPT_temp_cdata_get_f(SculptFaceRef vertex, SculptCustomLayer *scl)
|
||||
static inline void *SCULPT_temp_cdata_get_f(const SculptFaceRef vertex,
|
||||
const SculptCustomLayer *scl)
|
||||
{
|
||||
if (scl->data) {
|
||||
char *p = (char *)scl->data;
|
||||
|
|
Loading…
Reference in New Issue