Merged changes in the trunk up to revision 42116.
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index e5797e1a14a46ec7f48ab5e10d317ef25dbb8a0f..be3a599330b15fe65d56c25f5d763c4cacb6b90b 100644 (file)
@@ -36,6 +36,7 @@
 #include "DNA_camera_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_constraint_types.h" // for drawing constraint
+#include "DNA_dynamicpaint_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_material_types.h"
 
 /* this condition has been made more complex since editmode can draw textures */
 #define CHECK_OB_DRAWTEXTURE(vd, dt)                                          \
-       ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) ||                             \
+       ((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);
@@ -252,6 +259,8 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
                return 0;
        if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
                return 0;
+       if(scene_use_new_shading_nodes(scene))
+               return 0;
        
        return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID);
 }
@@ -1090,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 */
@@ -1476,7 +1490,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
 
                glPushMatrix();
                        glTranslatef(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
-                       glScalef(v3d->bundle_size/0.05, v3d->bundle_size/0.05, v3d->bundle_size/0.05);
+                       glScalef(v3d->bundle_size/0.05f, v3d->bundle_size/0.05f, v3d->bundle_size/0.05f);
 
                        if(v3d->drawtype==OB_WIRE) {
                                glDisable(GL_LIGHTING);
@@ -1565,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();
 
@@ -1690,7 +1704,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
                        if(cam->flag & CAM_SHOWLIMITS) {
                                draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
                                /* qdn: was yafray only, now also enabled for Blender to be used with defocus composit node */
-                               draw_focus_cross(dof_camera(ob), cam->drawsize);
+                               draw_focus_cross(object_camera_dof_distance(ob), cam->drawsize);
                        }
 
                        wrld= scene->world;
@@ -1717,8 +1731,8 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
 
                glBegin(GL_LINE_LOOP);
                for(i = 0; i < 16; i++) {
-                       vec[0] = cosf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
-                       vec[1] = sinf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
+                       vec[0] = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
+                       vec[1] = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
                        glVertex3fv(vec);
                }
                glEnd();
@@ -1803,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);
 
        }
@@ -2573,7 +2587,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                                copy_v3_v3(v1, eed->v1->co);
                                copy_v3_v3(v2, eed->v2->co);
 
-                               interp_v3_v3v3(vmid, v1, v2, 0.5f);
+                               mid_v3_v3v3(vmid, v1, v2);
 
                                if(do_global) {
                                        mul_mat3_m4_v3(ob->obmat, v1);
@@ -2745,11 +2759,11 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                if(CHECK_OB_DRAWTEXTURE(v3d, dt)) {
                        if(draw_glsl_material(scene, ob, v3d, dt)) {
                                glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
-
+                               
                                finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
-                                       draw_em_fancy__setGLSLFaceOpts, NULL);
+                                                            draw_em_fancy__setGLSLFaceOpts, NULL);
                                GPU_disable_material();
-
+                               
                                glFrontFace(GL_CCW);
                        }
                        else {
@@ -2759,12 +2773,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                else {
                        /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
-
+                       
                        glEnable(GL_LIGHTING);
                        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
-
+                       
                        finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL);
-
+                       
                        glFrontFace(GL_CCW);
                        glDisable(GL_LIGHTING);
                }
@@ -2935,16 +2949,36 @@ 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));
-       const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob));
-       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;
+       int draw_flags = (ob==OBACT && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
 
        if(!dm)
                return;
-       
-       if (ob->dtx&OB_DRAWWIRE) {
-               draw_wire = 2; /* draw wire after solid using zoffset and depth buffer adjusment */
+
+       /* check to draw dynamic paint colors */
+       if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
+       {
+               /* check if target has an active dpaint modifier        */
+               if(md && (md->mode & eModifierMode_Realtime))                                   
+               {
+                       DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+                       /* if canvas is ready to preview vertex colors */
+                       if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY &&
+                               DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) {
+                               draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW;
+                       }
+               }
+       }
+
+       /* 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*/
@@ -2954,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 (is_paint_sel) 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);
@@ -2967,16 +2998,21 @@ 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(        (is_paint_sel || (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 || is_paint_sel) && !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);
                }
 
-               if(draw_glsl_material(scene, ob, v3d, dt)) {
+               if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
                        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
                        dm->drawFacesGLSL(dm, GPU_enable_material);
@@ -2987,10 +3023,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        glFrontFace(GL_CCW);
                }
                else {
-                       draw_mesh_textured(scene, v3d, rv3d, ob, dm, is_paint_sel);
+                       draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags);
                }
 
-               if(!is_paint_sel) {
+               if(!(draw_flags & DRAW_FACE_SELECT)) {
                        if(base->flag & SELECT)
                                UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
                        else
@@ -3024,13 +3060,57 @@ 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 */
+                       if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) {
+                               dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
+                       }
+                       else {
+                               /* draw outline */
+                               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();
+
+                               GPU_enable_material(0, NULL);
+                               
+                               /* set default spec */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
+                               glEnable(GL_COLOR_MATERIAL);    /* according manpages needed */
+                               glColor3ub(120, 120, 120);
+                               glDisable(GL_COLOR_MATERIAL);
+                               /* diffuse */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+                               glEnable(GL_LIGHTING);
+                               glEnable(GL_COLOR_MATERIAL);
+
+                               dm->drawMappedFaces(dm, NULL, NULL, 1, GPU_enable_material, NULL);
+                               glDisable(GL_COLOR_MATERIAL);
+                               glDisable(GL_LIGHTING);
+
+                               GPU_disable_material();
+                       }
                }
                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 );
 
@@ -3124,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
@@ -3147,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
                }
@@ -3155,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);
                }
@@ -3210,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();
 
@@ -3671,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);
                }
        }
 
@@ -3694,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;
@@ -3722,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);
@@ -3769,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;
@@ -3785,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;
                        }
 
@@ -3842,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];
@@ -3906,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);
@@ -4075,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);
@@ -4119,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{
@@ -4380,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);
 
@@ -4445,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) ) {