Commit: 4c3b444c85e3c5686ffc32c915b6c1cf1c9545ea Author: Joseph Eagar Date: Thu Oct 1 05:00:31 2020 -0700 Branches: temp-trimesh-sculpt https://developer.blender.org/rB4c3b444c85e3c5686ffc32c915b6c1cf1c9545ea
it compiles =================================================================== M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/paint.c M source/blender/blenkernel/intern/pbvh.c M source/blender/blenkernel/intern/pbvh_bmesh.c M source/blender/blenkernel/intern/pbvh_trimesh.c M source/blender/blenlib/intern/BLI_threadsafe_mempool.c M source/blender/editors/sculpt_paint/paint_hide.c M source/blender/editors/sculpt_paint/paint_mask.c M source/blender/editors/sculpt_paint/paint_vertex.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_boundary.c M source/blender/editors/sculpt_paint/sculpt_cloth.c M source/blender/editors/sculpt_paint/sculpt_dyntopo.c M source/blender/editors/sculpt_paint/sculpt_face_set.c M source/blender/editors/sculpt_paint/sculpt_filter_color.c M source/blender/editors/sculpt_paint/sculpt_filter_mask.c M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_mask_expand.c M source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c M source/blender/editors/sculpt_paint/sculpt_paint_color.c M source/blender/editors/sculpt_paint/sculpt_pose.c M source/blender/editors/sculpt_paint/sculpt_smooth.c M source/blender/editors/sculpt_paint/sculpt_transform.c M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_buffers.h M source/blender/gpu/intern/gpu_buffers.c M source/blender/trimesh/intern/trimesh_conv.c M source/blender/trimesh/intern/trimesh_log.c M source/blender/trimesh/intern/trimesh_private.h M source/blender/trimesh/trimesh.h =================================================================== diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index fb56c13d0c8..dbed842ea9e 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -255,6 +255,7 @@ int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh); struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh); struct TM_TriMesh *BKE_pbvh_get_trimesh(PBVH *pbvh); void BKE_pbvh_topology_detail_size_set(PBVH *pbvh, float detail_size); +void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size); typedef enum { PBVH_Subdivide = 1, @@ -472,6 +473,24 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi.col = vi.vcol[vi.index].color; \ } \ } \ + else if (vi.tm_vdata) { \ + if (!BLI_gsetIterator_done(&vi.tm_unique_verts)) { \ + vi.tm_vert = BLI_gsetIterator_getKey(&vi.tm_unique_verts); \ + BLI_gsetIterator_step(&vi.tm_unique_verts); \ + } \ + else { \ + vi.tm_vert = BLI_gsetIterator_getKey(&vi.tm_other_verts); \ + BLI_gsetIterator_step(&vi.tm_other_verts); \ + } \ + vi.visible = !TM_elem_flag_test_bool(vi.tm_vert, TM_ELEM_HIDDEN); \ + if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \ + continue; \ + } \ + vi.co = vi.tm_vert->co; \ + vi.fno = vi.tm_vert->no; \ + vi.index = vi.tm_vert->index; \ + vi.mask = TM_ELEM_CD_GET_VOID_P(vi.tm_vert, vi.cd_vert_mask_offset); \ + }\ else { \ if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) { \ vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_unique_verts); \ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 2ac2364fc93..ff0b8023c73 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1098,7 +1098,9 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint) paint = &ts->imapaint.paint; } - paint->flags |= PAINT_SHOW_BRUSH; + if (paint) { + paint->flags |= PAINT_SHOW_BRUSH; + } *r_paint = paint; @@ -1218,9 +1220,9 @@ bool paint_is_bmesh_face_hidden(BMFace *f) /* Return true if all vertices in the face are visible, false otherwise */ bool paint_is_trimesh_face_hidden(TMFace *f) { - bool ret = f->v1->flag & TRIMESH_HIDE; - ret = ret || (f->v2->flag & TRIMESH_HIDE); - ret = ret || (f->v3->flag & TRIMESH_HIDE); + bool ret = f->v1->flag & TM_ELEM_HIDDEN; + ret = ret || (f->v2->flag & TM_ELEM_HIDDEN); + ret = ret || (f->v3->flag & TM_ELEM_HIDDEN); return ret; } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 288e64b6020..b502711578d 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1293,6 +1293,10 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, node->draw_buffers = GPU_pbvh_bmesh_buffers_build(pbvh->flags & PBVH_DYNTOPO_SMOOTH_SHADING); break; + case PBVH_TRIMESH: + node->draw_buffers = GPU_pbvh_trimesh_buffers_build(pbvh->flags & + PBVH_DYNTOPO_SMOOTH_SHADING); + break; } } @@ -1331,13 +1335,21 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, node->bm_other_verts, update_flags); break; + case PBVH_TRIMESH: + GPU_pbvh_trimesh_buffers_update(node->draw_buffers, + pbvh->tm, + node->tm_faces, + node->tm_unique_verts, + node->tm_other_verts, + update_flags); + break; } } } static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag) { - if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->type, PBVH_GRIDS, PBVH_BMESH)) { + if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->type, PBVH_GRIDS, PBVH_TRIMESH, PBVH_BMESH)) { /* Free buffers uses OpenGL, so not in parallel. */ for (int n = 0; n < totnode; n++) { PBVHNode *node = nodes[n]; @@ -1352,6 +1364,8 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, } else if (pbvh->type == PBVH_BMESH) { GPU_pbvh_bmesh_buffers_update_free(node->draw_buffers); + } else if (pbvh->type == PBVH_TRIMESH) { + GPU_pbvh_trimesh_buffers_update_free(node->draw_buffers); } } } @@ -1528,6 +1542,34 @@ static void pbvh_bmesh_node_visibility_update(PBVHNode *node) BKE_pbvh_node_fully_hidden_set(node, true); } +static void pbvh_trimesh_node_visibility_update(PBVHNode *node) +{ + GSet *unique, *other; + + unique = BKE_pbvh_trimesh_node_unique_verts(node); + other = BKE_pbvh_trimesh_node_other_verts(node); + + GSetIterator gs_iter; + + GSET_ITER (gs_iter, unique) { + TMVert *v = BLI_gsetIterator_getKey(&gs_iter); + if (!TM_elem_flag_test(v, TM_ELEM_HIDDEN)) { + BKE_pbvh_node_fully_hidden_set(node, false); + return; + } + } + + GSET_ITER (gs_iter, other) { + TMVert *v = BLI_gsetIterator_getKey(&gs_iter); + if (!TM_elem_flag_test(v, TM_ELEM_HIDDEN)) { + BKE_pbvh_node_fully_hidden_set(node, false); + return; + } + } + + BKE_pbvh_node_fully_hidden_set(node, true); +} + static void pbvh_update_visibility_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) @@ -1547,6 +1589,9 @@ static void pbvh_update_visibility_task_cb(void *__restrict userdata, case PBVH_BMESH: pbvh_bmesh_node_visibility_update(node); break; + case PBVH_TRIMESH: + pbvh_trimesh_node_visibility_update(node); + break; } node->flag &= ~PBVH_UpdateVisibility; } @@ -1660,6 +1705,8 @@ bool BKE_pbvh_has_faces(const PBVH *pbvh) { if (pbvh->type == PBVH_BMESH) { return (pbvh->bm->totface != 0); + } else if (pbvh->type == PBVH_TRIMESH) { + return pbvh->tm->tottri > 0; } return (pbvh->totprim != 0); @@ -1855,6 +1902,15 @@ void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int *r_uniquevert = tot; } break; + case PBVH_TRIMESH: + tot = BLI_gset_len(node->tm_unique_verts); + if (r_totvert) { + *r_totvert = tot + BLI_gset_len(node->tm_other_verts); + } + if (r_uniquevert) { + *r_uniquevert = tot; + } + break; } } @@ -1902,6 +1958,23 @@ void BKE_pbvh_node_get_grids(PBVH *pbvh, *r_griddata = NULL; } break; + case PBVH_TRIMESH: + if (r_grid_indices) { + *r_grid_indices = NULL; + } + if (r_totgrid) { + *r_totgrid = 0; + } + if (r_maxgrid) { + *r_maxgrid = 0; + } + if (r_gridsize) { + *r_gridsize = 0; + } + if (r_griddata) { + *r_griddata = NULL; + } + break; } } @@ -2338,6 +2411,17 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh, active_vertex_index, face_normal); break; + case PBVH_TRIMESH: + TM_mesh_elem_index_ensure(pbvh->tm, TM_VERTEX); + hit = pbvh_trimesh_node_raycast(node, + ray_start, + ray_normal, + isect_precalc, + depth, + use_origco, + active_vertex_index, + face_normal); + break; } return hit; @@ -2572,6 +2656,10 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *pbvh, hit = pbvh_bmesh_node_nearest_to_ray( node, ray_start, ray_normal, depth, dist_sq, use_origco); break; + case PBVH_TRIMESH: + hit = pbvh_trimesh_node_nearest_to_ray( + node, ray_start, ray_normal, depth, dist_sq, use_origco); + break; } return hit; @@ -2653,6 +2741,9 @@ void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg) if (pbvh->type == PBVH_BMESH) { pbvh_bmesh_normals_update(nodes, totnode); } + else if (pbvh->type == PBVH_TRIMESH) { + pbvh_trimesh_normals_update(nodes, totnode); + } else if (pbvh->type == PBVH_FACES) { pbvh_faces_update_normals(pbvh, nodes, totnode); } @@ -2980,10 +3071,10 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi->cd_vert_mask_offset = CustomData_get_offset(vi->bm_vdata, CD_PAINT_MASK); } - if (bvh->type == PBVH_TRIMESH) { + if (pbvh->type == PBVH_TRIMESH) { BLI_gsetIterator_init(&vi->tm_unique_verts, node->tm_unique_verts); BLI_gsetIterator_init(&vi->tm_other_verts, node->tm_other_verts); - vi->tm_vdata = &bvh->tm->vdata; + vi->tm_vdata = &pbvh->tm->vdata; vi->cd_vert_mask_offset = CustomData_get_offset(vi->tm_vdata, CD_PAINT_MASK); } diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index a04fa1506d0..5c048b78147 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -656,6 +656,12 @@ static void pbvh_bmesh_vert_remove(PBVH *pbvh, BMVert *v) BM_FACES_OF_VERT_ITER_END; } +void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size) +{ + pbvh->bm_max_edge_len = detail_size; + pbvh->bm_min_edge_len = pbvh->bm_max_edge_len * 0.4f; +} + static void pbvh_bmesh_face_remove(PBVH *pbvh, BMFace *f) { PBVHNode *f_node = pbvh_bmesh_node_from_face(pbvh, f); @@ -2108,12 +2114,6 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh) } } -void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size) -{ - pbvh->bm_max_edge_len = detail_size; - pbvh->bm_min_edge_len = pbvh->bm_max_edge_len * 0.4f; -} - void BKE_pbvh_node_mark_topology_update(PBVHNode *node) { node->flag |= PBVH_UpdateTopology; diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c b/so @@ 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