diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-05-11 00:51:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-05-11 00:53:03 +0300 |
commit | 1e9f922c9e310eda225ca2cb9d72f6b86be0348c (patch) | |
tree | 1882680c4fe5e61b096e90dbb9741ba88b854c08 /source/blender/gpu/intern/gpu_buffers.c | |
parent | 891159cea064ea83e78e9fb1ccb03bc2517ed62d (diff) | |
parent | 722bcb554f9c2bb26c9abde5d8a3a16c5e3075bc (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/gpu/intern/gpu_buffers.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 7a5ed4784d4..707bdf7d829 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1104,6 +1104,9 @@ void GPU_update_mesh_pbvh_buffers( copy_v4_v4(buffers->diffuse_color, diffuse_color); + uchar diffuse_color_ub[4]; + rgba_float_to_uchar(diffuse_color_ub, diffuse_color); + /* Build VBO */ VERTEXBUFFER_DISCARD_SAFE(buffers->vert_buf); @@ -1129,16 +1132,16 @@ void GPU_update_mesh_pbvh_buffers( for (uint i = 0; i < buffers->face_indices_len; i++) { const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; for (uint j = 0; j < 3; j++) { - int v_orig = buffers->mloop[lt->tri[j]].v; - int v_index = face_vert_indices[i][j]; - uchar color_ub[3]; + int vidx = face_vert_indices[i][j]; if (vmask) { - gpu_color_from_mask_copy(vmask[v_orig], diffuse_color, color_ub); + int v_index = buffers->mloop[lt->tri[j]].v; + uchar color_ub[3]; + gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub); + VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.col, vidx, color_ub); } else { - rgb_float_to_uchar(color_ub, diffuse_color); + VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.col, vidx, diffuse_color_ub); } - VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.col, v_index, color_ub); } } } @@ -1156,8 +1159,6 @@ void GPU_update_mesh_pbvh_buffers( buffers->mloop[lt->tri[2]].v, }; - float fmask; - if (paint_is_face_hidden(lt, mvert, buffers->mloop)) continue; @@ -1170,10 +1171,13 @@ void GPU_update_mesh_pbvh_buffers( mpoly_prev = lt->poly; } + uchar color_ub[3]; if (vmask) { - fmask = (vmask[vtri[0]] + - vmask[vtri[1]] + - vmask[vtri[2]]) / 3.0f; + float fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f; + gpu_color_from_mask_copy(fmask, diffuse_color, color_ub); + } + else { + copy_v3_v3_uchar(color_ub, diffuse_color_ub); } for (uint j = 0; j < 3; j++) { @@ -1181,13 +1185,6 @@ void GPU_update_mesh_pbvh_buffers( VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.pos, vbo_index, v->co); VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.nor, vbo_index, no); - - uchar color_ub[3]; \ - if (vmask) - gpu_color_from_mask_copy(fmask, diffuse_color, color_ub); - else - rgb_float_to_uchar(color_ub, diffuse_color); - VertexBuffer_set_attrib(buffers->vert_buf, vbo_id.col, vbo_index, color_ub); vbo_index++; |