Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-04-01 15:14:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-04-01 15:14:34 +0400
commit7d6e7c716fcea69cacb74132efbae27133345f57 (patch)
tree196ad280462129bbf9fe55912455482bc5a17b1b /source
parent22149c95ba5e3f885b9609b0cf60f54a13c481d5 (diff)
function for getting object texspace settings, without dealing with curve/mball/mesh separately.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/intern/object.c41
-rw-r--r--source/blender/src/buttons_editing.c6
-rw-r--r--source/blender/src/transform_conversions.c23
4 files changed, 46 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 903ca7a66aa..5599acc1571 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -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
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 3f1515f146a..287708a8ed4 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -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;
+}
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index cc6919a4a19..8080798c91f 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -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);
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 45e75bff39b..7d9c0242568 100644
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -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);