NEW! Blender now displays flipped (negative scaled) Objects correctly in
authorTon Roosendaal <ton@blender.org>
Sat, 29 May 2004 16:17:46 +0000 (16:17 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 29 May 2004 16:17:46 +0000 (16:17 +0000)
OpenGL draw.

(BTW: the previous commit also solves raytrace errors with negative scaled
objects...)

Further a cleanup of displaylist flags and object/base flags. The #define
ACTIVE is moved to filesel.c (only used here).
The GONNA_MOVE #define got a OB_ added in front.

source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/object.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/src/drawobject.c
source/blender/src/editobject.c
source/blender/src/filesel.c

index 7b487bfca1e190d76308635cd1afe1664c93fb86..18b421f17807fece8f00795ddb9f8618926f59a3 100644 (file)
@@ -35,6 +35,7 @@
 #ifndef BKE_DISPLIST_H
 #define BKE_DISPLIST_H
 
+/* dl->type */
 #define DL_POLY                 0
 #define DL_SEGM                 1
 #define DL_SURF                 2
@@ -46,7 +47,9 @@
 #define DL_NORS                 8
 #define DL_MESH                                        9
 
-/* EVIL: #define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev) */
+/* dl->flag */
+#define DL_CYCL_U              1
+#define DL_CYCL_V              2
 
 /* prototypes */
 
index 3a7a73508f703bca03597932d46bee441963e6e6..841676947412dfef71bc72230dc28644851f8613 100644 (file)
@@ -790,7 +790,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
                                
                                for(a=0; a<dl->parts; a++) {
        
-                                       DL_SURFINDEX(dl->flag & 1, dl->flag & 2, dl->nr, dl->parts);
+                                       DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
        
                                        v1= vdata+ 3*p1; 
                                        n1= ndata+ 3*p1;
@@ -850,6 +850,7 @@ void shadeDispList(Object *ob)
        
        Mat4Invert(tmat, mat);
        Mat3CpyMat4(imat, tmat);
+       if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
        
        /* we extract dl_verts, deform info */
        dldeform= find_displist(&ob->disp, DL_VERTS);
@@ -1543,7 +1544,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
        dl= dispbase->first;
        while(dl) {
                if(dl->type==DL_SURF) {
-                       if(dl->flag==2) {
+                       if(dl->flag == DL_CYCL_V) {
                                if(cu->flag & CU_BACK) {
                                        dlnew= MEM_callocN(sizeof(DispList), "filldisp");
                                        BLI_addtail(&front, dlnew);
@@ -1644,7 +1645,7 @@ void makeDispList(Object *ob)
        if(ob==0) return;
        if(ob->flag & OB_FROMDUPLI) return;
        freedisplist(&(ob->disp));
-
+       
        if(ob->type==OB_MESH) {
                me= ob->data;
 
@@ -1736,14 +1737,14 @@ void makeDispList(Object *ob)
                                                if(draw==0) {
                                                        dl->parts= nu->pntsv;
                                                        dl->nr= nu->pntsu;
-                                                       if(nu->flagu & 1) dl->flag|= 1;
-                                                       if(nu->flagv & 1) dl->flag|= 2;
+                                                       if(nu->flagu & 1) dl->flag|= DL_CYCL_U;
+                                                       if(nu->flagv & 1) dl->flag|= DL_CYCL_V;
                                                }
                                                else {
                                                        dl->parts= nu->resolu;  /* in reverse, because makeNurbfaces works that way */
                                                        dl->nr= nu->resolv;
-                                                       if(nu->flagv & 1) dl->flag|= 1; /* reverse too! */
-                                                       if(nu->flagu & 1) dl->flag|= 2;
+                                                       if(nu->flagv & 1) dl->flag|= DL_CYCL_U; /* reverse too! */
+                                                       if(nu->flagu & 1) dl->flag|= DL_CYCL_V;
                                                }
                                                dl->col= nu->mat_nr;
        
@@ -1837,8 +1838,8 @@ void makeDispList(Object *ob)
 
                                                dl->type= DL_SURF;
                                                dl->flag= 0;
-                                               if(dlb->type==DL_POLY) dl->flag++;
-                                               if(bl->poly>=0) dl->flag+=2;
+                                               if(dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
+                                               if(bl->poly>=0) dl->flag |= DL_CYCL_V;
 
                                                dl->parts= bl->nr;
                                                dl->nr= dlb->nr;
@@ -1897,6 +1898,7 @@ void makeDispList(Object *ob)
                tex_space_curve(cu);
 
        }
+       
 }
 
 
index 55e939e0d6d3ac3a785c20e11dac8d5fc1baddbf..9e6691f55256593665527cff2e4d6e07a21baeda 100644 (file)
@@ -1178,7 +1178,7 @@ void where_is_object_time(Object *ob, float ctime)
 {
        Object *par;
        float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY;
-       float stime, fac1, fac2;
+       float stime, fac1, fac2, vec[3];
        int a;
        int pop; 
        
@@ -1258,6 +1258,11 @@ void where_is_object_time(Object *ob, float ctime)
        if(ob->scriptlink.totscript && !during_script()) {
                BPY_do_pyscript((ID *)ob, SCRIPT_REDRAW);
        }
+       
+       /* set negative scale flag in object */
+       Crossf(vec, ob->obmat[0], ob->obmat[1]);
+       if( Inpf(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE;
+       else ob->transflag &= ~OB_NEG_SCALE;
 }
 
 static void solve_parenting (Object *ob, Object *par, float slowmat[][4], int simul)
index 4553696435183acac523b5c2791a3506057144ea..a32985294727a5835e220ee1c2c250d6b5a39372 100644 (file)
@@ -193,14 +193,8 @@ extern Object workob;
 
 /* **************** OBJECT ********************* */
 
-/* used many places... should be specialized */
+/* used many places... should be specialized  */
 #define SELECT                 1
-#define ACTIVE                 2
-#define GONNA_MOVE     32 /* temporary, for figuring what stuff needs
-                                                  * updating during transform due to parenting
-                                                  * or constraints... do not rely on this value
-                                                  * unless you are me (CW).
-                                                  */
 
 /* type */
 #define OB_EMPTY               0
@@ -235,6 +229,7 @@ extern Object workob;
 /* char! transflag */
 #define OB_OFFS_LOCAL  1
 #define OB_QUAT                        2
+#define OB_NEG_SCALE   4
 #define OB_DUPLI               (8+16)
 #define OB_DUPLIFRAMES 8
 #define OB_DUPLIVERTS  16
@@ -291,12 +286,14 @@ extern Object workob;
 #define OB_BOUND_POLYH         4
 
 /* also needed for base!!!!! or rather, thy interfere....*/
-/* base->flag en ob->flag */
+/* base->flag and ob->flag */
 #define BA_WASSEL                      2
 #define BA_PARSEL                      4
 #define BA_WHERE_UPDATE                8
 #define BA_DISP_UPDATE         16
 #define BA_DO_IPO                      32
+#define OB_GONNA_MOVE          32
+
 #define BA_FROMSET                     128
 #define OB_DO_IMAT                     256
 #define OB_FROMDUPLI           512
index f1f374fe182c6d766482970c21d1691e40689f32..4cd398796988757b1b5ea491231c1abe42d3d4c5 100644 (file)
@@ -360,18 +360,7 @@ typedef struct Scene {
 #define RAD_PHASE_PATCHES      1
 #define RAD_PHASE_FACES                2
 
-/* base->flag and ob->flag */
-#define BA_WASSEL                      2
-#define BA_PARSEL                      4
-#define BA_WHERE_UPDATE                8
-#define BA_DISP_UPDATE         16
-#define BA_DO_IPO                      32
-#define BA_FROMSET                     128
-#define OB_DO_IMAT                     256
-#define OB_FROMDUPLI           512
-#define OB_DONE                                1024
-#define OB_RADIO                       2048
-#define OB_FROMGROUP           4096
+/* base->flag is in DNA_object_types.h */
 
 /* sce->flag */
 #define SCE_ADDSCENAME         1
index 60233a3cef3bb7ee1a730d68d730f34670dfe922..48c02654fe1534468327b2ecd291541db95d6c89 100644 (file)
@@ -1297,7 +1297,7 @@ static void drawDispListwire(ListBase *dlbase)
                        parts= dl->parts;
                        while(parts--) {
                                nr= dl->nr;
-                               if(dl->flag & 1) glBegin(GL_LINE_LOOP);
+                               if(dl->flag & DL_CYCL_U) glBegin(GL_LINE_LOOP);
                                else glBegin(GL_LINE_STRIP);
 
                                while(nr--) {
@@ -1311,7 +1311,7 @@ static void drawDispListwire(ListBase *dlbase)
                        while(nr--) {
                                data= (  dl->verts )+3*nr;
                                parts= dl->parts;
-                               if(dl->flag & 2) glBegin(GL_LINE_LOOP);
+                               if(dl->flag & DL_CYCL_V) glBegin(GL_LINE_LOOP);
                                else glBegin(GL_LINE_STRIP);
                                
                                while(parts--) {
@@ -1374,9 +1374,14 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
        int drawsmooth= !(G.f & G_BACKBUFSEL);
        
        if(lb==0) return;
+       
+       /* drawsmooth abused here, except for Mesh this draws with smooth default */
        if (drawsmooth) {
                glShadeModel(GL_SMOOTH);
                glEnable(GL_LIGHTING);
+               
+               if(ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
+               else glFrontFace(GL_CCW);
        }
        
        dl= lb->first;
@@ -1389,7 +1394,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
                        if(!drawsmooth) {
                                for(a=0; a<dl->parts; a++) {
        
-                                       DL_SURFINDEX(dl->flag & 1, dl->flag & 2, dl->nr, dl->parts);
+                                       DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
        
                                        v1= data+ 3*p1; 
                                        v2= data+ 3*p2;
@@ -1420,7 +1425,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
 
                                for(a=0; a<dl->parts; a++) {
                                        
-                                       DL_SURFINDEX(dl->flag & 1, dl->flag & 2, dl->nr, dl->parts);
+                                       DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
                                        
                                        v1= data+ 3*p1; 
                                        v2= data+ 3*p2;
@@ -1560,6 +1565,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob)
        if(drawsmooth) {
                glShadeModel(GL_FLAT);
                glDisable(GL_LIGHTING);
+               glFrontFace(GL_CCW);
        }
 }
 
@@ -1588,7 +1594,7 @@ static void drawDispListshaded(ListBase *lb, Object *ob)
 
                        for(a=0; a<dl->parts; a++) {
 
-                               DL_SURFINDEX(dl->flag & 1, dl->flag & 2, dl->nr, dl->parts);
+                               DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
 
                                v1= data+ 3*p1; 
                                v2= data+ 3*p2;
@@ -1714,7 +1720,11 @@ static void drawmeshsolid(Object *ob, float *nors)
        if( (G.f & G_BACKBUFSEL)==0 ) {
                glEnable(GL_LIGHTING);
                init_gl_materials(ob);
+
                two_sided( me->flag & ME_TWOSIDED );
+
+               if(ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
+               else glFrontFace(GL_CCW);
        }
 
        mface= me->mface;
@@ -1917,7 +1927,7 @@ static void drawmeshsolid(Object *ob, float *nors)
                glDisable(GL_CULL_FACE);
        }
        glDisable(GL_LIGHTING);
-
+       glFrontFace(GL_CCW);
 }
 
 static void drawmeshshaded(Object *ob, unsigned int *col1, unsigned int *col2)
index eec31290391ec6f03f2dea5a30e7ee0b5a4b23d9..e28c43cb94830e4484311225daaac3739d174bdc 100644 (file)
@@ -2913,13 +2913,13 @@ void clear_gonna_move(void) {
 
        /* clear the gonna move flag */
        for (base= FIRSTBASE; base; base= base->next) {
-               base->object->flag &= ~GONNA_MOVE;
+               base->object->flag &= ~OB_GONNA_MOVE;
        }
 }
 
 int is_parent_gonna_move(Object *ob) {
        if ( (ob->parent) &&
-                (ob->parent->flag & GONNA_MOVE) ) {
+                (ob->parent->flag & OB_GONNA_MOVE) ) {
                return 1;
        }
        return 0;
@@ -2932,7 +2932,7 @@ int is_constraint_target_gonna_move(Object *ob) {
 
        for (con = ob->constraints.first; con; con=con->next) {
                if ( (tarOb = get_con_target(con)) ) {
-                       if (tarOb->flag & GONNA_MOVE )
+                       if (tarOb->flag & OB_GONNA_MOVE )
                                return 1;
                }
        }
@@ -2941,7 +2941,7 @@ int is_constraint_target_gonna_move(Object *ob) {
                for (chan = ob->pose->chanbase.first; chan; chan=chan->next){
                        for (con = chan->constraints.first; con; con=con->next) {
                                if ( (tarOb = get_con_target(con)) ) {
-                                       if (tarOb->flag & GONNA_MOVE )
+                                       if (tarOb->flag & OB_GONNA_MOVE )
                                                return 1;
                                }
                        }
@@ -2963,19 +2963,19 @@ void flag_moving_objects(void) {
                oldnumgonnamove = numgonnamove;
                numgonnamove = 0;
                for (base= FIRSTBASE; base; base= base->next) {
-                       if (base->object->flag & GONNA_MOVE) {
+                       if (base->object->flag & OB_GONNA_MOVE) {
                                ++numgonnamove;
                        }
                        else if (base->flag & SELECT) {
-                               base->object->flag |= GONNA_MOVE;
+                               base->object->flag |= OB_GONNA_MOVE;
                                ++numgonnamove;
                        }
                        else if (is_parent_gonna_move(base->object)) {
-                               base->object->flag |= GONNA_MOVE;
+                               base->object->flag |= OB_GONNA_MOVE;
                                ++numgonnamove;
                        }
                        else if (is_constraint_target_gonna_move(base->object)) {
-                               base->object->flag |= GONNA_MOVE;
+                               base->object->flag |= OB_GONNA_MOVE;
                                ++numgonnamove;
                        }
                }
@@ -3007,8 +3007,8 @@ static int pose_do_update_flag(Object *ob) {
                                for (base= FIRSTBASE; base; base= base->next) {
                                        if (is_ob_constraint_target(base->object, 
                                                                                                &chan->constraints)) {
-                                               if( (base->object->flag & GONNA_MOVE) || 
-                                                       (ob->flag & GONNA_MOVE)) {
+                                               if( (base->object->flag & OB_GONNA_MOVE) || 
+                                                       (ob->flag & OB_GONNA_MOVE)) {
                                                        Bone *bone;
                                                        /* If this armature is selected, or if the
                                                         * object that is the target of a constraint
index ae7a8e66d9c95a86839a3a4d65debd5c21ad7937..9597af86250a38f9e595fe800886598cb7a2efc7 100644 (file)
 #define FILESELHEAD            60
 #define FILESEL_DY             16
 
+/* for events */
 #define NOTACTIVE                      0
 #define ACTIVATE                       1
 #define INACTIVATE                     2
+/* for state of file */
+#define ACTIVE                         2
 
 #define STARTSWITH(x, y) (strncmp(x, y, sizeof(x) - 1) == 0)