Revision: 14499
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14499
Author:   campbellbarton
Date:     2008-04-21 11:13:56 +0200 (Mon, 21 Apr 2008)

Log Message:
-----------
ground clamp during transform for speedy level editing,

The way this is integrated into transform code is really unacceptable, tried 
making this integrate into snap and retopo, but neither are good fits. - Will 
discuss with Theeth how this might best fit in.

Modified Paths:
--------------
    branches/apricot/source/blender/include/BSE_drawview.h
    branches/apricot/source/blender/include/transform.h
    branches/apricot/source/blender/src/buttons_editing.c
    branches/apricot/source/blender/src/drawview.c
    branches/apricot/source/blender/src/editview.c
    branches/apricot/source/blender/src/retopo.c
    branches/apricot/source/blender/src/transform.c
    branches/apricot/source/blender/src/transform_conversions.c
    branches/apricot/source/blender/src/transform_generics.c
    branches/apricot/source/blender/src/view.c

Modified: branches/apricot/source/blender/include/BSE_drawview.h
===================================================================
--- branches/apricot/source/blender/include/BSE_drawview.h      2008-04-21 
03:56:34 UTC (rev 14498)
+++ branches/apricot/source/blender/include/BSE_drawview.h      2008-04-21 
09:13:56 UTC (rev 14499)
@@ -56,9 +56,11 @@
 
 void drawview3dspace(struct ScrArea *sa, void *spacedata);
 void drawview3d_render(struct View3D *v3d, int winx, int winy, float 
winmat[][4]);
-void draw_depth(struct ScrArea *sa, void *spacedata);
+void draw_depth(struct ScrArea *sa, void *spacedata, int (*func)(void *) );
 void view3d_update_depths(struct View3D *v3d);
 
+void (*foo)(int);
+
 int update_time(void);
 void calc_viewborder(struct View3D *v3d, struct rctf *viewborder_r);
 void view3d_set_1_to_1_viewborder(struct View3D *v3d);

Modified: branches/apricot/source/blender/include/transform.h
===================================================================
--- branches/apricot/source/blender/include/transform.h 2008-04-21 03:56:34 UTC 
(rev 14498)
+++ branches/apricot/source/blender/include/transform.h 2008-04-21 09:13:56 UTC 
(rev 14499)
@@ -31,6 +31,7 @@
 #define TRANSFORM_H
 
 #include "BIF_transform.h"
+#include "BIF_glutil.h"
 
 /* ************************** Types ***************************** */
 
@@ -213,6 +214,10 @@
        struct Object *poseobj;         /* if t->flag & T_POSE, this denotes 
pose object */
        
        void       *customData;         /* Per Transform custom data */
+       
+       /* APRICOT HACK */
+       void            *txdepth;
+       struct bglMats txmats;
 } TransInfo;
 
 

Modified: branches/apricot/source/blender/src/buttons_editing.c
===================================================================
--- branches/apricot/source/blender/src/buttons_editing.c       2008-04-21 
03:56:34 UTC (rev 14498)
+++ branches/apricot/source/blender/src/buttons_editing.c       2008-04-21 
09:13:56 UTC (rev 14499)
@@ -875,6 +875,8 @@
                        uiButSetFunc(but,retopo_do_all_cb,ob,me);
                }
                uiBlockEndAlign(block);
+       } else {
+               but= uiDefButBitC(block,TOG,RETOPO,B_NOP, "Ground Snap", 
10,130,170,19, &G.scene->toolsettings->retopo_mode, 0,0,0,0, "");
        }
 
        uiBlockBeginAlign(block);

Modified: branches/apricot/source/blender/src/drawview.c
===================================================================
--- branches/apricot/source/blender/src/drawview.c      2008-04-21 03:56:34 UTC 
(rev 14498)
+++ branches/apricot/source/blender/src/drawview.c      2008-04-21 09:13:56 UTC 
(rev 14499)
@@ -2886,7 +2886,7 @@
        }
 }
 
-void draw_depth(ScrArea *sa, void *spacedata)
+void draw_depth(ScrArea *sa, void *spacedata, int (* func)(void *))
 {
        View3D *v3d= spacedata;
        Base *base;
@@ -2926,9 +2926,11 @@
        if(G.scene->set) {
                for(SETLOOPER(G.scene->set, base)) {
                        if(v3d->lay & base->lay) {
-                               draw_object(base, 0);
-                               if(base->object->transflag & OB_DUPLI) {
-                                       draw_dupli_objects_color(v3d, base, 
TH_WIRE);
+                               if (func == NULL || func(base)) {
+                                       draw_object(base, 0);
+                                       if(base->object->transflag & OB_DUPLI) {
+                                               draw_dupli_objects_color(v3d, 
base, TH_WIRE);
+                                       }
                                }
                        }
                }
@@ -2936,12 +2938,13 @@
        
        for(base= G.scene->base.first; base; base= base->next) {
                if(v3d->lay & base->lay) {
-                       
-                       /* dupli drawing */
-                       if(base->object->transflag & OB_DUPLI) {
-                               draw_dupli_objects(v3d, base);
+                       if (func == NULL || func(base)) {
+                               /* dupli drawing */
+                               if(base->object->transflag & OB_DUPLI) {
+                                       draw_dupli_objects(v3d, base);
+                               }
+                               draw_object(base, 0);
                        }
-                       draw_object(base, 0);
                }
        }
        

Modified: branches/apricot/source/blender/src/editview.c
===================================================================
--- branches/apricot/source/blender/src/editview.c      2008-04-21 03:56:34 UTC 
(rev 14498)
+++ branches/apricot/source/blender/src/editview.c      2008-04-21 09:13:56 UTC 
(rev 14499)
@@ -2247,7 +2247,7 @@
        
        /* Get Z Depths, needed for perspective, nice for ortho */
        bgl_get_mats(&mats);
-       draw_depth(curarea, (void *)v3d);
+       draw_depth(curarea, (void *)v3d, NULL);
        
        /* force updating */
        if (v3d->depths) {

Modified: branches/apricot/source/blender/src/retopo.c
===================================================================
--- branches/apricot/source/blender/src/retopo.c        2008-04-21 03:56:34 UTC 
(rev 14498)
+++ branches/apricot/source/blender/src/retopo.c        2008-04-21 09:13:56 UTC 
(rev 14499)
@@ -71,6 +71,8 @@
 #include "editmesh.h"
 #include "mydevice.h"
 
+#include "blendef.h"
+
 #ifdef WIN32
 #define _USE_MATH_DEFINES
 #endif
@@ -736,6 +738,10 @@
        return G.obedit && (G.obedit->type==OB_CURVE ||
                            G.obedit->type==OB_SURF) && 
(((Curve*)G.obedit->data)->flag & CU_RETOPO);
 }
+char retopo_object_check()
+{
+       return ((G.obedit==0) && ((FACESEL_PAINT_TEST)==0) && (G.f & 
G_PARTICLEEDIT)==0 && (G.f & G_SCULPTMODE)==0 && 
(G.scene->toolsettings->retopo_mode & RETOPO));
+}
 
 void retopo_toggle(void *j1,void *j2)
 {
@@ -792,6 +798,11 @@
        retopo_do_2d(v3d,proj,v,0);
 }
 
+static int testbase_unselected( void *base )
+{
+       return (((Base *)base)->flag & SELECT) ? 0 : 1;
+}
+
 void retopo_do_all()
 {
        RetopoViewData *rvd= G.vd->retopo_view_data;
@@ -850,6 +861,65 @@
                        DAG_object_flush_update(G.scene, G.obedit, 
OB_RECALC_DATA);
                        allqueue(REDRAWVIEW3D, 0);                      
                }
+       } else if(retopo_object_check()) {
+               //if(rvd) {
+               if (1) {
+               
+                       /* APRICOT HACK */
+                       Base *base;
+                       Object *ob;
+                       short s[2];
+                       View3D *v3d = G.vd;
+                       
+                       /* --- Make external func --- */
+                       
+                       /* ZBuffer depth vars */
+                       bglMats mats;
+                       float depth_close= ((float)3.40282347e+38);
+                       int had_depth = 0;
+                       double cent[2],  p[3];
+                       
+                       
+                       persp(PERSP_VIEW);
+                       
+                       /* Get Z Depths, needed for perspective, nice for ortho 
*/
+                       bgl_get_mats(&mats);
+                       draw_depth(curarea, (void *)G.vd, testbase_unselected);
+                       
+                       /* force updating */
+                       if (v3d->depths) {
+                               had_depth = 1;
+                               v3d->depths->damaged = 1;
+                       }
+                       
+                       view3d_update_depths(v3d);
+                       
+                       /* we have depths now*/                 
+                       for (base=G.scene->base.first; base; base=base->next) {
+                               /* object mode */
+                               if (TESTBASELIB(base)) {
+                                       ob = base->object;
+                                       project_short(ob->loc, s);
+                                       
+                                       if (s[0] != IS_CLIPPED) {
+                                               cent[0] = (double)s[0];
+                                               cent[1] = (double)s[1];
+                                               depth_close= 
v3d->depths->depths[s[1]*v3d->depths->w+s[0]];
+                                               if(depth_close < 
v3d->depths->depth_range[1] && depth_close > v3d->depths->depth_range[0]) {
+                                                       if 
(!gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, 
mats.viewport, &p[0], &p[1], &p[2])) {
+                                                               /* do nothing */
+                                                       } else {
+                                                               ob->loc[0] = 
(float)p[0];
+                                                               ob->loc[1] = 
(float)p[1];
+                                                               ob->loc[2] = 
(float)p[2];
+                                                               
DAG_object_flush_update(G.scene, ob, OB_RECALC);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       // ---
+               }
        }
 }
 

Modified: branches/apricot/source/blender/src/transform.c
===================================================================
--- branches/apricot/source/blender/src/transform.c     2008-04-21 03:56:34 UTC 
(rev 14498)
+++ branches/apricot/source/blender/src/transform.c     2008-04-21 09:13:56 UTC 
(rev 14499)
@@ -2943,6 +2943,85 @@
        }
 }
 
+static int testbase_unselected( void *base )
+{
+       return (((Base *)base)->flag & SELECT) ? 0 : 1;
+}
+
+
+
+
+static void applyTranslationRetopo(TransInfo *t) {
+       TransData *td = t->data;
+       //float tvec[3];
+       int i;
+
+       
+       // -----------------
+       /* APRICOT HACK */
+       Base *base;
+       Object *ob;
+       short s[2];
+       View3D *v3d = G.vd;
+       double cent[2],  p[3];
+       float depth_close= ((float)3.40282347e+38);
+       
+       /* --- Make external func --- */
+       if (t->txdepth==NULL) {
+               /* ZBuffer depth vars */
+               //bglMats mats;
+               
+
+               
+               
+               
+               persp(PERSP_VIEW);
+               
+               /* Get Z Depths, needed for perspective, nice for ortho */
+               bgl_get_mats(&t->txmats);
+               draw_depth(curarea, (void *)G.vd, testbase_unselected);
+               
+               /* force updating */
+               if (v3d->depths) {
+                       v3d->depths->damaged = 1;
+               }
+               
+               view3d_update_depths(v3d);
+               // ---------------
+               t->txdepth = v3d->depths->depths;
+               //MEM_freeN(v3d->depths->depths);
+               //v3d->depths->depths = NULL;
+       } else {
+               v3d->depths->depths = t->txdepth;
+       }
+       
+       for(i = 0 ; i < t->total; i++, td++) {
+               project_short(td->loc, s);
+               
+               if (s[0] != IS_CLIPPED) {
+                       cent[0] = (double)s[0];
+                       cent[1] = (double)s[1];
+                       depth_close= 
v3d->depths->depths[s[1]*v3d->depths->w+s[0]];
+                       if(depth_close < v3d->depths->depth_range[1] && 
depth_close > v3d->depths->depth_range[0]) {
+                               if (!gluUnProject(cent[0], cent[1], 
depth_close, t->txmats.modelview, t->txmats.projection, t->txmats.viewport, 
&p[0], &p[1], &p[2])) {
+                                       /* do nothing */
+                               } else {
+                                       td->loc[0] = (float)p[0];
+                                       td->loc[1] = (float)p[1];
+                                       td->loc[2] = (float)p[2];
+                                       
+                               }
+                       }
+               }
+               
+               //VecAddf(td->loc, td->iloc, tvec);
+       }
+       
+       v3d->depths->depths = NULL;
+       //txdepth = NULL;
+       
+}
+
 /* uses t->vec to store actual translation in */
 int Translation(TransInfo *t, short mval[2]) 
 {
@@ -2980,6 +3059,11 @@
        if (t->flag & T_CLIP_UV && clipUVTransform(t, t->vec, 0))
                applyTranslation(t, t->vec);
 
+       /* even more evil APRICOT HACK */
+       if ((t->spacetype==SPACE_VIEW3D) && retopo_object_check() ) {
+               applyTranslationRetopo(t);
+       }
+       
        recalcData(t);
 
        headerprint(str);

Modified: branches/apricot/source/blender/src/transform_conversions.c
===================================================================
--- branches/apricot/source/blender/src/transform_conversions.c 2008-04-21 
03:56:34 UTC (rev 14498)
+++ branches/apricot/source/blender/src/transform_conversions.c 2008-04-21 
09:13:56 UTC (rev 14499)
@@ -3427,6 +3427,9 @@
        short redrawipo=0, resetslowpar=1;
        int cancelled= (t->state == TRANS_CANCEL);
        
+       if (t->txdepth) MEM_freeN(t->txdepth);
+       t->txdepth = NULL;
+               
        if (t->spacetype==SPACE_VIEW3D) {
                if (G.obedit) {
                        if (cancelled==0) {
@@ -3436,66 +3439,10 @@
                                        retopo_do_all();
                                }
                        }
-#if 0
                } else {
-                       /* APRICOT HACK */
-                       float pmat[4][4], vmat[4][4];
-                       short s[2];
-                       View3D *v3d = G.vd;
-                       
-                       /* --- Make external func --- */
-                       
-                       /* ZBuffer depth vars */
-                       bglMats mats;
-                       float depth, depth_close= MAXFLOAT;
-                       int had_depth = 0;
-                       double cent[2],  p[3];
-                       int xs, ys;
-                       
-                       persp(PERSP_VIEW);
-                       
-                       /* Get Z Depths, needed for perspective, nice for ortho 
*/
-                       bgl_get_mats(&mats);
-                       draw_depth(curarea, (void *)G.vd);
-                       
-                       /* force updating */
-                       if (v3d->depths) {
-                               had_depth = 1;
-                               v3d->depths->damaged = 1;
+                       if (cancelled==0) {
+                               retopo_do_all();
                        }
-                       
-                       view3d_update_depths(v3d);
-                       

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to