Blender  V3.3
BKE_DerivedMesh.h
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 
4 #pragma once
5 
41 /*
42  * NOTE: This structure is read-only, for all practical purposes.
43  * At some point in the future, we may want to consider
44  * creating a replacement structure that implements a proper
45  * abstract mesh kernel interface. Or, we can leave this
46  * as it is and stick with using BMesh and CDDM.
47  */
48 
49 #include "BLI_compiler_attrs.h"
50 
51 #include "DNA_customdata_types.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 struct BMEditMesh;
58 struct CCGElem;
59 struct CCGKey;
61 struct Depsgraph;
62 struct MEdge;
63 struct MFace;
64 struct MVert;
65 struct Mesh;
66 struct ModifierData;
67 struct Object;
68 struct Scene;
69 
70 /*
71  * NOTE: all #MFace interfaces now officially operate on tessellated data.
72  * Also, the #MFace orig-index layer indexes #MPoly, not #MFace.
73  */
74 
75 /* keep in sync with MFace/MPoly types */
76 typedef struct DMFlagMat {
77  short mat_nr;
78  char flag;
80 
81 typedef enum DerivedMeshType {
85 
86 typedef struct DerivedMesh DerivedMesh;
87 struct DerivedMesh {
91  int needsFree; /* checked on ->release, is set to 0 for cached results */
92  int deformedOnly; /* set by modifier stack if only deformed from original */
94 
98  struct {
99  /* WARNING! swapping between array (ready-to-be-used data) and array_wip
100  * (where data is actually computed) shall always be protected by same
101  * lock as one used for looptris computing. */
103  int num;
106 
107  /* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
108  char cd_flag;
109 
110  short tangent_mask; /* which tangent layers are calculated */
111 
115  const struct MLoopTri *(*getLoopTriArray)(DerivedMesh *dm);
117 
118  /* Misc. Queries */
119 
120  /* Also called in Editmode */
125 
131  struct MVert *(*getVertArray)(DerivedMesh *dm);
132  struct MEdge *(*getEdgeArray)(DerivedMesh *dm);
133  struct MLoop *(*getLoopArray)(DerivedMesh *dm);
134  struct MPoly *(*getPolyArray)(DerivedMesh *dm);
135 
139  void (*copyVertArray)(DerivedMesh *dm, struct MVert *r_vert);
140  void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge);
141  void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop);
142  void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly);
143 
147  struct MVert *(*dupVertArray)(DerivedMesh *dm);
148  struct MEdge *(*dupEdgeArray)(DerivedMesh *dm);
149  struct MLoop *(*dupLoopArray)(DerivedMesh *dm);
150  struct MPoly *(*dupPolyArray)(DerivedMesh *dm);
151 
156  void *(*getVertDataArray)(DerivedMesh *dm, int type);
157  void *(*getEdgeDataArray)(DerivedMesh *dm, int type);
158  void *(*getLoopDataArray)(DerivedMesh *dm, int type);
159  void *(*getPolyDataArray)(DerivedMesh *dm, int type);
160 
164  struct CCGElem **(*getGridData)(DerivedMesh *dm);
165  int *(*getGridOffset)(DerivedMesh *dm);
166  void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
167  DMFlagMat *(*getGridFlagMats)(DerivedMesh *dm);
168  unsigned int **(*getGridHidden)(DerivedMesh *dm);
169 
175  void (*getVertCo)(DerivedMesh *dm, int index, float r_co[3]);
176 
178  void (*getVertNo)(DerivedMesh *dm, int index, float r_no[3]);
179 
183 };
184 
189 void DM_init_funcs(DerivedMesh *dm);
190 
196 void DM_init(DerivedMesh *dm,
198  int numVerts,
199  int numEdges,
200  int numTessFaces,
201  int numLoops,
202  int numPolys);
203 
209  DerivedMesh *source,
211  int numVerts,
212  int numEdges,
213  int numTessFaces,
214  int numLoops,
215  int numPolys);
216 
221 bool DM_release(DerivedMesh *dm);
222 
229 
230 /* -------------------------------------------------------------------- */
238 void *DM_get_vert_data_layer(struct DerivedMesh *dm, int type);
239 void *DM_get_edge_data_layer(struct DerivedMesh *dm, int type);
240 void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type);
241 void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type);
242 
250 void DM_copy_vert_data(struct DerivedMesh *source,
251  struct DerivedMesh *dest,
252  int source_index,
253  int dest_index,
254  int count);
255 
259 void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
260 
268 
274 void DM_interp_vert_data(struct DerivedMesh *source,
275  struct DerivedMesh *dest,
276  int *src_indices,
277  float *weights,
278  int count,
279  int dest_index);
280 
281 void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float (*r_cos)[3], int totcos);
282 
287  const struct Scene *scene,
288  struct Object *obedit,
289  struct BMEditMesh *em,
290  const struct CustomData_MeshMasks *dataMask);
292  const struct Scene *scene,
293  struct Object *obedit,
294  const struct CustomData_MeshMasks *dataMask);
295 
296 float (*editbmesh_vert_coords_alloc(struct BMEditMesh *em, int *r_vert_len))[3];
298  const struct Object *ob,
299  struct ModifierData *md,
300  bool has_prev_mesh);
302  const struct Scene *scene,
303  struct Object *ob,
304  const struct CustomData_MeshMasks *dataMask);
305 
306 #ifdef __cplusplus
307 }
308 #endif
typedef float(TangentPoint)[2]
void * DM_get_edge_data_layer(struct DerivedMesh *dm, int type)
Definition: DerivedMesh.cc:441
void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, int *src_indices, float *weights, int count, int dest_index)
Definition: DerivedMesh.cc:466
void DM_copy_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, int source_index, int dest_index, int count)
Definition: DerivedMesh.cc:460
void * DM_get_poly_data_layer(struct DerivedMesh *dm, int type)
Definition: DerivedMesh.cc:450
bool editbmesh_modifier_is_enabled(const struct Scene *scene, const struct Object *ob, struct ModifierData *md, bool has_prev_mesh)
struct Mesh * editbmesh_get_eval_cage_from_orig(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *obedit, const struct CustomData_MeshMasks *dataMask)
void DM_set_only_copy(DerivedMesh *dm, const struct CustomData_MeshMasks *mask)
void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, int numTessFaces, int numLoops, int numPolys)
Definition: DerivedMesh.cc:250
bool DM_release(DerivedMesh *dm)
Definition: DerivedMesh.cc:307
void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type, int numVerts, int numEdges, int numTessFaces, int numLoops, int numPolys)
Definition: DerivedMesh.cc:277
void DM_ensure_looptri_data(DerivedMesh *dm)
Definition: DerivedMesh.cc:362
void * DM_get_vert_data_layer(struct DerivedMesh *dm, int type)
Definition: DerivedMesh.cc:432
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target)
Definition: DerivedMesh.cc:332
struct DMFlagMat DMFlagMat
struct Mesh * editbmesh_get_eval_cage(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *obedit, struct BMEditMesh *em, const struct CustomData_MeshMasks *dataMask)
void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float(*r_cos)[3], int totcos)
void * DM_get_loop_data_layer(struct DerivedMesh *dm, int type)
Definition: DerivedMesh.cc:455
void makeDerivedMesh(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void DM_init_funcs(DerivedMesh *dm)
Definition: DerivedMesh.cc:227
float(* editbmesh_vert_coords_alloc(struct BMEditMesh *em, int *r_vert_len))[3]
DerivedMeshType
@ DM_TYPE_CDDM
@ DM_TYPE_CCGDM
struct CCGElem CCGElem
Definition: BKE_ccg.h:30
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
_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 type
Scene scene
const Depsgraph * depsgraph
SyclQueue void void size_t num_bytes void
SyclQueue void * dest
int count
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
Definition: BKE_ccg.h:32
int(* getGridSize)(DerivedMesh *dm)
CustomData faceData
void(* getVertNo)(DerivedMesh *dm, int index, float r_no[3])
CustomData vertData
void(* copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop)
void(* copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge)
int(* getNumVerts)(DerivedMesh *dm)
int(* getNumLoopTri)(DerivedMesh *dm)
void(* copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly)
int(* getNumPolys)(DerivedMesh *dm)
int(* getNumEdges)(DerivedMesh *dm)
struct DerivedMesh::@16 looptris
int(* getNumGrids)(DerivedMesh *dm)
CustomData polyData
struct MLoopTri * array_wip
void(* copyVertArray)(DerivedMesh *dm, struct MVert *r_vert)
void(* getGridKey)(DerivedMesh *dm, struct CCGKey *key)
CustomData edgeData
CustomData loopData
void(* recalcLoopTri)(DerivedMesh *dm)
struct MLoopTri * array
void(* release)(DerivedMesh *dm)
void(* getVertCo)(DerivedMesh *dm, int index, float r_co[3])
int(* getNumLoops)(DerivedMesh *dm)
DerivedMeshType type