update to center view.
- Dont do anything if no verts or faces are selected (used to zoom into 0,0,0) - use the centers of dupli objects (should eventually use their bound boxes), much nicer when dealing with many dupli-objects
This commit is contained in:
@@ -102,6 +102,7 @@ void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]);
|
||||
struct BoundBox *object_get_boundbox(struct Object *ob);
|
||||
void object_boundbox_flag(struct Object *ob, int flag, int set);
|
||||
void minmax_object(struct Object *ob, float *min, float *max);
|
||||
void minmax_object_duplis(struct Object *ob, float *min, float *max);
|
||||
void solve_tracking (struct Object *ob, float targetmat[][4]);
|
||||
void solve_constraints (struct Object *ob, short obtype, void *obdata, float ctime);
|
||||
|
||||
|
||||
@@ -1980,6 +1980,28 @@ void minmax_object(Object *ob, float *min, float *max)
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO - use dupli objects bounding boxes */
|
||||
void minmax_object_duplis(Object *ob, float *min, float *max)
|
||||
{
|
||||
if ((ob->transflag & OB_DUPLI)==0) {
|
||||
return;
|
||||
} else {
|
||||
ListBase *lb;
|
||||
DupliObject *dob;
|
||||
|
||||
lb= object_duplilist(G.scene, ob);
|
||||
for(dob= lb->first; dob; dob= dob->next) {
|
||||
if(dob->no_draw);
|
||||
else {
|
||||
/* should really use bound box of dup object */
|
||||
DO_MINMAX(dob->mat[3], min, max);
|
||||
}
|
||||
}
|
||||
free_object_duplilist(lb); /* does restore */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
|
||||
/* local_object->proxy == pointer to library object, saved in files and read */
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void deselectall_tface(void);
|
||||
void selectswap_tface(void);
|
||||
void rotate_uv_tface(void);
|
||||
void mirror_uv_tface(void);
|
||||
void minmax_tface(float *min, float *max);
|
||||
int minmax_tface(float *min, float *max);
|
||||
void face_select(void);
|
||||
void face_borderselect(void);
|
||||
void uv_autocalc_tface(void);
|
||||
|
||||
@@ -43,7 +43,7 @@ void mergemenu(void);
|
||||
void delete_context_selected(void);
|
||||
void duplicate_context_selected(void);
|
||||
void toggle_shading(void);
|
||||
void minmax_verts(float *min, float *max);
|
||||
int minmax_verts(float *min, float *max);
|
||||
|
||||
void snap_sel_to_grid(void);
|
||||
void snap_sel_to_curs(void);
|
||||
|
||||
@@ -1836,7 +1836,7 @@ void toggle_shading(void)
|
||||
}
|
||||
}
|
||||
|
||||
void minmax_verts(float *min, float *max)
|
||||
int minmax_verts(float *min, float *max)
|
||||
{
|
||||
TransVert *tv;
|
||||
float centroid[3], vec[3], bmat[3][3];
|
||||
@@ -1845,7 +1845,7 @@ void minmax_verts(float *min, float *max)
|
||||
tottrans=0;
|
||||
if ELEM5(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)
|
||||
make_trans_verts(bmat[0], bmat[1], 0);
|
||||
if(tottrans==0) return;
|
||||
if(tottrans==0) return 0;
|
||||
|
||||
Mat3CpyMat4(bmat, G.obedit->obmat);
|
||||
|
||||
@@ -1860,5 +1860,6 @@ void minmax_verts(float *min, float *max)
|
||||
|
||||
MEM_freeN(transvmain);
|
||||
transvmain= 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -911,20 +911,20 @@ void mirror_uv_tface()
|
||||
object_uvs_changed(OBACT);
|
||||
}
|
||||
|
||||
void minmax_tface(float *min, float *max)
|
||||
int minmax_tface(float *min, float *max)
|
||||
{
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
MFace *mf;
|
||||
MTFace *tf;
|
||||
MVert *mv;
|
||||
int a;
|
||||
int a, ok=0;
|
||||
float vec[3], bmat[3][3];
|
||||
|
||||
ob = OBACT;
|
||||
if (ob==0) return;
|
||||
if (ob==0) return ok;
|
||||
me= get_mesh(ob);
|
||||
if(me==0 || me->mtface==0) return;
|
||||
if(me==0 || me->mtface==0) return ok;
|
||||
|
||||
Mat3CpyMat4(bmat, ob->obmat);
|
||||
|
||||
@@ -956,7 +956,9 @@ void minmax_tface(float *min, float *max)
|
||||
VecAddf(vec, vec, ob->obmat[3]);
|
||||
DO_MINMAX(vec, min, max);
|
||||
}
|
||||
ok= 1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
#define ME_SEAM_DONE ME_SEAM_LAST /* reuse this flag */
|
||||
|
||||
@@ -1305,8 +1305,7 @@ void centerview() /* like a localview without local! */
|
||||
|
||||
|
||||
if(G.obedit) {
|
||||
minmax_verts(min, max); // ony selected
|
||||
ok= 1;
|
||||
ok = minmax_verts(min, max); /* only selected */
|
||||
}
|
||||
else if(ob && (ob->flag & OB_POSEMODE)) {
|
||||
if(ob->pose) {
|
||||
@@ -1330,14 +1329,16 @@ void centerview() /* like a localview without local! */
|
||||
}
|
||||
}
|
||||
else if (G.f & G_FACESELECT) {
|
||||
minmax_tface(min, max);
|
||||
ok= 1;
|
||||
ok= minmax_tface(min, max);
|
||||
}
|
||||
else {
|
||||
Base *base= FIRSTBASE;
|
||||
while(base) {
|
||||
if TESTBASE(base) {
|
||||
minmax_object(base->object, min, max);
|
||||
/* account for duplis */
|
||||
minmax_object_duplis(base->object, min, max);
|
||||
|
||||
ok= 1;
|
||||
}
|
||||
base= base->next;
|
||||
|
||||
Reference in New Issue
Block a user