bmesh minor changes
authorCampbell Barton <ideasman42@gmail.com>
Fri, 2 Mar 2012 10:49:15 +0000 (10:49 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 2 Mar 2012 10:49:15 +0000 (10:49 +0000)
* dont check selection and hiddent state (select + hide isnt allowed and api ensures this)
* MESH_OT_noise had incorrect check for texture (checked if slot [0] was filled but then used active texture)

source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/view3d_buttons.c

index 749ff66997b63a6dd3a5172011cdccff78a14f57..ac658f242af3d3ab03fc1cbf35f87784f199f848 100644 (file)
@@ -1894,7 +1894,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
        }
        else  {
                BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
        }
        else  {
                BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(v, BM_ELEM_SELECT) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
+                       if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
                                BM_elem_flag_enable(v, BM_ELEM_TAG);
                        }
                        else {
                                BM_elem_flag_enable(v, BM_ELEM_TAG);
                        }
                        else {
@@ -2470,7 +2470,7 @@ static int select_next_loop(bContext *C, wmOperator *UNUSED(op))
                BMIter liter;
                
                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
                BMIter liter;
                
                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
-                       if (BM_elem_flag_test(l->v, BM_ELEM_SELECT) && !BM_elem_flag_test(l->v, BM_ELEM_HIDDEN)) {
+                       if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
                                BM_elem_flag_enable(l->next->v, BM_ELEM_TAG);
                                BM_elem_select_set(em->bm, l->v, FALSE);
                        }
                                BM_elem_flag_enable(l->next->v, BM_ELEM_TAG);
                                BM_elem_select_set(em->bm, l->v, FALSE);
                        }
index 4b053b21a8bb6f4b4479e22419b8df2ece81acef..0a05d1b61e4e0c84150e65800973d0854066e9d7 100644 (file)
@@ -1372,7 +1372,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
 
        if (!eed) {
                BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 
        if (!eed) {
                BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+                       if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                /* de-select the edge before */
                                do_deselect = TRUE;
                                break;
                                /* de-select the edge before */
                                do_deselect = TRUE;
                                break;
@@ -4356,20 +4356,22 @@ static int mesh_noise_exec(bContext *C, wmOperator *op)
        BMIter iter;
        float fac = RNA_float_get(op->ptr, "factor");
 
        BMIter iter;
        float fac = RNA_float_get(op->ptr, "factor");
 
-       if (em == NULL) return OPERATOR_FINISHED;
+       if (em == NULL) {
+               return OPERATOR_FINISHED;
+       }
 
 
-       ma = give_current_material(obedit, obedit->actcol);
-       if (ma == 0 || ma->mtex[0] == 0 || ma->mtex[0]->tex == 0) {
+       if ((ma  = give_current_material(obedit, obedit->actcol)) == NULL ||
+           (tex = give_current_material_texture(ma)) == NULL)
+       {
                BKE_report(op->reports, RPT_WARNING, "Mesh has no material or texture assigned");
                return OPERATOR_FINISHED;
        }
                BKE_report(op->reports, RPT_WARNING, "Mesh has no material or texture assigned");
                return OPERATOR_FINISHED;
        }
-       tex = give_current_material_texture(ma);
 
        if (tex->type == TEX_STUCCI) {
                float b2, vec[3];
                float ofs = tex->turbul / 200.0;
                BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 
        if (tex->type == TEX_STUCCI) {
                float b2, vec[3];
                float ofs = tex->turbul / 200.0;
                BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && !BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
                                b2 = BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]);
                                if (tex->stype) ofs *= (b2 * b2);
                                vec[0] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0] + ofs, eve->co[1], eve->co[2]));
                                b2 = BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]);
                                if (tex->stype) ofs *= (b2 * b2);
                                vec[0] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0] + ofs, eve->co[1], eve->co[2]));
@@ -4382,7 +4384,7 @@ static int mesh_noise_exec(bContext *C, wmOperator *op)
        }
        else {
                BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
        }
        else {
                BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && !BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
                                float tin, dum;
                                externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0);
                                eve->co[2] += fac * tin;
                                float tin, dum;
                                externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0);
                                eve->co[2] += fac * tin;
index 6ac400b3e43fde023b01948e49cef331f0ba7edc..3e2979a7e887b8442a02d325ff0eb55eadb34211 100644 (file)
@@ -436,9 +436,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
-                                                       if (!crease)
-                                                               break;
-                                                       *crease = sca;
+                                                       if (crease) {
+                                                               *crease = sca;
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -446,10 +446,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
-                                                       if (!crease)
-                                                               break;
-                                                       *crease *= sca;
-                                                       CLAMP(*crease, 0.0f, 1.0f);
+                                                       if (crease) {
+                                                               *crease *= sca;
+                                                               CLAMP(*crease, 0.0f, 1.0f);
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -457,10 +457,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *crease = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE);
-                                                       if (!crease)
-                                                               break;
-                                                       *crease = 1.0f + ((1.0f - *crease) * sca);
-                                                       CLAMP(*crease, 0.0f, 1.0f);
+                                                       if (crease) {
+                                                               *crease = 1.0f + ((1.0f - *crease) * sca);
+                                                               CLAMP(*crease, 0.0f, 1.0f);
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -474,9 +474,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
-                                                       if (!bweight)
-                                                               break;
-                                                       *bweight = sca;
+                                                       if (bweight) {
+                                                               *bweight = sca;
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -484,10 +484,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
-                                                       if (!bweight)
-                                                               break;
-                                                       *bweight *= sca;
-                                                       CLAMP(*bweight, 0.0f, 1.0f);
+                                                       if (bweight) {
+                                                               *bweight *= sca;
+                                                               CLAMP(*bweight, 0.0f, 1.0f);
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -495,10 +495,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
                                        BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
                                                if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
                                                        float *bweight = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT);
-                                                       if (!bweight)
-                                                               break;
-                                                       *bweight = 1.0f + ((1.0f - *bweight) * sca);
-                                                       CLAMP(*bweight, 0.0f, 1.0f);
+                                                       if (bweight) {
+                                                               *bweight = 1.0f + ((1.0f - *bweight) * sca);
+                                                               CLAMP(*bweight, 0.0f, 1.0f);
+                                                       }
                                                }
                                        }
                                }
                                                }
                                        }
                                }