Blender  V2.93
transform_convert_sculpt.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include "MEM_guardedalloc.h"
25 
26 #include "BLI_math.h"
27 
28 #include "BKE_context.h"
29 #include "BKE_paint.h"
30 #include "BKE_report.h"
31 
32 #include "ED_sculpt.h"
33 
34 #include "transform.h"
35 #include "transform_convert.h"
36 
37 /* -------------------------------------------------------------------- */
42 {
43  TransData *td;
44 
45  Scene *scene = t->scene;
46  if (ID_IS_LINKED(scene)) {
47  BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
48  return;
49  }
50 
51  Object *ob = OBACT(t->view_layer);
52  SculptSession *ss = ob->sculpt;
53 
54  {
55  BLI_assert(t->data_container_len == 1);
56  TransDataContainer *tc = t->data_container;
57  tc->data_len = 1;
58  tc->is_active = 1;
59  td = tc->data = MEM_callocN(sizeof(TransData), "TransSculpt");
60  td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransSculpt");
61  }
62 
63  td->flag = TD_SELECTED;
64  copy_v3_v3(td->center, ss->pivot_pos);
65  mul_m4_v3(ob->obmat, td->center);
66  td->ob = ob;
67 
68  td->loc = ss->pivot_pos;
69  copy_v3_v3(td->iloc, ss->pivot_pos);
70 
71  if (is_zero_v4(ss->pivot_rot)) {
72  ss->pivot_rot[3] = 1.0f;
73  }
74 
75  float obmat_inv[3][3];
76  copy_m3_m4(obmat_inv, ob->obmat);
77  invert_m3(obmat_inv);
78 
79  td->ext->rot = NULL;
80  td->ext->rotAxis = NULL;
81  td->ext->rotAngle = NULL;
82  td->ext->quat = ss->pivot_rot;
83  copy_m4_m4(td->ext->obmat, ob->obmat);
84  copy_m3_m3(td->ext->l_smtx, obmat_inv);
85  copy_m3_m4(td->ext->r_mtx, ob->obmat);
86  copy_m3_m3(td->ext->r_smtx, obmat_inv);
87 
88  copy_qt_qt(td->ext->iquat, ss->pivot_rot);
89  td->ext->rotOrder = ROT_MODE_QUAT;
90 
91  ss->pivot_scale[0] = 1.0f;
92  ss->pivot_scale[1] = 1.0f;
93  ss->pivot_scale[2] = 1.0f;
94  td->ext->size = ss->pivot_scale;
97 
98  copy_m3_m3(td->smtx, obmat_inv);
99  copy_m3_m4(td->mtx, ob->obmat);
100  copy_m3_m4(td->axismtx, ob->obmat);
101 
102  BLI_assert(!(t->options & CTX_PAINT_CURVE));
104 }
105 
108 /* -------------------------------------------------------------------- */
113 {
114  Object *ob = OBACT(t->view_layer);
115  ED_sculpt_update_modal_transform(t->context, ob);
116 }
117 
119 {
120  Scene *scene = t->scene;
121  if (ID_IS_LINKED(scene)) {
122  /* `ED_sculpt_init_transform` was not called in this case. */
123  return;
124  }
125 
126  Object *ob = OBACT(t->view_layer);
127  BLI_assert(!(t->options & CTX_PAINT_CURVE));
129 }
130 
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
#define BLI_assert(a)
Definition: BLI_assert.h:58
void copy_m3_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:89
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:105
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
bool invert_m3(float R[3][3])
Definition: math_matrix.c:1152
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:52
MINLINE bool is_zero_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
@ ROT_MODE_QUAT
#define OBACT(_view_layer)
void ED_sculpt_init_transform(struct bContext *C, struct Object *ob)
void ED_sculpt_end_transform(struct bContext *C, struct Object *ob)
void ED_sculpt_update_modal_transform(struct bContext *C, struct Object *ob)
_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:39
Scene scene
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
float obmat[4][4]
struct SculptSession * sculpt
float pivot_scale[3]
Definition: BKE_paint.h:569
float pivot_pos[3]
Definition: BKE_paint.h:567
float init_pivot_scale[3]
Definition: BKE_paint.h:573
float pivot_rot[4]
Definition: BKE_paint.h:568
TransData * data
Definition: transform.h:448
TransDataExtension * data_ext
Definition: transform.h:450
float r_smtx[3][3]
float l_smtx[3][3]
float smtx[3][3]
float axismtx[3][3]
float mtx[3][3]
TransDataExtension * ext
struct Object * ob
@ CTX_PAINT_CURVE
Definition: transform.h:86
conversion and adaptation of different datablocks to a common struct.
void createTransSculpt(bContext *C, TransInfo *t)
void recalcData_sculpt(TransInfo *t)
void special_aftertrans_update__sculpt(bContext *C, TransInfo *t)
@ TD_SELECTED