[Bf-blender-cvs] [b991a92aaba] sculpt-dev: Merge branch 'master' into sculpt-dev
Pablo Dobarro
noreply at git.blender.org
Fri Aug 6 17:33:47 CEST 2021
Commit: b991a92aababe63ef85e1726a7fb94e840302cb9
Author: Pablo Dobarro
Date: Thu Aug 5 20:10:57 2021 +0200
Branches: sculpt-dev
https://developer.blender.org/rBb991a92aababe63ef85e1726a7fb94e840302cb9
Merge branch 'master' into sculpt-dev
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 5e17b006ac8,9f5703a015d..b77f18954b1
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@@ -330,82 -328,9 +330,82 @@@ void BKE_mesh_remesh_reproject_paint_ma
free_bvhtree_from_mesh(&bvhtree);
}
+void BKE_mesh_remesh_sculpt_array_update(Object *ob, Mesh *target, Mesh *source)
+{
+
+ SculptSession *ss = ob->sculpt;
+
+ if (!ss) {
+ return;
+ }
+
+ SculptArray *array = ss->array;
+ if (!array) {
+ return;
+ }
+
+ BVHTreeFromMesh bvhtree = {
+ .nearest_callback = NULL,
+ };
+ BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
+ MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
+
+ const int target_totvert = target->totvert;
+
+ int *target_copy_index = (int *)MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
+ int *target_symmertry = (int *)MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
+ float (*target_orco)[3] = (float (*)[3])MEM_malloc_arrayN(target->totvert, sizeof(float) * 3, "array orco");
+
+ for (int i = 0; i < target_totvert; i++) {
+ target_copy_index[i] = -1;
+ target_symmertry[i] = 0;
+ copy_v3_v3(target_orco[i], target->mvert[i].co);
+ }
+
+ for (int i = 0; i < target->totvert; i++) {
+ float from_co[3];
+ BVHTreeNearest nearest;
+ nearest.index = -1;
+ nearest.dist_sq = FLT_MAX;
+ copy_v3_v3(from_co, target_verts[i].co);
+ BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
+ if (nearest.index != -1) {
+ target_copy_index[i] = array->copy_index[nearest.index];
+ target_symmertry[i] = array->symmetry_pass[nearest.index];
+ }
+ }
+ free_bvhtree_from_mesh(&bvhtree);
+
+ MEM_freeN(array->copy_index);
+ MEM_freeN(array->symmetry_pass);
+ MEM_freeN(array->orco);
+
+ array->copy_index = target_copy_index;
+ array->symmetry_pass = target_symmertry;
+ array->orco = target_orco;
+
+ for (int i = 0; i < target->totvert; i++) {
+ int array_index = target_copy_index[i];
+ int array_symm_pass = target_symmertry[i];
+ if (array_index == -1) {
+ continue;
+ }
+ SculptArrayCopy *copy = &array->copies[array_symm_pass][array_index];
+ float co[3];
+ float source_origin_symm[3];
+ copy_v3_v3(co, target->mvert[i].co);
+ /* TODO: MAke symmetry work here. */
+ //flip_v3_v3(source_origin_symm, array->source_origin, array_symm_pass);
+ mul_v3_m4v3(co, array->source_imat, co);
+ mul_v3_m4v3(co, copy->imat, co);
+ sub_v3_v3v3(co, co, source_origin_symm);
+ copy_v3_v3(array->orco[i], co);
+ }
+}
+
void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, Mesh *source)
{
- BVHTreeFromMesh bvhtree = {{nullptr}};
+ BVHTreeFromMesh bvhtree = {nullptr};
const MPoly *target_polys = (const MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY);
const MVert *target_verts = (const MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
@@@ -450,37 -375,9 +450,37 @@@
free_bvhtree_from_mesh(&bvhtree);
}
+void BKE_remesh_reproject_materials(Mesh *target, Mesh *source)
+{
+ BVHTreeFromMesh bvhtree = {
+ .nearest_callback = NULL,
+ };
+
+ const MPoly *target_polys = (MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY);
+ const MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
+ const MLoop *target_loops = (MLoop *)CustomData_get_layer(&target->ldata, CD_MLOOP);
+
+ const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
+ BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_LOOPTRI, 2);
+
+ for (int i = 0; i < target->totpoly; i++) {
+ float from_co[3];
+ BVHTreeNearest nearest;
+ nearest.index = -1;
+ nearest.dist_sq = FLT_MAX;
+ const MPoly *mpoly = &target_polys[i];
+ BKE_mesh_calc_poly_center(mpoly, &target_loops[mpoly->loopstart], target_verts, from_co);
+ BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
+ if (nearest.index != -1) {
+ target->mpoly[i].mat_nr = source->mpoly[looptri[nearest.index].poly].mat_nr;
+ }
+ }
+ free_bvhtree_from_mesh(&bvhtree);
+}
+
void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
{
- BVHTreeFromMesh bvhtree = {{nullptr}};
+ BVHTreeFromMesh bvhtree = {nullptr};
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
int tot_color_layer = CustomData_number_of_layers(&source->vdata, CD_PROP_COLOR);
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index af114b5b3a3,8264affc465..efa902d11c2
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -8820,12 -7887,10 +8820,15 @@@ static bool sculpt_stroke_test_start(bC
sculpt_update_cache_invariants(C, sd, ss, op, mouse);
+ SculptCursorGeometryInfo sgi;
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+
SCULPT_undo_push_begin(ob, sculpt_tool_name(sd));
+
+ Brush *brush = BKE_paint_brush(&sd->paint);
+ if (brush->sculpt_tool == SCULPT_TOOL_ARRAY) {
+ SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_GEOMETRY);
+ }
return true;
}
More information about the Bf-blender-cvs
mailing list