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-02 19:56:19 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-02 19:56:19 +0400
commit8c730b1059032f45da06c278715909b71009909c (patch)
tree88078ebd72fec6bd47d310dc41f9a38f26db6fdc /source/blender/gpu
parent6785e45951288bca8176893dba46e73c10ad2673 (diff)
Fix T39520, show diffuse not working in dyntopo.
Was marked as a todo in the code. This does not yet take care of correct display for multi material meshes, since it would need correct separation of faces during pbvh creation. Instead we just take material of first face in node and assume that the rest faces have the same. This will create some funky effects if one attempts to sculpt in this way. Note: This does not yet address T39517
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_buffers.h5
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c38
2 files changed, 32 insertions, 11 deletions
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index eca74317585..0629bae26f6 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -179,7 +179,8 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
struct BMesh *bm,
struct GHash *bm_faces,
struct GSet *bm_unique_verts,
- struct GSet *bm_other_verts);
+ struct GSet *bm_other_verts,
+ int show_diffuse_color);
void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **grids,
const struct DMFlagMat *grid_flag_mats,
@@ -189,7 +190,7 @@ void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **gr
void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
bool wireframe);
-bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, bool show_diffuse_color);
+bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GHash *bm_faces, bool show_diffuse_color);
void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 3d5879b22d3..7875cad289a 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -1954,14 +1954,12 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v,
int *v_index,
const float fno[3],
const float *fmask,
- const int cd_vert_mask_offset)
+ const int cd_vert_mask_offset,
+ const float diffuse_color[4])
{
if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
VertexBufferFormat *vd = &vert_data[*v_index];
- /* TODO: should use material color */
- float diffuse_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
/* Set coord, normal, and mask */
copy_v3_v3(vd->co, v->co);
normal_float_to_short_v3(vd->no, fno ? fno : v->no);
@@ -2024,15 +2022,19 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
BMesh *bm,
GHash *bm_faces,
GSet *bm_unique_verts,
- GSet *bm_other_verts)
+ GSet *bm_other_verts,
+ int show_diffuse_color)
{
VertexBufferFormat *vert_data;
void *tri_data;
int tottri, totvert, maxvert = 0;
+ float diffuse_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
/* TODO, make mask layer optional for bmesh buffer */
const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
+ buffers->show_diffuse_color = show_diffuse_color;
+
if (!buffers->vert_buf || (buffers->smooth && !buffers->index_buf))
return;
@@ -2059,6 +2061,15 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
return;
}
+ if (show_diffuse_color) {
+ /* due to dynamc nature of dyntopo, only get first material */
+ GHashIterator gh_iter;
+ BMFace *f;
+ BLI_ghashIterator_init(&gh_iter, bm_faces);
+ f = BLI_ghashIterator_getKey(&gh_iter);
+ GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ }
+
/* Initialize vertex buffer */
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
@@ -2080,13 +2091,13 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
GSET_ITER (gs_iter, bm_unique_verts) {
gpu_bmesh_vert_to_buffer_copy(BLI_gsetIterator_getKey(&gs_iter),
vert_data, &v_index, NULL, NULL,
- cd_vert_mask_offset);
+ cd_vert_mask_offset, diffuse_color);
}
GSET_ITER (gs_iter, bm_other_verts) {
gpu_bmesh_vert_to_buffer_copy(BLI_gsetIterator_getKey(&gs_iter),
vert_data, &v_index, NULL, NULL,
- cd_vert_mask_offset);
+ cd_vert_mask_offset, diffuse_color);
}
maxvert = v_index;
@@ -2116,7 +2127,7 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
for (i = 0; i < 3; i++) {
gpu_bmesh_vert_to_buffer_copy(v[i], vert_data,
&v_index, f->no, &fmask,
- cd_vert_mask_offset);
+ cd_vert_mask_offset, diffuse_color);
}
}
}
@@ -2203,6 +2214,7 @@ GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading)
glGenBuffersARB(1, &buffers->vert_buf);
buffers->use_bmesh = true;
buffers->smooth = smooth_shading;
+ buffers->show_diffuse_color = false;
return buffers;
}
@@ -2498,7 +2510,7 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
}
}
-bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, bool show_diffuse_color)
+bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GHash *bm_faces, bool show_diffuse_color)
{
float diffuse_color[4];
@@ -2513,6 +2525,14 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, bool show_diffu
GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
}
+ else if (buffers->use_bmesh) {
+ /* due to dynamc nature of dyntopo, only get first material */
+ GHashIterator gh_iter;
+ BMFace *f;
+ BLI_ghashIterator_init(&gh_iter, bm_faces);
+ f = BLI_ghashIterator_getKey(&gh_iter);
+ GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ }
else {
const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]];