Merge with -r 22620:23107.
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index 57e7d897e249f3d358a7ba72cdc03a5531572fd0..7ed029f3eaf0506a684b443268ccdf4f6628a98c 100644 (file)
@@ -37,7 +37,7 @@
 #include "IMB_imbuf.h"
 
 
-#include "MTC_matrixops.h"
+
 
 #include "DNA_armature_types.h"
 #include "DNA_boid_types.h"
@@ -1124,7 +1124,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
                        Mat4Ortho(vec);
                        wmMultMatrix(vec);
 
-                       MTC_Mat4SwapMat4(rv3d->persmat, tmat);
+                       Mat4SwapMat4(rv3d->persmat, tmat);
                        wmGetSingleMatrix(rv3d->persmat);
 
                        if(cam->flag & CAM_SHOWLIMITS) {
@@ -1137,7 +1137,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
                        if(cam->flag & CAM_SHOWMIST) 
                                if(wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF);
                                
-                       MTC_Mat4SwapMat4(rv3d->persmat, tmat);
+                       Mat4SwapMat4(rv3d->persmat, tmat);
                }
        }
 }
@@ -1198,7 +1198,7 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
 
        if(use_wcol) {
                float col[3];
-               MDeformWeight *mdw= get_defweight (lt->dvert+index, use_wcol-1);
+               MDeformWeight *mdw= ED_vgroup_weight_get (lt->dvert+index, use_wcol-1);
                
                weight_to_rgb(mdw?mdw->weight:0.0f, col, col+1, col+2);
                glColor3fv(col);
@@ -1392,12 +1392,13 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb
        int i;
 
        for (nu= cu->editnurb->first; nu; nu=nu->next) {
-               if((nu->type & 7)==CU_BEZIER) {
+               if(nu->type == CU_BEZIER) {
                        for (i=0; i<nu->pntsu; i++) {
                                BezTriple *bezt = &nu->bezt[i];
 
                                if(bezt->hide==0) {
-                                       if (G.f & G_HIDDENHANDLES) {
+                                       
+                                       if(cu->drawflag & CU_HIDE_HANDLES) {
                                                view3d_project_short_clip(vc->ar, bezt->vec[1], s);
                                                if (s[0] != IS_CLIPPED)
                                                        func(userData, nu, NULL, bezt, 1, s[0], s[1]);
@@ -2797,7 +2798,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
                if(solid) {
                        dl= lb->first;
                        if(dl==NULL) return 1;
-                       
+
                        if(dl->nors==0) addnormalsDispList(ob, lb);
                        index3_nors_incr= 0;
                        
@@ -2838,7 +2839,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
                }
                break;
        case OB_SURF:
-       
+
                lb= &((Curve *)ob->data)->disp;
                
                if(solid) {
@@ -3877,18 +3878,18 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj
 unsigned int nurbcol[8]= {
        0, 0x9090, 0x409030, 0x603080, 0, 0x40fff0, 0x40c033, 0xA090F0 };
 
-static void tekenhandlesN(Nurb *nu, short sel)
+static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
 {
        BezTriple *bezt;
        float *fp;
        unsigned int *col;
        int a;
        
-       if(nu->hide || (G.f & G_HIDDENHANDLES)) return;
+       if(nu->hide || hide_handles) return;
        
        glBegin(GL_LINES); 
        
-       if( (nu->type & 7)==CU_BEZIER) {
+       if(nu->type == CU_BEZIER) {
                if(sel) col= nurbcol+4;
                else col= nurbcol;
 
@@ -3928,7 +3929,7 @@ static void tekenhandlesN(Nurb *nu, short sel)
        glEnd();
 }
 
-static void tekenvertsN(Nurb *nu, short sel)
+static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
 {
        BezTriple *bezt;
        BPoint *bp;
@@ -3945,13 +3946,13 @@ static void tekenvertsN(Nurb *nu, short sel)
        
        bglBegin(GL_POINTS);
        
-       if((nu->type & 7)==CU_BEZIER) {
+       if(nu->type == CU_BEZIER) {
 
                bezt= nu->bezt;
                a= nu->pntsu;
                while(a--) {
                        if(bezt->hide==0) {
-                               if (G.f & G_HIDDENHANDLES) {
+                               if (hide_handles) {
                                        if((bezt->f2 & SELECT)==sel) bglVertex3fv(bezt->vec[1]);
                                } else {
                                        if((bezt->f1 & SELECT)==sel) bglVertex3fv(bezt->vec[0]);
@@ -3986,7 +3987,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
        nu= nurb;
        while(nu) {
                if(nu->hide==0) {
-                       switch(nu->type & 7) {
+                       switch(nu->type) {
                        case CU_POLY:
                                cpack(nurbcol[3]);
                                bp= nu->bp;
@@ -4083,6 +4084,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        Curve *cu = ob->data;
        Nurb *nu;
        BevList *bl;
+       short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
 
 // XXX retopo_matrix_update(v3d);
 
@@ -4094,23 +4096,25 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        
        /* first non-selected handles */
        for(nu=nurb; nu; nu=nu->next) {
-               if((nu->type & 7)==CU_BEZIER) {
-                       tekenhandlesN(nu, 0);
+               if(nu->type == CU_BEZIER) {
+                       tekenhandlesN(nu, 0, hide_handles);
                }
        }
        draw_editnurb(ob, nurb, 0);
        draw_editnurb(ob, nurb, 1);
        /* selected handles */
        for(nu=nurb; nu; nu=nu->next) {
-               if((nu->type & 7)==1) tekenhandlesN(nu, 1);
-               tekenvertsN(nu, 0);
+               if(nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES)==0)
+                       tekenhandlesN(nu, 1, hide_handles);
+               tekenvertsN(nu, 0, hide_handles);
        }
        
        if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
 
        /*      direction vectors for 3d curve paths
                when at its lowest, dont render normals */
-       if(cu->flag & CU_3D && ts->normalsize > 0.0015) {
+       if(cu->flag & CU_3D && ts->normalsize > 0.0015 && (cu->drawflag & CU_HIDE_NORMALS)==0) {
+
                UI_ThemeColor(TH_WIRE);
                for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) {
                        BevPoint *bevp= (BevPoint *)(bl+1);             
@@ -4145,7 +4149,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);
+               tekenvertsN(nu, 1, hide_handles);
        }
        
        if(v3d->zbuf) glEnable(GL_DEPTH_TEST); 
@@ -5306,13 +5310,60 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        }
 
        /* draw code for smoke */
+       if((md = modifiers_findByType(ob, eModifierType_Smoke)))
        {
-               md = modifiers_findByType(ob, eModifierType_Smoke);
-               if (md) {
-                       SmokeModifierData *smd = (SmokeModifierData *)md;
-                       if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain && smd->domain->fluid) {
-                               GPU_create_smoke(smd);
-                               draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res);
+               SmokeModifierData *smd = (SmokeModifierData *)md;
+
+               // draw collision objects
+               if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll)
+               {
+                       /*SmokeCollSettings *scs = smd->coll;
+                       if(scs->points)
+                       {
+                               size_t i;
+
+                               wmLoadMatrix(rv3d->viewmat);
+
+                               if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); 
+                               glDepthMask(GL_FALSE);
+                               glEnable(GL_BLEND);
+                               
+
+                               // glPointSize(3.0);
+                               bglBegin(GL_POINTS);
+
+                               for(i = 0; i < scs->numpoints; i++)
+                               {
+                                       bglVertex3fv(&scs->points[3*i]);
+                               }
+
+                               bglEnd();
+                               glPointSize(1.0);
+
+                               wmMultMatrix(ob->obmat);
+                               glDisable(GL_BLEND);
+                               glDepthMask(GL_TRUE);
+                               if(col) cpack(col);
+                               
+                       }
+                       */
+               }
+
+               // only draw domains
+               if(smd->domain && smd->domain->fluid)
+               {
+                       if(!smd->domain->wt || !(smd->domain->viewsettings & MOD_SMOKE_VIEW_SHOWBIG))
+                       {
+                               smd->domain->tex = NULL;
+                               GPU_create_smoke(smd, 0);
+                               draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res, smd->domain->dx, smd->domain->tex_shadow);
+                               GPU_free_smoke(smd);
+                       }
+                       else if(smd->domain->wt || (smd->domain->viewsettings & MOD_SMOKE_VIEW_SHOWBIG))
+                       {
+                               smd->domain->tex = NULL;
+                               GPU_create_smoke(smd, 1);
+                               draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res_wt, smd->domain->dx_wt, smd->domain->tex_shadow);
                                GPU_free_smoke(smd);
                        }
                }