From 9ed4dc03789b19c3902209a65b37a6c79f6fd147 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 15 Nov 2023 22:29:57 +0100 Subject: [PATCH 1/2] Blender 4.0 update --- BlenderMalt/CBlenderMalt/CBlenderMalt.cpp | 12 +-- BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h | 91 +++++++++++++------ .../CBlenderMalt/blender_dna/DNA_ID_enums.h | 6 +- .../blender_dna/DNA_customdata_types.h | 41 ++++----- .../CBlenderMalt/blender_dna/DNA_defs.h | 19 +++- .../CBlenderMalt/blender_dna/DNA_listBase.h | 15 +-- .../CBlenderMalt/blender_dna/DNA_mesh_types.h | 89 +++++++++++------- .../blender_dna/DNA_meshdata_types.h | 87 +++++------------- .../blender_dna/DNA_session_uuid_types.h | 23 ++--- BlenderMalt/MaltNodes/MaltNode.py | 7 +- .../Nodes/MaltFunctionSubCategory.py | 6 +- BlenderMalt/__init__.py | 4 +- 12 files changed, 208 insertions(+), 192 deletions(-) diff --git a/BlenderMalt/CBlenderMalt/CBlenderMalt.cpp b/BlenderMalt/CBlenderMalt/CBlenderMalt.cpp index d83b35fb..521381e1 100644 --- a/BlenderMalt/CBlenderMalt/CBlenderMalt.cpp +++ b/BlenderMalt/CBlenderMalt/CBlenderMalt.cpp @@ -93,10 +93,10 @@ EXPORT void retrieve_mesh_data(void* in_mesh, void* in_loop_tris, int* in_loop_t Mesh* mesh = (Mesh*)in_mesh; MLoopTri* loop_tris = (MLoopTri*)in_loop_tris; - int* loop_verts = (int*)CustomData_get_layer_named(&mesh->ldata, CD_PROP_INT32, ".corner_vert"); - float* positions = (float*)CustomData_get_layer_named(&mesh->vdata, CD_PROP_FLOAT3, "position"); - float* normals = (float*)CustomData_get_layer(&mesh->ldata, CD_NORMAL); - int* mat_indices = (int*)CustomData_get_layer_named(&mesh->pdata, CD_PROP_INT32, "material_index"); + int* loop_verts = (int*)CustomData_get_layer_named(&mesh->loop_data, CD_PROP_INT32, ".corner_vert"); + float* positions = (float*)CustomData_get_layer_named(&mesh->vert_data, CD_PROP_FLOAT3, "position"); + float* normals = (float*)CustomData_get_layer(&mesh->loop_data, CD_NORMAL); + int* mat_indices = (int*)CustomData_get_layer_named(&mesh->face_data, CD_PROP_INT32, "material_index"); for(int i = 0; i < mesh->totloop; i++) { @@ -121,7 +121,7 @@ EXPORT void retrieve_mesh_data(void* in_mesh, void* in_loop_tris, int* in_loop_t EXPORT float* mesh_tangents_ptr(void* in_mesh) { Mesh* mesh = (Mesh*)in_mesh; - float* ptr = (float*)CustomData_get_layer(&mesh->ldata, CD_MLOOPTANGENT); + float* ptr = (float*)CustomData_get_layer(&mesh->loop_data, CD_MLOOPTANGENT); return ptr; } @@ -140,7 +140,7 @@ EXPORT void pack_tangents(float* in_tangents, float* in_bitangent_signs, int loo EXPORT bool has_flat_polys(void* in_mesh, int polys_count) { Mesh* mesh = (Mesh*)in_mesh; - const bool *sharp_faces = (bool*)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, "sharp_face"); + const bool *sharp_faces = (bool*)CustomData_get_layer_named(&mesh->face_data, CD_PROP_BOOL, "sharp_face"); for(int i = 0; i < polys_count; i++) { diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h index d5fa9f46..68cd6a7b 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h @@ -1,5 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -105,8 +106,11 @@ typedef struct IDPropertyUIDataString { typedef struct IDPropertyUIDataID { IDPropertyUIData base; /** - * #ID_Type. This type is not enforced. It is just a hint to the ui for what kind of ID is - * expected. If this is zero, any id type is expected. + * #ID_Type. With python-defined properties, this type is not enforced. A value of `0` means any + * ID type. + * + * However, when defined/edited from the UI (Custom Properties panel), it must/will be defined, + * as generic 'Any ID type' selection is a TODO UI-wise. */ short id_type; char _pad[6]; @@ -243,6 +247,11 @@ typedef struct IDOverrideLibraryPropertyOperation { char *subitem_local_name; int subitem_reference_index; int subitem_local_index; + /** Additional pointer to an ID. Only used and relevant when the related RNA collection stores ID + * pointers, to help disambiguate cases where several IDs from different libraries have the exact + * same name. */ + struct ID *subitem_reference_id; + struct ID *subitem_local_id; } IDOverrideLibraryPropertyOperation; /* IDOverrideLibraryPropertyOperation->operation. */ @@ -277,6 +286,12 @@ enum { * reference linked data. */ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE = 1 << 8, + /** + * For overrides of ID pointers within RNA collections: this override is using the ID + * pointer in addition to the item name (to fully disambiguate the reference, since IDs from + * different libraries can have a same name). + */ + LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID = 1 << 9, }; /** A single overridden property, contain all operations on this one. */ @@ -352,7 +367,8 @@ typedef struct IDOverrideLibrary { /** List of IDOverrideLibraryProperty structs. */ ListBase properties; - /** Override hierarchy root ID. Usually the actual root of the hierarchy, but not always + /** + * Override hierarchy root ID. Usually the actual root of the hierarchy, but not always * in degenerated cases. * * All liboverrides of a same hierarchy (e.g. a character collection) share the same root. @@ -509,7 +525,7 @@ typedef struct Library_Runtime { /** * For each library file used, a Library struct is added to Main - * WARNING: readfile.c, expand_doit() reads this struct without DNA check! + * WARNING: `readfile.cc`, expand_doit() reads this struct without DNA check! */ typedef struct Library { ID id; @@ -588,6 +604,10 @@ enum { PRV_TAG_DEFFERED_DELETE = (1 << 2), }; +/** + * This type allows shallow copies. Use #BKE_previewimg_free() to release contained resources. + * Don't call this for shallow copies (or the original instance will have dangling pointers). + */ typedef struct PreviewImage { /* All values of 2 are really NUM_ICON_SIZES */ unsigned int w[2]; @@ -604,12 +624,17 @@ typedef struct PreviewImage { /** Runtime data. */ short tag; char _pad[2]; -} PreviewImage; -#define PRV_DEFERRED_DATA(prv) \ - (CHECK_TYPE_INLINE(prv, PreviewImage *), \ - BLI_assert((prv)->tag & PRV_TAG_DEFFERED), \ - (void *)((prv) + 1)) +#ifdef UNDEFINED + PreviewImage(); + /* Shallow copy! Contained data is not copied. */ + PreviewImage(const PreviewImage &) = default; + /* Don't free contained data to allow shallow copies. */ + ~PreviewImage() = default; + /* Shallow copy! Contained data is not copied. */ + PreviewImage &operator=(const PreviewImage &) = default; +#endif +} PreviewImage; #define ID_FAKE_USERS(id) ((((const ID *)id)->flag & LIB_FAKEUSER) ? 1 : 0) #define ID_REAL_USERS(id) (((const ID *)id)->us - ID_FAKE_USERS(id)) @@ -680,7 +705,7 @@ typedef struct PreviewImage { (void *)((ID *)(_id))->newid) #define ID_NEW_REMAP(a) \ if ((a) && (a)->id.newid) { \ - (a) = (void *)(a)->id.newid; \ + *(void **)&(a) = (a)->id.newid; \ } \ ((void)0) @@ -830,7 +855,7 @@ enum { * * RESET_AFTER_USE * - * \note Also used internally in readfile.c to mark data-blocks needing do_versions. + * \note Also used internally in `readfile.cc` to mark data-blocks needing do_versions. */ LIB_TAG_NEW = 1 << 12, /** @@ -842,22 +867,22 @@ enum { LIB_TAG_PRE_EXISTING = 1 << 13, /** - * Tag used internally in readfile.c, to mark IDs needing to be expanded (only done once). + * Tag used internally in `readfile.cc`, to mark IDs needing to be expanded (only done once). * * RESET_AFTER_USE */ LIB_TAG_NEED_EXPAND = 1 << 14, /** - * Tag used internally in readfile.c, to mark ID placeholders for linked data-blocks needing to - * be read. + * Tag used internally in `readfile.cc`, to mark ID placeholders for linked data-blocks needing + * to be read. * * RESET_AFTER_USE */ LIB_TAG_ID_LINK_PLACEHOLDER = 1 << 15, /** - * Tag used internally in readfile.c, to mark IDs needing to be 'lib-linked', i.e. to get their - * pointers to other data-blocks updated from the 'UID' values stored in .blend files to the new, - * actual pointers. + * Tag used internally in `readfile.cc`, to mark IDs needing to be 'lib-linked', i.e. to get + * their pointers to other data-blocks updated from the 'UID' values stored in `.blend` files to + * the new, actual pointers. * * RESET_AFTER_USE */ @@ -872,12 +897,23 @@ enum { */ LIB_TAG_UNDO_OLD_ID_REUSED_UNCHANGED = 1 << 17, /** - * ID has be re-read in-place, the ID address is the same as in the old BMain, but the content is + * ID is being re-used from the old Main (instead of read from memfile), during memfile undo + * processing, because it is a 'NO_UNDO' type of ID. + * + * \note: Also means that such ID does not need to be lib-linked during undo readfile process. It + * does need to be relinked in a different way however, doing a `session_uuid`-based lookup into + * the newly read main database. + * + * RESET_AFTER_USE + */ + LIB_TAG_UNDO_OLD_ID_REUSED_NOUNDO = 1 << 18, + /** + * ID has be re-read in-place, the ID address is the same as in the old main, but the content is * different. * * RESET_AFTER_USE */ - LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE = 1 << 18, + LIB_TAG_UNDO_OLD_ID_REREAD_IN_PLACE = 1 << 19, /* ------------------------------------------------------------------------------------------- */ /** @@ -1003,7 +1039,7 @@ typedef enum IDRecalcFlag { ID_RECALC_ANIMATION = (1 << 2), /* ** Particle system changed. ** */ - /* Only do pathcache etc. */ + /* Only do path-cache etc. */ ID_RECALC_PSYS_REDO = (1 << 3), /* Reset everything including point-cache. */ ID_RECALC_PSYS_RESET = (1 << 4), @@ -1018,7 +1054,7 @@ typedef enum IDRecalcFlag { * changed, and the shader is to be recompiled. * For objects it means that the draw batch cache is to be redone. */ ID_RECALC_SHADING = (1 << 7), - /* TODO(sergey): Consider adding an explicit ID_RECALC_SHADING_PARAMATERS + /* TODO(sergey): Consider adding an explicit ID_RECALC_SHADING_PARAMETERS * which can be used for cases when only socket value changed, to speed up * redraw update in that case. */ @@ -1080,11 +1116,13 @@ typedef enum IDRecalcFlag { /* The node tree has changed in a way that affects its output nodes. */ ID_RECALC_NTREE_OUTPUT = (1 << 25), + /* Hierarchy of collection and object within collection changed. */ + ID_RECALC_HIERARCHY = (1 << 26), + /* Provisioned flags. * * Not for actual use. The idea of them is to have all bits of the `IDRecalcFlag` defined to a * known value, silencing sanitizer warnings when checking bits of the ID_RECALC_ALL. */ - ID_RECALC_PROVISION_26 = (1 << 26), ID_RECALC_PROVISION_27 = (1 << 27), ID_RECALC_PROVISION_28 = (1 << 28), ID_RECALC_PROVISION_29 = (1 << 29), @@ -1157,6 +1195,7 @@ typedef enum IDRecalcFlag { #define FILTER_ID_SCR (1ULL << 37) #define FILTER_ID_WM (1ULL << 38) #define FILTER_ID_LI (1ULL << 39) +#define FILTER_ID_GP (1ULL << 40) #define FILTER_ID_ALL \ (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU_LEGACY | \ @@ -1165,7 +1204,7 @@ typedef enum IDRecalcFlag { FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | \ FILTER_ID_SPK | FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | \ FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | \ - FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI) + FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI | FILTER_ID_GP) /** * This enum defines the index assigned to each type of IDs in the array returned by @@ -1237,7 +1276,6 @@ typedef enum eID_Index { /* Simulation-related types. */ INDEX_ID_CF, - INDEX_ID_SIM, INDEX_ID_PA, /* Shape Keys snow-flake, can be used by several obdata types. */ @@ -1256,6 +1294,7 @@ typedef enum eID_Index { INDEX_ID_CA, INDEX_ID_SPK, INDEX_ID_LP, + INDEX_ID_GP, /* Collection and object types. */ INDEX_ID_OB, diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID_enums.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID_enums.h index 7a778b6b..37499b0d 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID_enums.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_ID_enums.h @@ -1,4 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -81,7 +83,7 @@ typedef enum ID_Type { ID_CV = MAKE_ID2('C', 'V'), /* Curves */ ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */ ID_VO = MAKE_ID2('V', 'O'), /* Volume */ - ID_SIM = MAKE_ID2('S', 'I'), /* Simulation (geometry node groups) */ + ID_GP = MAKE_ID2('G', 'P'), /* Grease Pencil */ } ID_Type; /* Only used as 'placeholder' in .blend files for directly linked data-blocks. */ diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_customdata_types.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_customdata_types.h index 756c2f31..59718131 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_customdata_types.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_customdata_types.h @@ -1,5 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -11,9 +12,7 @@ #include "DNA_defs.h" -#ifdef UNDEFINED -extern "C" { -#endif +//#include "BLI_implicit_sharing.h" /** Workaround to forward-declare C++ type in C header. */ #ifdef UNDEFINED @@ -82,8 +81,7 @@ typedef struct CustomData { * MUST be >= CD_NUMTYPES, but we can't use a define here. * Correct size is ensured in CustomData_update_typemap assert(). */ - int typemap[52]; - char _pad[4]; + int typemap[53]; /** Number of layers, size of layers array. */ int totlayer, maxlayer; /** In editmode, total size of all data layers. */ @@ -119,7 +117,9 @@ typedef enum eCustomDataType { * lazily. Derived vertex and polygon normals are stored in #Mesh_Runtime. */ CD_NORMAL = 8, - CD_FACEMAP = 9, /* exclusive face group, each face can only be part of one */ +#ifdef DNA_DEPRECATED_ALLOW + CD_FACEMAP = 9, +#endif CD_PROP_FLOAT = 10, CD_PROP_INT32 = 11, CD_PROP_STRING = 12, @@ -136,17 +136,18 @@ typedef enum eCustomDataType { /* CD_ID_MCOL = 21, */ /* CD_TEXTURE_MLOOPCOL = 22, */ /* UNUSED */ CD_CLOTH_ORCO = 23, - /* CD_RECAST = 24, */ /* UNUSED */ +/* CD_RECAST = 24, */ /* UNUSED */ - CD_MPOLY = 25, #ifdef DNA_DEPRECATED_ALLOW + CD_MPOLY = 25, CD_MLOOP = 26, #endif CD_SHAPE_KEYINDEX = 27, CD_SHAPEKEY = 28, +#ifdef DNA_DEPRECATED_ALLOW CD_BWEIGHT = 29, - /** Subdivision sharpness data per edge or per vertex. */ CD_CREASE = 30, +#endif CD_ORIGSPACE_MLOOP = 31, CD_PREVIEW_MLOOPCOL = 32, CD_BM_ELEM_PYPTR = 33, @@ -174,9 +175,11 @@ typedef enum eCustomDataType { CD_PROP_FLOAT2 = 49, CD_PROP_BOOL = 50, - CD_HAIRLENGTH = 51, + /* CD_HAIRLENGTH = 51, */ /* UNUSED */ - CD_NUMTYPES = 52, + CD_PROP_QUATERNION = 52, + + CD_NUMTYPES = 53, } eCustomDataType; /* Bits for eCustomDataMask */ @@ -186,7 +189,6 @@ typedef enum eCustomDataType { #define CD_MASK_MCOL (1 << CD_MCOL) #define CD_MASK_ORIGINDEX (1 << CD_ORIGINDEX) #define CD_MASK_NORMAL (1 << CD_NORMAL) -#define CD_MASK_FACEMAP (1 << CD_FACEMAP) #define CD_MASK_PROP_FLOAT (1 << CD_PROP_FLOAT) #define CD_MASK_PROP_INT32 (1 << CD_PROP_INT32) #define CD_MASK_PROP_STRING (1 << CD_PROP_STRING) @@ -200,8 +202,6 @@ typedef enum eCustomDataType { #define CD_MASK_SHAPE_KEYINDEX (1 << CD_SHAPE_KEYINDEX) #define CD_MASK_SHAPEKEY (1 << CD_SHAPEKEY) -#define CD_MASK_BWEIGHT (1 << CD_BWEIGHT) -#define CD_MASK_CREASE (1 << CD_CREASE) #define CD_MASK_ORIGSPACE_MLOOP (1LL << CD_ORIGSPACE_MLOOP) #define CD_MASK_PREVIEW_MLOOPCOL (1LL << CD_PREVIEW_MLOOPCOL) #define CD_MASK_BM_ELEM_PYPTR (1LL << CD_BM_ELEM_PYPTR) @@ -220,8 +220,7 @@ typedef enum eCustomDataType { #define CD_MASK_PROP_BOOL (1ULL << CD_PROP_BOOL) #define CD_MASK_PROP_INT8 (1ULL << CD_PROP_INT8) #define CD_MASK_PROP_INT32_2D (1ULL << CD_PROP_INT32_2D) - -#define CD_MASK_HAIRLENGTH (1ULL << CD_HAIRLENGTH) +#define CD_MASK_PROP_QUATERNION (1ULL << CD_PROP_QUATERNION) /** Multi-resolution loop data. */ #define CD_MASK_MULTIRES_GRIDS (CD_MASK_MDISPS | CD_GRID_PAINT_MASK) @@ -233,7 +232,7 @@ typedef enum eCustomDataType { #define CD_MASK_PROP_ALL \ (CD_MASK_PROP_FLOAT | CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | \ CD_MASK_PROP_COLOR | CD_MASK_PROP_STRING | CD_MASK_PROP_BYTE_COLOR | CD_MASK_PROP_BOOL | \ - CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D) + CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION) /* All color attributes */ #define CD_MASK_COLOR_ALL (CD_MASK_PROP_COLOR | CD_MASK_PROP_BYTE_COLOR) @@ -267,7 +266,3 @@ enum { #define MAX_MTFACE 8 #define DYNTOPO_NODE_NONE -1 - -#ifdef UNDEFINED -} -#endif diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_defs.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_defs.h index 3378e498..a76577f7 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_defs.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_defs.h @@ -1,4 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -8,7 +10,7 @@ #pragma once -/* makesdna ignores */ +/* `makesdna` ignores. */ #ifdef DNA_DEPRECATED_ALLOW /* allow use of deprecated items */ # define DNA_DEPRECATED @@ -68,6 +70,7 @@ * Avoids pulling `string.h` from this header to get access to #memcpy. */ extern "C" void _DNA_internal_memcpy(void *dst, const void *src, size_t size); extern "C" void _DNA_internal_memzero(void *dst, size_t size); +extern "C" void _DNA_internal_swap(void *a, void *b, size_t size); namespace blender::dna::internal { @@ -131,12 +134,17 @@ namespace blender::dna { * * From the implementation detail go via copy constructor/assign operator defined in the structure. */ -template +template [[nodiscard]] inline internal::ShallowDataConstRef shallow_copy(const T &other) { return internal::ShallowDataConstRef(other); } +template inline void shallow_copy_array(T *dst, const T *src, const int64_t size) +{ + _DNA_internal_memcpy(dst, src, sizeof(T) * size_t(size)); +} + /* DNA object initializer which leads to an object which underlying memory is filled with zeroes. */ [[nodiscard]] inline internal::ShallowZeroInitializeTag shallow_zero_initialize() @@ -144,6 +152,11 @@ template return internal::ShallowZeroInitializeTag(); } +template inline void shallow_swap(T &a, T &b) +{ + _DNA_internal_swap(&a, &b, sizeof(T)); +} + } // namespace blender::dna #endif diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_listBase.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_listBase.h index ae80c81e..c316a375 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_listBase.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_listBase.h @@ -1,5 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -11,10 +12,6 @@ #pragma once -#ifdef UNDEFINED -extern "C" { -#endif - /** Generic - all structs which are put into linked lists begin with this. */ typedef struct Link { struct Link *next, *prev; @@ -26,13 +23,9 @@ typedef struct LinkData { void *data; } LinkData; -/** Never change the size of this! dna_genfile.c detects pointer_size with it. */ +/** Never change the size of this! dna_genfile.cc detects pointer_size with it. */ typedef struct ListBase { void *first, *last; } ListBase; /* 8 byte alignment! */ - -#ifdef UNDEFINED -} -#endif diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_mesh_types.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_mesh_types.h index f29e30f0..61919bc6 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_mesh_types.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_mesh_types.h @@ -1,5 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -16,6 +17,8 @@ /** Workaround to forward-declare C++ type in C header. */ #ifdef UNDEFINED +# include + # include "BLI_bounds_types.hh" # include "BLI_math_vector_types.hh" # include "BLI_offset_indices.hh" @@ -36,10 +39,6 @@ using MeshRuntimeHandle = blender::bke::MeshRuntime; typedef struct MeshRuntimeHandle MeshRuntimeHandle; #endif -#ifdef UNDEFINED -extern "C" { -#endif - struct AnimData; struct Ipo; struct Key; @@ -67,28 +66,31 @@ typedef struct Mesh { */ struct Material **mat; - /** The number of vertices in the mesh, and the size of #vdata. */ + /** The number of vertices in the mesh, and the size of #vert_data. */ int totvert; - /** The number of edges in the mesh, and the size of #edata. */ + /** The number of edges in the mesh, and the size of #edge_data. */ int totedge; - /** The number of polygons/faces in the mesh, and the size of #pdata. */ - int totpoly; - /** The number of face corners in the mesh, and the size of #ldata. */ + /** The number of polygons/faces in the mesh, and the size of #face_data. */ + int faces_num; + /** The number of face corners in the mesh, and the size of #loop_data. */ int totloop; /** - * Array owned by mesh. See #Mesh::polys() and #OffsetIndices. + * Array owned by mesh. See #Mesh::faces() and #OffsetIndices. * * This array is shared based on the bke::MeshRuntime::poly_offsets_sharing_info. * Avoid accessing directly when possible. */ - int *poly_offset_indices; + int *face_offset_indices; - CustomData vdata, edata, pdata, ldata; + CustomData vert_data; + CustomData edge_data; + CustomData face_data; + CustomData loop_data; /** * List of vertex group (#bDeformGroup) names and flags only. Actual weights are stored in dvert. - * \note This pointer is for convenient access to the #CD_MDEFORMVERT layer in #vdata. + * \note This pointer is for convenient access to the #CD_MDEFORMVERT layer in #vert_data. */ ListBase vertex_group_names; /** The active index in the #vertex_group_names list. */ @@ -214,9 +216,9 @@ typedef struct Mesh { * \note This would be marked deprecated, however the particles still use this at run-time * for placing particles on the mesh (something which should be eventually upgraded). */ - CustomData fdata; + CustomData fdata_legacy; /* Deprecated size of #fdata. */ - int totface; + int totface_legacy; char _pad1[4]; @@ -236,7 +238,7 @@ typedef struct Mesh { blender::MutableSpan vert_positions_for_write(); /** * Array of edges, containing vertex indices, stored in the ".edge_verts" attributes. For simple - * triangle or quad meshes, edges could be calculated from the polygon and "corner edge" arrays, + * triangle or quad meshes, edges could be calculated from the face and "corner edge" arrays, * however, edges need to be stored explicitly to edge domain attributes and to support loose * edges that aren't connected to faces. */ @@ -245,26 +247,26 @@ typedef struct Mesh { blender::MutableSpan edges_for_write(); /** * Face topology storage of the offset of each face's section of the face corners. The size of - * each polygon is encoded using the next offset value. Can be used to slice the #corner_verts or + * each face is encoded using the next offset value. Can be used to slice the #corner_verts or * #corner_edges arrays to find the vertices or edges that make up each face. */ - blender::OffsetIndices polys() const; + blender::OffsetIndices faces() const; /** - * Index of the first corner of each polygon, and the size of the polygon encoded as the next + * Index of the first corner of each face, and the size of the face encoded as the next * offset. The total number of corners is the final value, and the first value is always zero. * May be empty if there are no polygons. */ - blender::Span poly_offsets() const; + blender::Span face_offsets() const; /** Write access to #poly_offsets data. */ - blender::MutableSpan poly_offsets_for_write(); + blender::MutableSpan face_offsets_for_write(); /** * Array of vertices for every face corner, stored in the ".corner_vert" integer attribute. * For example, the vertices in a face can be retrieved with the #slice method: * \code{.cc} - * const Span poly_verts = corner_verts.slice(poly.loopstart, poly.totloop); + * const Span poly_verts = corner_verts.slice(face); * \endcode - * Such a span can often be passed as an argument in lieu of a polygon and the entire corner + * Such a span can often be passed as an argument in lieu of a polygon or the entire corner * verts array. */ blender::Span corner_verts() const; @@ -299,11 +301,34 @@ typedef struct Mesh { /** * A map containing the face index that each cached triangle from #Mesh::looptris() came from. */ - blender::Span looptri_polys() const; + blender::Span looptri_faces() const; + + /** + * Calculate the largest and smallest position values of vertices. + * \note Does not take non-mesh data (edit mesh) into account, see #BKE_mesh_wrapper_minmax, + */ + std::optional> bounds_min_max() const; /** Set cached mesh bounds to a known-correct value to avoid their lazy calculation later on. */ void bounds_set_eager(const blender::Bounds &bounds); + /** + * Cached map containing the index of the face using each face corner. + */ + blender::Span corner_to_face_map() const; + /** + * Offsets per vertex used to slice arrays containing data for connected faces or face corners. + */ + blender::OffsetIndices vert_to_face_map_offsets() const; + /** + * Cached map from each vertex to the corners using it. + */ + blender::GroupedSpan vert_to_corner_map() const; + /** + * Cached map from each vertex to the faces using it. + */ + blender::GroupedSpan vert_to_face_map() const; + /** * Cached information about loose edges, calculated lazily when necessary. */ @@ -324,12 +349,12 @@ typedef struct Mesh { * \note To allow setting this status on meshes without changing them, this does not tag the * cache dirty. If the mesh was changed first, the relevant dirty tags should be called first. */ - void loose_edges_tag_none() const; + void tag_loose_edges_none() const; /** - * Set the number of vertices not connected to edges to zero. Similar to #loose_edges_tag_none(). + * Set the number of vertices not connected to edges to zero. Similar to #tag_loose_edges_none(). * There may still be vertices only used by loose edges though. * - * \note If both #loose_edges_tag_none() and #tag_loose_verts_none() are called, + * \note If both #tag_loose_edges_none() and #tag_loose_verts_none() are called, * all vertices are used by faces, so #verts_no_faces() will be tagged empty as well. */ void tag_loose_verts_none() const; @@ -337,7 +362,7 @@ typedef struct Mesh { /** * Normal direction of polygons, defined by positions and the winding direction of face corners. */ - blender::Span poly_normals() const; + blender::Span face_normals() const; /** * Normal direction of vertices, defined as the weighted average of face normals * surrounding each vertex and the normalized position for loose vertices. @@ -440,7 +465,3 @@ typedef enum eMeshSymmetryType { } eMeshSymmetryType; #define MESH_MAX_VERTS 2000000000L - -#ifdef UNDEFINED -} -#endif diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_meshdata_types.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_meshdata_types.h index 5a977c8d..095d2bd8 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_meshdata_types.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_meshdata_types.h @@ -1,5 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -7,12 +8,7 @@ #pragma once -#include "DNA_customdata_types.h" -#include "DNA_listBase.h" - -#ifdef UNDEFINED -extern "C" { -#endif +#include "BLI_sys_types.h" /* -------------------------------------------------------------------- */ /** \name Ordered Selection Storage @@ -52,11 +48,11 @@ enum { * any changes to the underlying mesh invalidate the #MLoopTri array, * which will need to be re-calculated. * - * Users normally access this via #BKE_mesh_runtime_looptri_ensure. - * In rare cases its calculated directly, with #BKE_mesh_recalc_looptri. + * Users normally access this via #Mesh::looptris(). + * In rare cases its calculated directly, with #bke::mesh::looptris_calc. * * Typical usage includes: - * - OpenGL drawing. + * - Viewport drawing. * - #BVHTree creation. * - Physics/collision detection. * @@ -86,15 +82,15 @@ enum { * * #MLoopTri's are allocated in an array, where each polygon's #MLoopTri's are stored contiguously, * the number of triangles for each polygon is guaranteed to be the corner count - 2, - * even for degenerate geometry. See #ME_POLY_TRI_TOT macro. + * even for degenerate geometry. See #bke::mesh::face_triangles_num macro. * - * It's also possible to perform a reverse lookup (find all #MLoopTri's for any given poly). + * It's also possible to perform a reverse lookup (find all #MLoopTri's for any given face). * * \code{.c} * // loop over all looptri's for a given polygon: i - * const IndexRange poly = polys[i]; - * MLoopTri *lt = &looptri[poly_to_tri_count(i, poly.start())]; - * int j, lt_tot = ME_POLY_TRI_TOT(poly.size()); + * const IndexRange face = faces[i]; + * MLoopTri *lt = &looptri[poly_to_tri_count(i, face.start())]; + * int j, lt_tot = bke::mesh::face_triangles_num(face.size()); * * for (j = 0; j < lt_tot; j++, lt++) { * int vtri[3] = { @@ -213,12 +209,14 @@ typedef struct MVertSkin { } MVertSkin; typedef enum eMVertSkinFlag { - /** Marks a vertex as the edge-graph root, used for calculating rotations for all connected + /** + * Marks a vertex as the edge-graph root, used for calculating rotations for all connected * edges (recursively). Also used to choose a root when generating an armature. */ MVERT_SKIN_ROOT = 1, - /** Marks a branch vertex (vertex with more than two connected edges), so that its neighbors + /** + * Marks a branch vertex (vertex with more than two connected edges), so that its neighbors * are directly hulled together, rather than the default of generating intermediate frames. */ MVERT_SKIN_LOOSE = 2, @@ -323,25 +321,6 @@ enum { /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Utility Macros - * \{ */ - -/** Number of tri's that make up this polygon once tessellated. */ -#define ME_POLY_TRI_TOT(size) (size - 2) - -/** - * Check out-of-bounds material, note that this is nearly always prevented, - * yet its still possible in rare cases. - * So usage such as array lookup needs to check. - */ -#define ME_MAT_NR_TEST(mat_nr, totmat) \ - (CHECK_TYPE_ANY(mat_nr, short, const short), \ - CHECK_TYPE_ANY(totmat, short, const short), \ - (LIKELY(mat_nr < totmat) ? mat_nr : 0)) - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Deprecated Structs * \{ */ @@ -356,7 +335,7 @@ enum { typedef struct MEdge { /** Un-ordered vertex indices (cannot match). */ unsigned int v1, v2; - /** Deprecated edge crease, now located in #CD_CREASE, except for file read and write. */ + /** Deprecated edge crease, now located in `edge_crease`, except for file read and write. */ char crease_legacy; /** * Deprecated bevel weight storage, now located in #CD_BWEIGHT, except for file read and write. @@ -383,7 +362,7 @@ enum { * This only stores the polygon size & flags, the vertex & edge indices are stored in the "corner * edges" array. * - * Typically accessed with #Mesh.polys(). + * Typically accessed with #Mesh.faces(). */ typedef struct MPoly { /** Offset into loop array and number of loops in the face. */ @@ -461,7 +440,7 @@ typedef struct MLoop { #endif /** - * Used in Blender pre 2.63, See #Mesh::corner_verts(), #Mesh::polys() for face data stored in the + * Used in Blender pre 2.63, See #Mesh::corner_verts(), #Mesh::faces() for face data stored in the * blend file. Use for reading old files and in a handful of cases which should be removed * eventually. */ @@ -495,35 +474,13 @@ typedef struct MCol { unsigned char a, r, g, b; } MCol; -#define MESH_MLOOPCOL_FROM_MCOL(_mloopcol, _mcol) \ - { \ - MLoopCol *mloopcol__tmp = _mloopcol; \ - const MCol *mcol__tmp = _mcol; \ - mloopcol__tmp->r = mcol__tmp->b; \ - mloopcol__tmp->g = mcol__tmp->g; \ - mloopcol__tmp->b = mcol__tmp->r; \ - mloopcol__tmp->a = mcol__tmp->a; \ - } \ - (void)0 - -#define MESH_MLOOPCOL_TO_MCOL(_mloopcol, _mcol) \ - { \ - const MLoopCol *mloopcol__tmp = _mloopcol; \ - MCol *mcol__tmp = _mcol; \ - mcol__tmp->b = mloopcol__tmp->r; \ - mcol__tmp->g = mloopcol__tmp->g; \ - mcol__tmp->r = mloopcol__tmp->b; \ - mcol__tmp->a = mloopcol__tmp->a; \ - } \ - (void)0 +#ifdef DNA_DEPRECATED_ALLOW /** Old game engine recast navigation data, while unused 2.7x files may contain this. */ typedef struct MRecast { int i; } MRecast; -/** \} */ - -#ifdef UNDEFINED -} #endif + +/** \} */ diff --git a/BlenderMalt/CBlenderMalt/blender_dna/DNA_session_uuid_types.h b/BlenderMalt/CBlenderMalt/blender_dna/DNA_session_uuid_types.h index 3cec8868..a68dcdb4 100644 --- a/BlenderMalt/CBlenderMalt/blender_dna/DNA_session_uuid_types.h +++ b/BlenderMalt/CBlenderMalt/blender_dna/DNA_session_uuid_types.h @@ -1,4 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup DNA @@ -8,22 +10,17 @@ #include "BLI_sys_types.h" -#ifdef UNDEFINED -extern "C" { -#endif - -/* Is a structure because of the following considerations: +/** + * Is a structure because of the following considerations: * - * - It is not possible to use custom types in DNA members: makesdna does not recognize them. + * - It is not possible to use custom types in DNA members: `makesdna` does not recognize them. * - It allows to add more bits, more than standard fixed-size types can store. For example, if * we ever need to go 128 bits, it is as simple as adding extra 64bit field. */ typedef struct SessionUUID { - /* Never access directly, as it might cause a headache when more bits are needed: if the field - * is used directly it will not be easy to find all places where partial access is used. */ + /** + * Never access directly, as it might cause a headache when more bits are needed: if the field + * is used directly it will not be easy to find all places where partial access is used. + */ uint64_t uuid_; } SessionUUID; - -#ifdef UNDEFINED -} -#endif diff --git a/BlenderMalt/MaltNodes/MaltNode.py b/BlenderMalt/MaltNodes/MaltNode.py index 64455e7e..685daeb1 100644 --- a/BlenderMalt/MaltNodes/MaltNode.py +++ b/BlenderMalt/MaltNodes/MaltNode.py @@ -248,9 +248,9 @@ def get_input_parameter_name(self, key): def should_delete_outdated_links(self): return False - def calc_node_width(self, point_size, dpi) -> float: + def calc_node_width(self, point_size) -> float: import blf - blf.size(0, point_size, dpi) + blf.size(0, point_size) header_padding = 36 # account for a little space for the arrow icon + extra padding on the side of a label socket_padding = 31 # account for little offset of the text from the node border @@ -271,8 +271,7 @@ def adjust_width(width, text, scale=1, padding=0): def setup_width(self): point_size = bpy.context.preferences.ui_styles[0].widget_label.points - dpi = 72 #dont use bpy.context.preferences.system.dpi because that is influenced by the UI scale but the node widths are not - self.width = self.calc_node_width(point_size, dpi) + self.width = self.calc_node_width(point_size) def get_source_name(self): return self.id_data.get_transpiler().get_source_name(self.internal_name) diff --git a/BlenderMalt/MaltNodes/Nodes/MaltFunctionSubCategory.py b/BlenderMalt/MaltNodes/Nodes/MaltFunctionSubCategory.py index 301dba86..8470aff9 100644 --- a/BlenderMalt/MaltNodes/Nodes/MaltFunctionSubCategory.py +++ b/BlenderMalt/MaltNodes/Nodes/MaltFunctionSubCategory.py @@ -50,10 +50,10 @@ def draw_buttons(self, context, layout): r.operator('wm.malt_cycle_sub_categories', text='', icon='COLLAPSEMENU') return super().draw_buttons(context, layout) - def calc_node_width(self, point_size, dpi) -> float: + def calc_node_width(self, point_size) -> float: import blf - blf.size(0, point_size, dpi) - max_width = super().calc_node_width(point_size, dpi) + blf.size(0, point_size) + max_width = super().calc_node_width(point_size) layout_padding = 70 # account for the spaces on both sides of the enum dropdown label = next(enum[1] for enum in self.get_function_enums() if enum[0]==self.function_enum) return max(max_width, blf.dimensions(0, label)[0] + layout_padding) diff --git a/BlenderMalt/__init__.py b/BlenderMalt/__init__.py index 99ec4a73..2e1263cb 100644 --- a/BlenderMalt/__init__.py +++ b/BlenderMalt/__init__.py @@ -2,8 +2,8 @@ "name": "BlenderMalt", "description" : "Extensible Python Render Engine", "author" : "Miguel Pozo", - "version": (1,0,0,'beta.3','Release'), - "blender" : (3, 6, 0), + "version": (1,0,0,'Release'), + "blender" : (4, 0, 0), "doc_url": "https://malt3d.com", "tracker_url": "https://github.com/bnpr/Malt/issues/new/choose", "category": "Render" From e6c504a8f6fd4828488165e56d65feb2285f646d Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 29 Nov 2023 00:35:10 +0100 Subject: [PATCH 2/2] Update Release text --- .github/workflows/BlenderMalt.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BlenderMalt.yml b/.github/workflows/BlenderMalt.yml index 14db2161..b3193334 100644 --- a/.github/workflows/BlenderMalt.yml +++ b/.github/workflows/BlenderMalt.yml @@ -33,7 +33,7 @@ jobs: [**BlenderMalt-Windows.zip**](https://github.com/${{github.repository}}/releases/download/${{env.BRANCH_NAME}}-latest/BlenderMalt-Windows.zip) [**BlenderMalt-Linux.zip**](https://github.com/${{github.repository}}/releases/download/${{env.BRANCH_NAME}}-latest/BlenderMalt-Linux.zip) - *(Requires Blender 3.6)* + *(Requires Blender 4.0)* - name: Rollback Tagged Release uses: author/action-rollback@stable @@ -56,7 +56,7 @@ jobs: [**BlenderMalt-Windows.zip**](https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/BlenderMalt-Windows.zip) [**BlenderMalt-Linux.zip**](https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/BlenderMalt-Linux.zip) - *(Requires Blender 3.6)* + *(Requires Blender 4.0)* outputs: upload_url: ${{ steps.create_release.outputs.upload_url }}