Made "Centre" in mesh editmode listen to the "Around" setting, so it can

now use centroid as well (instead of only bounbox-centre)
It doesn't do "cursor" though... it's centering for object center, right?
This commit is contained in:
Ton Roosendaal 2005-04-28 18:46:35 +00:00
parent 7e85b26750
commit 6fd281c14d

@ -1604,29 +1604,39 @@ void docentre(int centremode)
Nurb *nu, *nu1; Nurb *nu, *nu1;
EditVert *eve; EditVert *eve;
float cent[3], centn[3], min[3], max[3], omat[3][3]; float cent[3], centn[3], min[3], max[3], omat[3][3];
int a; int a, total= 0;
MVert *mvert; MVert *mvert;
if(G.scene->id.lib) return; if(G.scene->id.lib) return;
cent[0]= cent[1]= cent[2]= 0.0;
if(G.obedit) { if(G.obedit) {
INIT_MINMAX(min, max); INIT_MINMAX(min, max);
if(G.obedit->type==OB_MESH) { if(G.obedit->type==OB_MESH) {
eve= em->verts.first; for(eve= em->verts.first; eve; eve= eve->next) {
while(eve) { if(G.vd->around==V3D_CENTROID) {
DO_MINMAX(eve->co, min, max); total++;
eve= eve->next; VECADD(cent, cent, eve->co);
} }
else {
DO_MINMAX(eve->co, min, max);
}
}
if(G.vd->around==V3D_CENTROID) {
VecMulf(cent, 1.0f/(float)total);
}
else {
cent[0]= (min[0]+max[0])/2.0f; cent[0]= (min[0]+max[0])/2.0f;
cent[1]= (min[1]+max[1])/2.0f; cent[1]= (min[1]+max[1])/2.0f;
cent[2]= (min[2]+max[2])/2.0f; cent[2]= (min[2]+max[2])/2.0f;
}
eve= em->verts.first; for(eve= em->verts.first; eve; eve= eve->next) {
while(eve) {
VecSubf(eve->co, eve->co, cent); VecSubf(eve->co, eve->co, cent);
eve= eve->next;
} }
} }
} }