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:
authorAntony Riakiotakis <kalast@gmail.com>2014-04-17 21:53:20 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-17 21:53:40 +0400
commit169f8313940e826587fc50b3c4e3b082d15b51e5 (patch)
tree97e968ed2f30d326530d7a666fea3f49b1adc37b
parentfe3eb825206c969a2cf333769e6b58f2abec74b1 (diff)
Make sure we invalidate the node ID layer each time the PBVH is reset.
It makes code more tidy (avoids having to call invalidation on a myriad places). Also makes sure other invalidation cases (some mesh change, e.g.) work as expected.
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c22
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c23
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c7
4 files changed, 22 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index d316cbba86b..e2e4592403c 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1143,6 +1143,26 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
/***************************** Public API *****************************/
+static void pbvh_bmesh_node_layers_reset(PBVH *bvh)
+{
+ BMFace *f;
+ BMVert *v;
+ BMIter iter;
+ BMesh *bm = bvh->bm;
+ int cd_vert_node_offset = bvh->cd_vert_node_offset;
+ int cd_face_node_offset = bvh->cd_face_node_offset;
+
+ /* clear the elements of the node information */
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
+ }
+
+ BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
+ }
+}
+
+
/* Build a PBVH from a BMesh */
void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log,
const int cd_vert_node_offset, const int cd_face_node_offset)
@@ -1167,6 +1187,8 @@ void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log,
if (smooth_shading)
bvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
+ pbvh_bmesh_node_layers_reset(bvh);
+
/* Start with all faces in the root node */
n = bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
bvh->totnode = 1;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index f5bdbfa974d..16c0f9bc4fb 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4793,25 +4793,6 @@ void sculpt_pbvh_clear(Object *ob)
BKE_object_free_derived_caches(ob);
}
-void sculpt_dyntopo_node_layers_reset(SculptSession *ss)
-{
- BMFace *f;
- BMVert *v;
- BMIter iter;
- BMesh *bm = ss->bm;
- int cd_vert_node_offset = ss->cd_vert_node_offset;
- int cd_face_node_offset = ss->cd_face_node_offset;
-
- /* clear the elements of the node information */
- BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
- BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
- }
-
- BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
- BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
- }
-}
-
void sculpt_dyntopo_node_layers_add(SculptSession *ss)
{
int cd_node_layer_index;
@@ -4874,7 +4855,6 @@ void sculpt_dynamic_topology_enable(bContext *C)
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
sculpt_dyntopo_node_layers_add(ss);
/* make sure the data for existing faces are initialized */
- sculpt_dyntopo_node_layers_reset(ss);
BM_mesh_normals_update(ss->bm);
/* Enable dynamic topology */
@@ -5013,7 +4993,6 @@ static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
sculpt_pbvh_clear(ob);
- sculpt_dyntopo_node_layers_reset(ob->sculpt);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -5072,7 +5051,6 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op))
/* Redraw */
sculpt_pbvh_clear(ob);
- sculpt_dyntopo_node_layers_reset(ss);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -5333,7 +5311,6 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
/* force rebuild of pbvh for better BB placement */
sculpt_pbvh_clear(ob);
- sculpt_dyntopo_node_layers_reset(ss);
/* Redraw */
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 8cf5bf88bcc..a4d2f0dc057 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -48,7 +48,6 @@ struct MultiresModifierData;
struct Object;
struct Scene;
struct Sculpt;
-struct SculptSession;
struct SculptStroke;
struct SculptUndoNode;
@@ -68,7 +67,6 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);
-void sculpt_dyntopo_node_layers_reset(struct SculptSession *ss);
void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
void sculpt_update_after_dynamic_topology_toggle(bContext *C);
void sculpt_dynamic_topology_enable(struct bContext *C);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 39df15bd985..6ac65e431ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -301,7 +301,6 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
MEM_freeN(nodes);
}
else {
- sculpt_dyntopo_node_layers_reset(ss);
sculpt_pbvh_clear(ob);
}
}
@@ -341,9 +340,6 @@ static void sculpt_undo_bmesh_restore_begin(bContext *C,
/* Restore the mesh from the first log entry */
BM_log_redo(ss->bm, ss->bm_log);
- /* reset layers for all bmesh data */
- sculpt_dyntopo_node_layers_reset(ss);
-
unode->applied = true;
}
}
@@ -359,9 +355,6 @@ static void sculpt_undo_bmesh_restore_end(bContext *C,
/* Restore the mesh from the last log entry */
BM_log_undo(ss->bm, ss->bm_log);
- /* reset layers for all bmesh data */
- sculpt_dyntopo_node_layers_reset(ss);
-
unode->applied = false;
}
else {