Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-04-15 13:52:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-15 13:56:59 +0300
commitb9ea6fbb301f264110b5b0ab0ace021079434e69 (patch)
tree5baa2e5bd861ba7b55cba9b8901ccde4df70f57f /source/blender/blenkernel/intern
parent240c5704e479ede0635beca1c2be07d1cd028c8c (diff)
BMesh: dyntopo used lopsided normals
Normals from subdivided edges were only taken from the edges first vertex. Interpolate between the two to give more even results.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 630f3ab2b07..ce405e88481 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -330,8 +330,7 @@ static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, void *key)
static BMVert *pbvh_bmesh_vert_create(
PBVH *bvh, int node_index,
- const float co[3],
- const BMVert *example,
+ const float co[3], const float no[3],
const int cd_vert_mask_offset)
{
PBVHNode *node = &bvh->nodes[node_index];
@@ -340,9 +339,12 @@ static BMVert *pbvh_bmesh_vert_create(
BLI_assert((bvh->totnode == 1 || node_index) && node_index <= bvh->totnode);
/* avoid initializing customdata because its quite involved */
- v = BM_vert_create(bvh->bm, co, example, BM_CREATE_SKIP_CD);
+ v = BM_vert_create(bvh->bm, co, NULL, BM_CREATE_SKIP_CD);
CustomData_bmesh_set_default(&bvh->bm->vdata, &v->head.data);
+ /* This value is logged below */
+ copy_v3_v3(v->no, no);
+
BLI_gset_insert(node->bm_unique_verts, v);
BM_ELEM_CD_SET_INT(v, bvh->cd_vert_node_offset, node_index);
@@ -879,17 +881,19 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
BMEdge *e, BLI_Buffer *edge_loops)
{
BMVert *v_new;
- float mid[3];
+ float co_mid[3], no_mid[3];
int i, node_index;
/* Get all faces adjacent to the edge */
pbvh_bmesh_edge_loops(edge_loops, e);
/* Create a new vertex in current node at the edge's midpoint */
- mid_v3_v3v3(mid, e->v1->co, e->v2->co);
+ mid_v3_v3v3(co_mid, e->v1->co, e->v2->co);
+ mid_v3_v3v3(no_mid, e->v1->no, e->v2->no);
+ normalize_v3(no_mid);
node_index = BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset);
- v_new = pbvh_bmesh_vert_create(bvh, node_index, mid, e->v1, eq_ctx->cd_vert_mask_offset);
+ v_new = pbvh_bmesh_vert_create(bvh, node_index, co_mid, no_mid, eq_ctx->cd_vert_mask_offset);
/* update paint mask */
if (eq_ctx->cd_vert_mask_offset != -1) {