code cleanup
authorCampbell Barton <ideasman42@gmail.com>
Thu, 6 Sep 2012 23:41:03 +0000 (23:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 6 Sep 2012 23:41:03 +0000 (23:41 +0000)
source/blender/editors/mesh/editmesh_bvh.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c

index 549032f728655edba92d4217dcb6e283bf143184..c7e0077bc0252b0cc1dc47e4c1622cca9813c267 100644 (file)
@@ -394,15 +394,15 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje
        float co1[3], co2[3], co3[3], dir1[4], dir2[4], dir3[4];
        float origin[3], invmat[4][4];
        float epsilon = 0.01f; 
-       float mval_f[2], end[3];
+       float end[3];
+       const float mval_f[2] = {ar->winx / 2.0f,
+                                ar->winy / 2.0f};
        
        if (!ar) {
                printf("error in BMBVH_EdgeVisible!\n");
                return 0;
        }
-       
-       mval_f[0] = ar->winx / 2.0f;
-       mval_f[1] = ar->winy / 2.0f;
+
        ED_view3d_win_to_segment_clip(ar, v3d, mval_f, origin, end);
        
        invert_m4_m4(invmat, obedit->obmat);
index 92cc3366b3e2d733b76245ca7db8d17c57eed035..546b28bfb25cdc2292e4a429b6d26b98d6fb282d 100644 (file)
@@ -751,10 +751,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
                float nor[3] = {0.0, 0.0, 0.0};
 
                /* 2D normal calc */
-               float mval_f[2];
-
-               mval_f[0] = (float)event->mval[0];
-               mval_f[1] = (float)event->mval[1];
+               const float mval_f[2] = {(float)event->mval[0],
+                                        (float)event->mval[1]};
 
                /* check for edges that are half selected, use for rotation */
                done = FALSE;
index 72d2d67e08127bfda4b77e45ae1e7573a59bae57..3ed31abca942360e8be5fd52b4ba1eef929a04d6 100644 (file)
@@ -3540,7 +3540,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                        switch (pset->brushtype) {
                                case PE_BRUSH_COMB:
                                {
-                                       float mval_f[2];
+                                       const float mval_f[2] = {dx, dy};
                                        data.mval= mval;
                                        data.rad= (float)brush->size;
 
@@ -3552,8 +3552,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
 
                                        invert_m4_m4(ob->imat, ob->obmat);
 
-                                       mval_f[0]= dx;
-                                       mval_f[1]= dy;
                                        ED_view3d_win_to_delta(ar, mval_f, vec);
                                        data.dvec= vec;
 
index 99bc192042c03b06b8202bdc121578e61014368f..df64e1c9d90264aaf12530ddf86490ffe46c362f 100644 (file)
@@ -159,14 +159,12 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
 {
        Object *ob = vc->obact;
        float delta[3], scale, loc[3];
-       float mval_f[2];
+       const float mval_f[2] = {pixel_radius, 0.0f};
 
        mul_v3_m4v3(loc, ob->obmat, center);
 
        initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
 
-       mval_f[0] = pixel_radius;
-       mval_f[1] = 0.0f;
        ED_view3d_win_to_delta(vc->ar, mval_f, delta);
 
        scale = fabsf(mat4_to_scale(ob->obmat));
index bf948bf9dd809806bce519e070c0f99cbb527e9f..ca086544c0c2116bcf89279edc2fa1c60b59698c 100644 (file)
@@ -1027,14 +1027,12 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                Scene *scene = vc.scene;
                                ToolSettings *ts = vc.scene->toolsettings;
                                Brush *brush = paint_brush(&ts->wpaint->paint);
-                               float mval_f[2];
+                               const float mval_f[2] = {(float)event->mval[0],
+                                                        (float)event->mval[1]};
                                int v_idx_best = -1;
                                int fidx;
                                float len_best = FLT_MAX;
 
-                               mval_f[0] = (float)event->mval[0];
-                               mval_f[1] = (float)event->mval[1];
-
                                fidx = mp->totloop - 1;
                                do {
                                        float co[3], sco[3], len;
@@ -1098,10 +1096,12 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA
 
                        if (me && me->dvert && vc.v3d && vc.rv3d) {
                                int index;
+                               int mval[2] = {win->eventstate->x - vc.ar->winrct.xmin,
+                                              win->eventstate->y - vc.ar->winrct.ymin};
 
                                view3d_operator_needs_opengl(C);
 
-                               index = view3d_sample_backbuf(&vc, win->eventstate->x - vc.ar->winrct.xmin, win->eventstate->y - vc.ar->winrct.ymin);
+                               index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
 
                                if (index && index <= me->totpoly) {
                                        const int defbase_tot = BLI_countlist(&vc.obact->defbase);
index 39b926451666a3e6ca8c070c72377bdb0db7285c..8a334423ab05675d7d69b6711fbb419b2288dc15 100644 (file)
@@ -1389,14 +1389,17 @@ unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y)
 {
        unsigned int col;
        
-       if (x >= vc->ar->winx || y >= vc->ar->winy) return 0;
+       if (x >= vc->ar->winx || y >= vc->ar->winy) {
+               return 0;
+       }
+
        x += vc->ar->winrct.xmin;
        y += vc->ar->winrct.ymin;
        
        view3d_validate_backbuf(vc);
 
-       glReadPixels(x,  y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,  &col);
-       glReadBuffer(GL_BACK);  
+       glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
+       glReadBuffer(GL_BACK);
        
        if (ENDIAN_ORDER == B_ENDIAN) {
                BLI_endian_switch_uint32(&col);
index 5169d823bd83354562488eb0ab127d79a37209a1..17f1081f5c49dfc339033a5bf5060f56a08beb71 100644 (file)
@@ -475,8 +475,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
 
        {
                /* for dolly */
-               float mval_f[2];
-               VECCOPY2D(mval_f, event->mval);
+               const float mval_f[2] = {(float)event->mval[0],
+                                        (float)event->mval[1]};
                ED_view3d_win_to_vector(vod->ar, mval_f, vod->mousevec);
        }
 
index d8e394ab68c78a23be0e281c0b0ae72aa7c7ad2c..df0908e445e272c48e2ccd37dc2b906b600af665 100644 (file)
@@ -119,8 +119,8 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
        initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
 
        if (mval_cpy[0] != IS_CLIPPED) {
-               float mval_f[2];
-               VECSUB2D(mval_f, mval_cpy, mval);
+               const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]),
+                                        (float)(mval_cpy[1] - mval[1])};
                ED_view3d_win_to_delta(vc->ar, mval_f, dvec);
                sub_v3_v3(fp, dvec);
 
index fbbf23beca4221890979c536dcb0f308781965e8..1d40ae280b7c017d9cf361d22e2d91bd45a340df 100644 (file)
@@ -87,8 +87,9 @@ void view3d_operator_needs_opengl(const bContext *C)
 void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
 {
        /* for debugging purpose, context should always be OK */
-       if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW))
+       if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW)) {
                printf("view3d_region_operator_needs_opengl error, wrong region\n");
+       }
        else {
                RegionView3D *rv3d = ar->regiondata;
                
index fa7964b31ca519363d36e31e00fa7c31e3db10c3..68cc1c8e9b653f3ee64308712ec1d7ce94ff166a 100644 (file)
@@ -164,9 +164,7 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
 void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
 {
        if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) {
-               float mval_f[2];
-               mval_f[0] = dx;
-               mval_f[1] = dy;
+               const float mval_f[2] = {(float)dx, (float)dy};
                ED_view3d_win_to_delta(t->ar, mval_f, r_vec);
        }
        else if (t->spacetype == SPACE_IMAGE) {