[Bf-blender-cvs] [4cd558b7115] blender2.8: Mesh Batch Cache: Port Texture paint wires to new batch request
Clément Foucault
noreply at git.blender.org
Mon Dec 17 17:17:01 CET 2018
Commit: 4cd558b7115e40affe2e94769bfa16b2a29fd176
Author: Clément Foucault
Date: Mon Dec 17 17:01:06 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB4cd558b7115e40affe2e94769bfa16b2a29fd176
Mesh Batch Cache: Port Texture paint wires to new batch request
===================================================================
M source/blender/draw/CMakeLists.txt
M source/blender/draw/engines/eevee/eevee_materials.c
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_texture_mode.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_face_vert.glsl
===================================================================
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 4fcd43dc2a8..8ba9058f210 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -314,6 +314,7 @@ data_to_c_simple(modes/shaders/paint_vertex_frag.glsl SRC)
data_to_c_simple(modes/shaders/paint_vertex_vert.glsl SRC)
data_to_c_simple(modes/shaders/paint_weight_frag.glsl SRC)
data_to_c_simple(modes/shaders/paint_weight_vert.glsl SRC)
+data_to_c_simple(modes/shaders/paint_face_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)
data_to_c_simple(modes/shaders/paint_vert_frag.glsl SRC)
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 642dbed24b0..f26920c2474 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1446,7 +1446,6 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
const bool is_sculpt_mode_draw =
is_sculpt_mode &&
((ob->sculpt && ob->sculpt->pbvh) && (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES));
- const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
const bool is_default_mode_shader = is_sculpt_mode;
/* First get materials for this mesh. */
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 468d56fd816..d5c99e149f9 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -3032,6 +3032,14 @@ GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals(me);
}
+GPUBatch *DRW_cache_mesh_wire_get(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ return DRW_mesh_batch_cache_get_wire_loops(me);
+}
+
GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -3152,14 +3160,6 @@ GPUBatch *DRW_cache_mesh_verts_get(Object *ob)
return DRW_mesh_batch_cache_get_all_verts(me);
}
-GPUBatch *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_sel);
-}
-
GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index b5c7c96db3e..f503c0de76d 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -129,6 +129,7 @@ struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_wire_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob, struct ToolSettings *ts, bool paint_mode);
struct GPUBatch *DRW_cache_mesh_surface_vert_colors_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 b22508395b6..ffaa99b9d4e 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -126,7 +126,7 @@ struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel, bool use_hide);
+struct GPUBatch *DRW_mesh_batch_cache_get_wire_loops(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
struct GPUBatch *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 1aa7a850da5..ab9c13e059d 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -56,6 +56,8 @@
#include "BKE_colorband.h"
#include "BKE_cdderivedmesh.h"
+#include "DEG_depsgraph_query.h"
+
#include "bmesh.h"
#include "GPU_batch.h"
@@ -1435,94 +1437,6 @@ fallback:
}
}
-
-/** Ensure #MeshRenderData.edge_select_bool */
-static void mesh_render_data_ensure_edge_select_bool(MeshRenderData *rdata, bool use_wire)
-{
- bool *edge_select_bool = rdata->edge_select_bool;
- if (edge_select_bool == NULL) {
- edge_select_bool = rdata->edge_select_bool =
- MEM_callocN(sizeof(*edge_select_bool) * rdata->edge_len, __func__);
-
- for (int i = 0; i < rdata->poly_len; i++) {
- const MPoly *poly = &rdata->mpoly[i];
-
- if (poly->flag & ME_FACE_SEL) {
- for (int j = 0; j < poly->totloop; j++) {
- const MLoop *loop = &rdata->mloop[poly->loopstart + j];
- if (use_wire) {
- edge_select_bool[loop->e] = true;
- }
- else {
- /* Not totally correct, will cause problems for edges with 3x faces. */
- edge_select_bool[loop->e] = !edge_select_bool[loop->e];
- }
- }
- }
- }
- }
-}
-
-/** Ensure #MeshRenderData.edge_visible_bool */
-static void mesh_render_data_ensure_edge_visible_bool(MeshRenderData *rdata)
-{
- bool *edge_visible_bool = rdata->edge_visible_bool;
- if (edge_visible_bool == NULL) {
- edge_visible_bool = rdata->edge_visible_bool =
- MEM_callocN(sizeof(*edge_visible_bool) * rdata->edge_len, __func__);
-
- /* If original index is available, hide edges within the same original poly. */
- const int *p_origindex = NULL;
- int *index_table = NULL;
-
- if (rdata->me != NULL) {
- p_origindex = CustomData_get_layer(&rdata->me->pdata, CD_ORIGINDEX);
- if (p_origindex != NULL) {
- index_table = MEM_malloc_arrayN(sizeof(int), rdata->edge_len, __func__);
- memset(index_table, -1, sizeof(int) * rdata->edge_len);
- }
- }
-
- for (int i = 0; i < rdata->poly_len; i++) {
- const MPoly *poly = &rdata->mpoly[i];
- int p_orig = p_origindex ? p_origindex[i] : ORIGINDEX_NONE;
-
- if (!(poly->flag & ME_HIDE)) {
- for (int j = 0; j < poly->totloop; j++) {
- const MLoop *loop = &rdata->mloop[poly->loopstart + j];
-
- if (p_orig != ORIGINDEX_NONE) {
- /* Boundary edge is visible. */
- if (index_table[loop->e] == -1) {
- index_table[loop->e] = p_orig;
- edge_visible_bool[loop->e] = true;
- }
- /* Edge between two faces with the same original is hidden. */
- else if (index_table[loop->e] == p_orig) {
- edge_visible_bool[loop->e] = false;
- }
- /* Edge between two different original faces is visible. */
- else {
- index_table[loop->e] = -2;
- edge_visible_bool[loop->e] = true;
- }
- }
- else {
- if (index_table != NULL) {
- index_table[loop->e] = -2;
- }
- edge_visible_bool[loop->e] = true;
- }
- }
- }
- }
-
- if (index_table != NULL) {
- MEM_freeN(index_table);
- }
- }
-}
-
/** \} */
/* ---------------------------------------------------------------------- */
@@ -2150,6 +2064,7 @@ typedef struct MeshBatchCache {
struct {
/* Indices to vloops. */
GPUIndexBuf *surface_tris;
+ GPUIndexBuf *loops_lines;
/* Contains indices to unique edit vertices to not
* draw the same vert multiple times (because of tesselation). */
GPUIndexBuf *edit_verts_points;
@@ -2169,6 +2084,7 @@ typedef struct MeshBatchCache {
GPUBatch *edit_facedots;
/* Common display / Other */
GPUBatch *all_verts;
+ GPUBatch *wire_loops; /* Loops around faces. */
GPUBatch *wire_triangles; /* Triangles for object mode wireframe. */
} batch;
@@ -2478,6 +2394,15 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
/* Paint mode selection */
+ /* TODO only do that in paint mode. */
+ GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_pos_nor);
+ GPU_BATCH_DISCARD_SAFE(cache->batch.surface);
+ GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops);
+ if (cache->surf_per_mat) {
+ for (int i = 0; i < cache->mat_len; i++) {
+ GPU_BATCH_DISCARD_SAFE(cache->surf_per_mat[i]);
+ }
+ }
GPU_BATCH_DISCARD_SAFE(cache->overlay_paint_edges);
GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
@@ -2623,8 +2548,6 @@ static void mesh_batch_cache_clear(Mesh *me)
}
MEM_SAFE_FREE(cache->texpaint_triangles);
- GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single);
-
DRW_mesh_weight_state_clear(&cache->weight_state);
}
@@ -3466,14 +3389,14 @@ static void mesh_create_pos_and_nor(MeshRenderData *rdata, GPUVertBuf *vbo)
}
}
-static void mesh_create_loop_pos_and_nor(MeshRenderData *rdata, GPUVertBuf *vbo)
+static void mesh_create_loop_pos_and_nor(MeshRenderData *rdata, GPUVertBuf *vbo, const bool use_face_sel)
{
/* TODO deduplicate format creation*/
static GPUVertFormat format = { 0 };
static struct { uint pos, nor; } attr_id;
if (format.attr_len == 0) {
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
const int poly_len = mesh_render_data_polys_len_get(rdata);
const int loop_len = mesh_render_data_loops_len_get(rdata);
@@ -3537,14 +3460,18 @@ static void mesh_create_loop_pos_and_nor(MeshRenderData *rdata, GPUVertBuf *vbo)
const GPUPackedNormal *fnor = (
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list