[Bf-blender-cvs] [12c8e10] soc-2016-pbvh-painting: Fixed multires bug.
Nathan Vollmer
noreply at git.blender.org
Sun Dec 18 05:30:15 CET 2016
Commit: 12c8e10c3989c1bb536a56604582c9cfffd62541
Author: Nathan Vollmer
Date: Sat Dec 17 21:29:59 2016 -0700
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB12c8e10c3989c1bb536a56604582c9cfffd62541
Fixed multires bug.
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/object.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/subsurf_ccg.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/tools
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index ee35b90..81e6949 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit ee35b906abbd72c1a36e61027b15e9af970f5f2b
+Subproject commit 81e6949b1f1bf3da1b685610bf76efcc7adc30a4
diff --git a/release/scripts/addons b/release/scripts/addons
index d5d095f..e7c7ef6 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit d5d095f2bc3ea279b3a52003d2496d9d52a754d9
+Subproject commit e7c7ef6be466111196c283f48b51c372e4167a88
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 04af69b..2f47d3d 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 04af69be141a5757fc60b44cc1a5b72db524af30
+Subproject commit 2f47d3d7cfea05672f7bb706c6878b7d07d52a1b
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 9be9f64..3a46e82 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -218,6 +218,7 @@ typedef struct SculptSession {
void BKE_sculptsession_free(struct Object *ob);
void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
+void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob,
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index f99019b..bece60d 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -190,7 +190,7 @@ void BKE_pbvh_node_num_verts(
void BKE_pbvh_node_get_verts(
PBVH *bvh, PBVHNode *node,
const int **r_vert_indices, struct MVert **r_verts);
-void BKE_pbvh_node_num_nodes(PBVH *bvh, int* r_totnode);
+void BKE_pbvh_get_num_nodes(PBVH *bvh, int* r_totnode);
void BKE_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
void BKE_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index c6666ec..ebe8091 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2751,6 +2751,9 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
}
BKE_sculptsession_free_deformMats(ob->sculpt);
+
+ /* In VWpaint, force maps to be rebuilt. */
+ BKE_sculptsession_free_vwpaint_data(ob->sculpt);
}
else {
PBVHNode **nodes;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 69bac3d..b1006f3 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -656,6 +656,48 @@ void BKE_sculptsession_free_deformMats(SculptSession *ss)
MEM_SAFE_FREE(ss->deform_imats);
}
+void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss) {
+ /* Free maps */
+ if (ss->vert_to_loop) {
+ MEM_freeN(ss->vert_to_loop);
+ ss->vert_to_loop = NULL;
+ }
+ if (ss->vert_map_mem) {
+ MEM_freeN(ss->vert_map_mem);
+ ss->vert_map_mem = NULL;
+ }
+ if (ss->vert_to_poly) {
+ MEM_freeN(ss->vert_to_poly);
+ ss->vert_to_poly = NULL;
+ }
+ if (ss->poly_map_mem) {
+ MEM_freeN(ss->poly_map_mem);
+ ss->poly_map_mem = NULL;
+ }
+
+ /* Free average, blur, and spray brush arrays */
+ if (ss->tot_loops_hit) {
+ MEM_freeN(ss->tot_loops_hit);
+ ss->tot_loops_hit = NULL;
+ }
+ if (ss->total_color) {
+ MEM_freeN(ss->total_color);
+ ss->total_color = NULL;
+ }
+ if (ss->total_weight) {
+ MEM_freeN(ss->total_weight);
+ ss->total_weight = NULL;
+ }
+ if (ss->max_weight) {
+ MEM_freeN(ss->max_weight);
+ ss->max_weight = NULL;
+ }
+ if (ss->previous_color) {
+ MEM_freeN(ss->previous_color);
+ ss->previous_color = NULL;
+ }
+}
+
/* Write out the sculpt dynamic-topology BMesh to the Mesh */
static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
{
@@ -747,27 +789,7 @@ void BKE_sculptsession_free(Object *ob)
if (ss->deform_imats)
MEM_freeN(ss->deform_imats);
- /* Free maps */
- if (ss->vert_to_loop)
- MEM_freeN(ss->vert_to_loop);
- if (ss->vert_map_mem)
- MEM_freeN(ss->vert_map_mem);
- if (ss->vert_to_poly)
- MEM_freeN(ss->vert_to_poly);
- if (ss->poly_map_mem)
- MEM_freeN(ss->poly_map_mem);
-
- /* Free average, blur, and spray brush arrays */
- if (ob->sculpt->tot_loops_hit)
- MEM_freeN(ob->sculpt->tot_loops_hit);
- if (ob->sculpt->total_color)
- MEM_freeN(ob->sculpt->total_color);
- if (ob->sculpt->total_weight)
- MEM_freeN(ob->sculpt->total_weight);
- if (ob->sculpt->max_weight)
- MEM_freeN(ob->sculpt->max_weight);
- if (ob->sculpt->previous_color)
- MEM_freeN(ob->sculpt->previous_color);
+ BKE_sculptsession_free_vwpaint_data(ob->sculpt);
MEM_freeN(ss);
@@ -881,7 +903,8 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- if (mmd) {
+ /* VWPaint require mesh info for loop lookup, so require sculpt mode here */
+ if (mmd && ob->mode & OB_MODE_SCULPT) {
ss->multires = mmd;
ss->totvert = dm->getNumVerts(dm);
ss->totpoly = dm->getNumPolys(dm);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 8d588d5..e3a5bd1 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1403,7 +1403,7 @@ void BKE_pbvh_node_num_verts(
}
}
-void BKE_pbvh_node_num_nodes(PBVH *bvh, int* r_totnode) {
+void BKE_pbvh_get_num_nodes(PBVH *bvh, int* r_totnode) {
*r_totnode = bvh->totnode;
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 2e1064d..53dae7a 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -4441,7 +4441,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
/* no pbvh exists yet, we need to create one. only in case of multires
* we build a pbvh over the modified mesh, in other cases the base mesh
* is being sculpted, so we build a pbvh from that. */
- if (grid_pbvh) {
+ /* Note: VWPaint do not support PBVH_GRIDS at the moment. */
+ if (grid_pbvh && ob->mode & OB_MODE_SCULPT) {
ccgdm_create_grids(dm);
numGrids = ccgDM_getNumGrids(dm);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 187f4d3..96858b2 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1656,34 +1656,40 @@ static void do_weight_paint_vertex(
/ copied from sculpt.c ****/
static void vertex_paint_init_session(Scene *scene, Object *ob)
{
- ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
+ if (!ob->sculpt)
+ ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false);
}
static void vertex_paint_init_session_maps(Object *ob) {
/* Create maps */
- Mesh *me = ob->data;
- ob->sculpt->vert_map_mem = NULL;
- ob->sculpt->vert_to_loop = NULL;
- ob->sculpt->poly_map_mem = NULL;
- ob->sculpt->vert_to_poly = NULL;
- BKE_mesh_vert_loop_map_create(&ob->sculpt->vert_to_loop, &ob->sculpt->vert_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
- BKE_mesh_vert_poly_map_create(&ob->sculpt->vert_to_poly, &ob->sculpt->poly_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
+ if (!ob->sculpt->vert_to_loop)
+ {
+ Mesh *me = ob->data;
+ ob->sculpt->vert_map_mem = NULL;
+ ob->sculpt->vert_to_loop = NULL;
+ ob->sculpt->poly_map_mem = NULL;
+ ob->sculpt->vert_to_poly = NULL;
+ BKE_mesh_vert_loop_map_create(&ob->sculpt->vert_to_loop, &ob->sculpt->vert_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
+ BKE_mesh_vert_poly_map_create(&ob->sculpt->vert_to_poly, &ob->sculpt->poly_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
+ }
}
static void vertex_paint_init_session_average_arrays(Object *ob){
/* Create average brush arrays */
- int totNode = 0;
- /* I think the totNodes might include internal nodes, and we really only need the tot leaves. */
- BKE_pbvh_node_num_nodes(ob->sculpt->pbvh, &totNode);
- Mesh *me = BKE_mesh_from_object(ob);
+ if (!ob->sculpt->tot_loops_hit) {
+ int totNode = 0;
+ /* I think the totNodes might include internal nodes, and we really only need the tot leaves. */
+ BKE_pbvh_get_num_nodes(ob->sculpt->pbvh, &totNode);
+ Mesh *me = BKE_mesh_from_object(ob);
- /* Need unsigned long to prevent overflow when averaging multiple whites, which take up an entire unsigned int each. */
- ob->sculpt->total_color = MEM_callocN(totNode * 3 * sizeof(unsigned int), "total_color");
- ob->sculpt->total_weight = MEM_callocN(totNode * sizeof(double), "total_weight");
- ob->sculpt->tot_loops_hit = MEM_callocN(totNode * sizeof(unsigned int), "tot_loops_hit");
- ob->sculpt->max_weight = MEM_callocN(me->totvert * sizeof(float), "max_weight");
- ob->sculpt->previous_color = MEM_callocN(me->totloop * sizeof(unsigned int), "previous_color");
+ /* Need unsigned long to prevent overflow when averaging multiple whites, which take up an entire unsigned int each. */
+ ob->sculpt->total_color = MEM_callocN(totNode * 3 * sizeof(unsigned int), "total_color");
+ ob->sculpt->total_weight = MEM_callocN(totNode * sizeof(double), "total_weight");
+ ob->sculpt->tot_loops_hit = MEM_callocN(totNode * sizeof(unsigned int), "tot_loops_hit");
+ ob->sculpt->max_weight = MEM_callocN(me->totvert * sizeof(float), "max_weight");
+ ob->sculpt->previous_color = MEM_callocN(me->totloop * sizeof(unsigned int), "previous_color");
+ }
}
/* *************** set wpaint operator ****************** */
@@ -1751,9 +1757,6 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_sculptsession
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list