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

@ -125,9 +125,12 @@ typedef struct View3D {
/* View3D->around */ /* View3D->around */
#define V3D_CENTRE 0 #define V3D_CENTRE 0
#define V3D_CENTROID 3 #define V3D_CENTROID 3
#define V3D_CENTROID_LOC 4
#define V3D_CURSOR 1 #define V3D_CURSOR 1
#define V3D_CURSOR_LOC 5
#define V3D_LOCAL 2 #define V3D_LOCAL 2
/* View3d->persp */ /* View3d->persp */
#define V3D_PERSP_ORTHO 0 #define V3D_PERSP_ORTHO 0
#define V3D_PERSP_DO_3D_PERSP 1 #define V3D_PERSP_DO_3D_PERSP 1

File diff suppressed because it is too large Load Diff

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

@ -125,6 +125,7 @@ static void uv_calc_center_vector(float *result, Object *ob, Mesh *me)
} }
VecMidf(result, min, max); VecMidf(result, min, max);
break; break;
case V3D_CURSOR_LOC:
case V3D_CURSOR: /*cursor center*/ case V3D_CURSOR: /*cursor center*/
cursx= give_cursor(); cursx= give_cursor();
/* shift to objects world */ /* 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]; result[2]= cursx[2]-ob->obmat[3][2];
break; break;
case V3D_LOCAL: /*object center*/ case V3D_LOCAL: /*object center*/
case V3D_CENTROID_LOC:
case V3D_CENTROID: /* multiple objects centers, only one object here*/ case V3D_CENTROID: /* multiple objects centers, only one object here*/
default: default:
result[0]= result[1]= result[2]= 0.0; 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); 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(); curs= give_cursor();
VECCOPY(centre, curs); VECCOPY(centre, curs);
@ -4969,7 +4969,7 @@ void transform(int mode)
* 3. multiply with its own rotation, calculate euler. * 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 */ /* Roll around local axis */
if (mode=='r' || mode=='R'){ if (mode=='r' || mode=='R'){
@ -5194,7 +5194,7 @@ void transform(int mode)
scrarea_do_windraw(curarea); scrarea_do_windraw(curarea);
screen_swapbuffers(); 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); else if (G.obpose) helpline (centre);
} }
} }
@ -5268,7 +5268,7 @@ void transform(int mode)
/* size local with respect to parent AND own rotation */ /* size local with respect to parent AND own rotation */
/* local wrt parent: */ /* 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); Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
@ -5442,7 +5442,7 @@ void transform(int mode)
scrarea_do_windraw(curarea); scrarea_do_windraw(curarea);
screen_swapbuffers(); 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') { else if(mode=='w') {
@ -7332,10 +7332,10 @@ void mirror_edit(short mode) {
tv = transvmain; tv = transvmain;
// Taking care of all the centre modes // 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); 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; float *curs;
curs= give_cursor(); curs= give_cursor();
VECCOPY(centre, curs); VECCOPY(centre, curs);
@ -7459,10 +7459,10 @@ void mirror_object(short mode) {
tob = transmain; tob = transmain;
// Taking care of all the centre modes // 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); 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; float *curs;
curs= give_cursor(); curs= give_cursor();
VECCOPY(centre, curs); VECCOPY(centre, curs);

@ -3362,6 +3362,9 @@ static char *around_pup(void)
strcat(string, "|Median Point %x3"); strcat(string, "|Median Point %x3");
strcat(string, "|3D Cursor %x1"); strcat(string, "|3D Cursor %x1");
strcat(string, "|Individual Object Centers %x2"); 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); return (string);
} }

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