Blender  V3.3
transform_convert_mesh_edge.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 "DNA_mesh_types.h"
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BLI_math.h"
13 
14 #include "BKE_context.h"
15 #include "BKE_customdata.h"
16 #include "BKE_editmesh.h"
17 #include "BKE_mesh.h"
18 
19 #include "transform.h"
20 #include "transform_convert.h"
21 
22 /* -------------------------------------------------------------------- */
27 {
29 
30  BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
31  TransData *td = NULL;
32  BMEdge *eed;
33  BMIter iter;
34  float mtx[3][3], smtx[3][3];
35  int count = 0, countsel = 0;
36  const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
37  const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
38  int cd_edge_float_offset;
39 
40  BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
41  if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
43  countsel++;
44  }
45  if (is_prop_edit) {
46  count++;
47  }
48  }
49  }
50 
51  if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) {
52  tc->data_len = 0;
53  continue;
54  }
55 
56  if (is_prop_edit) {
57  tc->data_len = count;
58  }
59  else {
60  tc->data_len = countsel;
61  }
62 
63  td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransCrease");
64 
65  copy_m3_m4(mtx, tc->obedit->obmat);
67 
68  /* create data we need */
69  if (t->mode == TFM_BWEIGHT) {
71  cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
72  }
73  else { /* if (t->mode == TFM_EDGE_CREASE) { */
74  BLI_assert(t->mode == TFM_EDGE_CREASE);
76  cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
77  }
78 
79  BLI_assert(cd_edge_float_offset != -1);
80 
81  BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
82  if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) &&
83  (BM_elem_flag_test(eed, BM_ELEM_SELECT) || is_prop_edit)) {
84  float *fl_ptr;
85  /* need to set center for center calculations */
86  mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
87 
88  td->loc = NULL;
90  td->flag = TD_SELECTED;
91  }
92  else {
93  td->flag = 0;
94  }
95 
96  copy_m3_m3(td->smtx, smtx);
97  copy_m3_m3(td->mtx, mtx);
98 
99  td->ext = NULL;
100 
101  fl_ptr = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_float_offset);
102  td->loc = fl_ptr;
103  td->iloc[0] = *fl_ptr;
104 
105  td++;
106  }
107  }
108  }
109 }
110 
112 {
114  DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY);
115  }
116 }
117 
121  /* flags */ T_EDIT,
122  /* createTransData */ createTransEdge,
123  /* recalcData */ recalcData_mesh_edge,
124  /* special_aftertrans_update */ special_aftertrans_update__mesh,
125 };
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_offset(const struct CustomData *data, int type)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:58
struct Mesh * BKE_mesh_from_object(struct Object *ob)
Definition: mesh.cc:1365
#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
#define PSEUDOINVERSE_EPSILON
void pseudoinverse_m3_m3(float Ainv[3][3], const float A[3][3], float epsilon)
Definition: math_matrix.c:3107
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:237
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ CD_BWEIGHT
@ ME_CDFLAG_EDGE_CREASE
@ ME_CDFLAG_EDGE_BWEIGHT
@ TFM_BWEIGHT
Definition: ED_transform.h:57
@ TFM_EDGE_CREASE
Definition: ED_transform.h:41
_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
@ BM_ELEM_HIDDEN
Definition: bmesh_class.h:472
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
Definition: bmesh_class.h:541
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_EDGES_OF_MESH
void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag)
int count
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
BMVert * v1
Definition: bmesh_class.h:122
BMVert * v2
Definition: bmesh_class.h:122
struct BMesh * bm
Definition: BKE_editmesh.h:40
float co[3]
Definition: bmesh_class.h:87
CustomData edata
Definition: bmesh_class.h:337
float smtx[3][3]
float mtx[3][3]
TransDataExtension * ext
conversion and adaptation of different datablocks to a common struct.
void special_aftertrans_update__mesh(bContext *C, TransInfo *t)
static void createTransEdge(bContext *UNUSED(C), TransInfo *t)
static void recalcData_mesh_edge(TransInfo *t)
TransConvertTypeInfo TransConvertType_MeshEdge
@ TD_SELECTED