Commit: 872d8993ddda28a4340730a5842af18ccf55fd2b
Author: Luca Rood
Date:   Fri May 5 14:25:43 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB872d8993ddda28a4340730a5842af18ccf55fd2b

Clean up weight/vertex painting code

Now passing selection state instead of colors for the wire/face mask
overlay thing. Also added masking indication on the faces in vertex
paint.

===================================================================

M       source/blender/draw/CMakeLists.txt
M       source/blender/draw/intern/draw_cache.c
M       source/blender/draw/intern/draw_cache.h
M       source/blender/draw/intern/draw_cache_impl.h
M       source/blender/draw/intern/draw_cache_impl_mesh.c
M       source/blender/draw/modes/paint_vertex_mode.c
M       source/blender/draw/modes/paint_weight_mode.c
A       source/blender/draw/modes/shaders/paint_wire_frag.glsl
A       source/blender/draw/modes/shaders/paint_wire_vert.glsl

===================================================================

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 15c9da0d9b5..4b5efe60eae 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -151,6 +151,8 @@ 
data_to_c_simple(modes/shaders/object_outline_expand_frag.glsl SRC)
 data_to_c_simple(modes/shaders/object_outline_detect_frag.glsl SRC)
 data_to_c_simple(modes/shaders/object_grid_frag.glsl SRC)
 data_to_c_simple(modes/shaders/object_grid_vert.glsl SRC)
+data_to_c_simple(modes/shaders/paint_wire_frag.glsl SRC)
+data_to_c_simple(modes/shaders/paint_wire_vert.glsl SRC)
 
 list(APPEND INC
 )
diff --git a/source/blender/draw/intern/draw_cache.c 
b/source/blender/draw/intern/draw_cache.c
index 7e49d998fa0..eed62725df5 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -1818,12 +1818,12 @@ Batch *DRW_cache_mesh_verts_get(Object *ob)
        return DRW_mesh_batch_cache_get_all_verts(me);
 }
 
-Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool 
use_sel, bool use_theme)
+Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool 
use_sel)
 {
        BLI_assert(ob->type == OB_MESH);
 
        Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, 
use_sel, use_theme);
+       return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, 
use_sel);
 }
 
 Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
diff --git a/source/blender/draw/intern/draw_cache.h 
b/source/blender/draw/intern/draw_cache.h
index 160cfaf1693..00031560113 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -99,7 +99,7 @@ struct Batch *DRW_cache_mesh_surface_vert_colors_get(struct 
Object *ob);
 struct Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
 struct Batch *DRW_cache_mesh_edges_get(struct Object *ob);
 struct Batch *DRW_cache_mesh_verts_get(struct Object *ob);
-struct Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool 
use_wire, bool use_sel,  bool use_theme);
+struct Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool 
use_wire, bool use_sel);
 struct Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
 struct Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
 struct Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl.h 
b/source/blender/draw/intern/draw_cache_impl.h
index bbb1c820f63..ddcc55fd85e 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -68,7 +68,7 @@ struct Batch 
*DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
 /* Mesh */
 
 struct Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
-struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, 
bool use_wire, bool use_sel, bool use_theme);
+struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, 
bool use_wire, bool use_sel);
 struct Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
 struct Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
 struct Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c 
b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 5d6f7673c9e..e17f3700bf6 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -51,8 +51,6 @@
 #include "GPU_batch.h"
 #include "GPU_draw.h"
 
-#include "UI_resources.h"
-
 #include "draw_cache_impl.h"  /* own include */
 
 static void mesh_batch_cache_clear(Mesh *me);
@@ -1329,8 +1327,8 @@ static bool mesh_render_data_looptri_cos_select_id_get(
 
 static bool mesh_render_data_edge_cos_sel_get(
         MeshRenderData *rdata, const int edge_idx,
-        float r_vert_cos[2][3], float r_vert_col[3],
-        bool use_wire, bool use_sel, bool use_theme)
+        float r_vert_cos[2][3], int *r_vert_sel,
+        bool use_wire, bool use_sel)
 {
        BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | 
MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
 
@@ -1361,20 +1359,11 @@ static bool mesh_render_data_edge_cos_sel_get(
                }
 
                if (use_sel && rdata->edge_selection[edge_idx]) {
-                       if (use_theme) {
-                               UI_GetThemeColorShade3fv(TH_EDGE_SELECT, -50, 
r_vert_col);
-                       }
-                       else {
-                               r_vert_col[0] = 1.0f;
-                               r_vert_col[1] = 1.0f;
-                               r_vert_col[2] = 1.0f;
-                       }
+                       *r_vert_sel = true;
                }
                else {
                        if (use_wire) {
-                               r_vert_col[0] = 0.5f;
-                               r_vert_col[1] = 0.5f;
-                               r_vert_col[2] = 0.5f;
+                               *r_vert_sel = false;
                        }
                        else {
                                return false;
@@ -1390,7 +1379,7 @@ static bool mesh_render_data_edge_cos_sel_get(
 
 static bool mesh_render_data_tri_cos_sel_get(
         MeshRenderData *rdata, const int tri_idx,
-        float r_vert_cos[3][3], float r_vert_col[4])
+        float r_vert_cos[3][3])
 {
        BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY | 
MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
 
@@ -1401,13 +1390,7 @@ static bool mesh_render_data_tri_cos_sel_get(
                const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
 
                if (rdata->mpoly[mlt->poly].flag & ME_FACE_SEL) {
-                       r_vert_col[3] = 0.0f;
-               }
-               else {
-                       r_vert_col[0] = 1.0f;
-                       r_vert_col[1] = 1.0f;
-                       r_vert_col[2] = 1.0f;
-                       r_vert_col[3] = 0.2f;
+                       return false;
                }
 
                copy_v3_v3(r_vert_cos[0], 
rdata->mvert[rdata->mloop[mlt->tri[0]].v].co);
@@ -1663,7 +1646,7 @@ typedef struct MeshBatchCache {
        Batch *overlay_loose_verts;
        Batch *overlay_loose_edges;
        Batch *overlay_facedots;
-       Batch *overlay_weight_edges;
+       Batch *overlay_paint_edges;
        Batch *overlay_weight_faces;
        Batch *overlay_weight_verts;
 
@@ -1800,7 +1783,7 @@ static void mesh_batch_cache_clear(Mesh *me)
        BATCH_DISCARD_ALL_SAFE(cache->overlay_loose_verts);
        BATCH_DISCARD_ALL_SAFE(cache->overlay_loose_edges);
        BATCH_DISCARD_ALL_SAFE(cache->overlay_facedots);
-       BATCH_DISCARD_ALL_SAFE(cache->overlay_weight_edges);
+       BATCH_DISCARD_ALL_SAFE(cache->overlay_paint_edges);
        BATCH_DISCARD_ALL_SAFE(cache->overlay_weight_faces);
        BATCH_DISCARD_ALL_SAFE(cache->overlay_weight_verts);
 
@@ -2373,7 +2356,7 @@ static ElementList 
**mesh_batch_cache_get_shaded_triangles_in_order(MeshRenderDa
 }
 
 static VertexBuffer *mesh_batch_cache_get_edge_pos_with_sel(
-        MeshRenderData *rdata, MeshBatchCache *cache, bool use_wire, bool 
use_sel, bool use_theme)
+        MeshRenderData *rdata, MeshBatchCache *cache, bool use_wire, bool 
use_sel)
 {
        BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | 
MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
 
@@ -2385,7 +2368,7 @@ static VertexBuffer 
*mesh_batch_cache_get_edge_pos_with_sel(
                if (format.attrib_ct == 0) {
                        /* initialize vertex format */
                        pos_id = VertexFormat_add_attrib(&format, "pos", 
COMP_F32, 3, KEEP_FLOAT);
-                       col_id = VertexFormat_add_attrib(&format, "color", 
COMP_F32, 3, KEEP_FLOAT);
+                       col_id = VertexFormat_add_attrib(&format, "select", 
COMP_U8, 1, KEEP_INT);
                }
 
                const int edge_len = mesh_render_data_edges_len_get(rdata);
@@ -2397,13 +2380,14 @@ static VertexBuffer 
*mesh_batch_cache_get_edge_pos_with_sel(
                VertexBuffer_allocate_data(vbo, vbo_len_capacity);
 
                for (int i = 0; i < edge_len; i++) {
-                       static float edge_vert_cos[2][3], edge_vert_col[3];
+                       static float edge_vert_cos[2][3];
+                       static int edge_vert_sel;
 
                        if (mesh_render_data_edge_cos_sel_get(
-                               rdata, i, edge_vert_cos, edge_vert_col, 
use_wire, use_sel, use_theme))
+                               rdata, i, edge_vert_cos, &edge_vert_sel, 
use_wire, use_sel))
                        {
-                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
edge_vert_col);
-                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
edge_vert_col);
+                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
&edge_vert_sel);
+                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
&edge_vert_sel);
 
                                VertexBuffer_set_attrib(vbo, pos_id, vidx++, 
edge_vert_cos[0]);
                                VertexBuffer_set_attrib(vbo, pos_id, vidx++, 
edge_vert_cos[1]);
@@ -2425,14 +2409,13 @@ static VertexBuffer 
*mesh_batch_cache_get_tri_pos_with_sel(MeshRenderData *rdata
        BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY | 
MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
 
        if (cache->tri_pos_with_sel == NULL) {
-               unsigned int vidx = 0, cidx = 0;
+               unsigned int vidx = 0;
 
                static VertexFormat format = { 0 };
-               static unsigned int pos_id, col_id;
+               static unsigned int pos_id;
                if (format.attrib_ct == 0) {
                        /* initialize vertex format */
                        pos_id = VertexFormat_add_attrib(&format, "pos", 
COMP_F32, 3, KEEP_FLOAT);
-                       col_id = VertexFormat_add_attrib(&format, "color", 
COMP_F32, 4, KEEP_FLOAT);
                }
 
                const int tri_len = mesh_render_data_looptri_len_get(rdata);
@@ -2444,15 +2427,11 @@ static VertexBuffer 
*mesh_batch_cache_get_tri_pos_with_sel(MeshRenderData *rdata
                VertexBuffer_allocate_data(vbo, vbo_len_capacity);
 
                for (int i = 0; i < tri_len; i++) {
-                       static float tri_vert_cos[3][3], tri_vert_col[4];
+                       static float tri_vert_cos[3][3];
 
                        if (mesh_render_data_tri_cos_sel_get(
-                               rdata, i, tri_vert_cos, tri_vert_col))
+                               rdata, i, tri_vert_cos))
                        {
-                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
tri_vert_col);
-                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
tri_vert_col);
-                               VertexBuffer_set_attrib(vbo, col_id, cidx++, 
tri_vert_col);
-
                                VertexBuffer_set_attrib(vbo, pos_id, vidx++, 
tri_vert_cos[0]);
                                VertexBuffer_set_attrib(vbo, pos_id, vidx++, 
tri_vert_cos[1]);
                                VertexBuffer_set_attrib(vbo, pos_id, vidx++, 
tri_vert_cos[2]);
@@ -2941,22 +2920,22 @@ Batch **DRW_mesh_batch_cache_get_surface_shaded(Mesh 
*me)
        return cache->shaded_triangles;
 }
 
-Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, 
bool use_sel, bool use_theme)
+Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, 
bool use_sel)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
 
-       if (cache->overlay_weight_edges == NULL) {
+       if (cache->overlay_paint_edges == NULL) {
                /* create batch from Mesh */
                const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | 
MR_DATATYPE_POLY 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to