Orange: Display types and variable size for Empties.
authorMatt Ebb <matt@mke3.net>
Fri, 13 Jan 2006 15:50:32 +0000 (15:50 +0000)
committerMatt Ebb <matt@mke3.net>
Fri, 13 Jan 2006 15:50:32 +0000 (15:50 +0000)
This is using instructions from Ton, so hopefully the implementation is ok.
This is really needed here where we are using all sorts of wacky scales, and
empties look too big or too small. Of course we don't want to scale the
empties because there are often things parented to them.

New options are in edit buttons for empties to control the display style
and the size. New styles are easy to add, too. Just needs useful ideas and
minor effort from anyone who wants to.

Support for copying these values has also been added to the Copy Attributes
->Drawtype menu command.

source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/include/BDR_drawobject.h
source/blender/makesdna/DNA_object_types.h
source/blender/src/buttons_editing.c
source/blender/src/drawarmature.c
source/blender/src/drawobject.c
source/blender/src/editobject.c

index 2990da483d4c6721388f7390924975d520370932..d60236d226cb9cbae93a796ba0d2ad4b1de2a42d 100644 (file)
@@ -759,6 +759,8 @@ Object *add_object(int type)
        Mat4One(ob->obmat);
        ob->dt= OB_SHADED;
        if(U.flag & USER_MAT_ON_OB) ob->colbits= -1;
+       ob->empty_drawtype= OB_ARROWS;
+       ob->empty_drawsize= 1.0;
        
        if(type==OB_CAMERA || type==OB_LAMP) {
                ob->trackflag= OB_NEGZ;
index ec6289c38b70e1ce63873b87cf8b2e2ee2fef4ee..13011f17516865e878189eead4cc8db8d7d3a75c 100644 (file)
@@ -5244,6 +5244,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
        
+       if(main->versionfile <= 241) {
+               Object *ob;
+               
+               /* for empty drawsize and drawtype */
+               for(ob=main->object.first; ob; ob= ob->id.next) {
+                       ob->empty_drawtype = OB_ARROWS;
+                       ob->empty_drawsize = 1.0;
+               }
+       }
+       
        
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
index 40bf3fe2395d37f247e377fd72eb85a8dcf1653c..99aa76b2462fa59fc2d4952d9d509a404e272a81 100644 (file)
@@ -63,7 +63,7 @@ void get_local_bounds(struct Object *ob, float *centre, float *size);
 #define DRAW_PICKING   1
 #define DRAW_CONSTCOLOR        2
 void draw_object(struct Base *base, int flag);
-void drawaxes(float size, int flag);
+void drawaxes(float size, int flag, char drawtype);
 
 void draw_object_ext(struct Base *base);
 void drawsolidcube(float size);
index 50243c268877b4e05f90ae8e002459c771d4c3e8..0f1cdb8368fa03838f6cd2bda2a275a69ac238e9 100644 (file)
@@ -148,6 +148,8 @@ typedef struct Object {
        char dt, dtx;
        char totcol;    /* copy of mesh or curve or meta */
        char actcol;
+       char empty_drawtype, pad1[3];
+       float empty_drawsize;
        
        ScriptLink scriptlink;
        ListBase prop;
@@ -311,6 +313,11 @@ extern Object workob;
        /* enable transparent draw */
 #define OB_DRAWTRANSP  128
 
+/* empty_drawtype: no flags */
+#define OB_ARROWS              1
+#define OB_PLAINAXES   2
+#define OB_CIRCLE              3
+
 /* boundtype */
 #define OB_BOUND_BOX           0
 #define OB_BOUND_SPHERE                1
index 12662f3a6f0eca2bd0247e8faf83e79d0981e88c..601c92ba946861cd1000e14f401c13a3cf71e53b 100644 (file)
@@ -3434,9 +3434,21 @@ static void editing_panel_links(Object *ob)
 
 
        /* to be sure */
-       if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL);
+       if ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_EMPTY);
        else return;
 
+       if (ob->type==OB_EMPTY) {
+               uiDefBut(block, LABEL,0,"Empty Display:",
+                               xco, 154, 130,20, 0, 0, 0, 0, 0, "");
+               
+               uiBlockBeginAlign(block);
+               uiDefButC(block, MENU, REDRAWVIEW3D, "Empty Drawtype%t|Arrows%x1|Plain Axes%x2",
+                               xco, 128, 140, 20, &ob->empty_drawtype, 0, 0, 0, 0, "Selects the Empty display type");
+               uiDefButF(block, NUM, REDRAWVIEW3D, "Size:",
+                               xco, 108, 140, 21, &ob->empty_drawsize, 0.01, 10.0, 1, 0, "The size to display the Empty");
+               uiBlockEndAlign(block);
+               return;
+       }
 
        if(ob->type==OB_MESH) poin= &( ((Mesh *)ob->data)->texflag );
        else if(ob->type==OB_MBALL) poin= &( ((MetaBall *)ob->data)->texflag );
index c284b31bd3037e34ce1e6268ed6fef4b3a1fe862..083125442afc01fdcb11bf555c1e6958d375fdc9 100644 (file)
@@ -1529,7 +1529,7 @@ static void draw_pose_channels(Base *base, int dt)
                                                        glPushMatrix();
                                                        glMultMatrixf(pchan->pose_mat);
                                                        glTranslatef(0.0f, pchan->bone->length, 0.0f);
-                                                       drawaxes(0.25f*pchan->bone->length, 0);
+                                                       drawaxes(0.25f*pchan->bone->length, 0, OB_ARROWS);
                                                        glPopMatrix();
                                                }
                                        }
@@ -1713,7 +1713,7 @@ static void draw_ebones(Object *ob, int dt)
                                                        glPushMatrix();
                                                        set_matrix_editbone(eBone);
                                                        glTranslatef(0.0f, eBone->length, 0.0f);
-                                                       drawaxes(eBone->length*0.25f, 0);
+                                                       drawaxes(eBone->length*0.25f, 0, OB_ARROWS);
                                                        glPopMatrix();
                                                }
                                                
index 44c00f44f8e294e1d0185c69af8a05c4796db0e0..8c150afac1eaf095985f632f99d91ea2ce50602d 100644 (file)
@@ -239,44 +239,67 @@ static float cube[8][3] = {
 };
 
 /* flag is same as for draw_object */
-void drawaxes(float size, int flag)
+void drawaxes(float size, int flag, char drawtype)
 {
+       View3D *v3d= G.vd;
        int axis;
+       float vec[3]= {0.0, 0.0, 0.0};
+       
+       switch(drawtype) {
+       
+       case OB_PLAINAXES:
+               for (axis=0; axis<3; axis++) {
+                       float v1[3]= {0.0, 0.0, 0.0};
+                       float v2[3]= {0.0, 0.0, 0.0};
+                       
+                       glBegin(GL_LINES);
 
-       for (axis=0; axis<3; axis++) {
-               float v1[3]= {0.0, 0.0, 0.0};
-               float v2[3]= {0.0, 0.0, 0.0};
-               int arrow_axis= (axis==0)?1:0;
-               
-               glBegin(GL_LINES);
-
-               v2[axis]= size;
-               glVertex3fv(v1);
-               glVertex3fv(v2);
+                       v1[axis]= size;
+                       v2[axis]= -size;
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
                        
-               v1[axis]= size*0.8;
-               v1[arrow_axis]= -size*0.125;
-               glVertex3fv(v1);
-               glVertex3fv(v2);
+                       glEnd();
+               }
+               break;
+       case OB_ARROWS:
+       default:
+               for (axis=0; axis<3; axis++) {
+                       float v1[3]= {0.0, 0.0, 0.0};
+                       float v2[3]= {0.0, 0.0, 0.0};
+                       int arrow_axis= (axis==0)?1:0;
                        
-               v1[arrow_axis]= size*0.125;
-               glVertex3fv(v1);
-               glVertex3fv(v2);
+                       glBegin(GL_LINES);
 
-               glEnd();
+                       v2[axis]= size;
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                               
+                       v1[axis]= size*0.8;
+                       v1[arrow_axis]= -size*0.125;
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+                               
+                       v1[arrow_axis]= size*0.125;
+                       glVertex3fv(v1);
+                       glVertex3fv(v2);
+
+                       glEnd();
+                               
+                       v2[axis]+= size*0.125;
+                       glRasterPos3fv(v2);
                        
-               v2[axis]+= size*0.125;
-               glRasterPos3fv(v2);
-               
-               // patch for 3d cards crashing on glSelect for text drawing (IBM)
-               if((flag & DRAW_PICKING) == 0) {
-                       if (axis==0)
-                               BMF_DrawString(G.font, "x");
-                       else if (axis==1)
-                               BMF_DrawString(G.font, "y");
-                       else
-                               BMF_DrawString(G.font, "z");
+                       // patch for 3d cards crashing on glSelect for text drawing (IBM)
+                       if((flag & DRAW_PICKING) == 0) {
+                               if (axis==0)
+                                       BMF_DrawString(G.font, "x");
+                               else if (axis==1)
+                                       BMF_DrawString(G.font, "y");
+                               else
+                                       BMF_DrawString(G.font, "z");
+                       }
                }
+               break;
        }
 }
 
@@ -3823,7 +3846,7 @@ void draw_object(Base *base, int flag)
                        empty_object= drawmball(base, dt);
                break;
        case OB_EMPTY:
-               drawaxes(1.0, flag);
+               drawaxes(ob->empty_drawsize, flag, ob->empty_drawtype);
                break;
        case OB_LAMP:
                drawlamp(ob);
@@ -3840,7 +3863,7 @@ void draw_object(Base *base, int flag)
                empty_object= draw_armature(base, dt);
                break;
        default:
-               drawaxes(1.0, flag);
+               drawaxes(1.0, flag, OB_ARROWS);
        }
        if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
 
@@ -3849,7 +3872,7 @@ void draw_object(Base *base, int flag)
        if(dtx) {
                if(G.f & G_SIMULATION);
                else if(dtx & OB_AXIS) {
-                       drawaxes(1.0f, flag);
+                       drawaxes(1.0f, flag, OB_ARROWS);
                }
                if(dtx & OB_BOUNDBOX) draw_bounding_volume(ob);
                if(dtx & OB_TEXSPACE) drawtexspace(ob);
index 243ae777923076e74bc3d37623dfb5c0fa05bc75..f4e66029d06a57a187003be6bfd2cca19d5ea71e 100644 (file)
@@ -2751,6 +2751,8 @@ void copy_attr(short event)
                                else if(event==4) {  /* drawtype */
                                        base->object->dt= ob->dt;
                                        base->object->dtx= ob->dtx;
+                                       base->object->empty_drawtype= ob->empty_drawtype;
+                                       base->object->empty_drawsize= ob->empty_drawsize;
                                }
                                else if(event==5) {  /* time offs */
                                        base->object->sf= ob->sf;