Commit: 781a7f0822a479ce3fc131a37d4be484000c231c Author: Sebastian Witt Date: Wed Aug 9 13:18:38 2017 +0200 Branches: soc-2017-sculpting_improvements https://developer.blender.org/rB781a7f0822a479ce3fc131a37d4be484000c231c
Generating Tri array for later intersection testing. =================================================================== M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/pbvh.c M source/blender/editors/sculpt_paint/sculpt.c =================================================================== diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index a6186a4ee05..690a50208f5 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -363,6 +363,7 @@ void BKE_pbvh_node_get_bm_orco_data( bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node); +void BKE_pbvh_get_node_tris_from_verts(PBVH *bvh, PBVHNode *curr_node, GHash *vert_hash, struct MLoopTri **tris, int *r_tot_tris); //void BKE_pbvh_node_BB_reset(PBVHNode *node); //void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 0deccc7019f..aabc72c85ac 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -58,6 +58,9 @@ #define PBVH_THREADED_LIMIT 4 +/*TODO: Usefull?*/ +#define TRI_ARRAY_GROW 50 + typedef struct PBVHStack { PBVHNode *node; bool revisiting; @@ -1561,6 +1564,39 @@ int BKE_pbvh_recalc_looptri_from_me(PBVH *pbvh, Mesh *me) return looptri_num; } +void BKE_pbvh_get_node_tris_from_verts(PBVH *bvh, PBVHNode *node, GHash *vert_hash, MLoopTri **r_tris, int *r_tot_tris) +{ + + const int *faces = node->prim_indices; + const MLoop *mloop = bvh->mloop; + int totface = node->totprim; + MLoopTri *tris; + int r_tris_max; + /* Estimated that every vert has roughly two tris in a uniform mesh*/ + tris = MEM_callocN(sizeof(MLoopTri) * BLI_ghash_size(vert_hash) * 2, "tris connected to verts"); + r_tris_max = BLI_ghash_size(vert_hash) * 2; + *r_tot_tris = 0; + + for (int i = 0; i < totface; i++) { + const MLoopTri lt = bvh->looptri[faces[i]]; + /* TODO: Original or not etc? + const int *face_verts = node->face_vert_indices[i];*/ + for(int s = 0; s < 3; s++) { + if (BLI_ghash_haskey(vert_hash, SET_INT_IN_POINTER(mloop[lt.tri[s]].v))) { + if (*r_tot_tris >= r_tris_max) { + r_tris_max += TRI_ARRAY_GROW; + tris = MEM_reallocN(tris, sizeof(MLoopTri) * r_tris_max); + } + tris[*r_tot_tris] = lt; + *r_tot_tris += 1; + break; + } + } + } + + *r_tris = tris; +} + PBVHNode *BKE_search_closest_pbvh_leaf_node(PBVH *pbvh, PBVHNode *p_node, float *target_bmin, float *target_bmax) { BB new_BB; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 67b836cac8a..eb9454461ca 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7712,10 +7712,10 @@ static void do_calc_fillet_line_task_cb_ex(void *userdata, void *UNUSED(userdata { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; + PBVH *bvh = ss->pbvh; SilhouetteData *sil = data->sil; Mesh *me = data->ob->data; PBVHNode *curr_node = data->nodes[n]; - PBVHVertexIter vd; float point[2], p_on_plane[3], delta_p[3]; float sil_plane[4]; @@ -7731,6 +7731,8 @@ static void do_calc_fillet_line_task_cb_ex(void *userdata, void *UNUSED(userdata BLI_array_declare(edge_ring_fillet); BLI_array_declare(ring_start); int comp_v, idx; + MLoopTri *tris = NULL; + int tot_tris; /*GHashIterState state;*/ GHashIterator gh_iter; @@ -7773,6 +7775,10 @@ static void do_calc_fillet_line_task_cb_ex(void *userdata, void *UNUSED(userdata } BKE_pbvh_vertex_iter_end; + + /*TODO: tris need to be freed somewhere!*/ + BKE_pbvh_get_node_tris_from_verts(bvh, curr_node, vert_hash, &tris, &tot_tris); + /* Finished writing all vertices which are within the intersection and need to be removed. * write them to the shared array. Lock the mutex to avoid collisions */ BLI_mutex_lock(&data->mutex); @@ -8051,6 +8057,7 @@ static int sculpt_silhouette_modal(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_FINISHED; } else { if (sil->state == SIL_DRAWING) { + /*TODO: Add spacing */ sculpt_silhouette_stroke_update(mouse, op->customdata); } return OPERATOR_RUNNING_MODAL; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs