bmesh minor changes

* 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)
This commit is contained in:
Campbell Barton 2012-03-02 10:49:15 +00:00
parent 47a1c7e5aa
commit cf927d3fd1
3 changed files with 33 additions and 31 deletions

@ -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) {
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 {
@ -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) {
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);
}

@ -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 (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;
@ -4356,20 +4356,22 @@ static int mesh_noise_exec(bContext *C, wmOperator *op)
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;
}
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 (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]));
@ -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) {
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;

@ -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);
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);
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);
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);
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);
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);
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);
}
}
}
}