diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-31 10:28:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-31 10:28:11 +0400 |
commit | 54e8cacdcf5fb06441530d7c5b10265733f6e54f (patch) | |
tree | 2f5a7fb07ae1894d19d6687a10d517bedda9d664 /source | |
parent | 58a748431e7b3b268a0b8f77b09279ed0c19eca2 (diff) |
improve edgering subdivide curvature calculations (calculate length projected onto the normal plane).
also correct recely added asserts.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide_edgering.c | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index fc5b91a93cc..dd36ea4bcd8 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -873,7 +873,7 @@ static void modwrap_deformVerts( ModifierApplyFlag flag) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { DM_ensure_normals(dm); @@ -887,7 +887,7 @@ static void modwrap_deformVertsEM( float (*vertexCos)[3], int numVerts) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { DM_ensure_normals(dm); diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c index 0b3aeec0aea..871ebdf0feb 100644 --- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c +++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c @@ -86,6 +86,7 @@ static float bezier_handle_calc_length_v3(const float co_a[3], const float no_a[ const float dot = dot_v3v3(no_a, no_b); /* gives closest approx at a circle with 2 parallel handles */ float fac = 1.333333f; + float len; if (dot < 0.0f) { /* scale down to 0.666 if we point directly at each other rough but ok */ /* TODO, current blend from dot may not be optimal but its also a detail */ @@ -93,7 +94,25 @@ static float bezier_handle_calc_length_v3(const float co_a[3], const float no_a[ fac = (fac * t) + (0.75f * (1.0f - t)); } - return (len_v3v3(co_a, co_b) * 0.5f) * fac; +#if 0 + len = len_v3v3(co_a, co_b); +#else + /* 2d length projected on plane of normals */ + { + float co_a_ofs[3]; + cross_v3_v3v3(co_a_ofs, no_a, no_b); + if (len_squared_v3(co_a_ofs) > FLT_EPSILON) { + add_v3_v3(co_a_ofs, co_a); + closest_to_line_v3(co_a_ofs, co_b, co_a, co_a_ofs); + } + else { + copy_v3_v3(co_a_ofs, co_a); + } + len = len_v3v3(co_a_ofs, co_b); + } +#endif + + return (len * 0.5f) * fac; } static void bm_edgeloop_vert_tag(struct BMEdgeLoopStore *el_store, const bool tag) |