[Bf-blender-cvs] [80ff0dd03c4] soc-2018-npr: Change cusp edge shift criteria
Sebastian Parborg
noreply at git.blender.org
Fri Aug 10 11:14:25 CEST 2018
Commit: 80ff0dd03c4470f11a2e646bd288bc533f283fc7
Author: Sebastian Parborg
Date: Wed Aug 8 17:23:43 2018 +0200
Branches: soc-2018-npr
https://developer.blender.org/rB80ff0dd03c4470f11a2e646bd288bc533f283fc7
Change cusp edge shift criteria
===================================================================
M source/blender/modifiers/intern/MOD_mybmesh.c
===================================================================
diff --git a/source/blender/modifiers/intern/MOD_mybmesh.c b/source/blender/modifiers/intern/MOD_mybmesh.c
index 495fc337cab..e2e9ba1b905 100644
--- a/source/blender/modifiers/intern/MOD_mybmesh.c
+++ b/source/blender/modifiers/intern/MOD_mybmesh.c
@@ -133,9 +133,6 @@ typedef struct {
//Radial edge vert start idx
int radi_start_idx;
- //are we in the cusp insertion step
- bool is_cusp;
-
struct OpenSubdiv_Evaluator *eval;
} MeshData;
@@ -1022,19 +1019,40 @@ static bool check_and_shift(BMVert *vert, const float new_loc[3], const float ne
}
//Will this shift a cusp edge
- if( !m_d->is_cusp ){
- int edge_i;
+ {
BMEdge *edge;
BMIter iter_e;
+ BMFace* f;
+ BMIter iter_f;
+ float mat[3][3];
+
+ copy_v3_v3(vert->co, new_loc);
BM_ITER_ELEM (edge, &iter_e, vert, BM_EDGES_OF_VERT) {
- for(edge_i = 0; edge_i < m_d->cusp_edges->count; edge_i++){
- BMEdge* cusp_edge = BLI_buffer_at(m_d->cusp_edges, Cusp, edge_i).cusp_e;
- if( edge == cusp_edge ){
- return false;
+ for(int cusp_i = 0; cusp_i < m_d->cusp_edges->count; cusp_i++){
+ Cusp cusp = BLI_buffer_at(m_d->cusp_edges, Cusp, cusp_i);
+ if( edge == cusp.cusp_e ){
+ bool still_inside_face = false;
+ //Check if moving this cusp edge will produce any folds
+ axis_dominant_v3_to_m3(mat, cusp.cusp_no);
+ BM_ITER_ELEM (f, &iter_f, edge, BM_FACES_OF_EDGE) {
+
+ // BM_face_point_inside_test is too inaccurate to use here as some overhangs are missed with it.
+ if( point_inside(mat, cusp.cusp_co, f) ){
+ still_inside_face = true;
+ break;
+ }
+ }
+ if (!still_inside_face){
+ copy_v3_v3(vert->co, old_loc);
+ return false;
+ }
}
}
}
+
+ //Move the vert back for future checks
+ copy_v3_v3(vert->co, old_loc);
}
//Check if the shift might/will cause a CCC face
@@ -1983,7 +2001,6 @@ static void cusp_detection( MeshData *m_d ){
static void cusp_insertion(MeshData *m_d){
int cusp_i;
- m_d->is_cusp = true;
for(cusp_i = 0; cusp_i < m_d->cusp_edges->count; cusp_i++){
BMVert *vert;
@@ -2019,7 +2036,6 @@ static void cusp_insertion(MeshData *m_d){
BLI_buffer_append(m_d->new_vert_buffer, Vert_buf, new_buf);
}
- m_d->is_cusp = false;
}
static bool poke_and_move(BMFace *f, const float new_pos[3], const float du[3], const float dv[3], Radi_vert *r_vert, MeshData *m_d){
@@ -4456,7 +4472,6 @@ static Mesh *mybmesh_do(Mesh *mesh, MyBMeshModifierData *mmd, float cam_loc[3])
mesh_data.C_verts = &C_verts;
mesh_data.cusp_verts = &cusp_verts;
mesh_data.radi_vert_buffer = &radi_vert_buffer;
- mesh_data.is_cusp = false;
mesh_data.eval = osd_eval;
create_vert_mapping(&mesh_data);
@@ -4470,11 +4485,9 @@ static Mesh *mybmesh_do(Mesh *mesh, MyBMeshModifierData *mmd, float cam_loc[3])
// (6.2) Contour Insertion
if (mmd->flag & MOD_MYBMESH_CUSP_D) {
- mesh_data.is_cusp = true;
TIMEIT_START(cusp_detect);
cusp_detection(&mesh_data);
TIMEIT_END(cusp_detect);
- mesh_data.is_cusp = false;
}
if (mmd->flag & MOD_MYBMESH_FB_SPLIT) {
More information about the Bf-blender-cvs
mailing list