diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-09-01 20:05:33 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-09-01 20:05:33 +0400 |
commit | bb28b5d1feedd75f387069a0d5e35626777e9ca1 (patch) | |
tree | c2f4d7b9a76d81c370444e2529d78ab78e1b8a07 /source/blender | |
parent | c91e8e6ca15436fd39c66dbf512344c47012b0a3 (diff) |
some merge, vpaint and wpaint bugfixes
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 9 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_layers.c | 17 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 24 |
6 files changed, 50 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 401cfba2fbd..a59ae7e5424 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -423,8 +423,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me) CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN, dm->dupEdgeArray(dm), totedge); if(!CustomData_has_layer(&tmp.fdata, CD_MFACE)) CustomData_add_layer(&tmp.fdata, CD_MFACE, CD_ASSIGN, dm->dupTessFaceArray(dm), totface); - - if(!CustomData_has_layer(&tmp.fdata, CD_MPOLY)) + if(!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) dm_add_polys_from_iter(&tmp.ldata, &tmp.pdata, dm, totloop); mesh_update_customdata_pointers(&tmp); @@ -1801,14 +1800,11 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) /*first add colors to the tesselation faces*/ memset(wtcol, 0x55, sizeof (unsigned char) * totface*4*4); for (i=0; i<totface; i++, mf++) { - if (origIndex[mf->v1] != ORIGINDEX_NONE) - calc_weightpaint_vert_color(ob, coba, origIndex[mf->v1], &wtcol[(i*4 + 0)*4]); - if (origIndex[mf->v2] != ORIGINDEX_NONE) - calc_weightpaint_vert_color(ob, coba, origIndex[mf->v2], &wtcol[(i*4 + 1)*4]); - if (origIndex[mf->v3] != ORIGINDEX_NONE) - calc_weightpaint_vert_color(ob, coba, origIndex[mf->v3], &wtcol[(i*4 + 2)*4]); - if (mf->v4 && origIndex[mf->v4] != ORIGINDEX_NONE) - calc_weightpaint_vert_color(ob, coba, origIndex[mf->v4], &wtcol[(i*4 + 3)*4]); + calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4]); + calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4]); + calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4]); + if (mf->v4) + calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4]); } CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, totface); @@ -1820,7 +1816,7 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) dliter = dfiter->getLoopsIter(dfiter); for (; !dliter->done; dliter->step(dliter), totloop++) { V_GROW(wlcol); - calc_weightpaint_vert_color(ob, coba, origIndex[dliter->vindex], &wlcol[totloop]); + calc_weightpaint_vert_color(ob, coba, dliter->vindex, &wlcol[totloop]); } } @@ -2049,9 +2045,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_apply_vert_coords(finaldm, deformedVerts); CDDM_calc_normals(finaldm); - - if(dataMask & CD_MASK_WEIGHT_MCOL) - add_weight_mcol_dm(ob, finaldm); } else if(dm) { finaldm = dm; } else { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 94a9eb22c5d..d2f12a8b5a1 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1458,9 +1458,9 @@ static void mesh_loops_to_corners(CustomData *fdata, CustomData *ldata, returns number of tesselation faces.*/ int mesh_recalcTesselation(CustomData *fdata, - CustomData *ldata, CustomData *pdata, - MVert *mvert, int totface, int totloop, - int totpoly) + CustomData *ldata, CustomData *pdata, + MVert *mvert, int totface, int totloop, + int totpoly) { MPoly *mp, *mpoly; MLoop *ml, *mloop; diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index c5a9916ae24..82249d062f4 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -236,6 +236,14 @@ int BM_Edge_FaceCount(BMEdge *e) int BM_Vert_FaceCount(BMVert *v){ int count = 0; + BMLoop *l; + BMIter iter; + + BM_ITER(l, &iter, NULL, BM_LOOPS_OF_VERT, v) + count++; + + return count; +#if 0 //this code isn't working BMEdge *curedge = NULL; if(v->edge){ @@ -246,6 +254,7 @@ int BM_Vert_FaceCount(BMVert *v){ }while(curedge != v->edge); } return count; +#endif } /** diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 59ff6b389ba..fd9736787a1 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -2596,5 +2596,5 @@ void MESH_OT_merge(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use."); RNA_def_enum_funcs(prop, merge_type_itemf); - RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge."); + RNA_def_boolean(ot->srna, "uvs", 1, "UVs", "Move UVs according to merge."); } diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c index 2b4ba03270f..2430ecdd110 100644 --- a/source/blender/editors/mesh/mesh_layers.c +++ b/source/blender/editors/mesh/mesh_layers.c @@ -157,6 +157,14 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la /* set index */ CustomData_set_layer_mask(data, type, maskindex); } + + if (!me->edit_btmesh) { + /*recalc mesh tesselation*/ + me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, + &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly); + + mesh_update_customdata_pointers(me); + } } /*********************** UV texture operators ************************/ @@ -199,6 +207,10 @@ static int uv_texture_add_exec(bContext *C, wmOperator *op) } CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum); + + /*recalc mesh tesselation*/ + me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, + &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly); mesh_update_customdata_pointers(me); } @@ -305,6 +317,11 @@ static int vertex_color_add_exec(bContext *C, wmOperator *op) CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop); CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum); + + /*recalc mesh tesselation*/ + me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, + &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly); + mesh_update_customdata_pointers(me); //if(!mcol) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index f8432dc4fa0..5498339feee 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -216,7 +216,7 @@ void do_shared_vertexcol(Mesh *me) /* if no mloopcol: do not do */ /* if mtexpoly: only the involved faces, otherwise all */ - if(me->mloopcol==0 || me->totvert==0 || me->totface==0) return; + if(me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return; scol = MEM_callocN(sizeof(float)*me->totvert*5, "scol"); @@ -248,7 +248,7 @@ void do_shared_vertexcol(Mesh *me) ml = me->mloop; lcol = me->mloopcol; for (i=0; i<me->totloop; i++, ml++, lcol++) { - if (!scol[4]) continue; + if (!scol[ml->v][4]) continue; lcol->r = scol[ml->v][0]; lcol->g = scol[ml->v][1]; @@ -339,11 +339,13 @@ void make_vertexcol(Scene *scene, int shade) /* single ob */ if(me==0) return; /* copies from shadedisplist to mcol */ - if(!me->mcol) { + if(!me->mcol) CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); + if (!me->mloopcol) CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, me->totloop); - mesh_update_customdata_pointers(me); - } + + mesh_update_customdata_pointers(me); + /* if(shade) @@ -390,7 +392,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) void clear_vpaint(Scene *scene, int selected) { Mesh *me; - MFace *mf; + MFace *mf; MPoly *mp; MLoopCol *lcol; Object *ob; @@ -1691,7 +1693,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent /* context checks could be a poll() */ me= get_mesh(ob); - if(me==NULL || me->totface==0) + if(me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; if(me->mloopcol==NULL) @@ -1750,7 +1752,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* which faces are involved */ if(vp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); + totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush->size); } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); @@ -1762,7 +1764,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if(vp->flag & VP_COLINDEX) { for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { + if(indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); if(mpoly->mat_nr!=ob->actcol-1) { @@ -1773,7 +1775,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } if((G.f & G_FACESELECT) && me->mface) { for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { + if(indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); if((mpoly->flag & ME_FACE_SEL)==0) @@ -1784,7 +1786,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totface) { + if(indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); MFace *mf; MCol *mc; |