This adds two modes to the 'around' drop down in 3d header

3d Cursor, only Ob Centers
Median Point, only Ob Centers

They prevent rotation/scaling from effecting the scale/rotation of the objects and just effects their position.
This is handy for aligning objects if you constrain to an axis and scale, as well as other neato things :)

Intrr came up with the code and I hacked it into the GUI
This commit is contained in:
Johnny Matthews 2004-07-15 17:42:04 +00:00
parent 665a2f8fdd
commit 700d9c5559
8 changed files with 1372 additions and 1387 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 42 KiB

@ -123,10 +123,13 @@ typedef struct View3D {
#define V3D_ALIGN 1024
/* View3D->around */
#define V3D_CENTRE 0
#define V3D_CENTROID 3
#define V3D_CURSOR 1
#define V3D_LOCAL 2
#define V3D_CENTRE 0
#define V3D_CENTROID 3
#define V3D_CENTROID_LOC 4
#define V3D_CURSOR 1
#define V3D_CURSOR_LOC 5
#define V3D_LOCAL 2
/* View3d->persp */
#define V3D_PERSP_ORTHO 0

File diff suppressed because it is too large Load Diff

@ -899,7 +899,7 @@ void snap_curs_to_sel()
DO_MINMAX(vec, min, max);
}
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(centroid, 1.0/(float)tottrans);
VECCOPY(curs, centroid);
}
@ -923,7 +923,7 @@ void snap_curs_to_sel()
base= base->next;
}
if(count) {
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(centroid, 1.0/(float)count);
VECCOPY(curs, centroid);
}
@ -970,7 +970,7 @@ void snap_curs_to_firstsel()
VecAddf(centroid, centroid, vec);
DO_MINMAX(vec, min, max);*/
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(vec, 1.0/(float)tottrans);
VECCOPY(curs, vec);
}
@ -994,7 +994,7 @@ void snap_curs_to_firstsel()
base= base->next;
}
if(count) {
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(centroid, 1.0/(float)count);
VECCOPY(curs, centroid);
}
@ -1046,7 +1046,7 @@ void snap_to_center()
DO_MINMAX(vec, min, max);
}
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(centroid, 1.0/(float)tottrans);
VECCOPY(snaploc, centroid);
}
@ -1072,7 +1072,7 @@ void snap_to_center()
base= base->next;
}
if(count) {
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecMulf(centroid, 1.0/(float)count);
VECCOPY(snaploc, centroid);
}

@ -125,6 +125,7 @@ static void uv_calc_center_vector(float *result, Object *ob, Mesh *me)
}
VecMidf(result, min, max);
break;
case V3D_CURSOR_LOC:
case V3D_CURSOR: /*cursor center*/
cursx= give_cursor();
/* shift to objects world */
@ -133,6 +134,7 @@ static void uv_calc_center_vector(float *result, Object *ob, Mesh *me)
result[2]= cursx[2]-ob->obmat[3][2];
break;
case V3D_LOCAL: /*object center*/
case V3D_CENTROID_LOC:
case V3D_CENTROID: /* multiple objects centers, only one object here*/
default:
result[0]= result[1]= result[2]= 0.0;

@ -4576,10 +4576,10 @@ void transform(int mode)
}
}
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VECCOPY(centre, centroid);
}
else if(G.vd->around==V3D_CURSOR) {
else if(G.vd->around==V3D_CURSOR || G.vd->around==V3D_CURSOR_LOC) {
curs= give_cursor();
VECCOPY(centre, curs);
@ -4969,7 +4969,7 @@ void transform(int mode)
* 3. multiply with its own rotation, calculate euler.
*/
if ((G.vd->flag & V3D_ALIGN)==0) {
if (/*(G.vd->flag & V3D_ALIGN)==0*/ G.vd->around != V3D_CURSOR_LOC && G.vd->around != V3D_CENTROID_LOC){
/* Roll around local axis */
if (mode=='r' || mode=='R'){
@ -5194,7 +5194,7 @@ void transform(int mode)
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
if(tottrans>1 || G.vd->around==V3D_CURSOR) helpline(centre);
if(tottrans>1 || G.vd->around==V3D_CURSOR || G.vd->around==V3D_CURSOR_LOC) helpline(centre);
else if (G.obpose) helpline (centre);
}
}
@ -5268,8 +5268,8 @@ void transform(int mode)
/* size local with respect to parent AND own rotation */
/* local wrt parent: */
if ((G.vd->flag & V3D_ALIGN)==0) {
if ( /*(G.vd->flag & V3D_ALIGN)==0 */ G.vd->around != V3D_CURSOR_LOC && G.vd->around != V3D_CENTROID_LOC) {
Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
/* local wrt own rotation: */
@ -5442,7 +5442,7 @@ void transform(int mode)
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
if(tottrans>1 || G.vd->around==V3D_CURSOR) helpline(centre);
if(tottrans>1 || G.vd->around==V3D_CURSOR || G.vd->around==V3D_CURSOR_LOC) helpline(centre);
}
}
else if(mode=='w') {
@ -7332,10 +7332,10 @@ void mirror_edit(short mode) {
tv = transvmain;
// Taking care of all the centre modes
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecCopyf(centre, centroid);
}
else if(G.vd->around==V3D_CURSOR) {
else if(G.vd->around==V3D_CURSOR || G.vd->around==V3D_CURSOR_LOC) {
float *curs;
curs= give_cursor();
VECCOPY(centre, curs);
@ -7459,10 +7459,10 @@ void mirror_object(short mode) {
tob = transmain;
// Taking care of all the centre modes
if(G.vd->around==V3D_CENTROID) {
if(G.vd->around==V3D_CENTROID || G.vd->around==V3D_CENTROID_LOC) {
VecCopyf(centre, centroid);
}
else if(G.vd->around==V3D_CURSOR) {
else if(G.vd->around==V3D_CURSOR || G.vd->around==V3D_CURSOR_LOC) {
float *curs;
curs= give_cursor();
VECCOPY(centre, curs);

@ -3362,6 +3362,9 @@ static char *around_pup(void)
strcat(string, "|Median Point %x3");
strcat(string, "|3D Cursor %x1");
strcat(string, "|Individual Object Centers %x2");
strcat(string, "|%l");
strcat(string, "|Median Point, only Ob Centers %x4");
strcat(string, "|3D Cursor, only Ob Centers %x5");
return (string);
}

@ -1474,6 +1474,8 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case COMMAKEY:
if(G.qual==LR_CTRLKEY) {
G.vd->around= V3D_CENTROID;
} else if(G.qual==LR_SHIFTKEY) {
G.vd->around= V3D_CENTROID;
} else if(G.qual==0) {
G.vd->around= V3D_CENTRE;
}
@ -1483,7 +1485,9 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case PERIODKEY:
if(G.qual==LR_CTRLKEY) {
G.vd->around= V3D_LOCAL;
} else if(G.qual==0) {
} else if(G.qual==LR_SHIFTKEY) {
G.vd->around= V3D_CURSOR_LOC;
} else if(G.qual==0) {
G.vd->around= V3D_CURSOR;
}
scrarea_queue_headredraw(curarea);