[Bf-blender-cvs] [37a657a45f3] temp_bmesh_multires: Added face set support to dyntopo. Still need to finish "edit face sets" tool and do more testing.
Joseph Eagar
noreply at git.blender.org
Wed Nov 4 01:06:06 CET 2020
Commit: 37a657a45f34bd759a28e1c246ca5d6722f1025c
Author: Joseph Eagar
Date: Tue Nov 3 16:05:38 2020 -0800
Branches: temp_bmesh_multires
https://developer.blender.org/rB37a657a45f34bd759a28e1c246ca5d6722f1025c
Added face set support to dyntopo. Still need to finish "edit face
sets" tool and do more testing.
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/paint.c
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenkernel/intern/pbvh_intern.h
M source/blender/bmesh/intern/bmesh_log.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_face_set.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_undo.c
M source/blender/gpu/GPU_buffers.h
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index a110b45da25..3183539da3c 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -479,6 +479,8 @@ typedef struct SculptSession {
int cd_vert_node_offset;
int cd_face_node_offset;
int cd_vcol_offset;
+ int cd_faceset_offset;
+
bool bm_smooth_shading;
/* Undo/redo log for dynamic topology sculpting */
struct BMLog *bm_log;
@@ -506,8 +508,8 @@ typedef struct SculptSession {
/* Cursor data and active vertex for tools */
SculptVertRef active_vertex_index;
+ SculptFaceRef active_face_index;
- int active_face_index;
int active_grid_index;
/* When active, the cursor draws with faded colors, indicating that there is an action enabled.
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 28df1a259e6..36f7764c6ec 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -37,12 +37,20 @@ typedef struct {
int64_t i;
} SculptVertRef;
+typedef SculptVertRef SculptFaceRef;
+
BLI_INLINE SculptVertRef BKE_pbvh_make_vref(intptr_t i)
{
SculptVertRef ret = {i};
return ret;
}
+BLI_INLINE SculptFaceRef BKE_pbvh_make_fref(intptr_t i)
+{
+ SculptFaceRef ret = {i};
+ return ret;
+}
+
struct BMLog;
struct BMesh;
struct BMVert;
@@ -267,7 +275,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
struct IsectRayPrecalc *isect_precalc,
float *depth,
SculptVertRef *active_vertex_index,
- int *active_face_grid_index,
+ SculptFaceRef *active_face_grid_index,
float *face_normal);
bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 994616819e2..8a40bde0a7e 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1737,15 +1737,16 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
SCULPT_dynamic_topology_sync_layers(object, orig_me);
}
-/** \warning Expects a fully evaluated depsgraph. */
void BKE_sculpt_update_object_for_edit(
Depsgraph *depsgraph, Object *ob_orig, bool need_pmap, bool need_mask, bool need_colors)
{
- BLI_assert(ob_orig == DEG_get_original_object(ob_orig));
-
+ /* Update from sculpt operators and undo, to update sculpt session
+ * and PBVH after edits. */
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig);
- Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
- BLI_assert(me_eval != NULL);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
+
+ BLI_assert(ob_orig == DEG_get_original_object(ob_orig));
sculpt_update_object(depsgraph, ob_orig, me_eval, need_pmap, need_mask, need_colors);
}
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 102eaefc245..47da1e913cc 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -845,11 +845,8 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
return NULL;
}
-void BKE_pbvh_search_gather(PBVH *pbvh,
- BKE_pbvh_SearchCallback scb,
- void *search_data,
- PBVHNode ***r_array,
- int *r_tot)
+void BKE_pbvh_search_gather(
+ PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***r_array, int *r_tot)
{
PBVHIter iter;
PBVHNode **array = NULL, *node;
@@ -1337,7 +1334,9 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
node->bm_unique_verts,
node->bm_other_verts,
update_flags,
- pbvh->cd_vert_node_offset);
+ pbvh->cd_vert_node_offset,
+ pbvh->face_sets_color_seed,
+ pbvh->face_sets_color_default);
break;
}
}
@@ -2175,7 +2174,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
struct IsectRayPrecalc *isect_precalc,
float *depth,
SculptVertRef *r_active_vertex_index,
- int *r_active_face_index,
+ SculptFaceRef *r_active_face_index,
float *r_face_normal)
{
const MVert *vert = pbvh->verts;
@@ -2225,7 +2224,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, co[j]);
*r_active_vertex_index = BKE_pbvh_make_vref(mloop[lt->tri[j]].v);
- *r_active_face_index = lt->poly;
+ r_active_face_index->i = lt->poly;
}
}
}
@@ -2243,7 +2242,7 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
struct IsectRayPrecalc *isect_precalc,
float *depth,
SculptVertRef *r_active_vertex_index,
- int *r_active_grid_index,
+ SculptFaceRef *r_active_grid_index,
float *r_face_normal)
{
const int totgrid = node->totprim;
@@ -2316,7 +2315,7 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
}
}
if (r_active_grid_index) {
- *r_active_grid_index = grid_index;
+ r_active_grid_index->i = grid_index;
}
}
}
@@ -2339,7 +2338,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
struct IsectRayPrecalc *isect_precalc,
float *depth,
SculptVertRef *active_vertex_index,
- int *active_face_grid_index,
+ SculptFaceRef *active_face_grid_index,
float *face_normal)
{
bool hit = false;
@@ -2382,6 +2381,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
depth,
use_origco,
active_vertex_index,
+ active_face_grid_index,
face_normal);
break;
}
@@ -3092,7 +3092,7 @@ bool pbvh_has_face_sets(PBVH *pbvh)
case PBVH_FACES:
return (pbvh->pdata && CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS));
case PBVH_BMESH:
- return false;
+ return (pbvh->bm && CustomData_get_layer(&pbvh->bm->pdata, CD_SCULPT_FACE_SETS));
}
return false;
@@ -3153,7 +3153,8 @@ void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide)
pbvh->respect_hide = respect_hide;
}
-int BKE_pbvh_get_node_index(PBVH *pbvh, PBVHNode *node) {
+int BKE_pbvh_get_node_index(PBVH *pbvh, PBVHNode *node)
+{
return (int)(node - pbvh->nodes);
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 85d4625ab3b..505db38d42d 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -2061,10 +2061,11 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
/* Move v_conn to the midpoint of v_conn and v_del (if v_conn still exists, it
* may have been deleted above) */
if (v_conn != NULL) {
- //log vert in bmlog, but don't update original customata layers, we want them to be interpolated
+ // log vert in bmlog, but don't update original customata layers, we want them to be
+ // interpolated
BM_log_vert_before_modified(pbvh->bm_log, v_conn, eq_ctx->cd_vert_mask_offset, true);
- //void *dummy;
- //BKE_pbvh_bmesh_update_origvert(pbvh, v_conn, &dummy, &dummy, &dummy);
+ // void *dummy;
+ // BKE_pbvh_bmesh_update_origvert(pbvh, v_conn, &dummy, &dummy, &dummy);
mid_v3_v3v3(v_conn->co, v_conn->co, v_del->co);
add_v3_v3(v_conn->no, v_del->no);
@@ -2223,6 +2224,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
float *depth,
bool use_original,
SculptVertRef *r_active_vertex_index,
+ SculptFaceRef *r_active_face_index,
float *r_face_normal)
{
bool hit = false;
@@ -2270,6 +2272,10 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
if (r_active_vertex_index) {
*r_active_vertex_index = BKE_pbvh_make_vref((intptr_t)l->v);
}
+
+ if (r_active_face_index) {
+ *r_active_face_index = BKE_pbvh_make_fref((intptr_t)l->f);
+ }
}
}
}
@@ -2305,6 +2311,10 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
copy_v3_v3(nearest_vertex_co, v_tri[j]->co);
SculptVertRef vref = {(intptr_t)v_tri[j]}; // BM_elem_index_get(v_tri[j]);
*r_active_vertex_index = vref;
+
+ if (r_active_face_index) {
+ *r_active_face_index = BKE_pbvh_make_fref((intptr_t)f);
+ }
}
}
}
@@ -2656,6 +2666,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
pbvh->type = PBVH_BMESH;
pbvh->bm_log = log;
pbvh->cd_vcol_offset = CustomData_get_offset(&bm->vdata, CD_PROP_COLOR);
+ pbvh->cd_faceset_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
/* TODO: choose leaf limit better */
pbvh->leaf_limit = 1000;
@@ -3567,6 +3578,7 @@ void BKE_pbvh_update_offsets(PBVH *pbvh,
pbvh->cd_origco_offset = cd_origco_offset;
pbvh->cd_origno_offset = cd_origno_offset;
pbvh->cd_origvcol_offse
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list