Blender V5.3
DNA_mesh_types.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "DNA_ID.h"
12#include "DNA_attribute_types.h"
14#include "DNA_defs.h"
15
16#include "BLI_enum_flags.hh"
17
18#include <optional>
19
20#include "BLI_index_mask_fwd.hh"
23#include "BLI_vector_set.hh"
24
25namespace blender {
26
27template<typename T> struct Bounds;
28namespace offset_indices {
29template<typename T> struct GroupedSpan;
30template<typename T> class OffsetIndices;
31} // namespace offset_indices
34template<typename T> class MutableSpan;
35template<typename T> class Span;
36namespace bke {
37struct BVHTreeFromMesh;
38struct MeshRuntime;
41enum class MeshNormalDomain : int8_t;
42namespace bvh {
43class Tree;
44}
45} // namespace bke
46
47struct AnimData;
48struct bDeformGroup;
49struct Ipo;
50struct Key;
51struct Material;
52struct MCol;
53struct MEdge;
54struct MFace;
55
62
63
64enum eMesh_EditFlag : char {
66 ME_EDIT_MIRROR_Y = 1 << 1, /* unused so far */
67 ME_EDIT_MIRROR_Z = 1 << 2, /* unused so far */
68
72};
74
75/* Helper macro to see if vertex group X mirror is on. */
76#define ME_USING_MIRROR_X_VERTEX_GROUPS(_me) \
77 (((_me)->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) && ((_me)->symmetry & ME_SYMMETRY_X))
78
79/* We can't have both flags enabled at once,
80 * flags defined in DNA_scene_types.h */
81#define ME_EDIT_PAINT_SEL_MODE(_me) \
82 (((_me)->editflag & ME_EDIT_PAINT_FACE_SEL) ? SCE_SELECT_FACE : \
83 ((_me)->editflag & ME_EDIT_PAINT_VERT_SEL) ? SCE_SELECT_VERTEX : \
84 0)
85
88 ME_FLAG_UNUSED_0 = 1 << 0, /* cleared */
89 ME_FLAG_UNUSED_1 = 1 << 1, /* cleared */
90 ME_FLAG_DEPRECATED_2 = 1 << 2, /* deprecated */
96 ME_FLAG_UNUSED_4 = 1 << 4, /* cleared */
97 ME_AUTOSMOOTH_LEGACY = 1 << 5, /* deprecated */
98 ME_FLAG_UNUSED_6 = 1 << 6, /* cleared */
99 ME_FLAG_UNUSED_7 = 1 << 7, /* cleared */
101 ME_DS_EXPAND = 1 << 9,
109 ME_FLAG_UNUSED_8 = 1 << 12, /* deprecated */
112 ME_FLAG_UNUSED_9 = 1 << 15, /* deprecated */
113};
115
116#ifdef DNA_DEPRECATED_ALLOW
118enum eMesh_CDFlag : char {
119 ME_CDFLAG_VERT_BWEIGHT = 1 << 0,
120 ME_CDFLAG_EDGE_BWEIGHT = 1 << 1,
121 ME_CDFLAG_EDGE_CREASE = 1 << 2,
122 ME_CDFLAG_VERT_CREASE = 1 << 3,
123};
124ENUM_OPERATORS(eMesh_CDFlag)
125#endif
126
132
138
147
148struct Mesh {
149#ifdef __cplusplus
152 static constexpr ID_Type id_type = ID_ME;
153#endif
154
157 struct AnimData *adt = nullptr;
158
159 struct Key *key = nullptr;
160
166 struct Material **mat = nullptr;
167
169 int verts_num = 0;
171 int edges_num = 0;
173 int faces_num = 0;
175 int corners_num = 0;
176
183 int *face_offset_indices = nullptr;
184
189
195
200 ListBaseT<bDeformGroup> vertex_group_names = {nullptr, nullptr};
203
211
219 struct MSelect *mselect = nullptr;
220
222 int totselect = 0;
223
233 int act_face = 0;
234
240 struct Mesh *texcomesh = nullptr;
241
243 float texspace_location[3] = {};
244 float texspace_size[3] = {1.0f, 1.0f, 1.0f};
246
251
253
255 float remesh_voxel_size = 0.1f;
257
259 /* Stores the initial Face Set to be rendered white. This way the overlay can be enabled by
260 * default and Face Sets can be used without affecting the color of the mesh. */
262
264 char *active_color_attribute = nullptr;
266 char *default_color_attribute = nullptr;
267
273 char *active_uv_map_attribute = nullptr;
283 char *clone_uv_map_attribute = nullptr;
284
290
293
295 short totcol = 0;
296
306
308 DNA_DEPRECATED struct MPoly *mpoly = nullptr;
310 DNA_DEPRECATED struct MLoop *mloop = nullptr;
311
313 DNA_DEPRECATED struct MVert *mvert = nullptr;
315 DNA_DEPRECATED struct MEdge *medge = nullptr;
319 DNA_DEPRECATED struct MTFace *mtface = nullptr;
321 DNA_DEPRECATED struct TFace *tface = nullptr;
323 DNA_DEPRECATED struct MCol *mcol = nullptr;
325 DNA_DEPRECATED struct MFace *mface = nullptr;
326
334 /* Deprecated size of #fdata. */
336
337 char _pad1 = {};
338 int8_t radial_symmetry[3] = {1, 1, 1};
339
347#ifdef __cplusplus
351 Span<float3> vert_positions() const;
353 MutableSpan<float3> vert_positions_for_write();
360 Span<int2> edges() const;
362 MutableSpan<int2> edges_for_write();
368 OffsetIndices<int> faces() const;
374 Span<int> face_offsets() const;
376 MutableSpan<int> face_offsets_for_write();
377
387 Span<int> corner_verts() const;
389 MutableSpan<int> corner_verts_for_write();
390
396 Span<int> corner_edges() const;
398 MutableSpan<int> corner_edges_for_write();
399
400 bke::AttributeAccessor attributes() const;
401 bke::MutableAttributeAccessor attributes_for_write();
402
409 VectorSet<StringRefNull> uv_map_names() const;
410
412 StringRefNull active_uv_map_name() const;
414 StringRefNull default_uv_map_name() const;
416 StringRefNull active_or_default_uv_map_name() const;
417
418 void uv_maps_active_set(StringRef name);
419 void uv_maps_default_set(StringRef name);
420
425 Span<MDeformVert> deform_verts() const;
427 MutableSpan<MDeformVert> deform_verts_for_write();
428
432 Span<int3> corner_tris() const;
433
437 Span<int> corner_tri_faces() const;
438
442 std::optional<Bounds<float3>> bounds_min_max() const;
443
445 void bounds_set_eager(const Bounds<float3> &bounds);
446
448 std::optional<int> material_index_max() const;
449
451 const VectorSet<int> &material_indices_used() const;
452
456 Span<int> corner_to_face_map() const;
460 OffsetIndices<int> vert_to_face_map_offsets() const;
464 GroupedSpan<int> vert_to_corner_map() const;
468 GroupedSpan<int> vert_to_face_map() const;
472 GroupedSpan<int> edge_to_corner_map() const;
473
477 const IndexMask &loose_edges() const;
481 const IndexMask &loose_verts() const;
485 const IndexMask &verts_no_face() const;
494 bool no_overlapping_topology() const;
495
503 void tag_loose_edges_none() const;
511 void tag_loose_verts_none() const;
513 void tag_overlapping_none();
514
525 bke::MeshNormalDomain normals_domain() const;
529 Span<float3> face_normals() const;
530 Span<float3> face_normals_true() const;
535 Span<float3> vert_normals() const;
536 Span<float3> vert_normals_true() const;
546 Span<float3> corner_normals() const;
547
548 const blender::bke::bvh::Tree &bvh_verts() const;
549 const blender::bke::bvh::Tree &bvh_edges() const;
550 const blender::bke::bvh::Tree &bvh_tris() const;
555 bke::BVHTreeFromMesh bvh_edges_legacy() const;
557 bke::BVHTreeFromMesh bvh_corner_tris() const;
558 bke::BVHTreeFromMesh bvh_corner_tris_no_hidden() const;
559 bke::BVHTreeFromMesh bvh_loose_verts() const;
560 bke::BVHTreeFromMesh bvh_loose_edges() const;
561 bke::BVHTreeFromMesh bvh_loose_no_hidden_verts() const;
562 bke::BVHTreeFromMesh bvh_loose_no_hidden_edges() const;
563 bke::BVHTreeFromMesh bvh_legacy_faces() const;
564
565 void count_memory(MemoryCounter &memory) const;
566
568 void tag_positions_changed();
570 void tag_positions_changed_uniformly();
572 void tag_positions_changed_no_normals();
574 void tag_sharpness_changed();
576 void tag_custom_normals_changed();
578 void tag_face_winding_changed();
580 void tag_edges_split();
582 void tag_topology_changed();
584 void tag_visibility_changed();
586 void tag_material_index_changed();
587#endif
588};
589
590/* deprecated by MTFace, only here for file reading */
591
592#ifdef DNA_DEPRECATED_ALLOW
593struct TFace {
595
596
597 void *tpage = nullptr;
598 float uv[4][2] = {};
599 unsigned int col[4] = {};
600 char flag = 0, transp = 0;
601 short mode = 0, tile = 0, unwrap = 0;
602};
603#endif
604
605#define MESH_MAX_VERTS 2000000000L
606
607} // namespace blender
#define ENUM_OPERATORS(_enum_type)
ID and Library types, which are fundamental for SDNA.
#define DNA_DEFINE_CXX_METHODS(class_name)
Definition DNA_defs.h:104
#define DNA_DEPRECATED
Definition DNA_defs.h:21
const ccl_global KernelWorkTile * tile
ENUM_OPERATORS(Layer::Flags)
BLI_INLINE MTLTexture * unwrap(Texture *tex)
BMesh Iterators.
unsigned short uint16_t
Definition BKE_text.h:80
@ ME_EDIT_MIRROR_VERTEX_GROUPS
@ ME_EDIT_PAINT_VERT_SEL
@ ME_EDIT_PAINT_FACE_SEL
@ ME_EDIT_MIRROR_TOPO
@ ME_TEXSPACE_FLAG_AUTO
@ ME_TEXSPACE_FLAG_AUTO_EVALUATED
@ ME_NO_OVERLAPPING_TOPOLOGY
@ ME_REMESH_REPROJECT_ATTRIBUTES
@ ME_FLAG_DEPRECATED_2
@ ME_REMESH_REPROJECT_VOLUME
@ ME_FLAG_UV_SELECT_SYNC_VALID
@ ME_REMESH_FIX_POLES
@ ME_AUTOSMOOTH_LEGACY
@ ME_SCULPT_DYNAMIC_TOPOLOGY
signed char int8_t
Definition BKE_text.h:76
struct AttributeStorage attribute_storage
float texspace_location[3]
eMesh_EditFlag editflag
DNA_DEPRECATED struct MPoly * mpoly
struct Material ** mat
float texspace_size[3]
DNA_DEPRECATED char subdivr
ListBaseT< bDeformGroup > vertex_group_names
struct MSelect * mselect
bke::MeshRuntime * runtime
char * stencil_uv_map_attribute
int * face_offset_indices
DNA_DEPRECATED struct MLoop * mloop
DNA_DEPRECATED char cd_flag
DNA_DEPRECATED struct MFace * mface
int vertex_group_active_index
DNA_DEPRECATED float smoothresh_legacy
char * default_uv_map_attribute
eMeshSymmetryType symmetry
struct Mesh * texcomesh
char * active_uv_map_attribute
DNA_DEPRECATED struct TFace * tface
struct Key * key
DNA_DEPRECATED struct MDeformVert * dvert
float remesh_voxel_adaptivity
DNA_DEPRECATED struct MEdge * medge
DNA_DEPRECATED struct MCol * mcol
CustomData corner_data
eMesh_RemeshMode remesh_mode
char * clone_uv_map_attribute
eMesh_Flag flag
CustomData face_data
DNA_DEPRECATED struct MTFace * mtface
int8_t radial_symmetry[3]
DNA_DEPRECATED struct MVert * mvert
char * active_color_attribute
CustomData edge_data
CustomData fdata_legacy
DNA_DEPRECATED char subsurftype
char * default_color_attribute
CustomData vert_data
struct AnimData * adt