diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-08-01 22:27:08 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-08-01 22:27:08 +0300 |
commit | f04a5ad1e44c389f260d6c36ead72abac9b22384 (patch) | |
tree | 84f7fd5883a46fbeafa852cf25804fa8b2dfd3d8 /source | |
parent | ab1455e9720fbcd20707562df0a7943b902555a5 (diff) | |
parent | aa0322524ea6f59068dc4ea9cef5e6f3e2a7979a (diff) |
Merge branch 'master' into soc-2019-openxr
Diffstat (limited to 'source')
392 files changed, 2357 insertions, 1764 deletions
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 9e6f2dd6b52..6647ca83bd6 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -1093,10 +1093,11 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); if (read_mesh != mesh) { - BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true); - /* XXX fixme after 2.80; mesh->flag isn't copied by BKE_mesh_nomain_to_mesh() */ - mesh->flag |= (read_mesh->flag & ME_AUTOSMOOTH); + /* read_mesh can be freed by BKE_mesh_nomain_to_mesh(), so get the flag before that happens. */ + short autosmooth = (read_mesh->flag & ME_AUTOSMOOTH); + BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true); + mesh->flag |= autosmooth; } if (m_settings->validate_meshes) { diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index 7b0d94a2305..f863fe4fee7 100644 --- a/source/blender/alembic/intern/abc_object.cc +++ b/source/blender/alembic/intern/abc_object.cc @@ -335,8 +335,10 @@ void AbcObjectReader::read_matrix(float r_mat[4][4], mul_m4_m4m4(r_mat, m_object->parent->obmat, r_mat); } else { - /* This can happen if the user deleted the parent object. */ - unit_m4(r_mat); + /* This can happen if the user deleted the parent object, but also if the Alembic parent was + * not imported (because of unknown/unsupported schema, for example). In that case just use + * the local matrix as if it is the world matrix. This allows us to import Alembic files from + * MeshRoom, see T61935. */ } } else { diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index b502692d0e5..d63b310fef7 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -19,7 +19,6 @@ */ #include "../ABC_alembic.h" -#include <boost/foreach.hpp> #include <Alembic/AbcMaterial/IMaterial.h> @@ -567,11 +566,10 @@ static std::pair<bool, AbcObjectReader *> visit_object( /* We can now assign this reader as parent for our children. */ if (nonclaiming_child_readers.size() + assign_as_parent.size() > 0) { - /* TODO: When we only support C++11, use for (a: b) instead. */ - BOOST_FOREACH (AbcObjectReader *child_reader, nonclaiming_child_readers) { + for (AbcObjectReader *child_reader : nonclaiming_child_readers) { child_reader->parent_reader = reader; } - BOOST_FOREACH (AbcObjectReader *child_reader, assign_as_parent) { + for (AbcObjectReader *child_reader : assign_as_parent) { child_reader->parent_reader = reader; } } @@ -582,14 +580,14 @@ static std::pair<bool, AbcObjectReader *> visit_object( * our non-claiming children. Since all claiming children share * the same XForm, it doesn't really matter which one we pick. */ AbcObjectReader *claiming_child = claiming_child_readers[0]; - BOOST_FOREACH (AbcObjectReader *child_reader, nonclaiming_child_readers) { + for (AbcObjectReader *child_reader : nonclaiming_child_readers) { child_reader->parent_reader = claiming_child; } - BOOST_FOREACH (AbcObjectReader *child_reader, assign_as_parent) { + for (AbcObjectReader *child_reader : assign_as_parent) { child_reader->parent_reader = claiming_child; } /* Claiming children should have our parent set as their parent. */ - BOOST_FOREACH (AbcObjectReader *child_reader, claiming_child_readers) { + for (AbcObjectReader *child_reader : claiming_child_readers) { r_assign_as_parent.push_back(child_reader); } } @@ -597,13 +595,13 @@ static std::pair<bool, AbcObjectReader *> visit_object( /* This object isn't claimed by any child, and didn't produce * a reader. Odd situation, could be the top Alembic object, or * an unsupported Alembic schema. Delegate to our parent. */ - BOOST_FOREACH (AbcObjectReader *child_reader, claiming_child_readers) { + for (AbcObjectReader *child_reader : claiming_child_readers) { r_assign_as_parent.push_back(child_reader); } - BOOST_FOREACH (AbcObjectReader *child_reader, nonclaiming_child_readers) { + for (AbcObjectReader *child_reader : nonclaiming_child_readers) { r_assign_as_parent.push_back(child_reader); } - BOOST_FOREACH (AbcObjectReader *child_reader, assign_as_parent) { + for (AbcObjectReader *child_reader : assign_as_parent) { r_assign_as_parent.push_back(child_reader); } } @@ -782,7 +780,7 @@ static void import_endjob(void *user_data) std::vector<AbcObjectReader *>::iterator iter; - /* Delete objects on cancelation. */ + /* Delete objects on cancellation. */ if (data->was_cancelled) { for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { Object *ob = (*iter)->object(); diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 64a8c78cfef..fa8e294bdc1 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -217,10 +217,10 @@ void BKE_fcurves_id_cb(struct ID *id, ID_FCurve_Edit_Callback func, void *user_d typedef struct NlaKeyframingContext NlaKeyframingContext; struct NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *cache, - struct Depsgraph *depsgraph, struct PointerRNA *ptr, struct AnimData *adt, - float ctime); + float ctime, + const bool flush_to_original); bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, struct PointerRNA *prop_ptr, struct PropertyRNA *prop, @@ -244,12 +244,12 @@ typedef enum eAnimData_Recalc { } eAnimData_Recalc; /* Evaluation loop for evaluating animation data */ -void BKE_animsys_evaluate_animdata(struct Depsgraph *depsgraph, - struct Scene *scene, +void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, - short recalc); + short recalc, + const bool flush_to_original); /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */ void BKE_animsys_evaluate_all_animation(struct Main *main, @@ -269,10 +269,10 @@ bool BKE_animsys_execute_fcurve(struct PointerRNA *ptr, struct FCurve *fcu, floa */ /* Evaluate Action (F-Curve Bag) */ -void animsys_evaluate_action(struct Depsgraph *depsgraph, - struct PointerRNA *ptr, +void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, - float ctime); + float ctime, + const bool flush_to_original); /* Evaluate Action Group */ void animsys_evaluate_action_group(struct PointerRNA *ptr, diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 062e185eb23..ced9f4a3153 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ * \note Use #STRINGIFY() rather than defining with quotes. */ #define BLENDER_VERSION 281 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 /** Several breakages with 280, e.g. collections vs layers. */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index 7fc27321fc7..2bff684948d 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -52,6 +52,7 @@ struct UserDef *BKE_blendfile_userdef_read(const char *filepath, struct ReportLi struct UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf, int filelength, struct ReportList *reports); +struct UserDef *BKE_blendfile_userdef_from_defaults(void); bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports); diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 0d2998cc51e..53976b4c1ad 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -318,7 +318,14 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list); * evaluated data points of view. * * NOTE: Can not be used if access to a fully evaluated datablock is needed. */ -struct Depsgraph *CTX_data_depsgraph(const bContext *C); +struct Depsgraph *CTX_data_depsgraph_pointer(const bContext *C); + +/* Get dependency graph which is expected to be fully evaluated. + * + * In the release builds it is the same as CTX_data_depsgraph_pointer(). In the debug builds extra + * sanity checks are done. Additionally, this provides more semantic meaning to what is exactly + * expected to happen. */ +struct Depsgraph *CTX_data_expect_evaluated_depsgraph(const bContext *C); /* Gets fully updated and evaluated dependency graph. * @@ -326,7 +333,7 @@ struct Depsgraph *CTX_data_depsgraph(const bContext *C); * * NOTE: Will be expensive if there are relations or objects tagged for update. * NOTE: If there are pending updates depsgraph hooks will be invoked. */ -struct Depsgraph *CTX_data_evaluated_depsgraph(const bContext *C); +struct Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C); /* Will Return NULL if depsgraph is not allocated yet. * Only used by handful of operators which are run on file load. diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index df1e7a7baea..51ff4673aba 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -109,6 +109,7 @@ void BKE_curve_transform(struct Curve *cu, const bool do_props); void BKE_curve_translate(struct Curve *cu, float offset[3], const bool do_keys); void BKE_curve_material_index_remove(struct Curve *cu, int index); +bool BKE_curve_material_index_used(struct Curve *cu, int index); void BKE_curve_material_index_clear(struct Curve *cu); bool BKE_curve_material_index_validate(struct Curve *cu); void BKE_curve_material_remap(struct Curve *cu, const unsigned int *remap, unsigned int remap_len); diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index ae1000d1b99..60e9e6b91d3 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -87,6 +87,7 @@ void BKE_gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe /* materials */ void BKE_gpencil_material_index_reassign(struct bGPdata *gpd, int totcol, int index); +bool BKE_gpencil_material_index_used(struct bGPdata *gpd, int index); void BKE_gpencil_material_remap(struct bGPdata *gpd, const unsigned int *remap, unsigned int remap_len); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 9d8b9218a79..b1200c7e608 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -28,6 +28,7 @@ extern "C" { #endif +struct bNode; struct ID; struct Main; struct Material; @@ -89,11 +90,13 @@ void assign_matarar(struct Main *bmain, struct Object *ob, struct Material ***ma short BKE_object_material_slot_find_index(struct Object *ob, struct Material *ma); bool BKE_object_material_slot_add(struct Main *bmain, struct Object *ob); bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob); +bool BKE_object_material_slot_used(struct ID *id, short actcol); struct MaterialGPencilStyle *BKE_material_gpencil_settings_get(struct Object *ob, short act); void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma); void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob); +struct bNode *BKE_texpaint_slot_material_find_node(struct Material *ma, short texpaint_slot); /* rna api */ void BKE_material_resize_id(struct Main *bmain, struct ID *id, short totcol, bool do_id_user); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index d6b4fa72281..59812df246f 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -105,6 +105,7 @@ void BKE_mesh_looptri_get_real_edges(const struct Mesh *mesh, void BKE_mesh_free(struct Mesh *me); void BKE_mesh_init(struct Mesh *me); +void BKE_mesh_clear_geometry(struct Mesh *me); struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name); void BKE_mesh_copy_data(struct Main *bmain, struct Mesh *me_dst, @@ -181,6 +182,7 @@ void BKE_mesh_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob); void BKE_mesh_material_index_remove(struct Mesh *me, short index); +bool BKE_mesh_material_index_used(struct Mesh *me, short index); void BKE_mesh_material_index_clear(struct Mesh *me); void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len); void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 6509788932c..f018e912945 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -90,10 +90,10 @@ void txt_backspace_word(struct Text *text); bool txt_add_char(struct Text *text, unsigned int add); bool txt_add_raw_char(struct Text *text, unsigned int add); bool txt_replace_char(struct Text *text, unsigned int add); -void txt_unindent(struct Text *text); +bool txt_unindent(struct Text *text); void txt_comment(struct Text *text); void txt_indent(struct Text *text); -void txt_uncomment(struct Text *text); +bool txt_uncomment(struct Text *text); void txt_move_lines(struct Text *text, const int direction); void txt_duplicate_line(struct Text *text); int txt_setcurr_tab_spaces(struct Text *text, int space); diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 4d008f8d249..9da28c849d9 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -43,6 +43,7 @@ enum { FFMPEG_MKV = 9, FFMPEG_OGG = 10, FFMPEG_INVALID = 11, + FFMPEG_WEBM = 12, }; enum { diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index b5e9ce4d7e4..5719fc0164b 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -58,6 +58,7 @@ set(INC_SYS ) set(SRC + ${CMAKE_SOURCE_DIR}/release/datafiles/userdef/userdef_default.c intern/CCGSubSurf.c intern/CCGSubSurf_legacy.c intern/CCGSubSurf_opensubdiv.c diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index a7159f85dc2..984de700ce7 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1612,6 +1612,6 @@ void what_does_obaction( adt.action = act; /* execute effects of Action on to workob (or it's PoseChannels) */ - BKE_animsys_evaluate_animdata(NULL, NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM, false); } } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 08faae9874b..26a2018f015 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -330,7 +330,7 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag) /** * \param flag: Control ID pointers management, * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h - * \return true is succesfully copied. + * \return true is successfully copied. */ bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag) { @@ -1882,12 +1882,11 @@ static void animsys_write_orig_anim_rna(PointerRNA *ptr, * This performs a set of standard checks. If extra checks are required, * separate code should be used. */ -static void animsys_evaluate_fcurves(Depsgraph *depsgraph, - PointerRNA *ptr, +static void animsys_evaluate_fcurves(PointerRNA *ptr, ListBase *list, - float ctime) + float ctime, + bool flush_to_original) { - const bool is_active_depsgraph = DEG_is_active(depsgraph); /* Calculate then execute each curve. */ for (FCurve *fcu = list->first; fcu; fcu = fcu->next) { /* Check if this F-Curve doesn't belong to a muted group. */ @@ -1906,7 +1905,7 @@ static void animsys_evaluate_fcurves(Depsgraph *depsgraph, if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) { const float curval = calculate_fcurve(&anim_rna, fcu, ctime); animsys_write_rna_setting(&anim_rna, curval); - if (is_active_depsgraph) { + if (flush_to_original) { animsys_write_orig_anim_rna(ptr, fcu->rna_path, fcu->array_index, curval); } } @@ -2025,10 +2024,10 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup * } /* Evaluate Action (F-Curve Bag) */ -static void animsys_evaluate_action_ex(Depsgraph *depsgraph, - PointerRNA *ptr, +static void animsys_evaluate_action_ex(PointerRNA *ptr, bAction *act, - float ctime) + float ctime, + const bool flush_to_original) { /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */ if (act == NULL) { @@ -2038,12 +2037,15 @@ static void animsys_evaluate_action_ex(Depsgraph *depsgraph, action_idcode_patch_check(ptr->id.data, act); /* calculate then execute each curve */ - animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, ctime); + animsys_evaluate_fcurves(ptr, &act->curves, ctime, flush_to_original); } -void animsys_evaluate_action(Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, float ctime) +void animsys_evaluate_action(PointerRNA *ptr, + bAction *act, + float ctime, + const bool flush_to_original) { - animsys_evaluate_action_ex(depsgraph, ptr, act, ctime); + animsys_evaluate_action_ex(ptr, act, ctime, flush_to_original); } /* ***************************************** */ @@ -2072,7 +2074,7 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe) } /* evaluate the evaluation time and influence for the strip, storing the results in the strip */ -static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, float ctime) +static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime, const bool flush_to_original) { /* now strip's evaluate F-Curves for these settings (if applicable) */ if (strip->fcurves.first) { @@ -2082,7 +2084,7 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); /* execute these settings as per normal */ - animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, ctime); + animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, ctime, flush_to_original); } /* analytically generate values for influence and time (if applicable) @@ -2115,7 +2117,7 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl /* gets the strip active at the current time for a list of strips for evaluation purposes */ NlaEvalStrip *nlastrips_ctime_get_strip( - Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime) + ListBase *list, ListBase *strips, short index, float ctime, const bool flush_to_original) { NlaStrip *strip, *estrip = NULL; NlaEvalStrip *nes; @@ -2198,7 +2200,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip( */ /* TODO: this sounds a bit hacky having a few isolated F-Curves * stuck on some data it operates on... */ - nlastrip_evaluate_controls(depsgraph, estrip, ctime); + nlastrip_evaluate_controls(estrip, ctime, flush_to_original); if (estrip->influence <= 0.0f) { return NULL; } @@ -2220,8 +2222,8 @@ NlaEvalStrip *nlastrips_ctime_get_strip( } /* evaluate controls for the relevant extents of the bordering strips... */ - nlastrip_evaluate_controls(depsgraph, estrip->prev, estrip->start); - nlastrip_evaluate_controls(depsgraph, estrip->next, estrip->end); + nlastrip_evaluate_controls(estrip->prev, estrip->start, flush_to_original); + nlastrip_evaluate_controls(estrip->next, estrip->end, flush_to_original); break; } @@ -3141,12 +3143,12 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr, } /* evaluate transition strip */ -static void nlastrip_evaluate_transition(Depsgraph *depsgraph, - PointerRNA *ptr, +static void nlastrip_evaluate_transition(PointerRNA *ptr, NlaEvalData *channels, ListBase *modifiers, NlaEvalStrip *nes, - NlaEvalSnapshot *snapshot) + NlaEvalSnapshot *snapshot, + const bool flush_to_original) { ListBase tmp_modifiers = {NULL, NULL}; NlaEvalSnapshot snapshot1, snapshot2; @@ -3187,13 +3189,13 @@ static void nlastrip_evaluate_transition(Depsgraph *depsgraph, tmp_nes.strip_mode = NES_TIME_TRANSITION_START; tmp_nes.strip = s1; nlaeval_snapshot_init(&snapshot1, channels, snapshot); - nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot1); + nlastrip_evaluate(ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot1, flush_to_original); /* second strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_END; tmp_nes.strip = s2; nlaeval_snapshot_init(&snapshot2, channels, snapshot); - nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2); + nlastrip_evaluate(ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2, flush_to_original); /* accumulate temp-buffer and full-buffer, using the 'real' strip */ nlaeval_snapshot_mix_and_free(channels, snapshot, &snapshot1, &snapshot2, nes->strip_time); @@ -3203,12 +3205,12 @@ static void nlastrip_evaluate_transition(Depsgraph *depsgraph, } /* evaluate meta-strip */ -static void nlastrip_evaluate_meta(Depsgraph *depsgraph, - PointerRNA *ptr, +static void nlastrip_evaluate_meta(PointerRNA *ptr, NlaEvalData *channels, ListBase *modifiers, NlaEvalStrip *nes, - NlaEvalSnapshot *snapshot) + NlaEvalSnapshot *snapshot, + const bool flush_to_original) { ListBase tmp_modifiers = {NULL, NULL}; NlaStrip *strip = nes->strip; @@ -3228,13 +3230,13 @@ static void nlastrip_evaluate_meta(Depsgraph *depsgraph, /* find the child-strip to evaluate */ evaltime = (nes->strip_time * (strip->end - strip->start)) + strip->start; - tmp_nes = nlastrips_ctime_get_strip(depsgraph, NULL, &strip->strips, -1, evaltime); + tmp_nes = nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime, flush_to_original); /* directly evaluate child strip into accumulation buffer... * - there's no need to use a temporary buffer (as it causes issues [T40082]) */ if (tmp_nes) { - nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, tmp_nes, snapshot); + nlastrip_evaluate(ptr, channels, &tmp_modifiers, tmp_nes, snapshot, flush_to_original); /* free temp eval-strip */ MEM_freeN(tmp_nes); @@ -3245,12 +3247,12 @@ static void nlastrip_evaluate_meta(Depsgraph *depsgraph, } /* evaluates the given evaluation strip */ -void nlastrip_evaluate(Depsgraph *depsgraph, - PointerRNA *ptr, +void nlastrip_evaluate(PointerRNA *ptr, NlaEvalData *channels, ListBase *modifiers, NlaEvalStrip *nes, - NlaEvalSnapshot *snapshot) + NlaEvalSnapshot *snapshot, + const bool flush_to_original) { NlaStrip *strip = nes->strip; @@ -3272,10 +3274,10 @@ void nlastrip_evaluate(Depsgraph *depsgraph, nlastrip_evaluate_actionclip(ptr, channels, modifiers, nes, snapshot); break; case NLASTRIP_TYPE_TRANSITION: /* transition */ - nlastrip_evaluate_transition(depsgraph, ptr, channels, modifiers, nes, snapshot); + nlastrip_evaluate_transition(ptr, channels, modifiers, nes, snapshot, flush_to_original); break; case NLASTRIP_TYPE_META: /* meta */ - nlastrip_evaluate_meta(depsgraph, ptr, channels, modifiers, nes, snapshot); + nlastrip_evaluate_meta(ptr, channels, modifiers, nes, snapshot, flush_to_original); break; default: /* do nothing */ @@ -3287,18 +3289,16 @@ void nlastrip_evaluate(Depsgraph *depsgraph, } /* write the accumulated settings to */ -void nladata_flush_channels(Depsgraph *depsgraph, - PointerRNA *ptr, +void nladata_flush_channels(PointerRNA *ptr, NlaEvalData *channels, - NlaEvalSnapshot *snapshot) + NlaEvalSnapshot *snapshot, + const bool flush_to_original) { /* sanity checks */ if (channels == NULL) { return; } - const bool is_active_depsgraph = DEG_is_active(depsgraph); - /* for each channel with accumulated values, write its value on the property it affects */ for (NlaEvalChannel *nec = channels->channels.first; nec; nec = nec->next) { NlaEvalChannelSnapshot *nec_snapshot = nlaeval_snapshot_find_channel(snapshot, nec); @@ -3312,7 +3312,7 @@ void nladata_flush_channels(Depsgraph *depsgraph, rna.prop_index = i; } animsys_write_rna_setting(&rna, value); - if (is_active_depsgraph) { + if (flush_to_original) { animsys_write_orig_anim_rna(ptr, nec->rna_path, rna.prop_index, value); } } @@ -3422,11 +3422,11 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels, * data about the currently edited strip is stored here and excluded from value calculation. * \return false if NLA evaluation isn't actually applicable. */ -static bool animsys_evaluate_nla(Depsgraph *depsgraph, - NlaEvalData *echannels, +static bool animsys_evaluate_nla(NlaEvalData *echannels, PointerRNA *ptr, AnimData *adt, float ctime, + const bool flush_to_original, NlaKeyframingContext *r_context) { NlaTrack *nlt; @@ -3473,7 +3473,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph, } /* otherwise, get strip to evaluate for this channel */ - nes = nlastrips_ctime_get_strip(depsgraph, &estrips, &nlt->strips, track_index, ctime); + nes = nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime, flush_to_original); if (nes) { nes->track = nlt; } @@ -3539,7 +3539,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph, /* add this to our list of evaluation strips */ if (r_context == NULL) { - nlastrips_ctime_get_strip(depsgraph, &estrips, &dummy_trackslist, -1, ctime); + nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime, flush_to_original); } /* If computing the context for keyframing, store data there instead of the list. */ else { @@ -3549,7 +3549,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph, NLASTRIP_EXTEND_HOLD; r_context->eval_strip = nes = nlastrips_ctime_get_strip( - depsgraph, NULL, &dummy_trackslist, -1, ctime); + NULL, &dummy_trackslist, -1, ctime, flush_to_original); /* These setting combinations require no data from strips below, so exit immediately. */ if ((nes == NULL) || @@ -3574,7 +3574,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph, /* 2. for each strip, evaluate then accumulate on top of existing channels, * but don't set values yet. */ for (nes = estrips.first; nes; nes = nes->next) { - nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes, &echannels->eval_snapshot); + nlastrip_evaluate(ptr, echannels, NULL, nes, &echannels->eval_snapshot, flush_to_original); } /* 3. free temporary evaluation data that's not used elsewhere */ @@ -3586,22 +3586,22 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph, * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into * some temp channels, where values can be accumulated in one go. */ -static void animsys_calculate_nla(Depsgraph *depsgraph, - PointerRNA *ptr, +static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, - float ctime) + float ctime, + const bool flush_to_original) { NlaEvalData echannels; nlaeval_init(&echannels); /* evaluate the NLA stack, obtaining a set of values to flush */ - if (animsys_evaluate_nla(depsgraph, &echannels, ptr, adt, ctime, NULL)) { + if (animsys_evaluate_nla(&echannels, ptr, adt, ctime, flush_to_original, NULL)) { /* reset any channels touched by currently inactive actions to default value */ animsys_evaluate_nla_domain(ptr, &echannels, adt); /* flush effects of accumulating channels in NLA to the actual data they affect */ - nladata_flush_channels(depsgraph, ptr, &echannels, &echannels.eval_snapshot); + nladata_flush_channels(ptr, &echannels, &echannels.eval_snapshot, flush_to_original); } else { /* special case - evaluate as if there isn't any NLA data */ @@ -3610,7 +3610,7 @@ static void animsys_calculate_nla(Depsgraph *depsgraph, CLOG_WARN(&LOG, "NLA Eval: Stopgap for active action on NLA Stack - no strips case"); } - animsys_evaluate_action(depsgraph, ptr, adt->action, ctime); + animsys_evaluate_action(ptr, adt->action, ctime, flush_to_original); } /* free temp data */ @@ -3629,10 +3629,10 @@ static void animsys_calculate_nla(Depsgraph *depsgraph, * \return Keyframing context, or NULL if not necessary. */ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *cache, - struct Depsgraph *depsgraph, struct PointerRNA *ptr, struct AnimData *adt, - float ctime) + float ctime, + const bool flush_to_original) { /* No remapping needed if NLA is off or no action. */ if ((adt == NULL) || (adt->action == NULL) || (adt->nla_tracks.first == NULL) || @@ -3655,7 +3655,7 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *ca ctx->adt = adt; nlaeval_init(&ctx->nla_channels); - animsys_evaluate_nla(depsgraph, &ctx->nla_channels, ptr, adt, ctime, ctx); + animsys_evaluate_nla(&ctx->nla_channels, ptr, adt, ctime, flush_to_original, ctx); BLI_assert(ELEM(ctx->strip.act, NULL, adt->action)); BLI_addtail(cache, ctx); @@ -3846,7 +3846,7 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt) * have been set already by the depsgraph. Now, we use the recalc */ void BKE_animsys_evaluate_animdata( - Depsgraph *depsgraph, Scene *scene, ID *id, AnimData *adt, float ctime, short recalc) + Scene *scene, ID *id, AnimData *adt, float ctime, short recalc, const bool flush_to_original) { PointerRNA id_ptr; @@ -3869,11 +3869,11 @@ void BKE_animsys_evaluate_animdata( /* evaluate NLA-stack * - active action is evaluated as part of the NLA stack as the last item */ - animsys_calculate_nla(depsgraph, &id_ptr, adt, ctime); + animsys_calculate_nla(&id_ptr, adt, ctime, flush_to_original); } /* evaluate Active Action only */ else if (adt->action) { - animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, ctime); + animsys_evaluate_action_ex(&id_ptr, adt->action, ctime, flush_to_original); } } @@ -3920,6 +3920,8 @@ void BKE_animsys_evaluate_all_animation(Main *main, printf("Evaluate all animation - %f\n", ctime); } + const bool flush_to_original = DEG_is_active(depsgraph); + /* macros for less typing * - only evaluate animation data for id if it has users (and not just fake ones) * - whether animdata exists is checked for by the evaluation function, though taking @@ -3929,7 +3931,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, for (id = first; id; id = id->next) { \ if (ID_REAL_USERS(id) > 0) { \ AnimData *adt = BKE_animdata_from_id(id); \ - BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \ + BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag, flush_to_original); \ } \ } \ (void)0 @@ -3948,9 +3950,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, if (ntp->nodetree) { \ AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ BKE_animsys_evaluate_animdata( \ - depsgraph, scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \ + scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM, flush_to_original); \ } \ - BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \ + BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag, flush_to_original); \ } \ } \ (void)0 @@ -4055,7 +4057,8 @@ void BKE_animsys_eval_animdata(Depsgraph *depsgraph, ID *id) * which should get handled as part of the dependency graph instead. */ Scene *scene = NULL; DEG_debug_print_eval_time(depsgraph, __func__, id->name, id, ctime); - BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, ADT_RECALC_ANIM); + const bool flush_to_original = DEG_is_active(depsgraph); + BKE_animsys_evaluate_animdata(scene, id, adt, ctime, ADT_RECALC_ANIM, flush_to_original); } void BKE_animsys_update_driver_array(ID *id) diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index e31494ecb4e..bc62ad685ef 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -32,25 +32,30 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_system.h" #include "BLI_path_util.h" #include "BLI_utildefines.h" #include "IMB_colormanagement.h" +#include "BKE_addon.h" #include "BKE_appdir.h" #include "BKE_blender.h" #include "BKE_blender_version.h" #include "BKE_blendfile.h" #include "BKE_bpath.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_ipo.h" +#include "BKE_keyconfig.h" #include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_studiolight.h" #include "BKE_workspace.h" #include "BLO_readfile.h" @@ -552,6 +557,62 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf, return userdef; } +UserDef *BKE_blendfile_userdef_from_defaults(void) +{ + UserDef *userdef = MEM_mallocN(sizeof(*userdef), __func__); + memcpy(userdef, &U_default, sizeof(*userdef)); + + /* Add-ons. */ + { + const char *addons[] = { + "io_anim_bvh", + "io_curve_svg", + "io_mesh_ply", + "io_mesh_stl", + "io_mesh_uv_layout", + "io_scene_fbx", + "io_scene_gltf2", + "io_scene_obj", + "io_scene_x3d", + }; + for (int i = 0; i < ARRAY_SIZE(addons); i++) { + bAddon *addon = BKE_addon_new(); + STRNCPY(addon->module, addons[i]); + BLI_addtail(&userdef->addons, addon); + } + } + + /* Theme. */ + { + bTheme *btheme = MEM_mallocN(sizeof(*btheme), __func__); + memcpy(btheme, &U_theme_default, sizeof(*btheme)); + + BLI_addtail(&userdef->themes, btheme); + } + +#ifdef WITH_PYTHON_SECURITY + /* use alternative setting for security nuts + * otherwise we'd need to patch the binary blob - startup.blend.c */ + userdef->flag |= USER_SCRIPT_AUTOEXEC_DISABLE; +#else + userdef->flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE; +#endif + + /* System-specific fonts directory. */ + BKE_appdir_font_folder_default(userdef->fontdir); + + userdef->memcachelimit = min_ii(BLI_system_memory_max_in_megabytes_int() / 2, + userdef->memcachelimit); + + /* Init weight paint range. */ + BKE_colorband_init(&userdef->coba_weight, true); + + /* Default studio light. */ + BKE_studiolight_default(userdef->light_param, userdef->light_ambient); + + return userdef; +} + /** * Only write the userdef in a .blend * \return success diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ec9a774a65c..709f74808a3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1400,16 +1400,45 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask) /* Uses the brush curve control to find a strength value */ float BKE_brush_curve_strength(const Brush *br, float p, const float len) { - float strength; + float strength = 1.0f; if (p >= len) { return 0; } else { p = p / len; + p = 1.0f - p; } - strength = curvemapping_evaluateF(br->curve, 0, p); + switch (br->curve_preset) { + case BRUSH_CURVE_CUSTOM: + strength = curvemapping_evaluateF(br->curve, 0, 1.0f - p); + break; + case BRUSH_CURVE_SHARP: + strength = p * p; + break; + case BRUSH_CURVE_SMOOTH: + strength = 3.0f * p * p - 2.0f * p * p * p; + break; + case BRUSH_CURVE_ROOT: + strength = sqrtf(p); + break; + case BRUSH_CURVE_LIN: + strength = p; + break; + case BRUSH_CURVE_CONSTANT: + strength = 1.0f; + break; + case BRUSH_CURVE_SPHERE: + strength = sqrtf(2 * p - p * p); + break; + case BRUSH_CURVE_POW4: + strength = p * p * p * p; + break; + case BRUSH_CURVE_INVSQUARE: + strength = p * (2.0f - p); + break; + } return strength; } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index a8f38c3c4ce..a563a8d581c 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -375,7 +375,7 @@ void BKE_camera_view_frame_ex(const Scene *scene, float facx, facy; float depth; - /* aspect correcton */ + /* aspect correction */ if (scene) { float aspx = (float)scene->r.xsch * scene->r.xasp; float aspy = (float)scene->r.ysch * scene->r.yasp; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 793dc910394..e1e4d138fd9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -5273,7 +5273,7 @@ static void constraint_copy_data_ex(bConstraint *dst, } } -/** Allocate and duplicate a single constraint, ouside of any object/pose context. */ +/** Allocate and duplicate a single constraint, outside of any object/pose context. */ bConstraint *BKE_constraint_duplicate_ex(bConstraint *src, const int flag, const bool do_extern) { bConstraint *dst = MEM_dupallocN(src); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 4ae87713aa5..2cb98d8d90b 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1348,7 +1348,7 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list) return ctx_data_collection_get(C, "editable_gpencil_strokes", list); } -Depsgraph *CTX_data_depsgraph(const bContext *C) +Depsgraph *CTX_data_depsgraph_pointer(const bContext *C) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1361,9 +1361,18 @@ Depsgraph *CTX_data_depsgraph(const bContext *C) return depsgraph; } -Depsgraph *CTX_data_evaluated_depsgraph(const bContext *C) +Depsgraph *CTX_data_expect_evaluated_depsgraph(const bContext *C) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + /* TODO(sergey): Assert that the dependency graph is fully evaluated. + * Note that first the depsgraph and scene post-eval hooks needs to run extra round of updates + * first to make check here really reliable. */ + return depsgraph; +} + +Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C) +{ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Main *bmain = CTX_data_main(C); BKE_scene_graph_evaluated_ensure(depsgraph, bmain); return depsgraph; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 931c0ed73d3..efdfa2c19bb 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -5313,6 +5313,32 @@ void BKE_curve_material_index_remove(Curve *cu, int index) } } +bool BKE_curve_material_index_used(Curve *cu, int index) +{ + const int curvetype = BKE_curve_type_get(cu); + + if (curvetype == OB_FONT) { + struct CharInfo *info = cu->strinfo; + int i; + for (i = cu->len_wchar - 1; i >= 0; i--, info++) { + if (info->mat_nr == index) { + return true; + } + } + } + else { + Nurb *nu; + + for (nu = cu->nurb.first; nu; nu = nu->next) { + if (nu->mat_nr == index) { + return true; + } + } + } + + return false; +} + void BKE_curve_material_index_clear(Curve *cu) { const int curvetype = BKE_curve_type_get(cu); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1fb29745dba..3c7ac5d8d2e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -4756,7 +4756,8 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap, for (i = 0; i < totelem; i++, data_dst = POINTER_OFFSET(data_dst, data_step), mapit++) { const int sources_num = mapit->sources_num; - const float mix_factor = laymap->mix_weights ? laymap->mix_weights[i] : laymap->mix_factor; + const float mix_factor = laymap->mix_factor * + (laymap->mix_weights ? laymap->mix_weights[i] : 1.0f); int j; if (!sources_num) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index cf6f1fdeec1..83a10344b96 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -477,7 +477,7 @@ static void curve_to_displist(Curve *cu, } /** - * \param normal_proj: Optional normal thats used to project the scanfill verts into 2d coords. + * \param normal_proj: Optional normal that's used to project the scanfill verts into 2d coords. * Pass this along if known since it saves time calculating the normal. * \param flipnormal: Flip the normal (same as passing \a normal_proj negated) */ @@ -1857,7 +1857,7 @@ void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3]) } } -/* this is confusing, there's also min_max_object, appplying the obmat... */ +/* this is confusing, there's also min_max_object, applying the obmat... */ static void boundbox_displist_object(Object *ob) { if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 936fe3b3bea..03530fc76b6 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2739,7 +2739,7 @@ static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points) int *new_n_num = MEM_callocN(sizeof(int) * active_points, "Surface Adj Counts"); if (new_n_num && new_n_index) { - /* Count symmetrized neigbors */ + /* Count symmetrized neighbors */ int total_targets = 0; for (int index = 0; index < active_points; index++) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 754b3f5876d..140d1f0d26c 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1113,7 +1113,7 @@ void calchandles_fcurve(FCurve *fcu) first->f5 = last->f5 = HD_AUTOTYPE_SPECIAL; } - /* do a second pass for auto handle: compute the handle to have 0 accelaration step */ + /* do a second pass for auto handle: compute the handle to have 0 acceleration step */ if (fcu->auto_smoothing != FCURVE_SMOOTH_NONE) { BKE_nurb_handle_smooth_fcurve(fcu->bezt, fcu->totvert, cycle); } @@ -1744,7 +1744,7 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) /* ......... */ -/* Table of Driver Varaiable Type Info Data */ +/* Table of Driver Variable Type Info Data */ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP) dvar_eval_singleProp, /* eval callback */ 1, /* number of targets used */ diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a0216e9b413..78117a4f615 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1408,7 +1408,9 @@ static bool vfont_to_curve(Object *ob, cha = towupper(cha); } - if (ob == NULL || info->mat_nr > (ob->totcol)) { + /* Only do that check in case we do have an object, otherwise all materials get erased every + * time that code is called without an object... */ + if (ob != NULL && (info->mat_nr > (ob->totcol))) { // CLOG_ERROR( // &LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr); info->mat_nr = 0; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 058c0d10b8e..133c6e7297b 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -414,7 +414,7 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) /* general flags */ gpd->flag |= GP_DATA_VIEWALIGN; gpd->flag |= GP_DATA_STROKE_FORCE_RECALC; - /* always enable object onion skin swith */ + /* always enable object onion skin switch */ gpd->flag |= GP_DATA_SHOW_ONIONSKINS; /* GP object specific settings */ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f); @@ -1662,6 +1662,22 @@ void BKE_gpencil_material_index_reassign(bGPdata *gpd, int totcol, int index) } } +/* remove strokes using a material */ +bool BKE_gpencil_material_index_used(bGPdata *gpd, int index) +{ + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + if (gps->mat_nr == index) { + return true; + } + } + } + } + + return false; +} + void BKE_gpencil_material_remap(struct bGPdata *gpd, const unsigned int *remap, unsigned int remap_len) diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index 7907be40984..34daba385f6 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -361,7 +361,7 @@ void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph, if (mti && mti->deformStroke) { mti->deformStroke(md, depsgraph, ob, gpl, gps); - /* subdivide allways requires update */ + /* subdivide always requires update */ if (md->type == eGpencilModifierType_Subdiv) { gps->flag |= GP_STROKE_RECALC_GEOMETRY; } diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 0a9178a8b6d..6b7cb181374 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -47,8 +47,8 @@ typedef struct { /* Keep alignment for readability. */ /* clang-format off */ /** - * When editing enusre that: - * - Plural need to match rna_main.c's #MainCollectionDef. + * When editing ensure that: + * - Plural needs to match rna_main.c's #MainCollectionDef. * - Keep it in sync with i18n contexts in BLT_translation.h */ static IDType idtypes[] = { diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index e03b61bfba1..adf5d55efaa 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1097,7 +1097,7 @@ static char *get_rna_access(ID *id, BLI_dynstr_append(path, buf); - /* need to add dot before property if there was anything precceding this */ + /* need to add dot before property if there was anything preceding this */ if (buf[0]) { BLI_dynstr_append(path, "."); } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 7dc04214ba5..40608285785 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -797,7 +797,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) parent_restrict, parent_layer_restrict); - /* Any remaning object bases are to be removed. */ + /* Any remaining object bases are to be removed. */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { if (view_layer->basact == base) { view_layer->basact = NULL; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index b62ec88ed24..3f095d923b1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1130,7 +1130,7 @@ void BKE_main_lib_objects_recalc_all(Main *bmain) * **************************** */ /** - * Get allocation size fo a given data-block type and optionally allocation name. + * Get allocation size of a given data-block type and optionally allocation name. */ size_t BKE_libblock_get_alloc_info(short type, const char **name) { diff --git a/source/blender/blenkernel/intern/library_idmap.c b/source/blender/blenkernel/intern/library_idmap.c index cc7e2e31d07..ab0ff5b0096 100644 --- a/source/blender/blenkernel/intern/library_idmap.c +++ b/source/blender/blenkernel/intern/library_idmap.c @@ -85,7 +85,7 @@ static struct IDNameLib_TypeMap *main_idmap_from_idcode(struct IDNameLib_Map *id * * \note When used during undo/redo, there is no guaranty that ID pointers from UI area * are not pointing to freed memory (when some IDs have been deleted). To avoid crashes - * in those cases, one can provide the 'old' (aka current) Main databse as reference. + * in those cases, one can provide the 'old' (aka current) Main database as reference. * #BKE_main_idmap_lookup_id will then check that given ID does exist in \a old_bmain * before trying to use it. * diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 691ef4a4dba..db4265d0894 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -376,7 +376,7 @@ static void library_foreach_ID_link(Main *bmain, int i; if (flag & IDWALK_RECURSE) { - /* For now, recusion implies read-only. */ + /* For now, recursion implies read-only. */ flag |= IDWALK_READONLY; data.ids_handled = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e845271d802..b01c1189fd1 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -366,6 +366,26 @@ static void material_data_index_remove_id(ID *id, short index) } } +bool BKE_object_material_slot_used(ID *id, short actcol) +{ + /* ensure we don't try get materials from non-obdata */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); + + switch (GS(id->name)) { + case ID_ME: + return BKE_mesh_material_index_used((Mesh *)id, actcol - 1); + case ID_CU: + return BKE_curve_material_index_used((Curve *)id, actcol - 1); + case ID_MB: + /* meta-elems don't have materials atm */ + return false; + case ID_GD: + return BKE_gpencil_material_index_used((bGPdata *)id, actcol - 1); + default: + return false; + } +} + static void material_data_index_clear_id(ID *id) { /* ensure we don't try get materials from non-obdata */ @@ -496,6 +516,7 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool update_data) MEM_freeN(*matar); *matar = NULL; } + test_all_objects_materials(bmain, id); if (update_data) { /* decrease mat_nr index */ @@ -1085,65 +1106,93 @@ static bNode *nodetree_uv_node_recursive(bNode *node) return NULL; } -static int count_texture_nodes_recursive(bNodeTree *nodetree) +typedef bool (*ForEachTexNodeCallback)(bNode *node, void *userdata); +static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree, + ForEachTexNodeCallback callback, + void *userdata) { - int tex_nodes = 0; - for (bNode *node = nodetree->nodes.first; node; node = node->next) { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { - tex_nodes++; + if (!callback(node, userdata)) { + return false; + } } else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) { /* recurse into the node group and see if it contains any textures */ - tex_nodes += count_texture_nodes_recursive((bNodeTree *)node->id); + if (!ntree_foreach_texnode_recursive((bNodeTree *)node->id, callback, userdata)) { + return false; + } } } + return true; +} + +static bool count_texture_nodes_cb(bNode *UNUSED(node), void *userdata) +{ + (*((int *)userdata))++; + return true; +} + +static int count_texture_nodes_recursive(bNodeTree *nodetree) +{ + int tex_nodes = 0; + ntree_foreach_texnode_recursive(nodetree, count_texture_nodes_cb, &tex_nodes); return tex_nodes; } -static void fill_texpaint_slots_recursive(bNodeTree *nodetree, - bNode *active_node, - Material *ma, - int *index) +struct FillTexPaintSlotsData { + bNode *active_node; + Material *ma; + int index; + int slot_len; +}; + +static bool fill_texpaint_slots_cb(bNode *node, void *userdata) { - for (bNode *node = nodetree->nodes.first; node; node = node->next) { - if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && - node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { - if (active_node == node) { - ma->paint_active_slot = *index; - } + struct FillTexPaintSlotsData *fill_data = userdata; - ma->texpaintslot[*index].ima = (Image *)node->id; - ma->texpaintslot[*index].interp = ((NodeTexImage *)node->storage)->interpolation; + Material *ma = fill_data->ma; + int index = fill_data->index; + fill_data->index++; - /* for new renderer, we need to traverse the treeback in search of a UV node */ - bNode *uvnode = nodetree_uv_node_recursive(node); + if (fill_data->active_node == node) { + ma->paint_active_slot = index; + } - if (uvnode) { - NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage; - ma->texpaintslot[*index].uvname = storage->uv_map; - /* set a value to index so UI knows that we have a valid pointer for the mesh */ - ma->texpaintslot[*index].valid = true; - } - else { - /* just invalidate the index here so UV map does not get displayed on the UI */ - ma->texpaintslot[*index].valid = false; - } - (*index)++; - } - else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) { - /* recurse into the node group and see if it contains any textures */ - fill_texpaint_slots_recursive((bNodeTree *)node->id, active_node, ma, index); - } + ma->texpaintslot[index].ima = (Image *)node->id; + ma->texpaintslot[index].interp = ((NodeTexImage *)node->storage)->interpolation; + + /* for new renderer, we need to traverse the treeback in search of a UV node */ + bNode *uvnode = nodetree_uv_node_recursive(node); + + if (uvnode) { + NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage; + ma->texpaintslot[index].uvname = storage->uv_map; + /* set a value to index so UI knows that we have a valid pointer for the mesh */ + ma->texpaintslot[index].valid = true; } + else { + /* just invalidate the index here so UV map does not get displayed on the UI */ + ma->texpaintslot[index].valid = false; + } + + return fill_data->index != fill_data->slot_len; +} + +static void fill_texpaint_slots_recursive(bNodeTree *nodetree, + bNode *active_node, + Material *ma, + int slot_len) +{ + struct FillTexPaintSlotsData fill_data = {active_node, ma, 0, slot_len}; + ntree_foreach_texnode_recursive(nodetree, fill_texpaint_slots_cb, &fill_data); } void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma) { int count = 0; - int index = 0; if (!ma) { return; @@ -1182,7 +1231,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma) bNode *active_node = nodeGetActiveTexture(ma->nodetree); - fill_texpaint_slots_recursive(ma->nodetree, active_node, ma, &index); + fill_texpaint_slots_recursive(ma->nodetree, active_node, ma, count); ma->tot_slots = count; @@ -1207,6 +1256,31 @@ void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob) } } +struct FindTexPaintNodeData { + bNode *node; + short iter_index; + short index; +}; + +static bool texpaint_slot_node_find_cb(bNode *node, void *userdata) +{ + struct FindTexPaintNodeData *find_data = userdata; + if (find_data->iter_index++ == find_data->index) { + find_data->node = node; + return false; + } + + return true; +} + +bNode *BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot) +{ + struct FindTexPaintNodeData find_data = {NULL, 0, texpaint_slot}; + ntree_foreach_texnode_recursive(ma->nodetree, texpaint_slot_node_find_cb, &find_data); + + return find_data.node; +} + /* r_col = current value, col = new value, (fac == 0) is no change */ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9e01bfe62d6..7e755e54eaa 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -40,6 +40,7 @@ #include "BKE_idcode.h" #include "BKE_main.h" #include "BKE_global.h" +#include "BKE_key.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_library.h" @@ -479,20 +480,38 @@ bool BKE_mesh_has_custom_loop_normals(Mesh *me) /** Free (or release) any data used by this mesh (does not free the mesh itself). */ void BKE_mesh_free(Mesh *me) { - BKE_animdata_free(&me->id, false); + BKE_mesh_clear_geometry(me); + MEM_SAFE_FREE(me->mat); +} + +void BKE_mesh_clear_geometry(Mesh *mesh) +{ + BKE_animdata_free(&mesh->id, false); + BKE_mesh_runtime_clear_cache(mesh); - BKE_mesh_runtime_clear_cache(me); + CustomData_free(&mesh->vdata, mesh->totvert); + CustomData_free(&mesh->edata, mesh->totedge); + CustomData_free(&mesh->fdata, mesh->totface); + CustomData_free(&mesh->ldata, mesh->totloop); + CustomData_free(&mesh->pdata, mesh->totpoly); - CustomData_free(&me->vdata, me->totvert); - CustomData_free(&me->edata, me->totedge); - CustomData_free(&me->fdata, me->totface); - CustomData_free(&me->ldata, me->totloop); - CustomData_free(&me->pdata, me->totpoly); + MEM_SAFE_FREE(mesh->bb); + MEM_SAFE_FREE(mesh->mselect); + MEM_SAFE_FREE(mesh->edit_mesh); - MEM_SAFE_FREE(me->mat); - MEM_SAFE_FREE(me->bb); - MEM_SAFE_FREE(me->mselect); - MEM_SAFE_FREE(me->edit_mesh); + /* Note that materials and shape keys are not freed here. This is intentional, as freeing + * shape keys requires tagging the depsgraph for updated relations, which is expensive. + * Material slots should be kept in sync with the object.*/ + + mesh->totvert = 0; + mesh->totedge = 0; + mesh->totface = 0; + mesh->totloop = 0; + mesh->totpoly = 0; + mesh->act_face = -1; + mesh->totselect = 0; + + BKE_mesh_update_customdata_pointers(mesh, false); } static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) @@ -1187,6 +1206,27 @@ void BKE_mesh_material_index_remove(Mesh *me, short index) } } +bool BKE_mesh_material_index_used(Mesh *me, short index) +{ + MPoly *mp; + MFace *mf; + int i; + + for (mp = me->mpoly, i = 0; i < me->totpoly; i++, mp++) { + if (mp->mat_nr == index) { + return true; + } + } + + for (mf = me->mface, i = 0; i < me->totface; i++, mf++) { + if (mf->mat_nr == index) { + return true; + } + } + + return false; +} + void BKE_mesh_material_index_clear(Mesh *me) { MPoly *mp; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c23fe30d311..656ec50f31b 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -802,7 +802,7 @@ bool modifiers_usesSubsurfFacedots(struct Scene *scene, Object *ob) } } else if (mti->type == eModifierTypeType_OnlyDeform) { - /* Theses modifiers do not reset the subdiv flag nor change the topology. + /* These modifiers do not reset the subdiv flag nor change the topology. * We can still search for a subsurf modifier. */ } else { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 69ba7ccab8e..eb2f23a7b2a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1823,7 +1823,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target) else { /* only on local objects because this causes indirect links * 'a -> b -> c', blend to point directly to a.blend - * when a.blend has a proxy thats linked into c.blend */ + * when a.blend has a proxy that's linked into c.blend */ if (!ID_IS_LINKED(ob)) { id_lib_extern((ID *)dtar->id); } @@ -2562,7 +2562,8 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) { /* Execute drivers and animation. */ - BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); + const bool flush_to_original = DEG_is_active(depsgraph); + BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL, flush_to_original); object_where_is_calc_ex(depsgraph, scene, ob, ctime, NULL, NULL); } @@ -4335,6 +4336,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, float frame, int type) { + const bool flush_to_original = DEG_is_active(depsgraph); ModifierData *md = modifiers_findByType(ob, (ModifierType)type); bConstraint *con; @@ -4399,7 +4401,8 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, /* TODO(sergey): What about animation? */ ob->id.recalc |= ID_RECALC_ALL; if (update_mesh) { - BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata( + scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM, flush_to_original); /* ignore cache clear during subframe updates * to not mess up cache validity */ object_cacheIgnoreClear(ob, 1); @@ -4413,12 +4416,14 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, /* for curve following objects, parented curve has to be updated too */ if (ob->type == OB_CURVE) { Curve *cu = ob->data; - BKE_animsys_evaluate_animdata(depsgraph, scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata( + scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM, flush_to_original); } /* and armatures... */ if (ob->type == OB_ARMATURE) { bArmature *arm = ob->data; - BKE_animsys_evaluate_animdata(depsgraph, scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata( + scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM, flush_to_original); BKE_pose_where_is(depsgraph, scene, ob); } diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c index fbf586e3f49..a252329b635 100644 --- a/source/blender/blenkernel/intern/paint_toolslots.c +++ b/source/blender/blenkernel/intern/paint_toolslots.c @@ -67,11 +67,21 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain) for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; paint_toolslots_init(bmain, &ts->imapaint.paint); - paint_toolslots_init(bmain, &ts->sculpt->paint); - paint_toolslots_init(bmain, &ts->vpaint->paint); - paint_toolslots_init(bmain, &ts->wpaint->paint); - paint_toolslots_init(bmain, &ts->uvsculpt->paint); - paint_toolslots_init(bmain, &ts->gp_paint->paint); + if (ts->sculpt) { + paint_toolslots_init(bmain, &ts->sculpt->paint); + } + if (ts->vpaint) { + paint_toolslots_init(bmain, &ts->vpaint->paint); + } + if (ts->wpaint) { + paint_toolslots_init(bmain, &ts->wpaint->paint); + } + if (ts->uvsculpt) { + paint_toolslots_init(bmain, &ts->uvsculpt->paint); + } + if (ts->gp_paint) { + paint_toolslots_init(bmain, &ts->gp_paint->paint); + } } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b80f64e3472..64616af945f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4259,7 +4259,7 @@ static void get_child_modifier_parameters(ParticleSettings *part, ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_twist); } } -/* get's hair (or keyed) particles state at the "path time" specified in state->time */ +/* gets hair (or keyed) particles state at the "path time" specified in state->time */ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *state, diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e12537784f3..5685e5cd05e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3753,8 +3753,9 @@ static void dynamics_step_sph_classical_calc_density_task_cb_ex( sphclassical_calc_dens(pa, pa->state.time, sphdata); } -static void dynamics_step_sph_classical_integrate_task_cb_ex( - void *__restrict userdata, const int p, const TaskParallelTLS *__restrict tls) +static void dynamics_step_sph_classical_integrate_task_cb_ex(void *__restrict userdata, + const int p, + const TaskParallelTLS *__restrict tls) { DynamicStepSolverTaskData *data = userdata; ParticleSimulationData *sim = data->sim; @@ -4662,7 +4663,7 @@ void particle_system_update(struct Depsgraph *depsgraph, hcfra = 100.0f * (float)i / (float)psys->part->hair_step; if ((part->flag & PART_HAIR_REGROW) == 0) { BKE_animsys_evaluate_animdata( - depsgraph, scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM); + scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM, false); } system_step(&sim, hcfra, use_render_params); psys->cfra = hcfra; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b577efd2a22..bf33e076e32 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3810,7 +3810,7 @@ void BKE_ptcache_remove(void) closedir(dir); } else { - rmdir = 0; /* path dosnt exist */ + rmdir = 0; /* path doesn't exist */ } if (rmdir) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index c2d51b72b29..b29e07bb56d 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3336,8 +3336,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr /* anim-data */ adt = BKE_animdata_from_id(&mask->id); - BKE_animsys_evaluate_animdata( - context->depsgraph, context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM, false); maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__); @@ -3711,7 +3710,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context, case SEQ_TYPE_SCENE: { if (seq->flag & SEQ_SCENE_STRIPS) { if (seq->scene && (context->scene != seq->scene)) { - /* recusrive check */ + /* recursive check */ if (BLI_linklist_index(state->scene_parents, seq->scene) != -1) { break; } @@ -4645,7 +4644,7 @@ void BKE_sequence_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag) BKE_sequence_tx_set_final_left(seq, seq_tx_get_end(seq) - 1); } - /* dosnt work now - TODO */ + /* doesn't work now - TODO */ #if 0 if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) { int ofs; @@ -5836,7 +5835,7 @@ static Sequence *seq_dupli(const Scene *scene_src, /* When using SEQ_DUPE_UNIQUE_NAME, it is mandatory to add new sequences in relevant container * (scene or meta's one), *before* checking for unique names. Otherwise the meta's list is empty * and hence we miss all seqs in that meta that have already been duplicated (see T55668). - * Note that unique name check itslef could be done at a later step in calling code, once all + * Note that unique name check itself could be done at a later step in calling code, once all * seqs have bee duplicated (that was first, simpler solution), but then handling of animation * data will be broken (see T60194). */ if (new_seq_list != NULL) { diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 1dcbf7615f7..688af539bbb 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -3523,7 +3523,7 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la // get starting cell (light pos) if (BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON) { - // we're ouside -> use point on side of domain + // we're outside -> use point on side of domain cell[0] = (int)floor(pos[0]); cell[1] = (int)floor(pos[1]); cell[2] = (int)floor(pos[2]); diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 03fbdc24ce4..2024a507ebb 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -258,7 +258,7 @@ static float _final_mass(Object *ob, BodyPoint *bp) /* just an ID here to reduce the prob for killing objects * ob->sumohandle points to we should not kill :) */ -static const int CCD_SAVETY = 190561; +static const int CCD_SAFETY = 190561; typedef struct ccdf_minmax { float minx, miny, minz, maxx, maxy, maxz; @@ -269,7 +269,7 @@ typedef struct ccd_Mesh { const MVert *mvert; const MVert *mprevvert; const MVertTri *tri; - int savety; + int safety; ccdf_minmax *mima; /* Axis Aligned Bounding Box AABB */ float bbmin[3]; @@ -298,7 +298,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) pccd_M = MEM_mallocN(sizeof(ccd_Mesh), "ccd_Mesh"); pccd_M->mvert_num = cmd->mvert_num; pccd_M->tri_num = cmd->tri_num; - pccd_M->savety = CCD_SAVETY; + pccd_M->safety = CCD_SAFETY; pccd_M->bbmin[0] = pccd_M->bbmin[1] = pccd_M->bbmin[2] = 1e30f; pccd_M->bbmax[0] = pccd_M->bbmax[1] = pccd_M->bbmax[2] = -1e30f; pccd_M->mprevvert = NULL; @@ -486,7 +486,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M) static void ccd_mesh_free(ccd_Mesh *ccdm) { - if (ccdm && (ccdm->savety == CCD_SAVETY)) { /*make sure we're not nuking objects we don't know*/ + /* Make sure we're not nuking objects we don't know. */ + if (ccdm && (ccdm->safety == CCD_SAFETY)) { MEM_freeN((void *)ccdm->mvert); MEM_freeN((void *)ccdm->tri); if (ccdm->mprevvert) { @@ -751,7 +752,7 @@ static void build_bps_springlist(Object *ob) int a, b; if (sb == NULL) { - return; /* paranoya check */ + return; /* paranoia check */ } for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) { @@ -781,7 +782,7 @@ static void calculate_collision_balls(Object *ob) float min, max, akku; if (sb == NULL) { - return; /* paranoya check */ + return; /* paranoia check */ } for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) { @@ -3322,7 +3323,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int copy_v3_v3(bp->prevdv, bp->vec); } - /* make a nice clean scratch struc */ + /* make a nice clean scratch struct */ free_scratch(sb); /* clear if any */ sb_new_scratch(sb); /* make a new */ sb->scratch->needstobuildcollider = 1; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 6d782726e07..6cbb01861e2 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -898,7 +898,7 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) { bool need_close_audio_handles = false; if (sound->playback_handle == NULL) { - /* TOOD(sergey): Make it fully independent audio handle. */ + /* TODO(sergey): Make it fully independent audio handle. */ sound_load_audio(bmain, sound); need_close_audio_handles = true; } @@ -1092,7 +1092,7 @@ bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *soun if (sound->playback_handle != NULL) { return sound_info_from_playback_handle(sound->playback_handle, sound_info); } - /* TOOD(sergey): Make it fully independent audio handle. */ + /* TODO(sergey): Make it fully independent audio handle. */ sound_load_audio(main, sound); const bool result = sound_info_from_playback_handle(sound->playback_handle, sound_info); sound_free_audio(sound); diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 472fbd9ad18..d346d4d6f8d 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -973,7 +973,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg, prev_grid = grid; } /* Average all grids centers into a single accumulator, and share it. - * Guarantees corrent and smooth averaging in the center. */ + * Guarantees correct and smooth averaging in the center. */ GridElementAccumulator center_accumulator; element_accumulator_init(¢er_accumulator); for (int corner = 0; corner < num_face_grids; corner++) { diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index c3f9bc3400c..f9039767f53 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -172,7 +172,7 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx) const MPoly *coarse_mpoly = coarse_mesh->mpoly; ctx->num_subdiv_vertices = coarse_mesh->totvert; ctx->num_subdiv_edges = coarse_mesh->totedge * (num_subdiv_vertices_per_coarse_edge + 1); - /* Calculate extra vertices and edges createdd by non-loose geometry. */ + /* Calculate extra vertices and edges created by non-loose geometry. */ for (int poly_index = 0; poly_index < coarse_mesh->totpoly; poly_index++) { const MPoly *coarse_poly = &coarse_mpoly[poly_index]; const int num_ptex_faces_per_poly = num_ptex_faces_per_poly_get(coarse_poly); @@ -206,7 +206,7 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx) num_polys_per_ptex_get(no_quad_patch_resolution); } } - /* Calculate extra vertices createdd by loose edges. */ + /* Calculate extra vertices created by loose edges. */ for (int edge_index = 0; edge_index < coarse_mesh->totedge; edge_index++) { if (!BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, edge_index)) { ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 056229ceb1c..29aa3ca1659 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2045,11 +2045,12 @@ static void txt_select_prefix(Text *text, const char *add) * * \note caller must handle undo. */ -static void txt_select_unprefix(Text *text, const char *remove) +static bool txt_select_unprefix(Text *text, const char *remove) { int num = 0; const int indentlen = strlen(remove); bool unindented_first = false; + bool changed_any = false; BLI_assert(!ELEM(NULL, text->curl, text->sell)); @@ -2062,6 +2063,7 @@ static void txt_select_unprefix(Text *text, const char *remove) text->curl->len -= indentlen; memmove(text->curl->line, text->curl->line + indentlen, text->curl->len + 1); changed = true; + changed_any = true; } txt_make_dirty(text); @@ -2089,6 +2091,7 @@ static void txt_select_unprefix(Text *text, const char *remove) } /* caller must handle undo */ + return changed_any; } void txt_comment(Text *text) @@ -2102,15 +2105,15 @@ void txt_comment(Text *text) txt_select_prefix(text, prefix); } -void txt_uncomment(Text *text) +bool txt_uncomment(Text *text) { const char *prefix = "#"; if (ELEM(NULL, text->curl, text->sell)) { - return; + return false; } - txt_select_unprefix(text, prefix); + return txt_select_unprefix(text, prefix); } void txt_indent(Text *text) @@ -2124,15 +2127,15 @@ void txt_indent(Text *text) txt_select_prefix(text, prefix); } -void txt_unindent(Text *text) +bool txt_unindent(Text *text) { const char *prefix = (text->flags & TXT_TABSTOSPACES) ? tab_to_spaces : "\t"; if (ELEM(NULL, text->curl, text->sell)) { - return; + return false; } - txt_select_unprefix(text, prefix); + return txt_select_unprefix(text, prefix); } void txt_move_lines(struct Text *text, const int direction) diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c index 84855cf4b82..47c12b329dc 100644 --- a/source/blender/blenkernel/intern/tracking_auto.c +++ b/source/blender/blenkernel/intern/tracking_auto.c @@ -42,7 +42,7 @@ #include "tracking_private.h" typedef struct AutoTrackOptions { - int clip_index; /** Index of the clip this track belogs to. */ + int clip_index; /** Index of the clip this track belongs to. */ int track_index; /* Index of the track in AutoTrack tracks structure. */ MovieTrackingTrack *track; /* Pointer to an original track/ */ libmv_TrackRegionOptions track_region_options; /* Options for the region tracker. */ @@ -50,7 +50,7 @@ typedef struct AutoTrackOptions { /* TODO(sergey): A bit awkward to keep it in here, only used to * place a disabled marker once the tracking fails, - * Wither find a more clear way to do it or call it track context + * Either find a clearer way to do it or call it track context * or state, not options. */ bool is_failed; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 7e7d5c82654..375721057c3 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -112,6 +112,8 @@ enum { B_UNIT_DEF_TENTH = 2, /** Short unit name is case sensitive, for example to distinguish mW and MW */ B_UNIT_DEF_CASE_SENSITIVE = 4, + /** Short unit name does not have space between it and preceding number */ + B_UNIT_DEF_NO_SPACE = 8, }; /* define a single unit */ @@ -161,8 +163,8 @@ static struct bUnitDef buImperialLenDef[] = { {"furlong", "furlongs", "fur", NULL, "Furlongs", "FURLONGS", UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, {"chain", "chains", "ch", NULL, "Chains", "CHAINS", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, {"yard", "yards", "yd", NULL, "Yards", "YARDS", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, - {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, {"thou", "thou", "thou", "mil", "Thou", "THOU", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ NULL_UNIT, }; @@ -289,10 +291,10 @@ static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, static struct bUnitDef buNaturalRotDef[] = { - {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE}, + {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, /* arcminutes/arcseconds are used in Astronomy/Navigation areas... */ - {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE}, + {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE}, {"radian", "radians", "r", NULL, "Radians", "RADIANS", 1.0, 0.0, B_UNIT_DEF_NONE}, // {"turn", "turns", "t", NULL, "Turns", NULL, 1.0 / (M_PI * 2.0), 0.0, B_UNIT_DEF_NONE}, NULL_UNIT, @@ -451,6 +453,11 @@ static size_t unit_as_string(char *str, } } + /* Now add a space for all units except foot, inch, degree, arcminute, arcsecond */ + if (!(unit->flag & B_UNIT_DEF_NO_SPACE)) { + str[++i] = ' '; + } + /* Now add the suffix */ if (i < len_max) { int j = 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index f3336adda30..5152643aaa1 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -54,6 +54,7 @@ * like M_SQRT1_2 leading to warnings with MSVC */ # include <libavformat/avformat.h> # include <libavcodec/avcodec.h> +# include <libavutil/imgutils.h> # include <libavutil/rational.h> # include <libavutil/samplefmt.h> # include <libswscale/swscale.h> @@ -80,7 +81,10 @@ typedef struct FFMpegContext { AVFormatContext *outfile; AVStream *video_stream; AVStream *audio_stream; - AVFrame *current_frame; + AVFrame *current_frame; /* Image frame in output pixel format. */ + + /* Image frame in Blender's own pixel format, may need conversion to the output pixel format. */ + AVFrame *img_convert_frame; struct SwsContext *img_convert_ctx; uint8_t *audio_input_buffer; @@ -264,6 +268,10 @@ static AVFrame *alloc_picture(int pix_fmt, int width, int height) return NULL; } avpicture_fill((AVPicture *)f, buf, pix_fmt, width, height); + f->format = pix_fmt; + f->width = width; + f->height = height; + return f; } @@ -319,6 +327,10 @@ static const char **get_file_extensions(int format) static const char *rv[] = {".ogv", ".ogg", NULL}; return rv; } + case FFMPEG_WEBM: { + static const char *rv[] = {".webm", NULL}; + return rv; + } default: return NULL; } @@ -371,67 +383,52 @@ static int write_video_frame( } /* read and encode a frame of audio from the buffer */ -static AVFrame *generate_video_frame(FFMpegContext *context, uint8_t *pixels, ReportList *reports) +static AVFrame *generate_video_frame(FFMpegContext *context, + const uint8_t *pixels, + ReportList *reports) { - uint8_t *rendered_frame; - AVCodecContext *c = context->video_stream->codec; - int width = c->width; int height = c->height; AVFrame *rgb_frame; - if (c->pix_fmt != AV_PIX_FMT_BGR32) { - rgb_frame = alloc_picture(AV_PIX_FMT_BGR32, width, height); - if (!rgb_frame) { - BKE_report(reports, RPT_ERROR, "Could not allocate temporary frame"); - return NULL; - } + if (context->img_convert_frame != NULL) { + /* Pixel format conversion is needed. */ + rgb_frame = context->img_convert_frame; } else { + /* The output pixel format is Blender's internal pixel format. */ rgb_frame = context->current_frame; } - rendered_frame = pixels; + /* Copy the Blender pixels into the FFmpeg datastructure, taking care of endianness and flipping + * the image vertically. */ + int linesize = rgb_frame->linesize[0]; + for (int y = 0; y < height; y++) { + uint8_t *target = rgb_frame->data[0] + linesize * (height - y - 1); + const uint8_t *src = pixels + linesize * y; - /* Do RGBA-conversion and flipping in one step depending - * on CPU-Endianess */ +# if ENDIAN_ORDER == L_ENDIAN + memcpy(target, src, linesize); - if (ENDIAN_ORDER == L_ENDIAN) { - int y; - for (y = 0; y < height; y++) { - uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1); - uint8_t *src = rendered_frame + width * 4 * y; - uint8_t *end = src + width * 4; - while (src != end) { - target[3] = src[3]; - target[2] = src[2]; - target[1] = src[1]; - target[0] = src[0]; +# elif ENDIAN_ORDER == B_ENDIAN + const uint8_t *end = src + linesize; + while (src != end) { + target[3] = src[0]; + target[2] = src[1]; + target[1] = src[2]; + target[0] = src[3]; - target += 4; - src += 4; - } - } - } - else { - int y; - for (y = 0; y < height; y++) { - uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1); - uint8_t *src = rendered_frame + width * 4 * y; - uint8_t *end = src + width * 4; - while (src != end) { - target[3] = src[0]; - target[2] = src[1]; - target[1] = src[2]; - target[0] = src[3]; - - target += 4; - src += 4; - } + target += 4; + src += 4; } +# else +# error ENDIAN_ORDER should either be L_ENDIAN or B_ENDIAN. +# endif } - if (c->pix_fmt != AV_PIX_FMT_BGR32) { + /* Convert to the output pixel format, if it's different that Blender's internal one. */ + if (context->img_convert_frame != NULL) { + BLI_assert(context->img_convert_ctx != NULL); sws_scale(context->img_convert_ctx, (const uint8_t *const *)rgb_frame->data, rgb_frame->linesize, @@ -439,13 +436,8 @@ static AVFrame *generate_video_frame(FFMpegContext *context, uint8_t *pixels, Re c->height, context->current_frame->data, context->current_frame->linesize); - delete_picture(rgb_frame); } - context->current_frame->format = AV_PIX_FMT_BGR32; - context->current_frame->width = width; - context->current_frame->height = height; - return context->current_frame; } @@ -696,9 +688,15 @@ static AVStream *alloc_video_stream(FFMpegContext *context, } if (codec_id == AV_CODEC_ID_QTRLE) { - /* Always write to ARGB. The default pixel format of QTRLE is RGB24, which uses 3 bytes per - * pixels, which breaks the export. */ - c->pix_fmt = AV_PIX_FMT_ARGB; + if (rd->im_format.planes == R_IMF_PLANES_RGBA) { + c->pix_fmt = AV_PIX_FMT_ARGB; + } + } + + if (codec_id == AV_CODEC_ID_VP9) { + if (rd->im_format.planes == R_IMF_PLANES_RGBA) { + c->pix_fmt = AV_PIX_FMT_YUVA420P; + } } if (codec_id == AV_CODEC_ID_PNG) { @@ -727,18 +725,29 @@ static AVStream *alloc_video_stream(FFMpegContext *context, } av_dict_free(&opts); + /* FFmpeg expects its data in the output pixel format. */ context->current_frame = alloc_picture(c->pix_fmt, c->width, c->height); - context->img_convert_ctx = sws_getContext(c->width, - c->height, - AV_PIX_FMT_BGR32, - c->width, - c->height, - c->pix_fmt, - SWS_BICUBIC, - NULL, - NULL, - NULL); + if (c->pix_fmt == AV_PIX_FMT_RGBA) { + /* Output pixel format is the same we use internally, no conversion necessary. */ + context->img_convert_frame = NULL; + context->img_convert_ctx = NULL; + } + else { + /* Output pixel format is different, allocate frame for conversion. */ + context->img_convert_frame = alloc_picture(AV_PIX_FMT_RGBA, c->width, c->height); + context->img_convert_ctx = sws_getContext(c->width, + c->height, + AV_PIX_FMT_RGBA, + c->width, + c->height, + c->pix_fmt, + SWS_BICUBIC, + NULL, + NULL, + NULL); + } + return st; } @@ -1427,6 +1436,11 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit) delete_picture(context->current_frame); context->current_frame = NULL; } + if (context->img_convert_frame != NULL) { + delete_picture(context->img_convert_frame); + context->img_convert_frame = NULL; + } + if (context->outfile != NULL && context->outfile->oformat) { if (!(context->outfile->oformat->flags & AVFMT_NOFILE)) { avio_close(context->outfile->pb); @@ -1836,25 +1850,14 @@ bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd) { int codec = rd->ffcodecdata.codec; - if (codec == AV_CODEC_ID_QTRLE) { - return true; - } - - if (codec == AV_CODEC_ID_PNG) { - return true; - } - - if (codec == AV_CODEC_ID_HUFFYUV) { - return true; - } - # ifdef FFMPEG_FFV1_ALPHA_SUPPORTED + /* Visual Studio 2019 doesn't like #ifdef within ELEM(). */ if (codec == AV_CODEC_ID_FFV1) { return true; } # endif - return false; + return ELEM(codec, AV_CODEC_ID_QTRLE, AV_CODEC_ID_PNG, AV_CODEC_ID_VP9, AV_CODEC_ID_HUFFYUV); } void *BKE_ffmpeg_context_create(void) diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h index dc086987e21..1705cd4effc 100644 --- a/source/blender/blenkernel/nla_private.h +++ b/source/blender/blenkernel/nla_private.h @@ -167,16 +167,16 @@ float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode); * in which they get defined. */ NlaEvalStrip *nlastrips_ctime_get_strip( - struct Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime); -void nlastrip_evaluate(struct Depsgraph *depsgraph, - PointerRNA *ptr, + ListBase *list, ListBase *strips, short index, float ctime, const bool flush_to_original); +void nlastrip_evaluate(PointerRNA *ptr, NlaEvalData *channels, ListBase *modifiers, NlaEvalStrip *nes, - NlaEvalSnapshot *snapshot); -void nladata_flush_channels(struct Depsgraph *depsgraph, - PointerRNA *ptr, + NlaEvalSnapshot *snapshot, + const bool flush_to_original); +void nladata_flush_channels(PointerRNA *ptr, NlaEvalData *channels, - NlaEvalSnapshot *snapshot); + NlaEvalSnapshot *snapshot, + const bool flush_to_original); #endif /* __NLA_PRIVATE_H__ */ diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index aa3d7520506..c235a72e7e4 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -171,7 +171,7 @@ struct LinkData *BLI_genericNodeN(void *data); #define LISTBASE_FOREACH(type, var, list) \ for (type var = (type)((list)->first); var != NULL; var = (type)(((Link *)(var))->next)) -/** A verion of #LISTBASE_FOREACH that supports removing the item we're looping over. */ +/** A version of #LISTBASE_FOREACH that supports removing the item we're looping over. */ #define LISTBASE_FOREACH_MUTABLE(type, var, list) \ for (type var = (type)((list)->first), *var##_iter_next; \ ((var != NULL) ? ((void)(var##_iter_next = (type)(((Link *)(var))->next)), 1) : 0); \ diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 177a1a84b16..5b941f570de 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -197,7 +197,7 @@ double double_round(double x, int ndigits); * check the vector is unit length, or zero length (which can't be helped in some cases). */ #ifndef NDEBUG -/** \note 0.0001 is too small becaues normals may be converted from short's: see T34322. */ +/** \note 0.0001 is too small because normals may be converted from short's: see T34322. */ # define BLI_ASSERT_UNIT_EPSILON 0.0002f /** * \note Checks are flipped so NAN doesn't assert. diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 216e409aee6..5d80da6de77 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -788,7 +788,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); /** Useful for debugging. */ #define AT __FILE__ ":" STRINGIFY(__LINE__) -/** No-op for expressions we don't want to instansiate, but must remian valid. */ +/** No-op for expressions we don't want to instantiate, but must remain valid. */ #define EXPR_NOP(expr) (void)(0 ? ((void)(expr), 1) : 0) /** \} */ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index f1811ff6e4f..0e93fd8e13b 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -561,7 +561,7 @@ static void bvhtree_verify(BVHTree *tree) /* Helper data and structures to build a min-leaf generalized implicit tree * This code can be easily reduced - * (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ + * (basically this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ typedef struct BVHBuildHelper { int tree_type; int totleafs; @@ -626,7 +626,7 @@ static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, con * * An implicit tree is a tree where its structure is implied, * thus there is no need to store child pointers or indexes. - * Its possible to find the position of the child or the parent with simple maths + * It's possible to find the position of the child or the parent with simple maths * (multiplication and addition). * This type of tree is for example used on heaps.. * where node N has its child at indices N*2 and N*2+1. diff --git a/source/blender/blenlib/intern/BLI_memblock.c b/source/blender/blenlib/intern/BLI_memblock.c index ec9b74f2b50..f26860afe77 100644 --- a/source/blender/blenlib/intern/BLI_memblock.c +++ b/source/blender/blenlib/intern/BLI_memblock.c @@ -55,9 +55,9 @@ struct BLI_memblock { int chunk_max_ofs; /** Id of the chunk used for the next allocation. */ int chunk_next; - /** Chunck size in bytes. */ + /** Chunk size in bytes. */ int chunk_size; - /** Number of allocated chunck. */ + /** Number of allocated chunk. */ int chunk_len; }; @@ -123,7 +123,7 @@ void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) void *BLI_memblock_alloc(BLI_memblock *mblk) { - /* Bookeeping. */ + /* Bookkeeping. */ if (mblk->elem_last < mblk->elem_next) { mblk->elem_last = mblk->elem_next; } diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 5765540a8f1..2b931507633 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -65,7 +65,7 @@ * Important that this value is an is _not_ aligned with ``sizeof(void *)``. * So having a pointer to 2/4/8... aligned memory is enough to ensure * the freeword will never be used. - * To be safe, use a word thats the same in both directions. + * To be safe, use a word that's the same in both directions. */ #define FREEWORD \ ((sizeof(void *) > sizeof(int32_t)) ? MAKE_ID_8('e', 'e', 'r', 'f', 'f', 'r', 'e', 'e') : \ diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c index 825f2e36c6e..c87dbee0f0e 100644 --- a/source/blender/blenlib/intern/array_store.c +++ b/source/blender/blenlib/intern/array_store.c @@ -82,7 +82,7 @@ * matching chunks from this state are re-used in the new state. * * First matches at either end of the array are detected. - * For identical arrays this is all thats needed. + * For identical arrays this is all that's needed. * * De-duplication is performed on any remaining chunks, by hashing the first few bytes of the chunk * (see: BCHUNK_HASH_TABLE_ACCUMULATE_STEPS). @@ -301,7 +301,7 @@ typedef struct BChunkRef { * used for lookups. * * Point to the #BChunkRef, not the #BChunk, - * to allow talking down the chunks in-order until a mis-match is found, + * to allow talking down the chunks in-order until a mismatch is found, * this avoids having to do so many table lookups. */ typedef struct BTableRef { diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c index f05523b8897..196d45967be 100644 --- a/source/blender/blenlib/intern/boxpack_2d.c +++ b/source/blender/blenlib/intern/boxpack_2d.c @@ -651,7 +651,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r } } /* The Box verts are only used internally - * Update the box x and y since thats what external + * Update the box x and y since that's what external * functions will see */ box->x = box_xmin_get(box); box->y = box_ymin_get(box); diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 8fff9603a88..0e3987eefc9 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -105,7 +105,7 @@ int BLI_file_gzip(const char *from, const char *to) #endif /* gzip the file in from_file and write it to memory to_mem, at most size bytes. - * return the unziped size + * return the unzipped size */ char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size) { @@ -519,7 +519,7 @@ enum { /* operation requested not to perform recursive digging for current path */ RecursiveOp_Callback_StopRecurs = 1, - /* error occured in callback and recursive walking should stop immediately */ + /* error occurred in callback and recursive walking should stop immediately */ RecursiveOp_Callback_Error = 2, }; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index c130c46a0fb..3a562778af7 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4941,7 +4941,7 @@ void vcloud_estimate_transform_v3(const int list_size, unit_m3(lscale); } /* do com for both clouds */ - if (pos && rpos && (list_size > 0)) { /* paranoya check */ + if (pos && rpos && (list_size > 0)) { /* paranoia check */ /* do com for both clouds */ for (a = 0; a < list_size; a++) { if (weight) { diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c index 1538b5922b1..575a4a06d6a 100644 --- a/source/blender/blenlib/intern/polyfill_2d.c +++ b/source/blender/blenlib/intern/polyfill_2d.c @@ -780,7 +780,7 @@ static void polyfill_prepare(PolyFill *pf, coords_sign = (cross_poly_v2(coords, coords_tot) >= 0.0f) ? 1 : -1; } else { - /* check we're passing in correcty args */ + /* check we're passing in correct args */ #ifdef USE_STRICT_ASSERT # ifndef NDEBUG if (coords_sign == 1) { diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 99288abb38c..ecff2ebffef 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -285,12 +285,12 @@ bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2]) return false; } - /* if either points intersect then we definetly intersect */ + /* if either points intersect then we definitely intersect */ if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) { return true; } else { - /* both points are outside but may insersect the rect */ + /* both points are outside but may intersect the rect */ int tvec1[2]; int tvec2[2]; /* diagonal: [/] */ @@ -332,12 +332,12 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[ return false; } - /* if either points intersect then we definetly intersect */ + /* if either points intersect then we definitely intersect */ if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) { return true; } else { - /* both points are outside but may insersect the rect */ + /* both points are outside but may intersect the rect */ float tvec1[2]; float tvec2[2]; /* diagonal: [/] */ diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 4ba198ac0b8..8d921b062dc 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -360,7 +360,7 @@ void *BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t * FILE *fp = BLI_fopen(filepath, "r"); void *mem = NULL; if (fp) { - mem = file_read_data_as_mem_impl(fp, true, pad_bytes, r_size); + mem = file_read_data_as_mem_impl(fp, false, pad_bytes, r_size); fclose(fp); } return mem; @@ -371,7 +371,7 @@ void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t FILE *fp = BLI_fopen(filepath, "rb"); void *mem = NULL; if (fp) { - mem = file_read_data_as_mem_impl(fp, false, pad_bytes, r_size); + mem = file_read_data_as_mem_impl(fp, true, pad_bytes, r_size); fclose(fp); } return mem; diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 1526a052aad..f0113a7028a 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -104,7 +104,7 @@ static eStrCursorDelimType cursor_delim_type_unicode(const uint uch) static eStrCursorDelimType cursor_delim_type_utf8(const char *ch_utf8) { /* for full unicode support we really need to have large lookup tables to figure - * out whats what in every possible char set - and python, glib both have these. */ + * out what's what in every possible char set - and python, glib both have these. */ uint uch = BLI_str_utf8_as_unicode(ch_utf8); return cursor_delim_type_unicode(uch); } diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 8769ed37d16..8944dfdb711 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -165,7 +165,6 @@ void BLO_main_expander(BLOExpandDoitCallback expand_doit_func); void BLO_expand_main(void *fdhandle, struct Main *mainvar); /* Update defaults in startup.blend & userprefs.blend, without having to save and embed it */ -void BLO_update_defaults_userpref_blend(void); void BLO_update_defaults_startup_blend(struct Main *mainvar, const char *app_template); void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template); @@ -176,6 +175,7 @@ struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath); /* datafiles (generated theme) */ extern const struct bTheme U_theme_default; +extern const struct UserDef U_default; #ifdef __cplusplus } diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 8ab93ba382c..1520c7b82b8 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -77,12 +77,6 @@ if(WITH_BUILDINFO) add_definitions(-DWITH_BUILDINFO) endif() -if(WITH_PYTHON) - if(WITH_PYTHON_SECURITY) - add_definitions(-DWITH_PYTHON_SECURITY) - endif() -endif() - if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6fe5c4516b5..a73ca6e896c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2419,7 +2419,7 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData array = (IDProperty *)prop->data.pointer; /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared - * theres not really anything we can do to correct this, at least don't crash */ + * there's not really anything we can do to correct this, at least don't crash */ if (array == NULL) { prop->len = 0; prop->totallen = 0; @@ -6413,12 +6413,22 @@ static void lib_link_scene(FileData *fd, Main *main) sce->set = newlibadr(fd, sce->id.lib, sce->set); sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd); - link_paint(fd, sce, &sce->toolsettings->sculpt->paint); - link_paint(fd, sce, &sce->toolsettings->vpaint->paint); - link_paint(fd, sce, &sce->toolsettings->wpaint->paint); link_paint(fd, sce, &sce->toolsettings->imapaint.paint); - link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); - link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); + if (sce->toolsettings->sculpt) { + link_paint(fd, sce, &sce->toolsettings->sculpt->paint); + } + if (sce->toolsettings->vpaint) { + link_paint(fd, sce, &sce->toolsettings->vpaint->paint); + } + if (sce->toolsettings->wpaint) { + link_paint(fd, sce, &sce->toolsettings->wpaint->paint); + } + if (sce->toolsettings->uvsculpt) { + link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); + } + if (sce->toolsettings->gp_paint) { + link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); + } if (sce->toolsettings->sculpt) { sce->toolsettings->sculpt->gravity_object = newlibadr( @@ -7127,7 +7137,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) link_list(fd, &ar->ui_previews); if (spacetype == SPACE_EMPTY) { - /* unkown space type, don't leak regiondata */ + /* unknown space type, don't leak regiondata */ ar->regiondata = NULL; } else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) { diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 17facb3ae20..81751a6ed07 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -960,7 +960,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - /* just need to initalise rotation axis properly... */ + /* just need to initialise rotation axis properly... */ pchan->rotAxis[1] = 1.0f; } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 9d9906fc3e0..3dc79308f64 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -888,7 +888,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* hysteresis setted to 10% but not actived */ + /* hysteresis set to 10% but not activated */ if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) { Object *ob; for (ob = bmain->objects.first; ob; ob = ob->id.next) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index cb2b64957f0..1a79b7c9b5a 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3533,6 +3533,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 281, 1)) { + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_DataTransfer) { + /* Now datatransfer's mix factor is multiplied with weights when any, + * instead of being ignored, + * we need to take care of that to keep 'old' files compatible. */ + DataTransferModifierData *dtmd = (DataTransferModifierData *)md; + if (dtmd->defgrp_name[0] != '\0') { + dtmd->mix_factor = 1.0f; + } + } + } + } + } + { /* Versioning code until next subversion bump goes here. */ } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 1cbafc7a707..14230752d1f 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -40,92 +40,17 @@ #include "DNA_meshdata_types.h" #include "BKE_appdir.h" -#include "BKE_brush.h" -#include "BKE_colorband.h" #include "BKE_colortools.h" -#include "BKE_idprop.h" -#include "BKE_keyconfig.h" #include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" -#include "BKE_paint.h" #include "BKE_screen.h" -#include "BKE_studiolight.h" #include "BKE_workspace.h" #include "BLO_readfile.h" /** - * Override values in in-memory startup.blend, avoids re-saving for small changes. - */ -void BLO_update_defaults_userpref_blend(void) -{ - /* default so DPI is detected automatically */ - U.dpi = 0; - U.ui_scale = 1.0f; - -#ifdef WITH_PYTHON_SECURITY - /* use alternative setting for security nuts - * otherwise we'd need to patch the binary blob - startup.blend.c */ - U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE; -#else - U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE; -#endif - - /* Transform tweak with single click and drag. */ - U.flag |= USER_RELEASECONFIRM; - - U.flag &= ~(USER_DEVELOPER_UI | USER_TOOLTIPS_PYTHON); - - /* Clear addon preferences. */ - for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) { - addon_next = addon->next; - - if (addon->prop) { - IDP_FreeProperty(addon->prop); - addon->prop = NULL; - } - } - - /* Ignore the theme saved in the blend file, - * instead use the theme from 'userdef_default_theme.c' */ - { - bTheme *theme = U.themes.first; - memcpy(theme, &U_theme_default, sizeof(bTheme)); - } - - /* Leave temp directory empty, will then get appropriate value per OS. */ - U.tempdir[0] = '\0'; - - /* System-specific fonts directory. */ - BKE_appdir_font_folder_default(U.fontdir); - - /* Only enable tooltips translation by default, - * without actually enabling translation itself, for now. */ - U.transopts = USER_TR_TOOLTIPS; - U.memcachelimit = min_ii(BLI_system_memory_max_in_megabytes_int() / 2, 4096); - - /* Auto perspective. */ - U.uiflag |= USER_AUTOPERSP; - - /* Init weight paint range. */ - BKE_colorband_init(&U.coba_weight, true); - - /* Default visible section. */ - U.userpref = USER_SECTION_INTERFACE; - - /* Default to left click select. */ - BKE_keyconfig_pref_set_select_mouse(&U, 0, true); - - /* Increase a little for new scrubbing area. */ - U.v2d_min_gridsize = 45; - - /* Default studio light. */ - BKE_studiolight_default(U.light_param, U.light_ambient); -} - -/** * Rename if the ID doesn't exist. */ static ID *rename_id_for_versioning(Main *bmain, diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 69802b35ff9..0f1d7cbf70f 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1181,7 +1181,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } /* new variable blockscale, for panels in any area, do again because new - * areas didnt initialize it to 0.7 yet + * areas didn't initialize it to 0.7 yet */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { ScrArea *sa; @@ -1782,7 +1782,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } } - /* copy old object level track settings to curve modifers */ + /* copy old object level track settings to curve modifiers */ for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Curve) { CurveModifierData *cmd = (CurveModifierData *)md; diff --git a/source/blender/blentranslation/msgfmt/msgfmt.c b/source/blender/blentranslation/msgfmt/msgfmt.c index 500ae2df4b5..f226699d8bf 100644 --- a/source/blender/blentranslation/msgfmt/msgfmt.c +++ b/source/blender/blentranslation/msgfmt/msgfmt.c @@ -362,7 +362,7 @@ static int make(const char *input_file_name, const char *output_file_name) else if (strstr(l, msgid_plural_kw) == l) { /* This is a message with plural forms. */ if (section != SECTION_ID) { - printf("msgid_plural not preceeded by msgid on %s:%d\n", input_file_name, lno); + printf("msgid_plural not preceded by msgid on %s:%d\n", input_file_name, lno); return EXIT_FAILURE; } l = l + msgid_plural_len; diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 8349dee06e2..1393e24e48e 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -23,7 +23,7 @@ /* bmesh data structures */ -/* dissable holes for now, +/* disable holes for now, * these are ifdef'd because they use more memory and cant be saved in DNA currently */ // #define USE_BMESH_HOLES diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 224f6ad1e5c..760b0aa00ae 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -487,7 +487,7 @@ static void bm_vert_attrs_copy(BMesh *source_mesh, uint64_t cd_mask) { if ((source_mesh == target_mesh) && (source_vertex == target_vertex)) { - BLI_assert(!"BMVert: source and targer match"); + BLI_assert(!"BMVert: source and target match"); return; } if ((cd_mask & CD_MASK_NORMAL) == 0) { @@ -507,7 +507,7 @@ static void bm_edge_attrs_copy(BMesh *source_mesh, uint64_t UNUSED(cd_mask)) { if ((source_mesh == target_mesh) && (source_edge == target_edge)) { - BLI_assert(!"BMEdge: source and targer match"); + BLI_assert(!"BMEdge: source and target match"); return; } CustomData_bmesh_free_block_data(&target_mesh->edata, target_edge->head.data); @@ -522,7 +522,7 @@ static void bm_loop_attrs_copy(BMesh *source_mesh, uint64_t UNUSED(cd_mask)) { if ((source_mesh == target_mesh) && (source_loop == target_loop)) { - BLI_assert(!"BMLoop: source and targer match"); + BLI_assert(!"BMLoop: source and target match"); return; } CustomData_bmesh_free_block_data(&target_mesh->ldata, target_loop->head.data); @@ -537,7 +537,7 @@ static void bm_face_attrs_copy(BMesh *source_mesh, uint64_t cd_mask) { if ((source_mesh == target_mesh) && (source_face == target_face)) { - BLI_assert(!"BMFace: source and targer match"); + BLI_assert(!"BMFace: source and target match"); return; } if ((cd_mask & CD_MASK_NORMAL) == 0) { diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 6ece32e57e8..68b30912041 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -209,7 +209,7 @@ BMEdge *BM_edge_create( /** * \note In most cases a \a l_example should be NULL, - * since this is a low level API and we shouldn't attempt to be clever and guess whats intended. + * since this is a low level API and we shouldn't attempt to be clever and guess what's intended. * In cases where copying adjacent loop-data is useful, see #BM_face_copy_shared. */ static BMLoop *bm_loop_create(BMesh *bm, diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 5aa67ad8c78..48d6bcd7b03 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -39,7 +39,7 @@ #include "bmesh.h" #include "intern/bmesh_private.h" -/* edge and vertex share, currently theres no need to have different logic */ +/* edge and vertex share, currently there's no need to have different logic */ static void bm_data_interp_from_elem(CustomData *data_layer, const BMElem *ele_src_1, const BMElem *ele_src_2, diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index bb55365f619..5aec59ccd5d 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -884,8 +884,8 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) sub_v3_v3v3(r_plane, vec, eve->co); } else { - /* make a fake plane thats at rightangles to the normal - * we cant make a crossvec from a vec thats the same as the vec + /* make a fake plane that's at rightangles to the normal + * we can't make a crossvec from a vec that's the same as the vec * unlikely but possible, so make sure if the normal is (0, 0, 1) * that vec isn't the same or in the same direction even. */ if (eve->no[0] < 0.5f) { diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index c796bdea688..f44b758ef6b 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -1345,7 +1345,7 @@ void BM_normals_loops_edges_tag(BMesh *bm, const bool do_edges) } /** - * Auxillary function only used by rebuild to detect if any spaces were not marked as invalid. + * Auxiliary function only used by rebuild to detect if any spaces were not marked as invalid. * Reports error if any of the lnor spaces change after rebuilding, meaning that all the possible * lnor spaces to be rebuilt were not correctly marked. */ diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index c28d748b2eb..53f68804bd3 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -1029,7 +1029,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f /* Rotate The Edge */ /* first create the new edge, this is so we can copy the customdata from the old one - * if splice if disabled, always add in a new edge even if theres one there. */ + * if splice if disabled, always add in a new edge even if there's one there. */ e_new = BM_edge_create( bm, v1, v2, e, (check_flag & BM_EDGEROT_CHECK_SPLICE) ? BM_CREATE_NO_DOUBLE : BM_CREATE_NOP); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 2114f9ebd3d..e8b35afdcb1 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1545,7 +1545,7 @@ static BMOpDefine bmo_split_edges_def = { "split_edges", /* slots_in */ {{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */ - /* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */ + /* needed for vertex rip so we can rip only half an edge at a boundary which would otherwise split off */ {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* optional tag verts, use to have greater control of splits */ {"use_verts", BMO_OP_SLOT_BOOL}, /* use 'verts' for splitting, else just find verts to split from edges */ {{'\0'}}, diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index f06a5fb8b13..2039289dcd7 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -100,7 +100,7 @@ BLI_INLINE BMFlagLayer *BMO_elem_flag_from_header(BMHeader *ele_head) _bmo_elem_flag_toggle( \ bm, (BM_CHECK_TYPE_ELEM_NONCONST(ele), BMO_elem_flag_from_header(&(ele)->head)), oflag) -/* take care not to instansiate args multiple times */ +/* take care not to instantiate args multiple times */ #ifdef __GNUC___ # define _BMO_CAST_V_CONST(e) \ ({ \ @@ -203,7 +203,7 @@ typedef enum eBMOpSlotType { /* normally store pointers to object, scene, * _never_ store arrays corresponding to mesh elements with this */ - BMO_OP_SLOT_PTR = 4, /* requres subtype BMO_OP_SLOT_SUBTYPE_PTR_xxx */ + BMO_OP_SLOT_PTR = 4, /* requires subtype BMO_OP_SLOT_SUBTYPE_PTR_xxx */ BMO_OP_SLOT_MAT = 5, BMO_OP_SLOT_VEC = 8, @@ -212,7 +212,7 @@ typedef enum eBMOpSlotType { * * it's very important this remain a power of two */ BMO_OP_SLOT_ELEMENT_BUF = 9, /* list of verts/edges/faces */ - BMO_OP_SLOT_MAPPING = 10 /* simple hash map, requres subtype BMO_OP_SLOT_SUBTYPE_MAP_xxx */ + BMO_OP_SLOT_MAPPING = 10 /* simple hash map, requires subtype BMO_OP_SLOT_SUBTYPE_MAP_xxx */ } eBMOpSlotType; #define BMO_OP_SLOT_TOTAL_TYPES 11 diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index 64768474765..83ac7df058a 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -496,7 +496,7 @@ bool BM_face_split_edgenet(BMesh *bm, } /* These arrays used to be stack memory, however they can be - * large for singe faces with complex edgenets, see: T65980. */ + * large for single faces with complex edgenets, see: T65980. */ /* over-alloc (probably 2-4 is only used in most cases), for the biggest-fan */ edge_order = MEM_mallocN(sizeof(*edge_order) * edge_order_len, __func__); @@ -765,8 +765,8 @@ struct EdgeGroupIsland { /* Set the following vars once we have >1 groups */ - /* when when an edge in a previous group connects to this one, - * so theres no need to create one pointing back. */ + /* when an edge in a previous group connects to this one, + * so there's no need to create one pointing back. */ uint has_prev_edge : 1; /* verts in the group which has the lowest & highest values, @@ -1000,7 +1000,7 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn * until a vertex is found which isn't blocked by an edge. * * \note It's possible none of the verts can be accessed (with self-intersecting lines). - * In that case theres no right answer (without subdividing edges), + * In that case there's no right answer (without subdividing edges), * so return a fall-back vertex in that case. */ @@ -1481,7 +1481,7 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm, if (!BM_elem_flag_test(v_iter, VERT_IN_ARRAY)) { BM_elem_flag_enable(v_iter, VERT_IN_ARRAY); - /* not nice, but alternatives arent much better :S */ + /* not nice, but alternatives aren't much better :S */ { copy_v3_v3(vert_coords_backup[v_index], v_iter->co); diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h index 7ae55a5fa6f..38c75dec354 100644 --- a/source/blender/bmesh/intern/bmesh_structure.h +++ b/source/blender/bmesh/intern/bmesh_structure.h @@ -34,7 +34,7 @@ /* LOOP CYCLE MANAGEMENT */ bool bmesh_loop_validate(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -/* DISK CYCLE MANAGMENT */ +/* DISK CYCLE MANAGEMENT */ void bmesh_disk_edge_append(BMEdge *e, BMVert *v) ATTR_NONNULL(); void bmesh_disk_edge_remove(BMEdge *e, BMVert *v) ATTR_NONNULL(); BLI_INLINE BMEdge *bmesh_disk_edge_next_safe(const BMEdge *e, @@ -60,7 +60,7 @@ BMLoop *bmesh_disk_faceloop_find_first_visible(const BMEdge *e, BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -/* RADIAL CYCLE MANAGMENT */ +/* RADIAL CYCLE MANAGEMENT */ void bmesh_radial_loop_append(BMEdge *e, BMLoop *l) ATTR_NONNULL(); void bmesh_radial_loop_remove(BMEdge *e, BMLoop *l) ATTR_NONNULL(); void bmesh_radial_loop_unlink(BMLoop *l) ATTR_NONNULL(); diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 20042e65287..ade6fdfcbed 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -805,7 +805,7 @@ static void *bmw_IslandWalker_step_ex(BMWalker *walker, bool only_manifold) continue; } - /* saves checking BLI_gset_haskey below (manifold edges theres a 50% chance) */ + /* saves checking BLI_gset_haskey below (manifold edges there's a 50% chance) */ if (f == iwalk->cur) { continue; } diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c index 7ec73412373..5403043efb4 100644 --- a/source/blender/bmesh/operators/bmo_bridge.c +++ b/source/blender/bmesh/operators/bmo_bridge.c @@ -59,7 +59,7 @@ static void bm_bridge_splice_loops(BMesh *bm, /* get the 2 loops matching 2 verts. * first attempt to get the face corners that use the edge defined by v1 & v2, - * if that fails just get any loop thats on the vert (the first one) */ + * if that fails just get any loop that's on the vert (the first one) */ static void bm_vert_loop_pair(BMesh *bm, BMVert *v1, BMVert *v2, BMLoop **l1, BMLoop **l2) { BMEdge *e = BM_edge_exists(v1, v2); @@ -515,7 +515,7 @@ static void bridge_loop_pair(BMesh *bm, } BMO_op_exec(bm, &op_sub); - /* there may also be tagged faces that didnt rotate, mark input */ + /* there may also be tagged faces that didn't rotate, mark input */ if (use_edgeout) { BMOIter siter; diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 6dd361d62b3..d9a7aa626e4 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -449,7 +449,7 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) } } - /* connect outputs of dupe to delete, exluding keep geometry */ + /* connect outputs of dupe to delete, excluding keep geometry */ BMO_mesh_delete_oflag_context(bm, SPLIT_INPUT, DEL_FACES); /* now we make our outputs by copying the dupe output */ diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c index 7ab8406a3ec..d38a1be7a8d 100644 --- a/source/blender/bmesh/operators/bmo_edgenet.c +++ b/source/blender/bmesh/operators/bmo_edgenet.c @@ -132,7 +132,7 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op) } } - /* we don't have valid edge layouts, retur */ + /* we don't have valid edge layouts, return */ if (!ok) { return; } diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 323bb5a7748..f23c420295b 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -549,7 +549,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) SplitEdgeInfo *es; /* Interpolation Vars */ - /* an array alligned with faces but only fill items which are used. */ + /* an array aligned with faces but only fill items which are used. */ InterpFace **iface_array = NULL; int iface_array_len; MemArena *interp_arena = NULL; diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 2eedefe7980..287a7e93470 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -1092,7 +1092,7 @@ static void bm_mesh_calc_uvs_sphere_face(BMFace *f, const int cd_loop_uv_offset) float z = l->v->co[2]; float len = len_v3(l->v->co); - /* Use neigboring point to compute angle for poles. */ + /* Use neighboring point to compute angle for poles. */ float theta; if (f->len == 3 && fabsf(x) < 0.0001f && fabsf(y) < 0.0001f) { theta = atan2f(avgy, avgx); diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 74635be4681..41f65dd6f5a 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -138,7 +138,7 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace * multiple faces yet. that might require a convexity test to figure out which * face is "best" and who knows what for non-manifold conditions. * - * note: we allow adjacent here, since theres no chance this happens. + * note: we allow adjacent here, since there's no chance this happens. */ f = BM_vert_pair_share_face_by_len(v_a, v_b, &l_a, &l_b, true); diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c index 6baf56f1723..cfbff105d70 100644 --- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c +++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c @@ -1145,7 +1145,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op) } else if (count == 2) { /* this case could be removed, - * but simple to avoid 'bm_edgering_pair_calc' in this case since theres only one. */ + * but simple to avoid 'bm_edgering_pair_calc' in this case since there's only one. */ struct BMEdgeLoopStore *el_store_a = eloops_rim.first; struct BMEdgeLoopStore *el_store_b = eloops_rim.last; LoopPairStore *lpair; diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index c317d064086..94935f2090b 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -1357,7 +1357,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) copy_v3_v3(pro->plane_co, co1); } else if (bndv->is_arc_start) { - /* assume pro->midco was alredy set */ + /* assume pro->midco was already set */ copy_v3_v3(pro->coa, co1); copy_v3_v3(pro->cob, co2); pro->super_r = PRO_CIRCLE_R; @@ -2295,7 +2295,7 @@ static void build_boundary_terminal_edge(BevelParams *bp, else { adjust_bound_vert(e->rightv, co); } - /* make artifical extra point along unbeveled edge, and form triangle */ + /* make artificial extra point along unbeveled edge, and form triangle */ slide_dist(e->next, bv->v, e->offset_l, co); if (construct) { v = add_new_bound_vert(mem_arena, vm, co); diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index da525becc78..e32a9334343 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -698,7 +698,7 @@ static void bm_edge_collapse_loop_customdata( const bool is_manifold = BM_edge_is_manifold(l->e); int side; - /* first find the loop of 'v_other' thats attached to the face of 'l' */ + /* first find the loop of 'v_other' that's attached to the face of 'l' */ if (l->v == v_clear) { l_clear = l; l_other = l->next; @@ -882,7 +882,7 @@ static bool bm_edge_collapse_is_degenerate_topology(BMEdge *e_first) bm_edge_tag_enable(e_iter); } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v1)) != e_first); - /* ... except for the edge we will collapse, we know thats shared, + /* ... except for the edge we will collapse, we know that's shared, * disable this to avoid false positive. We could be smart and never enable these * face/edge tags in the first place but easier to do this */ // bm_edge_tag_disable(e_first); diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c index 8b139e6a5ff..841109a251f 100644 --- a/source/blender/bmesh/tools/bmesh_path_region.c +++ b/source/blender/bmesh/tools/bmesh_path_region.c @@ -224,7 +224,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, #endif /* USE_EDGE_CHAIN */ /* Keep walking over connected geometry until we find all the vertices in - * `ele_verts[side_other]`, or exit the loop when theres no connection. */ + * `ele_verts[side_other]`, or exit the loop when there's no connection. */ found_all = false; for (pass = 1; (STACK_SIZE(stack) != 0); pass++) { while (STACK_SIZE(stack) != 0) { @@ -268,7 +268,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, } while ((e = BM_DISK_EDGE_NEXT(e, v_a)) != v_a->e); } - /* Stop searching once theres none left. + /* Stop searching once there's none left. * Note that this looks in-efficient, however until the target elements reached, * it will exit immediately. * After that, it takes as many passes as the element has edges to finish off. */ diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index 8b9a9de3988..943f7532960 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -43,7 +43,7 @@ #include "bmesh.h" -#include "tools/bmesh_region_match.h" /* own incldue */ +#include "tools/bmesh_region_match.h" /* own include */ /* avoid re-creating ghash and pools for each search */ #define USE_WALKER_REUSE @@ -95,13 +95,13 @@ typedef struct UUIDWalk { BLI_mempool *step_pool; BLI_mempool *step_pool_items; - /* Optionaly use face-tag to isolate search */ + /* Optionally use face-tag to isolate search */ bool use_face_isolate; /* Increment for each pass added */ UUID_Int pass; - /* runtime vars, aviod re-creating each pass */ + /* runtime vars, avoid re-creating each pass */ struct { GHash *verts_uuid; /* BMVert -> UUID */ GSet *faces_step; /* BMFace */ diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index be748110fb9..3bdc11291d5 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -751,7 +751,7 @@ float AnimationImporter::convert_to_focal_length(float in_xfov, float aspect, float sensorx) { - /* NOTE: Needs more testing (As we curretnly have no official test data for this) */ + /* NOTE: Needs more testing (As we currently have no official test data for this) */ float xfov = (fov_type == CAMERA_YFOV) ? (2.0f * atanf(aspect * tanf(DEG2RADF(in_xfov) * 0.5f))) : DEG2RADF(in_xfov); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index eabd9469582..98b166716c3 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -917,7 +917,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) double yfov = camera->getYFov().getValue(); double aspect = camera->getAspectRatio().getValue(); - /* NOTE: Needs more testing (As we curretnly have no official test data for this) */ + /* NOTE: Needs more testing (As we currently have no official test data for this) */ double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f)); cam->lens = fov_to_focallength(xfov, cam->sensor_x); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 2ab6d12d96d..657cce24a82 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -695,7 +695,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) first_vertex, position_indices[1], position_indices[2]}; set_poly_indices(mpoly, mloop, loop_index, triangle_vertex_indices, 3); - if (mp_has_normals) { // vertex normals, same inplementation as for the triangles + if (mp_has_normals) { // vertex normals, same implementation as for the triangles // the same for vertces normals unsigned int vertex_normal_indices[3] = { first_normal, normal_indices[1], normal_indices[2]}; diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index 81df85daf28..d0bab5aa4d9 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -56,19 +56,19 @@ void BrightnessOperation::executePixelSampled(float output[4], float contrast = inputContrast[0]; brightness /= 100.0f; float delta = contrast / 200.0f; - a = 1.0f - delta * 2.0f; /* * The algorithm is by Werner D. Streidt * (http://visca.com/ffactory/archives/5-99/msg00021.html) * Extracted of OpenCV demhist.c */ if (contrast > 0) { - a = 1.0f / a; + a = 1.0f / (1.0f - delta * 2.0f); b = a * (brightness - delta); } else { delta *= -1; - b = a * (brightness + delta); + a = 1.0f - delta * 2.0f; + b = a * brightness + delta; } if (this->m_use_premultiply) { premul_to_straight_v4(inputValue); diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index 44fedca4398..e58dbb1a61f 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -268,7 +268,7 @@ def main(): parser.add_argument( "--name_style", dest="name_style", metavar='ENUM', type=str, choices=('', 'UI_ICONS'), - help="The metod used for naming output data", + help="The method used for naming output data", ) # Options for dicing up the image diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index c3099c9486d..49c510d9d3e 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -115,11 +115,4 @@ set(SRC set(LIB ) -if(WITH_BOOST) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) - add_definitions(-DHAVE_BOOST_FUNCTION_BINDINGS) -endif() - blender_add_lib(bf_depsgraph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index b06d6e73de0..986f65df3fc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -623,7 +623,7 @@ void DepsgraphNodeBuilder::build_object(int base_index, is_parent_collection_visible_ = is_current_parent_collection_visible; add_operation_node(&object->id, NodeType::DUPLI, OperationCode::DUPLI); } - /* Syncronization back to original object. */ + /* Synchronization back to original object. */ add_operation_node(&object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 86cbb330170..0e608bdf903 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -677,7 +677,7 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object) } /* Point caches. */ build_object_pointcache(object); - /* Syncronization back to original object. */ + /* Synchronization back to original object. */ OperationKey synchronize_key( &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); add_relation(final_transform_key, synchronize_key, "Synchronize to Original"); @@ -695,7 +695,7 @@ void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) OperationKey object_flags_key( &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS); add_relation(view_layer_done_key, object_flags_key, "Base flags flush"); - /* Syncronization back to original object. */ + /* Synchronization back to original object. */ OperationKey synchronize_key( &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); add_relation(object_flags_key, synchronize_key, "Synchronize to Original"); @@ -1321,7 +1321,7 @@ void DepsgraphRelationBuilder::build_animdata_drivers(ID *id) void DepsgraphRelationBuilder::build_animation_images(ID *id) { - /* TODO: can we check for existance of node for performance? */ + /* TODO: can we check for existence of node for performance? */ if (BKE_image_user_id_has_animation(id)) { OperationKey image_animation_key(id, NodeType::ANIMATION, OperationCode::IMAGE_ANIMATION); TimeSourceKey time_src_key; @@ -1999,7 +1999,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object) } } } - /* Syncronization back to original object. */ + /* Synchronization back to original object. */ ComponentKey final_geometry_key(&object->id, NodeType::GEOMETRY); OperationKey synchronize_key( &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); @@ -2536,7 +2536,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) * copied by copy-on-write, and not preserved. PROBABLY it is better * to preserve that cache in copy-on-write, but for the time being * we allow flush to layer collections component which will ensure - * that cached array fo bases exists and is up-to-date. */ + * that cached array of bases exists and is up-to-date. */ if (comp_node->type == NodeType::PARAMETERS || comp_node->type == NodeType::LAYER_COLLECTIONS) { rel_flag &= ~RELATION_FLAG_NO_FLUSH; diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index 507d2d9ec08..15ce57cb169 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -73,7 +73,7 @@ enum RelationFlag { RELATION_FLAG_FLUSH_USER_EDIT_ONLY = (1 << 2), /* The relation can not be killed by the cyclic dependencies solver. */ RELATION_FLAG_GODMODE = (1 << 4), - /* Relation will check existance before being added. */ + /* Relation will check existence before being added. */ RELATION_CHECK_BEFORE_ADD = (1 << 5), }; diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index f519fe76724..55241d03e94 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -86,5 +86,5 @@ void DEG_evaluate_on_framechange(Main *bmain, Depsgraph *graph, float ctime) bool DEG_needs_eval(Depsgraph *graph) { DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); - return BLI_gset_len(deg_graph->entry_tags) != 0; + return BLI_gset_len(deg_graph->entry_tags) != 0 || deg_graph->need_update_time; } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 59f0c8c1933..392514990e3 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -325,25 +325,31 @@ void deg_graph_id_tag_legacy_compat( * tagging here. */ case ID_ME: { Mesh *mesh = (Mesh *)id; - ID *key_id = &mesh->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (mesh->key != NULL) { + ID *key_id = &mesh->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } case ID_LT: { Lattice *lattice = (Lattice *)id; - ID *key_id = &lattice->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (lattice->key != NULL) { + ID *key_id = &lattice->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } case ID_CU: { Curve *curve = (Curve *)id; - ID *key_id = &curve->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (curve->key != NULL) { + ID *key_id = &curve->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 8079a3df879..2479373b687 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -29,14 +29,15 @@ #include <deque> #include <cmath> -#include "BKE_object.h" - #include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_task.h" #include "BLI_ghash.h" +#include "BKE_object.h" +#include "BKE_scene.h" + extern "C" { #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -355,7 +356,7 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph) } if (graph->need_update_time) { const Scene *scene_orig = graph->scene; - const float ctime = scene_orig->r.cfra + scene_orig->r.subframe; + const float ctime = BKE_scene_frame_get(scene_orig); DEG::TimeSourceNode *time_source = graph->find_time_source(); graph->ctime = ctime; time_source->tag_update(graph, DEG::DEG_UPDATE_SOURCE_TIME); diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 8dd01050753..e14513a1aa2 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -58,7 +58,7 @@ const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state) return "DIRECTLY"; } BLI_assert(!"Unhandled linked state, should never happen."); - return "UNKNOW"; + return "UNKNOWN"; } IDNode::ComponentIDKey::ComponentIDKey(NodeType type, const char *name) : type(type), name(name) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 664484d9a57..016cd628969 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -127,6 +127,7 @@ set(SRC engines/gpencil/gpencil_render.c engines/gpencil/gpencil_shader_fx.c engines/select/select_engine.c + engines/select/select_draw_utils.c DRW_engine.h intern/DRW_render.h @@ -152,6 +153,7 @@ set(SRC engines/workbench/workbench_engine.h engines/workbench/workbench_private.h engines/select/select_engine.h + engines/select/select_private.h ) set(LIB diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index a51c3a04239..6c853d27f67 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -182,8 +182,7 @@ struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id); void DRW_drawdata_free(struct ID *id); /* select_engine.c */ -void DRW_select_context_create(struct Depsgraph *depsgraph, - struct Base **bases, +void DRW_select_context_create(struct Base **bases, const uint bases_len, short select_mode); bool DRW_select_elem_get(const uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type); diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 1b152afa3bf..93521c71127 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -47,7 +47,7 @@ static struct { struct GPUShader *downsample_sh; struct GPUShader *downsample_cube_sh; - /* Theses are just references, not actually allocated */ + /* These are just references, not actually allocated */ struct GPUTexture *depth_src; struct GPUTexture *color_src; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 5341661735f..2026b44fe87 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -1275,7 +1275,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v /* Rendering happens here! */ eevee_lightbake_render_scene_to_planars(sldata, vedata); - /* Make sure no aditionnal visibility check runs after this. */ + /* Make sure no additional visibility check runs after this. */ pinfo->vis_data.collection = NULL; DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data); diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index f6e8cefd165..d23287264b3 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -1347,7 +1347,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView int saved_ray_type = sldata->common_data.ray_type; - /* TODO: make it optionnal if we don't draw shadows. */ + /* TODO: make it optional if we don't draw shadows. */ sldata->common_data.ray_type = EEVEE_RAY_SHADOW; DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index abd5bb82815..670201555bd 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -74,7 +74,7 @@ static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, /* FIXME : This is a temporal solution that does not take care of parent animations */ /* Recalc Anim manually */ BKE_animsys_evaluate_animdata( - draw_ctx->depsgraph, scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL); + scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL, false); BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &cam_cpy, time); /* Compute winmat */ diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index bd08a61e3b8..8aeddc72316 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -633,7 +633,7 @@ typedef struct EEVEE_EffectsInfo { struct GPUTexture *source_buffer; /* latest updated texture */ struct GPUFrameBuffer *target_buffer; /* next target to render to */ struct GPUTexture *final_tx; /* Final color to transform to display color space. */ - struct GPUFrameBuffer *final_fb; /* Framebuffer with final_tx as attachement. */ + struct GPUFrameBuffer *final_fb; /* Framebuffer with final_tx as attachment. */ } EEVEE_EffectsInfo; /* ***************** COMMON DATA **************** */ @@ -761,8 +761,8 @@ typedef struct EEVEE_ShadowCascadeData { float radius[MAX_CASCADE_NUM]; } EEVEE_ShadowCascadeData; -/* Theses are the structs stored inside Objects. - * It works with even if the object is in multiple layers +/* These are the structs stored inside Objects. + * It works even if the object is in multiple layers * because we don't get the same "Object *" for each layer. */ typedef struct EEVEE_LightEngineData { DrawData dd; diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 286bcd8f738..ebd13ef1cf5 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -91,7 +91,7 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * copy_v4_fl4(camtexcofac, 1.0f, 1.0f, 0.0f, 0.0f); } - /* XXX overiding viewport size. Simplify things but is not really 100% safe. */ + /* XXX overriding viewport size. Simplify things but is not really 100% safe. */ DRW_render_viewport_size_set((int[2]){size_orig[0] + g_data->overscan_pixels * 2.0f, size_orig[1] + g_data->overscan_pixels * 2.0f}); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index d53ed239f4e..3d1b64422a4 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -44,7 +44,7 @@ static struct { /* Screen Space Reflection */ struct GPUShader *ssr_sh[SSR_MAX_SHADER]; - /* Theses are just references, not actually allocated */ + /* These are just references, not actually allocated */ struct GPUTexture *depth_src; struct GPUTexture *color_src; } e_data = {{NULL}}; /* Engine data */ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index f85c30044a9..7fb5c25ffc6 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -554,7 +554,7 @@ void EEVEE_volumes_draw_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) /* Final integration: We compute for each froxel the * amount of scattered light and extinction coef at this - * given depth. We use theses textures as double buffer + * given depth. We use these textures as double buffer * for the volumetric history. */ txl->volume_scatter_history = DRW_texture_create_3d( tex_size[0], tex_size[1], tex_size[2], GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL); diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl index d8cec17af58..ca4940ceffb 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl @@ -121,7 +121,7 @@ void main(void) /* Circle Dof */ float dist = length(particlecoord); - /* Ouside of bokeh shape */ + /* Outside of bokeh shape */ if (dist > 1.0) { discard; } @@ -141,7 +141,7 @@ void main(void) * Giving us the new linear radius to the shape edge. */ dist /= r; - /* Ouside of bokeh shape */ + /* Outside of bokeh shape */ if (dist > 1.0) { discard; } diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl index ac6751fb5fb..428318e3c68 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl @@ -96,7 +96,7 @@ void main() FragColor = safe_color(color_history); /* There is some ghost issue if we use the alpha - * in the viewport. Overwritting alpha fixes it. */ + * in the viewport. Overwriting alpha fixes it. */ FragColor.a = color.a; } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl index a70ac686efd..56c05e3c036 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl @@ -261,7 +261,7 @@ vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos) float weight_accum = 0.0; vec3 irradiance_accum = vec3(0.0); - /* For each neighboor cells */ + /* For each neighbor cells */ for (int i = 0; i < 8; ++i) { ivec3 offset = ivec3(i, i >> 1, i >> 2) & ivec3(1); vec3 cell_cos = clamp(localpos_floored + vec3(offset), vec3(0.0), vec3(gd.g_resolution) - 1.0); diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl index 82581f2327b..14e0c947b47 100644 --- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl @@ -83,8 +83,8 @@ void prepare_raycast(vec3 ray_origin, ss_start.w = project_point(ProjectionMatrix, ray_origin).z; ss_end.w = project_point(ProjectionMatrix, ray_end).z; - /* XXX This is a hack a better method is welcome ! */ - /* We take the delta between the offseted depth and the depth and substract it from the ray + /* XXX This is a hack. A better method is welcome! */ + /* We take the delta between the offsetted depth and the depth and subtract it from the ray * depth. This will change the world space thickness appearance a bit but we can have negative * values without worries. We cannot do this in viewspace because of the perspective division. */ ss_start.w = 2.0 * ss_start.z - ss_start.w; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl index 54f7dc10222..5646c257562 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl @@ -3,7 +3,7 @@ layout(std140) uniform shadow_render_block { - /* Use vectors to avoid alignement padding. */ + /* Use vectors to avoid alignment padding. */ ivec4 shadowSampleCount; vec4 shadowInvSampleCount; vec4 filterSize; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_process_geom.glsl b/source/blender/draw/engines/eevee/shaders/shadow_process_geom.glsl index 131cecd5db6..591666560c4 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_process_geom.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_process_geom.glsl @@ -4,7 +4,7 @@ layout(triangle_strip, max_vertices = 3) out; layout(std140) uniform shadow_render_block { - /* Use vectors to avoid alignement padding. */ + /* Use vectors to avoid alignment padding. */ ivec4 shadowSampleCount; vec4 shadowInvSampleCount; vec4 filterSize; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_process_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_process_vert.glsl index 01e0db97482..95e6a48b81f 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_process_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_process_vert.glsl @@ -1,7 +1,7 @@ layout(std140) uniform shadow_render_block { - /* Use vectors to avoid alignement padding. */ + /* Use vectors to avoid alignment padding. */ ivec4 shadowSampleCount; vec4 shadowInvSampleCount; vec4 filterSize; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl index e2982358e52..5c19ccd5ce1 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl @@ -1,7 +1,7 @@ layout(std140) uniform shadow_render_block { - /* Use vectors to avoid alignement padding. */ + /* Use vectors to avoid alignment padding. */ ivec4 shadowSampleCount; vec4 shadowInvSampleCount; vec4 filterSize; diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl index 4096fc2d511..2b1ae60654e 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl @@ -11,7 +11,7 @@ uniform vec3 volumeOrcoSize; flat in int slice; -/* Warning: theses are not attributes, theses are global vars. */ +/* Warning: these are not attributes, these are global vars. */ vec3 worldPosition = vec3(0.0); vec3 viewPosition = vec3(0.0); vec3 viewNormal = vec3(0.0); diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c new file mode 100644 index 00000000000..08c6c2ac865 --- /dev/null +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -0,0 +1,215 @@ +/* + * 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. + * + * Copyright 2019, Blender Foundation. + */ + +/** \file + * \ingroup draw_engine + * + * Engine for drawing a selection map where the pixels indicate the selection indices. + */ + +#include "BKE_editmesh.h" + +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + +#include "ED_view3d.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + +#include "draw_cache_impl.h" + +#include "select_private.h" + +/* -------------------------------------------------------------------- */ +/** \name Draw Utilities + * \{ */ + +static bool check_ob_drawface_dot(short select_mode, const View3D *v3d, char dt) +{ + if (select_mode & SCE_SELECT_FACE) { + if ((dt < OB_SOLID) || XRAY_FLAG_ENABLED(v3d)) { + return true; + } + if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) { + return true; + } + if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGES) == 0) { + /* Since we can't deduce face selection when edges aren't visible - show dots. */ + return true; + } + } + return false; +} + +static void draw_select_id_edit_mesh(SELECTID_StorageList *stl, + Object *ob, + short select_mode, + bool draw_facedot, + uint initial_offset, + uint *r_vert_offset, + uint *r_edge_offset, + uint *r_face_offset) +{ + Mesh *me = ob->data; + BMEditMesh *em = me->edit_mesh; + + BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); + + struct GPUBatch *geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(me); + DRWShadingGroup *face_shgrp; + if (select_mode & SCE_SELECT_FACE) { + face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_flat); + DRW_shgroup_uniform_int_copy(face_shgrp, "offset", *(int *)&initial_offset); + + if (draw_facedot) { + struct GPUBatch *geom_facedots = DRW_mesh_batch_cache_get_facedots_with_select_id(me); + DRW_shgroup_call(face_shgrp, geom_facedots, ob); + } + *r_face_offset = initial_offset + em->bm->totface; + } + else { + face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_unif); + DRW_shgroup_uniform_int_copy(face_shgrp, "id", 0); + + *r_face_offset = initial_offset; + } + DRW_shgroup_call(face_shgrp, geom_faces, ob); + + /* Unlike faces, only draw edges if edge select mode. */ + if (select_mode & SCE_SELECT_EDGE) { + struct GPUBatch *geom_edges = DRW_mesh_batch_cache_get_edges_with_select_id(me); + DRWShadingGroup *edge_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_edge); + DRW_shgroup_uniform_int_copy(edge_shgrp, "offset", *(int *)r_face_offset); + DRW_shgroup_call(edge_shgrp, geom_edges, ob); + *r_edge_offset = *r_face_offset + em->bm->totedge; + } + else { + /* Note that `r_vert_offset` is calculated from `r_edge_offset`. + * Otherwise the first vertex is never selected, see: T53512. */ + *r_edge_offset = *r_face_offset; + } + + /* Unlike faces, only verts if vert select mode. */ + if (select_mode & SCE_SELECT_VERTEX) { + struct GPUBatch *geom_verts = DRW_mesh_batch_cache_get_verts_with_select_id(me); + DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert); + DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", *(int *)r_edge_offset); + DRW_shgroup_call(vert_shgrp, geom_verts, ob); + *r_vert_offset = *r_edge_offset + em->bm->totvert; + } + else { + *r_vert_offset = *r_edge_offset; + } +} + +static void draw_select_id_mesh(SELECTID_StorageList *stl, + Object *ob, + short select_mode, + uint initial_offset, + uint *r_vert_offset, + uint *r_edge_offset, + uint *r_face_offset) +{ + Mesh *me = ob->data; + + struct GPUBatch *geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(me); + DRWShadingGroup *face_shgrp; + if (select_mode & SCE_SELECT_FACE) { + face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_flat); + DRW_shgroup_uniform_int_copy(face_shgrp, "offset", *(int *)&initial_offset); + *r_face_offset = initial_offset + me->totpoly; + } + else { + /* Only draw faces to mask out verts, we don't want their selection ID's. */ + face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_unif); + DRW_shgroup_uniform_int_copy(face_shgrp, "id", 0); + *r_face_offset = initial_offset; + } + DRW_shgroup_call(face_shgrp, geom_faces, ob); + + if (select_mode & SCE_SELECT_EDGE) { + struct GPUBatch *geom_edges = DRW_mesh_batch_cache_get_edges_with_select_id(me); + DRWShadingGroup *edge_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_edge); + DRW_shgroup_uniform_int_copy(edge_shgrp, "offset", *(int *)r_face_offset); + DRW_shgroup_call(edge_shgrp, geom_edges, ob); + *r_edge_offset = *r_face_offset + me->totedge; + } + else { + *r_edge_offset = *r_face_offset; + } + + if (select_mode & SCE_SELECT_VERTEX) { + struct GPUBatch *geom_verts = DRW_mesh_batch_cache_get_verts_with_select_id(me); + DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert); + DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", 1); + DRW_shgroup_call(vert_shgrp, geom_verts, ob); + *r_vert_offset = *r_edge_offset + me->totvert; + } +} + +void select_id_draw_object(void *vedata, + View3D *v3d, + Object *ob, + short select_mode, + uint initial_offset, + uint *r_vert_offset, + uint *r_edge_offset, + uint *r_face_offset) +{ + SELECTID_StorageList *stl = ((SELECTID_Data *)vedata)->stl; + + BLI_assert(initial_offset > 0); + + switch (ob->type) { + case OB_MESH: + if (ob->mode & OB_MODE_EDIT) { + bool draw_facedot = check_ob_drawface_dot(select_mode, v3d, ob->dt); + draw_select_id_edit_mesh(stl, + ob, + select_mode, + draw_facedot, + initial_offset, + r_vert_offset, + r_edge_offset, + r_face_offset); + } + else { + if (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_TEXTURE_PAINT)) { + Mesh *me_orig = DEG_get_original_object(ob)->data; + select_mode = 0; + if (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) { + select_mode = SCE_SELECT_FACE; + } + if (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) { + select_mode |= SCE_SELECT_VERTEX; + } + } + draw_select_id_mesh( + stl, ob, select_mode, initial_offset, r_vert_offset, r_edge_offset, r_face_offset); + } + break; + case OB_CURVE: + case OB_SURF: + break; + } +} + +/** \} */ + +#undef SELECT_ENGINE diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 260fe8793e6..68b4a8084f0 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -24,59 +24,20 @@ #include "BLI_rect.h" -#include "BKE_editmesh.h" - -#include "DNA_mesh_types.h" #include "DNA_screen_types.h" -#include "ED_view3d.h" - #include "GPU_shader.h" #include "GPU_select.h" -#include "DEG_depsgraph.h" -#include "DEG_depsgraph_query.h" - #include "UI_resources.h" #include "DRW_engine.h" -#include "DRW_render.h" - -#include "draw_cache_impl.h" +#include "select_private.h" #include "select_engine.h" -/* Shaders */ #define SELECT_ENGINE "SELECT_ENGINE" -/* *********** LISTS *********** */ - -/* GPUViewport.storage - * Is freed everytime the viewport engine changes */ -typedef struct SELECTID_StorageList { - struct SELECTID_PrivateData *g_data; -} SELECTID_StorageList; - -typedef struct SELECTID_PassList { - struct DRWPass *select_id_face_pass; - struct DRWPass *select_id_edge_pass; - struct DRWPass *select_id_vert_pass; -} SELECTID_PassList; - -typedef struct SELECTID_Data { - void *engine_type; - DRWViewportEmptyList *fbl; - DRWViewportEmptyList *txl; - SELECTID_PassList *psl; - SELECTID_StorageList *stl; -} SELECTID_Data; - -typedef struct SELECTID_Shaders { - /* Depth Pre Pass */ - struct GPUShader *select_id_flat; - struct GPUShader *select_id_uniform; -} SELECTID_Shaders; - /* *********** STATIC *********** */ static struct { @@ -92,39 +53,10 @@ static struct { /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */ uint last_index_drawn; - struct Depsgraph *depsgraph; short select_mode; } context; } e_data = {{{NULL}}}; /* Engine data */ -typedef struct SELECTID_PrivateData { - DRWShadingGroup *shgrp_face_unif; - DRWShadingGroup *shgrp_face_flat; - DRWShadingGroup *shgrp_edge; - DRWShadingGroup *shgrp_vert; - - DRWView *view_faces; - DRWView *view_edges; - DRWView *view_verts; -} SELECTID_PrivateData; /* Transient data */ - -struct BaseOffset { - /* For convenience only. */ - union { - uint offset; - uint face_start; - }; - union { - uint face; - uint edge_start; - }; - union { - uint edge; - uint vert_start; - }; - uint vert; -}; - /* Shaders */ extern char datatoc_common_view_lib_glsl[]; extern char datatoc_selection_id_3D_vert_glsl[]; @@ -152,149 +84,17 @@ static void draw_select_framebuffer_select_id_setup(void) e_data.texture_u32 = NULL; } + /* Make sure the depth texture is attached. + * It may disappear when loading another Blender session. */ + GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, dtxl->depth, 0, 0); + if (e_data.texture_u32 == NULL) { e_data.texture_u32 = GPU_texture_create_2d(size[0], size[1], GPU_R32UI, NULL, NULL); - - GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, dtxl->depth, 0, 0); GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0); GPU_framebuffer_check_valid(e_data.framebuffer_select_id, NULL); } } -static void draw_select_id_object(void *vedata, - Object *ob, - short select_mode, - bool draw_facedot, - uint initial_offset, - uint *r_vert_offset, - uint *r_edge_offset, - uint *r_face_offset) -{ - SELECTID_StorageList *stl = ((SELECTID_Data *)vedata)->stl; - - BLI_assert(initial_offset > 0); - - switch (ob->type) { - case OB_MESH: - if (ob->mode & OB_MODE_EDIT) { - Mesh *me = ob->data; - BMEditMesh *em = me->edit_mesh; - const bool use_faceselect = (select_mode & SCE_SELECT_FACE) != 0; - - DRW_mesh_batch_cache_validate(me); - - BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); - - struct GPUBatch *geom_faces, *geom_edges, *geom_verts, *geom_facedots; - geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(me); - if (select_mode & SCE_SELECT_EDGE) { - geom_edges = DRW_mesh_batch_cache_get_edges_with_select_id(me); - } - if (select_mode & SCE_SELECT_VERTEX) { - geom_verts = DRW_mesh_batch_cache_get_verts_with_select_id(me); - } - if (use_faceselect && draw_facedot) { - geom_facedots = DRW_mesh_batch_cache_get_facedots_with_select_id(me); - } - - DRWShadingGroup *face_shgrp; - if (use_faceselect) { - face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_flat); - DRW_shgroup_uniform_int_copy(face_shgrp, "offset", *(int *)&initial_offset); - - if (draw_facedot) { - DRW_shgroup_call(face_shgrp, geom_facedots, ob); - } - *r_face_offset = initial_offset + em->bm->totface; - } - else { - face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_unif); - DRW_shgroup_uniform_int_copy(face_shgrp, "id", 0); - - *r_face_offset = initial_offset; - } - DRW_shgroup_call(face_shgrp, geom_faces, ob); - - /* Unlike faces, only draw edges if edge select mode. */ - if (select_mode & SCE_SELECT_EDGE) { - DRWShadingGroup *edge_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_edge); - DRW_shgroup_uniform_int_copy(edge_shgrp, "offset", *(int *)r_face_offset); - DRW_shgroup_call(edge_shgrp, geom_edges, ob); - *r_edge_offset = *r_face_offset + em->bm->totedge; - } - else { - /* Note that `r_vert_offset` is calculated from `r_edge_offset`. - * Otherwise the first vertex is never selected, see: T53512. */ - *r_edge_offset = *r_face_offset; - } - - /* Unlike faces, only verts if vert select mode. */ - if (select_mode & SCE_SELECT_VERTEX) { - DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert); - DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", *(int *)r_edge_offset); - DRW_shgroup_call(vert_shgrp, geom_verts, ob); - *r_vert_offset = *r_edge_offset + em->bm->totvert; - } - else { - *r_vert_offset = *r_edge_offset; - } - } - else { - Mesh *me_orig = DEG_get_original_object(ob)->data; - Mesh *me_eval = ob->data; - - struct GPUBatch *geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(me_eval); - if ((me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) && - /* Currently vertex select supports weight paint and vertex paint. */ - ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT))) { - - struct GPUBatch *geom_verts = DRW_mesh_batch_cache_get_verts_with_select_id(me_eval); - - /* Only draw faces to mask out verts, we don't want their selection ID's. */ - DRWShadingGroup *face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_unif); - DRW_shgroup_uniform_int_copy(face_shgrp, "id", 0); - DRW_shgroup_call(face_shgrp, geom_faces, ob); - - DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert); - DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", 1); - DRW_shgroup_call(vert_shgrp, geom_verts, ob); - - *r_face_offset = *r_edge_offset = initial_offset; - *r_vert_offset = me_eval->totvert + 1; - } - else { - DRWShadingGroup *face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_flat); - DRW_shgroup_uniform_int_copy(face_shgrp, "offset", *(int *)&initial_offset); - DRW_shgroup_call(face_shgrp, geom_faces, ob); - - *r_face_offset = initial_offset + me_eval->totpoly; - *r_edge_offset = *r_vert_offset = *r_face_offset; - } - } - break; - case OB_CURVE: - case OB_SURF: - break; - } -} - -static bool check_ob_drawface_dot(short select_mode, const View3D *v3d, char dt) -{ - if (select_mode & SCE_SELECT_FACE) { - if ((dt < OB_SOLID) || XRAY_FLAG_ENABLED(v3d)) { - return true; - } - if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) { - return true; - } - if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGES) == 0) { - /* Since we can't deduce face selection when edges aren't visible - show dots. */ - return true; - } - } - return false; -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -395,17 +195,15 @@ static void select_cache_populate(void *vedata, Object *ob) select_mode = ts->selectmode; } - bool draw_facedot = check_ob_drawface_dot(select_mode, draw_ctx->v3d, ob->dt); - struct BaseOffset *base_ofs = &e_data.context.base_array_index_offsets[e_data.context.last_base_drawn++]; uint offset = e_data.context.last_index_drawn; - draw_select_id_object(vedata, + select_id_draw_object(vedata, + draw_ctx->v3d, ob, select_mode, - draw_facedot, offset, &base_ofs->vert, &base_ofs->edge, @@ -561,12 +359,8 @@ void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf) } } -void DRW_select_context_create(Depsgraph *depsgraph, - Base **UNUSED(bases), - const uint bases_len, - short select_mode) +void DRW_select_context_create(Base **UNUSED(bases), const uint bases_len, short select_mode) { - e_data.context.depsgraph = depsgraph; e_data.context.select_mode = select_mode; e_data.context.bases_len = bases_len; diff --git a/source/blender/draw/engines/select/select_private.h b/source/blender/draw/engines/select/select_private.h new file mode 100644 index 00000000000..9b0addb0fb8 --- /dev/null +++ b/source/blender/draw/engines/select/select_private.h @@ -0,0 +1,91 @@ +/* + * 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. + * + * Copyright 2019, Blender Foundation. + */ + +/** \file + * \ingroup draw_engine + */ + +#ifndef __SELECT_PRIVATE_H__ +#define __SELECT_PRIVATE_H__ + +#include "DRW_render.h" + +/* GPUViewport.storage + * Is freed everytime the viewport engine changes */ +typedef struct SELECTID_StorageList { + struct SELECTID_PrivateData *g_data; +} SELECTID_StorageList; + +typedef struct SELECTID_PassList { + struct DRWPass *select_id_face_pass; + struct DRWPass *select_id_edge_pass; + struct DRWPass *select_id_vert_pass; +} SELECTID_PassList; + +typedef struct SELECTID_Data { + void *engine_type; + DRWViewportEmptyList *fbl; + DRWViewportEmptyList *txl; + SELECTID_PassList *psl; + SELECTID_StorageList *stl; +} SELECTID_Data; + +typedef struct SELECTID_Shaders { + /* Depth Pre Pass */ + struct GPUShader *select_id_flat; + struct GPUShader *select_id_uniform; +} SELECTID_Shaders; + +typedef struct SELECTID_PrivateData { + DRWShadingGroup *shgrp_face_unif; + DRWShadingGroup *shgrp_face_flat; + DRWShadingGroup *shgrp_edge; + DRWShadingGroup *shgrp_vert; + + DRWView *view_faces; + DRWView *view_edges; + DRWView *view_verts; +} SELECTID_PrivateData; /* Transient data */ + +struct BaseOffset { + /* For convenience only. */ + union { + uint offset; + uint face_start; + }; + union { + uint face; + uint edge_start; + }; + union { + uint edge; + uint vert_start; + }; + uint vert; +}; + +void select_id_draw_object(void *vedata, + View3D *v3d, + Object *ob, + short select_mode, + uint initial_offset, + uint *r_vert_offset, + uint *r_edge_offset, + uint *r_face_offset); + +#endif /* __SELECT_PRIVATE_H__ */ diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl index 8d66cd7b26c..a0e04f252e2 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl @@ -46,7 +46,7 @@ vec3 get_view_space_from_depth(in vec2 uvcoords, in float depth) } } -/* forward declartion */ +/* forward declaration */ void ssao_factors(in float depth, in vec3 normal, in vec3 position, diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl index 1af786b648c..376b19cdd1b 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl @@ -58,7 +58,7 @@ void ssao_factors(in float depth, /* Handle Background case */ bool is_background = (depth_new == 1.0); - /* This trick provide good edge effect even if no neighboor is found. */ + /* This trick provide good edge effect even if no neighbor is found. */ vec3 pos_new = get_view_space_from_depth(uvcoords, (is_background) ? depth : depth_new); if (is_background) { diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index 575da1f9683..1beb02ea3a0 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -161,7 +161,7 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, sds->slice_axis - 1; float dim[3]; BKE_object_dimensions_get(ob, dim); - /* 0.05f to acheive somewhat the same opacity as the full view. */ + /* 0.05f to achieve somewhat the same opacity as the full view. */ float step_length = max_ff(1e-16f, dim[axis] * 0.05f); grp = DRW_shgroup_create(sh, vedata->psl->volume_pass); diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 75c498dfd88..241cd68bc3a 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -463,7 +463,7 @@ static void curve_batch_cache_init(Curve *cu) __func__); cache->surf_per_mat = MEM_mallocN(sizeof(*cache->surf_per_mat) * cache->mat_len, __func__); - /* TODO Might be wiser to alloc in one chunck. */ + /* TODO Might be wiser to alloc in one chunk. */ for (int i = 0; i < cache->mat_len; ++i) { cache->surf_per_mat_tris[i] = MEM_callocN(sizeof(GPUIndexBuf), "GPUIndexBuf"); cache->surf_per_mat[i] = MEM_callocN(sizeof(GPUBatch), "GPUBatch"); @@ -679,7 +679,7 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, GPUVertBuf *vbo GPU_vertbuf_attr_set(vbo_curves_nor, attr_id.tan, vbo_len_used, &ptan); vbo_len_used++; - /* Skip the other vertex (it does not need to be offseted). */ + /* Skip the other vertex (it does not need to be offsetted). */ GPU_vertbuf_attr_set(vbo_curves_nor, attr_id.pos, vbo_len_used, bevp->vec); vbo_len_used++; diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index d1c214c2aa6..90bbf996851 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -693,7 +693,7 @@ void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, v_idx += dl_vert_len(dl); } - /* Create edges for remaning non manifold edges. */ + /* Create edges for remaining non manifold edges. */ EdgeHashIterator *ehi; for (ehi = BLI_edgehashIterator_new(eh); BLI_edgehashIterator_isDone(ehi) == false; BLI_edgehashIterator_step(ehi)) { diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 2376787a273..ba58dc3d9de 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -3229,7 +3229,7 @@ static void mesh_create_loop_orco(MeshRenderData *rdata, GPUVertBuf *vbo) /* FIXME(fclem): We use the last component as a way to differentiate from generic vertex attribs. * This is a substential waste of Vram and should be done another way. Unfortunately, - * at the time of writting, I did not found any other "non disruptive" alternative. */ + * at the time of writing, I did not found any other "non disruptive" alternative. */ uint attr_id = GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPU_vertbuf_init_with_format(vbo, &format); @@ -3715,7 +3715,7 @@ static void mesh_create_edges_adjacency_lines(MeshRenderData *rdata, } } } - /* Create edges for remaning non manifold edges. */ + /* Create edges for remaining non manifold edges. */ EdgeHashIterator *ehi; for (ehi = BLI_edgehashIterator_new(eh); BLI_edgehashIterator_isDone(ehi) == false; BLI_edgehashIterator_step(ehi)) { diff --git a/source/blender/draw/intern/draw_cache_inline.h b/source/blender/draw/intern/draw_cache_inline.h index d94ef5b90d3..12dc0a47a68 100644 --- a/source/blender/draw/intern/draw_cache_inline.h +++ b/source/blender/draw/intern/draw_cache_inline.h @@ -47,7 +47,7 @@ BLI_INLINE GPUBatch *DRW_batch_request(GPUBatch **batch) { - /* XXX TODO(fclem): We are writting to batch cache here. Need to make this thread safe. */ + /* XXX TODO(fclem): We are writing to batch cache here. Need to make this thread safe. */ if (*batch == NULL) { *batch = MEM_callocN(sizeof(GPUBatch), "GPUBatch"); } diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 9e494cdad88..ac3e7e4ce67 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -939,7 +939,7 @@ struct DRWCallBuffer *buffer_instance_bone_stick(DRWPass *pass, eGPUShaderConfig { {"boneStart", DRW_ATTR_FLOAT, 3}, {"boneEnd", DRW_ATTR_FLOAT, 3}, - {"wireColor", DRW_ATTR_FLOAT, 4}, /* TODO port theses to uchar color */ + {"wireColor", DRW_ATTR_FLOAT, 4}, /* TODO port these to uchar color */ {"boneColor", DRW_ATTR_FLOAT, 4}, {"headColor", DRW_ATTR_FLOAT, 4}, {"tailColor", DRW_ATTR_FLOAT, 4}, diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 20d5ae096c9..fa1f1f2aab4 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -249,7 +249,7 @@ void DRW_hair_update(void) { #ifndef USE_TRANSFORM_FEEDBACK /** - * Workaround to tranform feedback not working on mac. + * Workaround to transform feedback not working on mac. * On some system it crashes (see T58489) and on some other it renders garbage (see T60171). * * So instead of using transform feedback we render to a texture, diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index f8640f17419..7176d81bd25 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1132,7 +1132,7 @@ static void drw_engines_cache_populate(Object *ob) drw_batch_cache_generate_requested(ob); } - /* ... and clearing it here too because theses draw data are + /* ... and clearing it here too because this draw data is * from a mempool and must not be free individually by depsgraph. */ drw_drawdata_unlink_dupli((ID *)ob); } @@ -1528,7 +1528,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx) * for each relevant engine / mode engine. */ void DRW_draw_view(const bContext *C) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = DEG_get_evaluated_scene(depsgraph); @@ -2563,7 +2563,7 @@ void DRW_draw_select_id(Depsgraph *depsgraph, Scene *scene = DEG_get_evaluated_scene(depsgraph); ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - DRW_select_context_create(depsgraph, bases, bases_len, select_mode); + DRW_select_context_create(bases, bases_len, select_mode); DRW_opengl_context_enable(); diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 424d06a3e56..f37e713e374 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -225,7 +225,7 @@ typedef struct DRWViewUboStorage { float wininv[4][4]; float clipplanes[6][4]; - /* Should not be here. Not view dependant (only main view). */ + /* Should not be here. Not view dependent (only main view). */ float viewcamtexcofac[4]; } DRWViewUboStorage; diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index e3c120e80cb..e68e03c2438 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -335,7 +335,7 @@ static void EDIT_CURVE_draw_scene(void *vedata) MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl); } - /* Thoses passes don't write to depth and are AA'ed using other tricks. */ + /* These passes don't write to depth and are AA'ed using other tricks. */ DRW_draw_pass(psl->overlay_edge_pass); DRW_draw_pass(psl->overlay_vert_pass); } diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 272aa552d38..f0e35e47a66 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -371,7 +371,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha, DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); } - /* Cage geom needs to be offseted to avoid Z-fighting. */ + /* Cage geom needs to be offsetted to avoid Z-fighting. */ passes->faces_cage = DRW_pass_create("Edit Mesh Faces Cage", DRW_STATE_WRITE_COLOR | statemod); grp = shgrps->faces_cage = DRW_shgroup_create(face_sh, passes->faces_cage); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 8d4083f1723..148a4951dc6 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -2862,7 +2862,7 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data, DRWCallBuffer *buf = buffer_theme_id_to_probe_cube_outline_shgrp( stl, theme_id, ob->base_flag); - /* TODO remove or change the drawing of the cube probes. Theses line draws nothing on purpose + /* TODO remove or change the drawing of the cube probes. This line draws nothing on purpose * to keep the call ids correct. */ zero_m4(probe_cube_mat); DRW_buffer_add_entry(buf, call_id, &draw_size, probe_cube_mat); diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl index 3cc6ac9a5a4..f75ef06b6d9 100644 --- a/source/blender/draw/modes/shaders/common_globals_lib.glsl +++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl @@ -83,7 +83,7 @@ layout(std140) uniform globalsBlock float pad_globalsBlock; }; -/* data[0] (1nd byte flags) */ +/* data[0] (1st byte flags) */ #define FACE_ACTIVE (1 << 0) #define FACE_SELECTED (1 << 1) #define FACE_FREESTYLE (1 << 2) diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl index f9c3df34658..cbcdc947bc7 100644 --- a/source/blender/draw/modes/shaders/common_hair_lib.glsl +++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl @@ -1,8 +1,8 @@ /** * Library to create hairs dynamically from control points. * This is less bandwidth intensive than fetching the vertex attributes - * but does more ALU work per vertex. This also reduce the number - * of data the CPU has to precompute and transfert for each update. + * but does more ALU work per vertex. This also reduces the amount + * of data the CPU has to precompute and transfer for each update. */ /** @@ -44,7 +44,7 @@ uniform usamplerBuffer hairStrandSegBuffer; /* R16UI */ /* -- Subdivision stage -- */ /** * We use a transform feedback to preprocess the strands and add more subdivision to it. - * For the moment theses are simple smooth interpolation but one could hope to see the full + * For the moment these are simple smooth interpolation but one could hope to see the full * children particle modifiers being evaluated at this stage. * * If no more subdivision is needed, we can skip this step. diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 7a7769ccc90..3d7178a4114 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4340,7 +4340,6 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi AnimData *adt = BKE_animdata_from_id(id); FCurve *fcu = (FCurve *)fcu_poin; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4356,7 +4355,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, adt, (float)CFRA); + &nla_cache, &id_ptr, adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4373,7 +4372,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { if (adt->action != NULL) { @@ -4395,7 +4394,6 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi KeyBlock *kb = (KeyBlock *)kb_poin; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4411,7 +4409,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, key->adt, (float)CFRA); + &nla_cache, &id_ptr, key->adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4433,7 +4431,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -4460,7 +4458,6 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, PropertyRNA *prop; int index; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4485,8 +4482,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, } /* insert a keyframe for this F-Curve */ - done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 2d16ce30d31..625a52fc800 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -412,7 +412,6 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) if (scene) { ac->markers = ED_context_get_markers(C); } - ac->depsgraph = CTX_data_depsgraph(C); ac->view_layer = CTX_data_view_layer(C); ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; ac->sa = sa; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index f5bd7a47248..fad9a1a8e49 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -238,6 +238,6 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ hsv[2] = 1.0f; - /* finally, conver this to RGB colors */ + /* finally, convert this to RGB colors */ hsv_to_rgb_v(hsv, out); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2bbb8e5888c..ded59466370 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -470,7 +470,7 @@ static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos } static void draw_marker( - const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height) + const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height) { GPU_blend(true); GPU_blend_set_func_separate( @@ -484,7 +484,9 @@ static void draw_marker( GPU_blend(false); float name_y = UI_DPI_FAC * 18; - if (marker->flag & SELECT) { + /* Give an offset to the marker name when selected, + * or when near the current frame (5 frames range, starting from the current one). */ + if ((marker->flag & SELECT) || (IN_RANGE_INCL(marker->frame, cfra, cfra - 4))) { name_y += UI_DPI_FAC * 10; } draw_marker_name(fstyle, marker, xpos, name_y); @@ -547,6 +549,7 @@ void ED_markers_draw(const bContext *C, int flag) ARegion *ar = CTX_wm_region(C); View2D *v2d = UI_view2d_fromcontext(C); + int cfra = CTX_data_scene(C)->r.cfra; rctf markers_region_rect; get_marker_region_rect(v2d, &markers_region_rect); @@ -564,17 +567,18 @@ void ED_markers_draw(const bContext *C, int flag) const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + /* Separate loops in order to draw selected markers on top */ for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if ((marker->flag & SELECT) == 0) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2e7ed7eae34..de6e4c2fd0d 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -721,23 +721,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) /* ------------------ RNA Data-Access Functions ------------------ */ /* Try to read value using RNA-properties obtained already */ -static float *setting_get_rna_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - const bool get_evaluated, - float *buffer, - int buffer_size, - int *r_count) +static float *setting_get_rna_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 1); float *values = buffer; - PointerRNA ptr_eval; - - if (get_evaluated) { - DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval); - ptr = &ptr_eval; - } if (RNA_property_array_check(prop)) { int length = *r_count = RNA_property_array_length(ptr, prop); @@ -977,12 +966,8 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ -static float *visualkey_get_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - float *buffer, - int buffer_size, - int *r_count) +static float *visualkey_get_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 4); @@ -999,27 +984,21 @@ static float *visualkey_get_values(Depsgraph *depsgraph, */ if (ptr->type == &RNA_Object) { Object *ob = (Object *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - /* Loc code is specific... */ if (strstr(identifier, "location")) { - copy_v3_v3(buffer, ob_eval->obmat[3]); + copy_v3_v3(buffer, ob->obmat[3]); *r_count = 3; return buffer; } - copy_m4_m4(tmat, ob_eval->obmat); - rotmode = ob_eval->rotmode; + copy_m4_m4(tmat, ob->obmat); + rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { - Object *ob = (Object *)ptr->id.data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); - - BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, tmat); - rotmode = pchan_eval->rotmode; + BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat); + rotmode = pchan->rotmode; /* Loc code is specific... */ if (strstr(identifier, "location")) { @@ -1032,7 +1011,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } } else { - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* Rot/Scale code are common! */ @@ -1066,7 +1045,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } /* as the function hasn't returned yet, read value from system in the default way */ - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* ------------------------- Insert Key API ------------------------- */ @@ -1075,8 +1054,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, * Retrieve current property values to keyframe, * possibly applying NLA correction when necessary. */ -static float *get_keyframe_values(Depsgraph *depsgraph, - ReportList *reports, +static float *get_keyframe_values(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, int index, @@ -1094,11 +1072,11 @@ static float *get_keyframe_values(Depsgraph *depsgraph, * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - values = visualkey_get_values(depsgraph, &ptr, prop, buffer, buffer_size, r_count); + values = visualkey_get_values(&ptr, prop, buffer, buffer_size, r_count); } else { /* read value from system */ - values = setting_get_rna_values(depsgraph, &ptr, prop, false, buffer, buffer_size, r_count); + values = setting_get_rna_values(&ptr, prop, buffer, buffer_size, r_count); } /* adjust the value for NLA factors */ @@ -1207,8 +1185,7 @@ static bool insert_keyframe_value(ReportList *reports, * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, * and extra keyframe filtering. */ -bool insert_keyframe_direct(Depsgraph *depsgraph, - ReportList *reports, +bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, @@ -1261,8 +1238,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, int value_count; int index = fcu->array_index; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, index, @@ -1347,7 +1323,6 @@ static bool insert_keyframe_fcurve_value(Main *bmain, * index of -1 keys all array indices */ short insert_keyframe(Main *bmain, - Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act, @@ -1405,7 +1380,7 @@ short insert_keyframe(Main *bmain, if (adt && adt->action == act) { /* Get NLA context for value remapping. */ nla_context = BKE_animsys_get_nla_keyframing_context( - nla_cache ? nla_cache : &tmp_nla_cache, depsgraph, &id_ptr, adt, cfra); + nla_cache ? nla_cache : &tmp_nla_cache, &id_ptr, adt, cfra, false); /* Apply NLA-mapping to frame. */ cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); @@ -1416,8 +1391,7 @@ short insert_keyframe(Main *bmain, int value_count; bool force_all; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, array_index, @@ -2373,7 +2347,6 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) static int insert_key_button_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -2407,7 +2380,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) if (fcu) { success = insert_keyframe_direct( - depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); } else { BKE_report(op->reports, @@ -2423,15 +2396,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); if (fcu && driven) { - success = insert_keyframe_direct(depsgraph, - op->reports, - ptr, - prop, - fcu, - cfra, - ts->keyframe_type, - NULL, - INSERTKEY_DRIVER); + success = insert_keyframe_direct( + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER); } } else { @@ -2468,7 +2434,6 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } success = insert_keyframe(bmain, - depsgraph, op->reports, ptr.id.data, NULL, @@ -2794,8 +2759,7 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra float buffer[RNA_MAX_ARRAY_LENGTH]; int count, index = fcu->array_index; - float *values = setting_get_rna_values( - NULL, &ptr, prop, false, buffer, RNA_MAX_ARRAY_LENGTH, &count); + float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count); float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame); float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0cb83c79c85..ccd0fc54611 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1030,7 +1030,6 @@ static short keyingset_apply_keying_flags(const short base_flags, int ANIM_apply_keyingset( bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); @@ -1125,7 +1124,6 @@ int ANIM_apply_keyingset( /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) { success += insert_keyframe(bmain, - depsgraph, reports, ksp->id, act, diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 5daf6b584e5..8f4896c0b82 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -195,7 +195,9 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre } Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some + * nested pointers, like animation data. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ListBase targets = {NULL, NULL}; bool free_depsgraph = false; @@ -384,7 +386,7 @@ void POSE_OT_paths_update(wmOperatorType *ot) ot->idname = "POSE_OT_paths_update"; ot->description = "Recalculate paths for bones that already have them"; - /* api callbakcs */ + /* api callbacks */ ot->exec = pose_update_paths_exec; ot->poll = pose_update_paths_poll; diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 3407b3e6b7f..4cda7f264aa 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1731,9 +1731,6 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) if (IS_AUTOKEY_MODE(scene, NORMAL)) { // remake_action_ipos(ob->action); } - else { - BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob); - } } /* Request final redraw of the view. */ diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 4c5a42cade6..c8e79b879a4 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1122,7 +1122,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) break; } - /* Percentage Chane... */ + /* Percentage Change... */ case MOUSEMOVE: /* calculate new position */ { /* only handle mousemove if not doing numinput */ @@ -1373,7 +1373,7 @@ void POSE_OT_push(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1435,7 +1435,7 @@ void POSE_OT_relax(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1496,7 +1496,7 @@ void POSE_OT_push_rest(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1558,7 +1558,7 @@ void POSE_OT_relax_rest(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1620,7 +1620,7 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -2025,7 +2025,7 @@ void POSE_OT_propagate(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */ /* flag */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */ diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 325e6eaee2a..854fb237929 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -71,7 +71,15 @@ * that are bone-parented to armature */ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Object *armob) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Depsgraph has been ensured to be evaluated at the beginning of the operator. + * + * Must not evaluate depsgraph here yet, since this will ruin object matrix which we want to + * preserve after other changes has been done in the operator. + * + * TODO(sergey): This seems very similar to `ignore_parent_tx()`, which was now ensured to work + * quite reliably. Can we de-duplicate the code? Or at least verify we don't need an extra logic + * in this function. */ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Main *bmain = CTX_data_main(C); Object workob, *ob; @@ -318,7 +326,7 @@ static void applyarmature_process_selected_rec(bArmature *arm, static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); // must be active object, not edit-object Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); @@ -422,7 +430,7 @@ void POSE_OT_armature_apply(wmOperatorType *ot) ot->ui = apply_armature_pose2bones_ui; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "selected", @@ -436,7 +444,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) { /* loop over all selected pchans @@ -1026,6 +1034,7 @@ static int pose_clear_transform_generic_exec(bContext *C, void (*clear_func)(bPoseChannel *), const char default_ksName[]) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); bool changed_multi = false; @@ -1041,8 +1050,8 @@ static int pose_clear_transform_generic_exec(bContext *C, ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) { - Object *ob_eval = DEG_get_evaluated_object( - CTX_data_depsgraph(C), ob_iter); // XXX: UGLY HACK (for autokey + clear transforms) + // XXX: UGLY HACK (for autokey + clear transforms) + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); ListBase dsources = {NULL, NULL}; bool changed = false; @@ -1217,7 +1226,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) workob.adt = ob->adt; workob.pose = dummyPose; - BKE_animsys_evaluate_animdata(NULL, scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM, false); /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d1d43a49826..047b78af7b1 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -7094,16 +7094,17 @@ static bool match_texture_space_poll(bContext *C) static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); + /* Need to ensure the dependency graph is fully evaluated, so the display list is at a correct + * state. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + (void)depsgraph; + Object *object = CTX_data_active_object(C); Curve *curve = (Curve *)object->data; float min[3], max[3], size[3], loc[3]; int a; - if (object->runtime.curve_cache == NULL) { - BKE_displist_make_curveTypes(depsgraph, scene, object, false, false); - } + BLI_assert(object->runtime.curve_cache != NULL); INIT_MINMAX(min, max); BKE_displist_minmax(&object->runtime.curve_cache->disp, min, max); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 9debea7bf88..5e0053782d4 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -586,7 +586,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) } else { cdd->vc.bmain = CTX_data_main(C); - cdd->vc.depsgraph = CTX_data_depsgraph(C); + cdd->vc.depsgraph = CTX_data_ensure_evaluated_depsgraph(C); cdd->vc.scene = CTX_data_scene(C); cdd->vc.view_layer = CTX_data_view_layer(C); cdd->vc.obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index db3d5ad401d..c912cea5937 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -407,7 +407,6 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) static void text_update_edited(bContext *C, Object *obedit, int mode) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Curve *cu = obedit->data; EditFont *ef = cu->editfont; @@ -421,6 +420,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode) else { /* depsgraph runs above, but since we're not tagging for update, call direct */ /* We need evaluated data here. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), mode); } @@ -590,7 +590,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3]) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Curve *cu; @@ -1084,7 +1084,7 @@ static const EnumPropertyItem move_type_items[] = { static int move_cursor(bContext *C, int type, const bool select) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obedit = CTX_data_edit_object(C); Curve *cu = obedit->data; EditFont *ef = cu->editfont; diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index ce62171ccb0..ae43894b7b6 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -125,6 +125,8 @@ void ED_gizmo_draw_preset_circle(const struct wmGizmo *gz, void ED_gizmo_draw_preset_facemap( const bContext *C, const struct wmGizmo *gz, Object *ob, const int facemap, int select_id) { + /* Dependency graph is supposed to be evaluated prior to draw. */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); const bool is_select = (select_id != -1); const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; @@ -137,7 +139,7 @@ void ED_gizmo_draw_preset_facemap( GPU_matrix_push(); GPU_matrix_mul(ob->obmat); - ED_draw_object_facemap(CTX_data_depsgraph(C), ob, color, facemap); + ED_draw_object_facemap(depsgraph, ob, color, facemap); GPU_matrix_pop(); if (is_select) { diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c index f9ad836b054..21f779b72b1 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c @@ -363,7 +363,7 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d( CTX_data_main(C), CTX_data_scene(C), - CTX_data_depsgraph(C), + CTX_data_ensure_evaluated_depsgraph(C), 0, CTX_wm_region(C), CTX_wm_view3d(C)); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 5793b407bdc..e59e5d6a878 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1073,7 +1073,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* pass on current scene and window */ p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); - p->depsgraph = CTX_data_depsgraph(C); + p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); unit_m4(p->imat); @@ -1630,7 +1630,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) } /* init painting data */ - gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C)); if (p->status == GP_STATUS_ERROR) { gpencil_draw_exit(C, op); return 0; @@ -1903,7 +1903,7 @@ static void annotation_draw_apply_event( static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* printf("GPencil - Starting Re-Drawing\n"); */ @@ -2057,7 +2057,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { @@ -2098,7 +2098,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) * it'd be nice to allow changing paint-mode when in sketching-sessions */ if (gp_session_initdata(C, p)) { - gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, p->paintmode, CTX_data_ensure_evaluated_depsgraph(C)); } if (p->status != GP_STATUS_ERROR) { @@ -2133,6 +2133,7 @@ static void annotation_add_missing_events(bContext *C, const wmEvent *event, tGPsdata *p) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float pt[2], a[2], b[2]; float factor = 10.0f; @@ -2148,7 +2149,7 @@ static void annotation_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, 0.5f); sub_v2_v2v2(pt, b, pt); /* create fake event */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]); } else if (dist >= factor) { int slices = 2 + (int)((dist - 1.0) / factor); @@ -2157,7 +2158,7 @@ static void annotation_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, n * i); sub_v2_v2v2(pt, b, pt); /* create fake event */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]); } } } @@ -2387,7 +2388,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) annotation_add_missing_events(C, op, event, p); } - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + /* TODO(sergey): Possibly evaluating dependency graph from modal operator? */ + annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 809acc3b322..0c2af982279 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1117,7 +1117,8 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in RegionView3D *rv3d = ar->regiondata; tGPDinterpolate_layer *tgpil; Object *obact = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Drawing code is expected to run with fully evaluated depsgraph. */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); float color[4]; diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c index 08f752bb72e..9e70be323eb 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -554,7 +554,7 @@ static bool gpencil_generate_weights_poll(bContext *C) static int gpencil_generate_weights_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = CTX_data_active_object(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index d97207baed8..1a7422cd174 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1650,7 +1650,7 @@ static bool gpsculpt_brush_do_frame( static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) { ToolSettings *ts = CTX_data_tool_settings(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = gso->object; bGPdata *gpd = gso->gpd; bool changed = false; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 087d8540b03..4a91a90c075 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -162,7 +162,10 @@ static void gp_strokepoint_convertcoords(bContext *C, Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): This function might be called from a loop, but no tagging is happening in it, + * so it's not that expensive to ensure evaluated depsgraph here. However, ideally all the + * parameters are to wrapped into a context style struct and queried from Context once.*/ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); bGPDspoint mypt, *pt; @@ -387,8 +390,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, } } -static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, - ReportList *reports, +static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, @@ -446,7 +448,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, cfra = last_valid_time + MIN_TIME_DELTA; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else if (G.debug & G_DEBUG) { @@ -459,7 +461,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, cfra = last_valid_time + MIN_TIME_DELTA; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else { @@ -467,15 +469,8 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, * and also far enough from (not yet added!) end_stroke keyframe! */ if ((cfra - last_valid_time) > MIN_TIME_DELTA && (end_stroke_time - cfra) > MIN_TIME_DELTA) { - insert_keyframe_direct(depsgraph, - reports, - ptr, - prop, - fcu, - cfra, - BEZT_KEYTYPE_BREAKDOWN, - NULL, - INSERTKEY_FAST); + insert_keyframe_direct( + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_BREAKDOWN, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else if (G.debug & G_DEBUG) { @@ -493,7 +488,6 @@ static void gp_stroke_path_animation(bContext *C, Curve *cu, tGpTimingData *gtd) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bAction *act; @@ -538,7 +532,7 @@ static void gp_stroke_path_animation(bContext *C, cu->ctime = 0.0f; cfra = (float)gtd->start_frame; insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); cu->ctime = cu->pathlen; if (gtd->realtime) { @@ -548,7 +542,7 @@ static void gp_stroke_path_animation(bContext *C, cfra = (float)gtd->end_frame; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); } else { /* Use actual recorded timing! */ @@ -575,7 +569,7 @@ static void gp_stroke_path_animation(bContext *C, } gp_stroke_path_animation_add_keyframes( - depsgraph, reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); + reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); BLI_rng_free(rng); } @@ -1250,7 +1244,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, subrect, true); return 1; } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 0ee4fd20f0f..696c98c6646 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -2200,7 +2200,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_active = CTX_data_active_object(C); bGPdata *gpd_dst = NULL; bool ok = false; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 0fc051e4756..c6d0d6e3ce2 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -139,7 +139,6 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) const int back = RNA_boolean_get(op->ptr, "back"); struct wmMsgBus *mbus = CTX_wm_message_bus(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); bGPdata *gpd = ED_gpencil_data_get_active(C); bool is_object = false; short mode; @@ -159,6 +158,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) gpd->flag ^= GP_DATA_STROKE_EDITMODE; /* recalculate parent matrix */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_gpencil_reset_layers_parent(depsgraph, ob, gpd); } /* set mode */ @@ -1381,7 +1381,7 @@ void GPENCIL_OT_paste(wmOperatorType *ot) ot->poll = gp_strokes_paste_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", copy_type, 0, "Type", ""); @@ -2495,7 +2495,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) RegionView3D *rv3d = CTX_wm_region_data(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); const float gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL); @@ -2570,7 +2570,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); @@ -2663,7 +2663,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); float *cursor = scene->cursor.location; @@ -3374,7 +3374,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; @@ -3519,7 +3519,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot) "CURSOR", 0, "Cursor", - "Reproject the strokes using the orienation of 3D cursor"}, + "Reproject the strokes using the orientation of 3D cursor"}, {0, NULL, 0, NULL, NULL}, }; @@ -3537,7 +3537,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot) ot->poll = gp_strokes_edit3d_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum( @@ -4527,7 +4527,7 @@ void GPENCIL_OT_stroke_cutter(wmOperatorType *ot) ot->cancel = WM_gesture_lasso_cancel; /* flag */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_lasso(ot); diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 1ac4471547e..5637e755198 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -1213,7 +1213,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) tgpf->ar = CTX_wm_region(C); tgpf->rv3d = tgpf->ar->regiondata; tgpf->v3d = tgpf->sa->spacedata.first; - tgpf->depsgraph = CTX_data_depsgraph(C); + tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpf->win = CTX_wm_window(C); /* set GP datablock */ diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index e28e83b23b0..a8a3c2f9306 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -599,7 +599,7 @@ struct GP_EditableStrokes_Iter { #define GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps) \ { \ struct GP_EditableStrokes_Iter gpstroke_iter = {{{0}}}; \ - Depsgraph *depsgraph_ = CTX_data_depsgraph(C); \ + Depsgraph *depsgraph_ = CTX_data_ensure_evaluated_depsgraph(C); \ Object *obact_ = CTX_data_active_object(C); \ bGPdata *gpd_ = CTX_data_gpencil_data(C); \ const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \ diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index db4c601709c..d259bb9183c 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -81,9 +81,15 @@ static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_t { /* TODO: limit this to mode, but review 2D editors */ bGPdata *gpd = CTX_data_gpencil_data(C); + if (!gpd) + return false; + ToolSettings *ts = CTX_data_tool_settings(C); + if (!ts || !ts->gp_paint) + return false; + Brush *brush = BKE_paint_brush(&ts->gp_paint->paint); - return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && + return ((gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && WM_toolsystem_active_tool_is_brush(C) && (brush->gpencil_tool == gpencil_tool)); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 5af355b908d..a271274fa71 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1894,7 +1894,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) p->C = C; p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); - p->depsgraph = CTX_data_depsgraph(C); + p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); p->disable_fill = RNA_boolean_get(op->ptr, "disable_fill"); @@ -2431,7 +2431,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) } /* init painting data */ - gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C)); if (p->status == GP_STATUS_ERROR) { gpencil_draw_exit(C, op); return 0; @@ -2825,10 +2825,10 @@ static void gpencil_draw_apply_event( float pt[2]; copy_v2_v2(tmp, p->mval); sub_v2_v2v2(pt, p->mval, p->mvali); - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); if (len_v2v2(p->mval, p->mvalo)) { sub_v2_v2v2(pt, p->mval, p->mvalo); - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } copy_v2_v2(p->mval, tmp); } @@ -2948,7 +2948,7 @@ static void gpencil_draw_apply_event( static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* printf("GPencil - Starting Re-Drawing\n"); */ @@ -3196,7 +3196,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + gpencil_draw_apply_event(C, op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { @@ -3260,7 +3260,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) * it'd be nice to allow changing paint-mode when in sketching-sessions */ if (gp_session_initdata(C, op, p)) { - gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph_pointer(C)); } if (p->status != GP_STATUS_ERROR) { @@ -3321,6 +3321,7 @@ static void gpencil_add_missing_events(bContext *C, { Brush *brush = p->brush; GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); int input_samples = brush->gpencil_settings->input_samples; /* ensure sampling when using circular guide */ @@ -3379,7 +3380,7 @@ static void gpencil_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, 0.5f); sub_v2_v2v2(pt, b, pt); /* create fake event */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } else if (dist >= factor) { int slices = 2 + (int)((dist - 1.0) / factor); @@ -3388,7 +3389,7 @@ static void gpencil_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, n * i); sub_v2_v2v2(pt, b, pt); /* create fake event */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } } } @@ -3695,7 +3696,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) gpencil_add_missing_events(C, op, event, p); } - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph_pointer(C), 0.0f, 0.0f); /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index c79366e6a2b..bdc65e7172a 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1109,7 +1109,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) tgpi->ar = CTX_wm_region(C); tgpi->rv3d = tgpi->ar->regiondata; tgpi->v3d = tgpi->sa->spacedata.first; - tgpi->depsgraph = CTX_data_depsgraph(C); + tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpi->win = CTX_wm_window(C); /* save original type */ diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index b1d9bcfbe16..5a962809954 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -989,7 +989,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) ot->cancel = WM_gesture_circle_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_circle(ot); @@ -1180,7 +1180,7 @@ void GPENCIL_OT_select_box(wmOperatorType *ot) ot->poll = gpencil_select_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_box(ot); @@ -1248,7 +1248,7 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) ot->cancel = WM_gesture_lasso_cancel; /* flags */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_select_operation(ot); @@ -1468,7 +1468,7 @@ void GPENCIL_OT_select(wmOperatorType *ot) ot->poll = gpencil_select_poll; /* flag */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_mouse_select(ot); diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index ac8196f5ed0..a475e43755c 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -259,7 +259,7 @@ bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C) ID *screen_id = (ID *)CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob = CTX_data_active_object(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); @@ -548,7 +548,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) if (sa->spacetype == SPACE_VIEW3D) { wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = (View3D *)CTX_wm_space_data(C); RegionView3D *rv3d = ar->regiondata; @@ -560,8 +560,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border( - scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &r_gsc->subrect_data, true); r_gsc->subrect = &r_gsc->subrect_data; } } @@ -929,7 +928,7 @@ void ED_gp_get_drawing_reference( void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *gps) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; GP_SpaceConversion gsc = {NULL}; @@ -1094,7 +1093,7 @@ void ED_gp_project_point_to_plane(const Scene *scene, /* get a vector from the point with the current view direction of the viewport */ ED_view3d_global_to_vector(rv3d, &pt->x, vn); - /* calculate line extrem point to create a ray that cross the plane */ + /* calculate line extreme point to create a ray that cross the plane */ mul_v3_fl(vn, -50.0f); add_v3_v3v3(ray, &pt->x, vn); diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 230d62d400c..a232e1376d3 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -27,6 +27,7 @@ struct AnimData; struct ID; struct ListBase; +struct Depsgraph; struct ARegion; struct Main; @@ -84,8 +85,6 @@ typedef struct bAnimContext { /** dopesheet data for editor (or which is being used) */ struct bDopeSheet *ads; - /** active dependency graph */ - struct Depsgraph *depsgraph; /** Current Main */ struct Main *bmain; /** active scene */ diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 9fa8996c384..05f641abe91 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -127,7 +127,7 @@ typedef enum eKeyframeExtremeDrawOpts { KEYFRAME_EXTREME_MAX = (1 << 1), /* Grouped keys have different states. */ KEYFRAME_EXTREME_MIXED = (1 << 2), - /* Both neigbors are equal to this key. */ + /* Both neighbors are equal to this key. */ KEYFRAME_EXTREME_FLAT = (1 << 3), } eKeyframeExtremeDrawOpts; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index a893f03bd88..8f197fa9afe 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -113,8 +113,7 @@ int insert_vert_fcurve( * Use this to insert a keyframe using the current value being keyframed, in the * nominated F-Curve (no creation of animation data performed). Returns success. */ -bool insert_keyframe_direct(struct Depsgraph *depsgraph, - struct ReportList *reports, +bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, @@ -130,7 +129,6 @@ bool insert_keyframe_direct(struct Depsgraph *depsgraph, * using the current value being keyframed, in the relevant place. Returns success. */ short insert_keyframe(struct Main *bmain, - struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act, diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index d2613facd83..5ebba4e5d25 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -254,7 +254,10 @@ void ED_operatormacros_mesh(void); void ED_keymap_mesh(struct wmKeyConfig *keyconf); /* editmesh_tools.c (could be moved) */ -void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em); +void EDBM_project_snap_verts(struct bContext *C, + struct Depsgraph *depsgraph, + struct ARegion *ar, + struct BMEditMesh *em); /* editface.c */ void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 038f1bf52a6..5f9534a1f1c 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -166,13 +166,11 @@ void ED_object_vpaintmode_enter_ex(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene, struct Object *ob); -void ED_object_vpaintmode_enter(struct bContext *C); void ED_object_wpaintmode_enter_ex(struct Main *bmain, struct Depsgraph *depsgraph, struct wmWindowManager *wm, struct Scene *scene, struct Object *ob); -void ED_object_wpaintmode_enter(struct bContext *C); void ED_object_vpaintmode_exit_ex(struct Object *ob); void ED_object_vpaintmode_exit(struct bContext *C); @@ -185,12 +183,10 @@ void ED_object_sculptmode_enter_ex(struct Main *bmain, struct Object *ob, const bool force_dyntopo, struct ReportList *reports); -void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports); void ED_object_sculptmode_exit_ex(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); -void ED_object_sculptmode_exit(struct bContext *C); void ED_object_location_from_view(struct bContext *C, float loc[3]); void ED_object_rotation_from_quat(float rot[3], const float quat[4], const char align_axis); @@ -271,7 +267,6 @@ bool ED_object_mode_compat_set(struct bContext *C, struct ReportList *reports); void ED_object_mode_toggle(struct bContext *C, eObjectMode mode); void ED_object_mode_set(struct bContext *C, eObjectMode mode); -void ED_object_mode_exit(struct bContext *C); bool ED_object_mode_generic_enter(struct bContext *C, eObjectMode object_mode); void ED_object_mode_generic_exit(struct Main *bmain, diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 72efea32c38..9bf85b8268a 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -76,6 +76,10 @@ enum eGPUFXFlags; typedef struct ViewContext { struct bContext *C; struct Main *bmain; + /* Dependency graph is uses for depth drawing, viewport camera matrix access, and also some areas + * are re-using this to access evaluated entities. + * + * Moral of the story: assign to a fully evaluated state. */ struct Depsgraph *depsgraph; struct Scene *scene; struct ViewLayer *view_layer; @@ -564,7 +568,7 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph, bool do_sky, bool is_persp, const char *viewname, - const bool do_color_managment, + const bool do_color_management, struct GPUOffScreen *ofs, struct GPUViewport *viewport); void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph, diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 47cf827ed66..03a49943ed3 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -90,8 +90,8 @@ DEF_ICON(COPY_ID) DEF_ICON(EYEDROPPER) DEF_ICON_BLANK(92) DEF_ICON(AUTO) -DEF_ICON(CHECKBOX_DEHLT) /* de-Hilight - Checkbox OFF */ -DEF_ICON(CHECKBOX_HLT) /* Hilight - Checkbox ON */ +DEF_ICON(CHECKBOX_DEHLT) /* de-Highlight - Checkbox OFF */ +DEF_ICON(CHECKBOX_HLT) /* Highlight - Checkbox ON */ DEF_ICON(UNLOCKED) DEF_ICON(LOCKED) DEF_ICON(UNPINNED) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 5ff200fa7e4..4d87cc22ef2 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -286,12 +286,11 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) if (special) { /* NLA Strip property */ if (IS_AUTOKEY_ON(scene)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; insert_keyframe_direct( - depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0); + reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } } @@ -300,12 +299,10 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) * making it easier to set up corrective drivers */ if (IS_AUTOKEY_ON(scene)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; - insert_keyframe_direct(depsgraph, - reports, + insert_keyframe_direct(reports, but->rnapoin, but->rnaprop, fcu, @@ -321,7 +318,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) /* TODO: this should probably respect the keyingset only option for anim */ if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; short flag = ANIM_get_keyframing_flags(scene, 1); @@ -333,7 +329,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) * E.g., color wheels (see T42567). */ BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1)); insert_keyframe(bmain, - depsgraph, reports, id, action, diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index fc60fc06ac0..2e51701e01d 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -168,7 +168,7 @@ static void depthdropper_depth_sample_pt( if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); if (ar) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; /* weak, we could pass in some reference point */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d4e8b7548bc..245277c8d22 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -10113,31 +10113,18 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE if (but) { bScreen *screen = CTX_wm_screen(C); - ARegion *ar_temp; uiBut *but_other; uiHandleButtonData *data; - bool is_inside_menu = false; - - /* look for a popup menu containing the mouse */ - for (ar_temp = screen->regionbase.first; ar_temp; ar_temp = ar_temp->next) { - rcti winrct; - - ui_region_winrct_get_no_margin(ar_temp, &winrct); - - if (BLI_rcti_isect_pt_v(&winrct, &event->x) || ui_region_find_active_but(ar_temp)) { - BLI_assert(ar_temp->type->regionid == RGN_TYPE_TEMPORARY); - - is_inside_menu = true; - break; - } - } /* handle activated button events */ data = but->active; if ((data->state == BUTTON_STATE_MENU_OPEN) && + /* Make sure this popup isn't dragging a button. + * can happen with popovers (see T67882). */ + (ui_region_find_active_but(data->menu->region) == NULL) && /* make sure mouse isn't inside another menu (see T43247) */ - (is_inside_menu == false) && + (ui_screen_region_find_mouse_over(screen, event) == NULL) && (ELEM(but->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU)) && (but_other = ui_but_find_mouse_over(ar, event)) && (but != but_other) && (ELEM(but_other->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU))) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index ea5ef94d90d..7584a43a790 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -464,7 +464,7 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19) # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH /* Dynamically render icon instead of rendering a plain color to a texture/buffer - * This is mot strictly a "vicon", as it needs access to icon->obj to get the color info, + * This is not strictly a "vicon", as it needs access to icon->obj to get the color info, * but it works in a very similar way. */ static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index fc65129ebf7..a5d9d35e2fe 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -938,6 +938,9 @@ uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT; bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT; bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px); +ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y); +ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent *event); + /* interface_context_menu.c */ bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa); diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 462183b4245..d0efb3714bc 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -570,3 +570,29 @@ bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Screen (#bScreen) Spatial + * \{ */ + +/** Check if the cursor is over any popups. */ +ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y) +{ + for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) { + rcti winrct; + + ui_region_winrct_get_no_margin(ar, &winrct); + + if (BLI_rcti_isect_pt(&winrct, x, y)) { + return ar; + } + } + return NULL; +} + +ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event) +{ + return ui_screen_region_find_mouse_over_ex(screen, event->x, event->y); +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index bba5103bc03..54bdbe0ec6e 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -70,7 +70,7 @@ static bool last_redo_poll(const bContext *C, short region_type) bool success = false; { - /* Make sure that we are using the same region type as the originial + /* Make sure that we are using the same region type as the original * operator call. Otherwise we would be polling the operator with the * wrong context. */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 7d9b722fcc0..b57d100127e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -31,6 +31,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_math_base.h" +#include "BLI_math_vector.h" #include "BKE_context.h" @@ -1146,33 +1147,49 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event } else if (event->type == MOUSEMOVE) { float dx, dy; + float zoomfac = 0.01f; + + /* some view2d's (graph) don't have min/max zoom, or extreme ones */ + if (v2d->maxzoom > 0.0f) { + zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); + } /* calculate new delta transform, based on zooming mode */ if (U.viewzoom == USER_ZOOM_SCALE) { /* 'scale' zooming */ float dist; + float len_old[2]; + float len_new[2]; /* x-axis transform */ dist = BLI_rcti_size_x(&v2d->mask) / 2.0f; - dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) / - (fabsf(event->mval[0] - dist) + 2.0f); - dx *= 0.5f * BLI_rctf_size_x(&v2d->cur); + len_old[0] = fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist); + len_new[0] = fabsf(event->x - vzd->ar->winrct.xmin - dist); + + len_old[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur); + len_new[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur); /* y-axis transform */ dist = BLI_rcti_size_y(&v2d->mask) / 2.0f; - dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / - (fabsf(event->mval[1] - dist) + 2.0f); - dy *= 0.5f * BLI_rctf_size_y(&v2d->cur); + len_old[1] = fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist); + len_new[1] = fabsf(event->y - vzd->ar->winrct.ymin - dist); + + len_old[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur); + len_new[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur); + + /* Calculate distance */ + if (v2d->keepzoom & V2D_KEEPASPECT) { + dist = len_v2(len_new) - len_v2(len_old); + dx = dy = dist; + } + else { + dx = len_new[0] - len_old[0]; + dy = len_new[1] - len_old[1]; + } } else { /* 'continuous' or 'dolly' */ - float fac, zoomfac = 0.01f; - - /* some view2d's (graph) don't have min/max zoom, or extreme ones */ - if (v2d->maxzoom > 0.0f) { - zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); - } - + float fac; /* x-axis transform */ fac = zoomfac * (event->x - vzd->lastx); dx = fac * BLI_rctf_size_x(&v2d->cur); @@ -1180,6 +1197,18 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event /* y-axis transform */ fac = zoomfac * (event->y - vzd->lasty); dy = fac * BLI_rctf_size_y(&v2d->cur); + + /* Only respect user setting zoom axis if the view does not have any zoom restrictions + * any will be scaled uniformly */ + if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && + (v2d->keepzoom & V2D_KEEPASPECT)) { + if (U.uiflag & USER_ZOOM_HORIZ) { + dy = 0; + } + else { + dx = 0; + } + } } /* support zoom to always zoom entirely - the v2d code uses portrait or diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 9fdcec71cfd..ff2bc72c2f7 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -147,7 +147,7 @@ static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); BKE_cachefile_reload(depsgraph, cache_file); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 883dfe9ad7c..683e6d8a2b0 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -72,7 +72,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, float u = 0.0f; float scalex, scaley; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 8e4efddd8a7..c91f431ad20 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -86,7 +86,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, eMaskWhichHandle which_handle = MASK_WHICH_HANDLE_NONE; int width, height; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); @@ -241,7 +241,7 @@ bool ED_mask_feather_find_nearest(const bContext *C, float scalex, scaley; int width, height; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index d61c340f7a2..9a70b0a8d36 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -77,7 +77,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) BKE_mesh_flush_select_from_polys(me); } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); if (ob_eval == NULL) { diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 0da4d20c6b5..5b16cfd00f5 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -658,6 +658,7 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot) static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; BMVert *v1; BMIter iter; @@ -819,7 +820,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w /* also project the source, for retopo workflow */ if (use_proj) { - EDBM_project_snap_verts(C, vc.ar, vc.em); + EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em); } } @@ -852,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w } if (use_proj) { - EDBM_project_snap_verts(C, vc.ar, vc.em); + EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em); } /* This normally happens when pushing undo but modal operators diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 13bcb1334a9..3d34a4ad3b5 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -57,7 +57,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Object *ob, LinkNode *polys) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ARegion *ar = CTX_wm_region(C); struct Mesh *me_eval; bool me_eval_needs_free; @@ -173,7 +173,7 @@ void MESH_OT_knife_project(wmOperatorType *ot) ot->poll = ED_operator_editmesh_region_view3d; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* parameters */ RNA_def_boolean(ot->srna, diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index c7606758b63..2ddd654f824 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -272,7 +272,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) em_setup_viewcontext(C, &lcd->vc); - lcd->depsgraph = CTX_data_depsgraph(C); + lcd->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* assign the drawing handle for drawing preview line... */ lcd->ar = CTX_wm_region(C); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3b5c8e9f101..ecdf103e6eb 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -411,7 +411,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot) ot->srna, "iterations", 2, 1, 1000, "Iterations", "Number of times to unsubdivide", 1, 100); } -void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) +void EDBM_project_snap_verts(bContext *C, Depsgraph *depsgraph, ARegion *ar, BMEditMesh *em) { Main *bmain = CTX_data_main(C); Object *obedit = em->ob; @@ -421,7 +421,7 @@ void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) ED_view3d_init_mats_rv3d(obedit, ar->regiondata); struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ar, CTX_wm_view3d(C)); + bmain, CTX_data_scene(C), depsgraph, 0, ar, CTX_wm_view3d(C)); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index d76801a2500..e086eda9b33 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -278,7 +278,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, } if ((tot_unique <= tot_unique_prev) && (tot_unique_edges <= tot_unique_edges_prev)) { - /* Finish searching for unique values when 1 loop dosn't give a + /* Finish searching for unique values when 1 loop doesn't give a * higher number of unique values compared to the previous loop. */ break; } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 41736fb9a14..b082af352b2 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -311,7 +311,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* count & check */ CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { @@ -674,7 +674,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob_active = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = (Mesh *)ob_active->data; Mesh *selme = NULL; Mesh *me_deformed = NULL; @@ -1165,7 +1165,7 @@ static void ed_mesh_pick_face_vert__mpoly_find( bool ED_mesh_pick_face_vert( bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); unsigned int poly_index; Mesh *me = ob->data; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f8cf55933aa..137af917f9a 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -236,7 +236,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], { Object *ob = base->object; Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (!scene) { return; @@ -250,7 +250,11 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], copy_v3_v3(ob->rot, rot); } - BKE_object_where_is_calc(depsgraph, scene, ob); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + BKE_object_transform_copy(object_eval, ob); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); + BKE_object_transform_copy(ob, object_eval); } /* Uses context to figure out transform for primitive. @@ -1758,12 +1762,15 @@ static bool dupliobject_instancer_cmp(const void *a_, const void *b_) return false; } -static void make_object_duplilist_real( - bContext *C, Scene *scene, Base *base, const bool use_base_parent, const bool use_hierarchy) +static void make_object_duplilist_real(bContext *C, + Depsgraph *depsgraph, + Scene *scene, + Base *base, + const bool use_base_parent, + const bool use_hierarchy) { Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); ListBase *lb_duplis; DupliObject *dob; GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL; @@ -1955,6 +1962,7 @@ static void make_object_duplilist_real( static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent"); @@ -1963,7 +1971,7 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) BKE_main_id_clear_newpoins(bmain); CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy); + make_object_duplilist_real(C, depsgraph, scene, base, use_base_parent, use_hierarchy); /* dependencies were changed */ WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object); @@ -1990,7 +1998,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_base_parent", @@ -2131,7 +2139,7 @@ static Base *duplibase_for_convert( static int convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Base *basen = NULL, *basact = NULL; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 5ef133e87de..7343dba420f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -864,13 +864,12 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) /* ------------- Child-Of Constraint ------------------ */ static void child_get_inverse_matrix_owner_bone( - const bContext *C, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4]) + Depsgraph *depsgraph, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4]) { /* For bone owner we want to do this in evaluated domain. * BKE_pose_where_is / BKE_pose_where_is_bone relies on (re)evaluating parts of the scene * and copying new evaluated stuff back to original. */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); bConstraint *con_eval = edit_constraint_property_get(op, ob_eval, CONSTRAINT_TYPE_CHILDOF); @@ -947,9 +946,8 @@ static void child_get_inverse_matrix_owner_bone( } static void child_get_inverse_matrix_owner_object( - const bContext *C, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) + Depsgraph *depsgraph, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); /* nullify inverse matrix first */ unit_m4(invmat); @@ -971,6 +969,7 @@ static void child_get_inverse_matrix_owner_object( static int childof_set_inverse_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); @@ -985,10 +984,10 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) } if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { - child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat); + child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat); } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat); + child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat); } ED_object_constraint_update(bmain, ob); @@ -1224,6 +1223,7 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot) static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); @@ -1238,10 +1238,10 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) } if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { - child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat); + child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat); } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat); + child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat); } ED_object_constraint_update(bmain, ob); diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 465a60ba75c..79aafc6978f 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -111,8 +111,6 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, int totitem = 0; const int data_type = RNA_enum_get(ptr, "data_type"); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer"); const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop); const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") : @@ -158,6 +156,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -183,6 +182,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -397,7 +397,7 @@ static bool data_transfer_exec_is_object_valid(wmOperator *op, static int data_transfer_exec(bContext *C, wmOperator *op) { Object *ob_src = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); ListBase ctx_objects; @@ -613,7 +613,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) ot->check = data_transfer_check; /* Flags.*/ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties.*/ prop = RNA_def_boolean(ot->srna, @@ -767,7 +767,7 @@ static bool datalayout_transfer_poll(bContext *C) static int datalayout_transfer_exec(bContext *C, wmOperator *op) { Object *ob_act = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); DataTransferModifierData *dtmd; @@ -873,7 +873,7 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot) ot->check = data_transfer_check; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties.*/ edit_modifier_properties(ot); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a390cf67cf5..ed40a4eb948 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -906,7 +906,9 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_ } Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some + * nested pointers, like animation data. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ListBase targets = {NULL, NULL}; /* loop over objects in scene */ @@ -1056,7 +1058,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot) ot->idname = "OBJECT_OT_paths_update"; ot->description = "Recalculate paths for selected objects"; - /* api callbakcs */ + /* api callbacks */ ot->exec = object_update_paths_exec; ot->poll = object_update_paths_poll; diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index 5c4fa5aeee6..075cd5acad6 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -596,7 +596,7 @@ void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot) static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C); GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0); int apply_as = RNA_enum_get(op->ptr, "apply_as"); diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 707489d588a..15c5ea40991 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -528,7 +528,7 @@ static int add_hook_object(const bContext *C, int mode, ReportList *reports) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ModifierData *md = NULL; HookModifierData *hmd = NULL; float cent[3]; @@ -603,13 +603,14 @@ static int add_hook_object(const bContext *C, /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ - Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - BKE_object_transform_copy(ob_eval, ob); - BKE_object_where_is_calc(depsgraph, scene, ob_eval); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + BKE_object_transform_copy(object_eval, ob); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); - invert_m4_m4(ob_eval->imat, ob_eval->obmat); + invert_m4_m4(object_eval->imat, object_eval->obmat); /* apparently this call goes from right to left... */ - mul_m4_series(hmd->parentinv, pose_mat, ob_eval->imat, obedit->obmat); + mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->obmat); DEG_relations_tag_update(bmain); diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 0ec98e089a2..271d8effd30 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -171,14 +171,6 @@ void ED_object_mode_toggle(bContext *C, eObjectMode mode) if (opstring) { wmOperatorType *ot = WM_operatortype_find(opstring, false); - if (ot->flag & OPTYPE_USE_EVAL_DATA) { - /* We need to force refresh of depsgraph after undo step, - * redoing the operator *may* rely on some valid evaluated data. */ - struct Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); - } WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL); } } @@ -194,20 +186,6 @@ void ED_object_mode_set(bContext *C, eObjectMode mode) wm->op_undo_depth--; } -void ED_object_mode_exit(bContext *C) -{ - Depsgraph *depsgraph = CTX_data_depsgraph(C); - struct Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - FOREACH_OBJECT_BEGIN (view_layer, ob) { - if (ob->mode & OB_MODE_ALL_MODE_DATA) { - ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); - } - } - FOREACH_OBJECT_END; -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d1d910021a6..8818fd71190 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1130,7 +1130,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) static int modifier_apply_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); @@ -1194,7 +1194,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); @@ -1391,7 +1391,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) static int multires_reshape_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C), *secondob = NULL; MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get( op, ob, eModifierType_Multires); @@ -1934,7 +1934,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, static int skin_armature_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C), *arm_ob; Mesh *me = ob->data; @@ -1999,7 +1999,7 @@ static bool correctivesmooth_poll(bContext *C) static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get( @@ -2077,7 +2077,7 @@ static bool meshdeform_poll(bContext *C) static int meshdeform_bind_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_MeshDeform); @@ -2316,8 +2316,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) for (f = omd->bakestart; f <= omd->bakeend; f++) { /* For now only simple animation of time value is supported, nothing else. * No drivers or other modifier parameters. */ - BKE_animsys_evaluate_animdata( - CTX_data_depsgraph(C), scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); + /* TODO(sergey): This operates on an original data, so no flush is needed. However, baking + * usually should happen on an evaluated objects, so this seems to be deeper issue here. */ + BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM, false); och->time[i] = omd->time; i++; @@ -2402,7 +2403,7 @@ static bool laplaciandeform_poll(bContext *C) static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_LaplacianDeform); @@ -2477,7 +2478,7 @@ static bool surfacedeform_bind_poll(bContext *C) static int surfacedeform_bind_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_SurfaceDeform); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ff31cbc4590..a69f4872e72 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -124,7 +124,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); BMVert *eve; @@ -677,7 +677,7 @@ bool ED_object_parent_set(ReportList *reports, const int vert_par[3]) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bPoseChannel *pchan = NULL; bPoseChannel *pchan_eval = NULL; const bool pararm = ELEM( @@ -1727,7 +1727,7 @@ static Collection *single_object_users_collection(Main *bmain, const bool is_master_collection) { /* Generate new copies for objects in given collection and all its children, - * and optionnaly also copy collections themselves. */ + * and optionally also copy collections themselves. */ if (copy_collections && !is_master_collection) { collection = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection)); } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 3f7d5dba149..5934eab62bb 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -547,7 +547,7 @@ static int apply_objects_internal(bContext *C, { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; bool changed = true; @@ -881,7 +881,7 @@ static int apply_objects_internal(bContext *C, static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bool changed = false; CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -976,7 +976,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *tob; float cent[3], cent_neg[3], centn[3]; const float *cursor = scene->cursor.location; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 4f61443ac54..a43ac59c9b8 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1514,7 +1514,7 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, static void vgroup_fix( const bContext *C, Scene *UNUSED(scene), Object *ob, float distToBe, float strength, float cp) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); int i; diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 40b7a245f69..c06c21b9057 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -473,7 +473,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update */ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_ = ED_object_context(C); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -505,7 +505,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"); job->bmain = CTX_data_main(C); job->scene = scene_eval; - job->depsgraph = CTX_data_depsgraph(C); + job->depsgraph = depsgraph; job->ob = object_eval; job->canvas = canvas; job->surface = surface; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 2f2516f2055..e6870cda19d 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -252,7 +252,7 @@ static void pe_update_hair_particle_edit_pointers(PTCacheEdit *edit) /* always gets at least the first particlesystem even if PSYS_CURRENT flag is not set * - * note: this function runs on poll, therefor it can runs many times a second + * note: this function runs on poll, therefore it can runs many times a second * keep it fast! */ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *ob, int create) { @@ -465,7 +465,7 @@ static void PE_set_data(bContext *C, PEData *data) data->scene = CTX_data_scene(C); data->view_layer = CTX_data_view_layer(C); data->ob = CTX_data_active_object(C); - data->depsgraph = CTX_data_depsgraph(C); + data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); data->edit = PE_get_current(data->scene, data->ob); } @@ -1499,7 +1499,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, DEG_id_tag_update(&ob->id, ID_RECALC_SELECT); } -void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edit) +void update_world_cos(Object *ob, PTCacheEdit *edit) { ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd_eval = edit->psmd_eval; @@ -1619,7 +1619,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla PE_apply_mirror(ob, edit->psys); } if (edit->psys) { - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); } if (pset->flag & PE_AUTO_VELOCITY) { update_velocities(edit); @@ -1778,7 +1778,7 @@ static bool select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in static int pe_select_all_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; @@ -2348,7 +2348,7 @@ static int hide_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; @@ -2409,7 +2409,7 @@ static int reveal_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PTCacheEdit *edit = PE_get_current(scene, ob); const bool select = RNA_boolean_get(op->ptr, "select"); POINT_P; @@ -2709,7 +2709,7 @@ static void rekey_particle_to_time( psys = edit->psys; - sim.depsgraph = CTX_data_depsgraph(C); + sim.depsgraph = CTX_data_depsgraph_pointer(C); sim.scene = scene; sim.ob = ob; sim.psys = psys; @@ -3519,7 +3519,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) PE_mirror_x(scene, ob, 0); - update_world_cos(CTX_data_depsgraph(C), ob, edit); + update_world_cos(ob, edit); WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -4211,7 +4211,7 @@ static void brush_add_count_iter_finalize(void *__restrict userdata_v, static int brush_add(const bContext *C, PEData *data, short number) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = data->scene; Object *ob = data->ob; Mesh *mesh; @@ -4542,7 +4542,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { BrushEdit *bedit = op->customdata; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = bedit->scene; Object *ob = bedit->ob; PTCacheEdit *edit = bedit->edit; @@ -4747,7 +4747,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) PE_mirror_x(scene, ob, 1); } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -4993,7 +4993,6 @@ static void shape_cut(PEData *data, int pa_index) static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); ParticleEditSettings *pset = PE_settings(scene); @@ -5032,7 +5031,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) recalc_lengths(edit); if (removed) { - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -5203,7 +5202,7 @@ void PE_create_particle_edit( } pa++; } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); } else { PTCacheMem *pm; @@ -5295,7 +5294,7 @@ static void free_all_psys_edit(Object *object) static int particle_edit_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_PARTICLE_EDIT; @@ -5496,7 +5495,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); PTCacheEdit *edit = PE_get_current(scene, ob); float average_length = calculate_average_length(edit); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index fcee2cde5b1..0999d1f3588 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -652,7 +652,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part static int disconnect_hair_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); ParticleSystem *psys = NULL; @@ -934,7 +934,7 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl static int connect_hair_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); ParticleSystem *psys = NULL; @@ -1037,7 +1037,7 @@ static void copy_particle_edit(Depsgraph *depsgraph, pa++; } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col); UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); @@ -1086,7 +1086,7 @@ static bool copy_particle_systems_to_object(const bContext *C, bool duplicate_settings) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ModifierData *md; ParticleSystem *psys_start = NULL, *psys, *psys_from; ParticleSystem **tmp_psys; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index dc3673c972f..44858e36fab 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -334,6 +334,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) } static void fluid_init_all_channels(bContext *C, + Depsgraph *depsgraph, Object *UNUSED(fsDomain), FluidsimSettings *domainSettings, FluidAnimChannels *channels, @@ -341,7 +342,6 @@ static void fluid_init_all_channels(bContext *C, { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); Base *base; int i; int length = channels->length; @@ -514,9 +514,11 @@ static void fluid_init_all_channels(bContext *C, } } -static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length) +static void export_fluid_objects(Depsgraph *depsgraph, + ListBase *fobjects, + Scene *scene, + int length) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); FluidObject *fobj; for (fobj = fobjects->first; fobj; fobj = fobj->next) { @@ -714,7 +716,7 @@ static bool fluid_init_filepaths(Main *bmain, /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); - /* Ensure whole path exists and is wirtable. */ + /* Ensure whole path exists and is writeable. */ const bool dir_exists = BLI_dir_create_recursive(targetDir); const bool is_writable = BLI_file_is_writable(targetFile); @@ -747,7 +749,7 @@ static bool fluid_init_filepaths(Main *bmain, /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); - /* Ensure whole path exists and is wirtable. */ + /* Ensure whole path exists and is writeable. */ if (!BLI_dir_create_recursive(targetDir) || !BLI_file_is_writable(targetFile)) { BKE_reportf(reports, RPT_ERROR, @@ -922,7 +924,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); int i; FluidsimSettings *domainSettings; @@ -1051,11 +1053,11 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor (double)noFrames; /* ******** initialize and allocate animation channels ******** */ - fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); + fluid_init_all_channels(C, depsgraph, fsDomain, domainSettings, channels, fobjects); /* reset to original current frame */ scene->r.cfra = origFrame; - ED_update_for_newframe(CTX_data_main(C), depsgraph); + ED_update_for_newframe(CTX_data_main(C), CTX_data_depsgraph_pointer(C)); /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); @@ -1153,7 +1155,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor elbeemAddDomain(fsset); /* ******** export all fluid objects to elbeem ******** */ - export_fluid_objects(C, fobjects, scene, channels->length); + export_fluid_objects(depsgraph, fobjects, scene, channels->length); /* custom data for fluid bake job */ fb->settings = fsset; diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index bb7cfe9b1a3..9ebbba07fdf 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -70,7 +70,7 @@ void recalc_lengths(struct PTCacheEdit *edit); void recalc_emitter_field(struct Depsgraph *depsgraph, struct Object *ob, struct ParticleSystem *psys); -void update_world_cos(struct Depsgraph *depsgraph, struct Object *ob, struct PTCacheEdit *edit); +void update_world_cos(struct Object *ob, struct PTCacheEdit *edit); /* particle_object.c */ void OBJECT_OT_particle_system_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index e9e89a31f94..bc2f1d6cef6 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -156,7 +156,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) baker->bmain = CTX_data_main(C); baker->scene = CTX_data_scene(C); baker->view_layer = CTX_data_view_layer(C); - baker->depsgraph = CTX_data_depsgraph(C); + /* Depsgraph is used to sweep the frame range and evaluate scene at different times. */ + baker->depsgraph = CTX_data_depsgraph_pointer(C); baker->bake = RNA_boolean_get(op->ptr, "bake"); baker->render = 0; baker->anim_init = 0; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index aa323dc53eb..70142b790c0 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -464,7 +464,7 @@ static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); int material = RNA_enum_get(op->ptr, "material"); float density; bool changed = false; @@ -537,7 +537,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = prop = RNA_def_enum( diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index 1e03d986e3e..50f0b53c037 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -37,6 +37,7 @@ void OBJECT_OT_material_slot_select(struct wmOperatorType *ot); void OBJECT_OT_material_slot_deselect(struct wmOperatorType *ot); void OBJECT_OT_material_slot_copy(struct wmOperatorType *ot); void OBJECT_OT_material_slot_move(struct wmOperatorType *ot); +void OBJECT_OT_material_slot_remove_unused(struct wmOperatorType *ot); void MATERIAL_OT_new(struct wmOperatorType *ot); void TEXTURE_OT_new(struct wmOperatorType *ot); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 9ac93f07300..acd7126e56a 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -368,7 +368,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) RE_SetReports(re, NULL); // no redraw needed, we leave state as we entered it - ED_update_for_newframe(mainp, CTX_data_depsgraph(C)); + ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C)); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); @@ -978,8 +978,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even rj->scene = scene; rj->current_scene = rj->scene; rj->single_layer = single_layer; - /* TODO(sergey): Render engine should be using own depsgraph. */ - rj->depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): Render engine should be using own depsgraph. + * + * NOTE: Currently is only used by ED_update_for_newframe() at the end of the render, so no + * need to ensure evaluation here. */ + rj->depsgraph = CTX_data_depsgraph_pointer(C); rj->camera_override = camera_override; rj->anim = is_animation; rj->write_still = is_write_still && !is_animation; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 72e6c6fdf03..f419d30a17e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -273,7 +273,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = oglrender->scene; ARegion *ar = oglrender->ar; View3D *v3d = oglrender->v3d; @@ -592,7 +592,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->scene = scene; oglrender->workspace = workspace; oglrender->view_layer = CTX_data_view_layer(C); - oglrender->depsgraph = CTX_data_depsgraph(C); + /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize + * output video handles, which does need evaluated scene. */ + oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); oglrender->cfrao = scene->r.cfra; oglrender->ofs_samples = samples; diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index b77f5c2bbad..8156f48343f 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -42,6 +42,7 @@ void ED_operatortypes_render(void) WM_operatortype_append(OBJECT_OT_material_slot_deselect); WM_operatortype_append(OBJECT_OT_material_slot_copy); WM_operatortype_append(OBJECT_OT_material_slot_move); + WM_operatortype_append(OBJECT_OT_material_slot_remove_unused); WM_operatortype_append(MATERIAL_OT_new); WM_operatortype_append(TEXTURE_OT_new); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index c646ef12846..9b380ad5db1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -290,7 +290,7 @@ static void set_preview_visibility(Scene *scene, char pr_type, int pr_method) { - /* Set appropriate layer as visibile. */ + /* Set appropriate layer as visible. */ LayerCollection *lc = view_layer->layer_collections.first; const char *collection_name = preview_collection_name(pr_type); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index f7a1d7187f1..01740c13c9d 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -310,7 +310,7 @@ static int material_slot_de_select(bContext *C, bool select) } else { /* Find the first matching material. - * Note: there may be multiple but thats not a common use case. */ + * Note: there may be multiple but that's not a common use case. */ for (short i = 0; i < ob->totcol; i++) { const Material *mat = give_current_material(ob, i + 1); if (mat_active == mat) { @@ -549,6 +549,73 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot) "Direction to move the active material towards"); } +static int material_slot_remove_unused_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + + if (!ob) { + return OPERATOR_CANCELLED; + } + + /* Removing material slots in edit mode screws things up, see bug #21822.*/ + if (ob == CTX_data_edit_object(C)) { + BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode"); + return OPERATOR_CANCELLED; + } + + int actcol = ob->actcol; + + int removed = 0; + for (int slot = 1; slot <= ob->totcol; slot++) { + while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) { + ob->actcol = slot; + BKE_object_material_slot_remove(CTX_data_main(C), ob); + + if (actcol >= slot) { + actcol--; + } + + removed++; + } + } + + ob->actcol = actcol; + + if (!removed) { + return OPERATOR_CANCELLED; + } + + BKE_reportf(op->reports, RPT_INFO, "Removed %d slots", removed); + + if (ob->mode & OB_MODE_TEXTURE_PAINT) { + Scene *scene = CTX_data_scene(C); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + } + + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Unused Slots"; + ot->idname = "OBJECT_OT_material_slot_remove_unused"; + ot->description = "Remove unused material slots"; + + /* api callbacks */ + ot->exec = material_slot_remove_unused_exec; + ot->poll = ED_operator_object_active_editable; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /********************** new material operator *********************/ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) @@ -859,7 +926,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op) EEVEE_lightbake_job_data_free(rj); // no redraw needed, we leave state as we entered it - ED_update_for_newframe(bmain, CTX_data_depsgraph(C)); + ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C)); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 64869b71746..82e4d577777 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -135,7 +135,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update /* NOTE: Important to pass non-updated depsgraph, This is because this function is called * from inside dependency graph evaluation. Additionally, if we pass fully evaluated one * we will loose updates stored in the graph. */ - engine->type->view_update(engine, C, CTX_data_depsgraph(C)); + engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C)); } else { RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e5bbeafd89d..5099c370a85 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2696,7 +2696,7 @@ void ED_region_header_init(ARegion *ar) int ED_area_headersize(void) { - /* Accomodate widget and padding. */ + /* Accommodate widget and padding. */ return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c9a45728bc2..eccd85ab276 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1059,7 +1059,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) is_gesture = (delta_max > split_threshold); } else { - /* Different area, so posible join. */ + /* Different area, so possible join. */ if (sad->gesture_dir == 'n') { WM_cursor_set(win, BC_N_ARROWCURSOR); } @@ -4465,7 +4465,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) { bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); - Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_depsgraph(C)); + Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_ensure_evaluated_depsgraph(C)); if (ED_screen_animation_playing(CTX_wm_manager(C))) { /* stop playback now */ diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index d7e1b47d973..5852012891d 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -339,7 +339,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = ob->data; PartialVisAction action; PartialVisArea area; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a0f578c04d0..f3a6cfa0d5c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1238,7 +1238,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->poll = texture_paint_toggle_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index f768a66a41c..e5527e7210d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1771,7 +1771,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, } else if (angle_cos < ps->normal_angle_inner__cos) { mask *= (ps->normal_angle - acosf(angle_cos)) / ps->normal_angle_range; - } /* otherwise no mask normal is needed, were within the limit */ + } /* otherwise no mask normal is needed, we're within the limit */ } /* This only works when the opacity doesn't change while painting, stylus pressure messes with @@ -3159,7 +3159,7 @@ static void project_paint_face_init(const ProjPaintState *ps, //#endif } -#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +#if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -3215,7 +3215,7 @@ static void project_paint_face_init(const ProjPaintState *ps, * clipped by the bucket's screen aligned rectangle. */ float bucket_clip_edges[2][2]; float edge_verts_inset_clip[2][3]; - /* face edge pairs - loop throuh these: + /* face edge pairs - loop through these: * ((0,1), (1,2), (2,3), (3,0)) or ((0,1), (1,2), (2,0)) for a tri */ int fidx1, fidx2; @@ -3395,12 +3395,12 @@ static void project_paint_face_init(const ProjPaintState *ps, } else if (has_x_isect) { /* assuming the face is not a bow-tie - we know - * we cant intersect again on the X */ + * we can't intersect again on the X */ break; } } -# if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +# if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -4012,7 +4012,7 @@ static void project_paint_bleed_add_face_user(const ProjPaintState *ps, /* Return true if evaluated mesh can be painted on, false otherwise */ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ps->ob; Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -4388,7 +4388,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, image_index = BLI_linklist_index(image_LinkList.list, tpage); if (image_index == -1 && BKE_image_has_ibuf(tpage, NULL)) { - /* MemArena dosnt have an append func */ + /* MemArena doesn't have an append func */ BLI_linklist_append(&image_LinkList, tpage); image_index = ps->image_tot; ps->image_tot++; @@ -5710,7 +5710,7 @@ void paint_proj_stroke(const bContext *C, /* clone gets special treatment here to avoid going through image initialization */ if (ps_handle->is_clone_cursor_pick) { Scene *scene = ps_handle->scene; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); float *cursor = scene->cursor.location; @@ -5779,7 +5779,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->rv3d = CTX_wm_region_view3d(C); ps->ar = CTX_wm_region(C); - ps->depsgraph = CTX_data_depsgraph(C); + ps->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ps->scene = scene; /* allow override of active object */ ps->ob = ob; @@ -6143,7 +6143,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) char filename[FILE_MAX]; Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; int w = settings->imapaint.screen_grab_size[0]; @@ -6234,8 +6234,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) array += sizeof(rv3d->winmat) / sizeof(float); memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat) / sizeof(float); - is_ortho = ED_view3d_clip_range_get( - CTX_data_depsgraph(C), v3d, rv3d, &array[0], &array[1], true); + is_ortho = ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &array[0], &array[1], true); /* using float for a bool is dodgy but since its an extra member in the array... * easier then adding a single bool prop */ array[2] = is_ortho ? 1.0f : 0.0f; diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index c7e2b008d1f..74212058fc7 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -130,7 +130,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PaintMaskFloodMode mode; float value; PBVH *pbvh; @@ -277,7 +277,7 @@ static void mask_box_select_task_cb(void *__restrict userdata, bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; float clip_planes[4][4]; @@ -444,7 +444,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) const int(*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float clip_planes[4][4], clip_planes_final[4][4]; BoundBox bb; Object *ob; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 12891484e73..f073877ebcf 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1329,7 +1329,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) redraw = true; } - /* do updates for redraw. if event is inbetween mousemove there are more + /* do updates for redraw. if event is in between mouse-move there are more * coming, so postpone potentially slow redraw updates until all are done */ if (event->type != INBETWEEN_MOUSEMOVE) { wmWindow *window = CTX_wm_window(C); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index c8ad1b5781d..0f37968f599 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -463,7 +463,7 @@ void paint_sample_color( bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Paint *paint = BKE_paint_get_active_from_context(C); Palette *palette = BKE_paint_palette(paint); PaletteColor *color = NULL; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 47fa2872ff9..9215a90c446 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1171,30 +1171,11 @@ void ED_object_vpaintmode_enter_ex( { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT); } -void ED_object_vpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} - void ED_object_wpaintmode_enter_ex( Main *bmain, Depsgraph *depsgraph, wmWindowManager *wm, Scene *scene, Object *ob) { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT); } -void ED_object_wpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} /** \} */ @@ -1396,7 +1377,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -1556,7 +1537,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo bool *defbase_sel; SculptSession *ss = ob->sculpt; VPaint *vp = CTX_data_tool_settings(C)->wpaint; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) { return false; @@ -2569,7 +2550,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -2638,7 +2619,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f Object *ob = CTX_data_active_object(C); Mesh *me; SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* context checks could be a poll() */ me = BKE_mesh_from_object(ob); @@ -2705,8 +2686,9 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f return 1; } -static void do_vpaint_brush_calc_average_color_cb_ex( - void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) +static void do_vpaint_brush_calc_average_color_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index b6a6c897606..1dc28328244 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -119,7 +119,7 @@ static bool weight_from_bones_poll(bContext *C) static int weight_from_bones_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Object *armob = modifiers_isDeformedByArmature(ob); @@ -161,7 +161,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) ot->poll = weight_from_bones_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum( @@ -746,7 +746,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); WPGradient_userData data = {NULL}; @@ -880,7 +880,7 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot) ot->cancel = WM_gesture_straightline_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 4b35fdbd2ed..c8709d40f96 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1262,7 +1262,6 @@ float tex_strength(SculptSession *ss, /* Falloff curve */ avg *= BKE_brush_curve_strength(br, len, cache->radius); - avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ @@ -4923,7 +4922,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B SculptSession *ss = ob->sculpt; if (ss->kb || ss->modifiers_active) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); } @@ -5136,7 +5135,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -5184,7 +5183,7 @@ void sculpt_update_object_bounding_box(Object *ob) static void sculpt_flush_update_step(bContext *C) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); @@ -5753,7 +5752,7 @@ static void sculpt_dynamic_topology_disable_ex( void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); @@ -5790,7 +5789,7 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -6153,16 +6152,6 @@ void ED_object_sculptmode_enter_ex(Main *bmain, DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports) -{ - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, reports); -} - void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) { const int mode_flag = OB_MODE_SCULPT; @@ -6209,16 +6198,6 @@ void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scen DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_exit(bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - ED_object_sculptmode_exit_ex(bmain, depsgraph, scene, ob); -} - static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); @@ -6265,7 +6244,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->exec = sculpt_mode_toggle_exec; ot->poll = ED_operator_object_active_editable_mesh; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index e9d17b11ccc..dde1e51e764 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -127,11 +127,10 @@ static bool sculpt_undo_restore_deformed( } } -static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, SculptUndoNode *unode) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; MVert *mvert; @@ -455,13 +454,12 @@ static int sculpt_undo_bmesh_restore(bContext *C, return false; } -static void sculpt_undo_restore_list(bContext *C, ListBase *lb) +static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase *lb) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; SculptUndoNode *unode; @@ -512,7 +510,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) switch (unode->type) { case SCULPT_UNDO_COORDS: - if (sculpt_undo_restore_coords(C, unode)) { + if (sculpt_undo_restore_coords(C, depsgraph, unode)) { update = true; } break; @@ -1062,21 +1060,27 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), return true; } -static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == true); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = false; } -static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == false); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = true; } -static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -1086,12 +1090,14 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.next; } while (us_iter != us) { - sculpt_undosys_step_decode_undo_impl(C, us_iter); + sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter); us_iter = (SculptUndoStep *)us_iter->step.prev; } } -static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.prev && (us_iter->step.prev->type == us_iter->step.type)) { @@ -1101,7 +1107,7 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.prev; } while (us_iter && (us_iter->step.is_applied == false)) { - sculpt_undosys_step_decode_redo_impl(C, us_iter); + sculpt_undosys_step_decode_redo_impl(C, depsgraph, us_iter); if (us_iter == us) { break; } @@ -1112,6 +1118,8 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * static void sculpt_undosys_step_decode( struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final)) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + /* Ensure sculpt mode. */ { Scene *scene = CTX_data_scene(C); @@ -1120,7 +1128,6 @@ static void sculpt_undosys_step_decode( BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); Object *ob = OBACT(view_layer); if (ob && (ob->type == OB_MESH)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); if (ob->mode & OB_MODE_SCULPT) { /* pass */ } @@ -1142,10 +1149,10 @@ static void sculpt_undosys_step_decode( SculptUndoStep *us = (SculptUndoStep *)us_p; if (dir < 0) { - sculpt_undosys_step_decode_undo(C, us); + sculpt_undosys_step_decode_undo(C, depsgraph, us); } else { - sculpt_undosys_step_decode_redo(C, us); + sculpt_undosys_step_decode_redo(C, depsgraph, us); } } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 0241a2fbe88..10d38055085 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -305,7 +305,9 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: We will be forefully evaluating dependency graph at every frame, so no need to ensure + * current scene state is evaluated as it will be lost anyway. */ + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); int oldfra = scene->r.cfra; int cfra; @@ -343,7 +345,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) #ifdef WITH_AUDASPACE char path[FILE_MAX]; char filename[FILE_MAX]; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Main *bmain = CTX_data_main(C); int split; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 7fc84db3f75..944a0c74f4c 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -704,7 +704,6 @@ static void insert_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - struct Depsgraph *depsgraph = ac->depsgraph; ReportList *reports = ac->reports; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; @@ -741,7 +740,6 @@ static void insert_action_keys(bAnimContext *ac, short mode) */ if (ale->id && !ale->owner) { insert_keyframe(ac->bmain, - depsgraph, reports, ale->id, NULL, diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index e1af9728685..5f04d0863a7 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -626,36 +626,35 @@ static void view_zoom_apply( bContext *C, ViewZoomData *vpd, wmOperator *op, const wmEvent *event, const bool zoom_to_pos) { float factor; + float delta; - if (U.viewzoom == USER_ZOOM_CONT) { - SpaceClip *sclip = CTX_wm_space_clip(C); - double time = PIL_check_seconds_timer(); - float time_step = (float)(time - vpd->timer_lastdraw); - float fac; - float zfac; - + if (U.viewzoom != USER_ZOOM_SCALE) { if (U.uiflag & USER_ZOOM_HORIZ) { - fac = (float)(event->x - vpd->x); + delta = (float)(event->x - vpd->x); } else { - fac = (float)(event->y - vpd->y); + delta = (float)(event->y - vpd->y); } + } + else { + delta = event->x - vpd->x + event->y - vpd->y; + } - if (U.uiflag & USER_ZOOM_INVERT) { - fac = -fac; - } + if (U.uiflag & USER_ZOOM_INVERT) { + delta = -delta; + } - zfac = 1.0f + ((fac / 20.0f) * time_step); + if (U.viewzoom == USER_ZOOM_CONT) { + SpaceClip *sclip = CTX_wm_space_clip(C); + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float zfac; + + zfac = 1.0f + ((delta / 20.0f) * time_step); vpd->timer_lastdraw = time; factor = (sclip->zoom * zfac) / vpd->zoom; } else { - float delta = event->x - vpd->x + event->y - vpd->y; - - if (U.uiflag & USER_ZOOM_INVERT) { - delta *= -1; - } - factor = 1.0f + delta / 300.0f; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 7e19ac255f0..c1cb975447f 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -556,17 +556,17 @@ static void clip_operatortypes(void) static void clip_keymap(struct wmKeyConfig *keyconf) { - /* ******** Global hotkeys avalaible for all regions ******** */ + /* ******** Global hotkeys available for all regions ******** */ WM_keymap_ensure(keyconf, "Clip", SPACE_CLIP, 0); - /* ******** Hotkeys avalaible for main region only ******** */ + /* ******** Hotkeys available for main region only ******** */ WM_keymap_ensure(keyconf, "Clip Editor", SPACE_CLIP, 0); // keymap->poll = ED_space_clip_tracking_poll; - /* ******** Hotkeys avalaible for preview region only ******** */ + /* ******** Hotkeys available for preview region only ******** */ WM_keymap_ensure(keyconf, "Clip Graph Editor", SPACE_CLIP, 0); - /* ******** Hotkeys avalaible for channels region only ******** */ + /* ******** Hotkeys available for channels region only ******** */ WM_keymap_ensure(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); } @@ -947,7 +947,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); int mask_width, mask_height; ED_mask_get_size(sa, &mask_width, &mask_height); - ED_mask_draw_region(CTX_data_depsgraph(C), + ED_mask_draw_region(CTX_data_expect_evaluated_depsgraph(C), mask, ar, sc->mask_info.draw_flag, @@ -1224,7 +1224,7 @@ static void clip_header_region_listener(wmWindow *UNUSED(win), switch (wmn->data) { /* for proportional editmode only */ case ND_TOOLSETTINGS: - /* TODO - should do this when in mask mode only but no datas available */ + /* TODO - should do this when in mask mode only but no data available */ // if (sc->mode == SC_MODE_MASKEDIT) { ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c index 61991993b10..de0025a53d2 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.c +++ b/source/blender/editors/space_clip/tracking_ops_orient.c @@ -39,6 +39,7 @@ #include "BKE_report.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "WM_api.h" #include "WM_types.h" @@ -395,7 +396,6 @@ static int set_plane_exec(bContext *C, wmOperator *op) ListBase *tracksbase; Object *object; Object *camera = get_camera_with_movieclip(scene, clip); - Depsgraph *depsgraph = CTX_data_depsgraph(C); int tot = 0; float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f}; int plane = RNA_enum_get(op->ptr, "plane"); @@ -484,7 +484,13 @@ static int set_plane_exec(bContext *C, wmOperator *op) BKE_object_apply_mat4(object, mat, 0, 0); } - BKE_object_where_is_calc(depsgraph, scene, object); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, object); + BKE_object_transform_copy(object_eval, object); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); + BKE_object_transform_copy(object, object_eval); + set_axis(scene, object, clip, tracking_object, axis_track, 'X'); DEG_id_tag_update(&clip->id, 0); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 9bdea13276b..3a6d59c1dbf 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -536,7 +536,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) WM_report_banner_show(); } else { - /* If rename is sucessfull, scroll to newly renamed entry. */ + /* If rename is successful, scroll to newly renamed entry. */ BLI_strncpy(sfile->params->renamefile, filename, sizeof(sfile->params->renamefile)); sfile->params->rename_flag = FILE_PARAMS_RENAME_POSTSCROLL_PENDING; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4e50413513a..eb5f02b6e13 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1757,7 +1757,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w (middle_offset - min_middle_offset < items_block_size)); /* OR edited item must be towards the end, and we are scrolled fully to the end. * This one is crucial (unlike the one for the beginning), because without it we won't scroll - * fully to the end, and last column or row wil end up only partially drawn. */ + * fully to the end, and last column or row will end up only partially drawn. */ const bool is_full_end = ((sfile->scroll_offset > max_middle_offset) && (max_tot_scroll - max_curr_scroll < 1.0f) && (max_middle_offset - middle_offset < items_block_size)); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index faaecd975a3..db42d007b8e 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -28,7 +28,7 @@ #include <sys/stat.h> #include <sys/types.h> -/* path/file handeling stuff */ +/* path/file handling stuff */ #ifdef WIN32 # include <io.h> # include <direct.h> diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index b16374e0d66..e7ba498fc11 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -721,7 +721,7 @@ static void draw_fcurve_curve_bezts( v1[1] = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { - /* extrapolate linear dosnt use the handle, use the next points center instead */ + /* extrapolate linear doesn't use the handle, use the next points center instead */ fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) { fac = 1.0f / fac; @@ -840,7 +840,7 @@ static void draw_fcurve_curve_bezts( v1[1] = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { - /* extrapolate linear dosnt use the handle, use the previous points center instead */ + /* extrapolate linear doesn't use the handle, use the previous points center instead */ bezt = prevbezt - 1; fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) { diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dc5837e3fd1..b624e21937f 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -604,7 +604,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) ReportList *reports = ac->reports; SpaceGraph *sipo = (SpaceGraph *)ac->sl; - struct Depsgraph *depsgraph = ac->depsgraph; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; short flag = 0; @@ -696,7 +695,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) */ if (ale->id && !ale->owner && !fcu->driver) { insert_keyframe(ac->bmain, - depsgraph, reports, ale->id, NULL, diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b79ed1c83c4..374a58d1808 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -556,39 +556,36 @@ static void image_zoom_apply(ViewZoomData *vpd, const bool zoom_to_pos) { float factor; + float delta; - if (viewzoom == USER_ZOOM_CONT) { - double time = PIL_check_seconds_timer(); - float time_step = (float)(time - vpd->timer_lastdraw); - float fac; - float zfac; - + if (viewzoom != USER_ZOOM_SCALE) { if (U.uiflag & USER_ZOOM_HORIZ) { - fac = (float)(x - vpd->origx); + delta = (float)(x - vpd->origx); } else { - fac = (float)(y - vpd->origy); + delta = (float)(y - vpd->origy); } + } + else { + delta = x - vpd->origx + y - vpd->origy; + } - if (zoom_invert) { - fac = -fac; - } + if (zoom_invert) { + delta = -delta; + } + + if (viewzoom == USER_ZOOM_CONT) { + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float zfac; /* oldstyle zoom */ - zfac = 1.0f + ((fac / 20.0f) * time_step); + zfac = 1.0f + ((delta / 20.0f) * time_step); vpd->timer_lastdraw = time; /* this is the final zoom, but instead make it into a factor */ - // zoom = vpd->sima->zoom * zfac; factor = (vpd->sima->zoom * zfac) / vpd->zoom; } else { - /* for now do the same things for scale and dolly */ - float delta = x - vpd->origx + y - vpd->origy; - - if (zoom_invert) { - delta *= -1.0f; - } - factor = 1.0f + delta / 300.0f; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index e8116193c1f..7ff075bf819 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -576,7 +576,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) SpaceImage *sima = CTX_wm_space_image(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); Mask *mask = NULL; bool show_uvedit = false; bool show_curve = false; diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 1c9a7d3584c..946274de882 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -158,7 +158,7 @@ static void stats_object(Object *ob, SceneStats *stats, GSet *objects_gset) if (stats_mesheval(me_eval, is_selected, stats)) { break; } - ATTR_FALLTHROUGH; /* Falltrough to displist. */ + ATTR_FALLTHROUGH; /* Fallthrough to displist. */ } case OB_MBALL: { int totv = 0, totf = 0, tottri = 0; diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 0836617ab44..11933ef0811 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -143,7 +143,6 @@ void ED_operatormacros_node(void) "Move nodes and attach to frame", OPTYPE_UNDO | OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); @@ -153,7 +152,6 @@ void ED_operatormacros_node(void) "Move nodes and attach to frame", OPTYPE_UNDO | OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); RNA_boolean_set(mot->ptr, "remove_on_cancel", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); @@ -168,7 +166,6 @@ void ED_operatormacros_node(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_detach"); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index bee615108f9..c932766ab93 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -113,7 +113,7 @@ static void do_outliner_activate_obdata( bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = OBACT(view_layer); Object *ob = base->object; bool use_all = false; @@ -161,7 +161,7 @@ static void do_outliner_activate_pose( bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = OBACT(view_layer); Object *ob = base->object; bool use_all = false; @@ -341,7 +341,7 @@ static eOLDrawState tree_element_set_active_object(bContext *C, if (base && !BKE_object_is_mode_compat(base->object, object_mode)) { if (object_mode == OB_MODE_OBJECT) { struct Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object); } if (!BKE_object_is_mode_compat(base->object, object_mode)) { diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index a6458ee5d31..6740c2baad2 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -76,7 +76,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel) return; } struct Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); struct Scene *scene = CTX_data_scene(C); SpaceSeq *space_sequencer = CTX_wm_space_seq(C); /* NOTE: We can only reliably show metadata for the original (current) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 76c198b3d6b..ea815bd5456 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1546,7 +1546,7 @@ void sequencer_draw_preview(const bContext *C, bool draw_backdrop) { struct Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); struct View2D *v2d = &ar->v2d; struct ImBuf *ibuf = NULL; struct ImBuf *scope = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index ff0ab9285db..2cdadfbd2ab 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -181,7 +181,7 @@ static void seq_proxy_build_job(const bContext *C) { wmJob *wm_job; ProxyJob *pj; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); ScrArea *sa = CTX_wm_area(C); @@ -1135,6 +1135,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); return OPERATOR_FINISHED; } @@ -2886,7 +2887,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) imgwidth = (scene->r.size * scene->r.xsch) / 100; imgheight = (scene->r.size * scene->r.ysch) / 100; - /* Apply aspect, dosnt need to be that accurate */ + /* Apply aspect, doesn't need to be that accurate */ imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp)); if (((imgwidth >= width) || (imgheight >= height)) && ((width > 0) && (height > 0))) { @@ -3612,7 +3613,7 @@ static int sequencer_rebuild_proxy_invoke(bContext *C, static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 593dd86477a..534d02c7bf3 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -92,7 +92,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) { Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); ARegion *ar = CTX_wm_region(C); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 24f282ff920..7d8424a5996 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -199,6 +199,7 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_convert_whitespace); WM_operatortype_append(TEXT_OT_uncomment); WM_operatortype_append(TEXT_OT_comment); + WM_operatortype_append(TEXT_OT_toggle_comment); WM_operatortype_append(TEXT_OT_unindent); WM_operatortype_append(TEXT_OT_indent); @@ -254,7 +255,9 @@ static int text_context(const bContext *C, const char *member, bContextDataResul return 1; } else if (CTX_data_equals(member, "edit_text")) { - CTX_data_id_pointer_set(result, &st->text->id); + if (st->text != NULL) { + CTX_data_id_pointer_set(result, &st->text->id); + } return 1; } diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index aab5069f919..400405155f8 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -121,6 +121,7 @@ void TEXT_OT_duplicate_line(struct wmOperatorType *ot); void TEXT_OT_convert_whitespace(struct wmOperatorType *ot); void TEXT_OT_uncomment(struct wmOperatorType *ot); void TEXT_OT_comment(struct wmOperatorType *ot); +void TEXT_OT_toggle_comment(struct wmOperatorType *ot); void TEXT_OT_unindent(struct wmOperatorType *ot); void TEXT_OT_indent(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 8f7bd83cbf4..95e7d906b11 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -61,7 +61,9 @@ static void txt_screen_clamp(SpaceText *st, ARegion *ar); -/************************ util ***************************/ +/* -------------------------------------------------------------------- */ +/** \name Util + * \{ */ /** * Tests if the given character represents a start of a new line or the @@ -138,14 +140,18 @@ static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size) return out_buf; } -/************************ poll ***************************/ - BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x) { /* add half the char width so mouse cursor selection is inbetween letters */ return (x + (st->cwidth / 2)) / st->cwidth; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Operator Poll + * \{ */ + static bool text_new_poll(bContext *UNUSED(C)) { return 1; @@ -206,7 +212,11 @@ static bool text_region_edit_poll(bContext *C) return 1; } -/********************** updates *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Updates + * \{ */ void text_update_line_edited(TextLine *line) { @@ -230,7 +240,11 @@ void text_update_edited(Text *text) } } -/******************* new operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name New Operator + * \{ */ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -281,7 +295,11 @@ void TEXT_OT_new(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* open operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Open Operator + * \{ */ static void text_open_init(bContext *C, wmOperator *op) { @@ -392,7 +410,11 @@ void TEXT_OT_open(wmOperatorType *ot) ot->srna, "internal", 0, "Make internal", "Make text file internal after loading"); } -/******************* reload operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Reload Operator + * \{ */ static int text_reload_exec(bContext *C, wmOperator *op) { @@ -443,7 +465,11 @@ void TEXT_OT_reload(wmOperatorType *ot) ot->poll = text_edit_poll; } -/******************* delete operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Operator + * \{ */ static bool text_unlink_poll(bContext *C) { @@ -495,7 +521,11 @@ void TEXT_OT_unlink(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* make internal operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Make Internal Operator + * \{ */ static int text_make_internal_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -529,7 +559,11 @@ void TEXT_OT_make_internal(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* save operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Save Operator + * \{ */ static bool text_save_poll(bContext *C) { @@ -614,7 +648,11 @@ void TEXT_OT_save(wmOperatorType *ot) ot->poll = text_save_poll; } -/******************* save as operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Save As Operator + * \{ */ static int text_save_as_exec(bContext *C, wmOperator *op) { @@ -690,7 +728,11 @@ void TEXT_OT_save_as(wmOperatorType *ot) FILE_SORT_ALPHA); // XXX TODO, relative_path } -/******************* run script operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Run Script Operator + * \{ */ static bool text_run_script_poll(bContext *C) { @@ -765,7 +807,11 @@ void TEXT_OT_run_script(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/******************* refresh pyconstraints operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Refresh Pyconstraints Operator + * \{ */ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { @@ -825,7 +871,11 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot) ot->poll = text_edit_poll; } -/******************* paste operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Paste Operator + * \{ */ static int text_paste_exec(bContext *C, wmOperator *op) { @@ -889,7 +939,11 @@ void TEXT_OT_paste(wmOperatorType *ot) "Paste text selected elsewhere rather than copied (X11 only)"); } -/**************** duplicate operator *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Duplicate Operator + * \{ */ static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -924,7 +978,11 @@ void TEXT_OT_duplicate_line(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* copy operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Copy Operator + * \{ */ static void txt_copy_clipboard(Text *text) { @@ -963,7 +1021,11 @@ void TEXT_OT_copy(wmOperatorType *ot) ot->poll = text_edit_poll; } -/******************* cut operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Cut Operator + * \{ */ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1002,7 +1064,11 @@ void TEXT_OT_cut(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* indent operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Indent Operator + * \{ */ static int text_indent_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1043,7 +1109,11 @@ void TEXT_OT_indent(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* unindent operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Unindent Operator + * \{ */ static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1079,7 +1149,11 @@ void TEXT_OT_unindent(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* line break operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Line Break Operator + * \{ */ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1132,7 +1206,11 @@ void TEXT_OT_line_break(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* comment operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Comment Operator + * \{ */ static int text_comment_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1170,7 +1248,11 @@ void TEXT_OT_comment(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* uncomment operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Uncomment Operator + * \{ */ static int text_uncomment_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1209,7 +1291,55 @@ void TEXT_OT_uncomment(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* convert whitespace operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Toggle-Comment Operator + * \{ */ + +static int text_toggle_comment_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Text *text = CTX_data_edit_text(C); + + if (txt_has_sel(text)) { + text_drawcache_tag_update(CTX_wm_space_text(C), 0); + + ED_text_undo_push_init(C); + + txt_order_cursors(text, false); + if (txt_uncomment(text) == false) { + txt_comment(text); + } + text_update_edited(text); + + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + + return OPERATOR_FINISHED; + } + + return OPERATOR_CANCELLED; +} + +void TEXT_OT_toggle_comment(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Toggle Comment"; + ot->idname = "TEXT_OT_toggle_comment"; + + /* api callbacks */ + ot->exec = text_toggle_comment_exec; + ot->poll = text_edit_poll; + + /* flags */ + ot->flag = OPTYPE_UNDO; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Convert Whitespace Operator + * \{ */ enum { TO_SPACES, TO_TABS }; static const EnumPropertyItem whitespace_type_items[] = { @@ -1360,7 +1490,11 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot) "Type of whitespace to convert to"); } -/******************* select all operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select All Operator + * \{ */ static int text_select_all_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1386,7 +1520,11 @@ void TEXT_OT_select_all(wmOperatorType *ot) ot->poll = text_edit_poll; } -/******************* select line operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Line Operator + * \{ */ static int text_select_line_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1412,7 +1550,11 @@ void TEXT_OT_select_line(wmOperatorType *ot) ot->poll = text_edit_poll; } -/******************* select word operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Word Operator + * \{ */ static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1441,7 +1583,11 @@ void TEXT_OT_select_word(wmOperatorType *ot) ot->poll = text_edit_poll; } -/********************* move lines operators ***********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Move Lines Operators + * \{ */ static int move_lines_exec(bContext *C, wmOperator *op) { @@ -1487,7 +1633,11 @@ void TEXT_OT_move_lines(wmOperatorType *ot) RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", ""); } -/************************ move operator ************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Move Operator + * \{ */ static const EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, @@ -2126,7 +2276,11 @@ void TEXT_OT_move(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to"); } -/******************* move select operator ********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Move Select Operator + * \{ */ static int text_move_select_exec(bContext *C, wmOperator *op) { @@ -2155,7 +2309,11 @@ void TEXT_OT_move_select(wmOperatorType *ot) "Where to move cursor to, to make a selection"); } -/******************* jump operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Jump Operator + * \{ */ static int text_jump_exec(bContext *C, wmOperator *op) { @@ -2203,7 +2361,11 @@ void TEXT_OT_jump(wmOperatorType *ot) RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT); } -/******************* delete operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Operator + * \{ */ static const EnumPropertyItem delete_type_items[] = { {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, @@ -2317,7 +2479,11 @@ void TEXT_OT_delete(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -/******************* toggle overwrite operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Toggle Overwrite Operator + * \{ */ static int text_toggle_overwrite_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -2342,7 +2508,11 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot) ot->poll = text_space_edit_poll; } -/******************* scroll operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Scroll Operator + * \{ */ static void txt_screen_clamp(SpaceText *st, ARegion *ar) { @@ -2571,7 +2741,11 @@ void TEXT_OT_scroll(wmOperatorType *ot) ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100); } -/******************** scroll bar operator *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Scroll Bar Operator + * \{ */ static bool text_region_scroll_poll(bContext *C) { @@ -3073,7 +3247,11 @@ void TEXT_OT_selection_set(wmOperatorType *ot) RNA_def_boolean(ot->srna, "select", 0, "Select", "Set selection end rather than cursor"); } -/******************* set cursor operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Cursor Operator + * \{ */ static int text_cursor_set_exec(bContext *C, wmOperator *op) { @@ -3121,7 +3299,11 @@ void TEXT_OT_cursor_set(wmOperatorType *ot) RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); } -/******************* line number operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Line Number Operator + * \{ */ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { @@ -3177,7 +3359,11 @@ void TEXT_OT_line_number(wmOperatorType *ot) ot->poll = text_region_edit_poll; } -/******************* insert operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Insert Operator + * \{ */ static int text_insert_exec(bContext *C, wmOperator *op) { @@ -3284,7 +3470,11 @@ void TEXT_OT_insert(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/******************* find operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Find Operator + * \{ */ /* mode */ #define TEXT_FIND 0 @@ -3378,7 +3568,11 @@ void TEXT_OT_find(wmOperatorType *ot) ot->poll = text_space_edit_poll; } -/******************* replace operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Replace Operator + * \{ */ static int text_replace_exec(bContext *C, wmOperator *op) { @@ -3400,7 +3594,11 @@ void TEXT_OT_replace(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/******************* find set selected *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Find Set Selected + * \{ */ static int text_find_set_selected_exec(bContext *C, wmOperator *op) { @@ -3431,7 +3629,11 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot) ot->poll = text_space_edit_poll; } -/******************* replace set selected *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Replace Set Selected + * \{ */ static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -3461,7 +3663,11 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -/****************** resolve conflict operator ******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Resolve Conflict Operator + * \{ */ enum { RESOLVE_IGNORE, RESOLVE_RELOAD, RESOLVE_SAVE, RESOLVE_MAKE_INTERNAL }; static const EnumPropertyItem resolution_items[] = { @@ -3574,7 +3780,11 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot) "How to solve conflict due to differences in internal and external text"); } -/********************** to 3d object operator *****************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name To 3D Object Operator + * \{ */ static int text_to_3d_object_exec(bContext *C, wmOperator *op) { @@ -3604,3 +3814,5 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) RNA_def_boolean( ot->srna, "split_lines", 0, "Split Lines", "Create one object per line in the text"); } + +/** \} */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 57b98ffeda3..d1ea01146bc 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1140,7 +1140,7 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win), } /* From topbar, which ones are needed? split per header? */ - /* Disable for now, re-enable if neede, or remove - campbell. */ + /* Disable for now, re-enable if needed, or remove - campbell. */ #if 0 /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 84012ee26cc..5b1138fc7f1 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1082,7 +1082,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) static void view3d_draw_border(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); @@ -1453,7 +1453,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar) static void view3d_draw_view(const bContext *C, ARegion *ar) { ED_view3d_draw_setup_view(CTX_wm_window(C), - CTX_data_depsgraph(C), + CTX_data_expect_evaluated_depsgraph(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index fd0d9c6891f..826eddc63d1 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -219,7 +219,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op) /* store data */ op->customdata = vod; vod->bmain = CTX_data_main(C); - vod->depsgraph = CTX_data_depsgraph(C); + vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vod->scene = CTX_data_scene(C); vod->sa = CTX_wm_area(C); vod->ar = CTX_wm_region(C); @@ -249,7 +249,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) static float lastofs[3] = {0, 0, 0}; bool is_set = false; - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); View3D *v3d = CTX_wm_view3d(C); @@ -373,7 +373,7 @@ static void viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod = op->customdata; RegionView3D *rv3d = vod->rv3d; @@ -1317,7 +1317,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod; View3D *v3d; RegionView3D *rv3d; @@ -1397,7 +1397,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod; View3D *v3d; RegionView3D *rv3d; @@ -1511,7 +1511,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); const wmNDOFMotionData *ndof = event->customdata; @@ -2188,7 +2188,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) static int viewzoom_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; RegionView3D *rv3d; @@ -2553,7 +2553,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) ED_view3d_depth_tag_update(rv3d); - ED_view3d_camera_lock_sync(CTX_data_depsgraph(C), v3d, rv3d); + ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d); ED_region_tag_redraw(ar); @@ -2588,7 +2588,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (vod->rv3d->persp != RV3D_PERSP) { if (vod->rv3d->persp == RV3D_CAMOB) { /* ignore rv3d->lpersp because dolly only makes sense in perspective mode */ - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP); } else { @@ -2749,8 +2749,9 @@ static void view3d_from_minmax(bContext *C, } if (ok_dist) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); new_dist = ED_view3d_radius_to_dist( - v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN); + v3d, ar, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN); if (rv3d->is_persp) { /* don't zoom closer than the near clipping plane */ new_dist = max_ff(new_dist, v3d->clip_start * 1.5f); @@ -2817,7 +2818,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Base *base_eval; const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); @@ -2922,7 +2923,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *ob_eval = OBACT(view_layer_eval); Object *obedit = CTX_data_edit_object(C); @@ -3120,7 +3121,8 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) if (obact && obact->type == OB_ARMATURE) { if (obact->mode & OB_MODE_POSE) { - Object *obact_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), obact); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact); bPoseChannel *pcham_act = BKE_pose_channel_active(obact_eval); if (pcham_act) { BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); @@ -3216,7 +3218,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev ARegion *ar = CTX_wm_region(C); if (rv3d) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float new_ofs[3]; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); @@ -3262,7 +3264,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); float xfac, yfac; float size[2]; @@ -3361,7 +3363,7 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ if (rv3d->persp == RV3D_CAMOB) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); } else { @@ -3530,7 +3532,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ED_view3d_dist_range_get(v3d, dist_range); /* Get Z Depths, needed for perspective, nice for ortho */ - ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true); + ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), ar, v3d, true); { /* avoid allocating the whole depth buffer */ @@ -3585,7 +3587,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) float mval_f[2]; float zfac; - /* We cant use the depth, fallback to the old way that dosnt set the center depth */ + /* We can't use the depth, fallback to the old way that doesn't set the center depth */ copy_v3_v3(new_ofs, rv3d->ofs); { @@ -3619,7 +3621,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* TODO(campbell): 'is_camera_lock' not currently working well. */ const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); } @@ -3686,7 +3688,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; @@ -3794,7 +3796,8 @@ static void axis_set_view(bContext *C, dist = rv3d->dist; /* so we animate _from_ the camera location */ - Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera); + Object *camera_eval = DEG_get_evaluated_object(CTX_data_ensure_evaluated_depsgraph(C), + v3d->camera); ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL); ED_view3d_smooth_view(C, @@ -4124,7 +4127,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) float quat_new[4]; if (view_opposite == RV3D_VIEW_USER) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_ensure(depsgraph, v3d, ar); } @@ -4874,7 +4877,7 @@ void ED_view3d_cursor3d_position(bContext *C, } if (use_depth) { /* maybe this should be accessed some other way */ - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); view3d_operator_needs_opengl(C); if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { @@ -4930,7 +4933,7 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, float ray_co[3]; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d); + bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, ar, v3d); float obmat[4][4]; Object *ob_dummy = NULL; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 3fa0c2c59b7..961ac4c26fb 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -270,7 +270,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->rv3d = CTX_wm_region_view3d(C); fly->v3d = CTX_wm_view3d(C); fly->ar = CTX_wm_region(C); - fly->depsgraph = CTX_data_depsgraph(C); + fly->depsgraph = CTX_data_expect_evaluated_depsgraph(C); fly->scene = CTX_data_scene(C); #ifdef NDOF_FLY_DEBUG @@ -337,12 +337,8 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->zlock = FLY_AXISLOCK_STATE_IDLE; } - fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(CTX_data_depsgraph(C), - fly->scene, - fly->v3d, - fly->rv3d, - (U.uiflag & USER_CAM_LOCK_NO_PARENT) == - 0); + fly->v3d_camera_control = ED_view3d_cameracontrol_acquire( + fly->depsgraph, fly->scene, fly->v3d, fly->rv3d, (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0); /* calculate center */ if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 002a7e12515..1bb10697936 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -437,7 +437,8 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Drawing code should happen with fully evaluated graph. */ + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); RegionView3D *rv3d = ar->regiondata; if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c index 64697a59019..a984e339305 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c @@ -176,7 +176,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int const float(*coords)[3] = NULL; { Object *ob = gz_ele->bases[gz_ele->base_index]->object; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data); if (me_eval->runtime.edit_data) { coords = me_eval->runtime.edit_data->vertexCos; @@ -334,7 +334,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const const float(*coords)[3] = NULL; { Object *ob = gz_ring->bases[gz_ring->base_index]->object; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data); if (me_eval->runtime.edit_data) { coords = me_eval->runtime.edit_data->vertexCos; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index e781e129540..97a12c7100e 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -289,7 +289,12 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) else if (state == RULER_STATE_DRAG) { memset(&ruler_info->drag_state_prev, 0x0, sizeof(ruler_info->drag_state_prev)); ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ruler_info->ar, CTX_wm_view3d(C)); + bmain, + CTX_data_scene(C), + CTX_data_ensure_evaluated_depsgraph(C), + 0, + ruler_info->ar, + CTX_wm_view3d(C)); } else { BLI_assert(0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 754c8359d28..36eb07e9a2f 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -126,7 +126,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc) vc->C = C; vc->ar = CTX_wm_region(C); vc->bmain = CTX_data_main(C); - vc->depsgraph = CTX_data_depsgraph(C); + vc->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vc->scene = CTX_data_scene(C); vc->view_layer = CTX_data_view_layer(C); vc->v3d = CTX_wm_view3d(C); @@ -3956,7 +3956,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) const int radius = RNA_int_get(op->ptr, "radius"); const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; - /* Allow each selection type to allocate their own data thats used between executions. */ + /* Allow each selection type to allocate their own data that's used between executions. */ wmGesture *gesture = op->customdata; /* NULL when non-modal. */ wmGenericUserData wm_userdata_buf = {0}; wmGenericUserData *wm_userdata = gesture ? &gesture->user_data : &wm_userdata_buf; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 0103fd0df53..9a2f4062631 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -66,7 +66,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r /** Snaps every individual object center to its nearest point on the grid. */ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); @@ -226,7 +226,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) ot->poll = ED_operator_region_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ @@ -243,7 +243,6 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global[3], const bool use_offset) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); @@ -431,6 +430,7 @@ static int snap_selected_to_location(bContext *C, float originmat[3][3], parentmat[4][4]; /* Use the evaluated object here because sometimes * `ob->parent->runtime.curve_cache` is required. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); BKE_object_get_parent_matrix(ob_eval, ob_eval->parent, parentmat); @@ -486,7 +486,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ RNA_def_boolean(ot->srna, @@ -523,7 +523,7 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ @@ -626,7 +626,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3]) /** Snaps the 3D cursor location to the median point of the selection. */ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); @@ -757,7 +757,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ @@ -804,7 +804,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************************************************** */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c0902cd1cd5..2515ee6e482 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -304,7 +304,7 @@ void ED_view3d_smooth_view(bContext *C, const int smooth_viewtx, const struct V3D_SmoothParams *sview) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); @@ -315,7 +315,6 @@ void ED_view3d_smooth_view(bContext *C, /* only meant for timer usage */ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; @@ -336,6 +335,8 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); } else { + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); @@ -372,6 +373,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); if (ED_screen_animation_playing(CTX_wm_manager(C))) { ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); @@ -428,7 +430,7 @@ void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *ar) /* force update of view matrix so tools that run immediately after * can use them without redrawing first */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false); } @@ -457,7 +459,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d; ARegion *ar; RegionView3D *rv3d; @@ -527,7 +529,7 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot) * meant to take into account vertex/bone selection for eg. */ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ Object *camera_ob = v3d ? v3d->camera : scene->camera; @@ -1413,7 +1415,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, static int localview_exec(bContext *C, wmOperator *op) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 853955a4078..c5585857b55 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -426,7 +426,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d = CTX_wm_region_view3d(C); walk->v3d = CTX_wm_view3d(C); walk->ar = CTX_wm_region(C); - walk->depsgraph = CTX_data_depsgraph(C); + walk->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); walk->scene = CTX_data_scene(C); #ifdef NDOF_WALK_DEBUG @@ -520,7 +520,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->rflag |= RV3D_NAVIGATING; walk->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, walk->scene, CTX_data_depsgraph(C), 0, walk->ar, walk->v3d); + bmain, walk->scene, CTX_data_ensure_evaluated_depsgraph(C), 0, walk->ar, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( walk->depsgraph, diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d8dd6aa97b5..5ef86c71d2d 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1595,11 +1595,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) } /* confirm transform if launch key is released after mouse move */ - if (t->flag & T_RELEASE_CONFIRM) { - /* XXX Keyrepeat bug in Xorg messes this up, will test when fixed */ - if ((event->type == t->launch_event) && ISMOUSE(t->launch_event)) { - t->state = TRANS_CONFIRM; - } + if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) { + t->state = TRANS_CONFIRM; } } @@ -4640,8 +4637,13 @@ static void applyRotationValue(TransInfo *t, * Note that this is only needed when doing 'absolute' rotation * (i.e. from initial rotation again, typically when using numinput). * regular incremental rotation (from mouse/widget/...) will be called often enough, - * hence steps are small enough to be properly handled without that complicated trick. */ - if (is_large_rotation) { + * hence steps are small enough to be properly handled without that complicated trick. + * Note that we can only do that kind of stepped rotation if we have initial rotation values + * (and access to some actual rotation value storage). + * Otherwise, just assume it's useless (e.g. in case of mesh/UV/etc. editing). + * Also need to be in Euler rotation mode, the others never allow more than one turn anyway. + */ + if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) { copy_v3_v3(td->ext->rot, td->ext->irot); for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final); angle_progress += angle_step) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b0f720bfdf7..833792379ae 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -102,7 +102,7 @@ typedef struct TransSnap { * Get the transform distance between two points (used by Closest snap) * * \note Return value can be anything, - * where the smallest absolute value defines whats closest. + * where the smallest absolute value defines what's closest. */ float (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5626e9b5c81..4eccf4c5071 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6631,7 +6631,6 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); @@ -6658,11 +6657,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec /* only key on available channels */ if (adt && adt->action) { ListBase nla_cache = {NULL, NULL}; - for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(bmain, - depsgraph, reports, id, adt->action, @@ -6777,7 +6774,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); @@ -6825,7 +6821,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t */ if (pchanName && STREQ(pchanName, pchan->name)) { insert_keyframe(bmain, - depsgraph, reports, id, act, @@ -9020,7 +9015,7 @@ static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3]) static void createTransGPencil(bContext *C, TransInfo *t) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 4a9584ed9be..969e2558abb 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1391,7 +1391,6 @@ void initTransDataContainers_FromObjectData(TransInfo *t, */ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *sce = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); const eObjectMode object_mode = OBACT(view_layer) ? OBACT(view_layer)->mode : OB_MODE_OBJECT; @@ -1403,7 +1402,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve bGPdata *gpd = CTX_data_gpencil_data(C); PropertyRNA *prop; - t->depsgraph = depsgraph; + t->depsgraph = CTX_data_depsgraph_pointer(C); t->scene = sce; t->view_layer = view_layer; t->sa = sa; @@ -1692,7 +1691,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } else { - if (U.flag & USER_RELEASECONFIRM) { + if (ISMOUSE(t->launch_event) && (U.flag & USER_RELEASECONFIRM)) { + /* Global "release confirm" on mouse bindings */ t->flag |= T_RELEASE_CONFIRM; } } diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index a883b5b6ba5..fbfeb4f53de 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -731,7 +731,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C, ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): This function is used from operator's modal() and from gizmo's refresh(). + * Is it fine to possibly evaluate dependency graph here? */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = sa->spacedata.first; Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 183e140169d..c84d7539cce 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -568,15 +568,6 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) } } - if (op->type->flag & OPTYPE_USE_EVAL_DATA) { - /* We need to force refresh of depsgraph after undo step, - * redoing the operator *may* rely on some valid evaluated data. */ - Main *bmain = CTX_data_main(C); - scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); - } - retval = WM_operator_repeat(C, op); if ((retval & OPERATOR_FINISHED) == 0) { if (G.debug & G_DEBUG) { @@ -748,7 +739,7 @@ void ED_undo_object_editmode_restore_helper(struct bContext *C, Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint bases_len = 0; - /* Don't request unique data because we wan't to de-select objects when exiting edit-mode + /* Don't request unique data because we want to de-select objects when exiting edit-mode * for that to be done on all objects we can't skip ones that share data. */ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len); for (uint i = 0; i < bases_len; i++) { diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index c1b6a7b42b2..c2566d111cf 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -99,7 +99,7 @@ void ED_editors_init_for_undo(Main *bmain) void ED_editors_init(bContext *C) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); diff --git a/source/blender/editors/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c index 79f0f48830e..2201ee5cec2 100644 --- a/source/blender/editors/util/select_buffer_utils.c +++ b/source/blender/editors/util/select_buffer_utils.c @@ -216,7 +216,7 @@ uint ED_select_buffer_sample_point(const int center[2]) /** * Find the selection id closest to \a center. * \param dist[in,out]: Use to initialize the distance, - * when found, this value is set to the distance of the selection thats returned. + * when found, this value is set to the distance of the selection that's returned. */ uint ED_select_buffer_find_nearest_to_point(const int center[2], const uint id_min, diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 1482fea456d..2abbe67237e 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -40,8 +40,9 @@ #include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_screen.h" #include "BKE_editmesh.h" +#include "BKE_layer.h" +#include "BKE_screen.h" #include "DEG_depsgraph.h" @@ -57,7 +58,8 @@ /* UV Utilities */ -static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float center[2]) +static int uvedit_center( + Scene *scene, Object **objects, uint objects_len, Image *ima, float center[2]) { BMFace *f; BMLoop *l; @@ -65,19 +67,24 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im MLoopUV *luv; int tot = 0; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - zero_v2(center); - BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, f)) { - continue; - } - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(center, luv->uv); - tot++; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, obedit, ima, f)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + add_v2_v2(center, luv->uv); + tot++; + } } } } @@ -91,24 +98,29 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im } static void uvedit_translate( - Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float delta[2]) + Scene *scene, Object **objects, uint objects_len, Image *ima, float delta[2]) { BMFace *f; BMLoop *l; BMIter iter, liter; MLoopUV *luv; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); - BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, f)) { - continue; - } + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(luv->uv, delta); + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, obedit, ima, f)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + add_v2_v2(luv->uv, delta); + } } } } @@ -122,18 +134,17 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); Image *ima = sima->image; - BMEditMesh *em; float center[2]; int imx, imy, step, digits; float width = 8 * UI_UNIT_X; + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len); ED_space_image_get_size(sima, &imx, &imy); - em = BKE_editmesh_from_object(obedit); - - if (uvedit_center(scene, obedit, em, ima, center)) { + if (uvedit_center(scene, objects, objects_len, ima, center)) { float range_xy[2][2] = { {-10.0f, 10.0f}, {-10.0f, 10.0f}, @@ -193,15 +204,15 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) ""); UI_block_align_end(block); } + + MEM_freeN(objects); } static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); Image *ima = sima->image; - BMEditMesh *em; float center[2], delta[2]; int imx, imy; @@ -209,10 +220,12 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) return; } - em = BKE_editmesh_from_object(obedit); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len); ED_space_image_get_size(sima, &imx, &imy); - uvedit_center(scene, obedit, em, ima, center); + uvedit_center(scene, objects, objects_len, ima, center); if (sima->flag & SI_COORDFLOATS) { delta[0] = uvedit_old_center[0] - center[0]; @@ -223,10 +236,15 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) delta[1] = uvedit_old_center[1] / imy - center[1]; } - uvedit_translate(scene, obedit, em, ima, delta); + uvedit_translate(scene, objects, objects_len, ima, delta); WM_event_add_notifier(C, NC_IMAGE, sima->image); - DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY); + } + + MEM_freeN(objects); } /* Panels */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 71bf6a1946a..6a2f740ba51 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2376,7 +2376,7 @@ static void uv_select_all_perform_multi( static int uv_select_all_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; Image *ima = CTX_data_edit_image(C); @@ -2456,7 +2456,7 @@ static int uv_mouse_select_multi(bContext *C, const bool deselect_all, const bool loop) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -3429,7 +3429,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, static int uv_box_select_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -3587,7 +3587,7 @@ static int uv_inside_circle(const float uv[2], const float offset[2], const floa static int uv_circle_select_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); Scene *scene = CTX_data_scene(C); @@ -3727,7 +3727,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, short moves, const eSelectOp sel_op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); ARegion *ar = CTX_wm_region(C); @@ -4278,7 +4278,7 @@ static void UV_OT_pin(wmOperatorType *ot) static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; ViewLayer *view_layer = CTX_data_view_layer(C); diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h index a3b20661fa6..367c233d799 100644 --- a/source/blender/freestyle/intern/geometry/FastGrid.h +++ b/source/blender/freestyle/intern/geometry/FastGrid.h @@ -60,7 +60,7 @@ class FastGrid : public Grid { */ virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb); - /*! returns the cell whose coordinates are pased as argument */ + /*! returns the cell whose coordinates are passed as argument */ Cell *getCell(const Vec3u &p); /*! Fills the case p with the cell iCell */ diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h index 253d3553010..1c193e7252e 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.h +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h @@ -72,7 +72,7 @@ class GeomCleaner { unsigned **oIndices); /*! Compress a SORTED indexed vertex array by eliminating multiple - * appearing occurences of a single vertex. + * appearing occurrences of a single vertex. * iVertices * The SORTED vertex array to compress. * It is organized as a float series of vertex coordinates: XYZXYZXYZ... diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index e6b1c947476..4c4f12faaba 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -488,7 +488,7 @@ bool intersectRayTriangle(const Vec3r &orig, } } else { - return false; // ray is parallell to the plane of the triangle + return false; // ray is parallel to the plane of the triangle } u *= inv_det; diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp index 4076bfe03df..e3e25796de1 100644 --- a/source/blender/freestyle/intern/geometry/Grid.cpp +++ b/source/blender/freestyle/intern/geometry/Grid.cpp @@ -165,7 +165,7 @@ void Grid::insertOccluder(Polygon3r *occluder) Vec3r min, max; occluder->getBBox(min, max); - // Retrieve the cell x, y, z cordinates associated with these min and max + // Retrieve the cell x, y, z coordinates associated with these min and max Vec3u imax, imin; getCellCoordinates(max, imax); getCellCoordinates(min, imin); @@ -245,7 +245,7 @@ bool Grid::nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell) unsigned coord = 0; // predominant coord(0=x, 1=y, 2=z) // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively - // coresponding to the intersections with the plans: + // corresponding to the intersections with the plans: // x = _cell_size[0], y = _cell_size[1], z = _cell_size[2] for (i = 0; i < 3; i++) { if (_ray_dir[i] == 0) { diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h index 6090eeb122a..0a9fa5dc85a 100644 --- a/source/blender/freestyle/intern/geometry/Grid.h +++ b/source/blender/freestyle/intern/geometry/Grid.h @@ -243,7 +243,7 @@ class Grid { /*! Fills the case corresponding to coord with the cell */ virtual void fillCell(const Vec3u &coord, Cell &cell) = 0; - /*! returns the cell whose coordinates are pased as argument */ + /*! returns the cell whose coordinates are passed as argument */ virtual Cell *getCell(const Vec3u &coord) = 0; /*! returns the cell containing the point passed as argument. diff --git a/source/blender/freestyle/intern/geometry/HashGrid.h b/source/blender/freestyle/intern/geometry/HashGrid.h index 73751d820ab..4bb92859775 100644 --- a/source/blender/freestyle/intern/geometry/HashGrid.h +++ b/source/blender/freestyle/intern/geometry/HashGrid.h @@ -81,7 +81,7 @@ class HashGrid : public Grid { */ virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb); - /*! returns the cell whose coordinates are pased as argument */ + /*! returns the cell whose coordinates are passed as argument */ virtual Cell *getCell(const Vec3u &p) { Cell *found_cell = NULL; diff --git a/source/blender/freestyle/intern/geometry/VecMat.h b/source/blender/freestyle/intern/geometry/VecMat.h index acc593e8ac9..ee1cc42876c 100644 --- a/source/blender/freestyle/intern/geometry/VecMat.h +++ b/source/blender/freestyle/intern/geometry/VecMat.h @@ -474,7 +474,7 @@ template<class T> class HVec3 : public Vec<T, 4> { return this->_coord[3]; } - // Acces to non-homogeneous coordinates in 3D + // Access to non-homogeneous coordinates in 3D inline value_type x() const { return this->_coord[0] / this->_coord[3]; diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h index f933e66dc94..f8e2524fa4f 100644 --- a/source/blender/freestyle/intern/image/GaussianFilter.h +++ b/source/blender/freestyle/intern/image/GaussianFilter.h @@ -39,7 +39,7 @@ namespace Freestyle { class GaussianFilter { protected: - /* The mask is a symetrical 2d array (with respect to the middle point). + /* The mask is a symmetrical 2d array (with respect to the middle point). * Thus, M(i,j) = M(-i,j) = M(i,-j) = M(-i,-j). * For this reason, to represent a NxN array (N odd), we only store a ((N+1)/2)x((N+1)/2) array. */ diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp index 10417c07f33..d2575b3b5e9 100644 --- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp +++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp @@ -197,7 +197,7 @@ static PyObject *Iterator_name_get(BPy_Iterator *self, void *UNUSED(closure)) } PyDoc_STRVAR(Iterator_is_begin_doc, - "True if the interator points the first element.\n" + "True if the iterator points to the first element.\n" "\n" ":type: bool"); @@ -207,7 +207,7 @@ static PyObject *Iterator_is_begin_get(BPy_Iterator *self, void *UNUSED(closure) } PyDoc_STRVAR(Iterator_is_end_doc, - "True if the interator points the last element.\n" + "True if the iterator points to the last element.\n" "\n" ":type: bool"); diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index 505566d3515..e3d6738058e 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -241,7 +241,7 @@ PyDoc_STRVAR(StrokeAttribute_has_attribute_real_doc, "\n" " :arg name: The name of the attribute.\n" " :type name: str\n" - " :return: True if the attribute is availbale.\n" + " :return: True if the attribute is available.\n" " :rtype: bool\n"); static PyObject *StrokeAttribute_has_attribute_real(BPy_StrokeAttribute *self, @@ -265,7 +265,7 @@ PyDoc_STRVAR(StrokeAttribute_has_attribute_vec2_doc, "\n" " :arg name: The name of the attribute.\n" " :type name: str\n" - " :return: True if the attribute is availbale.\n" + " :return: True if the attribute is available.\n" " :rtype: bool\n"); static PyObject *StrokeAttribute_has_attribute_vec2(BPy_StrokeAttribute *self, @@ -289,7 +289,7 @@ PyDoc_STRVAR(StrokeAttribute_has_attribute_vec3_doc, "\n" " :arg name: The name of the attribute.\n" " :type name: str\n" - " :return: True if the attribute is availbale.\n" + " :return: True if the attribute is available.\n" " :rtype: bool\n"); static PyObject *StrokeAttribute_has_attribute_vec3(BPy_StrokeAttribute *self, diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp index 8e619ec95a4..49cd98376c5 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp @@ -45,7 +45,7 @@ PyDoc_STRVAR(CurvePoint_doc, "\n" ".. method:: __init__()\n" "\n" - " Defult constructor.\n" + " Default constructor.\n" "\n" ".. method:: __init__(brother)\n" "\n" diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp index b33ebc0f4ef..abc10b75ea1 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -35,7 +35,7 @@ PyDoc_STRVAR(CurvePointIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`CurvePointIterator`\n" "\n" "Class representing an iterator on a curve. Allows an iterating\n" - "outside initial vertices. A CurvePoint is instanciated and returned\n" + "outside initial vertices. A CurvePoint is instantiated and returned\n" "through the .object attribute.\n" "\n" ".. method:: __init__()\n" diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 13a981920f3..8428badc0fd 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -180,7 +180,7 @@ static PyObject *Interface0DIterator_u_get(BPy_Interface0DIterator *self, void * } PyDoc_STRVAR(Interface0DIterator_at_last_doc, - "True if the interator points to the last valid element.\n" + "True if the iterator points to the last valid element.\n" "For its counterpart (pointing to the first valid element), use it.is_begin.\n" "\n" ":type: bool"); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index 70de25aaf84..4269dfb3cdd 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -254,7 +254,7 @@ static PyObject *StrokeVertexIterator_u_get(BPy_StrokeVertexIterator *self, void } PyDoc_STRVAR(StrokeVertexIterator_at_last_doc, - "True if the interator points to the last valid element.\n" + "True if the iterator points to the last valid element.\n" "For its counterpart (pointing to the first valid element), use it.is_begin.\n" "\n" ":type: bool"); diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp index 98b50f2112c..27af7207b97 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp @@ -57,8 +57,8 @@ static char CalligraphicShader___doc__[] = "\n" " Assigns thicknesses to the stroke vertices so that the stroke looks\n" " like made with a calligraphic tool, i.e. the stroke will be the\n" - " thickest in a main direction, and the thinest in the direction\n" - " perpendicular to this one, and an interpolation inbetween.\n" + " thickest in a main direction, and the thinnest in the direction\n" + " perpendicular to this one, and an interpolation in between.\n" "\n" " :arg stroke: A Stroke object.\n" " :type stroke: :class:`freestyle.types.Stroke`\n"; diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h index 5163a0af07e..d70794d9b78 100644 --- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h +++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h @@ -42,7 +42,7 @@ class IndexedFaceSet : public Rep { }; /*! User-specified face and edge marks for feature edge detection */ - /* XXX Why in hel not use an enum here too? */ + /* XXX Why in hell not use an enum here too? */ typedef unsigned char FaceEdgeMark; static const FaceEdgeMark FACE_MARK = 1 << 0; static const FaceEdgeMark EDGE_MARK_V1V2 = 1 << 1; @@ -55,12 +55,12 @@ class IndexedFaceSet : public Rep { /*! Builds an indexed face set * iVertices * The array of object vertices 3D coordinates (for all faces). - * If iCopy != 0, the array is copied; you must desallocate iVertices. Else you must not. + * If iCopy != 0, the array is copied; you must deallocate iVertices. Else you must not. * iVSize * The size of iVertices (must be a multiple of 3) * iNormals * The array of object normals 3D coordinates. - * If iCopy != 0, the array is copied; you must desallocate iNormals. Else you must not. + * If iCopy != 0, the array is copied; you must deallocate iNormals. Else you must not. * iNSize * The size of iNormals * iMaterials @@ -81,17 +81,17 @@ class IndexedFaceSet : public Rep { * - TRIANGLE_STRIP: the face indices describe a triangle strip * - TRIANGLE_FAN : the face indices describe a triangle fan * - TRIANGLES : the face indices describe single triangles - * If iCopy != 0, the array is copied; you must desallocate iFaceStyle. Else you must not. + * If iCopy != 0, the array is copied; you must deallocate iFaceStyle. Else you must not. * iVIndices, * Array of vertices indices. * The integers contained in this array must be multiple of 3. - * If iCopy != 0, the array is copied; you must desallocate iVIndices. Else you must not. + * If iCopy != 0, the array is copied; you must deallocate iVIndices. Else you must not. * iVISize * The size of iVIndices. * iNIndices * Array of normals indices. * The integers contained in this array must be multiple of 3. - * If iCopy != 0, the array is copied; you must desallocate iNIndices. Else you must not. + * If iCopy != 0, the array is copied; you must deallocate iNIndices. Else you must not. * iNISize * The size of iNIndices * iMIndices @@ -167,8 +167,8 @@ class IndexedFaceSet : public Rep { return *this; } - /*! Desctructor - * desallocates all the resources + /*! Destructor + * deallocates all the resources */ virtual ~IndexedFaceSet(); diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h index f40deb13a3e..5ef16255e46 100644 --- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h +++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h @@ -54,7 +54,7 @@ class NodeGroup : public Node { /*! Detaches all the children */ virtual void DetachChildren(); - /*! Detached the sepcified child */ + /*! Detached the specified child */ virtual void DetachChild(Node *iChild); /*! Retrieve children */ diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h index 5209839a8e1..641e133b019 100644 --- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h +++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h @@ -28,8 +28,8 @@ namespace Freestyle { /*! [ Thickness Shader ]. * Assigns thicknesses to the stroke vertices so that the stroke looks like made with a - * calligraphic tool. i.e. The stroke will be the thickest in a main direction, the thinest in the - * direction perpendicular to this one, and an interpolation inbetween. + * calligraphic tool. i.e. The stroke will be the thickest in a main direction, the thinnest in the + * direction perpendicular to this one, and an interpolation in between. */ class CalligraphicShader : public StrokeShader { public: diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index 843395c136c..2c014c86d36 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -57,7 +57,7 @@ int ConstantThicknessShader::shade(Stroke &stroke) const int i = 0; int size = stroke.strokeVerticesSize(); for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { - // XXX What's the use of i here? And is not the thickness always overriden by the last line of + // XXX What's the use of i here? And is not the thickness always overridden by the last line of // the loop? if ((1 == i) || (size - 2 == i)) { v->attribute().setThickness(_thickness / 4.0, _thickness / 4.0); @@ -77,7 +77,7 @@ int ConstantExternThicknessShader::shade(Stroke &stroke) const int i = 0; int size = stroke.strokeVerticesSize(); for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { - // XXX What's the use of i here? And is not the thickness always overriden by the last line of + // XXX What's the use of i here? And is not the thickness always overridden by the last line of // the loop? if ((1 == i) || (size - 2 == i)) { v->attribute().setThickness(_thickness / 2.0, 0); @@ -156,7 +156,7 @@ int LengthDependingThicknessShader::shade(Stroke &stroke) const int i = 0; int size = stroke.strokeVerticesSize(); for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { - // XXX What's the use of i here? And is not the thickness always overriden by the last line of + // XXX What's the use of i here? And is not the thickness always overridden by the last line of // the loop? if ((1 == i) || (size - 2 == i)) { v->attribute().setThickness(thickness / 4.0, thickness / 4.0); @@ -427,7 +427,7 @@ int BezierCurveShader::shade(Stroke &stroke) const int newsize = stroke.strokeVerticesSize(); int nExtraVertex = 0; if (newsize < originalSize) { - cerr << "Warning: unsufficient resampling" << endl; + cerr << "Warning: insufficient resampling" << endl; } else { nExtraVertex = newsize - originalSize; diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h index db5738449e6..e4a54106c38 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h @@ -187,7 +187,7 @@ class ConstrainedIncreasingThicknessShader : public StrokeShader { }; /* [ Thickness Shader ]. - * Modifys the thickness in a relative way depending on its length. + * Modifies the thickness in a relative way depending on its length. */ class LengthDependingThicknessShader : public StrokeShader { private: diff --git a/source/blender/freestyle/intern/stroke/Chain.h b/source/blender/freestyle/intern/stroke/Chain.h index 2c19748771e..7cd0c64cc16 100644 --- a/source/blender/freestyle/intern/stroke/Chain.h +++ b/source/blender/freestyle/intern/stroke/Chain.h @@ -39,7 +39,7 @@ class Chain : public Curve { _fedgeB; // the last FEdge of the ViewEdge passed to the last call for push_viewedge_back(). public: - /*! Defult constructor. */ + /*! Default constructor. */ Chain() : Curve() { _splittingId = 0; diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h index 3e079256161..7eadfa830ce 100644 --- a/source/blender/freestyle/intern/stroke/Curve.h +++ b/source/blender/freestyle/intern/stroke/Curve.h @@ -205,7 +205,7 @@ class CurvePoint : public Interface0D { Vec3r _Point3d; public: - /*! Defult Constructor. */ + /*! Default Constructor. */ CurvePoint(); /*! Builds a CurvePoint from two SVertex and an interpolation parameter. diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h index 9999950e240..662222524f1 100644 --- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h +++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h @@ -50,8 +50,8 @@ class CurvePoint_nonconst_traits : public Nonconst_traits<CurvePoint *> { /* */ /**********************************/ -/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is - * instanciated an returned when the iterator is dereferenced. +/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is + * instantiated and returned when the iterator is dereferenced. */ template<class Traits> class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> { diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h index 0ebbd0509ca..3ac7ede0954 100644 --- a/source/blender/freestyle/intern/stroke/CurveIterators.h +++ b/source/blender/freestyle/intern/stroke/CurveIterators.h @@ -30,7 +30,7 @@ namespace Freestyle { namespace CurveInternal { /*! iterator on a curve. Allows an iterating outside - * initial vertices. A CurvePoint is instanciated an returned + * initial vertices. A CurvePoint is instantiated an returned * when the iterator is dereferenced. */ diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index ec722516d2a..f4fd2b132e8 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -194,13 +194,13 @@ class StrokeAttribute { */ Vec3f getAttributeVec3f(const char *iName) const; - /*! Checks whether the attribute iName is availbale */ + /*! Checks whether the attribute iName is available */ bool isAttributeAvailableReal(const char *iName) const; - /*! Checks whether the attribute iName is availbale */ + /*! Checks whether the attribute iName is available */ bool isAttributeAvailableVec2f(const char *iName) const; - /*! Checks whether the attribute iName is availbale */ + /*! Checks whether the attribute iName is available */ bool isAttributeAvailableVec3f(const char *iName) const; /* modifiers */ @@ -653,7 +653,7 @@ class Stroke : public Interface1D { return _textureId; } - /*! Returns the spacing of texture coordinates along the stroke lenght */ + /*! Returns the spacing of texture coordinates along the stroke length */ inline float getTextureStep() { return _textureStep; @@ -766,7 +766,7 @@ class Stroke : public Interface1D { _textureId = id; } - /*! sets the spacing of texture coordinates along the stroke lenght. */ + /*! sets the spacing of texture coordinates along the stroke length. */ inline void setTextureStep(float step) { _textureStep = step; diff --git a/source/blender/freestyle/intern/system/BaseIterator.h b/source/blender/freestyle/intern/system/BaseIterator.h index 3826a129a1c..651f2bf4387 100644 --- a/source/blender/freestyle/intern/system/BaseIterator.h +++ b/source/blender/freestyle/intern/system/BaseIterator.h @@ -30,7 +30,7 @@ namespace Freestyle { -// use for iterators defintions +// use for iterators definitions template<class Element> class Nonconst_traits; template<class Element> class Const_traits { diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp index 8e10d06d623..2df5ecd0867 100644 --- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp +++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp @@ -131,7 +131,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe GridHelpers::getDefaultViewProscenium(occluderProscenium); // XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and - // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be + // vector<ViewEdge*>::iterator. Probably all occurrences of vector<ViewEdge*>::iterator should be // replaced ViewMap::viewedges_container throughout the code. For each view edge ViewMap::viewedges_container::iterator ve, veend; @@ -144,7 +144,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe // If none exists, find the feature edge with center point closest to viewport origin. // Expand occluder proscenium to enclose center point. - // For each feature edge, while bestOccluderTarget not found and view edge not visibile + // For each feature edge, while bestOccluderTarget not found and view edge not visible bool bestOccluderTargetFound = false; FEdge *bestOccluderTarget = NULL; real bestOccluderDistance = 0.0; diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 5c3ba1c3db3..3788b5e3545 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -132,7 +132,7 @@ void FEdgeXDetector::preProcessShape(WXShape *iWShape) vector<WFace *> &wfaces = iWShape->GetFaceList(); vector<WFace *>::iterator f, fend; - // view dependant stuff + // view dependent stuff for (f = wfaces.begin(), fend = wfaces.end(); f != fend; ++f) { preProcessFace((WXFace *)(*f)); } @@ -226,7 +226,7 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex) _minK1 = absK1; } } - // view dependant + // view dependent C = vertex->curvatures(); if (C == 0) { return; diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h index 5e9edd234ef..648eb4e453d 100644 --- a/source/blender/freestyle/intern/view_map/Silhouette.h +++ b/source/blender/freestyle/intern/view_map/Silhouette.h @@ -168,7 +168,7 @@ class SVertex : public Interface0D { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; @@ -535,7 +535,7 @@ class FEdge : public Interface1D { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; @@ -620,7 +620,7 @@ class FEdge : public Interface1D { return _VertexB; } - /*! Returns the first SVertex if i=0, the seccond SVertex if i=1. */ + /*! Returns the first SVertex if i=0, the second SVertex if i=1. */ inline SVertex *operator[](const unsigned short int &i) const { return (i % 2 == 0) ? _VertexA : _VertexB; @@ -1433,7 +1433,7 @@ class SShape { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; // added by E.T. diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index fde4ee7e476..d024c360e3f 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -37,7 +37,7 @@ void ViewEdgeXBuilder::Init(ViewShape *oVShape) return; } - // for design conveniance, we store the current SShape. + // for design convenience, we store the current SShape. _pCurrentSShape = oVShape->sshape(); if (0 == _pCurrentSShape) { return; @@ -627,12 +627,12 @@ OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge) } if (wxe->GetaVertex() == v) { - // That means that the face necesarily lies on the edge left. + // That means that the face necessarily lies on the edge left. // So the vertex order is OK. return OWXEdge(wxe, true); } else { - // That means that the face necesarily lies on the edge left. + // That means that the face necessarily lies on the edge left. // So the vertex order is OK. return OWXEdge(wxe, false); } diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h index 26f114497c0..b1934d08376 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h @@ -272,11 +272,11 @@ class ViewEdgeXBuilder { FEdge *BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe); // GENERAL // - /*! Instanciate a SVertex */ + /*! Instantiate a SVertex */ SVertex *MakeSVertex(Vec3r &iPoint); - /*! Instanciate a SVertex if it hasn't been already created */ + /*! Instantiate a SVertex if it hasn't been already created */ SVertex *MakeSVertex(Vec3r &iPoint, bool shared); - /*! instanciate a ViewVertex from a SVertex, if it doesn't exist yet */ + /*! instantiate a ViewVertex from a SVertex, if it doesn't exist yet */ ViewVertex *MakeViewVertex(SVertex *iSVertex); // oldtmp values diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index a6ca4e3c072..83c45be8c61 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -81,7 +81,7 @@ class ViewMap { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; @@ -292,7 +292,7 @@ class ViewVertex : public Interface0D { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; @@ -962,7 +962,7 @@ class ViewEdge : public Interface1D { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; @@ -1414,7 +1414,7 @@ class ViewShape { public: /*! A field that can be used by the user to store any data. - * This field must be reseted afterwards using ResetUserData(). + * This field must be reset afterwards using ResetUserData(). */ void *userdata; diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index aaab3936fa6..c67be4f97b3 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1123,7 +1123,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap, GridHelpers::getDefaultViewProscenium(occluderProscenium); // N.B. Freestyle is inconsistent in its use of ViewMap::viewedges_container and - // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be + // vector<ViewEdge*>::iterator. Probably all occurrences of vector<ViewEdge*>::iterator should be // replaced ViewMap::viewedges_container throughout the code. For each view edge ViewMap::viewedges_container::iterator ve, veend; @@ -1137,7 +1137,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap, // If none exists, find the feature edge with center point closest to viewport origin. // Expand occluder proscenium to enclose center point. - // For each feature edge, while bestOccluderTarget not found and view edge not visibile + // For each feature edge, while bestOccluderTarget not found and view edge not visible bool bestOccluderTargetFound = false; FEdge *bestOccluderTarget = NULL; real bestOccluderDistance = 0.0; diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp index a293d2da62b..591d6518741 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp +++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp @@ -546,7 +546,7 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V e1[2] = eig[0] * basis1[2] + eig[1] * basis2[2]; e1.normalize(); - /* make N,e1,e2 a right handed coordinate sytem */ + /* make N,e1,e2 a right handed coordinate system */ e2 = N ^ e1; e2.normalize(); } diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h index 20c0bd172ad..21418c44614 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h @@ -108,7 +108,7 @@ class WXEdge : public WEdge { private: // flag to indicate whether the edge is a silhouette edge or not WXNature _nature; - // 0: the order doesn't matter. 1: the order is the orginal one. -1: the order is not good + // 0: the order doesn't matter. 1: the order is the original one. -1: the order is not good short _order; // A front facing edge is an edge for which the bording face which is the nearest from the // viewpoint is front. A back facing edge is the opposite. diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index e0139eac6b2..e891b6dea12 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -26,10 +26,9 @@ #include "BLI_utildefines.h" #include "BLI_math_vector.h" +#include "BLI_hash.h" #include "BLI_rand.h" -#include "PIL_time.h" - #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" @@ -58,20 +57,7 @@ static void initData(GpencilModifierData *md) gpmd->layername[0] = '\0'; gpmd->vgname[0] = '\0'; gpmd->step = 1; - gpmd->scene_frame = -999999; - gpmd->gp_frame = -999999; - - gpmd->vrand1 = 1.0; - gpmd->vrand2 = 1.0; -} - -static void freeData(GpencilModifierData *md) -{ - NoiseGpencilModifierData *mmd = (NoiseGpencilModifierData *)md; - - if (mmd->rng != NULL) { - BLI_rng_free(mmd->rng); - } + gpmd->seed = 0; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) @@ -85,21 +71,6 @@ static bool dependsOnTime(GpencilModifierData *md) return (mmd->flag & GP_NOISE_USE_RANDOM) != 0; } -/* Get the lower number of frame for all layers. */ -static int get_lower_frame(bGPdata *gpd) -{ - int init = 99999; - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - if (gpl->frames.first) { - bGPDframe *gpf = gpl->frames.first; - if (gpf->framenum < init) { - init = gpf->framenum; - } - } - } - return init; -} - /* aply noise effect based on stroke direction */ static void deformStroke( GpencilModifierData *md, Depsgraph *depsgraph, Object *ob, bGPDlayer *gpl, bGPDstroke *gps) @@ -111,26 +82,10 @@ static void deformStroke( float normal[3]; float vec1[3], vec2[3]; int sc_frame = 0; - int sc_diff = 0; + int stroke_seed = 0; const int def_nr = defgroup_name_index(ob, mmd->vgname); const float unit_v3[3] = {1.0f, 1.0f, 1.0f}; - Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); - GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name); - NoiseGpencilModifierData *mmd_eval = (NoiseGpencilModifierData *)md_eval; - bGPdata *gpd = (bGPdata *)ob->data; - - /* Random generator, only init once. (it uses eval to get same value in render) */ - if (mmd_eval->rng == NULL) { - uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); - rng_seed ^= POINTER_AS_UINT(mmd); - mmd_eval->rng = BLI_rng_new(rng_seed); - mmd->rng = mmd_eval->rng; - /* Get lower frame number */ - mmd_eval->scene_frame = get_lower_frame(gpd); - mmd->scene_frame = mmd_eval->scene_frame; - } - if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->pass_index, @@ -200,22 +155,14 @@ static void deformStroke( normalize_v3(vec2); /* Use random noise */ if (mmd->flag & GP_NOISE_USE_RANDOM) { - sc_diff = abs(sc_frame - mmd->scene_frame) % mmd->step; - /* Only recalc if the gp frame change or is a step. */ - if ((mmd->gp_frame != sc_frame) && (sc_diff == 0)) { - vran = mmd->vrand1 = BLI_rng_get_float(mmd->rng); - vdir = mmd->vrand2 = BLI_rng_get_float(mmd->rng); - mmd->gp_frame = sc_frame; + stroke_seed = BLI_hash_int_2d((sc_frame / mmd->step) + gps->totpoints, mmd->seed + 1); + vran = BLI_hash_frand(stroke_seed); + if (mmd->flag & GP_NOISE_FULL_STROKE) { + vdir = BLI_hash_frand(stroke_seed + 3); } else { - vran = mmd->vrand1; - if (mmd->flag & GP_NOISE_FULL_STROKE) { - vdir = mmd->vrand2; - } - else { - int f = (mmd->vrand2 * 10.0f) + i; - vdir = f % 2; - } + int f = (BLI_hash_frand(stroke_seed + 3) * 10.0f) + i; + vdir = f % 2; } } else { @@ -226,7 +173,6 @@ static void deformStroke( else { vdir = i % 2; } - mmd->gp_frame = -999999; } /* if vec2 is zero, set to something */ @@ -314,7 +260,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Noise = { /* remapTime */ NULL, /* initData */ initData, - /* freeData */ freeData, + /* freeData */ NULL, /* isDisabled */ NULL, /* updateDepsgraph */ NULL, /* dependsOnTime */ dependsOnTime, diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index d0abf671fcd..023cbb804d9 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -43,6 +43,7 @@ int GPU_max_ubo_binds(void); int GPU_max_ubo_size(void); float GPU_max_line_width(void); void GPU_get_dfdy_factors(float fac[2]); +bool GPU_arb_base_instance_is_supported(void); bool GPU_mip_render_workaround(void); bool GPU_depth_blitting_workaround(void); bool GPU_unused_fb_slot_workaround(void); diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h index b919a3dd8f3..7d0f8b0bcbf 100644 --- a/source/blender/gpu/GPU_framebuffer.h +++ b/source/blender/gpu/GPU_framebuffer.h @@ -71,7 +71,7 @@ GPUFrameBuffer *GPU_framebuffer_active_get(void); } \ } while (0) -/* Framebuffer setup : You need to call GPU_framebuffer_bind for theses +/* Framebuffer setup : You need to call GPU_framebuffer_bind for these * to be effective. */ void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int mip); diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index ba3c7f68518..11b487f7be4 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -28,6 +28,7 @@ #include "GPU_batch.h" #include "GPU_batch_presets.h" +#include "GPU_extensions.h" #include "GPU_matrix.h" #include "GPU_shader.h" @@ -599,7 +600,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi i_count = (batch->inst) ? batch->inst->vertex_len : 1; } - if (!GLEW_ARB_base_instance) { + if (!GPU_arb_base_instance_is_supported()) { if (i_first > 0 && i_count > 0) { /* If using offset drawing with instancing, we must * use the default VAO and redo bindings. */ @@ -624,7 +625,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi #endif void *v_first_ofs = elem_offset(el, v_first); - if (GLEW_ARB_base_instance) { + if (GPU_arb_base_instance_is_supported()) { glDrawElementsInstancedBaseVertexBaseInstance( batch->gl_prim_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first); } @@ -637,7 +638,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi #ifdef __APPLE__ glDisable(GL_PRIMITIVE_RESTART); #endif - if (GLEW_ARB_base_instance) { + if (GPU_arb_base_instance_is_supported()) { glDrawArraysInstancedBaseInstance(batch->gl_prim_type, v_first, v_count, i_count, i_first); } else { diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 0c751808489..51b73c93c86 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -2138,7 +2138,7 @@ static bool gpu_pass_shader_validate(GPUPass *pass, GPUShader *shader) bool GPU_pass_compile(GPUPass *pass, const char *shname) { - bool sucess = true; + bool success = true; if (!pass->compiled) { GPUShader *shader = GPU_shader_create( pass->vertexcode, pass->fragmentcode, pass->geometrycode, NULL, pass->defines, shname); @@ -2146,7 +2146,7 @@ bool GPU_pass_compile(GPUPass *pass, const char *shname) /* NOTE: Some drivers / gpu allows more active samplers than the opengl limit. * We need to make sure to count active samplers to avoid undefined behavior. */ if (!gpu_pass_shader_validate(pass, shader)) { - sucess = false; + success = false; if (shader != NULL) { fprintf(stderr, "GPUShader: error: too many samplers in shader.\n"); GPU_shader_free(shader); @@ -2169,7 +2169,7 @@ bool GPU_pass_compile(GPUPass *pass, const char *shname) MEM_SAFE_FREE(pass->binary.content); } - return sucess; + return success; } void GPU_pass_release(GPUPass *pass) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index ba5cf214a42..99dbff05453 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -77,6 +77,9 @@ static struct GPUGlobal { * number is factor on screen and second is off-screen */ float dfdyfactors[2]; float max_anisotropy; + /* Some Intel drivers have limited support for `GLEW_ARB_base_instance` so in + * these cases it is best to indicate that it is not supported. See T67951 */ + bool glew_arb_base_instance_is_supported; /* Some Intel drivers have issues with using mips as framebuffer targets if * GL_TEXTURE_MAX_LEVEL is higher than the target mip. * We need a workaround in this cases. */ @@ -197,6 +200,11 @@ void GPU_get_dfdy_factors(float fac[2]) copy_v2_v2(fac, GG.dfdyfactors); } +bool GPU_arb_base_instance_is_supported(void) +{ + return GG.glew_arb_base_instance_is_supported; +} + bool GPU_mip_render_workaround(void) { return GG.mip_render_workaround; @@ -343,6 +351,7 @@ void gpu_extensions_init(void) GG.os = GPU_OS_UNIX; #endif + GG.glew_arb_base_instance_is_supported = GLEW_ARB_base_instance; gpu_detect_mip_render_workaround(); if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) { @@ -378,11 +387,11 @@ void gpu_extensions_init(void) GG.dfdyfactors[1] = 1.0; } - if (strstr(version, "Build 10.18.10.3379") || strstr(version, "Build 10.18.10.3574") || - strstr(version, "Build 10.18.10.4252") || strstr(version, "Build 10.18.10.4358") || - strstr(version, "Build 10.18.10.4653") || strstr(version, "Build 10.18.10.5069") || - strstr(version, "Build 10.18.14.4264") || strstr(version, "Build 10.18.14.4432") || - strstr(version, "Build 10.18.14.5067")) { + if (strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") || + strstr(version, "Build 10.18.14.4") || strstr(version, "Build 10.18.14.5")) { + /* Maybe not all of these drivers have problems with `GLEW_ARB_base_instance`. + * But it's hard to test each case. */ + GG.glew_arb_base_instance_is_supported = false; GG.context_local_shaders_workaround = true; } } diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 6f1b8d2d0c6..20b91c0c95d 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -733,7 +733,7 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene, void GPU_material_compile(GPUMaterial *mat) { - bool sucess; + bool success; BLI_assert(mat->status == GPU_MAT_QUEUED); BLI_assert(mat->pass); @@ -741,12 +741,12 @@ void GPU_material_compile(GPUMaterial *mat) /* NOTE: The shader may have already been compiled here since we are * sharing GPUShader across GPUMaterials. In this case it's a no-op. */ #ifndef NDEBUG - sucess = GPU_pass_compile(mat->pass, mat->name); + success = GPU_pass_compile(mat->pass, mat->name); #else - sucess = GPU_pass_compile(mat->pass, __func__); + success = GPU_pass_compile(mat->pass, __func__); #endif - if (sucess) { + if (success) { GPUShader *sh = GPU_pass_shader_get(mat->pass); if (sh != NULL) { mat->status = GPU_MAT_SUCCESS; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index b1eb0978339..0401c485c2a 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -303,7 +303,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co /* create a target */ target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget"); target->con = con; - // by contruction there can be only one tree per channel + // by construction there can be only one tree per channel // and each channel can be part of at most one tree. tree = (PoseTree *)pchan_root->iktree.first; @@ -1729,7 +1729,7 @@ static void execute_scene(struct Depsgraph *depsgraph, IK_Channel *ikchan; if (ikparam->flag & ITASC_SIMULATION) { for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) { - // In simulation mode we don't allow external contraint to change our bones, mark the channel + // In simulation mode we don't allow external constraint to change our bones, mark the channel // done also tell Blender that this channel is part of IK tree // (cleared on each BKE_pose_where_is() ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN); diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index fbaa9b06d3b..791e939db7f 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -324,7 +324,7 @@ struct IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecode_Type tcs_in_use, IMB_Proxy_Size proxy_sizes_in_use, int quality, - const bool overwite, + const bool overwrite, struct GSet *file_list); /* will rebuild all used indices and proxies at once */ diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 1ca584e9b0e..cbc85962a36 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -84,7 +84,7 @@ void ColorBlock::init(uint w, uint h, const uint *data, uint x, uint y) const uint bh = MIN(h - y, 4U); // Blocks that are smaller than 4x4 are handled by repeating the pixels. - // @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :( + // @@ That's only correct when block size is 1, 2 or 4, but not with 3. :( // @@ Ideally we should zero the weights of the pixels out of range. for (uint i = 0; i < 4; i++) { @@ -105,7 +105,7 @@ void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y) const uint bh = MIN(h - y, 4U); // Blocks that are smaller than 4x4 are handled by repeating the pixels. - // @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :( + // @@ That's only correct when block size is 1, 2 or 4, but not with 3. :( // @@ Ideally we should zero the weights of the pixels out of range. uint srcPlane = w * h; diff --git a/source/blender/imbuf/intern/dds/Stream.h b/source/blender/imbuf/intern/dds/Stream.h index 35662e8f24e..43cd6b56fb9 100644 --- a/source/blender/imbuf/intern/dds/Stream.h +++ b/source/blender/imbuf/intern/dds/Stream.h @@ -27,7 +27,7 @@ struct Stream { unsigned char *mem; // location in memory unsigned int size; // size unsigned int pos; // current position - bool failed; // error occured when seeking + bool failed; // error occurred when seeking Stream(unsigned char *m, unsigned int s) : mem(m), size(s), pos(0), failed(false) { } diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 49437e77d8e..3bf97cb851f 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -450,7 +450,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, signed_offsets[i] = 1 << (image->comps[i].prec - 1); } - /* only needed for float images but dosnt hurt to calc this */ + /* only needed for float images but doesn't hurt to calc this */ float_divs[i] = (1 << image->comps[i].prec) - 1; } diff --git a/source/blender/imbuf/readme.txt b/source/blender/imbuf/readme.txt index 855f6229420..c192515371b 100644 --- a/source/blender/imbuf/readme.txt +++ b/source/blender/imbuf/readme.txt @@ -8,7 +8,7 @@ creating an openexr read/writer use openexr.c It should contain functions to match the following prototypes: struct ImBuf *imb_loadopenexr(unsigned char *mem,int size,int flags); -/* Use one of the following depending on whats easyer for your file format */ +/* Use one of the following depending on what's easier for your file format */ short imb_saveopenexr(struct ImBuf *ibuf, FILE myfile, int flags); short imb_saveopenexr(struct ImBuf *ibuf, char *myfile, int flags); diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 6f775e48d58..93ce3d9769b 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -186,6 +186,18 @@ typedef enum eGP_BrushIcons { GP_BRUSH_ICON_ERASE_STROKE = 10, } eGP_BrushIcons; +typedef enum eBrushCurvePreset { + BRUSH_CURVE_CUSTOM = 0, + BRUSH_CURVE_SMOOTH = 1, + BRUSH_CURVE_SPHERE = 2, + BRUSH_CURVE_ROOT = 3, + BRUSH_CURVE_SHARP = 4, + BRUSH_CURVE_LIN = 5, + BRUSH_CURVE_POW4 = 6, + BRUSH_CURVE_INVSQUARE = 7, + BRUSH_CURVE_CONSTANT = 8, +} eBrushCurvePreset; + typedef struct Brush { ID id; @@ -289,6 +301,9 @@ typedef struct Brush { float texture_sample_bias; + int curve_preset; + char _pad1[4]; + /* overlay */ int texture_overlay_alpha; int mask_overlay_alpha; diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index b613c661f29..eda52fdf14a 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -149,7 +149,7 @@ typedef struct bPythonConstraint { */ struct Object *tar; /** - * Subtarger from previous implementation + * Subtarget from previous implementation * (version-patch sets this to "" on file-load), MAX_ID_NAME-2. */ char subtarget[64]; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 75a417150c8..14a078d8386 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -42,13 +42,13 @@ typedef struct CustomDataLayer { int flag; /** Number of the active layer of this type. */ int active; - /** Number of the layer to rende.r*/ + /** Number of the layer to render. */ int active_rnd; - /** Number of the layer to rende.r*/ + /** Number of the layer to render. */ int active_clone; - /** Number of the layer to rende.r*/ + /** Number of the layer to render. */ int active_mask; - /** Shape keyblock unique id referenc.e*/ + /** Shape keyblock unique id reference. */ int uid; /** Layer name, MAX_CUSTOMDATA_LAYER_NAME. */ char name[64]; diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index c2a9d3cf296..47347753f42 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -90,16 +90,10 @@ typedef struct NoiseGpencilModifierData { float factor; /** How many frames before recalculate randoms. */ int step; - /** Last gp frame used. */ - int gp_frame; - /** First scene frame used. */ - int scene_frame; - /** Random values. */ - float vrand1, vrand2; - struct RNG *rng; /** Custom index for passes. */ int layer_pass; - char _pad[4]; + /** Random seed */ + int seed; } NoiseGpencilModifierData; typedef enum eNoiseGpencil_Flag { diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 9134e603a87..bf72ce5e598 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -148,8 +148,7 @@ typedef struct bGPDpalette { /* bGPDpalette->flag */ typedef enum eGPDpalette_Flag { /* palette is active */ - A, - PL_PALETTE_ACTIVE = (1 << 0) + PL_PALETTE_ACTIVE = (1 << 0), } eGPDpalette_Flag; /* ***************************************** */ diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h index 5cae3c0b1e9..6ffdd60a094 100644 --- a/source/blender/makesdna/DNA_lightprobe_types.h +++ b/source/blender/makesdna/DNA_lightprobe_types.h @@ -142,7 +142,7 @@ typedef struct LightGridCache { float visibility_bias, visibility_bleed, visibility_range, _pad5; } LightGridCache; -/* Theses are used as ubo data. They need to be aligned to size of vec4. */ +/* These are used as ubo data. They need to be aligned to size of vec4. */ BLI_STATIC_ASSERT_ALIGN(LightProbeCache, 16) BLI_STATIC_ASSERT_ALIGN(LightGridCache, 16) diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 672dbaebae1..75c0721f72a 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -387,12 +387,12 @@ typedef struct bNodeLink { #define NTREE_QUALITY_LOW 2 /* tree->chunksize */ -#define NTREE_CHUNCKSIZE_32 32 -#define NTREE_CHUNCKSIZE_64 64 -#define NTREE_CHUNCKSIZE_128 128 -#define NTREE_CHUNCKSIZE_256 256 -#define NTREE_CHUNCKSIZE_512 512 -#define NTREE_CHUNCKSIZE_1024 1024 +#define NTREE_CHUNKSIZE_32 32 +#define NTREE_CHUNKSIZE_64 64 +#define NTREE_CHUNKSIZE_128 128 +#define NTREE_CHUNKSIZE_256 256 +#define NTREE_CHUNKSIZE_512 512 +#define NTREE_CHUNKSIZE_1024 1024 /* the basis for a Node tree, all links and nodes reside internal here */ /* only re-usable node trees are in the library though, diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 13b7a0a7600..d9487f4338f 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -177,7 +177,7 @@ typedef struct Object_Runtime { /** Runtime grease pencil drawing data */ struct GpencilBatchCache *gpencil_cache; - void *_pad2; /* Padding is here for win32s unconventional stuct alignment rules. */ + void *_pad2; /* Padding is here for win32s unconventional struct alignment rules. */ } Object_Runtime; typedef struct Object { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 0973405ce7b..f0ca4e30cdf 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1116,7 +1116,7 @@ typedef struct GP_Sculpt_Settings { char _pad[4]; /** Multiframe edit falloff effect by frame. */ struct CurveMapping *cur_falloff; - /** Curve used for primitve tools. */ + /** Curve used for primitive tools. */ struct CurveMapping *cur_primitive; /** Guides used for paint tools */ struct GP_Sculpt_Guide guide; @@ -1138,7 +1138,7 @@ typedef enum eGP_Sculpt_SettingsFlag { GP_SCULPT_SETT_FLAG_FRAME_FALLOFF = (1 << 5), /* apply brush to uv data */ GP_SCULPT_SETT_FLAG_APPLY_UV = (1 << 6), - /* apply primitve curve */ + /* apply primitive curve */ GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE = (1 << 7), } eGP_Sculpt_SettingsFlag; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 894dbc05c54..2d3d091c65d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -756,8 +756,9 @@ typedef struct UserDef { char font_path_ui[1024]; char font_path_ui_mono[1024]; + /** Legacy, for backwards compatibility only. */ int compute_device_type; - int compute_device_id; + char _pad6[4]; /** Opacity of inactive F-Curves in F-Curve Editor. */ float fcu_inactive_alpha; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 3cc005535b6..5252c8f3350 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -899,7 +899,7 @@ static void cast_elem( * as lookup keys to identify data blocks in the saved .blend file, not * as actual in-memory pointers. * - * \param curlen: Pointer length to conver to + * \param curlen: Pointer length to convert to * \param oldlen: Length of pointers in olddata * \param name_array_len: Result of #DNA_elem_array_size for this element. * \param curdata: Where to put converted data diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index fb60f092d16..eeba7161309 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1565,6 +1565,19 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem brush_curve_preset_items[] = { + {BRUSH_CURVE_CUSTOM, "CUSTOM", ICON_RNDCURVE, "Custom", ""}, + {BRUSH_CURVE_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, + {BRUSH_CURVE_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", ""}, + {BRUSH_CURVE_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, + {BRUSH_CURVE_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, + {BRUSH_CURVE_LIN, "LIN", ICON_LINCURVE, "Linear", ""}, + {BRUSH_CURVE_POW4, "POW4", ICON_SHARPCURVE, "Sharper", ""}, + {BRUSH_CURVE_INVSQUARE, "INVSQUARE", ICON_INVERSESQUARECURVE, "Inverse square", ""}, + {BRUSH_CURVE_CONSTANT, "CONSTANT", ICON_NOCURVE, "Constant", ""}, + {0, NULL, 0, NULL, NULL}, + }; + srna = RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text( srna, "Brush", "Brush data-block for storing brush settings for painting and sculpting"); @@ -1640,6 +1653,11 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mask Tool", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "curve_preset", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, brush_curve_preset_items); + RNA_def_property_ui_text(prop, "Curve Preset", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + /* number values */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 9986b4c1674..735cd1fd923 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -211,7 +211,7 @@ static struct Depsgraph *rna_Context_evaluated_depsgraph_get(bContext *C) BPy_BEGIN_ALLOW_THREADS; # endif - depsgraph = CTX_data_evaluated_depsgraph(C); + depsgraph = CTX_data_ensure_evaluated_depsgraph(C); # ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index df1727ff87c..ebd9bd8e925 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -346,7 +346,7 @@ static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *) iter->internal.custom; - /* We need to copy current iterator status to next one beeing worked on. */ + /* We need to copy current iterator status to next one being worked on. */ di_it->iterators[(di_it->counter + 1) % 2] = di_it->iterators[di_it->counter % 2]; di_it->deg_data[(di_it->counter + 1) % 2] = di_it->deg_data[di_it->counter % 2]; di_it->counter++; diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 2b89225d34d..754c443e7e6 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -377,6 +377,10 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Random", "Use random values"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Seed", "Random seed"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "use_edit_position", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_LOCATION); RNA_def_property_ui_text( diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index d6f4d82c298..75867b2fe13 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -700,7 +700,7 @@ static void rna_def_image(BlenderRNA *brna) "PREMUL", 0, "Premultiplied", - "Store RGB channels with alpha multipled in, also known as associated alpha. The natural " + "Store RGB channels with alpha multiplied in, also known as associated alpha. The natural " "format for renders and used by file formats like OpenEXR"}, {IMA_ALPHA_CHANNEL_PACKED, "CHANNEL_PACKED", diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 1c0ced060d5..c9b51707759 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -178,8 +178,8 @@ static void rna_ViewLayer_update_tagged(ID *id_ptr, ViewLayer *view_layer, Main Scene *scene = (Scene *)id_ptr; Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); - /* NOTE: This is similar to CTX_data_depsgraph(). Ideally such access would be de-duplicated - * across all possible cases, but for now this is safest and easiest way to go. + /* NOTE: This is similar to CTX_data_depsgraph_pointer(). Ideally such access would be + * de-duplicated across all possible cases, but for now this is safest and easiest way to go. * * The reason for this is that it's possible to have Python operator which asks view layer to * be updated. After re-do of such operator view layer's dependency graph will not be marked diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 28989d1dd5f..162ba6be834 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -147,16 +147,8 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Material *ma = ptr->id.data; if (ma->use_nodes && ma->nodetree) { - struct bNode *node; - int index = 0; - for (node = ma->nodetree->nodes.first; node; node = node->next) { - if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && - node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { - if (index++ == ma->paint_active_slot) { - break; - } - } - } + struct bNode *node = BKE_texpaint_slot_material_find_node(ma, ma->paint_active_slot); + if (node) { nodeSetActive(ma->nodetree, node); } diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index d647c647136..283590fc529 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -202,6 +202,14 @@ static void rna_Mesh_count_selected_items(Mesh *mesh, int r_count[3]) BKE_mesh_count_selected_items(mesh, r_count); } +static void rna_Mesh_clear_geometry(Mesh *mesh) +{ + BKE_mesh_clear_geometry(mesh); + + DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY); + WM_main_add_notifier(NC_GEOM | ND_DATA, mesh); +} + #else void RNA_api_mesh(StructRNA *srna) @@ -319,6 +327,11 @@ void RNA_api_mesh(StructRNA *srna) func, "result", "nothing", 64, "Return value", "String description of result of comparison"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "clear_geometry", "rna_Mesh_clear_geometry"); + RNA_def_function_ui_description( + func, + "Remove all geometry from the mesh. Note that this does not free shape keys or materials"); + func = RNA_def_function(srna, "validate", "BKE_mesh_validate"); RNA_def_function_ui_description(func, "Validate geometry, return True when the mesh has had " diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 6cd4be81a56..7e1ff01a7c3 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1114,8 +1114,6 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( return rna_enum_dt_layers_select_src_items; } - Depsgraph *depsgraph = CTX_data_depsgraph(C); - /* No active here! */ RNA_enum_items_add_value( &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC); @@ -1155,6 +1153,7 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -1180,6 +1179,7 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -5668,7 +5668,8 @@ static void rna_def_modifier_datatransfer(BlenderRNA *brna) 0.0f, 1.0f, "Mix Factor", - "Factor to use when applying data to destination (exact behavior depends on mix mode)", + "Factor to use when applying data to destination (exact behavior depends on mix mode, " + "multiplied with weights from vertex group when defined)", 0.0f, 1.0f); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index eec280a5f3e..b28403bf28c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -89,12 +89,12 @@ static const EnumPropertyItem node_quality_items[] = { }; static const EnumPropertyItem node_chunksize_items[] = { - {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, - {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, - {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, - {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, - {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, - {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, + {NTREE_CHUNKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, + {NTREE_CHUNKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, + {NTREE_CHUNKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, + {NTREE_CHUNKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, + {NTREE_CHUNKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, + {NTREE_CHUNKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, {0, NULL, 0, NULL, NULL}, }; #endif diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 7fa1544d809..6069e78d874 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2537,7 +2537,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_array(prop, 3); - /* Only as convinient helper for py API, and conflicts with animating scale. */ + /* Only as convenient helper for py API, and conflicts with animating scale. */ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_float_funcs( prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL); @@ -2546,7 +2546,7 @@ static void rna_def_object(BlenderRNA *brna) prop, "Dimensions", "Absolute bounding box dimensions of the object (WARNING: assigning to it or " - "its members mutiple consecutive times will not work correctly, " + "its members multiple consecutive times will not work correctly, " "as this needs up-to-date evaluated data)"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index c91481931a2..9a76885a19d 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -465,6 +465,8 @@ static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt) return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; } +/* TOOD(sergey): Make the Python API more clear that evaluation might happen, or requite passing + * fully evaluated depsgraph. */ static Object *eval_object_ensure(Object *ob, bContext *C, ReportList *reports, @@ -474,7 +476,7 @@ static Object *eval_object_ensure(Object *ob, Object *ob_orig = ob; Depsgraph *depsgraph = rnaptr_depsgraph != NULL ? rnaptr_depsgraph->data : NULL; if (depsgraph == NULL) { - depsgraph = CTX_data_depsgraph(C); + depsgraph = CTX_data_ensure_evaluated_depsgraph(C); } if (depsgraph != NULL) { ob = DEG_get_evaluated_object(depsgraph, ob); @@ -502,6 +504,8 @@ static void rna_Object_ray_cast(Object *ob, { bool success = false; + /* TODO(sergey): This isn't very reliable check. It is possible to have non-NULL pointer but + * which is out of date, and possibly dangling one. */ if (ob->runtime.mesh_eval == NULL && (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { return; @@ -972,7 +976,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); /* return location and normal */ - parm = RNA_def_boolean(func, "result", 0, "", "Wheter the ray successfully hit the geometry"); + parm = RNA_def_boolean(func, "result", 0, "", "Whether the ray successfully hit the geometry"); RNA_def_function_output(func, parm); parm = RNA_def_float_vector(func, "location", @@ -1035,7 +1039,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); /* return location and normal */ - parm = RNA_def_boolean(func, "result", 0, "", "Wheter closest point on geometry was found"); + parm = RNA_def_boolean(func, "result", 0, "", "Whether closest point on geometry was found"); RNA_def_function_output(func, parm); parm = RNA_def_float_vector(func, "location", @@ -1109,7 +1113,7 @@ void RNA_api_object(StructRNA *srna) "(only needed if current Context's depsgraph is not suitable)"); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); /* weak!, no way to return dynamic string type */ - parm = RNA_def_string(func, "result", NULL, 16384, "", "Requested informations"); + parm = RNA_def_string(func, "result", NULL, 16384, "", "Requested information"); RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */ RNA_def_function_output(func, parm); # endif /* NDEBUG */ diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 9834520f952..3ca4792f9b4 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -3077,7 +3077,7 @@ void RNA_def_rna(BlenderRNA *brna) /* FloatProperty */ srna = RNA_def_struct(brna, "FloatProperty", "Property"); RNA_def_struct_ui_text( - srna, "Float Definition", "RNA floating pointer number property definition"); + srna, "Float Definition", "RNA floating point number (single precision) property definition"); rna_def_number_property(srna, PROP_FLOAT); /* StringProperty */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index dcbbdd67d7b..fd8791cf193 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5171,6 +5171,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {FFMPEG_OGG, "OGG", 0, "Ogg", ""}, {FFMPEG_MKV, "MKV", 0, "Matroska", ""}, {FFMPEG_FLV, "FLASH", 0, "Flash", ""}, + {FFMPEG_WEBM, "WEBM", 0, "WebM", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -5229,6 +5230,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {AV_CODEC_ID_FLAC, "FLAC", 0, "FLAC", ""}, {AV_CODEC_ID_MP2, "MP2", 0, "MP2", ""}, {AV_CODEC_ID_MP3, "MP3", 0, "MP3", ""}, + {AV_CODEC_ID_OPUS, "OPUS", 0, "Opus", ""}, {AV_CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""}, {AV_CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""}, {0, NULL, 0, NULL, NULL}, diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 241764ff9a6..b54fdf5aadb 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -161,7 +161,7 @@ static void rna_Sequence_use_sequence(Main *bmain, Scene *scene, PointerRNA *ptr { /* General update callback. */ rna_Sequence_invalidate_raw_update(bmain, scene, ptr); - /* Chaning recursion changes set of IDs which needs to be remapped by the copy-on-write. + /* Changing recursion changes set of IDs which needs to be remapped by the copy-on-write. * the only way for this currently is to tag the ID for ID_RECALC_COPY_ON_WRITE. */ Editing *ed = BKE_sequencer_editing_get(scene, false); if (ed) { diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 83e4766c57d..84bde91e654 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1066,7 +1066,7 @@ static void rna_def_trackingSettings(BlenderRNA *brna) prop, "Normalize", "Normalize light intensities while tracking (slower)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); - /* default minmal correlation */ + /* default minimal correlation */ prop = RNA_def_property(srna, "default_correlation_min", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 8a9b8a14563..7b7d9e71cd2 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -5112,13 +5112,18 @@ static void rna_def_userdef_input(BlenderRNA *brna) "CONTINUE", 0, "Continue", - "Old style zoom, continues while moving mouse up or down"}, - {USER_ZOOM_DOLLY, "DOLLY", 0, "Dolly", "Zoom in and out based on vertical mouse movement"}, + "Continuous zooming. The zoom direction and speed depends on how far along the set Zoom " + "Axis the mouse has moved"}, + {USER_ZOOM_DOLLY, + "DOLLY", + 0, + "Dolly", + "Zoom in and out based on mouse movement along the set Zoom Axis"}, {USER_ZOOM_SCALE, "SCALE", 0, "Scale", - "Zoom in and out like scaling the view, mouse movements relative to center"}, + "Zoom in and out as if you are scaling the view, mouse movements relative to center"}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 705ffb266c5..3df66855376 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -523,7 +523,7 @@ static void calc_deltas(CorrectiveSmoothModifierData *csmd, MEM_SAFE_FREE(csmd->delta_cache); } - /* allocate deltas if they have not yet been allocated, otheriwse we will just write over them */ + /* allocate deltas if they have not yet been allocated, otherwise we will just write over them */ if (!csmd->delta_cache) { csmd->delta_cache_num = numVerts; csmd->delta_cache = MEM_malloc_arrayN(numVerts, sizeof(float[3]), __func__); diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 3235d64cbbb..c994a680fb0 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -158,7 +158,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes Mesh *result = me_mod; ReportList reports; - /* Only used to check wehther we are operating on org data or not... */ + /* Only used to check whether we are operating on org data or not... */ Mesh *me = ctx->object->data; Object *ob_source = dtmd->ob_source; diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index b6ab3f5b4fe..1a541f9fc5a 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -864,7 +864,7 @@ static Mesh *subdivide_base(Mesh *orig) } /* Per edge, store how many subdivisions are needed */ - edge_subd = MEM_calloc_arrayN(totorigedge, sizeof(int), "edge_subd"); + edge_subd = MEM_calloc_arrayN((uint)totorigedge, sizeof(int), "edge_subd"); for (i = 0, totsubd = 0; i < totorigedge; i++) { edge_subd[i] += calc_edge_subdivisions(origvert, orignode, &origedge[i], degree); BLI_assert(edge_subd[i] >= 0); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index d47cf72f086..e4fa7fbc757 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -23,7 +23,7 @@ #include "node_composite_util.h" -/* ******************* Color Spill Supression ********************************* */ +/* ******************* Color Spill Suppression ********************************* */ static bNodeSocketTemplate cmp_node_color_spill_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index a22835ba85b..0736496a24f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -60,7 +60,7 @@ void register_node_type_cmp_group(void) void register_node_type_cmp_custom_group(bNodeType *ntype) { - /* These methods can be overriden but need a default implementation otherwise. */ + /* These methods can be overridden but need a default implementation otherwise. */ if (ntype->poll == NULL) { ntype->poll = cmp_node_poll_default; } diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c index 8d05c18621f..dcd8589cfdd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c @@ -63,7 +63,7 @@ static void cryptomatte_add(NodeCryptomatte *n, float f) ++start; } - /* Find the next seprator. */ + /* Find the next separator. */ char *token_end = strchr(n->matte_id + start, ','); if (token_end == NULL || token_end == n->matte_id + start) { token_end = n->matte_id + end; @@ -142,7 +142,7 @@ static void cryptomatte_remove(NodeCryptomatte *n, float f) ++start; } - /* Find the next seprator. */ + /* Find the next separator. */ char *token_end = strchr(n->matte_id + start + 1, ','); if (token_end == NULL || token_end == n->matte_id + start) { token_end = n->matte_id + end; diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c index f1f44d07084..497c2555d86 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c +++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c @@ -39,7 +39,7 @@ static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node) nbd->fac = 1.0f; } -/* custom1: itterations, custom2: maxspeed (0 = nolimit) */ +/* custom1: iterations, custom2: maxspeed (0 = nolimit) */ void register_node_type_cmp_vecblur(void) { static bNodeType ntype; diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 92b24d40b0d..4891fb323ad 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -782,7 +782,7 @@ static void ntree_shader_relink_displacement(bNodeTree *ntree, bNode *output_nod return; } - /* Copy the whole displacement branch to avoid cyclic dependancy + /* Copy the whole displacement branch to avoid cyclic dependency * and issue when bypassing bump nodes. */ ntree_shader_copy_branch_displacement( ntree, displacement_node, displacement_socket, displacement_link); diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index ec1bb988c1c..c92ae28f2e6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -42,7 +42,7 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, { NodeShaderAttribute *attr = node->storage; - /* FIXME : if an attribute layer (like vertex color) has one of theses name, + /* FIXME : if an attribute layer (like vertex color) has one of these names, * it will not work as expected. */ if (strcmp(attr->name, "density") == 0) { return GPU_stack_link( diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index cee4d2505b2..10f6aadbc5f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -254,7 +254,7 @@ void register_node_type_sh_group(void) void register_node_type_sh_custom_group(bNodeType *ntype) { - /* These methods can be overriden but need a default implementation otherwise. */ + /* These methods can be overridden but need a default implementation otherwise. */ if (ntype->poll == NULL) { ntype->poll = sh_node_poll_default; } diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index bc404110008..95c16c2f033 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -393,7 +393,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) if (s->type & CLOTH_SPRING_TYPE_SEWING) { /* TODO: verify, half verified (couldn't see error) * sewing springs usually have a large distance at first so clamp the force so we don't get - * tunnelling through colission objects */ + * tunnelling through collision objects. */ BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index a9e65413767..f147b7de01d 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -214,7 +214,7 @@ PyDoc_STRVAR(bpygpu_Batch_draw_doc, " Run the drawing program with the parameters assigned to the batch.\n" "\n" " :param program: Program that performs the drawing operations.\n" - " If ``None`` is passed, the last program setted to this batch will run.\n" + " If ``None`` is passed, the last program set to this batch will run.\n" " :type program: :class:`gpu.types.GPUShader`\n"); static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args) { diff --git a/source/blender/python/gpu/gpu_py_vertex_format.c b/source/blender/python/gpu/gpu_py_vertex_format.c index 34df4cb1a4b..d8266be7e2c 100644 --- a/source/blender/python/gpu/gpu_py_vertex_format.c +++ b/source/blender/python/gpu/gpu_py_vertex_format.c @@ -114,7 +114,7 @@ static int bpygpu_ParseVertCompType(PyObject *o, void *p) int comp_type = bpygpu_parse_component_type(str, length); if (comp_type == -1) { - PyErr_Format(PyExc_ValueError, "unkown component type: '%s", str); + PyErr_Format(PyExc_ValueError, "unknown component type: '%s", str); return 0; } @@ -188,7 +188,7 @@ static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *ar } params; if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) { - PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN)); + PyErr_SetString(PyExc_ValueError, "Maximum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN)); return NULL; } diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index b8a83d0588d..8c34699b598 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -386,7 +386,7 @@ void BPy_init_modules(void) Py_DECREF(py_modpath); } else { - printf("bpy: couldnt find 'scripts/modules', blender probably wont start.\n"); + printf("bpy: couldn't find 'scripts/modules', blender probably wont start.\n"); } /* stand alone utility modules not related to blender directly */ IDProp_Init_Types(); /* not actually a submodule, just types */ diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index 1c48dc1baae..4a43d4e6853 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -36,7 +36,7 @@ static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyOb /* close down enough of blender at least not to crash */ struct bContext *C = BPy_GetContext(); - WM_exit_ext(C, 0); + WM_exit_ex(C, false); Py_RETURN_NONE; } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index ad7d5137ebc..50c61dd0061 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -2566,8 +2566,8 @@ PyDoc_STRVAR(BPy_FloatProperty_doc, ".. function:: FloatProperty(name=\"\", " "description=\"\", " "default=0.0, " - "min=sys.float_info.min, max=sys.float_info.max, " - "soft_min=sys.float_info.min, soft_max=sys.float_info.max, " + "min=-3.402823e+38, max=3.402823e+38, " + "soft_min=-3.402823e+38, soft_max=3.402823e+38, " "step=3, " "precision=2, " "options={'ANIMATABLE'}, " @@ -2578,7 +2578,7 @@ PyDoc_STRVAR(BPy_FloatProperty_doc, "get=None, " "set=None)\n" "\n" - " Returns a new float property definition.\n" + " Returns a new float (single precision) property definition.\n" "\n" BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC BPY_PROPDEF_NUM_MIN_DOC " :type min: float\n" BPY_PROPDEF_NUM_MAX_DOC " :type max: float\n" BPY_PROPDEF_NUM_SOFTMIN_DOC @@ -2968,7 +2968,7 @@ PyDoc_STRVAR( " The first three elements of the tuples are mandatory.\n" "\n" " :identifier: The identifier is used for Python access.\n" - " :name: Name for the interace.\n" + " :name: Name for the interface.\n" " :description: Used for documentation and tooltips.\n" " :icon: An icon string identifier or integer icon value\n" " (e.g. returned by :class:`bpy.types.UILayout.icon`)\n" diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 734e929fdf4..9a8d8c5ec21 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1857,7 +1857,7 @@ static int pyrna_py_to_prop( else { /* Same as bytes. */ /* XXX, this is suspect, but needed for function calls, - * need to see if theres a better way. */ + * need to see if there's a better way. */ if (data) { *((char **)data) = (char *)param; } diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 710ae0433e0..fb9454bf108 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -301,7 +301,7 @@ char pyrna_struct_keyframe_insert_doc[] = " - ``INSERTKEY_VISUAL`` Insert keyframes based on 'visual transforms'.\n" " - ``INSERTKEY_XYZ_TO_RGB`` Color for newly added transformation F-Curves (Location, " "Rotation, Scale) is based on the transform axis.\n" - " - ``INSERTKEY_REPLACE`` Only replace already exising keyframes.\n" + " - ``INSERTKEY_REPLACE`` Only replace already existing keyframes.\n" " - ``INSERTKEY_AVAILABLE`` Only insert into already existing F-Curves.\n" " - ``INSERTKEY_CYCLE_AWARE`` Take cyclic extrapolation into account " "(Cycle-Aware Keying option).\n" @@ -337,7 +337,6 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb * strips themselves. These are stored separately or else the properties will * not have any effect. */ - struct Depsgraph *depsgraph = CTX_data_depsgraph(BPy_GetContext()); ReportList reports; short result = 0; @@ -357,8 +356,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb NlaStrip *strip = (NlaStrip *)ptr.data; FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index); - result = insert_keyframe_direct( - depsgraph, &reports, ptr, prop, fcu, cfra, keytype, NULL, options); + result = insert_keyframe_direct(&reports, ptr, prop, fcu, cfra, keytype, NULL, options); } else { BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full); @@ -373,25 +371,14 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb } else { ID *id = self->ptr.id.data; - struct Depsgraph *depsgraph = CTX_data_depsgraph(BPy_GetContext()); ReportList reports; short result; BKE_reports_init(&reports, RPT_STORE); BLI_assert(BKE_id_is_in_global_main(id)); - result = insert_keyframe(G_MAIN, - depsgraph, - &reports, - id, - NULL, - group_name, - path_full, - index, - cfra, - keytype, - NULL, - options); + result = insert_keyframe( + G_MAIN, &reports, id, NULL, group_name, path_full, index, cfra, keytype, NULL, options); MEM_freeN((void *)path_full); if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 2c9a25d24bc..1f17d1eebf2 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -47,7 +47,7 @@ static PyObject *Vector_copy(VectorObject *self); static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args); -static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits); +static PyObject *Vector_to_tuple_ex(VectorObject *self, int ndigits); static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *vec, MatrixObject *mat); @@ -630,7 +630,7 @@ PyDoc_STRVAR(Vector_to_tuple_doc, " :return: the values of the vector rounded by *precision*\n" " :rtype: tuple\n"); /* note: BaseMath_ReadCallback must be called beforehand */ -static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) +static PyObject *Vector_to_tuple_ex(VectorObject *self, int ndigits) { PyObject *ret; int i; @@ -674,7 +674,7 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) return NULL; } - return Vector_to_tuple_ext(self, ndigits); + return Vector_to_tuple_ex(self, ndigits); } PyDoc_STRVAR(Vector_to_track_quat_doc, @@ -1338,7 +1338,7 @@ static PyObject *Vector_repr(VectorObject *self) return NULL; } - tuple = Vector_to_tuple_ext(self, -1); + tuple = Vector_to_tuple_ex(self, -1); ret = PyUnicode_FromFormat("Vector(%R)", tuple); Py_DECREF(tuple); return ret; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index ee39ba4c92f..8764671ae04 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2566,7 +2566,7 @@ void RE_RenderAnim(Render *re, for (nfra = sfra, scene->r.cfra = sfra; scene->r.cfra <= efra; scene->r.cfra++) { char name[FILE_MAX]; - /* Here is a feedback loop exists -- render initialization requires updated + /* A feedback loop exists here -- render initialization requires updated * render layers settings which could be animated, but scene evaluation for * the frame happens later because it depends on what layers are visible to * render engine. @@ -2580,12 +2580,7 @@ void RE_RenderAnim(Render *re, { float ctime = BKE_scene_frame_get(scene); AnimData *adt = BKE_animdata_from_id(&scene->id); - /* TODO(sergey): Currently depsgraph is only used to check whether it is an active - * edit window or not to deal with unkeyed changes. We don't have depsgraph here yet, - * but we also dont' deal with unkeyed changes. But still nice to get proper depsgraph - * within tjhe render pipeline, somehow. - */ - BKE_animsys_evaluate_animdata(NULL, scene, &scene->id, adt, ctime, ADT_RECALC_ALL); + BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, ADT_RECALC_ALL, false); } render_update_depsgraph(re); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 63c6245ced5..75ddf7e0b22 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -792,7 +792,7 @@ static void particle_system_minmax(Depsgraph *depsgraph, INIT_MINMAX(min, max); if (part->type == PART_HAIR) { - /* TOOD(sergey): Not supported currently. */ + /* TODO(sergey): Not supported currently. */ return; } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 6fc73268a38..76ab06e0020 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -93,7 +93,7 @@ void WM_init_native_pixels(bool do_it); void WM_init_tablet_api(void); void WM_init(struct bContext *C, int argc, const char **argv); -void WM_exit_ext(struct bContext *C, const bool do_python); +void WM_exit_ex(struct bContext *C, const bool do_python); void WM_exit(struct bContext *C) ATTR_NORETURN; @@ -571,8 +571,8 @@ bool WM_menutype_poll(struct bContext *C, struct MenuType *mt); void WM_paneltype_init(void); void WM_paneltype_clear(void); struct PanelType *WM_paneltype_find(const char *idname, bool quiet); -bool WM_paneltype_add(struct PanelType *mt); -void WM_paneltype_remove(struct PanelType *mt); +bool WM_paneltype_add(struct PanelType *pt); +void WM_paneltype_remove(struct PanelType *pt); /* wm_gesture_ops.c */ int WM_gesture_box_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a0c7e8ef752..195822efd7e 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -180,8 +180,6 @@ enum { OPTYPE_LOCK_BYPASS = (1 << 9), /** Special type of undo which doesn't store itself multiple times. */ OPTYPE_UNDO_GROUPED = (1 << 10), - /** Need evaluated data (i.e. a valid, up-to-date depsgraph for current context). */ - OPTYPE_USE_EVAL_DATA = (1 << 11), }; /** For #WM_cursor_grab_enable wrap axis. */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index ee96515c27f..ef4d8174718 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -540,6 +540,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); rcti rect; /* Almost certainly overkill, but allow for many custom gizmos. */ GLuint buffer[MAXPICKBUF]; @@ -548,7 +549,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, BLI_rcti_init_pt_radius(&rect, co, hotspot); ED_view3d_draw_setup_view( - CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); + CTX_wm_window(C), depsgraph, CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); bool use_select_bias = false; @@ -568,7 +569,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, } ED_view3d_draw_setup_view( - CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); + CTX_wm_window(C), depsgraph, CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); if (use_select_bias && (hits > 1)) { float co_direction[3]; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 76cb78b1e04..cea2f127b3e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -495,7 +495,7 @@ void wm_event_do_notifiers(bContext *C) * twice which can depgraph update the same object at once */ if (G.is_rendering == false) { /* depsgraph gets called, might send more notifiers */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); ED_update_for_newframe(CTX_data_main(C), depsgraph); } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 3e965fc2f55..10773cf58e1 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -353,7 +353,7 @@ static void wm_window_match_do(bContext *C, } /* in case UserDef was read, we re-initialize all, and do versioning */ -static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory) +static void wm_init_userdef(Main *bmain) { /* versioning is here */ UI_init_userdef(bmain); @@ -367,11 +367,6 @@ static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory) SET_FLAG_FROM_TEST(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_FLAG_SCRIPT_AUTOEXEC); } - /* avoid re-saving for every small change to our prefs, allow overrides */ - if (read_userdef_from_memory) { - BLO_update_defaults_userpref_blend(); - } - MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024); BKE_sound_init(bmain); @@ -787,16 +782,6 @@ void wm_homefile_read(bContext *C, * '{BLENDER_SYSTEM_SCRIPTS}/startup/bl_app_templates_system/{app_template}' */ char app_template_config[FILE_MAX]; - /* Indicates whether user preferences were really load from memory. - * - * This is used for versioning code, and for this we can not rely on use_factory_settings - * passed via argument. This is because there might be configuration folder - * exists but it might not have userpref.blend and in this case we fallback to - * reading home file from memory. - * - * And in this case versioning code is to be run. - */ - bool read_userdef_from_memory = false; eBLOReadSkip skip_flags = 0; if (use_data == false) { @@ -936,7 +921,7 @@ void wm_homefile_read(bContext *C, filepath_startup, &(const struct BlendFileReadParams){ .is_startup = true, - .skip_flags = skip_flags, + .skip_flags = skip_flags | BLO_READ_SKIP_USERDEF, }, NULL); } @@ -963,6 +948,14 @@ void wm_homefile_read(bContext *C, } if (success == false) { + if (use_userdef) { + if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) { + UserDef *userdef_default = BKE_blendfile_userdef_from_defaults(); + BKE_blender_userdef_data_set_and_free(userdef_default); + skip_flags |= BLO_READ_SKIP_USERDEF; + } + } + success = BKE_blendfile_read_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, @@ -972,13 +965,7 @@ void wm_homefile_read(bContext *C, .skip_flags = skip_flags, }, NULL); - if (success) { - if (use_userdef) { - if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) { - read_userdef_from_memory = true; - } - } - } + if (use_data && BLI_listbase_is_empty(&wmbase)) { wm_clear_default_size(C); } @@ -1015,9 +1002,7 @@ void wm_homefile_read(bContext *C, } if (userdef_template == NULL) { /* we need to have preferences load to overwrite preferences from previous template */ - userdef_template = BKE_blendfile_userdef_read_from_memory( - datatoc_startup_blend, datatoc_startup_blend_size, NULL); - read_userdef_from_memory = true; + userdef_template = BKE_blendfile_userdef_from_defaults(); } if (userdef_template) { BKE_blender_userdef_app_template_data_set_and_free(userdef_template); @@ -1041,7 +1026,7 @@ void wm_homefile_read(bContext *C, if (use_userdef) { /* check userdef before open window, keymaps etc */ - wm_init_userdef(bmain, read_userdef_from_memory); + wm_init_userdef(bmain); reset_app_template = true; } @@ -1244,7 +1229,7 @@ static ImBuf *blend_file_thumb(const bContext *C, } /* gets scaled to BLEN_THUMB_SIZE */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (scene->camera) { ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, @@ -1650,7 +1635,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); - if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) { + if (BLO_write_file(bmain, filepath, fileflags, op->reports, NULL) == 0) { printf("fail\n"); return OPERATOR_CANCELLED; } @@ -1734,7 +1719,7 @@ void WM_OT_save_userpref(wmOperatorType *ot) { ot->name = "Save Preferences"; ot->idname = "WM_OT_save_userpref"; - ot->description = "Save preferences separately, overrides startup file preferences"; + ot->description = "Make the current preferences default"; ot->invoke = WM_operator_confirm; ot->exec = wm_userpref_write_exec; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index df14609d29b..eb3f2125ee7 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -470,7 +470,7 @@ void wm_exit_schedule_delayed(const bContext *C) /** * \note doesn't run exit() call #WM_exit() for that. */ -void WM_exit_ext(bContext *C, const bool do_python) +void WM_exit_ex(bContext *C, const bool do_python) { wmWindowManager *wm = C ? CTX_wm_manager(C) : NULL; @@ -670,7 +670,7 @@ void WM_exit_ext(bContext *C, const bool do_python) */ void WM_exit(bContext *C) { - WM_exit_ext(C, 1); + WM_exit_ex(C, true); printf("\nBlender quit\n"); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index d8ad0582bd8..4e7a7bf96f1 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -463,7 +463,7 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap) if (UNLIKELY(BLI_listbase_is_empty(&keymap->items))) { /* Empty key-maps may be missing more there may be a typo in the name. - * Warn early to avoid loosing time investigating each case. */ + * Warn early to avoid losing time investigating each case. */ CLOG_WARN(WM_LOG_KEYMAPS, "empty keymap '%s'", keymap->idname); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index aded1994c18..114a8e7c1f1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3158,7 +3158,10 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) const int cfra = scene->r.cfra; int a, iter_steps = 0; const char *infostr = ""; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + + /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here. + */ + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); WM_cursor_wait(1); diff --git a/source/creator/creator.c b/source/creator/creator.c index b257564519a..d6e1d7e7f5f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -25,9 +25,6 @@ #include <string.h> #ifdef WIN32 -# if defined(_MSC_VER) && defined(_M_X64) -# include <math.h> /* needed for _set_FMA3_enable */ -# endif # include <windows.h> # include "utfconv.h" #endif @@ -237,12 +234,6 @@ int main(int argc, _putenv_s("OMP_WAIT_POLICY", "PASSIVE"); # endif - /* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM - * (fixed in SP1). Just disable it. */ -# if defined(_MSC_VER) && defined(_M_X64) - _set_FMA3_enable(0); -# endif - /* Win32 Unicode Args */ /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized * (it depends on the args passed in, which is what we're getting here!) @@ -505,7 +496,7 @@ int main(int argc, #ifdef WITH_PYTHON_MODULE void main_python_exit(void) { - WM_exit_ext((bContext *)evil_C, true); + WM_exit_ex((bContext *)evil_C, true); evil_C = NULL; } #endif diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c index 5dae5c5d808..5a5bc74d2d3 100644 --- a/source/creator/creator_signals.c +++ b/source/creator/creator_signals.c @@ -31,9 +31,6 @@ # endif # ifdef WIN32 -# if defined(_MSC_VER) && defined(_M_X64) -# include <math.h> /* needed for _set_FMA3_enable */ -# endif # include <windows.h> # include <float.h> # endif @@ -311,7 +308,7 @@ void main_signal_setup(void) void main_signal_setup_background(void) { - /* for all platforms, even windos has it! */ + /* for all platforms, even windows has it! */ BLI_assert(G.background); # if !defined(WITH_HEADLESS) |