function for getting object texspace settings, without dealing with curve/mball/mesh separately.

This commit is contained in:
2008-04-01 11:14:34 +00:00
parent 22149c95ba
commit 7d6e7c716f
4 changed files with 46 additions and 26 deletions

View File

@@ -115,7 +115,7 @@ void solve_tracking (struct Object *ob, float targetmat[][4]);
void object_handle_update(struct Object *ob);
float give_timeoffset(struct Object *ob);
int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot);
#ifdef __cplusplus
}
#endif

View File

@@ -53,6 +53,8 @@
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_curve_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_nla_types.h"
@@ -2288,3 +2290,42 @@ float give_timeoffset(Object *ob) {
return ob->sf;
}
}
int give_obdata_texspace(Object *ob, int **texflag, float **loc, float **size, float **rot) {
if (ob->data==NULL)
return 0;
switch (GS(((ID *)ob->data)->name)) {
case ID_ME:
{
Mesh *me= ob->data;
if (texflag) *texflag = &me->texflag;
if (loc) *loc = me->loc;
if (size) *size = me->size;
if (rot) *rot = me->rot;
break;
}
case ID_CU:
{
Curve *cu= ob->data;
if (texflag) *texflag = &cu->texflag;
if (loc) *loc = cu->loc;
if (size) *size = cu->size;
if (rot) *rot = cu->rot;
break;
}
case ID_MB:
{
MetaBall *mb= ob->data;
if (texflag) *texflag = &mb->texflag;
if (loc) *loc = mb->loc;
if (size) *size = mb->size;
if (rot) *rot = mb->rot;
break;
}
default:
return 0;
}
return 1;
}

View File

@@ -5412,12 +5412,8 @@ static void editing_panel_links(Object *ob)
if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL);
else return;
id= ob->data;
uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
if(ob->type==OB_MESH) poin= &( ((Mesh *)ob->data)->texflag );
else if(ob->type==OB_MBALL) poin= &( ((MetaBall *)ob->data)->texflag );
else poin= &( ((Curve *)ob->data)->texflag );
give_obdata_texspace(ob, &poin, NULL, NULL, NULL);
uiDefButBitI(block, TOG, AUTOSPACE, B_AUTOTEX, "AutoTexSpace", 143,15,140,19, poin, 0, 0, 0, 0, "Adjusts active object's texture space automatically when transforming object");
sprintf(str,"%d Mat ", ob->totcol);

View File

@@ -284,6 +284,7 @@ static void createTransTexspace(TransInfo *t)
TransData *td;
Object *ob;
ID *id;
int *texflag;
ob= OBACT;
@@ -311,26 +312,8 @@ static void createTransTexspace(TransInfo *t)
Mat3Ortho(td->axismtx);
Mat3Inv(td->smtx, td->mtx);
if( GS(id->name)==ID_ME) {
Mesh *me= ob->data;
me->texflag &= ~AUTOSPACE;
td->loc= me->loc;
td->ext->rot= me->rot;
td->ext->size= me->size;
}
else if( GS(id->name)==ID_CU) {
Curve *cu= ob->data;
cu->texflag &= ~CU_AUTOSPACE;
td->loc= cu->loc;
td->ext->rot= cu->rot;
td->ext->size= cu->size;
}
else if( GS(id->name)==ID_MB) {
MetaBall *mb= ob->data;
mb->texflag &= ~MB_AUTOSPACE;
td->loc= mb->loc;
td->ext->rot= mb->rot;
td->ext->size= mb->size;
if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) {
*texflag &= ~AUTOSPACE;
}
VECCOPY(td->iloc, td->loc);