pre-valgrind commit

This commit is contained in:
Joseph Eagar 2020-10-25 20:00:42 -07:00
parent 5c6407c268
commit 6da9fa1bf2
10 changed files with 242 additions and 45 deletions

View File

@ -478,6 +478,7 @@ typedef struct SculptSession {
struct BMesh *bm;
int cd_vert_node_offset;
int cd_face_node_offset;
int cd_vcol_offset;
bool bm_smooth_shading;
/* Undo/redo log for dynamic topology sculpting */
struct BMLog *bm_log;

View File

@ -22,8 +22,8 @@
*/
#include "BLI_bitmap.h"
#include "BLI_ghash.h"
#include "BLI_compiler_compat.h"
#include "BLI_ghash.h"
/* For embedding CCGKey in iterator. */
#include "BKE_ccg.h"
@ -33,7 +33,9 @@
extern "C" {
#endif
typedef struct {int64_t i;} SculptVertRef;
typedef struct {
int64_t i;
} SculptVertRef;
BLI_INLINE SculptVertRef BKE_pbvh_make_vref(intptr_t i)
{
@ -211,6 +213,11 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
const int cd_face_node_offset,
const int cd_origco_offset,
const int cd_origno_offset);
void BKE_pbvh_update_offsets(PBVH *pbvh,
const int cd_vert_node_offset,
const int cd_face_node_offset,
const int cd_origco_offset,
const int cd_origno_offset);
void BKE_pbvh_free(PBVH *pbvh);
/* Hierarchical Search in the BVH, two methods:
@ -455,6 +462,7 @@ typedef struct PBVHVertexIter {
struct CustomData *bm_vdata;
int cd_vert_mask_offset;
int cd_vcol_offset;
/* result: these are all computed in the macro, but we assume
* that compiler optimization's will skip the ones we don't use */
@ -496,7 +504,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
vi.index++; \
vi.vertex.i++;\
vi.vertex.i++; \
vi.visible = true; \
if (vi.gh) { \
if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \
@ -547,8 +555,12 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
if (!bv) { \
continue; \
} \
vi.bm_vert = bv;\
vi.vertex.i = (intptr_t)bv;\
vi.bm_vert = bv; \
if (vi.cd_vcol_offset >= 0) { \
MPropCol *vcol = BM_ELEM_CD_GET_VOID_P(bv, vi.cd_vcol_offset); \
vi.col = vcol->color; \
} \
vi.vertex.i = (intptr_t)bv; \
vi.index = BM_elem_index_get(vi.bm_vert); \
vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
@ -569,7 +581,6 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
(BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != -1 ? BM_elem_index_get((BMVert *)(v.i)) : (v.i))
SculptVertRef BKE_pbvh_table_index_to_vertex(PBVH *pbvh, int idx);
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
void BKE_pbvh_node_free_proxies(PBVHNode *node);
PBVHProxyNode *BKE_pbvh_node_add_proxy(PBVH *pbvh, PBVHNode *node);

View File

@ -2068,6 +2068,8 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
if (subdiv_ccg != NULL) {
BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg);
}
} else if (BKE_pbvh_type(pbvh) == PBVH_BMESH) {
SCULPT_dynamic_topology_sync_layers(ob);
}
return pbvh;
}

View File

@ -2939,6 +2939,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->grid = NULL;
vi->no = NULL;
vi->col = NULL;
vi->fno = NULL;
vi->mvert = NULL;
vi->vertex.i = 0;
@ -2976,6 +2977,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->bm_other_verts = node->bm_other_verts;
vi->bm_vdata = &pbvh->bm->vdata;
vi->bm_vert = NULL;
vi->cd_vcol_offset = CustomData_get_offset(vi->bm_vdata, CD_PROP_COLOR);
vi->cd_vert_mask_offset = CustomData_get_offset(vi->bm_vdata, CD_PAINT_MASK);
}

View File

@ -3136,3 +3136,16 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
}
#endif
void BKE_pbvh_update_offsets(PBVH *pbvh,
const int cd_vert_node_offset,
const int cd_face_node_offset,
const int cd_origco_offset,
const int cd_origno_offset)
{
pbvh->cd_face_node_offset = cd_face_node_offset;
pbvh->cd_vert_node_offset = cd_vert_node_offset;
pbvh->cd_vert_mask_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK);
pbvh->cd_origco_offset = cd_origco_offset;
pbvh->cd_origno_offset = cd_origno_offset;
}

View File

@ -37,6 +37,7 @@
#include "BLI_utildefines.h"
#include "BLI_mempool.h" /* own include */
#include "BLI_asan.h"
#include "MEM_guardedalloc.h"
@ -223,13 +224,18 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
while (j--) {
curnode->next = NODE_STEP_NEXT(curnode);
curnode->freeword = FREEWORD;
curnode = curnode->next;
BLI_freenode *next = curnode->next;
//BLI_asan_poison(curnode, pool->esize);
curnode = next;
}
}
else {
while (j--) {
curnode->next = NODE_STEP_NEXT(curnode);
curnode = curnode->next;
BLI_freenode *next = curnode->next;
//BLI_asan_poison(curnode, pool->esize);
curnode = next;
}
}
@ -250,18 +256,20 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
return curnode;
}
static void mempool_chunk_free(BLI_mempool_chunk *mpchunk)
static void mempool_chunk_free(BLI_mempool *pool, BLI_mempool_chunk *mpchunk)
{
//BLI_asan_unpoison(mpchunk, sizeof(BLI_mempool_chunk) + pool->esize*pool->csize);
MEM_freeN(mpchunk);
}
static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk)
static void mempool_chunk_free_all(BLI_mempool *pool, BLI_mempool_chunk *mpchunk)
{
BLI_mempool_chunk *mpchunk_next;
for (; mpchunk; mpchunk = mpchunk_next) {
mpchunk_next = mpchunk->next;
mempool_chunk_free(mpchunk);
mempool_chunk_free(pool, mpchunk);
}
}
@ -343,6 +351,8 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
free_pop = pool->free;
//BLI_asan_unpoison(free_pop, pool->esize);
BLI_assert(pool->chunk_tail->next == NULL);
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
@ -404,7 +414,9 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
newhead->freeword = FREEWORD;
}
newhead->next = pool->free;
pool->free = newhead;
pool->totused--;
@ -421,7 +433,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
BLI_mempool_chunk *first;
first = pool->chunks;
mempool_chunk_free_all(first->next);
mempool_chunk_free_all(pool, first->next);
first->next = NULL;
pool->chunk_tail = first;
@ -439,15 +451,20 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
j = pool->pchunk;
while (j--) {
curnode->next = NODE_STEP_NEXT(curnode);
curnode = curnode->next;
BLI_freenode *next ; NODE_STEP_NEXT(curnode);
curnode->next = next;
//BLI_asan_poison(curnode, pool->esize);
curnode = next;
}
curnode = NODE_STEP_PREV(curnode);
curnode->next = NULL; /* terminate the list */
// BLI_asan_poison(newhead, pool->esize);
#ifdef WITH_MEM_VALGRIND
VALGRIND_MEMPOOL_FREE(pool, CHUNK_DATA(first));
#endif
} else {
//BLI_asan_poison(newhead, pool->esize);
}
}
@ -722,7 +739,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
do {
mpchunk_next = mpchunk->next;
mempool_chunk_free(mpchunk);
mempool_chunk_free(pool, mpchunk);
} while ((mpchunk = mpchunk_next));
}
@ -756,7 +773,7 @@ void BLI_mempool_clear(BLI_mempool *pool)
*/
void BLI_mempool_destroy(BLI_mempool *pool)
{
mempool_chunk_free_all(pool->chunks);
mempool_chunk_free_all(pool, pool->chunks);
#ifdef WITH_MEM_VALGRIND
VALGRIND_DESTROY_MEMPOOL(pool);

View File

@ -166,6 +166,12 @@ const float *SCULPT_vertex_color_get(SculptSession *ss, SculptVertRef index)
break;
case PBVH_BMESH: {
BMVert *v = (BMVert *)index.i;
if (ss->cd_vcol_offset >= 0) {
MPropCol *col = BM_ELEM_CD_GET_VOID_P(v, ss->cd_vcol_offset);
return col->color;
}
break;
}
case PBVH_GRIDS:
@ -348,7 +354,7 @@ void SCULPT_vertex_visible_set(SculptSession *ss, SculptVertRef index, bool visi
ss->mvert[index.i].flag |= ME_VERT_PBVH_UPDATE;
break;
case PBVH_BMESH:
BM_elem_flag_set((BMVert*)index.i, BM_ELEM_HIDDEN, !visible);
BM_elem_flag_set((BMVert *)index.i, BM_ELEM_HIDDEN, !visible);
break;
case PBVH_GRIDS:
break;
@ -577,7 +583,7 @@ void SCULPT_visibility_sync_all_face_sets_to_vertices(Object *ob)
static void UNUSED_FUNCTION(sculpt_visibility_sync_vertex_to_face_sets)(SculptSession *ss,
SculptVertRef vertex)
{
int index = (int) vertex.i;
int index = (int)vertex.i;
MeshElemMap *vert_map = &ss->pmap[index];
const bool visible = SCULPT_vertex_visible_get(ss, vertex);
@ -755,7 +761,7 @@ static void sculpt_vertex_neighbors_get_bmesh(SculptSession *ss,
SculptVertRef index,
SculptVertexNeighborIter *iter)
{
BMVert *v = (BMVert*)index.i;
BMVert *v = (BMVert *)index.i;
BMIter liter;
BMLoop *l;
iter->size = 0;
@ -770,7 +776,8 @@ static void sculpt_vertex_neighbors_get_bmesh(SculptSession *ss,
const BMVert *v_other = adj_v[i];
if (v_other != (BMVert *)index.i) {
sculpt_vertex_neighbor_add(iter, BKE_pbvh_make_vref((intptr_t)v_other), BM_elem_index_get(v_other));
sculpt_vertex_neighbor_add(
iter, BKE_pbvh_make_vref((intptr_t)v_other), BM_elem_index_get(v_other));
}
}
}
@ -881,7 +888,8 @@ static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss,
const SculptVertRef index)
{
BLI_assert(ss->vertex_info.boundary);
return BLI_BITMAP_TEST(ss->vertex_info.boundary, BKE_pbvh_vertex_index_to_table(ss->pbvh, index));
return BLI_BITMAP_TEST(ss->vertex_info.boundary,
BKE_pbvh_vertex_index_to_table(ss->pbvh, index));
}
bool SCULPT_vertex_is_boundary(const SculptSession *ss, const SculptVertRef vertex)
@ -894,7 +902,7 @@ bool SCULPT_vertex_is_boundary(const SculptSession *ss, const SculptVertRef vert
return sculpt_check_boundary_vertex_in_base_mesh(ss, vertex);
}
case PBVH_BMESH: {
BMVert *v = (BMVert*)vertex.i;
BMVert *v = (BMVert *)vertex.i;
return BM_vert_is_boundary(v);
}
@ -6458,6 +6466,24 @@ bool SCULPT_vertex_colors_poll(bContext *C)
if (!U.experimental.use_sculpt_vertex_colors) {
return false;
}
Object *ob = CTX_data_active_object(C);
return SCULPT_mode_poll(C);
}
bool SCULPT_vertex_colors_poll_no_bmesh(bContext *C)
{
if (!U.experimental.use_sculpt_vertex_colors) {
return false;
}
Object *ob = CTX_data_active_object(C);
if (ob && ob->sculpt && ob->sculpt->bm) {
return false;
}
return SCULPT_mode_poll(C);
}
@ -8520,7 +8546,8 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
const int max_preview_vertices = SCULPT_vertex_count_get(ss) * 3 * 2;
if (ss->preview_vert_index_list == NULL) {
ss->preview_vert_index_list = MEM_callocN(max_preview_vertices * sizeof(SculptVertRef), "preview lines");
ss->preview_vert_index_list = MEM_callocN(max_preview_vertices * sizeof(SculptVertRef),
"preview lines");
}
GSQueue *not_visited_vertices = BLI_gsqueue_new(sizeof(SculptVertRef));
@ -8618,7 +8645,7 @@ static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot)
ot->idname = "SCULPT_OT_vertex_to_loop_colors";
/* api callbacks */
ot->poll = SCULPT_vertex_colors_poll;
ot->poll = SCULPT_vertex_colors_poll_no_bmesh;
ot->exec = vertex_to_loop_colors_exec;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -8681,7 +8708,7 @@ static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot)
ot->idname = "SCULPT_OT_loop_to_vertex_colors";
/* api callbacks */
ot->poll = SCULPT_vertex_colors_poll;
ot->poll = SCULPT_vertex_colors_poll_no_bmesh;
ot->exec = loop_to_vertex_colors_exec;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

View File

@ -23,6 +23,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_array.h"
#include "BLI_blenlib.h"
#include "BLI_hash.h"
#include "BLI_math.h"
@ -124,14 +125,19 @@ void SCULPT_dyntopo_save_origverts(SculptSession *ss)
}
}
static char layer_id[] = "_dyntopo_node_id";
static char origco_id[] = "_dyntopop_orig_co";
static char origno_id[] = "_dyntopop_orig_no";
void SCULPT_dyntopo_node_layers_update_offsets(SculptSession *ss)
{
SCULPT_dyntopo_node_layers_add(ss);
}
void SCULPT_dyntopo_node_layers_add(SculptSession *ss)
{
int cd_node_layer_index, cd_face_node_layer_index;
char layer_id[] = "_dyntopo_node_id";
char origco_id[] = "_dyntopop_orig_co";
char origno_id[] = "_dyntopop_orig_no";
int cd_origco_index, cd_origno_index;
cd_origco_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_FLOAT3, origco_id);
@ -168,6 +174,8 @@ void SCULPT_dyntopo_node_layers_add(SculptSession *ss)
cd_origco_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_FLOAT3));
ss->bm->vdata.layers[cd_origco_index].flag |= CD_FLAG_TEMPORARY;
ss->cd_vcol_offset = CustomData_get_offset(&ss->bm->vdata, CD_PROP_COLOR);
ss->cd_origno_offset = CustomData_get_n_offset(
&ss->bm->vdata,
CD_PROP_FLOAT3,
@ -191,6 +199,96 @@ void SCULPT_dyntopo_node_layers_add(SculptSession *ss)
SCULPT_dyntopo_save_origverts(ss);
}
/**
Syncs customdata layers with internal bmesh, but ignores deleted layers.
*/
void SCULPT_dynamic_topology_sync_layers(Object *ob, Mesh *me)
{
SculptSession *ss = ob->sculpt;
if (!ss || !ss->bm) {
return;
}
bool modified = false;
BMesh *bm = ss->bm;
CustomData *cd1[4] = {&me->vdata, &me->edata, &me->ldata, &me->pdata};
CustomData *cd2[4] = {&bm->vdata, &bm->edata, &bm->ldata, &bm->pdata};
int types[4] = {BM_VERT, BM_EDGE, BM_LOOP, BM_FACE};
for (int i = 0; i < 4; i++) {
CustomDataLayer **newlayers = NULL;
BLI_array_declare(newlayers);
CustomData *data1 = cd1[i];
CustomData *data2 = cd2[i];
for (int j = 0; j < data1->totlayer; j++) {
CustomDataLayer *cl1 = data1->layers + j;
int idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
if (idx < 0) {
BLI_array_append(newlayers, cl1);
}
else {
idx -= CustomData_get_layer_index(data2, cl1->type);
int idx2 = i - CustomData_get_layer_index(data1, cl1->type);
if (idx != idx2) {
modified = true;
}
}
}
for (int j = 0; j < BLI_array_len(newlayers); j++) {
BM_data_layer_add_named(bm, data2, newlayers[j]->type, newlayers[j]->name);
modified |= true;
}
char typemap[CD_NUMTYPES] = {
0,
};
for (int j = 0; j < data1->totlayer; j++) {
CustomDataLayer *cl1 = data1->layers + j;
if (typemap[cl1->type]) {
continue;
}
typemap[cl1->type] = 1;
cl1 = CustomData_get_active_layer(data1, cl1->type);
int idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
CustomData_set_layer_active_index(data2, cl1->type, idx);
cl1 = CustomData_get_render_layer(data1, cl1->type);
idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
CustomData_set_layer_render_index(data2, cl1->type, idx);
cl1 = CustomData_get_stencil_layer(data1, cl1->type);
idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
CustomData_set_layer_stencil_index(data2, cl1->type, idx);
cl1 = CustomData_get_clone_layer(data1, cl1->type);
idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
CustomData_set_layer_clone_index(data2, cl1->type, idx);
}
BLI_array_free(newlayers);
}
if (modified) {
SCULPT_dyntopo_node_layers_update_offsets(ss);
BKE_pbvh_update_offsets(ss->pbvh,
ss->cd_vert_node_offset,
ss->cd_face_node_offset,
ss->cd_origco_offset,
ss->cd_origno_offset);
}
}
void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
{
SculptSession *ss = ob->sculpt;

View File

@ -52,6 +52,7 @@ bool SCULPT_poll(struct bContext *C);
bool SCULPT_poll_view3d(struct bContext *C);
bool SCULPT_vertex_colors_poll(struct bContext *C);
bool SCULPT_vertex_colors_poll_no_bmesh(struct bContext *C);
/* Updates */
@ -151,7 +152,7 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss,
SCULPT_vertex_neighbors_get(ss, v_index, false, &neighbor_iterator); \
for (neighbor_iterator.i = 0; neighbor_iterator.i < neighbor_iterator.size; \
neighbor_iterator.i++) { \
neighbor_iterator.vertex = neighbor_iterator.neighbors[neighbor_iterator.i];\
neighbor_iterator.vertex = neighbor_iterator.neighbors[neighbor_iterator.i]; \
neighbor_iterator.index = neighbor_iterator.neighbor_indices[neighbor_iterator.i];
/* Iterate over neighboring and duplicate vertices (for PBVH_GRIDS). Duplicates come
@ -255,10 +256,10 @@ void SCULPT_calc_area_normal(
Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3]);
SculptVertRef SCULPT_nearest_vertex_get(struct Sculpt *sd,
struct Object *ob,
const float co[3],
float max_distance,
bool use_original);
struct Object *ob,
const float co[3],
float max_distance,
bool use_original);
int SCULPT_plane_point_side(const float co[3], const float plane[4]);
int SCULPT_plane_trim(const struct StrokeCache *cache,
@ -303,11 +304,14 @@ void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd,
SculptVertRef index,
float radius);
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, SculptVertRef index);
void SCULPT_floodfill_execute(
struct SculptSession *ss,
SculptFloodFill *flood,
bool (*func)(SculptSession *ss, SculptVertRef from_v, SculptVertRef to_v, bool is_duplicate, void *userdata),
void *userdata);
void SCULPT_floodfill_execute(struct SculptSession *ss,
SculptFloodFill *flood,
bool (*func)(SculptSession *ss,
SculptVertRef from_v,
SculptVertRef to_v,
bool is_duplicate,
void *userdata),
void *userdata);
void SCULPT_floodfill_free(SculptFloodFill *flood);
/* Dynamic topology */
@ -319,6 +323,11 @@ enum eDynTopoWarnFlag {
DYNTOPO_WARN_MODIFIER = (1 << 3),
};
struct Mesh;
void SCULPT_dyntopo_node_layers_update_offsets(SculptSession *ss);
void SCULPT_dynamic_topology_sync_layers(Object *ob, struct Mesh *me);
void SCULPT_dynamic_topology_enable_ex(struct Main *bmain,
struct Depsgraph *depsgraph,
Scene *scene,
@ -502,7 +511,9 @@ float SCULPT_neighbor_mask_average(SculptSession *ss, SculptVertRef index);
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], SculptVertRef index);
/* Mask the mesh boundaries smoothing only the mesh surface without using automasking. */
void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], SculptVertRef index);
void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
float result[3],
SculptVertRef index);
void SCULPT_smooth(Sculpt *sd,
Object *ob,
@ -583,7 +594,7 @@ typedef struct SculptUndoNode {
int totvert;
/* non-multires */
int maxvert; /* to verify if totvert it still the same */
int maxvert; /* to verify if totvert it still the same */
SculptVertRef *index; /* to restore into right location */
BLI_bitmap *vert_hidden;

View File

@ -131,7 +131,6 @@ void gpu_pbvh_init()
GPU_vertformat_alias_add(&g_vbo_id.format, "texCoord");
GPU_vertformat_alias_add(&g_vbo_id.format, "u");
GPU_vertformat_alias_add(&g_vbo_id.format, "au");
}
}
@ -945,6 +944,11 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
int tottri, totvert;
bool empty_mask = true;
BMFace *f = NULL;
int cd_vcol_offset = -1;
if (CustomData_has_layer(&bm->vdata, CD_PROP_COLOR)) {
cd_vcol_offset = CustomData_get_offset(&bm->vdata, CD_PROP_COLOR);
}
/* Count visible triangles */
tottri = gpu_bmesh_face_visible_count(bm_faces);
@ -971,7 +975,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
/* TODO, make mask layer optional for bmesh buffer */
const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
const int cd_vcol_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPCOL);
const int cd_mcol_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPCOL);
const int cd_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
/* Fill vertex buffer */
@ -1013,7 +1017,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
show_mask,
show_vcol,
&empty_mask,
cd_vcol_offset);
cd_mcol_offset);
idx[i] = v_index;
v_index++;
@ -1087,9 +1091,20 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
-1);
if (cd_vcol_offset >= 0) {
MPropCol *mp = BM_ELEM_CD_GET_VOID_P(l[i]->v, cd_vcol_offset);
ushort vcol[4];
MLoopCol *ml = BM_ELEM_CD_GET_VOID_P(l[i], cd_vcol_offset);
vcol[0] = (ushort)(mp->color[0] * 65535.0f);
vcol[1] = (ushort)(mp->color[1] * 65535.0f);
vcol[2] = (ushort)(mp->color[2] * 65535.0f);
vcol[3] = (ushort)(mp->color[3] * 65535.0f);
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, v_index, vcol);
}
else if (cd_mcol_offset >= 0) {
ushort vcol[4];
MLoopCol *ml = BM_ELEM_CD_GET_VOID_P(l[i], cd_mcol_offset);
vcol[0] = ml->r * 257;
vcol[1] = ml->g * 257;