diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-20 11:00:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-20 11:00:57 +0400 |
commit | 972c01ac0cfa90d3414625a6ef248c3ab66d1842 (patch) | |
tree | f58166a127a5722b446f716d6cdb154e20d04619 /source/blender | |
parent | 62c6ee2c558eb33813dc41326f4f14ce046c477a (diff) |
remove NULL checks for return values from EDBM_***_at_index calls.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 75 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 11 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 11 |
6 files changed, 48 insertions, 60 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d38f4048572..80ca0b38f8c 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -976,11 +976,11 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) BMEditMesh *em = me->edit_btmesh; const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); /* warning, this lookup is _not_ fast */ - BMVert *eve; - - EDBM_index_arrays_ensure(em, BM_VERT); - if ((cd_dvert_offset != -1) && (eve = EDBM_vert_at_index(em, vertnum))) { + if (cd_dvert_offset != -1) { + BMVert *eve; + EDBM_index_arrays_ensure(em, BM_VERT); + eve = EDBM_vert_at_index(em, vertnum); dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); } else { diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index ade38a4288b..d0a34f20c77 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -567,7 +567,7 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) BMEditMesh *em = data->em; BMFace *efa = EDBM_face_at_index(em, index); - if (efa == NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_SKIP; } else { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ac0ecaf58dd..ac5deb057b5 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2060,7 +2060,9 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, const float BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index); const char sel = *(((char **)userData)[1]); - if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT) == sel) { + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && + (BM_elem_flag_test(efa, BM_ELEM_SELECT) == sel)) + { bglVertex3fv(cent); } } @@ -2326,9 +2328,6 @@ static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int { BMEdge *eed = EDBM_edge_at_index(userData, index); - if (!eed) - return DM_DRAW_OPTION_SKIP; - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && draw_dm_test_freestyle_edge_mark(userData, eed)) return DM_DRAW_OPTION_NORMAL; else @@ -2358,9 +2357,6 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) BMFace *efa = EDBM_face_at_index(data->em, index); unsigned char *col; - if (!efa) - return DM_DRAW_OPTION_SKIP; - if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (efa == data->efa_act) { glColor4ubv(data->cols[2]); @@ -2385,6 +2381,7 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int { drawDMFacesSel_userData *data = userData; + int i; BMFace *efa; BMFace *next_efa; @@ -2393,8 +2390,13 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int if (!data->orig_index_mf_to_mpoly) return 0; - efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index)); - next_efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index)); + i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index); + efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL; + i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index); + next_efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL; + + if (ELEM(NULL, efa, next_efa)) + return 0; if (efa == next_efa) return 1; @@ -2473,32 +2475,27 @@ static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index) { BMEditMesh *em = userData; BMEdge *eed = EDBM_edge_at_index(userData, index); - float *bweight = (float *)CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); - - if (!bweight) - return DM_DRAW_OPTION_SKIP; - - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *bweight != 0.0f) { - UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_SELECT, *bweight); - return DM_DRAW_OPTION_NORMAL; - } - else { - return DM_DRAW_OPTION_SKIP; + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { + const float *bweight = (float *)CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); + if (*bweight != 0.0f) { + UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_SELECT, *bweight); + return DM_DRAW_OPTION_NORMAL; + } } + return DM_DRAW_OPTION_SKIP; } static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) { BMEditMesh *em = userData; BMVert *eve = EDBM_vert_at_index(userData, index); - float *bweight = (float *)CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_BWEIGHT); - - if (!bweight) - return; - - if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && *bweight != 0.0f) { - UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight); - bglVertex3fv(co); + + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + const float *bweight = (float *)CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_BWEIGHT); + if (*bweight != 0.0f) { + UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight); + bglVertex3fv(co); + } } } static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) @@ -2506,15 +2503,19 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) ToolSettings *ts = scene->toolsettings; if (ts->selectmode & SCE_SELECT_VERTEX) { - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2); - bglBegin(GL_POINTS); - dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, em); - bglEnd(); + if (CustomData_has_layer(&em->bm->vdata, CD_BWEIGHT)) { + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2); + bglBegin(GL_POINTS); + dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, em); + bglEnd(); + } } else { - glLineWidth(3.0); - dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, em); - glLineWidth(1.0); + if (CustomData_has_layer(&em->bm->edata, CD_BWEIGHT)) { + glLineWidth(3.0); + dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, em); + glLineWidth(1.0); + } } } @@ -2958,7 +2959,7 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index) { BMFace *efa = EDBM_face_at_index(userData, index); - if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { GPU_enable_material(efa->mat_nr + 1, NULL); return DM_DRAW_OPTION_NORMAL; } @@ -7274,7 +7275,7 @@ static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int inde { BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index); - if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (((void **)userData)[1]) { WM_framebuffer_index_set(index + 1); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 68b93fe6560..7a8d4c6750e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2181,17 +2181,6 @@ int transformEnd(bContext *C, TransInfo *t) /* send events out for redraws */ viewRedrawPost(C, t); - /* Undo as last, certainly after special_trans_update! */ - - if (t->state == TRANS_CANCEL) { -// if (t->undostr) ED_undo_push(C, t->undostr); - } - else { -// if (t->undostr) ED_undo_push(C, t->undostr); -// else ED_undo_push(C, transform_to_undostr(t)); - } - t->undostr = NULL; - viewRedrawForce(C, t); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 987180d4efd..2cef3209b4e 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -319,7 +319,6 @@ typedef struct TransInfo { float vec[3]; /* translation, to show for widget */ float mat[3][3]; /* rot/rescale, to show for widget */ - char *undostr; /* if set, uses this string for undo */ float spacemtx[3][3]; /* orientation matrix of the current space */ char spacename[64]; /* name of the current space, MAX_NAME */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 6b529e13aec..4ab2269ff01 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1475,7 +1475,6 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes } for (i = 0; i < totedge; i++) { - BMEdge *eed = NULL; MEdge *e = edges + i; test = 1; /* reset for every vert */ @@ -1492,11 +1491,11 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes test = 0; } else { - eed = EDBM_edge_at_index(em, index); - - if (eed && (BM_elem_flag_test(eed, BM_ELEM_HIDDEN) || - BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || - BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) + BMEdge *eed = EDBM_edge_at_index(em, index); + + if ((BM_elem_flag_test(eed, BM_ELEM_HIDDEN) || + BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) { test = 0; } |