Commit: e4e1467fa4bdd1cd7991fd2156dd967431a29091 Author: Joseph Eagar Date: Tue Oct 13 15:24:43 2020 -0700 Branches: temp-trimesh-sculpt https://developer.blender.org/rBe4e1467fa4bdd1cd7991fd2156dd967431a29091
* code is in somewhat more working state * Began refactoring pbvh vertex indices to be uint64_t's, to eliminate usage of element tables in trimesh. =================================================================== M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/anim_data.c M source/blender/blenkernel/intern/collection.c M source/blender/blenkernel/intern/lib_id.c M source/blender/blenkernel/intern/object.c M source/blender/blenkernel/intern/pbvh_intern.h M source/blender/blenkernel/intern/pbvh_trimesh.c M source/blender/blenlib/BLI_smallhash.h M source/blender/blenlib/BLI_threadsafe_mempool.h M source/blender/blenlib/CMakeLists.txt M source/blender/blenlib/intern/BLI_threadsafe_mempool.c M source/blender/blenlib/intern/hashmap.cc M source/blender/blenlib/intern/task_pool.cc M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_automasking.c M source/blender/editors/sculpt_paint/sculpt_boundary.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_pose.c M source/blender/editors/sculpt_paint/sculpt_smooth.c M source/blender/trimesh/intern/trimesh.c M source/blender/trimesh/intern/trimesh_log.c M source/blender/trimesh/trimesh.h =================================================================== diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index a6cca2910df..cd6127512bc 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -23,6 +23,8 @@ * \ingroup bke */ +#include "BKE_pbvh.h" + #include "BLI_bitmap.h" #include "BLI_utildefines.h" #include "DNA_object_enums.h" @@ -500,7 +502,7 @@ typedef struct SculptSession { struct FilterCache *filter_cache; /* Cursor data and active vertex for tools */ - int active_vertex_index; + SculptIdx active_vertex_index; int active_face_index; int active_grid_index; diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index de2e571af22..0461e1e48b2 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -24,6 +24,10 @@ #include "BLI_bitmap.h" #include "BLI_ghash.h" +#include "stdint.h" + +typedef uintptr_t SculptIdx; + /* For embedding CCGKey in iterator. */ #include "BKE_ccg.h" @@ -169,8 +173,8 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh, const float ray_normal[3], struct IsectRayPrecalc *isect_precalc, float *depth, - int *active_vertex_index, - int *active_face_grid_index, + SculptIdx *active_vertex_index, + SculptIdx *active_face_grid_index, float *face_normal); bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, @@ -274,7 +278,7 @@ bool BKE_pbvh_trimesh_update_topology(PBVH *bvh, const float view_normal[3], float radius, const bool use_frontface, - const bool use_projected); + const bool use_projected, int sym_axis); /* Node Access */ void BKE_pbvh_node_mark_update(PBVHNode *node); @@ -373,7 +377,7 @@ typedef struct PBVHVertexIter { int gx; int gy; int i; - int index; + SculptIdx index; bool respect_hide; /* grid */ diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index c26fc6578f1..6f2e0c7257d 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -452,7 +452,7 @@ void BKE_animdata_copy_id_action(Main *bmain, ID *id) void BKE_animdata_duplicate_id_action(struct Main *bmain, struct ID *id, - const eDupli_ID_Flags duplicate_flags) + const uint duplicate_flags) { if (duplicate_flags & USER_DUP_ACT) { animdata_copy_id_action(bmain, id, true, (duplicate_flags & USER_DUP_LINKED_ID) != 0); diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index de2ec273567..de37f4d0b15 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -471,8 +471,8 @@ static Collection *collection_duplicate_recursive(Main *bmain, Collection *BKE_collection_duplicate(Main *bmain, Collection *parent, Collection *collection, - eDupli_ID_Flags duplicate_flags, - eLibIDDuplicateFlags duplicate_options) + uint duplicate_flags, + uint duplicate_options) { const bool is_subprocess = (duplicate_options & LIB_ID_DUPLICATE_IS_SUBPROCESS) != 0; diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 675e3956102..61b4d63f2e6 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -615,7 +615,7 @@ bool BKE_id_copy(Main *bmain, const ID *id, ID **newid) * Invokes the appropriate copy method for the block and returns the result in * newid, unless test. Returns true if the block can be copied. */ -ID *BKE_id_copy_for_duplicate(Main *bmain, ID *id, const eDupli_ID_Flags duplicate_flags) +ID *BKE_id_copy_for_duplicate(Main *bmain, ID *id, const uint duplicate_flags) { if (id == NULL) { return id; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 16ac027fb34..f7a3b72a83c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1812,8 +1812,8 @@ Object *BKE_object_copy(Main *bmain, const Object *ob) */ Object *BKE_object_duplicate(Main *bmain, Object *ob, - eDupli_ID_Flags dupflag, - const eLibIDDuplicateFlags duplicate_options) + uint dupflag, + const uint duplicate_options) { const bool is_subprocess = (duplicate_options & LIB_ID_DUPLICATE_IS_SUBPROCESS) != 0; diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index 3c14310ad6f..9a1233aced2 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -243,7 +243,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node, struct IsectRayPrecalc *isect_precalc, float *dist, bool use_original, - int *r_active_vertex_index, + SculptIdx *r_active_vertex_index, float *r_face_normal); bool pbvh_bmesh_node_nearest_to_ray(PBVHNode *node, const float ray_start[3], @@ -262,7 +262,7 @@ bool pbvh_trimesh_node_raycast(PBVHNode *node, struct IsectRayPrecalc *isect_precalc, float *dist, bool use_original, - int *r_active_vertex_index, + SculptIdx *r_active_vertex_index, float *r_face_normal); bool pbvh_trimesh_node_nearest_to_ray(PBVHNode *node, const float ray_start[3], diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c b/source/blender/blenkernel/intern/pbvh_trimesh.c index d96a1777180..40cc079d75e 100644 --- a/source/blender/blenkernel/intern/pbvh_trimesh.c +++ b/source/blender/blenkernel/intern/pbvh_trimesh.c @@ -27,6 +27,9 @@ #include "BLI_memarena.h" #include "BLI_utildefines.h" +#include "PIL_time.h" +#include "BLI_rand.h" + #include "BLI_threadsafe_mempool.h" #include "trimesh.h" @@ -80,7 +83,7 @@ void BKE_pbvh_trimesh_detail_size_set(PBVH *pbvh, float detail_size) pbvh->bm_min_edge_len = pbvh->bm_max_edge_len * 0.4f; } -TMFace *trimesh_tri_exists(TMEdge *e, TMVert *opposite) { +static TMFace *trimesh_tri_exists(TMEdge *e, TMVert *opposite) { for (int i=0; i<e->tris.length; i++) { TMFace *tri = e->tris.items[i]; @@ -162,6 +165,8 @@ static void pbvh_trimesh_node_finalize(PBVH *bvh, TMEdge *e = TM_GET_TRI_EDGE(f, i); TMLoopData *l = TM_GET_TRI_LOOP(f, i); + has_visible |= !(v->flag & TM_ELEM_HIDDEN); + if (TM_ELEM_CD_GET_INT(v, cd_vert_node_offset) != DYNTOPO_NODE_NONE) { BLI_gset_add(n->tm_other_verts, v); } @@ -242,7 +247,7 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC *bbc_array, int node_in } /* Enforce at least one primitive in each node */ - GSet *empty = NULL, *other; + GSet *empty = NULL, *other = NULL; if (BLI_gset_len(c1->tm_faces) == 0) { empty = c1->tm_faces; other = c2->tm_faces; @@ -251,7 +256,8 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC *bbc_array, int node_in empty = c2->tm_faces; other = c1->tm_faces; } - if (empty) { + + if (empty && other) { GSET_ITER (gs_iter, other) { void *key = BLI_gsetIterator_getKey(&gs_iter); BLI_gset_insert(empty, key); @@ -275,7 +281,7 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC *bbc_array, int node_in GSET_ITER (gs_iter, n->tm_faces) { TMFace *f = BLI_gsetIterator_getKey(&gs_iter); if (f) { -// TM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE); + TM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE); } } BLI_gset_free(n->tm_faces, NULL); @@ -343,7 +349,7 @@ static bool pbvh_trimesh_node_limit_ensure(PBVH *bvh, int node_index) f->index = i; /* set_dirty! */ } /* Likely this is already dirty. */ - bvh->tm->elem_index_dirty |= TM_VERTEX; + bvh->tm->elem_index_dirty |= TM_TRI; pbvh_trimesh_node_split(bvh, bbc_array, node_index); @@ -426,22 +432,50 @@ static TMVert *pbvh_trimesh_vert_create( PBVH *bvh, int node_index, const float co[3], const float no[3], const int cd_vert_mask_offset) { PBVHNode *node = &bvh->nodes[node_index]; + TMVert *v = TM_make_vert(bvh->tm, co, no, 0, false); + + if (node_index < 0 || node_index >= bvh->totnode) { + printf("eek!"); + return v; + } + + v->index = bvh->tm->totvert-1; + TM_ELEM_CD_SET_INT(v, bvh->cd_vert_node_offset, node_index); + + BLI_gset_insert(node->tm_unique_verts, v); + + bvh->tm->elem_table_dirty |= TM_VERTEX; + bvh->tm->elem_index_dirty |= TM_VERTEX; + + node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB; + + TM_log_vert_add(bvh->tm_log, v, cd_vert_mask_offset, false); + + return v; +#if 0 + PBVHNode *node = &bvh->nodes[node_index]; BLI_assert((bvh->totnode == 1 || node_index) && node_index <= bvh->totnode); + /* avoid initializing customdata because its quite involved */ - TMVert *v = TM_make_vert(bvh->tm, co, no, 0, true); - CustomData_bmesh_set_default(&bvh->tm->vdata, &v->customdata); + TMVert *v = TM_make_vert(bvh->tm, co, no, 0, false); + v->index = bvh->tm->totvert-1; + //CustomData_bmesh_set_default(&bvh->tm->vdata, &v->customdata); - BLI_gset_insert(node->tm_unique_verts, v); + //BLI_gset_insert(node->tm_unique_verts, v); TM_ELEM_CD_SET_INT(v, bvh->cd_vert_node_offset, node_index); + bvh->tm->elem_table_dirty |= TM_VERTEX|TM_EDGE|TM_TRI; + bvh->tm->elem_index_dirty |= TM_VERTEX|TM_EDGE|TM_TRI; + node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB; /* Log the new vertex */ TM_log_vert_add(bvh->tm_lo @@ 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