patch [#22901] pixel- and aspectratio corrected camera representation in 3dview
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index b7de750e601bcb52a6b9e4bb85397700323ea359..30bfa12300712e7c340a4b3b48083cecfe83aa7e 100644 (file)
 #include <string.h>
 #include <math.h>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include "MEM_guardedalloc.h"
 
-#include "IMB_imbuf.h"
-
-
-
-
-#include "DNA_armature_types.h"
-#include "DNA_boid_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_constraint_types.h" // for drawing constraint
-#include "DNA_effect_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_meta_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_force.h"
-#include "DNA_object_fluidsim.h"
-#include "DNA_particle_types.h"
-#include "DNA_space_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
 #include "DNA_smoke_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_view3d_types.h"
 #include "DNA_world_types.h"
 
 #include "BLI_blenlib.h"
 #include "BIF_glutil.h"
 
 #include "GPU_draw.h"
-#include "GPU_material.h"
 #include "GPU_extensions.h"
 
 #include "ED_mesh.h"
 #include "ED_screen.h"
 #include "ED_sculpt.h"
 #include "ED_types.h"
-#include "ED_util.h"
+#include "ED_curve.h" /* for ED_curve_editnurbs */
 
 #include "UI_resources.h"
-#include "UI_interface_icons.h"
 
 #include "WM_api.h"
 #include "wm_subwindow.h"
 ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \
        (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
 
-#define CHECK_OB_DRAWFACEDOT(sce, vd, dt) \
-(      (sce->toolsettings->selectmode & SCE_SELECT_FACE) && \
-       (vd->drawtype<=OB_SOLID) && \
-       (G.f & G_BACKBUFSEL)==0 && \
-       (((vd->drawtype==OB_SOLID) && (dt>=OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX) && (vd->flag & V3D_ZBUF_SELECT)) == 0) \
-       )
-
 static void draw_bounding_volume(Scene *scene, Object *ob);
 
 static void drawcube_size(float size);
@@ -140,6 +109,26 @@ static void drawcircle_size(float size);
 static void draw_empty_sphere(float size);
 static void draw_empty_cone(float size);
 
+static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
+{
+       if((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0)
+               return 0;
+
+       if(G.f & G_BACKBUFSEL)
+               return 0;
+
+       if((vd->flag & V3D_ZBUF_SELECT) == 0)
+               return 1;
+
+       /* if its drawing textures with zbuf sel, then dont draw dots */
+       if(dt==OB_TEXTURE && vd->drawtype==OB_TEXTURE)
+               return 0;
+
+       if(vd->drawtype>=OB_SOLID && vd->flag2 & V3D_SOLID_TEX)
+               return 0;
+
+       return 1;
+}
 
 /* ************* only use while object drawing **************
  * or after running ED_view3d_init_mats_rv3d
@@ -332,8 +321,109 @@ static float cosval[32] ={
        1.00000000
 };
 
+static void draw_xyz_wire(RegionView3D *rv3d, float mat[][4], float *c, float size, int axis)
+{
+       float v1[3]= {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f};
+       float imat[4][4];
+       float dim;
+       float dx[3], dy[3];
+
+       /* hrms, really only works properly after glLoadMatrixf(rv3d->viewmat); */
+       float pixscale= rv3d->persmat[0][3]*c[0]+ rv3d->persmat[1][3]*c[1]+ rv3d->persmat[2][3]*c[2] + rv3d->persmat[3][3];
+       pixscale*= rv3d->pixsize;
+
+       /* halfway blend between fixed size in worldspace vs viewspace -
+        * alleviates some of the weirdness due to not using viewmat for gl matrix */
+       dim = (0.05*size*0.5) + (size*10.f*pixscale*0.5);
+
+       invert_m4_m4(imat, mat);
+       normalize_v3(imat[0]);
+       normalize_v3(imat[1]);
+       
+       copy_v3_v3(dx, imat[0]);
+       copy_v3_v3(dy, imat[1]);
+       
+       mul_v3_fl(dx, dim);
+       mul_v3_fl(dy, dim);
+
+       switch(axis) {
+               case 0:         /* x axis */
+                       glBegin(GL_LINES);
+                       
+                       /* bottom left to top right */
+                       sub_v3_v3v3(v1, c, dx);
+                       sub_v3_v3(v1, dy);
+                       add_v3_v3v3(v2, c, dx);
+                       add_v3_v3(v2, dy);
+                       
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                       
+                       /* top left to bottom right */
+                       mul_v3_fl(dy, 2.f);
+                       add_v3_v3(v1, dy);
+                       sub_v3_v3(v2, dy);
+                       
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                       
+                       glEnd();
+                       break;
+               case 1:         /* y axis */
+                       glBegin(GL_LINES);
+                       
+                       /* bottom left to top right */
+                       mul_v3_fl(dx, 0.75f);
+                       sub_v3_v3v3(v1, c, dx);
+                       sub_v3_v3(v1, dy);
+                       add_v3_v3v3(v2, c, dx);
+                       add_v3_v3(v2, dy);
+                       
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                       
+                       /* top left to center */
+                       mul_v3_fl(dy, 2.f);
+                       add_v3_v3(v1, dy);
+                       copy_v3_v3(v2, c);
+                       
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                       
+                       glEnd();
+                       break;
+               case 2:         /* z axis */
+                       glBegin(GL_LINE_STRIP);
+                       
+                       /* start at top left */
+                       sub_v3_v3v3(v1, c, dx);
+                       add_v3_v3v3(v1, c, dy);
+                       
+                       glVertex3fv(v1);
+                       
+                       mul_v3_fl(dx, 2.f);
+                       add_v3_v3(v1, dx);
+
+                       glVertex3fv(v1);
+                       
+                       mul_v3_fl(dy, 2.f);
+                       sub_v3_v3(v1, dx);
+                       sub_v3_v3(v1, dy);
+                       
+                       glVertex3fv(v1);
+                       
+                       add_v3_v3(v1, dx);
+               
+                       glVertex3fv(v1);
+                       
+                       glEnd();
+                       break;
+       }
+       
+}
+
 /* flag is same as for draw_object */
-void drawaxes(float size, int flag, char drawtype)
+void drawaxes(RegionView3D *rv3d, float mat[][4], float size, int flag, char drawtype)
 {
        int axis;
        float v1[3]= {0.0, 0.0, 0.0};
@@ -419,12 +509,12 @@ void drawaxes(float size, int flag, char drawtype)
                        glVertex3fv(v1);
                        glVertex3fv(v2);
                                
-                       v1[axis]= size*0.8;
-                       v1[arrow_axis]= -size*0.125;
+                       v1[axis]= size*0.85;
+                       v1[arrow_axis]= -size*0.08;
                        glVertex3fv(v1);
                        glVertex3fv(v2);
                                
-                       v1[arrow_axis]= size*0.125;
+                       v1[arrow_axis]= size*0.08;
                        glVertex3fv(v1);
                        glVertex3fv(v2);
                        
@@ -432,15 +522,7 @@ void drawaxes(float size, int flag, char drawtype)
                                
                        v2[axis]+= size*0.125;
                        
-                       // patch for 3d cards crashing on glSelect for text drawing (IBM)
-                       if((flag & DRAW_PICKING) == 0) {
-                               if (axis==0)
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "x", 0, V3D_CACHE_TEXT_ZBUF);
-                               else if (axis==1)
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "y", 0, V3D_CACHE_TEXT_ZBUF);
-                               else
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "z", 0, V3D_CACHE_TEXT_ZBUF);
-                       }
+                       draw_xyz_wire(rv3d, mat, v2, size, axis);
                }
                break;
        }
@@ -549,14 +631,14 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
        }
 
        if(tot) {
+#if 0
                bglMats mats; /* ZBuffer depth vars */
                double ux, uy, uz;
                float depth;
 
                if(v3d->zbuf)
                        bgl_get_mats(&mats);
-
-
+#endif
                if(rv3d->rflag & RV3D_CLIPPING)
                        for(a=0; a<6; a++)
                                glDisable(GL_CLIP_PLANE0+a);
@@ -573,7 +655,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
                else glDepthMask(0);
                
                for(vos= strings->first; vos; vos= vos->next) {
-
+#if 0       // too slow, reading opengl info while drawing is very bad, better to see if we cn use the zbuffer while in pixel space - campbell
                        if(v3d->zbuf && (vos->flag & V3D_CACHE_TEXT_ZBUF)) {
                                gluProject(vos->vec[0], vos->vec[1], vos->vec[2], mats.modelview, mats.projection, (GLint *)mats.viewport, &ux, &uy, &uz);
                                glReadPixels(ar->winrct.xmin+vos->mval[0]+vos->xoffs, ar->winrct.ymin+vos->mval[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
@@ -581,7 +663,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
                                if(uz > depth)
                                        continue;
                        }
-
+#endif
                        if(vos->mval[0]!=IS_CLIPPED) {
                                glColor3fv(vos->col);
                                BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, vos->str);
@@ -692,9 +774,7 @@ static void drawshadbuflimits(Lamp *la, float mat[][4])
 {
        float sta[3], end[3], lavec[3];
 
-       lavec[0]= -mat[2][0];
-       lavec[1]= -mat[2][1];
-       lavec[2]= -mat[2][2];
+       negate_v3_v3(lavec, mat[2]);
        normalize_v3(lavec);
 
        sta[0]= mat[3][0]+ la->clipsta*lavec[0];
@@ -789,25 +869,17 @@ static void spotvolume(float *lvec, float *vvec, float inp)
 
 static void draw_spot_cone(Lamp *la, float x, float z)
 {
-       float vec[3];
-
        z= fabs(z);
 
        glBegin(GL_TRIANGLE_FAN);
        glVertex3f(0.0f, 0.0f, -x);
 
        if(la->mode & LA_SQUARE) {
-               vec[0]= z;
-               vec[1]= z;
-               vec[2]= 0.0;
-
-               glVertex3fv(vec);
-               vec[1]= -z;
-               glVertex3fv(vec);
-               vec[0]= -z;
-               glVertex3fv(vec);
-               vec[1]= z;
-               glVertex3fv(vec);
+               glVertex3f(z, z, 0);
+               glVertex3f(-z, z, 0);
+               glVertex3f(-z, -z, 0);
+               glVertex3f(z, -z, 0);
+               glVertex3f(z, z, 0);
        }
        else {
                float angle;
@@ -836,7 +908,7 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z)
 
        draw_spot_cone(la, x, z);
 
-       /* draw front side lightening */
+       /* draw front side lighting */
        glCullFace(GL_BACK);
 
        glBlendFunc(GL_ONE,  GL_ONE); 
@@ -907,21 +979,23 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
                        
                /* Outer circle */
                circrad = 3.0f*lampsize;
+               setlinestyle(3);
+
                drawcircball(GL_LINE_LOOP, vec, circrad, imat);
-       }
-       else
-               circrad = 0.0f;
-       
-       setlinestyle(3);
 
-       /* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
-       if (la->type!=LA_HEMI) {
-               if ((la->mode & LA_SHAD_RAY) ||
-                       ((la->mode & LA_SHAD_BUF) && (la->type==LA_SPOT)) )
-               {
-                       drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f*pixsize, imat);
+               /* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
+               if(la->type!=LA_HEMI) {
+                       if(     (la->mode & LA_SHAD_RAY) ||
+                               ((la->mode & LA_SHAD_BUF) && (la->type==LA_SPOT))
+                       ) {
+                               drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f*pixsize, imat);
+                       }
                }
        }
+       else {
+               setlinestyle(3);
+               circrad = 0.0f;
+       }
        
        /* draw the pretty sun rays */
        if(la->type==LA_SUN) {
@@ -994,17 +1068,20 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
                /* draw the circle/square at the end of the cone */
                glTranslatef(0.0, 0.0 ,  x);
                if(la->mode & LA_SQUARE) {
-                       vvec[0]= fabs(z);
-                       vvec[1]= fabs(z);
-                       vvec[2]= 0.0;
+                       float tvec[3];
+                       float z_abs= fabs(z);
+
+                       tvec[0]= tvec[1]= z_abs;
+                       tvec[2]= 0.0;
+
                        glBegin(GL_LINE_LOOP);
-                               glVertex3fv(vvec);
-                               vvec[1]= -fabs(z);
-                               glVertex3fv(vvec);
-                               vvec[0]= -fabs(z);
-                               glVertex3fv(vvec);
-                               vvec[1]= fabs(z);
-                               glVertex3fv(vvec);
+                               glVertex3fv(tvec);
+                               tvec[1]= -z_abs; /* neg */
+                               glVertex3fv(tvec);
+                               tvec[0]= -z_abs; /* neg */
+                               glVertex3fv(tvec);
+                               tvec[1]= z_abs; /* pos */
+                               glVertex3fv(tvec);
                        glEnd();
                }
                else circ(0.0, 0.0, fabs(z));
@@ -1021,6 +1098,22 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
 
                if(drawcone)
                        draw_transp_spot_volume(la, x, z);
+
+               /* draw clip start, useful for wide cones where its not obvious where the start is */
+               glTranslatef(0.0, 0.0 , -x); /* reverse translation above */
+               if(la->type==LA_SPOT && (la->mode & LA_SHAD_BUF) ) {
+                       float lvec_clip[3];
+                       float vvec_clip[3];
+                       float clipsta_fac= la->clipsta / -x;
+
+                       interp_v3_v3v3(lvec_clip, vec, lvec, clipsta_fac);
+                       interp_v3_v3v3(vvec_clip, vec, vvec, clipsta_fac);
+
+                       glBegin(GL_LINE_STRIP);
+                               glVertex3fv(lvec_clip);
+                               glVertex3fv(vvec_clip);
+                       glEnd();
+               }
        }
        else if ELEM(la->type, LA_HEMI, LA_SUN) {
                
@@ -1155,17 +1248,28 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
        /* a standing up pyramid with (0,0,0) as top */
        Camera *cam;
        World *wrld;
-       float nobmat[4][4], vec[8][4], fac, facx, facy, depth;
+       float nobmat[4][4], vec[8][4], fac, facx, facy, depth, aspx, aspy, caspx, caspy;
        int i;
 
        cam= ob->data;
+       aspx= (float) scene->r.xsch*scene->r.xasp;
+       aspy= (float) scene->r.ysch*scene->r.yasp;
+
+       if(aspx < aspy) {
+               caspx= aspx / aspy;
+               caspy= 1.0;
+       }
+       else {
+               caspx= 1.0;
+               caspy= aspy / aspx;
+       }
        
        glDisable(GL_LIGHTING);
        glDisable(GL_CULL_FACE);
        
        if(rv3d->persp>=2 && cam->type==CAM_ORTHO && ob==v3d->camera) {
-               facx= 0.5*cam->ortho_scale*1.28;
-               facy= 0.5*cam->ortho_scale*1.024;
+               facx= 0.5*cam->ortho_scale*caspx;
+               facy= 0.5*cam->ortho_scale*caspy;
                depth= -cam->clipsta-0.1;
        }
        else {
@@ -1173,8 +1277,8 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
                if(rv3d->persp>=2 && ob==v3d->camera) fac= cam->clipsta+0.1; /* that way it's always visible */
                
                depth= - fac*cam->lens/16.0;
-               facx= fac*1.28;
-               facy= fac*1.024;
+               facx= fac*caspx;
+               facy= fac*caspy;
        }
        
        vec[0][0]= 0.0; vec[0][1]= 0.0; vec[0][2]= 0.001;       /* GLBUG: for picking at iris Entry (well thats old!) */
@@ -1215,16 +1319,16 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
                else if (i==1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES);
                else break;
                
-               vec[0][0]= -0.7*cam->drawsize;
-               vec[0][1]= 1.1*cam->drawsize;
+               vec[0][0]= -0.7*cam->drawsize*caspx;
+               vec[0][1]= 1.1*cam->drawsize*caspy;
                glVertex3fv(vec[0]);
                
                vec[0][0]= 0.0; 
-               vec[0][1]= 1.8*cam->drawsize;
+               vec[0][1]= 1.8*cam->drawsize*caspy;
                glVertex3fv(vec[0]);
                
-               vec[0][0]= 0.7*cam->drawsize; 
-               vec[0][1]= 1.1*cam->drawsize;
+               vec[0][0]= 0.7*cam->drawsize*caspx
+               vec[0][1]= 1.1*cam->drawsize*caspy;
                glVertex3fv(vec[0]);
        
                glEnd();
@@ -1333,14 +1437,16 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
        Lattice *lt= ob->data;
        DispList *dl;
        int u, v, w;
-       int use_wcol= 0;
+       int use_wcol= 0, is_edit= (lt->editlatt != NULL);
 
        /* now we default make displist, this will modifiers work for non animated case */
        if(ob->disp.first==NULL)
                lattice_calc_modifiers(scene, ob);
        dl= find_displist(&ob->disp, DL_VERTS);
        
-       if(lt->editlatt) {
+       if(is_edit) {
+               lt= lt->editlatt;
+
                cpack(0x004000);
                
                if(ob->defbase.first && lt->dvert) {
@@ -1349,8 +1455,6 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
                }
        }
        
-       if(lt->editlatt) lt= lt->editlatt;
-       
        glBegin(GL_LINES);
        for(w=0; w<lt->pntsw; w++) {
                int wxt = (w==0 || w==lt->pntsw-1);
@@ -1380,7 +1484,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
        if(use_wcol)
                glShadeModel(GL_FLAT);
 
-       if( ((Lattice *)ob->data)->editlatt ) {
+       if(is_edit) {
                if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
                
                lattice_draw_verts(lt, dl, 0);
@@ -1518,10 +1622,11 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb
        short s[2] = {IS_CLIPPED, 0};
        Nurb *nu;
        int i;
+       ListBase *nurbs= ED_curve_editnurbs(cu);
 
        ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
 
-       for (nu= cu->editnurb->first; nu; nu=nu->next) {
+       for (nu= nurbs->first; nu; nu=nu->next) {
                if(nu->type == CU_BEZIER) {
                        for (i=0; i<nu->pntsu; i++) {
                                BezTriple *bezt = &nu->bezt[i];
@@ -1809,7 +1914,7 @@ static int draw_dm_creases__setDrawOptions(void *userData, int index)
        EditEdge *eed = EM_get_edge_for_index(index);
 
        if (eed->h==0 && eed->crease!=0.0) {
-               UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, eed->crease);
+               UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, eed->crease);
                return 1;
        } else {
                return 0;
@@ -1908,7 +2013,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, EditM
                                draw_dm_verts(cageDM, sel, eve_act);
                        }
                        
-                       if( CHECK_OB_DRAWFACEDOT(scene, v3d, obedit->dt) ) {
+                       if(check_ob_drawface_dot(scene, v3d, obedit->dt)) {
                                glPointSize(fsize);
                                glColor4ubv((GLubyte *)fcol);
                                draw_dm_face_centers(cageDM, sel);
@@ -1988,13 +2093,15 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
        Mesh *me= ob->data;
        EditEdge *eed;
        EditFace *efa;
-       float v1[3], v2[3], v3[3], v4[3], x, y, z;
+       float v1[3], v2[3], v3[3], v4[3], vmid[3];
        float fvec[3];
        char val[32]; /* Stores the measurement display text here */
        char conv_float[5]; /* Use a float conversion matching the grid size */
        float area, col[3]; /* area of the face,  color of the text to draw */
        float grid= unit->system ? unit->scale_length : v3d->grid;
-       int do_split= unit->flag & USER_UNIT_OPT_SPLIT;
+       const int do_split= unit->flag & USER_UNIT_OPT_SPLIT;
+       const int do_global= v3d->flag & V3D_GLOBAL_STATS;
+       const int do_moving= G.moving;
 
        if(v3d->flag2 & V3D_RENDER_OVERRIDE)
                return;
@@ -2027,24 +2134,22 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                
                for(eed= em->edges.first; eed; eed= eed->next) {
                        /* draw non fgon edges, or selected edges, or edges next to selected verts while draging */
-                       if((eed->h != EM_FGON) && ((eed->f & SELECT) || (G.moving && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT)) ))) {
-                               VECCOPY(v1, eed->v1->co);
-                               VECCOPY(v2, eed->v2->co);
-                               
-                               x= 0.5f*(v1[0]+v2[0]);
-                               y= 0.5f*(v1[1]+v2[1]);
-                               z= 0.5f*(v1[2]+v2[2]);
-                               
-                               if(v3d->flag & V3D_GLOBAL_STATS) {
-                                       mul_m4_v3(ob->obmat, v1);
-                                       mul_m4_v3(ob->obmat, v2);
+                       if((eed->h != EM_FGON) && ((eed->f & SELECT) || (do_moving && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT)) ))) {
+                               copy_v3_v3(v1, eed->v1->co);
+                               copy_v3_v3(v2, eed->v2->co);
+
+                               interp_v3_v3v3(vmid, v1, v2, 0.5f);
+
+                               if(do_global) {
+                                       mul_mat3_m4_v3(ob->obmat, v1);
+                                       mul_mat3_m4_v3(ob->obmat, v2);
                                }
                                if(unit->system)
                                        bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE);
                                else
                                        sprintf(val, conv_float, len_v3v3(v1, v2));
                                
-                               view3d_cached_text_draw_add(x, y, z, val, 0, 0);
+                               view3d_cached_text_draw_add(vmid[0], vmid[1], vmid[2], val, 0, 0);
                        }
                }
        }
@@ -2059,18 +2164,18 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                glColor3fv(col);
                
                for(efa= em->faces.first; efa; efa= efa->next) {
-                       if((efa->f & SELECT)) { // XXX || (G.moving && faceselectedOR(efa, SELECT)) ) {
-                               VECCOPY(v1, efa->v1->co);
-                               VECCOPY(v2, efa->v2->co);
-                               VECCOPY(v3, efa->v3->co);
+                       if((efa->f & SELECT)) { // XXX || (do_moving && faceselectedOR(efa, SELECT)) ) {
+                               copy_v3_v3(v1, efa->v1->co);
+                               copy_v3_v3(v2, efa->v2->co);
+                               copy_v3_v3(v3, efa->v3->co);
                                if (efa->v4) {
-                                       VECCOPY(v4, efa->v4->co);
+                                       copy_v3_v3(v4, efa->v4->co);
                                }
-                               if(v3d->flag & V3D_GLOBAL_STATS) {
-                                       mul_m4_v3(ob->obmat, v1);
-                                       mul_m4_v3(ob->obmat, v2);
-                                       mul_m4_v3(ob->obmat, v3);
-                                       if (efa->v4) mul_m4_v3(ob->obmat, v4);
+                               if(do_global) {
+                                       mul_mat3_m4_v3(ob->obmat, v1);
+                                       mul_mat3_m4_v3(ob->obmat, v2);
+                                       mul_mat3_m4_v3(ob->obmat, v3);
+                                       if (efa->v4) mul_mat3_m4_v3(ob->obmat, v4);
                                }
                                
                                if (efa->v4)
@@ -2098,20 +2203,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                glColor3fv(col);
                
                for(efa= em->faces.first; efa; efa= efa->next) {
-                       VECCOPY(v1, efa->v1->co);
-                       VECCOPY(v2, efa->v2->co);
-                       VECCOPY(v3, efa->v3->co);
+                       copy_v3_v3(v1, efa->v1->co);
+                       copy_v3_v3(v2, efa->v2->co);
+                       copy_v3_v3(v3, efa->v3->co);
                        if(efa->v4) {
-                               VECCOPY(v4, efa->v4->co); 
+                               copy_v3_v3(v4, efa->v4->co); 
                        }
                        else {
-                               VECCOPY(v4, v3);
+                               copy_v3_v3(v4, v3);
                        }
-                       if(v3d->flag & V3D_GLOBAL_STATS) {
-                               mul_m4_v3(ob->obmat, v1);
-                               mul_m4_v3(ob->obmat, v2);
-                               mul_m4_v3(ob->obmat, v3);
-                               mul_m4_v3(ob->obmat, v4);
+                       if(do_global) {
+                               mul_mat3_m4_v3(ob->obmat, v1);
+                               mul_mat3_m4_v3(ob->obmat, v2);
+                               mul_mat3_m4_v3(ob->obmat, v3);
+                               mul_mat3_m4_v3(ob->obmat, v4); /* intentionally executed even for tri's */
                        }
                        
                        e1= efa->e1;
@@ -2121,19 +2226,19 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                        
                        /* Calculate the angles */
                                
-                       if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) {
+                       if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) {
                                /* Vec 1 */
                                sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v4, v1, v2)));
                                interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f);
                                view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                        }
-                       if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) {
+                       if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) {
                                /* Vec 2 */
                                sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v1, v2, v3)));
                                interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f);
                                view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                        }
-                       if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) {
+                       if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) {
                                /* Vec 3 */
                                if(efa->v4) 
                                        sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v2, v3, v4)));
@@ -2144,7 +2249,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                        }
                                /* Vec 4 */
                        if(efa->v4) {
-                               if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) {
+                               if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) {
                                        sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v3, v4, v1)));
                                        interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f);
                                        view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
@@ -2237,7 +2342,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
        else {
                if (cageDM!=finalDM) {
                        UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
-                       finalDM->drawEdges(finalDM, 1);
+                       finalDM->drawEdges(finalDM, 1, 0);
                }
        }
        
@@ -2359,7 +2464,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
                        GPU_disable_material();
                }
                else {
-                       dm->drawEdges(dm, 0);
+                       dm->drawEdges(dm, 0, 1);
                }
                                        
                glLineWidth(1.0);
@@ -2403,7 +2508,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
        if (ob==OBACT && paint_facesel_test(ob)) draw_wire = 0;
 
        if(dt==OB_BOUNDBOX) {
-               draw_bounding_volume(scene, ob);
+               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
+                       draw_bounding_volume(scene, ob);
        }
        else if(hasHaloMat || (totface==0 && totedge==0)) {
                glPointSize(1.5);
@@ -2441,7 +2547,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        else
                                UI_ThemeColor(TH_WIRE);
 
-                       dm->drawLooseEdges(dm);
+                       if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
+                               dm->drawLooseEdges(dm);
                }
        }
        else if(dt==OB_SOLID) {
@@ -2459,7 +2566,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        glEnable(GL_LINE_STIPPLE);
                        glLineStipple(1, 0x8888);
 
-                       dm->drawEdges(dm, 1);
+                       dm->drawEdges(dm, 1, 0);
 
                        bglPolygonOffset(rv3d->dist, 0.0);
                        glDepthMask(1);
@@ -2486,9 +2593,11 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                                int fast= (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
 
                                if(ob->sculpt->partial_redraw) {
-                                       sculpt_get_redraw_planes(planes, ar, rv3d, ob);
-                                       fpl = planes;
-                                       ob->sculpt->partial_redraw = 0;
+                                       if(ar->do_draw & RGN_DRAW_PARTIAL) {
+                                               sculpt_get_redraw_planes(planes, ar, rv3d, ob);
+                                               fpl = planes;
+                                               ob->sculpt->partial_redraw = 0;
+                                       }
                                }
 
                                dm->drawFacesSolid(dm, fpl, fast, GPU_enable_material);
@@ -2506,7 +2615,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        } else {
                                UI_ThemeColor(TH_WIRE);
                        }
-                       if(!ob->sculpt)
+                       if(!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
                                dm->drawLooseEdges(dm);
                }
        }
@@ -2573,7 +2682,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        } else {
                                UI_ThemeColor(TH_WIRE);
                        }
-                       dm->drawLooseEdges(dm);
+                       if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
+                               dm->drawLooseEdges(dm);
                }
        }
        
@@ -2627,8 +2737,9 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        glDepthMask(0); // disable write in zbuffer, selected edge wires show better
                }
                
-               dm->drawEdges(dm, (dt==OB_WIRE || totface==0));
-               
+               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_SOLID)==0)
+                       dm->drawEdges(dm, (dt==OB_WIRE || totface==0), me->drawflag & ME_ALLEDGES);
+
                if (dt!=OB_WIRE && draw_wire==2) {
                        glDepthMask(1);
                        bglPolygonOffset(rv3d->dist, 0.0);
@@ -2970,7 +3081,7 @@ static void drawDispListshaded(ListBase *lb, Object *ob)
 static void drawCurveDMWired(Object *ob)
 {
        DerivedMesh *dm = ob->derivedFinal;
-       dm->drawEdges (dm, 1);
+       dm->drawEdges (dm, 1, 0);
 }
 
 /* return 1 when nothing was drawn */
@@ -2995,7 +3106,8 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B
                glDisable(GL_LIGHTING);
                GPU_end_object_materials();
        } else {
-               drawCurveDMWired (ob);
+               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_SOLID)==0)
+                       drawCurveDMWired (ob);
        }
 
        return 0;
@@ -3416,7 +3528,6 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        totpart=psys->totpart;
 
-       //if(part->flag&PART_GLOB_TIME)
        cfra=bsystem_time(scene, 0, (float)CFRA, 0.0f);
 
        if(draw_as==PART_DRAW_PATH && psys->pathcache==NULL && psys->childcache==NULL)
@@ -3737,7 +3848,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                                                sprintf(val_pos, (val_pos==val) ? "%.2f" : ":%.2f", pa_health);
 
                                        /* in path drawing state.co is the end point */
-                                       /* use worldspace beause object matrix is alredy applied */
+                                       /* use worldspace beause object matrix is already applied */
                                        mul_v3_m4v3(vec_txt, ob->imat, state.co);
                                        view3d_cached_text_draw_add(vec_txt[0],  vec_txt[1],  vec_txt[2], val, 10, V3D_CACHE_TEXT_WORLDSPACE);
                                }
@@ -3754,7 +3865,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                float *cd2=0,*cdata2=0;
 
                /* setup gl flags */
-               if(ob_dt > OB_WIRE) {
+               if (1) { //ob_dt > OB_WIRE) {
                        glEnableClientState(GL_NORMAL_ARRAY);
 
                        if(part->draw&PART_DRAW_MAT_COL)
@@ -3764,13 +3875,13 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                        glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
                        glEnable(GL_COLOR_MATERIAL);
                }
-               else {
+               /*else {
                        glDisableClientState(GL_NORMAL_ARRAY);
 
                        glDisable(GL_COLOR_MATERIAL);
                        glDisable(GL_LIGHTING);
                        UI_ThemeColor(TH_WIRE);
-               }
+               }*/
 
                if(totchild && (part->draw&PART_DRAW_PARENT)==0)
                        totpart=0;
@@ -3784,7 +3895,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                        if(path->steps > 0) {
                                glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
 
-                               if(ob_dt > OB_WIRE) {
+                               if(1) { //ob_dt > OB_WIRE) {
                                        glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
                                        if(part->draw&PART_DRAW_MAT_COL)
                                                glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
@@ -3800,7 +3911,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                        path=cache[a];
                        glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
 
-                       if(ob_dt > OB_WIRE) {
+                       if(1) { //ob_dt > OB_WIRE) {
                                glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
                                if(part->draw&PART_DRAW_MAT_COL)
                                        glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
@@ -3811,7 +3922,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
 
                /* restore & clean up */
-               if(ob_dt > OB_WIRE) {
+               if(1) { //ob_dt > OB_WIRE) {
                        if(part->draw&PART_DRAW_MAT_COL)
                                glDisable(GL_COLOR_ARRAY);
                        glDisable(GL_COLOR_MATERIAL);
@@ -3822,6 +3933,20 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                cd2=cdata2=0;
 
                glLineWidth(1.0f);
+
+               if((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0){
+                       cache=psys->pathcache;
+
+                       for(a=0, pa=psys->particles; a<totpart; a++, pa++){
+                               float vec_txt[3];
+                               val[0]= '\0';
+
+                               sprintf(val, "%i", a);
+                               /* use worldspace beause object matrix is already applied */
+                               mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
+                               view3d_cached_text_draw_add(vec_txt[0],  vec_txt[1],  vec_txt[2], val, 10, V3D_CACHE_TEXT_WORLDSPACE);
+                       }
+               }
        }
        else if(pdd && ELEM(draw_as, 0, PART_DRAW_CIRC)==0){
                glDisableClientState(GL_COLOR_ARRAY);
@@ -4331,17 +4456,19 @@ static void tekenhandlesN_active(Nurb *nu)
        glLineWidth(1);
 }
 
-static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
+static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel)
 {
        BezTriple *bezt;
        BPoint *bp;
        float size;
-       int a;
+       int a, color;
 
        if(nu->hide) return;
 
-       if(sel) UI_ThemeColor(TH_VERTEX_SELECT);
-       else UI_ThemeColor(TH_VERTEX);
+       if(sel) color= TH_VERTEX_SELECT;
+       else color= TH_VERTEX;
+
+       UI_ThemeColor(color);
 
        size= UI_GetThemeValuef(TH_VERTEX_SIZE);
        glPointSize(size);
@@ -4354,7 +4481,17 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
                a= nu->pntsu;
                while(a--) {
                        if(bezt->hide==0) {
-                               if (hide_handles) {
+                               if (sel == 1 && bezt == lastsel) {
+                                       UI_ThemeColor(TH_LASTSEL_POINT);
+                                       bglVertex3fv(bezt->vec[1]);
+
+                                       if (!hide_handles) {
+                                               if(bezt->f1 & SELECT) bglVertex3fv(bezt->vec[0]);
+                                               if(bezt->f3 & SELECT) bglVertex3fv(bezt->vec[2]);
+                                       }
+
+                                       UI_ThemeColor(color);
+                               } else if (hide_handles) {
                                        if((bezt->f2 & SELECT)==sel) bglVertex3fv(bezt->vec[1]);
                                } else {
                                        if((bezt->f1 & SELECT)==sel) bglVertex3fv(bezt->vec[0]);
@@ -4370,7 +4507,13 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
                a= nu->pntsu*nu->pntsv;
                while(a--) {
                        if(bp->hide==0) {
-                               if((bp->f1 & SELECT)==sel) bglVertex3fv(bp->vec);
+                               if (bp == lastsel) {
+                                       UI_ThemeColor(TH_LASTSEL_POINT);
+                                       bglVertex3fv(bp->vec);
+                                       UI_ThemeColor(color);
+                               } else {
+                                       if((bp->f1 & SELECT)==sel) bglVertex3fv(bp->vec);
+                               }
                        }
                        bp++;
                }
@@ -4595,7 +4738,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        for(nu=nurb; nu; nu=nu->next) {
                if(nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES)==0)
                        tekenhandlesN(nu, 1, hide_handles);
-               tekenvertsN(nu, 0, hide_handles);
+               tekenvertsN(nu, 0, hide_handles, NULL);
        }
        
        if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -4617,8 +4760,8 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
 
                                mul_qt_v3(bevp->quat, vec_a);
                                mul_qt_v3(bevp->quat, vec_b);
-                               add_v3_v3v3(vec_a, vec_a, bevp->vec);
-                               add_v3_v3v3(vec_b, vec_b, bevp->vec);
+                               add_v3_v3(vec_a, bevp->vec);
+                               add_v3_v3(vec_b, bevp->vec);
                                
                                VECSUBFAC(vec_a, vec_a, bevp->dir, fac);
                                VECSUBFAC(vec_b, vec_b, bevp->dir, fac);
@@ -4638,7 +4781,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
        
        for(nu=nurb; nu; nu=nu->next) {
-               tekenvertsN(nu, 1, hide_handles);
+               tekenvertsN(nu, 1, hide_handles, cu->lastsel);
        }
        
        if(v3d->zbuf) glEnable(GL_DEPTH_TEST); 
@@ -4885,6 +5028,8 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        }
 
        if(ml==NULL) return 1;
+
+       if(v3d->flag2 & V3D_RENDER_OVERRIDE) return 0;
        
        /* in case solid draw, reset wire colors */
        if(ob->flag & SELECT) {
@@ -5024,13 +5169,13 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
 
                        /*path end*/
                        setlinestyle(3);
-                       where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL);
+                       where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL);
                        UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
                        drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
 
                        /*path beginning*/
                        setlinestyle(0);
-                       where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL);
+                       where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL);
                        UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
                        drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
                        
@@ -5251,8 +5396,15 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
        if(ELEM3(ob->type, OB_FONT,OB_CURVE, OB_SURF)) {
                Curve *cu = ob->data;
                DerivedMesh *dm = ob->derivedFinal;
+               int hasfaces= 0;
 
-               if (displist_has_faces(&cu->disp) && boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
+               if (dm) {
+                       hasfaces= dm->getNumFaces(dm);
+               } else {
+                       hasfaces= displist_has_faces(&cu->disp);
+               }
+
+               if (hasfaces && boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
                        draw_index_wire= 0;
                        if (dm) {
                                draw_mesh_object_outline(v3d, ob, dm);
@@ -5413,6 +5565,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        if (ob!=scene->obedit) {
                if (ob->restrictflag & OB_RESTRICT_VIEW) 
                        return;
+               if ((ob->restrictflag & OB_RESTRICT_RENDER) && 
+                       (v3d->flag2 & V3D_RENDER_OVERRIDE))
+                       return;
        }
 
        /* XXX particles are not safe for simultaneous threaded render */
@@ -5727,8 +5882,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                                        set_inverted_drawing(0);
                                }
                        }
-                       else if(dt==OB_BOUNDBOX) 
-                               draw_bounding_volume(scene, ob);
+                       else if(dt==OB_BOUNDBOX) {
+                               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
+                                       draw_bounding_volume(scene, ob);
+                       }
                        else if(boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb))
                                empty_object= drawDispList(scene, v3d, rv3d, base, dt);
 
@@ -5738,10 +5895,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        cu= ob->data;
 
                        if(cu->editnurb) {
-                               drawnurb(scene, v3d, rv3d, base, cu->editnurb->first, dt);
+                               ListBase *nurbs= ED_curve_editnurbs(cu);
+                               drawnurb(scene, v3d, rv3d, base, nurbs->first, dt);
+                       }
+                       else if(dt==OB_BOUNDBOX) {
+                               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
+                                       draw_bounding_volume(scene, ob);
                        }
-                       else if(dt==OB_BOUNDBOX) 
-                               draw_bounding_volume(scene, ob);
                        else if(boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
                                empty_object= drawDispList(scene, v3d, rv3d, base, dt);
                                
@@ -5755,15 +5915,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        
                        if(mb->editelems) 
                                drawmball(scene, v3d, rv3d, base, dt);
-                       else if(dt==OB_BOUNDBOX) 
-                               draw_bounding_volume(scene, ob);
+                       else if(dt==OB_BOUNDBOX) {
+                               if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
+                                       draw_bounding_volume(scene, ob);
+                       }
                        else 
                                empty_object= drawmball(scene, v3d, rv3d, base, dt);
                        break;
                }
                case OB_EMPTY:
                        if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
-                               drawaxes(ob->empty_drawsize, flag, ob->empty_drawtype);
+                               drawaxes(rv3d, rv3d->viewmatob, ob->empty_drawsize, flag, ob->empty_drawtype);
                        break;
                case OB_LAMP:
                        if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
@@ -5789,11 +5951,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        break;
                default:
                        if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
-                               drawaxes(1.0, flag, OB_ARROWS);
+                               drawaxes(rv3d, rv3d->viewmatob, 1.0, flag, OB_ARROWS);
                        }
        }
 
-               if((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+       if((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
 
                if(ob->soft /*&& flag & OB_SBMOTION*/){
                        float mrt[3][3],msc[3][3],mtr[3][3]; 
@@ -5987,11 +6149,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
                /* draw extra: after normal draw because of makeDispList */
                if(dtx && (G.f & G_RENDER_OGL)==0) {
-        
+
                        if(dtx & OB_AXIS) {
-                               drawaxes(1.0f, flag, OB_ARROWS);
+                               drawaxes(rv3d, rv3d->viewmatob, 1.0f, flag, OB_ARROWS);
+                       }
+                       if(dtx & OB_BOUNDBOX) {
+                               if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
+                                       draw_bounding_volume(scene, ob);
                        }
-                       if(dtx & OB_BOUNDBOX) draw_bounding_volume(scene, ob);
                        if(dtx & OB_TEXSPACE) drawtexspace(ob);
                        if(dtx & OB_DRAWNAME) {
                                /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */
@@ -6005,7 +6170,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                }
        }
 
-       if(dt<OB_SHADED) {
+       if(dt<OB_SHADED && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
                if((ob->gameflag & OB_DYNAMIC) || 
                        ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) {
                        float imat[4][4], vec[3];
@@ -6194,7 +6359,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh
        if (facecol) {
                dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0);
 
-               if( CHECK_OB_DRAWFACEDOT(scene, v3d, ob->dt) ) {
+               if(check_ob_drawface_dot(scene, v3d, ob->dt)) {
                        glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
                
                        bglBegin(GL_POINTS);
@@ -6314,9 +6479,9 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
 
        if(dt<=OB_WIRE) {
                if(dm)
-                       dm->drawEdges(dm, 1);
+                       dm->drawEdges(dm, 1, 0);
                else if(edm)
-                       edm->drawEdges(edm, 1); 
+                       edm->drawEdges(edm, 1, 0);      
        }
        else {
                if(outline)
@@ -6360,7 +6525,7 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                        draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline);
                        break;
                case OB_EMPTY:
-                       drawaxes(ob->empty_drawsize, 0, ob->empty_drawtype);
+                       drawaxes(rv3d, rv3d->viewmatob, ob->empty_drawsize, 0, ob->empty_drawtype);
                        break;
        }
 }