diff options
author | Sergey Sharybin <sergey@blender.org> | 2020-11-12 11:26:20 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2020-11-12 11:26:20 +0300 |
commit | de6cee4fc1913982b0b2bd786bfd813c935bbe73 (patch) | |
tree | a726c0c63bbd1d6c47c90c32119ce14c8048cddc /source/blender/makesdna | |
parent | e4d432500a0e2f978fe019da43deb843da405032 (diff) | |
parent | 88bb29dea668df8cc46aa7f55895f229748bdbb4 (diff) |
Merge branch 'master' into codesign_error_tracker
Diffstat (limited to 'source/blender/makesdna')
60 files changed, 3394 insertions, 1068 deletions
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index e16a22f5459..f2d860a2851 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -130,6 +130,11 @@ enum { * Should only be used/be relevant for custom properties. */ IDP_FLAG_OVERRIDABLE_LIBRARY = 1 << 0, + /** This collection item IDProp has been inserted in a local override. + * This is used by internal code to distinguish between library-originated items and + * local-inserted ones, as many operations are not allowed on the former. */ + IDP_FLAG_OVERRIDELIBRARY_LOCAL = 1 << 1, + /** This means the property is set but RNA will return false when checking * 'RNA_property_is_set', currently this is a runtime flag */ IDP_FLAG_GHOST = 1 << 7, @@ -300,6 +305,7 @@ typedef struct ID { /** * Only set for data-blocks which are coming from copy-on-write, points to * the original version of it. + * Also used temporarily during memfile undo to keep a reference to old ID when found. */ struct ID *orig_id; @@ -441,7 +447,7 @@ typedef enum ID_Type { ID_HA = MAKE_ID2('H', 'A'), /* Hair */ ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */ ID_VO = MAKE_ID2('V', 'O'), /* Volume */ - ID_SIM = MAKE_ID2('S', 'I'), /* Simulation */ + ID_SIM = MAKE_ID2('S', 'I'), /* Simulation (currently unused) */ } ID_Type; /* Only used as 'placeholder' in .blend files for directly linked data-blocks. */ @@ -511,8 +517,10 @@ typedef enum ID_Type { ((ID *)(_id))->newid->tag |= LIB_TAG_NEW, \ (void *)((ID *)(_id))->newid) #define ID_NEW_REMAP(a) \ - if ((a) && (a)->id.newid) \ - (a) = (void *)(a)->id.newid + if ((a) && (a)->id.newid) { \ + (a) = (void *)(a)->id.newid; \ + } \ + ((void)0) /** id->flag (persitent). */ enum { @@ -621,7 +629,7 @@ typedef enum IDRecalcFlag { /* ** Object geometry changed. ** * - * When object of armature type gets tagged with this flag, it's pose is + * When object of armature type gets tagged with this flag, its pose is * re-evaluated. * When object of other type is tagged with this flag it makes the modifier * stack to be re-evaluated. diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 6e590001aff..790a7a36288 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -697,7 +697,7 @@ typedef enum eAction_Flags { typedef struct bDopeSheet { /** Currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil). */ ID *source; - /** Cache for channels (only initialized when pinned). */ // XXX not used! + /** Cache for channels (only initialized when pinned). */ /* XXX not used! */ ListBase chanbase; /** Object group for option to only include objects that belong to this Collection. */ @@ -796,6 +796,8 @@ typedef enum eDopeSheet_Flag { ADS_FLAG_FUZZY_NAMES = (1 << 2), /** do not sort datablocks (mostly objects) by name (NOTE: potentially expensive operation) */ ADS_FLAG_NO_DB_SORT = (1 << 3), + /** Invert the search filter */ + ADS_FLAG_INVERT_FILTER = (1 << 4), } eDopeSheet_Flag; typedef struct SpaceAction_Runtime { @@ -847,7 +849,7 @@ typedef enum eSAction_Flag { /* draw time in seconds instead of time in frames */ SACTION_DRAWTIME = (1 << 2), /* don't filter action channels according to visibility */ - // SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system + // SACTION_NOHIDE = (1 << 3), /* XXX deprecated... old animation systems. */ /* don't kill overlapping keyframes after transform */ SACTION_NOTRANSKEYCULL = (1 << 4), /* don't include keyframes that are out of view */ @@ -855,7 +857,7 @@ typedef enum eSAction_Flag { /* show pose-markers (local to action) in Action Editor mode */ SACTION_POSEMARKERS_SHOW = (1 << 6), /* don't draw action channels using group colors (where applicable) */ - SACTION_NODRAWGCOLORS = (1 << 7), + /* SACTION_NODRAWGCOLORS = (1 << 7), DEPRECATED */ /* SACTION_NODRAWCFRANUM = (1 << 8), DEPRECATED */ /* don't perform realtime updates */ SACTION_NOREALTIMEUPDATES = (1 << 10), diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 858daaac47c..9a31447dacd 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -263,7 +263,7 @@ typedef struct FMod_Noise { /* modification modes */ typedef enum eFMod_Noise_Modifications { - /** Modify existing curve, matching it's shape. */ + /** Modify existing curve, matching its shape. */ FCM_NOISE_MODIF_REPLACE = 0, /** Add noise to the curve. */ FCM_NOISE_MODIF_ADD, @@ -506,7 +506,7 @@ typedef struct ChannelDriver { /** Result of previous evaluation. */ float curval; - // XXX to be implemented... this is like the constraint influence setting + /* XXX to be implemented... this is like the constraint influence setting. */ /** Influence of driver on result. */ float influence; @@ -537,7 +537,7 @@ typedef enum eDriver_Flags { DRIVER_FLAG_INVALID = (1 << 0), DRIVER_FLAG_DEPRECATED = (1 << 1), /** Driver does replace value, but overrides (for layering of animation over driver) */ - // TODO: this needs to be implemented at some stage or left out... + /* TODO: this needs to be implemented at some stage or left out... */ // DRIVER_FLAG_LAYERING = (1 << 2), /** Use when the expression needs to be recompiled. */ DRIVER_FLAG_RECOMPILE = (1 << 3), @@ -550,6 +550,9 @@ typedef enum eDriver_Flags { /* F-Curves -------------------------------------- */ +/** When #active_keyframe_index is set to this, the FCurve does not have an active keyframe. */ +#define FCURVE_ACTIVE_KEYFRAME_NONE -1 + /** * FPoint (fpt) * @@ -587,10 +590,18 @@ typedef struct FCurve { /** Total number of points which define the curve (i.e. size of arrays in FPoints). */ unsigned int totvert; + /** + * Index of active keyframe in #bezt for numerical editing in the interface. A value of + * #FCURVE_ACTIVE_KEYFRAME_NONE indicates that the FCurve has no active keyframe. + * + * Do not access directly, use #BKE_fcurve_active_keyframe_index() and + * #BKE_fcurve_active_keyframe_set() instead. + */ + int active_keyframe_index; + /* value cache + settings */ /** Value stored from last time curve was evaluated (not threadsafe, debug display only!). */ float curval; - char _pad2[4]; /** User-editable settings for this curve. */ short flag; /** Value-extending mode for this curve (does not cover). */ @@ -699,7 +710,7 @@ typedef struct NlaStrip { /** Action that is referenced by this strip (strip is 'user' of the action). */ bAction *act; - /** F-Curves for controlling this strip's influence and timing */ // TODO: move o.ut? + /** F-Curves for controlling this strip's influence and timing */ /* TODO: move out? */ ListBase fcurves; /** F-Curve modifiers to be applied to the entire strip's referenced F-Curves. */ ListBase modifiers; @@ -774,8 +785,8 @@ typedef enum eNlaStrip_Flag { NLASTRIP_FLAG_ACTIVE = (1 << 0), /* NLA strip is selected for editing */ NLASTRIP_FLAG_SELECT = (1 << 1), - // NLASTRIP_FLAG_SELECT_L = (1 << 2), // left handle selected - // NLASTRIP_FLAG_SELECT_R = (1 << 3), // right handle selected + // NLASTRIP_FLAG_SELECT_L = (1 << 2), /* left handle selected. */ + // NLASTRIP_FLAG_SELECT_R = (1 << 3), /* right handle selected. */ /** NLA strip uses the same action that the action being tweaked uses * (not set for the tweaking one though). */ @@ -1047,8 +1058,12 @@ typedef struct AnimOverride { * See blenkernel/intern/anim_sys.c for details. */ typedef struct AnimData { - /** active action - acts as the 'tweaking track' for the NLA */ + /** + * Active action - acts as the 'tweaking track' for the NLA. + * Either use BKE_animdata_set_action() to set this, or call BKE_animdata_action_ensure_idroot() + * after setting. */ bAction *action; + /** temp-storage for the 'real' active action (i.e. the one used before the tweaking-action * took over to be edited in the Animation Editors) */ diff --git a/source/blender/makesdna/DNA_armature_defaults.h b/source/blender/makesdna/DNA_armature_defaults.h new file mode 100644 index 00000000000..c8a54aaee3c --- /dev/null +++ b/source/blender/makesdna/DNA_armature_defaults.h @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name bArmature Struct + * \{ */ + +#define _DNA_DEFAULT_bArmature \ + { \ + .deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE, \ + .flag = ARM_COL_CUSTOM, /* custom bone-group colors */ \ + .layer = 1, \ + .drawtype = ARM_OCTA, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h index 88b2c1e31b8..d5aa87fc8ae 100644 --- a/source/blender/makesdna/DNA_boid_types.h +++ b/source/blender/makesdna/DNA_boid_types.h @@ -46,11 +46,11 @@ typedef enum eBoidRuleType { #if 0 /** go to enemy closest to target and attack when in range */ eBoidRuleType_Protect = 9, - /** find a deflector move to it's other side from closest enemy */ + /** find a deflector move to its other side from closest enemy */ eBoidRuleType_Hide = 10, /** move along a assigned curve or closest curve in a group */ eBoidRuleType_FollowPath = 11, - /** move next to a deflector object's in direction of it's tangent */ + /** move next to a deflector object's in direction of its tangent */ eBoidRuleType_FollowWall = 12, #endif } eBoidRuleType; diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 6c3ffc09919..866c1c44e3f 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -27,10 +27,6 @@ #include "DNA_curve_types.h" #include "DNA_texture_types.h" /* for MTex */ -//#ifndef MAX_MTEX // XXX Not used? -//#define MAX_MTEX 18 -//#endif - struct CurveMapping; struct Image; struct MTex; @@ -187,7 +183,7 @@ typedef enum eGPBrush_Presets { GP_BRUSH_PRESET_DRAW_WEIGHT = 300, } eGPBrush_Presets; -/* BrushGpencilSettings->gp_flag */ +/* BrushGpencilSettings->flag */ typedef enum eGPDbrush_Flag { /* brush use pressure */ GP_BRUSH_USE_PRESSURE = (1 << 0), @@ -359,6 +355,7 @@ typedef enum eBrushClothForceFalloffType { typedef enum eBrushClothSimulationAreaType { BRUSH_CLOTH_SIMULATION_AREA_LOCAL = 0, BRUSH_CLOTH_SIMULATION_AREA_GLOBAL = 1, + BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC = 2, } eBrushClothSimulationAreaType; typedef enum eBrushPoseDeformType { @@ -391,6 +388,7 @@ typedef enum eBrushBoundaryDeformType { BRUSH_BOUNDARY_DEFORM_INFLATE = 2, BRUSH_BOUNDARY_DEFORM_GRAB = 3, BRUSH_BOUNDARY_DEFORM_TWIST = 4, + BRUSH_BOUNDARY_DEFORM_SMOOTH = 5, } eBrushBushBoundaryDeformType; typedef enum eBrushBoundaryFalloffType { @@ -571,10 +569,12 @@ typedef struct Brush { char gpencil_sculpt_tool; /** Active grease pencil weight tool. */ char gpencil_weight_tool; - char _pad1[2]; + char _pad1[6]; float autosmooth_factor; + float tilt_strength_factor; + float topology_rake_factor; float crease_pinch_factor; @@ -775,6 +775,7 @@ typedef enum eBrushFlags2 { BRUSH_POSE_USE_LOCK_ROTATION = (1 << 5), BRUSH_CLOTH_USE_COLLISION = (1 << 6), BRUSH_AREA_RADIUS_PRESSURE = (1 << 7), + BRUSH_GRAB_SILHOUETTE = (1 << 8), } eBrushFlags2; typedef enum { diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h index 55fbb59a161..b0237caa544 100644 --- a/source/blender/makesdna/DNA_camera_defaults.h +++ b/source/blender/makesdna/DNA_camera_defaults.h @@ -37,7 +37,7 @@ #define _DNA_DEFAULT_CameraStereoSettings \ { \ .interocular_distance = 0.065f, \ - .convergence_distance = 30.f * 0.065f, \ + .convergence_distance = 30.0f * 0.065f, \ .pole_merge_angle_from = DEG2RADF(60.0f), \ .pole_merge_angle_to = DEG2RADF(75.0f), \ } diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index bc6991b3249..3d11b3cd7a3 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -105,8 +105,8 @@ typedef struct ClothSimSettings { /* User set volume. This is the volume the mesh wants to expand to (the equilibrium volume). */ float target_volume; /* The scaling factor to apply to the actual pressure. - pressure=( (current_volume/target_volume) - 1 + uniform_pressure_force) * - pressure_factor */ + * pressure=( (current_volume/target_volume) - 1 + uniform_pressure_force) * + * pressure_factor */ float pressure_factor; /* Density of the fluid inside or outside the object for use in the hydrostatic pressure * gradient. */ @@ -177,6 +177,41 @@ typedef struct ClothSimSettings { } ClothSimSettings; +/* SIMULATION FLAGS: goal flags,.. */ +/* These are the bits used in SimSettings.flags. */ +typedef enum { + /** Object is only collision object, no cloth simulation is done. */ + CLOTH_SIMSETTINGS_FLAG_COLLOBJ = (1 << 2), + /** DEPRECATED, for versioning only. */ + CLOTH_SIMSETTINGS_FLAG_GOAL = (1 << 3), + /** True if tearing is enabled. */ + CLOTH_SIMSETTINGS_FLAG_TEARING = (1 << 4), + /** True if pressure sim is enabled. */ + CLOTH_SIMSETTINGS_FLAG_PRESSURE = (1 << 5), + /** Use the user defined target volume. */ + CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL = (1 << 6), + /** True if internal spring generation is enabled. */ + CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS = (1 << 7), + /** DEPRECATED, for versioning only. */ + CLOTH_SIMSETTINGS_FLAG_SCALING = (1 << 8), + /** Require internal springs to be created between points with opposite normals. */ + CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL = (1 << 9), + /** Edit cache in edit-mode. */ + /* CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), */ /* UNUSED */ + /** Don't allow spring compression. */ + CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS = (1 << 13), + /** Pull ends of loose edges together. */ + CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), + /** Make simulation respect deformations in the base object. */ + CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH = (1 << 15), +} CLOTH_SIMSETTINGS_FLAGS; + +/* ClothSimSettings.bending_model. */ +typedef enum { + CLOTH_BENDING_LINEAR = 0, + CLOTH_BENDING_ANGULAR = 1, +} CLOTH_BENDING_MODEL; + typedef struct ClothCollSettings { /** E.g. pointer to temp memory for collisions. */ struct LinkNode *collision_list; @@ -209,3 +244,9 @@ typedef struct ClothCollSettings { /** Impulse clamp for self collisions. */ float self_clamp; } ClothCollSettings; + +/* COLLISION FLAGS */ +typedef enum { + CLOTH_COLLSETTINGS_FLAG_ENABLED = (1 << 1), /* enables cloth - object collisions */ + CLOTH_COLLSETTINGS_FLAG_SELF = (1 << 2), /* enables selfcollisions */ +} CLOTH_COLLISIONSETTINGS_FLAGS; diff --git a/source/blender/makesdna/DNA_collection_defaults.h b/source/blender/makesdna/DNA_collection_defaults.h new file mode 100644 index 00000000000..079c24b04db --- /dev/null +++ b/source/blender/makesdna/DNA_collection_defaults.h @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Collection Struct + * \{ */ + +#define _DNA_DEFAULT_Collection \ + { \ + .color_tag = COLLECTION_COLOR_NONE, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_collection_types.h b/source/blender/makesdna/DNA_collection_types.h index 6cf02137fa6..e188426fdda 100644 --- a/source/blender/makesdna/DNA_collection_types.h +++ b/source/blender/makesdna/DNA_collection_types.h @@ -58,7 +58,9 @@ typedef struct Collection { short flag; /* Runtime-only, always cleared on file load. */ short tag; - char _pad[4]; + + int16_t color_tag; + char _pad[2]; /* Runtime. Cache of objects in this collection and all its * children. This is created on demand when e.g. some physics @@ -92,3 +94,18 @@ enum { * Using a generic tag like LIB_TAG_DOIT for this is just impossible, we need our very own. */ COLLECTION_TAG_RELATION_REBUILD = (1 << 0), }; + +/* Collection->color_tag. */ +typedef enum CollectionColorTag { + COLLECTION_COLOR_NONE = -1, + COLLECTION_COLOR_01, + COLLECTION_COLOR_02, + COLLECTION_COLOR_03, + COLLECTION_COLOR_04, + COLLECTION_COLOR_05, + COLLECTION_COLOR_06, + COLLECTION_COLOR_07, + COLLECTION_COLOR_08, + + COLLECTION_COLOR_TOT, +} CollectionColorTag; diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index cddc78d7640..93a67602047 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -60,7 +60,7 @@ typedef struct bConstraint { /** Constraint name, MAX_NAME. */ char name[64]; - /* Flag for panel and subpanel closed / open state in the UI. */ + /* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */ short ui_expand_flag; /** Amount of influence exherted by constraint (0.0-1.0). */ @@ -337,7 +337,8 @@ typedef struct bActionConstraint { float max; int flag; char mix_mode; - char _pad[7]; + char _pad[3]; + float eval_time; /* Only used when flag ACTCON_USE_EVAL_TIME is set. */ struct bAction *act; /** MAX_ID_NAME-2. */ char subtarget[64]; @@ -689,8 +690,10 @@ typedef enum eBConstraint_Types { /* flag 0x20 (1 << 5) was used to indicate that a constraint was evaluated * using a 'local' hack for posebones only. */ typedef enum eBConstraint_Flags { +#ifdef DNA_DEPRECATED_ALLOW /* Expansion for old box constraint layouts. Just for versioning. */ CONSTRAINT_EXPAND_DEPRECATED = (1 << 0), +#endif /* pre-check for illegal object name or bone name */ CONSTRAINT_DISABLE = (1 << 2), /* to indicate which Ipo should be shown, maybe for 3d access later too */ @@ -860,6 +863,8 @@ typedef enum eSameVolume_Mode { typedef enum eActionConstraint_Flags { /* Bones use "object" part of target action, instead of "same bone name" part */ ACTCON_BONE_USE_OBJECT_ACTION = (1 << 0), + /* Ignore the transform of 'tar' and use 'eval_time' instead: */ + ACTCON_USE_EVAL_TIME = (1 << 1), } eActionConstraint_Flags; /* bActionConstraint.mix_mode */ diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender/makesdna/DNA_curve_defaults.h index 0cb3960dbd7..07dd0aeb08d 100644 --- a/source/blender/makesdna/DNA_curve_defaults.h +++ b/source/blender/makesdna/DNA_curve_defaults.h @@ -49,6 +49,7 @@ .bevfac1_mapping = CU_BEVFAC_MAP_RESOLU, \ .bevfac2_mapping = CU_BEVFAC_MAP_RESOLU, \ .bevresol = 4, \ + .bevel_mode = CU_BEV_MODE_ROUND, \ } /** \} */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 2ae9ba13177..2f362034b78 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -31,6 +31,7 @@ #define MAXTEXTBOX 256 /* used in readfile.c and editfont.c */ struct AnimData; +struct CurveProfile; struct EditFont; struct GHash; struct Ipo; @@ -113,9 +114,9 @@ typedef struct BezTriple { char ipo; /** H1, h2: the handle type of the two handles. */ - char h1, h2; + uint8_t h1, h2; /** F1, f2, f3: used for selection status. */ - char f1, f2, f3; + uint8_t f1, f2, f3; /** Hide: used to indicate whether BezTriple is hidden (3D), * type of keyframe (eBezTriple_KeyframeType). */ @@ -143,7 +144,9 @@ typedef struct BPoint { /** Used for softbody goal weight. */ float weight; /** F1: selection status, hide: is point hidden or not. */ - short f1, hide; + uint8_t f1; + char _pad1[1]; + short hide; /** User-set radius per point for beveling etc. */ float radius; char _pad[4]; @@ -230,6 +233,8 @@ typedef struct Curve { struct Key *key; struct Material **mat; + struct CurveProfile *bevel_profile; + /* texture space, copied as one block in editobject.c */ float loc[3]; float size[3]; @@ -259,7 +264,8 @@ typedef struct Curve { char overflow; char spacemode, align_y; - char _pad[3]; + char bevel_mode; + char _pad[2]; /* font part */ short lines; @@ -383,6 +389,13 @@ enum { CU_ALIGN_Y_BOTTOM = 4, }; +/* Curve.bevel_mode */ +enum { + CU_BEV_MODE_ROUND = 0, + CU_BEV_MODE_OBJECT = 1, + CU_BEV_MODE_CURVE_PROFILE = 2, +}; + /* Curve.overflow. */ enum { CU_OVERFLOW_NONE = 0, diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index ca4d309e3b1..ae0bb20e529 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -123,7 +123,7 @@ typedef enum CustomDataType { /* CD_ID_MCOL = 21, */ /* CD_TEXTURE_MLOOPCOL = 22, */ /* UNUSED */ CD_CLOTH_ORCO = 23, - CD_RECAST = 24, + /* CD_RECAST = 24, */ /* UNUSED */ /* BMESH ONLY START */ CD_MPOLY = 25, @@ -182,7 +182,7 @@ typedef enum CustomDataType { #define CD_MASK_MDISPS (1 << CD_MDISPS) #define CD_MASK_PREVIEW_MCOL (1 << CD_PREVIEW_MCOL) #define CD_MASK_CLOTH_ORCO (1 << CD_CLOTH_ORCO) -#define CD_MASK_RECAST (1 << CD_RECAST) +// #define CD_MASK_RECAST (1 << CD_RECAST) /* DEPRECATED */ /* BMESH ONLY START */ #define CD_MASK_MPOLY (1 << CD_MPOLY) diff --git a/source/blender/makesdna/DNA_fluid_defaults.h b/source/blender/makesdna/DNA_fluid_defaults.h new file mode 100644 index 00000000000..2ee83cf3387 --- /dev/null +++ b/source/blender/makesdna/DNA_fluid_defaults.h @@ -0,0 +1,267 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Fluid Domain Settings Struct + * \{ */ + +#define _DNA_DEFAULT_FluidDomainSettings \ + { \ + .fmd = NULL, \ + .fluid = NULL, \ + .fluid_old = NULL, \ + .fluid_mutex = NULL, \ + .fluid_group = NULL, \ + .force_group = NULL, \ + .effector_group = NULL, \ + .tex_density = NULL, \ + .tex_color = NULL, \ + .tex_wt = NULL, \ + .tex_shadow = NULL, \ + .tex_flame = NULL, \ + .tex_flame_coba = NULL, \ + .tex_coba = NULL, \ + .tex_field = NULL, \ + .tex_velocity_x = NULL, \ + .tex_velocity_y = NULL, \ + .tex_velocity_z = NULL, \ + .tex_flags = NULL, \ + .tex_range_field = NULL, \ + .guide_parent = NULL, \ + .mesh_velocities = NULL, \ + .effector_weights = NULL, /* #BKE_effector_add_weights. */ \ + .p0 = {0.0f, 0.0f, 0.0f}, \ + .p1 = {0.0f, 0.0f, 0.0f}, \ + .dp0 = {0.0f, 0.0f, 0.0f}, \ + .cell_size = {0.0f, 0.0f, 0.0f}, \ + .global_size = {0.0f, 0.0f, 0.0f}, \ + .prev_loc = {0.0f, 0.0f, 0.0f}, \ + .shift = {0, 0, 0}, \ + .shift_f = {0.0f, 0.0f, 0.0f}, \ + .obj_shift_f = {0.0f, 0.0f, 0.0f}, \ + .imat = _DNA_DEFAULT_UNIT_M4, \ + .obmat = _DNA_DEFAULT_UNIT_M4, \ + .fluidmat = _DNA_DEFAULT_UNIT_M4, \ + .fluidmat_wt = _DNA_DEFAULT_UNIT_M4, \ + .base_res = {0, 0, 0}, \ + .res_min = {0, 0, 0}, \ + .res_max = {0, 0, 0}, \ + .res = {0, 0, 0}, \ + .total_cells = 0, \ + .dx = 0, \ + .scale = 0.0f, \ + .boundary_width = 1, \ + .gravity_final = {0.0f, 0.0f, 0.0f}, \ + .adapt_margin = 4, \ + .adapt_res = 0, \ + .adapt_threshold = 0.02f, \ + .maxres = 32, \ + .solver_res = 3, \ + .border_collisions = 0, \ + .flags = FLUID_DOMAIN_USE_DISSOLVE_LOG | FLUID_DOMAIN_USE_ADAPTIVE_TIME, \ + .gravity = {0.0f, 0.0f, -9.81f}, \ + .active_fields = 0, \ + .type = FLUID_DOMAIN_TYPE_GAS, \ + .alpha = 1.0f, \ + .beta = 1.0f, \ + .diss_speed = 5, \ + .vorticity = 0.0f, \ + .active_color = {0.0f, 0.0f, 0.0f}, \ + .highres_sampling = SM_HRES_FULLSAMPLE, \ + .burning_rate = 0.75f, \ + .flame_smoke = 1.0f, \ + .flame_vorticity = 0.5f, \ + .flame_ignition = 1.5f, \ + .flame_max_temp = 3.0f, \ + .flame_smoke_color = {0.7f, 0.7f, 0.7f}, \ + .noise_strength = 1.0f, \ + .noise_pos_scale = 2.0f, \ + .noise_time_anim = 0.1f, \ + .res_noise = {0, 0, 0}, \ + .noise_scale = 2, \ + .noise_type = FLUID_NOISE_TYPE_WAVELET, \ + .particle_randomness = 0.1f, \ + .particle_number = 2, \ + .particle_minimum = 8, \ + .particle_maximum = 16, \ + .particle_radius = 1.0f, \ + .particle_band_width = 3.0f, \ + .fractions_threshold = 0.05f, \ + .fractions_distance = 0.5f, \ + .flip_ratio = 0.97f, \ + .sys_particle_maximum = 0, \ + .simulation_method = FLUID_DOMAIN_METHOD_FLIP, \ + .surface_tension = 0.0f, \ + .viscosity_base = 1.0f, \ + .viscosity_exponent = 6.0f, \ + .mesh_concave_upper = 3.5f, \ + .mesh_concave_lower = 0.4f, \ + .mesh_particle_radius = 2.0f, \ + .mesh_smoothen_pos = 1, \ + .mesh_smoothen_neg = 1, \ + .mesh_scale = 2, \ + .totvert = 0, \ + .mesh_generator = FLUID_DOMAIN_MESH_IMPROVED, \ + .particle_type = 0, \ + .particle_scale = 1, \ + .sndparticle_tau_min_wc = 2.0f, \ + .sndparticle_tau_max_wc = 8.0f, \ + .sndparticle_tau_min_ta = 5.0f, \ + .sndparticle_tau_max_ta = 20.0f, \ + .sndparticle_tau_min_k = 1.0f, \ + .sndparticle_tau_max_k = 5.0f, \ + .sndparticle_k_wc = 200, \ + .sndparticle_k_ta = 40, \ + .sndparticle_k_b = 0.5f, \ + .sndparticle_k_d = 0.6f, \ + .sndparticle_l_min = 10.0f, \ + .sndparticle_l_max = 25.0f, \ + .sndparticle_potential_radius = 2, \ + .sndparticle_update_radius = 2, \ + .sndparticle_boundary = SNDPARTICLE_BOUNDARY_DELETE, \ + .sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF, \ + .guide_alpha = 2.0f, \ + .guide_beta = 5, \ + .guide_vel_factor = 2.0f, \ + .guide_res = {0, 0, 0}, \ + .guide_source = FLUID_DOMAIN_GUIDE_SRC_DOMAIN, \ + .cache_frame_start = 1, \ + .cache_frame_end = 250, \ + .cache_frame_pause_data = 0, \ + .cache_frame_pause_noise = 0, \ + .cache_frame_pause_mesh = 0, \ + .cache_frame_pause_particles = 0, \ + .cache_frame_pause_guide = 0, \ + .cache_frame_offset = 0, \ + .cache_flag = 0, \ + .cache_mesh_format = FLUID_DOMAIN_FILE_BIN_OBJECT, \ + .cache_data_format = FLUID_DOMAIN_FILE_OPENVDB, \ + .cache_particle_format = FLUID_DOMAIN_FILE_OPENVDB, \ + .cache_noise_format = FLUID_DOMAIN_FILE_OPENVDB, \ + .cache_directory = "", \ + .error = "", \ + .cache_type = FLUID_DOMAIN_CACHE_REPLAY, \ + .cache_id = "", \ + .dt = 0.0f, \ + .time_total = 0.0f, \ + .time_per_frame = 0.0f, \ + .frame_length = 0.0f, \ + .time_scale = 1.0f, \ + .cfl_condition = 4.0f, \ + .timesteps_minimum = 1, \ + .timesteps_maximum = 4, \ + .slice_per_voxel = 5.0f, \ + .slice_depth = 0.5f, \ + .display_thickness = 1.0f, \ + .grid_scale = 1.0f, \ + .coba = NULL, \ + .vector_scale = 1.0f, \ + .gridlines_lower_bound = 0.0f, \ + .gridlines_upper_bound = 1.0f, \ + .gridlines_range_color = {1.0f, 0.0f, 0.0f, 1.0f}, \ + .axis_slice_method = AXIS_SLICE_FULL, \ + .slice_axis = 0, \ + .show_gridlines = false, \ + .draw_velocity = false, \ + .vector_draw_type = VECTOR_DRAW_NEEDLE, \ + .vector_field = FLUID_DOMAIN_VECTOR_FIELD_VELOCITY, \ + .vector_scale_with_magnitude = true, \ + .vector_draw_mac_components = VECTOR_DRAW_MAC_X | VECTOR_DRAW_MAC_Y | VECTOR_DRAW_MAC_Z, \ + .use_coba = false, \ + .coba_field = FLUID_DOMAIN_FIELD_DENSITY, \ + .interp_method = FLUID_DISPLAY_INTERP_LINEAR, \ + .gridlines_color_field = 0, \ + .gridlines_cell_filter = FLUID_CELL_TYPE_NONE, \ + .openvdb_compression = VDB_COMPRESSION_BLOSC, \ + .clipping = 1e-6f, \ + .openvdb_data_depth = 0, \ + .viewsettings = 0, \ + .point_cache = {NULL, NULL}, /* Use #BKE_ptcache_add. */ \ + .ptcaches = {{NULL}}, \ + .cache_comp = SM_CACHE_LIGHT, \ + .cache_high_comp = SM_CACHE_LIGHT, \ + .cache_file_format = 0, \ + } + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Fluid Flow Settings Struct + * \{ */ + +#define _DNA_DEFAULT_FluidFlowSettings \ + { \ + .fmd = NULL, \ + .mesh = NULL, \ + .psys = NULL, \ + .noise_texture = NULL, \ + .verts_old = NULL, \ + .numverts = 0, \ + .vel_multi = 1.0f, \ + .vel_normal = 0.0f, \ + .vel_random = 0.0f, \ + .vel_coord = {0.0f, 0.0f, 0.0f}, \ + .density = 1.0f, \ + .color = {0.7f, 0.7f, 0.7f}, \ + .fuel_amount = 1.0f, \ + .temperature = 1.0f, \ + .volume_density = 0.0f, \ + .surface_distance = 1.5f, \ + .particle_size = 1.0f, \ + .subframes = 0, \ + .texture_size = 1.0f, \ + .texture_offset = 0.0f, \ + .uvlayer_name = "", \ + .vgroup_density = 0, \ + .type = FLUID_FLOW_TYPE_SMOKE, \ + .behavior = FLUID_FLOW_BEHAVIOR_GEOMETRY, \ + .source = FLUID_FLOW_SOURCE_MESH, \ + .texture_type = 0, \ + .flags = FLUID_FLOW_ABSOLUTE | FLUID_FLOW_USE_PART_SIZE | FLUID_FLOW_USE_INFLOW, \ + } + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Fluid Effector Settings Struct + * \{ */ + +#define _DNA_DEFAULT_FluidEffectorSettings \ + { \ + .fmd = NULL, \ + .mesh = NULL, \ + .verts_old = NULL, \ + .numverts = 0, \ + .surface_distance = 0.0f, \ + .flags = FLUID_EFFECTOR_USE_EFFEC, \ + .subframes = 0, \ + .type = FLUID_EFFECTOR_TYPE_COLLISION, \ + .vel_multi = 1.0f, \ + .guide_mode = FLUID_EFFECTOR_GUIDE_OVERRIDE, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h index 6035c43ad57..2786d4df868 100644 --- a/source/blender/makesdna/DNA_fluid_types.h +++ b/source/blender/makesdna/DNA_fluid_types.h @@ -25,7 +25,10 @@ #include "DNA_listBase.h" -/* Domain flags. */ +/** + * #FluidDomainSettings.flags + * Domain flags. + */ enum { FLUID_DOMAIN_USE_NOISE = (1 << 1), /* Use noise. */ FLUID_DOMAIN_USE_DISSOLVE = (1 << 2), /* Let smoke dissolve. */ @@ -47,7 +50,10 @@ enum { FLUID_DOMAIN_USE_RESUMABLE_CACHE = (1 << 16), /* Determine if cache should be resumable. */ }; -/* Border collisions. */ +/** + * #FluidDomainSettings.border_collisions + * Border collisions. + */ enum { FLUID_DOMAIN_BORDER_FRONT = (1 << 1), FLUID_DOMAIN_BORDER_BACK = (1 << 2), @@ -66,19 +72,19 @@ enum { FLUID_DOMAIN_FILE_BIN_OBJECT = (1 << 4), }; -/* Slice method. */ -enum { - FLUID_DOMAIN_SLICE_VIEW_ALIGNED = 0, - FLUID_DOMAIN_SLICE_AXIS_ALIGNED = 1, -}; - -/* Axis aligned method. */ +/** + * #FluidDomainSettings.axis_slice_method + * Axis aligned method. + */ enum { AXIS_SLICE_FULL = 0, AXIS_SLICE_SINGLE = 1, }; -/* Single slice direction. */ +/** + * #FluidDomainSettings.slice_axis + * Single slice direction. + */ enum { SLICE_AXIS_AUTO = 0, SLICE_AXIS_X = 1, @@ -86,22 +92,47 @@ enum { SLICE_AXIS_Z = 3, }; -/* Axis aligned method. */ -enum { - VOLUME_INTERP_LINEAR = 0, - VOLUME_INTERP_CUBIC = 1, -}; +/** + * #FluidDomainSettings.interp_method + * Display interpolation method. + */ +typedef enum FLUID_DisplayInterpolationMethod { + FLUID_DISPLAY_INTERP_LINEAR = 0, + FLUID_DISPLAY_INTERP_CUBIC = 1, + FLUID_DISPLAY_INTERP_CLOSEST = 2, +} FLUID_DisplayInterpolationMethod; +/** #FluidDomainSettings.vector_draw_type */ enum { VECTOR_DRAW_NEEDLE = 0, VECTOR_DRAW_STREAMLINE = 1, + VECTOR_DRAW_MAC = 2, }; +/** #FluidDomainSettings.vector_draw_mac_components */ +enum { + VECTOR_DRAW_MAC_X = (1 << 0), + VECTOR_DRAW_MAC_Y = (1 << 1), + VECTOR_DRAW_MAC_Z = (1 << 2), +}; + +/** + * #FluidDomainSettings.vector_field + * Fluid domain vector fields. + */ +typedef enum FLUID_DisplayVectorField { + FLUID_DOMAIN_VECTOR_FIELD_VELOCITY = 0, + FLUID_DOMAIN_VECTOR_FIELD_GUIDE_VELOCITY = 1, + FLUID_DOMAIN_VECTOR_FIELD_FORCE = 2, +} FLUID_DisplayVectorField; + +/** #FluidDomainSettings.sndparticle_boundary */ enum { SNDPARTICLE_BOUNDARY_DELETE = 0, SNDPARTICLE_BOUNDARY_PUSHOUT = 1, }; +/** #FluidDomainSettings.sndparticle_combined_export */ enum { SNDPARTICLE_COMBINED_EXPORT_OFF = 0, SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM = 1, @@ -110,6 +141,7 @@ enum { SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM_BUBBLE = 4, }; +/** #FluidDomainSettings.coba_field */ enum { FLUID_DOMAIN_FIELD_DENSITY = 0, FLUID_DOMAIN_FIELD_HEAT = 1, @@ -125,6 +157,34 @@ enum { FLUID_DOMAIN_FIELD_FORCE_X = 11, FLUID_DOMAIN_FIELD_FORCE_Y = 12, FLUID_DOMAIN_FIELD_FORCE_Z = 13, + FLUID_DOMAIN_FIELD_PHI = 14, + FLUID_DOMAIN_FIELD_PHI_IN = 15, + FLUID_DOMAIN_FIELD_PHI_OUT = 16, + FLUID_DOMAIN_FIELD_PHI_OBSTACLE = 17, + FLUID_DOMAIN_FIELD_FLAGS = 18, + FLUID_DOMAIN_FIELD_PRESSURE = 19, +}; + +/** + * #FluidDomainSettings.gridlines_color_field + * Fluid grid-line display color field types. + */ +enum { + FLUID_GRIDLINE_COLOR_TYPE_FLAGS = 1, + FLUID_GRIDLINE_COLOR_TYPE_RANGE = 2, +}; + +/** + * #FluidDomainSettings.gridlines_cell_filter + * Fluid cell types. + */ +enum { + FLUID_CELL_TYPE_NONE = 0, + FLUID_CELL_TYPE_FLUID = (1 << 0), + FLUID_CELL_TYPE_OBSTACLE = (1 << 1), + FLUID_CELL_TYPE_EMPTY = (1 << 2), + FLUID_CELL_TYPE_INFLOW = (1 << 3), + FLUID_CELL_TYPE_OUTFLOW = (1 << 4), }; /* Fluid domain types. */ @@ -251,7 +311,6 @@ enum { #define FLUID_NAME_OBVEL_Z "z_obvel" #define FLUID_NAME_FRACTIONS "fractions" #define FLUID_NAME_INVELC "invelC" -#define FLUID_NAME_INVEL "invel" #define FLUID_NAME_INVEL_X "x_invel" #define FLUID_NAME_INVEL_Y "y_invel" #define FLUID_NAME_INVEL_Z "z_invel" @@ -404,6 +463,7 @@ enum { enum { VDB_PRECISION_HALF_FLOAT = 0, VDB_PRECISION_FULL_FLOAT = 1, + VDB_PRECISION_MINI_FLOAT = 2, }; /* Deprecated values (i.e. all defines and enums below this line up until typedefs). */ @@ -446,6 +506,8 @@ typedef struct FluidDomainSettings { struct GPUTexture *tex_velocity_x; struct GPUTexture *tex_velocity_y; struct GPUTexture *tex_velocity_z; + struct GPUTexture *tex_flags; + struct GPUTexture *tex_range_field; struct Object *guide_parent; /** Vertex velocities of simulated fluid mesh. */ struct FluidDomainVertexVelocity *mesh_velocities; @@ -524,10 +586,11 @@ typedef struct FluidDomainSettings { float particle_radius; float particle_band_width; float fractions_threshold; + float fractions_distance; float flip_ratio; int sys_particle_maximum; short simulation_method; - char _pad4[2]; + char _pad4[6]; /* Diffusion options. */ float surface_tension; @@ -605,29 +668,41 @@ typedef struct FluidDomainSettings { int timesteps_maximum; /* Display options. */ - char slice_method, axis_slice_method; - char slice_axis, draw_velocity; float slice_per_voxel; float slice_depth; float display_thickness; + float grid_scale; struct ColorBand *coba; float vector_scale; + float gridlines_lower_bound; + float gridlines_upper_bound; + float gridlines_range_color[4]; + char axis_slice_method; + char slice_axis; + char show_gridlines; + char draw_velocity; char vector_draw_type; + char vector_field; /* Simulation field used for vector display. */ + char vector_scale_with_magnitude; + char vector_draw_mac_components; char use_coba; char coba_field; /* Simulation field used for the color mapping. */ char interp_method; + char gridlines_color_field; /* Simulation field used to color map onto gridlines. */ + char gridlines_cell_filter; + char _pad9[7]; /* OpenVDB cache options. */ int openvdb_compression; float clipping; char openvdb_data_depth; - char _pad9[7]; /* Unused. */ + char _pad10[7]; /* Unused. */ /* -- Deprecated / unsed options (below). -- */ /* View options. */ int viewsettings; - char _pad10[4]; /* Unused. */ + char _pad11[4]; /* Unused. */ /* Pointcache options. */ /* Smoke uses only one cache from now on (index [0]), but keeping the array for now for reading @@ -637,7 +712,7 @@ typedef struct FluidDomainSettings { int cache_comp; int cache_high_comp; char cache_file_format; - char _pad11[7]; /* Unused. */ + char _pad12[7]; /* Unused. */ } FluidDomainSettings; diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 1cdaba81ffa..6fcbc53d47b 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -78,6 +78,8 @@ enum eSDNA_StructCompare { /* Struct is different in some way * (needs to be copied/converted field by field) */ SDNA_CMP_NOT_EQUAL = 2, + /* This is only used temporarily by #DNA_struct_get_compareflags. */ + SDNA_CMP_UNKNOWN = 3, }; struct SDNA *DNA_sdna_from_data(const void *data, @@ -93,16 +95,20 @@ void DNA_sdna_current_init(void); const struct SDNA *DNA_sdna_current_get(void); void DNA_sdna_current_free(void); +struct DNA_ReconstructInfo; +struct DNA_ReconstructInfo *DNA_reconstruct_info_create(const struct SDNA *oldsdna, + const struct SDNA *newsdna, + const char *compare_flags); +void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info); + int DNA_struct_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last); int DNA_struct_find_nr(const struct SDNA *sdna, const char *str); -void DNA_struct_switch_endian(const struct SDNA *oldsdna, int oldSDNAnr, char *data); +void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_nr, char *data); const char *DNA_struct_get_compareflags(const struct SDNA *sdna, const struct SDNA *newsdna); -void *DNA_struct_reconstruct(const struct SDNA *newsdna, - const struct SDNA *oldsdna, - const char *compflags, - int oldSDNAnr, +void *DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info, + int old_struct_nr, int blocks, - const void *data); + const void *old_blocks); int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name); diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h new file mode 100644 index 00000000000..44239221df4 --- /dev/null +++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h @@ -0,0 +1,286 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Note that some struct members for colormapping and colorbands are not initialized here. */ + +/* Struct members on own line. */ +/* clang-format off */ + +#define _DNA_DEFAULT_ArmatureGpencilModifierData \ + { \ + .deformflag = ARM_DEF_VGROUP, \ + .multi = 0, \ + .object = NULL, \ + .vert_coords_prev = NULL, \ + .vgname = "", \ + } + +#define _DNA_DEFAULT_ArrayGpencilModifierData \ + { \ + .object = NULL, \ + .material = NULL, \ + .count = 2, \ + .flag = GP_ARRAY_USE_RELATIVE, \ + .offset = {0.0f, 0.0f, 0.0f}, \ + .shift = {1.0f, 0.0f, 0.0f}, \ + .rnd_offset = {0.0f, 0.0f, 0.0f}, \ + .rnd_rot = {0.0f, 0.0f, 0.0f}, \ + .rnd_scale = {0.0f, 0.0f, 0.0f}, \ + .seed = 1, \ + .pass_index = 0, \ + .layername = "", \ + .mat_rpl = 0, \ + .layer_pass = 0, \ + } + +/* Deliberately set this range to the half the default frame-range + * to have an immediate effect to suggest use-cases. */ +#define _DNA_DEFAULT_BuildGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .layer_pass = 0, \ + .start_frame = 1, \ + .end_frame = 125, \ + .start_delay = 0.0f, \ + .length = 100.0f, \ + .flag = 0, \ + .mode = 0, \ + .transition = 0, \ + .time_alignment = 0, \ + .percentage_fac = 0.0f, \ + } + +#define _DNA_DEFAULT_ColorGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .flag = 0, \ + .hsv = {0.5f, 1.0f, 1.0f}, \ + .modify_color = GP_MODIFY_COLOR_BOTH, \ + .layer_pass = 0, \ + .curve_intensity = NULL, \ + } + +#define _DNA_DEFAULT_HookGpencilModifierData \ + { \ + .object = NULL, \ + .material = NULL, \ + .subtarget = "", \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .layer_pass = 0, \ + .flag = 0, \ + .falloff_type = eGPHook_Falloff_Smooth, \ + .parentinv = _DNA_DEFAULT_UNIT_M4, \ + .cent = {0.0f, 0.0f, 0.0f}, \ + .falloff = 0.0f, \ + .force = 0.5f, \ + .curfalloff = NULL, \ + } + +#define _DNA_DEFAULT_LatticeGpencilModifierData \ + { \ + .object = NULL, \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = 0, \ + .strength = 1.0f, \ + .layer_pass = 0, \ + .cache_data = NULL, \ + } + +#define _DNA_DEFAULT_MirrorGpencilModifierData \ + { \ + .object = NULL, \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .flag = GP_MIRROR_AXIS_X, \ + .layer_pass = 0, \ + } + +#define _DNA_DEFAULT_MultiplyGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .flag = 0, \ + .layer_pass = 0, \ + .flags = 0, \ + .duplications = 3, \ + .distance = 0.1f, \ + .offset = 0.0f, \ + .fading_center = 0.5f, \ + .fading_thickness = 0.5f, \ + .fading_opacity = 0.5f, \ + .split_angle = DEG2RADF(1.0f), \ + } + +#define _DNA_DEFAULT_NoiseGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = GP_NOISE_FULL_STROKE | GP_NOISE_USE_RANDOM, \ + .factor = 0.5f, \ + .factor_strength = 0.0f, \ + .factor_thickness = 0.0f, \ + .factor_uvs = 0.0f, \ + .noise_scale = 0.0f, \ + .step = 4, \ + .layer_pass = 0, \ + .seed = 1, \ + .curve_intensity = NULL, \ + } + +#define _DNA_DEFAULT_OffsetGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = 0, \ + .loc = {0.0f, 0.0f, 0.0f}, \ + .rot = {0.0f, 0.0f, 0.0f}, \ + .scale = {0.0f, 0.0f, 0.0f}, \ + .layer_pass = 0, \ + } + +#define _DNA_DEFAULT_OpacityGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = 0, \ + .factor = 1.0f, \ + .modify_color = GP_MODIFY_COLOR_BOTH, \ + .layer_pass = 0, \ + .hardeness = 1.0f, \ + .curve_intensity = NULL, \ + } + +#define _DNA_DEFAULT_SimplifyGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .flag = 0, \ + .factor = 0.0f, \ + .mode = 0, \ + .step = 1, \ + .layer_pass = 0, \ + .length = 0.1f, \ + .distance = 0.1f, \ + } + +#define _DNA_DEFAULT_SmoothGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = GP_SMOOTH_MOD_LOCATION, \ + .factor = 0.5f, \ + .step = 1, \ + .layer_pass = 0, \ + .curve_intensity = NULL, \ + } + +#define _DNA_DEFAULT_SubdivGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .pass_index = 0, \ + .flag = 0, \ + .level = 1, \ + .layer_pass = 0, \ + .type = 0, \ + } + +#define _DNA_DEFAULT_TextureGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = 0, \ + .uv_offset = 0.0f, \ + .uv_scale = 1.0f, \ + .fill_rotation = 0.0f, \ + .fill_offset = {0.0f, 0.0f}, \ + .fill_scale = 1.0f, \ + .layer_pass = 0, \ + .fit_method = GP_TEX_CONSTANT_LENGTH, \ + .mode = 0, \ + } + +#define _DNA_DEFAULT_ThickGpencilModifierData \ + { \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .flag = 0, \ + .thickness_fac = 1.0f, \ + .thickness = 30, \ + .layer_pass = 0, \ + } + +#define _DNA_DEFAULT_TimeGpencilModifierData \ + { \ + .layername = "", \ + .layer_pass = 0, \ + .flag = GP_TIME_KEEP_LOOP, \ + .offset = 1, \ + .frame_scale = 1.0f, \ + .mode = 0, \ + .sfra = 1, \ + .efra = 250, \ + } + +#define _DNA_DEFAULT_TintGpencilModifierData \ + { \ + .object = NULL, \ + .material = NULL, \ + .layername = "", \ + .vgname = "", \ + .pass_index = 0, \ + .layer_pass = 0, \ + .flag = 0, \ + .mode = GPPAINT_MODE_BOTH, \ + .factor = 0.5f, \ + .radius = 1.0f, \ + .rgb = {1.0f, 1.0f, 1.0f}, \ + .type = 0, \ + .curve_intensity = NULL, \ + .colorband = NULL, \ + } + +/* clang-format off */ diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index bf268ae7c2d..7107e131eda 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -57,7 +57,9 @@ typedef enum GpencilModifierMode { eGpencilModifierMode_Realtime = (1 << 0), eGpencilModifierMode_Render = (1 << 1), eGpencilModifierMode_Editmode = (1 << 2), +#ifdef DNA_DEPRECATED_ALLOW eGpencilModifierMode_Expanded_DEPRECATED = (1 << 3), +#endif eGpencilModifierMode_Virtual = (1 << 4), } GpencilModifierMode; @@ -70,8 +72,9 @@ typedef struct GpencilModifierData { struct GpencilModifierData *next, *prev; int type, mode; - int stackindex; + char _pad0[4]; short flag; + /* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */ short ui_expand_flag; /** MAX_NAME. */ char name[64]; @@ -778,6 +781,9 @@ typedef struct TextureGpencilModifierData { /** Texture fit options. */ short fit_method; short mode; + /** Dot texture rotation */ + float alignment_rotation; + char _pad[4]; } TextureGpencilModifierData; typedef enum eTextureGpencil_Flag { diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 4a05d7ba319..6e0e3d6d6b7 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -151,7 +151,8 @@ typedef struct Image { short gpuflag; short gpu_pass; short gpu_layer; - char _pad2[6]; + short gpu_slot; + char _pad2[4]; /** Deprecated. */ struct PackedFile *packedfile DNA_DEPRECATED; diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h index 56a164e4f2c..3a613d92e4f 100644 --- a/source/blender/makesdna/DNA_key_types.h +++ b/source/blender/makesdna/DNA_key_types.h @@ -107,7 +107,7 @@ typedef struct Key { char _pad2; /** Only used when (Key->type == KEY_NORMAL), this value is used as a time slider, - * rather then using the scenes time, this value can be animated to give greater control */ + * rather than using the scene's time, this value can be animated to give greater control */ float ctime; /** diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index 3c2d479bea4..85065ba35d4 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -176,7 +176,7 @@ enum { }; /* Layer Collection->runtime_flag - Keep it synced with base->flag based on g_base_collection_flags. */ + * Keep it synced with base->flag based on g_base_collection_flags. */ enum { LAYER_COLLECTION_HAS_OBJECTS = (1 << 0), /* LAYER_COLLECTION_VISIBLE_DEPSGRAPH = (1 << 1), */ /* UNUSED */ diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h index 867f0995ae9..422b99f00a0 100644 --- a/source/blender/makesdna/DNA_linestyle_types.h +++ b/source/blender/makesdna/DNA_linestyle_types.h @@ -31,7 +31,7 @@ #endif /* texco (also in DNA_material_types.h) */ -#define TEXCO_STROKE 16 /* actually it's UV */ +#define TEXCO_STROKE 16 /* actually its UV */ struct AnimData; struct ColorBand; diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index 5f232036f2a..f877b8f0c51 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -89,7 +89,7 @@ typedef struct MaskSplinePointUW { } MaskSplinePointUW; typedef struct MaskSplinePoint { - /** Actual point coordinates and it's handles . */ + /** Actual point coordinates and its handles . */ BezTriple bezt; char _pad[4]; /** Number of uv feather values. */ diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 3d050805f12..1d31b876068 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -99,7 +99,8 @@ typedef struct MaterialGPencilStyle { float mix_stroke_factor; /** Mode used to align Dots and Boxes with stroke drawing path and object rotation */ int alignment_mode; - char _pad[4]; + /** Rotation for texture for Dots and Squares. */ + float alignment_rotation; } MaterialGPencilStyle; /* MaterialGPencilStyle->flag */ @@ -128,6 +129,10 @@ typedef enum eMaterialGPencilStyle_Flag { GP_MATERIAL_STROKE_TEX_MIX = (1 << 11), /* disable stencil clipping (overlap) */ GP_MATERIAL_DISABLE_STENCIL = (1 << 12), + /* Material used as stroke masking. */ + GP_MATERIAL_IS_STROKE_HOLDOUT = (1 << 13), + /* Material used as fill masking. */ + GP_MATERIAL_IS_FILL_HOLDOUT = (1 << 14), } eMaterialGPencilStyle_Flag; typedef enum eMaterialGPencilStyle_Mode { diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index abfa3cc1b2e..a822a6723fa 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -44,11 +44,10 @@ struct MLoopCol; struct MLoopTri; struct MLoopUV; struct MPoly; -struct MVert; struct MPropCol; +struct MVert; struct Material; struct Mesh; -struct Multires; struct SubdivCCG; # @@ -221,16 +220,15 @@ typedef struct Mesh { float remesh_voxel_adaptivity; char remesh_mode; - char _pad1[3]; + char symmetry; + + char _pad1[2]; int face_sets_color_seed; /* Stores the initial Face Set to be rendered white. This way the overlay can be enabled by * default and Face Sets can be used without affecting the color of the mesh. */ int face_sets_color_default; - /** Deprecated multiresolution modeling data, only keep for loading old files. */ - struct Multires *mr DNA_DEPRECATED; - Mesh_Runtime runtime; } Mesh; @@ -265,7 +263,7 @@ enum { /* me->editflag */ enum { - ME_EDIT_MIRROR_X = 1 << 0, + ME_EDIT_VERTEX_GROUPS_X_SYMMETRY = 1 << 0, ME_EDIT_MIRROR_Y = 1 << 1, /* unused so far */ ME_EDIT_MIRROR_Z = 1 << 2, /* unused so far */ @@ -320,6 +318,13 @@ enum { ME_SIMPLE_SUBSURF = 1, }; +/* me->symmetry */ +typedef enum eMeshSymmetryType { + ME_SYMMETRY_X = 1 << 0, + ME_SYMMETRY_Y = 1 << 1, + ME_SYMMETRY_Z = 1 << 2, +} eMeshSymmetryType; + #define MESH_MAX_VERTS 2000000000L #ifdef __cplusplus diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 57750b15dea..7cc94a2ad0b 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -308,7 +308,7 @@ typedef enum eMVertSkinFlag { */ MVERT_SKIN_ROOT = 1, - /** Marks a branch vertex (vertex with more than two connected edges), so that it's 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, @@ -518,54 +518,4 @@ typedef struct MRecast { int i; } MRecast; -/** Multires structs kept for compatibility with old files. */ -typedef struct MultiresCol { - float a, r, g, b; -} MultiresCol; - -typedef struct MultiresColFace { - /* vertex colors */ - MultiresCol col[4]; -} MultiresColFace; - -typedef struct MultiresFace { - unsigned int v[4]; - unsigned int mid; - char flag, mat_nr, _pad[2]; -} MultiresFace; - -typedef struct MultiresEdge { - unsigned int v[2]; - unsigned int mid; -} MultiresEdge; - -typedef struct MultiresLevel { - struct MultiresLevel *next, *prev; - - MultiresFace *faces; - MultiresColFace *colfaces; - MultiresEdge *edges; - - unsigned int totvert, totface, totedge; - char _pad[4]; - - /* Kept for compatibility with even older files */ - MVert *verts; -} MultiresLevel; - -typedef struct Multires { - ListBase levels; - MVert *verts; - - unsigned char level_count, current, newlvl, edgelvl, pinlvl, renderlvl; - unsigned char use_col, flag; - - /* Special level 1 data that cannot be modified from other levels */ - CustomData vdata; - CustomData fdata; - short *edge_flags; - char *edge_creases; -} Multires; -/* End multi-res structs. */ - /** \} */ diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h new file mode 100644 index 00000000000..b5bcfa4d157 --- /dev/null +++ b/source/blender/makesdna/DNA_modifier_defaults.h @@ -0,0 +1,818 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +#define _DNA_DEFAULT_ArmatureModifierData \ + { \ + .deformflag = ARM_DEF_VGROUP, \ + .multi = 0.0f, \ + .object = NULL, \ + .defgrp_name = "", \ + } + +/* Default to 2 duplicates distributed along the x-axis by an offset of 1 object width. */ +#define _DNA_DEFAULT_ArrayModifierData \ + { \ + .start_cap = NULL, \ + .end_cap = NULL, \ + .curve_ob = NULL, \ + .offset_ob = NULL, \ + .offset = {1.0f, 0.0f, 0.0f}, \ + .scale = {1.0f, 0.0f, 0.0f}, \ + .length = 0.0f, \ + .merge_dist = 0.01f, \ + .fit_type = MOD_ARR_FIXEDCOUNT, \ + .offset_type = MOD_ARR_OFF_RELATIVE, \ + .flags = 0, \ + .count = 2, \ + .uv_offset = {0.0f, 0.0f}, \ + } + +#define _DNA_DEFAULT_BevelModifierData \ + { \ + .value = 0.1f, \ + .res = 1, \ + .flags = 0, \ + .val_flags = MOD_BEVEL_AMT_OFFSET, \ + .profile_type = MOD_BEVEL_PROFILE_SUPERELLIPSE, \ + .lim_flags = 0, \ + .e_flags = 0, \ + .mat = -1, \ + .edge_flags = 0, \ + .face_str_mode = MOD_BEVEL_FACE_STRENGTH_NONE, \ + .miter_inner = MOD_BEVEL_MITER_SHARP, \ + .miter_outer = MOD_BEVEL_MITER_SHARP, \ + .affect_type = MOD_BEVEL_AFFECT_EDGES, \ + .profile = 0.5f, \ + .bevel_angle = DEG2RADF(30.0f), \ + .spread = 0.1f, \ + .defgrp_name = "", \ + } + +#define _DNA_DEFAULT_BooleanModifierData \ + { \ + .object = NULL, \ + .collection = NULL, \ + .double_threshold = 1e-6f, \ + .operation = eBooleanModifierOp_Difference, \ + .solver = eBooleanModifierSolver_Exact, \ + .flag = eBooleanModifierFlag_Object, \ + .bm_flag = 0, \ + } + +#define _DNA_DEFAULT_BuildModifierData \ + { \ + .start = 1.0f, \ + .length = 100.0f, \ + .flag = 0, \ + .randomize = 0, \ + .seed = 0, \ + } + +#define _DNA_DEFAULT_CastModifierData \ + { \ + .object = NULL, \ + .fac = 0.5f, \ + .radius = 0.0f, \ + .size = 0.0f, \ + .defgrp_name = "", \ + .flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z | MOD_CAST_SIZE_FROM_RADIUS, \ + .type = MOD_CAST_TYPE_SPHERE, \ + } + +#define _DNA_DEFAULT_ClothSimSettings \ + { \ + .cache = NULL, \ + .mingoal = 0.0f, \ + .Cvi = 1.0f, \ + .gravity = {0.0f, 0.0f, -9.81f}, \ + .dt = 0.0f, \ + .mass = 0.3f, \ + .shear = 5.0f, \ + .bending = 0.5f, \ + .max_bend = 0.5f, \ + .max_shear = 5.0f, \ + .max_sewing = 0.0f, \ + .avg_spring_len = 0.0f, \ + .timescale = 1.0f, \ + .time_scale = 1.0f, \ + .maxgoal = 1.0f, \ + .eff_force_scale = 1000.0f, \ + .eff_wind_scale = 250.0f, \ + .sim_time_old = 0.0f, \ + .defgoal = 0.0f, \ + .goalspring = 1.0f, \ + .goalfrict = 0.0f, \ + .velocity_smooth = 0.0f, \ + .density_target = 0.0f, \ + .density_strength = 0.0f, \ + .collider_friction = 0.0f, \ + .shrink_min = 0.0f, \ + .shrink_max = 0.0f, \ + .uniform_pressure_force = 0.0f, \ + .target_volume = 0.0f, \ + .pressure_factor = 1.0f, \ + .fluid_density = 0.0f, \ + .vgroup_pressure = 0, \ + .bending_damping = 0.5f, \ + .voxel_cell_size = 0.1f, \ + .stepsPerFrame = 5, \ + .flags = CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL, \ + .maxspringlen = 10, \ + .solver_type = 0, \ + .vgroup_bend = 0, \ + .vgroup_mass = 0, \ + .vgroup_struct = 0, \ + .vgroup_shrink = 0, \ + .shapekey_rest = 0, \ + .presets = 2, \ + .reset = 0, \ + .effector_weights = NULL, \ + .bending_model = CLOTH_BENDING_ANGULAR, \ + .vgroup_shear = 0, \ + .tension = 15.0f , \ + .compression = 15.0f, \ + .max_tension = 15.0f, \ + .max_compression = 15.0f, \ + .tension_damp = 5.0f, \ + .compression_damp = 5.0f, \ + .shear_damp = 5.0f, \ + .internal_spring_max_length = 0.0f, \ + .internal_spring_max_diversion = M_PI / 4.0f, \ + .vgroup_intern = 0, \ + .internal_tension = 15.0f, \ + .internal_compression = 15.0f, \ + .max_internal_tension = 15.0f, \ + .max_internal_compression = 15.0f, \ + } + +#define _DNA_DEFAULT_ClothCollSettings \ + { \ + .collision_list = NULL, \ + .epsilon = 0.015f, \ + .self_friction = 5.0f, \ + .friction = 5.0f, \ + .damping = 0.0f, \ + .selfepsilon = 0.015f, \ + .flags = CLOTH_COLLSETTINGS_FLAG_ENABLED, \ + .loop_count = 2, \ + .group = NULL, \ + .vgroup_selfcol = 0, \ + .clamp = 0.0f, \ + .self_clamp = 0.0f, \ + } + +#define _DNA_DEFAULT_ClothModifierData \ + { \ + .clothObject = NULL, \ + .sim_parms = NULL, \ + .coll_parms = NULL, \ + .point_cache = NULL, \ + .ptcaches = {NULL, NULL}, \ + .hairdata = NULL, \ + .hair_grid_min = {0.0f, 0.0f, 0.0f}, \ + .hair_grid_max = {0.0f, 0.0f, 0.0f}, \ + .hair_grid_res = {0, 0, 0}, \ + .hair_grid_cellsize = 0.0f, \ + .solver_result = NULL, \ + } + +#define _DNA_DEFAULT_CollisionModifierData \ + { \ + .x = NULL, \ + .xnew = NULL, \ + .xold = NULL, \ + .current_xnew = NULL, \ + .current_x = NULL, \ + .current_v = NULL, \ + .tri = NULL, \ + .mvert_num = 0, \ + .tri_num = 0, \ + .time_x = -1000.0f, \ + .time_xnew = -1000.0f, \ + .is_static = false, \ + .bvhtree = NULL, \ + } + +#define _DNA_DEFAULT_CorrectiveSmoothModifierData \ + { \ + .bind_coords = NULL, \ + .bind_coords_num = 0, \ + .lambda = 0.5f, \ + .scale = 1.0f, \ + .repeat = 5, \ + .flag = 0, \ + .smooth_type = MOD_CORRECTIVESMOOTH_SMOOTH_SIMPLE, \ + .defgrp_name = "", \ + } + +#define _DNA_DEFAULT_CurveModifierData \ + { \ + .object = NULL, \ + .name = "", \ + .defaxis = MOD_CURVE_POSX, \ + .flag = 0, \ + } + +/* Defines are scattered accross too many files, they need to be moved to DNA. */ +#if 0 +#define _DNA_DEFAULT_DataTransferModifierData \ + { \ + .ob_source = NULL, \ + .data_types = 0, \ + .vmap_mode = MREMAP_MODE_VERT_NEAREST, \ + .emap_mode = MREMAP_MODE_EDGE_NEAREST, \ + .lmap_mode = MREMAP_MODE_LOOP_NEAREST_POLYNOR, \ + .pmap_mode = MREMAP_MODE_POLY_NEAREST, \ + .map_max_distance = 1.0f, \ + .map_ray_radius = 0.0f, \ + .islands_precision = 0.0f, \ + .layers_select_src = {DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC}, \ + .layers_select_dst = {DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST}, \ + .mix_mod = CDT_MIX_TRANSFER, \ + .mix_factor = 1.0f, \ + .defgrp_name = "", \ + .flags = MOD_DATATRANSFER_OBSRC_TRANSFORM, \ + } +#endif + +#define _DNA_DEFAULT_DecimateModifierData \ + { \ + .percent = 1.0f, \ + .iter = 0, \ + .delimit = 0, \ + .symmetry_axis = 0, \ + .angle = DEG2RADF(5.0f), \ + .defgrp_name = "", \ + .defgrp_factor = 1.0f, \ + .flag = 0, \ + .mode = 0, \ + .face_count = 0, \ + } + +#define _DNA_DEFAULT_DisplaceModifierData \ + { \ + .texture = NULL, \ + .map_object = NULL, \ + .map_bone = "", \ + .uvlayer_name = "", \ + .uvlayer_tmp = 0, \ + .texmapping = 0, \ + .strength = 1.0f, \ + .direction = MOD_DISP_DIR_NOR, \ + .defgrp_name = "", \ + .midlevel = 0.5f, \ + .space = MOD_DISP_SPACE_LOCAL, \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_DynamicPaintModifierData \ + { \ + .canvas = NULL, \ + .brush = NULL, \ + .type = MOD_DYNAMICPAINT_TYPE_CANVAS, \ + } + +/* Default to 30-degree split angle, sharpness from both angle & flag. */ +#define _DNA_DEFAULT_EdgeSplitModifierData \ + { \ + .split_angle = DEG2RADF(30.0f), \ + .flags = MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG, \ + } + +#define _DNA_DEFAULT_ExplodeModifierData \ + { \ + .facepa = NULL, \ + .flag = eExplodeFlag_Unborn | eExplodeFlag_Alive | eExplodeFlag_Dead, \ + .vgroup = 0, \ + .protect = 0.0f, \ + .uvname = "", \ + } + +/* Fluid modifier settings skipped for now. */ + +#define _DNA_DEFAULT_HookModifierData \ + { \ + .subtarget = "", \ + .flag = 0, \ + .falloff_type = eHook_Falloff_Smooth, \ + .parentinv = _DNA_DEFAULT_UNIT_M4, \ + .cent = {0.0f, 0.0f, 0.0f}, \ + .falloff = 0.0f, \ + .curfalloff = NULL, \ + .indexar = NULL, \ + .totindex = 0, \ + .force = 1.0f, \ + .name = "", \ + } + +#define _DNA_DEFAULT_LaplacianDeformModifierData \ + { \ + .anchor_grp_name = "", \ + .total_verts = 0, \ + .repeat = 1, \ + .vertexco = NULL, \ + .cache_system = NULL, \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_LaplacianSmoothModifierData \ + { \ + .lambda = 0.01f, \ + .lambda_border = 0.01f, \ + .defgrp_name = "", \ + .flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | \ + MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME | MOD_LAPLACIANSMOOTH_NORMALIZED, \ + .repeat = 1, \ + } + +#define _DNA_DEFAULT_LatticeModifierData \ + { \ + .object = NULL, \ + .name = "", \ + .strength = 1.0f, \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_MaskModifierData \ + { \ + .ob_arm = NULL, \ + .vgroup = "", \ + .mode = 0, \ + .flag = 0, \ + .threshold = 0.0f, \ + } + +/* Y and Z forward and up axes, Blender default. */ +#define _DNA_DEFAULT_MeshCacheModifierData \ + { \ + .flag = 0, \ + .type = MOD_MESHCACHE_TYPE_MDD, \ + .time_mode = 0, \ + .play_mode = 0, \ + .forward_axis = 1, \ + .up_axis = 2, \ + .flip_axis = 0, \ + .interp = MOD_MESHCACHE_INTERP_LINEAR, \ + .factor = 1.0f, \ + .deform_mode = 0.0f, \ + .frame_start = 0.0f, \ + .frame_scale = 1.0f, \ + .eval_frame = 0.0f, \ + .eval_time = 0.0f, \ + .eval_factor = 0.0f, \ + .filepath = "", \ + } + +#define _DNA_DEFAULT_MeshDeformModifierData \ + { \ + .object = 0, \ + .defgrp_name = "", \ + .gridsize = 5, \ + .flag = 0, \ + .bindinfluences = NULL, \ + .bindoffsets = NULL, \ + .bindcagecos = NULL, \ + .totvert = 0, \ + .totcagevert = 0, \ + .dyngrid = NULL, \ + .dyninfluences = NULL, \ + .dynverts = NULL, \ + .dyngridsize = 0, \ + .totinfluence = 0, \ + .dyncellmin = {0.0f, 0.0f, 0.0f}, \ + .dyncellwidth = 0.0f, \ + .bindmat = _DNA_DEFAULT_UNIT_M4, \ + .bindweights = NULL, \ + .bindcos = NULL, \ + .bindfunc = NULL, \ + } + +#define _DNA_DEFAULT_MeshSeqCacheModifierData \ + { \ + .cache_file = NULL, \ + .object_path = "", \ + .read_flag = MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR, \ + .velocity_scale = 1.0f, \ + .reader = NULL, \ + .reader_object_path = "", \ + .vertex_velocities = NULL, \ + .num_vertices = 0, \ + .velocity_delta = 0.0f, \ + .last_lookup_time = 0.0f, \ + } + +#define _DNA_DEFAULT_MirrorModifierData \ + { \ + .flag = MOD_MIR_AXIS_X | MOD_MIR_VGROUP, \ + .tolerance = 0.001f, \ + .uv_offset = {0.0f, 0.0f}, \ + .uv_offset_copy = {0.0f, 0.0f}, \ + .mirror_ob = NULL, \ + } + +#define _DNA_DEFAULT_MultiresModifierData \ + { \ + .lvl = 0, \ + .sculptlvl = 0, \ + .renderlvl = 0, \ + .totlvl = 0, \ + .flags = eMultiresModifierFlag_UseCrease | eMultiresModifierFlag_ControlEdges, \ + .uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS, \ + .quality = 4, \ + .boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL, \ + } + +#define _DNA_DEFAULT_NormalEditModifierData \ + { \ + .defgrp_name = "", \ + .target = NULL, \ + .mode = MOD_NORMALEDIT_MODE_RADIAL, \ + .flag = 0, \ + .mix_mode = MOD_NORMALEDIT_MIX_COPY, \ + .mix_factor = 1.0f, \ + .mix_limit = M_PI, \ + .offset = {0.0f, 0.0f, 0.0f}, \ + } + +/* Some fields are initialized in #initData. */ +#define _DNA_DEFAULT_OceanModifierData \ + { \ + .ocean = NULL, \ + .oceancache = NULL, \ + .resolution = 7, \ + .viewport_resolution = 7, \ + .spatial_size = 50, \ + .wind_velocity = 30.0f, \ + .damp = 0.5f, \ + .smallest_wave = 0.01f, \ + .depth = 200.0f, \ + .wave_alignment = 0.0f, \ + .wave_direction = 0.0f, \ + .wave_scale = 1.0f, \ + .chop_amount = 1.0f, \ + .foam_coverage = 0.0f, \ + .time = 1.0f, \ + .spectrum = MOD_OCEAN_SPECTRUM_PHILLIPS, \ + .fetch_jonswap = 120.0f, \ + .sharpen_peak_jonswap = 0.0f, \ + .bakestart = 1, \ + .bakeend = 250, \ + .cachepath = "", \ + .foamlayername = "", \ + .spraylayername = "", \ + .cached = 0, \ + .geometry_mode = 0, \ + .flag = 0, \ + .repeat_x = 1, \ + .repeat_y = 1, \ + .seed = 0, \ + .size = 1.0f, \ + .foam_fade = 0.98f, \ + } + +#define _DNA_DEFAULT_ParticleInstanceModifierData \ + { \ + .psys = 1, \ + .flag = eParticleInstanceFlag_Parents | eParticleInstanceFlag_Unborn | \ + eParticleInstanceFlag_Alive | eParticleInstanceFlag_Dead, \ + .axis = 2, \ + .space = eParticleInstanceSpace_World, \ + .position = 1.0f, \ + .random_position = 0.0f, \ + .rotation = 0.0f, \ + .random_rotation = 0.0f, \ + .particle_offset = 1.0f, \ + .particle_amount = 0.0f, \ + .index_layer_name = "", \ + .value_layer_name = "", \ + } + +#define _DNA_DEFAULT_ParticleSystemModifierData \ + { \ + .psys = NULL, \ + .mesh_final = NULL, \ + .mesh_original = NULL, \ + .totdmvert = 0, \ + .totdmedge = 0, \ + .totdmface = 0, \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_RemeshModifierData \ + { \ + .threshold = 1.0f, \ + .scale = 0.9f, \ + .hermite_num = 1.0f, \ + .depth = 4, \ + .flag = MOD_REMESH_FLOOD_FILL, \ + .mode = MOD_REMESH_VOXEL, \ + .voxel_size = 0.1f, \ + .adaptivity = 0.0f, \ + } + +#define _DNA_DEFAULT_ScrewModifierData \ + { \ + .ob_axis = NULL, \ + .steps = 16, \ + .render_steps = 16, \ + .iter = 1, \ + .screw_ofs = 0.0f, \ + .angle = 2.0f * M_PI, \ + .merge_dist = 0.01f, \ + .flag = MOD_SCREW_SMOOTH_SHADING, \ + .axis = 2, \ + } + +/* Shape key modifier has no items. */ + +#define _DNA_DEFAULT_ShrinkwrapModifierData \ + { \ + .target = NULL, \ + .auxTarget = NULL, \ + .vgroup_name = "", \ + .keepDist = 0.0f, \ + .shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE, \ + .shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR, \ + .shrinkMode = 0, \ + .projLimit = 0.0f, \ + .projAxis = 0, \ + .subsurfLevels = 0, \ + } + +#define _DNA_DEFAULT_SimpleDeformModifierData \ + { \ + .origin = NULL, \ + .vgroup_name = "", \ + .factor = DEG2RADF(45.0f), \ + .limit = {0.0f, 1.0f}, \ + .mode = MOD_SIMPLEDEFORM_MODE_TWIST, \ + .axis = 0, \ + .deform_axis = 0, \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_SimulationModifierData \ + { 0 } + +#define _DNA_DEFAULT_SkinModifierData \ + { \ + .branch_smoothing = 0.0f, \ + .flag = 0, \ + .symmetry_axes = MOD_SKIN_SYMM_X, \ + } + +#define _DNA_DEFAULT_SmoothModifierData \ + { \ + .fac = 0.5f, \ + .repeat = 1, \ + .defgrp_name = "", \ + .flag = MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z, \ + } + +/* Softbody modifier skipped for now. */ + +#define _DNA_DEFAULT_SolidifyModifierData \ + { \ + .defgrp_name = "", \ + .shell_defgrp_name = "", \ + .rim_defgrp_name = "", \ + .offset = 0.01f, \ + .offset_fac = -1.0f, \ + .offset_fac_vg = 0.0f, \ + .offset_clamp = 0.0f, \ + .mode = MOD_SOLIDIFY_MODE_EXTRUDE, \ + .nonmanifold_offset_mode = MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS, \ + .nonmanifold_boundary_mode = MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE, \ + .crease_inner = 0.0f, \ + .crease_outer = 0.0f, \ + .crease_rim = 0.0f, \ + .flag = MOD_SOLIDIFY_RIM, \ + .mat_ofs = 0, \ + .mat_ofs_rim = 0, \ + .merge_tolerance = 0.0001f, \ + .bevel_convex = 0.0f, \ + } + +#define _DNA_DEFAULT_SubsurfModifierData \ + { \ + .subdivType = 0, \ + .levels = 1, \ + .renderLevels = 2, \ + .flags = eSubsurfModifierFlag_UseCrease | eSubsurfModifierFlag_ControlEdges, \ + .uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS, \ + .quality = 3, \ + .boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL, \ + .emCache = NULL, \ + .mCache = NULL, \ + } + +#define _DNA_DEFAULT_SurfaceModifierData \ + { \ + .x = NULL, \ + .v = NULL, \ + .mesh = NULL, \ + .bvhtree = NULL, \ + .cfra = 0, \ + .numverts = 0, \ + } + +#define _DNA_DEFAULT_SurfaceDeformModifierData \ + { \ + .depsgraph = NULL, \ + .target = NULL, \ + .verts = NULL, \ + .falloff = 4.0f, \ + .numverts = 0, \ + .numpoly = 0, \ + .flags = 0, \ + .mat = _DNA_DEFAULT_UNIT_M4, \ + .strength = 1.0f, \ + .defgrp_name = "", \ + } + +#define _DNA_DEFAULT_TriangulateModifierData \ + { \ + .flag = 0, \ + .quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE, \ + .ngon_method = MOD_TRIANGULATE_NGON_BEAUTY, \ + .min_vertices = 4, \ + } + +#define _DNA_DEFAULT_UVProjectModifierData \ + { \ + .projectors = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, \ + .num_projectors = 1, \ + .aspectx = 1.0f, \ + .aspecty = 1.0f, \ + .scalex = 1.0f, \ + .scaley = 1.0f, \ + .uvlayer_name = "", \ + .uvlayer_tmp = 0, \ + } + +#define _DNA_DEFAULT_UVWarpModifierData \ + { \ + .axis_u = 0, \ + .axis_v = 1, \ + .flag = 0, \ + .center = {0.5f, 0.5f}, \ + .offset = {0.0f, 0.0f}, \ + .scale = {1.0f, 1.0f}, \ + .rotation = 0.0f, \ + .object_src = NULL, \ + .bone_src = "", \ + .object_dst = NULL, \ + .bone_dst = "", \ + .vgroup_name = "", \ + .uvlayer_name = "", \ + } + +#define _DNA_DEFAULT_WarpModifierData \ + { \ + .texture = NULL, \ + .map_object = NULL, \ + .map_bone = "", \ + .uvlayer_name = "", \ + .uvlayer_tmp = 0, \ + .texmapping = 0, \ + .object_from = NULL, \ + .object_to = NULL, \ + .bone_from = "", \ + .bone_to = "", \ + .curfalloff = NULL, \ + .defgrp_name = "", \ + .strength = 1.0f, \ + .falloff_radius = 1.0f, \ + .flag = 0, \ + .falloff_type = eWarp_Falloff_Smooth, \ + } + +#define _DNA_DEFAULT_WaveModifierData \ + { \ + .texture = NULL, \ + .map_object = NULL, \ + .map_bone = "", \ + .uvlayer_name = "", \ + .uvlayer_tmp = 0, \ + .texmapping = MOD_DISP_MAP_LOCAL, \ + .objectcenter = NULL, \ + .defgrp_name = "", \ + .flag = MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL | MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z, \ + .startx = 0.0f, \ + .starty = 0.0f, \ + .height = 0.5f, \ + .width = 1.5f, \ + .narrow = 1.5f, \ + .speed = 0.25f, \ + .damp = 10.0f, \ + .falloff = 0.0f, \ + .timeoffs = 0.0f, \ + .lifetime = 0.0f, \ + } + +#define _DNA_DEFAULT_WeightedNormalModifierData \ + { \ + .defgrp_name = "", \ + .mode = MOD_WEIGHTEDNORMAL_MODE_FACE, \ + .flag = 0, \ + .weight = 50, \ + .thresh = 0.01f, \ + } + +#define _DNA_DEFAULT_WeightVGEditModifierData \ + { \ + .defgrp_name = "", \ + .edit_flags = 0, \ + .falloff_type = MOD_WVG_MAPPING_NONE, \ + .default_weight = 0.0f, \ + .cmap_curve = NULL, \ + .add_threshold = 0.01f, \ + .rem_threshold = 0.01f, \ + .mask_constant = 1.0f, \ + .mask_defgrp_name = "", \ + .mask_tex_use_channel = MOD_WVG_MASK_TEX_USE_INT, \ + .mask_texture = NULL, \ + .mask_tex_map_obj = NULL, \ + .mask_tex_map_bone = "", \ + .mask_tex_mapping = MOD_DISP_MAP_LOCAL, \ + .mask_tex_uvlayer_name = "", \ + } + +#define _DNA_DEFAULT_WeightVGMixModifierData \ + { \ + .defgrp_name_a = "", \ + .defgrp_name_b = "", \ + .default_weight_a = 0.0f, \ + .default_weight_b = 0.0f, \ + .mix_mode = MOD_WVG_MIX_SET, \ + .mix_set = MOD_WVG_SET_AND, \ + .mask_constant = 1.0f, \ + .mask_defgrp_name = "", \ + .mask_tex_use_channel = MOD_WVG_MASK_TEX_USE_INT, \ + .mask_texture = NULL, \ + .mask_tex_map_obj = NULL, \ + .mask_tex_map_bone = "", \ + .mask_tex_mapping = MOD_DISP_MAP_LOCAL, \ + .mask_tex_uvlayer_name = "", \ + .flag = 0, \ + } + +#define _DNA_DEFAULT_WeightVGProximityModifierData \ + { \ + .defgrp_name = "", \ + .proximity_mode = MOD_WVG_PROXIMITY_OBJECT, \ + .proximity_flags = MOD_WVG_PROXIMITY_GEOM_VERTS, \ + .proximity_ob_target = NULL, \ + .mask_constant = 1.0f, \ + .mask_defgrp_name = "", \ + .mask_tex_use_channel = MOD_WVG_MASK_TEX_USE_INT, \ + .mask_texture = NULL, \ + .mask_tex_map_obj = NULL, \ + .mask_tex_map_bone = "", \ + .mask_tex_mapping = MOD_DISP_MAP_LOCAL, \ + .mask_tex_uvlayer_name = "", \ + .min_dist = 0.0f, \ + .max_dist = 1.0f, \ + .falloff_type = MOD_WVG_MAPPING_NONE, \ + } + +#define _DNA_DEFAULT_WeldModifierData \ + { \ + .merge_dist = 0.001f, \ + .defgrp_name = "", \ + } + +#define _DNA_DEFAULT_WireframeModifierData \ + { \ + .defgrp_name = "", \ + .offset = 0.02f, \ + .offset_fac = 0.0f, \ + .offset_fac_vg = 0.0f, \ + .crease_weight = 1.0f, \ + .flag = MOD_WIREFRAME_REPLACE | MOD_WIREFRAME_OFS_EVEN, \ + .mat_ofs = 0, \ + } + +/* clang-format off */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index a9f1d5bcfc4..232fca062fa 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -95,6 +95,9 @@ typedef enum ModifierType { eModifierType_Weld = 55, eModifierType_Fluid = 56, eModifierType_Simulation = 57, + eModifierType_MeshToVolume = 58, + eModifierType_VolumeDisplace = 59, + eModifierType_VolumeToMesh = 60, NUM_MODIFIER_TYPES, } ModifierType; @@ -103,8 +106,10 @@ typedef enum ModifierMode { eModifierMode_Render = (1 << 1), eModifierMode_Editmode = (1 << 2), eModifierMode_OnCage = (1 << 3), - /* Old modifier box expansion, just for versioning. */ +#ifdef DNA_DEPRECATED_ALLOW + /** Old modifier box expansion, just for versioning. */ eModifierMode_Expanded_DEPRECATED = (1 << 4), +#endif eModifierMode_Virtual = (1 << 5), eModifierMode_ApplyOnSpline = (1 << 6), eModifierMode_DisableTemporary = (1u << 31), @@ -114,9 +119,9 @@ typedef struct ModifierData { struct ModifierData *next, *prev; int type, mode; - int stackindex; + char _pad0[4]; short flag; - /* An "expand" bit for each of the modifier's (sub)panels. */ + /* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */ short ui_expand_flag; /** MAX_NAME. */ char name[64]; @@ -161,6 +166,7 @@ typedef enum { eSubsurfModifierFlag_SubsurfUv_DEPRECATED = (1 << 3), eSubsurfModifierFlag_UseCrease = (1 << 4), eSubsurfModifierFlag_UseCustomNormals = (1 << 5), + eSubsurfModifierFlag_UseRecursiveSubdivision = (1 << 6), } SubsurfModifierFlag; typedef enum { @@ -177,13 +183,19 @@ typedef enum { SUBSURF_UV_SMOOTH_ALL = 5, } eSubsurfUVSmooth; +typedef enum { + SUBSURF_BOUNDARY_SMOOTH_ALL = 0, + SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS = 1, +} eSubsurfBoundarySmooth; + typedef struct SubsurfModifierData { ModifierData modifier; short subdivType, levels, renderLevels, flags; short uv_smooth; short quality; - char _pad[4]; + short boundary_smooth; + char _pad[2]; /* TODO(sergey): Get rid of those with the old CCG subdivision code. */ void *emCache, *mCache; @@ -861,26 +873,32 @@ typedef struct BooleanModifierData { ModifierData modifier; struct Object *object; + struct Collection *collection; + float double_threshold; char operation; char solver; char flag; char bm_flag; - float double_threshold; } BooleanModifierData; +/* BooleanModifierData->operation */ typedef enum { eBooleanModifierOp_Intersect = 0, eBooleanModifierOp_Union = 1, eBooleanModifierOp_Difference = 2, } BooleanModifierOp; +/* BooleanModifierData->solver */ typedef enum { eBooleanModifierSolver_Fast = 0, eBooleanModifierSolver_Exact = 1, } BooleanModifierSolver; +/* BooleanModifierData->flag */ enum { eBooleanModifierFlag_Self = (1 << 0), + eBooleanModifierFlag_Object = (1 << 1), + eBooleanModifierFlag_Collection = (1 << 2), }; /* bm_flag only used when G_DEBUG. */ @@ -1031,10 +1049,12 @@ typedef struct MultiresModifierData { ModifierData modifier; char lvl, sculptlvl, renderlvl, totlvl; - char simple, flags, _pad[2]; + char simple DNA_DEPRECATED; + char flags, _pad[2]; short quality; short uv_smooth; - char _pad2[4]; + short boundary_smooth; + char _pad2[2]; } MultiresModifierData; typedef enum { @@ -1972,12 +1992,11 @@ typedef struct WeldModifierData { /* The limit below which to merge vertices. */ float merge_dist; - unsigned int max_interactions; /* Name of vertex group to use to mask, MAX_VGROUP_NAME. */ char defgrp_name[64]; short flag; - char _pad[6]; + char _pad[2]; } WeldModifierData; /* WeldModifierData->flag */ @@ -2115,6 +2134,11 @@ enum { MOD_MESHSEQ_READ_POLY = (1 << 1), MOD_MESHSEQ_READ_UV = (1 << 2), MOD_MESHSEQ_READ_COLOR = (1 << 3), + + /* Allow interpolation of mesh vertex positions. There is a heuristic to avoid interpolation when + * the mesh topology changes, but this heuristic sometimes fails. In these cases, users can + * disable interpolation with this flag. */ + MOD_MESHSEQ_INTERPOLATE_VERTICES = (1 << 4), }; typedef struct SDefBind { @@ -2198,11 +2222,93 @@ enum { typedef struct SimulationModifierData { ModifierData modifier; - - struct Simulation *simulation; - char *data_path; } SimulationModifierData; +typedef struct MeshToVolumeModifierData { + ModifierData modifier; + + /** This is the object that is supposed to be converted to a volume. */ + struct Object *object; + + /** MeshToVolumeModifierResolutionMode */ + int resolution_mode; + /** Size of a voxel in object space. */ + float voxel_size; + /** The desired amount of voxels along one axis. The actual amount of voxels might be slightly + * different. */ + int voxel_amount; + + /** If true, every cell in the enclosed volume gets a density. Otherwise, the interior_band_width + * is used. */ + char fill_volume; + char _pad1[3]; + + /** Band widths are in object space. */ + float interior_band_width; + float exterior_band_width; + + float density; + char _pad2[4]; +} MeshToVolumeModifierData; + +/* MeshToVolumeModifierData->resolution_mode */ +typedef enum MeshToVolumeModifierResolutionMode { + MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT = 0, + MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE = 1, +} MeshToVolumeModifierResolutionMode; + +typedef struct VolumeDisplaceModifierData { + ModifierData modifier; + + struct Tex *texture; + struct Object *texture_map_object; + int texture_map_mode; + + float strength; + float texture_mid_level[3]; + float texture_sample_radius; +} VolumeDisplaceModifierData; + +/* VolumeDisplaceModifierData->texture_map_mode */ +enum { + MOD_VOLUME_DISPLACE_MAP_LOCAL = 0, + MOD_VOLUME_DISPLACE_MAP_GLOBAL = 1, + MOD_VOLUME_DISPLACE_MAP_OBJECT = 2, +}; + +typedef struct VolumeToMeshModifierData { + ModifierData modifier; + + /** This is the volume object that is supposed to be converted to a mesh. */ + struct Object *object; + + float threshold; + float adaptivity; + + /** VolumeToMeshFlag */ + uint32_t flag; + + /** VolumeToMeshResolutionMode */ + int resolution_mode; + float voxel_size; + int voxel_amount; + + /** MAX_NAME */ + char grid_name[64]; +} VolumeToMeshModifierData; + +/** VolumeToMeshModifierData->resolution_mode */ +typedef enum VolumeToMeshResolutionMode { + VOLUME_TO_MESH_RESOLUTION_MODE_GRID = 0, + VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT = 1, + VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE = 2, +} VolumeToMeshResolutionMode; + +/** VolumeToMeshModifierData->flag */ +typedef enum VolumeToMeshFlag { + VOLUME_TO_MESH_USE_SMOOTH_SHADE = 1 << 0, +} VolumeToMeshFlag; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesdna/DNA_movieclip_defaults.h b/source/blender/makesdna/DNA_movieclip_defaults.h new file mode 100644 index 00000000000..4aa1bd779c2 --- /dev/null +++ b/source/blender/makesdna/DNA_movieclip_defaults.h @@ -0,0 +1,50 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name MovieClip Struct + * \{ */ + +#define _DNA_DEFAULT_MovieClipProxy \ + { \ + .build_size_flag = IMB_PROXY_25, \ + .build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN | \ + IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN | IMB_TC_RECORD_RUN_NO_GAPS, \ + .quality = 90, \ + } + + +#define _DNA_DEFAULT_MovieClip \ + { \ + .aspx = 1.0f, \ + .aspy = 1.0f, \ + .proxy = _DNA_DEFAULT_MovieClipProxy, \ + .start_frame = 1, \ + .frame_offset = 0, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 1d76ebdff2c..6f6c9029d07 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -155,10 +155,6 @@ typedef enum eNodeSocketDatatype { SOCK_STRING = 7, SOCK_OBJECT = 8, SOCK_IMAGE = 9, - SOCK_EMITTERS = 10, - SOCK_EVENTS = 11, - SOCK_FORCES = 12, - SOCK_CONTROL_FLOW = 13, } eNodeSocketDatatype; /* socket shape */ @@ -927,6 +923,8 @@ typedef struct NodeTexMagic { typedef struct NodeShaderAttribute { char name[64]; + int type; + char _pad[4]; } NodeShaderAttribute; typedef struct NodeShaderVectTransform { @@ -1096,6 +1094,13 @@ typedef struct NodeDenoise { #define SHD_VECT_TRANSFORM_SPACE_OBJECT 1 #define SHD_VECT_TRANSFORM_SPACE_CAMERA 2 +/* attribute */ +enum { + SHD_ATTRIBUTE_GEOMETRY = 0, + SHD_ATTRIBUTE_OBJECT = 1, + SHD_ATTRIBUTE_INSTANCER = 2, +}; + /* toon modes */ #define SHD_TOON_DIFFUSE 0 #define SHD_TOON_GLOSSY 1 @@ -1356,7 +1361,7 @@ enum { /* subsurface */ enum { #ifdef DNA_DEPRECATED_ALLOW - SHD_SUBSURFACE_COMPATIBLE = 0, // Deprecated + SHD_SUBSURFACE_COMPATIBLE = 0, /* Deprecated */ #endif SHD_SUBSURFACE_CUBIC = 1, SHD_SUBSURFACE_GAUSSIAN = 2, diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h index 3b0640544ae..3bd11d02b7a 100644 --- a/source/blender/makesdna/DNA_object_force_types.h +++ b/source/blender/makesdna/DNA_object_force_types.h @@ -54,7 +54,7 @@ typedef enum ePFieldType { PFIELD_LENNARDJ = 9, /** Defines predator / goal for boids. */ PFIELD_BOID = 10, - /** Force defined by BLI_gTurbulence. */ + /** Force defined by BLI_noise_generic_turbulence. */ PFIELD_TURBULENCE = 11, /** Linear & quadratic drag. */ PFIELD_DRAG = 12, diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 586c704e0f1..345d1287ab1 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -202,7 +202,7 @@ typedef struct Object { /** Old animation system, deprecated for 2.5. */ struct Ipo *ipo DNA_DEPRECATED; /* struct Path *path; */ - struct bAction *action DNA_DEPRECATED; // XXX deprecated... old animation system + struct bAction *action DNA_DEPRECATED; /* XXX deprecated... old animation system */ struct bAction *poselib; /** Pose data, armature objects only. */ struct bPose *pose; @@ -211,7 +211,7 @@ typedef struct Object { /** Grease Pencil data. */ struct bGPdata *gpd - DNA_DEPRECATED; // XXX deprecated... replaced by gpencil object, keep for readfile + DNA_DEPRECATED; /* XXX deprecated... replaced by gpencil object, keep for readfile */ /** Settings for visualization of object-transform animation. */ bAnimVizSettings avs; @@ -219,8 +219,8 @@ typedef struct Object { bMotionPath *mpath; void *_pad0; - ListBase constraintChannels DNA_DEPRECATED; // XXX deprecated... old animation system - ListBase effect DNA_DEPRECATED; // XXX deprecated... keep for readfile + ListBase constraintChannels DNA_DEPRECATED; /* XXX deprecated... old animation system */ + ListBase effect DNA_DEPRECATED; /* XXX deprecated... keep for readfile */ /** List of bDeformGroup (vertex groups) names and flag only. */ ListBase defbase; /** List of ModifierData structures. */ @@ -352,8 +352,8 @@ typedef struct Object { /** Object constraints. */ ListBase constraints; - ListBase nlastrips DNA_DEPRECATED; // XXX deprecated... old animation system - ListBase hooks DNA_DEPRECATED; // XXX deprecated... old animation system + ListBase nlastrips DNA_DEPRECATED; /* XXX deprecated... old animation system */ + ListBase hooks DNA_DEPRECATED; /* XXX deprecated... old animation system */ /** Particle systems. */ ListBase particlesystem; @@ -366,7 +366,7 @@ typedef struct Object { /** If fluidsim enabled, store additional settings. */ struct FluidsimSettings *fluidsimSettings - DNA_DEPRECATED; // XXX deprecated... replaced by mantaflow, keep for readfile + DNA_DEPRECATED; /* XXX deprecated... replaced by mantaflow, keep for readfile */ ListBase pc_ids; @@ -508,7 +508,7 @@ enum { /* (short) transflag */ enum { - OB_TRANSFLAG_UNUSED_0 = 1 << 0, /* cleared */ + OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK = 1 << 0, OB_TRANSFLAG_UNUSED_1 = 1 << 1, /* cleared */ OB_NEG_SCALE = 1 << 2, OB_TRANSFLAG_UNUSED_3 = 1 << 3, /* cleared */ diff --git a/source/blender/makesdna/DNA_particle_defaults.h b/source/blender/makesdna/DNA_particle_defaults.h new file mode 100644 index 00000000000..85971b8e9b7 --- /dev/null +++ b/source/blender/makesdna/DNA_particle_defaults.h @@ -0,0 +1,113 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name ParticleSettings Struct + * \{ */ + +#define _DNA_DEFAULT_ParticleSettings \ + { \ + .type = PART_EMITTER, \ + .distr = PART_DISTR_JIT, \ + .draw_as = PART_DRAW_REND, \ + .ren_as = PART_DRAW_HALO, \ + .bb_uv_split = 1, \ + .flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR, \ + \ + .sta = 1.0f, \ + .end = 200.0f, \ + .lifetime = 50.0f, \ + .jitfac = 1.0f, \ + .totpart = 1000, \ + .grid_res = 10, \ + .timetweak = 1.0f, \ + .courant_target = 0.2f, \ + \ + .integrator = PART_INT_MIDPOINT, \ + .phystype = PART_PHYS_NEWTON, \ + .hair_step = 5, \ + .keys_step = 5, \ + .draw_step = 2, \ + .ren_step = 3, \ + .adapt_angle = 5, \ + .adapt_pix = 3, \ + .kink_axis = 2, \ + .kink_amp_clump = 1.0f, \ + .kink_extra_steps = 4, \ + .clump_noise_size = 1.0f, \ + .reactevent = PART_EVENT_DEATH, \ + .disp = 100, \ + .from = PART_FROM_FACE, \ + \ + .normfac = 1.0f, \ + \ + .mass = 1.0f, \ + .size = 0.05f, \ + .childsize = 1.0f, \ + \ + .rotmode = PART_ROT_VEL, \ + .avemode = PART_AVE_VELOCITY, \ + \ + .child_nbr = 10, \ + .ren_child_nbr = 100, \ + .childrad = 0.2f, \ + .childflat = 0.0f, \ + .clumppow = 0.0f, \ + .kink_amp = 0.2f, \ + .kink_freq = 2.0f, \ + \ + .rough1_size = 1.0f, \ + .rough2_size = 1.0f, \ + .rough_end_shape = 1.0f, \ + \ + .clength = 1.0f, \ + .clength_thres = 0.0f, \ + \ + .draw = 0, \ + .draw_line = {0.5f,}, \ + .path_start = 0.0f, \ + .path_end = 1.0f, \ + \ + .bb_size = {1.0f, 1.0f}, \ + \ + .keyed_loops = 1, \ + \ + .color_vec_max = 1.0f, \ + .draw_col = PART_DRAW_COL_MAT, \ + \ + .omat = 1, \ + .use_modifier_stack = false, \ + .draw_size = 0.1f, \ + \ + .shape_flag = PART_SHAPE_CLOSE_TIP, \ + .shape = 0.0f, \ + .rad_root = 1.0f, \ + .rad_tip = 0.0f, \ + .rad_scale = 0.01f, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 00f888dde5b..bd19498eba7 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -131,7 +131,7 @@ typedef struct ParticleData { /** Index to derived mesh data (face) to avoid slow lookups. */ int num_dmcache; - /** Coordinates on face/edge number "num" and depth alon.g*/ + /** Coordinates on face/edge number "num" and depth along. */ float fuv[4], foffset; /* face normal for volume emission. */ @@ -272,7 +272,7 @@ typedef struct ParticleSettings { struct Collection *instance_collection; struct ListBase instance_weights; - struct Collection *force_group DNA_DEPRECATED; // deprecated + struct Collection *force_group DNA_DEPRECATED; /* deprecated */ struct Object *instance_object; struct Object *bb_ob; /** Old animation system, deprecated for 2.5. */ diff --git a/source/blender/makesdna/DNA_pointcache_types.h b/source/blender/makesdna/DNA_pointcache_types.h index 678be7d8297..79d46ffe112 100644 --- a/source/blender/makesdna/DNA_pointcache_types.h +++ b/source/blender/makesdna/DNA_pointcache_types.h @@ -78,7 +78,7 @@ typedef struct PointCache { /** * The number of frames between cached frames. * This should probably be an upper bound for a per point adaptive step in the future, - * buf for now it's the same for all points. Without adaptivity this can effect the perceived + * but for now it's the same for all points. Without adaptivity this can effect the perceived * simulation quite a bit though. If for example particles are colliding with a horizontal * plane (with high damping) they quickly come to a stop on the plane, however there are still * forces acting on the particle (gravity and collisions), so the particle velocity isn't @@ -140,7 +140,7 @@ typedef struct PointCache { //#define PTCACHE_BAKE_EDIT (1 << 4) //#define PTCACHE_BAKE_EDIT_ACTIVE (1 << 5) #define PTCACHE_DISK_CACHE (1 << 6) -///* removed since 2.64 - [#30974], could be added back in a more useful way */ +///* removed since 2.64 - T30974, could be added back in a more useful way */ //#define PTCACHE_QUICK_CACHE (1 << 7) #define PTCACHE_FRAMES_SKIPPED (1 << 8) #define PTCACHE_EXTERNAL (1 << 9) diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h index 69580da8c5f..ae02ac5ee35 100644 --- a/source/blender/makesdna/DNA_scene_defaults.h +++ b/source/blender/makesdna/DNA_scene_defaults.h @@ -128,6 +128,7 @@ \ .simplify_subsurf = 6, \ .simplify_particles = 1.0f, \ + .simplify_volumes = 1.0f, \ \ .border.xmin = 0.0f, \ .border.ymin = 0.0f, \ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 1a63c532c68..028e150d904 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -28,6 +28,10 @@ /* XXX, temp feature - campbell */ #define DURIAN_CAMERA_SWITCH +/* check for cyclic set-scene, + * libs can cause this case which is normally prevented, see (T#####) */ +#define USE_SETSCENE_CHECK + #include "DNA_ID.h" #include "DNA_collection_types.h" #include "DNA_color_types.h" /* color management */ @@ -182,8 +186,8 @@ typedef struct FFMpegCodecData { /* Audio */ typedef struct AudioData { - int mixrate; // 2.5: now in FFMpegCodecData: audio_mixrate - float main; // 2.5: now in FFMpegCodecData: audio_volume + int mixrate; /* 2.5: now in FFMpegCodecData: audio_mixrate */ + float main; /* 2.5: now in FFMpegCodecData: audio_volume */ float speed_of_sound; float doppler_factor; int distance_model; @@ -622,7 +626,7 @@ typedef struct RenderData { /** Frames to jump during render/playback. */ int frame_step; - /** Standalone player stereo settings */ // XXX deprecated since .2.5 + /** Standalone player stereo settings */ /* XXX deprecated since .2.5 */ short stereomode DNA_DEPRECATED; /** For the dimensions presets menu. */ @@ -731,7 +735,7 @@ typedef struct RenderData { char seq_rend_type; /** Flag use for sequence render/draw. */ char seq_flag; - char _pad5[7]; + char _pad5[3]; /* render simplify */ short simplify_subsurf; @@ -739,6 +743,7 @@ typedef struct RenderData { short simplify_gpencil; float simplify_particles; float simplify_particles_render; + float simplify_volumes; /* Freestyle line thickness options */ int line_thickness_mode; @@ -837,6 +842,7 @@ typedef struct TimeMarker { char name[64]; unsigned int flag; struct Object *camera; + struct IDProperty *prop; } TimeMarker; /* *************************************************************** */ @@ -860,7 +866,7 @@ typedef struct PaintToolSlot { typedef struct Paint { struct Brush *brush; - /* Each tool has it's own active brush, + /* Each tool has its own active brush, * The currently active tool is defined by the current 'brush'. */ struct PaintToolSlot *tool_slots; int tool_slots_len; @@ -1633,8 +1639,10 @@ typedef struct SceneEEVEE { int motion_blur_samples DNA_DEPRECATED; int motion_blur_max; int motion_blur_steps; + int motion_blur_position; float motion_blur_shutter; float motion_blur_depth_scale; + char _pad0[4]; int shadow_method DNA_DEPRECATED; int shadow_cube_size; @@ -2179,7 +2187,7 @@ typedef enum eSculptFlags { SCULPT_FLAG_UNUSED_7 = (1 << 7), /* cleared */ SCULPT_ONLY_DEFORM = (1 << 8), - // SCULPT_SHOW_DIFFUSE = (1 << 9), // deprecated + // SCULPT_SHOW_DIFFUSE = (1 << 9), /* deprecated */ /* If set, the mesh will be drawn with smooth-shading in * dynamic-topology mode */ @@ -2199,7 +2207,7 @@ typedef enum eSculptFlags { SCULPT_HIDE_MASK = (1 << 15), /* Don't display face sets in viewport. */ - SCULPT_HIDE_FACE_SETS = (1 << 16), + SCULPT_HIDE_FACE_SETS = (1 << 17), } eSculptFlags; /* ImagePaintSettings.mode */ @@ -2216,8 +2224,8 @@ enum { /* ImagePaintSettings.flag */ #define IMAGEPAINT_DRAWING (1 << 0) -// #define IMAGEPAINT_DRAW_TOOL (1 << 1) // deprecated -// #define IMAGEPAINT_DRAW_TOOL_DRAWING (1 << 2) // deprecated +// #define IMAGEPAINT_DRAW_TOOL (1 << 1) /* deprecated */ +// #define IMAGEPAINT_DRAW_TOOL_DRAWING (1 << 2) /* deprecated */ /* projection painting only */ /* ImagePaintSettings.flag */ @@ -2403,6 +2411,13 @@ enum { /* SHADOW_METHOD_MAX = 3, */ /* UNUSED */ }; +/* SceneEEVEE->motion_blur_position */ +enum { + SCE_EEVEE_MB_CENTER = 0, + SCE_EEVEE_MB_START = 1, + SCE_EEVEE_MB_END = 2, +}; + /* SceneDisplay->render_aa, SceneDisplay->viewport_aa */ enum { SCE_DISPLAY_AA_OFF = 0, diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 93110d148bf..7101dacc803 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -33,14 +33,15 @@ struct ARegion; struct ARegionType; struct PanelType; +struct PointerRNA; struct Scene; struct SpaceLink; struct SpaceType; +struct uiBlock; struct uiLayout; struct wmDrawBuffer; struct wmTimer; struct wmTooltipState; -struct PointerRNA; /* TODO Doing this is quite ugly :) * Once the top-bar is merged bScreen should be refactored to use ScrAreaMap. */ @@ -94,7 +95,7 @@ typedef struct bScreen { /** If set, screen has timer handler added in window. */ struct wmTimer *animtimer; /** Context callback. */ - void *context; + void /*bContextDataCallback*/ *context; /** Runtime. */ struct wmTooltipState *tool_tip; @@ -143,6 +144,10 @@ typedef struct Panel_Runtime { * This avoids freeing the same pointer twice when panels are removed. */ struct PointerRNA *custom_data_ptr; + + /* Pointer to the panel's block. Useful when changes to panel #uiBlocks + * need some context from traversal of the panel "tree". */ + struct uiBlock *block; } Panel_Runtime; /** The part from uiBlock that needs saved in file. */ @@ -165,9 +170,8 @@ typedef struct Panel { /** Panel size excluding children. */ int blocksizex, blocksizey; short labelofs; - char _pad[4]; short flag, runtime_flag; - short snap; + char _pad[6]; /** Panels are aligned according to increasing sort-order. */ int sortorder; /** Runtime for panel manipulation. */ @@ -179,6 +183,34 @@ typedef struct Panel { } Panel; /** + * Used for passing expansion between instanced panel data and the panels themselves. + * There are 16 defines because the expansion data is typically stored in a short. + * + * \note Expansion for instanced panels is stored in depth first order. For example, the value of + * UI_SUBPANEL_DATA_EXPAND_2 correspond to mean the expansion of the second subpanel or the first + * subpanel's first subpanel. + */ +typedef enum uiPanelDataExpansion { + UI_PANEL_DATA_EXPAND_ROOT = (1 << 0), + UI_SUBPANEL_DATA_EXPAND_1 = (1 << 1), + UI_SUBPANEL_DATA_EXPAND_2 = (1 << 2), + UI_SUBPANEL_DATA_EXPAND_3 = (1 << 3), + UI_SUBPANEL_DATA_EXPAND_4 = (1 << 4), + UI_SUBPANEL_DATA_EXPAND_5 = (1 << 5), + UI_SUBPANEL_DATA_EXPAND_6 = (1 << 6), + UI_SUBPANEL_DATA_EXPAND_7 = (1 << 7), + UI_SUBPANEL_DATA_EXPAND_8 = (1 << 8), + UI_SUBPANEL_DATA_EXPAND_9 = (1 << 9), + UI_SUBPANEL_DATA_EXPAND_10 = (1 << 10), + UI_SUBPANEL_DATA_EXPAND_11 = (1 << 11), + UI_SUBPANEL_DATA_EXPAND_12 = (1 << 12), + UI_SUBPANEL_DATA_EXPAND_13 = (1 << 13), + UI_SUBPANEL_DATA_EXPAND_14 = (1 << 14), + UI_SUBPANEL_DATA_EXPAND_15 = (1 << 15), + UI_SUBPANEL_DATA_EXPAND_16 = (1 << 16), +} uiPanelDataExpansion; + +/** * Notes on Panel Categories: * * - #ARegion.panels_category (#PanelCategoryDyn) @@ -289,10 +321,6 @@ typedef struct uiPreview { char _pad1[6]; } uiPreview; -/* These two lines with # tell makesdna this struct can be excluded. - * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */ -# -# typedef struct ScrGlobalAreaData { /* Global areas have a non-dynamic size. That means, changing the window * size doesn't affect their size at all. However, they can still be @@ -543,15 +571,6 @@ enum { PNL_INSTANCED_LIST_ORDER_CHANGED = (1 << 7), }; -/** #Panel.snap - for snapping to screen edges */ -#define PNL_SNAP_NONE 0 -/* #define PNL_SNAP_TOP 1 */ -/* #define PNL_SNAP_RIGHT 2 */ -#define PNL_SNAP_BOTTOM 4 -/* #define PNL_SNAP_LEFT 8 */ - -/* #define PNL_SNAP_DIST 9.0 */ - /* paneltype flag */ enum { PNL_DEFAULT_CLOSED = (1 << 0), @@ -687,6 +706,14 @@ enum { /** When the user sets the region is hidden, * needed for floating regions that may be hidden for other reasons. */ RGN_FLAG_HIDDEN_BY_USER = (1 << 7), + /** Property search filter is active. */ + RGN_FLAG_SEARCH_FILTER_ACTIVE = (1 << 8), + /** + * Update the expansion of the region's panels and switch contexts. Only Set + * temporarily when the search filter is updated and cleared at the end of the + * region's layout pass. so that expansion is still interactive, + */ + RGN_FLAG_SEARCH_FILTER_UPDATE = (1 << 9), }; /** #ARegion.do_draw */ diff --git a/source/blender/makesdna/DNA_sdna_types.h b/source/blender/makesdna/DNA_sdna_types.h index cfb65860b8e..4505eed3208 100644 --- a/source/blender/makesdna/DNA_sdna_types.h +++ b/source/blender/makesdna/DNA_sdna_types.h @@ -26,6 +26,30 @@ struct MemArena; # # +typedef struct SDNA_StructMember { + /** This struct must not change, it's only a convenience view for raw data stored in SDNA. */ + + /** An index into SDNA->types. */ + short type; + /** An index into SDNA->names. */ + short name; +} SDNA_StructMember; + +# +# +typedef struct SDNA_Struct { + /** This struct must not change, it's only a convenience view for raw data stored in SDNA. */ + + /** An index into SDNA->types. */ + short type; + /** The amount of members in this struct. */ + short members_len; + /** "Flexible array member" that contains information about all members of this struct. */ + SDNA_StructMember members[]; +} SDNA_Struct; + +# +# typedef struct SDNA { /** Full copy of 'encoded' data (when data_alloc is set, otherwise borrowed). */ const char *data; @@ -51,14 +75,8 @@ typedef struct SDNA { /** Type lengths. */ short *types_size; - /** - * sp = structs[a] is the address of a struct definition - * sp[0] is struct type number, sp[1] amount of members - * - * (sp[2], sp[3]), (sp[4], sp[5]), .. are the member - * type and name numbers respectively. - */ - short **structs; + /** Information about structs and their members. */ + SDNA_Struct **structs; /** Number of struct types. */ int structs_len; @@ -74,7 +92,7 @@ typedef struct SDNA { const char **names; /** Aligned with #SDNA.types, same pointers when unchanged. */ const char **types; - /** A version of #SDNA.structs_map that uses #SDNA.alias.types for it's keys. */ + /** A version of #SDNA.structs_map that uses #SDNA.alias.types for its keys. */ struct GHash *structs_map; } alias; } SDNA; @@ -90,13 +108,13 @@ typedef struct BHead { # typedef struct BHead4 { int code, len; - int old; + uint old; int SDNAnr, nr; } BHead4; # # typedef struct BHead8 { int code, len; - int64_t old; + uint64_t old; int SDNAnr, nr; } BHead8; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 850b906af39..e21f3e1e706 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -68,6 +68,9 @@ typedef struct StripCrop { typedef struct StripTransform { int xofs; int yofs; + float scale_x; + float scale_y; + float rotation; } StripTransform; typedef struct StripColorBalance { @@ -76,24 +79,24 @@ typedef struct StripColorBalance { float gain[3]; int flag; char _pad[4]; - // float exposure; - // float saturation; + /* float exposure; */ + /* float saturation; */ } StripColorBalance; typedef struct StripProxy { - char dir[768]; // custom directory for index and proxy files - // (defaults to BL_proxy) + char dir[768]; /* custom directory for index and proxy files */ + /* (defaults to BL_proxy) */ - char file[256]; // custom file - struct anim *anim; // custom proxy anim file + char file[256]; /* custom file */ + struct anim *anim; /* custom proxy anim file */ - short tc; // time code in use + short tc; /* time code in use */ - short quality; // proxy build quality - short build_size_flags; // size flags (see below) of all proxies - // to build - short build_tc_flags; // time code flags (see below) of all tc indices - // to build + short quality; /* proxy build quality */ + short build_size_flags; /* size flags (see below) of all proxies */ + /* to build */ + short build_tc_flags; /* time code flags (see below) of all tc indices */ + /* to build */ short build_flags; char storage; char _pad[5]; @@ -338,17 +341,19 @@ typedef struct TextVars { VFont *text_font; int text_blf_id; int text_size; - float color[4], shadow_color[4]; + float color[4], shadow_color[4], box_color[4]; float loc[2]; float wrap_width; + float box_margin; char flag; char align, align_y; - char _pad[1]; + char _pad[5]; } TextVars; /* TextVars.flag */ enum { SEQ_TEXT_SHADOW = (1 << 0), + SEQ_TEXT_BOX = (1 << 1), }; /* TextVars.align */ @@ -494,8 +499,8 @@ enum { SEQ_MAKE_FLOAT = (1 << 13), SEQ_LOCK = (1 << 14), SEQ_USE_PROXY = (1 << 15), - SEQ_USE_TRANSFORM = (1 << 16), - SEQ_USE_CROP = (1 << 17), + SEQ_FLAG_UNUSED_23 = (1 << 16), /* cleared */ + SEQ_FLAG_UNUSED_22 = (1 << 17), /* cleared */ SEQ_FLAG_UNUSED_18 = (1 << 18), /* cleared */ SEQ_FLAG_UNUSED_19 = (1 << 19), /* cleared */ SEQ_FLAG_UNUSED_21 = (1 << 21), /* cleared */ diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h index 56caac51b94..07ccac5ba29 100644 --- a/source/blender/makesdna/DNA_shader_fx_types.h +++ b/source/blender/makesdna/DNA_shader_fx_types.h @@ -49,7 +49,9 @@ typedef enum ShaderFxMode { eShaderFxMode_Realtime = (1 << 0), eShaderFxMode_Render = (1 << 1), eShaderFxMode_Editmode = (1 << 2), +#ifdef DNA_DEPRECATED_ALLOW eShaderFxMode_Expanded_DEPRECATED = (1 << 3), +#endif } ShaderFxMode; typedef enum { @@ -61,9 +63,9 @@ typedef struct ShaderFxData { struct ShaderFxData *next, *prev; int type, mode; - int stackindex; + char _pad0[4]; short flag; - /* Expansion for shader effect panels and sub-panels. */ + /* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */ short ui_expand_flag; /** MAX_NAME. */ char name[64]; diff --git a/source/blender/makesdna/DNA_simulation_types.h b/source/blender/makesdna/DNA_simulation_types.h index 8cc2db99332..4ff694b29cc 100644 --- a/source/blender/makesdna/DNA_simulation_types.h +++ b/source/blender/makesdna/DNA_simulation_types.h @@ -27,69 +27,14 @@ typedef struct Simulation { ID id; struct AnimData *adt; /* animation data (must be immediately after id) */ + /* This nodetree is embedded into the data block. */ struct bNodeTree *nodetree; uint32_t flag; - - /** This is the frame in scene time, that the states correspond to. */ - float current_frame; - - /** Time since the start of the simulation in simulation time (which might differ from scene - * time). */ - float current_simulation_time; char _pad[4]; - - /** List containing SimulationState objects. */ - struct ListBase states; - - /** List containing SimulationDependency objects. */ - struct ListBase dependencies; } Simulation; -typedef struct SimulationState { - struct SimulationState *next; - struct SimulationState *prev; - - char *type; - char *name; -} SimulationState; - -typedef struct ParticleSimulationState { - SimulationState head; - - /** Contains the state of the particles at time Simulation->current_frame. */ - int32_t tot_particles; - int32_t next_particle_id; - struct CustomData attributes; -} ParticleSimulationState; - -typedef struct ParticleMeshEmitterSimulationState { - SimulationState head; - - float last_birth_time; - char _pad[4]; -} ParticleMeshEmitterSimulationState; - -/** Stores a reference to data that the simulation depends on. This is partially derived from the - * simulation node tree. */ -typedef struct SimulationDependency { - struct SimulationDependency *next; - struct SimulationDependency *prev; - struct ID *id; - int32_t handle; - uint32_t flag; -} SimulationDependency; - /* Simulation.flag */ enum { SIM_DS_EXPAND = (1 << 0), }; - -/* SimulationDependency.flag */ -enum { - SIM_DEPENDS_ON_TRANSFORM = (1 << 0), - SIM_DEPENDS_ON_GEOMETRY = (1 << 1), -}; - -#define SIM_TYPE_NAME_PARTICLE_SIMULATION "Particle Simulation" -#define SIM_TYPE_NAME_PARTICLE_MESH_EMITTER "Particle Mesh Emitter" diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 1d24e655f45..39e1c730f10 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -64,9 +64,9 @@ typedef struct bSound { short tags; char _pad[4]; - /* unused currently - int type; - struct bSound *child_sound; */ + /* Unused currently. */ + // int type; + // struct bSound *child_sound; /** * The audaspace handle for cache. @@ -80,7 +80,7 @@ typedef struct bSound { /** * The audaspace handle that should actually be played back. - * Should be cache if cache != NULL; otherwise it's handle + * Should be cache if cache != NULL; otherwise its handle */ void *playback_handle; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 06ab01a9730..a3aa79d29e8 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -56,9 +56,8 @@ struct bNodeTree; struct wmOperator; struct wmTimer; -/* TODO 2.8: We don't write the global areas to files currently. Uncomment - * define to enable writing (should become the default in a bit). */ -//#define WITH_GLOBAL_AREA_WRITING +/* Defined in `buttons_intern.h`. */ +typedef struct SpaceProperties_Runtime SpaceProperties_Runtime; /* -------------------------------------------------------------------- */ /** \name SpaceLink (Base) @@ -159,6 +158,9 @@ typedef struct SpaceProperties { ID *pinid; void *texuser; + + /* Doesn't necessarily need to be a pointer, but runtime structs are still written to files. */ + struct SpaceProperties_Runtime *runtime; } SpaceProperties; /* button defines (deprecated) */ @@ -232,6 +234,9 @@ typedef enum eSpaceButtons_Flag { /** \name Outliner * \{ */ +/* Defined in `outliner_intern.h`. */ +typedef struct SpaceOutliner_Runtime SpaceOutliner_Runtime; + /* Outliner */ typedef struct SpaceOutliner { SpaceLink *next, *prev; @@ -274,6 +279,8 @@ typedef struct SpaceOutliner { * Pointers to treestore elements, grouped by (id, type, nr) * in hashtable for faster searching */ void *treehash; + + SpaceOutliner_Runtime *runtime; } SpaceOutliner; /* SpaceOutliner.flag */ @@ -303,11 +310,11 @@ typedef enum eSpaceOutliner_Filter { SO_FILTER_NO_OB_CAMERA = (1 << 10), SO_FILTER_NO_OB_OTHERS = (1 << 11), - SO_FILTER_UNUSED_12 = (1 << 12), /* cleared */ - SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */ - SO_FILTER_OB_STATE_HIDDEN = (1 << 14), /* Not set via DNA. */ - SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */ - SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */ + SO_FILTER_OB_STATE_SELECTABLE = (1 << 12), /* Not set via DNA. */ + SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */ + SO_FILTER_OB_STATE_HIDDEN = (1 << 14), /* Not set via DNA. */ + SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */ + SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */ SO_FILTER_NO_COLLECTION = (1 << 17), SO_FILTER_ID_TYPE = (1 << 18), @@ -319,7 +326,7 @@ typedef enum eSpaceOutliner_Filter { #define SO_FILTER_OB_STATE \ (SO_FILTER_OB_STATE_VISIBLE | SO_FILTER_OB_STATE_HIDDEN | SO_FILTER_OB_STATE_SELECTED | \ - SO_FILTER_OB_STATE_ACTIVE) + SO_FILTER_OB_STATE_ACTIVE | SO_FILTER_OB_STATE_SELECTABLE) #define SO_FILTER_ANY \ (SO_FILTER_NO_OB_CONTENT | SO_FILTER_NO_CHILDREN | SO_FILTER_OB_TYPE | SO_FILTER_OB_STATE | \ @@ -332,6 +339,7 @@ typedef enum eSpaceOutliner_StateFilter { SO_FILTER_OB_HIDDEN = 2, SO_FILTER_OB_SELECTED = 3, SO_FILTER_OB_ACTIVE = 4, + SO_FILTER_OB_SELECTABLE = 5, } eSpaceOutliner_StateFilter; /* SpaceOutliner.show_restrict_flags */ @@ -462,7 +470,7 @@ typedef enum eGraphEdit_Flag { /* don't draw curves with AA ("beauty-draw") for performance */ SIPO_BEAUTYDRAW_OFF = (1 << 12), /* draw grouped channels with colors set in group */ - SIPO_NODRAWGCOLORS = (1 << 13), + /* SIPO_NODRAWGCOLORS = (1 << 13), DEPRECATED */ /* normalize curves on display */ SIPO_NORMALIZE = (1 << 14), SIPO_NORMALIZE_FREEZE = (1 << 15), @@ -625,13 +633,13 @@ typedef enum eSpaceSeq_Displays { /* SpaceSeq.render_size */ typedef enum eSpaceSeq_Proxy_RenderSize { - SEQ_PROXY_RENDER_SIZE_NONE = -1, - SEQ_PROXY_RENDER_SIZE_SCENE = 0, - SEQ_PROXY_RENDER_SIZE_25 = 25, - SEQ_PROXY_RENDER_SIZE_50 = 50, - SEQ_PROXY_RENDER_SIZE_75 = 75, - SEQ_PROXY_RENDER_SIZE_100 = 99, - SEQ_PROXY_RENDER_SIZE_FULL = 100, + SEQ_RENDER_SIZE_NONE = -1, + SEQ_RENDER_SIZE_SCENE = 0, + SEQ_RENDER_SIZE_PROXY_25 = 25, + SEQ_RENDER_SIZE_PROXY_50 = 50, + SEQ_RENDER_SIZE_PROXY_75 = 75, + SEQ_RENDER_SIZE_PROXY_100 = 99, + SEQ_RENDER_SIZE_FULL = 100, } eSpaceSeq_Proxy_RenderSize; typedef struct MaskSpaceInfo { @@ -758,7 +766,13 @@ typedef struct SpaceFile { /* FileSelectParams.display */ enum eFileDisplayType { + /** Internal (not exposed to users): Keep whatever display type was used during the last File + * Browser use, or the default if no such record is found. Use this unless there's a good reason + * to set a specific display type. */ FILE_DEFAULTDISPLAY = 0, + + /* User selectable choices. */ + FILE_VERTICALDISPLAY = 1, FILE_HORIZONTALDISPLAY = 2, FILE_IMGDISPLAY = 3, @@ -766,7 +780,13 @@ enum eFileDisplayType { /* FileSelectParams.sort */ enum eFileSortType { - FILE_SORT_NONE = 0, + /** Internal (not exposed to users): Sort by whatever was sorted by during the last File Browser + * use, or the default if no such record is found. Use this unless there's a good reason to set a + * specific sort order. */ + FILE_SORT_DEFAULT = 0, + + /* User selectable choices. */ + FILE_SORT_ALPHA = 1, FILE_SORT_EXTENSION = 2, FILE_SORT_TIME = 3, @@ -1027,6 +1047,12 @@ enum { * \{ */ /* Image/UV Editor */ + +typedef struct SpaceImageOverlay { + int flag; + char _pad[4]; +} SpaceImageOverlay; + typedef struct SpaceImage { SpaceLink *next, *prev; /** Storage of regions for inactive spaces. */ @@ -1086,6 +1112,7 @@ typedef struct SpaceImage { int tile_grid_shape[2]; MaskSpaceInfo mask_info; + SpaceImageOverlay overlay; } SpaceImage; /* SpaceImage.dt_uv */ @@ -1148,7 +1175,7 @@ typedef enum eSpaceImage_Flag { SI_PREVSPACE = (1 << 15), SI_FULLWINDOW = (1 << 16), - SI_FLAG_UNUSED_17 = (1 << 17), /* cleared */ + SI_FLAG_UNUSED_17 = (1 << 17), SI_FLAG_UNUSED_18 = (1 << 18), /* cleared */ /** @@ -1156,7 +1183,7 @@ typedef enum eSpaceImage_Flag { * in the image view, it's unrelated to UDIM tiles. */ SI_DRAW_TILE = (1 << 19), - SI_SMOOTH_UV = (1 << 20), + SI_FLAG_UNUSED_20 = (1 << 20), /* cleared */ SI_DRAW_STRETCH = (1 << 21), SI_SHOW_GPENCIL = (1 << 22), SI_FLAG_UNUSED_23 = (1 << 23), /* cleared */ @@ -1171,6 +1198,10 @@ typedef enum eSpaceImage_Flag { SI_SHOW_B = (1 << 29), } eSpaceImage_Flag; +typedef enum eSpaceImageOverlay_Flag { + SI_OVERLAY_SHOW_OVERLAYS = (1 << 0), +} eSpaceImageOverlay_Flag; + /** \} */ /* -------------------------------------------------------------------- */ @@ -1655,10 +1686,6 @@ typedef enum eSpaceClip_GPencil_Source { /** \name Top Bar * \{ */ -/* These two lines with # tell makesdna this struct can be excluded. - * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */ -# -# typedef struct SpaceTopBar { SpaceLink *next, *prev; /** Storage of regions for inactive spaces. */ @@ -1675,10 +1702,6 @@ typedef struct SpaceTopBar { /** \name Status Bar * \{ */ -/* These two lines with # tell makesdna this struct can be excluded. - * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */ -# -# typedef struct SpaceStatusBar { SpaceLink *next, *prev; /** Storage of regions for inactive spaces. */ diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 63e5f134c19..5381c524e4d 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -192,7 +192,7 @@ typedef struct Tex { float cropxmin, cropymin, cropxmax, cropymax; int texfilter; - int afmax; // anisotropic filter maximum value, ewa -> max eccentricity, feline -> max probes + int afmax; /* anisotropic filter maximum value, ewa -> max eccentricity, feline -> max probes */ short xrepeat, yrepeat; short extend; @@ -318,8 +318,7 @@ typedef struct ColorMapping { #define TEX_DERIVATIVEMAP (1 << 14) /* texfilter */ -// TXF_BOX -> blender's old texture filtering method -#define TXF_BOX 0 +#define TXF_BOX 0 /* Blender's old texture filtering method. */ #define TXF_EWA 1 #define TXF_FELINE 2 #define TXF_AREA 3 diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 4cd9034a83b..0bbeabf130f 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -72,6 +72,12 @@ typedef struct MovieTrackingCamera { /* Nuke distortion model coefficients */ float nuke_k1, nuke_k2; + + /* Brown-Conrady distortion model coefficients */ + /** Brown-Conrady radial distortion **/ + float brown_k1, brown_k2, brown_k3, brown_k4; + /** Brown-Conrady tangential distortion **/ + float brown_p1, brown_p2; } MovieTrackingCamera; typedef struct MovieTrackingMarker { @@ -172,7 +178,7 @@ typedef struct MovieTrackingTrack { /* Weight of this track. * * Weight defines how much the track affects on the final reconstruction, - * usually gets animated in a way so when track has just appeared it's + * usually gets animated in a way so when track has just appeared its * weight is zero and then it gets faded up. * * Used to prevent jumps of the camera when tracks are appearing or @@ -282,8 +288,7 @@ typedef struct MovieTrackingSettings { int reconstruction_flag; /* which camera intrinsics to refine. uses on the REFINE_* flags */ - short refine_camera_intrinsics; - char _pad2[2]; + int refine_camera_intrinsics; /* ** tool settings ** */ @@ -458,6 +463,7 @@ enum { TRACKING_DISTORTION_MODEL_POLYNOMIAL = 0, TRACKING_DISTORTION_MODEL_DIVISION = 1, TRACKING_DISTORTION_MODEL_NUKE = 2, + TRACKING_DISTORTION_MODEL_BROWN = 3, }; /* MovieTrackingCamera->units */ @@ -544,10 +550,12 @@ enum { /* MovieTrackingSettings->refine_camera_intrinsics */ enum { + REFINE_NO_INTRINSICS = (0), + REFINE_FOCAL_LENGTH = (1 << 0), REFINE_PRINCIPAL_POINT = (1 << 1), - REFINE_RADIAL_DISTORTION_K1 = (1 << 2), - REFINE_RADIAL_DISTORTION_K2 = (1 << 4), + REFINE_RADIAL_DISTORTION = (1 << 2), + REFINE_TANGENTIAL_DISTORTION = (1 << 3), }; /* MovieTrackingStrabilization->flag */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b63f4529559..f673b193a39 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -275,7 +275,8 @@ typedef struct ThemeSpace { unsigned char wire[4], wire_edit[4], select[4]; unsigned char lamp[4], speaker[4], empty[4], camera[4]; unsigned char active[4], group[4], group_active[4], transform[4]; - unsigned char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; + unsigned char vertex[4], vertex_select[4], vertex_active[4], vertex_bevel[4], + vertex_unreferenced[4]; unsigned char edge[4], edge_select[4]; unsigned char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4]; /** Solid faces. */ @@ -321,10 +322,10 @@ typedef struct ThemeSpace { unsigned char grid_levels; /* syntax for textwindow and nodes */ - unsigned char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte - unsigned char syntaxb[4], syntaxn[4]; // in nodespace used for color input - unsigned char syntaxv[4], syntaxc[4]; // in nodespace used for converter group - unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort + unsigned char syntaxl[4], syntaxs[4]; /* in nodespace used for backdrop matte */ + unsigned char syntaxb[4], syntaxn[4]; /* in nodespace used for color input */ + unsigned char syntaxv[4], syntaxc[4]; /* in nodespace used for converter group */ + unsigned char syntaxd[4], syntaxr[4]; /* in nodespace used for distort */ unsigned char line_numbers[4]; char _pad6[3]; @@ -357,7 +358,7 @@ typedef struct ThemeSpace { unsigned char path_before[4], path_after[4]; unsigned char path_keyframe_before[4], path_keyframe_after[4]; unsigned char camera_path[4]; - unsigned char _pad1[2]; + unsigned char _pad1[6]; unsigned char gp_vertex_size; unsigned char gp_vertex[4], gp_vertex_select[4]; @@ -453,6 +454,10 @@ typedef enum eWireColor_Flags { /* TH_WIRECOLOR_TEXTCOLS = (1 << 1), */ /* UNUSED */ } eWireColor_Flags; +typedef struct ThemeCollectionColor { + unsigned char color[4]; +} ThemeCollectionColor; + /** * A theme. * @@ -491,6 +496,9 @@ typedef struct bTheme { ThemeWireColor tarm[20]; /*ThemeWireColor tobj[20];*/ + /* See COLLECTION_COLOR_TOT for the number of collection colors. */ + ThemeCollectionColor collection_color[8]; + int active_theme_area; char _pad0[4]; } bTheme; @@ -581,6 +589,7 @@ typedef struct WalkNavigation { } WalkNavigation; typedef struct UserDef_Runtime { + /** Mark as changed so the preferences are saved on exit. */ char is_dirty; char _pad0[7]; } UserDef_Runtime; @@ -615,15 +624,20 @@ typedef struct UserDef_FileSpaceData { } UserDef_FileSpaceData; typedef struct UserDef_Experimental { + /* Debug options, always available. */ char use_undo_legacy; - char use_new_particle_system; - char use_new_hair_type; char use_cycles_debug; + char SANITIZE_AFTER_HERE; + /* The following options are automatically sanitized (set to 0) + * when the release cycle is not alpha. */ + char use_new_geometry_nodes; + char use_new_hair_type; + char use_new_point_cloud_type; char use_sculpt_vertex_colors; - char use_image_editor_legacy_drawing; - char use_tools_missing_icons; + char use_switch_object_operator; + char use_sculpt_tools_tilt; + char _pad[7]; /** `makesdna` does not allow empty structs. */ - char _pad[1]; } UserDef_Experimental; #define USER_EXPERIMENTAL_TEST(userdef, member) \ @@ -812,13 +826,13 @@ typedef struct UserDef { short autokey_mode; /** Flags for autokeying. */ short autokey_flag; + /** Flags for animation. */ + short animation_flag; /** Options for text rendering. */ char text_render; char navigation_mode; - char _pad9[2]; - /** Turn-table rotation amount per-pixel in radians. Scaled with DPI. */ float view_rotate_sensitivity_turntable; /** Track-ball rotation scale. */ @@ -978,8 +992,9 @@ typedef enum ePathCompare_Flag { /* Helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) \ { \ - if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ + if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) { \ cfra = 0; \ + } \ } \ (void)0 @@ -1031,7 +1046,7 @@ typedef enum eUserpref_UI_Flag { USER_HIDE_DOT = (1 << 16), USER_SHOW_GIZMO_NAVIGATE = (1 << 17), USER_SHOW_VIEWPORTNAME = (1 << 18), - USER_CAM_LOCK_NO_PARENT = (1 << 19), + USER_UIFLAG_UNUSED_3 = (1 << 19), /* Cleared. */ USER_ZOOM_TO_MOUSEPOS = (1 << 20), USER_SHOW_FPS = (1 << 21), USER_UIFLAG_UNUSED_22 = (1 << 22), /* cleared */ @@ -1058,7 +1073,7 @@ typedef enum eUserpref_UI_Flag { typedef enum eUserpref_UI_Flag2 { USER_UIFLAG2_UNUSED_0 = (1 << 0), /* cleared */ USER_REGION_OVERLAP = (1 << 1), - USER_TRACKPAD_NATURAL = (1 << 2), + USER_UIFLAG2_UNUSED_2 = (1 << 2), USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */ } eUserpref_UI_Flag2; @@ -1132,6 +1147,15 @@ typedef enum eAutokey_Flag { ANIMRECORD_FLAG_WITHNLA = (1 << 10), } eAutokey_Flag; +/** + * Animation flags + * #UserDef.animation_flag, used for animation flags that aren't covered by more specific flags + * (like eAutokey_Flag). + */ +typedef enum eUserpref_Anim_Flags { + USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0), +} eUserpref_Anim_Flags; + /** #UserDef.transopts */ typedef enum eUserpref_Translation_Flags { USER_TR_TOOLTIPS = (1 << 0), diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index 63038b6be2d..085f463a1cc 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -67,13 +67,6 @@ typedef struct View2D { /** Pivot point for transforms (rotate and scale). */ short around; - /** Different offset per tab, for buttons. */ - float *tab_offset; - /** Number of tabs stored. */ - int tab_num; - /** Current tab. */ - int tab_cur; - /* Usually set externally (as in, not in view2d files). */ /** Alpha of vertical and horizontal scrollbars (range is [0, 255]). */ char alpha_vert, alpha_hor; diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h index 62e3d14bd0c..68f23b33d07 100644 --- a/source/blender/makesdna/DNA_view3d_defaults.h +++ b/source/blender/makesdna/DNA_view3d_defaults.h @@ -52,6 +52,7 @@ { \ .wireframe_threshold = 1.0f, \ .xray_alpha_bone = 0.5f, \ + .fade_alpha = 0.40f, \ .texture_paint_mode_opacity = 1.0f, \ .weight_paint_mode_opacity = 1.0f, \ .vertex_paint_mode_opacity = 1.0f, \ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 7bfdc14d25c..3fc8b05c8b4 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -218,6 +218,9 @@ typedef struct View3DOverlay { /** Armature edit/pose mode settings. */ float xray_alpha_bone; + /** Darken Inactive. */ + float fade_alpha; + /** Other settings. */ float wireframe_threshold; @@ -230,6 +233,7 @@ typedef struct View3DOverlay { float gpencil_vertex_paint_opacity; /** Handles display type for curves. */ int handle_display; + char _pad[4]; } View3DOverlay; /* View3DOverlay->handle_display */ @@ -479,6 +483,7 @@ enum { V3D_SHADING_DEPTH_OF_FIELD = (1 << 11), V3D_SHADING_SCENE_LIGHTS_RENDER = (1 << 12), V3D_SHADING_SCENE_WORLD_RENDER = (1 << 13), + V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION = (1 << 14), }; /** #View3DShading.cavity_type */ @@ -502,6 +507,7 @@ enum { V3D_OVERLAY_HIDE_OBJECT_XTRAS = (1 << 9), V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10), V3D_OVERLAY_STATS = (1 << 11), + V3D_OVERLAY_FADE_INACTIVE = (1 << 12), }; /** #View3DOverlay.edit_flag */ diff --git a/source/blender/makesdna/DNA_volume_defaults.h b/source/blender/makesdna/DNA_volume_defaults.h index 8239f263c6c..a710754659b 100644 --- a/source/blender/makesdna/DNA_volume_defaults.h +++ b/source/blender/makesdna/DNA_volume_defaults.h @@ -32,6 +32,7 @@ .density = 1.0f, \ .wireframe_type = VOLUME_WIREFRAME_BOXES, \ .wireframe_detail = VOLUME_WIREFRAME_COARSE, \ + .slice_depth = 0.5f, \ } #define _DNA_DEFAULT_VolumeRender \ diff --git a/source/blender/makesdna/DNA_volume_types.h b/source/blender/makesdna/DNA_volume_types.h index 30ac67281e2..d6a3cdf04bf 100644 --- a/source/blender/makesdna/DNA_volume_types.h +++ b/source/blender/makesdna/DNA_volume_types.h @@ -31,13 +31,19 @@ typedef struct Volume_Runtime { /* Current frame in sequence for evaluated volume */ int frame; - int _pad; + + /* Default simplify level for volume grids loaded from files. */ + int default_simplify_level; } Volume_Runtime; typedef struct VolumeDisplay { float density; int wireframe_type; int wireframe_detail; + int interpolation_method; + int axis_slice_method; + int slice_axis; + float slice_depth; int _pad[1]; } VolumeDisplay; @@ -119,5 +125,26 @@ typedef enum VolumeRenderSpace { VOLUME_SPACE_WORLD = 1, } VolumeRenderSpace; +/* VolumeDisplay.interpolation_method */ +typedef enum VolumeDisplayInterpMethod { + VOLUME_DISPLAY_INTERP_LINEAR = 0, + VOLUME_DISPLAY_INTERP_CUBIC = 1, + VOLUME_DISPLAY_INTERP_CLOSEST = 2, +} VolumeDisplayInterpMethod; + +/* VolumeDisplay.axis_slice_method */ +typedef enum AxisAlignedSlicingMethod { + VOLUME_AXIS_SLICE_FULL = 0, + VOLUME_AXIS_SLICE_SINGLE = 1, +} AxisAlignedSlicingMethod; + +/* VolumeDisplay.slice_axis */ +typedef enum SliceAxis { + VOLUME_SLICE_AXIS_AUTO = 0, + VOLUME_SLICE_AXIS_X = 1, + VOLUME_SLICE_AXIS_Y = 2, + VOLUME_SLICE_AXIS_Z = 3, +} SliceAxis; + /* Only one material supported currently. */ #define VOLUME_MATERIAL_NR 1 diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 3f7e3e61d56..4b4e17b38bd 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -383,6 +383,19 @@ enum { KMI_EXPANDED = (1 << 1), KMI_USER_MODIFIED = (1 << 2), KMI_UPDATE = (1 << 3), + /** + * When set, ignore events with #wmEvent.is_repeat enabled. + * + * \note this flag isn't cleared when editing/loading the key-map items, + * so it may be set in cases which don't make sense (modifier-keys or mouse-motion for example). + * + * Knowing if an event may repeat is something set at the operating-systems event handling level + * so rely on #wmEvent.is_repeat being false non keyboard events instead of checking if this + * flag makes sense. + * + * Only used when: `ISKEYBOARD(kmi->type) || (kmi->type == KM_TEXTINPUT)` + * as mouse, 3d-mouse, timer... etc never repeat. + */ KMI_REPEAT_IGNORE = (1 << 4), }; diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 170366881c6..b9ca2598ff3 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -160,10 +160,15 @@ typedef struct WorkSpaceDataRelation { struct WorkSpaceDataRelation *next, *prev; /** The data used to identify the relation - * (e.g. to find screen-layout (= value) from/for a hook). */ + * (e.g. to find screen-layout (= value) from/for a hook). + * Note: Now runtime only. */ void *parent; /** The value for this parent-data/workspace relation. */ void *value; + + /** Reference to the actual parent window, wmWindow->winid. Used in read/write code. */ + int parentid; + char _pad_0[4]; } WorkSpaceDataRelation; /** diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 9808740e030..2051335dd7e 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -26,6 +26,7 @@ blender_include_dirs( ../../../../intern/atomic ../../../../intern/guardedalloc ../../blenlib + ../../imbuf .. ) @@ -56,9 +57,9 @@ endif() # SRC_DNA_INC is defined in the parent dir add_cc_flags_custom_test(makesdna) -setup_platform_linker_flags() add_executable(makesdna ${SRC} ${SRC_DNA_INC}) +setup_platform_linker_flags(makesdna) if(WIN32 AND NOT UNIX) target_link_libraries(makesdna ${PTHREADS_LIBRARIES}) @@ -142,6 +143,8 @@ set(SRC ../DNA_camera_defaults.h ../DNA_curve_defaults.h ../DNA_defaults.h + ../DNA_fluid_defaults.h + ../DNA_gpencil_modifier_defaults.h ../DNA_hair_defaults.h ../DNA_image_defaults.h ../DNA_lattice_defaults.h @@ -151,6 +154,8 @@ set(SRC ../DNA_material_defaults.h ../DNA_mesh_defaults.h ../DNA_meta_defaults.h + ../DNA_modifier_defaults.h + ../DNA_modifier_types.h ../DNA_object_defaults.h ../DNA_pointcloud_defaults.h ../DNA_scene_defaults.h diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 50794d1d2e5..8c95a6d2a31 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -65,7 +65,7 @@ * - When loading old files that don't contain newly added struct members (these will be zeroed) * to set their values use `versioning_{BLENDER_VERSION}.c` source files. * - For startup file data, to update these defaults use - * #BLO_update_defaults_startup_blend & #BLO_version_defaults_userpref_blend. + * #BLO_update_defaults_startup_blend & #blo_do_versions_userdef. */ #include <limits.h> @@ -80,12 +80,19 @@ #include "BLI_memarena.h" #include "BLI_utildefines.h" +#include "IMB_imbuf.h" + #include "DNA_defaults.h" +#include "DNA_armature_types.h" #include "DNA_brush_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_cloth_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" +#include "DNA_fluid_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_hair_types.h" #include "DNA_image_types.h" #include "DNA_key_types.h" @@ -96,7 +103,10 @@ #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" +#include "DNA_modifier_types.h" +#include "DNA_movieclip_types.h" #include "DNA_object_types.h" +#include "DNA_particle_types.h" #include "DNA_pointcloud_types.h" #include "DNA_scene_types.h" #include "DNA_simulation_types.h" @@ -106,10 +116,14 @@ #include "DNA_volume_types.h" #include "DNA_world_types.h" +#include "DNA_armature_defaults.h" #include "DNA_brush_defaults.h" #include "DNA_cachefile_defaults.h" #include "DNA_camera_defaults.h" +#include "DNA_collection_defaults.h" #include "DNA_curve_defaults.h" +#include "DNA_fluid_defaults.h" +#include "DNA_gpencil_modifier_defaults.h" #include "DNA_hair_defaults.h" #include "DNA_image_defaults.h" #include "DNA_lattice_defaults.h" @@ -119,7 +133,10 @@ #include "DNA_material_defaults.h" #include "DNA_mesh_defaults.h" #include "DNA_meta_defaults.h" +#include "DNA_modifier_defaults.h" +#include "DNA_movieclip_defaults.h" #include "DNA_object_defaults.h" +#include "DNA_particle_defaults.h" #include "DNA_pointcloud_defaults.h" #include "DNA_scene_defaults.h" #include "DNA_simulation_defaults.h" @@ -131,6 +148,9 @@ #define SDNA_DEFAULT_DECL_STRUCT(struct_name) \ static const struct_name DNA_DEFAULT_##struct_name = _DNA_DEFAULT_##struct_name +/* DNA_armature_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(bArmature); + /* DNA_brush_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Brush); @@ -140,9 +160,17 @@ SDNA_DEFAULT_DECL_STRUCT(CacheFile); /* DNA_camera_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Camera); +/* DNA_collection_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Collection); + /* DNA_curve_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Curve); +/* DNA_fluid_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(FluidDomainSettings); +SDNA_DEFAULT_DECL_STRUCT(FluidFlowSettings); +SDNA_DEFAULT_DECL_STRUCT(FluidEffectorSettings); + /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Image); @@ -170,9 +198,15 @@ SDNA_DEFAULT_DECL_STRUCT(Mesh); /* DNA_meta_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(MetaBall); +/* DNA_movieclip_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(MovieClip); + /* DNA_object_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Object); +/* DNA_particle_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(ParticleSettings); + /* DNA_pointcloud_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(PointCloud); @@ -198,6 +232,85 @@ SDNA_DEFAULT_DECL_STRUCT(Volume); /* DNA_world_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(World); +/* DNA_modifier_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(ArmatureModifierData); +SDNA_DEFAULT_DECL_STRUCT(ArrayModifierData); +SDNA_DEFAULT_DECL_STRUCT(BevelModifierData); +SDNA_DEFAULT_DECL_STRUCT(BooleanModifierData); +SDNA_DEFAULT_DECL_STRUCT(BuildModifierData); +SDNA_DEFAULT_DECL_STRUCT(CastModifierData); +SDNA_DEFAULT_DECL_STRUCT(ClothSimSettings); +SDNA_DEFAULT_DECL_STRUCT(ClothCollSettings); +SDNA_DEFAULT_DECL_STRUCT(ClothModifierData); +SDNA_DEFAULT_DECL_STRUCT(CollisionModifierData); +SDNA_DEFAULT_DECL_STRUCT(CorrectiveSmoothModifierData); +SDNA_DEFAULT_DECL_STRUCT(CurveModifierData); +// SDNA_DEFAULT_DECL_STRUCT(DataTransferModifierData); +SDNA_DEFAULT_DECL_STRUCT(DecimateModifierData); +SDNA_DEFAULT_DECL_STRUCT(DisplaceModifierData); +SDNA_DEFAULT_DECL_STRUCT(DynamicPaintModifierData); +SDNA_DEFAULT_DECL_STRUCT(EdgeSplitModifierData); +SDNA_DEFAULT_DECL_STRUCT(ExplodeModifierData); +/* Fluid modifier skipped for now. */ +SDNA_DEFAULT_DECL_STRUCT(HookModifierData); +SDNA_DEFAULT_DECL_STRUCT(LaplacianDeformModifierData); +SDNA_DEFAULT_DECL_STRUCT(LaplacianSmoothModifierData); +SDNA_DEFAULT_DECL_STRUCT(LatticeModifierData); +SDNA_DEFAULT_DECL_STRUCT(MaskModifierData); +SDNA_DEFAULT_DECL_STRUCT(MeshCacheModifierData); +SDNA_DEFAULT_DECL_STRUCT(MeshDeformModifierData); +SDNA_DEFAULT_DECL_STRUCT(MeshSeqCacheModifierData); +SDNA_DEFAULT_DECL_STRUCT(MirrorModifierData); +SDNA_DEFAULT_DECL_STRUCT(MultiresModifierData); +SDNA_DEFAULT_DECL_STRUCT(NormalEditModifierData); +SDNA_DEFAULT_DECL_STRUCT(OceanModifierData); +SDNA_DEFAULT_DECL_STRUCT(ParticleInstanceModifierData); +SDNA_DEFAULT_DECL_STRUCT(ParticleSystemModifierData); +SDNA_DEFAULT_DECL_STRUCT(RemeshModifierData); +SDNA_DEFAULT_DECL_STRUCT(ScrewModifierData); +/* Shape key modifier has no items. */ +SDNA_DEFAULT_DECL_STRUCT(ShrinkwrapModifierData); +SDNA_DEFAULT_DECL_STRUCT(SimpleDeformModifierData); +SDNA_DEFAULT_DECL_STRUCT(SimulationModifierData); +SDNA_DEFAULT_DECL_STRUCT(SkinModifierData); +SDNA_DEFAULT_DECL_STRUCT(SmoothModifierData); +/* Softbody modifier skipped for now. */ +SDNA_DEFAULT_DECL_STRUCT(SolidifyModifierData); +SDNA_DEFAULT_DECL_STRUCT(SubsurfModifierData); +SDNA_DEFAULT_DECL_STRUCT(SurfaceModifierData); +SDNA_DEFAULT_DECL_STRUCT(SurfaceDeformModifierData); +SDNA_DEFAULT_DECL_STRUCT(TriangulateModifierData); +SDNA_DEFAULT_DECL_STRUCT(UVProjectModifierData); +SDNA_DEFAULT_DECL_STRUCT(UVWarpModifierData); +SDNA_DEFAULT_DECL_STRUCT(WarpModifierData); +SDNA_DEFAULT_DECL_STRUCT(WaveModifierData); +SDNA_DEFAULT_DECL_STRUCT(WeightedNormalModifierData); +SDNA_DEFAULT_DECL_STRUCT(WeightVGEditModifierData); +SDNA_DEFAULT_DECL_STRUCT(WeightVGMixModifierData); +SDNA_DEFAULT_DECL_STRUCT(WeightVGProximityModifierData); +SDNA_DEFAULT_DECL_STRUCT(WeldModifierData); +SDNA_DEFAULT_DECL_STRUCT(WireframeModifierData); + +/* DNA_gpencil_modifier_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(ArmatureGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(ArrayGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(BuildGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(ColorGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(HookGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(LatticeGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(MirrorGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(MultiplyGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(NoiseGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(OffsetGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(OpacityGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(SimplifyGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(SmoothGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(SubdivGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData); + #undef SDNA_DEFAULT_DECL_STRUCT /* Reuse existing definitions. */ @@ -225,6 +338,9 @@ extern const bTheme U_theme_default; /** Keep headers sorted. */ const void *DNA_default_table[SDNA_TYPE_MAX] = { + /* DNA_arnature_defaults.h */ + SDNA_DEFAULT_DECL(bArmature), + /* DNA_brush_defaults.h */ SDNA_DEFAULT_DECL(Brush), @@ -236,9 +352,17 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { SDNA_DEFAULT_DECL_EX(CameraDOFSettings, Camera.dof), SDNA_DEFAULT_DECL_EX(CameraStereoSettings, Camera.stereo), + /* DNA_collection_defaults.h */ + SDNA_DEFAULT_DECL(Collection), + /* DNA_curve_defaults.h */ SDNA_DEFAULT_DECL(Curve), + /* DNA_fluid_defaults.h */ + SDNA_DEFAULT_DECL(FluidDomainSettings), + SDNA_DEFAULT_DECL(FluidFlowSettings), + SDNA_DEFAULT_DECL(FluidEffectorSettings), + /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL(Image), @@ -266,9 +390,15 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* DNA_meta_defaults.h */ SDNA_DEFAULT_DECL(MetaBall), + /* DNA_movieclip_defaults.h */ + SDNA_DEFAULT_DECL(MovieClip), + /* DNA_object_defaults.h */ SDNA_DEFAULT_DECL(Object), + /* DNA_particle_defaults.h */ + SDNA_DEFAULT_DECL(ParticleSettings), + /* DNA_pointcloud_defaults.h */ SDNA_DEFAULT_DECL(PointCloud), @@ -321,6 +451,85 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* DNA_world_defaults.h */ SDNA_DEFAULT_DECL(World), + + /* DNA_modifier_defaults.h */ + SDNA_DEFAULT_DECL(ArmatureModifierData), + SDNA_DEFAULT_DECL(ArrayModifierData), + SDNA_DEFAULT_DECL(BevelModifierData), + SDNA_DEFAULT_DECL(BooleanModifierData), + SDNA_DEFAULT_DECL(BuildModifierData), + SDNA_DEFAULT_DECL(CastModifierData), + SDNA_DEFAULT_DECL(ClothSimSettings), + SDNA_DEFAULT_DECL(ClothCollSettings), + SDNA_DEFAULT_DECL(ClothModifierData), + SDNA_DEFAULT_DECL(CollisionModifierData), + SDNA_DEFAULT_DECL(CorrectiveSmoothModifierData), + SDNA_DEFAULT_DECL(CurveModifierData), + // SDNA_DEFAULT_DECL(DataTransferModifierData), + SDNA_DEFAULT_DECL(DecimateModifierData), + SDNA_DEFAULT_DECL(DisplaceModifierData), + SDNA_DEFAULT_DECL(DynamicPaintModifierData), + SDNA_DEFAULT_DECL(EdgeSplitModifierData), + SDNA_DEFAULT_DECL(ExplodeModifierData), + /* Fluid modifier skipped for now. */ + SDNA_DEFAULT_DECL(HookModifierData), + SDNA_DEFAULT_DECL(LaplacianDeformModifierData), + SDNA_DEFAULT_DECL(LaplacianSmoothModifierData), + SDNA_DEFAULT_DECL(LatticeModifierData), + SDNA_DEFAULT_DECL(MaskModifierData), + SDNA_DEFAULT_DECL(MeshCacheModifierData), + SDNA_DEFAULT_DECL(MeshDeformModifierData), + SDNA_DEFAULT_DECL(MeshSeqCacheModifierData), + SDNA_DEFAULT_DECL(MirrorModifierData), + SDNA_DEFAULT_DECL(MultiresModifierData), + SDNA_DEFAULT_DECL(NormalEditModifierData), + SDNA_DEFAULT_DECL(OceanModifierData), + SDNA_DEFAULT_DECL(ParticleInstanceModifierData), + SDNA_DEFAULT_DECL(ParticleSystemModifierData), + SDNA_DEFAULT_DECL(RemeshModifierData), + SDNA_DEFAULT_DECL(ScrewModifierData), + /* Shape key modifier has no items. */ + SDNA_DEFAULT_DECL(ShrinkwrapModifierData), + SDNA_DEFAULT_DECL(SimpleDeformModifierData), + SDNA_DEFAULT_DECL(SimulationModifierData), + SDNA_DEFAULT_DECL(SkinModifierData), + SDNA_DEFAULT_DECL(SmoothModifierData), + /* Softbody modifier skipped for now. */ + SDNA_DEFAULT_DECL(SolidifyModifierData), + SDNA_DEFAULT_DECL(SubsurfModifierData), + SDNA_DEFAULT_DECL(SurfaceModifierData), + SDNA_DEFAULT_DECL(SurfaceDeformModifierData), + SDNA_DEFAULT_DECL(TriangulateModifierData), + SDNA_DEFAULT_DECL(UVProjectModifierData), + SDNA_DEFAULT_DECL(UVWarpModifierData), + SDNA_DEFAULT_DECL(WarpModifierData), + SDNA_DEFAULT_DECL(WaveModifierData), + SDNA_DEFAULT_DECL(WeightedNormalModifierData), + SDNA_DEFAULT_DECL(WeightVGEditModifierData), + SDNA_DEFAULT_DECL(WeightVGMixModifierData), + SDNA_DEFAULT_DECL(WeightVGProximityModifierData), + SDNA_DEFAULT_DECL(WeldModifierData), + SDNA_DEFAULT_DECL(WireframeModifierData), + + /* DNA_gpencil_modifier_defaults.h */ + SDNA_DEFAULT_DECL(ArmatureGpencilModifierData), + SDNA_DEFAULT_DECL(ArrayGpencilModifierData), + SDNA_DEFAULT_DECL(BuildGpencilModifierData), + SDNA_DEFAULT_DECL(ColorGpencilModifierData), + SDNA_DEFAULT_DECL(HookGpencilModifierData), + SDNA_DEFAULT_DECL(LatticeGpencilModifierData), + SDNA_DEFAULT_DECL(MirrorGpencilModifierData), + SDNA_DEFAULT_DECL(MultiplyGpencilModifierData), + SDNA_DEFAULT_DECL(NoiseGpencilModifierData), + SDNA_DEFAULT_DECL(OffsetGpencilModifierData), + SDNA_DEFAULT_DECL(OpacityGpencilModifierData), + SDNA_DEFAULT_DECL(SimplifyGpencilModifierData), + SDNA_DEFAULT_DECL(SmoothGpencilModifierData), + SDNA_DEFAULT_DECL(SubdivGpencilModifierData), + SDNA_DEFAULT_DECL(TextureGpencilModifierData), + SDNA_DEFAULT_DECL(ThickGpencilModifierData), + SDNA_DEFAULT_DECL(TimeGpencilModifierData), + SDNA_DEFAULT_DECL(TintGpencilModifierData), }; #undef SDNA_DEFAULT_DECL #undef SDNA_DEFAULT_DECL_EX diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index b9688df8a3e..3690a1126d4 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -32,7 +32,7 @@ #include <stdlib.h> #include <string.h> -#include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN +#include "MEM_guardedalloc.h" /* for MEM_freeN MEM_mallocN MEM_callocN */ #include "BLI_endian_switch.h" #include "BLI_memarena.h" @@ -42,7 +42,7 @@ #include "BLI_ghash.h" #include "DNA_genfile.h" -#include "DNA_sdna_types.h" // for SDNA ;-) +#include "DNA_sdna_types.h" /* for SDNA ;-) */ /** * \section dna_genfile Overview @@ -109,7 +109,7 @@ * * IMPORTANT: * - Do not use #defines in structs for array lengths, this cannot be read by the dna functions. - * - Do not use uint, but unsigned int instead, ushort and ulong are allowed. + * - Do not use `uint`, but unsigned int instead, `ushort` and `ulong` are allowed. * - Only use a long in Blender if you want this to be the size of a pointer. so it is * 32 bits or 64 bits, dependent at the cpu architecture. * - Chars are always unsigned @@ -186,9 +186,8 @@ static bool ispointer(const char *name) */ int DNA_elem_size_nr(const SDNA *sdna, short type, short name) { - int len; const char *cp = sdna->names[name]; - len = 0; + int len = 0; /* is it a pointer or function pointer? */ if (ispointer(cp)) { @@ -207,17 +206,15 @@ int DNA_elem_size_nr(const SDNA *sdna, short type, short name) static void printstruct(SDNA *sdna, short strnr) { /* is for debug */ - int b, nr; - short *sp; - - sp = sdna->structs[strnr]; - printf("struct %s\n", sdna->types[sp[0]]); - nr = sp[1]; - sp += 2; + SDNA_Struct *struct_info = sdna->structs[strnr]; + printf("struct %s\n", sdna->types[struct_info->type]); - for (b = 0; b < nr; b++, sp += 2) { - printf(" %s %s\n", sdna->types[sp[0]], sdna->names[sp[1]]); + for (int b = 0; b < struct_info->members_len; b++) { + SDNA_StructMember *struct_member = &struct_info->members[b]; + printf(" %s %s\n", + sdna->types[struct_member->type], + sdna->names[struct_member->name]); } } #endif @@ -229,7 +226,7 @@ static int dna_struct_find_nr_ex_impl( /* From SDNA struct. */ const char **types, const int UNUSED(types_len), - short **const structs, + SDNA_Struct **const structs, const int structs_len, #ifdef WITH_DNA_GHASH GHash *structs_map, @@ -239,8 +236,8 @@ static int dna_struct_find_nr_ex_impl( unsigned int *index_last) { if (*index_last < structs_len) { - const short *sp = structs[*index_last]; - if (STREQ(types[sp[0]], str)) { + const SDNA_Struct *struct_info = structs[*index_last]; + if (STREQ(types[struct_info->type], str)) { return *index_last; } } @@ -257,8 +254,8 @@ static int dna_struct_find_nr_ex_impl( #else { for (int index = 0; index < structs_len; index++) { - const short *sp = structs[index]; - if (STREQ(types[sp[0]], str)) { + const SDNA_Struct *struct_info = structs[index]; + if (STREQ(types[struct_info->type], str)) { *index_last = index; return index; } @@ -334,10 +331,9 @@ BLI_INLINE const char *pad_up_4(const char *ptr) */ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error_message) { - int *data, gravity_fix = -1; - short *sp; + int gravity_fix = -1; - data = (int *)sdna->data; + int *data = (int *)sdna->data; /* Clear pointers in case of error. */ sdna->names = NULL; @@ -431,6 +427,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error /* Type lengths array ('TLEN') */ data = (int *)cp; + short *sp; if (*data == MAKE_ID('T', 'L', 'E', 'N')) { data++; sp = (short *)data; @@ -462,7 +459,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error } data++; - sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs"); + sdna->structs = MEM_callocN(sizeof(SDNA_Struct *) * sdna->structs_len, "sdnastrcs"); } else { *r_error_message = "STRC error in SDNA file"; @@ -471,32 +468,27 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error sp = (short *)data; for (int nr = 0; nr < sdna->structs_len; nr++) { - sdna->structs[nr] = sp; + SDNA_Struct *struct_info = (SDNA_Struct *)sp; + sdna->structs[nr] = struct_info; if (do_endian_swap) { - short a; - - BLI_endian_switch_int16(&sp[0]); - BLI_endian_switch_int16(&sp[1]); + BLI_endian_switch_int16(&struct_info->type); + BLI_endian_switch_int16(&struct_info->members_len); - a = sp[1]; - sp += 2; - while (a--) { - BLI_endian_switch_int16(&sp[0]); - BLI_endian_switch_int16(&sp[1]); - sp += 2; + for (short a = 0; a < struct_info->members_len; a++) { + SDNA_StructMember *member = &struct_info->members[a]; + BLI_endian_switch_int16(&member->type); + BLI_endian_switch_int16(&member->name); } } - else { - sp += 2 * sp[1] + 2; - } + sp += 2 + (sizeof(SDNA_StructMember) / sizeof(short)) * struct_info->members_len; } { /* second part of gravity problem, setting "gravity" type to void */ if (gravity_fix > -1) { for (int nr = 0; nr < sdna->structs_len; nr++) { - sp = sdna->structs[nr]; + sp = (short *)sdna->structs[nr]; if (STREQ(sdna->types[sp[0]], "ClothSimSettings")) { sp[10] = SDNA_TYPE_VOID; } @@ -510,8 +502,9 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error sdna->structs_map = BLI_ghash_str_new_ex("init_structDNA gh", sdna->structs_len); for (intptr_t nr = 0; nr < sdna->structs_len; nr++) { - sp = sdna->structs[nr]; - BLI_ghash_insert(sdna->structs_map, (void *)sdna->types[sp[0]], POINTER_FROM_INT(nr)); + SDNA_Struct *struct_info = sdna->structs[nr]; + BLI_ghash_insert( + sdna->structs_map, (void *)sdna->types[struct_info->type], POINTER_FROM_INT(nr)); } } #endif @@ -527,12 +520,12 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error } /* finally pointer_size: use struct ListBase to test it, never change the size of it! */ - sp = sdna->structs[nr]; + SDNA_Struct *struct_info = sdna->structs[nr]; /* weird; i have no memory of that... I think I used sizeof(void *) before... (ton) */ - sdna->pointer_size = sdna->types_size[sp[0]] / 2; + sdna->pointer_size = sdna->types_size[struct_info->type] / 2; - if (sp[1] != 2 || (sdna->pointer_size != 4 && sdna->pointer_size != 8)) { + if (struct_info->members_len != 2 || (sdna->pointer_size != 4 && sdna->pointer_size != 8)) { *r_error_message = "ListBase struct error! Needs it to calculate pointerize."; /* well, at least sizeof(ListBase) is error proof! (ton) */ return false; @@ -618,327 +611,248 @@ void DNA_sdna_current_free(void) /* ******************* HANDLE DNA ***************** */ /** - * Used by #DNA_struct_get_compareflags (below) to recursively mark all structs - * containing a field of type structnr as changed between old and current SDNAs. + * This function changes compare_flags[old_struct_index] from SDNA_CMP_UNKNOWN to something else. + * It might call itself recursively. */ -static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structnr) +static void set_compare_flags_for_struct(const SDNA *oldsdna, + const SDNA *newsdna, + char *compare_flags, + const int old_struct_index) { - int a, b, typenr, elems; - const short *sp; - const char *cp; + if (compare_flags[old_struct_index] != SDNA_CMP_UNKNOWN) { + /* This flag has been initialized already. */ + return; + } - /* check all structs, test if it's inside another struct */ - sp = sdna->structs[structnr]; - typenr = sp[0]; - - for (a = 0; a < sdna->structs_len; a++) { - if ((a != structnr) && (compflags[a] == SDNA_CMP_EQUAL)) { - sp = sdna->structs[a]; - elems = sp[1]; - sp += 2; - for (b = 0; b < elems; b++, sp += 2) { - if (sp[0] == typenr) { - cp = sdna->names[sp[1]]; - if (!ispointer(cp)) { - compflags[a] = SDNA_CMP_NOT_EQUAL; - recurs_test_compflags(sdna, compflags, a); - } + SDNA_Struct *old_struct = oldsdna->structs[old_struct_index]; + const char *struct_name = oldsdna->types[old_struct->type]; + + const int new_struct_index = DNA_struct_find_nr(newsdna, struct_name); + if (new_struct_index == -1) { + /* Didn't find a matching new struct, so it has been removed. */ + compare_flags[old_struct_index] = SDNA_CMP_REMOVED; + return; + } + + SDNA_Struct *new_struct = newsdna->structs[new_struct_index]; + if (old_struct->members_len != new_struct->members_len) { + /* Structs with a different amount of members are not equal. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; + } + if (oldsdna->types_size[old_struct->type] != newsdna->types_size[new_struct->type]) { + /* Structs that don't have the same size are not equal. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; + } + + /* Compare each member individually. */ + for (int member_index = 0; member_index < old_struct->members_len; member_index++) { + SDNA_StructMember *old_member = &old_struct->members[member_index]; + SDNA_StructMember *new_member = &new_struct->members[member_index]; + + const char *old_type_name = oldsdna->types[old_member->type]; + const char *new_type_name = newsdna->types[new_member->type]; + if (!STREQ(old_type_name, new_type_name)) { + /* If two members have a different type in the same place, the structs are not equal. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; + } + + const char *old_member_name = oldsdna->names[old_member->name]; + const char *new_member_name = newsdna->names[new_member->name]; + if (!STREQ(old_member_name, new_member_name)) { + /* If two members have a different name in the same place, the structs are not equal. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; + } + + if (ispointer(old_member_name)) { + if (oldsdna->pointer_size != newsdna->pointer_size) { + /* When the struct contains a pointer, and the pointer sizes differ, the structs are not + * equal. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; + } + } + else { + const int old_member_struct_index = DNA_struct_find_nr(oldsdna, old_type_name); + if (old_member_struct_index >= 0) { + set_compare_flags_for_struct(oldsdna, newsdna, compare_flags, old_member_struct_index); + if (compare_flags[old_member_struct_index] != SDNA_CMP_EQUAL) { + /* If an embedded struct is not equal, the parent struct cannot be equal either. */ + compare_flags[old_struct_index] = SDNA_CMP_NOT_EQUAL; + return; } } } } + + compare_flags[old_struct_index] = SDNA_CMP_EQUAL; } /** * Constructs and returns an array of byte flags with one element for each struct in oldsdna, - * indicating how it compares to newsdna: + * indicating how it compares to newsdna. */ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna) { - int a, b; - const short *sp_old, *sp_new; - const char *str1, *str2; - char *compflags; - if (oldsdna->structs_len == 0) { printf("error: file without SDNA\n"); return NULL; } - compflags = MEM_callocN(oldsdna->structs_len, "compflags"); + char *compare_flags = MEM_mallocN(oldsdna->structs_len, "compare flags"); + memset(compare_flags, SDNA_CMP_UNKNOWN, oldsdna->structs_len); - /* we check all structs in 'oldsdna' and compare them with - * the structs in 'newsdna' - */ - unsigned int newsdna_index_last = 0; - - for (a = 0; a < oldsdna->structs_len; a++) { - sp_old = oldsdna->structs[a]; - - /* search for type in cur */ - int sp_new_index = DNA_struct_find_nr_ex( - newsdna, oldsdna->types[sp_old[0]], &newsdna_index_last); - - /* The next indices will almost always match */ - newsdna_index_last++; - - if (sp_new_index != -1) { - sp_new = newsdna->structs[sp_new_index]; - /* initial assumption */ - compflags[a] = SDNA_CMP_NOT_EQUAL; - - /* compare length and amount of elems */ - if (sp_new[1] == sp_old[1]) { - if (newsdna->types_size[sp_new[0]] == oldsdna->types_size[sp_old[0]]) { - - /* same length, same amount of elems, now per type and name */ - b = sp_old[1]; - sp_old += 2; - sp_new += 2; - while (b > 0) { - str1 = newsdna->types[sp_new[0]]; - str2 = oldsdna->types[sp_old[0]]; - if (!STREQ(str1, str2)) { - break; - } - - str1 = newsdna->names[sp_new[1]]; - str2 = oldsdna->names[sp_old[1]]; - if (!STREQ(str1, str2)) { - break; - } - - /* same type and same name, now pointersize */ - if (ispointer(str1)) { - if (oldsdna->pointer_size != newsdna->pointer_size) { - break; - } - } - - b--; - sp_old += 2; - sp_new += 2; - } - if (b == 0) { - /* no differences found */ - compflags[a] = SDNA_CMP_EQUAL; - } - } - } - } + /* Set correct flag for every struct. */ + for (int a = 0; a < oldsdna->structs_len; a++) { + set_compare_flags_for_struct(oldsdna, newsdna, compare_flags, a); + BLI_assert(compare_flags[a] != SDNA_CMP_UNKNOWN); } - /* first struct in util.h is struct Link, this is skipped in compflags (als # 0). + /* first struct in util.h is struct Link, this is skipped in compare_flags (als # 0). * was a bug, and this way dirty patched! Solve this later.... */ - compflags[0] = SDNA_CMP_EQUAL; - - /* Because structs can be inside structs, we recursively - * set flags when a struct is altered - */ - for (a = 0; a < oldsdna->structs_len; a++) { - if (compflags[a] == SDNA_CMP_NOT_EQUAL) { - recurs_test_compflags(oldsdna, compflags, a); - } - } + compare_flags[0] = SDNA_CMP_EQUAL; +/* This code can be enabled to see which structs have changed. */ #if 0 - for (a = 0; a < oldsdna->structs_len; a++) { - if (compflags[a] == SDNA_CMP_NOT_EQUAL) { - spold = oldsdna->structs[a]; - printf("changed: %s\n", oldsdna->types[spold[0]]); + for (int a = 0; a < oldsdna->structs_len; a++) { + if (compare_flags[a] == SDNA_CMP_NOT_EQUAL) { + SDNA_Struct *struct_info = oldsdna->structs[a]; + printf("changed: %s\n", oldsdna->types[struct_info->type]); } } #endif - return compflags; -} - -/** - * Converts the name of a primitive type to its enumeration code. - */ -static eSDNA_Type sdna_type_nr(const char *dna_type) -{ - if (STR_ELEM(dna_type, "char", "const char")) { - return SDNA_TYPE_CHAR; - } - if (STR_ELEM(dna_type, "uchar", "unsigned char")) { - return SDNA_TYPE_UCHAR; - } - if (STR_ELEM(dna_type, "short")) { - return SDNA_TYPE_SHORT; - } - if (STR_ELEM(dna_type, "ushort", "unsigned short")) { - return SDNA_TYPE_USHORT; - } - if (STR_ELEM(dna_type, "int")) { - return SDNA_TYPE_INT; - } - if (STR_ELEM(dna_type, "float")) { - return SDNA_TYPE_FLOAT; - } - if (STR_ELEM(dna_type, "double")) { - return SDNA_TYPE_DOUBLE; - } - if (STR_ELEM(dna_type, "int64_t")) { - return SDNA_TYPE_INT64; - } - if (STR_ELEM(dna_type, "uint64_t")) { - return SDNA_TYPE_UINT64; - } - /* invalid! */ - - return -1; + return compare_flags; } /** * Converts a value of one primitive type to another. - * Note there is no optimization for the case where otype and ctype are the same: + * + * \note there is no optimization for the case where \a otype and \a ctype are the same: * assumption is that caller will handle this case. * - * \param ctype: Name of type to convert to - * \param otype: Name of type to convert from - * \param name_array_len: Result of #DNA_elem_array_size for this element. - * \param curdata: Where to put converted data - * \param olddata: Data of type otype to convert + * \param old_type: Type to convert from. + * \param new_type: Type to convert to. + * \param array_len: Number of elements to convert. + * \param old_data: Buffer containing the old values. + * \param new_data: Buffer the converted values will be written to. */ -static void cast_elem( - const char *ctype, const char *otype, int name_array_len, char *curdata, const char *olddata) +static void cast_primitive_type(const eSDNA_Type old_type, + const eSDNA_Type new_type, + const int array_len, + const char *old_data, + char *new_data) { - eSDNA_Type ctypenr, otypenr; - if ((otypenr = sdna_type_nr(otype)) == -1 || (ctypenr = sdna_type_nr(ctype)) == -1) { - return; - } - /* define lengths */ - const int oldlen = DNA_elem_type_size(otypenr); - const int curlen = DNA_elem_type_size(ctypenr); + const int oldlen = DNA_elem_type_size(old_type); + const int curlen = DNA_elem_type_size(new_type); double old_value_f = 0.0; uint64_t old_value_i = 0; - while (name_array_len > 0) { - switch (otypenr) { + for (int a = 0; a < array_len; a++) { + switch (old_type) { case SDNA_TYPE_CHAR: - old_value_i = *olddata; + old_value_i = *old_data; old_value_f = (double)old_value_i; break; case SDNA_TYPE_UCHAR: - old_value_i = *((unsigned char *)olddata); + old_value_i = *((unsigned char *)old_data); old_value_f = (double)old_value_i; break; case SDNA_TYPE_SHORT: - old_value_i = *((short *)olddata); + old_value_i = *((short *)old_data); old_value_f = (double)old_value_i; break; case SDNA_TYPE_USHORT: - old_value_i = *((unsigned short *)olddata); + old_value_i = *((unsigned short *)old_data); old_value_f = (double)old_value_i; break; case SDNA_TYPE_INT: - old_value_i = *((int *)olddata); + old_value_i = *((int *)old_data); old_value_f = (double)old_value_i; break; case SDNA_TYPE_FLOAT: - old_value_f = *((float *)olddata); + old_value_f = *((float *)old_data); old_value_i = (uint64_t)(int64_t)old_value_f; break; case SDNA_TYPE_DOUBLE: - old_value_f = *((double *)olddata); + old_value_f = *((double *)old_data); old_value_i = (uint64_t)(int64_t)old_value_f; break; case SDNA_TYPE_INT64: - old_value_i = (uint64_t) * ((int64_t *)olddata); + old_value_i = (uint64_t) * ((int64_t *)old_data); old_value_f = (double)old_value_i; break; case SDNA_TYPE_UINT64: - old_value_i = *((uint64_t *)olddata); + old_value_i = *((uint64_t *)old_data); old_value_f = (double)old_value_i; break; } - switch (ctypenr) { + switch (new_type) { case SDNA_TYPE_CHAR: - *curdata = (char)old_value_i; + *new_data = (char)old_value_i; break; case SDNA_TYPE_UCHAR: - *((unsigned char *)curdata) = (unsigned char)old_value_i; + *((unsigned char *)new_data) = (unsigned char)old_value_i; break; case SDNA_TYPE_SHORT: - *((short *)curdata) = (short)old_value_i; + *((short *)new_data) = (short)old_value_i; break; case SDNA_TYPE_USHORT: - *((unsigned short *)curdata) = (unsigned short)old_value_i; + *((unsigned short *)new_data) = (unsigned short)old_value_i; break; case SDNA_TYPE_INT: - *((int *)curdata) = (int)old_value_i; + *((int *)new_data) = (int)old_value_i; break; case SDNA_TYPE_FLOAT: - if (otypenr < 2) { + if (old_type < 2) { old_value_f /= 255.0; } - *((float *)curdata) = old_value_f; + *((float *)new_data) = old_value_f; break; case SDNA_TYPE_DOUBLE: - if (otypenr < 2) { + if (old_type < 2) { old_value_f /= 255.0; } - *((double *)curdata) = old_value_f; + *((double *)new_data) = old_value_f; break; case SDNA_TYPE_INT64: - *((int64_t *)curdata) = (int64_t)old_value_i; + *((int64_t *)new_data) = (int64_t)old_value_i; break; case SDNA_TYPE_UINT64: - *((uint64_t *)curdata) = old_value_i; + *((uint64_t *)new_data) = old_value_i; break; } - olddata += oldlen; - curdata += curlen; - name_array_len--; + old_data += oldlen; + new_data += curlen; } } -/** - * Converts pointer values between different sizes. These are only used - * as lookup keys to identify data blocks in the saved .blend file, not - * as actual in-memory pointers. - * - * \param curlen: Pointer length to convert to - * \param oldlen: Length of pointers in olddata - * \param name_array_len: Result of #DNA_elem_array_size for this element. - * \param curdata: Where to put converted data - * \param olddata: Data to convert - */ -static void cast_pointer( - int curlen, int oldlen, int name_array_len, char *curdata, const char *olddata) +static void cast_pointer_32_to_64(const int array_len, + const uint32_t *old_data, + uint64_t *new_data) { - int64_t lval; - - while (name_array_len > 0) { - - if (curlen == oldlen) { - memcpy(curdata, olddata, curlen); - } - else if (curlen == 4 && oldlen == 8) { - lval = *((int64_t *)olddata); - - /* WARNING: 32-bit Blender trying to load file saved by 64-bit Blender, - * pointers may lose uniqueness on truncation! (Hopefully this wont - * happen unless/until we ever get to multi-gigabyte .blend files...) */ - *((int *)curdata) = lval >> 3; - } - else if (curlen == 8 && oldlen == 4) { - *((int64_t *)curdata) = *((int *)olddata); - } - else { - /* for debug */ - printf("errpr: illegal pointersize!\n"); - } + for (int a = 0; a < array_len; a++) { + new_data[a] = old_data[a]; + } +} - olddata += oldlen; - curdata += curlen; - name_array_len--; +static void cast_pointer_64_to_32(const int array_len, + const uint64_t *old_data, + uint32_t *new_data) +{ + /* WARNING: 32-bit Blender trying to load file saved by 64-bit Blender, + * pointers may lose uniqueness on truncation! (Hopefully this wont + * happen unless/until we ever get to multi-gigabyte .blend files...) */ + for (int a = 0; a < array_len; a++) { + new_data[a] = old_data[a] >> 3; } } @@ -980,17 +894,13 @@ static bool elem_exists_impl( /* Regular args. */ const char *type, const char *name, - const short *old) + const SDNA_Struct *old) { - int a, elemcount; - const char *otype, *oname; - /* in old is the old struct */ - elemcount = old[1]; - old += 2; - for (a = 0; a < elemcount; a++, old += 2) { - otype = types[old[0]]; - oname = names[old[1]]; + for (int a = 0; a < old->members_len; a++) { + const SDNA_StructMember *member = &old->members[a]; + const char *otype = types[member->type]; + const char *oname = names[member->name]; if (elem_streq(name, oname)) { /* name equal */ return STREQ(type, otype); /* type equal */ @@ -1002,7 +912,10 @@ static bool elem_exists_impl( /** * \param sdna: Old SDNA. */ -static bool elem_exists(const SDNA *sdna, const char *type, const char *name, const short *old) +static bool elem_exists(const SDNA *sdna, + const char *type, + const char *name, + const SDNA_Struct *old) { return elem_exists_impl( /* Expand SDNA. */ @@ -1017,7 +930,7 @@ static bool elem_exists(const SDNA *sdna, const char *type, const char *name, co static bool elem_exists_alias(const SDNA *sdna, const char *type, const char *name, - const short *old) + const SDNA_Struct *old) { return elem_exists_impl( /* Expand SDNA. */ @@ -1030,436 +943,662 @@ static bool elem_exists_alias(const SDNA *sdna, } /** - * Returns the address of the data for the specified field within olddata - * according to the struct format pointed to by old, or NULL if no such - * field can be found. + * Return the offset in bytes or -1 on failure to find the struct member with its expected type. + * + * \param sdna: Old #SDNA. + * \param type: Current field type name. + * \param name: Current field name. + * \param old: Pointer to struct information in #SDNA. + * \return The offset or -1 on failure. * - * Passing olddata=NULL doesn't work reliably for existence checks; it will - * return NULL both when the field is found at offset 0 and when it is not - * found at all. For field existence checks, use #elem_exists() instead. + * \note Use #elem_exists if additional information provided by this function is not needed. * - * \param sdna: Old SDNA - * \param type: Current field type name - * \param name: Current field name - * \param old: Pointer to struct information in sdna - * \param olddata: Struct data - * \param sppo: Optional place to return pointer to field info in sdna - * \return Data address. + * \note We could have a version of this function that + * returns the #SDNA_StructMember currently it's not needed. */ -static const char *find_elem(const SDNA *sdna, - const char *type, - const char *name, - const short *old, - const char *olddata, - const short **sppo) +static int elem_offset(const SDNA *sdna, + const char *type, + const char *name, + const SDNA_Struct *old) { - int a, elemcount, len; - const char *otype, *oname; - /* without arraypart, so names can differ: return old namenr and type */ /* in old is the old struct */ - elemcount = old[1]; - old += 2; - for (a = 0; a < elemcount; a++, old += 2) { - - otype = sdna->types[old[0]]; - oname = sdna->names[old[1]]; - - len = DNA_elem_size_nr(sdna, old[0], old[1]); - + int offset = 0; + for (int a = 0; a < old->members_len; a++) { + const SDNA_StructMember *member = &old->members[a]; + const char *otype = sdna->types[member->type]; + const char *oname = sdna->names[member->name]; if (elem_streq(name, oname)) { /* name equal */ if (STREQ(type, otype)) { /* type equal */ - if (sppo) { - *sppo = old; - } - return olddata; + return offset; } - - return NULL; + break; /* Fail below. */ } + offset += DNA_elem_size_nr(sdna, member->type, member->name); + } + return -1; +} + +/* Each struct member belongs to one of the categories below. */ +typedef enum eStructMemberCategory { + STRUCT_MEMBER_CATEGORY_STRUCT, + STRUCT_MEMBER_CATEGORY_PRIMITIVE, + STRUCT_MEMBER_CATEGORY_POINTER, +} eStructMemberCategory; - olddata += len; +static eStructMemberCategory get_struct_member_category(const SDNA *sdna, + const SDNA_StructMember *member) +{ + const char *member_name = sdna->names[member->name]; + if (ispointer(member_name)) { + return STRUCT_MEMBER_CATEGORY_POINTER; } - return NULL; + const char *member_type_name = sdna->types[member->type]; + if (DNA_struct_find(sdna, member_type_name)) { + return STRUCT_MEMBER_CATEGORY_STRUCT; + } + return STRUCT_MEMBER_CATEGORY_PRIMITIVE; +} + +static int get_member_size_in_bytes(const SDNA *sdna, const SDNA_StructMember *member) +{ + const char *name = sdna->names[member->name]; + const int array_length = sdna->names_array_len[member->name]; + if (ispointer(name)) { + return sdna->pointer_size * array_length; + } + const int type_size = sdna->types_size[member->type]; + return type_size * array_length; } /** - * Converts the contents of a single field of a struct, of a non-struct type, - * from \a oldsdna to \a newsdna format. + * Does endian swapping on the fields of a struct value. * - * \param newsdna: SDNA of current Blender - * \param oldsdna: SDNA of Blender that saved file - * \param type: current field type name - * \param new_name_nr: current field name number. - * \param curdata: put field data converted to newsdna here - * \param old: pointer to struct info in oldsdna - * \param olddata: struct contents laid out according to oldsdna + * \param sdna: SDNA of the struct_nr belongs to + * \param struct_nr: Index of struct info within sdna + * \param data: Struct data that is to be converted */ -static void reconstruct_elem(const SDNA *newsdna, - const SDNA *oldsdna, - const char *type, - const int new_name_nr, - char *curdata, - const short *old, - const char *olddata) +void DNA_struct_switch_endian(const SDNA *sdna, int struct_nr, char *data) { - /* rules: test for NAME: - * - name equal: - * - cast type - * - name partially equal (array differs) - * - type equal: memcpy - * - type cast (per element). - * (nzc 2-4-2001 I want the 'unsigned' bit to be parsed as well. Where - * can I force this?) - */ - int a, elemcount, len, countpos, mul; - const char *otype, *oname, *cp; - - /* is 'name' an array? */ - const char *name = newsdna->names[new_name_nr]; - cp = name; - countpos = 0; - while (*cp && *cp != '[') { - cp++; - countpos++; - } - if (*cp != '[') { - countpos = 0; + if (struct_nr == -1) { + return; } - /* in old is the old struct */ - elemcount = old[1]; - old += 2; - for (a = 0; a < elemcount; a++, old += 2) { - const int old_name_nr = old[1]; - otype = oldsdna->types[old[0]]; - oname = oldsdna->names[old[1]]; - len = DNA_elem_size_nr(oldsdna, old[0], old[1]); - - if (STREQ(name, oname)) { /* name equal */ - - if (ispointer(name)) { /* pointer of functionpointer afhandelen */ - cast_pointer(newsdna->pointer_size, - oldsdna->pointer_size, - newsdna->names_array_len[new_name_nr], - curdata, - olddata); - } - else if (STREQ(type, otype)) { /* type equal */ - memcpy(curdata, olddata, len); - } - else { - cast_elem(type, otype, newsdna->names_array_len[new_name_nr], curdata, olddata); - } - - return; - } - if (countpos != 0) { /* name is an array */ + const SDNA_Struct *struct_info = sdna->structs[struct_nr]; - if (oname[countpos] == '[' && strncmp(name, oname, countpos) == 0) { /* basis equal */ - const int new_name_array_len = newsdna->names_array_len[new_name_nr]; - const int old_name_array_len = oldsdna->names_array_len[old_name_nr]; - const int min_name_array_len = MIN2(new_name_array_len, old_name_array_len); + int offset_in_bytes = 0; + for (int member_index = 0; member_index < struct_info->members_len; member_index++) { + const SDNA_StructMember *member = &struct_info->members[member_index]; + const eStructMemberCategory member_category = get_struct_member_category(sdna, member); + char *member_data = data + offset_in_bytes; + const char *member_type_name = sdna->types[member->type]; + const int member_array_length = sdna->names_array_len[member->name]; - if (ispointer(name)) { /* handle pointer or functionpointer */ - cast_pointer( - newsdna->pointer_size, oldsdna->pointer_size, min_name_array_len, curdata, olddata); + switch (member_category) { + case STRUCT_MEMBER_CATEGORY_STRUCT: { + const int substruct_size = sdna->types_size[member->type]; + const int substruct_nr = DNA_struct_find_nr(sdna, member_type_name); + BLI_assert(substruct_nr != -1); + for (int a = 0; a < member_array_length; a++) { + DNA_struct_switch_endian(sdna, substruct_nr, member_data + a * substruct_size); } - else if (STREQ(type, otype)) { /* type equal */ - /* size of single old array element */ - mul = len / old_name_array_len; - /* smaller of sizes of old and new arrays */ - mul *= min_name_array_len; - - memcpy(curdata, olddata, mul); - - if (old_name_array_len > new_name_array_len && STREQ(type, "char")) { - /* string had to be truncated, ensure it's still null-terminated */ - curdata[mul - 1] = '\0'; + break; + } + case STRUCT_MEMBER_CATEGORY_PRIMITIVE: { + switch (member->type) { + case SDNA_TYPE_SHORT: + case SDNA_TYPE_USHORT: { + BLI_endian_switch_int16_array((int16_t *)member_data, member_array_length); + break; + } + case SDNA_TYPE_INT: + case SDNA_TYPE_FLOAT: { + /* Note, intentionally ignore long/ulong, because these could be 4 or 8 bytes. + * Fortunately, we only use these types for runtime variables and only once for a + * struct type that is no longer used. */ + BLI_endian_switch_int32_array((int32_t *)member_data, member_array_length); + break; + } + case SDNA_TYPE_INT64: + case SDNA_TYPE_UINT64: + case SDNA_TYPE_DOUBLE: { + BLI_endian_switch_int64_array((int64_t *)member_data, member_array_length); + break; + } + default: { + break; } } - else { - cast_elem(type, otype, min_name_array_len, curdata, olddata); + break; + } + case STRUCT_MEMBER_CATEGORY_POINTER: { + /* See readfile.c (#bh4_from_bh8 swap endian argument), + * this is only done when reducing the size of a pointer from 4 to 8. */ + if (sizeof(void *) < 8) { + if (sdna->pointer_size == 8) { + BLI_endian_switch_uint64_array((uint64_t *)member_data, member_array_length); + } } - return; + break; } } - olddata += len; + offset_in_bytes += get_member_size_in_bytes(sdna, member); } } +typedef enum eReconstructStepType { + RECONSTRUCT_STEP_MEMCPY, + RECONSTRUCT_STEP_CAST_PRIMITIVE, + RECONSTRUCT_STEP_CAST_POINTER_TO_32, + RECONSTRUCT_STEP_CAST_POINTER_TO_64, + RECONSTRUCT_STEP_SUBSTRUCT, + RECONSTRUCT_STEP_INIT_ZERO, +} eReconstructStepType; + +typedef struct ReconstructStep { + eReconstructStepType type; + union { + struct { + int old_offset; + int new_offset; + int size; + } memcpy; + struct { + int old_offset; + int new_offset; + int array_len; + eSDNA_Type old_type; + eSDNA_Type new_type; + } cast_primitive; + struct { + int old_offset; + int new_offset; + int array_len; + } cast_pointer; + struct { + int old_offset; + int new_offset; + int array_len; + short old_struct_nr; + short new_struct_nr; + } substruct; + } data; +} ReconstructStep; + +typedef struct DNA_ReconstructInfo { + const SDNA *oldsdna; + const SDNA *newsdna; + const char *compare_flags; + + int *step_counts; + ReconstructStep **steps; +} DNA_ReconstructInfo; + +static void reconstruct_structs(const DNA_ReconstructInfo *reconstruct_info, + const int blocks, + const int old_struct_nr, + const int new_struct_nr, + const char *old_blocks, + char *new_blocks); + /** * Converts the contents of an entire struct from oldsdna to newsdna format. * - * \param newsdna: SDNA of current Blender - * \param oldsdna: SDNA of Blender that saved file - * \param compflags: - * - * Result from DNA_struct_get_compareflags to avoid needless conversions. - * \param oldSDNAnr: Index of old struct definition in oldsdna - * \param data: Struct contents laid out according to oldsdna - * \param curSDNAnr: Index of current struct definition in newsdna - * \param cur: Where to put converted struct contents + * \param reconstruct_info: Preprocessed reconstruct information generated by + * #DNA_reconstruct_info_create. + * \param new_struct_nr: Index in newsdna->structs of the struct that is being reconstructed. + * \param old_block: Memory buffer containing the old struct. + * \param new_block: Where to put converted struct contents. */ -static void reconstruct_struct(const SDNA *newsdna, - const SDNA *oldsdna, - const char *compflags, - - int oldSDNAnr, - const char *data, - int curSDNAnr, - char *cur) +static void reconstruct_struct(const DNA_ReconstructInfo *reconstruct_info, + const int new_struct_nr, + const char *old_block, + char *new_block) { - /* Recursive! - * Per element from cur_struct, read data from old_struct. - * If element is a struct, call recursive. - */ - int a, elemcount, elen, eleno, mul, mulo, firststructtypenr; - const short *spo, *spc, *sppo; - const char *type; - const char *cpo; - char *cpc; - const char *name; - - unsigned int oldsdna_index_last = UINT_MAX; - unsigned int cursdna_index_last = UINT_MAX; - - if (oldSDNAnr == -1) { - return; - } - if (curSDNAnr == -1) { - return; + const ReconstructStep *steps = reconstruct_info->steps[new_struct_nr]; + const int step_count = reconstruct_info->step_counts[new_struct_nr]; + + /* Execute all preprocessed steps. */ + for (int a = 0; a < step_count; a++) { + const ReconstructStep *step = &steps[a]; + switch (step->type) { + case RECONSTRUCT_STEP_MEMCPY: + memcpy(new_block + step->data.memcpy.new_offset, + old_block + step->data.memcpy.old_offset, + step->data.memcpy.size); + break; + case RECONSTRUCT_STEP_CAST_PRIMITIVE: + cast_primitive_type(step->data.cast_primitive.old_type, + step->data.cast_primitive.new_type, + step->data.cast_primitive.array_len, + old_block + step->data.cast_primitive.old_offset, + new_block + step->data.cast_primitive.new_offset); + break; + case RECONSTRUCT_STEP_CAST_POINTER_TO_32: + cast_pointer_64_to_32(step->data.cast_pointer.array_len, + (const uint64_t *)(old_block + step->data.cast_pointer.old_offset), + (uint32_t *)(new_block + step->data.cast_pointer.new_offset)); + break; + case RECONSTRUCT_STEP_CAST_POINTER_TO_64: + cast_pointer_32_to_64(step->data.cast_pointer.array_len, + (const uint32_t *)(old_block + step->data.cast_pointer.old_offset), + (uint64_t *)(new_block + step->data.cast_pointer.new_offset)); + break; + case RECONSTRUCT_STEP_SUBSTRUCT: + reconstruct_structs(reconstruct_info, + step->data.substruct.array_len, + step->data.substruct.old_struct_nr, + step->data.substruct.new_struct_nr, + old_block + step->data.substruct.old_offset, + new_block + step->data.substruct.new_offset); + break; + case RECONSTRUCT_STEP_INIT_ZERO: + /* Do nothing, because the memory block has been calloced. */ + break; + } } +} - if (compflags[oldSDNAnr] == SDNA_CMP_EQUAL) { - /* if recursive: test for equal */ - spo = oldsdna->structs[oldSDNAnr]; - elen = oldsdna->types_size[spo[0]]; - memcpy(cur, data, elen); +/** Reconstructs an array of structs. */ +static void reconstruct_structs(const DNA_ReconstructInfo *reconstruct_info, + const int blocks, + const int old_struct_nr, + const int new_struct_nr, + const char *old_blocks, + char *new_blocks) +{ + const SDNA_Struct *old_struct = reconstruct_info->oldsdna->structs[old_struct_nr]; + const SDNA_Struct *new_struct = reconstruct_info->newsdna->structs[new_struct_nr]; - return; + const int old_block_size = reconstruct_info->oldsdna->types_size[old_struct->type]; + const int new_block_size = reconstruct_info->newsdna->types_size[new_struct->type]; + + for (int a = 0; a < blocks; a++) { + const char *old_block = old_blocks + a * old_block_size; + char *new_block = new_blocks + a * new_block_size; + reconstruct_struct(reconstruct_info, new_struct_nr, old_block, new_block); } +} - firststructtypenr = *(newsdna->structs[0]); +/** + * \param reconstruct_info: Information preprocessed by #DNA_reconstruct_info_create. + * \param old_struct_nr: Index of struct info within oldsdna. + * \param blocks: The number of array elements. + * \param old_blocks: Array of struct data. + * \return An allocated reconstructed struct. + */ +void *DNA_struct_reconstruct(const DNA_ReconstructInfo *reconstruct_info, + int old_struct_nr, + int blocks, + const void *old_blocks) +{ + const SDNA *oldsdna = reconstruct_info->oldsdna; + const SDNA *newsdna = reconstruct_info->newsdna; - spo = oldsdna->structs[oldSDNAnr]; - spc = newsdna->structs[curSDNAnr]; + const SDNA_Struct *old_struct = oldsdna->structs[old_struct_nr]; + const char *type_name = oldsdna->types[old_struct->type]; + const int new_struct_nr = DNA_struct_find_nr(newsdna, type_name); - elemcount = spc[1]; + if (new_struct_nr == -1) { + return NULL; + } - spc += 2; - cpc = cur; - for (a = 0; a < elemcount; a++, spc += 2) { /* convert each field */ - type = newsdna->types[spc[0]]; - name = newsdna->names[spc[1]]; + const SDNA_Struct *new_struct = newsdna->structs[new_struct_nr]; + const int new_block_size = newsdna->types_size[new_struct->type]; - elen = DNA_elem_size_nr(newsdna, spc[0], spc[1]); + char *new_blocks = MEM_callocN(blocks * new_block_size, "reconstruct"); + reconstruct_structs( + reconstruct_info, blocks, old_struct_nr, new_struct_nr, old_blocks, new_blocks); + return new_blocks; +} - /* Skip pad bytes which must start with '_pad', see makesdna.c 'is_name_legal'. - * for exact rules. Note that if we fail to skip a pad byte it's harmless, - * this just avoids unnecessary reconstruction. */ - if (name[0] == '_' || (name[0] == '*' && name[1] == '_')) { - cpc += elen; +/** Finds a member in the given struct with the given name. */ +static const SDNA_StructMember *find_member_with_matching_name(const SDNA *sdna, + const SDNA_Struct *struct_info, + const char *name, + int *r_offset) +{ + int offset = 0; + for (int a = 0; a < struct_info->members_len; a++) { + const SDNA_StructMember *member = &struct_info->members[a]; + const char *member_name = sdna->names[member->name]; + if (elem_streq(name, member_name)) { + *r_offset = offset; + return member; } - else if (spc[0] >= firststructtypenr && !ispointer(name)) { - /* struct field type */ - - /* where does the old struct data start (and is there an old one?) */ - cpo = (char *)find_elem(oldsdna, type, name, spo, data, &sppo); + offset += get_member_size_in_bytes(sdna, member); + } + return NULL; +} - if (cpo) { - oldSDNAnr = DNA_struct_find_nr_ex(oldsdna, type, &oldsdna_index_last); - curSDNAnr = DNA_struct_find_nr_ex(newsdna, type, &cursdna_index_last); +/** Initializes a single reconstruct step for a member in the new struct. */ +static void init_reconstruct_step_for_member(const SDNA *oldsdna, + const SDNA *newsdna, + const char *compare_flags, + const SDNA_Struct *old_struct, + const SDNA_StructMember *new_member, + const int new_member_offset, + ReconstructStep *r_step) +{ - /* array! */ - mul = newsdna->names_array_len[spc[1]]; - mulo = oldsdna->names_array_len[sppo[1]]; + /* Find the matching old member. */ + int old_member_offset; + const char *new_name = newsdna->names[new_member->name]; + const SDNA_StructMember *old_member = find_member_with_matching_name( + oldsdna, old_struct, new_name, &old_member_offset); - eleno = DNA_elem_size_nr(oldsdna, sppo[0], sppo[1]); + if (old_member == NULL) { + /* No matching member has been found in the old struct. */ + r_step->type = RECONSTRUCT_STEP_INIT_ZERO; + return; + } - elen /= mul; - eleno /= mulo; + /* Determine the member category of the old an new members. */ + const eStructMemberCategory new_category = get_struct_member_category(newsdna, new_member); + const eStructMemberCategory old_category = get_struct_member_category(oldsdna, old_member); - while (mul--) { - reconstruct_struct(newsdna, oldsdna, compflags, oldSDNAnr, cpo, curSDNAnr, cpc); - cpo += eleno; - cpc += elen; + if (new_category != old_category) { + /* Can only reconstruct the new member based on the old member, when the belong to the same + * category. */ + r_step->type = RECONSTRUCT_STEP_INIT_ZERO; + return; + } - /* new struct array larger than old */ - mulo--; - if (mulo <= 0) { - break; - } + const int new_array_length = newsdna->names_array_len[new_member->name]; + const int old_array_length = oldsdna->names_array_len[old_member->name]; + const int shared_array_length = MIN2(new_array_length, old_array_length); + + const char *new_type_name = newsdna->types[new_member->type]; + const char *old_type_name = oldsdna->types[old_member->type]; + + switch (new_category) { + case STRUCT_MEMBER_CATEGORY_STRUCT: { + if (STREQ(new_type_name, old_type_name)) { + const int old_struct_nr = DNA_struct_find_nr(oldsdna, old_type_name); + BLI_assert(old_struct_nr != -1); + enum eSDNA_StructCompare compare_flag = compare_flags[old_struct_nr]; + BLI_assert(compare_flag != SDNA_CMP_REMOVED); + if (compare_flag == SDNA_CMP_EQUAL) { + /* The old and new members are identical, just do a memcpy. */ + r_step->type = RECONSTRUCT_STEP_MEMCPY; + r_step->data.memcpy.new_offset = new_member_offset; + r_step->data.memcpy.old_offset = old_member_offset; + r_step->data.memcpy.size = newsdna->types_size[new_member->type] * shared_array_length; + } + else { + const int new_struct_nr = DNA_struct_find_nr(newsdna, new_type_name); + BLI_assert(new_struct_nr != -1); + + /* The old and new members are different, use recursion to reconstruct the + * nested struct. */ + BLI_assert(compare_flag == SDNA_CMP_NOT_EQUAL); + r_step->type = RECONSTRUCT_STEP_SUBSTRUCT; + r_step->data.substruct.new_offset = new_member_offset; + r_step->data.substruct.old_offset = old_member_offset; + r_step->data.substruct.array_len = shared_array_length; + r_step->data.substruct.new_struct_nr = new_struct_nr; + r_step->data.substruct.old_struct_nr = old_struct_nr; } } else { - cpc += elen; /* skip field no longer present */ + /* Cannot match structs that have different names. */ + r_step->type = RECONSTRUCT_STEP_INIT_ZERO; + } + break; + } + case STRUCT_MEMBER_CATEGORY_PRIMITIVE: { + if (STREQ(new_type_name, old_type_name)) { + /* Primitives with the same name cannot be different, so just do a memcpy. */ + r_step->type = RECONSTRUCT_STEP_MEMCPY; + r_step->data.memcpy.new_offset = new_member_offset; + r_step->data.memcpy.old_offset = old_member_offset; + r_step->data.memcpy.size = newsdna->types_size[new_member->type] * shared_array_length; + } + else { + /* The old and new primitive types are different, cast from the old to new type. */ + r_step->type = RECONSTRUCT_STEP_CAST_PRIMITIVE; + r_step->data.cast_primitive.array_len = shared_array_length; + r_step->data.cast_primitive.new_offset = new_member_offset; + r_step->data.cast_primitive.old_offset = old_member_offset; + r_step->data.cast_primitive.new_type = new_member->type; + r_step->data.cast_primitive.old_type = old_member->type; } + break; } - else { - /* non-struct field type */ - reconstruct_elem(newsdna, oldsdna, type, spc[1], cpc, spo, data); - cpc += elen; + case STRUCT_MEMBER_CATEGORY_POINTER: { + if (newsdna->pointer_size == oldsdna->pointer_size) { + /* The pointer size is the same, so just do a memcpy. */ + r_step->type = RECONSTRUCT_STEP_MEMCPY; + r_step->data.memcpy.new_offset = new_member_offset; + r_step->data.memcpy.old_offset = old_member_offset; + r_step->data.memcpy.size = newsdna->pointer_size * shared_array_length; + } + else if (newsdna->pointer_size == 8 && oldsdna->pointer_size == 4) { + /* Need to convert from 32 bit to 64 bit pointers. */ + r_step->type = RECONSTRUCT_STEP_CAST_POINTER_TO_64; + r_step->data.cast_pointer.new_offset = new_member_offset; + r_step->data.cast_pointer.old_offset = old_member_offset; + r_step->data.cast_pointer.array_len = shared_array_length; + } + else if (newsdna->pointer_size == 4 && oldsdna->pointer_size == 8) { + /* Need to convert from 64 bit to 32 bit pointers. */ + r_step->type = RECONSTRUCT_STEP_CAST_POINTER_TO_32; + r_step->data.cast_pointer.new_offset = new_member_offset; + r_step->data.cast_pointer.old_offset = old_member_offset; + r_step->data.cast_pointer.array_len = shared_array_length; + } + else { + BLI_assert(!"invalid pointer size"); + r_step->type = RECONSTRUCT_STEP_INIT_ZERO; + } + break; } } } -/** - * Does endian swapping on the fields of a struct value. - * - * \param oldsdna: SDNA of Blender that saved file - * \param oldSDNAnr: Index of struct info within oldsdna - * \param data: Struct data - */ -void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data) +/** Useful function when debugging the reconstruct steps. */ +static void print_reconstruct_step(ReconstructStep *step, const SDNA *oldsdna, const SDNA *newsdna) { - /* Recursive! - * If element is a struct, call recursive. - */ - int a, mul, elemcount, elen, elena, firststructtypenr; - const short *spo, *spc; - char *cur; - const char *type, *name; - unsigned int oldsdna_index_last = UINT_MAX; - - if (oldSDNAnr == -1) { - return; + switch (step->type) { + case RECONSTRUCT_STEP_INIT_ZERO: { + printf("init zero"); + break; + } + case RECONSTRUCT_STEP_MEMCPY: { + printf("memcpy, size: %d, old offset: %d, new offset: %d", + step->data.memcpy.size, + step->data.memcpy.old_offset, + step->data.memcpy.new_offset); + break; + } + case RECONSTRUCT_STEP_CAST_PRIMITIVE: { + printf( + "cast element, old type: %d ('%s'), new type: %d ('%s'), old offset: %d, new offset: " + "%d, length: %d", + (int)step->data.cast_primitive.old_type, + oldsdna->types[step->data.cast_primitive.old_type], + (int)step->data.cast_primitive.new_type, + newsdna->types[step->data.cast_primitive.new_type], + step->data.cast_primitive.old_offset, + step->data.cast_primitive.new_offset, + step->data.cast_primitive.array_len); + break; + } + case RECONSTRUCT_STEP_CAST_POINTER_TO_32: { + printf("pointer to 32, old offset: %d, new offset: %d, length: %d", + step->data.cast_pointer.old_offset, + step->data.cast_pointer.new_offset, + step->data.cast_pointer.array_len); + break; + } + case RECONSTRUCT_STEP_CAST_POINTER_TO_64: { + printf("pointer to 64, old offset: %d, new offset: %d, length: %d", + step->data.cast_pointer.old_offset, + step->data.cast_pointer.new_offset, + step->data.cast_pointer.array_len); + break; + } + case RECONSTRUCT_STEP_SUBSTRUCT: { + printf( + "substruct, old offset: %d, new offset: %d, new struct: %d ('%s', size per struct: %d), " + "length: %d", + step->data.substruct.old_offset, + step->data.substruct.new_offset, + step->data.substruct.new_struct_nr, + newsdna->types[newsdna->structs[step->data.substruct.new_struct_nr]->type], + newsdna->types_size[newsdna->structs[step->data.substruct.new_struct_nr]->type], + step->data.substruct.array_len); + break; + } } - firststructtypenr = *(oldsdna->structs[0]); - - spo = spc = oldsdna->structs[oldSDNAnr]; - - elemcount = spo[1]; - - spc += 2; - cur = data; - - for (a = 0; a < elemcount; a++, spc += 2) { - type = oldsdna->types[spc[0]]; - name = oldsdna->names[spc[1]]; - const int old_name_array_len = oldsdna->names_array_len[spc[1]]; - - /* DNA_elem_size_nr = including arraysize */ - elen = DNA_elem_size_nr(oldsdna, spc[0], spc[1]); - - /* test: is type a struct? */ - if (spc[0] >= firststructtypenr && !ispointer(name)) { - /* struct field type */ - /* where does the old data start (is there one?) */ - char *cpo = (char *)find_elem(oldsdna, type, name, spo, data, NULL); - if (cpo) { - oldSDNAnr = DNA_struct_find_nr_ex(oldsdna, type, &oldsdna_index_last); - - mul = old_name_array_len; - elena = elen / mul; +} - while (mul--) { - DNA_struct_switch_endian(oldsdna, oldSDNAnr, cpo); - cpo += elena; - } - } - } - else { - /* non-struct field type */ - if (ispointer(name)) { - if (oldsdna->pointer_size == 8) { - BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len); - } - } - else { - if (ELEM(spc[0], SDNA_TYPE_SHORT, SDNA_TYPE_USHORT)) { +/** + * Generate an array of reconstruct steps for the given #new_struct. There will be one + * reconstruct step for every member. + */ +static ReconstructStep *create_reconstruct_steps_for_struct(const SDNA *oldsdna, + const SDNA *newsdna, + const char *compare_flags, + const SDNA_Struct *old_struct, + const SDNA_Struct *new_struct) +{ + ReconstructStep *steps = MEM_calloc_arrayN( + new_struct->members_len, sizeof(ReconstructStep), __func__); + + int new_member_offset = 0; + for (int new_member_index = 0; new_member_index < new_struct->members_len; new_member_index++) { + const SDNA_StructMember *new_member = &new_struct->members[new_member_index]; + init_reconstruct_step_for_member(oldsdna, + newsdna, + compare_flags, + old_struct, + new_member, + new_member_offset, + &steps[new_member_index]); + new_member_offset += get_member_size_in_bytes(newsdna, new_member); + } + + return steps; +} - /* exception: variable called blocktype: derived from ID_ */ - bool skip = false; - if (name[0] == 'b' && name[1] == 'l') { - if (STREQ(name, "blocktype")) { - skip = true; +/** Compresses an array of reconstruct steps in-place and returns the new step count. */ +static int compress_reconstruct_steps(ReconstructStep *steps, const int old_step_count) +{ + int new_step_count = 0; + for (int a = 0; a < old_step_count; a++) { + ReconstructStep *step = &steps[a]; + switch (step->type) { + case RECONSTRUCT_STEP_INIT_ZERO: + /* These steps are simply removed. */ + break; + case RECONSTRUCT_STEP_MEMCPY: + if (new_step_count > 0) { + /* Try to merge this memcpy step with the previous one. */ + ReconstructStep *prev_step = &steps[new_step_count - 1]; + if (prev_step->type == RECONSTRUCT_STEP_MEMCPY) { + /* Check if there are no bytes between the blocks to copy. */ + if (prev_step->data.memcpy.old_offset + prev_step->data.memcpy.size == + step->data.memcpy.old_offset && + prev_step->data.memcpy.new_offset + prev_step->data.memcpy.size == + step->data.memcpy.new_offset) { + prev_step->data.memcpy.size += step->data.memcpy.size; + break; } } - - if (skip == false) { - BLI_endian_switch_int16_array((int16_t *)cur, old_name_array_len); - } - } - else if (ELEM(spc[0], SDNA_TYPE_INT, SDNA_TYPE_FLOAT)) { - /* note, intentionally ignore long/ulong here these could be 4 or 8 bits, - * but turns out we only used for runtime vars and - * only once for a struct type that's no longer used. */ - - BLI_endian_switch_int32_array((int32_t *)cur, old_name_array_len); - } - else if (ELEM(spc[0], SDNA_TYPE_INT64, SDNA_TYPE_UINT64, SDNA_TYPE_DOUBLE)) { - BLI_endian_switch_int64_array((int64_t *)cur, old_name_array_len); } - } + steps[new_step_count] = *step; + new_step_count++; + break; + case RECONSTRUCT_STEP_CAST_PRIMITIVE: + case RECONSTRUCT_STEP_CAST_POINTER_TO_32: + case RECONSTRUCT_STEP_CAST_POINTER_TO_64: + case RECONSTRUCT_STEP_SUBSTRUCT: + /* These steps are not changed at all for now. It should be possible to merge consecutive + * steps of the same type, but it is not really worth it. */ + steps[new_step_count] = *step; + new_step_count++; + break; } - cur += elen; } + return new_step_count; } /** - * \param newsdna: SDNA of current Blender - * \param oldsdna: SDNA of Blender that saved file - * \param compflags: - * - * Result from DNA_struct_get_compareflags to avoid needless conversions - * \param oldSDNAnr: Index of struct info within oldsdna - * \param blocks: The number of array elements - * \param data: Array of struct data - * \return An allocated reconstructed struct + * Pre-process information about how structs in \a newsdna can be reconstructed from structs in + * \a oldsdna. This information is then used to speedup #DNA_struct_reconstruct. */ -void *DNA_struct_reconstruct(const SDNA *newsdna, - const SDNA *oldsdna, - const char *compflags, - int oldSDNAnr, - int blocks, - const void *data) +DNA_ReconstructInfo *DNA_reconstruct_info_create(const SDNA *oldsdna, + const SDNA *newsdna, + const char *compare_flags) { - int a, curSDNAnr, curlen = 0, oldlen; - const short *spo, *spc; - char *cur, *cpc; - const char *cpo; - const char *type; - - /* oldSDNAnr == structnr, we're looking for the corresponding 'cur' number */ - spo = oldsdna->structs[oldSDNAnr]; - type = oldsdna->types[spo[0]]; - oldlen = oldsdna->types_size[spo[0]]; - curSDNAnr = DNA_struct_find_nr(newsdna, type); - - /* init data and alloc */ - if (curSDNAnr != -1) { - spc = newsdna->structs[curSDNAnr]; - curlen = newsdna->types_size[spc[0]]; - } - if (curlen == 0) { - return NULL; - } + DNA_ReconstructInfo *reconstruct_info = MEM_callocN(sizeof(DNA_ReconstructInfo), __func__); + reconstruct_info->oldsdna = oldsdna; + reconstruct_info->newsdna = newsdna; + reconstruct_info->compare_flags = compare_flags; + reconstruct_info->step_counts = MEM_malloc_arrayN(sizeof(int), newsdna->structs_len, __func__); + reconstruct_info->steps = MEM_malloc_arrayN( + sizeof(ReconstructStep *), newsdna->structs_len, __func__); + + /* Generate reconstruct steps for all structs. */ + for (int new_struct_nr = 0; new_struct_nr < newsdna->structs_len; new_struct_nr++) { + const SDNA_Struct *new_struct = newsdna->structs[new_struct_nr]; + const char *new_struct_name = newsdna->types[new_struct->type]; + const int old_struct_nr = DNA_struct_find_nr(oldsdna, new_struct_name); + if (old_struct_nr < 0) { + reconstruct_info->steps[new_struct_nr] = NULL; + reconstruct_info->step_counts[new_struct_nr] = 0; + continue; + } + const SDNA_Struct *old_struct = oldsdna->structs[old_struct_nr]; + ReconstructStep *steps = create_reconstruct_steps_for_struct( + oldsdna, newsdna, compare_flags, old_struct, new_struct); + + int steps_len = new_struct->members_len; + /* Comment the line below to skip the compression for debugging purposes. */ + steps_len = compress_reconstruct_steps(steps, new_struct->members_len); + + reconstruct_info->steps[new_struct_nr] = steps; + reconstruct_info->step_counts[new_struct_nr] = steps_len; - cur = MEM_callocN(blocks * curlen, "reconstruct"); - cpc = cur; - cpo = data; - for (a = 0; a < blocks; a++) { - reconstruct_struct(newsdna, oldsdna, compflags, oldSDNAnr, cpo, curSDNAnr, cpc); - cpc += curlen; - cpo += oldlen; +/* This is useful when debugging the reconstruct steps. */ +#if 0 + printf("%s: \n", new_struct_name); + for (int a = 0; a < steps_len; a++) { + printf(" "); + print_reconstruct_step(&steps[a], oldsdna, newsdna); + printf("\n"); + } +#endif + UNUSED_VARS(print_reconstruct_step); } - return cur; + return reconstruct_info; +} + +void DNA_reconstruct_info_free(DNA_ReconstructInfo *reconstruct_info) +{ + for (int a = 0; a < reconstruct_info->newsdna->structs_len; a++) { + if (reconstruct_info->steps[a] != NULL) { + MEM_freeN(reconstruct_info->steps[a]); + } + } + MEM_freeN(reconstruct_info->steps); + MEM_freeN(reconstruct_info->step_counts); + MEM_freeN(reconstruct_info); } /** * Returns the offset of the field with the specified name and type within the specified - * struct type in sdna. + * struct type in #SDNA, -1 on failure. */ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const char *name) { const int SDNAnr = DNA_struct_find_nr(sdna, stype); - const short *const spo = sdna->structs[SDNAnr]; - const char *const cp = find_elem(sdna, vartype, name, spo, NULL, NULL); BLI_assert(SDNAnr != -1); - return (int)((intptr_t)cp); + const SDNA_Struct *const spo = sdna->structs[SDNAnr]; + return elem_offset(sdna, vartype, name, spo); } bool DNA_struct_find(const SDNA *sdna, const char *stype) @@ -1475,7 +1614,7 @@ bool DNA_struct_elem_find(const SDNA *sdna, const int SDNAnr = DNA_struct_find_nr(sdna, stype); if (SDNAnr != -1) { - const short *const spo = sdna->structs[SDNAnr]; + const SDNA_Struct *const spo = sdna->structs[SDNAnr]; const bool found = elem_exists(sdna, vartype, name, spo); if (found) { @@ -1494,7 +1633,7 @@ bool DNA_struct_alias_elem_find(const SDNA *sdna, const int SDNAnr = DNA_struct_alias_find_nr(sdna, stype); if (SDNAnr != -1) { - const short *const spo = sdna->structs[SDNAnr]; + const SDNA_Struct *const spo = sdna->structs[SDNAnr]; const bool found = elem_exists_alias(sdna, vartype, name, spo); if (found) { @@ -1539,13 +1678,13 @@ static bool DNA_sdna_patch_struct_nr(SDNA *sdna, const char *struct_name_new) { BLI_assert(DNA_struct_find_nr(DNA_sdna_current_get(), struct_name_new) != -1); - const short *sp = sdna->structs[struct_name_old_nr]; + const SDNA_Struct *struct_info = sdna->structs[struct_name_old_nr]; #ifdef WITH_DNA_GHASH - BLI_ghash_remove(sdna->structs_map, (void *)sdna->types[sp[0]], NULL, NULL); + BLI_ghash_remove(sdna->structs_map, (void *)sdna->types[struct_info->type], NULL, NULL); BLI_ghash_insert( sdna->structs_map, (void *)struct_name_new, POINTER_FROM_INT(struct_name_old_nr)); #endif - sdna->types[sp[0]] = struct_name_new; + sdna->types[struct_info->type] = struct_name_new; return true; } /** @@ -1560,7 +1699,7 @@ bool DNA_sdna_patch_struct(SDNA *sdna, const char *struct_name_old, const char * return false; } -/* Make public if called often with same struct (avoid duplicate look-ups). */ +/* Make public if called often with same struct (avoid duplicate lookups). */ static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna, const int struct_name_nr, const char *elem_old, @@ -1572,9 +1711,10 @@ static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna, const int elem_old_len = strlen(elem_old); const int elem_new_len = strlen(elem_new); BLI_assert(elem_new != NULL); - short *sp = sdna->structs[struct_name_nr]; - for (int elem_index = sp[1]; elem_index > 0; elem_index--, sp += 2) { - const char *elem_old_full = sdna->names[sp[1]]; + SDNA_Struct *sp = sdna->structs[struct_name_nr]; + for (int elem_index = sp->members_len; elem_index > 0; elem_index--) { + SDNA_StructMember *member = &sp->members[elem_index]; + const char *elem_old_full = sdna->names[member->name]; /* Start & end offsets in 'elem_old_full'. */ uint elem_old_full_offset_start; if (DNA_elem_id_match(elem_old, elem_old_len, elem_old_full, &elem_old_full_offset_start)) { @@ -1597,10 +1737,10 @@ static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna, sdna->names_array_len = MEM_recallocN( (void *)sdna->names_array_len, sizeof(*sdna->names_array_len) * sdna->names_len_alloc); } - const short name_nr_prev = sp[1]; - sp[1] = sdna->names_len++; - sdna->names[sp[1]] = elem_new_full; - sdna->names_array_len[sp[1]] = sdna->names_array_len[name_nr_prev]; + const short name_nr_prev = member->name; + member->name = sdna->names_len++; + sdna->names[member->name] = elem_new_full; + sdna->names_array_len[member->name] = sdna->names_array_len[name_nr_prev]; return true; } @@ -1634,7 +1774,7 @@ bool DNA_sdna_patch_struct_member(SDNA *sdna, /** * Names are shared between structs which causes problems renaming. - * Make sure every struct member gets it's own name so renaming only ever impacts a single struct. + * Make sure every struct member gets its own name so renaming only ever impacts a single struct. * * The resulting SDNA is never written to disk. */ @@ -1642,8 +1782,8 @@ static void sdna_expand_names(SDNA *sdna) { int names_expand_len = 0; for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { - const short *sp = sdna->structs[struct_nr]; - names_expand_len += sp[1]; + const SDNA_Struct *struct_old = sdna->structs[struct_nr]; + names_expand_len += struct_old->members_len; } const char **names_expand = MEM_mallocN(sizeof(*names_expand) * names_expand_len, __func__); short *names_array_len_expand = MEM_mallocN(sizeof(*names_array_len_expand) * names_expand_len, @@ -1652,18 +1792,22 @@ static void sdna_expand_names(SDNA *sdna) int names_expand_index = 0; for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { /* We can't edit this memory 'sdna->structs' points to (readonly datatoc file). */ - const short *sp = sdna->structs[struct_nr]; - short *sp_expand = BLI_memarena_alloc(sdna->mem_arena, sizeof(short[2]) * (1 + sp[1])); - memcpy(sp_expand, sp, sizeof(short[2]) * (1 + sp[1])); - sdna->structs[struct_nr] = sp_expand; - const int names_len = sp[1]; - sp += 2; - sp_expand += 2; - for (int i = 0; i < names_len; i++, sp += 2, sp_expand += 2) { - names_expand[names_expand_index] = sdna->names[sp[1]]; - names_array_len_expand[names_expand_index] = sdna->names_array_len[sp[1]]; + const SDNA_Struct *struct_old = sdna->structs[struct_nr]; + + const int array_size = sizeof(short) * 2 + sizeof(SDNA_StructMember) * struct_old->members_len; + SDNA_Struct *struct_new = BLI_memarena_alloc(sdna->mem_arena, array_size); + memcpy(struct_new, struct_old, array_size); + sdna->structs[struct_nr] = struct_new; + + for (int i = 0; i < struct_old->members_len; i++) { + const SDNA_StructMember *member_old = &struct_old->members[i]; + SDNA_StructMember *member_new = &struct_new->members[i]; + + names_expand[names_expand_index] = sdna->names[member_old->name]; + names_array_len_expand[names_expand_index] = sdna->names_array_len[member_old->name]; + BLI_assert(names_expand_index < SHRT_MAX); - sp_expand[1] = names_expand_index; + member_new->name = names_expand_index; names_expand_index++; } } @@ -1732,23 +1876,22 @@ void DNA_sdna_alias_data_ensure(SDNA *sdna) sdna_expand_names(sdna); sdna->alias.names = MEM_mallocN(sizeof(*sdna->alias.names) * sdna->names_len, __func__); for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { - const short *sp = sdna->structs[struct_nr]; - const char *struct_name_static = sdna->types[sp[0]]; + const SDNA_Struct *struct_info = sdna->structs[struct_nr]; + const char *struct_name_static = sdna->types[struct_info->type]; if (use_legacy_hack) { struct_name_static = DNA_struct_rename_legacy_hack_alias_from_static(struct_name_static); } - const int dna_struct_names_len = sp[1]; - sp += 2; - for (int a = 0; a < dna_struct_names_len; a++, sp += 2) { + for (int a = 0; a < struct_info->members_len; a++) { + const SDNA_StructMember *member = &struct_info->members[a]; const char *elem_alias_full = dna_sdna_alias_from_static_elem_full( - sdna, elem_map_alias_from_static, struct_name_static, sdna->names[sp[1]]); + sdna, elem_map_alias_from_static, struct_name_static, sdna->names[member->name]); if (elem_alias_full != NULL) { - sdna->alias.names[sp[1]] = elem_alias_full; + sdna->alias.names[member->name] = elem_alias_full; } else { - sdna->alias.names[sp[1]] = sdna->names[sp[1]]; + sdna->alias.names[member->name] = sdna->names[member->name]; } } } @@ -1768,8 +1911,9 @@ void DNA_sdna_alias_data_ensure_structs_map(SDNA *sdna) /* create a ghash lookup to speed up */ struct GHash *structs_map = BLI_ghash_str_new_ex(__func__, sdna->structs_len); for (intptr_t nr = 0; nr < sdna->structs_len; nr++) { - const short *sp = sdna->structs[nr]; - BLI_ghash_insert(structs_map, (void *)sdna->alias.types[sp[0]], POINTER_FROM_INT(nr)); + const SDNA_Struct *struct_info = sdna->structs[nr]; + BLI_ghash_insert( + structs_map, (void *)sdna->alias.types[struct_info->type], POINTER_FROM_INT(nr)); } sdna->alias.structs_map = structs_map; #else diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index a0e983e7d3b..2a4160bdfb1 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -24,7 +24,7 @@ * Defines in this header are only used to define blend file storage. * This allows us to rename variables & structs without breaking compatibility. * - * - When renaming the member of a struct which has it's self been renamed + * - When renaming the member of a struct which has itself been renamed * refer to the newer name, not the original. * * - Changes here only change generated code for `makesdna.c` and `makesrna.c` @@ -126,3 +126,6 @@ DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar) DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences) DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d) DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame) +/* Write with a different name, old Blender versions crash loading files with non-NULL + * global_areas. See D9442. */ +DNA_STRUCT_RENAME_ELEM(wmWindow, global_area_map, global_areas) diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 29e29961028..81a7da7b4d8 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -43,7 +43,6 @@ #define DNA_DEPRECATED_ALLOW -#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -354,8 +353,6 @@ static bool is_name_legal(const char *name) static int add_type(const char *str, int size) { - char *cp; - /* first do validity check */ if (str[0] == 0) { return -1; @@ -382,7 +379,7 @@ static int add_type(const char *str, int size) /* append new type */ const int str_size = strlen(str) + 1; - cp = BLI_memarena_alloc(mem_arena, str_size); + char *cp = BLI_memarena_alloc(mem_arena, str_size); memcpy(cp, str, str_size); types[types_len] = cp; types_size_native[types_len] = size; @@ -408,8 +405,6 @@ static int add_type(const char *str, int size) * */ static int add_name(const char *str) { - int nr, i, j, k; - char *cp; char buf[255]; /* stupid limit, change it :) */ const char *name; @@ -420,15 +415,15 @@ static int add_name(const char *str) } if (str[0] == '(' && str[1] == '*') { - /* we handle function pointer and special array cases here, e.g. - * void (*function)(...) and float (*array)[..]. the array case + /* We handle function pointer and special array cases here, e.g. + * `void (*function)(...)` and `float (*array)[..]`. the array case * name is still converted to (array *)() though because it is that - * way in old dna too, and works correct with elementsize() */ + * way in old DNA too, and works correct with #DNA_elem_size_nr. */ int isfuncptr = (strchr(str + 1, '(')) != NULL; DEBUG_PRINTF(3, "\t\t\t\t*** Function pointer or multidim array pointer found\n"); /* functionpointer: transform the type (sometimes) */ - i = 0; + int i = 0; while (str[i] != ')') { buf[i] = str[i]; @@ -438,7 +433,7 @@ static int add_name(const char *str) /* Another number we need is the extra slen offset. This extra * offset is the overshoot after a space. If there is no * space, no overshoot should be calculated. */ - j = i; /* j at first closing brace */ + int j = i; /* j at first closing brace */ DEBUG_PRINTF(3, "first brace after offset %d\n", i); @@ -466,7 +461,7 @@ static int add_name(const char *str) else if (str[j] == 0) { DEBUG_PRINTF(3, "offsetting for space\n"); /* get additional offset */ - k = 0; + int k = 0; while (str[j] != ')') { j++; k++; @@ -512,7 +507,7 @@ static int add_name(const char *str) buf[i + 2] = ')'; buf[i + 3] = 0; } - /* now precede with buf*/ + /* now proceed with buf*/ DEBUG_PRINTF(3, "\t\t\t\t\tProposing fp name %s\n", buf); name = buf; } @@ -522,7 +517,7 @@ static int add_name(const char *str) } /* search name array */ - for (nr = 0; nr < names_len; nr++) { + for (int nr = 0; nr < names_len; nr++) { if (STREQ(name, names[nr])) { return nr; } @@ -535,7 +530,7 @@ static int add_name(const char *str) /* Append new name. */ const int name_size = strlen(name) + 1; - cp = BLI_memarena_alloc(mem_arena, name_size); + char *cp = BLI_memarena_alloc(mem_arena, name_size); memcpy(cp, name, name_size); names[names_len] = cp; @@ -550,19 +545,16 @@ static int add_name(const char *str) static short *add_struct(int namecode) { - int len; - short *sp; - if (structs_len == 0) { structs[0] = structdata; } else { - sp = structs[structs_len - 1]; - len = sp[1]; + short *sp = structs[structs_len - 1]; + const int len = sp[1]; structs[structs_len] = sp + 2 * len + 2; } - sp = structs[structs_len]; + short *sp = structs[structs_len]; sp[0] = namecode; if (structs_len >= max_array_len) { @@ -576,21 +568,18 @@ static short *add_struct(int namecode) static int preprocess_include(char *maindata, const int maindata_len) { - int a, newlen, comment = 0; - char *cp, *temp, *md; - /* note: len + 1, last character is a dummy to prevent * comparisons using uninitialized memory */ - temp = MEM_mallocN(maindata_len + 1, "preprocess_include"); + char *temp = MEM_mallocN(maindata_len + 1, "preprocess_include"); temp[maindata_len] = ' '; memcpy(temp, maindata, maindata_len); /* remove all c++ comments */ /* replace all enters/tabs/etc with spaces */ - cp = temp; - a = maindata_len; - comment = 0; + char *cp = temp; + int a = maindata_len; + int comment = 0; while (a--) { if (cp[0] == '/' && cp[1] == '/') { comment = 1; @@ -606,8 +595,8 @@ static int preprocess_include(char *maindata, const int maindata_len) /* data from temp copy to maindata, remove comments and double spaces */ cp = temp; - md = maindata; - newlen = 0; + char *md = maindata; + int newlen = 0; comment = 0; a = maindata_len; while (a--) { @@ -694,23 +683,21 @@ static int convert_include(const char *filename) /* read include file, skip structs with a '#' before it. * store all data in temporal arrays. */ - int maindata_len, count, slen, type, name, strct; - short *structpoin, *sp; - char *maindata, *mainend, *md, *md1; - bool skip_struct; - md = maindata = read_file_data(filename, &maindata_len); + int maindata_len; + char *maindata = read_file_data(filename, &maindata_len); + char *md = maindata; if (maindata_len == -1) { fprintf(stderr, "Can't read file %s\n", filename); return 1; } maindata_len = preprocess_include(maindata, maindata_len); - mainend = maindata + maindata_len - 1; + char *mainend = maindata + maindata_len - 1; /* we look for '{' and then back to 'struct' */ - count = 0; - skip_struct = false; + int count = 0; + bool skip_struct = false; while (count < maindata_len) { /* code for skipping a struct: two hashes on 2 lines. (preprocess added a space) */ @@ -727,7 +714,7 @@ static int convert_include(const char *filename) if (md[-1] == ' ') { md[-1] = 0; } - md1 = md - 2; + char *md1 = md - 2; while (*md1 != 32) { /* to beginning of word */ md1--; @@ -737,14 +724,14 @@ static int convert_include(const char *filename) /* we've got a struct name when... */ if (strncmp(md1 - 7, "struct", 6) == 0) { - strct = add_type(md1, 0); + const int strct = add_type(md1, 0); if (strct == -1) { fprintf(stderr, "File '%s' contains struct we cant parse \"%s\"\n", filename, md1); return 1; } - structpoin = add_struct(strct); - sp = structpoin + 2; + short *structpoin = add_struct(strct); + short *sp = structpoin + 2; DEBUG_PRINTF(1, "\t|\t|-- detected struct %s\n", types[strct]); @@ -755,7 +742,7 @@ static int convert_include(const char *filename) break; } - if (*md1 == ',' || *md1 == ' ') { + if (ELEM(*md1, ',', ' ')) { *md1 = 0; } md1++; @@ -781,7 +768,7 @@ static int convert_include(const char *filename) } /* we've got a type! */ - type = add_type(md1, 0); + const int type = add_type(md1, 0); if (type == -1) { fprintf( stderr, "File '%s' contains struct we can't parse \"%s\"\n", filename, md1); @@ -802,11 +789,11 @@ static int convert_include(const char *filename) /* We've got a name. slen needs * correction for function * pointers! */ - slen = (int)strlen(md1); + int slen = (int)strlen(md1); if (md1[slen - 1] == ';') { md1[slen - 1] = 0; - name = add_name(version_elem_static_from_alias(strct, md1)); + const int name = add_name(version_elem_static_from_alias(strct, md1)); if (name == -1) { fprintf(stderr, "File '%s' contains struct with name that can't be added \"%s\"\n", @@ -829,7 +816,7 @@ static int convert_include(const char *filename) break; } - name = add_name(version_elem_static_from_alias(strct, md1)); + const int name = add_name(version_elem_static_from_alias(strct, md1)); if (name == -1) { fprintf(stderr, "File '%s' contains struct with name that can't be added \"%s\"\n", @@ -905,7 +892,6 @@ static bool check_field_alignment( static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char *base_directory) { - int unknown = structs_len, lastunknown; bool dna_error = false; /* Write test to verify sizes are accurate. */ @@ -923,8 +909,9 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char fprintf(file_verify, "\n"); /* Multiple iterations to handle nested structs. */ + int unknown = structs_len; while (unknown) { - lastunknown = unknown; + const int lastunknown = unknown; unknown = 0; /* check all structs... */ @@ -1151,12 +1138,9 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char static void dna_write(FILE *file, const void *pntr, const int size) { static int linelength = 0; - int i; - const char *data; + const char *data = (const char *)pntr; - data = (const char *)pntr; - - for (i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { fprintf(file, "%d, ", data[i]); linelength++; if (linelength >= MAX_DNA_LINE_LENGTH) { @@ -1168,19 +1152,16 @@ static void dna_write(FILE *file, const void *pntr, const int size) void print_struct_sizes(void) { - int a, unknown = structs_len, structtype; - /*int lastunknown;*/ /*UNUSED*/ - const short *structpoin; + int unknown = structs_len; printf("\n\n*** All detected structs:\n"); while (unknown) { - /*lastunknown = unknown;*/ /*UNUSED*/ unknown = 0; /* check all structs... */ - for (a = 0; a < structs_len; a++) { - structpoin = structs[a]; - structtype = structpoin[0]; + for (int a = 0; a < structs_len; a++) { + const short *structpoin = structs[a]; + const int structtype = structpoin[0]; printf("\t%s\t:%d\n", types[structtype], types_size_native[structtype]); } } @@ -1193,13 +1174,6 @@ static int make_structDNA(const char *base_directory, FILE *file_offsets, FILE *file_verify) { - int i; - const short *sp; - /* str contains filenames. Since we now include paths, I stretched */ - /* it a bit. Hope this is enough :) -nzc- */ - char str[SDNA_MAX_FILENAME_LENGTH]; - int firststruct; - if (debugSDNA > 0) { fflush(stdout); printf("Running makesdna at debug level %d\n", debugSDNA); @@ -1251,21 +1225,27 @@ static int make_structDNA(const char *base_directory, add_type("void", 0); /* SDNA_TYPE_VOID */ /* the defines above shouldn't be output in the padding file... */ - firststruct = types_len; + const int firststruct = types_len; /* add all include files defined in the global array */ /* Since the internal file+path name buffer has limited length, I do a */ /* little test first... */ /* Mind the breaking condition here! */ DEBUG_PRINTF(0, "\tStart of header scan:\n"); - for (i = 0; *(includefiles[i]) != '\0'; i++) { + int header_count = 0; + for (int i = 0; *(includefiles[i]) != '\0'; i++) { + header_count++; + + /* str contains filenames. Since we now include paths, I stretched */ + /* it a bit. Hope this is enough :) -nzc- */ + char str[SDNA_MAX_FILENAME_LENGTH]; sprintf(str, "%s%s", base_directory, includefiles[i]); DEBUG_PRINTF(0, "\t|-- Converting %s\n", str); if (convert_include(str)) { return 1; } } - DEBUG_PRINTF(0, "\tFinished scanning %d headers.\n", i); + DEBUG_PRINTF(0, "\tFinished scanning %d headers.\n", header_count); if (calculate_struct_sizes(firststruct, file_verify, base_directory)) { /* error */ @@ -1284,7 +1264,7 @@ static int make_structDNA(const char *base_directory, } printf("\n"); - sp = types_size_native; + const short *sp = types_size_native; for (a = 0; a < types_len; a++, sp++) { printf(" %s %d\n", types[a], *sp); } @@ -1311,13 +1291,12 @@ static int make_structDNA(const char *base_directory, } else { const char nil_bytes[4] = {0}; - int len, len_align; dna_write(file, "SDNA", 4); /* write names */ dna_write(file, "NAME", 4); - len = names_len; + int len = names_len; dna_write(file, &len, 4); /* write array */ len = 0; @@ -1326,7 +1305,7 @@ static int make_structDNA(const char *base_directory, dna_write(file, names[nr], name_size); len += name_size; } - len_align = (len + 3) & ~3; + int len_align = (len + 3) & ~3; if (len != len_align) { dna_write(file, nil_bytes, len_align - len); } @@ -1362,7 +1341,7 @@ static int make_structDNA(const char *base_directory, dna_write(file, &len, 4); /* calc datablock size */ - sp = structs[structs_len - 1]; + const short *sp = structs[structs_len - 1]; sp += 2 + 2 * (sp[1]); len = (intptr_t)((char *)sp - (char *)structs[0]); len = (len + 3) & ~3; @@ -1376,7 +1355,7 @@ static int make_structDNA(const char *base_directory, fprintf(file_offsets, "#pragma once\n"); fprintf(file_offsets, "#define SDNA_TYPE_FROM_STRUCT(id) _SDNA_TYPE_##id\n"); fprintf(file_offsets, "enum {\n"); - for (i = 0; i < structs_len; i++) { + for (int i = 0; i < structs_len; i++) { const short *structpoin = structs[i]; const int structtype = structpoin[0]; fprintf(file_offsets, @@ -1393,7 +1372,7 @@ static int make_structDNA(const char *base_directory, { GSet *names_unique = BLI_gset_str_new_ex(__func__, 512); for (int struct_nr = 0; struct_nr < structs_len; struct_nr++) { - sp = structs[struct_nr]; + const short *sp = structs[struct_nr]; const char *struct_name = types[sp[0]]; const int len = sp[1]; sp += 2; @@ -1460,7 +1439,7 @@ int main(int argc, char **argv) { int return_status = 0; - if (argc != 4 && argc != 5) { + if (!ELEM(argc, 4, 5)) { printf("Usage: %s dna.c dna_struct_offsets.h [base directory]\n", argv[0]); return_status = 1; } |