Skip to content

Commit

Permalink
Merge branch 'Development' into node-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
pragma37 committed Nov 15, 2023
2 parents f9a05cd + f7e8a92 commit 2c9d228
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 199 deletions.
12 changes: 6 additions & 6 deletions BlenderMalt/CBlenderMalt/CBlenderMalt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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;
}
Expand All @@ -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++)
{
Expand Down
91 changes: 65 additions & 26 deletions BlenderMalt/CBlenderMalt/blender_dna/DNA_ID.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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))
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
/**
Expand All @@ -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
*/
Expand All @@ -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,

/* ------------------------------------------------------------------------------------------- */
/**
Expand Down Expand Up @@ -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),
Expand All @@ -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. */

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 | \
Expand All @@ -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
Expand Down Expand Up @@ -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. */
Expand All @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions BlenderMalt/CBlenderMalt/blender_dna/DNA_ID_enums.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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. */
Expand Down
Loading

0 comments on commit 2c9d228

Please sign in to comment.