Blender  V3.3
transform_convert_sculpt.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_context.h"
13 #include "BKE_lib_id.h"
14 #include "BKE_paint.h"
15 #include "BKE_report.h"
16 
17 #include "ED_sculpt.h"
18 
19 #include "transform.h"
20 #include "transform_convert.h"
21 
22 /* -------------------------------------------------------------------- */
27 {
28  TransData *td;
29 
30  Scene *scene = t->scene;
32  BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
33  return;
34  }
35 
36  Object *ob = OBACT(t->view_layer);
37  SculptSession *ss = ob->sculpt;
38 
39  {
40  BLI_assert(t->data_container_len == 1);
41  TransDataContainer *tc = t->data_container;
42  tc->data_len = 1;
43  tc->is_active = 1;
44  td = tc->data = MEM_callocN(sizeof(TransData), "TransSculpt");
45  td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransSculpt");
46  }
47 
48  td->flag = TD_SELECTED;
49  copy_v3_v3(td->center, ss->pivot_pos);
50  mul_m4_v3(ob->obmat, td->center);
51  td->ob = ob;
52 
53  td->loc = ss->pivot_pos;
54  copy_v3_v3(td->iloc, ss->pivot_pos);
55 
56  if (is_zero_v4(ss->pivot_rot)) {
57  ss->pivot_rot[3] = 1.0f;
58  }
59 
60  float obmat_inv[3][3];
61  copy_m3_m4(obmat_inv, ob->obmat);
62  invert_m3(obmat_inv);
63 
64  td->ext->rot = NULL;
65  td->ext->rotAxis = NULL;
66  td->ext->rotAngle = NULL;
67  td->ext->quat = ss->pivot_rot;
68  copy_m4_m4(td->ext->obmat, ob->obmat);
69  copy_m3_m3(td->ext->l_smtx, obmat_inv);
70  copy_m3_m4(td->ext->r_mtx, ob->obmat);
71  copy_m3_m3(td->ext->r_smtx, obmat_inv);
72 
73  copy_qt_qt(td->ext->iquat, ss->pivot_rot);
74  td->ext->rotOrder = ROT_MODE_QUAT;
75 
76  ss->pivot_scale[0] = 1.0f;
77  ss->pivot_scale[1] = 1.0f;
78  ss->pivot_scale[2] = 1.0f;
79  td->ext->size = ss->pivot_scale;
82 
83  copy_m3_m3(td->smtx, obmat_inv);
84  copy_m3_m4(td->mtx, ob->obmat);
85  copy_m3_m4(td->axismtx, ob->obmat);
86 
87  BLI_assert(!(t->options & CTX_PAINT_CURVE));
89 }
90 
93 /* -------------------------------------------------------------------- */
98 {
99  Object *ob = OBACT(t->view_layer);
100  ED_sculpt_update_modal_transform(t->context, ob);
101 }
102 
104 {
105  Scene *scene = t->scene;
107  /* `ED_sculpt_init_transform` was not called in this case. */
108  return;
109  }
110 
111  Object *ob = OBACT(t->view_layer);
112  BLI_assert(!(t->options & CTX_PAINT_CURVE));
114 }
115 
119  /* flags */ 0,
120  /* createTransData */ createTransSculpt,
121  /* recalcData */ recalcData_sculpt,
122  /* special_aftertrans_update */ special_aftertrans_update__sculpt,
123 };
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
bool BKE_id_is_editable(const struct Main *bmain, const struct ID *id)
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_m3(float m1[3][3], const float m2[3][3])
Definition: math_matrix.c:71
void copy_m3_m4(float m1[3][3], const float m2[4][4])
Definition: math_matrix.c:87
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
bool invert_m3(float R[3][3])
Definition: math_matrix.c:1171
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
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])
@ 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:25
Scene scene
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
float obmat[4][4]
struct SculptSession * sculpt
float pivot_scale[3]
Definition: BKE_paint.h:614
float pivot_pos[3]
Definition: BKE_paint.h:612
float init_pivot_scale[3]
Definition: BKE_paint.h:618
float pivot_rot[4]
Definition: BKE_paint.h:613
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
conversion and adaptation of different datablocks to a common struct.
static void recalcData_sculpt(TransInfo *t)
static void createTransSculpt(bContext *C, TransInfo *t)
static void special_aftertrans_update__sculpt(bContext *C, TransInfo *t)
TransConvertTypeInfo TransConvertType_Sculpt
@ TD_SELECTED