115 if (
g_vbo_id.format.attr_len == 0) {
148 else if (vert_len != buffers->
vert_buf->vertex_len) {
201 const int *sculpt_face_sets)
212 const int *sculpt_face_sets,
213 const int face_sets_color_seed,
214 const int face_sets_color_default,
216 const int update_flags)
219 const bool show_face_sets = sculpt_face_sets &&
221 const bool show_vcol = (vcol || (vtcol &&
U.experimental.use_sculpt_vertex_colors)) &&
223 bool empty_mask =
true;
224 bool default_face_set =
true;
227 const int totelem = buffers->
tot_tri * 3;
247 short no[3] = {0, 0, 0};
251 const uint vtri[3] = {
262 if (lt->
poly != mpoly_prev && !buffers->
smooth) {
267 mpoly_prev = lt->
poly;
270 uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
271 if (show_face_sets) {
274 if (
fset != face_sets_color_default) {
276 default_face_set =
false;
282 if (show_mask && !buffers->
smooth) {
283 fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f;
284 cmask = (
uchar)(fmask * 255);
287 for (
uint j = 0; j < 3; j++) {
288 const MVert *
v = &mvert[vtri[j]];
296 if (show_mask && buffers->
smooth) {
297 cmask = (
uchar)(vmask[vtri[j]] * 255);
301 empty_mask = empty_mask && (cmask == 0);
304 ushort scol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
305 if (vtcol &&
U.experimental.use_sculpt_vertex_colors) {
313 const uint loop_index = lt->
tri[j];
314 const MLoopCol *mcol = &vcol[loop_index];
336 buffers->
show_overlay = !empty_mask || !default_face_set;
337 buffers->
mvert = mvert;
345 const int *face_indices,
346 const int *sculpt_face_sets,
347 const int face_indices_len,
352 int tot_real_edges = 0;
362 for (i = 0, tottri = 0; i < face_indices_len; i++) {
363 const MLoopTri *lt = &looptri[face_indices[i]];
367 for (
int j = 0; j < 3; j++) {
368 if (r_edges[j] != -1) {
379 buffers->
mpoly = mpoly;
380 buffers->
mloop = mloop;
393 for (i = 0; i < face_indices_len; i++) {
394 const MLoopTri *lt = &looptri[face_indices[i]];
403 if (r_edges[0] != -1) {
406 if (r_edges[1] != -1) {
409 if (r_edges[2] != -1) {
419 buffers->
mpoly = mpoly;
420 buffers->
mloop = mloop;
437 const int *
UNUSED(face_sets),
438 const int *grid_indices,
439 uint visible_quad_len,
453 const uint grid_vert_len = gridsize * gridsize;
454 for (
int i = 0; i < totgrid; i++, offset += grid_vert_len) {
456 bool grid_visible =
false;
460 for (
int j = 0; j < gridsize - 1; j++) {
461 for (
int k = 0; k < gridsize - 1; k++) {
467 v0 = offset + j * gridsize + k;
478 if (j + 2 == gridsize) {
492 v1 = offset + gridsize - 1;
493 v2 = offset + grid_vert_len - 1;
494 v3 = offset + grid_vert_len - gridsize;
509 for (
int i = 0; i < totgrid; i++, offset += grid_vert_len) {
510 bool grid_visible =
false;
514 for (
int j = 0; j < gridsize - 1; j++) {
515 for (
int k = 0; k < gridsize - 1; k++) {
521 v0 = offset + (j * (gridsize - 1) + k) * 4;
532 if (j + 2 == gridsize) {
546 v1 = offset + (gridsize - 1) * 4 - 3;
547 v2 = offset + grid_vert_len - 2;
548 v3 = offset + grid_vert_len - (gridsize - 1) * 4 + 3;
569 const int *grid_indices)
571 const bool smooth = grid_flag_mats[grid_indices[0]].
flag &
ME_SMOOTH;
573 if (buffers->
smooth != smooth) {
594 const int *sculpt_face_sets,
595 const int face_sets_color_seed,
596 const int face_sets_color_default,
598 const int update_flags)
602 const bool show_face_sets = sculpt_face_sets &&
604 bool empty_mask =
true;
605 bool default_face_set =
true;
615 uint vert_count = totgrid * vert_per_grid;
622 if (visible_quad_len == 0) {
635 uint vbo_index_offset = 0;
644 for (i = 0; i < totgrid; i++) {
645 const int grid_index = grid_indices[i];
646 CCGElem *grid = grids[grid_index];
647 int vbo_index = vbo_index_offset;
649 uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
651 if (show_face_sets && subdiv_ccg && sculpt_face_sets) {
654 const int fset =
abs(sculpt_face_sets[face_index]);
656 if (
fset != face_sets_color_default) {
658 default_face_set =
false;
673 if (has_mask && show_mask) {
677 empty_mask = empty_mask && (cmask == 0);
681 const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
693 for (j = 0; j < key->
grid_size - 1; j++) {
694 for (k = 0; k < key->
grid_size - 1; k++) {
723 if (has_mask && show_mask) {
732 empty_mask = empty_mask && (cmask == 0);
735 const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
759 buffers->
grids = grids;
764 buffers->
show_overlay = !empty_mask || !default_face_set;
781 #undef FILL_QUAD_BUFFER
795 const int cd_vert_mask_offset,
796 const bool show_mask,
797 const bool show_vcol,
814 *empty_mask = *empty_mask && (cmask == 0);
818 const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
823 const uchar face_set[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
887 GSet *bm_unique_verts,
888 GSet *bm_other_verts,
889 const int update_flags)
894 bool empty_mask =
true;
905 totvert = tottri * 3;
947 for (
int i = 0; i < 3; i++) {
1010 for (i = 0; i < 3; i++) {
1019 for (i = 0; i < 3; i++) {
1025 cd_vert_mask_offset,
1058 buffers->
smooth = smooth_shading;
BLI_INLINE CCGElem * CCG_grid_elem(const CCGKey *key, CCGElem *elem, int x, int y)
BLI_INLINE float * CCG_elem_mask(const CCGKey *key, CCGElem *elem)
BLI_INLINE float * CCG_elem_no(const CCGKey *key, CCGElem *elem)
BLI_INLINE float * CCG_elem_co(const CCGKey *key, CCGElem *elem)
int CustomData_get_offset(const struct CustomData *data, int type)
void BKE_mesh_looptri_get_real_edges(const struct Mesh *mesh, const struct MLoopTri *looptri, int r_edges[3])
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_no[3])
bool paint_is_face_hidden(const struct MLoopTri *lt, const struct MVert *mvert, const struct MLoop *mloop)
#define SCULPT_FACE_SET_NONE
bool paint_is_grid_face_hidden(const unsigned int *grid_hidden, int gridsize, int x, int y)
void BKE_paint_face_set_overlay_color_get(const int face_set, const int seed, uchar r_color[4])
A BVH for high poly meshes.
int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, const int *grid_indices, int totgrid, int gridsize)
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index)
unsigned int BLI_gset_len(GSet *gs) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_int_new_ex(const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
#define GSET_ITER(gs_iter_, gset_)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
MINLINE int square_i(int a)
MINLINE unsigned int square_uint(unsigned int a)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3_short(short r[3], const short a[3])
#define POINTER_AS_UINT(i)
#define POINTER_FROM_UINT(i)
#define GPU_batch_create(prim, verts, elem)
#define GPU_BATCH_DISCARD_SAFE(batch)
@ GPU_PBVH_BUFFERS_SHOW_MASK
@ GPU_PBVH_BUFFERS_SHOW_VCOL
@ GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS
struct GPUIndexBuf GPUIndexBuf
#define GPU_INDEXBUF_DISCARD_SAFE(elem)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
GPUIndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2)
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, GPUIndexBuf *)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
uint GPU_vertbuf_get_vertex_len(const GPUVertBuf *verts)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_use(GPUVertBuf *)
GPUVertBuf * GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageType)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access)
void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len)
Read Guarded memory(de)allocation.
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_elem_flag_test(ele, hflag)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers)
void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, SubdivCCG *subdiv_ccg, CCGElem **grids, const struct DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, const int *sculpt_face_sets, const int face_sets_color_seed, const int face_sets_color_default, const struct CCGKey *key, const int update_flags)
static struct @618 g_vbo_id
static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
static void gpu_bmesh_vert_to_buffer_copy(BMVert *v, GPUVertBuf *vert_buf, int v_index, const float fno[3], const float *fmask, const int cd_vert_mask_offset, const bool show_mask, const bool show_vcol, bool *empty_mask)
void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, const MVert *mvert, const float *vmask, const MLoopCol *vcol, const int *sculpt_face_sets, const int face_sets_color_seed, const int face_sets_color_default, const MPropCol *vtcol, const int update_flags)
static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers, GPUPrimType prim)
static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_verts)
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers *buffers, SubdivCCG *UNUSED(subdiv_ccg), const int *UNUSED(face_sets), const int *grid_indices, uint visible_quad_len, int totgrid, int gridsize)
void GPU_pbvh_bmesh_buffers_update_free(GPU_PBVH_Buffers *buffers)
static bool gpu_pbvh_is_looptri_visible(const MLoopTri *lt, const MVert *mvert, const MLoop *mloop, const int *sculpt_face_sets)
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers)
void GPU_pbvh_buffers_update_flush(GPU_PBVH_Buffers *buffers)
static int gpu_bmesh_face_visible_count(GSet *bm_faces)
static void gpu_pbvh_buffers_clear(GPU_PBVH_Buffers *buffers)
GPUBatch * GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool wires)
GPU_PBVH_Buffers * GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, BMesh *bm, GSet *bm_faces, GSet *bm_unique_verts, GSet *bm_other_verts, const int update_flags)
GPU_PBVH_Buffers * GPU_pbvh_grid_buffers_build(int totgrid, BLI_bitmap **grid_hidden)
void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers, const struct DMFlagMat *grid_flag_mats, const int *grid_indices)
GPU_PBVH_Buffers * GPU_pbvh_mesh_buffers_build(const MPoly *mpoly, const MLoop *mloop, const MLoopTri *looptri, const MVert *mvert, const int *face_indices, const int *sculpt_face_sets, const int face_indices_len, const struct Mesh *mesh)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
MINLINE unsigned short unit_float_to_ushort_clamp(float val)
float BLI_color_from_srgb_table[256]
GPUIndexBuf * index_lines_buf_fast
GPUBatch * triangles_fast
GPUIndexBuf * index_lines_buf
bool clear_bmesh_on_flush
GPUIndexBuf * index_buf_fast
const DMFlagMat * grid_flag_mats
BLI_bitmap *const * grid_hidden
__forceinline const avxi abs(const avxi &a)