remove NULL checks for return values from EDBM_***_at_index calls.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 20 Jun 2013 07:00:57 +0000 (07:00 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 20 Jun 2013 07:00:57 +0000 (07:00 +0000)
source/blender/editors/object/object_vgroup.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_snap.c

index d38f40485723a78af318f90780cbfbb717bcca31..80ca0b38f8c0e70a028d8051d021a4517d10adac 100644 (file)
@@ -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 {
index ade38a4288bca7bf5567724e015405f23bfa5ea5..d0a34f20c773231e33683b90465b4c69f3be7208 100644 (file)
@@ -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 {
index ac0ecaf58dde4e80fa5f271948c40d1a812fe3f0..ac5deb057b58b57c95acc7ebc3f842e12b6b38cc 100644 (file)
@@ -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);
                }
index 68b93fe6560b40f0038cf676db8151f81d3c7cd5..7a8d4c6750e11aab372630f94fcef44546567a63 100644 (file)
@@ -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);
        }
 
index 987180d4efdfbe0646992443379ef2de511a9b1c..2cef3209b4e0065cbc416d9c276a9a763eaf851f 100644 (file)
@@ -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          */
 
index 6b529e13aec3275966ce40e7310218b3230e2b60..4ab2269ff011ca32182ed841a21cb8a81329fcaa 100644 (file)
@@ -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;
                                                                }