Blender  V3.3
transform_convert_object_texspace.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_math.h"
11 
12 #include "BKE_animsys.h"
13 #include "BKE_context.h"
14 #include "BKE_object.h"
15 #include "BKE_report.h"
16 
17 #include "DNA_mesh_types.h"
18 
19 #include "transform.h"
20 #include "transform_snap.h"
21 
22 /* Own include. */
23 #include "transform_convert.h"
24 
25 /* -------------------------------------------------------------------- */
33 {
34  ViewLayer *view_layer = t->view_layer;
35  TransData *td;
36  Object *ob;
37  ID *id;
38  char *texflag;
39 
40  ob = OBACT(view_layer);
41 
42  if (ob == NULL) { /* Shouldn't logically happen, but still. */
43  return;
44  }
45 
46  id = ob->data;
47  if (id == NULL || !ELEM(GS(id->name), ID_ME, ID_CU_LEGACY, ID_MB)) {
48  BKE_report(t->reports, RPT_ERROR, "Unsupported object type for text-space transform");
49  return;
50  }
51 
53  BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
54  return;
55  }
56 
57  {
58  BLI_assert(t->data_container_len == 1);
59  TransDataContainer *tc = t->data_container;
60  tc->data_len = 1;
61  td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
62  td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
63  }
64 
65  td->flag = TD_SELECTED;
66  td->ob = ob;
67 
68  copy_m3_m4(td->mtx, ob->obmat);
69  copy_m3_m4(td->axismtx, ob->obmat);
70  normalize_m3(td->axismtx);
72 
73  if (BKE_object_obdata_texspace_get(ob, &texflag, &td->loc, &td->ext->size)) {
74  ob->dtx |= OB_TEXSPACE;
75  *texflag &= ~ME_AUTOSPACE;
76  }
77 
78  copy_v3_v3(td->iloc, td->loc);
79  copy_v3_v3(td->center, td->loc);
80  copy_v3_v3(td->ext->isize, td->ext->size);
81 }
82 
85 /* -------------------------------------------------------------------- */
90 {
91 
92  if (t->state != TRANS_CANCEL) {
94  }
95 
97  TransData *td = tc->data;
98 
99  for (int i = 0; i < tc->data_len; i++, td++) {
100  if (td->flag & TD_SKIP) {
101  continue;
102  }
104  }
105  }
106 }
107 
111  /* flags */ 0,
112  /* createTransData */ createTransTexspace,
113  /* recalcData */ recalcData_texspace,
114  /* special_aftertrans_update */ NULL,
115 };
General operations, lookup, etc. for blender objects.
bool BKE_object_obdata_is_libdata(const struct Object *ob)
bool BKE_object_obdata_texspace_get(struct Object *ob, char **r_texflag, float **r_loc, float **r_size)
Definition: object.cc:4328
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
#define PSEUDOINVERSE_EPSILON
void normalize_m3(float R[3][3]) ATTR_NONNULL()
Definition: math_matrix.c:1912
void pseudoinverse_m3_m3(float Ainv[3][3], const float A[3][3], float epsilon)
Definition: math_matrix.c:3107
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define UNUSED(x)
#define ELEM(...)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ID_CU_LEGACY
Definition: DNA_ID_enums.h:49
@ ID_ME
Definition: DNA_ID_enums.h:48
@ ID_MB
Definition: DNA_ID_enums.h:50
@ ME_AUTOSPACE
@ OB_TEXSPACE
#define OBACT(_view_layer)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
#define GS(x)
Definition: iris.c:225
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
float obmat[4][4]
void * data
float smtx[3][3]
float axismtx[3][3]
float mtx[3][3]
TransDataExtension * ext
struct Object * ob
conversion and adaptation of different datablocks to a common struct.
static void recalcData_texspace(TransInfo *t)
static void createTransTexspace(bContext *UNUSED(C), TransInfo *t)
TransConvertTypeInfo TransConvertType_ObjectTexSpace
@ TD_SELECTED
@ TD_SKIP
void applySnappingIndividual(TransInfo *t)