Merged changes in the trunk up to revision 42116.
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index baf977e605694dddf0c458d6e4d8385af2272a76..be3a599330b15fe65d56c25f5d763c4cacb6b90b 100644 (file)
        ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt>OB_SOLID) ||          \
        (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
 
+typedef enum eWireDrawMode {
+       OBDRAW_WIRE_OFF= 0,
+       OBDRAW_WIRE_ON= 1,
+       OBDRAW_WIRE_ON_DEPTH= 2
+} eWireDrawMode;
+
 static void draw_bounding_volume(Scene *scene, Object *ob, char type);
 
 static void drawcube_size(float size);
@@ -1093,7 +1099,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */
        /* the moment of view3d_draw_transp() call */
        const short is_view= (rv3d->persp==RV3D_CAMOB && v3d->camera == base->object);
-       const short drawcone= (dt>OB_WIRE && !(G.f & G_PICKSEL) && (la->type == LA_SPOT) && (la->mode & LA_SHOW_CONE) && !(base->flag & OB_FROMDUPLI) && !is_view);
+       const short drawcone= ((dt > OB_WIRE) &&
+                              !(G.f & G_PICKSEL) &&
+                              (la->type == LA_SPOT) &&
+                              (la->mode & LA_SHOW_CONE) &&
+                              !(base->flag & OB_FROMDUPLI) &&
+                              !is_view);
 
        if(drawcone && !v3d->transp) {
                /* in this case we need to draw delayed */
@@ -1568,7 +1579,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
 
                        glBegin(GL_LINE_STRIP);
                                for(a= 0; a<reconstruction->camnr; a++, camera++) {
-                                       glVertex3f(camera->mat[3][0], camera->mat[3][1], camera->mat[3][2]);
+                                       glVertex3fv(camera->mat[3]);
                                }
                        glEnd();
 
@@ -1806,7 +1817,7 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
                float col[3];
                MDeformWeight *mdw= defvert_find_index (lt->dvert+index, use_wcol-1);
                
-               weight_to_rgb(mdw?mdw->weight:0.0f, col, col+1, col+2);
+               weight_to_rgb(col, mdw?mdw->weight:0.0f);
                glColor3fv(col);
 
        }
@@ -2290,21 +2301,32 @@ static void draw_dm_edges_sharp(DerivedMesh *dm)
        dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, NULL);
 }
 
+       /* Draw only Freestyle feature edges */
+static int draw_dm_edges_freestyle__setDrawOptions(void *UNUSED(userData), int index)
+{
+       EditEdge *eed = EM_get_edge_for_index(index);
+
+       return (eed->h==0 && eed->freestyle);
+}
+static void draw_dm_edges_freestyle(DerivedMesh *dm)
+{
+       dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, NULL);
+}
 
        /* Draw faces with color set based on selection
         * return 2 for the active face so it renders with stipple enabled */
 static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r))
 {
-       struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
+       struct { unsigned char *cols[4]; EditFace *efa_act; } * data = userData;
        EditFace *efa = EM_get_face_for_index(index);
        unsigned char *col;
        
        if (efa->h==0) {
                if (efa == data->efa_act) {
-                       glColor4ubv(data->cols[2]);
+                       glColor4ubv(data->cols[3]);
                        return 2; /* stipple */
                } else {
-                       col = data->cols[(efa->f&SELECT)?1:0];
+                       col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
                        if (col[3]==0) return 0;
                        glColor4ubv(col);
                        return 1;
@@ -2315,7 +2337,7 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU
 
 static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index)
 {
-       struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
+       struct { unsigned char *cols[4]; EditFace *efa_act; } * data = userData;
        EditFace *efa = EM_get_face_for_index(index);
        EditFace *next_efa = EM_get_face_for_index(next_index);
        unsigned char *col, *next_col;
@@ -2326,8 +2348,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
        if(efa == data->efa_act || next_efa == data->efa_act)
                return 0;
 
-       col = data->cols[(efa->f&SELECT)?1:0];
-       next_col = data->cols[(next_efa->f&SELECT)?1:0];
+       col = data->cols[(efa->f & SELECT) ? 1 : (efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
+       next_col = data->cols[(next_efa->f & SELECT) ? 1 : (next_efa->flag & ME_FREESTYLE_FACE) ? 2 : 0];
 
        if(col[3]==0 || next_col[3]==0)
                return 0;
@@ -2336,12 +2358,13 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
 }
 
 /* also draws the active face */
-static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) 
+static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, EditFace *efa_act) 
 {
-       struct { unsigned char *cols[3]; EditFace *efa_act; } data;
+       struct { unsigned char *cols[4]; EditFace *efa_act; } data;
        data.cols[0] = baseCol;
        data.cols[1] = selCol;
-       data.cols[2] = actCol;
+       data.cols[2] = markCol;
+       data.cols[3] = actCol;
        data.efa_act = efa_act;
 
        dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions);
@@ -2775,11 +2798,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
        }
        
        if(me->drawflag & ME_DRAWFACES) {       /* transp faces */
-               unsigned char col1[4], col2[4], col3[4];
+               unsigned char col1[4], col2[4], col3[4], col4[4];
                        
                UI_GetThemeColor4ubv(TH_FACE, col1);
                UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
-               UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
+               UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3);
+               UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
@@ -2788,7 +2812,10 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                if CHECK_OB_DRAWTEXTURE(v3d, dt)
                        col1[3] = 0;
                
-               draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
+               if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE))
+                       col3[3] = 0;
+
+               draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
 
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
@@ -2796,14 +2823,14 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                /* even if draw faces is off it would be nice to draw the stipple face
                 * Make all other faces zero alpha except for the active
                 * */
-               unsigned char col1[4], col2[4], col3[4];
-               col1[3] = col2[3] = 0; /* dont draw */
-               UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
+               unsigned char col1[4], col2[4], col3[4], col4[4];
+               col1[3] = col2[3] = col3[3] = 0; /* dont draw */
+               UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
                
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                
-               draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
+               draw_dm_faces_sel(cageDM, col1, col2, col3, col4, efa_act);
 
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
@@ -2838,6 +2865,16 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                        glLineWidth(1);
                }
        
+               if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) {
+                       UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
+                       glLineWidth(2);
+       
+                       draw_dm_edges_freestyle(cageDM);
+       
+                       glColor3ub(0,0,0);
+                       glLineWidth(1);
+               }
+       
                if(me->drawflag & ME_DRAWCREASES) {
                        draw_dm_creases(cageDM);
                }
@@ -2912,7 +2949,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
        Mesh *me = ob->data;
        Material *ma= give_current_material(ob, 1);
        const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO));
-       int draw_wire = 0;
+       eWireDrawMode draw_wire= OBDRAW_WIRE_OFF;
        int /* totvert,*/ totedge, totface;
        DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
        ModifierData *md = NULL;
@@ -2935,9 +2972,13 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        }
                }
        }
-       
-       if (ob->dtx&OB_DRAWWIRE) {
-               draw_wire = 2; /* draw wire after solid using zoffset and depth buffer adjusment */
+
+       /* Unwanted combination */
+       if (draw_flags & DRAW_FACE_SELECT) {
+               draw_wire= OBDRAW_WIRE_OFF;
+       }
+       else if (ob->dtx & OB_DRAWWIRE) {
+               draw_wire= OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */
        }
        
        /* totvert = dm->getNumVerts(dm); */ /*UNUSED*/
@@ -2947,9 +2988,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
        /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
-               // Unwanted combination.
-       if (draw_flags & DRAW_FACE_SELECT) draw_wire = 0;
-
        if(dt==OB_BOUNDBOX) {
                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
                        draw_bounding_volume(scene, ob, ob->boundtype);
@@ -2960,12 +2998,17 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                glPointSize(1.0);
        }
        else if(dt==OB_WIRE || totface==0) {
-               draw_wire = 1; /* draw wire only, no depth buffer stuff  */
+               draw_wire= OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff  */
        }
-       else if(        (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
-                               CHECK_OB_DRAWTEXTURE(v3d, dt))
+       else if ( (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
+                 CHECK_OB_DRAWTEXTURE(v3d, dt))
        {
-               if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && !draw_wire) {
+               if ( (v3d->flag & V3D_SELECT_OUTLINE) &&
+                    ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) &&
+                    (base->flag & SELECT) &&
+                    !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
+                    (draw_wire == OBDRAW_WIRE_OFF))
+               {
                        draw_mesh_object_outline(v3d, ob, dm);
                }
 
@@ -3017,7 +3060,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        GPU_disable_material();
                        
                        /* since we already draw wire as wp guide, dont draw over the top */
-                       draw_wire= 0;
+                       draw_wire= OBDRAW_WIRE_OFF;
                }
                else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) {
                        /* for object selection draws no shade */
@@ -3026,8 +3069,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        }
                        else {
                                /* draw outline */
-                               if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt)
+                               if ( (v3d->flag & V3D_SELECT_OUTLINE) &&
+                                    ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) &&
+                                    (base->flag & SELECT) &&
+                                    (draw_wire == OBDRAW_WIRE_OFF) &&
+                                    (ob->sculpt == NULL))
+                               {
                                        draw_mesh_object_outline(v3d, ob, dm);
+                               }
 
                                /* materials arent compatible with vertex colors */
                                GPU_end_object_materials();
@@ -3054,8 +3103,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                else {
                        Paint *p;
 
-                       if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt)
+                       if ( (v3d->flag & V3D_SELECT_OUTLINE) &&
+                            ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) &&
+                            (base->flag & SELECT) &&
+                            (draw_wire == OBDRAW_WIRE_OFF) &&
+                            (ob->sculpt == NULL))
+                       {
                                draw_mesh_object_outline(v3d, ob, dm);
+                       }
 
                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED );
 
@@ -3149,7 +3204,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        }
                }
        }
-       if (draw_wire) {
+       if (draw_wire != OBDRAW_WIRE_OFF) {
 
                /* When using wireframe object traw in particle edit mode
                 * the mesh gets in the way of seeing the particles, fade the wire color
@@ -3172,7 +3227,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                 * if draw wire is 1 then just drawing wire, no need for depth buffer stuff,
                 * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks.
                 */
-               if (dt!=OB_WIRE && draw_wire==2) {
+               if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
                        bglPolygonOffset(rv3d->dist, 1.0);
                        glDepthMask(0); // disable write in zbuffer, selected edge wires show better
                }
@@ -3180,7 +3235,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                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) {
+               if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
                        glDepthMask(1);
                        bglPolygonOffset(rv3d->dist, 0.0);
                }
@@ -3235,15 +3290,11 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
 
                if(dt>OB_WIRE) {
                        glsl = draw_glsl_material(scene, ob, v3d, dt);
-                       check_alpha = check_material_alpha(base, glsl);
 
-                       GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl,
-                                       (check_alpha)? &do_alpha_pass: NULL);
+                       GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
                }
 
-               // transp in editmode makes the fancy draw over go bad
-               if (!do_alpha_pass)
-                       draw_em_fancy(scene, v3d, rv3d, ob, em, cageDM, finalDM, dt);
+               draw_em_fancy(scene, v3d, rv3d, ob, em, cageDM, finalDM, dt);
 
                GPU_end_object_materials();
 
@@ -3696,19 +3747,15 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
        float vec[3], vec2[3];
        float *vd = NULL;
        float *cd = NULL;
-       float ma_r=0.0f;
-       float ma_g=0.0f;
-       float ma_b=0.0f;
+       float ma_col[3]= {0.0f, 0.0f, 0.0f};
 
        /* null only for PART_DRAW_CIRC */
        if(pdd) {
                vd = pdd->vd;
                cd = pdd->cd;
 
-               if(pdd->ma_r) {
-                       ma_r = *pdd->ma_r;
-                       ma_g = *pdd->ma_g;
-                       ma_b = *pdd->ma_b;
+               if(pdd->ma_col) {
+                       copy_v3_v3(ma_col, pdd->ma_col);
                }
        }
 
@@ -3719,9 +3766,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                                copy_v3_v3(vd,state->co); pdd->vd+=3;
                        }
                        if(cd) {
-                               cd[0]=ma_r;
-                               cd[1]=ma_g;
-                               cd[2]=ma_b;
+                               copy_v3_v3(cd, pdd->ma_col);
                                pdd->cd+=3;
                        }
                        break;
@@ -3747,9 +3792,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                        }
                        else {
                                if(cd) {
-                                       cd[0]=cd[3]=cd[6]=cd[9]=cd[12]=cd[15]=ma_r;
-                                       cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]=ma_g;
-                                       cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma_b;
+                                       cd[0]=cd[3]=cd[6]=cd[ 9]=cd[12]=cd[15]= ma_col[0];
+                                       cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]= ma_col[1];
+                                       cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]= ma_col[2];
                                        pdd->cd+=18;
                                }
                                sub_v3_v3v3(vec2, state->co, vec);
@@ -3794,9 +3839,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                        madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3;
                        madd_v3_v3v3fl(pdd->vd, state->co, vec,  draw_line[1]); pdd->vd+=3;
                        if(cd) {
-                               cd[0]=cd[3]=ma_r;
-                               cd[1]=cd[4]=ma_g;
-                               cd[2]=cd[5]=ma_b;
+                               cd[0]=cd[3]= ma_col[0];
+                               cd[1]=cd[4]= ma_col[1];
+                               cd[2]=cd[5]= ma_col[2];
                                pdd->cd+=6;
                        }
                        break;
@@ -3810,9 +3855,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                {
                        float xvec[3], yvec[3], zvec[3], bb_center[3];
                        if(cd) {
-                               cd[0]=cd[3]=cd[6]=cd[9]=ma_r;
-                               cd[1]=cd[4]=cd[7]=cd[10]=ma_g;
-                               cd[2]=cd[5]=cd[8]=cd[11]=ma_b;
+                               cd[0]=cd[3]=cd[6]=cd[ 9]= ma_col[0];
+                               cd[1]=cd[4]=cd[7]=cd[10]= ma_col[1];
+                               cd[2]=cd[5]=cd[8]=cd[11]= ma_col[2];
                                pdd->cd+=12;
                        }
 
@@ -3867,7 +3912,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
        float timestep, pixsize=1.0, pa_size, r_tilt, r_length;
        float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
        float cfra;
-       float ma_r=0.0f, ma_g=0.0f, ma_b=0.0f;
+       float ma_col[3]= {0.0f, 0.0f, 0.0f};
        int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0;
        int select=ob->flag&SELECT, create_cdata=0, need_v=0;
        GLint polygonmode[2];
@@ -3931,10 +3976,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
                rgb_float_to_byte(&(ma->r), tcol);
-
-               ma_r = ma->r;
-               ma_g = ma->g;
-               ma_b = ma->b;
+               copy_v3_v3(ma_col, &ma->r);
        }
 
        glColor3ubv(tcol);
@@ -4100,9 +4142,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
        }
 
        if(pdd) {
-               pdd->ma_r = &ma_r;
-               pdd->ma_g = &ma_g;
-               pdd->ma_b = &ma_b;
+               pdd->ma_col= ma_col;
        }
 
        psys->lattice= psys_get_lattice(&sim);
@@ -4144,7 +4184,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                                                        intensity= 1.0f; /* should never happen */
                                        }
                                        CLAMP(intensity, 0.f, 1.f);
-                                       weight_to_rgb(intensity, &ma_r, &ma_g, &ma_b);
+                                       weight_to_rgb(ma_col, intensity);
                                }
                        }
                        else{
@@ -4405,7 +4445,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                }
 
                /* restore from select */
-               glColor3f(ma_r,ma_g,ma_b);
+               glColor3fv(ma_col);
                glPointSize(part->draw_size ? part->draw_size : 2.0);
                glLineWidth(1.0);
 
@@ -4470,7 +4510,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        if(pdd) {
                /* drop references to stack memory */
-               pdd->ma_r= pdd->ma_g= pdd->ma_b= NULL;
+               pdd->ma_col= NULL;
        }
 
        if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {