diff options
Diffstat (limited to 'source/blender')
305 files changed, 2262 insertions, 1909 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index c6112344208..1fcde431d2d 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -48,7 +48,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_hair_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curves_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ipo_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_key_types.h diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index c1410447de6..3ac9fdc7f41 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1238,6 +1238,12 @@ FontBLF *blf_font_new(const char *name, const char *filename) font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); err = FT_New_Face(ft_lib, filename, 0, &font->face); if (err) { + if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { + printf("Format of this font file is not supported\n"); + } + else { + printf("Error encountered while opening font file\n"); + } MEM_freeN(font); return NULL; } diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 12d8135ba55..ede300b19dd 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -163,6 +163,30 @@ void BKE_armature_transform(struct bArmature *arm, const float mat[4][4], bool d /* Bounding box. */ struct BoundBox *BKE_armature_boundbox_get(struct Object *ob); +/** + * Calculate the axis-aligned bounds of `pchan` in world-space, + * taking into account custom transform when set. + * + * `r_min` and `r_max` are expanded to fit `pchan` so the caller must initialize them + * (typically using #INIT_MINMAX). + * + * \note The bounds are calculated based on the head & tail of the bone + * or the custom object's bounds (if the bone uses a custom object). + * Visual elements such as the envelopes radius & bendy-bone spline segments are *not* included, + * making this not so useful for viewport culling. + */ +void BKE_pchan_minmax(const struct Object *ob, + const struct bPoseChannel *pchan, + float r_min[3], + float r_max[3]); +/** + * Calculate the axis aligned bounds of the pose of `ob` in world-space. + + * `r_min` and `r_max` are expanded to fit `ob->pose` so the caller must initialize them + * (typically using #INIT_MINMAX). + * + * \note This uses #BKE_pchan_minmax, see its documentation for details on bounds calculation. + */ bool BKE_pose_minmax( struct Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select); diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 6020da08f51..ff207997e79 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -40,11 +40,11 @@ struct ReportList; /* Attribute.domain */ typedef enum AttributeDomain { ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */ - ATTR_DOMAIN_POINT = 0, /* Mesh, Hair or PointCloud Point */ + ATTR_DOMAIN_POINT = 0, /* Mesh, Curve or Point Cloud Point */ ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */ ATTR_DOMAIN_FACE = 2, /* Mesh Face */ ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */ - ATTR_DOMAIN_CURVE = 4, /* Hair Curve */ + ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */ ATTR_DOMAIN_INSTANCE = 5, /* Instance */ ATTR_DOMAIN_NUM diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index fe656166ada..1ba887903c8 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -39,7 +39,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 2 +#define BLENDER_FILE_SUBVERSION 3 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_curves.h b/source/blender/blenkernel/BKE_curves.h new file mode 100644 index 00000000000..99839b20121 --- /dev/null +++ b/source/blender/blenkernel/BKE_curves.h @@ -0,0 +1,68 @@ +/* + * 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. + */ + +#pragma once + +/** \file + * \ingroup bke + * \brief Low-level operations for curves. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct BoundBox; +struct CustomDataLayer; +struct Depsgraph; +struct Curves; +struct Main; +struct Object; +struct Scene; + +void *BKE_curves_add(struct Main *bmain, const char *name); + +struct BoundBox *BKE_curves_boundbox_get(struct Object *ob); + +void BKE_curves_update_customdata_pointers(struct Curves *curves); +bool BKE_curves_customdata_required(struct Curves *curves, struct CustomDataLayer *layer); + +/* Depsgraph */ + +struct Curves *BKE_curves_new_for_eval(const struct Curves *curves_src, + int totpoint, + int totcurve); +struct Curves *BKE_curves_copy_for_eval(struct Curves *curves_src, bool reference); + +void BKE_curves_data_update(struct Depsgraph *depsgraph, + struct Scene *scene, + struct Object *object); + +/* Draw Cache */ + +enum { + BKE_CURVES_BATCH_DIRTY_ALL = 0, +}; + +void BKE_curves_batch_cache_dirty_tag(struct Curves *curves, int mode); +void BKE_curves_batch_cache_free(struct Curves *curves); + +extern void (*BKE_curves_batch_cache_dirty_tag_cb)(struct Curves *curves, int mode); +extern void (*BKE_curves_batch_cache_free_cb)(struct Curves *curves); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index ab7961c479e..6397298c904 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -199,6 +199,17 @@ void BKE_gpencil_stroke_copy_settings(const struct bGPDstroke *gpf_src, struct bGPDstroke *gpf_dst); /** + * Make a copy of a given gpencil frame settings. + */ +void BKE_gpencil_frame_copy_settings(const struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst); + +/** + * Make a copy of a given gpencil stroke settings. + */ +void BKE_gpencil_stroke_copy_settings(const struct bGPDstroke *gpf_src, + struct bGPDstroke *gpf_dst); + +/** * Make a copy of strokes between gpencil frames. * \param gpf_src: Source grease pencil frame * \param gpf_dst: Destination grease pencil frame @@ -742,7 +753,7 @@ int BKE_gpencil_material_find_index_by_name_prefix(struct Object *ob, const char void BKE_gpencil_blend_read_data(struct BlendDataReader *reader, struct bGPdata *gpd); -bool BKE_gpencil_update_on_write_check(const struct Depsgraph *depsgraph, struct bGPdata *gpd); +bool BKE_gpencil_can_avoid_full_copy_on_write(const struct Depsgraph *depsgraph, struct bGPdata *gpd); void BKE_gpencil_update_on_write(struct bGPdata *gpd_orig, struct bGPdata *gpd_eval); diff --git a/source/blender/blenkernel/BKE_gpencil_update_cache.h b/source/blender/blenkernel/BKE_gpencil_update_cache.h index 3f491c266b4..3ac78267922 100644 --- a/source/blender/blenkernel/BKE_gpencil_update_cache.h +++ b/source/blender/blenkernel/BKE_gpencil_update_cache.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008, Blender Foundation + * The Original Code is Copyright (C) 2022, Blender Foundation * This is a new part of Blender */ @@ -83,9 +83,11 @@ typedef struct GPencilUpdateCacheNode { } GPencilUpdateCacheNode; /** - * Callback that is called in BKE_gpencil_traverse_update_cache at each level. + * Callback that is called in BKE_gpencil_traverse_update_cache at each level. If the callback + * returns true, then the children will not be iterated over and instead continue. * \param cache: The cache at this level. * \param user_data: Pointer to the user_data passed to BKE_gpencil_traverse_update_cache. + * \returns true, if iterating over the children of \a cache should be skipped, false if not. */ typedef bool (*GPencilUpdateCacheIter_Cb)(GPencilUpdateCache *cache, void *user_data); @@ -140,31 +142,11 @@ void BKE_gpencil_tag_light_update(struct bGPdata *gpd, struct bGPDstroke *gps); /** - * - */ -GPencilUpdateCache *BKE_gpencil_duplicate_update_cache_and_data(GPencilUpdateCache *gpd_cache); - -/** - * - */ -bool BKE_gpencil_compare_update_caches(GPencilUpdateCache *cache_a, GPencilUpdateCache *cache_b); - -/** * Frees the GPencilUpdateCache on the gpd->runtime. This will not free the data that the cache * node might point to. It assumes that the cache does not own the data. */ void BKE_gpencil_free_update_cache(struct bGPdata *gpd); -/** - * - */ -void BKE_gpencil_free_update_cache_and_data(GPencilUpdateCache *cache); - -/** - * - */ -void BKE_gpencil_print_update_cache(struct GPencilUpdateCache *cache); - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h deleted file mode 100644 index 403e461a9dc..00000000000 --- a/source/blender/blenkernel/BKE_hair.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ - -#pragma once - -/** \file - * \ingroup bke - * \brief General operations for hairs. - */ -#ifdef __cplusplus -extern "C" { -#endif - -struct BoundBox; -struct CustomDataLayer; -struct Depsgraph; -struct Hair; -struct Main; -struct Object; -struct Scene; - -void *BKE_hair_add(struct Main *bmain, const char *name); - -struct BoundBox *BKE_hair_boundbox_get(struct Object *ob); - -void BKE_hair_update_customdata_pointers(struct Hair *hair); -bool BKE_hair_customdata_required(struct Hair *hair, struct CustomDataLayer *layer); - -/* Depsgraph */ - -struct Hair *BKE_hair_new_for_eval(const struct Hair *hair_src, int totpoint, int totcurve); -struct Hair *BKE_hair_copy_for_eval(struct Hair *hair_src, bool reference); - -void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object); - -/* Draw Cache */ - -enum { - BKE_HAIR_BATCH_DIRTY_ALL = 0, -}; - -void BKE_hair_batch_cache_dirty_tag(struct Hair *hair, int mode); -void BKE_hair_batch_cache_free(struct Hair *hair); - -extern void (*BKE_hair_batch_cache_dirty_tag_cb)(struct Hair *hair, int mode); -extern void (*BKE_hair_batch_cache_free_cb)(struct Hair *hair); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h index df50f773a46..e9e5b183e4a 100644 --- a/source/blender/blenkernel/BKE_idtype.h +++ b/source/blender/blenkernel/BKE_idtype.h @@ -278,7 +278,7 @@ extern IDTypeInfo IDType_ID_PC; extern IDTypeInfo IDType_ID_CF; extern IDTypeInfo IDType_ID_WS; extern IDTypeInfo IDType_ID_LP; -extern IDTypeInfo IDType_ID_HA; +extern IDTypeInfo IDType_ID_CV; extern IDTypeInfo IDType_ID_PT; extern IDTypeInfo IDType_ID_VO; extern IDTypeInfo IDType_ID_SIM; diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index e8065566c97..c81616110cc 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -103,8 +103,12 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, * \param owner_library: the library in which the overrides should be created. Besides versioning * and resync code path, this should always be NULL (i.e. the local .blend file). * - * \param reference_library: the library from which the linked data being overridden come from - * (i.e. the library of the linked reference ID). + * \param id_root_reference: the linked ID that is considered as the root of the overridden + * hierarchy. + * + * \param id_hierarchy_root: the override ID that is the root of the hierarchy. May be NULL, in + * which case it is assumed that the given `id_root_reference` is tagged for override, and its + * newly created override will be used as hierarchy root. * * \param do_no_main: Create the new override data outside of Main database. * Used for resyncing of linked overrides. @@ -113,7 +117,8 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, */ bool BKE_lib_override_library_create_from_tag(struct Main *bmain, struct Library *owner_library, - const struct Library *reference_library, + const struct ID *id_root_reference, + struct ID *id_hierarchy_root, bool do_no_main); /** * Advanced 'smart' function to create fully functional overrides. @@ -172,6 +177,15 @@ bool BKE_lib_override_library_proxy_convert(struct Main *bmain, */ void BKE_lib_override_library_main_proxy_convert(struct Main *bmain, struct BlendFileReadReport *reports); + +/** + * Find and set the 'hierarchy root' ID pointer of all library overrides in given `bmain`. + * + * NOTE: Cannot be called from `do_versions_after_linking` as this code needs a single complete + * Main database, not a split-by-libraries one. + */ +void BKE_lib_override_library_main_hierarchy_root_ensure(struct Main *bmain); + /** * Advanced 'smart' function to resync, re-create fully functional overrides up-to-date with linked * data, from an existing override hierarchy. diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 4c6eb31db4b..e4f94110eb1 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -182,7 +182,11 @@ typedef struct Main { ListBase linestyles; ListBase cachefiles; ListBase workspaces; - ListBase hairs; + /** + * \note The name `hair_curves` is chosen to be different than `curves`, + * but they are generic curve data-blocks, not just for hair. + */ + ListBase hair_curves; ListBase pointclouds; ListBase volumes; ListBase simulations; diff --git a/source/blender/blenkernel/BKE_mesh_fair.h b/source/blender/blenkernel/BKE_mesh_fair.h index c4c1af054f0..2884de6d5c1 100644 --- a/source/blender/blenkernel/BKE_mesh_fair.h +++ b/source/blender/blenkernel/BKE_mesh_fair.h @@ -12,15 +12,14 @@ * 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. - * - * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": - * https://github.com/fedackb/mesh-fairing. */ #pragma once /** \file * \ingroup bke + * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": + * https://github.com/fedackb/mesh-fairing. */ #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index d583b5f0648..359a5662a13 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -274,6 +274,9 @@ typedef struct bNodeType { char *label, int maxlen); + /** Optional override for node class, used for drawing node header. */ + int (*ui_class)(const struct bNode *node); + /** Called when the node is updated in the editor. */ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node); /** Check and update if internal ID data has changed. */ @@ -1300,12 +1303,13 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i /* filter types */ #define CMP_FILT_SOFT 0 -#define CMP_FILT_SHARP 1 +#define CMP_FILT_SHARP_BOX 1 #define CMP_FILT_LAPLACE 2 #define CMP_FILT_SOBEL 3 #define CMP_FILT_PREWITT 4 #define CMP_FILT_KIRSCH 5 #define CMP_FILT_SHADOW 6 +#define CMP_FILT_SHARP_DIAMOND 7 /* scale node type, in custom1 */ #define CMP_SCALE_RELATIVE 0 diff --git a/source/blender/blenkernel/BKE_node_tree_update.h b/source/blender/blenkernel/BKE_node_tree_update.h index 443ceafb073..834445420ef 100644 --- a/source/blender/blenkernel/BKE_node_tree_update.h +++ b/source/blender/blenkernel/BKE_node_tree_update.h @@ -60,6 +60,8 @@ void BKE_ntree_update_tag_link_removed(struct bNodeTree *ntree); void BKE_ntree_update_tag_link_added(struct bNodeTree *ntree, struct bNodeLink *link); void BKE_ntree_update_tag_link_mute(struct bNodeTree *ntree, struct bNodeLink *link); +/** Used when the a new output node becomes active and therefore changes the output. */ +void BKE_ntree_update_tag_active_output_changed(struct bNodeTree *ntree); /** Used after file loading when run-time data on the tree has not been initialized yet. */ void BKE_ntree_update_tag_missing_runtime_data(struct bNodeTree *ntree); /** Used when the interface sockets/values have changed. */ diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 4b8c7f9c984..2012f749234 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -433,7 +433,7 @@ void BKE_object_eval_constraints(struct Depsgraph *depsgraph, struct Object *ob); void BKE_object_eval_transform_final(struct Depsgraph *depsgraph, struct Object *ob); -void BKE_object_eval_uber_transform(struct Depsgraph *depsgraph, struct Object *ob); +void BKE_object_eval_uber_transform(struct Depsgraph *depsgraph, struct Object *object); void BKE_object_eval_uber_data(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 804331a3412..b5e60da540e 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -13,11 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 by Janne Karhu. - * All rights reserved. - * Adaptive time step - * Classical SPH - * Copyright 2011-2012 AutoCRC + * Copyright 2007 Janne Karhu. All rights reserved. + * 2011-2012 AutoCRC (adaptive time step, Classical SPH). */ #pragma once diff --git a/source/blender/blenkernel/BKE_subdiv_foreach.h b/source/blender/blenkernel/BKE_subdiv_foreach.h index 7d9a589666a..001a4f9401b 100644 --- a/source/blender/blenkernel/BKE_subdiv_foreach.h +++ b/source/blender/blenkernel/BKE_subdiv_foreach.h @@ -74,6 +74,7 @@ typedef void (*SubdivForeachEdgeCb)(const struct SubdivForeachContext *context, void *tls, int coarse_edge_index, int subdiv_edge_index, + bool is_loose, int subdiv_v1, int subdiv_v2); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 7309caa97b0..1483466061f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -119,6 +119,7 @@ set(SRC intern/crazyspace.c intern/cryptomatte.cc intern/curve.cc + intern/curves.cc intern/curve_bevel.c intern/curve_convert.c intern/curve_decimate.c @@ -157,7 +158,6 @@ set(SRC intern/gpencil_geom.cc intern/gpencil_modifier.c intern/gpencil_update_cache.c - intern/hair.cc intern/icons.cc intern/icons_rasterize.c intern/idprop.c @@ -357,6 +357,7 @@ set(SRC BKE_cryptomatte.h BKE_cryptomatte.hh BKE_curve.h + BKE_curves.h BKE_curve_to_mesh.hh BKE_curveprofile.h BKE_customdata.h @@ -386,7 +387,6 @@ set(SRC BKE_gpencil_geom.h BKE_gpencil_modifier.h BKE_gpencil_update_cache.h - BKE_hair.h BKE_icons.h BKE_idprop.h BKE_idprop.hh diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 42b72a7cd66..1c0b465d202 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -1284,8 +1284,8 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use /* cache files */ ANIMDATA_IDS_CB(bmain->cachefiles.first); - /* hairs */ - ANIMDATA_IDS_CB(bmain->hairs.first); + /* Hair Curves. */ + ANIMDATA_IDS_CB(bmain->hair_curves.first); /* pointclouds */ ANIMDATA_IDS_CB(bmain->pointclouds.first); @@ -1413,8 +1413,8 @@ void BKE_animdata_fix_paths_rename_all_ex(Main *bmain, /* cache files */ RENAMEFIX_ANIM_IDS(bmain->cachefiles.first); - /* hairs */ - RENAMEFIX_ANIM_IDS(bmain->hairs.first); + /* Hair Curves. */ + RENAMEFIX_ANIM_IDS(bmain->hair_curves.first); /* pointclouds */ RENAMEFIX_ANIM_IDS(bmain->pointclouds.first); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b5ea68aaadc..c45856adbda 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -3382,8 +3382,8 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float /* cache files */ EVAL_ANIM_IDS(main->cachefiles.first, ADT_RECALC_ANIM); - /* hairs */ - EVAL_ANIM_IDS(main->hairs.first, ADT_RECALC_ANIM); + /* Hair Curves. */ + EVAL_ANIM_IDS(main->hair_curves.first, ADT_RECALC_ANIM); /* pointclouds */ EVAL_ANIM_IDS(main->pointclouds.first, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7feb9d08915..1a9f0a9130d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2679,6 +2679,35 @@ BoundBox *BKE_armature_boundbox_get(Object *ob) return ob->runtime.bb; } +void BKE_pchan_minmax(const Object *ob, const bPoseChannel *pchan, float r_min[3], float r_max[3]) +{ + const bArmature *arm = ob->data; + const bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan; + const BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ? + BKE_object_boundbox_get(pchan->custom) : + NULL; + if (bb_custom) { + float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4]; + scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan)); + rescale_m4(smat, pchan->custom_scale_xyz); + eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ); + copy_m4_m4(tmp, pchan_tx->pose_mat); + translate_m4(tmp, + pchan->custom_translation[0], + pchan->custom_translation[1], + pchan->custom_translation[2]); + mul_m4_series(mat, ob->obmat, tmp, rmat, smat); + BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); + } + else { + float vec[3]; + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); + minmax_v3v3_v3(r_min, r_max, vec); + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); + minmax_v3v3_v3(r_min, r_max, vec); + } +} + bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select) { bool changed = false; @@ -2692,31 +2721,8 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden * (editarmature.c:2592)... Skip in this case too! */ if (pchan->bone && (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) && !((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) { - bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan; - BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ? - BKE_object_boundbox_get(pchan->custom) : - NULL; - if (bb_custom) { - float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4]; - scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan)); - rescale_m4(smat, pchan->custom_scale_xyz); - eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ); - copy_m4_m4(tmp, pchan_tx->pose_mat); - translate_m4(tmp, - pchan->custom_translation[0], - pchan->custom_translation[1], - pchan->custom_translation[2]); - mul_m4_series(mat, ob->obmat, tmp, rmat, smat); - BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); - } - else { - float vec[3]; - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); - minmax_v3v3_v3(r_min, r_max, vec); - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); - minmax_v3v3_v3(r_min, r_max, vec); - } + BKE_pchan_minmax(ob, pchan, r_min, r_max); changed = true; } } diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc index a62a32d9633..de26b997e76 100644 --- a/source/blender/blenkernel/intern/armature_pose.cc +++ b/source/blender/blenkernel/intern/armature_pose.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2015 Blender Foundation. * All rights reserved. - * - * Defines and code for core node types */ /** \file diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 73a396b2cdd..f19065f039b 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2015 Blender Foundation. * All rights reserved. - * - * Defines and code for core node types */ /** \file diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 73e00398084..fdd84f3dfd4 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -15,13 +15,12 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * - * Implementation of generic geometry attributes management. This is built - * on top of CustomData, which manages individual domains. */ /** \file * \ingroup bke + * Implementation of generic geometry attributes management. This is built + * on top of CustomData, which manages individual domains. */ #include <string.h> @@ -29,8 +28,8 @@ #include "MEM_guardedalloc.h" #include "DNA_ID.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" @@ -38,9 +37,9 @@ #include "BLI_string_utf8.h" #include "BKE_attribute.h" +#include "BKE_curves.h" #include "BKE_customdata.h" #include "BKE_editmesh.h" -#include "BKE_hair.h" #include "BKE_pointcloud.h" #include "BKE_report.h" @@ -88,12 +87,12 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM]) } break; } - case ID_HA: { - Hair *hair = (Hair *)id; - info[ATTR_DOMAIN_POINT].customdata = &hair->geometry.point_data; - info[ATTR_DOMAIN_POINT].length = hair->geometry.point_size; - info[ATTR_DOMAIN_CURVE].customdata = &hair->geometry.curve_data; - info[ATTR_DOMAIN_CURVE].length = hair->geometry.curve_size; + case ID_CV: { + Curves *curves = (Curves *)id; + info[ATTR_DOMAIN_POINT].customdata = &curves->geometry.point_data; + info[ATTR_DOMAIN_POINT].length = curves->geometry.point_size; + info[ATTR_DOMAIN_CURVE].customdata = &curves->geometry.curve_data; + info[ATTR_DOMAIN_CURVE].length = curves->geometry.curve_size; break; } default: @@ -301,8 +300,8 @@ bool BKE_id_attribute_required(ID *id, CustomDataLayer *layer) case ID_PT: { return BKE_pointcloud_customdata_required((PointCloud *)id, layer); } - case ID_HA: { - return BKE_hair_customdata_required((Hair *)id, layer); + case ID_CV: { + return BKE_curves_customdata_required((Curves *)id, layer); } default: return false; @@ -372,8 +371,8 @@ int *BKE_id_attributes_active_index_p(ID *id) case ID_ME: { return &((Mesh *)id)->attributes_active_index; } - case ID_HA: { - return &((Hair *)id)->attributes_active_index; + case ID_CV: { + return &((Curves *)id)->attributes_active_index; } default: return NULL; diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 86c2593e2e6..07fd859765a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -374,6 +374,10 @@ static void setup_app_data(bContext *C, BKE_lib_override_library_main_proxy_convert(bmain, reports); } + if (mode != LOAD_UNDO && !blendfile_or_libraries_versions_atleast(bmain, 302, 3)) { + BKE_lib_override_library_main_hierarchy_root_ensure(bmain); + } + bmain->recovered = 0; /* startup.blend or recovered startup */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 275500ba2f6..d8ad4dd89e4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -15,13 +15,12 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Implementation of CDDerivedMesh. - * - * BKE_cdderivedmesh.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * Implementation of #CDDerivedMesh. + * BKE_cdderivedmesh.h contains the function prototypes for this file. */ #include "atomic_ops.h" diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index dda2b5076a8..c611e280793 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -32,6 +32,7 @@ #include "BLI_ghash.h" #include "BLI_index_range.hh" #include "BLI_math.h" +#include "BLI_math_vec_types.hh" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -59,6 +60,7 @@ #include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_spline.hh" #include "BKE_vfont.h" #include "DEG_depsgraph.h" @@ -68,6 +70,7 @@ #include "BLO_read_write.h" +using blender::float3; using blender::IndexRange; /* globals */ @@ -503,7 +506,10 @@ BoundBox *BKE_curve_boundbox_get(Object *ob) float min[3], max[3]; INIT_MINMAX(min, max); - BKE_curve_minmax(cu, true, min, max); + if (!BKE_curve_minmax(cu, true, min, max)) { + copy_v3_fl(min, -1.0f); + copy_v3_fl(max, 1.0f); + } if (ob->runtime.bb == nullptr) { ob->runtime.bb = (BoundBox *)MEM_mallocN(sizeof(*ob->runtime.bb), __func__); diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc new file mode 100644 index 00000000000..f5672e9b288 --- /dev/null +++ b/source/blender/blenkernel/intern/curves.cc @@ -0,0 +1,473 @@ +/* + * 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 bke + */ + +#include <cmath> +#include <cstring> + +#include "MEM_guardedalloc.h" + +#include "DNA_curves_types.h" +#include "DNA_defaults.h" +#include "DNA_material_types.h" +#include "DNA_object_types.h" + +#include "BLI_index_range.hh" +#include "BLI_listbase.h" +#include "BLI_math_base.h" +#include "BLI_math_vec_types.hh" +#include "BLI_rand.hh" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "BKE_anim_data.h" +#include "BKE_curves.h" +#include "BKE_customdata.h" +#include "BKE_global.h" +#include "BKE_idtype.h" +#include "BKE_lib_id.h" +#include "BKE_lib_query.h" +#include "BKE_lib_remap.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_object.h" + +#include "BLT_translation.h" + +#include "DEG_depsgraph_query.h" + +#include "BLO_read_write.h" + +using blender::float3; +using blender::IndexRange; +using blender::MutableSpan; +using blender::RandomNumberGenerator; + +static const char *ATTR_POSITION = "position"; +static const char *ATTR_RADIUS = "radius"; + +static void curves_random(Curves *curves); + +static void curves_init_data(ID *id) +{ + Curves *curves = (Curves *)id; + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(curves, id)); + + MEMCPY_STRUCT_AFTER(curves, DNA_struct_default_get(Curves), id); + + CustomData_reset(&curves->geometry.point_data); + CustomData_reset(&curves->geometry.curve_data); + + CustomData_add_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT3, + CD_CALLOC, + nullptr, + curves->geometry.point_size, + ATTR_POSITION); + CustomData_add_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT, + CD_CALLOC, + nullptr, + curves->geometry.point_size, + ATTR_RADIUS); + + BKE_curves_update_customdata_pointers(curves); + + curves_random(curves); +} + +static void curves_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) +{ + Curves *curves_dst = (Curves *)id_dst; + const Curves *curves_src = (const Curves *)id_src; + curves_dst->mat = static_cast<Material **>(MEM_dupallocN(curves_src->mat)); + + curves_dst->geometry.point_size = curves_src->geometry.point_size; + curves_dst->geometry.curve_size = curves_src->geometry.curve_size; + + const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; + CustomData_copy(&curves_src->geometry.point_data, + &curves_dst->geometry.point_data, + CD_MASK_ALL, + alloc_type, + curves_dst->geometry.point_size); + CustomData_copy(&curves_src->geometry.curve_data, + &curves_dst->geometry.curve_data, + CD_MASK_ALL, + alloc_type, + curves_dst->geometry.curve_size); + BKE_curves_update_customdata_pointers(curves_dst); + + curves_dst->geometry.offsets = static_cast<int *>(MEM_dupallocN(curves_src->geometry.offsets)); + + curves_dst->batch_cache = nullptr; +} + +static void curves_free_data(ID *id) +{ + Curves *curves = (Curves *)id; + BKE_animdata_free(&curves->id, false); + + BKE_curves_batch_cache_free(curves); + + CustomData_free(&curves->geometry.point_data, curves->geometry.point_size); + CustomData_free(&curves->geometry.curve_data, curves->geometry.curve_size); + + MEM_SAFE_FREE(curves->geometry.offsets); + + MEM_SAFE_FREE(curves->mat); +} + +static void curves_foreach_id(ID *id, LibraryForeachIDData *data) +{ + Curves *curves = (Curves *)id; + for (int i = 0; i < curves->totcol; i++) { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->mat[i], IDWALK_CB_USER); + } +} + +static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_address) +{ + Curves *curves = (Curves *)id; + + CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *clayers = nullptr, clayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomData_blend_write_prepare( + &curves->geometry.point_data, &players, players_buff, ARRAY_SIZE(players_buff)); + CustomData_blend_write_prepare( + &curves->geometry.curve_data, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff)); + + /* Write LibData */ + BLO_write_id_struct(writer, Curves, id_address, &curves->id); + BKE_id_blend_write(writer, &curves->id); + + /* Direct data */ + CustomData_blend_write(writer, + &curves->geometry.point_data, + players, + curves->geometry.point_size, + CD_MASK_ALL, + &curves->id); + CustomData_blend_write(writer, + &curves->geometry.curve_data, + clayers, + curves->geometry.curve_size, + CD_MASK_ALL, + &curves->id); + + BLO_write_int32_array(writer, curves->geometry.curve_size + 1, curves->geometry.offsets); + + BLO_write_pointer_array(writer, curves->totcol, curves->mat); + if (curves->adt) { + BKE_animdata_blend_write(writer, curves->adt); + } + + /* Remove temporary data. */ + if (players && players != players_buff) { + MEM_freeN(players); + } + if (clayers && clayers != clayers_buff) { + MEM_freeN(clayers); + } +} + +static void curves_blend_read_data(BlendDataReader *reader, ID *id) +{ + Curves *curves = (Curves *)id; + BLO_read_data_address(reader, &curves->adt); + BKE_animdata_blend_read_data(reader, curves->adt); + + /* Geometry */ + CustomData_blend_read(reader, &curves->geometry.point_data, curves->geometry.point_size); + CustomData_blend_read(reader, &curves->geometry.curve_data, curves->geometry.point_size); + BKE_curves_update_customdata_pointers(curves); + + BLO_read_int32_array(reader, curves->geometry.curve_size + 1, &curves->geometry.offsets); + + /* Materials */ + BLO_read_pointer_array(reader, (void **)&curves->mat); +} + +static void curves_blend_read_lib(BlendLibReader *reader, ID *id) +{ + Curves *curves = (Curves *)id; + for (int a = 0; a < curves->totcol; a++) { + BLO_read_id_address(reader, curves->id.lib, &curves->mat[a]); + } +} + +static void curves_blend_read_expand(BlendExpander *expander, ID *id) +{ + Curves *curves = (Curves *)id; + for (int a = 0; a < curves->totcol; a++) { + BLO_expand(expander, curves->mat[a]); + } +} + +IDTypeInfo IDType_ID_CV = { + /*id_code */ ID_CV, + /*id_filter */ FILTER_ID_CV, + /*main_listbase_index */ INDEX_ID_CV, + /*struct_size */ sizeof(Curves), + /*name */ "Hair Curves", + /*name_plural */ "Hair Curves", + /*translation_context */ BLT_I18NCONTEXT_ID_CURVES, + /*flags */ IDTYPE_FLAGS_APPEND_IS_REUSABLE, + /*asset_type_info */ nullptr, + + /*init_data */ curves_init_data, + /*copy_data */ curves_copy_data, + /*free_data */ curves_free_data, + /*make_local */ nullptr, + /*foreach_id */ curves_foreach_id, + /*foreach_cache */ nullptr, + /*foreach_path */ nullptr, + /*owner_get */ nullptr, + + /*blend_write */ curves_blend_write, + /*blend_read_data */ curves_blend_read_data, + /*blend_read_lib */ curves_blend_read_lib, + /*blend_read_expand */ curves_blend_read_expand, + + /*blend_read_undo_preserve */ nullptr, + + /*lib_override_apply_post */ nullptr, +}; + +static void curves_random(Curves *curves) +{ + CurvesGeometry &geometry = curves->geometry; + const int numpoints = 8; + + geometry.curve_size = 500; + + geometry.curve_size = 500; + geometry.point_size = geometry.curve_size * numpoints; + + curves->geometry.offsets = (int *)MEM_calloc_arrayN( + curves->geometry.curve_size + 1, sizeof(int), __func__); + CustomData_realloc(&geometry.point_data, geometry.point_size); + CustomData_realloc(&geometry.curve_data, geometry.curve_size); + BKE_curves_update_customdata_pointers(curves); + + MutableSpan<int> offsets{geometry.offsets, geometry.curve_size + 1}; + MutableSpan<float3> positions{(float3 *)geometry.position, geometry.point_size}; + MutableSpan<float> radii{geometry.radius, geometry.point_size}; + + for (const int i : offsets.index_range()) { + geometry.offsets[i] = numpoints * i; + } + + RandomNumberGenerator rng; + + for (int i = 0; i < geometry.curve_size; i++) { + const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); + MutableSpan<float3> curve_positions = positions.slice(curve_range); + MutableSpan<float> curve_radii = radii.slice(curve_range); + + const float theta = 2.0f * M_PI * rng.get_float(); + const float phi = saacosf(2.0f * rng.get_float() - 1.0f); + + float3 no = {std::sin(theta) * std::sin(phi), std::cos(theta) * std::sin(phi), std::cos(phi)}; + no = blender::math::normalize(no); + + float3 co = no; + for (int key = 0; key < numpoints; key++) { + float t = key / (float)(numpoints - 1); + curve_positions[key] = co; + curve_radii[key] = 0.02f * (1.0f - t); + + float3 offset = float3(rng.get_float(), rng.get_float(), rng.get_float()) * 2.0f - 1.0f; + co += (offset + no) / numpoints; + } + } +} + +void *BKE_curves_add(Main *bmain, const char *name) +{ + Curves *curves = static_cast<Curves *>(BKE_id_new(bmain, ID_CV, name)); + + return curves; +} + +BoundBox *BKE_curves_boundbox_get(Object *ob) +{ + BLI_assert(ob->type == OB_CURVES); + Curves *curves = static_cast<Curves *>(ob->data); + + if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { + return ob->runtime.bb; + } + + if (ob->runtime.bb == nullptr) { + ob->runtime.bb = MEM_cnew<BoundBox>(__func__); + + float min[3], max[3]; + INIT_MINMAX(min, max); + + float(*curves_co)[3] = curves->geometry.position; + float *curves_radius = curves->geometry.radius; + for (int a = 0; a < curves->geometry.point_size; a++) { + float *co = curves_co[a]; + float radius = (curves_radius) ? curves_radius[a] : 0.0f; + const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; + const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; + DO_MIN(co_min, min); + DO_MAX(co_max, max); + } + + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); + } + + return ob->runtime.bb; +} + +void BKE_curves_update_customdata_pointers(Curves *curves) +{ + curves->geometry.position = (float(*)[3])CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT3, ATTR_POSITION); + curves->geometry.radius = (float *)CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT, ATTR_RADIUS); +} + +bool BKE_curves_customdata_required(Curves *UNUSED(curves), CustomDataLayer *layer) +{ + return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, ATTR_POSITION); +} + +/* Dependency Graph */ + +Curves *BKE_curves_new_for_eval(const Curves *curves_src, int totpoint, int totcurve) +{ + Curves *curves_dst = static_cast<Curves *>(BKE_id_new_nomain(ID_CV, nullptr)); + + STRNCPY(curves_dst->id.name, curves_src->id.name); + curves_dst->mat = static_cast<Material **>(MEM_dupallocN(curves_src->mat)); + curves_dst->totcol = curves_src->totcol; + + curves_dst->geometry.point_size = totpoint; + curves_dst->geometry.curve_size = totcurve; + CustomData_copy(&curves_src->geometry.point_data, + &curves_dst->geometry.point_data, + CD_MASK_ALL, + CD_CALLOC, + totpoint); + CustomData_copy(&curves_src->geometry.curve_data, + &curves_dst->geometry.curve_data, + CD_MASK_ALL, + CD_CALLOC, + totcurve); + BKE_curves_update_customdata_pointers(curves_dst); + + return curves_dst; +} + +Curves *BKE_curves_copy_for_eval(Curves *curves_src, bool reference) +{ + int flags = LIB_ID_COPY_LOCALIZE; + + if (reference) { + flags |= LIB_ID_COPY_CD_REFERENCE; + } + + Curves *result = (Curves *)BKE_id_copy_ex(nullptr, &curves_src->id, nullptr, flags); + return result; +} + +static Curves *curves_evaluate_modifiers(struct Depsgraph *depsgraph, + struct Scene *scene, + Object *object, + Curves *curves_input) +{ + Curves *curves = curves_input; + + /* Modifier evaluation modes. */ + const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; + ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; + const ModifierEvalContext mectx = {depsgraph, object, apply_flag}; + + /* Get effective list of modifiers to execute. Some effects like shape keys + * are added as virtual modifiers before the user created modifiers. */ + VirtualModifierData virtualModifierData; + ModifierData *md = BKE_modifiers_get_virtual_modifierlist(object, &virtualModifierData); + + /* Evaluate modifiers. */ + for (; md; md = md->next) { + const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); + + if (!BKE_modifier_is_enabled(scene, md, required_mode)) { + continue; + } + + if ((mti->type == eModifierTypeType_OnlyDeform) && + (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly)) { + /* Ensure we are not modifying the input. */ + if (curves == curves_input) { + curves = BKE_curves_copy_for_eval(curves, true); + } + + /* Ensure we are not overwriting referenced data. */ + CustomData_duplicate_referenced_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT3, + ATTR_POSITION, + curves->geometry.point_size); + BKE_curves_update_customdata_pointers(curves); + + /* Created deformed coordinates array on demand. */ + mti->deformVerts( + md, &mectx, nullptr, curves->geometry.position, curves->geometry.point_size); + } + } + + return curves; +} + +void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) +{ + /* Free any evaluated data and restore original data. */ + BKE_object_free_derived_caches(object); + + /* Evaluate modifiers. */ + Curves *curves = static_cast<Curves *>(object->data); + Curves *curves_eval = curves_evaluate_modifiers(depsgraph, scene, object, curves); + + /* Assign evaluated object. */ + const bool is_owned = (curves != curves_eval); + BKE_object_eval_assign_data(object, &curves_eval->id, is_owned); +} + +/* Draw Cache */ + +void (*BKE_curves_batch_cache_dirty_tag_cb)(Curves *curves, int mode) = nullptr; +void (*BKE_curves_batch_cache_free_cb)(Curves *curves) = nullptr; + +void BKE_curves_batch_cache_dirty_tag(Curves *curves, int mode) +{ + if (curves->batch_cache) { + BKE_curves_batch_cache_dirty_tag_cb(curves, mode); + } +} + +void BKE_curves_batch_cache_free(Curves *curves) +{ + if (curves->batch_cache) { + BKE_curves_batch_cache_free_cb(curves); + } +} diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 36d511422aa..6db5ae7567f 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Implementation of CustomData. - * - * BKE_customdata.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * Implementation of CustomData. + * + * BKE_customdata.h contains the function prototypes for this file. */ #include "MEM_guardedalloc.h" @@ -31,7 +31,6 @@ #include "DNA_ID.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_meshdata_types.h" #include "BLI_bitmap.h" diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index ceb1195e817..c4e0b924ffa 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1076,6 +1076,32 @@ void BKE_gpencil_stroke_copy_settings(const bGPDstroke *gps_src, bGPDstroke *gps copy_v4_v4(gps_dst->vert_color_fill, gps_src->vert_color_fill); } +bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy) +{ + gpf_dst->flag = gpf_src->flag; + gpf_dst->key_type = gpf_src->key_type; + gpf_dst->framenum = gpf_src->framenum; +} + +void BKE_gpencil_stroke_copy_settings(const bGPDstroke *gps_src, bGPDstroke *gps_dst) +{ + gps_dst->thickness = gps_src->thickness; + gps_dst->flag = gps_src->flag; + gps_dst->inittime = gps_src->inittime; + gps_dst->mat_nr = gps_src->mat_nr; + copy_v2_v2_short(gps_dst->caps, gps_src->caps); + gps_dst->hardeness = gps_src->hardeness; + copy_v2_v2(gps_dst->aspect_ratio, gps_src->aspect_ratio); + gps_dst->fill_opacity_fac = gps_dst->fill_opacity_fac; + copy_v3_v3(gps_dst->boundbox_min, gps_src->boundbox_min); + copy_v3_v3(gps_dst->boundbox_max, gps_src->boundbox_max); + gps_dst->uv_rotation = gps_src->uv_rotation; + copy_v2_v2(gps_dst->uv_translation, gps_src->uv_translation); + gps_dst->uv_scale = gps_src->uv_scale; + gps_dst->select_index = gps_src->select_index; + copy_v4_v4(gps_dst->vert_color_fill, gps_src->vert_color_fill); +} + void BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bGPdata **gpd_dst) { /* error checking */ @@ -2834,12 +2860,8 @@ void BKE_gpencil_frame_selected_hash(bGPdata *gpd, struct GHash *r_list) } } -bool BKE_gpencil_update_on_write_check(const Depsgraph *depsgraph, bGPdata *gpd) +bool BKE_gpencil_can_avoid_full_copy_on_write(const Depsgraph *depsgraph, bGPdata *gpd) { - if (!U.experimental.use_gpencil_update_cache) { - return false; - } - /* For now, we only use the update cache in the active depsgraph. Othwerwise we might access the * cache while another depsgraph frees it. */ if (!DEG_is_active(depsgraph)) { @@ -3007,20 +3029,11 @@ void BKE_gpencil_update_on_write(bGPdata *gpd_orig, bGPdata *gpd_eval) }; BKE_gpencil_traverse_update_cache(update_cache, &ts, &data); + gpd_eval->flag |= GP_DATA_CACHE_IS_DIRTY; - const bool gpencil_undo_system_inactive = !(U.experimental.use_gpencil_undo_system && - GPENCIL_ANY_MODE(gpd_orig)); - /* If the gpencil undo system is active, make sure to only free the cache if - * GP_DATA_UPDATE_CACHE_DISPOSABLE is set. Even though we already used the cache to update the - * eval object, it might still be needed for the undo system (e.g if a modal operator is running, - * it might call the update-on-write multiple times before an undo step is encoded). Only when - * the undo system marks the cache as disposable can we safely free it here.*/ - if (gpencil_undo_system_inactive || (gpd_orig->flag & GP_DATA_UPDATE_CACHE_DISPOSABLE)) { - /* TODO: This might cause issues when we have multiple depsgraphs? Because the cache might be - * accessed later/concurrently even if it was freed here? */ - BKE_gpencil_free_update_cache(gpd_orig); - } + /* TODO: This might cause issues when we have multiple depsgraphs? */ + BKE_gpencil_free_update_cache(gpd_orig); } /** \} */ diff --git a/source/blender/blenkernel/intern/gpencil_update_cache.c b/source/blender/blenkernel/intern/gpencil_update_cache.c index 2e42ae40f32..323c3a9f2a2 100644 --- a/source/blender/blenkernel/intern/gpencil_update_cache.c +++ b/source/blender/blenkernel/intern/gpencil_update_cache.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008, Blender Foundation + * The Original Code is Copyright (C) 2022, Blender Foundation * This is a new part of Blender */ @@ -88,40 +88,22 @@ static void cache_node_update(void *node, void *data) GPencilUpdateCache *update_cache = ((GPencilUpdateCacheNode *)node)->cache; GPencilUpdateCache *new_update_cache = (GPencilUpdateCache *)data; - /* IMPORTANT: Because we are comparing the values of the flags here, make sure that any potential - * new flag either respects this ordering or changes the following logic. */ - const bool current_cache_covers_new_cache = new_update_cache->flag < update_cache->flag; - - /* In case: - * - the new cache is a no copy - * - or the new cache is a light copy and the current cache a full copy - * then it means we are already caching "more" and we shouldn't update the current cache. - * So we free the structure and return early. - */ - if (current_cache_covers_new_cache) { + /* If the new cache is already "covered" by the current cache, just free it and return. */ + if (new_update_cache->flag <= update_cache->flag) { update_cache_free(new_update_cache); return; } - /* In case: - * - the cache types are equal - * - or the new cache contains more than the current cache (full copy > light copy > no copy) - * the data pointer is updated. If the cache types are equal, this might be a no-op (when the new - * data pointer is equal to the previous), but is necessary when the data pointer needs to - * change. This can for example happen when the underlying data was reallocated, but the cache - * type stayed the same. - */ update_cache->data = new_update_cache->data; update_cache->flag = new_update_cache->flag; /* In case the new cache does a full update, remove its children since they will be all - * updated by the new cache. */ + * updated by this cache. */ if (new_update_cache->flag == GP_UPDATE_NODE_FULL_COPY && update_cache->children != NULL) { - /* We don't free the tree itself here, because we just want to clear the children, not delete - * the whole node. */ BLI_dlrbTree_free(update_cache->children, cache_node_free); + MEM_freeN(update_cache->children); } - /* Once we updated the data pointer and the flag, we can safely free the new cache structure. */ + update_cache_free(new_update_cache); } @@ -185,11 +167,8 @@ static void update_cache_node_create_ex(GPencilUpdateCache *root_cache, } GPencilUpdateCache *gps_cache = update_cache_alloc(gps_index, node_flag, (bGPDstroke *)data); - BLI_dlrbTree_add(gpf_node->cache->children, - cache_node_compare, - cache_node_alloc, - cache_node_update, - gps_cache); + BLI_dlrbTree_add( + gpf_node->cache->children, cache_node_compare, cache_node_alloc, cache_node_update, gps_cache); BLI_dlrbTree_linkedlist_sync(gpf_node->cache->children); } @@ -255,143 +234,6 @@ static void gpencil_traverse_update_cache_ex(GPencilUpdateCache *parent_cache, } } -typedef struct GPencilUpdateCacheDuplicateTraverseData { - GPencilUpdateCache *new_cache; - int gpl_index; - int gpf_index; -} GPencilUpdateCacheDuplicateTraverseData; - -static bool gpencil_duplicate_update_cache_layer_cb(GPencilUpdateCache *cache, void *user_data) -{ - GPencilUpdateCacheDuplicateTraverseData *td = (GPencilUpdateCacheDuplicateTraverseData *) - user_data; - - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - /* Do a full copy of the layer. */ - bGPDlayer *gpl = (bGPDlayer *)cache->data; - bGPDlayer *gpl_new = BKE_gpencil_layer_duplicate(gpl, true, true); - update_cache_node_create_ex(td->new_cache, gpl_new, cache->index, -1, -1, true); - return true; - } - else if (cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { - bGPDlayer *gpl = (bGPDlayer *)cache->data; - bGPDlayer *gpl_new = (bGPDlayer *)MEM_dupallocN(gpl); - - gpl_new->prev = gpl_new->next = NULL; - BLI_listbase_clear(&gpl_new->frames); - BLI_listbase_clear(&gpl_new->mask_layers); - update_cache_node_create_ex(td->new_cache, gpl_new, cache->index, -1, -1, false); - } - td->gpl_index = cache->index; - return false; -} - -static bool gpencil_duplicate_update_cache_frame_cb(GPencilUpdateCache *cache, void *user_data) -{ - GPencilUpdateCacheDuplicateTraverseData *td = (GPencilUpdateCacheDuplicateTraverseData *) - user_data; - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - bGPDframe *gpf = (bGPDframe *)cache->data; - bGPDframe *gpf_new = BKE_gpencil_frame_duplicate(gpf, true); - update_cache_node_create_ex(td->new_cache, gpf_new, td->gpl_index, cache->index, -1, true); - return true; - } - else if (cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { - bGPDframe *gpf = (bGPDframe *)cache->data; - bGPDframe *gpf_new = MEM_dupallocN(gpf); - gpf_new->prev = gpf_new->next = NULL; - BLI_listbase_clear(&gpf_new->strokes); - update_cache_node_create_ex(td->new_cache, gpf_new, td->gpl_index, cache->index, -1, false); - } - td->gpf_index = cache->index; - return false; -} - -static bool gpencil_duplicate_update_cache_stroke_cb(GPencilUpdateCache *cache, void *user_data) -{ - GPencilUpdateCacheDuplicateTraverseData *td = (GPencilUpdateCacheDuplicateTraverseData *) - user_data; - - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - bGPDstroke *gps = (bGPDstroke *)cache->data; - bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, true, true); - update_cache_node_create_ex( - td->new_cache, gps_new, td->gpl_index, td->gpf_index, cache->index, true); - } - else if (cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { - bGPDstroke *gps = (bGPDstroke *)cache->data; - bGPDstroke *gps_new = MEM_dupallocN(gps); - - gps_new->prev = gps_new->next = NULL; - gps_new->points = NULL; - gps_new->triangles = NULL; - gps_new->dvert = NULL; - gps_new->editcurve = NULL; - - update_cache_node_create_ex( - td->new_cache, gps_new, td->gpl_index, td->gpf_index, cache->index, false); - } - return true; -} - -static bool gpencil_free_update_cache_layer_cb(GPencilUpdateCache *cache, void *UNUSED(user_data)) -{ - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - BKE_gpencil_free_frames(cache->data); - BKE_gpencil_free_layer_masks(cache->data); - } - if (cache->data) { - MEM_freeN(cache->data); - } - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - -static bool gpencil_free_update_cache_frame_cb(GPencilUpdateCache *cache, void *UNUSED(user_data)) -{ - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - BKE_gpencil_free_strokes(cache->data); - } - if (cache->data) { - MEM_freeN(cache->data); - } - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - -static bool gpencil_free_update_cache_stroke_cb(GPencilUpdateCache *cache, void *UNUSED(user_data)) -{ - if (cache->flag == GP_UPDATE_NODE_FULL_COPY) { - BKE_gpencil_free_stroke(cache->data); - } - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - -static bool gpencil_print_update_cache_layer_cb(GPencilUpdateCache *cache, void *UNUSED(user_data)) -{ - printf(" - Layer: %s | Index: %d | Flag: %d | Tagged Frames: %d\n", - (cache->data ? ((bGPDlayer *)cache->data)->info : "N/A"), - cache->index, - cache->flag, - BLI_listbase_count((ListBase *)cache->children)); - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - -static bool gpencil_print_update_cache_frame_cb(GPencilUpdateCache *cache, void *UNUSED(user_data)) -{ - printf(" - Frame: %d | Index: %d | Flag: %d | Tagged Strokes: %d\n", - (cache->data ? ((bGPDframe *)cache->data)->framenum : -1), - cache->index, - cache->flag, - BLI_listbase_count((ListBase *)cache->children)); - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - -static bool gpencil_print_update_cache_stroke_cb(GPencilUpdateCache *cache, - void *UNUSED(user_data)) -{ - printf(" - Stroke Index: %d | | Flag: %d\n", cache->index, cache->flag); - return cache->flag == GP_UPDATE_NODE_FULL_COPY; -} - /* -------------------------------------------------------------------- */ /** \name Update Cache API * @@ -412,80 +254,12 @@ void BKE_gpencil_traverse_update_cache(GPencilUpdateCache *cache, void BKE_gpencil_tag_full_update(bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps) { - if (U.experimental.use_gpencil_update_cache) { - update_cache_node_create(gpd, gpl, gpf, gps, true); - } + update_cache_node_create(gpd, gpl, gpf, gps, true); } void BKE_gpencil_tag_light_update(bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps) { - if (U.experimental.use_gpencil_update_cache) { - update_cache_node_create(gpd, gpl, gpf, gps, false); - } -} - -GPencilUpdateCache *BKE_gpencil_duplicate_update_cache_and_data(GPencilUpdateCache *gpd_cache) -{ - GPencilUpdateCache *new_cache = update_cache_alloc(0, gpd_cache->flag, NULL); - bGPdata *gpd_new = NULL; - if (gpd_cache->flag == GP_UPDATE_NODE_FULL_COPY) { - BKE_gpencil_data_duplicate(NULL, gpd_cache->data, &gpd_new); - new_cache->data = gpd_new; - return new_cache; - } - else if (gpd_cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { - gpd_new = MEM_dupallocN(gpd_cache->data); - - /* Clear all the pointers, since they shouldn't store anything. */ - BLI_listbase_clear(&gpd_new->layers); - BLI_listbase_clear(&gpd_new->vertex_group_names); - gpd_new->adt = NULL; - gpd_new->mat = NULL; - gpd_new->runtime.update_cache = NULL; - - new_cache->data = gpd_new; - } - - GPencilUpdateCacheTraverseSettings ts = {{gpencil_duplicate_update_cache_layer_cb, - gpencil_duplicate_update_cache_frame_cb, - gpencil_duplicate_update_cache_stroke_cb}}; - - GPencilUpdateCacheDuplicateTraverseData td = { - .new_cache = new_cache, - .gpl_index = -1, - .gpf_index = -1, - }; - - BKE_gpencil_traverse_update_cache(gpd_cache, &ts, &td); - return new_cache; -} - -/** - * Return true if any of the branches in gpd_cache_b are "strictly greater than" the branches in - * gpd_cache_a, e.g. one of them contains more data than their counterpart. - */ -bool BKE_gpencil_compare_update_caches(GPencilUpdateCache *gpd_cache_a, - GPencilUpdateCache *gpd_cache_b) -{ - if (gpd_cache_b->flag == GP_UPDATE_NODE_FULL_COPY) { - return gpd_cache_a->flag != GP_UPDATE_NODE_FULL_COPY; - } - if (gpd_cache_a->flag == GP_UPDATE_NODE_FULL_COPY) { - return false; - } - - LISTBASE_FOREACH (GPencilUpdateCacheNode *, node_b, gpd_cache_b->children) { - GPencilUpdateCacheNode *node_a = (GPencilUpdateCacheNode *)BLI_dlrbTree_search_exact( - gpd_cache_a->children, cache_node_compare, node_b->cache); - if (node_a == NULL) { - return true; - } - - if (BKE_gpencil_compare_update_caches(node_a->cache, node_b->cache)) { - return true; - } - } - return false; + update_cache_node_create(gpd, gpl, gpf, gps, false); } void BKE_gpencil_free_update_cache(bGPdata *gpd) @@ -495,43 +269,6 @@ void BKE_gpencil_free_update_cache(bGPdata *gpd) update_cache_free(gpd_cache); gpd->runtime.update_cache = NULL; } - gpd->flag &= ~GP_DATA_UPDATE_CACHE_DISPOSABLE; -} - -void BKE_gpencil_free_update_cache_and_data(GPencilUpdateCache *gpd_cache) -{ - if (gpd_cache->data != NULL) { - if (gpd_cache->flag == GP_UPDATE_NODE_FULL_COPY) { - BKE_gpencil_free_data(gpd_cache->data, true); - MEM_freeN(gpd_cache->data); - update_cache_free(gpd_cache); - return; - } - MEM_freeN(gpd_cache->data); - } - - GPencilUpdateCacheTraverseSettings ts = {{gpencil_free_update_cache_layer_cb, - gpencil_free_update_cache_frame_cb, - gpencil_free_update_cache_stroke_cb}}; - - BKE_gpencil_traverse_update_cache(gpd_cache, &ts, NULL); - update_cache_free(gpd_cache); -} - -void BKE_gpencil_print_update_cache(GPencilUpdateCache *update_cache) -{ - if (update_cache == NULL) { - printf("No update cache\n"); - return; - } - printf("Update cache: - Flag: %d | Tagged Layers: %d\n", - update_cache->flag, - BLI_listbase_count((ListBase *)update_cache->children)); - - GPencilUpdateCacheTraverseSettings ts = {{gpencil_print_update_cache_layer_cb, - gpencil_print_update_cache_frame_cb, - gpencil_print_update_cache_stroke_cb}}; - BKE_gpencil_traverse_update_cache(update_cache, &ts, NULL); } /** \} */ diff --git a/source/blender/blenkernel/intern/hair.cc b/source/blender/blenkernel/intern/hair.cc deleted file mode 100644 index bddadc3bcfd..00000000000 --- a/source/blender/blenkernel/intern/hair.cc +++ /dev/null @@ -1,474 +0,0 @@ -/* - * 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 bke - */ - -#include <cmath> -#include <cstring> - -#include "MEM_guardedalloc.h" - -#include "DNA_defaults.h" -#include "DNA_hair_types.h" -#include "DNA_material_types.h" -#include "DNA_object_types.h" - -#include "BLI_index_range.hh" -#include "BLI_listbase.h" -#include "BLI_math_base.h" -#include "BLI_math_vec_types.hh" -#include "BLI_rand.hh" -#include "BLI_string.h" -#include "BLI_utildefines.h" - -#include "BKE_anim_data.h" -#include "BKE_customdata.h" -#include "BKE_global.h" -#include "BKE_hair.h" -#include "BKE_idtype.h" -#include "BKE_lib_id.h" -#include "BKE_lib_query.h" -#include "BKE_lib_remap.h" -#include "BKE_main.h" -#include "BKE_modifier.h" -#include "BKE_object.h" - -#include "BLT_translation.h" - -#include "DEG_depsgraph_query.h" - -#include "BLO_read_write.h" - -using blender::float3; -using blender::IndexRange; -using blender::MutableSpan; -using blender::RandomNumberGenerator; - -static const char *HAIR_ATTR_POSITION = "position"; -static const char *HAIR_ATTR_RADIUS = "radius"; - -/* Hair datablock */ - -static void hair_random(Hair *hair); - -static void hair_init_data(ID *id) -{ - Hair *hair = (Hair *)id; - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(hair, id)); - - MEMCPY_STRUCT_AFTER(hair, DNA_struct_default_get(Hair), id); - - CustomData_reset(&hair->geometry.point_data); - CustomData_reset(&hair->geometry.curve_data); - - CustomData_add_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT3, - CD_CALLOC, - nullptr, - hair->geometry.point_size, - HAIR_ATTR_POSITION); - CustomData_add_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT, - CD_CALLOC, - nullptr, - hair->geometry.point_size, - HAIR_ATTR_RADIUS); - - BKE_hair_update_customdata_pointers(hair); - - hair_random(hair); -} - -static void hair_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) -{ - Hair *hair_dst = (Hair *)id_dst; - const Hair *hair_src = (const Hair *)id_src; - hair_dst->mat = static_cast<Material **>(MEM_dupallocN(hair_src->mat)); - - hair_dst->geometry.point_size = hair_src->geometry.point_size; - hair_dst->geometry.curve_size = hair_src->geometry.curve_size; - - const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; - CustomData_copy(&hair_src->geometry.point_data, - &hair_dst->geometry.point_data, - CD_MASK_ALL, - alloc_type, - hair_dst->geometry.point_size); - CustomData_copy(&hair_src->geometry.curve_data, - &hair_dst->geometry.curve_data, - CD_MASK_ALL, - alloc_type, - hair_dst->geometry.curve_size); - BKE_hair_update_customdata_pointers(hair_dst); - - hair_dst->geometry.offsets = static_cast<int *>(MEM_dupallocN(hair_src->geometry.offsets)); - - hair_dst->batch_cache = nullptr; -} - -static void hair_free_data(ID *id) -{ - Hair *hair = (Hair *)id; - BKE_animdata_free(&hair->id, false); - - BKE_hair_batch_cache_free(hair); - - CustomData_free(&hair->geometry.point_data, hair->geometry.point_size); - CustomData_free(&hair->geometry.curve_data, hair->geometry.curve_size); - - MEM_SAFE_FREE(hair->geometry.offsets); - - MEM_SAFE_FREE(hair->mat); -} - -static void hair_foreach_id(ID *id, LibraryForeachIDData *data) -{ - Hair *hair = (Hair *)id; - for (int i = 0; i < hair->totcol; i++) { - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, hair->mat[i], IDWALK_CB_USER); - } -} - -static void hair_blend_write(BlendWriter *writer, ID *id, const void *id_address) -{ - Hair *hair = (Hair *)id; - - CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *clayers = nullptr, clayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomData_blend_write_prepare( - &hair->geometry.point_data, &players, players_buff, ARRAY_SIZE(players_buff)); - CustomData_blend_write_prepare( - &hair->geometry.curve_data, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff)); - - /* Write LibData */ - BLO_write_id_struct(writer, Hair, id_address, &hair->id); - BKE_id_blend_write(writer, &hair->id); - - /* Direct data */ - CustomData_blend_write(writer, - &hair->geometry.point_data, - players, - hair->geometry.point_size, - CD_MASK_ALL, - &hair->id); - CustomData_blend_write(writer, - &hair->geometry.curve_data, - clayers, - hair->geometry.curve_size, - CD_MASK_ALL, - &hair->id); - - BLO_write_int32_array(writer, hair->geometry.curve_size + 1, hair->geometry.offsets); - - BLO_write_pointer_array(writer, hair->totcol, hair->mat); - if (hair->adt) { - BKE_animdata_blend_write(writer, hair->adt); - } - - /* Remove temporary data. */ - if (players && players != players_buff) { - MEM_freeN(players); - } - if (clayers && clayers != clayers_buff) { - MEM_freeN(clayers); - } -} - -static void hair_blend_read_data(BlendDataReader *reader, ID *id) -{ - Hair *hair = (Hair *)id; - BLO_read_data_address(reader, &hair->adt); - BKE_animdata_blend_read_data(reader, hair->adt); - - /* Geometry */ - CustomData_blend_read(reader, &hair->geometry.point_data, hair->geometry.point_size); - CustomData_blend_read(reader, &hair->geometry.curve_data, hair->geometry.point_size); - BKE_hair_update_customdata_pointers(hair); - - BLO_read_int32_array(reader, hair->geometry.curve_size + 1, &hair->geometry.offsets); - - /* Materials */ - BLO_read_pointer_array(reader, (void **)&hair->mat); -} - -static void hair_blend_read_lib(BlendLibReader *reader, ID *id) -{ - Hair *hair = (Hair *)id; - for (int a = 0; a < hair->totcol; a++) { - BLO_read_id_address(reader, hair->id.lib, &hair->mat[a]); - } -} - -static void hair_blend_read_expand(BlendExpander *expander, ID *id) -{ - Hair *hair = (Hair *)id; - for (int a = 0; a < hair->totcol; a++) { - BLO_expand(expander, hair->mat[a]); - } -} - -IDTypeInfo IDType_ID_HA = { - /*id_code */ ID_HA, - /*id_filter */ FILTER_ID_HA, - /*main_listbase_index */ INDEX_ID_HA, - /*struct_size */ sizeof(Hair), - /*name */ "Hair", - /*name_plural */ "hairs", - /*translation_context */ BLT_I18NCONTEXT_ID_HAIR, - /*flags */ IDTYPE_FLAGS_APPEND_IS_REUSABLE, - /*asset_type_info */ nullptr, - - /*init_data */ hair_init_data, - /*copy_data */ hair_copy_data, - /*free_data */ hair_free_data, - /*make_local */ nullptr, - /*foreach_id */ hair_foreach_id, - /*foreach_cache */ nullptr, - /*foreach_path */ nullptr, - /*owner_get */ nullptr, - - /*blend_write */ hair_blend_write, - /*blend_read_data */ hair_blend_read_data, - /*blend_read_lib */ hair_blend_read_lib, - /*blend_read_expand */ hair_blend_read_expand, - - /*blend_read_undo_preserve */ nullptr, - - /*lib_override_apply_post */ nullptr, -}; - -static void hair_random(Hair *hair) -{ - CurvesGeometry &geometry = hair->geometry; - const int numpoints = 8; - - geometry.curve_size = 500; - - geometry.curve_size = 500; - geometry.point_size = geometry.curve_size * numpoints; - - hair->geometry.offsets = (int *)MEM_calloc_arrayN( - hair->geometry.curve_size + 1, sizeof(int), __func__); - CustomData_realloc(&geometry.point_data, geometry.point_size); - CustomData_realloc(&geometry.curve_data, geometry.curve_size); - BKE_hair_update_customdata_pointers(hair); - - MutableSpan<int> offsets{geometry.offsets, geometry.curve_size + 1}; - MutableSpan<float3> positions{(float3 *)geometry.position, geometry.point_size}; - MutableSpan<float> radii{geometry.radius, geometry.point_size}; - - for (const int i : offsets.index_range()) { - geometry.offsets[i] = numpoints * i; - } - - RandomNumberGenerator rng; - - for (int i = 0; i < geometry.curve_size; i++) { - const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); - MutableSpan<float3> curve_positions = positions.slice(curve_range); - MutableSpan<float> curve_radii = radii.slice(curve_range); - - const float theta = 2.0f * M_PI * rng.get_float(); - const float phi = saacosf(2.0f * rng.get_float() - 1.0f); - - float3 no = {std::sin(theta) * std::sin(phi), std::cos(theta) * std::sin(phi), std::cos(phi)}; - no = blender::math::normalize(no); - - float3 co = no; - for (int key = 0; key < numpoints; key++) { - float t = key / (float)(numpoints - 1); - curve_positions[key] = co; - curve_radii[key] = 0.02f * (1.0f - t); - - float3 offset = float3(rng.get_float(), rng.get_float(), rng.get_float()) * 2.0f - 1.0f; - co += (offset + no) / numpoints; - } - } -} - -void *BKE_hair_add(Main *bmain, const char *name) -{ - Hair *hair = static_cast<Hair *>(BKE_id_new(bmain, ID_HA, name)); - - return hair; -} - -BoundBox *BKE_hair_boundbox_get(Object *ob) -{ - BLI_assert(ob->type == OB_HAIR); - Hair *hair = static_cast<Hair *>(ob->data); - - if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { - return ob->runtime.bb; - } - - if (ob->runtime.bb == nullptr) { - ob->runtime.bb = MEM_cnew<BoundBox>(__func__); - - float min[3], max[3]; - INIT_MINMAX(min, max); - - float(*hair_co)[3] = hair->geometry.position; - float *hair_radius = hair->geometry.radius; - for (int a = 0; a < hair->geometry.point_size; a++) { - float *co = hair_co[a]; - float radius = (hair_radius) ? hair_radius[a] : 0.0f; - const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; - const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; - DO_MIN(co_min, min); - DO_MAX(co_max, max); - } - - BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); - } - - return ob->runtime.bb; -} - -void BKE_hair_update_customdata_pointers(Hair *hair) -{ - hair->geometry.position = (float(*)[3])CustomData_get_layer_named( - &hair->geometry.point_data, CD_PROP_FLOAT3, HAIR_ATTR_POSITION); - hair->geometry.radius = (float *)CustomData_get_layer_named( - &hair->geometry.point_data, CD_PROP_FLOAT, HAIR_ATTR_RADIUS); -} - -bool BKE_hair_customdata_required(Hair *UNUSED(hair), CustomDataLayer *layer) -{ - return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, HAIR_ATTR_POSITION); -} - -/* Dependency Graph */ - -Hair *BKE_hair_new_for_eval(const Hair *hair_src, int totpoint, int totcurve) -{ - Hair *hair_dst = static_cast<Hair *>(BKE_id_new_nomain(ID_HA, nullptr)); - - STRNCPY(hair_dst->id.name, hair_src->id.name); - hair_dst->mat = static_cast<Material **>(MEM_dupallocN(hair_src->mat)); - hair_dst->totcol = hair_src->totcol; - - hair_dst->geometry.point_size = totpoint; - hair_dst->geometry.curve_size = totcurve; - CustomData_copy(&hair_src->geometry.point_data, - &hair_dst->geometry.point_data, - CD_MASK_ALL, - CD_CALLOC, - totpoint); - CustomData_copy(&hair_src->geometry.curve_data, - &hair_dst->geometry.curve_data, - CD_MASK_ALL, - CD_CALLOC, - totcurve); - BKE_hair_update_customdata_pointers(hair_dst); - - return hair_dst; -} - -Hair *BKE_hair_copy_for_eval(Hair *hair_src, bool reference) -{ - int flags = LIB_ID_COPY_LOCALIZE; - - if (reference) { - flags |= LIB_ID_COPY_CD_REFERENCE; - } - - Hair *result = (Hair *)BKE_id_copy_ex(nullptr, &hair_src->id, nullptr, flags); - return result; -} - -static Hair *hair_evaluate_modifiers(struct Depsgraph *depsgraph, - struct Scene *scene, - Object *object, - Hair *hair_input) -{ - Hair *hair = hair_input; - - /* Modifier evaluation modes. */ - const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); - const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; - ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; - const ModifierEvalContext mectx = {depsgraph, object, apply_flag}; - - /* Get effective list of modifiers to execute. Some effects like shape keys - * are added as virtual modifiers before the user created modifiers. */ - VirtualModifierData virtualModifierData; - ModifierData *md = BKE_modifiers_get_virtual_modifierlist(object, &virtualModifierData); - - /* Evaluate modifiers. */ - for (; md; md = md->next) { - const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); - - if (!BKE_modifier_is_enabled(scene, md, required_mode)) { - continue; - } - - if ((mti->type == eModifierTypeType_OnlyDeform) && - (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly)) { - /* Ensure we are not modifying the input. */ - if (hair == hair_input) { - hair = BKE_hair_copy_for_eval(hair, true); - } - - /* Ensure we are not overwriting referenced data. */ - CustomData_duplicate_referenced_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT3, - HAIR_ATTR_POSITION, - hair->geometry.point_size); - BKE_hair_update_customdata_pointers(hair); - - /* Created deformed coordinates array on demand. */ - mti->deformVerts(md, &mectx, nullptr, hair->geometry.position, hair->geometry.point_size); - } - } - - return hair; -} - -void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) -{ - /* Free any evaluated data and restore original data. */ - BKE_object_free_derived_caches(object); - - /* Evaluate modifiers. */ - Hair *hair = static_cast<Hair *>(object->data); - Hair *hair_eval = hair_evaluate_modifiers(depsgraph, scene, object, hair); - - /* Assign evaluated object. */ - const bool is_owned = (hair != hair_eval); - BKE_object_eval_assign_data(object, &hair_eval->id, is_owned); -} - -/* Draw Cache */ - -void (*BKE_hair_batch_cache_dirty_tag_cb)(Hair *hair, int mode) = nullptr; -void (*BKE_hair_batch_cache_free_cb)(Hair *hair) = nullptr; - -void BKE_hair_batch_cache_dirty_tag(Hair *hair, int mode) -{ - if (hair->batch_cache) { - BKE_hair_batch_cache_dirty_tag_cb(hair, mode); - } -} - -void BKE_hair_batch_cache_free(Hair *hair) -{ - if (hair->batch_cache) { - BKE_hair_batch_cache_free_cb(hair); - } -} diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index e6fd6c14d42..98bbd920615 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -15,9 +15,6 @@ * * The Original Code is Copyright (C) 2005 by the Blender Foundation. * All rights reserved. - * Modifier stack implementation. - * - * BKE_modifier.h contains the function prototypes for this file. */ /** \file @@ -110,7 +107,7 @@ static void id_type_init(void) INIT_TYPE(ID_CF); INIT_TYPE(ID_WS); INIT_TYPE(ID_LP); - INIT_TYPE(ID_HA); + INIT_TYPE(ID_CV); INIT_TYPE(ID_PT); INIT_TYPE(ID_VO); INIT_TYPE(ID_SIM); @@ -237,7 +234,7 @@ uint64_t BKE_idtype_idcode_to_idfilter(const short idcode) CASE_IDFILTER(CU); CASE_IDFILTER(GD); CASE_IDFILTER(GR); - CASE_IDFILTER(HA); + CASE_IDFILTER(CV); CASE_IDFILTER(IM); CASE_IDFILTER(LA); CASE_IDFILTER(LS); @@ -286,7 +283,7 @@ short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter) CASE_IDFILTER(CU); CASE_IDFILTER(GD); CASE_IDFILTER(GR); - CASE_IDFILTER(HA); + CASE_IDFILTER(CV); CASE_IDFILTER(IM); CASE_IDFILTER(LA); CASE_IDFILTER(LS); @@ -334,7 +331,7 @@ int BKE_idtype_idcode_to_index(const short idcode) CASE_IDINDEX(CU); CASE_IDINDEX(GD); CASE_IDINDEX(GR); - CASE_IDINDEX(HA); + CASE_IDINDEX(CV); CASE_IDINDEX(IM); CASE_IDINDEX(IP); CASE_IDINDEX(KE); @@ -393,7 +390,7 @@ short BKE_idtype_idcode_from_index(const int index) CASE_IDCODE(CU); CASE_IDCODE(GD); CASE_IDCODE(GR); - CASE_IDCODE(HA); + CASE_IDCODE(CV); CASE_IDCODE(IM); CASE_IDCODE(IP); CASE_IDCODE(KE); diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 314351e4ad7..961f63b1f82 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -161,6 +161,8 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f (ID *)src_id; id_us_plus(dst_id->override_library->reference); + dst_id->override_library->hierarchy_root = src_id->override_library->hierarchy_root; + if (do_full_copy) { BLI_duplicatelist(&dst_id->override_library->properties, &src_id->override_library->properties); @@ -293,6 +295,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, * mess in case there are a lot of hidden, non-instantiated, non-properly organized dependencies. * Ref T94650. */ local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY; + local_id->override_library->hierarchy_root = local_id; if (do_tagged_remap) { Key *reference_key, *local_key = NULL; @@ -328,9 +331,18 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, bool BKE_lib_override_library_create_from_tag(Main *bmain, Library *owner_library, - const Library *reference_library, + const ID *id_root_reference, + ID *id_hierarchy_root, const bool do_no_main) { + BLI_assert(id_root_reference != NULL); + BLI_assert(id_hierarchy_root != NULL || (id_root_reference->tag & LIB_TAG_DOIT) != 0); + BLI_assert(id_hierarchy_root == NULL || + (ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root) && + id_hierarchy_root->override_library->reference == id_root_reference)); + + const Library *reference_library = id_root_reference->lib; + ID *reference_id; bool success = true; @@ -383,6 +395,11 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, /* Only remap new local ID's pointers, we don't want to force our new overrides onto our whole * existing linked IDs usages. */ if (success) { + if (id_root_reference->newid != NULL) { + id_hierarchy_root = id_root_reference->newid; + } + BLI_assert(id_hierarchy_root != NULL); + for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) { reference_id = todo_id_iter->data; ID *local_id = reference_id->newid; @@ -391,6 +408,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, continue; } + local_id->override_library->hierarchy_root = id_hierarchy_root; + Key *reference_key, *local_key = NULL; if ((reference_key = BKE_key_from_id(reference_id)) != NULL) { local_key = BKE_key_from_id(reference_id->newid); @@ -459,6 +478,7 @@ typedef struct LibOverrideGroupTagData { Main *bmain; Scene *scene; ID *id_root; + ID *hierarchy_root_id; uint tag; uint missing_tag; /* Whether we are looping on override data, or their references (linked) one. */ @@ -769,6 +789,8 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * BLI_assert(ID_IS_OVERRIDE_LIBRARY(id_owner)); BLI_assert(data->is_override); + ID *id_hierarchy_root = data->hierarchy_root_id; + if (ID_IS_OVERRIDE_LIBRARY_REAL(id_owner) && (id_owner->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) != 0) { return; @@ -800,9 +822,15 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * if (ELEM(to_id, NULL, id_owner)) { continue; } + /* Different libraries or different hierarchy roots are break points in override hierarchies. + */ if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id_owner->lib)) { continue; } + if (ID_IS_OVERRIDE_LIBRARY_REAL(to_id) && + to_id->override_library->hierarchy_root != id_hierarchy_root) { + continue; + } Library *reference_lib = lib_override_get(bmain, id_owner)->reference->lib; ID *to_id_reference = lib_override_get(bmain, to_id)->reference; @@ -832,6 +860,11 @@ static void lib_override_overrides_group_tag(LibOverrideGroupTagData *data) BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root)); BLI_assert(data->is_override); + ID *id_hierarchy_root = data->hierarchy_root_id; + BLI_assert(id_hierarchy_root != NULL); + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root)); + UNUSED_VARS_NDEBUG(id_hierarchy_root); + if (id_root->override_library->reference->tag & LIB_TAG_MISSING) { id_root->tag |= data->missing_tag; } @@ -865,7 +898,10 @@ static bool lib_override_library_create_do(Main *bmain, BKE_main_relations_free(bmain); lib_override_group_tag_data_clear(&data); - return BKE_lib_override_library_create_from_tag(bmain, owner_library, id_root->lib, false); + const bool success = BKE_lib_override_library_create_from_tag( + bmain, owner_library, id_root, NULL, false); + + return success; } static void lib_override_library_create_post_process(Main *bmain, @@ -1047,6 +1083,189 @@ bool BKE_lib_override_library_template_create(struct ID *id) return true; } +static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int *r_best_level) +{ + if (curr_level > 1000) { + CLOG_ERROR(&LOG, + "Levels of dependency relationships between library overrides IDs is way too high, " + "skipping further processing loops (involves at least '%s')", + id->name); + BLI_assert(0); + return NULL; + } + + if (!ID_IS_OVERRIDE_LIBRARY(id)) { + BLI_assert(0); + return NULL; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + int best_level_candidate = curr_level; + ID *best_root_id_candidate = id; + + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *from_id = from_id_entry->id_pointer.from; + if (ELEM(from_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(from_id) || (from_id->lib != id->lib)) { + continue; + } + + int level_candidate = curr_level + 1; + /* Recursively process the parent. */ + ID *root_id_candidate = lib_override_root_find( + bmain, from_id, curr_level + 1, &level_candidate); + if (level_candidate > best_level_candidate && root_id_candidate != NULL) { + best_root_id_candidate = root_id_candidate; + best_level_candidate = level_candidate; + } + } + + *r_best_level = best_level_candidate; + return best_root_id_candidate; +} + +static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID *id_from) +{ + if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + if (id->override_library->hierarchy_root == id_root) { + /* Already set, nothing else to do here, sub-hierarchy is also assumed to be properly set + * then. */ + return; + } + + /* Hierarchy root already set, and not matching currently proposed one, try to find which is + * best. */ + if (id->override_library->hierarchy_root != NULL) { + /* Check if given `id_from` matches with the hierarchy of the linked reference ID, in which + * case we assume that the given hierarchy root is the 'real' one. + * + * NOTE: This can fail if user mixed dependencies between several overrides of a same + * reference linked hierarchy. Not much to be done in that case, it's virtually impossible to + * fix this automatically in a reliable way. */ + if (id_from == NULL || !ID_IS_OVERRIDE_LIBRARY_REAL(id_from)) { + /* Too complicated to deal with for now. */ + CLOG_WARN(&LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tNot enough data to verify validity of current proposed root '%s', assuming " + "already set one '%s' is valid.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + + ID *id_from_ref = id_from->override_library->reference; + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, + id->override_library->reference); + BLI_assert(entry != NULL); + + bool do_replace_root = false; + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + if (id_from_ref == from_id_entry->id_pointer.from) { + /* A matching parent was found in reference linked data, assume given hierarchy root is + * the valid one. */ + do_replace_root = true; + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' detected as valid, will replace already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + break; + } + } + + if (!do_replace_root) { + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' not detected as valid, keeping already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + } + + id->override_library->hierarchy_root = id_root; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL; + to_id_entry = to_id_entry->next) { + if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *to_id = *to_id_entry->id_pointer.to; + if (ELEM(to_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id->lib)) { + continue; + } + + /* Recursively process the sub-hierarchy. */ + lib_override_root_hierarchy_set(bmain, id_root, to_id, id); + } +} + +void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) +{ + ID *id; + + BKE_main_relations_create(bmain, 0); + + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + continue; + } + if (id->override_library->hierarchy_root != NULL) { + continue; + } + + int best_level = 0; + ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level); + + if (!ELEM(id_root->override_library->hierarchy_root, id_root, NULL)) { + CLOG_WARN(&LOG, + "Potential inconsistency in library override hierarchy of ID '%s', detected as " + "part of the hierarchy of '%s', which has a different root '%s'", + id->name, + id_root->name, + id_root->override_library->hierarchy_root->name); + continue; + } + + lib_override_root_hierarchy_set(bmain, id_root, id_root, NULL); + + BLI_assert(id->override_library->hierarchy_root != NULL); + } + FOREACH_MAIN_ID_END; + + BKE_main_relations_free(bmain); +} + static void lib_override_library_remap(Main *bmain, const ID *id_root_reference, GHash *linkedref_to_old_override) @@ -1112,6 +1331,7 @@ static bool lib_override_library_resync(Main *bmain, LibOverrideGroupTagData data = {.bmain = bmain, .scene = scene, .id_root = id_root, + .hierarchy_root_id = id_root->override_library->hierarchy_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, .is_override = true, @@ -1214,7 +1434,7 @@ static bool lib_override_library_resync(Main *bmain, * override IDs (including within the old overrides themselves, since those are tagged too * above). */ const bool success = BKE_lib_override_library_create_from_tag( - bmain, NULL, id_root_reference->lib, true); + bmain, NULL, id_root_reference, id_root->override_library->hierarchy_root, true); if (!success) { return success; @@ -1533,46 +1753,20 @@ static void lib_override_resync_tagging_finalize_recurse(Main *bmain, * * NOTE: Related to `lib_override_resync_tagging_finalize` above. */ -static ID *lib_override_library_main_resync_find_root_recurse(ID *id, int *level) -{ - (*level)++; - ID *return_id = id; - - switch (GS(id->name)) { - case ID_GR: { - /* Find the highest valid collection in the parenting hierarchy. - * Note that in practice, in any decent common case there is only one well defined root - * collection anyway. */ - int max_level = *level; - Collection *collection = (Collection *)id; - LISTBASE_FOREACH (CollectionParent *, collection_parent_iter, &collection->parents) { - Collection *collection_parent = collection_parent_iter->collection; - if (ID_IS_OVERRIDE_LIBRARY_REAL(collection_parent) && - collection_parent->id.lib == id->lib) { - int tmp_level = *level; - ID *tmp_id = lib_override_library_main_resync_find_root_recurse(&collection_parent->id, - &tmp_level); - if (tmp_level > max_level) { - max_level = tmp_level; - return_id = tmp_id; - } - } - } - break; - } - case ID_OB: { - Object *object = (Object *)id; - if (object->parent != NULL && ID_IS_OVERRIDE_LIBRARY_REAL(object->parent) && - object->parent->id.lib == id->lib) { - return_id = lib_override_library_main_resync_find_root_recurse(&object->parent->id, level); - } - break; +static ID *lib_override_library_main_resync_root_get(Main *bmain, ID *id) +{ + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); + if (id_type->owner_get != NULL) { + id = id_type->owner_get(bmain, id); } - default: - break; + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); } - return return_id; + ID *hierarchy_root_id = id->override_library->hierarchy_root; + BLI_assert(hierarchy_root_id != NULL); + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(hierarchy_root_id)); + return hierarchy_root_id; } /* Ensure resync of all overrides at one level of indirect usage. @@ -1714,14 +1908,13 @@ static void lib_override_library_main_resync_on_library_indirect_level( Library *library = id->lib; - int level = 0; /* In complex non-supported cases, with several different override hierarchies sharing * relations between each-other, we may end up not actually updating/replacing the given * root id (see e.g. pro/shots/110_rextoria/110_0150_A/110_0150_A.anim.blend of sprites * project repository, r2687). * This can lead to infinite loop here, at least avoid this. */ id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; - id = lib_override_library_main_resync_find_root_recurse(id, &level); + id = lib_override_library_main_resync_root_get(bmain, id); id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); BLI_assert(id->lib == library); @@ -1879,6 +2072,7 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root) LibOverrideGroupTagData data = {.bmain = bmain, .scene = NULL, .id_root = id_root, + .hierarchy_root_id = id_root->override_library->hierarchy_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, .is_override = true, diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index e73b53c4bf8..f49af9abffe 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -323,6 +323,8 @@ static bool library_foreach_ID_link(Main *bmain, IDWALK_CB_USER | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE); CALLBACK_INVOKE_ID(id->override_library->storage, IDWALK_CB_USER | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE); + + CALLBACK_INVOKE_ID(id->override_library->hierarchy_root, IDWALK_CB_LOOPBACK); } IDP_foreach_property(id->properties, @@ -471,7 +473,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) return ELEM(id_type_used, ID_MA); case ID_WS: return ELEM(id_type_used, ID_SCR, ID_SCE); - case ID_HA: + case ID_CV: return ELEM(id_type_used, ID_MA); case ID_PT: return ELEM(id_type_used, ID_MA); diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index e4e0466416a..8e375ff16b5 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -97,14 +97,14 @@ static void foreach_libblock_remap_callback_skip(const ID *UNUSED(id_owner), const int cb_flag, const bool is_indirect, const bool is_reference, - const bool is_never_null, + const bool violates_never_null, const bool UNUSED(is_obj), const bool is_obj_editmode) { if (is_indirect) { id_remap_data->skipped_indirect++; } - else if (is_never_null || is_obj_editmode || is_reference) { + else if (violates_never_null || is_obj_editmode || is_reference) { id_remap_data->skipped_direct++; } else { @@ -127,10 +127,10 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, IDRemap *id_remap_data, const int cb_flag, const bool is_indirect, - const bool is_never_null, + const bool violates_never_null, const bool force_user_refcount) { - if (!is_never_null) { + if (!violates_never_null) { *id_ptr = new_id; DEG_id_tag_update_ex(id_remap_data->bmain, id_self, @@ -210,8 +210,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) * remapped in this situation. */ const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id_owner) && (id_remap_data->flag & ID_REMAP_FORCE_OBDATA_IN_EDITMODE) == 0); - const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && - (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); + const bool violates_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && + (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); const bool skip_reference = (id_remap_data->flag & ID_REMAP_SKIP_OVERRIDE_LIBRARY) != 0; const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0; const bool force_user_refcount = (id_remap_data->flag & ID_REMAP_FORCE_USER_REFCOUNT) != 0; @@ -239,7 +239,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) /* Special hack in case it's Object->data and we are in edit mode, and new_id is not NULL * (otherwise, we follow common NEVER_NULL flags). * (skipped_indirect too). */ - if ((is_never_null && skip_never_null) || + if ((violates_never_null && skip_never_null) || (is_obj_editmode && (((Object *)id_owner)->data == *id_p) && new_id != NULL) || (skip_indirect && is_indirect) || (is_reference && skip_reference)) { foreach_libblock_remap_callback_skip(id_owner, @@ -248,7 +248,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) cb_flag, is_indirect, is_reference, - is_never_null, + violates_never_null, is_obj, is_obj_editmode); } @@ -261,7 +261,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) id_remap_data, cb_flag, is_indirect, - is_never_null, + violates_never_null, force_user_refcount); } @@ -558,7 +558,7 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ case ID_ME: case ID_CU: case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: if (new_id) { /* Only affects us in case obdata was relinked (changed). */ diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 64731be57ac..53b1a9c9e16 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -643,8 +643,8 @@ ListBase *which_libbase(Main *bmain, short type) return &(bmain->cachefiles); case ID_WS: return &(bmain->workspaces); - case ID_HA: - return &(bmain->hairs); + case ID_CV: + return &(bmain->hair_curves); case ID_PT: return &(bmain->pointclouds); case ID_VO: @@ -688,7 +688,7 @@ int set_listbasepointers(Main *bmain, ListBase *lb[/*INDEX_ID_MAX*/]) lb[INDEX_ID_ME] = &(bmain->meshes); lb[INDEX_ID_CU] = &(bmain->curves); lb[INDEX_ID_MB] = &(bmain->metaballs); - lb[INDEX_ID_HA] = &(bmain->hairs); + lb[INDEX_ID_CV] = &(bmain->hair_curves); lb[INDEX_ID_PT] = &(bmain->pointclouds); lb[INDEX_ID_VO] = &(bmain->volumes); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 15469f910b4..1c1b2c2cd27 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -36,10 +36,10 @@ #include "DNA_anim_types.h" #include "DNA_collection_types.h" #include "DNA_curve_types.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" #include "DNA_defaults.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -341,9 +341,9 @@ Material ***BKE_object_material_array_p(Object *ob) bGPdata *gpd = ob->data; return &(gpd->mat); } - if (ob->type == OB_HAIR) { - Hair *hair = ob->data; - return &(hair->mat); + if (ob->type == OB_CURVES) { + Curves *curves = ob->data; + return &(curves->mat); } if (ob->type == OB_POINTCLOUD) { PointCloud *pointcloud = ob->data; @@ -374,9 +374,9 @@ short *BKE_object_material_len_p(Object *ob) bGPdata *gpd = ob->data; return &(gpd->totcol); } - if (ob->type == OB_HAIR) { - Hair *hair = ob->data; - return &(hair->totcol); + if (ob->type == OB_CURVES) { + Curves *curves = ob->data; + return &(curves->totcol); } if (ob->type == OB_POINTCLOUD) { PointCloud *pointcloud = ob->data; @@ -403,8 +403,8 @@ Material ***BKE_id_material_array_p(ID *id) return &(((MetaBall *)id)->mat); case ID_GD: return &(((bGPdata *)id)->mat); - case ID_HA: - return &(((Hair *)id)->mat); + case ID_CV: + return &(((Curves *)id)->mat); case ID_PT: return &(((PointCloud *)id)->mat); case ID_VO: @@ -429,8 +429,8 @@ short *BKE_id_material_len_p(ID *id) return &(((MetaBall *)id)->totcol); case ID_GD: return &(((bGPdata *)id)->totcol); - case ID_HA: - return &(((Hair *)id)->totcol); + case ID_CV: + return &(((Curves *)id)->totcol); case ID_PT: return &(((PointCloud *)id)->totcol); case ID_VO: @@ -454,7 +454,7 @@ static void material_data_index_remove_id(ID *id, short index) BKE_curve_material_index_remove((Curve *)id, index); break; case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: /* No material indices for these object data types. */ @@ -509,7 +509,7 @@ static void material_data_index_clear_id(ID *id) BKE_curve_material_index_clear((Curve *)id); break; case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: /* No material indices for these object data types. */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index ac6b0a04def..3c5cdb1ba78 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -15,6 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. + */ + +/** \file + * \ingroup bke + * * MetaBalls are created from a single Object (with a name without number in it), * here the DispList and BoundBox also is located. * All objects with the same name (but with a number in it) are added to this. @@ -22,10 +27,6 @@ * texture coordinates are patched within the displist */ -/** \file - * \ingroup bke - */ - #include <ctype.h> #include <float.h> #include <math.h> diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index 50db1bc1564..d0a57310fcf 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -12,13 +12,12 @@ * 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. - * - * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": - * https://github.com/fedackb/mesh-fairing. */ /** \file * \ingroup bke + * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": + * https://github.com/fedackb/mesh-fairing. */ #include "BLI_map.hh" diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 08a17060549..1b3c7e01be8 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -43,6 +43,7 @@ #include "BLI_span.hh" #include "BLI_stack.h" #include "BLI_task.h" +#include "BLI_task.hh" #include "BLI_utildefines.h" #include "BKE_customdata.h" @@ -373,22 +374,28 @@ const float (*BKE_mesh_vertex_normals_ensure(const Mesh *mesh))[3] return (const float(*)[3])CustomData_get_layer(&mesh->vdata, CD_NORMAL); } - Mesh &mesh_mutable = *const_cast<Mesh *>(mesh); + float(*vert_normals)[3]; + float(*poly_normals)[3]; - float(*vert_normals)[3] = BKE_mesh_vertex_normals_for_write(&mesh_mutable); - float(*poly_normals)[3] = BKE_mesh_poly_normals_for_write(&mesh_mutable); + /* Isolate task because a mutex is locked and computing normals is multi-threaded. */ + blender::threading::isolate_task([&]() { + Mesh &mesh_mutable = *const_cast<Mesh *>(mesh); - mesh_calc_normals_poly_and_vertex(mesh_mutable.mvert, - mesh_mutable.totvert, - mesh_mutable.mloop, - mesh_mutable.totloop, - mesh_mutable.mpoly, - mesh_mutable.totpoly, - poly_normals, - vert_normals); + vert_normals = BKE_mesh_vertex_normals_for_write(&mesh_mutable); + poly_normals = BKE_mesh_poly_normals_for_write(&mesh_mutable); - BKE_mesh_vertex_normals_clear_dirty(&mesh_mutable); - BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + mesh_calc_normals_poly_and_vertex(mesh_mutable.mvert, + mesh_mutable.totvert, + mesh_mutable.mloop, + mesh_mutable.totloop, + mesh_mutable.mpoly, + mesh_mutable.totpoly, + poly_normals, + vert_normals); + + BKE_mesh_vertex_normals_clear_dirty(&mesh_mutable); + BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + }); BLI_mutex_unlock(normals_mutex); return vert_normals; @@ -413,19 +420,24 @@ const float (*BKE_mesh_poly_normals_ensure(const Mesh *mesh))[3] return (const float(*)[3])CustomData_get_layer(&mesh->pdata, CD_NORMAL); } - Mesh &mesh_mutable = *const_cast<Mesh *>(mesh); + float(*poly_normals)[3]; + + /* Isolate task because a mutex is locked and computing normals is multi-threaded. */ + blender::threading::isolate_task([&]() { + Mesh &mesh_mutable = *const_cast<Mesh *>(mesh); - float(*poly_normals)[3] = BKE_mesh_poly_normals_for_write(&mesh_mutable); + poly_normals = BKE_mesh_poly_normals_for_write(&mesh_mutable); - BKE_mesh_calc_normals_poly(mesh_mutable.mvert, - mesh_mutable.totvert, - mesh_mutable.mloop, - mesh_mutable.totloop, - mesh_mutable.mpoly, - mesh_mutable.totpoly, - poly_normals); + BKE_mesh_calc_normals_poly(mesh_mutable.mvert, + mesh_mutable.totvert, + mesh_mutable.mloop, + mesh_mutable.totloop, + mesh_mutable.mpoly, + mesh_mutable.totpoly, + poly_normals); - BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + }); BLI_mutex_unlock(normals_mutex); return poly_normals; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 829ef08a8fb..4cedaff7c00 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -15,13 +15,12 @@ * * The Original Code is Copyright (C) 2005 by the Blender Foundation. * All rights reserved. - * Modifier stack implementation. - * - * BKE_modifier.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * Modifier stack implementation. + * BKE_modifier.h contains the function prototypes for this file. */ /* Allow using deprecated functionality for .blend file I/O. */ diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index 839c457dd84..9ecd0901689 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -825,6 +825,7 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int UNUSED(subdiv_edge_index), + const bool is_loose, const int subdiv_v1, const int subdiv_v2) { @@ -832,7 +833,9 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context, const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context; if (reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR) { - store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, (char)255); + if (!is_loose) { + store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, (char)255); + } return; } diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 0555707b64c..9f3ce68ca69 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -273,6 +273,12 @@ static OutputFieldDependency find_group_output_dependencies( while (!sockets_to_check.is_empty()) { const InputSocketRef *input_socket = sockets_to_check.pop(); + if (!input_socket->is_directly_linked() && + !field_state_by_socket_id[input_socket->id()].is_single) { + /* This socket uses a field as input by default. */ + return OutputFieldDependency::ForFieldSource(); + } + for (const OutputSocketRef *origin_socket : input_socket->directly_linked_sockets()) { const NodeRef &origin_node = origin_socket->node(); const SocketFieldState &origin_state = field_state_by_socket_id[origin_socket->id()]; @@ -1608,6 +1614,11 @@ void BKE_ntree_update_tag_link_mute(bNodeTree *ntree, bNodeLink *UNUSED(link)) add_tree_tag(ntree, NTREE_CHANGED_LINK); } +void BKE_ntree_update_tag_active_output_changed(bNodeTree *ntree) +{ + add_tree_tag(ntree, NTREE_CHANGED_ANY); +} + void BKE_ntree_update_tag_missing_runtime_data(bNodeTree *ntree) { add_tree_tag(ntree, NTREE_CHANGED_ALL); diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 04d60c096f2..8faae6efb26 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -89,6 +89,7 @@ #include "BKE_constraint.h" #include "BKE_crazyspace.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_deform.h" #include "BKE_displist.h" #include "BKE_duplilist.h" @@ -103,7 +104,6 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_icons.h" #include "BKE_idprop.h" #include "BKE_idtype.h" @@ -1415,7 +1415,7 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) } /* Only geometry objects should be able to get modifiers T25291. */ - if (ELEM(ob->type, OB_POINTCLOUD, OB_VOLUME, OB_HAIR)) { + if (ELEM(ob->type, OB_POINTCLOUD, OB_VOLUME, OB_CURVES)) { return (mti->modifyGeometrySet != nullptr); } if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { @@ -2098,8 +2098,8 @@ static const char *get_obdata_defname(int type) return DATA_("Armature"); case OB_SPEAKER: return DATA_("Speaker"); - case OB_HAIR: - return DATA_("Hair"); + case OB_CURVES: + return DATA_("HairCurves"); case OB_POINTCLOUD: return DATA_("PointCloud"); case OB_VOLUME: @@ -2173,8 +2173,8 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) return BKE_lightprobe_add(bmain, name); case OB_GPENCIL: return BKE_gpencil_data_addnew(bmain, name); - case OB_HAIR: - return BKE_hair_add(bmain, name); + case OB_CURVES: + return BKE_curves_add(bmain, name); case OB_POINTCLOUD: return BKE_pointcloud_add_default(bmain, name); case OB_VOLUME: @@ -2211,8 +2211,8 @@ int BKE_object_obdata_to_type(const ID *id) return OB_ARMATURE; case ID_LP: return OB_LIGHTPROBE; - case ID_HA: - return OB_HAIR; + case ID_CV: + return OB_CURVES; case ID_PT: return OB_POINTCLOUD; case ID_VO: @@ -2729,8 +2729,8 @@ Object *BKE_object_duplicate(Main *bmain, Object *ob, uint dupflag, uint duplica id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; - case OB_HAIR: - if (dupflag & USER_DUP_HAIR) { + case OB_CURVES: + if (dupflag & USER_DUP_CURVES) { id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; @@ -3624,8 +3624,8 @@ BoundBox *BKE_object_boundbox_get(Object *ob) case OB_GPENCIL: bb = BKE_gpencil_boundbox_get(ob); break; - case OB_HAIR: - bb = BKE_hair_boundbox_get(ob); + case OB_CURVES: + bb = BKE_curves_boundbox_get(ob); break; case OB_POINTCLOUD: bb = BKE_pointcloud_boundbox_get(ob); @@ -3826,8 +3826,8 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us } break; } - case OB_HAIR: { - BoundBox bb = *BKE_hair_boundbox_get(ob); + case OB_CURVES: { + BoundBox bb = *BKE_curves_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; @@ -4941,7 +4941,7 @@ bool BKE_object_supports_material_slots(struct Object *ob) OB_SURF, OB_FONT, OB_MBALL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME, OB_GPENCIL); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 9c2b48303b2..6352fd19239 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 20014 by Blender Foundation. + * The Original Code is Copyright (C) 2014 by Blender Foundation. * All rights reserved. */ @@ -41,12 +41,12 @@ #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_effect.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_image.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -214,8 +214,8 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o BKE_gpencil_update_layer_transforms(depsgraph, ob); break; } - case OB_HAIR: - BKE_hair_data_update(depsgraph, scene, ob); + case OB_CURVES: + BKE_curves_data_update(depsgraph, scene, ob); break; case OB_POINTCLOUD: BKE_pointcloud_data_update(depsgraph, scene, ob); @@ -304,7 +304,6 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) void BKE_object_eval_uber_transform(Depsgraph *UNUSED(depsgraph), Object *UNUSED(object)) { - return; } void BKE_object_data_batch_cache_dirty_tag(ID *object_data) @@ -326,8 +325,8 @@ void BKE_object_data_batch_cache_dirty_tag(ID *object_data) case ID_GD: BKE_gpencil_batch_cache_dirty_tag((struct bGPdata *)object_data); break; - case ID_HA: - BKE_hair_batch_cache_dirty_tag((struct Hair *)object_data, BKE_HAIR_BATCH_DIRTY_ALL); + case ID_CV: + BKE_curves_batch_cache_dirty_tag((struct Curves *)object_data, BKE_CURVES_BATCH_DIRTY_ALL); break; case ID_PT: BKE_pointcloud_batch_cache_dirty_tag((struct PointCloud *)object_data, diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 97326c24a61..dacc24c32da 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Based on original code by Drew Whitehouse / Houdini Ocean Toolkit - * OpenMP hints by Christian Schnellhammer */ /** \file * \ingroup bke + * + * Based on original code by Drew Whitehouse / Houdini Ocean Toolkit + * OpenMP hints by Christian Schnellhammer */ #include <math.h> diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e489f9e2bac..6953ecf38c3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -13,11 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 by Janne Karhu. - * All rights reserved. - * Adaptive time step - * Classical SPH - * Copyright 2011-2012 AutoCRC + * Copyright 2007 Janne Karhu. All rights reserved. + * 2011-2012 AutoCRC (adaptive time step, Classical SPH). */ /** \file diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 69bead27fe6..b510a9b3bba 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -734,7 +734,7 @@ static int subdiv_foreach_edges_row(SubdivForeachTaskContext *ctx, const int v1 = vertex_index; const int v2 = vertex_index + 1; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, false, v1, v2); vertex_index += 1; } return subdiv_edge_index; @@ -762,7 +762,7 @@ static int subdiv_foreach_edges_column(SubdivForeachTaskContext *ctx, const int v1 = vertex_index; const int v2 = vertex_index + num_edges_per_row; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, false, v1, v2); vertex_index += 1; } return subdiv_edge_index; @@ -862,7 +862,7 @@ static void subdiv_foreach_edges_all_patches_regular(SubdivForeachTaskContext *c const int v1 = (flip) ? (start_edge_vertex + (resolution - i - 3)) : (start_edge_vertex + i); const int v2 = side_start_index + side_stride * i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } } @@ -926,7 +926,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c const int v1 = current_patch_vertex_index; const int v2 = next_path_vertex_index; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); current_patch_vertex_index += ptex_face_inner_resolution + 1; next_path_vertex_index += 1; } @@ -940,7 +940,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c const int v1 = center_vertex_index; const int v2 = current_patch_end_vertex_index; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } /* Connect inner path of patch to boundary. */ @@ -964,7 +964,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c (start_edge_vertex + i); const int v2 = side_start_index + i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } if (ptex_face_resolution >= 3) { @@ -978,7 +978,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c (start_edge_vertex + i); const int v2 = side_start_index + (ptex_face_inner_resolution + 1) * i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } prev_coarse_loop = coarse_loop; @@ -1015,6 +1015,8 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx, const int resolution = ctx->settings->resolution; const int num_subdiv_vertices_per_coarse_edge = resolution - 2; const int num_subdiv_edges_per_coarse_edge = resolution - 1; + const bool is_loose = !BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, coarse_edge_index); + int subdiv_edge_index = ctx->edge_boundary_offset + coarse_edge_index * num_subdiv_edges_per_coarse_edge; int last_vertex_index = ctx->vertices_corner_offset + coarse_edge->v1; @@ -1023,13 +1025,13 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx, const int v2 = ctx->vertices_edge_offset + coarse_edge_index * num_subdiv_vertices_per_coarse_edge + i; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, is_loose, v1, v2); last_vertex_index = v2; } const int v1 = last_vertex_index; const int v2 = ctx->vertices_corner_offset + coarse_edge->v2; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, is_loose, v1, v2); } /** \} */ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index c334d9a2c33..09af77d5f09 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -767,6 +767,7 @@ static void subdiv_mesh_edge(const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int subdiv_edge_index, + const bool UNUSED(is_loose), const int subdiv_v1, const int subdiv_v2) { diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index 9b79d5635d1..60b7e4e5c8b 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -15,6 +15,10 @@ * * The Original Code is written by Rob Haarsma (phase) * All rights reserved. + */ + +/** \file + * \ingroup bke * * This code parses the Freetype font outline data to chains of Blender's bezier-triples. * Additional information can be found at the bottom of this file. @@ -22,10 +26,6 @@ * Code that uses exotic character maps is present but commented out. */ -/** \file - * \ingroup bke - */ - #include <ft2build.h> #include FT_FREETYPE_H /* not needed yet */ diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index a4f20f980b4..138c75acd7b 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Functions for writing avi-format files. - * Added interface for generic movie support (ton) */ /** \file + * Functions for writing AVI-format files. + * Added interface for generic movie support (ton) * \ingroup bke */ diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h index 1df5b6f814a..d3a5d5fb53e 100644 --- a/source/blender/blenlib/BLI_fnmatch.h +++ b/source/blender/blenlib/BLI_fnmatch.h @@ -14,15 +14,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. - * - * NOTE: The canonical source of this file is maintained with the GNU C Library. - * Bugs can be reported to <bug-glibc@prep.ai.mit.edu>. */ #pragma once /** \file * \ingroup bli + * \note The canonical source of this file is maintained with the GNU C Library. + * Bugs can be reported to <bug-glibc@prep.ai.mit.edu>. */ #ifdef __cplusplus diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index 3609dd7d891..f970563d2a6 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -62,8 +62,7 @@ void *BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED /** * Returns the nth element after \a link, numbering from 0. */ -void *BLI_findlinkfrom(struct Link *start, int number) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(1); +void *BLI_findlinkfrom(struct Link *start, int number) ATTR_WARN_UNUSED_RESULT; /** * Finds the first element of \a listbase which contains the null-terminated diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h index 5768b098d2f..b3ce6c0747a 100644 --- a/source/blender/blenlib/BLI_math.h +++ b/source/blender/blenlib/BLI_math.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index f6462233106..69abe49c207 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 0798acbb790..e1956d2bc2b 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_color_blend.h b/source/blender/blenlib/BLI_math_color_blend.h index 2aff629def8..df70da0eec3 100644 --- a/source/blender/blenlib/BLI_math_color_blend.h +++ b/source/blender/blenlib/BLI_math_color_blend.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 6d7159f73c6..2556aae6aa4 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h index 70f56d15164..35e08898385 100644 --- a/source/blender/blenlib/BLI_math_inline.h +++ b/source/blender/blenlib/BLI_math_inline.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 03b6ff25a4f..ac9364fc254 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once @@ -431,6 +429,20 @@ void mat3_to_size(float size[3], const float M[3][3]); void mat4_to_size(float size[3], const float M[4][4]); /** + * Return the largest scale on any axis, the equivalent of calling: + * \code{.c} + * mat3_to_size(size_v3, mat); + * size = size_v3[max_axis_v3(size_v3)]; + * \endcode + * .. without 2x unnecessary `sqrtf` calls. + */ +float mat3_to_size_max_axis(const float M[3][3]); +/** + * Only the first 3 axes are used. + */ +float mat4_to_size_max_axis(const float M[4][4]); + +/** * Extract scale factors from the matrix, with correction to ensure * exact volume in case of a sheared matrix. */ diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index c27cf71ce5f..907dc5601fe 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 1ed8d4fc005..04b7ac5db62 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh index 84d5cd39bb4..8f75aa19cfe 100644 --- a/source/blender/blenlib/BLI_task.hh +++ b/source/blender/blenlib/BLI_task.hh @@ -31,6 +31,7 @@ # include <tbb/blocked_range.h> # include <tbb/parallel_for.h> # include <tbb/parallel_for_each.h> +# include <tbb/parallel_invoke.h> # include <tbb/parallel_reduce.h> # include <tbb/task_arena.h> # ifdef WIN32 @@ -103,6 +104,19 @@ Value parallel_reduce(IndexRange range, #endif } +/** + * Execute all of the provided functions. The functions might be executed in parallel or in serial + * or some combination of both. + */ +template<typename... Functions> void parallel_invoke(Functions &&...functions) +{ +#ifdef WITH_TBB + tbb::parallel_invoke(std::forward<Functions>(functions)...); +#else + (functions(), ...); +#endif +} + /** See #BLI_task_isolate for a description of what isolating a task means. */ template<typename Function> void isolate_task(const Function &function) { diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c index 262d112d914..bc61282fa20 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.c +++ b/source/blender/blenlib/intern/BLI_dynstr.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Dynamically sized string ADT */ /** \file * \ingroup bli + * Dynamically sized string ADT. */ #include <stdio.h> diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 765d2f0be55..f34179b2fa6 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Support for linked lists. */ /** \file diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 85ff5a6e46f..9c22afeb893 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -74,7 +74,7 @@ void BLI_dlrbTree_free(DLRBT_Tree *tree, DLRBT_NFree_FP free_cb) if (tree->first) { /* free list */ if (free_cb) { - LISTBASE_FOREACH_MUTABLE (DLRBT_Node *, node, tree) { + LISTBASE_FOREACH_MUTABLE(DLRBT_Node *, node, tree) { free_cb(node); } BLI_listbase_clear((ListBase *)tree); diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c index 670ea75e9ea..31b8939753e 100644 --- a/source/blender/blenlib/intern/bitmap_draw_2d.c +++ b/source/blender/blenlib/intern/bitmap_draw_2d.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c index 6a0ca8bb33f..a2cc1a0fc12 100644 --- a/source/blender/blenlib/intern/hash_md5.c +++ b/source/blender/blenlib/intern/hash_md5.c @@ -12,7 +12,7 @@ * 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. - * Copyright (C) 1995 Software Foundation, Inc. + * Copyright (C) 1995 Free Software Foundation, Inc. * * Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>. */ diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index be70acf622a..f2e7f411524 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index cfcc54b1136..a7729d83726 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 5e52873649e..60931f0c474 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c index 73ecb2cf798..7d1003a05ba 100644 --- a/source/blender/blenlib/intern/math_color_blend_inline.c +++ b/source/blender/blenlib/intern/math_color_blend_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index a7f229e7147..27cad310aa5 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d61c6c015f6..afbaf0733b6 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 09028a1eb9a..17580d84c38 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index f307672361b..73e64c2bee7 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file @@ -2144,6 +2142,16 @@ void mat4_to_size(float size[3], const float M[4][4]) size[2] = len_v3(M[2]); } +float mat3_to_size_max_axis(const float M[3][3]) +{ + return sqrtf(max_fff(len_squared_v3(M[0]), len_squared_v3(M[1]), len_squared_v3(M[2]))); +} + +float mat4_to_size_max_axis(const float M[4][4]) +{ + return sqrtf(max_fff(len_squared_v3(M[0]), len_squared_v3(M[1]), len_squared_v3(M[2]))); +} + void mat4_to_size_fix_shear(float size[3], const float M[4][4]) { mat4_to_size(size, M); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index dbcf3a6500c..9de9e3d2045 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index a0afab8a179..fb23018b0e0 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 3022dbbe4ff..3e932572038 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f39797c980c..3b9b7ed6ddb 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * various string, file, list operations. */ /** \file * \ingroup bli + * Various string, file, list operations. */ #include <ctype.h> diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 9fe82069d2c..4fd6670507a 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * (uit traces) maart 95 */ /** \file diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c index 21162904dbd..d785d3d17f8 100644 --- a/source/blender/blenlib/intern/string_utils.c +++ b/source/blender/blenlib/intern/string_utils.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2017 by the Blender FOundation. + * The Original Code is Copyright (C) 2017 by the Blender Foundation. * All rights reserved. */ diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 11345fc7242..57f3b740a03 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Windows-posix compatibility layer, windows-specific functions. */ /** \file * \ingroup bli + * Windows-posix compatibility layer, windows-specific functions. */ #ifdef WIN32 diff --git a/source/blender/blenlib/intern/winstuff_dir.c b/source/blender/blenlib/intern/winstuff_dir.c index 6f99ea075bb..f8ab3dc8403 100644 --- a/source/blender/blenlib/intern/winstuff_dir.c +++ b/source/blender/blenlib/intern/winstuff_dir.c @@ -12,7 +12,6 @@ * 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. - * Windows-posix compatibility layer for opendir/readdir/closedir */ /** \file diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc index 9e4d7c7dd36..88f597cdf67 100644 --- a/source/blender/blenlib/tests/BLI_listbase_test.cc +++ b/source/blender/blenlib/tests/BLI_listbase_test.cc @@ -80,18 +80,26 @@ TEST(listbase, FindLinkOrIndex) EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)nullptr); EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)nullptr); EXPECT_EQ(BLI_findindex(&lb, link1), -1); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, -1), (void *)nullptr); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 0), (void *)nullptr); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 1), (void *)nullptr); /* One link */ BLI_addtail(&lb, link1); EXPECT_EQ(BLI_findlink(&lb, 0), link1); EXPECT_EQ(BLI_rfindlink(&lb, 0), link1); EXPECT_EQ(BLI_findindex(&lb, link1), 0); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 0), link1); /* Two links */ BLI_addtail(&lb, link2); EXPECT_EQ(BLI_findlink(&lb, 1), link2); EXPECT_EQ(BLI_rfindlink(&lb, 0), link2); EXPECT_EQ(BLI_findindex(&lb, link2), 1); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 1), link2); + + /* After end of list */ + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 2), (void *)nullptr); BLI_freelistN(&lb); } diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc index 3bb6f6f753c..1ed732c1f18 100644 --- a/source/blender/blenlib/tests/BLI_task_test.cc +++ b/source/blender/blenlib/tests/BLI_task_test.cc @@ -1,6 +1,7 @@ /* Apache License, Version 2.0 */ #include "testing/testing.h" +#include <atomic> #include <cstring> #include "atomic_ops.h" @@ -12,6 +13,7 @@ #include "BLI_listbase.h" #include "BLI_mempool.h" #include "BLI_task.h" +#include "BLI_task.hh" #define NUM_ITEMS 10000 @@ -280,3 +282,15 @@ TEST(task, ListBaseIter) MEM_freeN(items_buffer); BLI_threadapi_exit(); } + +TEST(task, ParallelInvoke) +{ + std::atomic<int> counter = 0; + blender::threading::parallel_invoke([&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }); + EXPECT_EQ(counter, 6); +} diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h index 0e2c22d7e4d..772abebeb26 100644 --- a/source/blender/blenloader/BLO_undofile.h +++ b/source/blender/blenloader/BLO_undofile.h @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. - * external writefile function prototypes */ #pragma once /** \file * \ingroup blenloader + * External writefile function prototypes. */ #include "BLI_filereader.h" @@ -91,6 +91,8 @@ void BLO_memfile_chunk_add(MemFileWriteData *mem_data, const char *buf, size_t s /** * Not memfile itself. */ +/* **************** support for memory-write, for undo buffers *************** */ + extern void BLO_memfile_free(MemFile *memfile); /** * Result is that 'first' is being freed. diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index a334d70819d..f01d6afb22d 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * .blend file reading entry point */ /** \file * \ingroup blenloader + * `.blend` file reading entry point. */ #include <stddef.h> diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2ba66657499..6757177a385 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1999,6 +1999,7 @@ static void lib_link_id(BlendLibReader *reader, ID *id) if (id->override_library) { BLO_read_id_address(reader, id->lib, &id->override_library->reference); BLO_read_id_address(reader, id->lib, &id->override_library->storage); + BLO_read_id_address(reader, id->lib, &id->override_library->hierarchy_root); } lib_link_id_embedded_id(reader, id); @@ -2988,7 +2989,7 @@ static const char *dataname(short id_code) return "Data from CF"; case ID_WS: return "Data from WS"; - case ID_HA: + case ID_CV: return "Data from HA"; case ID_PT: return "Data from PT"; diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 44045cf99dd..d75aab9ba9c 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * blenloader readfile private function prototypes */ /** \file * \ingroup blenloader + * blenloader readfile private function prototypes. */ #pragma once diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index dfa6135dac9..638e6a13b01 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2004 Blender Foundation * All rights reserved. - * .blend file reading entry point */ /** \file diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index ef146606ff0..87b5da09a60 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -32,11 +32,11 @@ #include "DNA_cachefile_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" #include "DNA_genfile.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_light_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -1120,10 +1120,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Hair and PointCloud attributes. */ - for (Hair *hair = bmain->hairs.first; hair != NULL; hair = hair->id.next) { - do_versions_point_attributes(&hair->geometry.point_data); - } + /* PointCloud attributes. */ for (PointCloud *pointcloud = bmain->pointclouds.first; pointcloud != NULL; pointcloud = pointcloud->id.next) { do_versions_point_attributes(&pointcloud->pdata); @@ -1422,10 +1419,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Hair and PointCloud attributes names. */ - LISTBASE_FOREACH (Hair *, hair, &bmain->hairs) { - do_versions_point_attribute_names(&hair->geometry.point_data); - } + /* PointCloud attributes names. */ LISTBASE_FOREACH (PointCloud *, pointcloud, &bmain->pointclouds) { do_versions_point_attribute_names(&pointcloud->pdata); } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index aa3eef4b475..4eda63d0817 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -999,7 +999,7 @@ static void write_libraries(WriteData *wd, Main *main) if (!BKE_idtype_idcode_is_linkable(GS(id->name))) { printf( "ERROR: write file: data-block '%s' from lib '%s' is not linkable " - "but is flagged as directly linked", + "but is flagged as directly linked\n", id->name, main->curlib->filepath_abs); BLI_assert(0); diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h index 8785eadf5f1..379ff923229 100644 --- a/source/blender/blentranslation/BLT_translation.h +++ b/source/blender/blentranslation/BLT_translation.h @@ -111,7 +111,7 @@ bool BLT_lang_is_ime_supported(void); #define BLT_I18NCONTEXT_ID_CURVE "Curve" #define BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE "FreestyleLineStyle" #define BLT_I18NCONTEXT_ID_GPENCIL "GPencil" -#define BLT_I18NCONTEXT_ID_HAIR "Hair" +#define BLT_I18NCONTEXT_ID_CURVES "Curves" #define BLT_I18NCONTEXT_ID_ID "ID" #define BLT_I18NCONTEXT_ID_IMAGE "Image" // #define BLT_I18NCONTEXT_ID_IPO "Ipo" /* DEPRECATED */ @@ -173,7 +173,7 @@ typedef struct { BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVE, "id_curve"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, "id_fs_linestyle"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_GPENCIL, "id_gpencil"), \ - BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_HAIR, "id_hair"), \ + BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVES, "id_curves"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ID, "id_id"), \ BLT_I18NCONTEXTS_ITEM( \ BLT_I18NCONTEXT_ID_IMAGE, \ diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index e5ede75f737..900844af4e5 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -93,6 +93,7 @@ enum { SIMVERT_FACE, SIMVERT_VGROUP, SIMVERT_EDGE, + SIMVERT_CREASE, }; /* Poke face center calculation */ diff --git a/source/blender/compositor/nodes/COM_AntiAliasingNode.cc b/source/blender/compositor/nodes/COM_AntiAliasingNode.cc index b11c57041d9..d1b2e69d7ff 100644 --- a/source/blender/compositor/nodes/COM_AntiAliasingNode.cc +++ b/source/blender/compositor/nodes/COM_AntiAliasingNode.cc @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * 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 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #include "COM_AntiAliasingNode.h" diff --git a/source/blender/compositor/nodes/COM_AntiAliasingNode.h b/source/blender/compositor/nodes/COM_AntiAliasingNode.h index 05c51d5856a..bcae235b434 100644 --- a/source/blender/compositor/nodes/COM_AntiAliasingNode.h +++ b/source/blender/compositor/nodes/COM_AntiAliasingNode.h @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * 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 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #pragma once diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc b/source/blender/compositor/nodes/COM_FilterNode.cc index 2108e68cbec..4eca1492fe9 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cc +++ b/source/blender/compositor/nodes/COM_FilterNode.cc @@ -48,7 +48,7 @@ void FilterNode::convert_to_operations(NodeConverter &converter, 2 / 16.0f, 1 / 16.0f); break; - case CMP_FILT_SHARP: + case CMP_FILT_SHARP_BOX: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1); break; @@ -80,6 +80,10 @@ void FilterNode::convert_to_operations(NodeConverter &converter, operation = new ConvolutionFilterOperation(); operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1); break; + case CMP_FILT_SHARP_DIAMOND: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0); + break; default: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0); diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 20e85c69ac8..c466338b61c 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * 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 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #include "COM_SMAAOperation.h" diff --git a/source/blender/compositor/operations/COM_SMAAOperation.h b/source/blender/compositor/operations/COM_SMAAOperation.h index ec04594e0aa..bac33f0a2b4 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.h +++ b/source/blender/compositor/operations/COM_SMAAOperation.h @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * 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 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #pragma once diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc index 069d00b5e66..f0e661818f8 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cc +++ b/source/blender/compositor/operations/COM_TextureOperation.cc @@ -102,7 +102,7 @@ void TextureBaseOperation::execute_pixel_sampled(float output[4], float y, PixelSampler sampler) { - TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, nullptr}; + TexResult texres = {0.0f}; float texture_size[4]; float texture_offset[4]; float vec[3]; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index b886d5a5b9a..ba1432d9ec8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -599,7 +599,7 @@ void DepsgraphNodeBuilder::build_id(ID *id) case ID_CU: case ID_LT: case ID_GD: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: build_object_data_geometry_datablock(id); @@ -894,7 +894,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object) case OB_MBALL: case OB_LATTICE: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: build_object_data_geometry(object); @@ -1563,7 +1563,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata) op_node->set_as_entry(); break; } - case ID_HA: { + case ID_CV: { op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); op_node->set_as_entry(); break; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 97dae46c75f..26dd7bc1363 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -555,7 +555,7 @@ void DepsgraphRelationBuilder::build_id(ID *id) case ID_MB: case ID_CU: case ID_LT: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_GD: @@ -849,7 +849,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object) case OB_MBALL: case OB_LATTICE: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: { build_object_data_geometry(object); @@ -2301,7 +2301,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) } break; } - case ID_HA: + case ID_CV: break; case ID_PT: break; @@ -2925,7 +2925,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) continue; } int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE); - if ((ELEM(id_type, ID_ME, ID_HA, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || + if ((ELEM(id_type, ID_ME, ID_CV, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || (id_type == ID_CF && comp_node->type == NodeType::CACHE)) { rel_flag &= ~RELATION_FLAG_NO_FLUSH; } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index d9147d88045..b9ec01d729c 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -87,7 +87,7 @@ void depsgraph_geometry_tag_to_component(const ID *id, NodeType *component_type) bool is_selectable_data_id_type(const ID_Type id_type) { - return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD, ID_HA, ID_PT, ID_VO); + return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD, ID_CV, ID_PT, ID_VO); } void depsgraph_select_tag_to_component_opcode(const ID *id, @@ -591,7 +591,7 @@ NodeType geometry_tag_to_component(const ID *id) case OB_LATTICE: case OB_MBALL: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: return NodeType::GEOMETRY; @@ -605,7 +605,7 @@ NodeType geometry_tag_to_component(const ID *id) case ID_CU: case ID_LT: case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_GR: diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 85d1f97de5e..f1a8c15a664 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -892,8 +892,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode } /* In case we don't need to do a copy-on-write, we can use the update cache of the grease * pencil data to do an update-on-write.*/ - else if (id_type == ID_GD && BKE_gpencil_update_on_write_check((const ::Depsgraph *)depsgraph, - (bGPdata *)id_orig)) { + if (id_type == ID_GD && BKE_gpencil_can_avoid_full_copy_on_write( + (const ::Depsgraph *)depsgraph, (bGPdata *)id_orig)) { BKE_gpencil_update_on_write((bGPdata *)id_orig, (bGPdata *)id_cow); return id_cow; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h index bc023766a46..728f631f789 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 20137Blender Foundation. + * The Original Code is Copyright (C) 2017 Blender Foundation. * All rights reserved. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc index 22aa2f48eb9..63d1eb9f711 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2019 Blender Foundation. + * The Original Code is Copyright (C) 2022 Blender Foundation. * All rights reserved. */ @@ -35,17 +35,24 @@ GPencilBackup::GPencilBackup(const Depsgraph *depsgraph) : depsgraph(depsgraph) { } -void GPencilBackup::init_from_gpencil(bGPdata *gpd) +void GPencilBackup::init_from_gpencil(bGPdata *UNUSED(gpd)) { } void GPencilBackup::restore_to_gpencil(bGPdata *gpd) { bGPdata *gpd_orig = reinterpret_cast<bGPdata *>(gpd->id.orig_id); + + /* We check for the active depsgraph here to avoid freeing the cache on the original object + * multiple times. This free is only needed for the case where we tagged a full update in the + * update cache and did not do an update-on-write. */ if (depsgraph->is_active) { BKE_gpencil_free_update_cache(gpd_orig); - gpd->runtime.update_cache = NULL; } + /* Doing a copy-on-write copies the update cache pointer. Make sure to reset it + * to NULL as we should never use the update cache from eval data. */ + gpd->runtime.update_cache = NULL; + /* Make sure to update the original runtime pointers in the eval data. */ BKE_gpencil_data_update_orig_pointers(gpd_orig, gpd); } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h index d09e0e2258b..baf0f6a6945 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2019 Blender Foundation. + * The Original Code is Copyright (C) 2022 Blender Foundation. * All rights reserved. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index 17369f723ec..10507948246 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -127,7 +127,7 @@ void ObjectRuntimeBackup::restore_to_object(Object *object) } } } - else if (ELEM(object->type, OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) { + else if (ELEM(object->type, OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { if (object->id.recalc & ID_RECALC_GEOMETRY) { /* Free evaluated caches. */ object->data = data_orig; diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 47d99963ef9..17feb39a072 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -86,9 +86,9 @@ set(SRC intern/mesh_extractors/extract_mesh_vbo_vcol.cc intern/mesh_extractors/extract_mesh_vbo_weights.cc intern/draw_cache_impl_curve.cc + intern/draw_cache_impl_curves.cc intern/draw_cache_impl_displist.c intern/draw_cache_impl_gpencil.c - intern/draw_cache_impl_hair.cc intern/draw_cache_impl_lattice.c intern/draw_cache_impl_mesh.c intern/draw_cache_impl_metaball.c diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index 80207523a65..8f02e96b168 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -56,7 +56,7 @@ #include "BLI_math_bits.h" #include "BLI_rect.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -248,25 +248,25 @@ static DRWShadingGroup *eevee_cryptomatte_shading_group_create(EEVEE_Data *vedat return grp; } -static void eevee_cryptomatte_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob, - ParticleSystem *psys, - ModifierData *md, - Material *material) +static void eevee_cryptomatte_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob, + ParticleSystem *psys, + ModifierData *md, + Material *material) { DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create( vedata, sldata, ob, material, true); DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL); } -void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob) +void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob) { - BLI_assert(ob->type == OB_HAIR); - Material *material = BKE_object_material_get_eval(ob, HAIR_MATERIAL_NR); - eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, NULL, NULL, material); + BLI_assert(ob->type == OB_CURVES); + Material *material = BKE_object_material_get_eval(ob, CURVES_MATERIAL_NR); + eevee_cryptomatte_curves_cache_populate(vedata, sldata, ob, NULL, NULL, material); } void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, @@ -291,7 +291,7 @@ void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, continue; } Material *material = BKE_object_material_get_eval(ob, part->omat); - eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, psys, md, material); + eevee_cryptomatte_curves_cache_populate(vedata, sldata, ob, psys, md, material); } } } diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c index b453df284ed..64553acd228 100644 --- a/source/blender/draw/engines/eevee/eevee_data.c +++ b/source/blender/draw/engines/eevee/eevee_data.c @@ -177,7 +177,7 @@ static void *motion_blur_deform_data_get(EEVEE_MotionBlurData *mb, Object *ob, b if (hair) { EEVEE_HairMotionData *hair_step; /* Ugly, we allocate for each modifiers and just fill based on modifier index in the list. */ - int psys_len = (ob->type != OB_HAIR) ? BLI_listbase_count(&ob->modifiers) : 1; + int psys_len = (ob->type != OB_CURVES) ? BLI_listbase_count(&ob->modifiers) : 1; hair_step = MEM_callocN(sizeof(EEVEE_HairMotionData) + sizeof(hair_step->psys[0]) * psys_len, __func__); hair_step->psys_len = psys_len; diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index fc9b8b0cde4..9b6b5c5f08d 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -125,7 +125,7 @@ void EEVEE_cache_populate(void *vedata, Object *ob) if (ELEM(ob->type, OB_MESH, OB_SURF, OB_MBALL)) { EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow); } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { EEVEE_object_hair_cache_populate(vedata, sldata, ob, &cast_shadow); } else if (ob->type == OB_VOLUME) { diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index a027a29c813..b8586ee0f68 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -33,7 +33,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_modifier_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" @@ -925,7 +925,7 @@ void EEVEE_object_hair_cache_populate(EEVEE_Data *vedata, Object *ob, bool *cast_shadow) { - eevee_hair_cache_populate(vedata, sldata, ob, NULL, NULL, HAIR_MATERIAL_NR, cast_shadow); + eevee_hair_cache_populate(vedata, sldata, ob, NULL, NULL, CURVES_MATERIAL_NR, cast_shadow); } void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 766e721b1b8..883d2eff852 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -1385,9 +1385,9 @@ void EEVEE_cryptomatte_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *s void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob); -void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob); +void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob); void EEVEE_cryptomatte_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); /** * Register the render passes needed for cryptomatte diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index e4e7f6fa4e3..2fd033b6745 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -244,10 +244,10 @@ void EEVEE_render_cache(void *vedata, EEVEE_cryptomatte_cache_populate(data, sldata, ob); } } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { EEVEE_object_hair_cache_populate(vedata, sldata, ob, &cast_shadow); if (do_cryptomatte) { - EEVEE_cryptomatte_object_hair_cache_populate(data, sldata, ob); + EEVEE_cryptomatte_object_curves_cache_populate(data, sldata, ob); } } else if (ob->type == OB_VOLUME) { diff --git a/source/blender/draw/engines/image/image_partial_updater.hh b/source/blender/draw/engines/image/image_partial_updater.hh index f0c1db2331a..e74c31e9e8a 100644 --- a/source/blender/draw/engines/image/image_partial_updater.hh +++ b/source/blender/draw/engines/image/image_partial_updater.hh @@ -32,11 +32,11 @@ struct PartialImageUpdater { /** * \brief Ensure that there is a partial update user for the given image. */ - void ensure_image(const Image *image) + void ensure_image(const Image *new_image) { - if (!is_valid(image)) { + if (!is_valid(new_image)) { free(); - create(image); + create(new_image); } } @@ -60,11 +60,11 @@ struct PartialImageUpdater { return user != nullptr; } - void create(const Image *image) + void create(const Image *new_image) { BLI_assert(user == nullptr); - user = BKE_image_partial_update_create(image); - image = image; + user = BKE_image_partial_update_create(new_image); + image = new_image; } void free() diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index ccf8f9e0c36..f9694b329aa 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -2038,6 +2038,128 @@ static void draw_bone_name(ArmatureDrawContext *ctx, /** \} */ /* -------------------------------------------------------------------- */ +/** \name Pose Bone Culling + * + * Used for selection since drawing many bones can be slow, see: T91253. + * + * Bounding spheres are used with margins added to ensure bones are included. + * An added margin is needed because #BKE_pchan_minmax only returns the bounds + * of the bones head & tail which doesn't account for parts of the bone users may select + * (octahedral spheres or envelope radius for example). + * \{ */ + +static void pchan_culling_calc_bsphere(const Object *ob, + const bPoseChannel *pchan, + BoundSphere *r_bsphere) +{ + float min[3], max[3]; + INIT_MINMAX(min, max); + BKE_pchan_minmax(ob, pchan, min, max); + mid_v3_v3v3(r_bsphere->center, min, max); + r_bsphere->radius = len_v3v3(min, r_bsphere->center); +} + +/** + * \return true when bounding sphere from `pchan` intersect the view. + * (same for other "test" functions defined here). + */ +static bool pchan_culling_test_simple(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_with_radius_scale(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan, + const float scale) +{ + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + bsphere.radius *= scale; + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_custom(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + /* For more aggressive culling the bounding box of the custom-object could be used. */ + return pchan_culling_test_simple(view, ob, pchan); +} + +static bool pchan_culling_test_wire(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BLI_assert(((const bArmature *)ob->data)->drawtype == ARM_WIRE); + return pchan_culling_test_simple(view, ob, pchan); +} + +static bool pchan_culling_test_line(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BLI_assert(((const bArmature *)ob->data)->drawtype == ARM_LINE); + /* Account for the end-points, as the line end-points size is in pixels, this is a rough value. + * Since the end-points are small the difference between having any margin or not is unlikely + * to be noticeable. */ + const float scale = 1.1f; + return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); +} + +static bool pchan_culling_test_envelope(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + const bArmature *arm = ob->data; + BLI_assert(arm->drawtype == ARM_ENVELOPE); + UNUSED_VARS_NDEBUG(arm); + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * + mat4_to_size_max_axis(ob->obmat) * mat4_to_size_max_axis(pchan->disp_mat); + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_bbone(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + const bArmature *arm = ob->data; + BLI_assert(arm->drawtype == ARM_B_BONE); + UNUSED_VARS_NDEBUG(arm); + const float ob_scale = mat4_to_size_max_axis(ob->obmat); + const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; + for (int i = pchan->bone->segments; i--; bbones_mat++) { + BoundSphere bsphere; + float size[3]; + mat4_to_size(size, bbones_mat->mat); + copy_v3_v3(bsphere.center, bbones_mat->mat[3]); + bsphere.radius = len_v3(size) * ob_scale; + if (DRW_culling_sphere_test(view, &bsphere)) { + return true; + } + } + return false; +} + +static bool pchan_culling_test_octohedral(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + /* No type assertion as this is a fallback (files from the future will end up here). */ + /* Account for spheres on the end-points. */ + const float scale = 1.2f; + return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Main Draw Loops * \{ */ @@ -2185,6 +2307,8 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) } } + const DRWView *view = is_pose_select ? DRW_view_default_get() : NULL; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { Bone *bone = pchan->bone; const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; @@ -2225,27 +2349,39 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { draw_bone_update_disp_matrix_custom(pchan); - draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_custom(view, ob, pchan)) { + draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_ENVELOPE) { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_envelope(view, ob, pchan)) { + draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_LINE) { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_line(view, ob, pchan)) { + draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_WIRE) { draw_bone_update_disp_matrix_bbone(NULL, pchan); - draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_wire(view, ob, pchan)) { + draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_B_BONE) { draw_bone_update_disp_matrix_bbone(NULL, pchan); - draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_bbone(view, ob, pchan)) { + draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_octohedral(view, ob, pchan)) { + draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } /* These aren't included in the selection. */ diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 12db2bd02cf..54e8ef80854 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -262,7 +262,7 @@ static bool overlay_object_is_edit_mode(const OVERLAY_PrivateData *pd, const Obj return pd->ctx_mode == CTX_MODE_EDIT_METABALL; case OB_FONT: return pd->ctx_mode == CTX_MODE_EDIT_TEXT; - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: /* No edit mode yet. */ @@ -316,7 +316,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OB_MBALL, OB_FONT, OB_GPENCIL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME); const bool draw_surface = (ob->dt >= OB_WIRE) && (renderable || (ob->dt == OB_WIRE)); diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index a2362cd8850..de0003625a2 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -484,7 +484,7 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons texcosize = mb->size; break; } - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: { /* No user defined texture space support. */ diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 0dfc3c4b119..8773c78e82f 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -34,8 +34,8 @@ #include "BKE_paint.h" #include "BKE_particle.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" -#include "DNA_hair_types.h" #include "DNA_image_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" @@ -419,9 +419,9 @@ void workbench_cache_populate(void *ved, Object *ob) workbench_shadow_cache_populate(vedata, ob, has_transp_mat); } } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL); - workbench_cache_hair_populate(wpd, ob, NULL, NULL, color_type, false, HAIR_MATERIAL_NR); + workbench_cache_hair_populate(wpd, ob, NULL, NULL, color_type, false, CURVES_MATERIAL_NR); } else if (ob->type == OB_VOLUME) { if (wpd->shading.type != OB_WIRE) { diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a4564ce2668..430b28f1224 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -19,7 +19,7 @@ */ #include "DNA_curve_types.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" @@ -835,7 +835,7 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) return NULL; case OB_MBALL: return DRW_cache_mball_edge_detection_get(ob, r_is_manifold); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -859,7 +859,7 @@ GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob) return NULL; case OB_MBALL: return DRW_cache_mball_face_wireframe_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_pointcloud_batch_cache_get_dots(ob); @@ -886,7 +886,7 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) return NULL; case OB_MBALL: return NULL; - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -910,7 +910,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) return NULL; case OB_MBALL: return DRW_cache_mball_surface_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_cache_pointcloud_surface_get(ob); @@ -935,7 +935,7 @@ GPUVertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob) return DRW_curve_batch_cache_pos_vertbuf_get(ob->data); case OB_MBALL: return DRW_mball_batch_cache_pos_vertbuf_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -967,8 +967,8 @@ int DRW_cache_object_material_count_get(struct Object *ob) return DRW_curve_material_count_get(ob->data); case OB_MBALL: return DRW_metaball_material_count_get(ob->data); - case OB_HAIR: - return DRW_hair_material_count_get(ob->data); + case OB_CURVES: + return DRW_curves_material_count_get(ob->data); case OB_POINTCLOUD: return DRW_pointcloud_material_count_get(ob->data); case OB_VOLUME: @@ -994,7 +994,7 @@ GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, return NULL; case OB_MBALL: return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_cache_pointcloud_surface_shaded_get(ob, gpumat_array, gpumat_array_len); @@ -3403,8 +3403,8 @@ void drw_batch_cache_validate(Object *ob) case OB_LATTICE: DRW_lattice_batch_cache_validate((Lattice *)ob->data); break; - case OB_HAIR: - DRW_hair_batch_cache_validate((Hair *)ob->data); + case OB_CURVES: + DRW_curves_batch_cache_validate((Curves *)ob->data); break; case OB_POINTCLOUD: DRW_pointcloud_batch_cache_validate((PointCloud *)ob->data); diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 30e5a10df91..b94dd466364 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -246,14 +246,14 @@ struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUBatch *DRW_cache_mball_face_wireframe_get(struct Object *ob); struct GPUBatch *DRW_cache_mball_edge_detection_get(struct Object *ob, bool *r_is_manifold); -/* Hair */ - -struct GPUBatch *DRW_cache_hair_surface_get(struct Object *ob); -struct GPUBatch **DRW_cache_hair_surface_shaded_get(struct Object *ob, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len); -struct GPUBatch *DRW_cache_hair_face_wireframe_get(struct Object *ob); -struct GPUBatch *DRW_cache_hair_edge_detection_get(struct Object *ob, bool *r_is_manifold); +/* Curves */ + +struct GPUBatch *DRW_cache_curves_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_curves_surface_shaded_get(struct Object *ob, + struct GPUMaterial **gpumat_array, + uint gpumat_array_len); +struct GPUBatch *DRW_cache_curves_face_wireframe_get(struct Object *ob); +struct GPUBatch *DRW_cache_curves_edge_detection_get(struct Object *ob, bool *r_is_manifold); /* PointCloud */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 6a2f4b91ad1..9c6814d910e 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -33,7 +33,7 @@ struct ParticleSystem; struct TaskGraph; struct Curve; -struct Hair; +struct Curves; struct Lattice; struct Mesh; struct MetaBall; @@ -73,9 +73,9 @@ void DRW_particle_batch_cache_free(struct ParticleSystem *psys); void DRW_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd); void DRW_gpencil_batch_cache_free(struct bGPdata *gpd); -void DRW_hair_batch_cache_dirty_tag(struct Hair *hair, int mode); -void DRW_hair_batch_cache_validate(struct Hair *hair); -void DRW_hair_batch_cache_free(struct Hair *hair); +void DRW_curves_batch_cache_dirty_tag(struct Curves *curves, int mode); +void DRW_curves_batch_cache_validate(struct Curves *curves); +void DRW_curves_batch_cache_free(struct Curves *curves); void DRW_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, int mode); void DRW_pointcloud_batch_cache_validate(struct PointCloud *pointcloud); @@ -188,7 +188,7 @@ struct GPUBatch *DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt); /** \name Hair * \{ */ -int DRW_hair_material_count_get(struct Hair *hair); +int DRW_curves_material_count_get(struct Curves *curves); /** \} */ diff --git a/source/blender/draw/intern/draw_cache_impl_hair.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index cdc06b121b0..8ec97495fcf 100644 --- a/source/blender/draw/intern/draw_cache_impl_hair.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -35,10 +35,10 @@ #include "BLI_span.hh" #include "BLI_utildefines.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_object_types.h" -#include "BKE_hair.h" +#include "BKE_curves.h" #include "GPU_batch.h" #include "GPU_material.h" @@ -51,7 +51,7 @@ using blender::float3; using blender::IndexRange; using blender::Span; -static void hair_batch_cache_clear(Hair *hair); +static void curves_batch_cache_clear(Curves *curves); /* ---------------------------------------------------------------------- */ /* Hair GPUBatch Cache */ @@ -65,19 +65,19 @@ struct HairBatchCache { /* GPUBatch cache management. */ -static bool hair_batch_cache_valid(Hair *hair) +static bool curves_batch_cache_valid(Curves *curves) { - HairBatchCache *cache = static_cast<HairBatchCache *>(hair->batch_cache); + HairBatchCache *cache = static_cast<HairBatchCache *>(curves->batch_cache); return (cache && cache->is_dirty == false); } -static void hair_batch_cache_init(Hair *hair) +static void curves_batch_cache_init(Curves *curves) { - HairBatchCache *cache = static_cast<HairBatchCache *>(hair->batch_cache); + HairBatchCache *cache = static_cast<HairBatchCache *>(curves->batch_cache); if (!cache) { cache = MEM_cnew<HairBatchCache>(__func__); - hair->batch_cache = cache; + curves->batch_cache = cache; } else { memset(cache, 0, sizeof(*cache)); @@ -86,28 +86,28 @@ static void hair_batch_cache_init(Hair *hair) cache->is_dirty = false; } -void DRW_hair_batch_cache_validate(Hair *hair) +void DRW_curves_batch_cache_validate(Curves *curves) { - if (!hair_batch_cache_valid(hair)) { - hair_batch_cache_clear(hair); - hair_batch_cache_init(hair); + if (!curves_batch_cache_valid(curves)) { + curves_batch_cache_clear(curves); + curves_batch_cache_init(curves); } } -static HairBatchCache *hair_batch_cache_get(Hair *hair) +static HairBatchCache *curves_batch_cache_get(Curves *curves) { - DRW_hair_batch_cache_validate(hair); - return static_cast<HairBatchCache *>(hair->batch_cache); + DRW_curves_batch_cache_validate(curves); + return static_cast<HairBatchCache *>(curves->batch_cache); } -void DRW_hair_batch_cache_dirty_tag(Hair *hair, int mode) +void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode) { - HairBatchCache *cache = static_cast<HairBatchCache *>(hair->batch_cache); + HairBatchCache *cache = static_cast<HairBatchCache *>(curves->batch_cache); if (cache == nullptr) { return; } switch (mode) { - case BKE_HAIR_BATCH_DIRTY_ALL: + case BKE_CURVES_BATCH_DIRTY_ALL: cache->is_dirty = true; break; default: @@ -115,9 +115,9 @@ void DRW_hair_batch_cache_dirty_tag(Hair *hair, int mode) } } -static void hair_batch_cache_clear(Hair *hair) +static void curves_batch_cache_clear(Curves *curves) { - HairBatchCache *cache = static_cast<HairBatchCache *>(hair->batch_cache); + HairBatchCache *cache = static_cast<HairBatchCache *>(curves->batch_cache); if (!cache) { return; } @@ -125,33 +125,33 @@ static void hair_batch_cache_clear(Hair *hair) particle_batch_cache_clear_hair(&cache->hair); } -void DRW_hair_batch_cache_free(Hair *hair) +void DRW_curves_batch_cache_free(Curves *curves) { - hair_batch_cache_clear(hair); - MEM_SAFE_FREE(hair->batch_cache); + curves_batch_cache_clear(curves); + MEM_SAFE_FREE(curves->batch_cache); } -static void ensure_seg_pt_count(Hair *hair, ParticleHairCache *hair_cache) +static void ensure_seg_pt_count(Curves *curves, ParticleHairCache *curves_cache) { - if ((hair_cache->pos != nullptr && hair_cache->indices != nullptr) || - (hair_cache->proc_point_buf != nullptr)) { + if ((curves_cache->pos != nullptr && curves_cache->indices != nullptr) || + (curves_cache->proc_point_buf != nullptr)) { return; } - hair_cache->strands_len = hair->geometry.curve_size; - hair_cache->elems_len = hair->geometry.point_size + hair->geometry.curve_size; - hair_cache->point_len = hair->geometry.point_size; + curves_cache->strands_len = curves->geometry.curve_size; + curves_cache->elems_len = curves->geometry.point_size + curves->geometry.curve_size; + curves_cache->point_len = curves->geometry.point_size; } -static void hair_batch_cache_fill_segments_proc_pos(Hair *hair, - GPUVertBufRaw *attr_step, - GPUVertBufRaw *length_step) +static void curves_batch_cache_fill_segments_proc_pos(Curves *curves, + GPUVertBufRaw *attr_step, + GPUVertBufRaw *length_step) { /* TODO: use hair radius layer if available. */ - const int curve_size = hair->geometry.curve_size; - Span<int> offsets{hair->geometry.offsets, hair->geometry.curve_size + 1}; + const int curve_size = curves->geometry.curve_size; + Span<int> offsets{curves->geometry.offsets, curves->geometry.curve_size + 1}; - Span<float3> positions{(float3 *)hair->geometry.position, hair->geometry.point_size}; + Span<float3> positions{(float3 *)curves->geometry.position, curves->geometry.point_size}; for (const int i : IndexRange(curve_size)) { const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); @@ -183,9 +183,9 @@ static void hair_batch_cache_fill_segments_proc_pos(Hair *hair, } } -static void hair_batch_cache_ensure_procedural_pos(Hair *hair, - ParticleHairCache *cache, - GPUMaterial *gpu_material) +static void curves_batch_cache_ensure_procedural_pos(Curves *curves, + ParticleHairCache *cache, + GPUMaterial *gpu_material) { if (cache->proc_point_buf == nullptr) { /* initialize vertex format */ @@ -208,7 +208,7 @@ static void hair_batch_cache_ensure_procedural_pos(Hair *hair, GPUVertBufRaw length_step; GPU_vertbuf_attr_get_raw_data(cache->proc_length_buf, length_id, &length_step); - hair_batch_cache_fill_segments_proc_pos(hair, &point_step, &length_step); + curves_batch_cache_fill_segments_proc_pos(curves, &point_step, &length_step); /* Create vbo immediately to bind to texture buffer. */ GPU_vertbuf_use(cache->proc_point_buf); @@ -227,12 +227,12 @@ static void hair_batch_cache_ensure_procedural_pos(Hair *hair, } } -static void hair_batch_cache_fill_strands_data(Hair *hair, - GPUVertBufRaw *data_step, - GPUVertBufRaw *seg_step) +static void curves_batch_cache_fill_strands_data(Curves *curves, + GPUVertBufRaw *data_step, + GPUVertBufRaw *seg_step) { - const int curve_size = hair->geometry.curve_size; - Span<int> offsets{hair->geometry.offsets, hair->geometry.curve_size + 1}; + const int curve_size = curves->geometry.curve_size; + Span<int> offsets{curves->geometry.offsets, curves->geometry.curve_size + 1}; for (const int i : IndexRange(curve_size)) { const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); @@ -242,7 +242,8 @@ static void hair_batch_cache_fill_strands_data(Hair *hair, } } -static void hair_batch_cache_ensure_procedural_strand_data(Hair *hair, ParticleHairCache *cache) +static void curves_batch_cache_ensure_procedural_strand_data(Curves *curves, + ParticleHairCache *cache) { GPUVertBufRaw data_step, seg_step; @@ -261,18 +262,18 @@ static void hair_batch_cache_ensure_procedural_strand_data(Hair *hair, ParticleH GPU_vertbuf_data_alloc(cache->proc_strand_seg_buf, cache->strands_len); GPU_vertbuf_attr_get_raw_data(cache->proc_strand_seg_buf, seg_id, &seg_step); - hair_batch_cache_fill_strands_data(hair, &data_step, &seg_step); + curves_batch_cache_fill_strands_data(curves, &data_step, &seg_step); /* Create vbo immediately to bind to texture buffer. */ GPU_vertbuf_use(cache->proc_strand_buf); - cache->strand_tex = GPU_texture_create_from_vertbuf("hair_strand", cache->proc_strand_buf); + cache->strand_tex = GPU_texture_create_from_vertbuf("curves_strand", cache->proc_strand_buf); GPU_vertbuf_use(cache->proc_strand_seg_buf); - cache->strand_seg_tex = GPU_texture_create_from_vertbuf("hair_strand_seg", + cache->strand_seg_tex = GPU_texture_create_from_vertbuf("curves_strand_seg", cache->proc_strand_seg_buf); } -static void hair_batch_cache_ensure_procedural_final_points(ParticleHairCache *cache, int subdiv) +static void curves_batch_cache_ensure_procedural_final_points(ParticleHairCache *cache, int subdiv) { /* Same format as point_tex. */ GPUVertFormat format = {0}; @@ -293,11 +294,11 @@ static void hair_batch_cache_ensure_procedural_final_points(ParticleHairCache *c cache->final[subdiv].proc_buf); } -static void hair_batch_cache_fill_segments_indices(Hair *hair, - const int res, - GPUIndexBufBuilder *elb) +static void curves_batch_cache_fill_segments_indices(Curves *curves, + const int res, + GPUIndexBufBuilder *elb) { - const int curve_size = hair->geometry.curve_size; + const int curve_size = curves->geometry.curve_size; uint curr_point = 0; @@ -309,10 +310,10 @@ static void hair_batch_cache_fill_segments_indices(Hair *hair, } } -static void hair_batch_cache_ensure_procedural_indices(Hair *hair, - ParticleHairCache *cache, - int thickness_res, - int subdiv) +static void curves_batch_cache_ensure_procedural_indices(Curves *curves, + ParticleHairCache *cache, + int thickness_res, + int subdiv) { BLI_assert(thickness_res <= MAX_THICKRES); /* Cylinder strip not currently supported. */ @@ -337,7 +338,7 @@ static void hair_batch_cache_ensure_procedural_indices(Hair *hair, GPUIndexBufBuilder elb; GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count); - hair_batch_cache_fill_segments_indices(hair, verts_per_hair, &elb); + curves_batch_cache_fill_segments_indices(curves, verts_per_hair, &elb); cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex( prim_type, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); @@ -350,9 +351,9 @@ bool hair_ensure_procedural_data(Object *object, int thickness_res) { bool need_ft_update = false; - Hair *hair = static_cast<Hair *>(object->data); + Curves *curves = static_cast<Curves *>(object->data); - HairBatchCache *cache = hair_batch_cache_get(hair); + HairBatchCache *cache = curves_batch_cache_get(curves); *r_hair_cache = &cache->hair; const int steps = 2; /* TODO: don't hard-code? */ @@ -360,29 +361,29 @@ bool hair_ensure_procedural_data(Object *object, /* Refreshed on combing and simulation. */ if ((*r_hair_cache)->proc_point_buf == nullptr) { - ensure_seg_pt_count(hair, &cache->hair); - hair_batch_cache_ensure_procedural_pos(hair, &cache->hair, gpu_material); + ensure_seg_pt_count(curves, &cache->hair); + curves_batch_cache_ensure_procedural_pos(curves, &cache->hair, gpu_material); need_ft_update = true; } /* Refreshed if active layer or custom data changes. */ if ((*r_hair_cache)->strand_tex == nullptr) { - hair_batch_cache_ensure_procedural_strand_data(hair, &cache->hair); + curves_batch_cache_ensure_procedural_strand_data(curves, &cache->hair); } /* Refreshed only on subdiv count change. */ if ((*r_hair_cache)->final[subdiv].proc_buf == nullptr) { - hair_batch_cache_ensure_procedural_final_points(&cache->hair, subdiv); + curves_batch_cache_ensure_procedural_final_points(&cache->hair, subdiv); need_ft_update = true; } if ((*r_hair_cache)->final[subdiv].proc_hairs[thickness_res - 1] == nullptr) { - hair_batch_cache_ensure_procedural_indices(hair, &cache->hair, thickness_res, subdiv); + curves_batch_cache_ensure_procedural_indices(curves, &cache->hair, thickness_res, subdiv); } return need_ft_update; } -int DRW_hair_material_count_get(Hair *hair) +int DRW_curves_material_count_get(Curves *curves) { - return max_ii(1, hair->totcol); + return max_ii(1, curves->totcol); } diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 4a8670a9ee2..56184f20f7b 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -820,6 +820,7 @@ static void draw_subdiv_edge_cb(const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int subdiv_edge_index, + const bool UNUSED(is_loose), const int UNUSED(subdiv_v1), const int UNUSED(subdiv_v2)) { diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 65afc5ed3d8..82b830f6799 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -431,7 +431,7 @@ bool DRW_object_is_flat(Object *ob, int *r_axis) OB_SURF, OB_FONT, OB_MBALL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { /* Non-meshes object cannot be considered as flat. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1249004eda0..039fae43329 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -35,11 +35,11 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_hair.h" #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_mball.h" @@ -2948,8 +2948,8 @@ void DRW_engines_register(void) BKE_gpencil_batch_cache_dirty_tag_cb = DRW_gpencil_batch_cache_dirty_tag; BKE_gpencil_batch_cache_free_cb = DRW_gpencil_batch_cache_free; - BKE_hair_batch_cache_dirty_tag_cb = DRW_hair_batch_cache_dirty_tag; - BKE_hair_batch_cache_free_cb = DRW_hair_batch_cache_free; + BKE_curves_batch_cache_dirty_tag_cb = DRW_curves_batch_cache_dirty_tag; + BKE_curves_batch_cache_free_cb = DRW_curves_batch_cache_free; BKE_pointcloud_batch_cache_dirty_tag_cb = DRW_pointcloud_batch_cache_dirty_tag; BKE_pointcloud_batch_cache_free_cb = DRW_pointcloud_batch_cache_free; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 5afb9334612..a697fd2fc96 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -35,8 +35,8 @@ #include "DNA_armature_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_light_types.h" @@ -700,8 +700,8 @@ static int acf_object_icon(bAnimListElem *ale) return ICON_OUTLINER_OB_FONT; case OB_SURF: return ICON_OUTLINER_OB_SURFACE; - case OB_HAIR: - return ICON_OUTLINER_OB_HAIR; + case OB_CURVES: + return ICON_OUTLINER_OB_CURVES; case OB_POINTCLOUD: return ICON_OUTLINER_OB_POINTCLOUD; case OB_VOLUME: @@ -2813,15 +2813,15 @@ static bAnimChannelType ACF_DSSPK = { /* Hair Expander ------------------------------------------- */ /* TODO: just get this from RNA? */ -static int acf_dshair_icon(bAnimListElem *UNUSED(ale)) +static int acf_dscurves_icon(bAnimListElem *UNUSED(ale)) { - return ICON_HAIR_DATA; + return ICON_CURVES_DATA; } /* Get the appropriate flag(s) for the setting when it is valid. */ -static int acf_dshair_setting_flag(bAnimContext *UNUSED(ac), - eAnimChannel_Settings setting, - bool *neg) +static int acf_dscurves_setting_flag(bAnimContext *UNUSED(ac), + eAnimChannel_Settings setting, + bool *neg) { /* clear extra return data first */ *neg = false; @@ -2846,22 +2846,24 @@ static int acf_dshair_setting_flag(bAnimContext *UNUSED(ac), } /* get pointer to the setting */ -static void *acf_dshair_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) +static void *acf_dscurves_setting_ptr(bAnimListElem *ale, + eAnimChannel_Settings setting, + short *type) { - Hair *hair = (Hair *)ale->data; + Curves *curves = (Curves *)ale->data; /* clear extra return data first */ *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ - return GET_ACF_FLAG_PTR(hair->flag, type); + return GET_ACF_FLAG_PTR(curves->flag, type); case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ - if (hair->adt) { - return GET_ACF_FLAG_PTR(hair->adt->flag, type); + if (curves->adt) { + return GET_ACF_FLAG_PTR(curves->adt->flag, type); } return NULL; @@ -2870,9 +2872,9 @@ static void *acf_dshair_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se } } -/* hair expander type define */ +/* Curves expander type define */ static bAnimChannelType ACF_DSHAIR = { - "Hair Expander", /* type name */ + "Curves Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ acf_generic_dataexpand_color, /* backdrop color */ @@ -2882,11 +2884,11 @@ static bAnimChannelType ACF_DSHAIR = { acf_generic_idblock_name, /* name */ acf_generic_idblock_name_prop, /* name prop */ - acf_dshair_icon, /* icon */ + acf_dscurves_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dshair_setting_flag, /* flag for setting */ - acf_dshair_setting_ptr /* pointer for setting */ + acf_dscurves_setting_flag, /* flag for setting */ + acf_dscurves_setting_ptr /* pointer for setting */ }; /* PointCloud Expander ------------------------------------------- */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index c1a09b9d21f..3307385b84a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -47,8 +47,8 @@ #include "DNA_brush_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_layer_types.h" @@ -791,10 +791,10 @@ static bAnimListElem *make_new_animlistelem(void *data, break; } case ANIMTYPE_DSHAIR: { - Hair *hair = (Hair *)data; - AnimData *adt = hair->adt; + Curves *curves = (Curves *)data; + AnimData *adt = curves->adt; - ale->flag = FILTER_HAIR_OBJD(hair); + ale->flag = FILTER_CURVES_OBJD(curves); ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; @@ -2616,16 +2616,16 @@ static size_t animdata_filter_ds_obdata( expanded = FILTER_SPK_OBJD(spk); break; } - case OB_HAIR: /* ---------- Hair ----------- */ + case OB_CURVES: /* ---------- Curves ----------- */ { - Hair *hair = (Hair *)ob->data; + Curves *curves = (Curves *)ob->data; if (ads->filterflag2 & ADS_FILTER_NOHAIR) { return 0; } type = ANIMTYPE_DSHAIR; - expanded = FILTER_HAIR_OBJD(hair); + expanded = FILTER_CURVES_OBJD(curves); break; } case OB_POINTCLOUD: /* ---------- PointCloud ----------- */ diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index fb7b6b8983a..9029c451290 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung + * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung. * This is a new part of Blender (with some old code) */ diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 4a327904ddd..e1d4b5fec73 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators and API's for creating bones */ /** \file * \ingroup edarmature + * Operators and API's for creating bones. */ #include "DNA_anim_types.h" @@ -859,14 +859,28 @@ static void updateDuplicateCustomBoneShapes(bContext *C, EditBone *dup_bone, Obj Main *bmain = CTX_data_main(C); char name_flip[MAX_ID_NAME - 2]; + /* Invert the X location */ + pchan->custom_translation[0] *= -1; + /* Invert the Y rotation */ + pchan->custom_rotation_euler[1] *= -1; + /* Invert the Z rotation */ + pchan->custom_rotation_euler[2] *= -1; + /* Skip the first two chars in the object name as those are used to store object type */ BLI_string_flip_side_name(name_flip, pchan->custom->id.name + 2, false, sizeof(name_flip)); Object *shape_ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); + /* If name_flip doesn't exist, BKE_libblock_find_name() returns pchan->custom (best match) */ + shape_ob = shape_ob == pchan->custom ? NULL : shape_ob; + if (shape_ob != NULL) { /* A flipped shape object exists, use it! */ pchan->custom = shape_ob; } + else { + /* Flip shape */ + pchan->custom_scale_xyz[0] *= -1; + } } } diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index b709980cabe..0094783e50f 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Armature EditMode tools - transforms, chain based editing, and other settings */ /** \file * \ingroup edarmature + * Armature EditMode tools - transforms, chain based editing, and other settings. */ #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 750c64d74a7..c45c6297d86 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators and API's for renaming bones both in and out of Edit Mode */ /** \file * \ingroup edarmature + * Operators and API's for renaming bones both in and out of Edit Mode. * * This file contains functions/API's for renaming bones and/or working with them. */ diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index eebe8a447f7..17d25aec198 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators for relations between bones and for transferring bones between armature objects */ /** \file * \ingroup edarmature + * Operators for relations between bones and for transferring bones between armature objects. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index f9b52eb53ed..111989f1d86 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * API's and Operators for selecting armature bones in EditMode */ /** \file * \ingroup edarmature + * API's and Operators for selecting armature bones in EditMode. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index ec5c665402b..9ef198f442c 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -15,12 +15,12 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * API's for creating vertex groups from bones - * - Interfaces with heat weighting in meshlaplacian */ /** \file * \ingroup edarmature + * API's for creating vertex groups from bones + * - Interfaces with heat weighting in meshlaplacian. */ #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 14f47a84286..b3b6c37cf61 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -12,11 +12,11 @@ * 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. - * meshlaplacian.c: Algorithms using the mesh laplacian. */ /** \file * \ingroup edarmature + * Algorithms using the mesh laplacian. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 7e7b64c7510..f024b17f1cc 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -12,12 +12,11 @@ * 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. - * - * BIF_meshlaplacian.h: Algorithms using the mesh laplacian. */ /** \file * \ingroup edarmature + * BIF_meshlaplacian.h: Algorithms using the mesh laplacian. */ #pragma once diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index cc99027c470..5db4a4b6eaa 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Pose Mode API's and Operators for Pose Mode armatures */ /** \file * \ingroup edarmature + * Pose Mode API's and Operators for Pose Mode armatures. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 466c423c27c..10ffa3fcae2 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation * All rights reserved. - * Implementation of Bone Groups operators and editing API's */ /** \file * \ingroup edarmature + * Implementation of Bone Groups operators and editing API's. */ #include <string.h> diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index c075ae390d9..fa0946ffe3d 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -41,6 +41,7 @@ #include "WM_api.h" /* XXX uses private header of file-space. */ +#include "../space_file/file_indexer.h" #include "../space_file/filelist.h" #include "ED_asset_handle.h" @@ -170,7 +171,8 @@ void AssetList::setup() "", ""); - filelist_setindexer(files, &file_indexer_asset); + const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing); + filelist_setindexer(files, use_asset_indexer ? &file_indexer_asset : &file_indexer_noop); char path[FILE_MAXDIR] = ""; if (user_library) { diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index e75e9314659..042fe5d3806 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008/2018, Blender Foundation + * The Original Code is Copyright (C) 2008-2018, Blender Foundation * This is a new part of Blender */ diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index bf414851aed..8e7a0083ded 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operator for converting Grease Pencil data to geometry */ /** \file * \ingroup edgpencil + * Operator for converting Grease Pencil data to geometry. */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c910162415d..dda36cf78d9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for editing Grease Pencil strokes. */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index 2d7497357f2..5002623fbb1 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for editing Grease Pencil strokes. */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 2023ae5fe27..2d88461fb15 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2016, Blender Foundation * This is a new part of Blender - * Operators for interpolating new Grease Pencil frames from existing strokes */ /** \file * \ingroup edgpencil + * Operators for interpolating new Grease Pencil frames from existing strokes. */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 925c2e1cd7f..884167d7496 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2019, Blender Foundation. * This is a new part of Blender - * Operators for merge Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for merge Grease Pencil strokes. */ #include <stdio.h> diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c index efe29e852f2..adf76e79c2a 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.c +++ b/source/blender/editors/gpencil/gpencil_mesh.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operator for converting Grease Pencil data to geometry */ /** \file * \ingroup edgpencil + * Operator for converting Grease Pencil data to geometry. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c index 45842c28dff..d9706c281ca 100644 --- a/source/blender/editors/gpencil/gpencil_ops_versioning.c +++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2018, Blender Foundation, * This is a new part of Blender - * Use deprecated data to convert old 2.7x files */ /** \file * \ingroup edgpencil + * Use deprecated data to convert old 2.7x files. */ /* Allow using deprecated functionality. */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 2715491414a..fa31dfffbc1 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2017, Blender Foundation * This is a new part of Blender - * Operators for creating new Grease Pencil primitives (boxes, circles, ...) */ /** \file * \ingroup edgpencil + * Operators for creating new Grease Pencil primitives (boxes, circles, ...). */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 29f34cc2d67..66b7f260f28 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include <math.h> diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil/gpencil_vertex_ops.c index 891bd3ca5ec..d9f4cc87afc 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_ops.c +++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c index 05304f9914f..2c16894354e 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c index 15f99d83f6d..fe4ab648581 100644 --- a/source/blender/editors/gpencil/gpencil_weight_paint.c +++ b/source/blender/editors/gpencil/gpencil_weight_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 3294316f880..04a892ab411 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -378,7 +378,7 @@ typedef enum eAnimFilter_Flags { #define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh *), ((me->flag & ME_DS_EXPAND))) #define FILTER_LATTICE_OBJD(lt) (CHECK_TYPE_INLINE(lt, Lattice *), ((lt->flag & LT_DS_EXPAND))) #define FILTER_SPK_OBJD(spk) (CHECK_TYPE_INLINE(spk, Speaker *), ((spk->flag & SPK_DS_EXPAND))) -#define FILTER_HAIR_OBJD(ha) (CHECK_TYPE_INLINE(ha, Hair *), ((ha->flag & HA_DS_EXPAND))) +#define FILTER_CURVES_OBJD(ha) (CHECK_TYPE_INLINE(ha, Curves *), ((ha->flag & HA_DS_EXPAND))) #define FILTER_POINTS_OBJD(pt) (CHECK_TYPE_INLINE(pt, PointCloud *), ((pt->flag & PT_DS_EXPAND))) #define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND))) #define FILTER_SIMULATION_OBJD(sim) \ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 8d89555c732..22a6bdb27ba 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -14,7 +14,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation - * This is a new part of Blender (with some old code) */ /** \file diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 4cf606bf98d..05353de2f92 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -752,9 +752,9 @@ DEF_ICON_BLANK(257) DEF_ICON_BLANK(257b) /* ADDITIONAL OBJECT TYPES */ -DEF_ICON_OBJECT(OUTLINER_OB_HAIR) -DEF_ICON_OBJECT_DATA(OUTLINER_DATA_HAIR) -DEF_ICON_OBJECT_DATA(HAIR_DATA) +DEF_ICON_OBJECT(OUTLINER_OB_CURVES) +DEF_ICON_OBJECT_DATA(OUTLINER_DATA_CURVES) +DEF_ICON_OBJECT_DATA(CURVES_DATA) DEF_ICON_OBJECT(OUTLINER_OB_POINTCLOUD) DEF_ICON_OBJECT_DATA(OUTLINER_DATA_POINTCLOUD) DEF_ICON_OBJECT_DATA(POINTCLOUD_DATA) @@ -840,7 +840,7 @@ DEF_ICON(MATPLANE) DEF_ICON(MATSPHERE) DEF_ICON(MATCUBE) DEF_ICON(MONKEY) -DEF_ICON(HAIR) +DEF_ICON(CURVES) DEF_ICON(ALIASED) DEF_ICON(ANTIALIASED) DEF_ICON(MAT_SPHERE_SKY) diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index a3f39e1286e..0a28b1cafe1 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -15,12 +15,12 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * Generic 2d view with should allow drawing grids, - * panning, zooming, scrolling, .. */ /** \file * \ingroup editorui + * Generic 2D view with should allow drawing grids, + * panning, zooming, scrolling, .. etc. */ #pragma once diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c0d6b8a1a6c..d7d3288a68d 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2335,8 +2335,8 @@ int UI_icon_from_idcode(const int idcode) return ICON_TEXT; case ID_VF: return ICON_FONT_DATA; - case ID_HA: - return ICON_HAIR_DATA; + case ID_CV: + return ICON_CURVES_DATA; case ID_PT: return ICON_POINTCLOUD_DATA; case ID_VO: diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d605847c270..03d0cba5ec8 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -667,6 +667,13 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* Assign new pointer, takes care of updates/notifiers */ RNA_id_pointer_create(override_id, &idptr); + /* Insert into override hierarchy if possible. */ + ID *owner_id = template_ui->ptr.owner_id; + if (owner_id != NULL && ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) { + override_id->override_library->hierarchy_root = + owner_id->override_library->hierarchy_root; + owner_id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY; + } } undo_push_label = "Make Library Override"; } @@ -792,8 +799,8 @@ static const char *template_id_browse_tip(const StructRNA *type) return N_("Browse Workspace to be linked"); case ID_LP: return N_("Browse LightProbe to be linked"); - case ID_HA: - return N_("Browse Hair Data to be linked"); + case ID_CV: + return N_("Browse Hair Curves Data to be linked"); case ID_PT: return N_("Browse Point Cloud Data to be linked"); case ID_VO: @@ -874,7 +881,7 @@ static uiBut *template_id_def_new_but(uiBlock *block, BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, BLT_I18NCONTEXT_ID_WORKSPACE, BLT_I18NCONTEXT_ID_LIGHTPROBE, - BLT_I18NCONTEXT_ID_HAIR, + BLT_I18NCONTEXT_ID_CURVES, BLT_I18NCONTEXT_ID_POINTCLOUD, BLT_I18NCONTEXT_ID_VOLUME, BLT_I18NCONTEXT_ID_SIMULATION, ); diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index 949b12f9a65..5ea3c0d7b32 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -68,6 +68,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMVERT_FACE, "FACE", 0, "Amount of Adjacent Faces", ""}, {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, {SIMVERT_EDGE, "EDGE", 0, "Amount of Connecting Edges", ""}, + {SIMVERT_CREASE, "VCREASE", 0, "Vertex Crease", ""}, {SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""}, {SIMEDGE_DIR, "DIR", 0, "Direction", ""}, @@ -1009,12 +1010,16 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } KDTree_3d *tree_3d = NULL; + KDTree_1d *tree_1d = NULL; GSet *gset = NULL; switch (type) { case SIMVERT_NORMAL: tree_3d = BLI_kdtree_3d_new(tot_verts_selected_all); break; + case SIMVERT_CREASE: + tree_1d = BLI_kdtree_1d_new(tot_verts_selected_all); + break; case SIMVERT_EDGE: case SIMVERT_FACE: gset = BLI_gset_ptr_new("Select similar vertex: edge/face"); @@ -1025,6 +1030,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } int normal_tree_index = 0; + int tree_1d_index = 0; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(ob); @@ -1050,6 +1056,12 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } defbase_selected = BLI_BITMAP_NEW(defbase_len, __func__); } + else if (type == SIMVERT_CREASE) { + if (!CustomData_has_layer(&bm->vdata, CD_CREASE)) { + BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, (float[1]){0.0f}); + continue; + } + } BMVert *vert; /* Mesh vertex. */ BMIter iter; /* Selected verts iterator. */ @@ -1085,6 +1097,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } break; } + case SIMVERT_CREASE: { + const float *value = CustomData_bmesh_get(&bm->vdata, vert->head.data, CD_CREASE); + BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, value); + break; + } } } } @@ -1113,6 +1130,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } /* Remove duplicated entries. */ + if (tree_1d != NULL) { + BLI_kdtree_1d_deduplicate(tree_1d); + BLI_kdtree_1d_balance(tree_1d); + } if (tree_3d != NULL) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); @@ -1124,6 +1145,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; bool changed = false; + bool has_crease_layer = false; int cd_dvert_offset = -1; BLI_bitmap *defbase_selected = NULL; int defbase_len = 0; @@ -1158,6 +1180,17 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) continue; } } + else if (type == SIMVERT_CREASE) { + has_crease_layer = CustomData_has_layer(&bm->vdata, CD_CREASE); + if (!has_crease_layer) { + /* Proceed only if we have to select all the vertices that have custom data value of 0.0f. + * In this case we will just select all the vertices. + * Otherwise continue the for loop. */ + if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, compare)) { + continue; + } + } + } BMVert *vert; /* Mesh vertex. */ BMIter iter; /* Selected verts iterator. */ @@ -1224,6 +1257,17 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } break; } + case SIMVERT_CREASE: { + if (!has_crease_layer) { + select = true; + break; + } + const float *value = CustomData_bmesh_get(&bm->vdata, vert->head.data, CD_CREASE); + if (ED_select_similar_compare_float_tree(tree_1d, *value, thresh, compare)) { + select = true; + } + break; + } } if (select) { @@ -1249,6 +1293,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } MEM_freeN(objects); + BLI_kdtree_1d_free(tree_1d); BLI_kdtree_3d_free(tree_3d); if (gset != NULL) { BLI_gset_free(gset, NULL); diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index a953c7d7f89..df76e605ebb 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -88,7 +88,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() blender_add_lib(bf_editor_object "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0f1b0f5bdc0..d1deb6824ea 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -62,6 +62,7 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_duplilist.h" #include "BKE_effect.h" @@ -69,7 +70,6 @@ #include "BKE_gpencil_curve.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_layer.h" @@ -1894,18 +1894,18 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Add Hair Operator +/** \name Add Hair Curves Operator * \{ */ -static bool object_hair_add_poll(bContext *C) +static bool object_hair_curves_add_poll(bContext *C) { - if (!U.experimental.use_new_hair_type) { + if (!U.experimental.use_new_curves_type) { return false; } return ED_operator_objectmode(C); } -static int object_hair_add_exec(bContext *C, wmOperator *op) +static int object_hair_curves_add_exec(bContext *C, wmOperator *op) { ushort local_view_bits; float loc[3], rot[3]; @@ -1913,22 +1913,22 @@ static int object_hair_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Object *object = ED_object_add_type(C, OB_HAIR, NULL, loc, rot, false, local_view_bits); + Object *object = ED_object_add_type(C, OB_CURVES, NULL, loc, rot, false, local_view_bits); object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */ return OPERATOR_FINISHED; } -void OBJECT_OT_hair_add(wmOperatorType *ot) +void OBJECT_OT_hair_curves_add(wmOperatorType *ot) { /* identifiers */ - ot->name = "Add Hair"; - ot->description = "Add a hair object to the scene"; - ot->idname = "OBJECT_OT_hair_add"; + ot->name = "Add Hair Curves"; + ot->description = "Add a hair curves object to the scene"; + ot->idname = "OBJECT_OT_hair_curves_add"; /* api callbacks */ - ot->exec = object_hair_add_exec; - ot->poll = object_hair_add_poll; + ot->exec = object_hair_curves_add_exec; + ot->poll = object_hair_curves_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index f478f5004d4..ddd44fb9ded 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -129,7 +129,7 @@ void OBJECT_OT_light_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); void OBJECT_OT_camera_add(struct wmOperatorType *ot); void OBJECT_OT_speaker_add(struct wmOperatorType *ot); -void OBJECT_OT_hair_add(struct wmOperatorType *ot); +void OBJECT_OT_hair_curves_add(struct wmOperatorType *ot); void OBJECT_OT_pointcloud_add(struct wmOperatorType *ot); /** * Only used as menu. diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 775fac96d57..af428512cfd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -53,12 +53,12 @@ #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_lib_id.h" @@ -132,8 +132,8 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object * else if (ob->type == OB_GPENCIL) { BKE_gpencil_modifiers_calc(depsgraph, scene_eval, ob_eval); } - else if (ob->type == OB_HAIR) { - BKE_hair_data_update(depsgraph, scene_eval, ob); + else if (ob->type == OB_CURVES) { + BKE_curves_data_update(depsgraph, scene_eval, ob); } else if (ob->type == OB_POINTCLOUD) { BKE_pointcloud_data_update(depsgraph, scene_eval, ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 03a36006fea..a9a429e7e6f 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -105,7 +105,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_light_add); WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_speaker_add); - WM_operatortype_append(OBJECT_OT_hair_add); + WM_operatortype_append(OBJECT_OT_hair_curves_add); WM_operatortype_append(OBJECT_OT_pointcloud_add); WM_operatortype_append(OBJECT_OT_volume_add); WM_operatortype_append(OBJECT_OT_volume_import); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 57a0fe0a39d..8678bf9bd92 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -63,11 +63,11 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_fcurve.h" #include "BKE_gpencil.h" -#include "BKE_hair.h" #include "BKE_idprop.h" #include "BKE_idtype.h" #include "BKE_lattice.h" @@ -1872,7 +1872,7 @@ static void single_obdata_users( ob->data, BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; - case OB_HAIR: + case OB_CURVES: ob->data = ID_NEW_SET( ob->data, BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index c4ce8bac126..fb6742c9fd5 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -635,7 +635,7 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data) case ID_MC: /* MovieClip */ case ID_MSK: /* Mask */ case ID_LP: /* LightProbe */ - case ID_HA: /* Hair */ + case ID_CV: /* Curves */ case ID_PT: /* PointCloud */ case ID_VO: /* Volume */ case ID_SIM: /* Simulation */ diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 4bc9f1e2565..2b16b70d1ef 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Making screendumps. */ /** \file * \ingroup edscr + * Making screenshots of the entire window or sub-regions. */ #include <errno.h> diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index da627c6b7db..805d2221f6f 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2010 by Nicholas Bishop * All rights reserved. - * Implements the PBVH node hiding operator */ /** \file * \ingroup edsculpt + * Implements the PBVH node hiding operator. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a912bb5cf3b..d5aa7647603 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -14,8 +14,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index f05cd4c3d5f..4d23119dd5f 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -14,8 +14,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 07e26a3d931..ea3d694542c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c index c2acc361a79..0d2c5641183 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 119d246a770..f50775f8a32 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 8819496c168..0b64d1f8a35 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include <stddef.h> diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index e5ca5e4defd..35ad582d4ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -13,13 +13,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) Blender Foundation, 2002-2009 + * The Original Code is Copyright (C) 2002-2009, Blender Foundation * All rights reserved. - * UV Sculpt tools */ /** \file * \ingroup edsculpt + * UV Sculpt tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index f8adba30547..b786cada908 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) Blender Foundation, 2008 + * The Original Code is Copyright (C) 2008, Blender Foundation */ /** \file diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index e2b2579c256..14cc03e3120 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -48,7 +48,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f5107cb13fd..b83396b10d9 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -273,8 +273,8 @@ static bool buttons_context_path_data(ButsContextPath *path, int type) if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (ELEM(type, -1, OB_GPENCIL))) { return true; } -#ifdef WITH_HAIR_NODES - if (RNA_struct_is_a(ptr->type, &RNA_Hair) && (ELEM(type, -1, OB_HAIR))) { +#ifdef WITH_NEW_CURVES_TYPE + if (RNA_struct_is_a(ptr->type, &RNA_Curves) && (ELEM(type, -1, OB_CURVES))) { return true; } #endif @@ -314,7 +314,7 @@ static bool buttons_context_path_modifier(ButsContextPath *path) OB_SURF, OB_LATTICE, OB_GPENCIL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { ModifierData *md = BKE_object_active_modifier(ob); @@ -845,8 +845,8 @@ const char *buttons_context_dir[] = { "line_style", "collection", "gpencil", -#ifdef WITH_HAIR_NODES - "hair", +#ifdef WITH_NEW_CURVES_TYPE + "curves", #endif #ifdef WITH_POINT_CLOUD "pointcloud", @@ -941,9 +941,9 @@ int /*eContextResult*/ buttons_context(const bContext *C, set_pointer_type(path, result, &RNA_LightProbe); return CTX_RESULT_OK; } -#ifdef WITH_HAIR_NODES - if (CTX_data_equals(member, "hair")) { - set_pointer_type(path, result, &RNA_Hair); +#ifdef WITH_NEW_CURVES_TYPE + if (CTX_data_equals(member, "curves")) { + set_pointer_type(path, result, &RNA_Curves); return CTX_RESULT_OK; } #endif diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 044d7aba88f..6be17bbd355 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2783,7 +2783,8 @@ int ED_path_extension_type(const char *path) NULL)) { return FILE_TYPE_TEXT; } - if (BLI_path_extension_check_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) { + if (BLI_path_extension_check_n( + path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", NULL)) { return FILE_TYPE_FTFONT; } if (BLI_path_extension_check(path, ".btx")) { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0a69d0f9b39..e95e3bef8a8 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -790,7 +790,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) } /* Get mounted volumes better method OSX 10.6 and higher, see: - * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html + * https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html */ /* We get all volumes sorted including network and do not relay diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 005ae0214cd..a1eacc2bc3a 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -219,7 +219,7 @@ static void stats_object(Object *ob, } break; } - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: { break; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 1376dade659..28041c0389f 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1397,8 +1397,11 @@ static void nlaedit_split_strip_actclip( nstrip->actstart = splitaframe; } - /* clear the active flag from the copy */ - nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE; + /* Make sure Sync Length is off. With that setting on, entering and exiting tweak mode would + * effectively undo the split, because both the old and the new strip will be at the length of + * the Action again. */ + strip->flag &= ~NLASTRIP_FLAG_SYNC_LENGTH; + nstrip->flag &= ~(NLASTRIP_FLAG_SYNC_LENGTH | NLASTRIP_FLAG_ACTIVE); /* auto-name the new strip */ BKE_nlastrip_validate_name(adt, nstrip); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 94da7d55e5d..30f2cc970bd 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -231,7 +231,6 @@ static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt NodeResizeDirection node_get_resize_direction(const bNode *node, const int x, const int y) { if (node->type == NODE_FRAME) { - const float size = 10.0f; NodeFrame *data = (NodeFrame *)node->storage; /* shrinking frame size is determined by child nodes */ @@ -242,7 +241,9 @@ NodeResizeDirection node_get_resize_direction(const bNode *node, const int x, co NodeResizeDirection dir = NODE_RESIZE_NONE; const rctf &totr = node->totr; - if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { + const float size = NODE_RESIZE_MARGIN; + + if (x > totr.xmax - size && x <= totr.xmax && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_RIGHT; } if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 834bb3e5802..e290316af1f 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -397,7 +397,7 @@ static void node_update_basis(const bContext &C, bNodeTree &ntree, bNode &node, /* Round the socket location to stop it from jiggling. */ nsock->locx = round(loc.x + NODE_WIDTH(node)); - nsock->locy = round(0.5f * (dy + buty)); + nsock->locy = round(dy - NODE_DYS); dy = buty; if (nsock->next) { @@ -527,7 +527,7 @@ static void node_update_basis(const bContext &C, bNodeTree &ntree, bNode &node, nsock->locx = loc.x; /* Round the socket vertical position to stop it from jiggling. */ - nsock->locy = round(0.5f * (dy + buty)); + nsock->locy = round(dy - NODE_DYS); dy = buty - multi_input_socket_offset * 0.5; if (nsock->next) { @@ -626,7 +626,9 @@ static void node_update_hidden(bNode &node, uiBlock &block) static int node_get_colorid(const bNode &node) { - switch (node.typeinfo->nclass) { + const int nclass = (node.typeinfo->ui_class == nullptr) ? node.typeinfo->nclass : + node.typeinfo->ui_class(&node); + switch (nclass) { case NODE_CLASS_INPUT: return TH_NODE_INPUT; case NODE_CLASS_OUTPUT: @@ -2270,6 +2272,13 @@ void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor) if (node) { NodeResizeDirection dir = node_get_resize_direction(node, cursor[0], cursor[1]); wmcursor = node_get_resize_cursor(dir); + /* We want to indicate that Frame nodes can be moved/selected on their borders. */ + if (node->type == NODE_FRAME && dir == NODE_RESIZE_NONE) { + const rctf frame_inside = node_frame_rect_inside(*node); + if (!BLI_rctf_isect_pt(&frame_inside, cursor[0], cursor[1])) { + wmcursor = WM_CURSOR_NSEW_SCROLL; + } + } } WM_cursor_set(&win, wmcursor); diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 6275e7e4656..aa27edd77a7 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -394,7 +394,7 @@ static void send_notifiers_after_tree_change(ID *id, bNodeTree *ntree) { WM_main_add_notifier(NC_NODE | NA_EDITED, nullptr); - if (ntree->type == NTREE_SHADER) { + if (ntree->type == NTREE_SHADER && id != nullptr) { if (GS(id->name) == ID_MA) { WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); } @@ -667,6 +667,7 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; if (!was_output) { do_update = true; + BKE_ntree_update_tag_active_output_changed(ntree); } } @@ -684,6 +685,7 @@ void ED_node_set_active( } node->flag |= NODE_DO_OUTPUT; + BKE_ntree_update_tag_active_output_changed(ntree); } ED_node_tree_propagate_change(nullptr, bmain, ntree); @@ -750,6 +752,7 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; if (was_output == 0) { + BKE_ntree_update_tag_active_output_changed(ntree); ED_node_tree_propagate_change(nullptr, bmain, ntree); } @@ -765,6 +768,7 @@ void ED_node_set_active( } node->flag |= NODE_DO_OUTPUT; + BKE_ntree_update_tag_active_output_changed(ntree); ED_node_tree_propagate_change(nullptr, bmain, ntree); } } diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index f6397baf9f2..51825f5bd39 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -130,6 +130,8 @@ ENUM_OPERATORS(NodeResizeDirection, NODE_RESIZE_LEFT); */ float2 space_node_group_offset(const SpaceNode &snode); +rctf node_frame_rect_inside(const bNode &node); + int node_get_resize_cursor(NodeResizeDirection directions); /** * Usual convention here would be #node_socket_get_color(), diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index fd9420b173d..d92f86c2cfc 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -365,10 +365,7 @@ void sort_multi_input_socket_links(SpaceNode &snode, } } -static void snode_autoconnect(Main &bmain, - SpaceNode &snode, - const bool allow_multiple, - const bool replace) +static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const bool replace) { bNodeTree *ntree = snode.edittree; Vector<bNode *> sorted_nodes; @@ -441,10 +438,6 @@ static void snode_autoconnect(Main &bmain, } } } - - if (numlinks > 0) { - BKE_ntree_update_main_tree(&bmain, ntree, nullptr); - } } /** \} */ @@ -1304,13 +1297,13 @@ static int node_make_link_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), &bmain); - snode_autoconnect(bmain, snode, true, replace); + snode_autoconnect(snode, true, replace); /* deselect sockets after linking */ node_deselect_all_input_sockets(snode, false); node_deselect_all_output_sockets(snode, false); - ED_node_tree_propagate_change(C, CTX_data_main(C), snode.edittree); + ED_node_tree_propagate_change(C, &bmain, snode.edittree); return OPERATOR_FINISHED; } @@ -2435,54 +2428,73 @@ void ED_node_link_insert(Main *bmain, ScrArea *area) { using namespace blender::ed::space_node; - bNode *select; + bNode *node_to_insert; SpaceNode *snode; - if (!ed_node_link_conditions(area, true, &snode, &select)) { + if (!ed_node_link_conditions(area, true, &snode, &node_to_insert)) { return; } - /* get the link */ - bNodeLink *link; - for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) { + /* Find link to insert on. */ + bNodeTree &ntree = *snode->edittree; + bNodeLink *old_link = nullptr; + LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) { if (link->flag & NODE_LINKFLAG_HILITE) { + old_link = link; break; } } + if (old_link == nullptr) { + return; + } - if (link) { - bNodeSocket *best_input = get_main_socket(*snode->edittree, *select, SOCK_IN); - bNodeSocket *best_output = get_main_socket(*snode->edittree, *select, SOCK_OUT); + old_link->flag &= ~NODE_LINKFLAG_HILITE; - if (best_input && best_output) { - bNode *node = link->tonode; - bNodeSocket *sockto = link->tosock; + bNodeSocket *best_input = get_main_socket(ntree, *node_to_insert, SOCK_IN); + bNodeSocket *best_output = get_main_socket(ntree, *node_to_insert, SOCK_OUT); - link->tonode = select; - link->tosock = best_input; - node_remove_extra_links(*snode, *link); - link->flag &= ~NODE_LINKFLAG_HILITE; + /* Ignore main sockets when the types don't match. */ + if (best_input != nullptr && ntree.typeinfo->validate_link != nullptr && + !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(old_link->fromsock->type), + static_cast<eNodeSocketDatatype>(best_input->type))) { + best_input = nullptr; + } + if (best_output != nullptr && ntree.typeinfo->validate_link != nullptr && + !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(best_output->type), + static_cast<eNodeSocketDatatype>(old_link->tosock->type))) { + best_output = nullptr; + } - bNodeLink *new_link = nodeAddLink(snode->edittree, select, best_output, node, sockto); + bNode *from_node = old_link->fromnode; + bNodeSocket *from_socket = old_link->fromsock; + bNode *to_node = old_link->tonode; - /* Copy the socket index for the new link, and reset it for the old link. This way the - * relative order of links is preserved, and the links get drawn in the right place. */ - new_link->multi_input_socket_index = link->multi_input_socket_index; - link->multi_input_socket_index = 0; + if (best_output != nullptr) { + /* Relink the "start" of the existing link to the newly inserted node. */ + old_link->fromnode = node_to_insert; + old_link->fromsock = best_output; + BKE_ntree_update_tag_link_changed(&ntree); + } + else { + nodeRemLink(&ntree, old_link); + } - /* set up insert offset data, it needs stuff from here */ - if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { - NodeInsertOfsData *iofsd = MEM_cnew<NodeInsertOfsData>(__func__); + if (best_input != nullptr) { + /* Add a new link that connects the node on the left to the newly inserted node. */ + nodeAddLink(&ntree, from_node, from_socket, node_to_insert, best_input); + } - iofsd->insert = select; - iofsd->prev = link->fromnode; - iofsd->next = node; + /* Set up insert offset data, it needs stuff from here. */ + if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { + NodeInsertOfsData *iofsd = MEM_cnew<NodeInsertOfsData>(__func__); - snode->runtime->iofsd = iofsd; - } + iofsd->insert = node_to_insert; + iofsd->prev = from_node; + iofsd->next = to_node; - ED_node_tree_propagate_change(nullptr, bmain, snode->edittree); - } + snode->runtime->iofsd = iofsd; } + + ED_node_tree_propagate_change(nullptr, bmain, snode->edittree); } /** \} */ diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index 2751a53e8af..6b0fa2cc37c 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -99,11 +99,51 @@ static bool has_workbench_in_texture_color(const wmWindowManager *wm, /** \name Public Node Selection API * \{ */ +rctf node_frame_rect_inside(const bNode &node) +{ + const float margin = 1.5f * U.widget_unit; + rctf frame_inside = { + node.totr.xmin, + node.totr.xmax, + node.totr.ymin, + node.totr.ymax, + }; + + BLI_rctf_pad(&frame_inside, -margin, -margin); + + return frame_inside; +} + +static bool node_frame_select_isect_mouse(bNode *node, const float2 &mouse) +{ + /* Frame nodes are selectable by their borders (including their whole rect - as for other nodes - + * would prevent e.g. box selection of nodes inside that frame). */ + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y) && + !BLI_rctf_isect_pt(&frame_inside, mouse.x, mouse.y)) { + return true; + } + + return false; +} + static bNode *node_under_mouse_select(bNodeTree &ntree, int mx, int my) { LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) { - if (BLI_rctf_isect_pt(&node->totr, mx, my)) { - return node; + switch (node->type) { + case NODE_FRAME: { + const float2 mouse{(float)mx, (float)my}; + if (node_frame_select_isect_mouse(node, mouse)) { + return node; + } + break; + } + default: { + if (BLI_rctf_isect_pt(&node->totr, mx, my)) { + return node; + } + break; + } } } return nullptr; @@ -114,15 +154,27 @@ static bNode *node_under_mouse_tweak(bNodeTree &ntree, const float2 &mouse) using namespace blender::math; LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) { - if (node->type == NODE_REROUTE) { - bNodeSocket *socket = (bNodeSocket *)node->inputs.first; - const float2 location{socket->locx, socket->locy}; - if (distance(mouse, location) < 24.0f) { - return node; + switch (node->type) { + case NODE_REROUTE: { + bNodeSocket *socket = (bNodeSocket *)node->inputs.first; + const float2 location{socket->locx, socket->locy}; + if (distance(mouse, location) < 24.0f) { + return node; + } + break; + } + case NODE_FRAME: { + if (node_frame_select_isect_mouse(node, mouse)) { + return node; + } + break; + } + default: { + if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y)) { + return node; + } + break; } - } - if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y)) { - return node; } } return nullptr; @@ -687,12 +739,24 @@ static int node_box_select_exec(bContext *C, wmOperator *op) } LISTBASE_FOREACH (bNode *, node, &node_tree.nodes) { - bool is_inside; - if (node->type == NODE_FRAME) { - is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr); - } - else { - is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr); + bool is_inside = false; + + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of other nodes inside that frame. */ + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect(&rectf, &node->totr, NULL) && + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + nodeSetSelected(node, select); + is_inside = true; + } + break; + } + default: { + is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr); + break; + } } if (is_inside) { @@ -781,8 +845,25 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(®ion->v2d, x, y, &offset[0], &offset[1]); for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) { - if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { - nodeSetSelected(node, select); + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of _only_ other nodes inside that frame. */ + rctf frame_inside = node_frame_rect_inside(*node); + const float radius_adjusted = (float)radius / zoom; + BLI_rctf_pad(&frame_inside, -2.0f * radius_adjusted, -2.0f * radius_adjusted); + if (BLI_rctf_isect_circle(&node->totr, offset, radius_adjusted) && + !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted)) { + nodeSetSelected(node, select); + } + break; + } + default: { + if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { + nodeSetSelected(node, select); + } + break; + } } } @@ -859,16 +940,35 @@ static bool do_lasso_select_node(bContext *C, continue; } - int screen_co[2]; - const float cent[2] = {BLI_rctf_cent_x(&node->totr), BLI_rctf_cent_y(&node->totr)}; - - /* marker in screen coords */ - if (UI_view2d_view_to_region_clip( - ®ion->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) && - BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && - BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) { - nodeSetSelected(node, select); - changed = true; + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of other nodes inside that frame. */ + rctf rectf; + BLI_rctf_rcti_copy(&rectf, &rect); + UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf); + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect(&rectf, &node->totr, NULL) && + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + nodeSetSelected(node, select); + changed = true; + } + break; + } + default: { + int screen_co[2]; + const float cent[2] = {BLI_rctf_cent_x(&node->totr), BLI_rctf_cent_y(&node->totr)}; + + /* marker in screen coords */ + if (UI_view2d_view_to_region_clip( + ®ion->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) && + BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && + BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) { + nodeSetSelected(node, select); + changed = true; + } + break; + } } } diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 259fdd4e009..13c273d1ec9 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -2632,8 +2632,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case OB_LIGHTPROBE: data.icon = ICON_OUTLINER_OB_LIGHTPROBE; break; - case OB_HAIR: - data.icon = ICON_OUTLINER_OB_HAIR; + case OB_CURVES: + data.icon = ICON_OUTLINER_OB_CURVES; break; case OB_POINTCLOUD: data.icon = ICON_OUTLINER_OB_POINTCLOUD; @@ -2746,8 +2746,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case ID_GR: data.icon = ICON_OUTLINER_COLLECTION; break; - case ID_HA: - data.icon = ICON_OUTLINER_DATA_HAIR; + case ID_CV: + data.icon = ICON_OUTLINER_DATA_CURVES; break; case ID_PT: data.icon = ICON_OUTLINER_DATA_POINTCLOUD; diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index bd288241a63..efbd8a32716 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -145,7 +145,7 @@ typedef struct TreeElementIcon { ID_GD, \ ID_LS, \ ID_LP, \ - ID_HA, \ + ID_CV, \ ID_PT, \ ID_VO, \ ID_SIM) || /* Only in 'blendfile' mode ... :/ */ \ diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index ebb4e529b04..f256475c0da 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -1198,7 +1198,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE case ID_AR: case ID_GD: case ID_LP: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: context = BCONTEXT_DATA; diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 3b8c284cd65..337649834a4 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -29,8 +29,8 @@ #include "DNA_armature_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_light_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -164,7 +164,7 @@ static void get_element_operation_type( case ID_CF: case ID_WS: case ID_LP: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_SIM: @@ -262,10 +262,10 @@ static void unlink_material_fn(bContext *UNUSED(C), totcol = mb->totcol; matar = mb->mat; } - else if (GS(tsep->id->name) == ID_HA) { - Hair *hair = (Hair *)tsep->id; - totcol = hair->totcol; - matar = hair->mat; + else if (GS(tsep->id->name) == ID_CV) { + Curves *curves = (Curves *)tsep->id; + totcol = curves->totcol; + matar = curves->mat; } else if (GS(tsep->id->name) == ID_PT) { PointCloud *pointcloud = (PointCloud *)tsep->id; diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 4e16fe64988..60f5437ad88 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -32,9 +32,9 @@ #include "DNA_camera_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_light_types.h" #include "DNA_lightprobe_types.h" @@ -773,10 +773,10 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, } break; } - case ID_HA: { - Hair *hair = (Hair *)id; - if (outliner_animdata_test(hair->adt)) { - outliner_add_element(space_outliner, &te->subtree, hair, te, TSE_ANIM_DATA, 0); + case ID_CV: { + Curves *curves = (Curves *)id; + if (outliner_animdata_test(curves->adt)) { + outliner_add_element(space_outliner, &te->subtree, curves, te, TSE_ANIM_DATA, 0); } break; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index afbbd171cf4..3289cb8ac76 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -69,7 +69,7 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t case ID_LP: case ID_GD: case ID_WS: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_SIM: diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index aef6b30986d..439a37631e0 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -632,7 +632,7 @@ static void sequencer_add_movie_clamp_sound_strip_length(Scene *scene, Sequence *seq_movie, Sequence *seq_sound) { - if (ELEM(NULL, seq_movie, seq_sound) || seq_sound->len <= seq_movie->len) { + if (ELEM(NULL, seq_movie, seq_sound)) { return; } diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 5d857f62b47..fd341fc9c0d 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Author: Peter Schlaile < peter [at] schlaile [dot] de > + * Copyright 2006-2008 Peter Schlaile < peter [at] schlaile [dot] de > */ /** \file diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 243d4033cbc..6edb0a070c0 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1764,7 +1764,8 @@ static void view3d_panel_transform(const bContext *C, Panel *panel) v3d_transform_butsR(col, &obptr); /* Dimensions and editmode are mostly the same check. */ - if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_HAIR, OB_POINTCLOUD)) { + if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || + ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) { View3D *v3d = CTX_wm_view3d(C); v3d_object_dimension_buts(NULL, col, v3d, ob); } diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp index 95a24d85677..c917e9c87fd 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.cpp +++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp @@ -15,14 +15,7 @@ * * The Original Code is: * GXML/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy <levy@loria.fr> */ /** \file diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h index 8c2eb799d13..147e25e9608 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.h +++ b/source/blender/freestyle/intern/geometry/matrix_util.h @@ -15,14 +15,7 @@ * * The Original Code is: * GXML/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy <levy@loria.fr> */ #pragma once diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.cpp b/source/blender/freestyle/intern/geometry/normal_cycle.cpp index 77a80e63b77..fbcbeb220df 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.cpp +++ b/source/blender/freestyle/intern/geometry/normal_cycle.cpp @@ -15,14 +15,7 @@ * * The Original Code is: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy <levy@loria.fr> */ /** \file diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h index 949675e9d8d..1fb59bcad19 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.h +++ b/source/blender/freestyle/intern/geometry/normal_cycle.h @@ -15,14 +15,7 @@ * * The Original Code is: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy <levy@loria.fr> */ #pragma once diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp index ec07a124808..571f21ac309 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp +++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp @@ -18,13 +18,7 @@ * Copyright (C) 1999 Stephane Popinet * and: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000-2003 Bruno Levy - * Contact: Bruno Levy <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000-2003 Bruno Levy <levy@loria.fr> */ /** \file diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.h b/source/blender/freestyle/intern/winged_edge/Curvature.h index acbe4e8daf6..c87134a0c14 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.h +++ b/source/blender/freestyle/intern/winged_edge/Curvature.h @@ -15,16 +15,10 @@ * * The Original Code is: * GTS - Library for the manipulation of triangulated surfaces - * Copyright (C) 1999 Stephane Popinet + * Copyright 1999 Stephane Popinet * and: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000-2003 Bruno Levy - * Contact: Bruno Levy <levy@loria.fr> - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright (C) 2000-2003 Bruno Levy <levy@loria.fr> */ #pragma once diff --git a/source/blender/geometry/CMakeLists.txt b/source/blender/geometry/CMakeLists.txt index f7ddd393b4d..110092e4f5f 100644 --- a/source/blender/geometry/CMakeLists.txt +++ b/source/blender/geometry/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# The Original Code is Copyright (C) 2006, Blender Foundation +# The Original Code is Copyright (C) 2006 Blender Foundation # All rights reserved. set(INC diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl index c6203bc36ab..2a98d9fadd0 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl @@ -109,6 +109,11 @@ void vector_normalize(vec3 normal, out vec3 outnormal) outnormal = normalize(normal); } +void vector_copy(vec3 normal, out vec3 outnormal) +{ + outnormal = normal; +} + /* Matirx Math */ mat3 euler_to_mat3(vec3 euler) diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h index 674b384adf2..7ce0feb3989 100644 --- a/source/blender/ikplugin/BIK_api.h +++ b/source/blender/ikplugin/BIK_api.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index 233150a77aa..8bbab832b66 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h index f61ba7e3a63..9d54cbec80c 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.h +++ b/source/blender/ikplugin/intern/ikplugin_api.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 0ee8b3057d2..5daad507efe 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h index 28356b4fc9c..3cb6ac171d9 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.h +++ b/source/blender/ikplugin/intern/iksolver_plugin.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 4a4e22ed884..102ad46a5f2 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h index 89342295b35..cd4e210966e 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.h +++ b/source/blender/ikplugin/intern/itasc_plugin.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 758b21f8cda..aa10d8949fe 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999-2001 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/cineon/cineonlib.h b/source/blender/imbuf/intern/cineon/cineonlib.h index d1225027b4c..d71b6da9bc6 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.h +++ b/source/blender/imbuf/intern/cineon/cineonlib.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999-2001 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 4580bfd2cbf..79374f87cc1 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> + * Copyright 1999-2002 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h index 1228ac4ee66..59fc6344737 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.h +++ b/source/blender/imbuf/intern/cineon/dpxlib.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> + * Copyright 1999-2002 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index 73bcb8d7ebc..2852e8c6f73 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999-2001 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h index c2704a086b6..3e98780016e 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.h +++ b/source/blender/imbuf/intern/cineon/logImageCore.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999-2001 David Hodson <hodsond@acm.org> */ /** \file diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp index 6686d56e9d1..a3cd8056290 100644 --- a/source/blender/imbuf/intern/dds/FlipDXT.cpp +++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp @@ -31,8 +31,11 @@ * All rights reserved. */ -/* This file comes from the chromium project, adapted to Blender to add DDS - * flipping to OpenGL convention for Blender */ +/** \file + * \ingroup imbdds + * This file comes from the chromium project, adapted to Blender to add DDS + * flipping to OpenGL convention for Blender. + */ #include "IMB_imbuf_types.h" diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index f23748e59a2..37ed993f3f6 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 324bc9806c1..c6f33664f8b 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * filter.c */ /** \file diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 00e96e7840b..2aa61a3b5ee 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Peter Schlaile <peter [at] schlaile [dot] de> 2011 + * Copyright 2011 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 925ef0a8502..616f4d1421c 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -12,21 +12,14 @@ * 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. - * - * The Original Code is Copyright - * All rights reserved. */ /** \file * \ingroup imbuf - */ - -/* ---------------------------------------------------------------------- * Radiance High Dynamic Range image file IO * For description and code for reading/writing of radiance hdr files * by Greg Ward, refer to: * http://radsite.lbl.gov/radiance/refer/Notes/picture_format.html - * ---------------------------------------------------------------------- */ #include "MEM_guardedalloc.h" diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index c75bdfa375c..ef0d547055d 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 1d81ee768e9..d368504dab0 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index f02f3e37d6a..84161167ebc 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * rotate.c */ /** \file diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index a18ba6748de..a745555eec7 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 18ed4710e78..10de80c1330 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * util.c */ /** \file diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index cc6fef634d5..4775d5154a3 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * util.c */ /** \file diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index f21d274f8fd..c2c87375363 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * writeimage.c */ /** \file diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 95b73c85da6..10de47da0e3 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -14,10 +14,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Adapted from the Blender Alembic importer implementation. - * - * Modifications Copyright (C) 2021 Tangent Animation and - * NVIDIA Corporation. All rights reserved. - */ + * Modifications Copyright 2021 Tangent Animation and + * NVIDIA Corporation. All rights reserved. */ #include "usd_reader_mesh.h" #include "usd_reader_material.h" diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h b/source/blender/io/usd/intern/usd_reader_mesh.h index c5869fcbd32..0a1ab9a5fbe 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.h +++ b/source/blender/io/usd/intern/usd_reader_mesh.h @@ -16,7 +16,7 @@ * Adapted from the Blender Alembic importer implementation. * * Modifications Copyright (C) 2021 Tangent Animation and - * NVIDIA Corporation. All rights reserved. + * NVIDIA Corporation. All rights reserved. */ #pragma once diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index 7d8427a8980..1745169ff98 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -129,7 +129,7 @@ constexpr bool is_type_string_related = (... && std::is_constructible_v<std::str * results in "obj_export_io.hh:205:18: warning: ‘%s’ directive output truncated writing 34 bytes * into a region of size 6" and similar warnings. Yes the output is truncated, and that is covered * as an edge case by tests on purpose. */ -#if defined __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wformat-truncation" #endif @@ -273,7 +273,7 @@ constexpr FormattingSyntax syntax_elem_to_formatting(const eMTLSyntaxElement key } } } -#if defined __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic pop #endif diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 132121064c8..cfee35e147a 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -310,6 +310,13 @@ typedef struct IDOverrideLibrary { /** List of IDOverrideLibraryProperty structs. */ ListBase properties; + /** Override hierarchy root ID. Usually the actual root of the hierarchy, but not always + * in degenerated cases. + * + * All liboverrides of a same hierarchy (e.g. a character collection) share the same root. + */ + struct ID *hierarchy_root; + /* Read/write data. */ /* Temp ID storing extra override data (used for differential operations only currently). * Always NULL outside of read/write context. */ @@ -317,8 +324,6 @@ typedef struct IDOverrideLibrary { IDOverrideLibraryRuntime *runtime; - void *_pad_0; - unsigned int flag; char _pad_1[4]; } IDOverrideLibrary; @@ -890,7 +895,7 @@ typedef enum IDRecalcFlag { #define FILTER_ID_CF (1ULL << 28) #define FILTER_ID_WS (1ULL << 29) #define FILTER_ID_LP (1ULL << 31) -#define FILTER_ID_HA (1ULL << 32) +#define FILTER_ID_CV (1ULL << 32) #define FILTER_ID_PT (1ULL << 33) #define FILTER_ID_VO (1ULL << 34) #define FILTER_ID_SIM (1ULL << 35) @@ -901,7 +906,7 @@ typedef enum IDRecalcFlag { FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \ FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \ FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \ - FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM) + FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM) /** * This enum defines the index assigned to each type of IDs in the array returned by @@ -984,7 +989,7 @@ enum { INDEX_ID_ME, INDEX_ID_CU, INDEX_ID_MB, - INDEX_ID_HA, + INDEX_ID_CV, INDEX_ID_PT, INDEX_ID_VO, INDEX_ID_LT, diff --git a/source/blender/makesdna/DNA_ID_enums.h b/source/blender/makesdna/DNA_ID_enums.h index 45faf9e7f57..839c1e8933f 100644 --- a/source/blender/makesdna/DNA_ID_enums.h +++ b/source/blender/makesdna/DNA_ID_enums.h @@ -90,7 +90,7 @@ typedef enum ID_Type { ID_CF = MAKE_ID2('C', 'F'), /* CacheFile */ ID_WS = MAKE_ID2('W', 'S'), /* WorkSpace */ ID_LP = MAKE_ID2('L', 'P'), /* LightProbe */ - ID_HA = MAKE_ID2('H', 'A'), /* Hair */ + ID_CV = MAKE_ID2('C', 'V'), /* Curves */ ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */ ID_VO = MAKE_ID2('V', 'O'), /* Volume */ ID_SIM = MAKE_ID2('S', 'I'), /* Simulation (geometry node groups) */ diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 53b1a60e53e..b7ba05f5879 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Constraint DNA data */ /** \file * \ingroup DNA + * Constraint DNA data. */ #pragma once diff --git a/source/blender/makesdna/DNA_hair_defaults.h b/source/blender/makesdna/DNA_curves_defaults.h index 095e4fdf583..66c7a1bd71b 100644 --- a/source/blender/makesdna/DNA_hair_defaults.h +++ b/source/blender/makesdna/DNA_curves_defaults.h @@ -24,10 +24,10 @@ /* clang-format off */ /* -------------------------------------------------------------------- */ -/** \name Hair Struct +/** \name Curves Struct * \{ */ -#define _DNA_DEFAULT_Hair \ +#define _DNA_DEFAULT_Curves \ { \ .flag = 0, \ } diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_curves_types.h index 5d54a4bb8cc..c7f31557e48 100644 --- a/source/blender/makesdna/DNA_hair_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -76,7 +76,7 @@ typedef struct CurvesGeometry { int curve_size; } CurvesGeometry; -typedef struct Hair { +typedef struct Curves { ID id; /* Animation data (must be immediately after id). */ struct AnimData *adt; @@ -93,15 +93,15 @@ typedef struct Hair { /* Draw Cache. */ void *batch_cache; -} Hair; +} Curves; -/* Hair.flag */ +/* Curves.flag */ enum { HA_DS_EXPAND = (1 << 0), }; /* Only one material supported currently. */ -#define HAIR_MATERIAL_NR 1 +#define CURVES_MATERIAL_NR 1 #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index e6ae90489a5..067915f090d 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -326,8 +326,7 @@ typedef struct bGPDstroke { /** Curve used to edit the stroke using Bezier handlers. */ struct bGPDcurve *editcurve; - /* NOTE: When adding new members, make sure to add them to BKE_gpencil_stroke_copy_settings as - * well! */ + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_stroke_copy_settings as well! */ bGPDstroke_Runtime runtime; void *_pad5; @@ -413,8 +412,7 @@ typedef struct bGPDframe { /** Keyframe type (eBezTriple_KeyframeType). */ short key_type; - /* NOTE: When adding new members, make sure to add them to BKE_gpencil_frame_copy_settings as - * well! */ + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_frame_copy_settings as well! */ bGPDframe_Runtime runtime; } bGPDframe; @@ -539,8 +537,7 @@ typedef struct bGPDlayer { float layer_mat[4][4], layer_invmat[4][4]; char _pad3[4]; - /* NOTE: When adding new members, make sure to add them to BKE_gpencil_layer_copy_settings as - * well! */ + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_layer_copy_settings as well! */ bGPDlayer_Runtime runtime; } bGPDlayer; @@ -643,6 +640,7 @@ typedef struct bGPdata_Runtime { Brush *sbuffer_brush; struct GpencilBatchCache *gpencil_cache; struct LineartCache *lineart_cache; + struct GPencilUpdateCache *update_cache; } bGPdata_Runtime; @@ -737,8 +735,7 @@ typedef struct bGPdata { bGPgrid grid; - /* NOTE: When adding new members, make sure to add them to BKE_gpencil_data_copy_settings as - * well! */ + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_data_copy_settings as well! */ bGPdata_Runtime runtime; } bGPdata; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index ce735ad79c4..ca8696d1326 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -505,7 +505,7 @@ enum { /** Grease Pencil object used in 3D view but not used for annotation in 2D. */ OB_GPENCIL = 26, - OB_HAIR = 27, + OB_CURVES = 27, OB_POINTCLOUD = 28, @@ -520,7 +520,15 @@ enum { (((_type) >= OB_MESH && (_type) <= OB_MBALL) || ((_type) >= OB_GPENCIL && (_type) <= OB_VOLUME)) /** Does the object have some render-able geometry (unlike empties, cameras, etc.). */ #define OB_TYPE_IS_GEOMETRY(_type) \ - (ELEM(_type, OB_MESH, OB_SURF, OB_FONT, OB_MBALL, OB_GPENCIL, OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) + (ELEM(_type, \ + OB_MESH, \ + OB_SURF, \ + OB_FONT, \ + OB_MBALL, \ + OB_GPENCIL, \ + OB_CURVES, \ + OB_POINTCLOUD, \ + OB_VOLUME)) #define OB_TYPE_SUPPORT_VGROUP(_type) (ELEM(_type, OB_MESH, OB_LATTICE, OB_GPENCIL)) #define OB_TYPE_SUPPORT_EDITMODE(_type) \ (ELEM(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) @@ -542,7 +550,7 @@ enum { ID_LT, \ ID_GD, \ ID_AR, \ - ID_HA, \ + ID_CV, \ ID_PT, \ ID_VO)) @@ -557,7 +565,7 @@ enum { case ID_LT: \ case ID_GD: \ case ID_AR: \ - case ID_HA: \ + case ID_CV: \ case ID_PT: \ case ID_VO diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 70f0dc3f5de..622175a8429 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -73,8 +73,8 @@ typedef struct StripCrop { } StripCrop; typedef struct StripTransform { - int xofs; - int yofs; + float xofs; + float yofs; float scale_x; float scale_y; float rotation; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index a03bf082861..3e071d3bc3a 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -660,7 +660,7 @@ typedef struct UserDef_Experimental { char SANITIZE_AFTER_HERE; /* The following options are automatically sanitized (set to 0) * when the release cycle is not alpha. */ - char use_new_hair_type; + char use_new_curves_type; char use_new_point_cloud_type; char use_full_frame_compositor; char use_sculpt_vertex_colors; @@ -1253,7 +1253,7 @@ typedef enum eDupli_ID_Flags { USER_DUP_PSYS = (1 << 11), USER_DUP_LIGHTPROBE = (1 << 12), USER_DUP_GPENCIL = (1 << 13), - USER_DUP_HAIR = (1 << 14), + USER_DUP_CURVES = (1 << 14), USER_DUP_POINTCLOUD = (1 << 15), USER_DUP_VOLUME = (1 << 16), USER_DUP_LATTICE = (1 << 17), diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index a3c54e91780..af30fa5cc9e 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -142,7 +142,7 @@ set(SRC ../DNA_defaults.h ../DNA_fluid_defaults.h ../DNA_gpencil_modifier_defaults.h - ../DNA_hair_defaults.h + ../DNA_curves_defaults.h ../DNA_image_defaults.h ../DNA_lattice_defaults.h ../DNA_light_defaults.h diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 5bc5de7a20b..93d8051d6c4 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -12,8 +12,6 @@ * 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. - * - * DNA default value access. */ /** \file @@ -94,9 +92,9 @@ #include "DNA_cloth_types.h" #include "DNA_collection_types.h" #include "DNA_curve_types.h" +#include "DNA_curves_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" #include "DNA_lattice_types.h" @@ -127,9 +125,9 @@ #include "DNA_camera_defaults.h" #include "DNA_collection_defaults.h" #include "DNA_curve_defaults.h" +#include "DNA_curves_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" #include "DNA_light_defaults.h" @@ -184,8 +182,8 @@ SDNA_DEFAULT_DECL_STRUCT(FluidEffectorSettings); /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Image); -/* DNA_hair_defaults.h */ -SDNA_DEFAULT_DECL_STRUCT(Hair); +/* DNA_curves_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Curves); /* DNA_lattice_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Lattice); @@ -392,8 +390,8 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL(Image), - /* DNA_hair_defaults.h */ - SDNA_DEFAULT_DECL(Hair), + /* DNA_curves_defaults.h */ + SDNA_DEFAULT_DECL(Curves), /* DNA_lattice_defaults.h */ SDNA_DEFAULT_DECL(Lattice), diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 6322cb459dd..634aa91cf95 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * DNA handling */ /** \file * \ingroup DNA + * \brief DNA handling * * Lowest-level functions for decoding the parts of a saved .blend * file, including interpretation of its SDNA block and conversion of @@ -733,49 +733,73 @@ static void cast_primitive_type(const eSDNA_Type old_type, const int curlen = DNA_elem_type_size(new_type); double old_value_f = 0.0; + /* Intentionally overflow signed values into an unsigned type. + * Casting back to a signed value preserves the sign (when the new value is signed). */ uint64_t old_value_i = 0; for (int a = 0; a < array_len; a++) { switch (old_type) { - case SDNA_TYPE_CHAR: - old_value_i = *old_data; - old_value_f = (double)old_value_i; + case SDNA_TYPE_CHAR: { + const char value = *old_data; + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_UCHAR: - old_value_i = *((unsigned char *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_UCHAR: { + const uchar value = *((uchar *)old_data); + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_SHORT: - old_value_i = *((short *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_SHORT: { + const short value = *((short *)old_data); + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_USHORT: - old_value_i = *((unsigned short *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_USHORT: { + const ushort value = *((unsigned short *)old_data); + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_INT: - old_value_i = *((int *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_INT: { + const int value = *((int *)old_data); + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_FLOAT: - old_value_f = *((float *)old_data); - old_value_i = (uint64_t)(int64_t)old_value_f; + } + case SDNA_TYPE_FLOAT: { + const float value = *((float *)old_data); + /* `int64_t` range stored in a `uint64_t`. */ + old_value_i = (uint64_t)(int64_t)value; + old_value_f = value; break; - case SDNA_TYPE_DOUBLE: - old_value_f = *((double *)old_data); - old_value_i = (uint64_t)(int64_t)old_value_f; + } + case SDNA_TYPE_DOUBLE: { + const double value = *((double *)old_data); + /* `int64_t` range stored in a `uint64_t`. */ + old_value_i = (uint64_t)(int64_t)value; + old_value_f = value; break; - case SDNA_TYPE_INT64: - old_value_i = (uint64_t) * ((int64_t *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_INT64: { + const int64_t value = *((int64_t *)old_data); + old_value_i = (uint64_t)value; + old_value_f = (double)value; break; - case SDNA_TYPE_UINT64: - old_value_i = *((uint64_t *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_UINT64: { + const uint64_t value = *((uint64_t *)old_data); + old_value_i = value; + old_value_f = (double)value; break; - case SDNA_TYPE_INT8: - old_value_i = (uint64_t) * ((int8_t *)old_data); - old_value_f = (double)old_value_i; + } + case SDNA_TYPE_INT8: { + const int8_t value = *((int8_t *)old_data); + old_value_i = (uint64_t)value; + old_value_f = (double)value; + } } switch (new_type) { diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index cb8052856a7..b666a5dce56 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * DNA handling */ /** \file diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index d94b95fc6f4..5156203b71f 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -134,7 +134,7 @@ static const char *includefiles[] = { "DNA_lightprobe_types.h", "DNA_curveprofile_types.h", "DNA_xr_types.h", - "DNA_hair_types.h", + "DNA_curves_types.h", "DNA_pointcloud_types.h", "DNA_volume_types.h", "DNA_simulation_types.h", @@ -1636,6 +1636,7 @@ int main(int argc, char **argv) #include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_curveprofile_types.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_effect_types.h" @@ -1644,7 +1645,6 @@ int main(int argc, char **argv) #include "DNA_freestyle_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_image_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 43439428ea7..47afa0f9a13 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -308,7 +308,7 @@ extern StructRNA RNA_GizmoProperties; extern StructRNA RNA_GlowSequence; extern StructRNA RNA_GpencilModifier; extern StructRNA RNA_GreasePencil; -extern StructRNA RNA_Hair; +extern StructRNA RNA_Curves; extern StructRNA RNA_Header; extern StructRNA RNA_Histogram; extern StructRNA RNA_HookGpencilModifier; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index e3c89af6186..91d7c5a1394 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -101,9 +101,9 @@ set(DEFSRC if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) list(APPEND DEFSRC - rna_hair.c + rna_curves.c rna_simulation.c ) endif() diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1e9cebbc3ea..0fadbda5a18 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -4376,8 +4376,8 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint}, {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve}, {"rna_gpencil.c", NULL, RNA_def_gpencil}, -#ifdef WITH_HAIR_NODES - {"rna_hair.c", NULL, RNA_def_hair}, +#ifdef WITH_NEW_CURVES_TYPE + {"rna_curves.c", NULL, RNA_def_curves}, #endif {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 8fc634fc087..e7f885b2160 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -76,7 +76,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, - {ID_HA, "HAIR", ICON_HAIR_DATA, "Hair", ""}, + {ID_CV, "CURVES", ICON_CURVES_DATA, "Hair Curves", ""}, {ID_PT, "POINTCLOUD", ICON_POINTCLOUD_DATA, "Point Cloud", ""}, {ID_VO, "VOLUME", ICON_VOLUME_DATA, "Volume", ""}, {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""}, @@ -151,7 +151,7 @@ const struct IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = { ICON_OUTLINER_COLLECTION, "Collections", "Show Collection data-blocks"}, - {FILTER_ID_HA, "filter_hair", ICON_HAIR_DATA, "Hairs", "Show/hide Hair data-blocks"}, + {FILTER_ID_CV, "filter_hair", ICON_CURVES_DATA, "Hairs", "Show/hide Hair data-blocks"}, {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"}, {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"}, {FILTER_ID_LP, @@ -385,9 +385,9 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_FreestyleLineStyle) { return ID_LS; } -# ifdef WITH_HAIR_NODES - if (base_type == &RNA_Hair) { - return ID_HA; +# ifdef WITH_NEW_CURVES_TYPE + if (base_type == &RNA_Curves) { + return ID_CV; } # endif if (base_type == &RNA_Lattice) { @@ -492,9 +492,9 @@ StructRNA *ID_code_to_RNA_type(short idcode) return &RNA_GreasePencil; case ID_GR: return &RNA_Collection; - case ID_HA: -# ifdef WITH_HAIR_NODES - return &RNA_Hair; + case ID_CV: +# ifdef WITH_NEW_CURVES_TYPE + return &RNA_Curves; # else return &RNA_ID; # endif @@ -1822,6 +1822,13 @@ static void rna_def_ID_override_library(BlenderRNA *brna) srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override"); RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); + RNA_def_pointer( + srna, + "hierarchy_root", + "ID", + "Hierarchy Root ID", + "Library override ID used as root of the override hierarchy this ID is a member of"); + prop = RNA_def_boolean(srna, "is_in_hierarchy", true, diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 6b134977c5a..f4236a860ab 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -625,11 +625,11 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_FILE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "show_hairs", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_hair_curves", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag2", ADS_FILTER_NOHAIR); RNA_def_property_ui_text( prop, "Display Hair", "Include visualization of hair related animation data"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_HAIR, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CURVES, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_pointclouds", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index da835fb89c4..dc0d00aaa77 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -26,8 +26,8 @@ #include "rna_internal.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" @@ -188,7 +188,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, if (id_type == ID_PT && !ELEM(domain_item->value, ATTR_DOMAIN_POINT)) { continue; } - if (id_type == ID_HA && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (id_type == ID_CV && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { continue; } if (id_type == ID_ME && ELEM(domain_item->value, ATTR_DOMAIN_CURVE)) { diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_curves.c index 30e1fd48c03..faa067000bb 100644 --- a/source/blender/makesrna/intern/rna_hair.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -25,7 +25,7 @@ #include "rna_internal.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "BLI_math_base.h" #include "BLI_string.h" @@ -35,27 +35,27 @@ # include "BLI_math_vector.h" # include "BKE_attribute.h" -# include "BKE_hair.h" +# include "BKE_curves.h" # include "DEG_depsgraph.h" # include "WM_api.h" # include "WM_types.h" -static Hair *rna_hair(PointerRNA *ptr) +static Curves *rna_curves(PointerRNA *ptr) { - return (Hair *)ptr->owner_id; + return (Curves *)ptr->owner_id; } -static int rna_Hair_curve_offset_data_length(PointerRNA *ptr) +static int rna_Curves_curve_offset_data_length(PointerRNA *ptr) { - const Hair *curves = rna_hair(ptr); + const Curves *curves = rna_curves(ptr); return curves->geometry.curve_size + 1; } -static void rna_Hair_curve_offset_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - const Hair *curves = rna_hair(ptr); + const Curves *curves = rna_curves(ptr); rna_iterator_array_begin(iter, (void *)curves->geometry.offsets, sizeof(int), @@ -66,9 +66,9 @@ static void rna_Hair_curve_offset_data_begin(CollectionPropertyIterator *iter, P static int rna_CurvePoint_index_get(PointerRNA *ptr) { - const Hair *hair = rna_hair(ptr); + const Curves *curves = rna_curves(ptr); const float(*co)[3] = ptr->data; - return (int)(co - hair->geometry.position); + return (int)(co - curves->geometry.position); } static void rna_CurvePoint_location_get(PointerRNA *ptr, float value[3]) @@ -83,22 +83,22 @@ static void rna_CurvePoint_location_set(PointerRNA *ptr, const float value[3]) static float rna_CurvePoint_radius_get(PointerRNA *ptr) { - const Hair *hair = rna_hair(ptr); - if (hair->geometry.radius == NULL) { + const Curves *curves = rna_curves(ptr); + if (curves->geometry.radius == NULL) { return 0.0f; } const float(*co)[3] = ptr->data; - return hair->geometry.radius[co - hair->geometry.position]; + return curves->geometry.radius[co - curves->geometry.position]; } static void rna_CurvePoint_radius_set(PointerRNA *ptr, float value) { - const Hair *hair = rna_hair(ptr); - if (hair->geometry.radius == NULL) { + const Curves *curves = rna_curves(ptr); + if (curves->geometry.radius == NULL) { return; } const float(*co)[3] = ptr->data; - hair->geometry.radius[co - hair->geometry.position] = value; + curves->geometry.radius[co - curves->geometry.position] = value; } static char *rna_CurvePoint_path(PointerRNA *ptr) @@ -108,8 +108,8 @@ static char *rna_CurvePoint_path(PointerRNA *ptr) static int rna_CurveSlice_index_get(PointerRNA *ptr) { - Hair *hair = rna_hair(ptr); - return (int)((int *)ptr->data - hair->geometry.offsets); + Curves *curves = rna_curves(ptr); + return (int)((int *)ptr->data - curves->geometry.offsets); } static char *rna_CurveSlice_path(PointerRNA *ptr) @@ -119,11 +119,11 @@ static char *rna_CurveSlice_path(PointerRNA *ptr) static void rna_CurveSlice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Hair *hair = rna_hair(ptr); + Curves *curves = rna_curves(ptr); const int *offset_ptr = (int *)ptr->data; const int offset = *offset_ptr; const int size = *(offset_ptr + 1) - offset; - float(*co)[3] = hair->geometry.position + *offset_ptr; + float(*co)[3] = curves->geometry.position + *offset_ptr; rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, NULL); } @@ -140,9 +140,9 @@ static int rna_CurveSlice_points_length_get(PointerRNA *ptr) return *(offset_ptr + 1) - offset; } -static void rna_Hair_update_data(struct Main *UNUSED(bmain), - struct Scene *UNUSED(scene), - PointerRNA *ptr) +static void rna_Curves_update_data(struct Main *UNUSED(bmain), + struct Scene *UNUSED(scene), + PointerRNA *ptr) { ID *id = ptr->owner_id; @@ -155,7 +155,7 @@ static void rna_Hair_update_data(struct Main *UNUSED(bmain), #else -static void rna_def_hair_point(BlenderRNA *brna) +static void rna_def_curves_point(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -169,13 +169,13 @@ static void rna_def_hair_point(BlenderRNA *brna) RNA_def_property_float_funcs( prop, "rna_CurvePoint_location_get", "rna_CurvePoint_location_set", NULL); RNA_def_property_ui_text(prop, "Position", ""); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_funcs( prop, "rna_CurvePoint_radius_get", "rna_CurvePoint_radius_set", NULL); RNA_def_property_ui_text(prop, "Radius", ""); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -183,7 +183,7 @@ static void rna_def_hair_point(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Index", "Index of this points"); } -static void rna_def_hair_curve(BlenderRNA *brna) +static void rna_def_curves_curve(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -222,21 +222,21 @@ static void rna_def_hair_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Index", "Index of this curve"); } -static void rna_def_hair(BlenderRNA *brna) +static void rna_def_curves(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "Hair", "ID"); - RNA_def_struct_ui_text(srna, "Hair", "Hair data-block for hair curves"); - RNA_def_struct_ui_icon(srna, ICON_HAIR_DATA); + srna = RNA_def_struct(brna, "Curves", "ID"); + RNA_def_struct_ui_text(srna, "Hair Curves", "Hair data-block for hair curves"); + RNA_def_struct_ui_icon(srna, ICON_CURVES_DATA); /* Point and Curve RNA API helpers. */ prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", "geometry.curve_size"); RNA_def_property_struct_type(prop, "CurveSlice"); - RNA_def_property_ui_text(prop, "Curves", "All hair curves"); + RNA_def_property_ui_text(prop, "Curves", "All curves in the data-block"); /* TODO: better solution for (*co)[3] parsing issue. */ @@ -244,7 +244,7 @@ static void rna_def_hair(BlenderRNA *brna) prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_ui_text(prop, "Points", "Control points of all hair curves"); + RNA_def_property_ui_text(prop, "Points", "Control points of all curves"); RNA_define_verify_sdna(1); /* Direct access to built-in attributes. */ @@ -253,22 +253,22 @@ static void rna_def_hair(BlenderRNA *brna) prop = RNA_def_property(srna, "position_data", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); RNA_def_property_struct_type(prop, "FloatVectorAttributeValue"); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); RNA_define_verify_sdna(1); prop = RNA_def_property(srna, "curve_offset_data", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", NULL); RNA_def_property_struct_type(prop, "IntAttributeValue"); RNA_def_property_collection_funcs(prop, - "rna_Hair_curve_offset_data_begin", + "rna_Curves_curve_offset_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", - "rna_Hair_curve_offset_data_length", + "rna_Curves_curve_offset_data_length", NULL, NULL, NULL); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); /* materials */ prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); @@ -286,11 +286,11 @@ static void rna_def_hair(BlenderRNA *brna) rna_def_animdata_common(srna); } -void RNA_def_hair(BlenderRNA *brna) +void RNA_def_curves(BlenderRNA *brna) { - rna_def_hair_point(brna); - rna_def_hair_curve(brna); - rna_def_hair(brna); + rna_def_curves_point(brna); + rna_def_curves_curve(brna); + rna_def_curves(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 98255a46ae7..ff194e2c52a 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -180,10 +180,12 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = { static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { +#if 0 /* In case a property on a layer changed, tag it with a light update. */ if (ptr->type == &RNA_GPencilLayer) { BKE_gpencil_tag_light_update((bGPdata *)(ptr->owner_id), (bGPDlayer *)(ptr->data), NULL, NULL); } +#endif DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY); WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 0e0391197ea..407f474ddab 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -170,7 +170,7 @@ void RNA_def_fcurve(struct BlenderRNA *brna); void RNA_def_gpencil(struct BlenderRNA *brna); void RNA_def_greasepencil_modifier(struct BlenderRNA *brna); void RNA_def_shader_fx(struct BlenderRNA *brna); -void RNA_def_hair(struct BlenderRNA *brna); +void RNA_def_curves(struct BlenderRNA *brna); void RNA_def_image(struct BlenderRNA *brna); void RNA_def_key(struct BlenderRNA *brna); void RNA_def_light(struct BlenderRNA *brna); @@ -496,8 +496,8 @@ void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop); -#ifdef WITH_HAIR_NODES -void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop); +#ifdef WITH_NEW_CURVES_TYPE +void RNA_def_main_hair_curves(BlenderRNA *brna, PropertyRNA *cprop); #endif void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 57a2a867d0a..230c04bfd9c 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -110,8 +110,8 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(collections) RNA_MAIN_LISTBASE_FUNCS_DEF(curves) RNA_MAIN_LISTBASE_FUNCS_DEF(fonts) RNA_MAIN_LISTBASE_FUNCS_DEF(gpencils) -# ifdef WITH_HAIR_NODES -RNA_MAIN_LISTBASE_FUNCS_DEF(hairs) +# ifdef WITH_NEW_CURVES_TYPE +RNA_MAIN_LISTBASE_FUNCS_DEF(hair_curves) # endif RNA_MAIN_LISTBASE_FUNCS_DEF(images) RNA_MAIN_LISTBASE_FUNCS_DEF(lattices) @@ -389,8 +389,17 @@ void RNA_def_main(BlenderRNA *brna) "Light Probes", "Light Probe data-blocks", RNA_def_main_lightprobes}, -# ifdef WITH_HAIR_NODES - {"hairs", "Hair", "rna_Main_hairs_begin", "Hairs", "Hair data-blocks", RNA_def_main_hairs}, +# ifdef WITH_NEW_CURVES_TYPE + /** + * \note The name `hair_curves` is chosen to be different than `curves`, + * but they are generic curve data-blocks, not just for hair. + */ + {"hair_curves", + "Curves", + "rna_Main_hair_curves_begin", + "Hair Curves", + "Hair curve data-blocks", + RNA_def_main_hair_curves}, # endif {"pointclouds", "PointCloud", diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 4344ed0dff5..f8d2d6524c2 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -46,9 +46,9 @@ # include "BKE_camera.h" # include "BKE_collection.h" # include "BKE_curve.h" +# include "BKE_curves.h" # include "BKE_displist.h" # include "BKE_gpencil.h" -# include "BKE_hair.h" # include "BKE_icons.h" # include "BKE_idtype.h" # include "BKE_image.h" @@ -86,8 +86,8 @@ # include "DNA_camera_types.h" # include "DNA_collection_types.h" # include "DNA_curve_types.h" +# include "DNA_curves_types.h" # include "DNA_gpencil_types.h" -# include "DNA_hair_types.h" # include "DNA_lattice_types.h" # include "DNA_light_types.h" # include "DNA_lightprobe_types.h" @@ -763,18 +763,18 @@ static bGPdata *rna_Main_gpencils_new(Main *bmain, const char *name) return gpd; } -# ifdef WITH_HAIR_NODES -static Hair *rna_Main_hairs_new(Main *bmain, const char *name) +# ifdef WITH_NEW_CURVES_TYPE +static Curves *rna_Main_hair_curves_new(Main *bmain, const char *name) { char safe_name[MAX_ID_NAME - 2]; rna_idname_validate(name, safe_name); - Hair *hair = BKE_hair_add(bmain, safe_name); - id_us_min(&hair->id); + Curves *curves = BKE_curves_add(bmain, safe_name); + id_us_min(&curves->id); WM_main_add_notifier(NC_ID | NA_ADDED, NULL); - return hair; + return curves; } # endif @@ -861,8 +861,8 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP) -# ifdef WITH_HAIR_NODES -RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA) +# ifdef WITH_NEW_CURVES_TYPE +RNA_MAIN_ID_TAG_FUNCS_DEF(hair_curves, hair_curves, ID_CV) # endif RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT) RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO) @@ -2269,47 +2269,47 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } -# ifdef WITH_HAIR_NODES -void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop) +# ifdef WITH_NEW_CURVES_TYPE +void RNA_def_main_hair_curves(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "BlendDataHairs"); - srna = RNA_def_struct(brna, "BlendDataHairs", NULL); + RNA_def_property_srna(cprop, "BlendDataHairCurves"); + srna = RNA_def_struct(brna, "BlendDataHairCurves", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Hairs", "Collection of hairs"); + RNA_def_struct_ui_text(srna, "Main Hair Curves", "Collection of hair curves"); - func = RNA_def_function(srna, "new", "rna_Main_hairs_new"); + func = RNA_def_function(srna, "new", "rna_Main_hair_curves_new"); RNA_def_function_ui_description(func, "Add a new hair to the main database"); - parm = RNA_def_string(func, "name", "Hair", 0, "", "New name for the data-block"); + parm = RNA_def_string(func, "name", "Curves", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "hair", "Hair", "", "New hair data-block"); + parm = RNA_def_pointer(func, "curves", "Curves", "", "New curves data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove a hair from the current blendfile"); - parm = RNA_def_pointer(func, "hair", "Hair", "", "Hair to remove"); + RNA_def_function_ui_description(func, "Remove a curves data-block from the current blendfile"); + parm = RNA_def_pointer(func, "curves", "Curves", "", "Curves data-block to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); RNA_def_boolean(func, "do_unlink", true, "", - "Unlink all usages of this hair before deleting it " - "(WARNING: will also delete objects instancing that hair data)"); + "Unlink all usages of this curves before deleting it " + "(WARNING: will also delete objects instancing that curves data)"); RNA_def_boolean(func, "do_id_user", true, "", - "Decrement user counter of all datablocks used by this hair data"); + "Decrement user counter of all datablocks used by this curves data"); RNA_def_boolean( - func, "do_ui_user", true, "", "Make sure interface does not reference this hair data"); + func, "do_ui_user", true, "", "Make sure interface does not reference this curves data"); - func = RNA_def_function(srna, "tag", "rna_Main_hairs_tag"); + func = RNA_def_function(srna, "tag", "rna_Main_hair_curves_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 22a75c0d992..6dea0dbbf7d 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -718,7 +718,7 @@ void RNA_def_material(BlenderRNA *brna) {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"}, {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"}, {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"}, - {MA_HAIR, "HAIR", ICON_HAIR, "Hair", "Hair strands"}, + {MA_HAIR, "HAIR", ICON_CURVES, "Hair", "Hair strands"}, {MA_SHADERBALL, "SHADERBALL", ICON_MATSHADERBALL, "Shader Ball", "Shader ball"}, {MA_CLOTH, "CLOTH", ICON_MATCLOTH, "Cloth", "Cloth"}, {MA_FLUID, "FLUID", ICON_MATFLUID, "Fluid", "Fluid"}, @@ -791,8 +791,8 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKFACE); RNA_def_property_ui_text(prop, "Show Backface", - "Limit transparency to a single layer " - "(avoids transparency sorting problems)"); + "Render multiple transparent layers " + "(may introduce transparency sorting problems)"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE); @@ -819,7 +819,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Refraction Depth", "Approximate the thickness of the object to compute two refraction " - "event (0 is disabled)"); + "events (0 is disabled)"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); /* For Preview Render */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 13c8444de1d..bd74f86c79a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -465,7 +465,8 @@ static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = { const EnumPropertyItem rna_enum_node_filter_items[] = { {0, "SOFTEN", 0, "Soften", ""}, - {1, "SHARPEN", 0, "Sharpen", ""}, + {1, "SHARPEN", 0, "Box Sharpen", "An aggressive sharpening filter"}, + {7, "SHARPEN_DIAMOND", 0, "Diamond Sharpen", "A moderate sharpening filter"}, {2, "LAPLACE", 0, "Laplace", ""}, {3, "SOBEL", 0, "Sobel", ""}, {4, "PREWITT", 0, "Prewitt", ""}, diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 2bb341e00fb..be37e574c9c 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -271,7 +271,7 @@ const EnumPropertyItem rna_enum_object_type_items[] = { OBTYPE_CU_SURF, {OB_MBALL, "META", ICON_OUTLINER_OB_META, "Metaball", ""}, OBTYPE_CU_FONT, - {OB_HAIR, "HAIR", ICON_OUTLINER_OB_HAIR, "Hair", ""}, + {OB_CURVES, "CURVES", ICON_OUTLINER_OB_CURVES, "Hair Curves", ""}, {OB_POINTCLOUD, "POINTCLOUD", ICON_OUTLINER_OB_POINTCLOUD, "Point Cloud", ""}, {OB_VOLUME, "VOLUME", ICON_OUTLINER_OB_VOLUME, "Volume", ""}, {OB_GPENCIL, "GPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil", ""}, @@ -613,9 +613,9 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) return &RNA_LightProbe; case OB_GPENCIL: return &RNA_GreasePencil; - case OB_HAIR: -# ifdef WITH_HAIR_NODES - return &RNA_Hair; + case OB_CURVES: +# ifdef WITH_NEW_CURVES_TYPE + return &RNA_Curves; # else return &RNA_ID; # endif diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 23ec5148f00..df6c12ffb27 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -12,8 +12,8 @@ * 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. - * Adaptive time step - * Copyright 2011 AutoCRC + * + * Copyright 2011 AutoCRC (adaptive time step) */ /** \file diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 9fee54ef38d..15b3a2fe998 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1485,16 +1485,16 @@ static void rna_def_strip_transform(BlenderRNA *brna) RNA_def_property_float_default(prop, 1.0f); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); - prop = RNA_def_property(srna, "offset_x", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "xofs"); + prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_float_sdna(prop, NULL, "xofs"); RNA_def_property_ui_text(prop, "Translate X", "Move along X axis"); - RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, 3); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); - prop = RNA_def_property(srna, "offset_y", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "yofs"); + prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_float_sdna(prop, NULL, "yofs"); RNA_def_property_ui_text(prop, "Translate Y", "Move along Y axis"); - RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, 3); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9a3c40bf306..07521d39256 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3277,7 +3277,7 @@ static struct IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[ ICON_OUTLINER_COLLECTION, "Objects & Collections", "Show objects and collections"}, - {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_HA | + {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO, "category_geometry", ICON_NODETREE, @@ -5004,7 +5004,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}}, {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}}, {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}}, - {"Hair", (1 << OB_HAIR), {"show_object_viewport_hair", "show_object_select_hair"}}, + {"Hair", (1 << OB_CURVES), {"show_object_viewport_hair", "show_object_select_hair"}}, {"Point Cloud", (1 << OB_POINTCLOUD), {"show_object_viewport_pointcloud", "show_object_select_pointcloud"}}, diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index bc0512d70d4..7ff345f9e02 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -5314,7 +5314,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) prop, "Duplicate GPencil", "Causes grease pencil data to be duplicated with the object"); prop = RNA_def_property(srna, "use_duplicate_hair", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_HAIR); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_CURVES); RNA_def_property_ui_text( prop, "Duplicate Hair", "Causes hair data to be duplicated with the object"); @@ -6420,9 +6420,9 @@ static void rna_def_userdef_experimental(BlenderRNA *brna) "reduces execution time and memory usage)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "use_new_hair_type", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "use_new_hair_type", 1); - RNA_def_property_ui_text(prop, "New Hair Type", "Enable the new hair type in the ui"); + prop = RNA_def_property(srna, "use_new_curves_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_new_curves_type", 1); + RNA_def_property_ui_text(prop, "New Curves Type", "Enable the new curves data type in the UI"); prop = RNA_def_property(srna, "use_cycles_debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_cycles_debug", 1); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 5065a23ee1b..719a07adbab 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -232,7 +232,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() # So we can have special tricks in modifier system. diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index ca4bfbed5f5..f16fc8ff764 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1031,7 +1031,11 @@ static void store_computed_output_attributes( { for (const OutputAttributeToStore &store : attributes_to_store) { GeometryComponent &component = geometry.get_component_for_write(store.component_type); - if (component.attribute_exists(store.name)) { + const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(store.data.type()); + const std::optional<AttributeMetaData> meta_data = component.attribute_get_meta_data( + store.name); + if (meta_data.has_value() && meta_data->domain == store.domain && + meta_data->data_type == data_type) { /* Copy the data into an existing attribute. */ blender::bke::WriteAttributeLookup write_attribute = component.attribute_try_get_for_write( store.name); @@ -1045,6 +1049,10 @@ static void store_computed_output_attributes( MEM_freeN(store.data.data()); } else { + /* Replace the existing attribute with the new data. */ + if (meta_data.has_value()) { + component.attribute_try_delete(store.name); + } component.attribute_try_create(store.name, store.domain, blender::bke::cpp_type_to_custom_data_type(store.data.type()), diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc index fcc04a85b38..d889130c2fa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc +++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2017 Blender Foundation. * All rights reserved. - * - * The Original Code is: all of this file. */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index dd0a6db74c1..96dbf0def4a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc index 282328b5e10..b7ab28f3465 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc index d5f7279398e..a3fa940460b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.cc +++ b/source/blender/nodes/composite/nodes/node_composite_common.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index d407bcbde63..8b9ccfe47e0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2019 Blender Foundation. * All rights reserved. - * - * The Original Code is: all of this file. */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.cc b/source/blender/nodes/composite/nodes/node_composite_switchview.cc index 678d7fe1a9b..606eaa8ed99 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switchview.cc +++ b/source/blender/nodes/composite/nodes/node_composite_switchview.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Dalai Felinto */ /** \file diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc index 3c790079b5b..89227c773cc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc @@ -60,7 +60,7 @@ static std::optional<Mesh *> mesh_merge_by_distance(const MeshComponent &mesh_co const IndexMask selection = evaluator.get_evaluated_as_mask(0); if (selection.is_empty()) { - return nullptr; + return std::nullopt; } const Mesh &mesh = *mesh_component.get_for_read(); @@ -78,7 +78,9 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_pointcloud()) { PointCloud *result = pointcloud_merge_by_distance( *geometry_set.get_component_for_read<PointCloudComponent>(), merge_distance, selection); - geometry_set.replace_pointcloud(result); + if (result) { + geometry_set.replace_pointcloud(result); + } } if (geometry_set.has_mesh()) { std::optional<Mesh *> result = mesh_merge_by_distance( diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.cc b/source/blender/nodes/shader/nodes/node_shader_bump.cc index 252abd02ad7..690eacf30ff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bump.cc @@ -60,6 +60,17 @@ static int gpu_shader_bump(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { + /* If there is no Height input, the node becomes a no-op. */ + if (!in[2].link) { + if (!in[5].link) { + return GPU_link(mat, "world_normals_get", &out[0].link); + } + else { + /* Actually running the bump code would normalize, but Cycles handles it as total no-op. */ + return GPU_link(mat, "vector_copy", in[5].link, &out[0].link); + } + } + if (!in[5].link) { GPU_link(mat, "world_normals_get", &in[5].link); } diff --git a/source/blender/nodes/shader/nodes/node_shader_common.cc b/source/blender/nodes/shader/nodes/node_shader_common.cc index 3f0fff34533..f7a17f0722c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.cc +++ b/source/blender/nodes/shader/nodes/node_shader_common.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index bc7ca661a77..254ab9f866d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -66,6 +66,16 @@ static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), Po } } +static int node_shader_map_range_ui_class(const bNode *node) +{ + const NodeMapRange &storage = node_storage(*node); + const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type); + if (data_type == CD_PROP_FLOAT3) { + return NODE_CLASS_OP_VECTOR; + } + return NODE_CLASS_CONVERTER; +} + static void node_shader_update_map_range(bNodeTree *ntree, bNode *node) { const NodeMapRange &storage = node_storage(*node); @@ -665,6 +675,7 @@ void register_node_type_sh_map_range() sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_map_range_declare; ntype.draw_buttons = file_ns::node_shader_buts_map_range; + ntype.ui_class = file_ns::node_shader_map_range_ui_class; node_type_init(&ntype, file_ns::node_shader_init_map_range); node_type_storage( &ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index d68cfe78b44..9bd16a318c9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index faa668df775..cbbf2a3cb43 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -12,8 +12,6 @@ * 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. - * - * Chris Keith, Chris Want, Ken Hughes, Campbell Barton */ /** \file diff --git a/source/blender/render/RE_pipeline.h b/source/blender/render/RE_pipeline.h index c1392b24023..6374b70ae1f 100644 --- a/source/blender/render/RE_pipeline.h +++ b/source/blender/render/RE_pipeline.h @@ -31,6 +31,7 @@ struct Image; struct ImageFormatData; struct Main; struct Object; +struct ImBuf; struct RenderData; struct RenderResult; struct ReportList; @@ -209,7 +210,7 @@ void RE_FreeAllPersistentData(void); /** * Free persistent render data, optionally only for the given scene. */ -void RE_FreePersistentData(const Scene *scene); +void RE_FreePersistentData(const struct Scene *scene); /** * Get results and statistics. diff --git a/source/blender/sequencer/intern/clipboard.c b/source/blender/sequencer/intern/clipboard.c index 886ee89595b..82599a5fb69 100644 --- a/source/blender/sequencer/intern/clipboard.c +++ b/source/blender/sequencer/intern/clipboard.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index a35e83a8632..909954b99f1 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 51e4613f088..3caf965a608 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Peter Schlaile <peter [at] schlaile [dot] de> 2010 + * Copyright 2010 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c index 6cd53f08b3a..42a5f5df787 100644 --- a/source/blender/sequencer/intern/iterator.c +++ b/source/blender/sequencer/intern/iterator.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/multiview.c b/source/blender/sequencer/intern/multiview.c index 68d2a33fd5c..2658846209f 100644 --- a/source/blender/sequencer/intern/multiview.c +++ b/source/blender/sequencer/intern/multiview.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index 5982f89a287..906474f301d 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/proxy_job.c b/source/blender/sequencer/intern/proxy_job.c index afdac04d998..8989d7959c9 100644 --- a/source/blender/sequencer/intern/proxy_job.c +++ b/source/blender/sequencer/intern/proxy_job.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index a6c627e5ce7..08c81096b14 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index 8e824f59dda..387b65648a4 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/sound.c b/source/blender/sequencer/intern/sound.c index 0788003fb12..141b07cebbe 100644 --- a/source/blender/sequencer/intern/sound.c +++ b/source/blender/sequencer/intern/sound.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index dd8966acfd8..eb34d287dcc 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index 0479d3012fa..0d6a94a806d 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c index 7e7fc9e6bf7..a716bd6fed8 100644 --- a/source/blender/sequencer/intern/strip_relations.c +++ b/source/blender/sequencer/intern/strip_relations.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_select.c b/source/blender/sequencer/intern/strip_select.c index 8927e092864..c73e7d3a420 100644 --- a/source/blender/sequencer/intern/strip_select.c +++ b/source/blender/sequencer/intern/strip_select.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c index 31ee20cb6ca..2d36ab0654b 100644 --- a/source/blender/sequencer/intern/strip_time.c +++ b/source/blender/sequencer/intern/strip_time.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index 432fc1c166f..f4f492708eb 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 140aa2d67c5..fa34f0d6c79 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */ /** \file diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1d26c58bcf9..cff4287a2d0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -356,10 +356,10 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { if (wm_start_with_console) { - GHOST_toggleConsole(1); + setConsoleWindowState(GHOST_kConsoleWindowStateShow); } else { - GHOST_toggleConsole(3); + setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6c9b0af5186..2c82d8f5b6b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2046,7 +2046,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - GHOST_toggleConsole(2); + setConsoleWindowState(GHOST_kConsoleWindowStateToggle); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a7b5b9bddda..7e4acf709b7 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -13,9 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 Blender Foundation but based - * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV - * All rights reserved. + * Copyright 2001-2002 by NaN Holding BV. All rights reserved. + * 2007 Blender Foundation */ /** \file |