diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 21:33:53 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 21:33:53 +0400 |
commit | 6e62491c5a101ee36ec48db97e4a4f4945f5eada (patch) | |
tree | 7f118f3c3acbee43cee33494bb6da332a8a68ee5 /source/blender/blenlib/intern/pbvh.c | |
parent | c6b4494727144154511cdacb0e9e832a4b6fefc1 (diff) |
Fix #32522: Object's diffuse color not showing in Sculpt Mode
Added option to display object's diffuse color multiplied by sculpting
mask. This option could be found in Options panel of toolshelf when in
sculpting mode.
Thanks to Nicholas and Brecht for reviewing the patch!
Diffstat (limited to 'source/blender/blenlib/intern/pbvh.c')
-rw-r--r-- | source/blender/blenlib/intern/pbvh.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index bf237ffd75a..2ac84062d0c 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -157,6 +157,8 @@ struct PBVH { /* flag are verts/faces deformed */ int deformed; + + int show_diffuse_color; }; #define STACK_FIXED_DEPTH 100 @@ -1001,7 +1003,7 @@ static int update_search_cb(PBVHNode *node, void *data_v) if (node->flag & PBVH_Leaf) return (node->flag & flag); - + return 1; } @@ -1165,7 +1167,8 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) bvh->grid_flag_mats, node->prim_indices, node->totprim, - &bvh->gridkey); + &bvh->gridkey, + bvh->show_diffuse_color); break; case PBVH_FACES: GPU_update_mesh_buffers(node->draw_buffers, @@ -1174,7 +1177,9 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->uniq_verts + node->face_verts, CustomData_get_layer(bvh->vdata, - CD_PAINT_MASK)); + CD_PAINT_MASK), + node->face_vert_indices, + bvh->show_diffuse_color); break; } @@ -1667,11 +1672,23 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE; } +static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node) +{ + if (!node->draw_buffers) + return; + + if (GPU_buffers_diffuse_changed(node->draw_buffers, bvh->show_diffuse_color)) + node->flag |= PBVH_UpdateDrawBuffers; +} + void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], DMSetMaterial setMaterial) { PBVHNode **nodes; - int totnode; + int a, totnode; + + for (a = 0; a < bvh->totnode; a++) + pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]); BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), &nodes, &totnode); @@ -1876,3 +1893,8 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, if (!vi->grids) vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK); } + +void pbvh_show_diffuse_color_set(PBVH *bvh, int show_diffuse_color) +{ + bvh->show_diffuse_color = show_diffuse_color; +} |