centralize function for calculating pixel size. (no functional changes)
authorCampbell Barton <ideasman42@gmail.com>
Fri, 5 Nov 2010 05:26:34 +0000 (05:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 5 Nov 2010 05:26:34 +0000 (05:26 +0000)
source/blender/editors/include/ED_view3d.h
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_snap.c

index d2c13b7bf85f5eec98b09e91e6d2236bd1091b2a..afc6787010abb22aa0bb14d103cf5d425b22d881 100644 (file)
@@ -118,6 +118,7 @@ void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userDa
 void ED_view3d_local_clipping(struct RegionView3D *rv3d, float mat[][4]);
 int view3d_test_clipping(struct RegionView3D *rv3d, float *vec, int local);
 void view3d_align_axis_to_vector(struct View3D *v3d, struct RegionView3D *rv3d, int axisidx, float vec[3]);
+float view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
 
 void drawcircball(int mode, float *cent, float rad, float tmat[][4]);
 
@@ -164,7 +165,6 @@ void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct AR
 struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag);
 struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype);
 
-void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
 
 Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
 void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar);
index d59f40666801cefec6ae6dea0dbd62f030d793e0..7d30c404bf09783c333289a0abf23fbd00b3eca4 100644 (file)
@@ -528,14 +528,7 @@ void drawcircball(int mode, float *cent, float rad, float tmat[][4])
 /* circle for object centers, special_color is for library or ob users */
 static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, float *co, int selstate, int special_color)
 {
-       float size= rv3d->pixsize*((float)U.obcenter_dia*0.5f);
-       float vec[3];
-       
-       vec[0]= rv3d->persmat[0][3];
-       vec[1]= rv3d->persmat[1][3];
-       vec[2]= rv3d->persmat[2][3];
-
-       size *= dot_v3v3(vec, co) + rv3d->persmat[3][3];
+       const float size= view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f;
 
        /* using gldepthfunc guarantees that it does write z values, but not checks for it, so centers remain visible independt order of drawing */
        if(v3d->zbuf)  glDepthFunc(GL_ALWAYS);
@@ -906,9 +899,10 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z)
 static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
 {
        Object *ob= base->object;
+       const float pixsize= view3d_pixel_size(rv3d, ob->obmat[3]);
        Lamp *la= ob->data;
        float vec[3], lvec[3], vvec[3], circrad, x,y,z;
-       float pixsize, lampsize;
+       float lampsize;
        float imat[4][4], curcol[4];
        char col[4];
        int drawcone= (dt>OB_WIRE && !(G.f & G_PICKSEL) && la->type == LA_SPOT && (la->mode & LA_SHOW_CONE));
@@ -924,8 +918,6 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        glLoadMatrixf(rv3d->viewmat);
 
        /* lets calculate the scale: */
-       pixsize= rv3d->persmat[0][3]*ob->obmat[3][0]+ rv3d->persmat[1][3]*ob->obmat[3][1]+ rv3d->persmat[2][3]*ob->obmat[3][2]+ rv3d->persmat[3][3];
-       pixsize*= rv3d->pixsize;
        lampsize= pixsize*((float)U.obcenter_dia*0.5f);
 
        /* and view aligned matrix: */
@@ -3552,12 +3544,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                case PART_DRAW_CROSS:
                case PART_DRAW_AXIS:
                        /* lets calculate the scale: */
-                       pixsize= rv3d->persmat[0][3]*ob->obmat[3][0]+ rv3d->persmat[1][3]*ob->obmat[3][1]+ rv3d->persmat[2][3]*ob->obmat[3][2]+ rv3d->persmat[3][3];
-                       pixsize*= rv3d->pixsize;
-                       if(part->draw_size==0.0)
-                               pixsize*=2.0;
-                       else
-                               pixsize*=part->draw_size;
+                       pixsize= view3d_pixel_size(rv3d, ob->obmat[3]);
 
                        if(draw_as==PART_DRAW_AXIS)
                                create_cdata = 1;
index 2e75b5163f9848ff7a746534bec50b057f458d4e..1be7816f5ea1d82ea74bfb675d1775ef72574c38 100644 (file)
@@ -1873,3 +1873,12 @@ int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d)
 {
        return (rv3d->persp == RV3D_ORTHO || (v3d->camera && ((Camera *)v3d->camera->data)->type == CAM_ORTHO));
 }
+
+float view3d_pixel_size(struct RegionView3D *rv3d, const float co[3])
+{
+       return  (rv3d->persmat[3][3] + (
+                               rv3d->persmat[0][3]*co[0] +
+                               rv3d->persmat[1][3]*co[1] +
+                               rv3d->persmat[2][3]*co[2])
+                       ) * rv3d->pixsize;
+}
index ec18b2f81a08c9e83720670ae9182c51236dd29b..b9f3382e9d3a3570548697a99795de4a509d2c06 100644 (file)
@@ -557,7 +557,6 @@ void flushTransSeq(TransInfo *t);
 /*********************** exported from transform_manipulator.c ********** */
 int gimbal_axis(struct Object *ob, float gmat[][3]); /* return 0 when no gimbal for selection */
 int calc_manipulator_stats(const struct bContext *C);
-float get_drawsize(struct ARegion *ar, float *co);
 
 /*********************** TransData Creation and General Handling *********** */
 void createTransData(struct bContext *C, TransInfo *t);
index 7ff93be87ee05d9f7f5b30daf0a1c614a609fcd7..22888a6b0079fb021cb7c3ffebc9c2888c0ac26d 100644 (file)
@@ -1568,17 +1568,3 @@ void calculatePropRatio(TransInfo *t)
                strcpy(t->proptext, "");
        }
 }
-
-float get_drawsize(ARegion *ar, float *co)
-{
-       RegionView3D *rv3d= ar->regiondata;
-       float size= rv3d->pixsize * 5;
-       float vec[3];
-
-       vec[0]= rv3d->persmat[0][3];
-       vec[1]= rv3d->persmat[1][3];
-       vec[2]= rv3d->persmat[2][3];
-
-       size *= dot_v3v3(vec, co) + rv3d->persmat[3][3];
-       return size;
-}
index 23b4cf5fd995873e6591225f8ce2008ed9a47be0..7ed569dab93f07e169f73c6192130573f1a0cf0c 100644 (file)
@@ -1401,17 +1401,6 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
 
 /* ********************************************* */
 
-static float get_manipulator_drawsize(ARegion *ar)
-{
-       RegionView3D *rv3d= ar->regiondata;
-       float size = get_drawsize(ar, rv3d->twmat[3]);
-
-       size*= (float)U.tw_size;
-
-       return size;
-}
-
-
 /* main call, does calc centers & orientation too */
 /* uses global G.moving */
 static int drawflags= 0xFFFF;          // only for the calls below, belongs in scene...?
@@ -1459,7 +1448,7 @@ void BIF_draw_manipulator(const bContext *C)
                        break;
                }
 
-               mul_mat3_m4_fl(rv3d->twmat, get_manipulator_drawsize(ar));
+               mul_mat3_m4_fl(rv3d->twmat, view3d_pixel_size(rv3d, rv3d->twmat[3]) * U.tw_size * 5.0f);
        }
 
        test_manipulator_axis(C);
index adaaf7c9de627038251b697e603b491b53a51248..06a2db527fdbaa42010b8a9d755c6549522c55fa 100644 (file)
@@ -146,16 +146,16 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
                        
                        glDisable(GL_DEPTH_TEST);
        
-                       size = 0.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
+                       size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
 
                        invert_m4_m4(imat, rv3d->viewmat);
 
                        for (p = t->tsnap.points.first; p; p = p->next) {
-                               drawcircball(GL_LINE_LOOP, p->co, size * get_drawsize(t->ar, p->co), imat);
+                               drawcircball(GL_LINE_LOOP, p->co, view3d_pixel_size(rv3d, p->co) * size, imat);
                        }
 
                        if (t->tsnap.status & POINT_INIT) {
-                               drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, size * get_drawsize(t->ar, t->tsnap.snapPoint), imat);
+                               drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat);
                        }
                        
                        /* draw normal if needed */