From 039d619c760e1dccdc2d1674c30a300a3a21e312 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 31 Mar 2020 10:26:41 +0200 Subject: Fix T74898: Multiresolution Ghost After Orbiting EEVEE and Workbench both had the same issue that they continue with the last sample when leaving navigating. This is ok for regular meshes as they are all the same. For multiresolution it ain't as a low res version of the mesh is used during navigation. This patch also resets the AA samples when the user leaves navigation. --- source/blender/draw/engines/eevee/eevee_private.h | 1 + source/blender/draw/engines/eevee/eevee_temporal_sampling.c | 4 +++- source/blender/draw/engines/workbench/workbench_data.c | 2 +- .../draw/engines/workbench/workbench_effect_antialiasing.c | 9 ++++++++- source/blender/draw/engines/workbench/workbench_private.h | 1 + source/blender/draw/intern/DRW_render.h | 1 + source/blender/draw/intern/draw_manager.c | 9 +++++++++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index e2470b4fa76..264f301e52c 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -600,6 +600,7 @@ typedef struct EEVEE_EffectsInfo { int taa_total_sample; float taa_alpha; bool prev_drw_support; + bool prev_is_navigating; float prev_drw_persmat[4][4]; struct DRWView *taa_view; /* Ambient Occlusion */ diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index 1f44b815a42..b70d872c4af 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -244,8 +244,10 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data copy_m4_m4(effects->prev_drw_persmat, persmat); /* Prevent ghosting from probe data. */ - view_is_valid = view_is_valid && (effects->prev_drw_support == DRW_state_draw_support()); + view_is_valid = view_is_valid && (effects->prev_drw_support == DRW_state_draw_support()) && + (effects->prev_is_navigating == DRW_state_is_navigating()); effects->prev_drw_support = DRW_state_draw_support(); + effects->prev_is_navigating = DRW_state_is_navigating(); if (((effects->taa_total_sample == 0) || (effects->taa_current_sample < effects->taa_total_sample)) || diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index fc047eadf55..6ef9cbfab57 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -182,7 +182,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) WORKBENCH_ViewLayerData *vldata = workbench_view_layer_data_ensure_ex(draw_ctx->view_layer); wpd->is_playback = DRW_state_is_playback(); - wpd->is_navigating = rv3d && (rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING)); + wpd->is_navigating = DRW_state_is_navigating(); wpd->ctx_mode = CTX_data_mode_enum_ex( draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index a0db09e9273..094d13fb84c 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -168,10 +168,17 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata) wpd->view = NULL; - /* reset complete drawing when navigating or during viewport playback. */ + /* Reset complete drawing when navigating or during viewport playback or when + * leaving one of those states. In case of multires modifier the navigation + * mesh differs from the viewport mesh, so we need to be sure to restart. */ if (wpd->taa_sample != 0) { if (wpd->is_navigating || wpd->is_playback) { wpd->taa_sample = 0; + wpd->reset_next_sample = true; + } + else if (wpd->reset_next_sample) { + wpd->taa_sample = 0; + wpd->reset_next_sample = false; } } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 87b1c82ce94..a5e80f417d3 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -333,6 +333,7 @@ typedef struct WORKBENCH_PrivateData { bool dof_enabled; bool is_playback; bool is_navigating; + bool reset_next_sample; } WORKBENCH_PrivateData; /* Transient data */ typedef struct WORKBENCH_ObjectData { diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 382e7313f21..2d6d6c7d9d0 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -670,6 +670,7 @@ bool DRW_state_do_color_management(void); bool DRW_state_is_scene_render(void); bool DRW_state_is_opengl_render(void); bool DRW_state_is_playback(void); +bool DRW_state_is_navigating(void); bool DRW_state_show_text(void); bool DRW_state_draw_support(void); bool DRW_state_draw_background(void); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index cc618c76ccd..b265035f449 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2574,6 +2574,15 @@ bool DRW_state_is_playback(void) return false; } +/** + * Is the user navigating the region. + */ +bool DRW_state_is_navigating(void) +{ + const RegionView3D *rv3d = DST.draw_ctx.rv3d; + return (rv3d) && (rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING)); +} + /** * Should text draw in this mode? */ -- cgit v1.2.3 From d8217ec6d05af47ae53a0aa8a2584fc8dbe39827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Mar 2020 19:44:47 +1100 Subject: UI: improve names for mesh split operations --- source/blender/editors/mesh/editmesh_tools.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5a04822613e..1a25e582859 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1902,12 +1902,12 @@ void MESH_OT_edge_split(wmOperatorType *ot) /* properties */ static const EnumPropertyItem merge_type_items[] = { - {BM_EDGE, "EDGE", 0, "Edges", "Split along selected edges"}, + {BM_EDGE, "EDGE", 0, "Faces by Edges", "Split faces along selected edges"}, {BM_VERT, "VERT", 0, - "Edges from Vertices", - "Split all edges connected to selected vertices"}, + "Faces & Edges by Vertices", + "Split faces & edges connected to selected vertices"}, {0, NULL, 0, NULL, NULL}, }; -- cgit v1.2.3 From 155f917403b32725a9f9c04ec098964fcbcf0204 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 31 Mar 2020 11:46:19 +0200 Subject: Fix T73513: Facing Overlay Intervene With Selection Do not draw the facing overlay during selection. --- source/blender/draw/engines/overlay/overlay_engine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 97f6b91b7a9..e0b599f43a9 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -241,7 +241,8 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OB_POINTCLOUD, OB_VOLUME); const bool draw_surface = (ob->dt >= OB_WIRE) && (renderable || (ob->dt == OB_WIRE)); - const bool draw_facing = draw_surface && (pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION); + const bool draw_facing = draw_surface && (pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) && + !is_select; const bool draw_bones = (pd->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0; const bool draw_wires = draw_surface && has_surface && (pd->wireframe_mode || !pd->hide_overlays); -- cgit v1.2.3 From b74e38861714be4aa36e2e10fbce8b3b21bb8adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Tue, 31 Mar 2020 12:18:03 +0200 Subject: Fix T75210: Frame range does not go down to 0 in the physics tab for mantaflow when clicking the left arrow Added nore flexibility to cache frame range and ensured validity of frame range. --- source/blender/blenkernel/BKE_fluid.h | 3 +++ source/blender/blenkernel/intern/fluid.c | 10 ++++++++++ source/blender/makesrna/intern/rna_fluid.c | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_fluid.h b/source/blender/blenkernel/BKE_fluid.h index 2c5742d3dc7..e8b4c819c62 100644 --- a/source/blender/blenkernel/BKE_fluid.h +++ b/source/blender/blenkernel/BKE_fluid.h @@ -75,6 +75,9 @@ void BKE_fluid_particle_system_create(struct Main *bmain, const int psys_type); void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_type); +void BKE_fluid_cache_startframe_set(struct FluidDomainSettings *settings, int value); +void BKE_fluid_cache_endframe_set(struct FluidDomainSettings *settings, int value); + void BKE_fluid_cachetype_mesh_set(struct FluidDomainSettings *settings, int cache_mesh_format); void BKE_fluid_cachetype_data_set(struct FluidDomainSettings *settings, int cache_data_format); void BKE_fluid_cachetype_particle_set(struct FluidDomainSettings *settings, diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index b095e6dbeec..8ced4a06c02 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4471,6 +4471,16 @@ void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_typ * Use for versioning, even when fluids are disabled. * \{ */ +void BKE_fluid_cache_startframe_set(FluidDomainSettings *settings, int value) +{ + settings->cache_frame_start = (value > settings->cache_frame_end) ? settings->cache_frame_end : value; +} + +void BKE_fluid_cache_endframe_set(FluidDomainSettings *settings, int value) +{ + settings->cache_frame_end = (value < settings->cache_frame_start) ? settings->cache_frame_start : value; +} + void BKE_fluid_cachetype_mesh_set(FluidDomainSettings *settings, int cache_mesh_format) { if (cache_mesh_format == settings->cache_mesh_format) { diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 9410906595d..e087056e850 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -391,6 +391,18 @@ static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerR } } +static void rna_Fluid_cache_startframe_set(struct PointerRNA *ptr, int value) +{ + FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; + BKE_fluid_cache_startframe_set(settings, value); +} + +static void rna_Fluid_cache_endframe_set(struct PointerRNA *ptr, int value) +{ + FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; + BKE_fluid_cache_endframe_set(settings, value); +} + static void rna_Fluid_cachetype_mesh_set(struct PointerRNA *ptr, int value) { FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; @@ -1925,12 +1937,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "cache_frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_start"); RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); - RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1); + RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_startframe_set", NULL); RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts"); prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_end"); - RNA_def_property_range(prop, 1, MAXFRAME); + RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); + RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_endframe_set", NULL); RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops"); prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME); -- cgit v1.2.3 From 17a409e223a7b72fbfa89c97728017e5afcb54a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Mar 2020 22:20:22 +1100 Subject: Cleanup: use '_recursive' suffix instead of '_rec' This convention isn't very clear and wasn't used much. Use the more verbose term instead. --- source/blender/blenkernel/intern/sequencer.c | 12 ++++++------ source/blender/editors/armature/armature_utils.c | 12 ++++++------ source/blender/editors/armature/pose_transform.c | 17 +++++++++-------- source/blender/editors/space_file/filelist.c | 2 +- source/blender/editors/space_sequencer/sequencer_edit.c | 16 ++++++++-------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9fb28fe250a..3501ac642c5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -752,10 +752,10 @@ static int metaseq_end(Sequence *metaseq) return metaseq->start + metaseq->len - metaseq->endofs; } -static void seq_update_sound_bounds_recursive_rec(Scene *scene, - Sequence *metaseq, - int start, - int end) +static void seq_update_sound_bounds_recursive_impl(Scene *scene, + Sequence *metaseq, + int start, + int end) { Sequence *seq; @@ -763,7 +763,7 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, * since sound is played outside of evaluating the imbufs, */ for (seq = metaseq->seqbase.first; seq; seq = seq->next) { if (seq->type == SEQ_TYPE_META) { - seq_update_sound_bounds_recursive_rec( + seq_update_sound_bounds_recursive_impl( scene, seq, max_ii(start, metaseq_start(seq)), min_ii(end, metaseq_end(seq))); } else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) { @@ -790,7 +790,7 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) { - seq_update_sound_bounds_recursive_rec( + seq_update_sound_bounds_recursive_impl( scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq)); } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 58ceef5b7db..8f63f239abc 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -482,10 +482,10 @@ void ED_armature_edit_transform_mirror_update(Object *obedit) /* Armature EditMode Conversions */ /* converts Bones to EditBone list, used for tools as well */ -static EditBone *make_boneList_rec(ListBase *edbo, - ListBase *bones, - EditBone *parent, - Bone *actBone) +static EditBone *make_boneList_recursive(ListBase *edbo, + ListBase *bones, + EditBone *parent, + Bone *actBone) { EditBone *eBone; EditBone *eBoneAct = NULL; @@ -564,7 +564,7 @@ static EditBone *make_boneList_rec(ListBase *edbo, /* Add children if necessary. */ if (curBone->childbase.first) { - eBoneTest = make_boneList_rec(edbo, &curBone->childbase, eBone, actBone); + eBoneTest = make_boneList_recursive(edbo, &curBone->childbase, eBone, actBone); if (eBoneTest) { eBoneAct = eBoneTest; } @@ -595,7 +595,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone) { BLI_assert(!edbo->first && !edbo->last); - EditBone *active = make_boneList_rec(edbo, bones, NULL, actBone); + EditBone *active = make_boneList_recursive(edbo, bones, NULL, actBone); for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) { Bone *bone = ebone->temp.bone; diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index fe79894a351..3be5e033e00 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -207,12 +207,12 @@ typedef struct ApplyArmature_ParentState { } ApplyArmature_ParentState; /* Recursive walk for Apply To Selected mode; pstate NULL unless child of an applied bone. */ -static void applyarmature_process_selected_rec(bArmature *arm, - bPose *pose, - bPose *pose_eval, - Bone *bone, - ListBase *selected, - ApplyArmature_ParentState *pstate) +static void applyarmature_process_selected_recursive(bArmature *arm, + bPose *pose, + bPose *pose_eval, + Bone *bone, + ListBase *selected, + ApplyArmature_ParentState *pstate) { bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name); const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(pose_eval, bone->name); @@ -334,7 +334,7 @@ static void applyarmature_process_selected_rec(bArmature *arm, } for (Bone *child = bone->childbase.first; child; child = child->next) { - applyarmature_process_selected_rec(arm, pose, pose_eval, child, selected, pstate); + applyarmature_process_selected_recursive(arm, pose, pose_eval, child, selected, pstate); } } @@ -390,7 +390,8 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) if (use_selected) { /* The selected only mode requires a recursive walk to handle parent-child relations. */ for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { - applyarmature_process_selected_rec(arm, pose, ob_eval->pose, bone, &selected_bones, NULL); + applyarmature_process_selected_recursive( + arm, pose, ob_eval->pose, bone, &selected_bones, NULL); } BLI_freelistN(&selected_bones); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index dec38501d38..1396c0a2f69 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2627,7 +2627,7 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const /* Kept for reference here, in case we want to add back that feature later. * We do not need it currently. */ /* Code ***NOT*** updated for job stuff! */ -static void filelist_readjob_main_rec(Main *bmain, FileList *filelist) +static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) { ID *id; FileDirEntry *files, *firstlib = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 71e63547eae..29d8f213d7e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1429,7 +1429,7 @@ static void transseq_restore(TransSeq *ts, Sequence *seq) seq->len = ts->len; } -static int slip_add_sequences_rec( +static int slip_add_sequences_recursive( ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim) { Sequence *seq; @@ -1443,7 +1443,7 @@ static int slip_add_sequences_rec( if (seq->type == SEQ_TYPE_META) { /* trim the sub-sequences */ - num_items += slip_add_sequences_rec( + num_items += slip_add_sequences_recursive( &seq->seqbase, seq_array, trim, num_items + offset, false); } else if (seq->type & SEQ_TYPE_EFFECT) { @@ -1455,7 +1455,7 @@ static int slip_add_sequences_rec( return num_items; } -static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level) +static int slip_count_sequences_recursive(ListBase *seqbasep, bool first_level) { Sequence *seq; int trimmed_sequences = 0; @@ -1466,7 +1466,7 @@ static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level) if (seq->type == SEQ_TYPE_META) { /* trim the sub-sequences */ - trimmed_sequences += slip_count_sequences_rec(&seq->seqbase, false); + trimmed_sequences += slip_count_sequences_recursive(&seq->seqbase, false); } } } @@ -1484,7 +1484,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve View2D *v2d = UI_view2d_fromcontext(C); /* first recursively count the trimmed elements */ - num_seq = slip_count_sequences_rec(ed->seqbasep, true); + num_seq = slip_count_sequences_recursive(ed->seqbasep, true); if (num_seq == 0) { return OPERATOR_CANCELLED; @@ -1502,7 +1502,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve data->num_input.unit_sys = USER_UNIT_NONE; data->num_input.unit_type[0] = 0; - slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); + slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true); for (i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); @@ -1596,7 +1596,7 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) bool success = false; /* first recursively count the trimmed elements */ - num_seq = slip_count_sequences_rec(ed->seqbasep, true); + num_seq = slip_count_sequences_recursive(ed->seqbasep, true); if (num_seq == 0) { return OPERATOR_CANCELLED; @@ -1608,7 +1608,7 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim"); data->num_seq = num_seq; - slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); + slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true); for (i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); -- cgit v1.2.3 From 39684e455459e37057006a1082a4d2a95f13be06 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Mar 2020 22:37:25 +1100 Subject: Cleanup: remove duplicate function --- source/blender/editors/armature/armature_select.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 99dcd5bb42b..86396dd6783 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -816,18 +816,6 @@ bool ED_armature_edit_deselect_all_visible_multi(bContext *C) /** \name Cursor Picking API * \{ */ -/* accounts for connected parents */ -static int ebone_select_flag(EditBone *ebone) -{ - if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { - return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | - (ebone->flag & (BONE_SELECTED | BONE_TIPSEL)); - } - else { - return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); - } -} - /* context: editmode armature in view3d */ bool ED_armature_edit_select_pick( bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) @@ -939,7 +927,7 @@ bool ED_armature_edit_select_pick( ED_armature_edit_sync_selection(arm->edbo); /* then now check for active status */ - if (ebone_select_flag(nearBone)) { + if (ED_armature_ebone_selectflag_get(nearBone)) { arm->act_edbone = nearBone; } -- cgit v1.2.3 From b0bd9b4c70ccdf5d6c2891a543fafd36be0d8af0 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 31 Mar 2020 16:05:19 +0200 Subject: Fix T75244: Screw Modifier Crash Draw batch extraction wrongly assumed that when mapped extraction happened that all original data could be found. This is not the case as mapped extraction is also enabled when part of the data is present. This fix does additional nullptr checks. --- .../blender/draw/intern/draw_cache_extract_mesh.c | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index f54fef63c82..3f7421dc2f6 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -606,7 +606,7 @@ static void extract_lines_loop_mesh(const MeshRenderData *mr, { const MEdge *medge = &mr->medge[mloop->e]; if (!((mr->use_hide && (medge->flag & ME_HIDE)) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && + ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->e_origindex) && (mr->e_origindex[mloop->e] == ORIGINDEX_NONE)))) { int loopend = mpoly->totloop + mpoly->loopstart - 1; int other_loop = (l == loopend) ? mpoly->loopstart : (l + 1); @@ -639,7 +639,7 @@ static void extract_lines_ledge_mesh(const MeshRenderData *mr, int ledge_idx = mr->edge_len + e; int edge_idx = mr->ledges[e]; if (!((mr->use_hide && (medge->flag & ME_HIDE)) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && + ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->e_origindex) && (mr->e_origindex[edge_idx] == ORIGINDEX_NONE)))) { int l = mr->loop_len + e * 2; GPU_indexbuf_set_line_verts(elb, ledge_idx, l, l + 1); @@ -765,7 +765,7 @@ BLI_INLINE void vert_set_mesh(GPUIndexBufBuilder *elb, { const MVert *mvert = &mr->mvert[vert_idx]; if (!((mr->use_hide && (mvert->flag & ME_HIDE)) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && + ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) && (mr->v_origindex[vert_idx] == ORIGINDEX_NONE)))) { GPU_indexbuf_set_point_vert(elb, vert_idx, loop); } @@ -937,7 +937,7 @@ static void extract_lines_paint_mask_loop_mesh(const MeshRenderData *mr, const int edge_idx = mloop->e; const MEdge *medge = &mr->medge[edge_idx]; if (!((mr->use_hide && (medge->flag & ME_HIDE)) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && + ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->e_origindex) && (mr->e_origindex[edge_idx] == ORIGINDEX_NONE)))) { int loopend = mpoly->totloop + mpoly->loopstart - 1; @@ -1333,7 +1333,7 @@ static void extract_edituv_points_loop_mesh(const MeshRenderData *mr, const MPoly *mpoly, void *data) { - const bool real_vert = (mr->extract_type == MR_EXTRACT_MAPPED && + const bool real_vert = (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && mr->v_origindex[mloop->v] != ORIGINDEX_NONE); edituv_point_add( data, ((mpoly->flag & ME_HIDE) != 0) || !real_vert, (mpoly->flag & ME_FACE_SEL) != 0, l); @@ -1407,7 +1407,7 @@ static void extract_edituv_fdots_loop_mesh(const MeshRenderData *mr, const MPoly *mpoly, void *data) { - const bool real_fdot = (mr->extract_type == MR_EXTRACT_MAPPED && + const bool real_fdot = (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex && mr->p_origindex[p] != ORIGINDEX_NONE); const bool subd_fdot = (!mr->use_subsurf_fdots || (mr->mvert[mloop->v].flag & ME_VERT_FACEDOT) != 0); @@ -1518,7 +1518,8 @@ static void extract_pos_nor_loop_mesh(const MeshRenderData *mr, vert->nor = data->packed_nor[mloop->v]; /* Flag for paint mode overlay. */ if (mpoly->flag & ME_HIDE || mvert->flag & ME_HIDE || - ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex[mloop->v] == ORIGINDEX_NONE))) { + ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) && + (mr->v_origindex[mloop->v] == ORIGINDEX_NONE))) { vert->nor.w = -1; } else if (mvert->flag & SELECT) { @@ -1647,8 +1648,8 @@ static void extract_lnor_hq_loop_mesh( } /* Flag for paint mode overlay. */ - if (mpoly->flag & ME_HIDE || - (mr->extract_type == MR_EXTRACT_MAPPED && mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { + if (mpoly->flag & ME_HIDE || (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && + mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { lnor_data->w = -1; } else if (mpoly->flag & ME_FACE_SEL) { @@ -1723,8 +1724,8 @@ static void extract_lnor_loop_mesh( } /* Flag for paint mode overlay. */ - if (mpoly->flag & ME_HIDE || - (mr->extract_type == MR_EXTRACT_MAPPED && mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { + if (mpoly->flag & ME_HIDE || (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && + mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { lnor_data->w = -1; } else if (mpoly->flag & ME_FACE_SEL) { @@ -3914,8 +3915,8 @@ static void extract_fdots_nor_finish(const MeshRenderData *mr, void *buf, void * for (int f = 0; f < mr->poly_len; f++) { efa = BM_face_at_index(mr->bm, f); const bool is_face_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN); - if (is_face_hidden || - (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex[f] == ORIGINDEX_NONE)) { + if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex && + mr->p_origindex[f] == ORIGINDEX_NONE)) { nor[f] = GPU_normal_convert_i10_v3(invalid_normal); nor[f].w = NOR_AND_FLAG_HIDDEN; } @@ -3932,8 +3933,8 @@ static void extract_fdots_nor_finish(const MeshRenderData *mr, void *buf, void * for (int f = 0; f < mr->poly_len; f++) { efa = bm_original_face_get(mr, f); const bool is_face_hidden = efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN); - if (is_face_hidden || - (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex[f] == ORIGINDEX_NONE)) { + if (is_face_hidden || (mr->extract_type == MR_EXTRACT_MAPPED && mr->p_origindex && + mr->p_origindex[f] == ORIGINDEX_NONE)) { nor[f] = GPU_normal_convert_i10_v3(invalid_normal); nor[f].w = NOR_AND_FLAG_HIDDEN; } -- cgit v1.2.3 From afe707cc3a3d0185b3b750bc9e907838bbea8e0c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 30 Mar 2020 15:29:17 +0200 Subject: Fix missing XR space destruction I think destructing the XrSession would destruct this anyway, but rather have this done explicitly, consistently and in a controlled manner. --- intern/ghost/intern/GHOST_XrSession.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index 53d22cbd679..dbe0846a2ca 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -76,6 +76,9 @@ GHOST_XrSession::~GHOST_XrSession() if (m_oxr->reference_space != XR_NULL_HANDLE) { CHECK_XR_ASSERT(xrDestroySpace(m_oxr->reference_space)); } + if (m_oxr->view_space != XR_NULL_HANDLE) { + CHECK_XR_ASSERT(xrDestroySpace(m_oxr->view_space)); + } if (m_oxr->session != XR_NULL_HANDLE) { CHECK_XR_ASSERT(xrDestroySession(m_oxr->session)); } -- cgit v1.2.3 From f149d5e4b21f372f779fdb28b39984355c9682a6 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 31 Mar 2020 16:39:59 +0200 Subject: Fix VR session toggle not changing reliably on session start/end The text and icon were supposed to change but didn't reliably, which was a race condition I think. It depended on how fast the OpenXR runtime would transition the session state. This also makes sure the correct notifier is sent on session exit. --- source/blender/makesrna/intern/rna_xr.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index 76cbc99b397..b08e48a4b17 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -38,7 +38,7 @@ static bool rna_XrSessionState_is_running(bContext *C) { # ifdef WITH_XR_OPENXR const wmWindowManager *wm = CTX_wm_manager(C); - return WM_xr_session_is_ready(&wm->xr); + return WM_xr_session_exists(&wm->xr); # else UNUSED_VARS(C); return false; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index e782b802729..c3446a016f1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3711,6 +3711,8 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data) } } } + + WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); } static void wm_xr_session_update_screen_on_exit_cb(const wmXrData *xr_data) -- cgit v1.2.3 From 1c1a14dcdfffd8572bade4f9a55784eb6bc94d5f Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 25 Mar 2020 17:39:48 +0100 Subject: Voxel Remesh: Edit Voxel Size operator This operator lets the user control the voxel/detail size of the voxel remesher directly from the 3D view in a similar way the Brush radius and strength are controlled. The shorcut from sculpt mode is Shift + R (similar to Shift + F for brush strength). It shows a grid that represents the real voxel size of the object. The grid and the text are automatically aligned to the view to avoid rendering all voxels with thousands of lines. It also has a slow mode when pressing shift that works like the slow mode of the brush radius control. This operator controls the value changes sensitivity automatically to avoid jumping to extremelly high resolutions and run out of memory. This way, adjusments done in lower voxel sizes are more precise. Pressing Ctrl disables this functionality and allows changing the voxel size directly in a linear way. Reviewed By: jbakker, #user_interface, billreynish Differential Revision: https://developer.blender.org/D6449 --- .../keyconfig/keymap_data/blender_default.py | 1 + source/blender/editors/object/CMakeLists.txt | 1 + source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 2 + source/blender/editors/object/object_remesh.c | 410 ++++++++++++++++++++- 5 files changed, 411 insertions(+), 4 deletions(-) diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 22b62d27684..971c702aeac 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -4323,6 +4323,7 @@ def km_sculpt(params): ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": True}, None), # Remesh ("object.voxel_remesh", {"type": 'R', "value": 'PRESS', "ctrl": True}, None), + ("object.voxel_size_edit", {"type": 'R', "value": 'PRESS', "shift": True}, None), ("object.quadriflow_remesh", {"type": 'R', "value": 'PRESS', "ctrl": True, "alt": True}, None), # Brush properties ("brush.scale_size", {"type": 'LEFT_BRACKET', "value": 'PRESS'}, diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index a5b6fa55aa9..c2c25e47908 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -18,6 +18,7 @@ set(INC ../include ../../blenkernel + ../../blenfont ../../blenlib ../../blentranslation ../../bmesh diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 559bb434f9d..d8ba270073e 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -291,6 +291,7 @@ void TRANSFORM_OT_vertex_random(struct wmOperatorType *ot); /* object_remesh.c */ void OBJECT_OT_voxel_remesh(struct wmOperatorType *ot); +void OBJECT_OT_voxel_size_edit(struct wmOperatorType *ot); void OBJECT_OT_quadriflow_remesh(struct wmOperatorType *ot); /* object_transfer_data.c */ diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index cacf7b67777..fef046169a7 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -265,6 +265,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_hide_collection); WM_operatortype_append(OBJECT_OT_voxel_remesh); + WM_operatortype_append(OBJECT_OT_voxel_size_edit); + WM_operatortype_append(OBJECT_OT_quadriflow_remesh); } diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index a9f2319d926..08c44b87664 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -37,6 +37,9 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_userdef_types.h" + +#include "BLT_translation.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -61,17 +64,29 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_sculpt.h" +#include "ED_space_api.h" #include "ED_undo.h" +#include "ED_view3d.h" #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" +#include "GPU_draw.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_state.h" + #include "WM_api.h" #include "WM_message.h" #include "WM_toolsystem.h" #include "WM_types.h" +#include "UI_interface.h" + +#include "BLF_api.h" + #include "object_intern.h" // own include /* TODO(sebpa): unstable, can lead to unrecoverable errors. */ @@ -188,16 +203,403 @@ void OBJECT_OT_voxel_remesh(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +#define VOXEL_SIZE_EDIT_MAX_GRIDS_LINES 500 +#define VOXEL_SIZE_EDIT_MAX_STR_LEN 20 + +typedef struct VoxelSizeEditCustomData { + void *draw_handle; + Object *active_object; + + float init_mval[2]; + float slow_mval[2]; + + bool slow_mode; + + float init_voxel_size; + float slow_voxel_size; + float voxel_size; + + float preview_plane[4][3]; + + float text_mat[4][4]; +} VoxelSizeEditCustomData; + +static void voxel_size_parallel_lines_draw(uint pos3d, + const float initial_co[3], + const float end_co[3], + const float length_co[3], + const float spacing) +{ + const float total_len = len_v3v3(initial_co, end_co); + const int tot_lines = (int)(total_len / spacing); + const int tot_lines_half = (tot_lines / 2) + 1; + float spacing_dir[3], lines_start[3]; + float line_dir[3]; + sub_v3_v3v3(spacing_dir, end_co, initial_co); + normalize_v3(spacing_dir); + + sub_v3_v3v3(line_dir, length_co, initial_co); + + if (tot_lines > VOXEL_SIZE_EDIT_MAX_GRIDS_LINES || tot_lines <= 1) { + return; + } + + mid_v3_v3v3(lines_start, initial_co, end_co); + + immBegin(GPU_PRIM_LINES, (uint)tot_lines_half * 2); + for (int i = 0; i < tot_lines_half; i++) { + float line_start[3]; + float line_end[3]; + madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i); + add_v3_v3v3(line_end, line_start, line_dir); + immVertex3fv(pos3d, line_start); + immVertex3fv(pos3d, line_end); + } + immEnd(); + + mul_v3_fl(spacing_dir, -1.0f); + + immBegin(GPU_PRIM_LINES, (uint)(tot_lines_half - 1) * 2); + for (int i = 1; i < tot_lines_half; i++) { + float line_start[3]; + float line_end[3]; + madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i); + add_v3_v3v3(line_end, line_start, line_dir); + immVertex3fv(pos3d, line_start); + immVertex3fv(pos3d, line_end); + } + immEnd(); +} + +static void voxel_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) +{ + VoxelSizeEditCustomData *cd = arg; + + GPU_blend(true); + GPU_line_smooth(true); + + uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + GPU_matrix_push(); + GPU_matrix_mul(cd->active_object->obmat); + + /* Draw Rect */ + immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f); + GPU_line_width(3.0f); + + immBegin(GPU_PRIM_LINES, 8); + immVertex3fv(pos3d, cd->preview_plane[0]); + immVertex3fv(pos3d, cd->preview_plane[1]); + + immVertex3fv(pos3d, cd->preview_plane[1]); + immVertex3fv(pos3d, cd->preview_plane[2]); + + immVertex3fv(pos3d, cd->preview_plane[2]); + immVertex3fv(pos3d, cd->preview_plane[3]); + + immVertex3fv(pos3d, cd->preview_plane[3]); + immVertex3fv(pos3d, cd->preview_plane[0]); + immEnd(); + + /* Draw Grid */ + GPU_line_width(1.0f); + + const float total_len = len_v3v3(cd->preview_plane[0], cd->preview_plane[1]); + const int tot_lines = (int)(total_len / cd->voxel_size); + + /* Smoothstep to reduce the alpha of the grid as the line number increases. */ + const float a = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES * 0.1f; + const float b = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES; + const float x = clamp_f((tot_lines - a) / (b - a), 0.0f, 1.0); + const float alpha_factor = 1.0f - (x * x * (3.0f - 2.0f * x)); + + immUniformColor4f(0.9f, 0.9f, 0.9f, 0.75f * alpha_factor); + voxel_size_parallel_lines_draw( + pos3d, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[3], cd->voxel_size); + voxel_size_parallel_lines_draw( + pos3d, cd->preview_plane[1], cd->preview_plane[2], cd->preview_plane[0], cd->voxel_size); + + /* Draw text */ + uiStyle *style = UI_style_get(); + const uiFontStyle *fstyle = &style->widget; + const int fontid = fstyle->uifont_id; + float strwidth, strheight; + short fstyle_points = fstyle->points; + char str[VOXEL_SIZE_EDIT_MAX_STR_LEN]; + short strdrawlen = 0; + + BLI_snprintf(str, VOXEL_SIZE_EDIT_MAX_STR_LEN, "%3.4f%%", cd->voxel_size); + strdrawlen = BLI_strlen_utf8(str); + + immUnbindProgram(); + + GPU_matrix_push(); + GPU_matrix_mul(cd->text_mat); + BLF_size(fontid, 10.0f * fstyle_points, U.dpi); + BLF_color3f(fontid, 1.0f, 1.0f, 1.0f); + BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight); + BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f); + BLF_draw(fontid, str, strdrawlen); + GPU_matrix_pop(); + + GPU_matrix_pop(); + + GPU_blend(false); + GPU_line_smooth(false); +} + +static void voxel_size_edit_cancel(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + VoxelSizeEditCustomData *cd = op->customdata; + + ED_region_draw_cb_exit(ar->type, cd->draw_handle); + + MEM_freeN(op->customdata); + + ED_workspace_status_text(C, NULL); +} + +static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + VoxelSizeEditCustomData *cd = op->customdata; + Object *active_object = cd->active_object; + Mesh *mesh = (Mesh *)active_object->data; + + /* Cancel modal operator */ + if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || + (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { + voxel_size_edit_cancel(C, op); + ED_region_tag_redraw(ar); + return OPERATOR_FINISHED; + } + + /* Finish modal operator */ + if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || + (event->type == EVT_RETKEY && event->val == KM_PRESS) || + (event->type == EVT_PADENTER && event->val == KM_PRESS)) { + ED_region_draw_cb_exit(ar->type, cd->draw_handle); + mesh->remesh_voxel_size = cd->voxel_size; + MEM_freeN(op->customdata); + ED_region_tag_redraw(ar); + return OPERATOR_FINISHED; + } + + float mval[2] = {event->mval[0], event->mval[1]}; + + float d = cd->init_mval[0] - mval[0]; + + if (cd->slow_mode) { + d = cd->slow_mval[0] - mval[0]; + } + + if (event->ctrl) { + /* Linear mode, enables jumping to any voxel size. */ + d = d * 0.0005f; + } + else { + /* Multiply d by the initial voxel size to prevent incontrolable speeds when using low voxel + * sizes. */ + /* When the voxel size is slower, it needs more precision. */ + d = d * min_ff(pow2f(cd->init_voxel_size), 0.1f) * 0.05f; + } + if (cd->slow_mode) { + cd->voxel_size = cd->slow_voxel_size + d * 0.05f; + } + else { + cd->voxel_size = cd->init_voxel_size + d; + } + + if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_PRESS) { + cd->slow_mode = true; + copy_v2_v2(cd->slow_mval, mval); + cd->slow_voxel_size = cd->voxel_size; + } + if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_RELEASE) { + cd->slow_mode = false; + cd->slow_voxel_size = 0.0f; + } + + cd->voxel_size = clamp_f(cd->voxel_size, 0.0001f, 1.0f); + + ED_region_tag_redraw(ar); + return OPERATOR_RUNNING_MODAL; +} + +static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + Object *active_object = CTX_data_active_object(C); + Mesh *mesh = (Mesh *)active_object->data; + + VoxelSizeEditCustomData *cd = MEM_callocN(sizeof(VoxelSizeEditCustomData), + "Voxel Size Edit OP Custom Data"); + + /* Initial operator Custom Data setup. */ + cd->draw_handle = ED_region_draw_cb_activate( + ar->type, voxel_size_edit_draw, cd, REGION_DRAW_POST_VIEW); + cd->active_object = active_object; + cd->init_mval[0] = event->mval[0]; + cd->init_mval[1] = event->mval[1]; + cd->init_voxel_size = mesh->remesh_voxel_size; + cd->voxel_size = mesh->remesh_voxel_size; + op->customdata = cd; + + /* Select the front facing face of the mesh boundig box. */ + BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object); + + /* Indices of the Bounding Box faces. */ + int BB_faces[6][4] = { + {3, 0, 4, 7}, + {1, 2, 6, 5}, + {3, 2, 1, 0}, + {4, 5, 6, 7}, + {0, 1, 5, 4}, + {2, 3, 7, 6}, + }; + + copy_v3_v3(cd->preview_plane[0], bb->vec[BB_faces[0][0]]); + copy_v3_v3(cd->preview_plane[1], bb->vec[BB_faces[0][1]]); + copy_v3_v3(cd->preview_plane[2], bb->vec[BB_faces[0][2]]); + copy_v3_v3(cd->preview_plane[3], bb->vec[BB_faces[0][3]]); + + RegionView3D *rv3d = CTX_wm_region_view3d(C); + + float mat[3][3]; + float current_normal[3]; + float view_normal[3] = {0.0f, 0.0f, 1.0f}; + + /* Calculate the view normal. */ + invert_m4_m4(active_object->imat, active_object->obmat); + copy_m3_m4(mat, rv3d->viewinv); + mul_m3_v3(mat, view_normal); + copy_m3_m4(mat, active_object->imat); + mul_m3_v3(mat, view_normal); + normalize_v3(view_normal); + + normal_tri_v3(current_normal, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]); + + float min_dot = dot_v3v3(current_normal, view_normal); + float current_dot = 1; + + /* Check if there is a face that is more aligned towards the view. */ + for (int i = 0; i < 6; i++) { + normal_tri_v3( + current_normal, bb->vec[BB_faces[i][0]], bb->vec[BB_faces[i][1]], bb->vec[BB_faces[i][2]]); + current_dot = dot_v3v3(current_normal, view_normal); + + if (current_dot < min_dot) { + min_dot = current_dot; + copy_v3_v3(cd->preview_plane[0], bb->vec[BB_faces[i][0]]); + copy_v3_v3(cd->preview_plane[1], bb->vec[BB_faces[i][1]]); + copy_v3_v3(cd->preview_plane[2], bb->vec[BB_faces[i][2]]); + copy_v3_v3(cd->preview_plane[3], bb->vec[BB_faces[i][3]]); + } + } + + /* Matrix calculation to position the text in 3D space. */ + float text_pos[3]; + float scale_mat[4][4]; + + float d_a[3], d_b[3]; + float d_a_proj[2], d_b_proj[2]; + float preview_plane_proj[4][3]; + float y_axis_proj[2] = {0.0f, 1.0f}; + + mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]); + + /* Project the selected face in the previous step of the Bounding Box. */ + for (int i = 0; i < 4; i++) { + ED_view3d_project(ar, cd->preview_plane[i], preview_plane_proj[i]); + } + + /* Get the initial X and Y axis of the basis from the edges of the Bounding Box face. */ + sub_v3_v3v3(d_a, cd->preview_plane[1], cd->preview_plane[0]); + sub_v3_v3v3(d_b, cd->preview_plane[3], cd->preview_plane[0]); + normalize_v3(d_a); + normalize_v3(d_b); + + /* Project the X and Y axis. */ + sub_v2_v2v2(d_a_proj, preview_plane_proj[1], preview_plane_proj[0]); + sub_v2_v2v2(d_b_proj, preview_plane_proj[3], preview_plane_proj[0]); + normalize_v2(d_a_proj); + normalize_v2(d_b_proj); + + unit_m4(cd->text_mat); + + /* Select the axis that is aligned with the view Y axis to use it as the basis Y. */ + if (fabsf(dot_v2v2(d_a_proj, y_axis_proj)) > fabsf(dot_v2v2(d_b_proj, y_axis_proj))) { + copy_v3_v3(cd->text_mat[0], d_b); + copy_v3_v3(cd->text_mat[1], d_a); + + /* Flip the X and Y basis vectors to make sure they always point upwards and to the right. */ + if (d_b_proj[0] < 0.0f) { + mul_v3_fl(cd->text_mat[0], -1.0f); + } + if (d_a_proj[1] < 0.0f) { + mul_v3_fl(cd->text_mat[1], -1.0f); + } + } + else { + copy_v3_v3(cd->text_mat[0], d_a); + copy_v3_v3(cd->text_mat[1], d_b); + if (d_a_proj[0] < 0.0f) { + mul_v3_fl(cd->text_mat[0], -1.0f); + } + if (d_b_proj[1] < 0.0f) { + mul_v3_fl(cd->text_mat[1], -1.0f); + } + } + + /* Use the Bounding Box face normal as the basis Z. */ + normal_tri_v3(cd->text_mat[2], cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]); + + /* Write the text position into the matrix. */ + copy_v3_v3(cd->text_mat[3], text_pos); + + /* Scale the text. */ + unit_m4(scale_mat); + scale_m4_fl(scale_mat, 0.0008f); + mul_m4_m4_post(cd->text_mat, scale_mat); + + WM_event_add_modal_handler(C, op); + + ED_region_tag_redraw(ar); + + const char *status_str = TIP_( + "Move the mouse to change the voxel size. LBM: confirm size, ESC/RMB: cancel"); + ED_workspace_status_text(C, status_str); + + return OPERATOR_RUNNING_MODAL; +} + +void OBJECT_OT_voxel_size_edit(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Edit Voxel Size"; + ot->description = "Modify the mesh voxel size interactively used in the voxel remesher"; + ot->idname = "OBJECT_OT_voxel_size_edit"; + + /* api callbacks */ + ot->poll = object_remesh_poll; + ot->invoke = voxel_size_edit_invoke; + ot->modal = voxel_size_edit_modal; + ot->cancel = voxel_size_edit_cancel; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/****************** quadriflow remesh operator *********************/ + +#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f + enum { QUADRIFLOW_REMESH_RATIO = 1, QUADRIFLOW_REMESH_EDGE_LENGTH, QUADRIFLOW_REMESH_FACES, }; -/****************** quadriflow remesh operator *********************/ - -#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f - typedef enum eSymmetryAxes { SYMMETRY_AXES_X = (1 << 0), SYMMETRY_AXES_Y = (1 << 1), -- cgit v1.2.3 From 38685b5a3976954634b441858cf9c5df65bbe83f Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 30 Mar 2020 10:10:43 -0300 Subject: Edit Curve: Improve Curve extrude The original code has two logics, extrude the end points or duplicate points (making new splines). Now all the logic has been redone by extruding contiguous selected segments. Fix T47169 Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D6982 --- source/blender/editors/curve/editcurve.c | 322 +++++++++++++------------------ 1 file changed, 138 insertions(+), 184 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2911611c516..47dcc8538d6 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5217,9 +5217,6 @@ void CURVE_OT_spin(wmOperatorType *ot) static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) { - Nurb *nu = NULL; - Nurb *nu_last = NULL; - bool changed = false; Nurb *cu_actnu; @@ -5234,211 +5231,168 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) } BKE_curve_nurb_vert_active_get(cu, &cu_actnu, &cu_actvert.p); - BKE_curve_nurb_vert_active_set(cu, NULL, NULL); - - /* first pass (endpoints) */ - for (nu = editnurb->nurbs.first; nu; nu = nu->next) { - - if ((nu->flagu & CU_NURB_CYCLIC) && (nu->pntsu > 1)) { - continue; - } + int act_offset = 0; + for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) { + BLI_assert(nu->pntsu > 0); + int i; + int pnt_len = nu->pntsu; + int new_points = 0; + int offset = 0; + bool is_prev_selected = false; if (nu->type == CU_BEZIER) { - - /* Check to see if the first bezier point is selected */ - if (nu->pntsu > 0 && nu->bezt != NULL) { - BezTriple *nu_bezt_old = nu->bezt; - BezTriple *bezt = nu->bezt; - - if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) { - BezTriple *bezt_new; - BEZT_DESEL_ALL(bezt); - - bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__); - ED_curve_beztcpy(editnurb, bezt_new + 1, bezt, nu->pntsu); - *bezt_new = *bezt; - - MEM_freeN(nu->bezt); - nu->bezt = bezt_new; - - nu->pntsu += 1; - - if (ARRAY_HAS_ITEM(cu_actvert.bezt, nu_bezt_old, nu->pntsu - 1)) { - cu_actvert.bezt = (cu_actvert.bezt == bezt) ? - bezt_new : - &nu->bezt[(cu_actvert.bezt - nu_bezt_old) + 1]; - BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt); - } - - BEZT_SEL_ALL(bezt_new); - changed = true; + BezTriple *bezt, *bezt_prev = NULL; + bool is_cyclic = false; + if (pnt_len == 1) { + /* Single point extrusion. + * Keep `is_prev_selected` false to force extrude. */ + bezt_prev = &nu->bezt[0]; + } + else if (nu->flagu & CU_NURB_CYCLIC) { + is_cyclic = true; + bezt_prev = &nu->bezt[pnt_len - 1]; + is_prev_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev); + } + i = pnt_len; + for (bezt = &nu->bezt[0]; i--; bezt++) { + bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt); + if (bezt_prev && is_prev_selected != is_selected) { + new_points++; + } + if (bezt == cu_actvert.bezt) { + act_offset = new_points; + } + bezt_prev = bezt; + is_prev_selected = is_selected; + } + + if (new_points) { + if (pnt_len == 1) { + /* Single point extrusion. + * Set `is_prev_selected` as false to force extrude. */ + BLI_assert(bezt_prev == &nu->bezt[0]); + is_prev_selected = false; + } + else if (is_cyclic) { + BLI_assert(bezt_prev == &nu->bezt[pnt_len - 1]); + BLI_assert(is_prev_selected == BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt_prev)); } - } - - /* Check to see if the last bezier point is selected */ - if (nu->pntsu > 1) { - BezTriple *nu_bezt_old = nu->bezt; - BezTriple *bezt = &nu->bezt[nu->pntsu - 1]; - - if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) { - BezTriple *bezt_new; - BEZT_DESEL_ALL(bezt); - - bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__); - ED_curve_beztcpy(editnurb, bezt_new, nu->bezt, nu->pntsu); - bezt_new[nu->pntsu] = *bezt; - - MEM_freeN(nu->bezt); - nu->bezt = bezt_new; - - bezt_new += nu->pntsu; - nu->pntsu += 1; + else { + bezt_prev = NULL; + } + BezTriple *bezt_src, *bezt_dst, *bezt_src_iter, *bezt_dst_iter; + bezt_src = nu->bezt; + bezt_dst = MEM_mallocN((pnt_len + new_points) * sizeof(BezTriple), __func__); + bezt_src_iter = &bezt_src[0]; + bezt_dst_iter = &bezt_dst[0]; + i = 0; + for (bezt = &nu->bezt[0]; i < pnt_len; i++, bezt++) { + bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt); + if (bezt_prev && is_prev_selected != is_selected) { + int count = i - offset + 1; + if (is_prev_selected) { + ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count - 1); + ED_curve_beztcpy(editnurb, &bezt_dst_iter[count - 1], bezt_prev, 1); + } + else { + ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, count); + } + ED_curve_beztcpy(editnurb, &bezt_dst_iter[count], bezt, 1); + BEZT_DESEL_ALL(&bezt_dst_iter[count - 1]); - if (ARRAY_HAS_ITEM(cu_actvert.bezt, nu_bezt_old, nu->pntsu - 1)) { - cu_actvert.bezt = (cu_actvert.bezt == bezt) ? bezt_new : - &nu->bezt[cu_actvert.bezt - nu_bezt_old]; - BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt); + bezt_dst_iter += count + 1; + bezt_src_iter += count; + offset = i + 1; } + bezt_prev = bezt; + is_prev_selected = is_selected; + } - BEZT_SEL_ALL(bezt_new); - changed = true; + int remain = pnt_len - offset; + if (remain) { + ED_curve_beztcpy(editnurb, bezt_dst_iter, bezt_src_iter, pnt_len - offset); } + + MEM_freeN(nu->bezt); + nu->bezt = bezt_dst; + nu->pntsu += new_points; + changed = true; } } else { - - /* Check to see if the first bpoint is selected */ - if (nu->pntsu > 0 && nu->bp != NULL) { - BPoint *nu_bp_old = nu->bp; - BPoint *bp = nu->bp; - - if (bp->f1 & SELECT) { - BPoint *bp_new; - bp->f1 &= ~SELECT; - - bp_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BPoint), __func__); - ED_curve_bpcpy(editnurb, bp_new + 1, bp, nu->pntsu); - *bp_new = *bp; - - MEM_freeN(nu->bp); - nu->bp = bp_new; - - nu->pntsu += 1; - BKE_nurb_knot_calc_u(nu); - - if (ARRAY_HAS_ITEM(cu_actvert.bp, nu_bp_old, nu->pntsu - 1)) { - cu_actvert.bp = (cu_actvert.bp == bp) ? bp_new : - &nu->bp[(cu_actvert.bp - nu_bp_old) + 1]; - BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bp); - } - - bp_new->f1 |= SELECT; - changed = true; - } + BPoint *bp, *bp_prev = NULL; + if (pnt_len == 1) { + /* Single point extrusion. + * Reference a `prev_bp` to force extrude. */ + bp_prev = &nu->bp[0]; } - - /* Check to see if the last bpoint is selected */ - if (nu->pntsu > 1) { - BPoint *nu_bp_old = nu->bp; - BPoint *bp = &nu->bp[nu->pntsu - 1]; - - if (bp->f1 & SELECT) { - BPoint *bp_new; - bp->f1 &= ~SELECT; - - bp_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BPoint), __func__); - ED_curve_bpcpy(editnurb, bp_new, nu->bp, nu->pntsu); - bp_new[nu->pntsu] = *bp; - - MEM_freeN(nu->bp); - nu->bp = bp_new; - - bp_new += nu->pntsu; - nu->pntsu += 1; - - if (ARRAY_HAS_ITEM(cu_actvert.bp, nu_bp_old, nu->pntsu - 1)) { - cu_actvert.bp = (cu_actvert.bp == bp) ? bp_new : &nu->bp[cu_actvert.bp - nu_bp_old]; - BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bp); - } - - BKE_nurb_knot_calc_u(nu); - - bp_new->f1 |= SELECT; - changed = true; + i = pnt_len; + for (bp = &nu->bp[0]; i--; bp++) { + bool is_selected = (bp->f1 & SELECT) != 0; + if (bp_prev && is_prev_selected != is_selected) { + new_points++; } + if (bp == cu_actvert.bp) { + act_offset = new_points; + } + bp_prev = bp; + is_prev_selected = is_selected; } - } - } - - /* second pass (interior points) */ - nu_last = editnurb->nurbs.last; - for (nu = editnurb->nurbs.first; (nu != nu_last->next); nu = nu->next) { - int i, i_end; - - if ((nu->flagu & CU_NURB_CYCLIC) && (nu->pntsu > 1)) { - /* all points are interior */ - i = 0; - i_end = nu->pntsu; - } - else { - /* skip endpoints */ - i = 1; - i_end = nu->pntsu - 1; - } - - if (nu->type == CU_BEZIER) { - BezTriple *bezt; - for (bezt = &nu->bezt[i]; i < i_end; i++, bezt++) { - if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) { - Nurb *nurb_new; - BezTriple *bezt_new; - - BEZT_DESEL_ALL(bezt); - nurb_new = BKE_nurb_copy(nu, 1, 1); - nurb_new->flagu &= ~CU_NURB_CYCLIC; - BLI_addtail(&editnurb->nurbs, nurb_new); - bezt_new = nurb_new->bezt; - ED_curve_beztcpy(editnurb, bezt_new, bezt, 1); - BEZT_SEL_ALL(bezt_new); + if (new_points) { + BPoint *bp_src, *bp_dst, *bp_src_iter, *bp_dst_iter; + is_prev_selected = false; + if (pnt_len == 1) { + /* Single point extrusion. + * Keep `is_prev_selected` false to force extrude. */ + BLI_assert(bp_prev == &nu->bp[0]); + } + else { + bp_prev = NULL; + } + bp_src = nu->bp; + bp_dst = MEM_mallocN((pnt_len + new_points) * sizeof(BPoint), __func__); + bp_src_iter = &bp_src[0]; + bp_dst_iter = &bp_dst[0]; + i = 0; + for (bp = &nu->bp[0]; i < pnt_len; i++, bp++) { + bool is_selected = (bp->f1 & SELECT) != 0; + if (bp_prev && is_prev_selected != is_selected) { + int count = i - offset + 1; + if (is_prev_selected) { + ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count - 1); + ED_curve_bpcpy(editnurb, &bp_dst_iter[count - 1], bp_prev, 1); + } + else { + ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, count); + } + ED_curve_bpcpy(editnurb, &bp_dst_iter[count], bp, 1); + bp_dst_iter[count - 1].f1 &= ~SELECT; - if (cu_actvert.bezt == bezt || cu_actnu == NULL) { - BKE_curve_nurb_vert_active_set(cu, nurb_new, bezt_new); + bp_dst_iter += count + 1; + bp_src_iter += count; + offset = i + 1; } - - changed = true; + bp_prev = bp; + is_prev_selected = is_selected; } - } - } - else { - BPoint *bp; - for (bp = &nu->bp[i]; i < i_end; i++, bp++) { - if (bp->f1 & SELECT) { - Nurb *nurb_new; - BPoint *bp_new; - - bp->f1 &= ~SELECT; - nurb_new = BKE_nurb_copy(nu, 1, 1); - nurb_new->flagu &= ~CU_NURB_CYCLIC; - BLI_addtail(&editnurb->nurbs, nurb_new); - bp_new = nurb_new->bp; - ED_curve_bpcpy(editnurb, bp_new, bp, 1); - bp_new->f1 |= SELECT; + int remain = pnt_len - offset; + if (remain) { + ED_curve_bpcpy(editnurb, bp_dst_iter, bp_src_iter, pnt_len - offset); + } - if (cu_actvert.bp == bp || cu_actnu == NULL) { - BKE_curve_nurb_vert_active_set(cu, nurb_new, bp_new); - } + MEM_freeN(nu->bp); + nu->bp = bp_dst; + nu->pntsu += new_points; - changed = true; - } + BKE_nurb_knot_calc_u(nu); + changed = true; } } } - if (changed == false) { - BKE_curve_nurb_vert_active_set(cu, cu_actnu, cu_actvert.p); - } + cu->actvert += act_offset; return changed; } -- cgit v1.2.3 From 6c036a65c9741786deb53191fa77d83e7ffb1be3 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Tue, 31 Mar 2020 17:06:17 +0200 Subject: Add Voxel Mode to the Remesh modifier This adds the Voxel Mode to the current remesh modifier. It works exactly the same way as the voxel remesh operator and uses the same properties to control the remeshing. We can exand this with more options in the future (fix poles, reprojection...) Reviewed By: brecht Differential Revision: https://developer.blender.org/D7292 --- .../startup/bl_ui/properties_data_modifier.py | 21 ++++--- source/blender/blenloader/intern/versioning_280.c | 13 ++++ source/blender/makesdna/DNA_modifier_types.h | 7 ++- source/blender/makesrna/intern/rna_modifier.c | 24 +++++++ source/blender/modifiers/intern/MOD_remesh.c | 73 +++++++++++++--------- 5 files changed, 101 insertions(+), 37 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index e5ea1a94945..cbcd6e2b614 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1317,17 +1317,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "mode") row = layout.row() - row.prop(md, "octree_depth") - row.prop(md, "scale") + if md.mode == 'VOXEL': + layout.prop(md, "voxel_size") + layout.prop(md, "adaptivity") + else: + row.prop(md, "octree_depth") + row.prop(md, "scale") - if md.mode == 'SHARP': - layout.prop(md, "sharpness") + if md.mode == 'SHARP': + layout.prop(md, "sharpness") + + layout.prop(md, "use_remove_disconnected") + row = layout.row() + row.active = md.use_remove_disconnected + row.prop(md, "threshold") layout.prop(md, "use_smooth_shade") - layout.prop(md, "use_remove_disconnected") - row = layout.row() - row.active = md.use_remove_disconnected - row.prop(md, "threshold") @staticmethod def vertex_weight_mask(layout, ob, md): diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 50b1e385dd4..b3c0473e173 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -4878,5 +4878,18 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Remesh Modifier Voxel Mode. */ + if (!DNA_struct_elem_find(fd->filesdna, "RemeshModifierData", "float", "voxel_size")) { + for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Remesh) { + RemeshModifierData *rmd = (RemeshModifierData *)md; + rmd->voxel_size = 0.1f; + rmd->adaptivity = 0.0f; + } + } + } + } } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 74cb72a1fae..855bf8434be 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1608,6 +1608,8 @@ typedef enum eRemeshModifierMode { MOD_REMESH_MASS_POINT = 1, /* keeps sharp edges */ MOD_REMESH_SHARP_FEATURES = 2, + /* Voxel remesh */ + MOD_REMESH_VOXEL = 3, } eRemeshModifierMode; typedef struct RemeshModifierData { @@ -1623,10 +1625,13 @@ typedef struct RemeshModifierData { /* octree depth */ char depth; - char flag; char mode; char _pad; + + /* OpenVDB Voxel remesh properties. */ + float voxel_size; + float adaptivity; } RemeshModifierData; /* Skin modifier */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 455fb1c50c9..d2eaa9538ff 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -5128,6 +5128,11 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) 0, "Sharp", "Output a surface that reproduces sharp edges and corners from the input mesh"}, + {MOD_REMESH_VOXEL, + "VOXEL", + 0, + "Voxel", + "Output a mesh corresponding to the volume of the original mesh"}, {0, NULL, 0, NULL, NULL}, }; @@ -5181,6 +5186,25 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) "edges closer to the input"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "voxel_size"); + RNA_def_property_ui_range(prop, 0.0001, 2, 0.1, 3); + RNA_def_property_ui_text(prop, + "Voxel Size", + "Size of the voxel in object space used for volume evaluation. Lower " + "values preserve finer details"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "adaptivity", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "adaptivity"); + RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); + RNA_def_property_ui_text( + prop, + "Adaptivity", + "Reduces the final face count by simplifying geometry where detail is not needed, " + "generating triangles. A value greater than 0 disables Fix Poles"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_remove_disconnected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_REMESH_FLOOD_FILL); RNA_def_property_ui_text(prop, "Remove Disconnected Pieces", ""); diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 3300cda947c..2fa8dc973a1 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -34,6 +34,7 @@ #include "MOD_modifiertypes.h" #include "BKE_mesh.h" +#include "BKE_mesh_remesh_voxel.h" #include "BKE_mesh_runtime.h" #include @@ -54,8 +55,10 @@ static void initData(ModifierData *md) rmd->depth = 4; rmd->hermite_num = 1; rmd->flag = MOD_REMESH_FLOOD_FILL; - rmd->mode = MOD_REMESH_SHARP_FEATURES; + rmd->mode = MOD_REMESH_VOXEL; rmd->threshold = 1; + rmd->voxel_size = 0.1f; + rmd->adaptivity = 0.0f; } #ifdef WITH_MOD_REMESH @@ -144,36 +147,50 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c rmd = (RemeshModifierData *)md; - init_dualcon_mesh(&input, mesh); - - if (rmd->flag & MOD_REMESH_FLOOD_FILL) { - flags |= DUALCON_FLOOD_FILL; + if (rmd->mode == MOD_REMESH_VOXEL) { + /* OpenVDB modes. */ + if (rmd->voxel_size == 0.0f) { + return NULL; + } + result = BKE_mesh_remesh_voxel_to_mesh_nomain(mesh, rmd->voxel_size, rmd->adaptivity, 0.0f); } + else { + /* Dualcon modes. */ + init_dualcon_mesh(&input, mesh); - switch (rmd->mode) { - case MOD_REMESH_CENTROID: - mode = DUALCON_CENTROID; - break; - case MOD_REMESH_MASS_POINT: - mode = DUALCON_MASS_POINT; - break; - case MOD_REMESH_SHARP_FEATURES: - mode = DUALCON_SHARP_FEATURES; - break; - } + if (rmd->flag & MOD_REMESH_FLOOD_FILL) { + flags |= DUALCON_FLOOD_FILL; + } - output = dualcon(&input, - dualcon_alloc_output, - dualcon_add_vert, - dualcon_add_quad, - flags, - mode, - rmd->threshold, - rmd->hermite_num, - rmd->scale, - rmd->depth); - result = output->mesh; - MEM_freeN(output); + switch (rmd->mode) { + case MOD_REMESH_CENTROID: + mode = DUALCON_CENTROID; + break; + case MOD_REMESH_MASS_POINT: + mode = DUALCON_MASS_POINT; + break; + case MOD_REMESH_SHARP_FEATURES: + mode = DUALCON_SHARP_FEATURES; + break; + case MOD_REMESH_VOXEL: + /* Should have been processed before as an OpenVDB operation. */ + BLI_assert(false); + break; + } + + output = dualcon(&input, + dualcon_alloc_output, + dualcon_add_vert, + dualcon_add_quad, + flags, + mode, + rmd->threshold, + rmd->hermite_num, + rmd->scale, + rmd->depth); + result = output->mesh; + MEM_freeN(output); + } if (rmd->flag & MOD_REMESH_SMOOTH_SHADING) { MPoly *mpoly = result->mpoly; -- cgit v1.2.3 From 5b88ab25bd83804af007136a1c7b9d8a9d1c1514 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Tue, 31 Mar 2020 18:54:41 +0200 Subject: Fix T75219: Move to New Layer not working This was an old design problem. --- .../scripts/startup/bl_ui/properties_grease_pencil_common.py | 2 +- source/blender/editors/gpencil/gpencil_edit.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 64d4b6e2d4a..5647f35383a 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -332,7 +332,7 @@ class GPENCIL_MT_move_to_layer(Menu): layout.separator() - layout.operator("gpencil.layer_add", text="New Layer", icon='ADD') + layout.operator("gpencil.move_to_layer", text="New Layer", icon='ADD').layer = -1 class GPENCIL_MT_layer_active(Menu): diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index dc7bbfb99fa..91169b34e34 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1569,7 +1569,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) } /* Try to get layer */ - target_layer = BLI_findlink(&gpd->layers, layer_num); + if (layer_num > -1) { + target_layer = BLI_findlink(&gpd->layers, layer_num); + } + else { + /* Create a new layer. */ + target_layer = BKE_gpencil_layer_addnew(gpd, "GP_Layer", true); + } if (target_layer == NULL) { /* back autolock status */ @@ -1655,7 +1661,8 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* GPencil layer to use. */ - ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX); + ot->prop = RNA_def_int( + ot->srna, "layer", 0, -1, INT_MAX, "Grease Pencil Layer", "", -1, INT_MAX); RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -- cgit v1.2.3 From 0062813c731ff2a0866d86a2b0558c67b8091f37 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Tue, 31 Mar 2020 13:14:16 -0600 Subject: make.bat: Improve messaging when not detecting MSVC Inspired by @mrwhite in D7295 --- build_files/windows/detect_msvc_vswhere.cmd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build_files/windows/detect_msvc_vswhere.cmd b/build_files/windows/detect_msvc_vswhere.cmd index 609375cee89..52f765c20c4 100644 --- a/build_files/windows/detect_msvc_vswhere.cmd +++ b/build_files/windows/detect_msvc_vswhere.cmd @@ -27,7 +27,13 @@ if NOT "%verbose%" == "" ( if "%VS_InstallDir%"=="" ( if NOT "%verbose%" == "" ( - echo Visual Studio is detected but the "Desktop development with C++" workload has not been instlled + echo. + echo Visual Studio is detected but no suitable installation was found. + echo. + echo Check the "Desktop development with C++" workload has been installed. + echo. + echo If you are attempting to use either Visual Studio Preview version or the Visual C++ Build tools, Please see 'make help' on how to opt in to those toolsets. + echo. goto FAIL ) ) -- cgit v1.2.3 From da3cb514e52de922148534c660a0b04ee5c43eeb Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 1 Apr 2020 01:03:20 +0200 Subject: Multires: Initial Face Sets support This implements the Sculpt Mode API functions needed for Face Sets and visibility management for PBVH_GRIDS. No major changes were needed in the operators and the sculpt mode code. This implementation stores the face sets in the base mesh, so faces created in higher subdivision levels can't be modified individually. Also, we are not checking for multiple face sets per vertex (that can be added in the future), so relax tools don't work yet. The rest of the features (paint, undo, visibility operators..) work as expected. Reviewed By: brecht Differential Revision: https://developer.blender.org/D7168 --- source/blender/blenkernel/BKE_paint.h | 1 + source/blender/blenkernel/BKE_pbvh.h | 4 + source/blender/blenkernel/BKE_subdiv_ccg.h | 2 + source/blender/blenkernel/intern/paint.c | 27 +++--- source/blender/blenkernel/intern/pbvh.c | 33 +++++++ source/blender/blenkernel/intern/pbvh_intern.h | 2 + source/blender/blenkernel/intern/subdiv_ccg.c | 11 +++ source/blender/editors/sculpt_paint/sculpt.c | 101 ++++++++++++++-------- source/blender/editors/sculpt_paint/sculpt_undo.c | 24 +++-- source/blender/gpu/GPU_buffers.h | 4 + source/blender/gpu/intern/gpu_buffers.c | 60 +++++++++---- 11 files changed, 196 insertions(+), 73 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 881f3356a86..8c925ee2ae1 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -296,6 +296,7 @@ typedef struct SculptSession { int *pmap_mem; /* Mesh Face Sets */ + int totfaces; int *face_sets; /* BMesh for dynamic topology sculpting */ diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 16a7e4d38d0..b4f16bfd899 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -219,6 +219,8 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, int totgrid, int gridsize); +void BKE_pbvh_sync_face_sets_to_grids(PBVH *bvh); + /* multires level, only valid for type == PBVH_GRIDS */ const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh); @@ -298,6 +300,8 @@ void BKE_pbvh_grids_update(PBVH *bvh, void **gridfaces, struct DMFlagMat *flagmats, unsigned int **grid_hidden); +void BKE_pbvh_subdiv_cgg_set(PBVH *bvh, struct SubdivCCG *subdiv_ccg); +void BKE_pbvh_face_sets_set(PBVH *bvh, int *face_sets); void BKE_pbvh_face_sets_color_set(PBVH *bvh, int seed, int color_default); diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h index f8534371b17..99b134dab3e 100644 --- a/source/blender/blenkernel/BKE_subdiv_ccg.h +++ b/source/blender/blenkernel/BKE_subdiv_ccg.h @@ -305,6 +305,8 @@ void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG *subdiv_ccg, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors); +int BKE_subdiv_cgg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 719336f7351..f52ec5f568f 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1525,6 +1525,7 @@ static void sculpt_update_object( ss->multires = mmd; ss->totvert = me_eval->totvert; ss->totpoly = me_eval->totpoly; + ss->totfaces = me->totpoly; ss->mvert = NULL; ss->mpoly = NULL; ss->mloop = NULL; @@ -1532,25 +1533,26 @@ static void sculpt_update_object( else { ss->totvert = me->totvert; ss->totpoly = me->totpoly; + ss->totfaces = me->totpoly; ss->mvert = me->mvert; ss->mpoly = me->mpoly; ss->mloop = me->mloop; ss->multires = NULL; ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); + } - /* Sculpt Face Sets. */ - if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { - ss->face_sets = CustomData_add_layer( - &me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); - for (int i = 0; i < me->totpoly; i++) { - ss->face_sets[i] = 1; - } - - /* Set the default face set color if the datalayer did not exist. */ - me->face_sets_color_default = 1; + /* Sculpt Face Sets. */ + if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { + ss->face_sets = CustomData_add_layer( + &me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); + for (int i = 0; i < me->totpoly; i++) { + ss->face_sets[i] = 1; } - ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + + /* Set the default face set color if the datalayer did not exist. */ + me->face_sets_color_default = 1; } + ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); ss->subdiv_ccg = me_eval->runtime.subdiv_ccg; @@ -1558,6 +1560,9 @@ static void sculpt_update_object( BLI_assert(pbvh == ss->pbvh); UNUSED_VARS_NDEBUG(pbvh); + BKE_pbvh_subdiv_cgg_set(ss->pbvh, ss->subdiv_ccg); + BKE_pbvh_face_sets_set(ss->pbvh, ss->face_sets); + BKE_pbvh_face_sets_color_set(ss->pbvh, me->face_sets_color_seed, me->face_sets_color_default); if (need_pmap && ob->type == OB_MESH && !ss->pmap) { diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 9a4ce8acb11..ac0c9d030cf 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -383,6 +383,25 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, return totquad; } +void BKE_pbvh_sync_face_sets_to_grids(PBVH *bvh) +{ + const int gridsize = bvh->gridkey.grid_size; + for (int i = 0; i < bvh->totgrid; i++) { + BLI_bitmap *gh = bvh->grid_hidden[i]; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(bvh->subdiv_ccg, i); + if (!gh && bvh->face_sets[face_index] < 0) { + gh = bvh->grid_hidden[i] = BLI_BITMAP_NEW(bvh->gridkey.grid_area, "partialvis_update_grids"); + } + if (gh) { + for (int y = 0; y < gridsize; y++) { + for (int x = 0; x < gridsize; x++) { + BLI_BITMAP_SET(gh, y * gridsize + x, bvh->face_sets[face_index] < 0); + } + } + } + } +} + static void build_grid_leaf_node(PBVH *bvh, PBVHNode *node) { int totquads = BKE_pbvh_count_grid_quads( @@ -1289,10 +1308,14 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, switch (bvh->type) { case PBVH_GRIDS: GPU_pbvh_grid_buffers_update(node->draw_buffers, + bvh->subdiv_ccg, bvh->grids, bvh->grid_flag_mats, node->prim_indices, node->totprim, + bvh->face_sets, + bvh->face_sets_color_seed, + bvh->face_sets_color_default, &bvh->gridkey, update_flags); break; @@ -2974,3 +2997,13 @@ MVert *BKE_pbvh_get_verts(const PBVH *bvh) BLI_assert(bvh->type == PBVH_FACES); return bvh->verts; } + +void BKE_pbvh_subdiv_cgg_set(PBVH *bvh, SubdivCCG *subdiv_ccg) +{ + bvh->subdiv_ccg = subdiv_ccg; +} + +void BKE_pbvh_face_sets_set(PBVH *bvh, int *face_sets) +{ + bvh->face_sets = face_sets; +} diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index af92f11e219..21cb5649330 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -138,6 +138,7 @@ struct PBVH { int face_sets_color_seed; int face_sets_color_default; + int *face_sets; /* Grid Data */ CCGKey gridkey; @@ -168,6 +169,7 @@ struct PBVH { int cd_face_node_offset; struct BMLog *bm_log; + struct SubdivCCG *subdiv_ccg; }; /* pbvh.c */ diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 3c1a9c4d3d6..dff7170e517 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -1780,3 +1780,14 @@ void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG *subdiv_ccg, } #endif } + +int BKE_subdiv_cgg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index) +{ + Subdiv *subdiv = subdiv_ccg->subdiv; + OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner; + SubdivCCGFace *face = subdiv_ccg->grid_faces[grid_index]; + + const int face_grid_index = grid_index - face->start_grid_index; + const int face_index = face - subdiv_ccg->faces; + return face_index; +} diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6ccd197c908..50b8c9a9677 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -248,7 +248,8 @@ static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: - for (int i = 0; i < ss->totpoly; i++) { + case PBVH_GRIDS: + for (int i = 0; i < ss->totfaces; i++) { if (abs(ss->face_sets[i]) == face_set) { if (visible) { ss->face_sets[i] = abs(ss->face_sets[i]); @@ -261,8 +262,6 @@ static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool break; case PBVH_BMESH: break; - case PBVH_GRIDS: - break; } } @@ -270,14 +269,13 @@ static void SCULPT_face_sets_visibility_invert(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: - for (int i = 0; i < ss->totpoly; i++) { + case PBVH_GRIDS: + for (int i = 0; i < ss->totfaces; i++) { ss->face_sets[i] *= -1; } break; case PBVH_BMESH: break; - case PBVH_GRIDS: - break; } } @@ -285,7 +283,8 @@ static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: - for (int i = 0; i < ss->totpoly; i++) { + case PBVH_GRIDS: + for (int i = 0; i < ss->totfaces; i++) { /* This can run on geometry without a face set assigned, so its ID sign can't be changed to * modify the visibility. Force that geometry to the ID 1 to enable changing the visibility @@ -304,8 +303,6 @@ static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible) break; case PBVH_BMESH: break; - case PBVH_GRIDS: - break; } } @@ -343,8 +340,12 @@ static bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index } case PBVH_BMESH: return true; - case PBVH_GRIDS: - return true; + case PBVH_GRIDS: { + const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh); + const int grid_index = index / key->grid_area; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index); + return ss->face_sets[face_index] > 0; + } } return true; } @@ -362,8 +363,15 @@ static void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_se } break; case PBVH_BMESH: break; - case PBVH_GRIDS: - break; + case PBVH_GRIDS: { + const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh); + const int grid_index = index / key->grid_area; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index); + if (ss->face_sets[face_index] > 0) { + ss->face_sets[face_index] = abs(face_set); + } + + } break; } } @@ -382,8 +390,12 @@ int SCULPT_vertex_face_set_get(SculptSession *ss, int index) } case PBVH_BMESH: return 0; - case PBVH_GRIDS: - return 0; + case PBVH_GRIDS: { + const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh); + const int grid_index = index / key->grid_area; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index); + return ss->face_sets[face_index]; + } } return 0; } @@ -402,8 +414,12 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set) } case PBVH_BMESH: return true; - case PBVH_GRIDS: - return true; + case PBVH_GRIDS: { + const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh); + const int grid_index = index / key->grid_area; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, grid_index); + return ss->face_sets[face_index] == face_set; + } } return true; } @@ -415,8 +431,17 @@ static void sculpt_visibility_sync_face_sets_to_vertex(SculptSession *ss, int in void SCULPT_visibility_sync_all_face_sets_to_vertices(SculptSession *ss) { - for (int i = 0; i < ss->totvert; i++) { - sculpt_visibility_sync_face_sets_to_vertex(ss, i); + switch (BKE_pbvh_type(ss->pbvh)) { + case PBVH_FACES: { + for (int i = 0; i < ss->totvert; i++) { + sculpt_visibility_sync_face_sets_to_vertex(ss, i); + } + } + case PBVH_GRIDS: { + BKE_pbvh_sync_face_sets_to_grids(ss->pbvh); + } + case PBVH_BMESH: + break; } } @@ -439,7 +464,7 @@ static void UNUSED_FUNCTION(sculpt_visibility_sync_vertex_to_face_sets)(SculptSe void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss) { if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { - for (int i = 0; i < ss->totpoly; i++) { + for (int i = 0; i < ss->totfaces; i++) { MPoly *poly = &ss->mpoly[i]; bool poly_visible = true; for (int l = 0; l < poly->totloop; l++) { @@ -479,7 +504,7 @@ bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index) case PBVH_BMESH: return false; case PBVH_GRIDS: - return false; + return true; } return false; } @@ -487,9 +512,10 @@ bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index) static int SCULPT_face_set_next_available_get(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { - case PBVH_FACES: { + case PBVH_FACES: + case PBVH_GRIDS: { int next_face_set = 0; - for (int i = 0; i < ss->totpoly; i++) { + for (int i = 0; i < ss->totfaces; i++) { if (abs(ss->face_sets[i]) > next_face_set) { next_face_set = abs(ss->face_sets[i]); } @@ -499,8 +525,6 @@ static int SCULPT_face_set_next_available_get(SculptSession *ss) } case PBVH_BMESH: return 0; - case PBVH_GRIDS: - return 0; } return 0; } @@ -10286,7 +10310,7 @@ static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) for (int n = 0; n < ss->filter_cache->totnode; n++) { PBVHNode *node = ss->filter_cache->nodes[n]; if (create_face_set) { - for (int i = 0; i < ss->totpoly; i++) { + for (int i = 0; i < ss->totfaces; i++) { ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; } } @@ -10492,7 +10516,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) { if (create_face_set) { - for (int i = 0; i < ss->totpoly; i++) { + for (int i = 0; i < ss->totfaces; i++) { ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; } } @@ -10619,8 +10643,8 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent } if (create_face_set) { - ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totpoly, "prev face mask"); - for (int i = 0; i < ss->totpoly; i++) { + ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totfaces, "prev face mask"); + for (int i = 0; i < ss->totfaces; i++) { ss->filter_cache->prev_face_set[i] = ss->face_sets[i]; } ss->filter_cache->new_face_set = SCULPT_face_set_next_available_get(ss); @@ -11172,8 +11196,8 @@ static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEv const int mode = RNA_enum_get(op->ptr, "mode"); - /* Dyntopo and Multires not supported for now. */ - if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { + /* Dyntopo not suported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { return OPERATOR_CANCELLED; } @@ -11514,8 +11538,8 @@ static int sculpt_face_set_init_invoke(bContext *C, wmOperator *op, const wmEven const int mode = RNA_enum_get(op->ptr, "mode"); - /* Dyntopo and Multires not supported for now. */ - if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { + /* Dyntopo not supported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { return OPERATOR_CANCELLED; } @@ -11673,8 +11697,8 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C, ARegion *region = CTX_wm_region(C); Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - /* Dyntopo and Multires not supported for now. */ - if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { + /* Dyntopo not supported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { return OPERATOR_CANCELLED; } @@ -11714,7 +11738,7 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C, } } - for (int i = 0; i < ss->totpoly; i++) { + for (int i = 0; i < ss->totfaces; i++) { if (ss->face_sets[i] <= 0) { hidden_vertex = true; break; @@ -11834,8 +11858,9 @@ static int sculpt_face_sets_randomize_colors_invoke(bContext *C, mesh->face_sets_color_seed += 1; if (ss->face_sets) { - const int random_index = clamp_i( - ss->totpoly * BLI_hash_int_01(mesh->face_sets_color_seed), 0, max_ii(0, ss->totpoly - 1)); + const int random_index = clamp_i(ss->totfaces * BLI_hash_int_01(mesh->face_sets_color_seed), + 0, + max_ii(0, ss->totfaces - 1)); mesh->face_sets_color_default = ss->face_sets[random_index]; } BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index af404c64fb0..5233ce8d257 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -48,6 +48,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_multires.h" +#include "BKE_object.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subdiv_ccg.h" @@ -335,8 +336,11 @@ static bool sculpt_undo_restore_face_sets(bContext *C, SculptUndoNode *unode) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - SculptSession *ss = ob->sculpt; - memcpy(ss->face_sets, unode->face_sets, ss->totpoly * sizeof(int)); + Mesh *me = BKE_object_get_original_mesh(ob); + int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + for (int i = 0; i < me->totpoly; i++) { + face_sets[i] = unode->face_sets[i]; + } return false; } @@ -542,7 +546,6 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase return; } else if (unode->type == SCULPT_UNDO_FACE_SETS) { - sculpt_undo_restore_face_sets(C, unode); rebuild = true; @@ -551,14 +554,15 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask); SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { BKE_mesh_flush_hidden_from_verts(ob->data); } + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -983,8 +987,6 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType type) { UndoSculpt *usculpt = sculpt_undo_get_nodes(); - SculptSession *ss = ob->sculpt; - SculptUndoNode *unode = usculpt->nodes.first; unode = MEM_callocN(sizeof(*unode), __func__); @@ -993,8 +995,14 @@ static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType typ unode->type = type; unode->applied = true; - unode->face_sets = MEM_callocN(ss->totpoly * sizeof(int), "sculpt face sets"); - memcpy(unode->face_sets, ss->face_sets, ss->totpoly * sizeof(int)); + Mesh *me = BKE_object_get_original_mesh(ob); + + unode->face_sets = MEM_callocN(me->totpoly * sizeof(int), "sculpt face sets"); + + int *face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + for (int i = 0; i < me->totpoly; i++) { + unode->face_sets[i] = face_sets[i]; + } BLI_addtail(&usculpt->nodes, unode); diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 9d91fd79137..b02f6ed09b3 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -95,10 +95,14 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, const int update_flags); void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, + struct SubdivCCG *subdiv_ccg, struct CCGElem **grids, const struct DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, + const int *sculpt_face_sets, + const int face_sets_color_seed, + const int face_sets_color_default, const struct CCGKey *key, const int update_flags); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 168a3c83a91..cfc1eb05731 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -43,6 +43,7 @@ #include "BKE_mesh.h" #include "BKE_paint.h" #include "BKE_pbvh.h" +#include "BKE_subdiv_ccg.h" #include "GPU_batch.h" #include "GPU_buffers.h" @@ -523,8 +524,13 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], /** \name Grid PBVH * \{ */ -static void gpu_pbvh_grid_fill_index_buffers( - GPU_PBVH_Buffers *buffers, int *grid_indices, uint visible_quad_len, int totgrid, int gridsize) +static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers *buffers, + SubdivCCG *subdiv_ccg, + const int *face_sets, + int *grid_indices, + uint visible_quad_len, + int totgrid, + int gridsize) { GPUIndexBufBuilder elb, elb_lines; GPUIndexBufBuilder elb_fast, elb_lines_fast; @@ -594,7 +600,6 @@ static void gpu_pbvh_grid_fill_index_buffers( const uint grid_vert_len = square_uint(gridsize - 1) * 4; for (int i = 0; i < totgrid; i++, offset += grid_vert_len) { bool grid_visible = false; - BLI_bitmap *gh = buffers->grid_hidden[grid_indices[i]]; uint v0, v1, v2, v3; @@ -673,16 +678,22 @@ void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers, /* Threaded - do not call any functions that use OpenGL calls! */ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, + SubdivCCG *subdiv_ccg, CCGElem **grids, - const DMFlagMat *grid_flag_mats, + const struct DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, - const CCGKey *key, + const int *sculpt_face_sets, + const int face_sets_color_seed, + const int face_sets_color_default, + const struct CCGKey *key, const int update_flags) { const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0; bool empty_mask = true; + bool default_face_set = true; + int i, j, k, x, y; /* Build VBO */ @@ -702,8 +713,13 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, return; } - gpu_pbvh_grid_fill_index_buffers( - buffers, grid_indices, visible_quad_len, totgrid, key->grid_size); + gpu_pbvh_grid_fill_index_buffers(buffers, + subdiv_ccg, + sculpt_face_sets, + grid_indices, + visible_quad_len, + totgrid, + key->grid_size); } uint vbo_index_offset = 0; @@ -716,9 +732,23 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, } for (i = 0; i < totgrid; i++) { - CCGElem *grid = grids[grid_indices[i]]; + const int grid_index = grid_indices[i]; + CCGElem *grid = grids[grid_index]; int vbo_index = vbo_index_offset; + uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; + + if (subdiv_ccg && sculpt_face_sets) { + const int face_index = BKE_subdiv_cgg_grid_to_face_index(subdiv_ccg, grid_index); + + const int fset = abs(sculpt_face_sets[face_index]); + /* Skip for the default color Face Set to render it white. */ + if (fset != face_sets_color_default) { + face_set_overlay_color_get(fset, face_sets_color_seed, face_set_color); + default_face_set = false; + } + } + if (buffers->smooth) { for (y = 0; y < key->grid_size; y++) { for (x = 0; x < key->grid_size; x++) { @@ -742,8 +772,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol); } - uchar fsets[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index, &fsets); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index, &face_set_color); vbo_index += 1; } @@ -799,11 +828,10 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 2, &vcol); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 3, &vcol); - uchar fsets[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 0, &fsets); - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 1, &fsets); - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 2, &fsets); - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 3, &fsets); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 0, &face_set_color); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 1, &face_set_color); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 2, &face_set_color); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.fset, vbo_index + 3, &face_set_color); vbo_index += 4; } @@ -823,7 +851,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, buffers->totgrid = totgrid; buffers->grid_flag_mats = grid_flag_mats; buffers->gridkey = *key; - buffers->show_overlay = !empty_mask; + buffers->show_overlay = !empty_mask || !default_face_set; } /* Threaded - do not call any functions that use OpenGL calls! */ -- cgit v1.2.3 From 74b5e5f6e15fa82a43d97329da157305cb055cc8 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 31 Mar 2020 20:27:46 -0300 Subject: Fix T74588: Weld Modifier: Vertex colors and UVs get incorrect values --- source/blender/modifiers/intern/MOD_weld.c | 88 +++++++++++++++++++----------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c index 5d56152e0ff..11fd411459c 100644 --- a/source/blender/modifiers/intern/MOD_weld.c +++ b/source/blender/modifiers/intern/MOD_weld.c @@ -800,6 +800,33 @@ static bool weld_iter_loop_of_poly_begin(WeldLoopOfPolyIter *iter, iter->mloop = mloop; iter->loop_map = loop_map; iter->group = group_buffer; + if (group_buffer) { + /* First loop group needs more attention. */ + uint loop_start, loop_end, l; + loop_start = iter->loop_start; + loop_end = l = iter->loop_end; + while (l >= loop_start) { + const uint loop_ctx = loop_map[l]; + if (loop_ctx != OUT_OF_CONTEXT) { + const WeldLoop *wl = &wloop[loop_ctx]; + if (wl->flag == ELEM_COLLAPSED) { + l--; + continue; + } + } + break; + } + if (l != loop_end) { + iter->group_len = iter->loop_end - l; + int i = 0; + while (l < loop_end) { + iter->group[i++] = ++l; + } + } + } + else { + iter->group_len = 0; + } iter->l_next = iter->loop_start; #ifdef USE_WELD_DEBUG @@ -813,8 +840,13 @@ static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter *iter) uint loop_end = iter->loop_end; const WeldLoop *wloop = iter->wloop; const uint *loop_map = iter->loop_map; - iter->group_len = 0; uint l = iter->l_curr = iter->l_next; + if (l == iter->loop_start) { + /* `grupo_len` is already calculated in the first loop */ + } + else { + iter->group_len = 0; + } while (l <= loop_end) { uint l_next = l + 1; const uint loop_ctx = loop_map[l]; @@ -825,20 +857,6 @@ static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter *iter) } if (wl->flag == ELEM_COLLAPSED) { if (iter->group) { - if (l == iter->loop_start) { - uint l_prev = loop_end; - const uint loop_ctx_end = loop_map[l_prev]; - if (loop_ctx_end != OUT_OF_CONTEXT) { - const WeldLoop *wl_prev = &wloop[loop_ctx_end]; - while (wl_prev->flag == ELEM_COLLAPSED) { - iter->group[iter->group_len++] = l_prev--; - wl_prev--; - if (wl_prev->loop_orig != l_prev) { - break; - } - } - } - } iter->group[iter->group_len++] = l; } l = l_next; @@ -1503,16 +1521,7 @@ static void customdata_weld( if (dest->layers[dest_i].type == type) { void *src_data = source->layers[src_i].data; - if (CustomData_layer_has_math(dest, dest_i)) { - const int size = CustomData_sizeof(type); - void *dst_data = dest->layers[dest_i].data; - void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size); - for (j = 0; j < count; j++) { - CustomData_data_add( - type, v_dst, POINTER_OFFSET(src_data, (size_t)src_indices[j] * size)); - } - } - else if (type == CD_MVERT) { + if (type == CD_MVERT) { for (j = 0; j < count; j++) { MVert *mv_src = &((MVert *)src_data)[src_indices[j]]; add_v3_v3(co, mv_src->co); @@ -1534,6 +1543,18 @@ static void customdata_weld( flag |= me_src->flag; } } + else if (CustomData_layer_has_interp(dest, dest_i)) { + CustomData_interp(source, dest, (const int *)src_indices, NULL, NULL, count, dest_index); + } + else if (CustomData_layer_has_math(dest, dest_i)) { + const int size = CustomData_sizeof(type); + void *dst_data = dest->layers[dest_i].data; + void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size); + for (j = 0; j < count; j++) { + CustomData_data_add( + type, v_dst, POINTER_OFFSET(src_data, (size_t)src_indices[j] * size)); + } + } else { CustomData_copy_layer_type_data(source, dest, type, src_indices[0], dest_index, 1); } @@ -1551,13 +1572,7 @@ static void customdata_weld( for (dest_i = 0; dest_i < dest->totlayer; dest_i++) { CustomDataLayer *layer_dst = &dest->layers[dest_i]; const int type = layer_dst->type; - if (CustomData_layer_has_math(dest, dest_i)) { - const int size = CustomData_sizeof(type); - void *dst_data = layer_dst->data; - void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size); - CustomData_data_multiply(type, v_dst, fac); - } - else if (type == CD_MVERT) { + if (type == CD_MVERT) { MVert *mv = &((MVert *)layer_dst->data)[dest_index]; mul_v3_fl(co, fac); bweight *= fac; @@ -1586,6 +1601,15 @@ static void customdata_weld( me->bweight = (char)bweight; me->flag = flag; } + else if (CustomData_layer_has_interp(dest, dest_i)) { + /* Already calculated. */ + } + else if (CustomData_layer_has_math(dest, dest_i)) { + const int size = CustomData_sizeof(type); + void *dst_data = layer_dst->data; + void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size); + CustomData_data_multiply(type, v_dst, fac); + } } } -- cgit v1.2.3 From e819f67500070b0854cd5d27386ddd40eaae5a4b Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 31 Mar 2020 20:39:37 -0300 Subject: Cleanup: Organize Weld Modifier in alphabetical order --- source/blender/makesrna/intern/rna_modifier.c | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index d2eaa9538ff..562fff1bf50 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -700,10 +700,10 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_MeshCacheModifier; case eModifierType_LaplacianDeform: return &RNA_LaplacianDeformModifier; - case eModifierType_Wireframe: - return &RNA_WireframeModifier; case eModifierType_Weld: return &RNA_WeldModifier; + case eModifierType_Wireframe: + return &RNA_WireframeModifier; case eModifierType_DataTransfer: return &RNA_DataTransferModifier; case eModifierType_NormalEdit: @@ -5782,6 +5782,45 @@ static void rna_def_modifier_laplaciandeform(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_weld(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "WeldModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Weld Modifier", "Weld modifier"); + RNA_def_struct_sdna(srna, "WeldModifierData"); + RNA_def_struct_ui_icon(srna, ICON_AUTOMERGE_OFF); + + prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "merge_dist"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 1, 0.001, 6); + RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "max_interactions", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "max_interactions"); + RNA_def_property_ui_text( + prop, + "Duplicate Limit", + "For a better performance, limits the number of elements found per vertex. " + "(0 makes it infinite)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text( + prop, "Vertex Group", "Vertex group name for selecting the affected areas"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeldModifier_defgrp_name_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WELD_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + static void rna_def_modifier_wireframe(BlenderRNA *brna) { StructRNA *srna; @@ -5865,45 +5904,6 @@ static void rna_def_modifier_wireframe(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } -static void rna_def_modifier_weld(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "WeldModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Weld Modifier", "Weld modifier"); - RNA_def_struct_sdna(srna, "WeldModifierData"); - RNA_def_struct_ui_icon(srna, ICON_AUTOMERGE_OFF); - - prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "merge_dist"); - RNA_def_property_range(prop, 0, FLT_MAX); - RNA_def_property_ui_range(prop, 0, 1, 0.001, 6); - RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "max_interactions", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "max_interactions"); - RNA_def_property_ui_text( - prop, - "Duplicate Limit", - "For a better performance, limits the number of elements found per vertex. " - "(0 makes it infinite)"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); - RNA_def_property_ui_text( - prop, "Vertex Group", "Vertex group name for selecting the affected areas"); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeldModifier_defgrp_name_set"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WELD_INVERT_VGROUP); - RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); -} - static void rna_def_modifier_datatransfer(BlenderRNA *brna) { StructRNA *srna; @@ -6629,8 +6629,8 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_triangulate(brna); rna_def_modifier_meshcache(brna); rna_def_modifier_laplaciandeform(brna); - rna_def_modifier_wireframe(brna); rna_def_modifier_weld(brna); + rna_def_modifier_wireframe(brna); rna_def_modifier_datatransfer(brna); rna_def_modifier_normaledit(brna); rna_def_modifier_meshseqcache(brna); -- cgit v1.2.3 From f9f0f44be85d4631afbbf9b248dc7787dd41255f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 10:41:34 +1100 Subject: Cleanup: quiet discarded-qualifiers, unused warnings --- source/blender/blenkernel/intern/subdiv_ccg.c | 6 +++--- source/blender/editors/object/object_remesh.c | 2 +- source/blender/gpu/intern/gpu_buffers.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index dff7170e517..bdb2a1c5686 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -1783,11 +1783,11 @@ void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG *subdiv_ccg, int BKE_subdiv_cgg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index) { - Subdiv *subdiv = subdiv_ccg->subdiv; - OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner; + // Subdiv *subdiv = subdiv_ccg->subdiv; /* UNUSED */ + // OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner; /* UNUSED */ SubdivCCGFace *face = subdiv_ccg->grid_faces[grid_index]; - const int face_grid_index = grid_index - face->start_grid_index; + // const int face_grid_index = grid_index - face->start_grid_index; /* UNUSED */ const int face_index = face - subdiv_ccg->faces; return face_index; } diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 08c44b87664..99e9f3034c9 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -320,7 +320,7 @@ static void voxel_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), pos3d, cd->preview_plane[1], cd->preview_plane[2], cd->preview_plane[0], cd->voxel_size); /* Draw text */ - uiStyle *style = UI_style_get(); + const uiStyle *style = UI_style_get(); const uiFontStyle *fstyle = &style->widget; const int fontid = fstyle->uifont_id; float strwidth, strheight; diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index cfc1eb05731..8496bcac693 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -525,8 +525,8 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], * \{ */ static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers *buffers, - SubdivCCG *subdiv_ccg, - const int *face_sets, + SubdivCCG *UNUSED(subdiv_ccg), + const int *UNUSED(face_sets), int *grid_indices, uint visible_quad_len, int totgrid, -- cgit v1.2.3 From 91604279c933b61bd8bef5d0bcf00691a0cfd91f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 10:43:48 +1100 Subject: Fix missing break statement in recent face-set support --- source/blender/editors/sculpt_paint/sculpt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 50b8c9a9677..25cf17b12ce 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -436,6 +436,7 @@ void SCULPT_visibility_sync_all_face_sets_to_vertices(SculptSession *ss) for (int i = 0; i < ss->totvert; i++) { sculpt_visibility_sync_face_sets_to_vertex(ss, i); } + break; } case PBVH_GRIDS: { BKE_pbvh_sync_face_sets_to_grids(ss->pbvh); -- cgit v1.2.3 From bcd3c3cb57e3fa809862f3c0ec8a202fa2a58a18 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 10:32:02 +1100 Subject: UI: rename "Edge Collapse" to "Collapse Regions" This is useful for collapsing regions of faces & edges, similar to a 'Merge -> Collapse' which can operate on multiple regions, merging UV's so they don't need to be manually corrected. The name & description didn't mention this. --- source/blender/editors/mesh/editmesh_tools.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 1a25e582859..eff903d5694 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -731,8 +731,9 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op) void MESH_OT_edge_collapse(wmOperatorType *ot) { /* identifiers */ - ot->name = "Edge Collapse"; - ot->description = "Collapse selected edges"; + ot->name = "Collapse Regions"; + ot->description = + "Collapse isolated edges & faces regions, merging data such as UV's and vertex colors"; ot->idname = "MESH_OT_edge_collapse"; /* api callbacks */ -- cgit v1.2.3 From 18fc4155fd4299d61789aa0d5b9c1c3f7883636b Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 31 Mar 2020 20:57:18 -0300 Subject: Fix customdata interpolation being done multiple times in Weld Modifier --- source/blender/modifiers/intern/MOD_weld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c index 11fd411459c..a7d3280b113 100644 --- a/source/blender/modifiers/intern/MOD_weld.c +++ b/source/blender/modifiers/intern/MOD_weld.c @@ -1489,6 +1489,8 @@ static void customdata_weld( return; } + CustomData_interp(source, dest, (const int *)src_indices, NULL, NULL, count, dest_index); + int src_i, dest_i; int j; @@ -1544,7 +1546,8 @@ static void customdata_weld( } } else if (CustomData_layer_has_interp(dest, dest_i)) { - CustomData_interp(source, dest, (const int *)src_indices, NULL, NULL, count, dest_index); + /* Already calculated. + * TODO: Optimize by exposing `typeInfo->interp`. */ } else if (CustomData_layer_has_math(dest, dest_i)) { const int size = CustomData_sizeof(type); -- cgit v1.2.3 From 9b0d72aa3d1ff94b8b116fb3e9315ba31bd8ce63 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 10:53:46 +1100 Subject: Cleanup: use sections for object_remesh.c Add missing sections. --- source/blender/editors/object/object_remesh.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 99e9f3034c9..92187bbf0c5 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -92,6 +92,10 @@ /* TODO(sebpa): unstable, can lead to unrecoverable errors. */ // #define USE_MESH_CURVATURE +/* -------------------------------------------------------------------- */ +/** \name Voxel Remesh Operator + * \{ */ + static bool object_remesh_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -203,6 +207,12 @@ void OBJECT_OT_voxel_remesh(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Voxel Size Operator + * \{ */ + #define VOXEL_SIZE_EDIT_MAX_GRIDS_LINES 500 #define VOXEL_SIZE_EDIT_MAX_STR_LEN 20 @@ -590,7 +600,11 @@ void OBJECT_OT_voxel_size_edit(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/****************** quadriflow remesh operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Quadriflow Remesh Operator + * \{ */ #define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f @@ -1166,3 +1180,5 @@ void OBJECT_OT_quadriflow_remesh(wmOperatorType *ot) 0, 255); } + +/** \} */ -- cgit v1.2.3 From 2d39e46f84ffd28892deb6a93f099c051d16c95f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 11:08:01 +1100 Subject: Cleanup: use doxy sections for wm_draw.c --- source/blender/windowmanager/intern/wm_draw.c | 39 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 6df8440f90f..ebfdd8a5f6a 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -73,7 +73,9 @@ # include "BKE_subsurf.h" #endif -/* ******************* paint cursor *************** */ +/* -------------------------------------------------------------------- */ +/** \name Draw Paint Cursor + * \{ */ static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *region) { @@ -116,6 +118,12 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *region) } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Internal Utilities + * \{ */ + static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *sa, ARegion *region, @@ -184,8 +192,6 @@ static bool wm_draw_region_stereo_set(Main *bmain, return false; } -/* ********************* drawing ****************** */ - static void wm_area_mark_invalid_backbuf(ScrArea *sa) { if (sa->spacetype == SPACE_VIEW3D) { @@ -286,8 +292,13 @@ static bool wm_region_use_viewport(ScrArea *sa, ARegion *region) return wm_region_use_viewport_by_type(sa->spacetype, region->regiontype); } -/********************** draw all **************************/ -/* - reference method, draw all each time */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Window Drawing (Draw All) + * + * Reference method, draw all each time. + * \{ */ typedef struct WindowDrawCB { struct WindowDrawCB *next, *prev; @@ -328,12 +339,16 @@ static void wm_draw_callbacks(wmWindow *win) } } -/************************* Region drawing. ******************************** +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Region Drawing * - * Each region draws into its own framebuffer, which is then blit on the + * Each region draws into its own frame-buffer, which is then blit on the * window draw buffer. This helps with fast redrawing if only some regions * change. It also means we can share a single context for multiple windows, - * so that for example VAOs can be shared between windows. */ + * so that for example VAOs can be shared between windows. + * \{ */ static void wm_draw_region_buffer_free(ARegion *region) { @@ -866,7 +881,11 @@ static void wm_draw_surface(bContext *C, wmSurface *surface) wm_surface_clear_drawable(); } -/****************** main update call **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Main Update Call + * \{ */ /* quick test to prevent changing window drawable */ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) @@ -1042,6 +1061,8 @@ void WM_redraw_windows(bContext *C) CTX_wm_region_set(C, ar_prev); } +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Region Viewport Drawing * -- cgit v1.2.3 From 6a1f0c1eaafee3b96563b84e48547ec6ec655fc3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 11:28:05 +1100 Subject: Cleanup: use doxy sections for 'idprop' API --- source/blender/python/generic/idprop_py_api.c | 71 ++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index ae9ffe4f3b8..cabeeba18b9 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -40,11 +40,11 @@ extern bool pyrna_id_FromPyObject(PyObject *obj, ID **id); extern PyObject *pyrna_id_CreatePyObject(ID *id); extern bool pyrna_id_CheckPyObject(PyObject *obj); -/*********************** ID Property Main Wrapper Stuff ***************/ - -/* ---------------------------------------------------------------------------- - * static conversion functions to avoid duplicate code, no type checking. - */ +/* -------------------------------------------------------------------- */ +/** \name Python from ID-Property (Internal Conversions) + * + * Low level conversion to avoid duplicate code, no type checking. + * \{ */ static PyObject *idprop_py_from_idp_string(const IDProperty *prop) { @@ -124,7 +124,11 @@ static PyObject *idprop_py_from_idp_idparray(ID *id, IDProperty *prop) return seq; } -/* -------------------------------------------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name IDProp Group Access + * \{ */ /* use for both array and group */ static Py_hash_t BPy_IDGroup_hash(BPy_IDProperty *self) @@ -374,7 +378,11 @@ static const char *idp_try_read_name(PyObject *name_obj) return name; } -/* -------------------------------------------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name ID-Property from Python (Internal Conversions) + * \{ */ /** * The 'idp_from_Py*' functions expect that the input type has been checked before @@ -658,7 +666,12 @@ static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob) } } -/* -------------------------------------------------------------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Mapping Get/Set (Internal Access) + * \{ */ + /** * \note group can be a pointer array or a group. * assume we already checked key is a string. @@ -862,6 +875,12 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop) return NULL; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name ID-Property Group Methods + * \{ */ + PyDoc_STRVAR( BPy_IDGroup_pop_doc, ".. method:: pop(key, default)\n" @@ -1142,6 +1161,12 @@ static struct PyMethodDef BPy_IDGroup_methods[] = { {NULL, NULL, 0, NULL}, }; +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name ID-Property Group Type + * \{ */ + static PySequenceMethods BPy_IDGroup_Seq = { (lenfunc)BPy_IDGroup_Map_Len, /* lenfunc sq_length */ NULL, /* binaryfunc sq_concat */ @@ -1223,7 +1248,11 @@ PyTypeObject BPy_IDGroup_Type = { BPy_IDGroup_getseters, /* struct PyGetSetDef *tp_getset; */ }; -/********Array Wrapper********/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name ID Array Methods + * \{ */ static PyTypeObject *idp_array_py_type(BPy_IDArray *self, bool *r_is_double) { @@ -1567,6 +1596,10 @@ static PyBufferProcs BPy_IDArray_Buffer = { (releasebufferproc)BPy_IDArray_releasebuffer, }; +/* -------------------------------------------------------------------- */ +/** \name ID Array Type + * \{ */ + PyTypeObject BPy_IDArray_Type = { PyVarObject_HEAD_INIT(NULL, 0) /* For printing, in format "." */ @@ -1648,7 +1681,11 @@ PyTypeObject BPy_IDArray_Type = { NULL, }; -/*********** ID Property Group iterator ********/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name ID-Property Group Iterator Type + * \{ */ static PyObject *IDGroup_Iter_repr(BPy_IDGroup_Iter *self) { @@ -1746,9 +1783,11 @@ void IDProp_Init_Types(void) PyType_Ready(&BPy_IDArray_Type); } -/*----------------------------MODULE INIT-------------------------*/ +/** \} */ -/* --- */ +/* -------------------------------------------------------------------- */ +/** \name Public Module 'idprop.types' + * \{ */ static struct PyModuleDef IDProp_types_module_def = { PyModuleDef_HEAD_INIT, @@ -1784,7 +1823,11 @@ static PyObject *BPyInit_idprop_types(void) return submodule; } -/* --- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Public Module 'idprop' + * \{ */ static PyMethodDef IDProp_methods[] = { {NULL, NULL, 0, NULL}, @@ -1818,3 +1861,5 @@ PyObject *BPyInit_idprop(void) return mod; } + +/** \} */ -- cgit v1.2.3 From b7868c0b890c4c06100b771548ba16a99d4e6eb9 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 1 Apr 2020 03:52:58 +0200 Subject: Grease Pencil: Fix typo in labels and comments. Hardeness -> Hardness Only changed the labels/tooltips, will leave the internal change to @antoniov. --- source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c | 2 +- source/blender/makesrna/intern/rna_brush.c | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 2 +- source/blender/makesrna/intern/rna_gpencil_modifier.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index 93f3776827b..a1f1519d11f 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -105,7 +105,7 @@ static void deformStroke(GpencilModifierData *md, return; } - /* Hardeness (at stroke level). */ + /* Hardness (at stroke level). */ if (mmd->modify_color == GP_MODIFY_COLOR_HARDENESS) { gps->hardeness *= mmd->hardeness; CLAMP(gps->hardeness, 0.0f, 1.0f); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 75201322094..93f8053058a 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1346,7 +1346,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_ui_text( - prop, "Hardeness", "Amount of gradient for Dot and Box strokes (set to 1 for full solid)"); + prop, "Hardness", "Gradient from the center of Dot and Box strokes (set to 1 for a solid stroke)"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); /* gradient shape ratio */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 4afa467d2e3..e841813beca 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1203,7 +1203,7 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "hardeness"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Hardeness", "Amount of gradient along section of stroke"); + RNA_def_property_ui_text(prop, "Hardness", "Amount of gradient along section of stroke"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 6c3f26003fa..34de6b2938b 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -144,7 +144,7 @@ static const EnumPropertyItem modifier_modify_opacity_items[] = { {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke and Fill", "Modify fill and stroke colors"}, {GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"}, {GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"}, - {GP_MODIFY_COLOR_HARDENESS, "HARDENESS", 0, "Hardeness", "Modify stroke hardeness"}, + {GP_MODIFY_COLOR_HARDENESS, "HARDENESS", 0, "Hardness", "Modify stroke hardness"}, {0, NULL, 0, NULL, NULL}, }; @@ -1365,7 +1365,7 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, FLT_MAX); RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.1, 2); RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Hardeness", "Factor of stroke hardeness"); + RNA_def_property_ui_text(prop, "Hardness", "Factor of stroke hardness"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); -- cgit v1.2.3 From b157abebe5d8a0ca865cfe54f0371838466948b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 14:09:15 +1100 Subject: UI: avoid term 'Region', use 'Edges & Faces' instead Change to recent renaming of "Edge Collapse" as it has multiple uses, as it collapses edge-rings, but isn't limited to collapsing single edges, it can be used to collapse faces with arbitrary topology. The name "Collapse Regions" is too vague, users might not think to use this to collapse edge-rings. Use a more verbose name "Collapse Edges & Faces", referencing edge-rings in the tool-tip. --- source/blender/editors/mesh/editmesh_tools.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index eff903d5694..58e10764145 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -731,9 +731,10 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op) void MESH_OT_edge_collapse(wmOperatorType *ot) { /* identifiers */ - ot->name = "Collapse Regions"; + ot->name = "Collapse Edges & Faces"; ot->description = - "Collapse isolated edges & faces regions, merging data such as UV's and vertex colors"; + "Collapse isolated edges & faces regions, merging data such as UV's and vertex colors. " + "This can collapse edge-rings as well as regions of connected faces into vertices"; ot->idname = "MESH_OT_edge_collapse"; /* api callbacks */ -- cgit v1.2.3 From 8d116e99569f9d8a5f297686d2c0e0757fab6daf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 16:19:32 +1100 Subject: Cleanup: use doxy sections --- source/blender/editors/curve/editcurve.c | 241 ++++++++++++++++++++++++++----- 1 file changed, 204 insertions(+), 37 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 47dcc8538d6..c513410cfd9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -81,6 +81,10 @@ static void adduplicateflagNurb( static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split); static bool curve_delete_vertices(Object *obedit, View3D *v3d); +/* -------------------------------------------------------------------- */ +/** \name Utility Functions + * \{ */ + ListBase *object_editcurve_get(Object *ob) { if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) { @@ -90,7 +94,11 @@ ListBase *object_editcurve_get(Object *ob) return NULL; } -/* ******************* PRINTS ********************* */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Debug Printing + * \{ */ #if 0 void printknots(Object *obedit) @@ -118,7 +126,11 @@ void printknots(Object *obedit) } #endif -/* ********************* Shape keys *************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Shape keys + * \{ */ static CVKeyIndex *init_cvKeyIndex( void *cv, int key_index, int nu_index, int pt_index, int vertex_index) @@ -897,7 +909,11 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs) } } -/* ********************* Amimation data *************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Animation Data + * \{ */ static bool curve_is_animated(Curve *cu) { @@ -1114,7 +1130,11 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu) return 1; } -/* ********************* LOAD and MAKE *************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Edit Mode Conversion (Make & Load) + * \{ */ static int *initialize_index_map(Object *obedit, int *r_old_totvert) { @@ -1354,7 +1374,11 @@ void ED_curve_editnurb_free(Object *obedit) BKE_curve_editNurb_free(cu); } -/******************** separate operator ***********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Separate Operator + * \{ */ static int separate_exec(bContext *C, wmOperator *op) { @@ -1495,7 +1519,11 @@ void CURVE_OT_separate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/******************** split operator ***********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split Operator + * \{ */ static int curve_split_exec(bContext *C, wmOperator *op) { @@ -1563,7 +1591,11 @@ void CURVE_OT_split(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************* FLAGS ********************* */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Flag Utility Functions + * \{ */ static bool isNurbselUV(const Nurb *nu, int flag, int *r_u, int *r_v) { @@ -2532,7 +2564,11 @@ static void adduplicateflagNurb( } } -/**************** switch direction operator ***************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Switch Direction Operator + * \{ */ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -2591,7 +2627,11 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/****************** set weight operator *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Weight Operator + * \{ */ static int set_goal_weight_exec(bContext *C, wmOperator *op) { @@ -2654,7 +2694,11 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) RNA_def_float_factor(ot->srna, "weight", 1.0f, 0.0f, 1.0f, "Weight", "", 0.0f, 1.0f); } -/******************* set radius operator ******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Radius Operator + * \{ */ static int set_radius_exec(bContext *C, wmOperator *op) { @@ -2718,7 +2762,11 @@ void CURVE_OT_radius_set(wmOperatorType *ot) ot->srna, "radius", 1.0f, 0.0f, OBJECT_ADD_SIZE_MAXF, "Radius", "", 0.0001f, 10.0f); } -/********************* smooth operator ********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Smooth Vertices Operator + * \{ */ static void smooth_single_bezt(BezTriple *bezt, const BezTriple *bezt_orig_prev, @@ -2875,12 +2923,15 @@ void CURVE_OT_smooth(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + /* -------------------------------------------------------------------- */ -/* Smooth radius/weight/tilt +/** \name Smooth Operator (Radius/Weight/Tilt) Utilities * - * TODO: make smoothing distance based - * TODO: support cyclic curves - */ + * To do: + * - Make smoothing distance based. + * - Support cyclic curves. + * \{ */ static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, const int bp_offset) { @@ -3059,6 +3110,12 @@ static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, cons } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Smooth Weight Operator + * \{ */ + static int curve_smooth_weight_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -3096,6 +3153,12 @@ void CURVE_OT_smooth_weight(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Smooth Radius Operator + * \{ */ + static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -3133,6 +3196,12 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Smooth Tilt Operator + * \{ */ + static int curve_smooth_tilt_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -3170,7 +3239,11 @@ void CURVE_OT_smooth_tilt(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/********************** hide operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Hide Operator + * \{ */ static int hide_exec(bContext *C, wmOperator *op) { @@ -3269,7 +3342,11 @@ void CURVE_OT_hide(wmOperatorType *ot) RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); } -/********************** reveal operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Reveal Operator + * \{ */ static int reveal_exec(bContext *C, wmOperator *op) { @@ -3345,7 +3422,11 @@ void CURVE_OT_reveal(wmOperatorType *ot) RNA_def_boolean(ot->srna, "select", true, "Select", ""); } -/********************** subdivide operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Subdivide Operator + * \{ */ /** * Divide the line segments associated with the currently selected @@ -3800,7 +3881,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/******************** find nearest ************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Cursor Picking API + * \{ */ static void ED_curve_pick_vert__doClosest( void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) @@ -3972,7 +4057,11 @@ static void findselectedNurbvert( } } -/***************** set spline type operator *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Spline Type Operator + * \{ */ static int set_spline_type_exec(bContext *C, wmOperator *op) { @@ -4069,7 +4158,11 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) "Use handles when converting bezier curves into polygons"); } -/***************** set handle type operator *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Set Handle Type Operator + * \{ */ static int set_handle_type_exec(bContext *C, wmOperator *op) { @@ -4127,7 +4220,11 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type"); } -/***************** recalculate handles operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Recalculate Handles Operator + * \{ */ static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op) { @@ -4175,9 +4272,13 @@ void CURVE_OT_normals_make_consistent(wmOperatorType *ot) RNA_def_boolean(ot->srna, "calc_length", false, "Length", "Recalculate handle length"); } -/***************** make segment operator **********************/ +/** \} */ -/* ******************** SKINNING LOFTING!!! ******************** */ +/* -------------------------------------------------------------------- */ +/** \name Make Segment Operator + * + * Also handles skinning & lofting. + * \{ */ static void switchdirection_knots(float *base, int tot) { @@ -4877,7 +4978,11 @@ void CURVE_OT_make_segment(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/***************** pick select from 3d view **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Pick Select from 3D View + * \{ */ bool ED_curve_editnurb_select_pick( bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) @@ -5033,7 +5138,11 @@ bool ED_curve_editnurb_select_pick( return false; } -/******************** spin operator ***********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Spin Operator + * \{ */ /* 'cent' is in object space and 'dvec' in worldspace. */ @@ -5213,7 +5322,11 @@ void CURVE_OT_spin(wmOperatorType *ot) ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); } -/***************** extrude vertex operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Extrude Vertex Operator + * \{ */ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) { @@ -5397,7 +5510,11 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) return changed; } -/***************** add vertex operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Add Vertex Operator + * \{ */ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, @@ -5714,7 +5831,11 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) 1.0e4f); } -/***************** extrude operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Extrude Operator + * \{ */ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -5785,7 +5906,11 @@ void CURVE_OT_extrude(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", ""); } -/***************** make cyclic operator **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Make Cyclic Operator + * \{ */ static bool curve_toggle_cyclic(View3D *v3d, ListBase *editnurb, int direction) { @@ -5951,7 +6076,11 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) "Direction to make surface cyclic in"); } -/********************** add duplicate operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Add Duplicate Operator + * \{ */ static int duplicate_exec(bContext *C, wmOperator *op) { @@ -6007,7 +6136,11 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/********************** delete operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Delete Operator + * \{ */ static bool curve_delete_vertices(Object *obedit, View3D *v3d) { @@ -6553,6 +6686,12 @@ void CURVE_OT_delete(wmOperatorType *ot) ot->prop = prop; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Dissolve Vertices + * \{ */ + static bool test_bezt_is_sel_any(const void *bezt_v, void *user_data) { View3D *v3d = user_data; @@ -6685,6 +6824,12 @@ void CURVE_OT_dissolve_verts(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Decimate Operator + * \{ */ + static bool nurb_bezt_flag_any(const Nurb *nu, const char flag_test) { BezTriple *bezt = nu->bezt; @@ -6778,7 +6923,11 @@ void CURVE_OT_decimate(wmOperatorType *ot) RNA_def_float_factor(ot->srna, "ratio", 1.0f, 0.0f, 1.0f, "Ratio", "", 0.0f, 1.0f); } -/********************** shade smooth/flat operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Shade Smooth/Flat Operator + * \{ */ static int shade_smooth_exec(bContext *C, wmOperator *op) { @@ -6849,8 +6998,16 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/************** join operator, to be used externally? ****************/ -/* TODO: shape keys - as with meshes */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Join Operator + * \{ */ + +/** + * This is used externally, by #OBJECT_OT_join. + * TODO: shape keys - as with meshes. + */ int join_curve_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); @@ -6950,7 +7107,11 @@ int join_curve_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -/***************** clear tilt operator ********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Clear Tilt Operator + * \{ */ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -7052,7 +7213,11 @@ bool ED_curve_active_center(Curve *cu, float center[3]) return true; } -/******************** Match texture space operator ***********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Match Texture Space Operator + * \{ */ static bool match_texture_space_poll(bContext *C) { @@ -7122,3 +7287,5 @@ void CURVE_OT_match_texture_space(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/** \} */ -- cgit v1.2.3 From 9bcc83a5d6f90788db14d5c69085eda2456e4cad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 17:08:41 +1100 Subject: Fix problem extruding curve segments with selected handles Issue introduced in 38685b5a39769 --- source/blender/editors/curve/editcurve.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index c513410cfd9..8a484867e9f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5401,6 +5401,12 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) i = 0; for (bezt = &nu->bezt[0]; i < pnt_len; i++, bezt++) { bool is_selected = BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt); + /* While this gets de-selected, selecting here ensures newly created verts are selected. + * without this, the vertices are copied but only the handles are transformed. + * which seems buggy from a user perspective. */ + if (is_selected) { + bezt->f2 |= SELECT; + } if (bezt_prev && is_prev_selected != is_selected) { int count = i - offset + 1; if (is_prev_selected) { -- cgit v1.2.3 From 29eb8916587be9bc58418937e86802b3d4eca4a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 17:33:24 +1100 Subject: Fix curve shortest path picking with right-click select --- release/scripts/presets/keyconfig/keymap_data/blender_default.py | 2 +- source/blender/editors/curve/editcurve_select.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 971c702aeac..7ee42fc4dc4 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -4043,7 +4043,7 @@ def km_curve(params): {"properties": [("deselect", False)]}), ("curve.select_linked_pick", {"type": 'L', "value": 'PRESS', "shift": True}, {"properties": [("deselect", True)]}), - ("curve.shortest_path_pick", {"type": params.select_mouse, "value": 'CLICK', "ctrl": True}, None), + ("curve.shortest_path_pick", {"type": params.select_mouse, "value": params.select_mouse_value, "ctrl": True}, None), ("curve.separate", {"type": 'P', "value": 'PRESS'}, None), ("curve.split", {"type": 'Y', "value": 'PRESS'}, None), ("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None), diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index 51bb1eafdb9..e590eb64f84 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1825,7 +1825,7 @@ static float curve_calc_dist_span(Nurb *nu, int vert_src, int vert_dst) int i_prev, i; float dist = 0.0f; - BLI_assert(nu->pntsv == 1); + BLI_assert(nu->pntsv <= 1); i_prev = vert_src; i = (i_prev + 1) % u; -- cgit v1.2.3 From 60d3a801db3a848fa82bc4bece08e0d27c7b8ecf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2020 17:24:24 +0100 Subject: Subdiv: Split evaluation begin+refine into separate steps Actually, begin will do the entire initialization. Refine will only refine if there is a topology refiner associated with the Subdiv descriptor. Allows to refine Subdiv to new coarse positions without touching displacement evaluation. Will be needed to update SubdivCCG during sculpt undo. --- source/blender/blenkernel/BKE_subdiv_eval.h | 5 ++++- .../blender/blenkernel/intern/multires_reshape_apply_base.c | 4 ++-- source/blender/blenkernel/intern/multires_reshape_util.c | 2 +- source/blender/blenkernel/intern/subdiv_ccg.c | 2 +- source/blender/blenkernel/intern/subdiv_deform.c | 2 +- source/blender/blenkernel/intern/subdiv_eval.c | 13 ++++++++++--- source/blender/blenkernel/intern/subdiv_mesh.c | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_subdiv_eval.h b/source/blender/blenkernel/BKE_subdiv_eval.h index 3f682716928..aa27df88be8 100644 --- a/source/blender/blenkernel/BKE_subdiv_eval.h +++ b/source/blender/blenkernel/BKE_subdiv_eval.h @@ -38,7 +38,10 @@ bool BKE_subdiv_eval_begin(struct Subdiv *subdiv); /* coarse_vertex_cos is an optional argument which allows to override coordinates of the coarse * mesh. */ -bool BKE_subdiv_eval_update_from_mesh(struct Subdiv *subdiv, +bool BKE_subdiv_eval_begin_from_mesh(struct Subdiv *subdiv, + const struct Mesh *mesh, + const float (*coarse_vertex_cos)[3]); +bool BKE_subdiv_eval_refine_from_mesh(struct Subdiv *subdiv, const struct Mesh *mesh, const float (*coarse_vertex_cos)[3]); diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c index d480c46f2d0..90736de12e1 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c @@ -177,7 +177,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshape_context) { - BKE_subdiv_eval_update_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL); + BKE_subdiv_eval_refine_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL); } void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *reshape_context) @@ -192,7 +192,7 @@ void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *resh float(*deformed_verts)[3] = BKE_multires_create_deformed_base_mesh_vert_coords( depsgraph, object, mmd, NULL); - BKE_subdiv_eval_update_from_mesh( + BKE_subdiv_eval_refine_from_mesh( reshape_context->subdiv, reshape_context->base_mesh, deformed_verts); MEM_freeN(deformed_verts); diff --git a/source/blender/blenkernel/intern/multires_reshape_util.c b/source/blender/blenkernel/intern/multires_reshape_util.c index 759306f9422..5b6e211cc9b 100644 --- a/source/blender/blenkernel/intern/multires_reshape_util.c +++ b/source/blender/blenkernel/intern/multires_reshape_util.c @@ -67,7 +67,7 @@ Subdiv *multires_reshape_create_subdiv(Depsgraph *depsgraph, SubdivSettings subdiv_settings; BKE_multires_subdiv_settings_init(&subdiv_settings, mmd); Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, base_mesh); - if (!BKE_subdiv_eval_update_from_mesh(subdiv, base_mesh, NULL)) { + if (!BKE_subdiv_eval_begin_from_mesh(subdiv, base_mesh, NULL)) { BKE_subdiv_free(subdiv); return NULL; } diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index bdb2a1c5686..521aeb60e66 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -589,7 +589,7 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv, { /* Make sure evaluator is ready. */ BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG); - if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, NULL)) { + if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, NULL)) { if (coarse_mesh->totpoly) { return NULL; } diff --git a/source/blender/blenkernel/intern/subdiv_deform.c b/source/blender/blenkernel/intern/subdiv_deform.c index b5fd3ae63eb..db0a51c390b 100644 --- a/source/blender/blenkernel/intern/subdiv_deform.c +++ b/source/blender/blenkernel/intern/subdiv_deform.c @@ -194,7 +194,7 @@ void BKE_subdiv_deform_coarse_vertices(struct Subdiv *subdiv, BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH); /* Make sure evaluator is up to date with possible new topology, and that * is refined for the new positions of coarse vertices. */ - if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, vertex_cos)) { + if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, vertex_cos)) { /* This could happen in two situations: * - OpenSubdiv is disabled. * - Something totally bad happened, and OpenSubdiv rejected our diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c index 78e0e42753a..1c10a9a1935 100644 --- a/source/blender/blenkernel/intern/subdiv_eval.c +++ b/source/blender/blenkernel/intern/subdiv_eval.c @@ -121,13 +121,20 @@ static void set_face_varying_data_from_uv(Subdiv *subdiv, } } -bool BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv, - const Mesh *mesh, - const float (*coarse_vertex_cos)[3]) +bool BKE_subdiv_eval_begin_from_mesh(Subdiv *subdiv, + const Mesh *mesh, + const float (*coarse_vertex_cos)[3]) { if (!BKE_subdiv_eval_begin(subdiv)) { return false; } + return BKE_subdiv_eval_refine_from_mesh(subdiv, mesh, coarse_vertex_cos); +} + +bool BKE_subdiv_eval_refine_from_mesh(Subdiv *subdiv, + const Mesh *mesh, + const float (*coarse_vertex_cos)[3]) +{ if (subdiv->evaluator == NULL) { /* NOTE: This situation is supposed to be handled by begin(). */ BLI_assert(!"Is not supposed to happen"); diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index cdb766f2507..bd091108b11 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -1168,7 +1168,7 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv, BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH); /* Make sure evaluator is up to date with possible new topology, and that * it is refined for the new positions of coarse vertices. */ - if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, NULL)) { + if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, NULL)) { /* This could happen in two situations: * - OpenSubdiv is disabled. * - Something totally bad happened, and OpenSubdiv rejected our -- cgit v1.2.3 From 7952274cf0c4a262c274fa93c800c84c1aa2d5d7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2020 16:37:29 +0100 Subject: Sculpt Undo: Refactor Geometry undo nodes Made it so there is a single UNDO node in the list which has both original and modified mesh state. Makes it easier to achieve "interleaved" undo nodes stored in the undo step (as opposite of either storing geometry or other data). Should be no functional changes, just preparing for an upcoming work to support undo of operation like Apply Base. Differential Revision: https://developer.blender.org/D7290 --- source/blender/editors/sculpt_paint/sculpt.c | 17 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 37 +++- source/blender/editors/sculpt_paint/sculpt_undo.c | 202 ++++++++++++--------- 3 files changed, 157 insertions(+), 99 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 25cf17b12ce..82f9bbc5f56 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -8362,19 +8362,20 @@ static void sculpt_dynamic_topology_disable_ex( CustomData_free(&me->pdata, me->totpoly); /* Copy over stored custom data. */ - me->totvert = unode->geom_totvert; - me->totloop = unode->geom_totloop; - me->totpoly = unode->geom_totpoly; - me->totedge = unode->geom_totedge; + SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter; + me->totvert = geometry->totvert; + me->totloop = geometry->totloop; + me->totpoly = geometry->totpoly; + me->totedge = geometry->totedge; me->totface = 0; CustomData_copy( - &unode->geom_vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, unode->geom_totvert); + &geometry->vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert); CustomData_copy( - &unode->geom_edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, unode->geom_totedge); + &geometry->edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge); CustomData_copy( - &unode->geom_ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, unode->geom_totloop); + &geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop); CustomData_copy( - &unode->geom_pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, unode->geom_totpoly); + &geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly); BKE_mesh_update_customdata_pointers(me, false); } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index fe56283dbcb..478d2be9a30 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -299,6 +299,23 @@ typedef enum { SCULPT_UNDO_FACE_SETS, } SculptUndoType; +/* Storage of geometry for the undo node. + * Is used as a storage for either original or modified geometry. */ +typedef struct SculptUndoNodeGeometry { + /* Is used for sanity check, helping with ensuring that two and only two + * geometry pushes happenned in the undo stack. */ + bool is_initialized; + + CustomData vdata; + CustomData edata; + CustomData ldata; + CustomData pdata; + int totvert; + int totedge; + int totloop; + int totpoly; +} SculptUndoNodeGeometry; + typedef struct SculptUndoNode { struct SculptUndoNode *next, *prev; @@ -332,15 +349,17 @@ typedef struct SculptUndoNode { /* shape keys */ char shapeName[sizeof(((KeyBlock *)0))->name]; - /* geometry modification operations and bmesh enter data */ - CustomData geom_vdata; - CustomData geom_edata; - CustomData geom_ldata; - CustomData geom_pdata; - int geom_totvert; - int geom_totedge; - int geom_totloop; - int geom_totpoly; + /* Geometry modification operations. + * + * Original geometry is stored before some modification is run and is used to restore state of + * the object when undoing the operation + * + * Modified geometry is stored after the modification and is used to redo the modification. */ + SculptUndoNodeGeometry geometry_original; + SculptUndoNodeGeometry geometry_modified; + + /* Geometry at the bmesh enter moment. */ + SculptUndoNodeGeometry geometry_bmesh_enter; /* pivot */ float pivot_pos[3]; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 5233ce8d257..67ef82aeaaf 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -447,30 +447,82 @@ static void sculpt_undo_bmesh_restore_end(bContext *C, } } -static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *ob) +static void sculpt_undo_geometry_store_data(SculptUndoNodeGeometry *geometry, Object *object) { - Mesh *me; - sculpt_pbvh_clear(ob); - me = ob->data; - 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); - me->totvert = unode->geom_totvert; - me->totedge = unode->geom_totedge; - me->totloop = unode->geom_totloop; - me->totpoly = unode->geom_totpoly; - me->totface = 0; + Mesh *mesh = object->data; + + BLI_assert(!geometry->is_initialized); + geometry->is_initialized = true; + + CustomData_copy(&mesh->vdata, &geometry->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, mesh->totvert); + CustomData_copy(&mesh->edata, &geometry->edata, CD_MASK_MESH.emask, CD_DUPLICATE, mesh->totedge); + CustomData_copy(&mesh->ldata, &geometry->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, mesh->totloop); + CustomData_copy(&mesh->pdata, &geometry->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, mesh->totpoly); + + geometry->totvert = mesh->totvert; + geometry->totedge = mesh->totedge; + geometry->totloop = mesh->totloop; + geometry->totpoly = mesh->totpoly; +} + +static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry, Object *object) +{ + Mesh *mesh = object->data; + + BLI_assert(geometry->is_initialized); + + 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); + + mesh->totvert = geometry->totvert; + mesh->totedge = geometry->totedge; + mesh->totloop = geometry->totloop; + mesh->totpoly = geometry->totpoly; + mesh->totface = 0; + CustomData_copy( - &unode->geom_vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, unode->geom_totvert); + &geometry->vdata, &mesh->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert); CustomData_copy( - &unode->geom_edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, unode->geom_totedge); + &geometry->edata, &mesh->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge); CustomData_copy( - &unode->geom_ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, unode->geom_totloop); + &geometry->ldata, &mesh->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop); CustomData_copy( - &unode->geom_pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, unode->geom_totpoly); - BKE_mesh_update_customdata_pointers(me, false); + &geometry->pdata, &mesh->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly); + + BKE_mesh_update_customdata_pointers(mesh, false); +} + +static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry) +{ + if (geometry->totvert) { + CustomData_free(&geometry->vdata, geometry->totvert); + } + if (geometry->totedge) { + CustomData_free(&geometry->edata, geometry->totedge); + } + if (geometry->totloop) { + CustomData_free(&geometry->ldata, geometry->totloop); + } + if (geometry->totpoly) { + CustomData_free(&geometry->pdata, geometry->totpoly); + } +} + +static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *object) +{ + sculpt_pbvh_clear(object); + + if (unode->applied) { + sculpt_undo_geometry_restore_data(&unode->geometry_modified, object); + unode->applied = false; + } + else { + sculpt_undo_geometry_restore_data(&unode->geometry_original, object); + unode->applied = true; + } } /* Handle all dynamic-topology updates @@ -532,16 +584,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase if (lb->first) { unode = lb->first; if (unode->type == SCULPT_UNDO_GEOMETRY) { - if (unode->applied) { - sculpt_undo_geometry_restore(unode->next, ob); - unode->next->applied = true; - unode->applied = false; - } - else { - sculpt_undo_geometry_restore(unode, ob); - unode->next->applied = false; - unode->applied = true; - } + sculpt_undo_geometry_restore(unode, ob); BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); return; } @@ -741,18 +784,8 @@ static void sculpt_undo_free_list(ListBase *lb) BM_log_entry_drop(unode->bm_entry); } - if (unode->geom_totvert) { - CustomData_free(&unode->geom_vdata, unode->geom_totvert); - } - if (unode->geom_totedge) { - CustomData_free(&unode->geom_edata, unode->geom_totedge); - } - if (unode->geom_totloop) { - CustomData_free(&unode->geom_ldata, unode->geom_totloop); - } - if (unode->geom_totpoly) { - CustomData_free(&unode->geom_pdata, unode->geom_totpoly); - } + sculpt_undo_geometry_free_data(&unode->geometry_original); + sculpt_undo_geometry_free_data(&unode->geometry_modified); if (unode->face_sets) { MEM_freeN(unode->face_sets); @@ -820,16 +853,43 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode } } +/* Allocate node and initialize its default fields specific for the given undo type. + * Will also add the node to the list in the undo step. */ +static SculptUndoNode *sculpt_undo_alloc_node_type(Object *object, SculptUndoType type) +{ + SculptUndoNode *unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); + BLI_strncpy(unode->idname, object->id.name, sizeof(unode->idname)); + unode->type = type; + + UndoSculpt *usculpt = sculpt_undo_get_nodes(); + BLI_addtail(&usculpt->nodes, unode); + + return unode; +} + +/* Will return first existing undo node of the given type. + * If such node does not exist will allocate node of this type, register it in the undo step and + * return it. */ +static SculptUndoNode *sculpt_undo_find_or_alloc_node_type(Object *object, SculptUndoType type) +{ + UndoSculpt *usculpt = sculpt_undo_get_nodes(); + + LISTBASE_FOREACH (SculptUndoNode *, unode, &usculpt->nodes) { + if (unode->type == type) { + return unode; + } + } + + return sculpt_undo_alloc_node_type(object, type); +} + static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, SculptUndoType type) { UndoSculpt *usculpt = sculpt_undo_get_nodes(); - SculptUndoNode *unode; SculptSession *ss = ob->sculpt; int totvert, allvert, totgrid, maxgrid, gridsize, *grids; - unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); - BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname)); - unode->type = type; + SculptUndoNode *unode = sculpt_undo_alloc_node_type(ob, type); unode->node = node; if (node) { @@ -876,8 +936,6 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt break; } - BLI_addtail(&usculpt->nodes, unode); - if (maxgrid) { /* Multires. */ unode->maxgrid = maxgrid; @@ -954,32 +1012,24 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode) BKE_pbvh_vertex_iter_end; } -static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type) +static SculptUndoNodeGeometry *sculpt_undo_geometry_get(SculptUndoNode *unode) { - UndoSculpt *usculpt = sculpt_undo_get_nodes(); - Mesh *me = ob->data; - bool applied; - - SculptUndoNode *unode = usculpt->nodes.first; - /* Store the original mesh in the first node, modifications in the second. */ - applied = unode != NULL; + if (!unode->geometry_original.is_initialized) { + return &unode->geometry_original; + } - unode = MEM_callocN(sizeof(*unode), __func__); + BLI_assert(!unode->geometry_modified.is_initialized); - BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname)); - unode->type = type; - unode->applied = applied; + return &unode->geometry_modified; +} - CustomData_copy(&me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert); - CustomData_copy(&me->edata, &unode->geom_edata, CD_MASK_MESH.emask, CD_DUPLICATE, me->totedge); - CustomData_copy(&me->ldata, &unode->geom_ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, me->totloop); - CustomData_copy(&me->pdata, &unode->geom_pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, me->totpoly); - unode->geom_totvert = me->totvert; - unode->geom_totedge = me->totedge; - unode->geom_totloop = me->totloop; - unode->geom_totpoly = me->totpoly; +static SculptUndoNode *sculpt_undo_geometry_push(Object *object, SculptUndoType type) +{ + SculptUndoNode *unode = sculpt_undo_find_or_alloc_node_type(object, type); + unode->applied = false; - BLI_addtail(&usculpt->nodes, unode); + SculptUndoNodeGeometry *geometry = sculpt_undo_geometry_get(unode); + sculpt_undo_geometry_store_data(geometry, object); return unode; } @@ -1029,25 +1079,13 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt BM_log_before_all_removed(ss->bm, ss->bm_log); } else if (type == SCULPT_UNDO_DYNTOPO_BEGIN) { - Mesh *me = ob->data; - /* Store a copy of the mesh's current vertices, loops, and * polys. A full copy like this is needed because entering * dynamic-topology immediately does topological edits * (converting polys to triangles) that the BMLog can't * fully restore from. */ - CustomData_copy( - &me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert); - CustomData_copy( - &me->edata, &unode->geom_edata, CD_MASK_MESH.emask, CD_DUPLICATE, me->totedge); - CustomData_copy( - &me->ldata, &unode->geom_ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, me->totloop); - CustomData_copy( - &me->pdata, &unode->geom_pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, me->totpoly); - unode->geom_totvert = me->totvert; - unode->geom_totedge = me->totedge; - unode->geom_totloop = me->totloop; - unode->geom_totpoly = me->totpoly; + SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter; + sculpt_undo_geometry_store_data(geometry, ob); unode->bm_entry = BM_log_entry_add(ss->bm_log); BM_log_all_added(ss->bm, ss->bm_log); -- cgit v1.2.3 From 2ad0ae8dadb7eb1e956b6d6c4583f1fa1f7fba4f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 09:40:11 +0200 Subject: Tweak write code to allow cleaning up runtime data before write. This basically generalizes what was being done in `write_mesh`, since we need to clean up ID tags anyway, it's easier to do it for all IDs. Then ID write funcs themsleves can do whatever they want on the passed struct, without risking interferring with regular Blender operations. Note that Text write function is doing a suspicious change on one of its flags, but this seems to be by-passed anyway by read code currently, so think it's OK to not do that on orig data-block. Reviewed By: brecht Differential Revision: https://developer.blender.org/D7294 --- source/blender/blenloader/intern/writefile.c | 266 +++++++++++++-------------- 1 file changed, 130 insertions(+), 136 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2c0dcd83cea..1ca8e7d5ade 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -854,10 +854,10 @@ static void write_fcurves(WriteData *wd, ListBase *fcurves) } } -static void write_action(WriteData *wd, bAction *act) +static void write_action(WriteData *wd, bAction *act, const void *id_address) { if (act->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_AC, bAction, 1, act); + writestruct_at_address(wd, ID_AC, bAction, 1, id_address, act); write_iddata(wd, &act->id); write_fcurves(wd, &act->curves); @@ -1391,11 +1391,11 @@ static void write_pointcaches(WriteData *wd, ListBase *ptcaches) } } -static void write_particlesettings(WriteData *wd, ParticleSettings *part) +static void write_particlesettings(WriteData *wd, ParticleSettings *part, const void *id_address) { if (part->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_PA, ParticleSettings, 1, part); + writestruct_at_address(wd, ID_PA, ParticleSettings, 1, id_address, part); write_iddata(wd, &part->id); if (part->adt) { @@ -1900,11 +1900,11 @@ static void write_shaderfxs(WriteData *wd, ListBase *fxbase) } } -static void write_object(WriteData *wd, Object *ob) +static void write_object(WriteData *wd, Object *ob, const void *id_address) { if (ob->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_OB, Object, 1, ob); + writestruct_at_address(wd, ID_OB, Object, 1, id_address, ob); write_iddata(wd, &ob->id); if (ob->adt) { @@ -1965,11 +1965,11 @@ static void write_object(WriteData *wd, Object *ob) } } -static void write_vfont(WriteData *wd, VFont *vf) +static void write_vfont(WriteData *wd, VFont *vf, const void *id_address) { if (vf->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_VF, VFont, 1, vf); + writestruct_at_address(wd, ID_VF, VFont, 1, id_address, vf); write_iddata(wd, &vf->id); /* direct data */ @@ -1981,11 +1981,11 @@ static void write_vfont(WriteData *wd, VFont *vf) } } -static void write_key(WriteData *wd, Key *key) +static void write_key(WriteData *wd, Key *key, const void *id_address) { if (key->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_KE, Key, 1, key); + writestruct_at_address(wd, ID_KE, Key, 1, id_address, key); write_iddata(wd, &key->id); if (key->adt) { @@ -2002,11 +2002,11 @@ static void write_key(WriteData *wd, Key *key) } } -static void write_camera(WriteData *wd, Camera *cam) +static void write_camera(WriteData *wd, Camera *cam, const void *id_address) { if (cam->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_CA, Camera, 1, cam); + writestruct_at_address(wd, ID_CA, Camera, 1, id_address, cam); write_iddata(wd, &cam->id); if (cam->adt) { @@ -2019,11 +2019,11 @@ static void write_camera(WriteData *wd, Camera *cam) } } -static void write_mball(WriteData *wd, MetaBall *mb) +static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) { if (mb->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_MB, MetaBall, 1, mb); + writestruct_at_address(wd, ID_MB, MetaBall, 1, id_address, mb); write_iddata(wd, &mb->id); /* direct data */ @@ -2038,11 +2038,11 @@ static void write_mball(WriteData *wd, MetaBall *mb) } } -static void write_curve(WriteData *wd, Curve *cu) +static void write_curve(WriteData *wd, Curve *cu, const void *id_address) { if (cu->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_CU, Curve, 1, cu); + writestruct_at_address(wd, ID_CU, Curve, 1, id_address, cu); write_iddata(wd, &cu->id); /* direct data */ @@ -2195,15 +2195,9 @@ static void write_customdata(WriteData *wd, } } -static void write_mesh(WriteData *wd, Mesh *mesh) +static void write_mesh(WriteData *wd, Mesh *mesh, const void *id_address) { if (mesh->id.us > 0 || wd->use_memfile) { - /* Write a copy of the mesh with possibly reduced number of data layers. - * Don't edit the original since other threads might be reading it. */ - Mesh *old_mesh = mesh; - Mesh copy_mesh = *mesh; - mesh = ©_mesh; - /* cache only - don't write */ mesh->mface = NULL; mesh->totface = 0; @@ -2225,7 +2219,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh) CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); - writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); + writestruct_at_address(wd, ID_ME, Mesh, 1, id_address, mesh); write_iddata(wd, &mesh->id); /* direct data */ @@ -2243,9 +2237,6 @@ static void write_mesh(WriteData *wd, Mesh *mesh) write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask); write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask); - /* restore pointer */ - mesh = old_mesh; - /* free temporary data */ if (vlayers && vlayers != vlayers_buff) { MEM_freeN(vlayers); @@ -2265,11 +2256,11 @@ static void write_mesh(WriteData *wd, Mesh *mesh) } } -static void write_lattice(WriteData *wd, Lattice *lt) +static void write_lattice(WriteData *wd, Lattice *lt, const void *id_address) { if (lt->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_LT, Lattice, 1, lt); + writestruct_at_address(wd, ID_LT, Lattice, 1, id_address, lt); write_iddata(wd, <->id); /* write animdata */ @@ -2284,7 +2275,7 @@ static void write_lattice(WriteData *wd, Lattice *lt) } } -static void write_image(WriteData *wd, Image *ima) +static void write_image(WriteData *wd, Image *ima, const void *id_address) { if (ima->id.us > 0 || wd->use_memfile) { ImagePackedFile *imapf; @@ -2297,7 +2288,7 @@ static void write_image(WriteData *wd, Image *ima) } /* write LibData */ - writestruct(wd, ID_IM, Image, 1, ima); + writestruct_at_address(wd, ID_IM, Image, 1, id_address, ima); write_iddata(wd, &ima->id); for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { @@ -2324,11 +2315,11 @@ static void write_image(WriteData *wd, Image *ima) } } -static void write_texture(WriteData *wd, Tex *tex) +static void write_texture(WriteData *wd, Tex *tex, const void *id_address) { if (tex->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_TE, Tex, 1, tex); + writestruct_at_address(wd, ID_TE, Tex, 1, id_address, tex); write_iddata(wd, &tex->id); if (tex->adt) { @@ -2350,11 +2341,11 @@ static void write_texture(WriteData *wd, Tex *tex) } } -static void write_material(WriteData *wd, Material *ma) +static void write_material(WriteData *wd, Material *ma, const void *id_address) { if (ma->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_MA, Material, 1, ma); + writestruct_at_address(wd, ID_MA, Material, 1, id_address, ma); write_iddata(wd, &ma->id); if (ma->adt) { @@ -2376,11 +2367,11 @@ static void write_material(WriteData *wd, Material *ma) } } -static void write_world(WriteData *wd, World *wrld) +static void write_world(WriteData *wd, World *wrld, const void *id_address) { if (wrld->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_WO, World, 1, wrld); + writestruct_at_address(wd, ID_WO, World, 1, id_address, wrld); write_iddata(wd, &wrld->id); if (wrld->adt) { @@ -2397,11 +2388,11 @@ static void write_world(WriteData *wd, World *wrld) } } -static void write_light(WriteData *wd, Light *la) +static void write_light(WriteData *wd, Light *la, const void *id_address) { if (la->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_LA, Light, 1, la); + writestruct_at_address(wd, ID_LA, Light, 1, id_address, la); write_iddata(wd, &la->id); if (la->adt) { @@ -2441,11 +2432,11 @@ static void write_collection_nolib(WriteData *wd, Collection *collection) } } -static void write_collection(WriteData *wd, Collection *collection) +static void write_collection(WriteData *wd, Collection *collection, const void *id_address) { if (collection->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_GR, Collection, 1, collection); + writestruct_at_address(wd, ID_GR, Collection, 1, id_address, collection); write_iddata(wd, &collection->id); write_collection_nolib(wd, collection); @@ -2560,10 +2551,10 @@ static void write_lightcache(WriteData *wd, LightCache *cache) writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data); } -static void write_scene(WriteData *wd, Scene *sce) +static void write_scene(WriteData *wd, Scene *sce, const void *id_address) { /* write LibData */ - writestruct(wd, ID_SCE, Scene, 1, sce); + writestruct_at_address(wd, ID_SCE, Scene, 1, id_address, sce); write_iddata(wd, &sce->id); if (sce->adt) { @@ -2786,11 +2777,11 @@ static void write_scene(WriteData *wd, Scene *sce) BLI_assert(sce->layer_properties == NULL); } -static void write_gpencil(WriteData *wd, bGPdata *gpd) +static void write_gpencil(WriteData *wd, bGPdata *gpd, const void *id_address) { if (gpd->id.us > 0 || wd->use_memfile) { /* write gpd data block to file */ - writestruct(wd, ID_GD, bGPdata, 1, gpd); + writestruct_at_address(wd, ID_GD, bGPdata, 1, id_address, gpd); write_iddata(wd, &gpd->id); if (gpd->adt) { @@ -3066,9 +3057,9 @@ static void write_area_map(WriteData *wd, ScrAreaMap *area_map) } } -static void write_windowmanager(WriteData *wd, wmWindowManager *wm) +static void write_windowmanager(WriteData *wd, wmWindowManager *wm, const void *id_address) { - writestruct(wd, ID_WM, wmWindowManager, 1, wm); + writestruct_at_address(wd, ID_WM, wmWindowManager, 1, id_address, wm); write_iddata(wd, &wm->id); write_wm_xr_data(wd, &wm->xr); @@ -3097,13 +3088,13 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm) } } -static void write_screen(WriteData *wd, bScreen *sc) +static void write_screen(WriteData *wd, bScreen *sc, const void *id_address) { /* Screens are reference counted, only saved if used by a workspace. */ if (sc->id.us > 0 || wd->use_memfile) { /* write LibData */ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ - writestruct(wd, ID_SCRN, bScreen, 1, sc); + writestruct_at_address(wd, ID_SCRN, bScreen, 1, id_address, sc); write_iddata(wd, &sc->id); write_previews(wd, sc->preview); @@ -3133,10 +3124,10 @@ static void write_bone(WriteData *wd, Bone *bone) } } -static void write_armature(WriteData *wd, bArmature *arm) +static void write_armature(WriteData *wd, bArmature *arm, const void *id_address) { if (arm->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_AR, bArmature, 1, arm); + writestruct_at_address(wd, ID_AR, bArmature, 1, id_address, arm); write_iddata(wd, &arm->id); if (arm->adt) { @@ -3150,14 +3141,15 @@ static void write_armature(WriteData *wd, bArmature *arm) } } -static void write_text(WriteData *wd, Text *text) +static void write_text(WriteData *wd, Text *text, const void *id_address) { + /* Note: we are clearing local temp data here, *not* the flag in the actual 'real' ID. */ if ((text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) { text->flags &= ~TXT_ISEXT; } /* write LibData */ - writestruct(wd, ID_TXT, Text, 1, text); + writestruct_at_address(wd, ID_TXT, Text, 1, id_address, text); write_iddata(wd, &text->id); if (text->name) { @@ -3176,11 +3168,11 @@ static void write_text(WriteData *wd, Text *text) } } -static void write_speaker(WriteData *wd, Speaker *spk) +static void write_speaker(WriteData *wd, Speaker *spk, const void *id_address) { if (spk->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_SPK, Speaker, 1, spk); + writestruct_at_address(wd, ID_SPK, Speaker, 1, id_address, spk); write_iddata(wd, &spk->id); if (spk->adt) { @@ -3189,11 +3181,11 @@ static void write_speaker(WriteData *wd, Speaker *spk) } } -static void write_sound(WriteData *wd, bSound *sound) +static void write_sound(WriteData *wd, bSound *sound, const void *id_address) { if (sound->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_SO, bSound, 1, sound); + writestruct_at_address(wd, ID_SO, bSound, 1, id_address, sound); write_iddata(wd, &sound->id); if (sound->packedfile) { @@ -3204,11 +3196,11 @@ static void write_sound(WriteData *wd, bSound *sound) } } -static void write_probe(WriteData *wd, LightProbe *prb) +static void write_probe(WriteData *wd, LightProbe *prb, const void *id_address) { if (prb->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_LP, LightProbe, 1, prb); + writestruct_at_address(wd, ID_LP, LightProbe, 1, id_address, prb); write_iddata(wd, &prb->id); if (prb->adt) { @@ -3217,10 +3209,10 @@ static void write_probe(WriteData *wd, LightProbe *prb) } } -static void write_nodetree(WriteData *wd, bNodeTree *ntree) +static void write_nodetree(WriteData *wd, bNodeTree *ntree, const void *id_address) { if (ntree->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_NT, bNodeTree, 1, ntree); + writestruct_at_address(wd, ID_NT, bNodeTree, 1, id_address, ntree); /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot * be linked, etc., so we write actual id data here only, for 'real' ID trees. */ write_iddata(wd, &ntree->id); @@ -3229,10 +3221,10 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) } } -static void write_brush(WriteData *wd, Brush *brush) +static void write_brush(WriteData *wd, Brush *brush, const void *id_address) { if (brush->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_BR, Brush, 1, brush); + writestruct_at_address(wd, ID_BR, Brush, 1, id_address, brush); write_iddata(wd, &brush->id); if (brush->curve) { @@ -3258,11 +3250,11 @@ static void write_brush(WriteData *wd, Brush *brush) } } -static void write_palette(WriteData *wd, Palette *palette) +static void write_palette(WriteData *wd, Palette *palette, const void *id_address) { if (palette->id.us > 0 || wd->use_memfile) { PaletteColor *color; - writestruct(wd, ID_PAL, Palette, 1, palette); + writestruct_at_address(wd, ID_PAL, Palette, 1, id_address, palette); write_iddata(wd, &palette->id); for (color = palette->colors.first; color; color = color->next) { @@ -3271,10 +3263,10 @@ static void write_palette(WriteData *wd, Palette *palette) } } -static void write_paintcurve(WriteData *wd, PaintCurve *pc) +static void write_paintcurve(WriteData *wd, PaintCurve *pc, const void *id_address) { if (pc->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_PC, PaintCurve, 1, pc); + writestruct_at_address(wd, ID_PC, PaintCurve, 1, id_address, pc); write_iddata(wd, &pc->id); writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points); @@ -3320,13 +3312,13 @@ static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction } } -static void write_movieclip(WriteData *wd, MovieClip *clip) +static void write_movieclip(WriteData *wd, MovieClip *clip, const void *id_address) { if (clip->id.us > 0 || wd->use_memfile) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; - writestruct(wd, ID_MC, MovieClip, 1, clip); + writestruct_at_address(wd, ID_MC, MovieClip, 1, id_address, clip); write_iddata(wd, &clip->id); if (clip->adt) { @@ -3350,12 +3342,12 @@ static void write_movieclip(WriteData *wd, MovieClip *clip) } } -static void write_mask(WriteData *wd, Mask *mask) +static void write_mask(WriteData *wd, Mask *mask, const void *id_address) { if (mask->id.us > 0 || wd->use_memfile) { MaskLayer *masklay; - writestruct(wd, ID_MSK, Mask, 1, mask); + writestruct_at_address(wd, ID_MSK, Mask, 1, id_address, mask); write_iddata(wd, &mask->id); if (mask->adt) { @@ -3657,10 +3649,10 @@ static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifier } } -static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle) +static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle, const void *id_address) { if (linestyle->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle); + writestruct_at_address(wd, ID_LS, FreestyleLineStyle, 1, id_address, linestyle); write_iddata(wd, &linestyle->id); if (linestyle->adt) { @@ -3683,10 +3675,10 @@ static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle) } } -static void write_cachefile(WriteData *wd, CacheFile *cache_file) +static void write_cachefile(WriteData *wd, CacheFile *cache_file, const void *id_address) { if (cache_file->id.us > 0 || wd->use_memfile) { - writestruct(wd, ID_CF, CacheFile, 1, cache_file); + writestruct_at_address(wd, ID_CF, CacheFile, 1, id_address, cache_file); if (cache_file->adt) { write_animdata(wd, cache_file->adt); @@ -3694,11 +3686,11 @@ static void write_cachefile(WriteData *wd, CacheFile *cache_file) } } -static void write_workspace(WriteData *wd, WorkSpace *workspace) +static void write_workspace(WriteData *wd, WorkSpace *workspace, const void *id_address) { ListBase *layouts = BKE_workspace_layouts_get(workspace); - writestruct(wd, ID_WS, WorkSpace, 1, workspace); + writestruct_at_address(wd, ID_WS, WorkSpace, 1, id_address, workspace); write_iddata(wd, &workspace->id); writelist(wd, DATA, WorkSpaceLayout, layouts); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); @@ -3711,22 +3703,16 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace) } } -static void write_hair(WriteData *wd, Hair *hair) +static void write_hair(WriteData *wd, Hair *hair, const void *id_address) { if (hair->id.us > 0 || wd->use_memfile) { - /* Write a copy of the hair with possibly reduced number of data layers. - * Don't edit the original since other threads might be reading it. */ - Hair *old_hair = hair; - Hair copy_hair = *hair; - hair = ©_hair; - CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; CustomDataLayer *clayers = NULL, clayers_buff[CD_TEMP_CHUNK_SIZE]; CustomData_file_write_prepare(&hair->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); CustomData_file_write_prepare(&hair->cdata, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff)); /* Write LibData */ - writestruct_at_address(wd, ID_HA, Hair, 1, old_hair, hair); + writestruct_at_address(wd, ID_HA, Hair, 1, id_address, hair); write_iddata(wd, &hair->id); /* Direct data */ @@ -3744,27 +3730,18 @@ static void write_hair(WriteData *wd, Hair *hair) if (clayers && clayers != clayers_buff) { MEM_freeN(clayers); } - - /* restore pointer */ - hair = old_hair; } } -static void write_pointcloud(WriteData *wd, PointCloud *pointcloud) +static void write_pointcloud(WriteData *wd, PointCloud *pointcloud, const void *id_address) { if (pointcloud->id.us > 0 || wd->use_memfile) { - /* Write a copy of the pointcloud with possibly reduced number of data layers. - * Don't edit the original since other threads might be reading it. */ - PointCloud *old_pointcloud = pointcloud; - PointCloud copy_pointcloud = *pointcloud; - pointcloud = ©_pointcloud; - CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; CustomData_file_write_prepare( &pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); /* Write LibData */ - writestruct_at_address(wd, ID_PT, PointCloud, 1, old_pointcloud, pointcloud); + writestruct_at_address(wd, ID_PT, PointCloud, 1, id_address, pointcloud); write_iddata(wd, &pointcloud->id); /* Direct data */ @@ -3782,11 +3759,11 @@ static void write_pointcloud(WriteData *wd, PointCloud *pointcloud) } } -static void write_volume(WriteData *wd, Volume *volume) +static void write_volume(WriteData *wd, Volume *volume, const void *id_address) { if (volume->id.us > 0 || wd->use_memfile) { /* write LibData */ - writestruct(wd, ID_VO, Volume, 1, volume); + writestruct_at_address(wd, ID_VO, Volume, 1, id_address, volume); write_iddata(wd, &volume->id); /* direct data */ @@ -3979,6 +3956,7 @@ static bool write_file_handle(Main *mainvar, OverrideLibraryStorage *override_storage = wd->use_memfile ? NULL : BKE_lib_override_library_operations_store_initialize(); +#define ID_BUFFER_STATIC_SIZE 8192 /* This outer loop allows to save first data-blocks from real mainvar, * then the temp ones from override process, * if needed, without duplicating whole code. */ @@ -3989,10 +3967,18 @@ static bool write_file_handle(Main *mainvar, while (a--) { ID *id = lbarray[a]->first; - if (id && GS(id->name) == ID_LI) { + if (id == NULL || GS(id->name) == ID_LI) { continue; /* Libraries are handled separately below. */ } + char id_buffer_static[ID_BUFFER_STATIC_SIZE]; + void *id_buffer = id_buffer_static; + const size_t idtype_struct_size = BKE_idtype_get_info_from_id(id)->struct_size; + if (idtype_struct_size > ID_BUFFER_STATIC_SIZE) { + BLI_assert(0); + id_buffer = MEM_mallocN(idtype_struct_size, __func__); + } + for (; id; id = id->next) { /* We should never attempt to write non-regular IDs * (i.e. all kind of temp/runtime ones). */ @@ -4005,117 +3991,121 @@ static bool write_file_handle(Main *mainvar, BKE_lib_override_library_operations_store_start(bmain, override_storage, id); } + memcpy(id_buffer, id, idtype_struct_size); + + ((ID *)id_buffer)->tag = 0; + switch ((ID_Type)GS(id->name)) { case ID_WM: - write_windowmanager(wd, (wmWindowManager *)id); + write_windowmanager(wd, (wmWindowManager *)id_buffer, id); break; case ID_WS: - write_workspace(wd, (WorkSpace *)id); + write_workspace(wd, (WorkSpace *)id_buffer, id); break; case ID_SCR: - write_screen(wd, (bScreen *)id); + write_screen(wd, (bScreen *)id_buffer, id); break; case ID_MC: - write_movieclip(wd, (MovieClip *)id); + write_movieclip(wd, (MovieClip *)id_buffer, id); break; case ID_MSK: - write_mask(wd, (Mask *)id); + write_mask(wd, (Mask *)id_buffer, id); break; case ID_SCE: - write_scene(wd, (Scene *)id); + write_scene(wd, (Scene *)id_buffer, id); break; case ID_CU: - write_curve(wd, (Curve *)id); + write_curve(wd, (Curve *)id_buffer, id); break; case ID_MB: - write_mball(wd, (MetaBall *)id); + write_mball(wd, (MetaBall *)id_buffer, id); break; case ID_IM: - write_image(wd, (Image *)id); + write_image(wd, (Image *)id_buffer, id); break; case ID_CA: - write_camera(wd, (Camera *)id); + write_camera(wd, (Camera *)id_buffer, id); break; case ID_LA: - write_light(wd, (Light *)id); + write_light(wd, (Light *)id_buffer, id); break; case ID_LT: - write_lattice(wd, (Lattice *)id); + write_lattice(wd, (Lattice *)id_buffer, id); break; case ID_VF: - write_vfont(wd, (VFont *)id); + write_vfont(wd, (VFont *)id_buffer, id); break; case ID_KE: - write_key(wd, (Key *)id); + write_key(wd, (Key *)id_buffer, id); break; case ID_WO: - write_world(wd, (World *)id); + write_world(wd, (World *)id_buffer, id); break; case ID_TXT: - write_text(wd, (Text *)id); + write_text(wd, (Text *)id_buffer, id); break; case ID_SPK: - write_speaker(wd, (Speaker *)id); + write_speaker(wd, (Speaker *)id_buffer, id); break; case ID_LP: - write_probe(wd, (LightProbe *)id); + write_probe(wd, (LightProbe *)id_buffer, id); break; case ID_SO: - write_sound(wd, (bSound *)id); + write_sound(wd, (bSound *)id_buffer, id); break; case ID_GR: - write_collection(wd, (Collection *)id); + write_collection(wd, (Collection *)id_buffer, id); break; case ID_AR: - write_armature(wd, (bArmature *)id); + write_armature(wd, (bArmature *)id_buffer, id); break; case ID_AC: - write_action(wd, (bAction *)id); + write_action(wd, (bAction *)id_buffer, id); break; case ID_OB: - write_object(wd, (Object *)id); + write_object(wd, (Object *)id_buffer, id); break; case ID_MA: - write_material(wd, (Material *)id); + write_material(wd, (Material *)id_buffer, id); break; case ID_TE: - write_texture(wd, (Tex *)id); + write_texture(wd, (Tex *)id_buffer, id); break; case ID_ME: - write_mesh(wd, (Mesh *)id); + write_mesh(wd, (Mesh *)id_buffer, id); break; case ID_PA: - write_particlesettings(wd, (ParticleSettings *)id); + write_particlesettings(wd, (ParticleSettings *)id_buffer, id); break; case ID_NT: - write_nodetree(wd, (bNodeTree *)id); + write_nodetree(wd, (bNodeTree *)id_buffer, id); break; case ID_BR: - write_brush(wd, (Brush *)id); + write_brush(wd, (Brush *)id_buffer, id); break; case ID_PAL: - write_palette(wd, (Palette *)id); + write_palette(wd, (Palette *)id_buffer, id); break; case ID_PC: - write_paintcurve(wd, (PaintCurve *)id); + write_paintcurve(wd, (PaintCurve *)id_buffer, id); break; case ID_GD: - write_gpencil(wd, (bGPdata *)id); + write_gpencil(wd, (bGPdata *)id_buffer, id); break; case ID_LS: - write_linestyle(wd, (FreestyleLineStyle *)id); + write_linestyle(wd, (FreestyleLineStyle *)id_buffer, id); break; case ID_CF: - write_cachefile(wd, (CacheFile *)id); + write_cachefile(wd, (CacheFile *)id_buffer, id); break; case ID_HA: - write_hair(wd, (Hair *)id); + write_hair(wd, (Hair *)id_buffer, id); break; case ID_PT: - write_pointcloud(wd, (PointCloud *)id); + write_pointcloud(wd, (PointCloud *)id_buffer, id); break; case ID_VO: - write_volume(wd, (Volume *)id); + write_volume(wd, (Volume *)id_buffer, id); break; case ID_LI: /* Do nothing, handled below - and should never be reached. */ @@ -4144,6 +4134,10 @@ static bool write_file_handle(Main *mainvar, } } + if (id_buffer != id_buffer_static) { + MEM_SAFE_FREE(id_buffer); + } + mywrite_flush(wd); } } while ((bmain != override_storage) && (bmain = override_storage)); -- cgit v1.2.3 From 59e001cbf6c40f7b8630a995acd9aec315e73501 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 1 Apr 2020 10:02:04 +0200 Subject: GPencil: Cleanup typo error --- source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c | 2 +- source/blender/makesdna/DNA_gpencil_modifier_types.h | 2 +- source/blender/makesrna/intern/rna_gpencil_modifier.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index a1f1519d11f..5ca99be0dff 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -106,7 +106,7 @@ static void deformStroke(GpencilModifierData *md, } /* Hardness (at stroke level). */ - if (mmd->modify_color == GP_MODIFY_COLOR_HARDENESS) { + if (mmd->modify_color == GP_MODIFY_COLOR_HARDNESS) { gps->hardeness *= mmd->hardeness; CLAMP(gps->hardeness, 0.0f, 1.0f); diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index f98ec281011..c3425826d36 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -215,7 +215,7 @@ typedef enum eModifyColorGpencil_Flag { GP_MODIFY_COLOR_BOTH = 0, GP_MODIFY_COLOR_STROKE = 1, GP_MODIFY_COLOR_FILL = 2, - GP_MODIFY_COLOR_HARDENESS = 3, + GP_MODIFY_COLOR_HARDNESS = 3, } eModifyColorGpencil_Flag; typedef enum eOpacityModesGpencil_Flag { diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 34de6b2938b..03b7c643f47 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -144,7 +144,7 @@ static const EnumPropertyItem modifier_modify_opacity_items[] = { {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke and Fill", "Modify fill and stroke colors"}, {GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"}, {GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"}, - {GP_MODIFY_COLOR_HARDENESS, "HARDENESS", 0, "Hardness", "Modify stroke hardness"}, + {GP_MODIFY_COLOR_HARDNESS, "HARDNESS", 0, "Hardness", "Modify stroke hardness"}, {0, NULL, 0, NULL, NULL}, }; -- cgit v1.2.3 From 029a714fc72d79a4dc8d80c3397c308112a7fea9 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 31 Mar 2020 17:51:50 +0200 Subject: Fix T75234: Saving UDIM tiled texture as OpenEXR saves only the first tile This happened when the UDIM tiled image needed to be colormanaged, so - when you set up the image as sRGB, then save as EXR/HDR/... - other way around as well: when you set up the images as Linear then save as PNG/JPG/... Reason being that for UDIM tiled images, `image_save_single` is called multiple times [once for each tile] and everytime `image_save_post` will fire the `IMA_SIGNAL_COLORMANAGE` signal which clears the cache if any of the above two is the case. Without the cache, the next tiles cannot be saved. Now determine if the colorspace changed from `image_save_single`/'image_save_post' and only fire IMA_SIGNAL_COLORMANAGE once from BKE_image_save in the end. (thx @brecht for suggesting this alternative to the original fix) Maniphest Tasks: T75234 Differential Revision: https://developer.blender.org/D7296 --- source/blender/blenkernel/intern/image_save.c | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c index bd570c9688b..b2e0f234f1e 100644 --- a/source/blender/blenkernel/intern/image_save.c +++ b/source/blender/blenkernel/intern/image_save.c @@ -54,13 +54,13 @@ void BKE_image_save_options_init(ImageSaveOptions *opts, Main *bmain, Scene *sce } static void image_save_post(ReportList *reports, - Main *bmain, Image *ima, ImBuf *ibuf, int ok, ImageSaveOptions *opts, int save_copy, - const char *filepath) + const char *filepath, + bool *r_colorspace_changed) { if (!ok) { BKE_reportf(reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); @@ -114,7 +114,7 @@ static void image_save_post(ReportList *reports, IMB_colormanagement_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf); if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings, &ima->colorspace_settings)) { - BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); + *r_colorspace_changed = true; } } @@ -138,8 +138,11 @@ static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) * \note ``ima->name`` and ``ibuf->name`` should end up the same. * \note for multiview the first ``ibuf`` is important to get the settings. */ -static bool image_save_single( - ReportList *reports, Main *bmain, Image *ima, ImageUser *iuser, ImageSaveOptions *opts) +static bool image_save_single(ReportList *reports, + Image *ima, + ImageUser *iuser, + ImageSaveOptions *opts, + bool *r_colorspace_changed) { void *lock; ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); @@ -223,7 +226,7 @@ static bool image_save_single( if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) { /* save render result */ ok = RE_WriteRenderResult(reports, rr, opts->filepath, imf, NULL, layer); - image_save_post(reports, bmain, ima, ibuf, ok, opts, true, opts->filepath); + image_save_post(reports, ima, ibuf, ok, opts, true, opts->filepath, r_colorspace_changed); BKE_image_release_ibuf(ima, ibuf, lock); } /* regular mono pipeline */ @@ -237,8 +240,14 @@ static bool image_save_single( ok = BKE_imbuf_write_as(colormanaged_ibuf, opts->filepath, imf, save_copy); imbuf_save_post(ibuf, colormanaged_ibuf); } - image_save_post( - reports, bmain, ima, ibuf, ok, opts, (is_exr_rr ? true : save_copy), opts->filepath); + image_save_post(reports, + ima, + ibuf, + ok, + opts, + (is_exr_rr ? true : save_copy), + opts->filepath, + r_colorspace_changed); BKE_image_release_ibuf(ima, ibuf, lock); } /* individual multiview images */ @@ -260,7 +269,7 @@ static bool image_save_single( if (is_exr_rr) { BKE_scene_multiview_view_filepath_get(&opts->scene->r, opts->filepath, view, filepath); ok_view = RE_WriteRenderResult(reports, rr, filepath, imf, view, layer); - image_save_post(reports, bmain, ima, ibuf, ok_view, opts, true, filepath); + image_save_post(reports, ima, ibuf, ok_view, opts, true, filepath, r_colorspace_changed); } else { /* copy iuser to get the correct ibuf for this view */ @@ -293,7 +302,7 @@ static bool image_save_single( ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf); ok_view = BKE_imbuf_write_as(colormanaged_ibuf, filepath, &opts->im_format, save_copy); imbuf_save_post(ibuf, colormanaged_ibuf); - image_save_post(reports, bmain, ima, ibuf, ok_view, opts, true, filepath); + image_save_post(reports, ima, ibuf, ok_view, opts, true, filepath, r_colorspace_changed); BKE_image_release_ibuf(ima, ibuf, lock); } ok &= ok_view; @@ -307,7 +316,7 @@ static bool image_save_single( else if (opts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) { if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) { ok = RE_WriteRenderResult(reports, rr, opts->filepath, imf, NULL, layer); - image_save_post(reports, bmain, ima, ibuf, ok, opts, true, opts->filepath); + image_save_post(reports, ima, ibuf, ok, opts, true, opts->filepath, r_colorspace_changed); BKE_image_release_ibuf(ima, ibuf, lock); } else { @@ -393,6 +402,8 @@ bool BKE_image_save( ImageUser save_iuser; BKE_imageuser_default(&save_iuser); + bool colorspace_changed = false; + if (ima->source == IMA_SRC_TILED) { /* Verify filepath for tiles images. */ if (BLI_stringdec(opts->filepath, NULL, NULL, NULL) != 1001) { @@ -410,7 +421,7 @@ bool BKE_image_save( } /* Save image - or, for tiled images, the first tile. */ - bool ok = image_save_single(reports, bmain, ima, iuser, opts); + bool ok = image_save_single(reports, ima, iuser, opts, &colorspace_changed); if (ok && ima->source == IMA_SRC_TILED) { char filepath[FILE_MAX]; @@ -431,10 +442,14 @@ bool BKE_image_save( BLI_stringenc(opts->filepath, head, tail, numlen, tile->tile_number); iuser->tile = tile->tile_number; - ok = ok && image_save_single(reports, bmain, ima, iuser, opts); + ok = ok && image_save_single(reports, ima, iuser, opts, &colorspace_changed); } BLI_strncpy(opts->filepath, filepath, sizeof(opts->filepath)); } + if (colorspace_changed) { + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); + } + return ok; } -- cgit v1.2.3 From f8c4f5e3085998c7db55fb490cb04c48c575a222 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 30 Mar 2020 19:33:13 +0200 Subject: Add a "selected_nla_strips" context member Needed for upcomming fix for T66494. ref T66494 / D7281 --- source/blender/editors/screen/screen_context.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 9536772be3d..ea29e2f611c 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -27,6 +27,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_gpencil_types.h" #include "DNA_object_types.h" @@ -88,6 +89,7 @@ const char *screen_context_dir[] = { "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */ + "selected_nla_strips", /* nla editor */ "gpencil_data", "gpencil_data_owner", /* grease pencil data */ "annotation_data", @@ -503,6 +505,28 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } + else if (CTX_data_equals(member, "selected_nla_strips")) { + bAnimContext ac; + if (ANIM_animdata_get_context(C, &ac) != 0) { + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + + ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype); + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaStrip *strip; + for (strip = nlt->strips.first; strip; strip = strip->next) { + if (strip->flag & NLASTRIP_FLAG_SELECT) { + CTX_data_list_add(result, &scene->id, &RNA_NlaStrip, strip); + } + } + } + ANIM_animdata_freelist(&anim_data); + + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); + return 1; + } + } else if (CTX_data_equals(member, "gpencil_data")) { /* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these * situations (as outlined above - see Campbell's #ifdefs). -- cgit v1.2.3 From 60ff3a7daff75e631993e6e5d284746442e824f3 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 1 Apr 2020 10:24:16 +0200 Subject: Fix T66494: Alt+ clicking (assign to all selected) does not work for NLA strips This uses the new "selected_nla_strips" context member in UI_context_copy_to_selected_list(). bonus: this also makes the "Copy To Selected" button operator [in the button context menu] work for anything NLA Strip related. Maniphest Tasks: T66494 Differential Revision: https://developer.blender.org/D7281 --- source/blender/editors/interface/interface_ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 519ba4cbbdf..b418cb4a1ac 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -807,6 +807,9 @@ bool UI_context_copy_to_selected_list(bContext *C, else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) { *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves"); } + else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) { + *r_lb = CTX_data_collection_get(C, "selected_nla_strips"); + } else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) && (path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) != NULL) { -- cgit v1.2.3 From 186ac842103f410c663dfab440c9e40038dcea5b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 18:54:34 +1100 Subject: Cleanup: clang-format --- source/blender/blenkernel/intern/fluid.c | 6 ++++-- source/blender/editors/screen/screen_context.c | 4 ++-- source/blender/makesrna/intern/rna_brush.c | 4 +++- source/blender/modifiers/intern/MOD_warp.c | 11 +++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 8ced4a06c02..75e1dce9958 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4473,12 +4473,14 @@ void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_typ void BKE_fluid_cache_startframe_set(FluidDomainSettings *settings, int value) { - settings->cache_frame_start = (value > settings->cache_frame_end) ? settings->cache_frame_end : value; + settings->cache_frame_start = (value > settings->cache_frame_end) ? settings->cache_frame_end : + value; } void BKE_fluid_cache_endframe_set(FluidDomainSettings *settings, int value) { - settings->cache_frame_end = (value < settings->cache_frame_start) ? settings->cache_frame_start : value; + settings->cache_frame_end = (value < settings->cache_frame_start) ? settings->cache_frame_start : + value; } void BKE_fluid_cachetype_mesh_set(FluidDomainSettings *settings, int cache_mesh_format) diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index ea29e2f611c..5ae1a89ba9b 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -89,7 +89,7 @@ const char *screen_context_dir[] = { "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */ - "selected_nla_strips", /* nla editor */ + "selected_nla_strips", /* nla editor */ "gpencil_data", "gpencil_data_owner", /* grease pencil data */ "annotation_data", @@ -506,7 +506,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_nla_strips")) { - bAnimContext ac; + bAnimContext ac; if (ANIM_animdata_get_context(C, &ac) != 0) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 93f8053058a..86958c5970a 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1346,7 +1346,9 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_ui_text( - prop, "Hardness", "Gradient from the center of Dot and Box strokes (set to 1 for a solid stroke)"); + prop, + "Hardness", + "Gradient from the center of Dot and Box strokes (set to 1 for a solid stroke)"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); /* gradient shape ratio */ diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index b8db14f610a..c3515578e42 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -30,9 +30,9 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_colortools.h" #include "BKE_deform.h" -#include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_editmesh.h" #include "BKE_lib_id.h" #include "BKE_lib_query.h" @@ -86,7 +86,10 @@ static void requiredDataMask(Object *UNUSED(ob), } } -static void matrix_from_obj_pchan(float mat[4][4], float obinv[4][4], Object *ob, const char *bonename) +static void matrix_from_obj_pchan(float mat[4][4], + const float obinv[4][4], + Object *ob, + const char *bonename) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename); if (pchan) { @@ -150,8 +153,8 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void } static void warp_deps_object_bone_new(struct DepsNodeHandle *node, - Object *object, - const char *bonename) + Object *object, + const char *bonename) { if (bonename[0] && object->type == OB_ARMATURE) { DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "Warp Modifier"); -- cgit v1.2.3 From ca0dcd830c5e880b9ea25d4b95a581b2aaeef4e4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Apr 2020 20:59:50 +1100 Subject: Fix T75222: Crash activating menu search --- release/scripts/startup/bl_ui/space_topbar.py | 2 +- source/blender/editors/interface/interface_templates.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 40824cbeb52..1e6f03c2b0c 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -208,7 +208,7 @@ class TOPBAR_MT_editor_menus(Menu): layout = self.layout # Allow calling this menu directly (this might not be a header area). - if getattr(context.area, "show_menus"): + if getattr(context.area, "show_menus", False): layout.menu("TOPBAR_MT_app", text="", icon='BLENDER') else: layout.menu("TOPBAR_MT_app", text="Blender") diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d7377a0e56e..c750187d7a3 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6827,12 +6827,15 @@ static void menu_types_add_from_keymap_items(bContext *C, { wmWindowManager *wm = CTX_wm_manager(C); ListBase *handlers[] = { - ®ion->handlers, - &sa->handlers, + region ? ®ion->handlers : NULL, + sa ? &sa->handlers : NULL, &win->handlers, }; for (int handler_index = 0; handler_index < ARRAY_SIZE(handlers); handler_index++) { + if (handlers[handler_index] == NULL) { + continue; + } LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers[handler_index]) { /* During this loop, ui handlers for nested menus can tag multiple handlers free. */ if (handler_base->flag & WM_HANDLER_DO_FREE) { @@ -7092,11 +7095,15 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C, menu_items_from_ui_create_item_from_button(data, memarena, mt, drawstr_submenu, sub_but); } - BLI_remlink(®ion->uiblocks, sub_block); + if (region) { + BLI_remlink(®ion->uiblocks, sub_block); + } UI_block_free(NULL, sub_block); } } - BLI_remlink(®ion->uiblocks, block); + if (region) { + BLI_remlink(®ion->uiblocks, block); + } UI_block_free(NULL, block); /* Add key-map items as a second pass, -- cgit v1.2.3 From 80280acc938204dedd654502bb109c541f78a302 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 09:56:29 +0200 Subject: Writefile: Cleanup Curve runtime data. --- source/blender/blenloader/intern/writefile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 1ca8e7d5ade..3a34b8a87eb 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2041,6 +2041,11 @@ static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) static void write_curve(WriteData *wd, Curve *cu, const void *id_address) { if (cu->id.us > 0 || wd->use_memfile) { + /* Clean up, important in udo case to reduce false detection of chaged datablocks. */ + cu->editnurb = NULL; + cu->editfont = NULL; + cu->batch_cache = NULL; + /* write LibData */ writestruct_at_address(wd, ID_CU, Curve, 1, id_address, cu); write_iddata(wd, &cu->id); -- cgit v1.2.3 From 9532ce4605a45999fdf4841f716a94383e25bbab Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 09:58:37 +0200 Subject: Writefile: Cleanup Object runtime data. --- source/blender/blenloader/intern/writefile.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3a34b8a87eb..a9bcf2c13d6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -164,6 +164,7 @@ #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_node.h" +#include "BKE_object.h" #include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_sequencer.h" @@ -1903,6 +1904,9 @@ static void write_shaderfxs(WriteData *wd, ListBase *fxbase) static void write_object(WriteData *wd, Object *ob, const void *id_address) { if (ob->id.us > 0 || wd->use_memfile) { + /* Clean up, important in udo case to reduce false detection of changed datablocks. */ + BKE_object_runtime_reset(ob); + /* write LibData */ writestruct_at_address(wd, ID_OB, Object, 1, id_address, ob); write_iddata(wd, &ob->id); @@ -2041,7 +2045,7 @@ static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) static void write_curve(WriteData *wd, Curve *cu, const void *id_address) { if (cu->id.us > 0 || wd->use_memfile) { - /* Clean up, important in udo case to reduce false detection of chaged datablocks. */ + /* Clean up, important in udo case to reduce false detection of changed datablocks. */ cu->editnurb = NULL; cu->editfont = NULL; cu->batch_cache = NULL; -- cgit v1.2.3 From ee0d91df5dd75029de6886db13e45af3d4c7ef7c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 10:04:08 +0200 Subject: Writefile: Cleanup Scene runtime data. --- source/blender/blenloader/intern/writefile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a9bcf2c13d6..f28063bc691 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1904,7 +1904,7 @@ static void write_shaderfxs(WriteData *wd, ListBase *fxbase) static void write_object(WriteData *wd, Object *ob, const void *id_address) { if (ob->id.us > 0 || wd->use_memfile) { - /* Clean up, important in udo case to reduce false detection of changed datablocks. */ + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ BKE_object_runtime_reset(ob); /* write LibData */ @@ -2045,7 +2045,7 @@ static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) static void write_curve(WriteData *wd, Curve *cu, const void *id_address) { if (cu->id.us > 0 || wd->use_memfile) { - /* Clean up, important in udo case to reduce false detection of changed datablocks. */ + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ cu->editnurb = NULL; cu->editfont = NULL; cu->batch_cache = NULL; @@ -2562,6 +2562,12 @@ static void write_lightcache(WriteData *wd, LightCache *cache) static void write_scene(WriteData *wd, Scene *sce, const void *id_address) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + if (sce->ed) { + sce->ed->cache = NULL; + sce->ed->prefetch_job = NULL; + } + /* write LibData */ writestruct_at_address(wd, ID_SCE, Scene, 1, id_address, sce); write_iddata(wd, &sce->id); -- cgit v1.2.3 From 27b9f1f626294173269af85ef0d928d059179598 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 10:12:19 +0200 Subject: Writefile: Cleanup MBall runtime data. --- source/blender/blenloader/intern/writefile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f28063bc691..a8f219ccf84 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2026,6 +2026,14 @@ static void write_camera(WriteData *wd, Camera *cam, const void *id_address) static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) { if (mb->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + BLI_listbase_clear(&mb->disp); + mb->editelems = NULL; + /* Must always be cleared (meta's don't have their own edit-data). */ + mb->needs_flush_to_id = 0; + mb->lastelem = NULL; + mb->batch_cache = NULL; + /* write LibData */ writestruct_at_address(wd, ID_MB, MetaBall, 1, id_address, mb); write_iddata(wd, &mb->id); -- cgit v1.2.3 From e790aa1f19ebed6d8135d8cc71003f490cbc219e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 10:15:13 +0200 Subject: Writefile: Cleanup material runtime data. --- source/blender/blenloader/intern/writefile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a8f219ccf84..4307d3c076f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2361,6 +2361,10 @@ static void write_texture(WriteData *wd, Tex *tex, const void *id_address) static void write_material(WriteData *wd, Material *ma, const void *id_address) { if (ma->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + ma->texpaintslot = NULL; + BLI_listbase_clear(&ma->gpumaterial); + /* write LibData */ writestruct_at_address(wd, ID_MA, Material, 1, id_address, ma); write_iddata(wd, &ma->id); -- cgit v1.2.3 From 33a622cbf4c50d1cf0390601f755cafa78867d52 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 10:18:39 +0200 Subject: Writefile: Cleanup VFont runtime data. --- source/blender/blenloader/intern/writefile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4307d3c076f..75e15525ede 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1972,6 +1972,10 @@ static void write_object(WriteData *wd, Object *ob, const void *id_address) static void write_vfont(WriteData *wd, VFont *vf, const void *id_address) { if (vf->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + vf->data = NULL; + vf->temp_pf = NULL; + /* write LibData */ writestruct_at_address(wd, ID_VF, VFont, 1, id_address, vf); write_iddata(wd, &vf->id); -- cgit v1.2.3 From 4f509db181f6a73383180f0fa19239b8deb46d9c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 10:38:20 +0200 Subject: Writefile: Cleanup Text runtime data. --- source/blender/blenloader/intern/writefile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 75e15525ede..c92a64288d9 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3179,6 +3179,9 @@ static void write_text(WriteData *wd, Text *text, const void *id_address) text->flags &= ~TXT_ISEXT; } + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + text->compiled = NULL; + /* write LibData */ writestruct_at_address(wd, ID_TXT, Text, 1, id_address, text); write_iddata(wd, &text->id); -- cgit v1.2.3 From 254748c3e7c7068a6fed97f42c7012c7c2594c3e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 11:28:41 +0200 Subject: Writefile: Cleanup Lattice runtime data. --- source/blender/blenloader/intern/writefile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c92a64288d9..78e36a49c11 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2280,6 +2280,10 @@ static void write_mesh(WriteData *wd, Mesh *mesh, const void *id_address) static void write_lattice(WriteData *wd, Lattice *lt, const void *id_address) { if (lt->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + lt->editlatt = NULL; + lt->batch_cache = NULL; + /* write LibData */ writestruct_at_address(wd, ID_LT, Lattice, 1, id_address, lt); write_iddata(wd, <->id); -- cgit v1.2.3 From 8d63135da313b09562bb0cd4b0dd079b0ebabc64 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 11:30:30 +0200 Subject: Writefile: Cleanup World runtime data. --- source/blender/blenloader/intern/writefile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 78e36a49c11..7567a76f565 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2399,6 +2399,9 @@ static void write_material(WriteData *wd, Material *ma, const void *id_address) static void write_world(WriteData *wd, World *wrld, const void *id_address) { if (wrld->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + BLI_listbase_clear(&wrld->gpumaterial); + /* write LibData */ writestruct_at_address(wd, ID_WO, World, 1, id_address, wrld); write_iddata(wd, &wrld->id); -- cgit v1.2.3 From e24553ca0f0d20a0eb738a39e55318756154a603 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 11:43:03 +0200 Subject: Writefile: Cleanup Soung runtime data. --- source/blender/blenloader/intern/writefile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 7567a76f565..e5209281d2b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3225,6 +3225,12 @@ static void write_speaker(WriteData *wd, Speaker *spk, const void *id_address) static void write_sound(WriteData *wd, bSound *sound, const void *id_address) { if (sound->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + sound->tags = 0; + sound->handle = NULL; + sound->playback_handle = NULL; + sound->spinlock = NULL; + /* write LibData */ writestruct_at_address(wd, ID_SO, bSound, 1, id_address, sound); write_iddata(wd, &sound->id); -- cgit v1.2.3 From 358f8b484fa0b786d905aac54c19603aca0d0f07 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 11:50:42 +0200 Subject: Writefile: Cleanup Collection runtime data. --- source/blender/blenloader/intern/writefile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e5209281d2b..4a2f6875c83 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2467,6 +2467,12 @@ static void write_collection_nolib(WriteData *wd, Collection *collection) static void write_collection(WriteData *wd, Collection *collection, const void *id_address) { if (collection->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; + collection->tag = 0; + BLI_listbase_clear(&collection->object_cache); + BLI_listbase_clear(&collection->parents); + /* write LibData */ writestruct_at_address(wd, ID_GR, Collection, 1, id_address, collection); write_iddata(wd, &collection->id); -- cgit v1.2.3 From e0dc4130fda77dc4d99ffe25e36a53228a2d0325 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 11:57:32 +0200 Subject: Writefile: Cleanup Armature runtime data. --- source/blender/blenloader/intern/writefile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4a2f6875c83..3b7ce3bdc1b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3171,6 +3171,13 @@ static void write_bone(WriteData *wd, Bone *bone) static void write_armature(WriteData *wd, bArmature *arm, const void *id_address) { if (arm->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + arm->bonehash = NULL; + arm->edbo = NULL; + /* Must always be cleared (armatures don't have their own edit-data). */ + arm->needs_flush_to_id = 0; + arm->act_edbone = NULL; + writestruct_at_address(wd, ID_AR, bArmature, 1, id_address, arm); write_iddata(wd, &arm->id); -- cgit v1.2.3 From ec351c7a653da2b5da6dd91b916deed70bff117e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 12:01:27 +0200 Subject: Writefile: Cleanup Nodetree runtime data. Note: As with collections, this does not affect embedded nodetrees from material etc. We prpbably need to tackle those as well at some point... --- source/blender/blenloader/intern/writefile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3b7ce3bdc1b..fb6bd637a3b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3272,6 +3272,14 @@ static void write_probe(WriteData *wd, LightProbe *prb, const void *id_address) static void write_nodetree(WriteData *wd, bNodeTree *ntree, const void *id_address) { if (ntree->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + ntree->init = 0; /* to set callbacks and force setting types */ + ntree->is_updating = false; + ntree->typeinfo = NULL; + ntree->interface_type = NULL; + ntree->progress = NULL; + ntree->execdata = NULL; + writestruct_at_address(wd, ID_NT, bNodeTree, 1, id_address, ntree); /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot * be linked, etc., so we write actual id data here only, for 'real' ID trees. */ -- cgit v1.2.3 From 1f065df03e66b865137252db594991150c51d1bc Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 12:23:12 +0200 Subject: Writefile: Cleanup GPencil data. Note: Not clearing the whole runtime data here, as this is not done in matching read code, not sure why, needs further investigation... --- source/blender/blenloader/intern/writefile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index fb6bd637a3b..eb85fc95e4a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2824,6 +2824,14 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address) static void write_gpencil(WriteData *wd, bGPdata *gpd, const void *id_address) { if (gpd->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + /* XXX not sure why the whole runtime data is not cleared in readcode, for now mimicking it + * here. */ + gpd->runtime.sbuffer = NULL; + gpd->runtime.sbuffer_used = 0; + gpd->runtime.sbuffer_size = 0; + gpd->runtime.tot_cp_points = 0; + /* write gpd data block to file */ writestruct_at_address(wd, ID_GD, bGPdata, 1, id_address, gpd); write_iddata(wd, &gpd->id); -- cgit v1.2.3 From d31f79a9bc6aff3c3f372e2eabbb50e07bc74193 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 12:27:24 +0200 Subject: Writefile: Cleanup MovieClip runtime data. --- source/blender/blenloader/intern/writefile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index eb85fc95e4a..c55c3c3404a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3391,6 +3391,11 @@ static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction static void write_movieclip(WriteData *wd, MovieClip *clip, const void *id_address) { if (clip->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + clip->anim = NULL; + clip->tracking_context = NULL; + clip->tracking.stats = NULL; + MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; -- cgit v1.2.3 From d66519f1972c49a9271cff71aaccf9274b180908 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 12:33:29 +0200 Subject: Writefile: Cleanup CacheFile runtime data. --- source/blender/blenloader/intern/writefile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c55c3c3404a..254a6f1876e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3759,6 +3759,12 @@ static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle, const static void write_cachefile(WriteData *wd, CacheFile *cache_file, const void *id_address) { if (cache_file->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + BLI_listbase_clear(&cache_file->object_paths); + cache_file->handle = NULL; + memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath)); + cache_file->handle_readers = NULL; + writestruct_at_address(wd, ID_CF, CacheFile, 1, id_address, cache_file); if (cache_file->adt) { -- cgit v1.2.3 From 5e176d67e193b80054392b3e9190510fd90001e4 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 1 Apr 2020 12:38:23 +0200 Subject: Writefile: Cleanup Volume runtime data. --- source/blender/blenloader/intern/writefile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 254a6f1876e..ea334f258a1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3849,6 +3849,9 @@ static void write_pointcloud(WriteData *wd, PointCloud *pointcloud, const void * static void write_volume(WriteData *wd, Volume *volume, const void *id_address) { if (volume->id.us > 0 || wd->use_memfile) { + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + volume->runtime.grids = 0; + /* write LibData */ writestruct_at_address(wd, ID_VO, Volume, 1, id_address, volume); write_iddata(wd, &volume->id); -- cgit v1.2.3 From f047d47e24fc5aab41d0b2349f41f539aa085b8f Mon Sep 17 00:00:00 2001 From: OmarSquircleArt Date: Wed, 1 Apr 2020 14:48:01 +0200 Subject: Cycles: AVX implantation of Perlin noise. This patch adds an AVX implementation of Perlin noise in Cycles. An avxi type was also added as a utility based on the respective type in Intel Embree. Only 3D and 4D noise were implemented, there is no benefit for utilizing AVX in 1D and 2D noise. The SSE trilinear interpolation function was used in the AVX implementation because there is no benefit from using AVX in interpolating the last three dimensions. Differential Revision: https://developer.blender.org/D6680 --- intern/cycles/kernel/svm/svm_noise.h | 261 +++++++++--- intern/cycles/util/util_avxb.h | 28 +- intern/cycles/util/util_avxf.h | 67 +++- intern/cycles/util/util_avxi.h | 745 +++++++++++++++++++++++++++++++++++ intern/cycles/util/util_hash.h | 54 +++ intern/cycles/util/util_simd.h | 25 ++ intern/cycles/util/util_types.h | 1 + 7 files changed, 1097 insertions(+), 84 deletions(-) create mode 100644 intern/cycles/util/util_avxi.h diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h index a16b226d8de..914ef2089a9 100644 --- a/intern/cycles/kernel/svm/svm_noise.h +++ b/intern/cycles/kernel/svm/svm_noise.h @@ -65,7 +65,7 @@ ccl_device_noinline_cpu float perlin_1d(float x) * supported, we do a standard implementation, but if it is supported, we * do an implementation using SSE intrinsics. */ -#ifndef __KERNEL_SSE2__ +#if !defined(__KERNEL_SSE2__) /* ** Standard Implementation ** */ @@ -266,7 +266,7 @@ ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w) return r; } -#else +#else /* SSE is supported. */ /* ** SSE Implementation ** */ @@ -300,6 +300,57 @@ ccl_device_inline ssef bi_mix(ssef p, ssef f) return mix(g, shuffle<1>(g), shuffle<1>(f)); } +ccl_device_inline ssef fade(const ssef &t) +{ + ssef a = madd(t, 6.0f, -15.0f); + ssef b = madd(t, a, 10.0f); + return (t * t) * (t * b); +} + +/* Negate val if the nth bit of h is 1. */ +# define negate_if_nth_bit(val, h, n) ((val) ^ cast(((h) & (1 << (n))) << (31 - (n)))) + +ccl_device_inline ssef grad(const ssei &hash, const ssef &x, const ssef &y) +{ + ssei h = hash & 7; + ssef u = select(h < 4, x, y); + ssef v = 2.0f * select(h < 4, y, x); + return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1); +} + +/* We use SSE to compute and interpolate 4 gradients at once: + * + * Point Offset from v0 + * v0 (0, 0) + * v1 (0, 1) + * v2 (1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(V, V + 1)) + * v3 (1, 1) ^ + * | |__________| (0, 0, 1, 1) = shuffle<0, 0, 0, 0>(V, V + 1) + * | ^ + * |__________________________| + * + */ +ccl_device_noinline float perlin_2d(float x, float y) +{ + ssei XY; + ssef fxy = floorfrac(ssef(x, y, 0.0f, 0.0f), &XY); + ssef uv = fade(fxy); + + ssei XY1 = XY + 1; + ssei X = shuffle<0, 0, 0, 0>(XY, XY1); + ssei Y = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(XY, XY1)); + + ssei h = hash_ssei2(X, Y); + + ssef fxy1 = fxy - 1.0f; + ssef fx = shuffle<0, 0, 0, 0>(fxy, fxy1); + ssef fy = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(fxy, fxy1)); + + ssef g = grad(h, fx, fy); + + return extract<0>(bi_mix(g, uv)); +} + /* SSE Trilinear Interpolation: * * The function takes three ssef inputs: @@ -340,34 +391,12 @@ ccl_device_inline ssef tri_mix(ssef p, ssef q, ssef f) return mix(g, shuffle<1>(g), shuffle<2>(f)); } -/* SSE Quadrilinear Interpolation: - * - * Quadrilinear interpolation is as simple as a linear interpolation - * between two trilinear interpolations. - * +/* 3D and 4D noise can be accelerated using AVX, so we first check if AVX + * is supported, that is, if __KERNEL_AVX__ is defined. If it is not + * supported, we do an SSE implementation, but if it is supported, + * we do an implementation using AVX intrinsics. */ -ccl_device_inline ssef quad_mix(ssef p, ssef q, ssef r, ssef s, ssef f) -{ - return mix(tri_mix(p, q, f), tri_mix(r, s, f), shuffle<3>(f)); -} - -ccl_device_inline ssef fade(const ssef &t) -{ - ssef a = madd(t, 6.0f, -15.0f); - ssef b = madd(t, a, 10.0f); - return (t * t) * (t * b); -} - -/* Negate val if the nth bit of h is 1. */ -# define negate_if_nth_bit(val, h, n) ((val) ^ cast(((h) & (1 << (n))) << (31 - (n)))) - -ccl_device_inline ssef grad(const ssei &hash, const ssef &x, const ssef &y) -{ - ssei h = hash & 7; - ssef u = select(h < 4, x, y); - ssef v = 2.0f * select(h < 4, y, x); - return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1); -} +# if !defined(__KERNEL_AVX__) ccl_device_inline ssef grad(const ssei &hash, const ssef &x, const ssef &y, const ssef &z) { @@ -388,37 +417,15 @@ grad(const ssei &hash, const ssef &x, const ssef &y, const ssef &z, const ssef & return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1) + negate_if_nth_bit(s, h, 2); } -/* We use SSE to compute and interpolate 4 gradients at once: +/* SSE Quadrilinear Interpolation: * - * Point Offset from v0 - * v0 (0, 0) - * v1 (0, 1) - * v2 (1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(V, V + 1)) - * v3 (1, 1) ^ - * | |__________| (0, 0, 1, 1) = shuffle<0, 0, 0, 0>(V, V + 1) - * | ^ - * |__________________________| + * Quadrilinear interpolation is as simple as a linear interpolation + * between two trilinear interpolations. * */ -ccl_device_noinline float perlin_2d(float x, float y) +ccl_device_inline ssef quad_mix(ssef p, ssef q, ssef r, ssef s, ssef f) { - ssei XY; - ssef fxy = floorfrac(ssef(x, y, 0.0f, 0.0f), &XY); - ssef uv = fade(fxy); - - ssei XY1 = XY + 1; - ssei X = shuffle<0, 0, 0, 0>(XY, XY1); - ssei Y = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(XY, XY1)); - - ssei h = hash_ssei2(X, Y); - - ssef fxy1 = fxy - 1.0f; - ssef fx = shuffle<0, 0, 0, 0>(fxy, fxy1); - ssef fy = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(fxy, fxy1)); - - ssef g = grad(h, fx, fy); - - return extract<0>(bi_mix(g, uv)); + return mix(tri_mix(p, q, f), tri_mix(r, s, f), shuffle<3>(f)); } /* We use SSE to compute and interpolate 4 gradients at once. Since we have 8 @@ -522,6 +529,148 @@ ccl_device_noinline float perlin_4d(float x, float y, float z, float w) return extract<0>(quad_mix(g1, g2, g3, g4, uvws)); } + +# else /* AVX is supported. */ + +/* AVX Implementation */ + +ccl_device_inline avxf grad(const avxi &hash, const avxf &x, const avxf &y, const avxf &z) +{ + avxi h = hash & 15; + avxf u = select(h < 8, x, y); + avxf vt = select((h == 12) | (h == 14), x, z); + avxf v = select(h < 4, y, vt); + return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1); +} + +ccl_device_inline avxf +grad(const avxi &hash, const avxf &x, const avxf &y, const avxf &z, const avxf &w) +{ + avxi h = hash & 31; + avxf u = select(h < 24, x, y); + avxf v = select(h < 16, y, z); + avxf s = select(h < 8, z, w); + return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1) + negate_if_nth_bit(s, h, 2); +} + +/* SSE Quadrilinear Interpolation: + * + * The interpolation is done in two steps: + * 1. Interpolate p and q along the w axis to get s. + * 2. Trilinearly interpolate (s0, s1, s2, s3) and (s4, s5, s6, s7) to get the final + * value. (s0, s1, s2, s3) and (s4, s5, s6, s7) are generated by extracting the + * low and high ssef from s. + * + */ +ccl_device_inline ssef quad_mix(avxf p, avxf q, ssef f) +{ + ssef fv = shuffle<3>(f); + avxf s = mix(p, q, avxf(fv, fv)); + return tri_mix(low(s), high(s), f); +} + +/* We use AVX to compute and interpolate 8 gradients at once. + * + * Point Offset from v0 + * v0 (0, 0, 0) + * v1 (0, 0, 1) The full avx type is computed by inserting the following + * v2 (0, 1, 0) sse types into both the low and high parts of the avx. + * v3 (0, 1, 1) + * v4 (1, 0, 0) + * v5 (1, 0, 1) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1)) + * v6 (1, 1, 0) ^ + * v7 (1, 1, 1) | + * | |__________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1) + * | ^ + * |__________________________| + * + */ +ccl_device_noinline float perlin_3d(float x, float y, float z) +{ + ssei XYZ; + ssef fxyz = floorfrac(ssef(x, y, z, 0.0f), &XYZ); + ssef uvw = fade(fxyz); + + ssei XYZ1 = XYZ + 1; + ssei X = shuffle<0>(XYZ); + ssei X1 = shuffle<0>(XYZ1); + ssei Y = shuffle<1, 1, 1, 1>(XYZ, XYZ1); + ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZ, XYZ1)); + + avxi h = hash_avxi3(avxi(X, X1), avxi(Y, Y), avxi(Z, Z)); + + ssef fxyz1 = fxyz - 1.0f; + ssef fx = shuffle<0>(fxyz); + ssef fx1 = shuffle<0>(fxyz1); + ssef fy = shuffle<1, 1, 1, 1>(fxyz, fxyz1); + ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyz, fxyz1)); + + avxf g = grad(h, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz)); + + return extract<0>(tri_mix(low(g), high(g), uvw)); +} + +/* We use AVX to compute and interpolate 8 gradients at once. Since we have 16 + * gradients in 4D, we need to compute two sets of gradients at the points: + * + * Point Offset from v0 + * v0 (0, 0, 0, 0) + * v1 (0, 0, 1, 0) The full avx type is computed by inserting the following + * v2 (0, 1, 0, 0) sse types into both the low and high parts of the avx. + * v3 (0, 1, 1, 0) + * v4 (1, 0, 0, 0) + * v5 (1, 0, 1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1)) + * v6 (1, 1, 0, 0) ^ + * v7 (1, 1, 1, 0) | + * | |________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1) + * | ^ + * |_______________________| + * + * Point Offset from v0 + * v8 (0, 0, 0, 1) + * v9 (0, 0, 1, 1) + * v10 (0, 1, 0, 1) + * v11 (0, 1, 1, 1) + * v12 (1, 0, 0, 1) + * v13 (1, 0, 1, 1) + * v14 (1, 1, 0, 1) + * v15 (1, 1, 1, 1) + * + */ +ccl_device_noinline float perlin_4d(float x, float y, float z, float w) +{ + ssei XYZW; + ssef fxyzw = floorfrac(ssef(x, y, z, w), &XYZW); + ssef uvws = fade(fxyzw); + + ssei XYZW1 = XYZW + 1; + ssei X = shuffle<0>(XYZW); + ssei X1 = shuffle<0>(XYZW1); + ssei Y = shuffle<1, 1, 1, 1>(XYZW, XYZW1); + ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZW, XYZW1)); + ssei W = shuffle<3>(XYZW); + ssei W1 = shuffle<3>(XYZW1); + + avxi h1 = hash_avxi4(avxi(X, X1), avxi(Y, Y), avxi(Z, Z), avxi(W, W)); + avxi h2 = hash_avxi4(avxi(X, X1), avxi(Y, Y), avxi(Z, Z), avxi(W1, W1)); + + ssef fxyzw1 = fxyzw - 1.0f; + ssef fx = shuffle<0>(fxyzw); + ssef fx1 = shuffle<0>(fxyzw1); + ssef fy = shuffle<1, 1, 1, 1>(fxyzw, fxyzw1); + ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyzw, fxyzw1)); + ssef fw = shuffle<3>(fxyzw); + ssef fw1 = shuffle<3>(fxyzw1); + + avxf g1 = grad(h1, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz), avxf(fw, fw)); + avxf g2 = grad(h2, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz), avxf(fw1, fw1)); + + return extract<0>(quad_mix(g1, g2, uvws)); +} +# endif + +# undef negate_if_nth_bit + #endif /* Remap the output of noise to a predictable range [-1, 1]. diff --git a/intern/cycles/util/util_avxb.h b/intern/cycles/util/util_avxb.h index 54dd8068eca..34fafd188de 100644 --- a/intern/cycles/util/util_avxb.h +++ b/intern/cycles/util/util_avxb.h @@ -16,7 +16,7 @@ */ #ifndef __UTIL_AVXB_H__ -# define __UTIL_AVXB_H__ +#define __UTIL_AVXB_H__ CCL_NAMESPACE_BEGIN @@ -53,6 +53,10 @@ struct avxb { __forceinline avxb(const __m256 input) : m256(input) { } + __forceinline avxb(const __m128 &a, const __m128 &b) + : m256(_mm256_insertf128_ps(_mm256_castps128_ps256(a), b, 1)) + { + } __forceinline operator const __m256 &(void)const { return m256; @@ -146,9 +150,9 @@ __forceinline const avxb operator!=(const avxb &a, const avxb &b) } __forceinline const avxb operator==(const avxb &a, const avxb &b) { -# ifdef __KERNEL_AVX2__ +#ifdef __KERNEL_AVX2__ return _mm256_castsi256_ps(_mm256_cmpeq_epi32(a, b)); -# else +#else __m128i a_lo = _mm_castps_si128(_mm256_extractf128_ps(a, 0)); __m128i a_hi = _mm_castps_si128(_mm256_extractf128_ps(a, 1)); __m128i b_lo = _mm_castps_si128(_mm256_extractf128_ps(b, 0)); @@ -157,16 +161,16 @@ __forceinline const avxb operator==(const avxb &a, const avxb &b) __m128i c_hi = _mm_cmpeq_epi32(a_hi, b_hi); __m256i result = _mm256_insertf128_si256(_mm256_castsi128_si256(c_lo), c_hi, 1); return _mm256_castsi256_ps(result); -# endif +#endif } __forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f) { -# if defined(__KERNEL_SSE41__) +#if defined(__KERNEL_SSE41__) return _mm256_blendv_ps(f, t, m); -# else +#else return _mm256_or_ps(_mm256_and_ps(m, t), _mm256_andnot_ps(m, f)); -# endif +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -186,18 +190,18 @@ __forceinline const avxb unpackhi(const avxb &a, const avxb &b) /// Reduction Operations //////////////////////////////////////////////////////////////////////////////// -# if defined(__KERNEL_SSE41__) +#if defined(__KERNEL_SSE41__) __forceinline size_t popcnt(const avxb &a) { return __popcnt(_mm256_movemask_ps(a)); } -# else +#else __forceinline size_t popcnt(const avxb &a) { return bool(a[0]) + bool(a[1]) + bool(a[2]) + bool(a[3]) + bool(a[4]) + bool(a[5]) + bool(a[6]) + bool(a[7]); } -# endif +#endif __forceinline bool reduce_and(const avxb &a) { @@ -234,8 +238,6 @@ ccl_device_inline void print_avxb(const char *label, const avxb &a) printf("%s: %d %d %d %d %d %d %d %d\n", label, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); } -#endif - CCL_NAMESPACE_END -//#endif +#endif diff --git a/intern/cycles/util/util_avxf.h b/intern/cycles/util/util_avxf.h index 156607e65fb..6781290bb83 100644 --- a/intern/cycles/util/util_avxf.h +++ b/intern/cycles/util/util_avxf.h @@ -15,7 +15,7 @@ */ #ifndef __UTIL_AVXF_H__ -# define __UTIL_AVXF_H__ +#define __UTIL_AVXF_H__ CCL_NAMESPACE_BEGIN @@ -140,6 +140,11 @@ __forceinline void dot3(const avxf &a, const avxf &b, float &den, float &den2) /// Unary Operators //////////////////////////////////////////////////////////////////////////////// +__forceinline const avxf cast(const __m256i &a) +{ + return _mm256_castsi256_ps(a); +} + __forceinline const avxf mm256_sqrt(const avxf &a) { return _mm256_sqrt_ps(a.m256); @@ -259,16 +264,34 @@ template __forceinline const avxf shuffle(const avxf &a) return shuffle(a, a); } +template __forceinline float extract(const avxf &a) +{ + return _mm256_cvtss_f32(shuffle(a)); +} +template<> __forceinline float extract<0>(const avxf &a) +{ + return _mm256_cvtss_f32(a); +} + +__forceinline ssef low(const avxf &a) +{ + return _mm256_extractf128_ps(a, 0); +} +__forceinline ssef high(const avxf &a) +{ + return _mm256_extractf128_ps(a, 1); +} + template __forceinline const avxf permute(const avxf &a) { -# ifdef __KERNEL_AVX2__ +#ifdef __KERNEL_AVX2__ return _mm256_permutevar8x32_ps(a, _mm256_set_epi32(i7, i6, i5, i4, i3, i2, i1, i0)); -# else +#else float temp[8]; _mm256_storeu_ps((float *)&temp, a); return avxf(temp[i7], temp[i6], temp[i5], temp[i4], temp[i3], temp[i2], temp[i1], temp[i0]); -# endif +#endif } template @@ -309,39 +332,51 @@ __forceinline avxf mini(const avxf &a, const avxf &b) //////////////////////////////////////////////////////////////////////////////// __forceinline const avxf madd(const avxf &a, const avxf &b, const avxf &c) { -# ifdef __KERNEL_AVX2__ +#ifdef __KERNEL_AVX2__ return _mm256_fmadd_ps(a, b, c); -# else +#else return c + (a * b); -# endif +#endif } __forceinline const avxf nmadd(const avxf &a, const avxf &b, const avxf &c) { -# ifdef __KERNEL_AVX2__ +#ifdef __KERNEL_AVX2__ return _mm256_fnmadd_ps(a, b, c); -# else +#else return c - (a * b); -# endif +#endif } __forceinline const avxf msub(const avxf &a, const avxf &b, const avxf &c) { -# ifdef __KERNEL_AVX2__ +#ifdef __KERNEL_AVX2__ return _mm256_fmsub_ps(a, b, c); -# else +#else return (a * b) - c; -# endif +#endif } //////////////////////////////////////////////////////////////////////////////// -/// Comparison Operators +/// Comparison Operators + Select //////////////////////////////////////////////////////////////////////////////// __forceinline const avxb operator<=(const avxf &a, const avxf &b) { return _mm256_cmp_ps(a.m256, b.m256, _CMP_LE_OS); } -#endif +__forceinline const avxf select(const avxb &m, const avxf &t, const avxf &f) +{ + return _mm256_blendv_ps(f, t, m); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Common Functions +//////////////////////////////////////////////////////////////////////////////// + +__forceinline avxf mix(const avxf &a, const avxf &b, const avxf &t) +{ + return madd(t, b, (avxf(1.0f) - t) * a); +} #ifndef _mm256_set_m128 # define _mm256_set_m128(/* __m128 */ hi, /* __m128 */ lo) \ @@ -352,3 +387,5 @@ __forceinline const avxb operator<=(const avxf &a, const avxf &b) _mm256_set_m128(_mm_loadu_ps(hiaddr), _mm_loadu_ps(loaddr)) CCL_NAMESPACE_END + +#endif diff --git a/intern/cycles/util/util_avxi.h b/intern/cycles/util/util_avxi.h new file mode 100644 index 00000000000..e658a4f848f --- /dev/null +++ b/intern/cycles/util/util_avxi.h @@ -0,0 +1,745 @@ +/* + * Copyright 2009-2013 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UTIL_AVXI_H__ +#define __UTIL_AVXI_H__ + +CCL_NAMESPACE_BEGIN + +struct avxb; + +struct avxi { + typedef avxb Mask; // mask type for us + enum { size = 8 }; // number of SIMD elements + union { // data + __m256i m256; +#if !defined(__KERNEL_AVX2__) + struct { + __m128i l, h; + }; +#endif + int32_t v[8]; + }; + + //////////////////////////////////////////////////////////////////////////////// + /// Constructors, Assignment & Cast Operators + //////////////////////////////////////////////////////////////////////////////// + + __forceinline avxi() + { + } + __forceinline avxi(const avxi &a) + { + m256 = a.m256; + } + __forceinline avxi &operator=(const avxi &a) + { + m256 = a.m256; + return *this; + } + + __forceinline avxi(const __m256i a) : m256(a) + { + } + __forceinline operator const __m256i &(void)const + { + return m256; + } + __forceinline operator __m256i &(void) + { + return m256; + } + + __forceinline explicit avxi(const ssei &a) + : m256(_mm256_insertf128_si256(_mm256_castsi128_si256(a), a, 1)) + { + } + __forceinline avxi(const ssei &a, const ssei &b) + : m256(_mm256_insertf128_si256(_mm256_castsi128_si256(a), b, 1)) + { + } +#if defined(__KERNEL_AVX2__) + __forceinline avxi(const __m128i &a, const __m128i &b) + : m256(_mm256_insertf128_si256(_mm256_castsi128_si256(a), b, 1)) + { + } +#else + __forceinline avxi(const __m128i &a, const __m128i &b) : l(a), h(b) + { + } +#endif + __forceinline explicit avxi(const int32_t *const a) + : m256(_mm256_castps_si256(_mm256_loadu_ps((const float *)a))) + { + } + __forceinline avxi(int32_t a) : m256(_mm256_set1_epi32(a)) + { + } + __forceinline avxi(int32_t a, int32_t b) : m256(_mm256_set_epi32(b, a, b, a, b, a, b, a)) + { + } + __forceinline avxi(int32_t a, int32_t b, int32_t c, int32_t d) + : m256(_mm256_set_epi32(d, c, b, a, d, c, b, a)) + { + } + __forceinline avxi( + int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t g, int32_t h) + : m256(_mm256_set_epi32(h, g, f, e, d, c, b, a)) + { + } + + __forceinline explicit avxi(const __m256 a) : m256(_mm256_cvtps_epi32(a)) + { + } + + //////////////////////////////////////////////////////////////////////////////// + /// Constants + //////////////////////////////////////////////////////////////////////////////// + + __forceinline avxi(ZeroTy) : m256(_mm256_setzero_si256()) + { + } +#if defined(__KERNEL_AVX2__) + __forceinline avxi(OneTy) : m256(_mm256_set1_epi32(1)) + { + } + __forceinline avxi(PosInfTy) : m256(_mm256_set1_epi32(pos_inf)) + { + } + __forceinline avxi(NegInfTy) : m256(_mm256_set1_epi32(neg_inf)) + { + } +#else + __forceinline avxi(OneTy) : m256(_mm256_set_epi32(1, 1, 1, 1, 1, 1, 1, 1)) + { + } + __forceinline avxi(PosInfTy) + : m256(_mm256_set_epi32( + pos_inf, pos_inf, pos_inf, pos_inf, pos_inf, pos_inf, pos_inf, pos_inf)) + { + } + __forceinline avxi(NegInfTy) + : m256(_mm256_set_epi32( + neg_inf, neg_inf, neg_inf, neg_inf, neg_inf, neg_inf, neg_inf, neg_inf)) + { + } +#endif + __forceinline avxi(StepTy) : m256(_mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0)) + { + } + + //////////////////////////////////////////////////////////////////////////////// + /// Array Access + //////////////////////////////////////////////////////////////////////////////// + + __forceinline const int32_t &operator[](const size_t i) const + { + assert(i < 8); + return v[i]; + } + __forceinline int32_t &operator[](const size_t i) + { + assert(i < 8); + return v[i]; + } +}; + +//////////////////////////////////////////////////////////////////////////////// +/// Unary Operators +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxi cast(const __m256 &a) +{ + return _mm256_castps_si256(a); +} +__forceinline const avxi operator+(const avxi &a) +{ + return a; +} +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator-(const avxi &a) +{ + return _mm256_sub_epi32(_mm256_setzero_si256(), a.m256); +} +__forceinline const avxi abs(const avxi &a) +{ + return _mm256_abs_epi32(a.m256); +} +#else +__forceinline const avxi operator-(const avxi &a) +{ + return avxi(_mm_sub_epi32(_mm_setzero_si128(), a.l), _mm_sub_epi32(_mm_setzero_si128(), a.h)); +} +__forceinline const avxi abs(const avxi &a) +{ + return avxi(_mm_abs_epi32(a.l), _mm_abs_epi32(a.h)); +} +#endif + +//////////////////////////////////////////////////////////////////////////////// +/// Binary Operators +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator+(const avxi &a, const avxi &b) +{ + return _mm256_add_epi32(a.m256, b.m256); +} +#else +__forceinline const avxi operator+(const avxi &a, const avxi &b) +{ + return avxi(_mm_add_epi32(a.l, b.l), _mm_add_epi32(a.h, b.h)); +} +#endif +__forceinline const avxi operator+(const avxi &a, const int32_t b) +{ + return a + avxi(b); +} +__forceinline const avxi operator+(const int32_t a, const avxi &b) +{ + return avxi(a) + b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator-(const avxi &a, const avxi &b) +{ + return _mm256_sub_epi32(a.m256, b.m256); +} +#else +__forceinline const avxi operator-(const avxi &a, const avxi &b) +{ + return avxi(_mm_sub_epi32(a.l, b.l), _mm_sub_epi32(a.h, b.h)); +} +#endif +__forceinline const avxi operator-(const avxi &a, const int32_t b) +{ + return a - avxi(b); +} +__forceinline const avxi operator-(const int32_t a, const avxi &b) +{ + return avxi(a) - b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator*(const avxi &a, const avxi &b) +{ + return _mm256_mullo_epi32(a.m256, b.m256); +} +#else +__forceinline const avxi operator*(const avxi &a, const avxi &b) +{ + return avxi(_mm_mullo_epi32(a.l, b.l), _mm_mullo_epi32(a.h, b.h)); +} +#endif +__forceinline const avxi operator*(const avxi &a, const int32_t b) +{ + return a * avxi(b); +} +__forceinline const avxi operator*(const int32_t a, const avxi &b) +{ + return avxi(a) * b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator&(const avxi &a, const avxi &b) +{ + return _mm256_and_si256(a.m256, b.m256); +} +#else +__forceinline const avxi operator&(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); +} +#endif +__forceinline const avxi operator&(const avxi &a, const int32_t b) +{ + return a & avxi(b); +} +__forceinline const avxi operator&(const int32_t a, const avxi &b) +{ + return avxi(a) & b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator|(const avxi &a, const avxi &b) +{ + return _mm256_or_si256(a.m256, b.m256); +} +#else +__forceinline const avxi operator|(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_or_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); +} +#endif +__forceinline const avxi operator|(const avxi &a, const int32_t b) +{ + return a | avxi(b); +} +__forceinline const avxi operator|(const int32_t a, const avxi &b) +{ + return avxi(a) | b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator^(const avxi &a, const avxi &b) +{ + return _mm256_xor_si256(a.m256, b.m256); +} +#else +__forceinline const avxi operator^(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); +} +#endif +__forceinline const avxi operator^(const avxi &a, const int32_t b) +{ + return a ^ avxi(b); +} +__forceinline const avxi operator^(const int32_t a, const avxi &b) +{ + return avxi(a) ^ b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi operator<<(const avxi &a, const int32_t n) +{ + return _mm256_slli_epi32(a.m256, n); +} +__forceinline const avxi operator>>(const avxi &a, const int32_t n) +{ + return _mm256_srai_epi32(a.m256, n); +} + +__forceinline const avxi sra(const avxi &a, const int32_t b) +{ + return _mm256_srai_epi32(a.m256, b); +} +__forceinline const avxi srl(const avxi &a, const int32_t b) +{ + return _mm256_srli_epi32(a.m256, b); +} +#else +__forceinline const avxi operator<<(const avxi &a, const int32_t n) +{ + return avxi(_mm_slli_epi32(a.l, n), _mm_slli_epi32(a.h, n)); +} +__forceinline const avxi operator>>(const avxi &a, const int32_t n) +{ + return avxi(_mm_srai_epi32(a.l, n), _mm_srai_epi32(a.h, n)); +} + +__forceinline const avxi sra(const avxi &a, const int32_t b) +{ + return avxi(_mm_srai_epi32(a.l, b), _mm_srai_epi32(a.h, b)); +} +__forceinline const avxi srl(const avxi &a, const int32_t b) +{ + return avxi(_mm_srli_epi32(a.l, b), _mm_srli_epi32(a.h, b)); +} +#endif + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi min(const avxi &a, const avxi &b) +{ + return _mm256_min_epi32(a.m256, b.m256); +} +#else +__forceinline const avxi min(const avxi &a, const avxi &b) +{ + return avxi(_mm_min_epi32(a.l, b.l), _mm_min_epi32(a.h, b.h)); +} +#endif +__forceinline const avxi min(const avxi &a, const int32_t b) +{ + return min(a, avxi(b)); +} +__forceinline const avxi min(const int32_t a, const avxi &b) +{ + return min(avxi(a), b); +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxi max(const avxi &a, const avxi &b) +{ + return _mm256_max_epi32(a.m256, b.m256); +} +#else +__forceinline const avxi max(const avxi &a, const avxi &b) +{ + return avxi(_mm_max_epi32(a.l, b.l), _mm_max_epi32(a.h, b.h)); +} +#endif +__forceinline const avxi max(const avxi &a, const int32_t b) +{ + return max(a, avxi(b)); +} +__forceinline const avxi max(const int32_t a, const avxi &b) +{ + return max(avxi(a), b); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Assignment Operators +//////////////////////////////////////////////////////////////////////////////// + +__forceinline avxi &operator+=(avxi &a, const avxi &b) +{ + return a = a + b; +} +__forceinline avxi &operator+=(avxi &a, const int32_t b) +{ + return a = a + b; +} + +__forceinline avxi &operator-=(avxi &a, const avxi &b) +{ + return a = a - b; +} +__forceinline avxi &operator-=(avxi &a, const int32_t b) +{ + return a = a - b; +} + +__forceinline avxi &operator*=(avxi &a, const avxi &b) +{ + return a = a * b; +} +__forceinline avxi &operator*=(avxi &a, const int32_t b) +{ + return a = a * b; +} + +__forceinline avxi &operator&=(avxi &a, const avxi &b) +{ + return a = a & b; +} +__forceinline avxi &operator&=(avxi &a, const int32_t b) +{ + return a = a & b; +} + +__forceinline avxi &operator|=(avxi &a, const avxi &b) +{ + return a = a | b; +} +__forceinline avxi &operator|=(avxi &a, const int32_t b) +{ + return a = a | b; +} + +__forceinline avxi &operator^=(avxi &a, const avxi &b) +{ + return a = a ^ b; +} +__forceinline avxi &operator^=(avxi &a, const int32_t b) +{ + return a = a ^ b; +} + +__forceinline avxi &operator<<=(avxi &a, const int32_t b) +{ + return a = a << b; +} +__forceinline avxi &operator>>=(avxi &a, const int32_t b) +{ + return a = a >> b; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Comparison Operators + Select +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__KERNEL_AVX2__) +__forceinline const avxb operator==(const avxi &a, const avxi &b) +{ + return _mm256_castsi256_ps(_mm256_cmpeq_epi32(a.m256, b.m256)); +} +#else +__forceinline const avxb operator==(const avxi &a, const avxi &b) +{ + return avxb(_mm_castsi128_ps(_mm_cmpeq_epi32(a.l, b.l)), + _mm_castsi128_ps(_mm_cmpeq_epi32(a.h, b.h))); +} +#endif +__forceinline const avxb operator==(const avxi &a, const int32_t b) +{ + return a == avxi(b); +} +__forceinline const avxb operator==(const int32_t a, const avxi &b) +{ + return avxi(a) == b; +} + +__forceinline const avxb operator!=(const avxi &a, const avxi &b) +{ + return !(a == b); +} +__forceinline const avxb operator!=(const avxi &a, const int32_t b) +{ + return a != avxi(b); +} +__forceinline const avxb operator!=(const int32_t a, const avxi &b) +{ + return avxi(a) != b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxb operator<(const avxi &a, const avxi &b) +{ + return _mm256_castsi256_ps(_mm256_cmpgt_epi32(b.m256, a.m256)); +} +#else +__forceinline const avxb operator<(const avxi &a, const avxi &b) +{ + return avxb(_mm_castsi128_ps(_mm_cmplt_epi32(a.l, b.l)), + _mm_castsi128_ps(_mm_cmplt_epi32(a.h, b.h))); +} +#endif +__forceinline const avxb operator<(const avxi &a, const int32_t b) +{ + return a < avxi(b); +} +__forceinline const avxb operator<(const int32_t a, const avxi &b) +{ + return avxi(a) < b; +} + +__forceinline const avxb operator>=(const avxi &a, const avxi &b) +{ + return !(a < b); +} +__forceinline const avxb operator>=(const avxi &a, const int32_t b) +{ + return a >= avxi(b); +} +__forceinline const avxb operator>=(const int32_t a, const avxi &b) +{ + return avxi(a) >= b; +} + +#if defined(__KERNEL_AVX2__) +__forceinline const avxb operator>(const avxi &a, const avxi &b) +{ + return _mm256_castsi256_ps(_mm256_cmpgt_epi32(a.m256, b.m256)); +} +#else +__forceinline const avxb operator>(const avxi &a, const avxi &b) +{ + return avxb(_mm_castsi128_ps(_mm_cmpgt_epi32(a.l, b.l)), + _mm_castsi128_ps(_mm_cmpgt_epi32(a.h, b.h))); +} +#endif +__forceinline const avxb operator>(const avxi &a, const int32_t b) +{ + return a > avxi(b); +} +__forceinline const avxb operator>(const int32_t a, const avxi &b) +{ + return avxi(a) > b; +} + +__forceinline const avxb operator<=(const avxi &a, const avxi &b) +{ + return !(a > b); +} +__forceinline const avxb operator<=(const avxi &a, const int32_t b) +{ + return a <= avxi(b); +} +__forceinline const avxb operator<=(const int32_t a, const avxi &b) +{ + return avxi(a) <= b; +} + +__forceinline const avxi select(const avxb &m, const avxi &t, const avxi &f) +{ + return _mm256_castps_si256(_mm256_blendv_ps(_mm256_castsi256_ps(f), _mm256_castsi256_ps(t), m)); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Movement/Shifting/Shuffling Functions +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__KERNEL_AVX2__) +__forceinline avxi unpacklo(const avxi &a, const avxi &b) +{ + return _mm256_unpacklo_epi32(a.m256, b.m256); +} +__forceinline avxi unpackhi(const avxi &a, const avxi &b) +{ + return _mm256_unpackhi_epi32(a.m256, b.m256); +} +#else +__forceinline avxi unpacklo(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_unpacklo_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); +} +__forceinline avxi unpackhi(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_unpackhi_ps(_mm256_castsi256_ps(a), _mm256_castsi256_ps(b))); +} +#endif + +template __forceinline const avxi shuffle(const avxi &a) +{ + return _mm256_castps_si256(_mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i, i, i, i))); +} + +template __forceinline const avxi shuffle(const avxi &a) +{ + return _mm256_permute2f128_si256(a, a, (i1 << 4) | (i0 << 0)); +} + +template __forceinline const avxi shuffle(const avxi &a, const avxi &b) +{ + return _mm256_permute2f128_si256(a, b, (i1 << 4) | (i0 << 0)); +} + +template +__forceinline const avxi shuffle(const avxi &a) +{ + return _mm256_castps_si256( + _mm256_permute_ps(_mm256_castsi256_ps(a), _MM_SHUFFLE(i3, i2, i1, i0))); +} + +template +__forceinline const avxi shuffle(const avxi &a, const avxi &b) +{ + return _mm256_castps_si256(_mm256_shuffle_ps( + _mm256_castsi256_ps(a), _mm256_castsi256_ps(b), _MM_SHUFFLE(i3, i2, i1, i0))); +} + +template<> __forceinline const avxi shuffle<0, 0, 2, 2>(const avxi &b) +{ + return _mm256_castps_si256(_mm256_moveldup_ps(_mm256_castsi256_ps(b))); +} +template<> __forceinline const avxi shuffle<1, 1, 3, 3>(const avxi &b) +{ + return _mm256_castps_si256(_mm256_movehdup_ps(_mm256_castsi256_ps(b))); +} +template<> __forceinline const avxi shuffle<0, 1, 0, 1>(const avxi &b) +{ + return _mm256_castps_si256( + _mm256_castpd_ps(_mm256_movedup_pd(_mm256_castps_pd(_mm256_castsi256_ps(b))))); +} + +__forceinline const avxi broadcast(const int *ptr) +{ + return _mm256_castps_si256(_mm256_broadcast_ss((const float *)ptr)); +} +template __forceinline const avxi insert(const avxi &a, const ssei &b) +{ + return _mm256_insertf128_si256(a, b, i); +} +template __forceinline const ssei extract(const avxi &a) +{ + return _mm256_extractf128_si256(a, i); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Reductions +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxi vreduce_min2(const avxi &v) +{ + return min(v, shuffle<1, 0, 3, 2>(v)); +} +__forceinline const avxi vreduce_min4(const avxi &v) +{ + avxi v1 = vreduce_min2(v); + return min(v1, shuffle<2, 3, 0, 1>(v1)); +} +__forceinline const avxi vreduce_min(const avxi &v) +{ + avxi v1 = vreduce_min4(v); + return min(v1, shuffle<1, 0>(v1)); +} + +__forceinline const avxi vreduce_max2(const avxi &v) +{ + return max(v, shuffle<1, 0, 3, 2>(v)); +} +__forceinline const avxi vreduce_max4(const avxi &v) +{ + avxi v1 = vreduce_max2(v); + return max(v1, shuffle<2, 3, 0, 1>(v1)); +} +__forceinline const avxi vreduce_max(const avxi &v) +{ + avxi v1 = vreduce_max4(v); + return max(v1, shuffle<1, 0>(v1)); +} + +__forceinline const avxi vreduce_add2(const avxi &v) +{ + return v + shuffle<1, 0, 3, 2>(v); +} +__forceinline const avxi vreduce_add4(const avxi &v) +{ + avxi v1 = vreduce_add2(v); + return v1 + shuffle<2, 3, 0, 1>(v1); +} +__forceinline const avxi vreduce_add(const avxi &v) +{ + avxi v1 = vreduce_add4(v); + return v1 + shuffle<1, 0>(v1); +} + +__forceinline int reduce_min(const avxi &v) +{ + return extract<0>(extract<0>(vreduce_min(v))); +} +__forceinline int reduce_max(const avxi &v) +{ + return extract<0>(extract<0>(vreduce_max(v))); +} +__forceinline int reduce_add(const avxi &v) +{ + return extract<0>(extract<0>(vreduce_add(v))); +} + +__forceinline size_t select_min(const avxi &v) +{ + return __bsf(movemask(v == vreduce_min(v))); +} +__forceinline size_t select_max(const avxi &v) +{ + return __bsf(movemask(v == vreduce_max(v))); +} + +__forceinline size_t select_min(const avxb &valid, const avxi &v) +{ + const avxi a = select(valid, v, avxi(pos_inf)); + return __bsf(movemask(valid & (a == vreduce_min(a)))); +} +__forceinline size_t select_max(const avxb &valid, const avxi &v) +{ + const avxi a = select(valid, v, avxi(neg_inf)); + return __bsf(movemask(valid & (a == vreduce_max(a)))); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Output Operators +//////////////////////////////////////////////////////////////////////////////// + +ccl_device_inline void print_avxi(const char *label, const avxi &a) +{ + printf("%s: %d %d %d %d %d %d %d %d\n", label, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); +} + +CCL_NAMESPACE_END + +#endif diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h index ca48758efcd..0021eec169b 100644 --- a/intern/cycles/util/util_hash.h +++ b/intern/cycles/util/util_hash.h @@ -312,6 +312,60 @@ ccl_device_inline ssei hash_ssei4(ssei kx, ssei ky, ssei kz, ssei kw) return c; } +# if defined(__KERNEL_AVX__) +ccl_device_inline avxi hash_avxi(avxi kx) +{ + avxi a, b, c; + a = b = c = avxi(0xdeadbeef + (1 << 2) + 13); + + a += kx; + final(a, b, c); + + return c; +} + +ccl_device_inline avxi hash_avxi2(avxi kx, avxi ky) +{ + avxi a, b, c; + a = b = c = avxi(0xdeadbeef + (2 << 2) + 13); + + b += ky; + a += kx; + final(a, b, c); + + return c; +} + +ccl_device_inline avxi hash_avxi3(avxi kx, avxi ky, avxi kz) +{ + avxi a, b, c; + a = b = c = avxi(0xdeadbeef + (3 << 2) + 13); + + c += kz; + b += ky; + a += kx; + final(a, b, c); + + return c; +} + +ccl_device_inline avxi hash_avxi4(avxi kx, avxi ky, avxi kz, avxi kw) +{ + avxi a, b, c; + a = b = c = avxi(0xdeadbeef + (4 << 2) + 13); + + a += kx; + b += ky; + c += kz; + mix(a, b, c); + + a += kw; + final(a, b, c); + + return c; +} +# endif + # undef rot # undef final # undef mix diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index f49cfb4184d..922f5dd274e 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -75,6 +75,28 @@ static struct FalseTy { } } False ccl_maybe_unused; +static struct ZeroTy { + __forceinline operator float() const + { + return 0; + } + __forceinline operator int() const + { + return 0; + } +} zero ccl_maybe_unused; + +static struct OneTy { + __forceinline operator float() const + { + return 1; + } + __forceinline operator int() const + { + return 1; + } +} one ccl_maybe_unused; + static struct NegInfTy { __forceinline operator float() const { @@ -97,6 +119,9 @@ static struct PosInfTy { } } inf ccl_maybe_unused, pos_inf ccl_maybe_unused; +static struct StepTy { +} step ccl_maybe_unused; + /* Intrinsics Functions */ # if defined(__BMI__) && defined(__GNUC__) diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index f6535848480..a721595667d 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -158,6 +158,7 @@ CCL_NAMESPACE_END # if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) # include "util/util_avxb.h" # include "util/util_avxf.h" +# include "util/util_avxi.h" # endif #endif -- cgit v1.2.3 From 25b2b6724d19d6f1f46b0489f58d03215127aeef Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 1 Apr 2020 16:21:34 +0200 Subject: Fix T74224: Add missing depsgraph relations for boid particles Reviewers: brecht Differential Revision: https://developer.blender.org/D7302 --- source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 2 +- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index f2108b3ad6c..128b2d3a9bf 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -1164,7 +1164,7 @@ void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object /* Particle system evaluation. */ add_operation_node(psys_comp, OperationCode::PARTICLE_SYSTEM_EVAL, nullptr, psys->name); /* Keyed particle targets. */ - if (part->phystype == PART_PHYS_KEYED) { + if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) { if (particle_target->ob == nullptr || particle_target->ob == object) { continue; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 40fbfbc2b99..9258af3e164 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1789,7 +1789,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) } } /* Keyed particle targets. */ - if (part->phystype == PART_PHYS_KEYED) { + if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) { if (particle_target->ob == nullptr || particle_target->ob == object) { continue; -- cgit v1.2.3 From c4374bc919c6ae8162ce5724a51a360e3dd36bfa Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 1 Apr 2020 18:00:35 +0200 Subject: Fix T75271: GPencil Segment select mode doesn't work The selection was workring with the evaluated data, but need work with the original data. --- source/blender/editors/gpencil/gpencil_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 312cb1b50c0..e153c22b17f 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2173,7 +2173,8 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl, float f = 0.0f; int i2 = 0; - bGPDframe *gpf = gpl->actframe; + bGPDlayer *gpl_orig = (gpl->runtime.gpl_orig) ? gpl->runtime.gpl_orig : gpl; + bGPDframe *gpf = gpl_orig->actframe; if (gpf == NULL) { return 0; } -- cgit v1.2.3 From a9963669f9d2360a8a7c84c36db5cd64df5e2139 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 1 Apr 2020 19:35:35 +0200 Subject: Fix T75283: GPencil Stroke created by `Merge points` can't have fill material --- source/blender/editors/gpencil/gpencil_merge.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index bd9daa83411..6a5c5f7eb07 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -132,18 +132,8 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, add_frame_mode); /* stroke */ - bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - gps->totpoints = totpoints; - gps->inittime = 0.0f; - gps->thickness = brush->size; - gps->hardeness = brush->gpencil_settings->hardeness; - copy_v2_v2(gps->aspect_ratio, brush->gpencil_settings->aspect_ratio); + bGPDstroke *gps = BKE_gpencil_stroke_new(ob->actcol - 1, totpoints, brush->size); gps->flag |= GP_STROKE_SELECT; - gps->flag |= GP_STROKE_3DSPACE; - gps->mat_nr = ob->actcol - 1; - - /* allocate memory for points */ - gps->points = MEM_callocN(sizeof(bGPDspoint) * totpoints, "gp_stroke_points"); if (cyclic) { gps->flag |= GP_STROKE_CYCLIC; @@ -529,6 +519,8 @@ static int gp_stroke_merge_exec(bContext *C, wmOperator *op) gpencil_dissolve_points(C); } + BKE_gpencil_stroke_geometry_update(gps); + /* free memory */ MEM_SAFE_FREE(original_array); MEM_SAFE_FREE(sorted_array); -- cgit v1.2.3 From 3ebebe62d77cb04618e3bf6b6b8602e7130dac6e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2020 16:54:28 +0100 Subject: Sculpt Undo: Fix multires undo for interleaved nodes Made it so grids array is properly allocated when first node in the undo list does not contain grid data. Differential Revision: https://developer.blender.org/D7299 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 67ef82aeaaf..bb463d29f1c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -677,11 +677,18 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } if (use_multires_undo) { - int max_grid; - unode = lb->first; - max_grid = unode->maxgrid; - undo_modified_grids = MEM_callocN(sizeof(char) * max_grid, "undo_grids"); for (unode = lb->first; unode; unode = unode->next) { + if (!STREQ(unode->idname, ob->id.name)) { + continue; + } + if (unode->maxgrid == 0) { + continue; + } + + if (undo_modified_grids == NULL) { + undo_modified_grids = MEM_callocN(sizeof(char) * unode->maxgrid, "undo_grids"); + } + for (int i = 0; i < unode->totgrid; i++) { undo_modified_grids[unode->grids[i]] = 1; } -- cgit v1.2.3 From 06cb321f337fdff0cb71814d955c6f929c8d354c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 31 Mar 2020 15:34:39 +0200 Subject: Sculpt: Give a brief explanation of undo stack Should make it a bit more clear overview of what is going on in this module. While some of the details might still be missing, having some sort of top-level overview is better than nothing. Differential Revision: https://developer.blender.org/D7300 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index bb463d29f1c..cccc5e29ba7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -67,6 +67,45 @@ #include "bmesh.h" #include "sculpt_intern.h" +/* Implementation of undo system for objects in sculpt mode. + * + * Each undo step in sculpt mode consists of list of nodes, each node contains: + * - Node type + * - Data for this type. + * + * Node type used for undo depends on specific operation and active sculpt mode + * ("regular" or dynamic topology). + * + * Regular sculpt brushes will use COORDS, HIDDEN or MASK nodes. These nodes are + * created for every BVH node which is affected by the brush. The undo push for + * the node happens BEFORE modifications. This makes the operation undo to work + * in the following way: for every node in the undo step swap happens between + * node in the undo stack and the corresponding value in the BVH. This is how + * redo is possible after undo. + * + * The COORDS, HIDDEN or MASK type of nodes contains arrays of the corresponding + * values. + * + * Operations like Symmetrize are using GEOMETRY type of nodes which pushes the + * entire state of the mesh to the undo stack. This node contains all CustomData + * layers. + * + * The tricky aspect of this undo node type is that it stores mesh before and + * after modification. This allows the undo system to both undo and redo the + * symmetrize operation within the pre-modified-push of other node type + * behavior, but it uses more memory that it seems it should be. + * + * The dynamic topology undo nodes are handled somewhat separately from all + * other ones and the idea there is to store log of operations: which verticies + * and faces have been added or removed. + * + * Begin of dynamic topology sculpting mode have own node type. It contains an + * entire copy of mesh since just enabling the dynamic topology mode already + * does modifications on it. + * + * End of dynamic topology and symmetrize in this mode are handled in a special + * manner as well. */ + typedef struct UndoSculpt { ListBase nodes; -- cgit v1.2.3 From 1c3ded12f439c90beee155ebd9261b8b2e947674 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 2 Apr 2020 10:34:05 +0200 Subject: Fluids: improve subframe handling Reviewers: sebbas Differential Revision: https://developer.blender.org/D7256 --- source/blender/blenkernel/intern/fluid.c | 73 +++++++------------------------- 1 file changed, 15 insertions(+), 58 deletions(-) diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 75e1dce9958..e8da4385fb9 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -1232,52 +1232,31 @@ static void update_obstacles(Depsgraph *depsgraph, continue; } - /* Length of one adaptive frame. If using adaptive stepping, length is smaller than actual - * frame length */ - float adaptframe_length = time_per_frame / frame_length; - /* Adaptive frame length as percentage */ - CLAMP(adaptframe_length, 0.0f, 1.0f); - - /* More splitting because of emission subframe: If no subframes present, sample_size is 1. */ - float sample_size = 1.0f / (float)(subframes + 1); - /* First frame cannot have any subframes because there is (obviously) no previous frame from * where subframes could come from. */ if (is_first_frame) { subframes = 0; } - int subframe; + /* More splitting because of emission subframe: If no subframes present, sample_size is 1. */ + float sample_size = 1.0f / (float)(subframes + 1); float subframe_dt = dt * sample_size; /* Emission loop. When not using subframes this will loop only once. */ - for (subframe = subframes; subframe >= 0; subframe--) { + for (int subframe = 0; subframe <= subframes; subframe++) { /* Temporary emission map used when subframes are enabled, i.e. at least one subframe. */ FluidObjectBB bb_temp = {NULL}; /* Set scene time */ /* Handle emission subframe */ - if (subframe > 0 && !is_first_frame) { - scene->r.subframe = adaptframe_length - - sample_size * (float)(subframe) * (dt / frame_length); + if (subframe < subframes || time_per_frame + dt + FLT_EPSILON < frame_length) { + scene->r.subframe = (time_per_frame + (subframe + 1.0f) * subframe_dt) / frame_length; scene->r.cfra = frame - 1; } - /* Last frame in this loop (subframe == suframes). Can be real end frame or in between - * frames (adaptive frame). */ else { - /* Handle adaptive subframe (ie has subframe fraction). Need to set according scene - * subframe parameter. */ - if (time_per_frame < frame_length) { - scene->r.subframe = adaptframe_length; - scene->r.cfra = frame - 1; - } - /* Handle absolute endframe (ie no subframe fraction). Need to set the scene subframe - * parameter to 0 and advance current scene frame. */ - else { - scene->r.subframe = 0.0f; - scene->r.cfra = frame; - } + scene->r.subframe = 0.0f; + scene->r.cfra = frame; } /* Sanity check: subframe portion must be between 0 and 1. */ CLAMP(scene->r.subframe, 0.0f, 1.0f); @@ -2768,53 +2747,31 @@ static void update_flowsfluids(struct Depsgraph *depsgraph, continue; } - /* Length of one adaptive frame. If using adaptive stepping, length is smaller than actual - * frame length */ - float adaptframe_length = time_per_frame / frame_length; - /* Adaptive frame length as percentage */ - CLAMP(adaptframe_length, 0.0f, 1.0f); - - /* More splitting because of emission subframe: If no subframes present, sample_size is 1. */ - float sample_size = 1.0f / (float)(subframes + 1); - /* First frame cannot have any subframes because there is (obviously) no previous frame from * where subframes could come from. */ if (is_first_frame) { subframes = 0; } - int subframe; + /* More splitting because of emission subframe: If no subframes present, sample_size is 1. */ + float sample_size = 1.0f / (float)(subframes + 1); float subframe_dt = dt * sample_size; /* Emission loop. When not using subframes this will loop only once. */ - for (subframe = subframes; subframe >= 0; subframe--) { - + for (int subframe = 0; subframe <= subframes; subframe++) { /* Temporary emission map used when subframes are enabled, i.e. at least one subframe. */ FluidObjectBB bb_temp = {NULL}; /* Set scene time */ - /* Handle emission subframe */ - if (subframe > 0 && !is_first_frame) { - scene->r.subframe = adaptframe_length - - sample_size * (float)(subframe) * (dt / frame_length); + if (subframe < subframes || time_per_frame + dt + FLT_EPSILON < frame_length) { + scene->r.subframe = (time_per_frame + (subframe + 1.0f) * subframe_dt) / frame_length; scene->r.cfra = frame - 1; } - /* Last frame in this loop (subframe == suframes). Can be real end frame or in between - * frames (adaptive frame). */ else { - /* Handle adaptive subframe (ie has subframe fraction). Need to set according scene - * subframe parameter. */ - if (time_per_frame < frame_length) { - scene->r.subframe = adaptframe_length; - scene->r.cfra = frame - 1; - } - /* Handle absolute endframe (ie no subframe fraction). Need to set the scene subframe - * parameter to 0 and advance current scene frame. */ - else { - scene->r.subframe = 0.0f; - scene->r.cfra = frame; - } + scene->r.subframe = 0.0f; + scene->r.cfra = frame; } + /* Sanity check: subframe portion must be between 0 and 1. */ CLAMP(scene->r.subframe, 0.0f, 1.0f); # ifdef DEBUG_PRINT -- cgit v1.2.3 From 782e6ea4edd9cb09f2583c8f28a24d6330dc6ce8 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 31 Mar 2020 15:32:03 +0200 Subject: Fix T72688: Vertex Group Weights in Edit Mode Occludes In Front Armatures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to legacy this overlay was implemented twice (Edit Mesh and Weight Painting) with different results. This patch consolidates both drawing and uses only the Weight Painting drawing. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D7289 --- .../blender/draw/engines/overlay/overlay_edit_mesh.c | 20 +------------------- source/blender/draw/engines/overlay/overlay_engine.c | 9 +++++++++ source/blender/draw/engines/overlay/overlay_paint.c | 16 ++++++++++------ .../blender/draw/engines/overlay/overlay_private.h | 2 -- source/blender/draw/intern/draw_manager.c | 5 +---- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index 400947ea819..be4e4a9e00e 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -118,18 +118,6 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) show_face_dots = true; } - { - /* TODO(fclem) Shouldn't this be going into the paint overlay? */ - state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; - DRW_PASS_CREATE(psl->edit_mesh_weight_ps, state | pd->clipping_state); - - sh = OVERLAY_shader_paint_weight(); - pd->edit_mesh_weight_grp = grp = DRW_shgroup_create(sh, psl->edit_mesh_weight_ps); - DRW_shgroup_uniform_float_copy(grp, "opacity", 1.0); - DRW_shgroup_uniform_bool_copy(grp, "drawContours", false); - DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp); - DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - } /* Run Twice for in-front passes. */ for (int i = 0; i < 2; i++) { /* Complementary Depth Pass */ @@ -283,17 +271,12 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0; bool do_occlude_wire = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0; - bool do_show_weight = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT) != 0; bool do_show_mesh_analysis = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_STATVIS) != 0; bool fnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0; bool vnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0; bool lnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0; - if (do_show_weight) { - geom = DRW_cache_mesh_surface_weights_get(ob); - DRW_shgroup_call_no_cull(pd->edit_mesh_weight_grp, geom, ob); - } - else if (do_show_mesh_analysis && !pd->xray_enabled) { + if (do_show_mesh_analysis && !pd->xray_enabled) { geom = DRW_cache_mesh_surface_mesh_analysis_get(ob); if (geom) { DRW_shgroup_call_no_cull(pd->edit_mesh_analysis_grp, geom, ob); @@ -364,7 +347,6 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata) GPU_framebuffer_bind(fbl->overlay_default_fb); } - DRW_draw_pass(psl->edit_mesh_weight_ps); DRW_draw_pass(psl->edit_mesh_analysis_ps); DRW_draw_pass(psl->edit_mesh_depth_ps[NOT_IN_FRONT]); diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index e0b599f43a9..19b0fa5e12b 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -106,10 +106,14 @@ static void OVERLAY_cache_init(void *vedata) OVERLAY_Data *data = vedata; OVERLAY_StorageList *stl = data->stl; OVERLAY_PrivateData *pd = stl->pd; + const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: OVERLAY_edit_mesh_cache_init(vedata); + if (draw_edit_weights) { + OVERLAY_paint_cache_init(vedata); + } break; case CTX_MODE_EDIT_SURFACE: case CTX_MODE_EDIT_CURVE: @@ -251,6 +255,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) (ob->base_flag & BASE_SELECTED); const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom && !is_select; + const bool draw_edit_weights = in_edit_mode && (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); const bool draw_extras = (!pd->hide_overlays) && (((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || @@ -279,6 +284,9 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) switch (ob->type) { case OB_MESH: OVERLAY_edit_mesh_cache_populate(vedata, ob); + if (draw_edit_weights) { + OVERLAY_paint_weight_cache_populate(vedata, ob); + } break; case OB_ARMATURE: if (draw_bones) { @@ -495,6 +503,7 @@ static void OVERLAY_draw_scene(void *vedata) switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: + OVERLAY_paint_draw(vedata); OVERLAY_edit_mesh_draw(vedata); break; case CTX_MODE_EDIT_SURFACE: diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 4a1aa270de0..33008963d8b 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -76,15 +76,18 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; DRWState state; - const bool draw_contours = (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; + const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); + const bool draw_contours = !is_edit_mode && + (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; float opacity = 0.0f; pd->paint_depth_grp = NULL; psl->paint_depth_ps = NULL; switch (pd->ctx_mode) { case CTX_MODE_POSE: + case CTX_MODE_EDIT_MESH: case CTX_MODE_PAINT_WEIGHT: { - opacity = pd->overlay.weight_paint_mode_opacity; + opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity; if (opacity > 0.0f) { state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; state |= pd->painting.alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL; @@ -207,11 +210,12 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) struct GPUBatch *geom = NULL; const Mesh *me_orig = DEG_get_original_object(ob)->data; - const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; - const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; + const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); + const bool use_wire = !is_edit_mode && (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE); + const bool use_face_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL); + const bool use_vert_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL); - if (ob->mode == OB_MODE_WEIGHT_PAINT) { + if (ELEM(ob->mode, OB_MODE_WEIGHT_PAINT, OB_MODE_EDIT)) { if (pd->paint_surf_grp) { geom = DRW_cache_mesh_surface_weights_get(ob); DRW_shgroup_call(pd->paint_surf_grp, geom, ob); diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index bd9583c6a5f..fa3d6fe3d8a 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -70,7 +70,6 @@ typedef struct OVERLAY_PassList { DRWPass *edit_mesh_faces_cage_ps[2]; DRWPass *edit_mesh_analysis_ps; DRWPass *edit_mesh_normals_ps; - DRWPass *edit_mesh_weight_ps; DRWPass *edit_particle_ps; DRWPass *edit_text_overlay_ps; DRWPass *edit_text_wire_ps[2]; @@ -235,7 +234,6 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *edit_mesh_skin_roots_grp[2]; DRWShadingGroup *edit_mesh_normals_grp; DRWShadingGroup *edit_mesh_analysis_grp; - DRWShadingGroup *edit_mesh_weight_grp; DRWShadingGroup *edit_particle_strand_grp; DRWShadingGroup *edit_particle_point_grp; DRWShadingGroup *edit_text_overlay_grp; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index b265035f449..1b169dbee1d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -145,11 +145,8 @@ bool DRW_object_is_renderable(const Object *ob) if (ob->type == OB_MESH) { if ((ob == DST.draw_ctx.object_edit) || DRW_object_is_in_edit_mode(ob)) { - View3D *v3d = DST.draw_ctx.v3d; - const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT); - - if (v3d && v3d->overlay.edit_flag & mask) { + if (v3d && v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) { return false; } } -- cgit v1.2.3 From 53d029d6daaa79ed2eb3e647a7c1313e47953fda Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 2 Apr 2020 13:49:08 +0200 Subject: Cleanup: Avoid complex template type for XR-Swapchain I rather avoid types like `std::vector>`, which is easy to do in this case. --- intern/ghost/intern/GHOST_XrSession.cpp | 7 +++---- intern/ghost/intern/GHOST_XrSwapchain.cpp | 12 +++++++++++- intern/ghost/intern/GHOST_XrSwapchain.h | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index dbe0846a2ca..7be0f300210 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -45,7 +45,7 @@ struct OpenXRSessionData { XrSpace reference_space; XrSpace view_space; std::vector views; - std::vector> swapchains; + std::vector swapchains; }; struct GHOST_XrDrawInfo { @@ -267,8 +267,7 @@ void GHOST_XrSession::prepareDrawing() "Failed to get count of view configurations."); for (const XrViewConfigurationView &view_config : view_configs) { - m_oxr->swapchains.push_back(std::unique_ptr( - new GHOST_XrSwapchain(*m_gpu_binding, m_oxr->session, view_config))); + m_oxr->swapchains.emplace_back(*m_gpu_binding, m_oxr->session, view_config); } m_oxr->views.resize(view_count, {XR_TYPE_VIEW}); @@ -443,7 +442,7 @@ XrCompositionLayerProjection GHOST_XrSession::drawLayer( r_proj_layer_views.resize(view_count); for (uint32_t view_idx = 0; view_idx < view_count; view_idx++) { - drawView(*m_oxr->swapchains[view_idx], + drawView(m_oxr->swapchains[view_idx], r_proj_layer_views[view_idx], view_location, m_oxr->views[view_idx], diff --git a/intern/ghost/intern/GHOST_XrSwapchain.cpp b/intern/ghost/intern/GHOST_XrSwapchain.cpp index 4c91bcc2dc3..f50cfde0687 100644 --- a/intern/ghost/intern/GHOST_XrSwapchain.cpp +++ b/intern/ghost/intern/GHOST_XrSwapchain.cpp @@ -92,9 +92,19 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, m_oxr->swapchain_images = swapchain_images_create(m_oxr->swapchain, gpu_binding); } +GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other) + : m_oxr(std::move(other.m_oxr)), + m_image_width(other.m_image_width), + m_image_height(other.m_image_height) +{ + /* Prevent xrDestroySwapchain call for the moved out item. */ + other.m_oxr = nullptr; +} + GHOST_XrSwapchain::~GHOST_XrSwapchain() { - if (m_oxr->swapchain != XR_NULL_HANDLE) { + /* m_oxr may be NULL after move. */ + if (m_oxr && m_oxr->swapchain != XR_NULL_HANDLE) { CHECK_XR_ASSERT(xrDestroySwapchain(m_oxr->swapchain)); } } diff --git a/intern/ghost/intern/GHOST_XrSwapchain.h b/intern/ghost/intern/GHOST_XrSwapchain.h index df9cd924dd0..ab0a6736c9c 100644 --- a/intern/ghost/intern/GHOST_XrSwapchain.h +++ b/intern/ghost/intern/GHOST_XrSwapchain.h @@ -30,6 +30,7 @@ class GHOST_XrSwapchain { GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, const XrSession &session, const XrViewConfigurationView &view_config); + GHOST_XrSwapchain(GHOST_XrSwapchain &&other); ~GHOST_XrSwapchain(); XrSwapchainImageBaseHeader *acquireDrawableSwapchainImage(); -- cgit v1.2.3 From 7bffdab93c40d6de0410f767cdb24ebe1e478344 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Thu, 2 Apr 2020 07:03:36 -0600 Subject: CMake: Add alembic boost dependency When building lite + alembic + boost cmake would turn boost off because it deemed it not needed leading to build errors. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a781488002a..5fb0393dcda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -633,9 +633,10 @@ set_and_warn_dependency(WITH_BOOST WITH_OPENVDB OFF) set_and_warn_dependency(WITH_BOOST WITH_OPENCOLORIO OFF) set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF) set_and_warn_dependency(WITH_BOOST WITH_USD OFF) +set_and_warn_dependency(WITH_BOOST WITH_ALEMBIC OFF) if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR - WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_USD)) + WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_USD OR WITH_ALEMBIC)) message(STATUS "No dependencies need 'WITH_BOOST' forcing WITH_BOOST=OFF") set(WITH_BOOST OFF) endif() -- cgit v1.2.3 From fa8a3c8f26f4eeb09d5d8b2792d32887be4fe111 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 2 Apr 2020 15:05:41 +0200 Subject: Revert "Fix T72688: Vertex Group Weights in Edit Mode Occludes In Front Armatures" This reverts commit 782e6ea4edd9cb09f2583c8f28a24d6330dc6ce8. Said fix introduced a crash the moment one goes to edit mode. --- .../blender/draw/engines/overlay/overlay_edit_mesh.c | 20 +++++++++++++++++++- source/blender/draw/engines/overlay/overlay_engine.c | 9 --------- source/blender/draw/engines/overlay/overlay_paint.c | 16 ++++++---------- .../blender/draw/engines/overlay/overlay_private.h | 2 ++ source/blender/draw/intern/draw_manager.c | 5 ++++- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index be4e4a9e00e..400947ea819 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -118,6 +118,18 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) show_face_dots = true; } + { + /* TODO(fclem) Shouldn't this be going into the paint overlay? */ + state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; + DRW_PASS_CREATE(psl->edit_mesh_weight_ps, state | pd->clipping_state); + + sh = OVERLAY_shader_paint_weight(); + pd->edit_mesh_weight_grp = grp = DRW_shgroup_create(sh, psl->edit_mesh_weight_ps); + DRW_shgroup_uniform_float_copy(grp, "opacity", 1.0); + DRW_shgroup_uniform_bool_copy(grp, "drawContours", false); + DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + } /* Run Twice for in-front passes. */ for (int i = 0; i < 2; i++) { /* Complementary Depth Pass */ @@ -271,12 +283,17 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0; bool do_occlude_wire = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0; + bool do_show_weight = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT) != 0; bool do_show_mesh_analysis = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_STATVIS) != 0; bool fnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0; bool vnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0; bool lnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0; - if (do_show_mesh_analysis && !pd->xray_enabled) { + if (do_show_weight) { + geom = DRW_cache_mesh_surface_weights_get(ob); + DRW_shgroup_call_no_cull(pd->edit_mesh_weight_grp, geom, ob); + } + else if (do_show_mesh_analysis && !pd->xray_enabled) { geom = DRW_cache_mesh_surface_mesh_analysis_get(ob); if (geom) { DRW_shgroup_call_no_cull(pd->edit_mesh_analysis_grp, geom, ob); @@ -347,6 +364,7 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata) GPU_framebuffer_bind(fbl->overlay_default_fb); } + DRW_draw_pass(psl->edit_mesh_weight_ps); DRW_draw_pass(psl->edit_mesh_analysis_ps); DRW_draw_pass(psl->edit_mesh_depth_ps[NOT_IN_FRONT]); diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 19b0fa5e12b..e0b599f43a9 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -106,14 +106,10 @@ static void OVERLAY_cache_init(void *vedata) OVERLAY_Data *data = vedata; OVERLAY_StorageList *stl = data->stl; OVERLAY_PrivateData *pd = stl->pd; - const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: OVERLAY_edit_mesh_cache_init(vedata); - if (draw_edit_weights) { - OVERLAY_paint_cache_init(vedata); - } break; case CTX_MODE_EDIT_SURFACE: case CTX_MODE_EDIT_CURVE: @@ -255,7 +251,6 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) (ob->base_flag & BASE_SELECTED); const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom && !is_select; - const bool draw_edit_weights = in_edit_mode && (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); const bool draw_extras = (!pd->hide_overlays) && (((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || @@ -284,9 +279,6 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) switch (ob->type) { case OB_MESH: OVERLAY_edit_mesh_cache_populate(vedata, ob); - if (draw_edit_weights) { - OVERLAY_paint_weight_cache_populate(vedata, ob); - } break; case OB_ARMATURE: if (draw_bones) { @@ -503,7 +495,6 @@ static void OVERLAY_draw_scene(void *vedata) switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: - OVERLAY_paint_draw(vedata); OVERLAY_edit_mesh_draw(vedata); break; case CTX_MODE_EDIT_SURFACE: diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 33008963d8b..4a1aa270de0 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -76,18 +76,15 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; DRWState state; - const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); - const bool draw_contours = !is_edit_mode && - (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; + const bool draw_contours = (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; float opacity = 0.0f; pd->paint_depth_grp = NULL; psl->paint_depth_ps = NULL; switch (pd->ctx_mode) { case CTX_MODE_POSE: - case CTX_MODE_EDIT_MESH: case CTX_MODE_PAINT_WEIGHT: { - opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity; + opacity = pd->overlay.weight_paint_mode_opacity; if (opacity > 0.0f) { state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; state |= pd->painting.alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL; @@ -210,12 +207,11 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) struct GPUBatch *geom = NULL; const Mesh *me_orig = DEG_get_original_object(ob)->data; - const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); - const bool use_wire = !is_edit_mode && (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE); - const bool use_face_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL); - const bool use_vert_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL); + const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; + const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; + const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; - if (ELEM(ob->mode, OB_MODE_WEIGHT_PAINT, OB_MODE_EDIT)) { + if (ob->mode == OB_MODE_WEIGHT_PAINT) { if (pd->paint_surf_grp) { geom = DRW_cache_mesh_surface_weights_get(ob); DRW_shgroup_call(pd->paint_surf_grp, geom, ob); diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index fa3d6fe3d8a..bd9583c6a5f 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -70,6 +70,7 @@ typedef struct OVERLAY_PassList { DRWPass *edit_mesh_faces_cage_ps[2]; DRWPass *edit_mesh_analysis_ps; DRWPass *edit_mesh_normals_ps; + DRWPass *edit_mesh_weight_ps; DRWPass *edit_particle_ps; DRWPass *edit_text_overlay_ps; DRWPass *edit_text_wire_ps[2]; @@ -234,6 +235,7 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *edit_mesh_skin_roots_grp[2]; DRWShadingGroup *edit_mesh_normals_grp; DRWShadingGroup *edit_mesh_analysis_grp; + DRWShadingGroup *edit_mesh_weight_grp; DRWShadingGroup *edit_particle_strand_grp; DRWShadingGroup *edit_particle_point_grp; DRWShadingGroup *edit_text_overlay_grp; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1b169dbee1d..b265035f449 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -145,8 +145,11 @@ bool DRW_object_is_renderable(const Object *ob) if (ob->type == OB_MESH) { if ((ob == DST.draw_ctx.object_edit) || DRW_object_is_in_edit_mode(ob)) { + View3D *v3d = DST.draw_ctx.v3d; - if (v3d && v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) { + const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT); + + if (v3d && v3d->overlay.edit_flag & mask) { return false; } } -- cgit v1.2.3 From f5e4f20dc1439bee3a76e6a850e5af66acc09036 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Thu, 2 Apr 2020 07:08:51 -0600 Subject: Fix: Build error when building with python off --- source/creator/creator_args.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index a5b9df166a4..6ce3066ece1 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -1929,7 +1929,9 @@ static int arg_handle_python_use_system_env_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { +# ifdef WITH_PYTHON BPY_python_use_system_env(); +# endif return 0; } -- cgit v1.2.3 From 88362565f688028a4a098a7911534e1d757d1c69 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 2 Apr 2020 15:10:56 +0200 Subject: Fix T72688: Vertex Group Weights in Edit Mode Occludes In Front Armatures Due to legacy this overlay was implemented twice (Edit Mesh and Weight Painting) with different results. This patch consolidates both drawing and uses only the Weight Painting drawing. --- .../blender/draw/engines/overlay/overlay_edit_mesh.c | 20 +------------------- source/blender/draw/engines/overlay/overlay_engine.c | 9 +++++++++ source/blender/draw/engines/overlay/overlay_paint.c | 16 ++++++++++------ .../blender/draw/engines/overlay/overlay_private.h | 2 -- source/blender/draw/intern/draw_manager.c | 5 +---- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index 400947ea819..be4e4a9e00e 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -118,18 +118,6 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) show_face_dots = true; } - { - /* TODO(fclem) Shouldn't this be going into the paint overlay? */ - state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; - DRW_PASS_CREATE(psl->edit_mesh_weight_ps, state | pd->clipping_state); - - sh = OVERLAY_shader_paint_weight(); - pd->edit_mesh_weight_grp = grp = DRW_shgroup_create(sh, psl->edit_mesh_weight_ps); - DRW_shgroup_uniform_float_copy(grp, "opacity", 1.0); - DRW_shgroup_uniform_bool_copy(grp, "drawContours", false); - DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp); - DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - } /* Run Twice for in-front passes. */ for (int i = 0; i < 2; i++) { /* Complementary Depth Pass */ @@ -283,17 +271,12 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0; bool do_occlude_wire = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0; - bool do_show_weight = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT) != 0; bool do_show_mesh_analysis = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_STATVIS) != 0; bool fnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0; bool vnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0; bool lnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0; - if (do_show_weight) { - geom = DRW_cache_mesh_surface_weights_get(ob); - DRW_shgroup_call_no_cull(pd->edit_mesh_weight_grp, geom, ob); - } - else if (do_show_mesh_analysis && !pd->xray_enabled) { + if (do_show_mesh_analysis && !pd->xray_enabled) { geom = DRW_cache_mesh_surface_mesh_analysis_get(ob); if (geom) { DRW_shgroup_call_no_cull(pd->edit_mesh_analysis_grp, geom, ob); @@ -364,7 +347,6 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata) GPU_framebuffer_bind(fbl->overlay_default_fb); } - DRW_draw_pass(psl->edit_mesh_weight_ps); DRW_draw_pass(psl->edit_mesh_analysis_ps); DRW_draw_pass(psl->edit_mesh_depth_ps[NOT_IN_FRONT]); diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index e0b599f43a9..19b0fa5e12b 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -106,10 +106,14 @@ static void OVERLAY_cache_init(void *vedata) OVERLAY_Data *data = vedata; OVERLAY_StorageList *stl = data->stl; OVERLAY_PrivateData *pd = stl->pd; + const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: OVERLAY_edit_mesh_cache_init(vedata); + if (draw_edit_weights) { + OVERLAY_paint_cache_init(vedata); + } break; case CTX_MODE_EDIT_SURFACE: case CTX_MODE_EDIT_CURVE: @@ -251,6 +255,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) (ob->base_flag & BASE_SELECTED); const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom && !is_select; + const bool draw_edit_weights = in_edit_mode && (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); const bool draw_extras = (!pd->hide_overlays) && (((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || @@ -279,6 +284,9 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) switch (ob->type) { case OB_MESH: OVERLAY_edit_mesh_cache_populate(vedata, ob); + if (draw_edit_weights) { + OVERLAY_paint_weight_cache_populate(vedata, ob); + } break; case OB_ARMATURE: if (draw_bones) { @@ -495,6 +503,7 @@ static void OVERLAY_draw_scene(void *vedata) switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: + OVERLAY_paint_draw(vedata); OVERLAY_edit_mesh_draw(vedata); break; case CTX_MODE_EDIT_SURFACE: diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 4a1aa270de0..33008963d8b 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -76,15 +76,18 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; DRWState state; - const bool draw_contours = (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; + const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); + const bool draw_contours = !is_edit_mode && + (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; float opacity = 0.0f; pd->paint_depth_grp = NULL; psl->paint_depth_ps = NULL; switch (pd->ctx_mode) { case CTX_MODE_POSE: + case CTX_MODE_EDIT_MESH: case CTX_MODE_PAINT_WEIGHT: { - opacity = pd->overlay.weight_paint_mode_opacity; + opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity; if (opacity > 0.0f) { state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; state |= pd->painting.alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL; @@ -207,11 +210,12 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) struct GPUBatch *geom = NULL; const Mesh *me_orig = DEG_get_original_object(ob)->data; - const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; - const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; + const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); + const bool use_wire = !is_edit_mode && (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE); + const bool use_face_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL); + const bool use_vert_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL); - if (ob->mode == OB_MODE_WEIGHT_PAINT) { + if (ELEM(ob->mode, OB_MODE_WEIGHT_PAINT, OB_MODE_EDIT)) { if (pd->paint_surf_grp) { geom = DRW_cache_mesh_surface_weights_get(ob); DRW_shgroup_call(pd->paint_surf_grp, geom, ob); diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index bd9583c6a5f..fa3d6fe3d8a 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -70,7 +70,6 @@ typedef struct OVERLAY_PassList { DRWPass *edit_mesh_faces_cage_ps[2]; DRWPass *edit_mesh_analysis_ps; DRWPass *edit_mesh_normals_ps; - DRWPass *edit_mesh_weight_ps; DRWPass *edit_particle_ps; DRWPass *edit_text_overlay_ps; DRWPass *edit_text_wire_ps[2]; @@ -235,7 +234,6 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *edit_mesh_skin_roots_grp[2]; DRWShadingGroup *edit_mesh_normals_grp; DRWShadingGroup *edit_mesh_analysis_grp; - DRWShadingGroup *edit_mesh_weight_grp; DRWShadingGroup *edit_particle_strand_grp; DRWShadingGroup *edit_particle_point_grp; DRWShadingGroup *edit_text_overlay_grp; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index b265035f449..1b169dbee1d 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -145,11 +145,8 @@ bool DRW_object_is_renderable(const Object *ob) if (ob->type == OB_MESH) { if ((ob == DST.draw_ctx.object_edit) || DRW_object_is_in_edit_mode(ob)) { - View3D *v3d = DST.draw_ctx.v3d; - const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT); - - if (v3d && v3d->overlay.edit_flag & mask) { + if (v3d && v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) { return false; } } -- cgit v1.2.3 From b26bebd59f2d1a859f7faa2d57413448686da8a8 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 2 Apr 2020 15:32:17 +0200 Subject: Missed file in previous commit --- source/blender/draw/engines/overlay/overlay_paint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 33008963d8b..ccb309fdc4c 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -266,5 +266,7 @@ void OVERLAY_paint_draw(OVERLAY_Data *vedata) if (psl->paint_color_ps) { DRW_draw_pass(psl->paint_color_ps); } - DRW_draw_pass(psl->paint_overlay_ps); + if (psl->paint_overlay_ps) { + DRW_draw_pass(psl->paint_overlay_ps); + } } -- cgit v1.2.3 From 43f748a32fd541aac8cf499e03cf624806e30967 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 27 Mar 2020 23:22:59 +0100 Subject: Fix mesh boundary automask curve falloff As the main use case of this feature is to work with cloth, using this curve makes more sense than a smoothstep to simulate cloth tension near the edges. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7262 --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 82f9bbc5f56..73173571277 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1741,7 +1741,7 @@ static float *sculpt_boundary_edges_automasking_init(Object *ob, for (int i = 0; i < totvert; i++) { if (edge_distance[i] != EDGE_DISTANCE_INF) { const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps); - const float edge_boundary_automask = 3.0f * p * p - 2.0f * p * p * p; + const float edge_boundary_automask = pow2f(p); automask_factor[i] *= (1.0f - edge_boundary_automask); } } -- cgit v1.2.3 From 6cc4c68dad795a4ac63e06a1d63a1865f74210bd Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 27 Mar 2020 14:49:46 +0100 Subject: Fix T75121: Memory leak in Surface Smooth The brush was allocating new memory for storing the displacemnets at the beginning of each stroke step and not freeing them. Reviewed By: jbakker Maniphest Tasks: T75121 Differential Revision: https://developer.blender.org/D7254 --- source/blender/editors/sculpt_paint/sculpt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 73173571277..dbb89617b08 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3458,7 +3458,9 @@ static void do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; - if (ss->cache->mirror_symmetry_pass == 0 && ss->cache->radial_symmetry_pass == 0) { + if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0) { + BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL); ss->cache->surface_smooth_laplacian_disp = MEM_callocN( SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b"); } @@ -6860,9 +6862,9 @@ static const char *sculpt_tool_name(Sculpt *sd) void SCULPT_cache_free(StrokeCache *cache) { - if (cache->dial) { - MEM_freeN(cache->dial); - } + MEM_SAFE_FREE(cache->dial); + MEM_SAFE_FREE(cache->surface_smooth_laplacian_disp); + if (cache->pose_ik_chain) { SCULPT_pose_ik_chain_free(cache->pose_ik_chain); } -- cgit v1.2.3 From 009dde69cde0030ab3048f17a55a826d1aeb8423 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 1 Apr 2020 17:51:59 +0200 Subject: Fix Face Sets painting and selection precision This fixes the following issues: - Previously, the face set from the active vertex was used directly. Vertices always return the most recently created face set, so in some cases there may be some face sets that were not possible to select as active. Now the active face set is set in the ray intersection, so it always matches the face under the cursor. - When drawing face sets they were set per vertex, so it was not possible to paint one face at a time. Now face sets are painted per poly when using the brush on meshes, testing the distance to the center of each poly. - The code for the active vertex on PBVH_GRIDS was not correct, so I also fixed that to test if everything was working correctly. {F8441699} Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7303 --- source/blender/blenkernel/BKE_paint.h | 3 + source/blender/blenkernel/BKE_pbvh.h | 1 + source/blender/blenkernel/intern/pbvh.c | 18 +++++- source/blender/editors/sculpt_paint/sculpt.c | 93 +++++++++++++++++++++++----- 4 files changed, 98 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 8c925ee2ae1..f4b485ae53a 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -334,6 +334,9 @@ typedef struct SculptSession { /* Cursor data and active vertex for tools */ int active_vertex_index; + int active_face_index; + int active_grid_index; + float cursor_radius; float cursor_location[3]; float cursor_normal[3]; diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index b4f16bfd899..2020d45ae86 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -155,6 +155,7 @@ bool BKE_pbvh_node_raycast(PBVH *bvh, struct IsectRayPrecalc *isect_precalc, float *depth, int *active_vertex_index, + int *active_face_grid_index, float *face_normal); bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index ac0c9d030cf..879f1e507ba 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2121,6 +2121,7 @@ static bool pbvh_faces_node_raycast(PBVH *bvh, struct IsectRayPrecalc *isect_precalc, float *depth, int *r_active_vertex_index, + int *r_active_face_index, float *r_face_normal) { const MVert *vert = bvh->verts; @@ -2166,6 +2167,7 @@ static bool pbvh_faces_node_raycast(PBVH *bvh, if (len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) { copy_v3_v3(nearest_vertex_co, co[j]); *r_active_vertex_index = mloop[lt->tri[j]].v; + *r_active_face_index = lt->poly; } } } @@ -2183,6 +2185,7 @@ static bool pbvh_grids_node_raycast(PBVH *bvh, struct IsectRayPrecalc *isect_precalc, float *depth, int *r_active_vertex_index, + int *r_active_grid_index, float *r_face_normal) { const int totgrid = node->totprim; @@ -2236,15 +2239,23 @@ static bool pbvh_grids_node_raycast(PBVH *bvh, if (r_active_vertex_index) { float location[3] = {0.0}; madd_v3_v3v3fl(location, ray_start, ray_normal, *depth); + + const int x_it[4] = {0, 1, 1, 0}; + const int y_it[4] = {0, 0, 1, 1}; + for (int j = 0; j < 4; j++) { if (len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) { copy_v3_v3(nearest_vertex_co, co[j]); - *r_active_vertex_index = gridkey->grid_area * grid_index + y * gridkey->grid_size + - x; + + *r_active_vertex_index = gridkey->grid_area * grid_index + + (y + y_it[j]) * gridkey->grid_size + (x + x_it[j]); } } } + if (r_active_grid_index) { + *r_active_grid_index = grid_index; + } } } } @@ -2266,6 +2277,7 @@ bool BKE_pbvh_node_raycast(PBVH *bvh, struct IsectRayPrecalc *isect_precalc, float *depth, int *active_vertex_index, + int *active_face_grid_index, float *face_normal) { bool hit = false; @@ -2284,6 +2296,7 @@ bool BKE_pbvh_node_raycast(PBVH *bvh, isect_precalc, depth, active_vertex_index, + active_face_grid_index, face_normal); break; case PBVH_GRIDS: @@ -2295,6 +2308,7 @@ bool BKE_pbvh_node_raycast(PBVH *bvh, isect_precalc, depth, active_vertex_index, + active_face_grid_index, face_normal); break; case PBVH_BMESH: diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index dbb89617b08..91c8262dd67 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -216,6 +216,22 @@ static void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]) /* Sculpt Face Sets and Visibility. */ +static int SCULPT_active_face_set_get(SculptSession *ss) +{ + switch (BKE_pbvh_type(ss->pbvh)) { + case PBVH_FACES: + return ss->face_sets[ss->active_face_index]; + case PBVH_GRIDS: { + const int face_index = BKE_subdiv_cgg_grid_to_face_index(ss->subdiv_ccg, + ss->active_grid_index); + return ss->face_sets[face_index]; + } + case PBVH_BMESH: + return SCULPT_FACE_SET_NONE; + } + return SCULPT_FACE_SET_NONE; +} + static void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible) { switch (BKE_pbvh_type(ss->pbvh)) { @@ -2997,6 +3013,8 @@ typedef struct { int active_vertex_index; float *face_normal; + int active_face_grid_index; + struct IsectRayPrecalc isect_precalc; } SculptRaycastData; @@ -3641,19 +3659,49 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata, BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - vd.mask ? *vd.mask : 0.0f, - vd.index, - tls->thread_id); + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + MeshElemMap *vert_map = &ss->pmap[vd.index]; + for (int j = 0; j < ss->pmap[vd.index].count; j++) { + const MPoly *p = &ss->mpoly[vert_map->indices[j]]; - if (fade > 0.05f) { - SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set); + float poly_center[3]; + BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], ss->mvert, poly_center); + + if (sculpt_brush_test_sq_fn(&test, poly_center)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + vd.mask ? *vd.mask : 0.0f, + vd.index, + tls->thread_id); + + if (fade > 0.05f && ss->face_sets[vert_map->indices[j]] > 0) { + ss->face_sets[vert_map->indices[j]] = abs(ss->cache->paint_face_set); + } + } + } + } + + else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + vd.mask ? *vd.mask : 0.0f, + vd.index, + tls->thread_id); + + if (fade > 0.05f) { + SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set); + } + } } } } @@ -3714,7 +3762,7 @@ static void do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in ss->cache->radial_symmetry_pass == 0) { if (ss->cache->invert) { /* When inverting the brush, pick the paint face mask ID from the mesh. */ - ss->cache->paint_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss)); + ss->cache->paint_face_set = SCULPT_active_face_set_get(ss); } else { /* By default create a new Face Sets. */ @@ -7440,6 +7488,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin) &srd->isect_precalc, &srd->depth, &srd->active_vertex_index, + &srd->active_face_grid_index, srd->face_normal)) { srd->hit = true; *tmin = srd->depth; @@ -7590,6 +7639,21 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, ss->active_vertex_index = srd.active_vertex_index; copy_v3_v3(out->active_vertex_co, SCULPT_active_vertex_co_get(ss)); + switch (BKE_pbvh_type(ss->pbvh)) { + case PBVH_FACES: + ss->active_face_index = srd.active_face_grid_index; + ss->active_grid_index = 0; + break; + case PBVH_GRIDS: + ss->active_face_index = 0; + ss->active_grid_index = srd.active_face_grid_index; + break; + case PBVH_BMESH: + ss->active_face_index = 0; + ss->active_grid_index = 0; + break; + } + copy_v3_v3(out->location, ray_normal); mul_v3_fl(out->location, srd.depth); add_v3_v3(out->location, ray_start); @@ -11710,8 +11774,7 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C, const int tot_vert = SCULPT_vertex_count_get(ss); const int mode = RNA_enum_get(op->ptr, "mode"); - int active_vertex_index = SCULPT_active_vertex_get(ss); - int active_face_set = SCULPT_vertex_face_set_get(ss, active_vertex_index); + const int active_face_set = SCULPT_active_face_set_get(ss); SCULPT_undo_push_begin("Hide area"); -- cgit v1.2.3 From f868d51bdd3ed56cbf4ec74846b54caa8fe1fa1d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2020 16:42:24 +0100 Subject: Sculpt Undo: Allow Geometry undo step to be non-exclusive Before this change it was not possible to have base geometry and grid coordinates to be stored in the same undo step. Differential Revision: https://developer.blender.org/D7298 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index cccc5e29ba7..f6ed4fa21e0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -622,12 +622,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase if (lb->first) { unode = lb->first; - if (unode->type == SCULPT_UNDO_GEOMETRY) { - sculpt_undo_geometry_restore(unode, ob); - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); - return; - } - else if (unode->type == SCULPT_UNDO_FACE_SETS) { + if (unode->type == SCULPT_UNDO_FACE_SETS) { sculpt_undo_restore_face_sets(C, unode); rebuild = true; @@ -653,10 +648,18 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } } - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + if (lb->first != NULL) { + /* Only do early object update for edits if first node needs this. + * Undo steps like geometry does not need object to be updated before they run and will + * ensure object is updated after the node is handled. */ + const SculptUndoNode *first_unode = (const SculptUndoNode *)lb->first; + if (first_unode->type != SCULPT_UNDO_GEOMETRY) { + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + } - if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) { - return; + if (sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) { + return; + } } char *undo_modified_grids = NULL; @@ -705,13 +708,16 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase case SCULPT_UNDO_FACE_SETS: break; + case SCULPT_UNDO_GEOMETRY: + sculpt_undo_geometry_restore(unode, ob); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); + break; + case SCULPT_UNDO_DYNTOPO_BEGIN: case SCULPT_UNDO_DYNTOPO_END: case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: BLI_assert(!"Dynamic topology should've already been handled"); break; - case SCULPT_UNDO_GEOMETRY: - break; } } -- cgit v1.2.3 From 3dad6294dae2f13ca1b9e8b08933ba32bf0f3bed Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 2 Apr 2020 10:10:13 +0200 Subject: Sculpt: Store explicit value for multires sculpt level Allows to know what level sculpting has been done after the value has been changed in the MultiresModifierData. No functional changes, just preparing code to have everything needed for propagation undo. Differential Revision: https://developer.blender.org/D7307 --- source/blender/blenkernel/BKE_paint.h | 6 +++++- source/blender/blenkernel/intern/multires.c | 5 +++-- source/blender/blenkernel/intern/multires_reshape_smooth.c | 2 +- source/blender/blenkernel/intern/paint.c | 8 ++++++-- source/blender/editors/sculpt_paint/sculpt.c | 8 ++++---- source/blender/modifiers/intern/MOD_multires.c | 4 +++- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index f4b485ae53a..012188bed96 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -283,7 +283,11 @@ typedef struct SculptClothSimulation { typedef struct SculptSession { /* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */ - struct MultiresModifierData *multires; /* Special handling for multires meshes */ + struct { /* Special handling for multires meshes */ + bool active; + struct MultiresModifierData *modifier; + int level; + } multires; struct MVert *mvert; struct MPoly *mpoly; struct MLoop *mloop; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 6ccfabcb5d2..69cd338e15f 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -473,7 +473,8 @@ void multires_flush_sculpt_updates(Object *object) } SculptSession *sculpt_session = object->sculpt; - if (BKE_pbvh_type(sculpt_session->pbvh) != PBVH_GRIDS || sculpt_session->multires == NULL) { + if (BKE_pbvh_type(sculpt_session->pbvh) != PBVH_GRIDS || !sculpt_session->multires.active || + sculpt_session->multires.modifier == NULL) { return; } @@ -488,7 +489,7 @@ void multires_flush_sculpt_updates(Object *object) Mesh *mesh = object->data; multiresModifier_reshapeFromCCG( - sculpt_session->multires->totlvl, mesh, sculpt_session->subdiv_ccg); + sculpt_session->multires.modifier->totlvl, mesh, sculpt_session->subdiv_ccg); subdiv_ccg->dirty.coords = false; subdiv_ccg->dirty.hidden = false; diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index 8b10d729901..fad5004ff4b 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -400,7 +400,7 @@ static char get_effective_edge_crease_char( const MultiresReshapeSmoothContext *reshape_smooth_context, const MEdge *base_edge) { const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context; - if (reshape_context->mmd->simple) { + if (reshape_context->subdiv->settings.is_simple) { return 255; } return base_edge->crease; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f52ec5f568f..5224fa3f8f6 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1522,7 +1522,9 @@ static void sculpt_update_object( /* NOTE: Weight pPaint require mesh info for loop lookup, but it never uses multires code path, * so no extra checks is needed here. */ if (mmd) { - ss->multires = mmd; + ss->multires.active = true; + ss->multires.modifier = mmd; + ss->multires.level = mmd->sculptlvl; ss->totvert = me_eval->totvert; ss->totpoly = me_eval->totpoly; ss->totfaces = me->totpoly; @@ -1537,7 +1539,9 @@ static void sculpt_update_object( ss->mvert = me->mvert; ss->mpoly = me->mpoly; ss->mloop = me->mloop; - ss->multires = NULL; + ss->multires.active = false; + ss->multires.modifier = NULL; + ss->multires.level = 0; ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 91c8262dd67..d734d2fec8b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5083,7 +5083,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(val, offset, *disp); - if (!ss->multires && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (!ss->multires.active && !ss->bm && ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { int index = vd.vert_indices[vd.i]; /* Persistent base. */ @@ -6758,7 +6758,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob) Brush *brush = BKE_paint_brush(&sd->paint); MTex *mtex = &brush->mtex; - if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) { + if (ss->multires.active && mtex->tex && mtex->tex->type == TEX_NOISE) { multires_stitch_grids(ob); } } @@ -7096,7 +7096,7 @@ static void sculpt_update_cache_invariants( /* Initialize layer brush displacements and persistent coords. */ if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* Not supported yet for multires or dynamic topology. */ - if (!ss->multires && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (!ss->multires.active && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { if (!ss->layer_co) { ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); } @@ -7862,7 +7862,7 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags) Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *region = CTX_wm_region(C); - MultiresModifierData *mmd = ss->multires; + MultiresModifierData *mmd = ss->multires.modifier; View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index ad8e0a9f259..f9d53d08c2e 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -211,7 +211,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes if (ctx->object->sculpt != NULL) { SculptSession *sculpt_session = ctx->object->sculpt; sculpt_session->subdiv_ccg = result->runtime.subdiv_ccg; - sculpt_session->multires = mmd; + sculpt_session->multires.active = true; + sculpt_session->multires.modifier = mmd; + sculpt_session->multires.level = mmd->sculptlvl; sculpt_session->totvert = mesh->totvert; sculpt_session->totpoly = mesh->totpoly; sculpt_session->mvert = NULL; -- cgit v1.2.3 From 7c88968c8954321f9bc267b83a1d61dcc5483057 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Thu, 2 Apr 2020 16:41:32 +0200 Subject: Scultp: Face Set boundary automasking With this brush option it is possible to mask the boundary vertices of all face sets. This is especially useful in the cloth brush, where face sets can be used to simulate seams between different patches of cloth and produce different patterns and effects. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7230 --- .../startup/bl_ui/properties_paint_common.py | 3 +- source/blender/editors/sculpt_paint/sculpt.c | 44 ++++++++++++++++++---- source/blender/makesdna/DNA_brush_types.h | 1 + source/blender/makesrna/intern/rna_brush.c | 8 ++++ 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 6e0613874d1..0b006c9cea3 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -823,8 +823,9 @@ def brush_settings_advanced(layout, context, brush, popover=False): # face masks automasking layout.prop(brush, "use_automasking_face_sets") - # boundary edges automasking + # boundary edges/face sets automasking layout.prop(brush, "use_automasking_boundary_edges") + layout.prop(brush, "use_automasking_boundary_face_sets") layout.prop(brush, "automasking_boundary_edges_propagation_steps") diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d734d2fec8b..10d431d12e6 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1601,6 +1601,9 @@ static bool sculpt_automasking_enabled(SculptSession *ss, const Brush *br) if (br->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) { return true; } + if (br->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) { + return true; + } return false; } @@ -1719,9 +1722,15 @@ static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *a #define EDGE_DISTANCE_INF -1 -static float *sculpt_boundary_edges_automasking_init(Object *ob, - int propagation_steps, - float *automask_factor) +typedef enum eBoundaryAutomaskMode { + AUTOMASK_INIT_BOUNDARY_EDGES = 1, + AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2, +} eBoundaryAutomaskMode; + +static float *sculpt_boundary_automasking_init(Object *ob, + eBoundaryAutomaskMode mode, + int propagation_steps, + float *automask_factor) { SculptSession *ss = ob->sculpt; @@ -1735,8 +1744,17 @@ static float *sculpt_boundary_edges_automasking_init(Object *ob, for (int i = 0; i < totvert; i++) { edge_distance[i] = EDGE_DISTANCE_INF; - if (!sculpt_vertex_is_boundary(ss, i)) { - edge_distance[i] = 0; + switch (mode) { + case AUTOMASK_INIT_BOUNDARY_EDGES: + if (!sculpt_vertex_is_boundary(ss, i)) { + edge_distance[i] = 0; + } + break; + case AUTOMASK_INIT_BOUNDARY_FACE_SETS: + if (!SCULPT_vertex_has_unique_face_set(ss, i)) { + edge_distance[i] = 0; + } + break; } } @@ -1794,8 +1812,17 @@ static void sculpt_automasking_init(Sculpt *sd, Object *ob) if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) { SCULPT_vertex_random_access_init(ss); - sculpt_boundary_edges_automasking_init( - ob, brush->automasking_boundary_edges_propagation_steps, ss->cache->automask); + sculpt_boundary_automasking_init(ob, + AUTOMASK_INIT_BOUNDARY_EDGES, + brush->automasking_boundary_edges_propagation_steps, + ss->cache->automask); + } + if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) { + SCULPT_vertex_random_access_init(ss); + sculpt_boundary_automasking_init(ob, + AUTOMASK_INIT_BOUNDARY_FACE_SETS, + brush->automasking_boundary_edges_propagation_steps, + ss->cache->automask); } } @@ -9871,7 +9898,8 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent for (int i = 0; i < totvert; i++) { ss->filter_cache->automask[i] = 1.0f; } - sculpt_boundary_edges_automasking_init(ob, 1, ss->filter_cache->automask); + sculpt_boundary_automasking_init( + ob, AUTOMASK_INIT_BOUNDARY_EDGES, 1, ss->filter_cache->automask); } WM_event_add_modal_handler(C, op); diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 95d9216f550..87f0de6daa2 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -332,6 +332,7 @@ typedef enum eAutomasking_flag { BRUSH_AUTOMASKING_TOPOLOGY = (1 << 0), BRUSH_AUTOMASKING_FACE_SETS = (1 << 1), BRUSH_AUTOMASKING_BOUNDARY_EDGES = (1 << 2), + BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS = (1 << 3), } eAutomasking_flag; typedef struct Brush { diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 86958c5970a..fb87f5486f4 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -2392,6 +2392,14 @@ static void rna_def_brush(BlenderRNA *brna) prop, "Mesh Boundary Auto-masking", "Do not affect non manifold boundary edges"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); + RNA_def_property_ui_text(prop, + "Face Sets Boundary Automasking", + "Do not affect vertices that belong to a Face Set boundary"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "use_scene_spacing", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, brush_spacing_unit_items); -- cgit v1.2.3 From e6c732e0cbe3e9ccb0b279b9e4af68772d7229dc Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Thu, 2 Apr 2020 16:27:14 +0200 Subject: GPencil: Cleanup typo error for hardness The variable cannot be names because it was already renamed. --- release/scripts/startup/bl_ui/properties_data_modifier.py | 4 ++-- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 2 +- source/blender/makesrna/intern/rna_brush.c | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 2 +- source/blender/makesrna/intern/rna_gpencil_modifier.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index cbcd6e2b614..5510941c4a5 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -2045,8 +2045,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.prop(md, "modify_color") - if md.modify_color == 'HARDENESS': - col.prop(md, "hardeness") + if md.modify_color == 'HARDNESS': + col.prop(md, "hardness") show = False else: col.prop(md, "normalize_opacity") diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index c612b47895c..27159b6e609 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1492,7 +1492,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel): ma = brush.gpencil_settings.material col.separator() - col.prop(gp_settings, "hardeness", slider=True) + col.prop(gp_settings, "hardness", slider=True) subcol = col.column(align=True) if ma and ma.grease_pencil.mode == 'LINE': subcol.enabled = False diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index fb87f5486f4..fed81b86417 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1341,7 +1341,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* gradient control */ - prop = RNA_def_property(srna, "hardeness", PROP_FLOAT, PROP_FACTOR); + prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "hardeness"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_float_default(prop, 1.0f); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index e841813beca..bd08e1c306c 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1199,7 +1199,7 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* gradient control along y */ - prop = RNA_def_property(srna, "hardeness", PROP_FLOAT, PROP_FACTOR); + prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "hardeness"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_float_default(prop, 1.0f); diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 03b7c643f47..b99517a5255 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -1360,7 +1360,7 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Opacity Factor", "Factor of Opacity"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); - prop = RNA_def_property(srna, "hardeness", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "hardeness"); RNA_def_property_range(prop, 0.0, FLT_MAX); RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.1, 2); -- cgit v1.2.3 From b75a7c2f8fb81eb7da067128dd90e3cd11406ab4 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Thu, 2 Apr 2020 16:47:52 +0200 Subject: Fix T75302: GPencil fill does not work on python generated strokes --- source/blender/blenkernel/intern/gpencil.c | 7 ++++++- source/blender/makesrna/intern/rna_gpencil.c | 5 +---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index fc7f15348bc..b2fc91fd0a6 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -541,7 +541,12 @@ bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness) gps->flag = GP_STROKE_3DSPACE; gps->totpoints = totpoints; - gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + if (gps->totpoints > 0) { + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + } + else { + gps->points = NULL; + } /* initialize triangle memory to dummy data */ gps->triangles = NULL; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index bd08e1c306c..94814003e99 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -710,10 +710,7 @@ static void rna_GPencil_stroke_point_pop(ID *id, static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) { - bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - stroke->hardeness = 1.0f; - ARRAY_SET_ITEMS(stroke->aspect_ratio, 1.0f, 1.0f); - stroke->uv_scale = 1.0f; + bGPDstroke *stroke = BKE_gpencil_stroke_new(0, 0, 1.0f); BLI_addtail(&frame->strokes, stroke); return stroke; -- cgit v1.2.3 From e276558a50f06c6ec5d6b36b138ad5777dd05c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 2 Apr 2020 16:54:17 +0200 Subject: Fix T74983: Material preview icons don't refresh The root cause of the issue reported in T74983 is that an `IDNode` would not be marked as user-modified. This marking happened while looping over outgoing relations of one of its operation nodes. Since rBff60dd8b18ed unused relations are removed, and as a result the `IDNode` would not be marked. The solution was to move the responsible code outside the loop; this is probably a good idea anyway, as the code did not actually use the looped-over relations at all, and was thus repeated unnecessarily. --- source/blender/depsgraph/intern/eval/deg_eval_flush.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index dd72bc22a70..990002cf2e8 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -172,16 +172,17 @@ BLI_INLINE void flush_handle_component_node(IDNode *id_node, */ BLI_INLINE OperationNode *flush_schedule_children(OperationNode *op_node, FlushQueue *queue) { + if (op_node->flag & DEPSOP_FLAG_USER_MODIFIED) { + IDNode *id_node = op_node->owner->owner; + id_node->is_user_modified = true; + } + OperationNode *result = nullptr; for (Relation *rel : op_node->outlinks) { /* Flush is forbidden, completely. */ if (rel->flag & RELATION_FLAG_NO_FLUSH) { continue; } - if (op_node->flag & DEPSOP_FLAG_USER_MODIFIED) { - IDNode *id_node = op_node->owner->owner; - id_node->is_user_modified = true; - } /* Relation only allows flushes on user changes, but the node was not * affected by user. */ if ((rel->flag & RELATION_FLAG_FLUSH_USER_EDIT_ONLY) && -- cgit v1.2.3 From 1f745e2c72b24cfdbd466e8558d8b66536320acd Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Thu, 2 Apr 2020 16:56:05 +0200 Subject: Sculpt: Add global automasking options for all brushes This adds the automasking options to the Sculpt Tool options in a way that they affect all brushes. This is more convenient when working with some of these options while switching brushes as they don't need to be enabled/disabled per brush. An automasking option is enabled if it is enabled in the brush or in the sculpt options. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7304 --- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 7 ++++ source/blender/editors/sculpt_paint/sculpt.c | 47 +++++++++++++--------- source/blender/makesdna/DNA_scene_types.h | 3 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 28 +++++++++++++ 4 files changed, 66 insertions(+), 19 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 27159b6e609..351b72f79fb 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -905,6 +905,13 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): col = flow.column() col.prop(sculpt, "use_deform_only") + col = flow.column() + col.separator() + col.prop(sculpt, "use_automasking_topology") + col.prop(sculpt, "use_automasking_face_sets") + col.prop(sculpt, "use_automasking_boundary_edges") + col.prop(sculpt, "use_automasking_boundary_face_sets") + class VIEW3D_PT_sculpt_options_gravity(Panel, View3DPaintPanel): bl_context = ".sculpt_mode" # dot on purpose (access from topbar) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 10d431d12e6..fede8ce97ca 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1587,21 +1587,28 @@ static bool sculpt_brush_test_cyl(SculptBrushTest *test, /* Automasking */ -static bool sculpt_automasking_enabled(SculptSession *ss, const Brush *br) +static bool sculpt_is_automasking_mode_enabled(const Sculpt *sd, + const Brush *br, + const eAutomasking_flag mode) +{ + return br->automasking_flags & mode || sd->automasking_flags & mode; +} + +static bool sculpt_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br) { if (sculpt_stroke_is_dynamic_topology(ss, br)) { return false; } - if (br->automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY) { + if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) { return true; } - if (br->automasking_flags & BRUSH_AUTOMASKING_FACE_SETS) { + if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_FACE_SETS)) { return true; } - if (br->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) { + if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { return true; } - if (br->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) { + if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { return true; } return false; @@ -1662,7 +1669,7 @@ static float *sculpt_topology_automasking_init(Sculpt *sd, Object *ob, float *au SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - if (!sculpt_automasking_enabled(ss, brush)) { + if (!sculpt_automasking_enabled(sd, ss, brush)) { return NULL; } @@ -1700,7 +1707,7 @@ static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *a SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - if (!sculpt_automasking_enabled(ss, brush)) { + if (!sculpt_automasking_enabled(sd, ss, brush)) { return NULL; } @@ -1790,7 +1797,7 @@ static void sculpt_automasking_init(Sculpt *sd, Object *ob) Brush *brush = BKE_paint_brush(&sd->paint); const int totvert = SCULPT_vertex_count_get(ss); - if (!sculpt_automasking_enabled(ss, brush)) { + if (!sculpt_automasking_enabled(sd, ss, brush)) { return; } @@ -1801,23 +1808,23 @@ static void sculpt_automasking_init(Sculpt *sd, Object *ob) ss->cache->automask[i] = 1.0f; } - if (brush->automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY) { + if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_TOPOLOGY)) { SCULPT_vertex_random_access_init(ss); sculpt_topology_automasking_init(sd, ob, ss->cache->automask); } - if (brush->automasking_flags & BRUSH_AUTOMASKING_FACE_SETS) { + if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_FACE_SETS)) { SCULPT_vertex_random_access_init(ss); sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask); } - if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) { + if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { SCULPT_vertex_random_access_init(ss); sculpt_boundary_automasking_init(ob, AUTOMASK_INIT_BOUNDARY_EDGES, brush->automasking_boundary_edges_propagation_steps, ss->cache->automask); } - if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS) { + if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { SCULPT_vertex_random_access_init(ss); sculpt_boundary_automasking_init(ob, AUTOMASK_INIT_BOUNDARY_FACE_SETS, @@ -6293,7 +6300,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe } if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0) { - if (sculpt_automasking_enabled(ss, brush)) { + if (sculpt_automasking_enabled(sd, ss, brush)) { sculpt_automasking_init(sd, ob); } } @@ -7460,9 +7467,12 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po /* Returns true if any of the smoothing modes are active (currently * one of smooth brush, autosmooth, mask smooth, or shift-key * smooth). */ -static bool sculpt_needs_connectivity_info(const Brush *brush, SculptSession *ss, int stroke_mode) +static bool sculpt_needs_connectivity_info(const Sculpt *sd, + const Brush *brush, + SculptSession *ss, + int stroke_mode) { - if (ss && ss->pbvh && sculpt_automasking_enabled(ss, brush)) { + if (ss && ss->pbvh && sculpt_automasking_enabled(sd, ss, brush)) { return true; } return ((stroke_mode == BRUSH_STROKE_SMOOTH) || (ss && ss->cache && ss->cache->alt_smooth) || @@ -7478,8 +7488,9 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B { SculptSession *ss = ob->sculpt; View3D *v3d = CTX_wm_view3d(C); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - bool need_pmap = sculpt_needs_connectivity_info(brush, ss, 0); + bool need_pmap = sculpt_needs_connectivity_info(sd, brush, ss, 0); if (ss->shapekey_active || ss->deform_modifiers_active || (!BKE_sculptsession_use_pbvh_draw(ob, v3d) && need_pmap)) { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); @@ -7853,7 +7864,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) view3d_operator_needs_opengl(C); sculpt_brush_init_tex(scene, sd, ss); - is_smooth = sculpt_needs_connectivity_info(brush, ss, mode); + is_smooth = sculpt_needs_connectivity_info(sd, brush, ss, mode); BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask); } @@ -8153,7 +8164,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str } } - if (sculpt_automasking_enabled(ss, brush)) { + if (sculpt_automasking_enabled(sd, ss, brush)) { sculpt_automasking_end(ob); } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 7837c1265ab..62640a2ce54 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -970,6 +970,8 @@ typedef struct Sculpt { // float pivot[3]; XXX not used? int flags; + int automasking_flags; + /* Control tablet input */ // char tablet_size, tablet_strength; XXX not used? int radial_symm[3]; @@ -987,7 +989,6 @@ typedef struct Sculpt { /** Constant detail resolution (Blender unit / constant_detail). */ float constant_detail; float detail_percent; - char _pad[4]; struct Object *gravity_object; } Sculpt; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 04a54063a03..f1a5cb79db4 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -815,6 +815,34 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); + prop = RNA_def_property(srna, "use_automasking_topology", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_TOPOLOGY); + RNA_def_property_ui_text(prop, + "Topology Auto-masking", + "Affect only vertices connected to the active vertex under the brush"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_face_sets", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_FACE_SETS); + RNA_def_property_ui_text(prop, + "Face Sets Auto-masking", + "Affect only vertices that share Face Sets with the active vertex"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_boundary_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_EDGES); + RNA_def_property_ui_text( + prop, "Mesh Boundary Auto-masking", "Do not affect non manifold boundary edges"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); + RNA_def_property_ui_text(prop, + "Face Sets Boundary Auto-masking", + "Do not affect vertices that belong to a Face Set boundary"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_symmetrize_direction_items); RNA_def_property_ui_text(prop, "Direction", "Source and destination for symmetrize operator"); -- cgit v1.2.3 From 2aa938b0ae77f4287a3c7f43b823cc648138c4ce Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 16:32:06 +0200 Subject: Cleanup: simplify Linux buildbot config, where default values already match Ref D7309 --- build_files/buildbot/config/blender_linux.cmake | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake index c970ae4c9c1..2db95c85fc2 100644 --- a/build_files/buildbot/config/blender_linux.cmake +++ b/build_files/buildbot/config/blender_linux.cmake @@ -7,9 +7,6 @@ message(STATUS "Building in CentOS 7 64bit environment") set(LIBDIR_NAME "linux_centos7_x86_64") set(WITH_CXX11_ABI OFF CACHE BOOL "" FORCE) -# Default to only build Blender -set(WITH_BLENDER ON CACHE BOOL "" FORCE) - # ######## Linux-specific build options ######## # Options which are specific to Linux-only platforms @@ -20,12 +17,6 @@ set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE) set(WITH_JACK_DYNLOAD ON CACHE BOOL "" FORCE) set(WITH_SDL_DYNLOAD ON CACHE BOOL "" FORCE) -set(WITH_SYSTEM_GLEW OFF CACHE BOOL "" FORCE) - -set(WITH_OPENMP_STATIC ON CACHE BOOL "" FORCE) - -set(WITH_PYTHON_INSTALL_NUMPY ON CACHE BOOL "" FORCE) -set(WITH_PYTHON_INSTALL_REQUESTS ON CACHE BOOL "" FORCE) # ######## Release environment specific settings ######## @@ -33,8 +24,6 @@ set(LIBDIR "${CMAKE_CURRENT_LIST_DIR}/../../../../lib/${LIBDIR_NAME}" CACHE STRI # Platform specific configuration, to ensure static linking against everything. -set(Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) - # We need to link OpenCOLLADA against PCRE library. Even though it is not installed # on /usr, we do not really care -- all we care is PCRE_FOUND be TRUE and its # library pointing to a valid one. -- cgit v1.2.3 From 5159ba6b333b27b247ffe0b950fa40c1dd7d2654 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 27 Mar 2020 14:24:52 +0100 Subject: Fix (harmless) PCRE not found warning when configuring CMake on Linux Differential Revision: https://developer.blender.org/D7309 --- build_files/buildbot/config/blender_linux.cmake | 6 ------ build_files/cmake/platform/platform_apple.cmake | 6 ++---- build_files/cmake/platform/platform_unix.cmake | 10 ++++++++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake index 2db95c85fc2..29004654807 100644 --- a/build_files/buildbot/config/blender_linux.cmake +++ b/build_files/buildbot/config/blender_linux.cmake @@ -24,11 +24,5 @@ set(LIBDIR "${CMAKE_CURRENT_LIST_DIR}/../../../../lib/${LIBDIR_NAME}" CACHE STRI # Platform specific configuration, to ensure static linking against everything. -# We need to link OpenCOLLADA against PCRE library. Even though it is not installed -# on /usr, we do not really care -- all we care is PCRE_FOUND be TRUE and its -# library pointing to a valid one. -set(PCRE_INCLUDE_DIR "/usr/include" CACHE STRING "" FORCE) -set(PCRE_LIBRARY "${LIBDIR}/opencollada/lib/libpcre.a" CACHE STRING "" FORCE) - # Additional linking libraries set(CMAKE_EXE_LINKER_FLAGS "-lrt -static-libstdc++ -no-pie" CACHE STRING "" FORCE) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 620a078f412..f5f8c209d9d 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -222,12 +222,10 @@ if(WITH_OPENCOLLADA) -lMathMLSolver -lGeneratedSaxParser -lbuffer -lftoa -lUTF - ${OPENCOLLADA_LIBPATH}/libxml2.a ) - # PCRE is bundled with openCollada - # set(PCRE ${LIBDIR}/pcre) - # set(PCRE_LIBPATH ${PCRE}/lib) + # PCRE and XML2 are bundled with OpenCollada. set(PCRE_LIBRARIES pcre) + set(XML2_LIBRARIES xml2) endif() if(WITH_SDL) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index c034e7028af..3f73916daf3 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -195,8 +195,14 @@ endif() if(WITH_OPENCOLLADA) find_package_wrapper(OpenCOLLADA) if(OPENCOLLADA_FOUND) - find_package_wrapper(XML2) - find_package_wrapper(PCRE) + if(WITH_STATIC_LIBS) + # PCRE and XML2 are bundled with OpenCollada. + set(PCRE_LIBRARIES pcre) + set(XML2_LIBRARIES xml2) + else() + find_package_wrapper(XML2) + find_package_wrapper(PCRE) + endif() else() set(WITH_OPENCOLLADA OFF) endif() -- cgit v1.2.3 From 967260593807c1e6f294c1ce8b5a220526f4597a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 17:08:24 +0200 Subject: Fix build error on Windows/Linux after recent AVX changes --- intern/cycles/util/util_avxf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/intern/cycles/util/util_avxf.h b/intern/cycles/util/util_avxf.h index 6781290bb83..47d416afbb7 100644 --- a/intern/cycles/util/util_avxf.h +++ b/intern/cycles/util/util_avxf.h @@ -266,20 +266,20 @@ template __forceinline const avxf shuffle(const avxf &a) template __forceinline float extract(const avxf &a) { - return _mm256_cvtss_f32(shuffle(a)); + return _mm256_cvtss_f32(shuffle(a).m256); } template<> __forceinline float extract<0>(const avxf &a) { - return _mm256_cvtss_f32(a); + return _mm256_cvtss_f32(a.m256); } __forceinline ssef low(const avxf &a) { - return _mm256_extractf128_ps(a, 0); + return _mm256_extractf128_ps(a.m256, 0); } __forceinline ssef high(const avxf &a) { - return _mm256_extractf128_ps(a, 1); + return _mm256_extractf128_ps(a.m256, 1); } template -- cgit v1.2.3 From 343a874831d3b9cc548d3fd72caa3e39d5cdaa71 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 2 Apr 2020 17:22:44 +0200 Subject: add memory address to undo steps print. Helps identifying who is what in debugger... --- source/blender/blenkernel/intern/undo_system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index b111dee80ad..847522a0a66 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -877,12 +877,13 @@ void BKE_undosys_print(UndoStack *ustack) BLI_listbase_count(&ustack->steps)); int index = 0; for (UndoStep *us = ustack->steps.first; us; us = us->next) { - printf("[%c%c%c%c] %3d type='%s', name='%s'\n", + printf("[%c%c%c%c] %3d {%p} type='%s', name='%s'\n", (us == ustack->step_active) ? '*' : ' ', us->is_applied ? '#' : ' ', (us == ustack->step_active_memfile) ? 'M' : ' ', us->skip ? 'S' : ' ', index, + (void *)us, us->type->name, us->name); index++; -- cgit v1.2.3 From 868d4526a8818fbffc5ea993fbbbd3890046a6e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 17:25:48 +0200 Subject: Fix more build errors/warnings after recent AVX changes Thanks to Sergey and Ray for the help identifying the problem. --- intern/cycles/util/util_avxf.h | 3 ++- intern/cycles/util/util_simd.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/intern/cycles/util/util_avxf.h b/intern/cycles/util/util_avxf.h index 47d416afbb7..1fb3ded422f 100644 --- a/intern/cycles/util/util_avxf.h +++ b/intern/cycles/util/util_avxf.h @@ -266,7 +266,8 @@ template __forceinline const avxf shuffle(const avxf &a) template __forceinline float extract(const avxf &a) { - return _mm256_cvtss_f32(shuffle(a).m256); + __m256 b = shuffle(a).m256; + return _mm256_cvtss_f32(b); } template<> __forceinline float extract<0>(const avxf &a) { diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index 922f5dd274e..ac2893692df 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -588,6 +588,13 @@ __forceinline __m128 _mm_round_ps_emu(__m128 value, const int flags) # endif /* !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__)) */ +/* Older GCC versions do not have _mm256_cvtss_f32 yet, so define it ourselves. + * _mm256_castps256_ps128 generates no instructions so this is jus as efficient. */ +# ifdef __KERNEL_AVX__ +# undef _mm256_cvtss_f32 +# define _mm256_cvtss_f32(a) (_mm_cvtss_f32(_mm256_castps256_ps128(a))) +# endif + # else /* __KERNEL_SSE2__ */ /* This section is for utility functions which operates on non-register data -- cgit v1.2.3 From 34465a7fb091664b07611353d99dcaa0862d4a4c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 2 Apr 2020 17:40:29 +0200 Subject: VR: Refactor DirectX context management All DirectX management happens on Ghost level now, higher level code can just assume everything is OpenGL (except of the upside-down drawing that still needs to be done for DirectX). This is similar to how the metal-layer is hidden outside of Ghost. The Ghost-XR graphics binding for DirectX is responsible for managing the DirectX compatibility now. --- intern/ghost/GHOST_C-api.h | 26 +++------- intern/ghost/GHOST_IContext.h | 5 -- intern/ghost/GHOST_ISystem.h | 6 --- intern/ghost/GHOST_IXrContext.h | 2 + intern/ghost/GHOST_Types.h | 5 +- intern/ghost/intern/GHOST_C-api.cpp | 34 +++---------- intern/ghost/intern/GHOST_Context.h | 4 +- intern/ghost/intern/GHOST_IXrGraphicsBinding.h | 3 +- intern/ghost/intern/GHOST_System.cpp | 10 ---- intern/ghost/intern/GHOST_System.h | 6 --- intern/ghost/intern/GHOST_SystemWin32.cpp | 17 +++---- intern/ghost/intern/GHOST_SystemWin32.h | 28 ++++++----- intern/ghost/intern/GHOST_XrContext.cpp | 7 +++ intern/ghost/intern/GHOST_XrContext.h | 1 + intern/ghost/intern/GHOST_XrGraphicsBinding.cpp | 67 +++++++++++++++++-------- intern/ghost/intern/GHOST_XrSession.cpp | 14 ++++-- intern/ghost/intern/GHOST_XrSession.h | 1 + source/blender/windowmanager/WM_api.h | 4 -- source/blender/windowmanager/intern/wm_window.c | 21 -------- source/blender/windowmanager/intern/wm_xr.c | 58 ++++++--------------- 20 files changed, 123 insertions(+), 196 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index aba5b5f733b..4f994f76539 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -214,25 +214,6 @@ extern GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemha extern GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle, GHOST_ContextHandle contexthandle); -#ifdef WIN32 -/** - * Create a new offscreen context. - * Never explicitly delete the context, use disposeContext() instead. - * \param systemhandle The handle to the system - * \return A handle to the new context ( == NULL if creation failed). - */ -GHOST_ContextHandle GHOST_CreateDirectXContext(GHOST_SystemHandle systemhandle); - -/** - * Dispose of a context. - * \param systemhandle The handle to the system - * \param contexthandle Handle to the context to be disposed. - * \return Indication of success. - */ -GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle, - GHOST_ContextHandle contexthandle); -#endif - /** * Returns the window user data. * \param windowhandle The handle to the window @@ -1078,6 +1059,13 @@ void GHOST_XrSessionDrawViews(GHOST_XrContextHandle xr_context, void *customdata */ int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_context); +/** + * Check if \a xr_context has a session that requrires an upside-down framebuffer (compared to + * OpenGL). If true, the render result should be flipped vertically for correct output. + * \note: Only to be called after session start, may otherwise result in a false negative. + */ +int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_context); + /* events */ /** * Invoke handling of all OpenXR events for \a xr_context. Should be called on every main-loop diff --git a/intern/ghost/GHOST_IContext.h b/intern/ghost/GHOST_IContext.h index d404287fe56..1225262a908 100644 --- a/intern/ghost/GHOST_IContext.h +++ b/intern/ghost/GHOST_IContext.h @@ -60,11 +60,6 @@ class GHOST_IContext { virtual GHOST_TSuccess swapBuffers() = 0; - /** - * Returns if the window is rendered upside down compared to OpenGL. - */ - virtual bool isUpsideDown() const = 0; - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IContext") #endif diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 8adf49fe1f9..58d1a08da74 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -266,12 +266,6 @@ class GHOST_ISystem { */ virtual GHOST_IContext *createOffscreenContext() = 0; - /** - * Overload to allow requesting a different context type. By default only OpenGL is supported. - * However by explicitly overloading this a system may add support for others. - */ - virtual GHOST_IContext *createOffscreenContext(GHOST_TDrawingContextType type) = 0; - /** * Dispose of a context. * \param context Pointer to the context to be disposed. diff --git a/intern/ghost/GHOST_IXrContext.h b/intern/ghost/GHOST_IXrContext.h index 362bc923ee8..3076de96690 100644 --- a/intern/ghost/GHOST_IXrContext.h +++ b/intern/ghost/GHOST_IXrContext.h @@ -37,6 +37,8 @@ class GHOST_IXrContext { virtual void setGraphicsContextBindFuncs(GHOST_XrGraphicsContextBindFn bind_fn, GHOST_XrGraphicsContextUnbindFn unbind_fn) = 0; virtual void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) = 0; + + virtual bool needsUpsideDownDrawing() const = 0; }; #endif // __GHOST_IXRCONTEXT_H__ diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 637935d9142..6667d113fe8 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -621,9 +621,8 @@ typedef void (*GHOST_XrErrorHandlerFn)(const struct GHOST_XrError *); typedef void (*GHOST_XrSessionExitFn)(void *customdata); -typedef void *(*GHOST_XrGraphicsContextBindFn)(enum GHOST_TXrGraphicsBinding graphics_lib); -typedef void (*GHOST_XrGraphicsContextUnbindFn)(enum GHOST_TXrGraphicsBinding graphics_lib, - GHOST_ContextHandle graphics_context); +typedef void *(*GHOST_XrGraphicsContextBindFn)(); +typedef void (*GHOST_XrGraphicsContextUnbindFn)(GHOST_ContextHandle graphics_context); typedef void (*GHOST_XrDrawViewFn)(const struct GHOST_XrDrawViewInfo *draw_view, void *customdata); /* An array of GHOST_TXrGraphicsBinding items defining the candidate bindings to use. The first diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index af2a13945d1..6ee1557122d 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -150,25 +150,6 @@ GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle, return system->disposeContext(context); } -#ifdef WIN32 -GHOST_ContextHandle GHOST_CreateDirectXContext(GHOST_SystemHandle systemhandle) -{ - GHOST_ISystem *system = (GHOST_ISystem *)systemhandle; - - return (GHOST_ContextHandle)system->createOffscreenContext(GHOST_kDrawingContextTypeD3D); -} - -GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle, - GHOST_ContextHandle contexthandle) -{ - GHOST_ISystem *system = (GHOST_ISystem *)systemhandle; - GHOST_IContext *context = (GHOST_IContext *)contexthandle; - - return system->disposeContext(context); -} - -#endif - GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, const char *title, GHOST_TInt32 left, @@ -716,13 +697,6 @@ unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contex return context->getDefaultFramebuffer(); } -int GHOST_isUpsideDownContext(GHOST_ContextHandle contexthandle) -{ - GHOST_IContext *context = (GHOST_IContext *)contexthandle; - - return context->isUpsideDown(); -} - unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle) { GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; @@ -991,4 +965,12 @@ void GHOST_XrDrawViewFunc(GHOST_XrContextHandle xr_contexthandle, GHOST_XrDrawVi GHOST_XR_CAPI_CALL(xr_context->setDrawViewFunc(draw_view_fn), xr_context); } +int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_contexthandle) +{ + GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle; + + GHOST_XR_CAPI_CALL_RET(xr_context->needsUpsideDownDrawing(), xr_context); + return 0; /* Only reached if exception is thrown. */ +} + #endif diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h index 0bd6f63d07e..411a7de5c79 100644 --- a/intern/ghost/intern/GHOST_Context.h +++ b/intern/ghost/intern/GHOST_Context.h @@ -120,9 +120,9 @@ class GHOST_Context : public GHOST_IContext { } /** - * Returns if the window is rendered upside down compared to OpenGL. + * Returns if the context is rendered upside down compared to OpenGL. */ - inline bool isUpsideDown() const + virtual inline bool isUpsideDown() const { return false; } diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h index 25281d3d0ba..cddb557d163 100644 --- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h +++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h @@ -61,6 +61,7 @@ class GHOST_IXrGraphicsBinding { uint32_t image_count) = 0; virtual void submitToSwapchainImage(XrSwapchainImageBaseHeader *swapchain_image, const GHOST_XrDrawViewInfo *draw_info) = 0; + virtual bool needsUpsideDownDrawing(GHOST_Context &ghost_ctx) const = 0; protected: /* Use GHOST_XrGraphicsBindingCreateFromType! */ @@ -68,6 +69,6 @@ class GHOST_IXrGraphicsBinding { }; std::unique_ptr GHOST_XrGraphicsBindingCreateFromType( - GHOST_TXrGraphicsBinding type); + GHOST_TXrGraphicsBinding type, GHOST_Context *ghost_ctx); #endif /* __GHOST_IXRGRAPHICSBINDING_H__ */ diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 97704435f04..85eb6d58679 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -122,16 +122,6 @@ GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow *window) return success; } -GHOST_IContext *GHOST_System::createOffscreenContext(GHOST_TDrawingContextType type) -{ - switch (type) { - case GHOST_kDrawingContextTypeOpenGL: - return createOffscreenContext(); - default: - return NULL; - } -} - bool GHOST_System::validWindow(GHOST_IWindow *window) { return m_windowManager->getWindowFound(window); diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 2eec6ca43b3..eaaa2ff6ee6 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -118,12 +118,6 @@ class GHOST_System : public GHOST_ISystem { */ virtual GHOST_IContext *createOffscreenContext() = 0; - /** - * Overload to allow requesting a different context type. By default only OpenGL is supported. - * However by explicitly overloading this a system may add support for others. - */ - GHOST_IContext *createOffscreenContext(GHOST_TDrawingContextType type); - /** * Returns whether a window is valid. * \param window Pointer to the window to be checked. diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index e4988d8a0b3..9149d81e32e 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -411,9 +411,9 @@ GHOST_TSuccess GHOST_SystemWin32::disposeContext(GHOST_IContext *context) * Never explicitly delete the window, use #disposeContext() instead. * \return The new context (or 0 if creation failed). */ -GHOST_IContext *GHOST_SystemWin32::createOffscreenContextD3D() +GHOST_ContextD3D *GHOST_SystemWin32::createOffscreenContextD3D() { - GHOST_Context *context; + GHOST_ContextD3D *context; HWND wnd = CreateWindowA("STATIC", "Blender XR", @@ -435,16 +435,11 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContextD3D() return context; } -GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_TDrawingContextType type) +GHOST_TSuccess GHOST_SystemWin32::disposeContextD3D(GHOST_ContextD3D *context) { - switch (type) { - case GHOST_kDrawingContextTypeOpenGL: - return createOffscreenContext(); - case GHOST_kDrawingContextTypeD3D: - return createOffscreenContextD3D(); - default: - return NULL; - } + delete context; + + return GHOST_kSuccess; } bool GHOST_SystemWin32::processEvents(bool waitForEvent) diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 0d9fd268d0f..27f23e00ae7 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -42,6 +42,7 @@ class GHOST_EventWheel; class GHOST_EventWindow; class GHOST_EventDragnDrop; +class GHOST_ContextD3D; class GHOST_WindowWin32; /** @@ -131,18 +132,28 @@ class GHOST_SystemWin32 : public GHOST_System { GHOST_IContext *createOffscreenContext(); /** - * Create a new offscreen context. - * Never explicitly delete the window, use disposeContext() instead. + * Dispose of a context. + * \param context Pointer to the context to be disposed. + * \return Indication of success. + */ + GHOST_TSuccess disposeContext(GHOST_IContext *context); + + /** + * Create a new offscreen DirectX context. + * Never explicitly delete the context, use disposeContext() instead. + * This is for GHOST internal, Win32 specific use, so it can be called statically. + * * \return The new context (or 0 if creation failed). */ - GHOST_IContext *createOffscreenContext(GHOST_TDrawingContextType type); + static GHOST_ContextD3D *createOffscreenContextD3D(); /** - * Dispose of a context. + * Dispose of a DirectX context. + * This is for GHOST internal, Win32 specific use, so it can be called statically. * \param context Pointer to the context to be disposed. * \return Indication of success. */ - GHOST_TSuccess disposeContext(GHOST_IContext *context); + static GHOST_TSuccess disposeContextD3D(GHOST_ContextD3D *context); /*************************************************************************************** ** Event management functionality @@ -255,13 +266,6 @@ class GHOST_SystemWin32 : public GHOST_System { */ GHOST_TSuccess exit(); - /** - * Create a new offscreen DirectX context. - * Never explicitly delete the window, use disposeContext() instead. - * \return The new context (or 0 if creation failed). - */ - GHOST_IContext *createOffscreenContextD3D(); - /** * Converts raw WIN32 key codes from the wndproc to GHOST keys. * \param vKey The virtual key from hardKey diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index a757aa9a555..2cd5b2ca8c8 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -512,6 +512,13 @@ void GHOST_XrContext::setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) m_custom_funcs.draw_view_fn = draw_view_fn; } +bool GHOST_XrContext::needsUpsideDownDrawing() const +{ + /* Must only be called after the session was started */ + assert(m_session); + return m_session->needsUpsideDownDrawing(); +} + /** \} */ /* Public Accessors and Mutators */ /* -------------------------------------------------------------------- */ diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h index af65f262323..7dbd0a0d011 100644 --- a/intern/ghost/intern/GHOST_XrContext.h +++ b/intern/ghost/intern/GHOST_XrContext.h @@ -78,6 +78,7 @@ class GHOST_XrContext : public GHOST_IXrContext { void setGraphicsContextBindFuncs(GHOST_XrGraphicsContextBindFn bind_fn, GHOST_XrGraphicsContextUnbindFn unbind_fn) override; void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) override; + bool needsUpsideDownDrawing() const override; void handleSessionStateChange(const XrEventDataSessionStateChanged *lifecycle); diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index ea97b3a50cf..fa4ca2283ea 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -27,6 +27,7 @@ #elif defined(WIN32) # include "GHOST_ContextD3D.h" # include "GHOST_ContextWGL.h" +# include "GHOST_SystemWin32.h" #endif #include "GHOST_C-api.h" #include "GHOST_Xr_intern.h" @@ -180,6 +181,11 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { glBindFramebuffer(GL_FRAMEBUFFER, 0); } + bool needsUpsideDownDrawing(GHOST_Context &ghost_ctx) const + { + return ghost_ctx.isUpsideDown(); + } + private: std::list> m_image_cache; GLuint m_fbo = 0; @@ -188,19 +194,27 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { #ifdef WIN32 class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { public: + GHOST_XrGraphicsBindingD3D(GHOST_Context *ghost_ctx) + : GHOST_IXrGraphicsBinding(), m_ghost_wgl_ctx(*static_cast(ghost_ctx)) + { + m_ghost_d3d_ctx = GHOST_SystemWin32::createOffscreenContextD3D(); + } ~GHOST_XrGraphicsBindingD3D() { if (m_shared_resource) { - m_ghost_ctx->disposeSharedOpenGLResource(m_shared_resource); + m_ghost_d3d_ctx->disposeSharedOpenGLResource(m_shared_resource); + } + if (m_ghost_d3d_ctx) { + GHOST_SystemWin32::disposeContextD3D(m_ghost_d3d_ctx); } } - bool checkVersionRequirements(GHOST_Context *ghost_ctx, - XrInstance instance, - XrSystemId system_id, - std::string *r_requirement_info) const override + bool checkVersionRequirements( + GHOST_Context * /*ghost_ctx*/, /* Remember: This is the OpenGL context! */ + XrInstance instance, + XrSystemId system_id, + std::string *r_requirement_info) const override { - GHOST_ContextD3D *ctx_dx = static_cast(ghost_ctx); static PFN_xrGetD3D11GraphicsRequirementsKHR s_xrGetD3D11GraphicsRequirementsKHR_fn = nullptr; XrGraphicsRequirementsD3D11KHR gpu_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; @@ -222,16 +236,15 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { *r_requirement_info = std::move(strstream.str()); } - return ctx_dx->m_device->GetFeatureLevel() >= gpu_requirements.minFeatureLevel; + return m_ghost_d3d_ctx->m_device->GetFeatureLevel() >= gpu_requirements.minFeatureLevel; } - void initFromGhostContext(GHOST_Context *ghost_ctx) override + void initFromGhostContext( + GHOST_Context * /*ghost_ctx*/ /* Remember: This is the OpenGL context! */ + ) override { - GHOST_ContextD3D *ctx_d3d = static_cast(ghost_ctx); - oxr_binding.d3d11.type = XR_TYPE_GRAPHICS_BINDING_D3D11_KHR; - oxr_binding.d3d11.device = ctx_d3d->m_device; - m_ghost_ctx = ctx_d3d; + oxr_binding.d3d11.device = m_ghost_d3d_ctx->m_device; } bool chooseSwapchainFormat(const std::vector &runtime_formats, @@ -284,33 +297,43 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { m_ghost_ctx->blitFromOpenGLContext(m_shared_resource, draw_info->width, draw_info->height); # else if (!m_shared_resource) { - m_shared_resource = m_ghost_ctx->createSharedOpenGLResource(draw_info->width, - draw_info->height); + m_shared_resource = m_ghost_d3d_ctx->createSharedOpenGLResource(draw_info->width, + draw_info->height); } - m_ghost_ctx->blitFromOpenGLContext(m_shared_resource, draw_info->width, draw_info->height); + m_ghost_d3d_ctx->blitFromOpenGLContext(m_shared_resource, draw_info->width, draw_info->height); - m_ghost_ctx->m_device_ctx->OMSetRenderTargets(0, nullptr, nullptr); - m_ghost_ctx->m_device_ctx->CopyResource(d3d_swapchain_image->texture, - m_ghost_ctx->getSharedTexture2D(m_shared_resource)); + m_ghost_d3d_ctx->m_device_ctx->OMSetRenderTargets(0, nullptr, nullptr); + m_ghost_d3d_ctx->m_device_ctx->CopyResource( + d3d_swapchain_image->texture, m_ghost_d3d_ctx->getSharedTexture2D(m_shared_resource)); # endif } + bool needsUpsideDownDrawing(GHOST_Context &) const + { + return m_ghost_d3d_ctx->isUpsideDown(); + } + private: - GHOST_ContextD3D *m_ghost_ctx; - GHOST_SharedOpenGLResource *m_shared_resource; + /** Primary OpenGL context for Blender to use for drawing. */ + GHOST_ContextWGL &m_ghost_wgl_ctx; + /** Secondary DirectX 11 context to share with OpenGL context. */ + GHOST_ContextD3D *m_ghost_d3d_ctx = nullptr; + /** Handle to shared resource object. */ + GHOST_SharedOpenGLResource *m_shared_resource = nullptr; + std::list> m_image_cache; }; #endif // WIN32 std::unique_ptr GHOST_XrGraphicsBindingCreateFromType( - GHOST_TXrGraphicsBinding type) + GHOST_TXrGraphicsBinding type, GHOST_Context *context) { switch (type) { case GHOST_kXrGraphicsOpenGL: return std::unique_ptr(new GHOST_XrGraphicsBindingOpenGL()); #ifdef WIN32 case GHOST_kXrGraphicsD3D11: - return std::unique_ptr(new GHOST_XrGraphicsBindingD3D()); + return std::unique_ptr(new GHOST_XrGraphicsBindingD3D(context)); #endif default: return nullptr; diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index 7be0f300210..1f24f2fb37f 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -172,7 +172,8 @@ void GHOST_XrSession::start(const GHOST_XrSessionBeginInfo *begin_info) } std::string requirement_str; - m_gpu_binding = GHOST_XrGraphicsBindingCreateFromType(m_context->getGraphicsBindingType()); + m_gpu_binding = GHOST_XrGraphicsBindingCreateFromType(m_context->getGraphicsBindingType(), + m_gpu_ctx); if (!m_gpu_binding->checkVersionRequirements( m_gpu_ctx, m_context->getInstance(), m_oxr->system_id, &requirement_str)) { std::ostringstream strstream; @@ -456,6 +457,11 @@ XrCompositionLayerProjection GHOST_XrSession::drawLayer( return layer; } +bool GHOST_XrSession::needsUpsideDownDrawing() const +{ + return m_gpu_binding && m_gpu_binding->needsUpsideDownDrawing(*m_gpu_ctx); +} + /** \} */ /* Drawing */ /* -------------------------------------------------------------------- */ @@ -495,16 +501,14 @@ void GHOST_XrSession::bindGraphicsContext() { const GHOST_XrCustomFuncs &custom_funcs = m_context->getCustomFuncs(); assert(custom_funcs.gpu_ctx_bind_fn); - m_gpu_ctx = static_cast( - custom_funcs.gpu_ctx_bind_fn(m_context->getGraphicsBindingType())); + m_gpu_ctx = static_cast(custom_funcs.gpu_ctx_bind_fn()); } void GHOST_XrSession::unbindGraphicsContext() { const GHOST_XrCustomFuncs &custom_funcs = m_context->getCustomFuncs(); if (custom_funcs.gpu_ctx_unbind_fn) { - custom_funcs.gpu_ctx_unbind_fn(m_context->getGraphicsBindingType(), - (GHOST_ContextHandle)m_gpu_ctx); + custom_funcs.gpu_ctx_unbind_fn((GHOST_ContextHandle)m_gpu_ctx); } m_gpu_ctx = nullptr; } diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h index 9c1ed3756d4..39e1a63ffda 100644 --- a/intern/ghost/intern/GHOST_XrSession.h +++ b/intern/ghost/intern/GHOST_XrSession.h @@ -47,6 +47,7 @@ class GHOST_XrSession { LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged *lifecycle); bool isRunning() const; + bool needsUpsideDownDrawing() const; void unbindGraphicsContext(); /* Public so context can ensure it's unbound as needed. */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a29ee4131cb..8047e5e2112 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -156,10 +156,6 @@ void *WM_opengl_context_create(void); void WM_opengl_context_dispose(void *context); void WM_opengl_context_activate(void *context); void WM_opengl_context_release(void *context); -#ifdef WIN32 -void *WM_directx_context_create(void); -void WM_directx_context_dispose(void *context); -#endif struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect); struct wmWindow *WM_window_open_temp(struct bContext *C, diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 505383d295f..c29fd24d4cd 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -2458,24 +2458,3 @@ void WM_ghost_show_message_box(const char *title, GHOST_ShowMessageBox(g_system, title, message, help_label, continue_label, link, dialog_options); } /** \} */ - -#ifdef WIN32 -/* -------------------------------------------------------------------- */ -/** \name Direct DirectX Context Management - * \{ */ - -void *WM_directx_context_create(void) -{ - BLI_assert(GPU_framebuffer_active_get() == NULL); - return GHOST_CreateDirectXContext(g_system); -} - -void WM_directx_context_dispose(void *context) -{ - BLI_assert(GPU_framebuffer_active_get() == NULL); - GHOST_DisposeDirectXContext(g_system, context); -} - -/** \} */ - -#endif diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c index 18c3b70ed01..5115607101c 100644 --- a/source/blender/windowmanager/intern/wm_xr.c +++ b/source/blender/windowmanager/intern/wm_xr.c @@ -68,9 +68,9 @@ struct wmXrRuntimeData *wm_xr_runtime_data_create(void); void wm_xr_runtime_data_free(struct wmXrRuntimeData **runtime); void wm_xr_draw_view(const GHOST_XrDrawViewInfo *, void *); -void *wm_xr_session_gpu_binding_context_create(GHOST_TXrGraphicsBinding); -void wm_xr_session_gpu_binding_context_destroy(GHOST_TXrGraphicsBinding, GHOST_ContextHandle); -wmSurface *wm_xr_session_surface_create(wmWindowManager *, unsigned int); +void *wm_xr_session_gpu_binding_context_create(); +void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle); +wmSurface *wm_xr_session_surface_create(void); void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]); /* -------------------------------------------------------------------- */ @@ -109,11 +109,8 @@ typedef struct wmXrDrawData { } wmXrDrawData; typedef struct { - GHOST_TXrGraphicsBinding gpu_binding_type; GPUOffScreen *offscreen; GPUViewport *viewport; - - GHOST_ContextHandle secondary_ghost_ctx; } wmXrSurfaceData; typedef struct { @@ -412,10 +409,9 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr, * * \{ */ -void *wm_xr_session_gpu_binding_context_create(GHOST_TXrGraphicsBinding graphics_binding) +void *wm_xr_session_gpu_binding_context_create(void) { - wmSurface *surface = wm_xr_session_surface_create(G_MAIN->wm.first, graphics_binding); - wmXrSurfaceData *data = surface->customdata; + wmSurface *surface = wm_xr_session_surface_create(); wm_surface_add(surface); @@ -423,11 +419,10 @@ void *wm_xr_session_gpu_binding_context_create(GHOST_TXrGraphicsBinding graphics * and running. */ WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); - return data->secondary_ghost_ctx ? data->secondary_ghost_ctx : surface->ghost_ctx; + return surface->ghost_ctx; } -void wm_xr_session_gpu_binding_context_destroy(GHOST_TXrGraphicsBinding UNUSED(graphics_lib), - GHOST_ContextHandle UNUSED(context)) +void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(context)) { if (g_xr_surface) { /* Might have been freed already */ wm_surface_remove(g_xr_surface); @@ -532,13 +527,6 @@ static void wm_xr_session_free_data(wmSurface *surface) { wmXrSurfaceData *data = surface->customdata; - if (data->secondary_ghost_ctx) { -#ifdef WIN32 - if (data->gpu_binding_type == GHOST_kXrGraphicsD3D11) { - WM_directx_context_dispose(data->secondary_ghost_ctx); - } -#endif - } if (data->viewport) { GPU_viewport_free(data->viewport); } @@ -591,7 +579,7 @@ static bool wm_xr_session_surface_offscreen_ensure(const GHOST_XrDrawViewInfo *d return true; } -wmSurface *wm_xr_session_surface_create(wmWindowManager *UNUSED(wm), unsigned int gpu_binding_type) +wmSurface *wm_xr_session_surface_create(void) { if (g_xr_surface) { BLI_assert(false); @@ -601,30 +589,13 @@ wmSurface *wm_xr_session_surface_create(wmWindowManager *UNUSED(wm), unsigned in wmSurface *surface = MEM_callocN(sizeof(*surface), __func__); wmXrSurfaceData *data = MEM_callocN(sizeof(*data), "XrSurfaceData"); -#ifndef WIN32 - BLI_assert(gpu_binding_type == GHOST_kXrGraphicsOpenGL); -#endif - surface->draw = wm_xr_session_surface_draw; surface->free_data = wm_xr_session_free_data; - - data->gpu_binding_type = gpu_binding_type; - surface->customdata = data; - surface->ghost_ctx = DRW_xr_opengl_context_get(); - - switch (gpu_binding_type) { - case GHOST_kXrGraphicsOpenGL: - break; -#ifdef WIN32 - case GHOST_kXrGraphicsD3D11: - data->secondary_ghost_ctx = WM_directx_context_create(); - break; -#endif - } - surface->gpu_ctx = DRW_xr_gpu_context_get(); + surface->customdata = data; + g_xr_surface = surface; return surface; @@ -679,10 +650,11 @@ static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data, } static void wm_xr_draw_viewport_buffers_to_active_framebuffer( - const wmXrSurfaceData *surface_data, const GHOST_XrDrawViewInfo *draw_view) + const wmXrRuntimeData *runtime_data, + const wmXrSurfaceData *surface_data, + const GHOST_XrDrawViewInfo *draw_view) { - const bool is_upside_down = surface_data->secondary_ghost_ctx && - GHOST_isUpsideDownContext(surface_data->secondary_ghost_ctx); + const bool is_upside_down = GHOST_XrSessionNeedsUpsideDownDrawing(runtime_data->context); rcti rect = {.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1}; wmViewport(&rect); @@ -759,7 +731,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) GPU_offscreen_bind(surface_data->offscreen, false); - wm_xr_draw_viewport_buffers_to_active_framebuffer(surface_data, draw_view); + wm_xr_draw_viewport_buffers_to_active_framebuffer(wm->xr.runtime, surface_data, draw_view); } /** \} */ /* XR Drawing */ -- cgit v1.2.3 From b8d9b5e3315232bb157de43713ec2a54433cf9a6 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Thu, 12 Mar 2020 17:51:39 +0100 Subject: Sculpt: Delay Viewport Updates In Blender 2.81 we update and draw all nodes inside the view planes. When navigating with a pen tablet after an operation that tags the whole mesh to update (like undo or inverting the mask), this introduces some lag as nodes are updating when they enter the view. The viewport is not fully responsive again until all nodes have entered the view after the operation. This commit delays nodes updates until the view navigation stops, so the viewport navigation is always fully responsive. This introduces some artifacts while navigating, so it can be disabled if you don't want to see them. I'm storing the update planes in the PBVH. This way I can add support for some tools to update in real-time only the nodes inside this plane while running the operator, like the mesh filter. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6269 --- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 2 + source/blender/blenkernel/BKE_pbvh.h | 6 ++- source/blender/blenkernel/intern/pbvh.c | 29 +++++++++++- source/blender/blenkernel/intern/pbvh_intern.h | 3 ++ source/blender/draw/intern/draw_manager_data.c | 53 ++++++++++++++++++---- source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesrna/intern/rna_sculpt_paint.c | 8 ++++ 7 files changed, 89 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 351b72f79fb..6aaeec3f3cf 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -903,6 +903,8 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): col = flow.column() col.prop(sculpt, "show_low_resolution") col = flow.column() + col.prop(sculpt, "use_sculpt_delay_updates") + col = flow.column() col.prop(sculpt, "use_deform_only") col = flow.column() diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 2020d45ae86..a59ce816e26 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -81,6 +81,9 @@ typedef struct PBVHFrustumPlanes { int num_planes; } PBVHFrustumPlanes; +void BKE_pbvh_set_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes); +void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes); + /* Callbacks */ /* returns 1 if the search should continue from this node, 0 otherwise */ @@ -190,7 +193,8 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh, void BKE_pbvh_draw_cb(PBVH *bvh, bool show_vcol, bool update_only_visible, - PBVHFrustumPlanes *frustum, + PBVHFrustumPlanes *update_frustum, + PBVHFrustumPlanes *draw_frustum, void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers), void *user_data); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 879f1e507ba..06622f0d009 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2683,7 +2683,8 @@ static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v) void BKE_pbvh_draw_cb(PBVH *bvh, bool show_vcol, bool update_only_visible, - PBVHFrustumPlanes *frustum, + PBVHFrustumPlanes *update_frustum, + PBVHFrustumPlanes *draw_frustum, void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers), void *user_data) { @@ -2704,7 +2705,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh, } /* Gather visible nodes. */ - PBVHDrawSearchData data = {.frustum = frustum, .accum_update_flag = 0}; + PBVHDrawSearchData data = {.frustum = update_frustum, .accum_update_flag = 0}; BKE_pbvh_search_gather(bvh, pbvh_draw_search_cb, &data, &nodes, &totnode); if (update_only_visible && (data.accum_update_flag & update_flag)) { @@ -2722,7 +2723,15 @@ void BKE_pbvh_draw_cb(PBVH *bvh, } node->flag &= ~(PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers); + } + + MEM_SAFE_FREE(nodes); + + PBVHDrawSearchData draw_data = {.frustum = draw_frustum, .accum_update_flag = 0}; + BKE_pbvh_search_gather(bvh, pbvh_draw_search_cb, &draw_data, &nodes, &totnode); + for (int a = 0; a < totnode; a++) { + PBVHNode *node = nodes[a]; if (!(node->flag & PBVH_FullyHidden)) { draw_fn(user_data, node->draw_buffers); } @@ -2998,6 +3007,22 @@ void pbvh_show_face_sets_set(PBVH *bvh, bool show_face_sets) bvh->show_face_sets = show_face_sets; } +void BKE_pbvh_set_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes) +{ + bvh->num_planes = planes->num_planes; + for (int i = 0; i < bvh->num_planes; i++) { + copy_v4_v4(bvh->planes[i], planes->planes[i]); + } +} + +void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes) +{ + planes->num_planes = bvh->num_planes; + for (int i = 0; i < planes->num_planes; i++) { + copy_v4_v4(planes->planes[i], bvh->planes[i]); + } +} + void BKE_pbvh_parallel_range_settings(PBVHParallelSettings *settings, bool use_threading, int totnode) diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index 21cb5649330..d3e42ac7705 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -168,6 +168,9 @@ struct PBVH { int cd_vert_node_offset; int cd_face_node_offset; + float planes[6][4]; + int num_planes; + struct BMLog *bm_log; struct SubdivCCG *subdiv_ccg; }; diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 94a3e9e8343..1d1ca575b02 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -884,7 +884,11 @@ static float sculpt_debug_colors[9][4] = { static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers) { + if (!buffers) { + return; + } + /* Meh... use_mask is a bit misleading here. */ if (scd->use_mask && !GPU_pbvh_buffers_has_overlays(buffers)) { return; } @@ -958,24 +962,52 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) const DRWContextState *drwctx = DRW_context_state_get(); RegionView3D *rv3d = drwctx->rv3d; + const bool navigating = rv3d && (rv3d->rflag & RV3D_NAVIGATING); + + Paint *p = NULL; + if (drwctx->evil_C != NULL) { + p = BKE_paint_get_active_from_context(drwctx->evil_C); + } /* Frustum planes to show only visible PBVH nodes. */ - float planes[6][4]; - drw_sculpt_get_frustum_planes(scd->ob, planes); - PBVHFrustumPlanes frustum = {.planes = planes, .num_planes = 6}; + float update_planes[6][4]; + float draw_planes[6][4]; + PBVHFrustumPlanes update_frustum; + PBVHFrustumPlanes draw_frustum; + + if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) { + update_frustum.planes = update_planes; + update_frustum.num_planes = 6; + BKE_pbvh_get_frustum_planes(pbvh, &update_frustum); + if (!navigating) { + drw_sculpt_get_frustum_planes(scd->ob, update_planes); + update_frustum.planes = update_planes; + update_frustum.num_planes = 6; + BKE_pbvh_set_frustum_planes(pbvh, &update_frustum); + } + } + else { + drw_sculpt_get_frustum_planes(scd->ob, update_planes); + update_frustum.planes = update_planes; + update_frustum.num_planes = 6; + } + + drw_sculpt_get_frustum_planes(scd->ob, draw_planes); + draw_frustum.planes = draw_planes; + draw_frustum.num_planes = 6; /* Fast mode to show low poly multires while navigating. */ scd->fast_mode = false; - if (drwctx->evil_C != NULL) { - Paint *p = BKE_paint_get_active_from_context(drwctx->evil_C); - if (p && (p->flags & PAINT_FAST_NAVIGATE)) { - scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING); - } + if (p && (p->flags & PAINT_FAST_NAVIGATE)) { + scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING); } /* Update draw buffers only for visible nodes while painting. * But do update them otherwise so navigating stays smooth. */ - const bool update_only_visible = rv3d && (rv3d->rflag & RV3D_PAINTING); + bool update_only_visible = rv3d && !(rv3d->rflag & RV3D_PAINTING); + if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) { + update_only_visible = true; + } Mesh *mesh = scd->ob->data; BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg); @@ -983,7 +1015,8 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) BKE_pbvh_draw_cb(pbvh, use_vcol, update_only_visible, - &frustum, + &update_frustum, + &draw_frustum, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 62640a2ce54..f4834355223 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2137,6 +2137,7 @@ typedef enum ePaintFlags { PAINT_FAST_NAVIGATE = (1 << 1), PAINT_SHOW_BRUSH_ON_SURFACE = (1 << 2), PAINT_USE_CAVITY_MASK = (1 << 3), + PAINT_SCULPT_DELAY_UPDATES = (1 << 4), } ePaintFlags; /* Paint.symmetry_flags diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index f1a5cb79db4..f2d5c465dac 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -617,6 +617,14 @@ static void rna_def_paint(BlenderRNA *brna) prop, "Fast Navigate", "For multires, show low resolution while navigating the view"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "use_sculpt_delay_updates", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SCULPT_DELAY_UPDATES); + RNA_def_property_ui_text( + prop, + "Delay Viewport Updates", + "Update the geometry when it enters the view, providing faster view navigation"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "num_input_samples"); RNA_def_property_ui_range(prop, 1, PAINT_MAX_INPUT_SAMPLES, 1, -1); -- cgit v1.2.3 From 12628e0794af1c1f1bfc7e39260c3c33b84984b4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 18:19:28 +0200 Subject: Fix Cycles AVX unit test still failing to build with old GCC --- intern/cycles/util/util_simd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index ac2893692df..de0e3c39f30 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -589,8 +589,8 @@ __forceinline __m128 _mm_round_ps_emu(__m128 value, const int flags) # endif /* !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__)) */ /* Older GCC versions do not have _mm256_cvtss_f32 yet, so define it ourselves. - * _mm256_castps256_ps128 generates no instructions so this is jus as efficient. */ -# ifdef __KERNEL_AVX__ + * _mm256_castps256_ps128 generates no instructions so this is just as efficient. */ +# if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) # undef _mm256_cvtss_f32 # define _mm256_cvtss_f32(a) (_mm_cvtss_f32(_mm256_castps256_ps128(a))) # endif -- cgit v1.2.3 From 6eb409bb9cb6333bbc30b12b683a4b739850652d Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 2 Apr 2020 18:44:58 +0200 Subject: Fix warnings caused by own earlier commit Caused by 34465a7fb091. --- intern/ghost/GHOST_Types.h | 2 +- intern/ghost/intern/GHOST_XrGraphicsBinding.cpp | 2 ++ source/blender/windowmanager/intern/wm_xr.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 6667d113fe8..eb844c9e574 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -621,7 +621,7 @@ typedef void (*GHOST_XrErrorHandlerFn)(const struct GHOST_XrError *); typedef void (*GHOST_XrSessionExitFn)(void *customdata); -typedef void *(*GHOST_XrGraphicsContextBindFn)(); +typedef void *(*GHOST_XrGraphicsContextBindFn)(void); typedef void (*GHOST_XrGraphicsContextUnbindFn)(GHOST_ContextHandle graphics_context); typedef void (*GHOST_XrDrawViewFn)(const struct GHOST_XrDrawViewInfo *draw_view, void *customdata); diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index fa4ca2283ea..e8de5d1bed7 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -338,4 +338,6 @@ std::unique_ptr GHOST_XrGraphicsBindingCreateFromType( default: return nullptr; } + + (void)context; /* Might be unused. */ } diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c index 5115607101c..be0c8b4798b 100644 --- a/source/blender/windowmanager/intern/wm_xr.c +++ b/source/blender/windowmanager/intern/wm_xr.c @@ -68,7 +68,7 @@ struct wmXrRuntimeData *wm_xr_runtime_data_create(void); void wm_xr_runtime_data_free(struct wmXrRuntimeData **runtime); void wm_xr_draw_view(const GHOST_XrDrawViewInfo *, void *); -void *wm_xr_session_gpu_binding_context_create(); +void *wm_xr_session_gpu_binding_context_create(void); void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle); wmSurface *wm_xr_session_surface_create(void); void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]); -- cgit v1.2.3 From 75f6e6b39e41dd453b4802eb3bae397a3be0d48f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 18:52:22 +0200 Subject: Fix link error on Linux buildbot with libxml2 On macOS this is part of the collada folder, but for Linux xml2 is in its own folder for precompiled libraries. --- build_files/cmake/platform/platform_unix.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 3f73916daf3..d3444f41e37 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -196,13 +196,12 @@ if(WITH_OPENCOLLADA) find_package_wrapper(OpenCOLLADA) if(OPENCOLLADA_FOUND) if(WITH_STATIC_LIBS) - # PCRE and XML2 are bundled with OpenCollada. + # PCRE is bundled with OpenCollada. set(PCRE_LIBRARIES pcre) - set(XML2_LIBRARIES xml2) else() - find_package_wrapper(XML2) find_package_wrapper(PCRE) endif() + find_package_wrapper(XML2) else() set(WITH_OPENCOLLADA OFF) endif() -- cgit v1.2.3 From c4ba0d15087b5052bb557f94f93ac5f76c75da93 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 22:05:03 +0200 Subject: Fix Linux link error with pcre after recent changes, must use absolute path --- build_files/cmake/platform/platform_unix.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index d3444f41e37..0bf790b34e6 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -196,8 +196,9 @@ if(WITH_OPENCOLLADA) find_package_wrapper(OpenCOLLADA) if(OPENCOLLADA_FOUND) if(WITH_STATIC_LIBS) - # PCRE is bundled with OpenCollada. - set(PCRE_LIBRARIES pcre) + # PCRE is bundled with OpenCollada without headers, so can't use + # find_package reliably to detect it. + set(PCRE_LIBRARIES ${LIBDIR}/opencollada/lib/libpcre.a) else() find_package_wrapper(PCRE) endif() -- cgit v1.2.3 From 6f4dbb661f104d7bc487765c618b023b3862e33d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 3 Apr 2020 02:24:14 +0200 Subject: Revert "Writefile: Cleanup Scene runtime data." This reverts commit ee0d91df5dd75029de6886db13e45af3d4c7ef7c. This is modifying scene data on write, which causes crashes. It can only do that on a copy of the data. --- source/blender/blenloader/intern/writefile.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ea334f258a1..693c4f8cced 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2591,12 +2591,6 @@ static void write_lightcache(WriteData *wd, LightCache *cache) static void write_scene(WriteData *wd, Scene *sce, const void *id_address) { - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - if (sce->ed) { - sce->ed->cache = NULL; - sce->ed->prefetch_job = NULL; - } - /* write LibData */ writestruct_at_address(wd, ID_SCE, Scene, 1, id_address, sce); write_iddata(wd, &sce->id); -- cgit v1.2.3 From c154f265dea9deaf5ad5f41b1c027b0dee2334a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 12:05:13 +1100 Subject: Cleanup: move curve picking functions into 'editcurve_query.c' --- source/blender/editors/curve/CMakeLists.txt | 1 + source/blender/editors/curve/curve_intern.h | 19 +- source/blender/editors/curve/editcurve.c | 199 +------------------- source/blender/editors/curve/editcurve_query.c | 244 +++++++++++++++++++++++++ 4 files changed, 257 insertions(+), 206 deletions(-) create mode 100644 source/blender/editors/curve/editcurve_query.c diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index 8c9309055c8..ff80c47baa8 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -40,6 +40,7 @@ set(SRC editcurve.c editcurve_add.c editcurve_paint.c + editcurve_query.c editcurve_select.c editcurve_undo.c editfont.c diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index 201ba2560dc..7d0a2e5edbc 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -142,14 +142,6 @@ void CURVE_OT_match_texture_space(struct wmOperatorType *ot); struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex); void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu); -bool ED_curve_pick_vert(struct ViewContext *vc, - short sel, - struct Nurb **r_nurb, - struct BezTriple **r_bezt, - struct BPoint **r_bp, - short *r_handle, - struct Base **r_base); - /* helper functions */ void ed_editnurb_translate_flag(struct ListBase *editnurb, short flag, const float vec[3]); bool ed_editnurb_extrude_flag(struct EditNurb *editnurb, const short flag); @@ -189,6 +181,17 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(struct wmOperatorType *ot); void SURFACE_OT_primitive_nurbs_surface_sphere_add(struct wmOperatorType *ot); void SURFACE_OT_primitive_nurbs_surface_torus_add(struct wmOperatorType *ot); +/* editcurve_query.c */ +bool ED_curve_pick_vert(struct ViewContext *vc, + short sel, + struct Nurb **r_nurb, + struct BezTriple **r_bezt, + struct BPoint **r_bp, + short *r_handle, + struct Base **r_base); +void ED_curve_nurb_vert_selected_find( + Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp); + /* editcurve_paint.c */ void CURVE_OT_draw(struct wmOperatorType *ot); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 8a484867e9f..f85b0f2331f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3883,182 +3883,6 @@ void CURVE_OT_subdivide(wmOperatorType *ot) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Cursor Picking API - * \{ */ - -static void ED_curve_pick_vert__doClosest( - void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) -{ - struct { - BPoint *bp; - BezTriple *bezt; - Nurb *nurb; - float dist; - int hpoint, select; - float mval_fl[2]; - bool is_changed; - } *data = userData; - - short flag; - float dist_test; - - if (bp) { - flag = bp->f1; - } - else { - if (beztindex == 0) { - flag = bezt->f1; - } - else if (beztindex == 1) { - flag = bezt->f2; - } - else { - flag = bezt->f3; - } - } - - dist_test = len_manhattan_v2v2(data->mval_fl, screen_co); - if ((flag & SELECT) == data->select) { - dist_test += 5.0f; - } - if (bezt && beztindex == 1) { - dist_test += 3.0f; /* middle points get a small disadvantage */ - } - - if (dist_test < data->dist) { - data->dist = dist_test; - - data->bp = bp; - data->bezt = bezt; - data->nurb = nu; - data->hpoint = bezt ? beztindex : 0; - data->is_changed = true; - } -} - -bool ED_curve_pick_vert(ViewContext *vc, - short sel, - Nurb **r_nurb, - BezTriple **r_bezt, - BPoint **r_bp, - short *r_handle, - Base **r_base) -{ - /* (sel == 1): selected gets a disadvantage */ - /* in nurb and bezt or bp the nearest is written */ - /* return 0 1 2: handlepunt */ - struct { - BPoint *bp; - BezTriple *bezt; - Nurb *nurb; - float dist; - int hpoint, select; - float mval_fl[2]; - bool is_changed; - } data = {NULL}; - - data.dist = ED_view3d_select_dist_px(); - data.hpoint = 0; - data.select = sel; - data.mval_fl[0] = vc->mval[0]; - data.mval_fl[1] = vc->mval[1]; - - uint bases_len; - Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( - vc->view_layer, vc->v3d, &bases_len); - for (uint base_index = 0; base_index < bases_len; base_index++) { - Base *base = bases[base_index]; - data.is_changed = false; - - ED_view3d_viewcontext_init_object(vc, base->object); - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - nurbs_foreachScreenVert(vc, ED_curve_pick_vert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT); - - if (r_base && data.is_changed) { - *r_base = base; - } - } - MEM_freeN(bases); - - *r_nurb = data.nurb; - *r_bezt = data.bezt; - *r_bp = data.bp; - - if (r_handle) { - *r_handle = data.hpoint; - } - - return (data.bezt || data.bp); -} - -static void findselectedNurbvert( - Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp) -{ - /* in nu and (bezt or bp) selected are written if there's 1 sel. */ - /* if more points selected in 1 spline: return only nu, bezt and bp are 0 */ - ListBase *editnurb = &cu->editnurb->nurbs; - Nurb *nu1; - BezTriple *bezt1; - BPoint *bp1; - int a; - - *r_nu = NULL; - *r_bezt = NULL; - *r_bp = NULL; - - for (nu1 = editnurb->first; nu1; nu1 = nu1->next) { - if (nu1->type == CU_BEZIER) { - bezt1 = nu1->bezt; - a = nu1->pntsu; - while (a--) { - if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) { - if (*r_nu != NULL && *r_nu != nu1) { - *r_nu = NULL; - *r_bp = NULL; - *r_bezt = NULL; - return; - } - else if (*r_bezt || *r_bp) { - *r_bp = NULL; - *r_bezt = NULL; - } - else { - *r_bezt = bezt1; - *r_nu = nu1; - } - } - bezt1++; - } - } - else { - bp1 = nu1->bp; - a = nu1->pntsu * nu1->pntsv; - while (a--) { - if (bp1->f1 & SELECT) { - if (*r_nu != NULL && *r_nu != nu1) { - *r_bp = NULL; - *r_bezt = NULL; - *r_nu = NULL; - return; - } - else if (*r_bezt || *r_bp) { - *r_bp = NULL; - *r_bezt = NULL; - } - else { - *r_bp = bp1; - *r_nu = nu1; - } - } - bp1++; - } - } - } -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Set Spline Type Operator * \{ */ @@ -5736,7 +5560,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) cu = vc.obedit->data; - findselectedNurbvert(cu, vc.v3d, &nu, &bezt, &bp); + ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp); if (bezt) { mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]); @@ -7198,27 +7022,6 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count) keyIndex_updateBP(editnurb, src, dst, count); } -bool ED_curve_active_center(Curve *cu, float center[3]) -{ - Nurb *nu = NULL; - void *vert = NULL; - - if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) { - return false; - } - - if (nu->type == CU_BEZIER) { - BezTriple *bezt = (BezTriple *)vert; - copy_v3_v3(center, bezt->vec[1]); - } - else { - BPoint *bp = (BPoint *)vert; - copy_v3_v3(center, bp->vec); - } - - return true; -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c new file mode 100644 index 00000000000..0b15d9e55b9 --- /dev/null +++ b/source/blender/editors/curve/editcurve_query.c @@ -0,0 +1,244 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ + +/** \file + * \ingroup edcurve + */ + +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BKE_curve.h" +#include "BKE_fcurve.h" +#include "BKE_layer.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +#include "ED_curve.h" +#include "ED_view3d.h" + +#include "curve_intern.h" + +/* -------------------------------------------------------------------- */ +/** \name Cursor Picking API + * \{ */ + +static void ED_curve_pick_vert__do_closest( + void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) +{ + struct { + BPoint *bp; + BezTriple *bezt; + Nurb *nurb; + float dist; + int hpoint, select; + float mval_fl[2]; + bool is_changed; + } *data = userData; + + short flag; + float dist_test; + + if (bp) { + flag = bp->f1; + } + else { + if (beztindex == 0) { + flag = bezt->f1; + } + else if (beztindex == 1) { + flag = bezt->f2; + } + else { + flag = bezt->f3; + } + } + + dist_test = len_manhattan_v2v2(data->mval_fl, screen_co); + if ((flag & SELECT) == data->select) { + dist_test += 5.0f; + } + if (bezt && beztindex == 1) { + dist_test += 3.0f; /* middle points get a small disadvantage */ + } + + if (dist_test < data->dist) { + data->dist = dist_test; + + data->bp = bp; + data->bezt = bezt; + data->nurb = nu; + data->hpoint = bezt ? beztindex : 0; + data->is_changed = true; + } +} + +bool ED_curve_pick_vert(ViewContext *vc, + short sel, + Nurb **r_nurb, + BezTriple **r_bezt, + BPoint **r_bp, + short *r_handle, + Base **r_base) +{ + /* (sel == 1): selected gets a disadvantage */ + /* in nurb and bezt or bp the nearest is written */ + /* return 0 1 2: handlepunt */ + struct { + BPoint *bp; + BezTriple *bezt; + Nurb *nurb; + float dist; + int hpoint, select; + float mval_fl[2]; + bool is_changed; + } data = {NULL}; + + data.dist = ED_view3d_select_dist_px(); + data.hpoint = 0; + data.select = sel; + data.mval_fl[0] = vc->mval[0]; + data.mval_fl[1] = vc->mval[1]; + + uint bases_len; + Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( + vc->view_layer, vc->v3d, &bases_len); + for (uint base_index = 0; base_index < bases_len; base_index++) { + Base *base = bases[base_index]; + data.is_changed = false; + + ED_view3d_viewcontext_init_object(vc, base->object); + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + nurbs_foreachScreenVert(vc, ED_curve_pick_vert__do_closest, &data, V3D_PROJ_TEST_CLIP_DEFAULT); + + if (r_base && data.is_changed) { + *r_base = base; + } + } + MEM_freeN(bases); + + *r_nurb = data.nurb; + *r_bezt = data.bezt; + *r_bp = data.bp; + + if (r_handle) { + *r_handle = data.hpoint; + } + + return (data.bezt || data.bp); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Selection Queries + * \{ */ + +void ED_curve_nurb_vert_selected_find( + Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp) +{ + /* in nu and (bezt or bp) selected are written if there's 1 sel. */ + /* if more points selected in 1 spline: return only nu, bezt and bp are 0 */ + ListBase *editnurb = &cu->editnurb->nurbs; + Nurb *nu1; + BezTriple *bezt1; + BPoint *bp1; + int a; + + *r_nu = NULL; + *r_bezt = NULL; + *r_bp = NULL; + + for (nu1 = editnurb->first; nu1; nu1 = nu1->next) { + if (nu1->type == CU_BEZIER) { + bezt1 = nu1->bezt; + a = nu1->pntsu; + while (a--) { + if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) { + if (*r_nu != NULL && *r_nu != nu1) { + *r_nu = NULL; + *r_bp = NULL; + *r_bezt = NULL; + return; + } + else if (*r_bezt || *r_bp) { + *r_bp = NULL; + *r_bezt = NULL; + } + else { + *r_bezt = bezt1; + *r_nu = nu1; + } + } + bezt1++; + } + } + else { + bp1 = nu1->bp; + a = nu1->pntsu * nu1->pntsv; + while (a--) { + if (bp1->f1 & SELECT) { + if (*r_nu != NULL && *r_nu != nu1) { + *r_bp = NULL; + *r_bezt = NULL; + *r_nu = NULL; + return; + } + else if (*r_bezt || *r_bp) { + *r_bp = NULL; + *r_bezt = NULL; + } + else { + *r_bp = bp1; + *r_nu = nu1; + } + } + bp1++; + } + } + } +} + +bool ED_curve_active_center(Curve *cu, float center[3]) +{ + Nurb *nu = NULL; + void *vert = NULL; + + if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) { + return false; + } + + if (nu->type == CU_BEZIER) { + BezTriple *bezt = (BezTriple *)vert; + copy_v3_v3(center, bezt->vec[1]); + } + else { + BPoint *bp = (BPoint *)vert; + copy_v3_v3(center, bp->vec); + } + + return true; +} + +/** \} */ -- cgit v1.2.3 From d52326bab39d6222e7cdc9613396aa6553757e2e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 12:38:04 +1100 Subject: Cleanup: spelling --- intern/ghost/GHOST_C-api.h | 6 +++--- source/blender/blenkernel/BKE_subdiv_ccg.h | 4 ++-- source/blender/blenkernel/BKE_subdiv_deform.h | 4 ++-- source/blender/blenkernel/intern/subdiv_foreach.c | 2 +- source/blender/blenloader/intern/writefile.c | 6 +++--- source/blender/editors/gpencil/annotate_draw.c | 2 +- source/blender/editors/object/object_remesh.c | 2 +- source/blender/editors/sculpt_paint/sculpt_intern.h | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 4f994f76539..5b45510a39f 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -738,7 +738,7 @@ extern GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthan extern GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle); /** - * Get the OpenGL framebuffer handle that serves as a default framebuffer. + * Get the OpenGL frame-buffer handle that serves as a default frame-buffer. */ extern unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle); @@ -750,7 +750,7 @@ extern unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle extern int GHOST_isUpsideDownContext(GHOST_ContextHandle contexthandle); /** - * Get the OpenGL framebuffer handle that serves as a default framebuffer. + * Get the OpenGL frame-buffer handle that serves as a default frame-buffer. */ extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHandle); @@ -1060,7 +1060,7 @@ void GHOST_XrSessionDrawViews(GHOST_XrContextHandle xr_context, void *customdata int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_context); /** - * Check if \a xr_context has a session that requrires an upside-down framebuffer (compared to + * Check if \a xr_context has a session that requires an upside-down frame-buffer (compared to * OpenGL). If true, the render result should be flipped vertically for correct output. * \note: Only to be called after session start, may otherwise result in a false negative. */ diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h index 99b134dab3e..6f886a4b850 100644 --- a/source/blender/blenkernel/BKE_subdiv_ccg.h +++ b/source/blender/blenkernel/BKE_subdiv_ccg.h @@ -218,8 +218,8 @@ typedef struct SubdivCCG { /* Create CCG representation of subdivision surface. * - * NOTE: CCG stores dense verticies in a grid-like storage. There is no edges or - * polygons informations for the high-poly surface. + * NOTE: CCG stores dense vertices in a grid-like storage. There is no edges or + * polygons information's for the high-poly surface. * * NOTE: Subdiv is expected to be refined and ready for evaluation. * NOTE: CCG becomes an owner of subdiv. diff --git a/source/blender/blenkernel/BKE_subdiv_deform.h b/source/blender/blenkernel/BKE_subdiv_deform.h index 11ef225de27..735cd20a6c8 100644 --- a/source/blender/blenkernel/BKE_subdiv_deform.h +++ b/source/blender/blenkernel/BKE_subdiv_deform.h @@ -34,10 +34,10 @@ struct Mesh; struct Subdiv; /* Special version of subdivision surface which calculates final positions for coarse vertices. - * Effectively is pushsing the coarse positions to the limit surface. + * Effectively is pushing the coarse positions to the limit surface. * * One of the usage examples is calculation of crazy space of subdivision modifier, allowing to - * paint on a deformed mesh with subsurf on it. + * paint on a deformed mesh with sub-surf on it. * * vertex_cos are supposed to hold coordinates of the coarse mesh. */ void BKE_subdiv_deform_coarse_vertices(struct Subdiv *subdiv, diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 6e39f9f302b..b31fb2c9312 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -1880,7 +1880,7 @@ bool BKE_subdiv_foreach_subdiv_geometry(Subdiv *subdiv, * the tasks into it. * NOTE: Watch out for callbacks which needs to run for loose geometry as they * currently are relying on the fact that face/grid callbacks will tag non- - * loose geomtry. */ + * loose geometry. */ BLI_task_parallel_range( 0, coarse_mesh->totpoly, &ctx, subdiv_foreach_task, ¶llel_range_settings); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 693c4f8cced..6851fb67fed 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2818,9 +2818,9 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address) static void write_gpencil(WriteData *wd, bGPdata *gpd, const void *id_address) { if (gpd->id.us > 0 || wd->use_memfile) { - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - /* XXX not sure why the whole runtime data is not cleared in readcode, for now mimicking it - * here. */ + /* Clean up, important in undo case to reduce false detection of changed data-blocks. */ + /* XXX not sure why the whole run-time data is not cleared in reading code, + * for now mimicking it here. */ gpd->runtime.sbuffer = NULL; gpd->runtime.sbuffer_used = 0; gpd->runtime.sbuffer_size = 0; diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index fc62defd757..3e2c3b17241 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -353,7 +353,7 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points, /* Tessellation code - draw stroke as series of connected quads * (triangle strips in fact) with connection edges rotated to minimize shrinking artifacts, - * and rounded endcaps. + * and rounded end-caps. */ { const bGPDspoint *pt1, *pt2; diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 92187bbf0c5..8a803821fe4 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -409,7 +409,7 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve d = d * 0.0005f; } else { - /* Multiply d by the initial voxel size to prevent incontrolable speeds when using low voxel + /* Multiply d by the initial voxel size to prevent uncontrollable speeds when using low voxel * sizes. */ /* When the voxel size is slower, it needs more precision. */ d = d * min_ff(pow2f(cd->init_voxel_size), 0.1f) * 0.05f; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 478d2be9a30..f0481582571 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -303,7 +303,7 @@ typedef enum { * Is used as a storage for either original or modified geometry. */ typedef struct SculptUndoNodeGeometry { /* Is used for sanity check, helping with ensuring that two and only two - * geometry pushes happenned in the undo stack. */ + * geometry pushes happened in the undo stack. */ bool is_initialized; CustomData vdata; -- cgit v1.2.3 From eae40c6c763c989f41210ff2972c1a024811133f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 13:15:18 +1100 Subject: Cleanup: improve & use doxy sections for armature_naming.c --- source/blender/editors/armature/armature_naming.c | 49 ++++++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 13660244547..d36e6100bcf 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -20,6 +20,8 @@ /** \file * \ingroup edarmature + * + * This file contains functions/API's for renaming bones and/or working with them. */ #include @@ -63,12 +65,11 @@ #include "armature_intern.h" -/* This file contains functions/API's for renaming bones and/or working with them */ - -/* ************************************************** */ -/* EditBone Names */ +/* -------------------------------------------------------------------- */ +/** \name Unique Bone Name Utility (Edit Mode) + * \{ */ -/* note: there's a unique_bone_name() too! */ +/* note: there's a ed_armature_bone_unique_name() too! */ static bool editbone_unique_check(void *arg, const char *name) { struct { @@ -92,20 +93,29 @@ void ED_armature_ebone_unique_name(ListBase *edbo, char *name, EditBone *bone) BLI_uniquename_cb(editbone_unique_check, &data, DATA_("Bone"), '.', name, sizeof(bone->name)); } -/* ************************************************** */ -/* Bone Renaming - API */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Unique Bone Name Utility (Object Mode) + * \{ */ static bool bone_unique_check(void *arg, const char *name) { return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL; } -static void unique_bone_name(bArmature *arm, char *name) +static void ed_armature_bone_unique_name(bArmature *arm, char *name) { BLI_uniquename_cb( bone_unique_check, (void *)arm, DATA_("Bone"), '.', name, sizeof(((Bone *)NULL)->name)); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Bone Renaming (Object & Edit Mode API) + * \{ */ + /* helper call for armature_bone_rename */ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, @@ -180,7 +190,7 @@ void ED_armature_bone_rename(Main *bmain, Bone *bone = BKE_armature_find_bone_name(arm, oldname); if (bone) { - unique_bone_name(arm, newname); + ed_armature_bone_unique_name(arm, newname); if (arm->bonehash) { BLI_assert(BLI_ghash_haskey(arm->bonehash, bone->name)); @@ -372,6 +382,12 @@ void ED_armature_bone_rename(Main *bmain, } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Bone Flipping (Object & Edit Mode API) + * \{ */ + typedef struct BoneFlipNameData { struct BoneFlipNameData *next, *prev; char *name; @@ -426,8 +442,11 @@ void ED_armature_bones_flip_names(Main *bmain, } } -/* ************************************************** */ -/* Bone Renaming - EditMode */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Flip Bone Names (Edit Mode Operator) + * \{ */ static int armature_flip_names_exec(bContext *C, wmOperator *op) { @@ -511,6 +530,12 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot) "(WARNING: may result in incoherent naming in some cases)"); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Bone Auto Side Names (Edit Mode Operator) + * \{ */ + static int armature_autoside_names_exec(bContext *C, wmOperator *op) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -599,3 +624,5 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) /* settings */ ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with"); } + +/** \} */ -- cgit v1.2.3 From 09071e27993a6a113ea08376e361230d99e7690d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 13:19:26 +1100 Subject: Fix T75330: Select linked crashes without a bone near the cursor Own error with recent improvements to select link. --- source/blender/editors/armature/armature_select.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 86396dd6783..cafaca1f967 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -290,6 +290,7 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_ba bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base); MEM_freeN(bases); + return bone; } return NULL; @@ -484,9 +485,13 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const Base *base = NULL; EditBone *ebone_active = get_nearest_bone(C, event->mval, true, &base); - bArmature *arm = base->object->data; - if (ebone_active == NULL || !EBONE_SELECTABLE(arm, ebone_active)) { + if (ebone_active == NULL) { + return OPERATOR_CANCELLED; + } + + bArmature *arm = base->object->data; + if (!EBONE_SELECTABLE(arm, ebone_active)) { return OPERATOR_CANCELLED; } -- cgit v1.2.3 From b18608f3e9066407b1d8a837161ad295d7719937 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 15:45:57 +1100 Subject: Cleanup: bone cursor picking API There was one function to access both pose/edit bones, which returned a void pointer type. Split these into 3 functions which return EditBone, bPoseChannel or Bone types. Internally the logic is still shared, this just makes it clearer to callers which type is expected. Also use more conventional prefix for picking API: - ED_armature_pick_(ebone/pchan/bone) - ED_armature_pick_(ebone/pchan/bone)_from_selectbuffer --- source/blender/editors/armature/armature_intern.h | 40 ++++- source/blender/editors/armature/armature_select.c | 163 ++++++++++++++++----- source/blender/editors/armature/pose_select.c | 8 +- source/blender/editors/include/ED_armature.h | 4 + .../blender/editors/space_view3d/view3d_select.c | 6 +- 5 files changed, 172 insertions(+), 49 deletions(-) diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 37f0c7197a9..a454461b144 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -258,16 +258,40 @@ void armature_select_mirrored_ex(struct bArmature *arm, const int flag); void armature_select_mirrored(struct bArmature *arm); void armature_tag_unselect(struct bArmature *arm); -void *get_nearest_bone(struct bContext *C, const int xy[2], bool findunsel, struct Base **r_base); - -void *get_bone_from_selectbuffer(struct Base **bases, - uint bases_len, - bool is_editmode, - const unsigned int *buffer, - short hits, +EditBone *ED_armature_pick_ebone(struct bContext *C, + const int xy[2], bool findunsel, - bool do_nearest, struct Base **r_base); +struct bPoseChannel *ED_armature_pick_pchan(struct bContext *C, + const int xy[2], + bool findunsel, + struct Base **r_base); +struct Bone *ED_armature_pick_bone(struct bContext *C, + const int xy[2], + bool findunsel, + struct Base **r_base); + +struct EditBone *ED_armature_pick_ebone_from_selectbuffer(struct Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + struct Base **r_base); +struct bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(struct Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + struct Base **r_base); +struct Bone *ED_armature_pick_bone_from_selectbuffer(struct Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + struct Base **r_base); int bone_looper(struct Object *ob, struct Bone *bone, diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index cafaca1f967..a8560f89a1a 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -30,6 +30,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_string_utils.h" #include "BKE_action.h" @@ -111,14 +112,14 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, return ob; } -Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, - uint bases_len, - int hit, - Bone **r_bone) +Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, + uint bases_len, + int hit, + bPoseChannel **r_pchan) { const uint hit_object = hit & 0xFFFF; Base *base = NULL; - Bone *bone = NULL; + bPoseChannel *pchan = NULL; /* TODO(campbell): optimize, eg: sort & binary search. */ for (uint base_index = 0; base_index < bases_len; base_index++) { if (bases[base_index]->object->runtime.select_id == hit_object) { @@ -129,26 +130,49 @@ Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, if (base != NULL) { if (base->object->pose != NULL) { const uint hit_bone = (hit & ~BONESEL_ANY) >> 16; - bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); - bone = pchan ? pchan->bone : NULL; + /* pchan may be NULL. */ + pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); } } - *r_bone = bone; + *r_pchan = pchan; + return base; +} + +/* For callers that don't need the pose channel. */ +Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, + uint bases_len, + int hit, + Bone **r_bone) +{ + bPoseChannel *pchan = NULL; + Base *base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, hit, &pchan); + *r_bone = pchan ? pchan->bone : NULL; return base; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Cursor Pick from Select Buffer API + * + * Internal #ed_armature_pick_bone_from_selectbuffer_impl is exposed as: + * - #ED_armature_pick_ebone_from_selectbuffer + * - #ED_armature_pick_pchan_from_selectbuffer + * - #ED_armature_pick_bone_from_selectbuffer + * \{ */ + /* See if there are any selected bones in this buffer */ /* only bones from base are checked on */ -void *get_bone_from_selectbuffer(Base **bases, - uint bases_len, - bool is_editmode, - const unsigned int *buffer, - short hits, - bool findunsel, - bool do_nearest, - Base **r_base) +static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode, + Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + Base **r_base) { - Bone *bone; + bPoseChannel *pchan; EditBone *ebone; void *firstunSel = NULL, *firstSel = NULL, *data; Base *firstunSel_base = NULL, *firstSel_base = NULL; @@ -168,16 +192,17 @@ void *get_bone_from_selectbuffer(Base **bases, hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ if (is_editmode == false) { - base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, hitresult, &bone); - if (bone != NULL) { + base = ED_armature_base_and_pchan_from_select_buffer( + bases, bases_len, hitresult, &pchan); + if (pchan != NULL) { if (findunsel) { - sel = (bone->flag & BONE_SELECTED); + sel = (pchan->bone->flag & BONE_SELECTED); } else { - sel = !(bone->flag & BONE_SELECTED); + sel = !(pchan->bone->flag & BONE_SELECTED); } - data = bone; + data = pchan; } else { data = NULL; @@ -248,10 +273,63 @@ void *get_bone_from_selectbuffer(Base **bases, } } -/* used by posemode as well editmode */ -/* only checks scene->basact! */ -/* x and y are mouse coords (area space) */ -void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_base) +EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + Base **r_base) +{ + const bool is_editmode = true; + return ed_armature_pick_bone_from_selectbuffer_impl( + is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); +} + +bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + Base **r_base) +{ + const bool is_editmode = false; + return ed_armature_pick_bone_from_selectbuffer_impl( + is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); +} + +Bone *ED_armature_pick_bone_from_selectbuffer(Base **bases, + uint bases_len, + const uint *buffer, + short hits, + bool findunsel, + bool do_nearest, + Base **r_base) +{ + bPoseChannel *pchan = ED_armature_pick_pchan_from_selectbuffer( + bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); + return pchan ? pchan->bone : NULL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Cursor Pick API + * + * Internal #ed_armature_pick_bone_impl is exposed as: + * - #ED_armature_pick_ebone + * - #ED_armature_pick_pchan + * - #ED_armature_pick_bone + * \{ */ + +/** + * \param xy: Cursor coordinates (area space). + * \return An #EditBone when is_editmode, otherwise a #bPoseChannel. + * \note Only checks objects in the current mode (edit-mode or pose-mode). + */ +static void *ed_armature_pick_bone_impl( + const bool is_editmode, bContext *C, const int xy[2], bool findunsel, Base **r_base) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; @@ -260,10 +338,9 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_ba short hits; ED_view3d_viewcontext_init(C, &vc, depsgraph); + BLI_assert((vc.obedit != NULL) == is_editmode); - // rect.xmin = ... mouseco! - rect.xmin = rect.xmax = xy[0]; - rect.ymin = rect.ymax = xy[1]; + BLI_rcti_init_pt_radius(&rect, xy, 0); hits = view3d_opengl_select( &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP); @@ -286,8 +363,8 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_ba bases = BKE_object_pose_base_array_get(vc.view_layer, vc.v3d, &bases_len); } - void *bone = get_bone_from_selectbuffer( - bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base); + void *bone = ed_armature_pick_bone_from_selectbuffer_impl( + is_editmode, bases, bases_len, buffer, hits, findunsel, true, r_base); MEM_freeN(bases); @@ -296,6 +373,24 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel, Base **r_ba return NULL; } +EditBone *ED_armature_pick_ebone(bContext *C, const int xy[2], bool findunsel, Base **r_base) +{ + const bool is_editmode = true; + return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base); +} + +bPoseChannel *ED_armature_pick_pchan(bContext *C, const int xy[2], bool findunsel, Base **r_base) +{ + const bool is_editmode = false; + return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base); +} + +Bone *ED_armature_pick_bone(bContext *C, const int xy[2], bool findunsel, Base **r_base) +{ + bPoseChannel *pchan = ED_armature_pick_pchan(C, xy, findunsel, r_base); + return pchan ? pchan->bone : NULL; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -484,7 +579,7 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const BKE_object_update_select_id(CTX_data_main(C)); Base *base = NULL; - EditBone *ebone_active = get_nearest_bone(C, event->mval, true, &base); + EditBone *ebone_active = ED_armature_pick_ebone(C, event->mval, true, &base); if (ebone_active == NULL) { return OPERATOR_CANCELLED; @@ -818,7 +913,7 @@ bool ED_armature_edit_deselect_all_visible_multi(bContext *C) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Cursor Picking API +/** \name Select Cursor Pick API * \{ */ /* context: editmode armature in view3d */ @@ -2052,7 +2147,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const BKE_object_update_select_id(CTX_data_main(C)); ebone_src = arm->act_edbone; - ebone_dst = get_nearest_bone(C, event->mval, false, &base_dst); + ebone_dst = ED_armature_pick_ebone(C, event->mval, false, &base_dst); /* fallback to object selection */ if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) { diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 475640fa37c..824cb50d5f1 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -156,12 +156,12 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer, } Object *ob_act = OBACT(view_layer); - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + BLI_assert(OBEDIT_FROM_VIEW_LAYER(view_layer) == NULL); /* Callers happen to already get the active base */ Base *base_dummy = NULL; - nearBone = get_bone_from_selectbuffer( - &base, 1, obedit != NULL, buffer, hits, 1, do_nearest, &base_dummy); + nearBone = ED_armature_pick_bone_from_selectbuffer( + &base, 1, buffer, hits, 1, do_nearest, &base_dummy); /* if the bone cannot be affected, don't do anything */ if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) { @@ -413,7 +413,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve view3d_operator_needs_opengl(C); Base *base = NULL; - bone = get_nearest_bone(C, event->mval, !extend, &base); + bone = ED_armature_pick_bone(C, event->mval, !extend, &base); if (!bone) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 40f5cade0d5..8e0103299eb 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -187,6 +187,10 @@ struct Object *ED_armature_object_and_ebone_from_select_buffer(struct Object **o uint objects_len, int hit, struct EditBone **r_ebone); +struct Base *ED_armature_base_and_pchan_from_select_buffer(struct Base **bases, + uint bases_len, + int hit, + struct bPoseChannel **r_pchan); struct Base *ED_armature_base_and_bone_from_select_buffer(struct Base **bases, uint bases_len, int hit, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 8fdef585fa2..b8dbd277fbc 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -3104,9 +3104,9 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) { - Bone *bone; - Base *base = ED_armature_base_and_bone_from_select_buffer( - bases, BLI_array_len(bases), *col, &bone); + bPoseChannel *pchan_dummy; + Base *base = ED_armature_base_and_pchan_from_select_buffer( + bases, BLI_array_len(bases), *col, &pchan_dummy); if (base != NULL) { base->object->id.tag |= LIB_TAG_DOIT; } -- cgit v1.2.3 From 71e543c68bc181606a70950d5fb80229f14223ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 16:04:02 +1100 Subject: Cleanup: replace static list with argument for curve merging --- source/blender/editors/curve/editcurve.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f85b0f2331f..681b03d691d 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4196,10 +4196,7 @@ typedef struct NurbSort { float vec[3]; } NurbSort; -static ListBase nsortbase = {NULL, NULL}; -/* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */ - -static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb) +static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *nsortbase) { ListBase nbase = {NULL, NULL}; NurbSort *nus, *nustest, *headdo, *taildo; @@ -4228,7 +4225,7 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb) /* just add the first one */ nus = nbase.first; BLI_remlink(&nbase, nus); - BLI_addtail(&nsortbase, nus); + BLI_addtail(nsortbase, nus); /* now add, either at head or tail, the closest one */ while (nbase.first) { @@ -4238,13 +4235,13 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb) nustest = nbase.first; while (nustest) { - dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase->first)->vec); if (dist < headdist) { headdist = dist; headdo = nustest; } - dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase->last)->vec); if (dist < taildist) { taildist = dist; @@ -4255,11 +4252,11 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb) if (headdist < taildist) { BLI_remlink(&nbase, headdo); - BLI_addhead(&nsortbase, headdo); + BLI_addhead(nsortbase, headdo); } else { BLI_remlink(&nbase, taildo); - BLI_addtail(&nsortbase, taildo); + BLI_addtail(nsortbase, taildo); } } } @@ -4436,8 +4433,9 @@ static int merge_nurb(View3D *v3d, Object *obedit) ListBase *editnurb = object_editcurve_get(obedit); NurbSort *nus1, *nus2; bool ok = true; + ListBase nsortbase = {NULL, NULL}; - make_selection_list_nurb(v3d, editnurb); + make_selection_list_nurb(v3d, editnurb, &nsortbase); if (nsortbase.first == nsortbase.last) { BLI_freelistN(&nsortbase); -- cgit v1.2.3 From 04fe37f93116bd3b276ebe86d9fa53f18223ee6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 16:15:57 +1100 Subject: Cleanup: quiet shadow warnings with ghost & mantaflow --- intern/ghost/intern/GHOST_SystemX11.cpp | 4 ++-- intern/mantaflow/intern/MANTA_main.cpp | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index a9d656a1c36..f076fe4c94a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -910,8 +910,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe) vector::const_iterator win_end = win_vec.end(); for (; win_it != win_end; ++win_it) { - GHOST_WindowX11 *window = static_cast(*win_it); - window->refreshXInputDevices(); + GHOST_WindowX11 *window_xinput = static_cast(*win_it); + window_xinput->refreshXInputDevices(); } } } diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index bf58e22938a..d14ab8d6dd3 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -2710,8 +2710,8 @@ void MANTA::updateMeshFromUni(const char *filename) if (!gzf) std::cout << "updateMeshFromUni: unable to open file" << std::endl; - char ID[5] = {0, 0, 0, 0, 0}; - gzread(gzf, ID, 4); + char file_magic[5] = {0, 0, 0, 0, 0}; + gzread(gzf, file_magic, 4); std::vector *velocityPointer = mMeshVelocities; @@ -2744,11 +2744,11 @@ void MANTA::updateMeshFromUni(const char *filename) } // Reading mesh - if (!strcmp(ID, "MB01")) { + if (!strcmp(file_magic, "MB01")) { // TODO (sebbas): Future update could add uni mesh support } // Reading mesh data file v1 with vec3 - else if (!strcmp(ID, "MD01")) { + else if (!strcmp(file_magic, "MD01")) { numParticles = ibuffer[0]; velocityPointer->resize(numParticles); @@ -2801,10 +2801,10 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo if (!gzf) std::cerr << "updateParticlesFromUni: unable to open file" << std::endl; - char ID[5] = {0, 0, 0, 0, 0}; - gzread(gzf, ID, 4); + char file_magic[5] = {0, 0, 0, 0, 0}; + gzread(gzf, file_magic, 4); - if (!strcmp(ID, "PB01")) { + if (!strcmp(file_magic, "PB01")) { std::cerr << "particle uni file format v01 not supported anymore" << std::endl; gzclose(gzf); return; @@ -2860,7 +2860,7 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo int readStart, readEnd, readBytes; // Reading base particle system file v2 - if (!strcmp(ID, "PB02")) { + if (!strcmp(file_magic, "PB02")) { MANTA::pData *bufferPData; todoParticles = numParticles; bufferPData = (MANTA::pData *)MEM_malloc_arrayN( @@ -2900,7 +2900,7 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo MEM_freeN(bufferPData); } // Reading particle data file v1 with velocities - else if (!strcmp(ID, "PD01") && isVelData) { + else if (!strcmp(file_magic, "PD01") && isVelData) { MANTA::pVel *bufferPVel; todoParticles = numParticles; bufferPVel = (MANTA::pVel *)MEM_malloc_arrayN( @@ -2939,7 +2939,7 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo MEM_freeN(bufferPVel); } // Reading particle data file v1 with lifetime - else if (!strcmp(ID, "PD01")) { + else if (!strcmp(file_magic, "PD01")) { float *bufferPLife; todoParticles = numParticles; bufferPLife = (float *)MEM_malloc_arrayN(PARTICLE_CHUNK, sizeof(float), "fluid_particle_life"); @@ -3029,22 +3029,22 @@ int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) return 0; } - char ID[5] = {0, 0, 0, 0, 0}; - gzread(gzf, ID, 4); + char file_magic[5] = {0, 0, 0, 0, 0}; + gzread(gzf, file_magic, 4); - if (!strcmp(ID, "DDF2")) { + if (!strcmp(file_magic, "DDF2")) { std::cout << "MANTA::updateGridFromUni(): grid uni file format DDF2 not supported anymore" << std::endl; gzclose(gzf); return 0; } - if (!strcmp(ID, "MNT1")) { + if (!strcmp(file_magic, "MNT1")) { std::cout << "MANTA::updateGridFromUni(): grid uni file format MNT1 not supported anymore" << std::endl; gzclose(gzf); return 0; } - if (!strcmp(ID, "MNT2")) { + if (!strcmp(file_magic, "MNT2")) { std::cout << "MANTA::updateGridFromUni(): grid uni file format MNT2 not supported anymore" << std::endl; gzclose(gzf); @@ -3083,7 +3083,7 @@ int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) } // Actual data reading - if (!strcmp(ID, "MNT3")) { + if (!strcmp(file_magic, "MNT3")) { gzread(gzf, grid, sizeof(float) * ibuffer[0] * ibuffer[1] * ibuffer[2]); } -- cgit v1.2.3 From 600a627f6e326f4542a876e6e82f771cd3da218f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 16:21:24 +1100 Subject: Cleanup: use abbreviated names for unsigned types in editors --- .../editors/animation/anim_channels_defines.c | 4 +- source/blender/editors/animation/anim_draw.c | 2 +- source/blender/editors/animation/anim_ipo_utils.c | 2 +- source/blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/animation/fmodifier_ui.c | 4 +- source/blender/editors/animation/keyframes_draw.c | 16 +-- source/blender/editors/animation/keyframes_edit.c | 2 +- .../blender/editors/animation/keyframes_general.c | 2 +- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/animation/time_scrub_ui.c | 2 +- source/blender/editors/armature/armature_select.c | 10 +- source/blender/editors/armature/armature_utils.c | 7 +- source/blender/editors/armature/pose_lib.c | 6 +- source/blender/editors/armature/pose_select.c | 2 +- source/blender/editors/curve/editcurve.c | 10 +- source/blender/editors/curve/editcurve_paint.c | 20 ++-- source/blender/editors/curve/editfont.c | 2 +- .../gizmo_library/geometry/geom_arrow_gizmo.c | 2 +- .../gizmo_library/geometry/geom_cube_gizmo.c | 2 +- .../gizmo_library/geometry/geom_dial_gizmo.c | 2 +- .../editors/gizmo_library/gizmo_draw_utils.c | 2 +- .../blender/editors/gizmo_library/gizmo_geometry.h | 4 +- source/blender/editors/interface/interface_icons.c | 14 +-- source/blender/editors/interface/resources.c | 2 +- source/blender/editors/mask/mask_draw.c | 50 ++++----- source/blender/editors/mask/mask_query.c | 4 +- source/blender/editors/mesh/editface.c | 6 +- source/blender/editors/mesh/editmesh_intersect.c | 6 +- source/blender/editors/mesh/editmesh_knife.c | 4 +- source/blender/editors/mesh/editmesh_rip.c | 6 +- source/blender/editors/mesh/editmesh_tools.c | 10 +- source/blender/editors/mesh/editmesh_utils.c | 8 +- source/blender/editors/mesh/mesh_mirror.c | 6 +- source/blender/editors/mesh/meshtools.c | 16 +-- source/blender/editors/metaball/mball_edit.c | 2 +- source/blender/editors/object/object_add.c | 8 +- source/blender/editors/object/object_bake_api.c | 6 +- source/blender/editors/object/object_modifier.c | 2 +- source/blender/editors/object/object_random.c | 4 +- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/object/object_remesh.c | 8 +- source/blender/editors/object/object_transform.c | 3 +- source/blender/editors/render/render_opengl.c | 13 +-- source/blender/editors/render/render_preview.c | 30 ++--- source/blender/editors/render/render_shading.c | 4 +- source/blender/editors/screen/glutil.c | 8 +- source/blender/editors/screen/screen_draw.c | 12 +- source/blender/editors/screen/screendump.c | 2 +- source/blender/editors/sculpt_paint/paint_cursor.c | 18 +-- .../blender/editors/sculpt_paint/paint_image_2d.c | 107 +++++++++--------- .../editors/sculpt_paint/paint_image_proj.c | 72 ++++++------ source/blender/editors/sculpt_paint/paint_utils.c | 27 ++--- .../editors/sculpt_paint/paint_vertex_color_ops.c | 2 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 10 +- source/blender/editors/space_action/action_draw.c | 19 ++-- .../editors/space_clip/clip_dopesheet_draw.c | 4 +- source/blender/editors/space_clip/clip_draw.c | 15 ++- source/blender/editors/space_clip/clip_editor.c | 20 ++-- .../blender/editors/space_clip/clip_graph_draw.c | 6 +- source/blender/editors/space_clip/clip_ops.c | 12 +- source/blender/editors/space_file/file_draw.c | 8 +- source/blender/editors/space_file/file_ops.c | 4 +- source/blender/editors/space_file/filelist.c | 40 +++---- source/blender/editors/space_graph/graph_edit.c | 4 +- source/blender/editors/space_image/image_ops.c | 10 +- .../blender/editors/space_image/image_sequence.c | 4 +- source/blender/editors/space_nla/nla_draw.c | 2 +- source/blender/editors/space_node/node_select.c | 2 +- source/blender/editors/space_node/node_view.c | 10 +- .../editors/space_sequencer/sequencer_draw.c | 30 ++--- .../editors/space_sequencer/sequencer_scopes.c | 121 ++++++++++----------- .../editors/space_sequencer/sequencer_view.c | 8 +- source/blender/editors/space_text/text_format.c | 2 +- source/blender/editors/space_text/text_ops.c | 2 +- source/blender/editors/space_view3d/view3d_view.c | 6 +- source/blender/editors/transform/transform.c | 4 +- .../blender/editors/transform/transform_convert.c | 8 +- .../editors/transform/transform_draw_cursors.c | 2 +- .../blender/editors/transform/transform_generics.c | 4 +- .../editors/transform/transform_orientations.c | 12 +- source/blender/editors/transform/transform_snap.c | 2 +- .../editors/transform/transform_snap_object.c | 20 ++-- source/blender/editors/uvedit/uvedit_ops.c | 10 +- .../blender/editors/uvedit/uvedit_parametrizer.c | 26 ++--- .../blender/editors/uvedit/uvedit_smart_stitch.c | 34 +++--- 85 files changed, 491 insertions(+), 539 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 67e899382bb..2c1b7f3fb76 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -856,7 +856,7 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ bool showGroupColors = acf_show_channel_colors(ac); if (showGroupColors && agrp->customCol) { - unsigned char cp[3]; + uchar cp[3]; /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) { @@ -4395,7 +4395,7 @@ void ANIM_channel_draw( if (acf->name && !achannel_is_being_renamed(ac, acf, channel_index)) { const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ - unsigned char col[4]; + uchar col[4]; /* set text color */ /* XXX: if active, highlight differently? */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 96fd2e94a5e..4203c2677b7 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -71,7 +71,7 @@ void ANIM_draw_cfra_number(const bContext *C, View2D *v2d, short flag) const bool show_time = (flag & DRAWCFRA_UNIT_SECONDS) != 0; const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; - unsigned char col[4]; + uchar col[4]; float color[4]; float xscale, x, y; char numstr[32] = " t "; /* t is the character to start replacing from */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index f631d08f3e4..3613ca9eeda 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -203,7 +203,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) #define HSV_BANDWIDTH 0.3f /* used to determine the color of F-Curves with FCURVE_COLOR_AUTO_RAINBOW set */ -// void fcurve_rainbow(unsigned int cur, unsigned int tot, float *out) +// void fcurve_rainbow(uint cur, uint tot, float *out) void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) { float hsv[3], fac; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 8b0e9b22ce8..27d38cf625a 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -528,7 +528,7 @@ static void draw_markers_background(rctf *rect) uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - unsigned char shade[4]; + uchar shade[4]; UI_GetThemeColor4ubv(TH_TIME_SCRUB_BACKGROUND, shade); immUniformColor4ubv(shade); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 9bdfd9cfe33..954daff560f 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -178,7 +178,7 @@ static void draw_modifier__generator(uiLayout *layout, const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; float *cp = NULL; char xval[32]; - unsigned int i; + uint i; int maxXWidth; /* draw polynomial order selector */ @@ -317,7 +317,7 @@ static void draw_modifier__generator(uiLayout *layout, case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */ { float *cp = NULL; - unsigned int i; + uint i; /* draw polynomial order selector */ row = uiLayoutRow(layout, false); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 4b3b730d0fe..37bfd7f396c 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -558,11 +558,11 @@ void draw_keyframe_shape(float x, short key_type, short mode, float alpha, - unsigned int pos_id, - unsigned int size_id, - unsigned int color_id, - unsigned int outline_color_id, - unsigned int flags_id, + uint pos_id, + uint size_id, + uint color_id, + uint outline_color_id, + uint flags_id, short handle_type, short extreme_type) { @@ -595,9 +595,9 @@ void draw_keyframe_shape(float x, size -= 0.8f * key_type; } - unsigned char fill_col[4]; - unsigned char outline_col[4]; - unsigned int flags = 0; + uchar fill_col[4]; + uchar outline_col[4]; + uint flags = 0; /* draw! */ if (draw_fill) { diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 61488e7f63a..e22fddc6d67 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -79,7 +79,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, { BezTriple *bezt; short ok = 0; - unsigned int i; + uint i; /* sanity check */ if (ELEM(NULL, fcu, fcu->bezt)) { diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index c526c185383..fc9ec870496 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -1189,7 +1189,7 @@ short paste_animedit_keys(bAnimContext *ac, * one F-Curve has been pasted into. */ for (pass = 0; pass < 3; pass++) { - unsigned int totmatch = 0; + uint totmatch = 0; for (ale = anim_data->first; ale; ale = ale->next) { /* Find buffer item to paste from: diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index e66ebb1928c..c22f1e0642b 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -494,7 +494,7 @@ int insert_vert_fcurve( FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag) { BezTriple beztr = {{{0}}}; - unsigned int oldTot = fcu->totvert; + uint oldTot = fcu->totvert; int a; /* set all three points, for nicer start position diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c index 25b8e78de92..7679995d9a4 100644 --- a/source/blender/editors/animation/time_scrub_ui.c +++ b/source/blender/editors/animation/time_scrub_ui.c @@ -95,7 +95,7 @@ static void draw_current_frame(const Scene *scene, int current_frame) { const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; - const unsigned char color[] = {255, 255, 255, 255}; + const uchar color[] = {255, 255, 255, 255}; int frame_x = UI_view2d_view_to_region_x(v2d, current_frame); char frame_str[64]; diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index a8560f89a1a..700fe14ade6 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -176,7 +176,7 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode EditBone *ebone; void *firstunSel = NULL, *firstSel = NULL, *data; Base *firstunSel_base = NULL, *firstSel_base = NULL; - unsigned int hitresult; + uint hitresult; short i; bool takeNext = false; int minsel = 0xffffffff, minunsel = 0xffffffff; @@ -334,7 +334,7 @@ static void *ed_armature_pick_bone_impl( Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; rcti rect; - unsigned int buffer[MAXPICKBUF]; + uint buffer[MAXPICKBUF]; short hits; ED_view3d_viewcontext_init(C, &vc, depsgraph); @@ -635,15 +635,15 @@ void ARMATURE_OT_select_linked_pick(wmOperatorType *ot) * \{ */ /* utility function for get_nearest_editbonepoint */ -static int selectbuffer_ret_hits_12(unsigned int *UNUSED(buffer), const int hits12) +static int selectbuffer_ret_hits_12(uint *UNUSED(buffer), const int hits12) { return hits12; } -static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits12, const int hits5) +static int selectbuffer_ret_hits_5(uint *buffer, const int hits12, const int hits5) { const int offs = 4 * hits12; - memcpy(buffer, buffer + offs, 4 * hits5 * sizeof(unsigned int)); + memcpy(buffer, buffer + offs, 4 * hits5 * sizeof(uint)); return hits5; } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 8f63f239abc..fe456324d9c 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -196,13 +196,12 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon * \param ebone_child_tot: Size of the ebone_child array * \return The shared parent or NULL. */ -EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], - const unsigned int ebone_child_tot) +EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const uint ebone_child_tot) { - unsigned int i; + uint i; EditBone *ebone_iter; -#define EBONE_TEMP_UINT(ebone) (*((unsigned int *)(&((ebone)->temp)))) +#define EBONE_TEMP_UINT(ebone) (*((uint *)(&((ebone)->temp)))) /* clear all */ for (i = 0; i < ebone_child_tot; i++) { diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index f759808d08e..455e7cb2733 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -626,7 +626,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op) /* remove relevant keyframes */ for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; - unsigned int i; + uint i; if (fcu->bezt) { for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { @@ -1323,9 +1323,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) } /* specially handle events for searching */ -static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, - unsigned short event, - char ascii) +static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, ushort event, char ascii) { /* try doing some form of string manipulation first */ switch (event) { diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 824cb50d5f1..f29900b0760 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -141,7 +141,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer, View3D *v3d, Base *base, - const unsigned int *buffer, + const uint *buffer, short hits, bool extend, bool deselect, diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 681b03d691d..de2c3d44caf 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -6549,8 +6549,8 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op)) for (nu = editnurb->first; nu; nu = nu->next) { if ((nu->type == CU_BEZIER) && (nu->pntsu > 2)) { - unsigned int span_step[2] = {nu->pntsu, nu->pntsu}; - unsigned int span_len; + uint span_step[2] = {nu->pntsu, nu->pntsu}; + uint span_len; while (BLI_array_iter_span(nu->bezt, nu->pntsu, @@ -6564,9 +6564,9 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op)) BezTriple *bezt_next = &nu->bezt[mod_i(span_step[1] + 1, nu->pntsu)]; int i_span_edge_len = span_len + 1; - const unsigned int dims = 3; + const uint dims = 3; - const unsigned int points_len = ((cu->resolu - 1) * i_span_edge_len) + 1; + const uint points_len = ((cu->resolu - 1) * i_span_edge_len) + 1; float *points = MEM_mallocN(points_len * dims * sizeof(float), __func__); float *points_stride = points; const int points_stride_len = (cu->resolu - 1); @@ -6591,7 +6591,7 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op)) BLI_assert(points_stride + dims == points + (points_len * dims)); float tan_l[3], tan_r[3], error_sq_dummy; - unsigned int error_index_dummy; + uint error_index_dummy; sub_v3_v3v3(tan_l, bezt_prev->vec[1], bezt_prev->vec[2]); normalize_v3(tan_l); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index d028a88e322..748bf040fbb 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -205,7 +205,7 @@ static bool stroke_elem_project(const struct CurveDrawData *cdd, } else { const ViewDepths *depths = rv3d->depths; - if (depths && ((unsigned int)mval_i[0] < depths->w) && ((unsigned int)mval_i[1] < depths->h)) { + if (depths && ((uint)mval_i[0] < depths->w) && ((uint)mval_i[1] < depths->h)) { const double depth = (double)ED_view3d_depth_read_cached(&cdd->vc, mval_i); if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) { if (ED_view3d_depth_unproject(region, mval_i, depth, r_location_world)) { @@ -798,7 +798,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) float *coords = MEM_mallocN(sizeof(*coords) * stroke_len * dims, __func__); float *cubic_spline = NULL; - unsigned int cubic_spline_len = 0; + uint cubic_spline_len = 0; /* error in object local space */ const int fit_method = RNA_enum_get(op->ptr, "fit_method"); @@ -827,14 +827,14 @@ static int curve_draw_exec(bContext *C, wmOperator *op) } } - unsigned int *corners = NULL; - unsigned int corners_len = 0; + uint *corners = NULL; + uint corners_len = 0; if ((fit_method == CURVE_PAINT_FIT_METHOD_SPLIT) && (corner_angle < (float)M_PI)) { /* this could be configurable... */ const float corner_radius_min = error_threshold / 8; const float corner_radius_max = error_threshold * 2; - const unsigned int samples_max = 16; + const uint samples_max = 16; curve_fit_corners_detect_fl(coords, stroke_len, @@ -847,9 +847,9 @@ static int curve_draw_exec(bContext *C, wmOperator *op) &corners_len); } - unsigned int *corners_index = NULL; - unsigned int corners_index_len = 0; - unsigned int calc_flag = CURVE_FIT_CALC_HIGH_QUALIY; + uint *corners_index = NULL; + uint corners_index_len = 0; + uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY; if ((stroke_len > 2) && use_cyclic) { calc_flag |= CURVE_FIT_CALC_CYCLIC; @@ -919,14 +919,14 @@ static int curve_draw_exec(bContext *C, wmOperator *op) if (corners_index) { /* ignore the first and last */ - unsigned int i_start = 0, i_end = corners_index_len; + uint i_start = 0, i_end = corners_index_len; if ((corners_index_len >= 2) && (calc_flag & CURVE_FIT_CALC_CYCLIC) == 0) { i_start += 1; i_end -= 1; } - for (unsigned int i = i_start; i < i_end; i++) { + for (uint i = i_start; i < i_end; i++) { bezt = &nu->bezt[corners_index[i]]; bezt->h1 = bezt->h2 = HD_FREE; } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 297af4cb72d..dc5dc71106f 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -76,7 +76,7 @@ static int kill_selection(Object *obedit, int ins); /** \name Internal Utilities * \{ */ -static wchar_t findaccent(wchar_t char1, unsigned int code) +static wchar_t findaccent(wchar_t char1, uint code) { wchar_t new = 0; diff --git a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c index 90196988d94..668b59ac191 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_arrow_gizmo.c @@ -55,7 +55,7 @@ static float normals[][3] = { {0.000000, 0.000000, 1.000000}, }; -static unsigned short indices[] = { +static ushort indices[] = { 1, 3, 2, 3, 5, 4, 5, 7, 6, 7, 9, 8, 9, 11, 10, 11, 13, 12, 5, 18, 19, 15, 1, 0, 13, 15, 14, 6, 10, 14, 11, 21, 22, 7, 19, 20, 13, 22, 23, 3, 17, 18, 9, 20, 21, 15, 23, 16, 1, 16, 17, 23, 22, 24, 21, 20, 24, 19, 18, 24, 17, 16, 24, 16, 23, 24, 22, 21, 24, diff --git a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c index ea1a3147148..51618e353f4 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_cube_gizmo.c @@ -45,7 +45,7 @@ static const float normals[][3] = { {-0.577349, 0.577349, 0.577349}, }; -static const unsigned short indices[] = { +static const ushort indices[] = { 1, 2, 3, 7, 6, 5, 4, 5, 1, 5, 6, 2, 2, 6, 7, 0, 3, 7, 0, 1, 3, 4, 7, 5, 0, 4, 1, 1, 5, 2, 3, 2, 7, 4, 0, 7, }; diff --git a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c index 273f957e9b6..7e37c233c2a 100644 --- a/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c +++ b/source/blender/editors/gizmo_library/geometry/geom_dial_gizmo.c @@ -221,7 +221,7 @@ static const float normals[][3] = { {-0.466689, 0.092807, -0.879513}, {0.512650, -0.101962, -0.852504}, }; -static const unsigned short indices[] = { +static const ushort indices[] = { 6, 7, 1, 7, 8, 2, 8, 9, 3, 9, 10, 4, 10, 11, 5, 5, 11, 6, 12, 13, 7, 13, 14, 8, 14, 15, 9, 15, 16, 10, 16, 17, 11, 11, 17, 12, 18, 19, 13, 13, 19, 20, 20, 21, 15, 15, 21, 22, 22, 23, 17, 17, 23, 18, 24, 25, 19, diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c index cffafc56693..01e5a7eacfd 100644 --- a/source/blender/editors/gizmo_library/gizmo_draw_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c @@ -66,7 +66,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, /* Elements */ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, info->ntris, info->nverts); for (int i = 0; i < info->ntris; i++) { - const unsigned short *idx = &info->indices[i * 3]; + const ushort *idx = &info->indices[i * 3]; GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); } el = GPU_indexbuf_build(&elb); diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h index ae8ba3c411b..a5f61158f66 100644 --- a/source/blender/editors/gizmo_library/gizmo_geometry.h +++ b/source/blender/editors/gizmo_library/gizmo_geometry.h @@ -30,12 +30,14 @@ #ifndef __GIZMO_GEOMETRY_H__ #define __GIZMO_GEOMETRY_H__ +#include "BLI_sys_types.h" + typedef struct GizmoGeomInfo { int nverts; int ntris; const float (*verts)[3]; const float (*normals)[3]; - const unsigned short *indices; + const ushort *indices; } GizmoGeomInfo; /* arrow gizmo */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index edc5087c8dd..075bd8af906 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -759,11 +759,11 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf, // blur alpha channel const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx; float alpha_accum = 0.0; - unsigned int alpha_samples = 0; + uint alpha_samples = 0; for (int ax = asx; ax < aex; ax++) { for (int ay = asy; ay < aey; ay++) { const int offset_read = (sy + ay) * buf->x + (sx + ax); - unsigned int color_read = buf->rect[offset_read]; + uint color_read = buf->rect[offset_read]; const float alpha_read = ((color_read & 0xff000000) >> 24) / 255.0; alpha_accum += alpha_read; alpha_samples += 1; @@ -782,8 +782,8 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf, const float border_srgb[4] = { 0, 0, 0, MIN2(1.0, blurred_alpha * border_sharpness) * border_intensity}; - const unsigned int color_read = buf->rect[offset_write]; - const unsigned char *orig_color = (unsigned char *)&color_read; + const uint color_read = buf->rect[offset_write]; + const uchar *orig_color = (uchar *)&color_read; float border_rgba[4]; float orig_rgba[4]; @@ -795,8 +795,8 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf, blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]); linearrgb_to_srgb_v4(dest_srgb, dest_rgba); - unsigned int alpha_mask = ((unsigned int)(dest_srgb[3] * 255)) << 24; - unsigned int cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask; + uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24; + uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask; result->rect[offset_write] = cpack; } } @@ -1892,7 +1892,7 @@ static void icon_draw_size(float x, mul_v4_fl(color, alpha); float border_outset = 0.0; - unsigned int border_texel = 0; + uint border_texel = 0; #ifndef WITH_HEADLESS if (with_border) { const float scale = (float)ICON_GRID_W / (float)ICON_DEFAULT_WIDTH; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index e5af8768e6e..01c9716ec86 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1198,7 +1198,7 @@ void UI_GetThemeColor4fv(int colorid, float col[4]) void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]) { - const unsigned char *cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid); + const uchar *cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid); col[0] = ((float)cp[0]) / 255.0f; col[1] = ((float)cp[1]) / 255.0f; col[2] = ((float)cp[2]) / 255.0f; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 2fda383ebb7..91c02408f95 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -57,7 +57,7 @@ static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, - unsigned char r_rgb[4]) + uchar r_rgb[4]) { if (is_sel) { if (mask_layer->act_spline == spline) { @@ -79,7 +79,7 @@ static void mask_spline_color_get(MaskLayer *mask_layer, static void mask_spline_feather_color_get(MaskLayer *UNUSED(mask_layer), MaskSpline *UNUSED(spline), const bool is_sel, - unsigned char r_rgb[4]) + uchar r_rgb[4]) { if (is_sel) { r_rgb[1] = 255; @@ -124,7 +124,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; + const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(rgb_gray); @@ -194,7 +194,7 @@ static void draw_spline_points(const bContext *C, (mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0; const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0; - unsigned char rgb_spline[4]; + uchar rgb_spline[4]; MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); SpaceClip *sc = CTX_wm_space_clip(C); bool undistort = false; @@ -368,28 +368,26 @@ static void draw_spline_points(const bContext *C, } } -static void mask_color_active_tint(unsigned char r_rgb[4], - const unsigned char rgb[4], - const bool is_active) +static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active) { if (!is_active) { - r_rgb[0] = (unsigned char)((((int)(rgb[0])) + 128) / 2); - r_rgb[1] = (unsigned char)((((int)(rgb[1])) + 128) / 2); - r_rgb[2] = (unsigned char)((((int)(rgb[2])) + 128) / 2); + r_rgb[0] = (uchar)((((int)(rgb[0])) + 128) / 2); + r_rgb[1] = (uchar)((((int)(rgb[1])) + 128) / 2); + r_rgb[2] = (uchar)((((int)(rgb[2])) + 128) / 2); r_rgb[3] = rgb[3]; } else { - *(unsigned int *)r_rgb = *(const unsigned int *)rgb; + *(uint *)r_rgb = *(const uint *)rgb; } } -static void mask_draw_array(unsigned int pos, +static void mask_draw_array(uint pos, GPUPrimType prim_type, const float (*points)[2], - unsigned int vertex_len) + uint vertex_len) { immBegin(prim_type, vertex_len); - for (unsigned int i = 0; i < vertex_len; i++) { + for (uint i = 0; i < vertex_len; i++) { immVertex2fv(pos, points[i]); } immEnd(); @@ -401,13 +399,13 @@ static void mask_draw_curve_type(const bContext *C, int tot_point, const bool is_feather, const bool is_active, - const unsigned char rgb_spline[4], + const uchar rgb_spline[4], const char draw_type) { const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP; - const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff}; - unsigned char rgb_tmp[4]; + const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff}; + uchar rgb_tmp[4]; SpaceClip *sc = CTX_wm_space_clip(C); float(*points)[2] = orig_points; @@ -469,9 +467,9 @@ static void mask_draw_curve_type(const bContext *C, } if (is_feather) { - rgb_tmp[0] = (unsigned char)(((short)rgb_tmp[0] + (short)rgb_spline[0]) / 2); - rgb_tmp[1] = (unsigned char)(((short)rgb_tmp[1] + (short)rgb_spline[1]) / 2); - rgb_tmp[2] = (unsigned char)(((short)rgb_tmp[2] + (short)rgb_spline[2]) / 2); + rgb_tmp[0] = (uchar)(((short)rgb_tmp[0] + (short)rgb_spline[0]) / 2); + rgb_tmp[1] = (uchar)(((short)rgb_tmp[1] + (short)rgb_spline[1]) / 2); + rgb_tmp[2] = (uchar)(((short)rgb_tmp[2] + (short)rgb_spline[2]) / 2); } mask_color_active_tint(rgb_tmp, rgb_tmp, is_active); @@ -525,20 +523,20 @@ static void draw_spline_curve(const bContext *C, const int width, const int height) { - const unsigned int resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height), - BKE_mask_spline_resolution(spline, width, height)); + const uint resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height), + BKE_mask_spline_resolution(spline, width, height)); - unsigned char rgb_tmp[4]; + uchar rgb_tmp[4]; const bool is_spline_sel = (spline->flag & SELECT) && (mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0; const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0; const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0; - unsigned int tot_diff_point; + uint tot_diff_point; float(*diff_points)[2]; - unsigned int tot_feather_point; + uint tot_feather_point; float(*feather_points)[2]; diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol); @@ -801,7 +799,7 @@ void ED_mask_draw_frames( return; } - unsigned int num_lines = BLI_listbase_count(&mask_layer->splines_shapes); + uint num_lines = BLI_listbase_count(&mask_layer->splines_shapes); if (num_lines == 0) { return; } diff --git a/source/blender/editors/mask/mask_query.c b/source/blender/editors/mask/mask_query.c index 8caf5f2ed7b..6b1bb0a08e2 100644 --- a/source/blender/editors/mask/mask_query.c +++ b/source/blender/editors/mask/mask_query.c @@ -99,13 +99,13 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, for (i = 0, cur_point_eval = use_deform ? spline_eval->points_deform : spline_eval->points; i < spline_eval->tot_point; i++, cur_point_eval++) { - unsigned int tot_diff_point; + uint tot_diff_point; float *diff_points = BKE_mask_point_segment_diff( spline_eval, cur_point_eval, width, height, &tot_diff_point); if (diff_points) { int j, tot_point; - unsigned int tot_feather_point; + uint tot_feather_point; float *feather_points = NULL, *points; if (feather) { diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 3d20b58b905..b303c4c7e4e 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -190,7 +190,7 @@ void paintface_reveal(bContext *C, Object *ob, const bool select) /* Set tface seams based on edge data, uses hash table to find seam edges. */ -static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, const bool select) +static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bool select) { MPoly *mp; MLoop *ml; @@ -201,7 +201,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, BLI_bitmap *edge_tag = BLI_BITMAP_NEW(me->totedge, __func__); BLI_bitmap *poly_tag = BLI_BITMAP_NEW(me->totpoly, __func__); - if (index != (unsigned int)-1) { + if (index != (uint)-1) { /* only put face under cursor in array */ mp = &me->mpoly[index]; BKE_mesh_poly_edgebitmap_insert(edge_tag, mp, me->mloop + mp->loopstart); @@ -267,7 +267,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const bool select) { Mesh *me; - unsigned int index = (unsigned int)-1; + uint index = (uint)-1; me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) { diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 7718a07a55e..0c37a2604d9 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -479,7 +479,7 @@ static bool bm_vert_in_faces_radial(BMVert *v, BMEdge *e_radial, BMFace *f_ignor struct LinkBase { LinkNode *list; - unsigned int list_len; + uint list_len; }; static void ghash_insert_face_edge_link(GHash *gh, @@ -535,7 +535,7 @@ static void bm_face_split_by_edges_island_connect( } { - unsigned int edge_arr_holes_len; + uint edge_arr_holes_len; BMEdge **edge_arr_holes; if (BM_face_split_edgenet_connect_islands(bm, f, @@ -765,7 +765,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) BMIter liter; BMLoop *l; - unsigned int loop_stack_len; + uint loop_stack_len; BMLoop *l_best = NULL; BLI_assert(BLI_SMALLSTACK_IS_EMPTY(loop_stack)); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 373dfc811ec..fd92d864a28 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1579,7 +1579,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) float line_tol, line_tol_sq; float face_tol, face_tol_sq; int isect_kind; - unsigned int tot; + uint tot; int i; const bool use_hit_prev = true; const bool use_hit_curr = (kcd->is_drag_hold == false); @@ -2419,7 +2419,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe edge_array_len = i; #ifdef USE_NET_ISLAND_CONNECT - unsigned int edge_array_holes_len; + uint edge_array_holes_len; BMEdge **edge_array_holes; if (BM_face_split_edgenet_connect_islands(bm, f, diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index a1ea6074044..5d9923c6a7d 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -402,7 +402,7 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm) BMIter iter; BMEdge *e; - unsigned int total_tag = 0; + uint total_tag = 0; /* count tags, could be pre-calculated */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { @@ -441,8 +441,8 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm) static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *uloop_pairs) { UnorderedLoopPair *ulp; - unsigned int total_tag = MEM_allocN_len(uloop_pairs) / sizeof(UnorderedLoopPair); - unsigned int i; + uint total_tag = MEM_allocN_len(uloop_pairs) / sizeof(UnorderedLoopPair); + uint i; for (i = 0, ulp = uloop_pairs; i < total_tag; i++, ulp++) { if ((ulp->l_pair[0] && ulp->l_pair[1]) && (ulp->l_pair[0]->e != ulp->l_pair[1]->e)) { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 58e10764145..b9ac24e1d03 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -756,7 +756,7 @@ static bool edbm_add_edge_face__smooth_get(BMesh *bm) BMEdge *e; BMIter iter; - unsigned int vote_on_smooth[2] = {0, 0}; + uint vote_on_smooth[2] = {0, 0}; BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l) { @@ -6122,7 +6122,7 @@ static void sort_bmelem_flag(bContext *C, const int flag, const int action, const int reverse, - const unsigned int seed) + const uint seed) { BMEditMesh *em = BKE_editmesh_from_object(ob); @@ -6135,7 +6135,7 @@ static void sort_bmelem_flag(bContext *C, /* Just to mark protected elements. */ char *pblock[3] = {NULL, NULL, NULL}, *pb; BMElemSort *sblock[3] = {NULL, NULL, NULL}, *sb; - unsigned int *map[3] = {NULL, NULL, NULL}, *mp; + uint *map[3] = {NULL, NULL, NULL}, *mp; int totelem[3] = {0, 0, 0}; int affected[3] = {0, 0, 0}; int i, j; @@ -6312,7 +6312,7 @@ static void sort_bmelem_flag(bContext *C, } else if (action == SRT_SELECTED) { - unsigned int *tbuf[3] = {NULL, NULL, NULL}, *tb; + uint *tbuf[3] = {NULL, NULL, NULL}, *tb; if (totelem[0]) { tb = tbuf[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert tbuf"); @@ -6576,7 +6576,7 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) const int action = RNA_enum_get(op->ptr, "type"); PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements"); const bool use_reverse = RNA_boolean_get(op->ptr, "reverse"); - unsigned int seed = RNA_int_get(op->ptr, "seed"); + uint seed = RNA_int_get(op->ptr, "seed"); int elem_types = 0; if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) { diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index f44a94a63f8..0bdc9e4e6ea 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -539,7 +539,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, UvVertMap *vmap; UvMapVert *buf; MLoopUV *luv; - unsigned int a; + uint a; int totverts, i, totuv, totfaces; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); bool *winding = NULL; @@ -669,7 +669,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, return vmap; } -UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v) +UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, uint v) { return vmap->vert[v]; } @@ -832,7 +832,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, } if (do_islands) { - unsigned int *map; + uint *map; BMFace **stack; int stacksize = 0; UvElement *islandbuf; @@ -1224,7 +1224,7 @@ BMFace *EDBM_verts_mirror_get_face(BMEditMesh *em, BMFace *f) BMVert **v_mirr_arr = BLI_array_alloca(v_mirr_arr, f->len); BMLoop *l_iter, *l_first; - unsigned int i = 0; + uint i = 0; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 9b599d8df7f..a4243c13940 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -119,7 +119,7 @@ int ED_mesh_mirror_spatial_table( /** \name Mesh Topology Mirror API * \{ */ -typedef unsigned int MirrTopoHash_t; +typedef uint MirrTopoHash_t; typedef struct MirrTopoVert_t { MirrTopoHash_t hash; @@ -231,7 +231,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em, medge = me->medge; for (a = 0, med = medge; a < totedge; a++, med++) { - const unsigned int i1 = med->v1, i2 = med->v2; + const uint i1 = med->v1, i2 = med->v2; topo_hash[i1]++; topo_hash[i2]++; } @@ -257,7 +257,7 @@ void ED_mesh_mirrtopo_init(BMEditMesh *em, } else { for (a = 0, med = medge; a < totedge; a++, med++) { - const unsigned int i1 = med->v1, i2 = med->v2; + const uint i1 = med->v1, i2 = med->v2; topo_hash[i1] += topo_hash_prev[i2] * topo_pass; topo_hash[i2] += topo_hash_prev[i1] * topo_pass; tot_unique_edges += (topo_hash[i1] != topo_hash[i2]); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 6c5106d3eec..62237b46481 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1023,10 +1023,10 @@ static float *editmesh_get_mirror_uv( #endif -static unsigned int mirror_facehash(const void *ptr) +static uint mirror_facehash(const void *ptr) { const MFace *mf = ptr; - unsigned int v0, v1; + uint v0, v1; if (mf->v4) { v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4); @@ -1119,8 +1119,8 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) /* make sure v4 is not 0 if a quad */ if (mf->v4 && mirrormf.v4 == 0) { - SWAP(unsigned int, mirrormf.v1, mirrormf.v3); - SWAP(unsigned int, mirrormf.v2, mirrormf.v4); + SWAP(uint, mirrormf.v1, mirrormf.v3); + SWAP(uint, mirrormf.v2, mirrormf.v4); } hashmf = BLI_ghash_lookup(fhash, &mirrormf); @@ -1174,7 +1174,7 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, *r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.region, vc.v3d, mval); } - if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) { + if ((*r_index) == 0 || (*r_index) > (uint)me->totpoly) { return false; } @@ -1218,7 +1218,7 @@ bool ED_mesh_pick_face_vert( bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - unsigned int poly_index; + uint poly_index; Mesh *me = ob->data; BLI_assert(me && GS(me->id.name) == ID_ME); @@ -1241,7 +1241,7 @@ bool ED_mesh_pick_face_vert( MPoly *me_eval_mpoly; MLoop *me_eval_mloop; MVert *me_eval_mvert; - unsigned int me_eval_mpoly_len; + uint me_eval_mpoly_len; const int *index_mp_to_orig; me_eval_mpoly = me_eval->mpoly; @@ -1254,7 +1254,7 @@ bool ED_mesh_pick_face_vert( /* tag all verts using this face */ if (index_mp_to_orig) { - unsigned int i; + uint i; for (i = 0; i < me_eval_mpoly_len; i++) { if (index_mp_to_orig[i] == poly_index) { diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index a64674deda4..b96f225f660 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -697,7 +697,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese static MetaElem *startelem = NULL; ViewContext vc; int a, hits; - unsigned int buffer[MAXPICKBUF]; + uint buffer[MAXPICKBUF]; rcti rect; ED_view3d_viewcontext_init(C, &vc, depsgraph); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ac2958282c1..65d3196d8c3 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1738,10 +1738,10 @@ static void copy_object_set_idnew(bContext *C) * In other words, we consider each group of objects from a same item as being * the 'local group' where to check for parents. */ -static unsigned int dupliobject_hash(const void *ptr) +static uint dupliobject_hash(const void *ptr) { const DupliObject *dob = ptr; - unsigned int hash = BLI_ghashutil_ptrhash(dob->ob); + uint hash = BLI_ghashutil_ptrhash(dob->ob); if (dob->type == OB_DUPLICOLLECTION) { for (int i = 1; (i < MAX_DUPLI_RECUR) && dob->persistent_id[i] != INT_MAX; i++) { @@ -1760,10 +1760,10 @@ static unsigned int dupliobject_hash(const void *ptr) * since its a unique index and we only want to know if the group objects are from the same * dupli-group instance. */ -static unsigned int dupliobject_instancer_hash(const void *ptr) +static uint dupliobject_instancer_hash(const void *ptr) { const DupliObject *dob = ptr; - unsigned int hash = BLI_ghashutil_inthash(dob->persistent_id[0]); + uint hash = BLI_ghashutil_inthash(dob->persistent_id[0]); for (int i = 1; (i < MAX_DUPLI_RECUR) && dob->persistent_id[i] != INT_MAX; i++) { hash ^= (dob->persistent_id[i] ^ i); } diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 7d39d2546b6..481d5dfb9a5 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -234,7 +234,7 @@ static bool write_internal_bake_pixels(Image *image, ibuf->x); } else { - IMB_buffer_byte_from_float((unsigned char *)ibuf->rect, + IMB_buffer_byte_from_float((uchar *)ibuf->rect, buffer, ibuf->channels, ibuf->dither, @@ -259,7 +259,7 @@ static bool write_internal_bake_pixels(Image *image, mask_buffer); } else { - IMB_buffer_byte_from_float_mask((unsigned char *)ibuf->rect, + IMB_buffer_byte_from_float_mask((uchar *)ibuf->rect, buffer, ibuf->channels, ibuf->dither, @@ -359,7 +359,7 @@ static bool write_external_bake_pixels(const char *filepath, buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false); } - IMB_buffer_byte_from_float((unsigned char *)ibuf->rect, + IMB_buffer_byte_from_float((uchar *)ibuf->rect, buffer, ibuf->channels, ibuf->dither, diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0de2f114b94..2babf27eb61 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2148,7 +2148,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) /* Signal to modifier to recalculate. */ CorrectiveSmoothModifierData *csmd_eval = (CorrectiveSmoothModifierData *) modifier_get_evaluated(depsgraph, ob, &csmd->modifier); - csmd_eval->bind_coords_num = (unsigned int)-1; + csmd_eval->bind_coords_num = (uint)-1; /* Force modifier to run, it will call binding routine * (this has to happen outside of depsgraph evaluation). */ diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.c index 43aaecb887b..a6958c798f1 100644 --- a/source/blender/editors/object/object_random.c +++ b/source/blender/editors/object/object_random.c @@ -50,7 +50,7 @@ static bool object_rand_transverts(TransVertStore *tvs, const float offset, const float uniform, const float normal_factor, - const unsigned int seed) + const uint seed) { bool use_normal = (normal_factor != 0.0f); struct RNG *rng; @@ -100,7 +100,7 @@ static int object_rand_verts_exec(bContext *C, wmOperator *op) const float offset = RNA_float_get(op->ptr, "offset"); const float uniform = RNA_float_get(op->ptr, "uniform"); const float normal_factor = RNA_float_get(op->ptr, "normal"); - const unsigned int seed = RNA_int_get(op->ptr, "seed"); + const uint seed = RNA_int_get(op->ptr, "seed"); bool changed_multi = false; uint objects_len = 0; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 3166c9ddea1..5d821308759 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1424,7 +1424,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot) * \{ */ #if 0 -static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) +static void link_to_scene(Main *UNUSED(bmain), ushort UNUSED(nr)) { Scene *sce = (Scene *)BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1); Base *base, *nbase; diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 8a803821fe4..b2b372df055 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -653,13 +653,13 @@ static bool mesh_is_manifold_consistent(Mesh *mesh) const MLoop *mloop = mesh->mloop; char *edge_faces = (char *)MEM_callocN(mesh->totedge * sizeof(char), "remesh_manifold_check"); int *edge_vert = (int *)MEM_malloc_arrayN( - mesh->totedge, sizeof(unsigned int), "remesh_consistent_check"); + mesh->totedge, sizeof(uint), "remesh_consistent_check"); - for (unsigned int i = 0; i < mesh->totedge; i++) { + for (uint i = 0; i < mesh->totedge; i++) { edge_vert[i] = -1; } - for (unsigned int loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) { + for (uint loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) { const MLoop *loop = &mloop[loop_idx]; edge_faces[loop->e] += 1; if (edge_faces[loop->e] > 2) { @@ -679,7 +679,7 @@ static bool mesh_is_manifold_consistent(Mesh *mesh) if (is_manifold_consistent) { /* check for wire edges */ - for (unsigned int i = 0; i < mesh->totedge; i++) { + for (uint i = 0; i < mesh->totedge; i++) { if (edge_faces[i] == 0) { is_manifold_consistent = false; break; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 28bb28a0298..46245d21d5b 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1860,8 +1860,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const if (event->type == MOUSEMOVE || is_translate_init) { const ViewDepths *depths = xfd->vc.rv3d->depths; - if (depths && ((unsigned int)event->mval[0] < depths->w) && - ((unsigned int)event->mval[1] < depths->h)) { + if (depths && ((uint)event->mval[0] < depths->w) && ((uint)event->mval[1] < depths->h)) { double depth = (double)ED_view3d_depth_read_cached(&xfd->vc, event->mval); float location_world[3]; if (depth == 1.0f) { diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 442f700ad6f..5a701ef8aa8 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -151,7 +151,7 @@ typedef struct OGLRender { eImageFormatDepth color_depth; SpinLock reports_lock; - unsigned int num_scheduled_frames; + uint num_scheduled_frames; ThreadMutex task_mutex; ThreadCondition task_condition; @@ -296,7 +296,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R const short view_context = (v3d != NULL); bool draw_sky = (scene->r.alphamode == R_ADDSKY); float *rectf = NULL; - unsigned char *rect = NULL; + uchar *rect = NULL; const char *viewname = RE_GetActiveRenderView(oglrender->re); ImBuf *ibuf_result = NULL; @@ -334,9 +334,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R if (gpd) { int i; - unsigned char *gp_rect; - unsigned char *render_rect = - (unsigned char *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32; + uchar *gp_rect; + uchar *render_rect = (uchar *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32; DRW_opengl_context_enable(); GPU_offscreen_bind(oglrender->ofs, true); @@ -352,7 +351,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R ED_annotation_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ); G.f &= ~G_FLAG_RENDER_VIEWPORT; - gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect"); + gp_rect = MEM_mallocN(sizex * sizey * sizeof(uchar) * 4, "offscreen rect"); GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, gp_rect); for (i = 0; i < sizex * sizey * 4; i += 4) { @@ -414,7 +413,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R rectf = ibuf_view->rect_float; } else { - rect = (unsigned char *)ibuf_view->rect; + rect = (uchar *)ibuf_view->rect; } } else { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 1427c6ed500..fc22e3cd3e0 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -167,7 +167,7 @@ typedef struct ShaderPreview { float color[4]; int sizex, sizey; - unsigned int *pr_rect; + uint *pr_rect; int pr_method; bool own_id_copy; @@ -178,7 +178,7 @@ typedef struct ShaderPreview { typedef struct IconPreviewSize { struct IconPreviewSize *next, *prev; int sizex, sizey; - unsigned int *rect; + uint *rect; } IconPreviewSize; typedef struct IconPreview { @@ -621,14 +621,14 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty); if (rres.rectx && rres.recty) { - unsigned char *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), - "ed_preview_draw_rect"); + uchar *rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), + "ed_preview_draw_rect"); float fx = rect->xmin + offx; float fy = rect->ymin; /* material preview only needs monoscopy (view 0) */ if (re) { - RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0); + RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0); } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); @@ -1014,10 +1014,10 @@ static void shader_preview_free(void *customdata) /* ************************* icon preview ********************** */ -static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect) +static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) { struct ImBuf *ima; - unsigned int *drect, *srect; + uint *drect, *srect; float scaledx, scaledy; short ex, ey, dx, dy; @@ -1144,7 +1144,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat br->icon_imbuf = get_brush_icon(br); - memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int)); + memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(uint)); if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) { return; @@ -1193,7 +1193,7 @@ static void common_preview_startjob(void *customdata, /* exported functions */ -static void icon_preview_add_size(IconPreview *ip, unsigned int *rect, int sizex, int sizey) +static void icon_preview_add_size(IconPreview *ip, uint *rect, int sizex, int sizey) { IconPreviewSize *cur_size = ip->sizes.first, *new_size; @@ -1324,8 +1324,7 @@ static void icon_preview_free(void *customdata) MEM_freeN(ip); } -void ED_preview_icon_render( - Main *bmain, Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey) +void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, uint *rect, int sizex, int sizey) { IconPreview ip = {NULL}; short stop = false, update = false; @@ -1348,13 +1347,8 @@ void ED_preview_icon_render( BLI_freelistN(&ip.sizes); } -void ED_preview_icon_job(const bContext *C, - void *owner, - ID *id, - unsigned int *rect, - int sizex, - int sizey, - const bool delay) +void ED_preview_icon_job( + const bContext *C, void *owner, ID *id, uint *rect, int sizex, int sizey, const bool delay) { wmJob *wm_job; IconPreview *ip, *old_ip; diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index e1fa4caafbd..a0dfa54f8f5 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -506,7 +506,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - unsigned int *slot_remap; + uint *slot_remap; int index_pair[2]; int dir = RNA_enum_get(op->ptr, "direction"); @@ -531,7 +531,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - slot_remap = MEM_mallocN(sizeof(unsigned int) * ob->totcol, __func__); + slot_remap = MEM_mallocN(sizeof(uint) * ob->totcol, __func__); range_vn_u(slot_remap, ob->totcol, 0); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index f757b856dcf..ddb345ab65e 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -132,7 +132,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, float yzoom, float color[4]) { - unsigned char *uc_rect = (unsigned char *)rect; + uchar *uc_rect = (uchar *)rect; const float *f_rect = (float *)rect; int subpart_x, subpart_y, tex_w, tex_h; int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y; @@ -185,7 +185,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, NULL); } - unsigned int pos = state->pos, texco = state->texco; + uint pos = state->pos, texco = state->texco; /* optional */ /* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since @@ -650,7 +650,7 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf, /* In case GLSL failed or not usable, fallback to glaDrawPixelsAuto */ if (need_fallback) { - unsigned char *display_buffer; + uchar *display_buffer; void *cache_handle; display_buffer = IMB_display_buffer_acquire( @@ -758,7 +758,7 @@ int ED_draw_imbuf_method(ImBuf *ibuf) /* don't move to GPU_immediate_util.h because this uses user-prefs * and isn't very low level */ -void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, float zoomy) +void immDrawBorderCorners(uint pos, const rcti *border, float zoomx, float zoomy) { float delta_x = 4.0f * UI_DPI_FAC / zoomx; float delta_y = 4.0f * UI_DPI_FAC / zoomy; diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 3331f4db11b..dbc7609722c 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -41,7 +41,7 @@ * Draw horizontal shape visualizing future joining * (left as well right direction of future joining). */ -static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) +static void draw_horizontal_join_shape(ScrArea *sa, char dir, uint pos) { const float width = screen_geom_area_width(sa) - 1; const float height = screen_geom_area_height(sa) - 1; @@ -122,7 +122,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) /** * Draw vertical shape visualizing future joining (up/down direction). */ -static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) +static void draw_vertical_join_shape(ScrArea *sa, char dir, uint pos) { const float width = screen_geom_area_width(sa) - 1; const float height = screen_geom_area_height(sa) - 1; @@ -203,7 +203,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) /** * Draw join shape due to direction of joining. */ -static void draw_join_shape(ScrArea *sa, char dir, unsigned int pos) +static void draw_join_shape(ScrArea *sa, char dir, uint pos) { if (dir == 'u' || dir == 'd') { draw_vertical_join_shape(sa, dir, pos); @@ -294,7 +294,7 @@ static GPUBatch *batch_screen_edges_get(int *corner_len) /** * Draw screen area darker with arrow (visualization of future joining). */ -static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos) +static void scrarea_draw_shape_dark(ScrArea *sa, char dir, uint pos) { GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); @@ -306,7 +306,7 @@ static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos) /** * Draw screen area lighter with arrow shape ("eraser" of previous dark shape). */ -static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), unsigned int pos) +static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), uint pos) { GPU_blend_set_func(GPU_DST_COLOR, GPU_SRC_ALPHA); /* value 181 was hardly computed: 181~105 */ @@ -608,7 +608,7 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y) /** * Render the preview for a screen layout in \a screen. */ -void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, unsigned int *r_rect) +void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, uint *r_rect) { char err_out[256] = "unknown"; GPUOffScreen *offscreen = GPU_offscreen_create(size_x, size_y, 0, true, false, err_out); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index d52dc262c3f..89b83b3518a 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -54,7 +54,7 @@ #include "screen_intern.h" typedef struct ScreenshotData { - unsigned int *dumprect; + uint *dumprect; int dumpsx, dumpsy; rcti crop; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index c035863203b..04ca5770a97 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -876,12 +876,8 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups, return alpha_overlay_active; } -BLI_INLINE void draw_tri_point(unsigned int pos, - const float sel_col[4], - float pivot_col[4], - float *co, - float width, - bool selected) +BLI_INLINE void draw_tri_point( + uint pos, const float sel_col[4], float pivot_col[4], float *co, float width, bool selected) { immUniformColor4fv(selected ? sel_col : pivot_col); @@ -910,12 +906,8 @@ BLI_INLINE void draw_tri_point(unsigned int pos, immEnd(); } -BLI_INLINE void draw_rect_point(unsigned int pos, - const float sel_col[4], - float handle_col[4], - float *co, - float width, - bool selected) +BLI_INLINE void draw_rect_point( + uint pos, const float sel_col[4], float handle_col[4], float *co, float width, bool selected) { immUniformColor4fv(selected ? sel_col : handle_col); @@ -935,7 +927,7 @@ BLI_INLINE void draw_rect_point(unsigned int pos, imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy); } -BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], BezTriple *bez) +BLI_INLINE void draw_bezier_handle_lines(uint pos, float sel_col[4], BezTriple *bez) { immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); GPU_line_width(3.0f); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 73c099c9407..3485941d3df 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -80,11 +80,11 @@ typedef struct BrushPainterCache { ImBuf *ibuf; ImBuf *texibuf; - unsigned short *curve_mask; - unsigned short *tex_mask; - unsigned short *tex_mask_old; - unsigned int tex_mask_old_w; - unsigned int tex_mask_old_h; + ushort *curve_mask; + ushort *tex_mask; + ushort *tex_mask_old; + uint tex_mask_old_w; + uint tex_mask_old_h; int image_size[2]; } BrushPainterCache; @@ -228,7 +228,7 @@ static void brush_imbuf_tex_co(rctf *mapping, int x, int y, float texco[3]) } /* create a mask with the mask texture */ -static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size) +static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size) { Scene *scene = painter->scene; Brush *brush = painter->brush; @@ -236,10 +236,10 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const struct ImagePool *pool = painter->pool; float texco[3]; - unsigned short *mask, *m; + ushort *mask, *m; int x, y, thread = 0; - mask = MEM_mallocN(sizeof(unsigned short) * size * size, "brush_painter_mask"); + mask = MEM_mallocN(sizeof(ushort) * size * size, "brush_painter_mask"); m = mask; for (y = 0; y < size; y++) { @@ -247,7 +247,7 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const float res; brush_imbuf_tex_co(&mask_mapping, x, y, texco); res = BKE_brush_sample_masktex(scene, brush, texco, thread, pool); - *m = (unsigned short)(65535.0f * res); + *m = (ushort)(65535.0f * res); } } @@ -257,7 +257,7 @@ static unsigned short *brush_painter_mask_ibuf_new(BrushPainter *painter, const /* update rectangular section of the brush image */ static void brush_painter_mask_imbuf_update(BrushPainter *painter, ImagePaintTile *tile, - unsigned short *tex_mask_old, + ushort *tex_mask_old, int origx, int origy, int w, @@ -271,14 +271,14 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter, BrushPainterCache *cache = &tile->cache; rctf tex_mapping = painter->mask_mapping; struct ImagePool *pool = painter->pool; - unsigned short res; + ushort res; bool use_texture_old = (tex_mask_old != NULL); int x, y, thread = 0; - unsigned short *tex_mask = cache->tex_mask; - unsigned short *tex_mask_cur = cache->tex_mask_old; + ushort *tex_mask = cache->tex_mask; + ushort *tex_mask_cur = cache->tex_mask_old; /* fill pixels */ for (y = origy; y < h; y++) { @@ -287,13 +287,12 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter, float texco[3]; /* handle byte pixel */ - unsigned short *b = tex_mask + (y * diameter + x); - unsigned short *t = tex_mask_cur + (y * diameter + x); + ushort *b = tex_mask + (y * diameter + x); + ushort *t = tex_mask_cur + (y * diameter + x); if (!use_texture_old) { brush_imbuf_tex_co(&tex_mapping, x, y, texco); - res = (unsigned short)(65535.0f * - BKE_brush_sample_masktex(scene, brush, texco, thread, pool)); + res = (ushort)(65535.0f * BKE_brush_sample_masktex(scene, brush, texco, thread, pool)); } /* read from old texture buffer */ @@ -320,19 +319,17 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter, const int diameter) { BrushPainterCache *cache = &tile->cache; - unsigned short *tex_mask_old; + ushort *tex_mask_old; int destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; /* create brush image buffer if it didn't exist yet */ if (!cache->tex_mask) { - cache->tex_mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter, - "brush_painter_mask"); + cache->tex_mask = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask"); } /* create new texture image buffer with coordinates relative to old */ tex_mask_old = cache->tex_mask_old; - cache->tex_mask_old = MEM_mallocN(sizeof(unsigned short) * diameter * diameter, - "brush_painter_mask"); + cache->tex_mask_old = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask"); if (tex_mask_old) { ImBuf maskibuf; @@ -393,18 +390,18 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter, } /* create a mask with the falloff strength */ -static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter, - int diameter, - float radius, - const float pos[2]) +static ushort *brush_painter_curve_mask_new(BrushPainter *painter, + int diameter, + float radius, + const float pos[2]) { Brush *brush = painter->brush; int offset = (int)floorf(diameter / 2.0f); - unsigned short *mask, *m; + ushort *mask, *m; - mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter, "brush_painter_mask"); + mask = MEM_mallocN(sizeof(ushort) * diameter * diameter, "brush_painter_mask"); m = mask; int aa_samples = 1.0f / (radius * 0.20f); @@ -458,7 +455,7 @@ static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter, total_samples += curve * hardness_factor; } } - *m = (unsigned short)(total_samples * norm_factor); + *m = (ushort)(total_samples * norm_factor); } } @@ -528,7 +525,7 @@ static ImBuf *brush_painter_imbuf_new( } else { /* write to byte pixel */ - unsigned char *dst = (unsigned char *)ibuf->rect + (y * size + x) * 4; + uchar *dst = (uchar *)ibuf->rect + (y * size + x) * 4; rgb_float_to_uchar(dst, rgba); dst[3] = unit_float_to_uchar_clamp(rgba[3]); @@ -624,16 +621,16 @@ static void brush_painter_imbuf_update(BrushPainter *painter, bf[3] = rgba[3]; } else { - unsigned char crgba[4]; + uchar crgba[4]; /* handle byte pixel */ - unsigned char *b = (unsigned char *)ibuf->rect + (y * ibuf->x + x) * 4; - unsigned char *t = (unsigned char *)texibuf->rect + (y * texibuf->x + x) * 4; + uchar *b = (uchar *)ibuf->rect + (y * ibuf->x + x) * 4; + uchar *t = (uchar *)texibuf->rect + (y * texibuf->x + x) * 4; /* read from old texture buffer */ if (use_texture_old) { - unsigned char *ot = (unsigned char *)oldtexibuf->rect + - ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4; + uchar *ot = (uchar *)oldtexibuf->rect + + ((y - origy + yt) * oldtexibuf->x + (x - origx + xt)) * 4; crgba[0] = ot[0]; crgba[1] = ot[1]; crgba[2] = ot[2]; @@ -975,7 +972,7 @@ static void paint_2d_ibuf_rgb_get(ImBuf *ibuf, int x, int y, float r_rgb[4]) copy_v4_v4(r_rgb, rrgbf); } else { - unsigned char *rrgb = (unsigned char *)ibuf->rect + (ibuf->x * y + x) * 4; + uchar *rrgb = (uchar *)ibuf->rect + (ibuf->x * y + x) * 4; straight_uchar_to_premul_float(r_rgb, rrgb); } } @@ -1001,8 +998,8 @@ static void paint_2d_ibuf_rgb_set( rrgbf[3] = rgb[3]; } else { - unsigned char straight[4]; - unsigned char *rrgb = (unsigned char *)ibuf->rect + (ibuf->x * y + x) * 4; + uchar straight[4]; + uchar *rrgb = (uchar *)ibuf->rect + (ibuf->x * y + x) * 4; premul_float_to_straight_uchar(straight, rgb); rrgb[0] = straight[0]; @@ -1329,7 +1326,7 @@ static void paint_2d_do_making_brush(ImagePaintState *s, for (int ty = tiley; ty <= tileh; ty++) { for (int tx = tilex; tx <= tilew; tx++) { /* retrieve original pixels + mask from undo buffer */ - unsigned short *mask; + ushort *mask; int origx = region->destx - tx * ED_IMAGE_UNDO_TILE_SIZE; int origy = region->desty - ty * ED_IMAGE_UNDO_TILE_SIZE; @@ -1829,7 +1826,7 @@ static void paint_2d_fill_add_pixel_byte(const int x_px, if (!BLI_BITMAP_TEST(touched, coordinate)) { float color_f[4]; - unsigned char *color_b = (unsigned char *)(ibuf->rect + coordinate); + uchar *color_b = (uchar *)(ibuf->rect + coordinate); rgba_uchar_to_float(color_f, color_b); straight_to_premul_v4(color_f); @@ -1895,7 +1892,7 @@ void paint_2d_bucket_fill(const bContext *C, ImBuf *ibuf; int x_px, y_px; - unsigned int color_b; + uint color_b; float color_f[4]; float strength = br ? BKE_brush_alpha_get(s->scene, br) : 1.0f; @@ -1935,7 +1932,7 @@ void paint_2d_bucket_fill(const bContext *C, * be in gamma space. strictly speaking this is not correct, but blender does not paint * byte images in linear space */ if (!do_float) { - linearrgb_to_srgb_uchar3((unsigned char *)&color_b, color); + linearrgb_to_srgb_uchar3((uchar *)&color_b, color); *(((char *)&color_b) + 3) = strength * 255; } else { @@ -1959,9 +1956,9 @@ void paint_2d_bucket_fill(const bContext *C, else { for (x_px = 0; x_px < ibuf->x; x_px++) { for (y_px = 0; y_px < ibuf->y; y_px++) { - blend_color_mix_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)&color_b); + blend_color_mix_byte((uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (uchar *)&color_b); } } } @@ -2000,7 +1997,7 @@ void paint_2d_bucket_fill(const bContext *C, } else { int pixel_color_b = *(ibuf->rect + coordinate); - rgba_uchar_to_float(pixel_color, (unsigned char *)&pixel_color_b); + rgba_uchar_to_float(pixel_color, (uchar *)&pixel_color_b); straight_to_premul_v4(pixel_color); } @@ -2055,9 +2052,9 @@ void paint_2d_bucket_fill(const bContext *C, while (!BLI_stack_is_empty(stack)) { BLI_stack_pop(stack, &coordinate); - IMB_blend_color_byte((unsigned char *)(ibuf->rect + coordinate), - (unsigned char *)(ibuf->rect + coordinate), - (unsigned char *)&color_b, + IMB_blend_color_byte((uchar *)(ibuf->rect + coordinate), + (uchar *)(ibuf->rect + coordinate), + (uchar *)&color_b, br->blend); /* reconstruct the coordinates here */ @@ -2117,7 +2114,7 @@ void paint_2d_gradient_fill( ImBuf *ibuf; int x_px, y_px; - unsigned int color_b; + uint color_b; float color_f[4]; float image_init[2], image_final[2]; float tangent[2]; @@ -2212,11 +2209,11 @@ void paint_2d_gradient_fill( BKE_colorband_evaluate(br->gradient, f, color_f); linearrgb_to_srgb_v3_v3(color_f, color_f); - rgba_float_to_uchar((unsigned char *)&color_b, color_f); - ((unsigned char *)&color_b)[3] *= brush_alpha; - IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)&color_b, + rgba_float_to_uchar((uchar *)&color_b, color_f); + ((uchar *)&color_b)[3] *= brush_alpha; + IMB_blend_color_byte((uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (uchar *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (uchar *)&color_b, br->blend); } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index c56ce8fd183..6494e53e182 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -112,7 +112,7 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr); /* Defines and Structs */ /* unit_float_to_uchar_clamp as inline function */ -BLI_INLINE unsigned char f_to_char(const float val) +BLI_INLINE uchar f_to_char(const float val) { return unit_float_to_uchar_clamp(val); } @@ -206,7 +206,7 @@ typedef struct ProjPaintImage { volatile void **undoRect; /** The mask accumulation must happen on canvas, not on space screen bucket. * Here we store the mask rectangle. */ - unsigned short **maskRect; + ushort **maskRect; /** Store flag to enforce validation of undo rectangle. */ bool **valid; bool touch; @@ -279,7 +279,7 @@ typedef struct ProjPaintState { /** bucketRect aligned array linkList of faces overlapping each bucket. */ LinkNode **bucketFaces; /** store if the bucks have been initialized. */ - unsigned char *bucketFlags; + uchar *bucketFlags; /** store options per vert, now only store if the vert is pointing away from the view. */ char *vertFlags; @@ -443,13 +443,13 @@ typedef union pixelPointer { /** float buffer. */ float *f_pt; /** 2 ways to access a char buffer. */ - unsigned int *uint_pt; - unsigned char *ch_pt; + uint *uint_pt; + uchar *ch_pt; } PixelPointer; typedef union pixelStore { - unsigned char ch[4]; - unsigned int uint; + uchar ch[4]; + uint uint; float f[4]; } PixelStore; @@ -461,17 +461,17 @@ typedef struct ProjPixel { short x_px, y_px; /** if anyone wants to paint onto more than 65535 images they can bite me. */ - unsigned short image_index; - unsigned char bb_cell_index; + ushort image_index; + uchar bb_cell_index; /* for various reasons we may want to mask out painting onto this pixel */ - unsigned short mask; + ushort mask; /* Only used when the airbrush is disabled. * Store the max mask value to avoid painting over an area with a lower opacity * with an advantage that we can avoid touching the pixel at all, if the * new mask value is lower then mask_accum */ - unsigned short *mask_accum; + ushort *mask_accum; /* horrible hack, store tile valid flag pointer here to re-validate tiles * used for anchored and drag-dot strokes */ @@ -491,7 +491,7 @@ typedef struct ProjPixelClone { typedef struct { SpinLock *lock; bool masked; - unsigned short tile_width; + ushort tile_width; ImBuf **tmpibuf; ProjPaintImage *pjima; } TileInfo; @@ -717,11 +717,8 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa /* Set the top-most face color that the screen space coord 'pt' touches * (or return 0 if none touch) */ -static bool project_paint_PickColor(const ProjPaintState *ps, - const float pt[2], - float *rgba_fp, - unsigned char *rgba, - const bool interp) +static bool project_paint_PickColor( + const ProjPaintState *ps, const float pt[2], float *rgba_fp, uchar *rgba, const bool interp) { const MLoopTri *lt; const float *lt_tri_uv[3]; @@ -774,7 +771,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, bilinear_interpolation_color_wrap(ibuf, rgba, NULL, x, y); } else { - unsigned char rgba_tmp[4]; + uchar rgba_tmp[4]; bilinear_interpolation_color_wrap(ibuf, rgba_tmp, NULL, x, y); straight_uchar_to_premul_float(rgba_fp, rgba_tmp); } @@ -795,8 +792,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, premul_float_to_straight_uchar(rgba, rgba_tmp_fp); } else { - *((unsigned int *)rgba) = *(unsigned int *)(((char *)ibuf->rect) + - ((xi + yi * ibuf->x) * 4)); + *((uint *)rgba) = *(uint *)(((char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4)); } } @@ -805,7 +801,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, copy_v4_v4(rgba_fp, (ibuf->rect_float + ((xi + yi * ibuf->x) * 4))); } else { - unsigned char *tmp_ch = ((unsigned char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4); + uchar *tmp_ch = ((uchar *)ibuf->rect) + ((xi + yi * ibuf->x) * 4); straight_uchar_to_premul_float(rgba_fp, tmp_ch); } } @@ -1150,8 +1146,8 @@ static bool check_seam(const ProjPaintState *ps, const MLoopTri *orig_lt = &ps->mlooptri_eval[orig_face]; const float *orig_lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, orig_lt)}; /* vert indices from face vert order indices */ - const unsigned int i1 = ps->mloop_eval[orig_lt->tri[orig_i1_fidx]].v; - const unsigned int i2 = ps->mloop_eval[orig_lt->tri[orig_i2_fidx]].v; + const uint i1 = ps->mloop_eval[orig_lt->tri[orig_i1_fidx]].v; + const uint i2 = ps->mloop_eval[orig_lt->tri[orig_i2_fidx]].v; LinkNode *node; /* index in face */ int i1_fidx = -1, i2_fidx = -1; @@ -1641,7 +1637,7 @@ static float screen_px_line_point_factor_v2_persp(const ProjPaintState *ps, static void project_face_pixel(const float *lt_tri_uv[3], ImBuf *ibuf_other, const float w[3], - unsigned char rgba_ub[4], + uchar rgba_ub[4], float rgba_f[4]) { float uv_other[2], x, y; @@ -1677,7 +1673,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, const float *lt_other_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt_other)}; /* BKE_image_acquire_ibuf - TODO - this may be slow */ - unsigned char rgba_ub[4]; + uchar rgba_ub[4]; float rgba_f[4]; project_face_pixel(lt_other_tri_uv, ibuf_other, w, rgba_ub, rgba_f); @@ -1937,8 +1933,8 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps, zero_v4(projPixel->newColor.f); } else { - projPixel->pixel.ch_pt = (unsigned char *)(ibuf->rect + (x_px + y_px * ibuf->x)); - projPixel->origColor.uint_pt = (unsigned int *)projima->undoRect[tile_index] + tile_offset; + projPixel->pixel.ch_pt = (uchar *)(ibuf->rect + (x_px + y_px * ibuf->x)); + projPixel->origColor.uint_pt = (uint *)projima->undoRect[tile_index] + tile_offset; projPixel->newColor.uint = 0; } @@ -1952,7 +1948,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps, projPixel->x_px = x_px; projPixel->y_px = y_px; - projPixel->mask = (unsigned short)(mask * 65535); + projPixel->mask = (ushort)(mask * 65535); if (ps->do_masking) { projPixel->mask_accum = projima->maskRect[tile_index] + tile_offset; } @@ -1984,7 +1980,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps, lt_other_tri_uv, ibuf_other, w, NULL, ((ProjPixelClone *)projPixel)->clonepx.f); } else { /* from char to float */ - unsigned char rgba_ub[4]; + uchar rgba_ub[4]; float rgba[4]; project_face_pixel(lt_other_tri_uv, ibuf_other, w, rgba_ub, NULL); if (ps->use_colormanagement) { @@ -4844,15 +4840,15 @@ typedef struct ProjectHandle { static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float mask) { - const unsigned char *clone_pt = ((ProjPixelClone *)projPixel)->clonepx.ch; + const uchar *clone_pt = ((ProjPixelClone *)projPixel)->clonepx.ch; if (clone_pt[3]) { - unsigned char clone_rgba[4]; + uchar clone_rgba[4]; clone_rgba[0] = clone_pt[0]; clone_rgba[1] = clone_pt[1]; clone_rgba[2] = clone_pt[2]; - clone_rgba[3] = (unsigned char)(clone_pt[3] * mask); + clone_rgba[3] = (uchar)(clone_pt[3] * mask); if (ps->do_masking) { IMB_blend_color_byte( @@ -4895,7 +4891,7 @@ static void do_projectpaint_smear(ProjPaintState *ps, LinkNode **smearPixels, const float co[2]) { - unsigned char rgba_ub[4]; + uchar rgba_ub[4]; if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0) { return; @@ -5016,7 +5012,7 @@ static void do_projectpaint_soften(ProjPaintState *ps, } if (LIKELY(accum_tot != 0)) { - unsigned char *rgba_ub = projPixel->newColor.ch; + uchar *rgba_ub = projPixel->newColor.ch; mul_v4_fl(rgba, 1.0f / (float)accum_tot); @@ -5061,7 +5057,7 @@ static void do_projectpaint_draw(ProjPaintState *ps, float v) { float rgb[3]; - unsigned char rgba_ub[4]; + uchar rgba_ub[4]; if (ps->is_texbrush) { mul_v3_v3v3(rgb, texrgb, ps->paint_color_linear); @@ -5119,7 +5115,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, static void do_projectpaint_mask(ProjPaintState *ps, ProjPixel *projPixel, float mask) { - unsigned char rgba_ub[4]; + uchar rgba_ub[4]; rgba_ub[0] = rgba_ub[1] = rgba_ub[2] = ps->stencil_value * 255.0f; rgba_ub[3] = f_to_char(mask); @@ -5204,7 +5200,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), /* for smear only */ float pos_ofs[2] = {0}; float co[2]; - unsigned short mask_short; + ushort mask_short; const float brush_alpha = BKE_brush_alpha_get(ps->scene, brush); const float brush_radius = ps->brush_size; /* avoid a square root with every dist comparison */ @@ -5468,7 +5464,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), } mask = min_ff(mask, 65535.0f); - mask_short = (unsigned short)mask; + mask_short = (ushort)mask; if (mask_short > *projPixel->mask_accum) { *projPixel->mask_accum = mask_short; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index e67d43d4571..60b4a2f8e0c 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -294,12 +294,8 @@ static void imapaint_tri_weights(float matrix[4][4], } /* compute uv coordinates of mouse in face */ -static void imapaint_pick_uv(Mesh *me_eval, - Scene *scene, - Object *ob_eval, - unsigned int faceindex, - const int xy[2], - float uv[2]) +static void imapaint_pick_uv( + Mesh *me_eval, Scene *scene, Object *ob_eval, uint faceindex, const int xy[2], float uv[2]) { int i, findex; float p[2], w[3], absw, minabsw; @@ -376,10 +372,7 @@ static void imapaint_pick_uv(Mesh *me_eval, } /* returns 0 if not found, otherwise 1 */ -static int imapaint_pick_face(ViewContext *vc, - const int mval[2], - unsigned int *r_index, - unsigned int totpoly) +static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly) { if (totpoly == 0) { return 0; @@ -389,7 +382,7 @@ static int imapaint_pick_face(ViewContext *vc, ED_view3d_select_id_validate(vc); *r_index = DRW_select_buffer_sample_point(vc->depsgraph, vc->region, vc->v3d, mval); - if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) { + if ((*r_index) == 0 || (*r_index) > (uint)totpoly) { return 0; } @@ -464,8 +457,8 @@ void paint_sample_color( Palette *palette = BKE_paint_palette(paint); PaletteColor *color = NULL; Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C)); - unsigned int col; - const unsigned char *cp; + uint col; + const uchar *cp; CLAMP(x, 0, region->winx); CLAMP(y, 0, region->winy); @@ -497,8 +490,8 @@ void paint_sample_color( ViewContext vc; const int mval[2] = {x, y}; - unsigned int faceindex; - unsigned int totpoly = me->totpoly; + uint faceindex; + uint totpoly = me->totpoly; if (CustomData_has_layer(&me_eval->ldata, CD_MLOOPUV)) { ED_view3d_viewcontext_init(C, &vc, depsgraph); @@ -563,7 +556,7 @@ void paint_sample_color( } } else { - unsigned char rgba[4]; + uchar rgba[4]; bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v); if (use_palette) { rgb_uchar_to_float(color->rgb, rgba); @@ -598,7 +591,7 @@ void paint_sample_color( x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); glReadBuffer(GL_BACK); } - cp = (unsigned char *)&col; + cp = (uchar *)&col; if (use_palette) { rgb_uchar_to_float(color->rgb, cp); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index 6e706c907dd..addf7e9f868 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -109,7 +109,7 @@ static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); - unsigned int paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false); + uint paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false); if (vertex_color_set(obact, paintcol)) { WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index f364c174f0f..0a5814be626 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -70,8 +70,8 @@ typedef struct UvAdjacencyElement { } UvAdjacencyElement; typedef struct UvEdge { - unsigned int uv1; - unsigned int uv2; + uint uv1; + uint uv2; /* general use flag * (Used to check if edge is boundary here, and propagates to adjacency elements) */ char flag; @@ -315,7 +315,7 @@ static void uv_sculpt_stroke_apply(bContext *C, Scene *scene = CTX_data_scene(C); ARegion *region = CTX_wm_region(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - unsigned int tool; + uint tool; UvSculptData *sculptdata = (UvSculptData *)op->customdata; SpaceImage *sima; int invert; @@ -386,7 +386,7 @@ static void uv_sculpt_stroke_apply(bContext *C, * Smooth Tool */ else if (tool == UV_SCULPT_TOOL_RELAX) { - unsigned int method = toolsettings->uv_relax_method; + uint method = toolsettings->uv_relax_method; if (method == UV_SCULPT_TOOL_RELAX_HC) { HC_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio); } @@ -464,7 +464,7 @@ static int uv_element_offset_from_face_get( return element - map->buf; } -static unsigned int uv_edge_hash(const void *key) +static uint uv_edge_hash(const void *key) { const UvEdge *edge = key; return (BLI_ghashutil_uinthash(edge->uv2) + BLI_ghashutil_uinthash(edge->uv1)); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 75eeb125609..7abbd2966a3 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -141,9 +141,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region bDopeSheet *ads = &saction->ads; AnimData *adt = NULL; - unsigned char col1[4], col2[4]; - unsigned char col1a[4], col2a[4]; - unsigned char col1b[4], col2b[4]; + uchar col1[4], col2[4]; + uchar col1a[4], col2a[4]; + uchar col1b[4], col2b[4]; const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS); @@ -212,10 +212,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region bActionGroup *agrp = ale->data; if (show_group_colors && agrp->customCol) { if (sel) { - immUniformColor3ubvAlpha((unsigned char *)agrp->cs.select, col1a[3]); + immUniformColor3ubvAlpha((uchar *)agrp->cs.select, col1a[3]); } else { - immUniformColor3ubvAlpha((unsigned char *)agrp->cs.solid, col2a[3]); + immUniformColor3ubvAlpha((uchar *)agrp->cs.solid, col2a[3]); } } else { @@ -226,8 +226,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region case ANIMTYPE_FCURVE: { FCurve *fcu = ale->data; if (show_group_colors && fcu->grp && fcu->grp->customCol) { - immUniformColor3ubvAlpha((unsigned char *)fcu->grp->cs.active, - sel ? col1[3] : col2[3]); + immUniformColor3ubvAlpha((uchar *)fcu->grp->cs.active, sel ? col1[3] : col2[3]); } else { immUniformColor4ubv(sel ? col1 : col2); @@ -243,8 +242,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax); } else if (ac->datatype == ANIMCONT_GPENCIL) { - unsigned char *color; - unsigned char gpl_col[4]; + uchar *color; + uchar gpl_col[4]; if ((show_group_colors) && (ale->type == ANIMTYPE_GPLAYER)) { bGPDlayer *gpl = (bGPDlayer *)ale->data; rgb_float_to_uchar(gpl_col, gpl->color); @@ -266,7 +265,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region else if (ac->datatype == ANIMCONT_MASK) { /* TODO --- this is a copy of gpencil */ /* frames less than one get less saturated background */ - unsigned char *color = sel ? col1 : col2; + uchar *color = sel ? col1 : col2; immUniformColor4ubv(color); immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax); diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index eba0f33d6cc..aef6781ec47 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -68,7 +68,7 @@ static void track_channel_color(MovieTrackingTrack *track, float default_color[3 } static void draw_keyframe_shape( - float x, float y, bool sel, float alpha, unsigned int pos_id, unsigned int color_id) + float x, float y, bool sel, float alpha, uint pos_id, uint color_id) { float color[4] = {0.91f, 0.91f, 0.91f, alpha}; if (sel) { @@ -79,7 +79,7 @@ static void draw_keyframe_shape( immVertex2f(pos_id, x, y); } -static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, unsigned int pos_id) +static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, uint pos_id) { View2D *v2d = ®ion->v2d; MovieTracking *tracking = &clip->tracking; diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 2a6cf4d5a55..a1652ca0e88 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -66,8 +66,7 @@ /*********************** main area drawing *************************/ -static void draw_keyframe( - int frame, int cfra, int sfra, float framelen, int width, unsigned int pos) +static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int width, uint pos) { int height = (frame == cfra) ? 22 : 10; int x = (frame - sfra) * framelen; @@ -592,7 +591,7 @@ static void draw_marker_outline(SpaceClip *sc, const float marker_pos[2], int width, int height, - unsigned int position) + uint position) { int tiny = sc->flag & SC_SHOW_TINY_MARKER; bool show_search = false; @@ -895,7 +894,7 @@ static float get_shortest_pattern_side(MovieTrackingMarker *marker) } static void draw_marker_slide_square( - float x, float y, float dx, float dy, int outline, const float px[2], unsigned int pos) + float x, float y, float dx, float dy, int outline, const float px[2], uint pos) { float tdx, tdy; @@ -911,7 +910,7 @@ static void draw_marker_slide_square( } static void draw_marker_slide_triangle( - float x, float y, float dx, float dy, int outline, const float px[2], unsigned int pos) + float x, float y, float dx, float dy, int outline, const float px[2], uint pos) { float tdx, tdy; @@ -939,7 +938,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, int act, int width, int height, - unsigned int pos) + uint pos) { float dx, dy, patdx, patdy, searchdx, searchdy; int tiny = sc->flag & SC_SHOW_TINY_MARKER; @@ -1056,7 +1055,7 @@ static void draw_marker_texts(SpaceClip *sc, UI_FontThemeColor(fontid, TH_ACT_MARKER); } else { - unsigned char color[4]; + uchar color[4]; UI_GetThemeColorShade4ubv(TH_DIS_MARKER, 128, color); BLF_color4ubv(fontid, color); } @@ -1191,7 +1190,7 @@ static void draw_plane_marker_image(Scene *scene, ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); if (ibuf) { - unsigned char *display_buffer; + uchar *display_buffer; void *cache_handle; if (image->flag & IMA_VIEW_AS_RENDER) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 6336f1bff3a..62d4a6ae4f0 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -282,7 +282,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], flo if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { const float *fp; - unsigned char *cp; + uchar *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -294,7 +294,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], flo ret = true; } else if (ibuf->rect) { - cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + cp = (uchar *)(ibuf->rect + y * ibuf->x + x); rgb_uchar_to_float(r_col, cp); IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); ret = true; @@ -744,7 +744,7 @@ static bool check_prefetch_break(void) } /* read file for specified frame number to the memory */ -static unsigned char *prefetch_read_file_to_memory( +static uchar *prefetch_read_file_to_memory( MovieClip *clip, int current_frame, short render_size, short render_flag, size_t *r_size) { MovieClipUser user = {0}; @@ -766,7 +766,7 @@ static unsigned char *prefetch_read_file_to_memory( return NULL; } - unsigned char *mem = MEM_mallocN(size, "movieclip prefetch memory file"); + uchar *mem = MEM_mallocN(size, "movieclip prefetch memory file"); if (mem == NULL) { close(file); return NULL; @@ -822,12 +822,12 @@ static int prefetch_find_uncached_frame(MovieClip *clip, } /* get memory buffer for first uncached frame within prefetch frame range */ -static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, - MovieClip *clip, - size_t *r_size, - int *r_current_frame) +static uchar *prefetch_thread_next_frame(PrefetchQueue *queue, + MovieClip *clip, + size_t *r_size, + int *r_current_frame) { - unsigned char *mem = NULL; + uchar *mem = NULL; BLI_spin_lock(&queue->spin); if (!*queue->stop && !check_prefetch_break() && @@ -888,7 +888,7 @@ static void prefetch_task_func(TaskPool *__restrict pool, void *task_data, int U { PrefetchQueue *queue = (PrefetchQueue *)BLI_task_pool_userdata(pool); MovieClip *clip = (MovieClip *)task_data; - unsigned char *mem; + uchar *mem; size_t size; int current_frame; diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 7f3d3f3d651..dc212741e6b 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -52,7 +52,7 @@ typedef struct TrackMotionCurveUserData { MovieTrackingTrack *act_track; bool sel; float xscale, yscale, hsize; - unsigned int pos; + uint pos; } TrackMotionCurveUserData; static void tracking_segment_point_cb(void *userdata, @@ -159,7 +159,7 @@ static void tracking_segment_knot_cb(void *userdata, } } -static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, unsigned int pos) +static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, uint pos) { MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; @@ -215,7 +215,7 @@ static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, unsi } } -static void draw_frame_curves(SpaceClip *sc, unsigned int pos) +static void draw_frame_curves(SpaceClip *sc, uint pos) { MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 4e5c6513695..79050fb4797 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1313,12 +1313,12 @@ typedef struct ProxyThread { int *build_undistort_sizes, build_undistort_count; } ProxyThread; -static unsigned char *proxy_thread_next_frame(ProxyQueue *queue, - MovieClip *clip, - size_t *r_size, - int *r_cfra) +static uchar *proxy_thread_next_frame(ProxyQueue *queue, + MovieClip *clip, + size_t *r_size, + int *r_cfra) { - unsigned char *mem = NULL; + uchar *mem = NULL; BLI_spin_lock(&queue->spin); if (!*queue->stop && queue->cfra <= queue->efra) { @@ -1371,7 +1371,7 @@ static void proxy_task_func(TaskPool *__restrict pool, void *task_data, int UNUS { ProxyThread *data = (ProxyThread *)task_data; ProxyQueue *queue = (ProxyQueue *)BLI_task_pool_userdata(pool); - unsigned char *mem; + uchar *mem; size_t size; int cfra; diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 5f5aced292d..226e7ae6b22 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -448,7 +448,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) const int step = (layout->tile_w + 2 * layout->tile_border_x); - unsigned int vertex_len = 0; + uint vertex_len = 0; int sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { sx += step; @@ -457,7 +457,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) if (vertex_len > 0) { int v1[2], v2[2]; - unsigned char col_hi[3], col_lo[3]; + uchar col_hi[3], col_lo[3]; UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi); UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo); @@ -685,7 +685,7 @@ void file_draw_list(const bContext *C, ARegion *region) bool is_icon; eFontStyle_Align align; bool do_drag; - unsigned char text_col[4]; + uchar text_col[4]; const bool draw_columnheader = (params->display == FILE_VERTICALDISPLAY); const float thumb_icon_aspect = MIN2(64.0f / (float)(params->thumbnail_size), 1.0f); @@ -753,7 +753,7 @@ void file_draw_list(const bContext *C, ARegion *region) UI_GetThemeColor4ubv(TH_TEXT, text_col); for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { - unsigned int file_selflag; + uint file_selflag; char path[FILE_MAX_LIBEXTRA]; int padx = 0.1f * UI_UNIT_X; int icon_ofs = 0; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 5258892d55d..cb574e35422 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -103,7 +103,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, return sel; } -static void file_deselect_all(SpaceFile *sfile, unsigned int flag) +static void file_deselect_all(SpaceFile *sfile, uint flag) { FileSelection sel; sel.first = 0; @@ -2494,7 +2494,7 @@ static void filenum_newname(char *name, size_t name_size, int add) char head[FILE_MAXFILE], tail[FILE_MAXFILE]; char name_temp[FILE_MAXFILE]; int pic; - unsigned short digits; + ushort digits; pic = BLI_stringdec(name, head, tail, &digits); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 1396c0a2f69..126430986a5 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -264,7 +264,7 @@ enum { typedef struct FileListEntryPreview { char path[FILE_MAX]; - unsigned int flags; + uint flags; int index; ImBuf *img; } FileListEntryPreview; @@ -2325,16 +2325,16 @@ int filelist_empty(struct FileList *filelist) return (filelist->filelist.nbr_entries == 0); } -unsigned int filelist_entry_select_set(const FileList *filelist, - const FileDirEntry *entry, - FileSelType select, - unsigned int flag, - FileCheckType check) +uint filelist_entry_select_set(const FileList *filelist, + const FileDirEntry *entry, + FileSelType select, + uint flag, + FileCheckType check) { /* Default NULL pointer if not found is fine here! */ void **es_p = BLI_ghash_lookup_p(filelist->selection_state, entry->uuid); - unsigned int entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0; - const unsigned int org_entry_flag = entry_flag; + uint entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0; + const uint org_entry_flag = entry_flag; BLI_assert(entry); BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL)); @@ -2373,11 +2373,8 @@ unsigned int filelist_entry_select_set(const FileList *filelist, return entry_flag; } -void filelist_entry_select_index_set(FileList *filelist, - const int index, - FileSelType select, - unsigned int flag, - FileCheckType check) +void filelist_entry_select_index_set( + FileList *filelist, const int index, FileSelType select, uint flag, FileCheckType check) { FileDirEntry *entry = filelist_file(filelist, index); @@ -2386,11 +2383,8 @@ void filelist_entry_select_index_set(FileList *filelist, } } -void filelist_entries_select_index_range_set(FileList *filelist, - FileSelection *sel, - FileSelType select, - unsigned int flag, - FileCheckType check) +void filelist_entries_select_index_range_set( + FileList *filelist, FileSelection *sel, FileSelType select, uint flag, FileCheckType check) { /* select all valid files between first and last indicated */ if ((sel->first >= 0) && (sel->first < filelist->filelist.nbr_entries_filtered) && @@ -2402,9 +2396,7 @@ void filelist_entries_select_index_range_set(FileList *filelist, } } -unsigned int filelist_entry_select_get(FileList *filelist, - FileDirEntry *entry, - FileCheckType check) +uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileCheckType check) { BLI_assert(entry); BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL)); @@ -2418,9 +2410,7 @@ unsigned int filelist_entry_select_get(FileList *filelist, return 0; } -unsigned int filelist_entry_select_index_get(FileList *filelist, - const int index, - FileCheckType check) +uint filelist_entry_select_index_get(FileList *filelist, const int index, FileCheckType check) { FileDirEntry *entry = filelist_file(filelist, index); @@ -2436,7 +2426,7 @@ unsigned int filelist_entry_select_index_get(FileList *filelist, */ void filelist_entry_parent_select_set(FileList *filelist, FileSelType select, - unsigned int flag, + uint flag, FileCheckType check) { if ((filelist->filter_data.flags & FLF_HIDE_PARENT) == 0) { diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 8c64fb5bb40..6096c27fc8c 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2647,7 +2647,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) for (f = 0; f < 3; f++) { FCurve *fcu = euf->fcurves[f]; BezTriple *bezt, *prev; - unsigned int i; + uint i; /* skip if not enough vets to do a decent analysis of... */ if (fcu->totvert <= 2) { @@ -3569,7 +3569,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) bAnimListElem *ale; int filter; bool ok = false; - unsigned int deleted = 0; + uint deleted = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7bd1b8e8291..c0b1efe0b73 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3107,13 +3107,13 @@ typedef struct ImageSampleInfo { int width, height; int sample_size; - unsigned char col[4]; + uchar col[4]; float colf[4]; float linearcol[4]; int z; float zf; - unsigned char *colp; + uchar *colp; const float *colfp; int *zp; float *zfp; @@ -3198,7 +3198,7 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2], if (uv[0] >= 0.0f && uv[1] >= 0.0f && uv[0] < 1.0f && uv[1] < 1.0f) { const float *fp; - unsigned char *cp; + uchar *cp; int x = (int)(uv[0] * ibuf->x), y = (int)(uv[1] * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -3210,7 +3210,7 @@ bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2], ret = true; } else if (ibuf->rect) { - cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + cp = (uchar *)(ibuf->rect + y * ibuf->x + x); rgb_uchar_to_float(r_col, cp); IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); ret = true; @@ -3230,7 +3230,7 @@ static void image_sample_pixel_color_ubyte(const ImBuf *ibuf, uchar r_col[4], float r_col_linear[4]) { - const uchar *cp = (unsigned char *)(ibuf->rect + coord[1] * ibuf->x + coord[0]); + const uchar *cp = (uchar *)(ibuf->rect + coord[1] * ibuf->x + coord[0]); copy_v4_v4_uchar(r_col, cp); rgba_uchar_to_float(r_col_linear, r_col); IMB_colormanagement_colorspace_to_scene_linear_v4(r_col_linear, false, ibuf->rect_colorspace); diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c index cc6fe38866d..245495bd179 100644 --- a/source/blender/editors/space_image/image_sequence.c +++ b/source/blender/editors/space_image/image_sequence.c @@ -69,7 +69,7 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges) RNA_BEGIN (op->ptr, itemptr, "files") { char base_head[FILE_MAX], base_tail[FILE_MAX]; char head[FILE_MAX], tail[FILE_MAX]; - unsigned short digits; + ushort digits; char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); ImageFrame *frame = MEM_callocN(sizeof(ImageFrame), "image_frame"); @@ -125,7 +125,7 @@ static int image_get_udim(char *filepath, ListBase *udim_tiles) char filename[FILE_MAX], dirname[FILE_MAXDIR]; BLI_split_dirfile(filepath, dirname, filename, sizeof(dirname), sizeof(filename)); - unsigned short digits; + ushort digits; char base_head[FILE_MAX], base_tail[FILE_MAX]; int id = BLI_stringdec(filename, base_head, base_tail, &digits); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 4ccf752a916..d3c93f6a5b6 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -313,7 +313,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col } /* helper call for drawing influence/time control curves for a given NLA-strip */ -static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos) +static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uint pos) { const float yheight = ymaxc - yminc; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 98fcf862290..051719fee3a 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -284,7 +284,7 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo { bNode *node; bool changed = false; - const unsigned int delims[] = {'.', '-', '_', '\0'}; + const uint delims[] = {'.', '-', '_', '\0'}; size_t pref_len_act, pref_len_curr; const char *sep, *suf_act, *suf_curr; diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 9283b073e86..5bdca04856b 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -382,7 +382,7 @@ typedef struct ImageSampleInfo { int x, y; int channels; - unsigned char col[4]; + uchar col[4]; float colf[4]; float linearcol[4]; @@ -450,7 +450,7 @@ bool ED_space_node_color_sample( if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { const float *fp; - unsigned char *cp; + uchar *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -463,7 +463,7 @@ bool ED_space_node_color_sample( ret = true; } else if (ibuf->rect) { - cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + cp = (uchar *)(ibuf->rect + y * ibuf->x + x); rgb_uchar_to_float(r_col, cp); IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); ret = true; @@ -507,7 +507,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { const float *fp; - unsigned char *cp; + uchar *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -522,7 +522,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->zfp = NULL; if (ibuf->rect) { - cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + cp = (uchar *)(ibuf->rect + y * ibuf->x + x); info->col[0] = cp[0]; info->col[1] = cp[1]; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 0766996c00b..b50a3e1743e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -99,9 +99,9 @@ static Sequence *special_seq_update = NULL; -void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3]) +void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3]) { - unsigned char blendcol[3]; + uchar blendcol[3]; switch (seq->type) { case SEQ_TYPE_IMAGE: @@ -366,7 +366,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, * so for now, just use the meta's immediate children, could be fixed but * its only drawing - campbell */ Sequence *seq; - unsigned char col[4]; + uchar col[4]; int chan_min = MAXSEQ; int chan_max = 0; @@ -467,15 +467,15 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction, - unsigned int pos, + uint pos, bool seq_active, float pixelx, bool y_threshold) { float rx1 = 0, rx2 = 0; float x1, x2, y1, y2; - unsigned int whichsel = 0; - unsigned char col[4]; + uint whichsel = 0; + uchar col[4]; x1 = seq->startdisp; x2 = seq->enddisp; @@ -557,7 +557,7 @@ static void draw_seq_handle(View2D *v2d, } static void draw_seq_outline(Sequence *seq, - unsigned int pos, + uint pos, float x1, float x2, float y1, @@ -566,7 +566,7 @@ static void draw_seq_outline(Sequence *seq, float pixely, bool seq_active) { - unsigned char col[3]; + uchar col[3]; /* Get the color for the outline. */ if (seq_active && (seq->flag & SELECT)) { @@ -751,10 +751,10 @@ static void draw_seq_text(View2D *v2d, UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col); } -static void draw_sequence_extensions(Scene *scene, Sequence *seq, unsigned int pos, float pixely) +static void draw_sequence_extensions(Scene *scene, Sequence *seq, uint pos, float pixely) { float x1, x2, y1, y2; - unsigned char col[4], blend_col[3]; + uchar col[4], blend_col[3]; x1 = seq->startdisp; x2 = seq->enddisp; @@ -793,9 +793,9 @@ static void draw_sequence_extensions(Scene *scene, Sequence *seq, unsigned int p GPU_blend(false); } -static void draw_color_strip_band(Sequence *seq, unsigned int pos, float text_margin_y, float y1) +static void draw_color_strip_band(Sequence *seq, uint pos, float text_margin_y, float y1) { - unsigned char col[4]; + uchar col[4]; SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; rgb_float_to_uchar(col, colvars->col); @@ -827,14 +827,14 @@ static void draw_color_strip_band(Sequence *seq, unsigned int pos, float text_ma static void draw_seq_background(Scene *scene, Sequence *seq, - unsigned int pos, + uint pos, float x1, float x2, float y1, float y2, bool is_single_image) { - unsigned char col[4]; + uchar col[4]; /* Get the correct color per strip type, transitions use their inputs ones. */ if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { @@ -1538,7 +1538,7 @@ static void sequencer_draw_display_buffer(const bContext *C, IMB_rect_from_float(ibuf); } - display_buffer = (unsigned char *)ibuf->rect; + display_buffer = (uchar *)ibuf->rect; format = GL_RGBA; type = GL_UNSIGNED_BYTE; } diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 309840ea9e3..3dcbdb6c4b0 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -50,24 +50,24 @@ static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3]) yuv[2] += 0.5f; } -static void scope_put_pixel(unsigned char *table, unsigned char *pos) +static void scope_put_pixel(uchar *table, uchar *pos) { - unsigned char newval = table[*pos]; + uchar newval = table[*pos]; pos[0] = pos[1] = pos[2] = newval; pos[3] = 255; } -static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, int col) +static void scope_put_pixel_single(uchar *table, uchar *pos, int col) { char newval = table[pos[col]]; pos[col] = newval; pos[3] = 255; } -static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_pos) +static void wform_put_line(int w, uchar *last_pos, uchar *new_pos) { if (last_pos > new_pos) { - unsigned char *temp = new_pos; + uchar *temp = new_pos; new_pos = last_pos; last_pos = temp; } @@ -81,10 +81,10 @@ static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_po } } -static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char *new_pos, int col) +static void wform_put_line_single(int w, uchar *last_pos, uchar *new_pos, int col) { if (last_pos > new_pos) { - unsigned char *temp = new_pos; + uchar *temp = new_pos; new_pos = last_pos; last_pos = temp; } @@ -98,12 +98,12 @@ static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char } } -static void wform_put_border(unsigned char *tgt, int w, int h) +static void wform_put_border(uchar *tgt, int w, int h) { int x, y; for (x = 0; x < w; x++) { - unsigned char *p = tgt + 4 * x; + uchar *p = tgt + 4 * x; p[1] = p[3] = 155; p[4 * w + 1] = p[4 * w + 3] = 155; p = tgt + 4 * (w * (h - 1) + x); @@ -112,7 +112,7 @@ static void wform_put_border(unsigned char *tgt, int w, int h) } for (y = 0; y < h; y++) { - unsigned char *p = tgt + 4 * w * y; + uchar *p = tgt + 4 * w * y; p[1] = p[3] = 155; p[4 + 1] = p[4 + 3] = 155; p = tgt + 4 * (w * y + w - 1); @@ -121,7 +121,7 @@ static void wform_put_border(unsigned char *tgt, int w, int h) } } -static void wform_put_gridrow(unsigned char *tgt, float perc, int w, int h) +static void wform_put_gridrow(uchar *tgt, float perc, int w, int h) { int i; @@ -134,7 +134,7 @@ static void wform_put_gridrow(unsigned char *tgt, float perc, int w, int h) } } -static void wform_put_grid(unsigned char *tgt, int w, int h) +static void wform_put_grid(uchar *tgt, int w, int h) { wform_put_gridrow(tgt, 90.0, w, h); wform_put_gridrow(tgt, 70.0, w, h); @@ -145,27 +145,27 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf) { ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; - const unsigned char *src = (unsigned char *)ibuf->rect; - unsigned char *tgt = (unsigned char *)rval->rect; + const uchar *src = (uchar *)ibuf->rect; + uchar *tgt = (uchar *)rval->rect; int w = ibuf->x + 3; int h = 515; float waveform_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; wform_put_grid(tgt, w, h); wform_put_border(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { - unsigned char *last_p = NULL; + uchar *last_p = NULL; for (x = 0; x < ibuf->x; x++) { - const unsigned char *rgb = src + 4 * (ibuf->x * y + x); + const uchar *rgb = src + 4 * (ibuf->x * y + x); float v = (float)IMB_colormanagement_get_luminance_byte(rgb) / 255.0f; - unsigned char *p = tgt; + uchar *p = tgt; p += 4 * (w * ((int)(v * (h - 3)) + 1) + x + 1); scope_put_pixel(wtable, p); @@ -187,25 +187,25 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf) ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; const float *src = ibuf->rect_float; - unsigned char *tgt = (unsigned char *)rval->rect; + uchar *tgt = (uchar *)rval->rect; int w = ibuf->x + 3; int h = 515; float waveform_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { - unsigned char *last_p = NULL; + uchar *last_p = NULL; for (x = 0; x < ibuf->x; x++) { const float *rgb = src + 4 * (ibuf->x * y + x); float v = IMB_colormanagement_get_luminance(rgb); - unsigned char *p = tgt; + uchar *p = tgt; CLAMP(v, 0.0f, 1.0f); @@ -241,28 +241,28 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) { ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; - const unsigned char *src = (const unsigned char *)ibuf->rect; - unsigned char *tgt = (unsigned char *)rval->rect; + const uchar *src = (const uchar *)ibuf->rect; + uchar *tgt = (uchar *)rval->rect; int w = ibuf->x + 3; int sw = ibuf->x / 3; int h = 515; float waveform_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { - unsigned char *last_p[3] = {NULL, NULL, NULL}; + uchar *last_p[3] = {NULL, NULL, NULL}; for (x = 0; x < ibuf->x; x++) { int c; - const unsigned char *rgb = src + 4 * (ibuf->x * y + x); + const uchar *rgb = src + 4 * (ibuf->x * y + x); for (c = 0; c < 3; c++) { - unsigned char *p = tgt; + uchar *p = tgt; p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); @@ -287,27 +287,27 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; const float *src = ibuf->rect_float; - unsigned char *tgt = (unsigned char *)rval->rect; + uchar *tgt = (uchar *)rval->rect; int w = ibuf->x + 3; int sw = ibuf->x / 3; int h = 515; float waveform_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { - unsigned char *last_p[3] = {NULL, NULL, NULL}; + uchar *last_p[3] = {NULL, NULL, NULL}; for (x = 0; x < ibuf->x; x++) { int c; const float *rgb = src + 4 * (ibuf->x * y + x); for (c = 0; c < 3; c++) { - unsigned char *p = tgt; + uchar *p = tgt; float v = rgb[c]; CLAMP(v, 0.0f, 1.0f); @@ -343,18 +343,18 @@ ImBuf *make_sep_waveform_view_from_ibuf(ImBuf *ibuf) static void draw_zebra_byte(ImBuf *src, ImBuf *ibuf, float perc) { - unsigned int limit = 255.0f * perc / 100.0f; - unsigned char *p = (unsigned char *)src->rect; - unsigned char *o = (unsigned char *)ibuf->rect; + uint limit = 255.0f * perc / 100.0f; + uchar *p = (uchar *)src->rect; + uchar *o = (uchar *)ibuf->rect; int x; int y; for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { - unsigned char r = *p++; - unsigned char g = *p++; - unsigned char b = *p++; - unsigned char a = *p++; + uchar r = *p++; + uchar g = *p++; + uchar b = *p++; + uchar a = *p++; if (r >= limit || g >= limit || b >= limit) { if (((x + y) & 0x08) != 0) { @@ -375,7 +375,7 @@ static void draw_zebra_float(ImBuf *src, ImBuf *ibuf, float perc) { float limit = perc / 100.0f; const float *p = src->rect_float; - unsigned char *o = (unsigned char *)ibuf->rect; + uchar *o = (uchar *)ibuf->rect; int x; int y; @@ -417,7 +417,7 @@ ImBuf *make_zebra_view_from_ibuf(ImBuf *src, float perc) static void draw_histogram_marker(ImBuf *ibuf, int x) { - unsigned char *p = (unsigned char *)ibuf->rect; + uchar *p = (uchar *)ibuf->rect; int barh = ibuf->y * 0.1; int i; @@ -431,7 +431,7 @@ static void draw_histogram_marker(ImBuf *ibuf, int x) static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col) { - unsigned char *p = (unsigned char *)ibuf->rect; + uchar *p = (uchar *)ibuf->rect; int barh = ibuf->y * val * 0.9f; int i; @@ -456,12 +456,12 @@ static void make_histogram_view_from_ibuf_byte_cb_ex(void *__restrict userdata, { MakeHistogramViewData *data = userdata; const ImBuf *ibuf = data->ibuf; - const unsigned char *src = (unsigned char *)ibuf->rect; + const uchar *src = (uchar *)ibuf->rect; uint32_t(*cur_bins)[HIS_STEPS] = tls->userdata_chunk; for (int x = 0; x < ibuf->x; x++) { - const unsigned char *pixel = src + (y * ibuf->x + x) * 4; + const uchar *pixel = src + (y * ibuf->x + x) * 4; for (int j = 3; j--;) { cur_bins[j][pixel[j]]++; @@ -488,9 +488,9 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) { ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect); int x; - unsigned int nr, ng, nb; + uint nr, ng, nb; - unsigned int bins[3][HIS_STEPS]; + uint bins[3][HIS_STEPS]; memset(bins, 0, sizeof(bins)); @@ -534,7 +534,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) } } - wform_put_border((unsigned char *)rval->rect, rval->x, rval->y); + wform_put_border((uchar *)rval->rect, rval->x, rval->y); return rval; } @@ -576,7 +576,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) int nr, ng, nb; int x; - unsigned int bins[3][HIS_STEPS]; + uint bins[3][HIS_STEPS]; memset(bins, 0, sizeof(bins)); @@ -619,7 +619,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) draw_histogram_marker(rval, get_bin_float(0.0)); draw_histogram_marker(rval, get_bin_float(1.0)); - wform_put_border((unsigned char *)rval->rect, rval->x, rval->y); + wform_put_border((uchar *)rval->rect, rval->x, rval->y); return rval; } @@ -636,8 +636,7 @@ ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf) } } -static void vectorscope_put_cross( - unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size) +static void vectorscope_put_cross(uchar r, uchar g, uchar b, char *tgt, int w, int h, int size) { float rgb[3], yuv[3]; char *p; @@ -676,10 +675,10 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) int w = 515; int h = 515; float scope_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, scope_gamma) * 255); } for (x = 0; x < 256; x++) { @@ -702,7 +701,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) rgb_to_yuv_normalized(rgb, yuv); p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1))); - scope_put_pixel(wtable, (unsigned char *)p); + scope_put_pixel(wtable, (uchar *)p); } } @@ -721,10 +720,10 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) int w = 515; int h = 515; float scope_gamma = 0.2; - unsigned char wtable[256]; + uchar wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255); + wtable[x] = (uchar)(pow(((float)x + 1) / 256, scope_gamma) * 255); } for (x = 0; x <= 255; x++) { @@ -748,7 +747,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) rgb_to_yuv_normalized(rgb, yuv); p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1))); - scope_put_pixel(wtable, (unsigned char *)p); + scope_put_pixel(wtable, (uchar *)p); } } diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 714a634766c..b2114eab62e 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -57,11 +57,11 @@ typedef struct ImageSampleInfo { int x, y; int channels; - unsigned char col[4]; + uchar col[4]; float colf[4]; float linearcol[4]; - unsigned char *colp; + uchar *colp; const float *colfp; int draw; @@ -117,7 +117,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { const float *fp; - unsigned char *cp; + uchar *cp; int x = (int)fx, y = (int)fy; info->x = x; @@ -129,7 +129,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->colfp = NULL; if (ibuf->rect) { - cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + cp = (uchar *)(ibuf->rect + y * ibuf->x + x); info->col[0] = cp[0]; info->col[1] = cp[1]; diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c index 2eeb46049d2..bdbf55d9198 100644 --- a/source/blender/editors/space_text/text_format.c +++ b/source/blender/editors/space_text/text_format.c @@ -121,7 +121,7 @@ int flatten_string_strlen(FlattenString *fs, const char *str) /* Ensures the format string for the given line is long enough, reallocating * as needed. Allocation is done here, alone, to ensure consistency. */ -int text_check_format_len(TextLine *line, unsigned int len) +int text_check_format_len(TextLine *line, uint len) { if (line->format) { if (strlen(line->format) < len) { diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e0b15d0a9d5..26600bd7dbc 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3420,7 +3420,7 @@ static int text_insert_exec(bContext *C, wmOperator *op) char *str; bool done = false; size_t i = 0; - unsigned int code; + uint code; text_drawcache_tag_update(st, 0); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 30587e6084d..522d1a15e3f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1555,9 +1555,7 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot) /** \name Local Collections * \{ */ -static uint free_localcollection_bit(Main *bmain, - unsigned short local_collections_uuid, - bool *r_reset) +static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset) { ScrArea *sa; bScreen *sc; @@ -1596,7 +1594,7 @@ static uint free_localcollection_bit(Main *bmain, } static void local_collections_reset_uuid(LayerCollection *layer_collection, - const unsigned short local_view_bit) + const ushort local_view_bit) { if (layer_collection->flag & LAYER_COLLECTION_HIDE) { layer_collection->local_collections_bits &= ~local_view_bit; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a9eaad6868e..965df86acc0 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -559,7 +559,7 @@ static void viewRedrawPost(bContext *C, TransInfo *t) /* ************************** TRANSFORMATIONS **************************** */ -static void view_editmove(unsigned short UNUSED(event)) +static void view_editmove(ushort UNUSED(event)) { #if 0 // TRANSFORM_FIX_ME int refresh = 0; @@ -1576,7 +1576,7 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *region) /* warning text (to clarify meaning of overlays) * - original color was red to match the icon, but that clashes badly with a less nasty border */ - unsigned char color[3]; + uchar color[3]; UI_GetThemeColorShade3ubv(TH_TEXT_HI, -50, color); BLF_color3ubv(font_id, color); #ifdef WITH_INTERNATIONAL diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 1049db74a75..19319d2606b 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -1128,10 +1128,10 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act) /* struct for use in re-sorting BezTriples during Graph Editor transform */ typedef struct BeztMap { BezTriple *bezt; - unsigned int oldIndex; /* index of bezt in fcu->bezt array before sorting */ - unsigned int newIndex; /* index of bezt in fcu->bezt array after sorting */ - short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */ - char pipo, cipo; /* interpolation of current and next segments */ + uint oldIndex; /* index of bezt in fcu->bezt array before sorting */ + uint newIndex; /* index of bezt in fcu->bezt array after sorting */ + short swapHs; /* swap order of handles (-1=clear; 0=not checked, 1=swap) */ + char pipo, cipo; /* interpolation of current and next segments */ } BeztMap; /* This function converts an FCurve's BezTriple array to a BeztMap array diff --git a/source/blender/editors/transform/transform_draw_cursors.c b/source/blender/editors/transform/transform_draw_cursors.c index f3105c8eb36..95ca5ae0c30 100644 --- a/source/blender/editors/transform/transform_draw_cursors.c +++ b/source/blender/editors/transform/transform_draw_cursors.c @@ -313,7 +313,7 @@ void transform_draw_cursor_draw(bContext *UNUSED(C), int x, int y, void *customd break; } case HLP_TRACKBALL: { - unsigned char col[3], col2[3]; + uchar col[3], col2[3]; UI_GetThemeColor3ubv(TH_GRID, col); GPU_matrix_translate_3fv(mval); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 7a787b77a62..11b4600466c 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -337,7 +337,7 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) static bool fcu_test_selected(FCurve *fcu) { BezTriple *bezt = fcu->bezt; - unsigned int i; + uint i; if (bezt == NULL) { /* ignore baked */ return 0; @@ -1222,7 +1222,7 @@ void recalcData(TransInfo *t) void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options) { float v1[3], v2[3], v3[3]; - unsigned char col[3], col2[3]; + uchar col[3], col2[3]; if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->view; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 5cc1feddf7a..423990b3713 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -523,12 +523,12 @@ void initTransformOrientation(bContext *C, TransInfo *t) /** * utility function - get first n, selected vert/edge/faces */ -static unsigned int bm_mesh_elems_select_get_n__internal( - BMesh *bm, BMElem **elems, const unsigned int n, const BMIterType itype, const char htype) +static uint bm_mesh_elems_select_get_n__internal( + BMesh *bm, BMElem **elems, const uint n, const BMIterType itype, const char htype) { BMIter iter; BMElem *ele; - unsigned int i; + uint i; BLI_assert(ELEM(htype, BM_VERT, BM_EDGE, BM_FACE)); BLI_assert(ELEM(itype, BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH)); @@ -579,18 +579,18 @@ static unsigned int bm_mesh_elems_select_get_n__internal( return i; } -static unsigned int bm_mesh_verts_select_get_n(BMesh *bm, BMVert **elems, const unsigned int n) +static uint bm_mesh_verts_select_get_n(BMesh *bm, BMVert **elems, const uint n) { return bm_mesh_elems_select_get_n__internal( bm, (BMElem **)elems, min_ii(n, bm->totvertsel), BM_VERTS_OF_MESH, BM_VERT); } -static unsigned int bm_mesh_edges_select_get_n(BMesh *bm, BMEdge **elems, const unsigned int n) +static uint bm_mesh_edges_select_get_n(BMesh *bm, BMEdge **elems, const uint n) { return bm_mesh_elems_select_get_n__internal( bm, (BMElem **)elems, min_ii(n, bm->totedgesel), BM_EDGES_OF_MESH, BM_EDGE); } #if 0 -static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const unsigned int n) +static uint bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const uint n) { return bm_mesh_elems_select_get_n__internal( bm, (BMElem **)elems, min_ii(n, bm->totfacesel), BM_FACES_OF_MESH, BM_FACE); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 86e99c986f8..9adc15ccb61 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -158,7 +158,7 @@ static bool doForceIncrementSnap(const TransInfo *t) void drawSnapping(const struct bContext *C, TransInfo *t) { - unsigned char col[4], selectedCol[4], activeCol[4]; + uchar col[4], selectedCol[4], activeCol[4]; if (!activeSnap(t)) { return; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index f55c73fd15e..34c9e1f3273 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -447,7 +447,7 @@ struct RayCastAll_Data { float local_scale; Object *ob; - unsigned int ob_uuid; + uint ob_uuid; /* output data */ ListBase *hit_list; @@ -460,7 +460,7 @@ static struct SnapObjectHitDepth *hit_depth_create(const float depth, int index, Object *ob, const float obmat[4][4], - unsigned int ob_uuid) + uint ob_uuid) { struct SnapObjectHitDepth *hit = MEM_mallocN(sizeof(*hit), __func__); @@ -586,7 +586,7 @@ static bool raycastMesh(SnapObjectContext *sctx, Object *ob, Mesh *me, const float obmat[4][4], - const unsigned int ob_index, + const uint ob_index, bool use_hide, bool use_backface_culling, /* read/write args */ @@ -761,7 +761,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx, Object *ob, BMEditMesh *em, const float obmat[4][4], - const unsigned int ob_index, + const uint ob_index, bool use_backface_culling, /* read/write args */ float *ray_depth, @@ -931,7 +931,7 @@ static bool raycastObj(SnapObjectContext *sctx, const float ray_dir[3], Object *ob, const float obmat[4][4], - const unsigned int ob_index, + const uint ob_index, bool use_obedit, bool use_occlusion_test, bool use_backface_culling, @@ -1046,7 +1046,7 @@ static bool raycastObj(SnapObjectContext *sctx, struct RaycastObjUserData { const float *ray_start; const float *ray_dir; - unsigned int ob_index; + uint ob_index; /* read/write args */ float *ray_depth; /* return args */ @@ -1227,7 +1227,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree const MLoopTri *lt = &data->looptri[index]; for (int j = 2, j_next = 0; j_next < 3; j = j_next++) { const MEdge *ed = &medge[mloop[lt->tri[j]].e]; - unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; + uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) { // printf("real edge found\n"); v_index[j] = mloop[lt->tri[j]].e; @@ -3049,7 +3049,7 @@ bool ED_transform_snap_object_project_ray(SnapObjectContext *sctx, static short transform_snap_context_project_view3d_mixed_impl( SnapObjectContext *sctx, Depsgraph *depsgraph, - const unsigned short snap_to_flag, + const ushort snap_to_flag, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], @@ -3225,7 +3225,7 @@ static short transform_snap_context_project_view3d_mixed_impl( short ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx, Depsgraph *depsgraph, - const unsigned short snap_to, + const ushort snap_to, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], @@ -3265,7 +3265,7 @@ short ED_transform_snap_object_project_view3d_ex(SnapObjectContext *sctx, */ bool ED_transform_snap_object_project_view3d(SnapObjectContext *sctx, Depsgraph *depsgraph, - const unsigned short snap_to, + const ushort snap_to, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b805681cfd3..33601de50da 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -695,7 +695,7 @@ void ED_uvedit_select_all(BMesh *bm) static bool ED_uvedit_median_multi( const Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float co[2]) { - unsigned int sel = 0; + uint sel = 0; zero_v2(co); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { @@ -1319,7 +1319,7 @@ static void uv_select_linked_multi(Scene *scene, UvVertMap *vmap; UvMapVert *vlist, *iterv, *startv; int i, stacksize = 0, *stack; - unsigned int a; + uint a; char *flag; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -3261,7 +3261,7 @@ static void uv_select_tag_update_for_object(Depsgraph *depsgraph, static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, BMEditMesh *em, UvVertMap *vmap, - const unsigned int efa_index, + const uint efa_index, BMLoop *l, const bool select, const int cd_loop_uv_offset) @@ -3361,7 +3361,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) { struct UvVertMap *vmap; float limit[2]; - unsigned int efa_index; + uint efa_index; uvedit_pixel_to_float(sima, limit, 0.05); @@ -3448,7 +3448,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, else if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_LOC) { struct UvVertMap *vmap; float limit[2]; - unsigned int efa_index; + uint efa_index; uvedit_pixel_to_float(sima, limit, 0.05); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 936ba750266..da8e0efa522 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -107,7 +107,7 @@ typedef struct PVert { struct PEdge *edge; float co[3]; float uv[2]; - unsigned char flag; + uchar flag; } PVert; @@ -126,7 +126,7 @@ typedef struct PEdge { struct PEdge *next; struct PFace *face; float *orig_uv, old_uv[2]; - unsigned short flag; + ushort flag; } PEdge; @@ -141,7 +141,7 @@ typedef struct PFace { } u; struct PEdge *edge; - unsigned char flag; + uchar flag; } PFace; enum PVertFlag { @@ -197,7 +197,7 @@ typedef struct PChart { } pack; } u; - unsigned char flag; + uchar flag; struct PHandle *handle; } PChart; @@ -245,7 +245,7 @@ static int PHashSizes[] = { 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459, }; -#define PHASH_hash(ph, item) (((uintptr_t)(item)) % ((unsigned int)(ph)->cursize)) +#define PHASH_hash(ph, item) (((uintptr_t)(item)) % ((uint)(ph)->cursize)) #define PHASH_edge(v1, v2) (((v1) < (v2)) ? ((v1)*39) ^ ((v2)*31) : ((v1)*31) ^ ((v2)*39)) static PHash *phash_new(PHashLink **list, int sizehint) @@ -511,7 +511,7 @@ static void p_chart_uv_transform(PChart *chart, float mat[2][2]) static void p_chart_uv_to_array(PChart *chart, float (*points)[2]) { PVert *v; - unsigned int i = 0; + uint i = 0; for (v = chart->verts; v; v = v->nextlink) { copy_v2_v2(points[i++], v->uv); @@ -521,7 +521,7 @@ static void p_chart_uv_to_array(PChart *chart, float (*points)[2]) static void UNUSED_FUNCTION(p_chart_uv_from_array)(PChart *chart, float (*points)[2]) { PVert *v; - unsigned int i = 0; + uint i = 0; for (v = chart->verts; v; v = v->nextlink) { copy_v2_v2(v->uv, points[i++]); @@ -4409,8 +4409,8 @@ static void p_add_ngon(ParamHandle *handle, PHandle *phandle = (PHandle *)handle; MemArena *arena = phandle->polyfill_arena; Heap *heap = phandle->polyfill_heap; - unsigned int nfilltri = nverts - 2; - unsigned int(*tris)[3] = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri); + uint nfilltri = nverts - 2; + uint(*tris)[3] = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri); float(*projverts)[2] = BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts); /* Calc normal, flipped: to get a positive 2d cross product. */ @@ -4441,10 +4441,10 @@ static void p_add_ngon(ParamHandle *handle, /* Add triangles. */ for (int j = 0; j < nfilltri; j++) { - unsigned int *tri = tris[j]; - unsigned int v0 = tri[0]; - unsigned int v1 = tri[1]; - unsigned int v2 = tri[2]; + uint *tri = tris[j]; + uint v0 = tri[0]; + uint v1 = tri[1]; + uint v2 = tri[2]; ParamKey tri_vkeys[3] = {vkeys[v0], vkeys[v1], vkeys[v2]}; float *tri_co[3] = {co[v0], co[v1], co[v2]}; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index cf23cac38a7..7f05eba7c72 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -75,20 +75,20 @@ typedef struct StitchPreviewer { /* here we'll store the preview triangle indices of the mesh */ float *preview_polys; /* uvs per polygon. */ - unsigned int *uvs_per_polygon; + uint *uvs_per_polygon; /*number of preview polygons */ - unsigned int num_polys; + uint num_polys; /* preview data. These will be either the previewed vertices or edges * depending on stitch mode settings */ float *preview_stitchable; float *preview_unstitchable; /* here we'll store the number of elements to be drawn */ - unsigned int num_stitchable; - unsigned int num_unstitchable; - unsigned int preview_uvs; + uint num_stitchable; + uint num_unstitchable; + uint preview_uvs; /* ...and here we'll store the static island triangles */ float *static_tris; - unsigned int num_static_tris; + uint num_static_tris; } StitchPreviewer; struct IslandStitchData; @@ -119,16 +119,16 @@ typedef struct IslandStitchData { /* just for averaging UVs */ typedef struct UVVertAverage { float uv[2]; - unsigned short count; + ushort count; } UVVertAverage; typedef struct UvEdge { /** index to uv buffer */ - unsigned int uv1; - unsigned int uv2; + uint uv1; + uint uv2; /** general use flag * (Used to check if edge is boundary here, and propagates to adjacency elements) */ - unsigned char flag; + uchar flag; /** element that guarantees element->face * has the edge on element->tfindex and element->tfindex+1 is the second uv */ UvElement *element; @@ -172,7 +172,7 @@ typedef struct StitchState { int selection_size; /* store number of primitives per face so that we can allocate the active island buffer later */ - unsigned int *tris_per_island; + uint *tris_per_island; /* preview data */ StitchPreviewer *stitch_preview; } StitchState; @@ -544,7 +544,7 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchStateContainer *ssc, StitchState *state, UVVertAverage *uv_average, - unsigned int *uvfinal_map, + uint *uvfinal_map, IslandStitchData *island_stitch_data) { BMesh *bm = state->em->bm; @@ -1032,7 +1032,7 @@ static int stitch_process_data(StitchStateContainer *ssc, char stitch_midpoints = ssc->midpoints; /* used to map uv indices to uvaverage indices for selection */ - unsigned int *uvfinal_map = NULL; + uint *uvfinal_map = NULL; /* per face preview position in preview buffer */ PreviewPosition *preview_position = NULL; @@ -1229,7 +1229,7 @@ static int stitch_process_data(StitchStateContainer *ssc, BMIter liter; BMLoop *l; MLoopUV *luv; - unsigned int buffer_index = 0; + uint buffer_index = 0; /* initialize the preview buffers */ preview->preview_polys = MEM_mallocN(preview->preview_uvs * sizeof(float) * 2, @@ -1575,7 +1575,7 @@ static int stitch_process_data_all(StitchStateContainer *ssc, Scene *scene, int } /* Stitch hash initialization functions */ -static unsigned int uv_edge_hash(const void *key) +static uint uv_edge_hash(const void *key) { const UvEdge *edge = key; return (BLI_ghashutil_uinthash(edge->uv2) + BLI_ghashutil_uinthash(edge->uv1)); @@ -1760,14 +1760,14 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void for (uint ob_index = 0; ob_index < ssc->objects_len; ob_index++) { int j, index = 0; - unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0; + uint num_line = 0, num_tri, tri_idx = 0, line_idx = 0; StitchState *state = ssc->states[ob_index]; StitchPreviewer *stitch_preview = state->stitch_preview; GPUVertBuf *vbo, *vbo_line; float col[4]; static GPUVertFormat format = {0}; - static unsigned int pos_id; + static uint pos_id; if (format.attr_len == 0) { pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } -- cgit v1.2.3 From 05dcb007e181c961c0db87c1ce4745ae2d1d0fd0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 16:46:34 +1100 Subject: Cleanup: use tern 'sync' instead of 'synchronization' for function names This is a common, unambiguous abbreviation already used throughout the code-base. --- source/blender/blenkernel/BKE_object.h | 2 +- source/blender/blenkernel/intern/armature.c | 4 ++-- source/blender/blenkernel/intern/movieclip.c | 4 ++-- source/blender/blenkernel/intern/object_update.c | 4 ++-- source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 75198cd3f63..70a44d6d8ce 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -277,7 +277,7 @@ void BKE_object_eval_uber_data(struct Depsgraph *depsgraph, void BKE_object_eval_assign_data(struct Object *object, struct ID *data, bool is_owned); void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object); -void BKE_object_synchronize_to_original(struct Depsgraph *depsgraph, struct Object *object); +void BKE_object_sync_to_original(struct Depsgraph *depsgraph, struct Object *object); void BKE_object_eval_ptcache_reset(struct Depsgraph *depsgraph, struct Scene *scene, diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9c88ffb5d52..444d63e33d0 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2523,7 +2523,7 @@ void BKE_armature_where_is(bArmature *arm) /* if bone layer is protected, copy the data from from->pose * when used with linked libraries this copies from the linked pose into the local pose */ -static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected) +static void pose_proxy_sync(Object *ob, Object *from, int layer_protected) { bPose *pose = ob->pose, *frompose = from->pose; bPoseChannel *pchan, *pchanp; @@ -2786,7 +2786,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ * using COW tag was working this morning, but not anymore... */ if (ob->proxy != NULL && (ob->id.tag & LIB_TAG_NO_MAIN) == 0) { BKE_object_copy_proxy_drivers(ob, ob->proxy); - pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); + pose_proxy_sync(ob, ob->proxy, arm->layer_protected); } BKE_pose_update_constraint_flags(pose); /* for IK detection for example */ diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 1935dc0cf6f..aeb8f29b084 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1744,7 +1744,7 @@ bool BKE_movieclip_put_frame_if_possible(MovieClip *clip, MovieClipUser *user, I return result; } -static void movieclip_selection_synchronize(MovieClip *clip_dst, const MovieClip *clip_src) +static void movieclip_selection_sync(MovieClip *clip_dst, const MovieClip *clip_src) { BLI_assert(clip_dst != clip_src); MovieTracking *tracking_dst = &clip_dst->tracking, tracking_src = clip_src->tracking; @@ -1811,5 +1811,5 @@ void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, Main *bmain, MovieCl void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip *clip) { DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip); - movieclip_selection_synchronize(clip, (MovieClip *)clip->id.orig_id); + movieclip_selection_sync(clip, (MovieClip *)clip->id.orig_id); } diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index dd06e4f1753..3e93ca96982 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -273,7 +273,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o /** * TODO(sergey): Ensure that bounding box is already calculated, and move this - * into #BKE_object_synchronize_to_original(). + * into #BKE_object_sync_to_original(). */ void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object) { @@ -290,7 +290,7 @@ void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object) } } -void BKE_object_synchronize_to_original(Depsgraph *depsgraph, Object *object) +void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) { if (!DEG_is_active(depsgraph)) { return; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 128b2d3a9bf..eee1a9d2fc8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -652,7 +652,7 @@ void DepsgraphNodeBuilder::build_object(int base_index, add_operation_node(&object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL, - function_bind(BKE_object_synchronize_to_original, _1, object_cow)); + function_bind(BKE_object_sync_to_original, _1, object_cow)); } void DepsgraphNodeBuilder::build_object_flags(int base_index, -- cgit v1.2.3 From 973e1f9d9a967132cc76fbbcd485979ac27e10c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 16:59:34 +1100 Subject: Cleanup: use term 'attr' instead of 'attrib' This was already the case in most parts of the GPU API. Use full name for descriptive-comments. --- source/blender/blenfont/intern/blf_font.c | 2 +- .../gpencil/shaders/gpencil_common_lib.glsl | 6 ++-- .../draw/engines/overlay/overlay_edit_mesh.c | 8 ++--- .../draw/engines/overlay/overlay_particle.c | 2 +- .../blender/draw/engines/overlay/overlay_shader.c | 6 ++-- .../overlay/shaders/edit_mesh_normal_vert.glsl | 2 +- .../engines/overlay/shaders/extra_wire_vert.glsl | 2 +- .../engines/overlay/shaders/wireframe_vert.glsl | 6 ++-- source/blender/draw/intern/DRW_render.h | 10 +++--- .../blender/draw/intern/draw_cache_extract_mesh.c | 22 ++++++------- .../blender/draw/intern/draw_cache_impl_gpencil.c | 6 ++-- source/blender/draw/intern/draw_cache_impl_mesh.c | 10 +++--- .../draw/intern/draw_cache_impl_particles.c | 16 +++++----- source/blender/draw/intern/draw_hair_private.h | 2 +- source/blender/draw/intern/draw_manager.h | 2 +- source/blender/draw/intern/draw_manager_data.c | 17 +++++----- source/blender/draw/intern/draw_manager_exec.c | 2 +- .../draw/intern/shaders/common_view_lib.glsl | 6 ++-- source/blender/gpu/GPU_shader_interface.h | 4 +-- source/blender/gpu/GPU_vertex_format.h | 6 ++-- source/blender/gpu/intern/gpu_batch.c | 34 ++++++++++---------- source/blender/gpu/intern/gpu_codegen.c | 4 +-- source/blender/gpu/intern/gpu_shader_interface.c | 4 +-- source/blender/gpu/intern/gpu_vertex_buffer.c | 2 +- source/blender/gpu/intern/gpu_vertex_format.c | 36 ++++++++++------------ .../blender/imbuf/intern/openexr/openexr_api.cpp | 6 ++-- 26 files changed, 110 insertions(+), 113 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 4d56f6f868f..0f93f2ca07b 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -99,7 +99,7 @@ static void blf_batch_draw_init(void) GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.glyph_size_loc, &g_batch.glyph_size_step); g_batch.glyph_len = 0; - /* A dummy vbo containing 4 points, attribs are not used. */ + /* A dummy VBO containing 4 points, attributes are not used. */ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); GPU_vertbuf_data_alloc(vbo, 4); diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl index 54b2369b32b..e2606473d07 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl @@ -212,7 +212,7 @@ uniform vec4 layerTint; uniform float layerOpacity; /* Used for onion skin. */ uniform float strokeIndexOffset = 0.0; -/* All of these attribs are quad loaded the same way +/* All of these attributes are quad loaded the same way * as GL_LINES_ADJACENCY would feed a geometry shader: * - ma reference the previous adjacency point. * - ma1 reference the current line first point. @@ -236,7 +236,7 @@ in vec4 uv2; in vec4 col1; in vec4 col2; in vec4 fcol1; -/* WARNING: Max attrib count is actually 14 because OSX OpenGL implementation +/* WARNING: Max attribute count is actually 14 because OSX OpenGL implementation * considers gl_VertexID and gl_InstanceID as vertex attribute. (see T74536) */ # define stroke_id1 ma1.y # define point_id1 ma1.z @@ -389,7 +389,7 @@ void stroke_vertex() mat4 model_mat = model_matrix_get(); - /* Avoid using a vertex attrib for quad positioning. */ + /* Avoid using a vertex attribute for quad positioning. */ float x = float(gl_VertexID & 1) * 2.0 - 1.0; /* [-1..1] */ float y = float(gl_VertexID & 2) - 1.0; /* [-1..1] */ diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index be4e4a9e00e..7fc1a7fdce6 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -254,7 +254,7 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob if (has_skin_roots) { circle = DRW_cache_circle_get(); skin_roots = DRW_mesh_batch_cache_get_edit_skin_roots(ob->data); - DRW_shgroup_call_instances_with_attribs(skin_roots_shgrp, ob, circle, skin_roots); + DRW_shgroup_call_instances_with_attrs(skin_roots_shgrp, ob, circle, skin_roots); } } @@ -292,15 +292,15 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) struct GPUBatch *normal_geom = DRW_cache_normal_arrow_get(); if (vnormals_do) { geom = DRW_mesh_batch_cache_get_edit_vnors(ob->data); - DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); + DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } if (lnormals_do) { geom = DRW_mesh_batch_cache_get_edit_lnors(ob->data); - DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); + DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } if (fnormals_do) { geom = DRW_mesh_batch_cache_get_edit_facedots(ob->data); - DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); + DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } } diff --git a/source/blender/draw/engines/overlay/overlay_particle.c b/source/blender/draw/engines/overlay/overlay_particle.c index dc98c1b55c1..98bc62ae66a 100644 --- a/source/blender/draw/engines/overlay/overlay_particle.c +++ b/source/blender/draw/engines/overlay/overlay_particle.c @@ -205,7 +205,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) grp = DRW_shgroup_create_sub(pd->particle_shapes_grp); DRW_shgroup_uniform_vec4_copy(grp, "color", color); shape = DRW_cache_particles_get_prim(draw_as); - DRW_shgroup_call_instances_with_attribs(grp, NULL, shape, geom); + DRW_shgroup_call_instances_with_attrs(grp, NULL, shape, geom); break; } } diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 8b70a0982af..2bb3555b8d1 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -713,7 +713,7 @@ GPUShader *OVERLAY_shader_edit_mesh_normal(void) datatoc_edit_mesh_normal_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL}, + .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL}, }); } return sh_data->edit_mesh_normals; @@ -750,7 +750,7 @@ GPUShader *OVERLAY_shader_edit_mesh_skin_root(void) datatoc_edit_mesh_skin_root_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL}, + .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL}, }); } return sh_data->edit_mesh_skin_root; @@ -1269,7 +1269,7 @@ GPUShader *OVERLAY_shader_particle_shape(void) datatoc_particle_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL}, + .defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL}, }); } return sh_data->particle_shape; diff --git a/source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl index fd37bc8c534..c2aeae4df91 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl @@ -21,7 +21,7 @@ void main() GPU_INTEL_VERTEX_SHADER_WORKAROUND vec3 nor; - /* Select the right normal by cheking if the generic attrib is used. */ + /* Select the right normal by checking if the generic attribute is used. */ if (!all(equal(lnor.xyz, vec3(0)))) { if (lnor.w < 0.0) { finalColor = vec4(0.0); diff --git a/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl index 97183638a71..474f3254389 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl @@ -1,7 +1,7 @@ in vec3 pos; in vec4 color; -in int colorid; /* if equal 0 (i.e: Not specified) use color attrib and stippling. */ +in int colorid; /* if equal 0 (i.e: Not specified) use color attribute and stippling. */ noperspective out vec2 stipple_coord; flat out vec2 stipple_start; diff --git a/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl b/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl index 3fefe2cc0bf..7e71f4ae587 100644 --- a/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl @@ -101,8 +101,8 @@ void wire_object_color_get(out vec3 rim_col, out vec3 wire_col) void main() { - bool no_attrib = all(equal(nor, vec3(0))); - vec3 wnor = no_attrib ? ViewMatrixInverse[2].xyz : normalize(normal_object_to_world(nor)); + bool no_attr = all(equal(nor, vec3(0))); + vec3 wnor = no_attr ? ViewMatrixInverse[2].xyz : normalize(normal_object_to_world(nor)); vec3 wpos = point_object_to_world(pos); @@ -152,7 +152,7 @@ void main() #endif /* Cull flat edges below threshold. */ - if (!no_attrib && (get_edge_sharpness(wd) < 0.0)) { + if (!no_attr && (get_edge_sharpness(wd) < 0.0)) { edgeStart = vec2(-1.0); } diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 2d6d6c7d9d0..de4bf0303fe 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -404,11 +404,11 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint count); -/* Warning: Only use with Shaders that have INSTANCED_ATTRIB defined. */ -void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup, - Object *ob, - struct GPUBatch *geom, - struct GPUBatch *inst_attributes); +/* Warning: Only use with Shaders that have INSTANCED_ATTR defined. */ +void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, + Object *ob, + struct GPUBatch *geom, + struct GPUBatch *inst_attributes); void DRW_shgroup_call_sculpt(DRWShadingGroup *sh, Object *ob, bool wire, bool mask, bool vcol); void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **sh, Object *ob, bool vcol); diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index 3f7421dc2f6..70fe6a55461 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -1775,10 +1775,10 @@ static void *extract_uv_init(const MeshRenderData *mr, void *buf) for (int i = 0; i < MAX_MTFACE; i++) { if (uv_layers & (1 << i)) { - char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i); - GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* UV layer name. */ BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name); GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1882,9 +1882,9 @@ static void extract_tan_ex(const MeshRenderData *mr, GPUVertBuf *vbo, const bool for (int i = 0; i < MAX_MTFACE; i++) { if (tan_layers & (1 << i)) { - char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i); - GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* Tangent layer name. */ BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name); GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode); @@ -1959,9 +1959,9 @@ static void extract_tan_ex(const MeshRenderData *mr, GPUVertBuf *vbo, const bool } if (use_orco_tan) { - char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_TANGENT, 0); - GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_snprintf(attr_name, sizeof(*attr_name), "t%s", attr_safe_name); GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode); GPU_vertformat_alias_add(&format, "t"); @@ -2090,9 +2090,9 @@ static void *extract_vcol_init(const MeshRenderData *mr, void *buf) for (int i = 0; i < 8; i++) { if (vcol_layers & (1 << i)) { - char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i); - GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name); GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); @@ -2164,7 +2164,7 @@ static void *extract_orco_init(const MeshRenderData *mr, void *buf) static GPUVertFormat format = {0}; if (format.attr_len == 0) { /* FIXME(fclem): We use the last component as a way to differentiate from generic vertex - * attribs. This is a substantial waste of Vram and should be done another way. + * attributes. This is a substantial waste of Vram and should be done another way. * Unfortunately, at the time of writing, I did not found any other "non disruptive" * alternative. */ GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); @@ -2192,7 +2192,7 @@ static void extract_orco_loop_bmesh(const MeshRenderData *UNUSED(mr), MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data; float *loop_orco = orco_data->vbo_data[l]; copy_v3_v3(loop_orco, orco_data->orco[BM_elem_index_get(loop->v)]); - loop_orco[3] = 0.0; /* Tag as not a generic attrib */ + loop_orco[3] = 0.0; /* Tag as not a generic attribute. */ } static void extract_orco_loop_mesh(const MeshRenderData *UNUSED(mr), @@ -2205,7 +2205,7 @@ static void extract_orco_loop_mesh(const MeshRenderData *UNUSED(mr), MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data; float *loop_orco = orco_data->vbo_data[l]; copy_v3_v3(loop_orco, orco_data->orco[mloop->v]); - loop_orco[3] = 0.0; /* Tag as not a generic attrib */ + loop_orco[3] = 0.0; /* Tag as not a generic attribute. */ } static void extract_orco_finish(const MeshRenderData *UNUSED(mr), void *UNUSED(buf), void *data) diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c index 3cbcdc1ede6..547a9a54b55 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.c +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c @@ -174,7 +174,8 @@ static GPUVertFormat *gpencil_stroke_format(void) GPU_vertformat_attr_add(&format, "ma", GPU_COMP_I32, 4, GPU_FETCH_INT); GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPU_vertformat_attr_add(&format, "uv", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - /* IMPORTANT: This means having only 4 attributes to fit into GPU module limit of 16 attrib. */ + /* IMPORTANT: This means having only 4 attributes + * to fit into GPU module limit of 16 attributes. */ GPU_vertformat_multiload_enable(&format, 4); } return &format; @@ -208,7 +209,8 @@ static GPUVertFormat *gpencil_color_format(void) if (format.attr_len == 0) { GPU_vertformat_attr_add(&format, "col", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPU_vertformat_attr_add(&format, "fcol", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - /* IMPORTANT: This means having only 4 attributes to fit into GPU module limit of 16 attrib. */ + /* IMPORTANT: This means having only 4 attributes + * to fit into GPU module limit of 16 attributes. */ GPU_vertformat_multiload_enable(&format, 4); } return &format; diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index fb0423a87a6..f6ffb8a1b8d 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -561,7 +561,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode) mesh_batch_cache_discard_uvedit_select(cache); break; case BKE_MESH_BATCH_DIRTY_SELECT_PAINT: - /* Paint mode selection flag is packed inside the nor attrib. + /* Paint mode selection flag is packed inside the nor attribute. * Note that it can be slow if auto smooth is enabled. (see T63946) */ FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) { GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.lines_paint_mask); @@ -1173,10 +1173,10 @@ void DRW_mesh_batch_cache_create_requested( MeshBufferCache *mbufcache = &cache->final; - /* Init batches and request VBOs & IBOs */ + /* Initialize batches and request VBO's & IBO's. */ if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.surface, &mbufcache->ibo.tris); - /* Order matters. First ones override latest vbos' attribs. */ + /* Order matters. First ones override latest VBO's attributes. */ DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor); DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.pos_nor); if (cache->cd_used.uv != 0) { @@ -1209,7 +1209,7 @@ void DRW_mesh_batch_cache_create_requested( } if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.wire_loops, &mbufcache->ibo.lines_paint_mask); - /* Order matters. First ones override latest vbos' attribs. */ + /* Order matters. First ones override latest VBO's attributes. */ DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.lnor); DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.pos_nor); } @@ -1241,7 +1241,7 @@ void DRW_mesh_batch_cache_create_requested( else { DRW_ibo_request(cache->surface_per_mat[i], &mbufcache->ibo.tris); } - /* Order matters. First ones override latest vbos' attribs. */ + /* Order matters. First ones override latest VBO's attributes. */ DRW_vbo_request(cache->surface_per_mat[i], &mbufcache->vbo.lnor); DRW_vbo_request(cache->surface_per_mat[i], &mbufcache->vbo.pos_nor); if (cache->cd_used.uv != 0) { diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 42a1dce891d..dca4f8e01e6 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -877,9 +877,9 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); - char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); - GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%s", attr_safe_name); @@ -898,9 +898,9 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); - char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); - GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%s", attr_safe_name); @@ -1164,9 +1164,9 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, for (int i = 0; i < num_uv_layers; i++) { - char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); - GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_snprintf(uuid, sizeof(uuid), "u%s", attr_safe_name); uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1177,9 +1177,9 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, } for (int i = 0; i < num_col_layers; i++) { - char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; + char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); - GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_snprintf(uuid, sizeof(uuid), "c%s", attr_safe_name); col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_U16, 4, GPU_FETCH_FLOAT); diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 4d9eaf88a7d..b599ad389c1 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -25,7 +25,7 @@ #define __DRAW_HAIR_PRIVATE_H__ #define MAX_LAYER_NAME_CT 4 /* u0123456789, u, au, a0123456789 */ -#define MAX_LAYER_NAME_LEN GPU_MAX_SAFE_ATTRIB_NAME + 2 +#define MAX_LAYER_NAME_LEN GPU_MAX_SAFE_ATTR_NAME + 2 #define MAX_THICKRES 2 /* see eHairType */ #define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index df7f0597017..f6d8179b193 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -210,7 +210,7 @@ typedef struct DRWCommandDrawInstance { GPUBatch *batch; DRWResourceHandle handle; uint inst_count; - uint use_attribs; /* bool */ + uint use_attrs; /* bool */ } DRWCommandDrawInstance; typedef struct DRWCommandDrawInstanceRange { diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 1d1ca575b02..fd13e22ff4e 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -657,17 +657,14 @@ static void drw_command_draw_range( cmd->vert_count = count; } -static void drw_command_draw_instance(DRWShadingGroup *shgroup, - GPUBatch *batch, - DRWResourceHandle handle, - uint count, - bool use_attrib) +static void drw_command_draw_instance( + DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint count, bool use_attr) { DRWCommandDrawInstance *cmd = drw_command_create(shgroup, DRW_CMD_DRAW_INSTANCE); cmd->batch = batch; cmd->handle = handle; cmd->inst_count = count; - cmd->use_attribs = use_attrib; + cmd->use_attrs = use_attr; } static void drw_command_draw_intance_range( @@ -841,10 +838,10 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, drw_command_draw_instance(shgroup, geom, handle, count, false); } -void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup, - Object *ob, - struct GPUBatch *geom, - struct GPUBatch *inst_attributes) +void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, + Object *ob, + struct GPUBatch *geom, + struct GPUBatch *inst_attributes) { BLI_assert(geom != NULL); BLI_assert(inst_attributes != NULL); diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 8e712295b61..6c62d4d2405 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -1376,7 +1376,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) 0, 0, cmd->instance.inst_count, - cmd->instance.use_attribs == 0); + cmd->instance.use_attrs == 0); break; case DRW_CMD_DRAW_RANGE: draw_call_single_do(shgroup, diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl b/source/blender/draw/intern/shaders/common_view_lib.glsl index 3faefd485bf..1054f4d11c9 100644 --- a/source/blender/draw/intern/shaders/common_view_lib.glsl +++ b/source/blender/draw/intern/shaders/common_view_lib.glsl @@ -77,12 +77,12 @@ uniform int resourceChunk; uniform int baseInstance; # endif -# if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTRIB) +# if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTR) /* When drawing instances of an object at the same position. */ # define instanceId 0 # elif defined(GPU_DEPRECATED_AMD_DRIVER) /* A driver bug make it so that when using an attribute with GL_INT_2_10_10_10_REV as format, - * the gl_InstanceID is incremented by the 2 bit component of the attrib. + * the gl_InstanceID is incremented by the 2 bit component of the attribute. * Ignore gl_InstanceID then. */ # define instanceId 0 # else @@ -124,7 +124,7 @@ flat in int resourceIDFrag; /* Breaking this across multiple lines causes issues for some older GLSL compilers. */ /* clang-format off */ -#if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTRIB) +#if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTR) /* clang-format on */ struct ObjectMatrices { mat4 drw_modelMatrix; diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 7a8900997d0..f0c1c4c0b98 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -88,8 +88,8 @@ typedef struct GPUShaderInterface { char *name_buffer; struct GPUBatch **batches; /* references to batches using this interface */ uint batches_len; - /** All enabled attribs in this shader. Used to set default values for unbound attribs. */ - uint16_t enabled_attrib_mask; + /** All enabled attributes in this shader. Used to set default values for unbound attributes. */ + uint16_t enabled_attr_mask; } GPUShaderInterface; GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 7e384d0a692..7adad2ff831 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -39,7 +39,7 @@ extern "C" { #define GPU_VERT_ATTR_NAMES_BUF_LEN 256 #define GPU_VERT_FORMAT_MAX_NAMES 63 /* More than enough, actual max is ~30. */ /* Computed as GPU_VERT_ATTR_NAMES_BUF_LEN / 30 (actual max format name). */ -#define GPU_MAX_SAFE_ATTRIB_NAME 12 +#define GPU_MAX_SAFE_ATTR_NAME 12 typedef enum { GPU_COMP_I8, @@ -94,7 +94,7 @@ typedef struct GPUVertFormat { uint packed : 1; /** Current offset in names[]. */ uint name_offset : 8; - /** Store each attrib in one contiguous buffer region. */ + /** Store each attribute in one contiguous buffer region. */ uint deinterleaved : 1; GPUVertAttr attrs[GPU_VERT_ATTR_MAX_LEN]; @@ -125,7 +125,7 @@ BLI_INLINE const char *GPU_vertformat_attr_name_get(const GPUVertFormat *format, return format->names + attr->names[n_idx]; } -void GPU_vertformat_safe_attrib_name(const char *attrib_name, char *r_safe_name, uint max_len); +void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint max_len); /* format conversion */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index fcfa4b7f0af..b0a24b1f2ff 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -42,7 +42,7 @@ #include #include -static GLuint g_default_attrib_vbo = 0; +static GLuint g_default_attr_vbo = 0; static void batch_update_program_bindings(GPUBatch *batch, uint i_first); @@ -416,7 +416,7 @@ void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *i static void create_bindings(GPUVertBuf *verts, const GPUShaderInterface *interface, - uint16_t *attrib_mask, + uint16_t *attr_mask, uint v_first, const bool use_instancing) { @@ -449,7 +449,7 @@ static void create_bindings(GPUVertBuf *verts, continue; } - *attrib_mask &= ~(1 << input->location); + *attr_mask &= ~(1 << input->location); if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE @@ -492,27 +492,27 @@ static void create_bindings(GPUVertBuf *verts, static void batch_update_program_bindings(GPUBatch *batch, uint i_first) { - uint16_t attrib_mask = batch->interface->enabled_attrib_mask; + uint16_t attr_mask = batch->interface->enabled_attr_mask; - /* Reverse order so first vbos have more prevalence (in term of attrib override). */ + /* Reverse order so first VBO'S have more prevalence (in term of attribute override). */ for (int v = GPU_BATCH_VBO_MAX_LEN - 1; v > -1; v--) { if (batch->verts[v] != NULL) { - create_bindings(batch->verts[v], batch->interface, &attrib_mask, 0, false); + create_bindings(batch->verts[v], batch->interface, &attr_mask, 0, false); } } for (int v = GPU_BATCH_INST_VBO_MAX_LEN - 1; v > -1; v--) { if (batch->inst[v]) { - create_bindings(batch->inst[v], batch->interface, &attrib_mask, i_first, true); + create_bindings(batch->inst[v], batch->interface, &attr_mask, i_first, true); } } - if (attrib_mask != 0 && GLEW_ARB_vertex_attrib_binding) { + if (attr_mask != 0 && GLEW_ARB_vertex_attrib_binding) { for (uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) { - if (attrib_mask & mask) { + if (attr_mask & mask) { /* This replaces glVertexAttrib4f(a, 0.0f, 0.0f, 0.0f, 1.0f); with a more modern style. * Fix issues for some drivers (see T75069). */ - glBindVertexBuffer(a, g_default_attrib_vbo, (intptr_t)0, (intptr_t)0); + glBindVertexBuffer(a, g_default_attr_vbo, (intptr_t)0, (intptr_t)0); glEnableVertexAttribArray(a); glVertexAttribFormat(a, 4, GL_FLOAT, GL_FALSE, 0); @@ -712,8 +712,8 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi } /* Verify there is enough data do draw. */ - /* TODO(fclem) Nice to have but this is invalid when using procedural drawcalls. - * The right assert would be to check if there is an enabled attrib from each VBO + /* TODO(fclem) Nice to have but this is invalid when using procedural draw-calls. + * The right assert would be to check if there is an enabled attribute from each VBO * and check their length. */ // BLI_assert(i_first + i_count <= (batch->inst ? batch->inst->vertex_len : INT_MAX)); // BLI_assert(v_first + v_count <= @@ -1025,11 +1025,11 @@ void GPU_batch_program_set_imm_shader(GPUBatch *batch) void gpu_batch_init(void) { - if (g_default_attrib_vbo == 0) { - g_default_attrib_vbo = GPU_buf_alloc(); + if (g_default_attr_vbo == 0) { + g_default_attr_vbo = GPU_buf_alloc(); float default_attrib_data[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - glBindBuffer(GL_ARRAY_BUFFER, g_default_attrib_vbo); + glBindBuffer(GL_ARRAY_BUFFER, g_default_attr_vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4, default_attrib_data, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -1039,8 +1039,8 @@ void gpu_batch_init(void) void gpu_batch_exit(void) { - GPU_buf_free(g_default_attrib_vbo); - g_default_attrib_vbo = 0; + GPU_buf_free(g_default_attr_vbo); + g_default_attr_vbo = 0; gpu_batch_presets_exit(); } diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 211ae0b3897..f279ab2c86c 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -689,8 +689,8 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo BLI_dynstr_appendf(ds, "#define att%d %s\n", attr->id, attr_prefix_get(attr->type)); } else { - char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; - GPU_vertformat_safe_attrib_name(attr->name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; + GPU_vertformat_safe_attr_name(attr->name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s%s);\n", gpu_data_type_to_string(attr->gputype), diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 349a7217456..b877da3f1d5 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -236,7 +236,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) shaderface->name_buffer = MEM_mallocN(name_buffer_len, "name_buffer"); /* Attributes */ - shaderface->enabled_attrib_mask = 0; + shaderface->enabled_attr_mask = 0; for (uint32_t i = 0; i < attr_len; i++) { GPUShaderInput *input = MEM_mallocN(sizeof(GPUShaderInput), "GPUShaderInput Attr"); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -256,7 +256,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) input->location = glGetAttribLocation(program, name); - shaderface->enabled_attrib_mask |= (1 << input->location); + shaderface->enabled_attr_mask |= (1 << input->location); set_input_name(shaderface, input, name, name_len); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index 1df7e68e08b..25daabe601d 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -196,7 +196,7 @@ void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data) GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data); } -/** Fills a whole vertex (all attribs). Data must match packed layout. */ +/** Fills a whole vertex (all attributes). Data must match packed layout. */ void GPU_vertbuf_vert_set(GPUVertBuf *verts, uint v_idx, const void *data) { const GPUVertFormat *format = &verts->format; diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 8370bcf4beb..e6a9cb8f2f2 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -207,15 +207,15 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias) } /** - * Makes vertex attrib from the next vertices to be accessible in the vertex shader. - * For an attrib named "attr" you can access the next nth vertex using "attrn". - * Use this function after specifying all the attribs in the format. + * Makes vertex attribute from the next vertices to be accessible in the vertex shader. + * For an attribute named "attr" you can access the next nth vertex using "attr{number}". + * Use this function after specifying all the attributes in the format. * * NOTE: This does NOT work when using indexed rendering. - * NOTE: Only works for first attrib name. (this limitation can be changed if needed) + * NOTE: Only works for first attribute name. (this limitation can be changed if needed) * - * WARNING: this function creates a lot of aliases/attribs, make sure to keep the attrib name - * short to avoid overflowing the namebuffer. + * WARNING: this function creates a lot of aliases/attributes, make sure to keep the attribute + * name short to avoid overflowing the name-buffer. * */ void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count) { @@ -276,28 +276,26 @@ static void safe_bytes(char out[11], const char data[8]) /* Warning: Always add a prefix to the result of this function as * the generated string can start with a number and not be a valid attribute name. */ -void GPU_vertformat_safe_attrib_name(const char *attrib_name, - char *r_safe_name, - uint UNUSED(max_len)) +void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint UNUSED(max_len)) { char data[8] = {0}; - uint len = strlen(attrib_name); + uint len = strlen(attr_name); if (len > 8) { /* Start with the first 4 chars of the name; */ for (int i = 0; i < 4; i++) { - data[i] = attrib_name[i]; + data[i] = attr_name[i]; } /* We use a hash to identify each data layer based on its name. * NOTE: This is still prone to hash collision but the risks are very low.*/ /* Start hashing after the first 2 chars. */ - *(uint *)&data[4] = BLI_ghashutil_strhash_p_murmur(attrib_name + 4); + *(uint *)&data[4] = BLI_ghashutil_strhash_p_murmur(attr_name + 4); } else { /* Copy the whole name. Collision is barely possible * (hash would have to be equal to the last 4 bytes). */ - for (int i = 0; i < 8 && attrib_name[i] != '\0'; i++) { - data[i] = attrib_name[i]; + for (int i = 0; i < 8 && attr_name[i] != '\0'; i++) { + data[i] = attr_name[i]; } } /* Convert to safe bytes characters. */ @@ -305,9 +303,9 @@ void GPU_vertformat_safe_attrib_name(const char *attrib_name, /* End the string */ r_safe_name[11] = '\0'; - BLI_assert(GPU_MAX_SAFE_ATTRIB_NAME >= 12); + BLI_assert(GPU_MAX_SAFE_ATTR_NAME >= 12); #if 0 /* For debugging */ - printf("%s > %lx > %s\n", attrib_name, *(uint64_t *)data, r_safe_name); + printf("%s > %lx > %s\n", attr_name, *(uint64_t *)data, r_safe_name); #endif } @@ -316,13 +314,13 @@ void GPU_vertformat_safe_attrib_name(const char *attrib_name, * Use direct buffer access to fill the data. * This is for advanced usage. * - * Deinterleaved data means all attrib data for each attrib - * is stored continuously like this : + * De-interleaved data means all attribute data for each attribute + * is stored continuously like this: * 000011112222 * instead of : * 012012012012 * - * Note this is per attrib deinterleaving, NOT per component. + * Note this is per attribute de-interleaving, NOT per component. * */ void GPU_vertformat_deinterleave(GPUVertFormat *format) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 8f001c9031f..a1719895853 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1938,12 +1938,12 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, IMB_metadata_ensure(&ibuf->metadata); for (iter = header.begin(); iter != header.end(); iter++) { - const StringAttribute *attrib = file->header(0).findTypedAttribute( + const StringAttribute *attr = file->header(0).findTypedAttribute( iter.name()); /* not all attributes are string attributes so we might get some NULLs here */ - if (attrib) { - IMB_metadata_set_field(ibuf->metadata, iter.name(), attrib->value().c_str()); + if (attr) { + IMB_metadata_set_field(ibuf->metadata, iter.name(), attr->value().c_str()); ibuf->flags |= IB_metadata; } } -- cgit v1.2.3 From 9aad06db8880a4097ab6c0f019185aa6671e55a6 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 3 Apr 2020 10:19:01 +0200 Subject: Fix T75315: typo in automasking UI text --- source/blender/makesrna/intern/rna_brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index fed81b86417..b625b3f0a84 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -2242,7 +2242,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_range(prop, 1, 20, 1, 3); RNA_def_property_ui_text(prop, "Propagation Steps", - "Distance where boundary edge automaking is going to protect vertices " + "Distance where boundary edge automasking is going to protect vertices " "from the fully masked edge"); RNA_def_property_update(prop, 0, "rna_Brush_update"); -- cgit v1.2.3 From a2a70cfc41edf3f8d63dcc6bc8d6b946583bec1a Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 1 Apr 2020 18:33:58 +0200 Subject: Cleanup: typo in comment --- source/blender/editors/space_info/info_stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 78bc0961cb3..e0e6edda850 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -582,8 +582,8 @@ void ED_info_stats_clear(ViewLayer *view_layer) const char *ED_info_stats_string(Main *bmain, Scene *scene, ViewLayer *view_layer) { - /* Looping through dependency graph when interface is locked in not safe. - * Thew interface is marked as locked when jobs wants to modify the + /* Looping through dependency graph when interface is locked is not safe. + * The interface is marked as locked when jobs wants to modify the * dependency graph. */ wmWindowManager *wm = bmain->wm.first; if (wm->is_interface_locked) { -- cgit v1.2.3 From fe7ea8a24c8a147078d033b76d9a37a84042368c Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 2 Apr 2020 16:52:43 +0200 Subject: Fix T75250: setting greasepencil active layer not refreshing the dopesheet This was only reported for the 'Change Active Layer' operator [which was not setting the channel as selected in the dopesheet], but this is also the case elsewhere [where BKE_gpencil_layer_active_set is used], namely: - gp_layer_remove_exec - gp_layer_copy_exec - gp_merge_layer_exec - gp_layer_change_exec - gp_layer_active_exec - gp_stroke_separate_exec We could set GP_LAYER_SELECT "by hand" in BKE_gpencil_layer_active_set(), but there is already animchan_sync_gplayer() that does that. For this, we need the NA_SELECTED notifier though. Maniphest Tasks: T75250 Differential Revision: https://developer.blender.org/D7311 --- source/blender/editors/gpencil/gpencil_data.c | 5 +++++ source/blender/editors/gpencil/gpencil_edit.c | 1 + 2 files changed, 6 insertions(+) diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 898facb86e8..a12f960c29e 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -331,6 +331,7 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op) /* notifiers */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -478,6 +479,7 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op)) /* notifiers */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -1228,6 +1230,7 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op) /* notifiers */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -1291,6 +1294,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op) /* updates */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -1336,6 +1340,7 @@ static int gp_layer_active_exec(bContext *C, wmOperator *op) /* updates */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 91169b34e34..8c31df02a11 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -4364,6 +4364,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -- cgit v1.2.3 From cecb25273ec6f473d3f8ae0b201e17a77225dd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Apr 2020 11:33:21 +0200 Subject: Cleanup: Font, added initialisation for two variables My compiler (GCC 7.5.0) was warning about these variables potentially not being initialised. Since the function is highly complex, instead of analysing it I just trust my compiler and added initial values. This should be no functional change. --- source/blender/blenkernel/intern/font.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index e25603e0af5..a4da7ceb861 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -734,7 +734,7 @@ static bool vfont_to_curve(Object *ob, float twidth = 0, maxlen = 0; int i, slen, j; int curbox; - int selstart, selend; + int selstart = 0, selend = 0; int cnr = 0, lnr = 0, wsnr = 0; const char32_t *mem = NULL; char32_t ascii; -- cgit v1.2.3 From 736f9f5a69c9565bc9b4c645bb2dcfcd22a95aff Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 3 Apr 2020 11:29:45 +0200 Subject: Fix accidentally reverted changes in VR merge due to merge error dc2df8307f41 unintentionally reverted part of 07bdbeda8462. --- source/blender/editors/space_view3d/view3d_gizmo_navigate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index cc00037b1fb..533fba3795b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -321,14 +321,14 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) { gz = navgroup->gz_array[GZ_INDEX_CAMERA]; - gz->matrix_basis[3][0] = co[0]; - gz->matrix_basis[3][1] = co[1] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][0] = roundf(co[0]); + gz->matrix_basis[3][1] = roundf(co[1] - (icon_offset_mini * icon_mini_slot++)); WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); if (navgroup->state.rv3d.is_camera == false) { gz = navgroup->gz_array[rv3d->is_persp ? GZ_INDEX_PERSP : GZ_INDEX_ORTHO]; - gz->matrix_basis[3][0] = co[0]; - gz->matrix_basis[3][1] = co[1] - (icon_offset_mini * icon_mini_slot++); + gz->matrix_basis[3][0] = roundf(co[0]); + gz->matrix_basis[3][1] = roundf(co[1] - (icon_offset_mini * icon_mini_slot++)); WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); } } -- cgit v1.2.3 From b5253159b6113e1f54297ebe06322191b483996e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Apr 2020 11:35:04 +0200 Subject: Cleanup: split `BKE_anim.h` and `anim.c` into smaller pieces The files are now split up into the following sections: - `BKE_anim_path.h` and `anim_path.c` for path/curve functions. - `BKE_anim_visualization.h` and `anim_visualizationanim_path.c` for animation visualization (mostly motion paths). - `BKE_duplilist.h` for DupliList function declarations. These were already implemented in `object_dupli.c`, so they were rather out of place being declared in `BKE_anim.h` in the first place. No functional changes. --- source/blender/blenkernel/BKE_anim.h | 101 ---- source/blender/blenkernel/BKE_anim_path.h | 51 ++ source/blender/blenkernel/BKE_anim_visualization.h | 56 ++ source/blender/blenkernel/BKE_duplilist.h | 68 +++ source/blender/blenkernel/CMakeLists.txt | 7 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim.c | 561 --------------------- source/blender/blenkernel/intern/anim_path.c | 347 +++++++++++++ .../blender/blenkernel/intern/anim_visualization.c | 228 +++++++++ source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/armature_update.c | 2 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/displist.c | 2 +- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/object.c | 4 +- source/blender/blenkernel/intern/object_dupli.c | 2 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 1 - source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenloader/intern/versioning_250.c | 2 +- source/blender/blenloader/intern/versioning_260.c | 2 +- .../depsgraph/intern/depsgraph_query_iter.cc | 2 +- .../blender/draw/engines/overlay/overlay_extra.c | 2 +- source/blender/draw/intern/draw_hair.c | 2 +- source/blender/draw/intern/draw_manager.c | 2 +- source/blender/draw/intern/draw_manager_data.c | 2 +- source/blender/editors/armature/pose_edit.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/space_info/info_stats.c | 1 - source/blender/editors/transform/transform_snap.c | 2 +- .../editors/transform/transform_snap_object.c | 2 +- source/blender/io/alembic/intern/abc_exporter.cc | 2 +- .../io/usd/intern/abstract_hierarchy_iterator.cc | 2 +- .../io/usd/intern/usd_hierarchy_iterator.cc | 2 +- source/blender/io/usd/intern/usd_writer_mesh.cc | 1 - source/blender/makesrna/intern/rna_depsgraph.c | 2 +- source/blender/makesrna/intern/rna_object_api.c | 1 - 40 files changed, 785 insertions(+), 696 deletions(-) delete mode 100644 source/blender/blenkernel/BKE_anim.h create mode 100644 source/blender/blenkernel/BKE_anim_path.h create mode 100644 source/blender/blenkernel/BKE_anim_visualization.h create mode 100644 source/blender/blenkernel/BKE_duplilist.h delete mode 100644 source/blender/blenkernel/intern/anim.c create mode 100644 source/blender/blenkernel/intern/anim_path.c create mode 100644 source/blender/blenkernel/intern/anim_visualization.c diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h deleted file mode 100644 index 38af96c2ff0..00000000000 --- a/source/blender/blenkernel/BKE_anim.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ -#ifndef __BKE_ANIM_H__ -#define __BKE_ANIM_H__ - -/** \file - * \ingroup bke - */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct Depsgraph; -struct ListBase; -struct Object; -struct ParticleSystem; -struct Path; -struct ReportList; -struct Scene; -struct bAnimVizSettings; -struct bMotionPath; -struct bPoseChannel; - -/* ---------------------------------------------------- */ -/* Animation Visualization */ - -void animviz_settings_init(struct bAnimVizSettings *avs); - -struct bMotionPath *animviz_copy_motionpath(const struct bMotionPath *mpath_src); - -void animviz_free_motionpath_cache(struct bMotionPath *mpath); -void animviz_free_motionpath(struct bMotionPath *mpath); - -struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, - struct Scene *scene, - struct Object *ob, - struct bPoseChannel *pchan); - -/* ---------------------------------------------------- */ -/* Curve Paths */ - -void free_path(struct Path *path); -void calc_curvepath(struct Object *ob, struct ListBase *nurbs); -int where_on_path(struct Object *ob, - float ctime, - float vec[4], - float dir[3], - float quat[4], - float *radius, - float *weight); - -/* ---------------------------------------------------- */ -/* Dupli-Geometry */ - -struct ListBase *object_duplilist(struct Depsgraph *depsgraph, - struct Scene *sce, - struct Object *ob); -void free_object_duplilist(struct ListBase *lb); - -typedef struct DupliObject { - struct DupliObject *next, *prev; - struct Object *ob; - float mat[4][4]; - float orco[3], uv[2]; - - short type; /* from Object.transflag */ - char no_draw; - - /* Persistent identifier for a dupli object, for inter-frame matching of - * objects with motion blur, or inter-update matching for syncing. */ - int persistent_id[16]; /* 2*MAX_DUPLI_RECUR */ - - /* Particle this dupli was generated from. */ - struct ParticleSystem *particle_system; - - /* Random ID for shading */ - unsigned int random_id; -} DupliObject; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source/blender/blenkernel/BKE_anim_path.h b/source/blender/blenkernel/BKE_anim_path.h new file mode 100644 index 00000000000..64bcedefa58 --- /dev/null +++ b/source/blender/blenkernel/BKE_anim_path.h @@ -0,0 +1,51 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ +#ifndef __BKE_ANIM_PATH_H__ +#define __BKE_ANIM_PATH_H__ + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ListBase; +struct Object; +struct Path; + +/* ---------------------------------------------------- */ +/* Curve Paths */ + +void free_path(struct Path *path); +void calc_curvepath(struct Object *ob, struct ListBase *nurbs); +int where_on_path(struct Object *ob, + float ctime, + float vec[4], + float dir[3], + float quat[4], + float *radius, + float *weight); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/blender/blenkernel/BKE_anim_visualization.h b/source/blender/blenkernel/BKE_anim_visualization.h new file mode 100644 index 00000000000..5dcbfa0919e --- /dev/null +++ b/source/blender/blenkernel/BKE_anim_visualization.h @@ -0,0 +1,56 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ +#ifndef __BKE_ANIM_VISUALIZATION_H__ +#define __BKE_ANIM_VISUALIZATION_H__ + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct Object; +struct ReportList; +struct Scene; +struct bAnimVizSettings; +struct bMotionPath; +struct bPoseChannel; + +/* ---------------------------------------------------- */ +/* Animation Visualization */ + +void animviz_settings_init(struct bAnimVizSettings *avs); + +struct bMotionPath *animviz_copy_motionpath(const struct bMotionPath *mpath_src); + +void animviz_free_motionpath_cache(struct bMotionPath *mpath); +void animviz_free_motionpath(struct bMotionPath *mpath); + +struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, + struct Scene *scene, + struct Object *ob, + struct bPoseChannel *pchan); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/blender/blenkernel/BKE_duplilist.h b/source/blender/blenkernel/BKE_duplilist.h new file mode 100644 index 00000000000..71b6d06b450 --- /dev/null +++ b/source/blender/blenkernel/BKE_duplilist.h @@ -0,0 +1,68 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ +#ifndef __BKE_DUPLILIST_H__ +#define __BKE_DUPLILIST_H__ + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct Depsgraph; +struct ListBase; +struct Object; +struct ParticleSystem; +struct Scene; + +/* ---------------------------------------------------- */ +/* Dupli-Geometry */ + +struct ListBase *object_duplilist(struct Depsgraph *depsgraph, + struct Scene *sce, + struct Object *ob); +void free_object_duplilist(struct ListBase *lb); + +typedef struct DupliObject { + struct DupliObject *next, *prev; + struct Object *ob; + float mat[4][4]; + float orco[3], uv[2]; + + short type; /* from Object.transflag */ + char no_draw; + + /* Persistent identifier for a dupli object, for inter-frame matching of + * objects with motion blur, or inter-update matching for syncing. */ + int persistent_id[16]; /* 2*MAX_DUPLI_RECUR */ + + /* Particle this dupli was generated from. */ + struct ParticleSystem *particle_system; + + /* Random ID for shading */ + unsigned int random_id; +} DupliObject; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 1e230e5af3a..ba4339f56ac 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -70,8 +70,9 @@ set(SRC intern/DerivedMesh.c intern/action.c intern/addon.c - intern/anim.c + intern/anim_path.c intern/anim_sys.c + intern/anim_visualization.c intern/appdir.c intern/armature.c intern/armature_update.c @@ -250,7 +251,8 @@ set(SRC BKE_DerivedMesh.h BKE_action.h BKE_addon.h - BKE_anim.h + BKE_anim_path.h + BKE_anim_visualization.h BKE_animsys.h BKE_appdir.h BKE_armature.h @@ -286,6 +288,7 @@ set(SRC BKE_deform.h BKE_displist.h BKE_displist_tangent.h + BKE_duplilist.h BKE_dynamicpaint.h BKE_editlattice.h BKE_editmesh.h diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c332939e906..478609f2f3f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -43,7 +43,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c deleted file mode 100644 index 8804e7ae26c..00000000000 --- a/source/blender/blenkernel/intern/anim.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ - -/** \file - * \ingroup bke - */ - -#include "MEM_guardedalloc.h" - -#include - -#include "BLI_dlrbTree.h" -#include "BLI_listbase.h" -#include "BLI_math.h" - -#include "BLT_translation.h" - -#include "DNA_anim_types.h" -#include "DNA_armature_types.h" -#include "DNA_key_types.h" -#include "DNA_scene_types.h" - -#include "BKE_action.h" -#include "BKE_anim.h" -#include "BKE_animsys.h" -#include "BKE_curve.h" -#include "BKE_key.h" -#include "BKE_main.h" -#include "BKE_object.h" -#include "BKE_particle.h" -#include "BKE_report.h" -#include "BKE_scene.h" - -#include "DEG_depsgraph.h" -#include "DEG_depsgraph_build.h" -#include "DEG_depsgraph_query.h" - -#include "GPU_batch.h" - -#include "CLG_log.h" - -static CLG_LogRef LOG = {"bke.anim"}; - -/* --------------------- */ -/* forward declarations */ - -/* ******************************************************************** */ -/* Animation Visualization */ - -/* Initialize the default settings for animation visualization */ -void animviz_settings_init(bAnimVizSettings *avs) -{ - /* sanity check */ - if (avs == NULL) { - return; - } - - /* path settings */ - avs->path_bc = avs->path_ac = 10; - - avs->path_sf = 1; /* xxx - take from scene instead? */ - avs->path_ef = 250; /* xxx - take from scene instead? */ - - avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); - - avs->path_step = 1; - - avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS; -} - -/* ------------------- */ - -/* Free the given motion path's cache */ -void animviz_free_motionpath_cache(bMotionPath *mpath) -{ - /* sanity check */ - if (mpath == NULL) { - return; - } - - /* free the path if necessary */ - if (mpath->points) { - MEM_freeN(mpath->points); - } - - GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); - GPU_BATCH_DISCARD_SAFE(mpath->batch_line); - GPU_BATCH_DISCARD_SAFE(mpath->batch_points); - - /* reset the relevant parameters */ - mpath->points = NULL; - mpath->length = 0; -} - -/* Free the given motion path instance and its data - * NOTE: this frees the motion path given! - */ -void animviz_free_motionpath(bMotionPath *mpath) -{ - /* sanity check */ - if (mpath == NULL) { - return; - } - - /* free the cache first */ - animviz_free_motionpath_cache(mpath); - - /* now the instance itself */ - MEM_freeN(mpath); -} - -/* ------------------- */ - -/* Make a copy of motionpath data, so that viewing with copy on write works */ -bMotionPath *animviz_copy_motionpath(const bMotionPath *mpath_src) -{ - bMotionPath *mpath_dst; - - if (mpath_src == NULL) { - return NULL; - } - - mpath_dst = MEM_dupallocN(mpath_src); - mpath_dst->points = MEM_dupallocN(mpath_src->points); - - /* should get recreated on draw... */ - mpath_dst->points_vbo = NULL; - mpath_dst->batch_line = NULL; - mpath_dst->batch_points = NULL; - - return mpath_dst; -} - -/* ------------------- */ - -/** - * Setup motion paths for the given data. - * \note Only used when explicitly calculating paths on bones which may/may not be consider already - * - * \param scene: Current scene (for frame ranges, etc.) - * \param ob: Object to add paths for (must be provided) - * \param pchan: Posechannel to add paths for (optional; if not provided, object-paths are assumed) - */ -bMotionPath *animviz_verify_motionpaths(ReportList *reports, - Scene *scene, - Object *ob, - bPoseChannel *pchan) -{ - bAnimVizSettings *avs; - bMotionPath *mpath, **dst; - - /* sanity checks */ - if (ELEM(NULL, scene, ob)) { - return NULL; - } - - /* get destination data */ - if (pchan) { - /* paths for posechannel - assume that posechannel belongs to the object */ - avs = &ob->pose->avs; - dst = &pchan->mpath; - } - else { - /* paths for object */ - avs = &ob->avs; - dst = &ob->mpath; - } - - /* avoid 0 size allocs */ - if (avs->path_sf >= avs->path_ef) { - BKE_reportf(reports, - RPT_ERROR, - "Motion path frame extents invalid for %s (%d to %d)%s", - (pchan) ? pchan->name : ob->id.name, - avs->path_sf, - avs->path_ef, - (avs->path_sf == avs->path_ef) ? TIP_(", cannot have single-frame paths") : ""); - return NULL; - } - - /* if there is already a motionpath, just return that, - * provided it's settings are ok (saves extra free+alloc) - */ - if (*dst != NULL) { - int expected_length = avs->path_ef - avs->path_sf; - - mpath = *dst; - - /* Path is "valid" if length is valid, - * but must also be of the same length as is being requested. */ - if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) { - /* outer check ensures that we have some curve data for this path */ - if (mpath->length == expected_length) { - /* return/use this as it is already valid length */ - return mpath; - } - else { - /* clear the existing path (as the range has changed), and reallocate below */ - animviz_free_motionpath_cache(mpath); - } - } - } - else { - /* create a new motionpath, and assign it */ - mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath"); - *dst = mpath; - } - - /* set settings from the viz settings */ - mpath->start_frame = avs->path_sf; - mpath->end_frame = avs->path_ef; - - mpath->length = mpath->end_frame - mpath->start_frame; - - if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) { - mpath->flag |= MOTIONPATH_FLAG_BHEAD; - } - else { - mpath->flag &= ~MOTIONPATH_FLAG_BHEAD; - } - - /* set default custom values */ - mpath->color[0] = 1.0; /* Red */ - mpath->color[1] = 0.0; - mpath->color[2] = 0.0; - - mpath->line_thickness = 2; - mpath->flag |= MOTIONPATH_FLAG_LINES; /* draw lines by default */ - - /* allocate a cache */ - mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts"); - - /* tag viz settings as currently having some path(s) which use it */ - avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS; - - /* return it */ - return mpath; -} - -/* ******************************************************************** */ -/* Curve Paths - for curve deforms and/or curve following */ - -/* free curve path data - * NOTE: frees the path itself! - * NOTE: this is increasingly inaccurate with non-uniform BevPoint subdivisions [#24633] - */ -void free_path(Path *path) -{ - if (path->data) { - MEM_freeN(path->data); - } - MEM_freeN(path); -} - -/* calculate a curve-deform path for a curve - * - only called from displist.c -> do_makeDispListCurveTypes - */ -void calc_curvepath(Object *ob, ListBase *nurbs) -{ - BevList *bl; - BevPoint *bevp, *bevpn, *bevpfirst, *bevplast; - PathPoint *pp; - Nurb *nu; - Path *path; - float *fp, *dist, *maxdist, xyz[3]; - float fac, d = 0, fac1, fac2; - int a, tot, cycl = 0; - - /* in a path vertices are with equal differences: path->len = number of verts */ - /* NOW WITH BEVELCURVE!!! */ - - if (ob == NULL || ob->type != OB_CURVE) { - return; - } - - if (ob->runtime.curve_cache->path) { - free_path(ob->runtime.curve_cache->path); - } - ob->runtime.curve_cache->path = NULL; - - /* weak! can only use first curve */ - bl = ob->runtime.curve_cache->bev.first; - if (bl == NULL || !bl->nr) { - return; - } - - nu = nurbs->first; - - ob->runtime.curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath"); - - /* if POLY: last vertice != first vertice */ - cycl = (bl->poly != -1); - - tot = cycl ? bl->nr : bl->nr - 1; - - path->len = tot + 1; - /* Exception: vector handle paths and polygon paths should be subdivided - * at least a factor resolution. */ - if (path->len < nu->resolu * SEGMENTSU(nu)) { - path->len = nu->resolu * SEGMENTSU(nu); - } - - dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist"); - - /* all lengths in *dist */ - bevp = bevpfirst = bl->bevpoints; - fp = dist; - *fp = 0.0f; - for (a = 0; a < tot; a++) { - fp++; - if (cycl && a == tot - 1) { - sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec); - } - else { - sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec); - } - - *fp = *(fp - 1) + len_v3(xyz); - bevp++; - } - - path->totdist = *fp; - - /* the path verts in path->data */ - /* now also with TILT value */ - pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata"); - - bevp = bevpfirst; - bevpn = bevp + 1; - bevplast = bevpfirst + (bl->nr - 1); - if (UNLIKELY(bevpn > bevplast)) { - bevpn = cycl ? bevpfirst : bevplast; - } - fp = dist + 1; - maxdist = dist + tot; - fac = 1.0f / ((float)path->len - 1.0f); - fac = fac * path->totdist; - - for (a = 0; a < path->len; a++) { - - d = ((float)a) * fac; - - /* we're looking for location (distance) 'd' in the array */ - if (LIKELY(tot > 0)) { - while ((fp < maxdist) && (d >= *fp)) { - fp++; - if (bevp < bevplast) { - bevp++; - } - bevpn = bevp + 1; - if (UNLIKELY(bevpn > bevplast)) { - bevpn = cycl ? bevpfirst : bevplast; - } - } - - fac1 = (*(fp)-d) / (*(fp) - *(fp - 1)); - fac2 = 1.0f - fac1; - } - else { - fac1 = 1.0f; - fac2 = 0.0f; - } - - interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); - pp->vec[3] = fac1 * bevp->tilt + fac2 * bevpn->tilt; - pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius; - pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight; - interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); - normalize_qt(pp->quat); - - pp++; - } - - MEM_freeN(dist); -} - -static int interval_test(const int min, const int max, int p1, const int cycl) -{ - if (cycl) { - p1 = mod_i(p1 - min, (max - min + 1)) + min; - } - else { - if (p1 < min) { - p1 = min; - } - else if (p1 > max) { - p1 = max; - } - } - return p1; -} - -/* calculate the deformation implied by the curve path at a given parametric position, - * and returns whether this operation succeeded. - * - * note: ctime is normalized range <0-1> - * - * returns OK: 1/0 - */ -int where_on_path(Object *ob, - float ctime, - float vec[4], - float dir[3], - float quat[4], - float *radius, - float *weight) -{ - Curve *cu; - Nurb *nu; - BevList *bl; - Path *path; - PathPoint *pp, *p0, *p1, *p2, *p3; - float fac; - float data[4]; - int cycl = 0, s0, s1, s2, s3; - ListBase *nurbs; - - if (ob == NULL || ob->type != OB_CURVE) { - return 0; - } - cu = ob->data; - if (ob->runtime.curve_cache == NULL || ob->runtime.curve_cache->path == NULL || - ob->runtime.curve_cache->path->data == NULL) { - CLOG_WARN(&LOG, "no path!"); - return 0; - } - path = ob->runtime.curve_cache->path; - pp = path->data; - - /* test for cyclic */ - bl = ob->runtime.curve_cache->bev.first; - if (!bl) { - return 0; - } - if (!bl->nr) { - return 0; - } - if (bl->poly > -1) { - cycl = 1; - } - - /* values below zero for non-cyclic curves give strange results */ - BLI_assert(cycl || ctime >= 0.0f); - - ctime *= (path->len - 1); - - s1 = (int)floor(ctime); - fac = (float)(s1 + 1) - ctime; - - /* path->len is corrected for cyclic */ - s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl); - s1 = interval_test(0, path->len - 1 - cycl, s1, cycl); - s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl); - s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl); - - p0 = pp + s0; - p1 = pp + s1; - p2 = pp + s2; - p3 = pp + s3; - - /* NOTE: commented out for follow constraint - * - * If it's ever be uncommented watch out for curve_deform_verts() - * which used to temporary set CU_FOLLOW flag for the curve and no - * longer does it (because of threading issues of such a thing. - */ - // if (cu->flag & CU_FOLLOW) { - - key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE); - - interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); - - /* make compatible with vectoquat */ - negate_v3(dir); - //} - - nurbs = BKE_curve_editNurbs_get(cu); - if (!nurbs) { - nurbs = &cu->nurb; - } - nu = nurbs->first; - - /* make sure that first and last frame are included in the vectors here */ - if (nu->type == CU_POLY) { - key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); - } - else if (nu->type == CU_BEZIER) { - key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); - } - else if (s0 == s1 || p2 == p3) { - key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL); - } - else { - key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE); - } - - vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + - data[3] * p3->vec[0]; /* X */ - vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + - data[3] * p3->vec[1]; /* Y */ - vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + - data[3] * p3->vec[2]; /* Z */ - vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + - data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */ - - if (quat) { - float totfac, q1[4], q2[4]; - - totfac = data[0] + data[3]; - if (totfac > FLT_EPSILON) { - interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); - } - else { - copy_qt_qt(q1, p1->quat); - } - - totfac = data[1] + data[2]; - if (totfac > FLT_EPSILON) { - interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); - } - else { - copy_qt_qt(q2, p3->quat); - } - - totfac = data[0] + data[1] + data[2] + data[3]; - if (totfac > FLT_EPSILON) { - interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac); - } - else { - copy_qt_qt(quat, q2); - } - } - - if (radius) { - *radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + - data[3] * p3->radius; - } - - if (weight) { - *weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + - data[3] * p3->weight; - } - - return 1; -} diff --git a/source/blender/blenkernel/intern/anim_path.c b/source/blender/blenkernel/intern/anim_path.c new file mode 100644 index 00000000000..e073bd6fc82 --- /dev/null +++ b/source/blender/blenkernel/intern/anim_path.c @@ -0,0 +1,347 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ + +/** \file + * \ingroup bke + */ + +#include "MEM_guardedalloc.h" + +#include + +#include "DNA_curve_types.h" +#include "DNA_key_types.h" +#include "DNA_object_types.h" + +#include "BLI_math_vector.h" + +#include "BKE_anim_path.h" +#include "BKE_curve.h" +#include "BKE_key.h" + +#include "CLG_log.h" + +static CLG_LogRef LOG = {"bke.anim"}; + +/* ******************************************************************** */ +/* Curve Paths - for curve deforms and/or curve following */ + +/* free curve path data + * NOTE: frees the path itself! + * NOTE: this is increasingly inaccurate with non-uniform BevPoint subdivisions [#24633] + */ +void free_path(Path *path) +{ + if (path->data) { + MEM_freeN(path->data); + } + MEM_freeN(path); +} + +/* calculate a curve-deform path for a curve + * - only called from displist.c -> do_makeDispListCurveTypes + */ +void calc_curvepath(Object *ob, ListBase *nurbs) +{ + BevList *bl; + BevPoint *bevp, *bevpn, *bevpfirst, *bevplast; + PathPoint *pp; + Nurb *nu; + Path *path; + float *fp, *dist, *maxdist, xyz[3]; + float fac, d = 0, fac1, fac2; + int a, tot, cycl = 0; + + /* in a path vertices are with equal differences: path->len = number of verts */ + /* NOW WITH BEVELCURVE!!! */ + + if (ob == NULL || ob->type != OB_CURVE) { + return; + } + + if (ob->runtime.curve_cache->path) { + free_path(ob->runtime.curve_cache->path); + } + ob->runtime.curve_cache->path = NULL; + + /* weak! can only use first curve */ + bl = ob->runtime.curve_cache->bev.first; + if (bl == NULL || !bl->nr) { + return; + } + + nu = nurbs->first; + + ob->runtime.curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath"); + + /* if POLY: last vertice != first vertice */ + cycl = (bl->poly != -1); + + tot = cycl ? bl->nr : bl->nr - 1; + + path->len = tot + 1; + /* Exception: vector handle paths and polygon paths should be subdivided + * at least a factor resolution. */ + if (path->len < nu->resolu * SEGMENTSU(nu)) { + path->len = nu->resolu * SEGMENTSU(nu); + } + + dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist"); + + /* all lengths in *dist */ + bevp = bevpfirst = bl->bevpoints; + fp = dist; + *fp = 0.0f; + for (a = 0; a < tot; a++) { + fp++; + if (cycl && a == tot - 1) { + sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec); + } + else { + sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec); + } + + *fp = *(fp - 1) + len_v3(xyz); + bevp++; + } + + path->totdist = *fp; + + /* the path verts in path->data */ + /* now also with TILT value */ + pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata"); + + bevp = bevpfirst; + bevpn = bevp + 1; + bevplast = bevpfirst + (bl->nr - 1); + if (UNLIKELY(bevpn > bevplast)) { + bevpn = cycl ? bevpfirst : bevplast; + } + fp = dist + 1; + maxdist = dist + tot; + fac = 1.0f / ((float)path->len - 1.0f); + fac = fac * path->totdist; + + for (a = 0; a < path->len; a++) { + + d = ((float)a) * fac; + + /* we're looking for location (distance) 'd' in the array */ + if (LIKELY(tot > 0)) { + while ((fp < maxdist) && (d >= *fp)) { + fp++; + if (bevp < bevplast) { + bevp++; + } + bevpn = bevp + 1; + if (UNLIKELY(bevpn > bevplast)) { + bevpn = cycl ? bevpfirst : bevplast; + } + } + + fac1 = (*(fp)-d) / (*(fp) - *(fp - 1)); + fac2 = 1.0f - fac1; + } + else { + fac1 = 1.0f; + fac2 = 0.0f; + } + + interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); + pp->vec[3] = fac1 * bevp->tilt + fac2 * bevpn->tilt; + pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius; + pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight; + interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); + normalize_qt(pp->quat); + + pp++; + } + + MEM_freeN(dist); +} + +static int interval_test(const int min, const int max, int p1, const int cycl) +{ + if (cycl) { + p1 = mod_i(p1 - min, (max - min + 1)) + min; + } + else { + if (p1 < min) { + p1 = min; + } + else if (p1 > max) { + p1 = max; + } + } + return p1; +} + +/* calculate the deformation implied by the curve path at a given parametric position, + * and returns whether this operation succeeded. + * + * note: ctime is normalized range <0-1> + * + * returns OK: 1/0 + */ +int where_on_path(Object *ob, + float ctime, + float vec[4], + float dir[3], + float quat[4], + float *radius, + float *weight) +{ + Curve *cu; + Nurb *nu; + BevList *bl; + Path *path; + PathPoint *pp, *p0, *p1, *p2, *p3; + float fac; + float data[4]; + int cycl = 0, s0, s1, s2, s3; + ListBase *nurbs; + + if (ob == NULL || ob->type != OB_CURVE) { + return 0; + } + cu = ob->data; + if (ob->runtime.curve_cache == NULL || ob->runtime.curve_cache->path == NULL || + ob->runtime.curve_cache->path->data == NULL) { + CLOG_WARN(&LOG, "no path!"); + return 0; + } + path = ob->runtime.curve_cache->path; + pp = path->data; + + /* test for cyclic */ + bl = ob->runtime.curve_cache->bev.first; + if (!bl) { + return 0; + } + if (!bl->nr) { + return 0; + } + if (bl->poly > -1) { + cycl = 1; + } + + /* values below zero for non-cyclic curves give strange results */ + BLI_assert(cycl || ctime >= 0.0f); + + ctime *= (path->len - 1); + + s1 = (int)floor(ctime); + fac = (float)(s1 + 1) - ctime; + + /* path->len is corrected for cyclic */ + s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl); + s1 = interval_test(0, path->len - 1 - cycl, s1, cycl); + s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl); + s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl); + + p0 = pp + s0; + p1 = pp + s1; + p2 = pp + s2; + p3 = pp + s3; + + /* NOTE: commented out for follow constraint + * + * If it's ever be uncommented watch out for curve_deform_verts() + * which used to temporary set CU_FOLLOW flag for the curve and no + * longer does it (because of threading issues of such a thing. + */ + // if (cu->flag & CU_FOLLOW) { + + key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE); + + interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); + + /* make compatible with vectoquat */ + negate_v3(dir); + //} + + nurbs = BKE_curve_editNurbs_get(cu); + if (!nurbs) { + nurbs = &cu->nurb; + } + nu = nurbs->first; + + /* make sure that first and last frame are included in the vectors here */ + if (nu->type == CU_POLY) { + key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + } + else if (nu->type == CU_BEZIER) { + key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + } + else if (s0 == s1 || p2 == p3) { + key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL); + } + else { + key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE); + } + + vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + + data[3] * p3->vec[0]; /* X */ + vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + + data[3] * p3->vec[1]; /* Y */ + vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + + data[3] * p3->vec[2]; /* Z */ + vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + + data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */ + + if (quat) { + float totfac, q1[4], q2[4]; + + totfac = data[0] + data[3]; + if (totfac > FLT_EPSILON) { + interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); + } + else { + copy_qt_qt(q1, p1->quat); + } + + totfac = data[1] + data[2]; + if (totfac > FLT_EPSILON) { + interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); + } + else { + copy_qt_qt(q2, p3->quat); + } + + totfac = data[0] + data[1] + data[2] + data[3]; + if (totfac > FLT_EPSILON) { + interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac); + } + else { + copy_qt_qt(quat, q2); + } + } + + if (radius) { + *radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + + data[3] * p3->radius; + } + + if (weight) { + *weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + + data[3] * p3->weight; + } + + return 1; +} diff --git a/source/blender/blenkernel/intern/anim_visualization.c b/source/blender/blenkernel/intern/anim_visualization.c new file mode 100644 index 00000000000..04dbe4102cc --- /dev/null +++ b/source/blender/blenkernel/intern/anim_visualization.c @@ -0,0 +1,228 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ + +/** \file + * \ingroup bke + */ +#include "MEM_guardedalloc.h" + +#include "DNA_action_types.h" +#include "DNA_anim_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BLT_translation.h" + +#include "BKE_anim_visualization.h" +#include "BKE_report.h" + +#include "GPU_batch.h" + +/* ******************************************************************** */ +/* Animation Visualization */ + +/* Initialize the default settings for animation visualization */ +void animviz_settings_init(bAnimVizSettings *avs) +{ + /* sanity check */ + if (avs == NULL) { + return; + } + + /* path settings */ + avs->path_bc = avs->path_ac = 10; + + avs->path_sf = 1; /* xxx - take from scene instead? */ + avs->path_ef = 250; /* xxx - take from scene instead? */ + + avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); + + avs->path_step = 1; + + avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS; +} + +/* ------------------- */ + +/* Free the given motion path's cache */ +void animviz_free_motionpath_cache(bMotionPath *mpath) +{ + /* sanity check */ + if (mpath == NULL) { + return; + } + + /* free the path if necessary */ + if (mpath->points) { + MEM_freeN(mpath->points); + } + + GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); + GPU_BATCH_DISCARD_SAFE(mpath->batch_line); + GPU_BATCH_DISCARD_SAFE(mpath->batch_points); + + /* reset the relevant parameters */ + mpath->points = NULL; + mpath->length = 0; +} + +/* Free the given motion path instance and its data + * NOTE: this frees the motion path given! + */ +void animviz_free_motionpath(bMotionPath *mpath) +{ + /* sanity check */ + if (mpath == NULL) { + return; + } + + /* free the cache first */ + animviz_free_motionpath_cache(mpath); + + /* now the instance itself */ + MEM_freeN(mpath); +} + +/* ------------------- */ + +/* Make a copy of motionpath data, so that viewing with copy on write works */ +bMotionPath *animviz_copy_motionpath(const bMotionPath *mpath_src) +{ + bMotionPath *mpath_dst; + + if (mpath_src == NULL) { + return NULL; + } + + mpath_dst = MEM_dupallocN(mpath_src); + mpath_dst->points = MEM_dupallocN(mpath_src->points); + + /* should get recreated on draw... */ + mpath_dst->points_vbo = NULL; + mpath_dst->batch_line = NULL; + mpath_dst->batch_points = NULL; + + return mpath_dst; +} + +/* ------------------- */ + +/** + * Setup motion paths for the given data. + * \note Only used when explicitly calculating paths on bones which may/may not be consider already + * + * \param scene: Current scene (for frame ranges, etc.) + * \param ob: Object to add paths for (must be provided) + * \param pchan: Posechannel to add paths for (optional; if not provided, object-paths are assumed) + */ +bMotionPath *animviz_verify_motionpaths(ReportList *reports, + Scene *scene, + Object *ob, + bPoseChannel *pchan) +{ + bAnimVizSettings *avs; + bMotionPath *mpath, **dst; + + /* sanity checks */ + if (ELEM(NULL, scene, ob)) { + return NULL; + } + + /* get destination data */ + if (pchan) { + /* paths for posechannel - assume that posechannel belongs to the object */ + avs = &ob->pose->avs; + dst = &pchan->mpath; + } + else { + /* paths for object */ + avs = &ob->avs; + dst = &ob->mpath; + } + + /* avoid 0 size allocs */ + if (avs->path_sf >= avs->path_ef) { + BKE_reportf(reports, + RPT_ERROR, + "Motion path frame extents invalid for %s (%d to %d)%s", + (pchan) ? pchan->name : ob->id.name, + avs->path_sf, + avs->path_ef, + (avs->path_sf == avs->path_ef) ? TIP_(", cannot have single-frame paths") : ""); + return NULL; + } + + /* if there is already a motionpath, just return that, + * provided it's settings are ok (saves extra free+alloc) + */ + if (*dst != NULL) { + int expected_length = avs->path_ef - avs->path_sf; + + mpath = *dst; + + /* Path is "valid" if length is valid, + * but must also be of the same length as is being requested. */ + if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) { + /* outer check ensures that we have some curve data for this path */ + if (mpath->length == expected_length) { + /* return/use this as it is already valid length */ + return mpath; + } + else { + /* clear the existing path (as the range has changed), and reallocate below */ + animviz_free_motionpath_cache(mpath); + } + } + } + else { + /* create a new motionpath, and assign it */ + mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath"); + *dst = mpath; + } + + /* set settings from the viz settings */ + mpath->start_frame = avs->path_sf; + mpath->end_frame = avs->path_ef; + + mpath->length = mpath->end_frame - mpath->start_frame; + + if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) { + mpath->flag |= MOTIONPATH_FLAG_BHEAD; + } + else { + mpath->flag &= ~MOTIONPATH_FLAG_BHEAD; + } + + /* set default custom values */ + mpath->color[0] = 1.0; /* Red */ + mpath->color[1] = 0.0; + mpath->color[2] = 0.0; + + mpath->line_thickness = 2; + mpath->flag |= MOTIONPATH_FLAG_LINES; /* draw lines by default */ + + /* allocate a cache */ + mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts"); + + /* tag viz settings as currently having some path(s) which use it */ + avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS; + + /* return it */ + return mpath; +} diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 444d63e33d0..38a9864fd36 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -51,7 +51,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index e51b9ea85d1..d0a5e4348b9 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -35,7 +35,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_armature.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 04adb642fc0..28ce62c3de2 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -52,7 +52,7 @@ #include "DNA_tracking_types.h" #include "BKE_action.h" -#include "BKE_anim.h" /* for the curve calculation part */ +#include "BKE_anim_path.h" #include "BKE_armature.h" #include "BKE_bvhutils.h" #include "BKE_cachefile.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index dc2f603aa5c..907e7eb66ec 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -42,7 +42,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_font.h" diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index f7ddc4385ac..984a7a12b94 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -49,7 +49,7 @@ #include "PIL_time.h" -#include "BKE_anim.h" /* needed for where_on_path */ +#include "BKE_anim_path.h" /* needed for where_on_path */ #include "BKE_bvhutils.h" #include "BKE_collection.h" #include "BKE_collision.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a4da7ceb861..e8ff2ccc1af 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -48,7 +48,7 @@ #include "DNA_packedFile_types.h" #include "DNA_vfont_types.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_curve.h" #include "BKE_font.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 3f353d6d576..65412493049 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -45,7 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 7a2e9583aa1..3f94958c779 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -68,7 +68,8 @@ #include "BKE_DerivedMesh.h" #include "BKE_action.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" +#include "BKE_anim_visualization.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_camera.h" @@ -77,6 +78,7 @@ #include "BKE_curve.h" #include "BKE_deform.h" #include "BKE_displist.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_effect.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 1217d230d0d..f093b8c4211 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -40,9 +40,9 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" -#include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_collection.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_font.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f110a2bd3ae..067eb6ab18e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -50,7 +50,7 @@ #include "BLT_translation.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_animsys.h" #include "BKE_boids.h" diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 76088867997..b1cff53d399 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -51,7 +51,6 @@ #include "PIL_time.h" -#include "BKE_anim.h" #include "BKE_appdir.h" #include "BKE_cloth.h" #include "BKE_collection.h" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b12402d74fc..0011247fcd0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -59,13 +59,13 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_cachefile.h" #include "BKE_collection.h" #include "BKE_colortools.h" #include "BKE_curveprofile.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_fcurve.h" #include "BKE_freestyle.h" diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index fed0cbda466..bb80aaaaa5a 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -61,7 +61,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_armature.h" #include "BKE_colortools.h" #include "BKE_global.h" // for G diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 26de003dc17..f1dcbba8e90 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -52,7 +52,7 @@ #include "BLT_translation.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_image.h" #include "BKE_main.h" // for Main #include "BKE_mesh.h" // for ME_ defines (patching) diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 427a16adfc4..fadd0beb636 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -29,7 +29,7 @@ #include "MEM_guardedalloc.h" extern "C" { -#include "BKE_anim.h" +#include "BKE_duplilist.h" #include "BKE_idprop.h" #include "BKE_layer.h" #include "BKE_node.h" diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index bc0797eff0d..80691a6c2ad 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -24,7 +24,7 @@ #include "UI_resources.h" -#include "BKE_anim.h" +#include "BKE_anim_path.h" #include "BKE_camera.h" #include "BKE_constraint.h" #include "BKE_curve.h" diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 048adccc4e6..0fe68950cde 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -32,7 +32,7 @@ #include "DNA_modifier_types.h" #include "DNA_particle_types.h" -#include "BKE_anim.h" +#include "BKE_duplilist.h" #include "GPU_batch.h" #include "GPU_shader.h" diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1b169dbee1d..280e82ef473 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -31,10 +31,10 @@ #include "BLF_api.h" -#include "BKE_anim.h" #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_gpencil.h" diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index fd13e22ff4e..ae18636227d 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -22,8 +22,8 @@ #include "draw_manager.h" -#include "BKE_anim.h" #include "BKE_curve.h" +#include "BKE_duplilist.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_mesh.h" diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 09b6cd9c8cc..5c75e8f6187 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -33,7 +33,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_deform.h" diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 65d3196d8c3..e800203ae79 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -53,7 +53,6 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_camera.h" @@ -62,6 +61,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_displist.h" +#include "BKE_duplilist.h" #include "BKE_effect.h" #include "BKE_font.h" #include "BKE_gpencil_geom.h" diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 7faad5cdd0e..80ee03ca860 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -54,7 +54,7 @@ #include "IMB_imbuf_types.h" -#include "BKE_anim.h" +#include "BKE_anim_visualization.h" #include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index e0e6edda850..a91a11b2465 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -40,7 +40,6 @@ #include "BLT_translation.h" -#include "BKE_anim.h" #include "BKE_blender_version.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9adc15ccb61..dffe52745e4 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -44,8 +44,8 @@ #include "GPU_immediate.h" #include "GPU_state.h" -#include "BKE_anim.h" /* for duplis */ #include "BKE_context.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_layer.h" #include "BKE_main.h" diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 34c9e1f3273..8e7e36d7cb7 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -38,10 +38,10 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_anim.h" /* for duplis */ #include "BKE_armature.h" #include "BKE_bvhutils.h" #include "BKE_curve.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_layer.h" #include "BKE_main.h" diff --git a/source/blender/io/alembic/intern/abc_exporter.cc b/source/blender/io/alembic/intern/abc_exporter.cc index fb75fb1f6c7..e3e095463b4 100644 --- a/source/blender/io/alembic/intern/abc_exporter.cc +++ b/source/blender/io/alembic/intern/abc_exporter.cc @@ -51,7 +51,7 @@ extern "C" { # include "BLI_winstuff.h" #endif -#include "BKE_anim.h" +#include "BKE_duplilist.h" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_layer.h" diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc index 50f81c2ffb1..89f75a6ad80 100644 --- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc @@ -24,8 +24,8 @@ #include extern "C" { -#include "BKE_anim.h" #include "BKE_animsys.h" +#include "BKE_duplilist.h" #include "BKE_key.h" #include "BKE_particle.h" diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc index fd888f39adc..47f09af7442 100644 --- a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc @@ -32,7 +32,7 @@ #include extern "C" { -#include "BKE_anim.h" +#include "BKE_duplilist.h" #include "BLI_assert.h" diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index cbf51fc15b3..2e6696e12ca 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -27,7 +27,6 @@ extern "C" { #include "BLI_assert.h" #include "BLI_math_vector.h" -#include "BKE_anim.h" #include "BKE_customdata.h" #include "BKE_lib_id.h" #include "BKE_material.h" diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index 66c8522c53a..41c107b8d04 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -43,7 +43,7 @@ # include "BLI_iterator.h" # include "BLI_math.h" -# include "BKE_anim.h" +# include "BKE_duplilist.h" # include "BKE_object.h" # include "BKE_scene.h" diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 5104f4a66a1..f4b64d2f812 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -63,7 +63,6 @@ static const EnumPropertyItem space_items[] = { # include "BLI_math.h" -# include "BKE_anim.h" # include "BKE_bvhutils.h" # include "BKE_constraint.h" # include "BKE_context.h" -- cgit v1.2.3 From 7ec59cc7b700952fdbddfbb44a55977e0bf3bcb6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 21:47:56 +1100 Subject: Cleanup: split ED_mesh_mirror_*_table into multiple functions Spatial & topology mirror table each used a single function taking a char as an identifier. Split these into begin/end/lookup functions. --- .../blender/editors/armature/armature_skinning.c | 2 +- source/blender/editors/include/ED_mesh.h | 16 +++- source/blender/editors/mesh/editmesh_utils.c | 8 +- source/blender/editors/mesh/mesh_mirror.c | 102 ++++++++++----------- source/blender/editors/mesh/meshtools.c | 85 +++++++++-------- source/blender/editors/object/object_edit.c | 4 +- source/blender/editors/object/object_shapekey.c | 4 +- source/blender/editors/sculpt_paint/paint_vertex.c | 6 +- .../blender/editors/transform/transform_convert.c | 3 +- source/blender/editors/util/ed_util.c | 4 +- 10 files changed, 126 insertions(+), 108 deletions(-) diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 87f980db7b9..b637a57f7c0 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -459,7 +459,7 @@ static void add_verts_to_dgroups(ReportList *reports, } /* only generated in some cases but can call anyway */ - ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(ob); /* free the memory allocated */ MEM_freeN(bonelist); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 6d3396bb393..7f69bcb25cd 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -450,9 +450,19 @@ int join_mesh_exec(struct bContext *C, struct wmOperator *op); int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op); /* mirror lookup api */ -int ED_mesh_mirror_spatial_table( - struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval, const float co[3], char mode); -int ED_mesh_mirror_topo_table(struct Object *ob, struct Mesh *me_eval, char mode); +/* Spatial Mirror */ +void ED_mesh_mirror_spatial_table_begin(struct Object *ob, + struct BMEditMesh *em, + struct Mesh *me_eval); +void ED_mesh_mirror_spatial_table_end(struct Object *ob); +int ED_mesh_mirror_spatial_table_lookup(struct Object *ob, + struct BMEditMesh *em, + struct Mesh *me_eval, + const float co[3]); + +/* Topology Mirror */ +void ED_mesh_mirror_topo_table_begin(struct Object *ob, struct Mesh *me_eval); +void ED_mesh_mirror_topo_table_end(struct Object *ob); /* retrieves mirrored cache vert, or NULL if there isn't one. * note: calling this without ensuring the mirror cache state diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 0bdc9e4e6ea..08976cc46c4 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -406,10 +406,10 @@ void EDBM_mesh_load(Main *bmain, Object *ob) void EDBM_mesh_free(BMEditMesh *em) { /* These tables aren't used yet, so it's not strictly necessary - * to 'end' them (with 'e' param) but if someone tries to start - * using them, having these in place will save a lot of pain */ - ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e'); - ED_mesh_mirror_topo_table(NULL, NULL, 'e'); + * to 'end' them but if someone tries to start using them, + * having these in place will save a lot of pain. */ + ED_mesh_mirror_spatial_table_end(NULL); + ED_mesh_mirror_topo_table_end(NULL); BKE_editmesh_free(em); } diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index a4243c13940..0bbc8b0df76 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -44,73 +44,71 @@ static struct { void *tree; } MirrKdStore = {NULL}; -/* mode is 's' start, or 'e' end, or 'u' use */ -/* if end, ob can be NULL */ -int ED_mesh_mirror_spatial_table( - Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode) +void ED_mesh_mirror_spatial_table_begin(Object *ob, BMEditMesh *em, Mesh *me_eval) { - if (mode == 'u') { /* use table */ - if (MirrKdStore.tree == NULL) { - ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); - } - - if (MirrKdStore.tree) { - KDTreeNearest_3d nearest; - const int i = BLI_kdtree_3d_find_nearest(MirrKdStore.tree, co, &nearest); + Mesh *me = ob->data; + const bool use_em = (!me_eval && em && me->edit_mesh == em); + const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert; - if (i != -1) { - if (nearest.dist < KD_THRESH) { - return i; - } - } - } - return -1; + if (MirrKdStore.tree) { /* happens when entering this call without ending it */ + ED_mesh_mirror_spatial_table_end(ob); } - else if (mode == 's') { /* start table */ - Mesh *me = ob->data; - const bool use_em = (!me_eval && em && me->edit_mesh == em); - const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert; - - if (MirrKdStore.tree) { /* happens when entering this call without ending it */ - ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e'); - } - MirrKdStore.tree = BLI_kdtree_3d_new(totvert); + MirrKdStore.tree = BLI_kdtree_3d_new(totvert); - if (use_em) { - BMVert *eve; - BMIter iter; - int i; + if (use_em) { + BMVert *eve; + BMIter iter; + int i; - /* this needs to be valid for index lookups later (callers need) */ - BM_mesh_elem_table_ensure(em->bm, BM_VERT); + /* this needs to be valid for index lookups later (callers need) */ + BM_mesh_elem_table_ensure(em->bm, BM_VERT); - BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - BLI_kdtree_3d_insert(MirrKdStore.tree, i, eve->co); - } + BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + BLI_kdtree_3d_insert(MirrKdStore.tree, i, eve->co); } - else { - MVert *mvert = me_eval ? me_eval->mvert : me->mvert; - int i; + } + else { + MVert *mvert = me_eval ? me_eval->mvert : me->mvert; + int i; - for (i = 0; i < totvert; i++, mvert++) { - BLI_kdtree_3d_insert(MirrKdStore.tree, i, mvert->co); - } + for (i = 0; i < totvert; i++, mvert++) { + BLI_kdtree_3d_insert(MirrKdStore.tree, i, mvert->co); } + } + + BLI_kdtree_3d_balance(MirrKdStore.tree); +} - BLI_kdtree_3d_balance(MirrKdStore.tree); +int ED_mesh_mirror_spatial_table_lookup(Object *ob, + BMEditMesh *em, + Mesh *me_eval, + const float co[3]) +{ + if (MirrKdStore.tree == NULL) { + ED_mesh_mirror_spatial_table_begin(ob, em, me_eval); } - else if (mode == 'e') { /* end table */ - if (MirrKdStore.tree) { - BLI_kdtree_3d_free(MirrKdStore.tree); - MirrKdStore.tree = NULL; + + if (MirrKdStore.tree) { + KDTreeNearest_3d nearest; + const int i = BLI_kdtree_3d_find_nearest(MirrKdStore.tree, co, &nearest); + + if (i != -1) { + if (nearest.dist < KD_THRESH) { + return i; + } } } - else { - BLI_assert(0); - } + return -1; +} - return 0; +void ED_mesh_mirror_spatial_table_end(Object *UNUSED(ob)) +{ + /* TODO: store this in object/object-data (keep unused argument for now). */ + if (MirrKdStore.tree) { + BLI_kdtree_3d_free(MirrKdStore.tree); + MirrKdStore.tree = NULL; + } } /** \} */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 62237b46481..519822dd65c 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -786,53 +786,64 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } /* -------------------------------------------------------------------- */ -/* Mesh Mirror (Topology) */ - /** \name Mesh Topology Mirror API * \{ */ static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1}; +BLI_INLINE void mesh_mirror_topo_table_get_meshes(Object *ob, + Mesh *me_eval, + Mesh **r_me_mirror, + BMEditMesh **r_em_mirror) +{ + Mesh *me_mirror = NULL; + BMEditMesh *em_mirror = NULL; + + Mesh *me = ob->data; + if (me_eval != NULL) { + me_mirror = me_eval; + } + else if (me->edit_mesh != NULL) { + em_mirror = me->edit_mesh; + } + else { + me_mirror = me; + } + + *r_me_mirror = me_mirror; + *r_em_mirror = em_mirror; +} + /** * Mode is 's' start, or 'e' end, or 'u' use * if end, ob can be NULL. * \note This is supposed return -1 on error, * which callers are currently checking for, but is not used so far. */ -int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode) +void ED_mesh_mirror_topo_table_begin(Object *ob, Mesh *me_eval) { + Mesh *me_mirror; + BMEditMesh *em_mirror; + mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror); - Mesh *me_mirror = NULL; - BMEditMesh *em_mirror = NULL; + ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false); +} - if (mode != 'e') { - Mesh *me = ob->data; - if (me_eval != NULL) { - me_mirror = me_eval; - } - else if (me->edit_mesh != NULL) { - em_mirror = me->edit_mesh; - } - else { - me_mirror = me; - } - } +void ED_mesh_mirror_topo_table_end(Object *UNUSED(ob)) +{ + /* TODO: store this in object/object-data (keep unused argument for now). */ + ED_mesh_mirrtopo_free(&mesh_topo_store); +} - if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) { - ED_mesh_mirror_topo_table(ob, me_eval, 's'); - } - } - else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false); - } - else if (mode == 'e') { /* end table */ - ED_mesh_mirrtopo_free(&mesh_topo_store); - } - else { - BLI_assert(0); - } +static int ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) +{ + Mesh *me_mirror; + BMEditMesh *em_mirror; + mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror); + if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) { + ED_mesh_mirror_topo_table_begin(ob, me_eval); + } return 0; } @@ -849,12 +860,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - return ED_mesh_mirror_spatial_table(ob, NULL, mesh, vec, 'u'); + return ED_mesh_mirror_spatial_table_lookup(ob, NULL, mesh, vec); } static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) { - if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) { + if (ed_mesh_mirror_topo_table_update(ob, mesh) == -1) { return -1; } @@ -885,7 +896,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c vec[1] = co[1]; vec[2] = co[2]; - i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u'); + i = ED_mesh_mirror_spatial_table_lookup(ob, em, NULL, vec); if (i != -1) { return BM_vert_at_index(em->bm, i); } @@ -898,7 +909,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, int index) { intptr_t poinval; - if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) { + if (ed_mesh_mirror_topo_table_update(ob, NULL) == -1) { return NULL; } @@ -1098,13 +1109,13 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) mvert = me_eval ? me_eval->mvert : me->mvert; mface = me_eval ? me_eval->mface : me->mface; - ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); + ED_mesh_mirror_spatial_table_begin(ob, em, me_eval); for (a = 0, mv = mvert; a < totvert; a++, mv++) { mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology); } - ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(ob); fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); for (a = 0, mf = mface; a < totface; a++, mf++) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 80ee03ca860..ee9b6b411ce 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -454,8 +454,8 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f } /* will be recalculated as needed. */ { - ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e'); - ED_mesh_mirror_topo_table(NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(obedit); + ED_mesh_mirror_topo_table_end(obedit); } } else if (obedit->type == OB_ARMATURE) { diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index abce985b65a..26d33bbc375 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -126,7 +126,7 @@ static bool object_shape_key_mirror( float *fp1, *fp2; float tvec[3]; - ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's'); + ED_mesh_mirror_spatial_table_begin(ob, NULL, NULL); for (i1 = 0, mv = me->mvert; i1 < me->totvert; i1++, mv++) { i2 = mesh_get_x_mirror_vert(ob, NULL, i1, use_topology); @@ -157,7 +157,7 @@ static bool object_shape_key_mirror( } } - ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(ob); } else if (ob->type == OB_LATTICE) { Lattice *lt = ob->data; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 604146e2ca6..8934f4d9668 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1226,7 +1226,7 @@ static void ed_vwpaintmode_enter_generic(Main *bmain, BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT); /* weight paint specific */ - ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's'); + ED_mesh_mirror_spatial_table_end(ob); ED_vgroup_sync_from_pose(ob); } else { @@ -1318,8 +1318,8 @@ static void ed_vwpaintmode_exit_generic(Object *ob, const eObjectMode mode_flag) paint_cursor_delete_textures(); if (mode_flag == OB_MODE_WEIGHT_PAINT) { - ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e'); - ED_mesh_mirror_topo_table(NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(ob); + ED_mesh_mirror_topo_table_end(ob); } /* Never leave derived meshes behind. */ diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 19319d2606b..665a279bdbe 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -2248,9 +2248,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (t->flag & T_EDIT) { if (t->obedit_type == OB_MESH) { FOREACH_TRANS_DATA_CONTAINER (t, tc) { - BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); /* table needs to be created for each edit command, since vertices can move etc */ - ED_mesh_mirror_spatial_table(tc->obedit, em, NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(tc->obedit); /* TODO(campbell): xform: We need support for many mirror objects at once! */ break; } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index fa28d9c2d6d..b88fcf5a328 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -224,8 +224,8 @@ void ED_editors_exit(Main *bmain, bool do_undo_system) } /* global in meshtools... */ - ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e'); - ED_mesh_mirror_topo_table(NULL, NULL, 'e'); + ED_mesh_mirror_spatial_table_end(NULL); + ED_mesh_mirror_topo_table_end(NULL); } bool ED_editors_flush_edits_for_object_ex(Main *bmain, -- cgit v1.2.3 From 10c2254d412d7cbee0b0d9f8b7c74a9d3ce69b69 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 3 Apr 2020 12:51:03 +0200 Subject: Cleanup: Continue renaming ARegion variables from ar to region Continuation of b2ee1770d4c3, now non-single word variables are also renamed. Part of T74432. Also ran clang-format on affected files. --- source/blender/blenkernel/intern/screen.c | 12 +- source/blender/blenloader/intern/versioning_250.c | 32 +++--- source/blender/blenloader/intern/versioning_280.c | 79 ++++++------- source/blender/editors/include/ED_screen.h | 4 +- source/blender/editors/include/ED_view3d.h | 4 +- .../interface/interface_eyedropper_datablock.c | 4 +- .../editors/interface/interface_eyedropper_depth.c | 4 +- .../blender/editors/interface/interface_handlers.c | 24 ++-- source/blender/editors/interface/interface_ops.c | 6 +- .../editors/interface/interface_region_hud.c | 32 +++--- .../editors/interface/interface_region_popup.c | 4 +- source/blender/editors/screen/area.c | 8 +- source/blender/editors/screen/area_query.c | 14 +-- source/blender/editors/screen/screen_edit.c | 18 +-- source/blender/editors/screen/screen_ops.c | 42 +++---- source/blender/editors/sculpt_paint/sculpt.c | 8 +- source/blender/editors/space_clip/space_clip.c | 126 ++++++++++----------- source/blender/editors/space_file/file_ops.c | 4 +- source/blender/editors/space_file/space_file.c | 32 +++--- source/blender/editors/space_graph/graph_utils.c | 24 ++-- .../editors/space_sequencer/space_sequencer.c | 86 +++++++------- source/blender/editors/space_view3d/space_view3d.c | 26 ++--- source/blender/editors/space_view3d/view3d_edit.c | 6 +- source/blender/editors/space_view3d/view3d_utils.c | 8 +- source/blender/editors/space_view3d/view3d_view.c | 15 +-- source/blender/editors/undo/ed_undo.c | 16 +-- source/blender/makesrna/intern/rna_space.c | 16 +-- source/blender/windowmanager/intern/wm_draw.c | 8 +- .../blender/windowmanager/intern/wm_event_system.c | 8 +- source/blender/windowmanager/intern/wm_operators.c | 10 +- .../windowmanager/intern/wm_splash_screen.c | 4 +- .../blender/windowmanager/intern/wm_toolsystem.c | 4 +- source/blender/windowmanager/intern/wm_tooltip.c | 4 +- 33 files changed, 348 insertions(+), 344 deletions(-) diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index dbf460fdea2..6c888e7b19e 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -748,19 +748,19 @@ ARegion *BKE_area_find_region_active_win(ScrArea *sa) ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y) { - ARegion *ar_found = NULL; + ARegion *region_found = NULL; if (sa) { ARegion *region; for (region = sa->regionbase.first; region; region = region->next) { if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { - ar_found = region; + region_found = region; break; } } } } - return ar_found; + return region_found; } /** @@ -768,16 +768,16 @@ ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y */ ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int y) { - ARegion *ar_found = NULL; + ARegion *region_found = NULL; for (ARegion *region = sc->regionbase.first; region; region = region->next) { if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { - ar_found = region; + region_found = region; break; } } } - return ar_found; + return region_found; } /** diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index bb80aaaaa5a..68e654a8cd5 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -136,7 +136,7 @@ static void sequencer_init_preview_region(ARegion *region) static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) { ARegion *region; - ARegion *ar_main; + ARegion *region_main; if (sl) { /* first channels for ipo action nla... */ @@ -205,14 +205,14 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) region->alignment = RGN_ALIGN_TOP; break; case SPACE_SEQ: - ar_main = (ARegion *)lb->first; - for (; ar_main; ar_main = ar_main->next) { - if (ar_main->regiontype == RGN_TYPE_WINDOW) { + region_main = (ARegion *)lb->first; + for (; region_main; region_main = region_main->next) { + if (region_main->regiontype == RGN_TYPE_WINDOW) { break; } } region = MEM_callocN(sizeof(ARegion), "preview area for sequencer"); - BLI_insertlinkbefore(lb, ar_main, region); + BLI_insertlinkbefore(lb, region_main, region); sequencer_init_preview_region(region); break; case SPACE_VIEW3D: @@ -1235,7 +1235,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { ARegion *region; - ARegion *ar_main; + ARegion *region_main; ListBase *regionbase; SpaceSeq *sseq = (SpaceSeq *)sl; @@ -1253,14 +1253,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) sseq->mainb = SEQ_DRAW_IMG_IMBUF; } - ar_main = (ARegion *)regionbase->first; - for (; ar_main; ar_main = ar_main->next) { - if (ar_main->regiontype == RGN_TYPE_WINDOW) { + region_main = (ARegion *)regionbase->first; + for (; region_main; region_main = region_main->next) { + if (region_main->regiontype == RGN_TYPE_WINDOW) { break; } } region = MEM_callocN(sizeof(ARegion), "preview area for sequencer"); - BLI_insertlinkbefore(regionbase, ar_main, region); + BLI_insertlinkbefore(regionbase, region_main, region); sequencer_init_preview_region(region); } } @@ -1433,7 +1433,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (sa = screen->areabase.first; sa; sa = sa->next) { for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { - ARegion *ar_preview; + ARegion *region_preview; ListBase *regionbase; if (sl == sa->spacedata.first) { @@ -1443,14 +1443,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) regionbase = &sl->regionbase; } - ar_preview = (ARegion *)regionbase->first; - for (; ar_preview; ar_preview = ar_preview->next) { - if (ar_preview->regiontype == RGN_TYPE_PREVIEW) { + region_preview = (ARegion *)regionbase->first; + for (; region_preview; region_preview = region_preview->next) { + if (region_preview->regiontype == RGN_TYPE_PREVIEW) { break; } } - if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) { - sequencer_init_preview_region(ar_preview); + if (region_preview && (region_preview->regiontype == RGN_TYPE_PREVIEW)) { + sequencer_init_preview_region(region_preview); } } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index b3c0473e173..ac0c0c3da39 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -609,9 +609,9 @@ static void do_versions_remove_region(ListBase *regionbase, ARegion *region) static void do_versions_remove_regions_by_type(ListBase *regionbase, int regiontype) { - ARegion *region, *ar_next; - for (region = regionbase->first; region; region = ar_next) { - ar_next = region->next; + ARegion *region, *region_next; + for (region = regionbase->first; region; region = region_next) { + region_next = region->next; if (region->regiontype == regiontype) { do_versions_remove_region(regionbase, region); } @@ -2934,9 +2934,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *ar_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER); + ARegion *region_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER); - if (!ar_header) { + if (!region_header) { /* Headers should always be first in the region list, except if there's also a * tool-header. These were only introduced in later versions though, so should be * fine to always insert headers first. */ @@ -2959,16 +2959,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (sl->spacetype == SPACE_PROPERTIES) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; ARegion *region = MEM_callocN(sizeof(ARegion), "navigation bar for properties"); - ARegion *ar_header = NULL; + ARegion *region_header = NULL; - for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) { - if (ar_header->regiontype == RGN_TYPE_HEADER) { + for (region_header = regionbase->first; region_header; + region_header = region_header->next) { + if (region_header->regiontype == RGN_TYPE_HEADER) { break; } } - BLI_assert(ar_header); + BLI_assert(region_header); - BLI_insertlinkafter(regionbase, ar_header, region); + BLI_insertlinkafter(regionbase, region_header, region); region->regiontype = RGN_TYPE_NAV_BAR; region->alignment = RGN_ALIGN_LEFT; @@ -3468,13 +3469,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!execute_region) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - ARegion *ar_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR); + ARegion *region_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR); execute_region = MEM_callocN(sizeof(ARegion), "execute region for properties"); - BLI_assert(ar_navbar); + BLI_assert(region_navbar); - BLI_insertlinkafter(regionbase, ar_navbar, execute_region); + BLI_insertlinkafter(regionbase, region_navbar, execute_region); execute_region->regiontype = RGN_TYPE_EXECUTE; execute_region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; @@ -3711,8 +3712,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) ARegion *region = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text"); region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM; - ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); - BLI_insertlinkafter(regionbase, ar_header, region); + ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); + BLI_insertlinkafter(regionbase, region_header, region); } } } @@ -3804,8 +3805,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) region = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header"); region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); - BLI_insertlinkbefore(regionbase, ar_header, region); + ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); + BLI_insertlinkbefore(regionbase, region_header, region); /* Hide by default, enable for painting workspaces (startup only). */ region->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; } @@ -4136,24 +4137,25 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *ar_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); - ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); - ARegion *ar_toolprops = do_versions_find_region_or_null(regionbase, - RGN_TYPE_TOOL_PROPS); + ARegion *region_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); + ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); + ARegion *region_toolprops = do_versions_find_region_or_null(regionbase, + RGN_TYPE_TOOL_PROPS); /* Reinsert UI region so that it spawns entire area width */ - BLI_remlink(regionbase, ar_ui); - BLI_insertlinkafter(regionbase, ar_header, ar_ui); + BLI_remlink(regionbase, region_ui); + BLI_insertlinkafter(regionbase, region_header, region_ui); - ar_ui->flag |= RGN_FLAG_DYNAMIC_SIZE; + region_ui->flag |= RGN_FLAG_DYNAMIC_SIZE; - if (ar_toolprops && (ar_toolprops->alignment == (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) { + if (region_toolprops && + (region_toolprops->alignment == (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) { SpaceType *stype = BKE_spacetype_from_id(sl->spacetype); /* Remove empty region at old location. */ BLI_assert(sfile->op == NULL); - BKE_area_region_free(stype, ar_toolprops); - BLI_freelinkN(regionbase, ar_toolprops); + BKE_area_region_free(stype, region_toolprops); + BLI_freelinkN(regionbase, region_toolprops); } if (sfile->params) { @@ -4244,24 +4246,25 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } else if (sl->spacetype == SPACE_FILE) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *ar_tools = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS); - ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); + ARegion *region_tools = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS); + ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); - if (ar_tools) { - ARegion *ar_next = ar_tools->next; + if (region_tools) { + ARegion *region_next = region_tools->next; /* We temporarily had two tools regions, get rid of the second one. */ - if (ar_next && ar_next->regiontype == RGN_TYPE_TOOLS) { - do_versions_remove_region(regionbase, ar_next); + if (region_next && region_next->regiontype == RGN_TYPE_TOOLS) { + do_versions_remove_region(regionbase, region_next); } - BLI_remlink(regionbase, ar_tools); - BLI_insertlinkafter(regionbase, ar_header, ar_tools); + BLI_remlink(regionbase, region_tools); + BLI_insertlinkafter(regionbase, region_header, region_tools); } else { - ar_tools = do_versions_add_region(RGN_TYPE_TOOLS, "versioning file tools region"); - BLI_insertlinkafter(regionbase, ar_header, ar_tools); - ar_tools->alignment = RGN_ALIGN_LEFT; + region_tools = do_versions_add_region(RGN_TYPE_TOOLS, + "versioning file tools region"); + BLI_insertlinkafter(regionbase, region_header, region_tools); + region_tools->alignment = RGN_ALIGN_LEFT; } } } diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 0785b0e97f7..7430f491d91 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -184,7 +184,7 @@ void ED_area_tag_refresh(ScrArea *sa); void ED_area_do_refresh(struct bContext *C, ScrArea *sa); struct AZone *ED_area_azones_update(ScrArea *sa, const int mouse_xy[]); void ED_area_status_text(ScrArea *sa, const char *str); -void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_ar_exit); +void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_region_exit); void ED_area_prevspace(struct bContext *C, ScrArea *sa); void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2); int ED_area_headersize(void); @@ -442,7 +442,7 @@ bool ED_region_overlap_isect_xy_with_margin(const ARegion *region, const int event_xy[2], const int margin); -bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar_gutter); +bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_region_gutter); bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2]); bool ED_region_contains_xy(const struct ARegion *region, const int event_xy[2]); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index bb065ee0008..86ad35cfa9f 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -560,10 +560,10 @@ bool edge_inside_circle(const float cent[2], struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, - struct ARegion **r_ar); + struct ARegion **r_region); bool ED_view3d_area_user_region(const struct ScrArea *sa, const struct View3D *v3d, - struct ARegion **r_ar); + struct ARegion **r_region); bool ED_operator_rv3d_user_region_poll(struct bContext *C); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index 93599b8727a..bf118481be2 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -155,7 +155,7 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); ddr->name[0] = '\0'; @@ -208,7 +208,7 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int } CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } /* sets the ID, returns success */ diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index a5e60adec55..26a6109e8cf 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -160,7 +160,7 @@ static void depthdropper_depth_sample_pt( Scene *scene = CTX_data_scene(C); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); ddr->name[0] = '\0'; @@ -209,7 +209,7 @@ static void depthdropper_depth_sample_pt( } CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } /* sets the sample depth RGB, maintaining A */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d378613c035..61c59643bcd 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1874,7 +1874,7 @@ static bool ui_but_drag_init(bContext *C, #ifdef USE_DRAG_TOGGLE if (ui_drag_toggle_but_is_supported(but)) { uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); - ARegion *ar_prev; + ARegion *region_prev; /* call here because regular mouse-up event wont run, * typically 'button_activate_exit()' handles this */ @@ -1887,7 +1887,7 @@ static bool ui_but_drag_init(bContext *C, copy_v2_v2_int(drag_info->xy_last, &event->x); /* needed for toggle drag on popups */ - ar_prev = CTX_wm_region(C); + region_prev = CTX_wm_region(C); CTX_wm_region_set(C, data->region); WM_event_add_ui_handler(C, @@ -1897,7 +1897,7 @@ static bool ui_but_drag_init(bContext *C, drag_info, WM_HANDLER_BLOCKING); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); /* Initialize alignment for single row/column regions, * otherwise we use the relative position of the first other button dragged over. */ @@ -1906,13 +1906,13 @@ static bool ui_but_drag_init(bContext *C, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER)) { - const int ar_alignment = RGN_ALIGN_ENUM_FROM_MASK(data->region->alignment); + const int region_alignment = RGN_ALIGN_ENUM_FROM_MASK(data->region->alignment); int lock_axis = -1; - if (ELEM(ar_alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) { + if (ELEM(region_alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) { lock_axis = 0; } - else if (ELEM(ar_alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { + else if (ELEM(region_alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { lock_axis = 1; } if (lock_axis != -1) { @@ -8326,16 +8326,16 @@ void UI_context_active_but_prop_handle(bContext *C) wmOperator *UI_context_active_operator_get(const struct bContext *C) { - ARegion *ar_ctx = CTX_wm_region(C); + ARegion *region_ctx = CTX_wm_region(C); uiBlock *block; /* background mode */ - if (ar_ctx == NULL) { + if (region_ctx == NULL) { return NULL; } /* scan active regions ui */ - for (block = ar_ctx->uiblocks.first; block; block = block->next) { + for (block = region_ctx->uiblocks.first; block; block = block->next) { if (block->ui_operator) { return block->ui_operator; } @@ -8347,7 +8347,7 @@ wmOperator *UI_context_active_operator_get(const struct bContext *C) ARegion *region; for (region = sc->regionbase.first; region; region = region->next) { - if (region == ar_ctx) { + if (region == region_ctx) { continue; } for (block = region->uiblocks.first; block; block = block->next) { @@ -8470,10 +8470,10 @@ void ui_but_activate_event(bContext *C, ARegion *region, uiBut *but) event.customdata = but; event.customdatafree = false; - ARegion *ar_ctx = CTX_wm_region(C); + ARegion *region_ctx = CTX_wm_region(C); CTX_wm_region_set(C, region); ui_do_button(C, but->block, but, &event); - CTX_wm_region_set(C, ar_ctx); + CTX_wm_region_set(C, region_ctx); } /** diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index b418cb4a1ac..5a4a549ea3e 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1622,11 +1622,11 @@ static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *ev { bScreen *sc = CTX_wm_screen(C); const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed"); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); ARegion *region = sc ? BKE_screen_find_region_xy(sc, RGN_TYPE_ANY, event->x, event->y) : NULL; if (region == NULL) { - region = ar_prev; + region = region_prev; } if (region == NULL) { @@ -1635,7 +1635,7 @@ static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *ev CTX_wm_region_set(C, region); uiBut *but = UI_context_active_but_get(C); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); if (but == NULL) { return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index f77739b5114..e0fc7a3ee71 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -75,14 +75,14 @@ static bool last_redo_poll(const bContext *C, short region_type) * wrong context. */ ScrArea *sa = CTX_wm_area(C); - ARegion *ar_op = (region_type != -1) ? BKE_area_find_region_type(sa, region_type) : NULL; - ARegion *ar_prev = CTX_wm_region(C); - CTX_wm_region_set((bContext *)C, ar_op); + ARegion *region_op = (region_type != -1) ? BKE_area_find_region_type(sa, region_type) : NULL; + ARegion *region_prev = CTX_wm_region(C); + CTX_wm_region_set((bContext *)C, region_op); if (WM_operator_repeat_check(C, op) && WM_operator_check_ui_empty(op->type) == false) { success = WM_operator_poll((bContext *)C, op->type); } - CTX_wm_region_set((bContext *)C, ar_prev); + CTX_wm_region_set((bContext *)C, region_prev); } return success; } @@ -253,9 +253,9 @@ ARegionType *ED_area_type_hud(int space_type) static ARegion *hud_region_add(ScrArea *sa) { ARegion *region = MEM_callocN(sizeof(ARegion), "area region"); - ARegion *ar_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar_win) { - BLI_insertlinkbefore(&sa->regionbase, ar_win, region); + ARegion *region_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (region_win) { + BLI_insertlinkbefore(&sa->regionbase, region_win, region); } else { BLI_addtail(&sa->regionbase, region); @@ -265,10 +265,10 @@ static ARegion *hud_region_add(ScrArea *sa) region->overlap = true; region->flag |= RGN_FLAG_DYNAMIC_SIZE; - if (ar_win) { + if (region_win) { float x, y; - UI_view2d_scroller_size_get(&ar_win->v2d, &x, &y); + UI_view2d_scroller_size_get(®ion_win->v2d, &x, &y); region->runtime.offset_x = x; region->runtime.offset_y = y; } @@ -316,9 +316,9 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) bool init = false; bool was_hidden = region == NULL || region->visible == false; - ARegion *ar_op = CTX_wm_region(C); - BLI_assert((ar_op == NULL) || (ar_op->regiontype != RGN_TYPE_HUD)); - if (!last_redo_poll(C, ar_op ? ar_op->regiontype : -1)) { + ARegion *region_op = CTX_wm_region(C); + BLI_assert((region_op == NULL) || (region_op->regiontype != RGN_TYPE_HUD)); + if (!last_redo_poll(C, region_op ? region_op->regiontype : -1)) { if (region) { ED_region_tag_redraw(region); hud_region_hide(region); @@ -350,8 +350,8 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) hrd = MEM_callocN(sizeof(*hrd), __func__); region->regiondata = hrd; } - if (ar_op) { - hrd->regionid = ar_op->regiontype; + if (region_op) { + hrd->regionid = region_op->regiontype; } else { hrd->regionid = -1; @@ -380,7 +380,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) /* We shouldn't need to do this every time :S */ /* XXX, this is evil! - it also makes the menu show on first draw. :( */ if (region->visible) { - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); CTX_wm_region_set((bContext *)C, region); hud_region_layout(C, region); if (was_hidden) { @@ -391,7 +391,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) .ymax = region->winy, }; } - CTX_wm_region_set((bContext *)C, ar_prev); + CTX_wm_region_set((bContext *)C, region_prev); } region->visible = !((region->flag & RGN_FLAG_HIDDEN) || (region->flag & RGN_FLAG_TOO_SMALL)); diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index ba9a5026ce3..7e32a91d08d 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -526,7 +526,7 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) { wmWindow *ctx_win = CTX_wm_window(C); ScrArea *ctx_sa = CTX_wm_area(C); - ARegion *ctx_ar = CTX_wm_region(C); + ARegion *ctx_region = CTX_wm_region(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = ctx_win; @@ -551,7 +551,7 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) /* Reset context (area and region were NULL'ed when chaning context window). */ CTX_wm_window_set(C, ctx_win); CTX_wm_area_set(C, ctx_sa); - CTX_wm_region_set(C, ctx_ar); + CTX_wm_region_set(C, ctx_region); /* reset to region cursor (only if there's not another menu open) */ if (BLI_listbase_is_empty(&sc->regionbase)) { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 56ea59c1d6e..efa98c358df 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2076,9 +2076,9 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) } /** - * \param skip_ar_exit: Skip calling area exit callback. Set for opening temp spaces. + * \param skip_region_exit: Skip calling area exit callback. Set for opening temp spaces. */ -void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exit) +void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region_exit) { wmWindow *win = CTX_wm_window(C); @@ -2104,14 +2104,14 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi /* in some cases (opening temp space) we don't want to * call area exit callback, so we temporarily unset it */ - if (skip_ar_exit && sa->type) { + if (skip_region_exit && sa->type) { sa->type->exit = NULL; } ED_area_exit(C, sa); /* restore old area exit callback */ - if (skip_ar_exit && sa->type) { + if (skip_region_exit && sa->type) { sa->type->exit = sa_exit; } diff --git a/source/blender/editors/screen/area_query.c b/source/blender/editors/screen/area_query.c index 739f1b93e07..d569e56e11b 100644 --- a/source/blender/editors/screen/area_query.c +++ b/source/blender/editors/screen/area_query.c @@ -73,19 +73,19 @@ bool ED_region_overlap_isect_any_xy(const ScrArea *area, const int event_xy[2]) return false; } -bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar_gutter) +bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_region_gutter) { - *r_ar_gutter = region->winrct; + *r_region_gutter = region->winrct; if (UI_panel_category_is_visible(region)) { const int category_tabs_width = round_fl_to_int(UI_view2d_scale_get_x(®ion->v2d) * UI_PANEL_CATEGORY_MARGIN_WIDTH); const int alignment = RGN_ALIGN_ENUM_FROM_MASK(region->alignment); if (alignment == RGN_ALIGN_LEFT) { - r_ar_gutter->xmax = r_ar_gutter->xmin + category_tabs_width; + r_region_gutter->xmax = r_region_gutter->xmin + category_tabs_width; } else if (alignment == RGN_ALIGN_RIGHT) { - r_ar_gutter->xmin = r_ar_gutter->xmax - category_tabs_width; + r_region_gutter->xmin = r_region_gutter->xmax - category_tabs_width; } else { BLI_assert(!"Unsupported alignment"); @@ -97,9 +97,9 @@ bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_ar bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2]) { - rcti ar_gutter; - if (ED_region_panel_category_gutter_calc_rect(region, &ar_gutter)) { - return BLI_rcti_isect_pt_v(&ar_gutter, event_xy); + rcti region_gutter; + if (ED_region_panel_category_gutter_calc_rect(region, ®ion_gutter)) { + return BLI_rcti_isect_pt_v(®ion_gutter, event_xy); } return false; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 0151a0fcb0d..01a30f7d6a4 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -687,7 +687,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) ScrArea *sa = NULL; ARegion *region; - ARegion *ar_prev = scr->active_region; + ARegion *region_prev = scr->active_region; ED_screen_areas_iter(win, scr, area_iter) { @@ -714,7 +714,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) } /* Check for redraw headers. */ - if (ar_prev != scr->active_region) { + if (region_prev != scr->active_region) { ED_screen_areas_iter(win, scr, area_iter) { @@ -723,20 +723,20 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) for (region = area_iter->regionbase.first; region; region = region->next) { /* Call old area's deactivate if assigned. */ - if (region == ar_prev && area_iter->type->deactivate) { + if (region == region_prev && area_iter->type->deactivate) { area_iter->type->deactivate(area_iter); } - if (region == ar_prev && region != scr->active_region) { - wmGizmoMap *gzmap = ar_prev->gizmo_map; + if (region == region_prev && region != scr->active_region) { + wmGizmoMap *gzmap = region_prev->gizmo_map; if (gzmap) { if (WM_gizmo_highlight_set(gzmap, NULL)) { - ED_region_tag_redraw_no_rebuild(ar_prev); + ED_region_tag_redraw_no_rebuild(region_prev); } } } - if (region == ar_prev || region == scr->active_region) { + if (region == region_prev || region == scr->active_region) { do_draw = true; } } @@ -758,9 +758,9 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) } else { /* Notifier invokes freeing the buttons... causing a bit too much redraws. */ - region_cursor_set_ex(win, sa, scr->active_region, ar_prev != scr->active_region); + region_cursor_set_ex(win, sa, scr->active_region, region_prev != scr->active_region); - if (ar_prev != scr->active_region) { + if (region_prev != scr->active_region) { /* This used to be a notifier, but needs to be done immediate * because it can undo setting the right button as active due * to delayed notifier handling. */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ae8dd829d8d..5eb676cd25c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2641,11 +2641,11 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) { if (rmd->region->regiontype == RGN_TYPE_HEADER) { - ARegion *ar_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER); - if (ar_tool_header != NULL) { - if ((ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 && - (ar_tool_header->flag & RGN_FLAG_HIDDEN) != 0) { - region_toggle_hidden(C, ar_tool_header, 0); + ARegion *region_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER); + if (region_tool_header != NULL) { + if ((region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 && + (region_tool_header->flag & RGN_FLAG_HIDDEN) != 0) { + region_toggle_hidden(C, region_tool_header, 0); } } } @@ -3848,17 +3848,17 @@ static int region_quadview_exec(bContext *C, wmOperator *op) region->alignment = 0; if (sa->spacetype == SPACE_VIEW3D) { - ARegion *ar_iter; + ARegion *region_iter; RegionView3D *rv3d = region->regiondata; /* if this is a locked view, use settings from 'User' view */ if (rv3d->viewlock) { View3D *v3d_user; - ARegion *ar_user; + ARegion *region_user; - if (ED_view3d_context_user_region(C, &v3d_user, &ar_user)) { - if (region != ar_user) { - SWAP(void *, region->regiondata, ar_user->regiondata); + if (ED_view3d_context_user_region(C, &v3d_user, ®ion_user)) { + if (region != region_user) { + SWAP(void *, region->regiondata, region_user->regiondata); rv3d = region->regiondata; } } @@ -3869,9 +3869,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op) rv3d->rflag &= ~RV3D_CLIPPING; /* Accumulate locks, in case they're mixed. */ - for (ar_iter = sa->regionbase.first; ar_iter; ar_iter = ar_iter->next) { - if (ar_iter->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d_iter = ar_iter->regiondata; + for (region_iter = sa->regionbase.first; region_iter; region_iter = region_iter->next) { + if (region_iter->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d_iter = region_iter->regiondata; rv3d->viewlock_quad |= rv3d_iter->viewlock; } } @@ -4140,9 +4140,9 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE); } - ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ARegion *region_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); uiLayout *col = uiLayoutColumn(layout, 0); - uiLayoutSetActive(col, (ar_header->flag & RGN_FLAG_HIDDEN) == 0); + uiLayoutSetActive(col, (region_header->flag & RGN_FLAG_HIDDEN) == 0); if (BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER)) { uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE); @@ -5070,7 +5070,7 @@ static void SCREEN_OT_delete(wmOperatorType *ot) typedef struct RegionAlphaInfo { ScrArea *sa; - ARegion *region, *child_ar; /* other region */ + ARegion *region, *child_region; /* other region */ int hidden; } RegionAlphaInfo; @@ -5107,8 +5107,8 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running /* always send redraw */ ED_region_tag_redraw(region); - if (rgi->child_ar) { - ED_region_tag_redraw(rgi->child_ar); + if (rgi->child_region) { + ED_region_tag_redraw(rgi->child_region); } /* if running timer was hiding, the flag toggle went wrong */ @@ -5159,7 +5159,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegi if (region->next) { if (region->next->alignment & RGN_SPLIT_PREV) { - rgi->child_ar = region->next; + rgi->child_region = region->next; } } @@ -5183,8 +5183,8 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven /* always send redraws */ ED_region_tag_redraw(rgi->region); - if (rgi->child_ar) { - ED_region_tag_redraw(rgi->child_ar); + if (rgi->child_region) { + ED_region_tag_redraw(rgi->child_region); } /* end timer? */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fede8ce97ca..8d4870f5dd8 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -9275,7 +9275,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) /* Set context to 3D view. */ ScrArea *prev_sa = CTX_wm_area(C); - ARegion *prev_ar = CTX_wm_region(C); + ARegion *prev_region = CTX_wm_region(C); CTX_wm_area_set(C, sa); CTX_wm_region_set(C, region); @@ -9295,7 +9295,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) case SAMPLE_DETAIL_DYNTOPO: if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) { CTX_wm_area_set(C, prev_sa); - CTX_wm_region_set(C, prev_ar); + CTX_wm_region_set(C, prev_region); return OPERATOR_CANCELLED; } sample_detail_dyntopo(C, &vc, region, mx, my); @@ -9303,7 +9303,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) case SAMPLE_DETAIL_VOXEL: if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { CTX_wm_area_set(C, prev_sa); - CTX_wm_region_set(C, prev_ar); + CTX_wm_region_set(C, prev_region); return OPERATOR_CANCELLED; } sample_detail_voxel(C, &vc, mx, my); @@ -9312,7 +9312,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) /* Restore context. */ CTX_wm_area_set(C, prev_sa); - CTX_wm_region_set(C, prev_ar); + CTX_wm_region_set(C, prev_region); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4b9c872ffce..82fb429d36c 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -645,11 +645,11 @@ static void clip_refresh(const bContext *C, ScrArea *sa) wmWindow *window = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); SpaceClip *sc = (SpaceClip *)sa->spacedata.first; - ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); - ARegion *ar_preview = ED_clip_has_preview_region(C, sa); - ARegion *ar_properties = ED_clip_has_properties_region(sa); - ARegion *ar_channels = ED_clip_has_channels_region(sa); + ARegion *region_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *region_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); + ARegion *region_preview = ED_clip_has_preview_region(C, sa); + ARegion *region_properties = ED_clip_has_properties_region(sa); + ARegion *region_channels = ED_clip_has_channels_region(sa); bool main_visible = false, preview_visible = false, tools_visible = false; bool properties_visible = false, channels_visible = false; bool view_changed = false; @@ -669,7 +669,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) properties_visible = false; channels_visible = false; - reinit_preview_region(C, ar_preview); + reinit_preview_region(C, region_preview); break; case SC_VIEW_DOPESHEET: main_visible = false; @@ -678,128 +678,128 @@ static void clip_refresh(const bContext *C, ScrArea *sa) properties_visible = false; channels_visible = true; - reinit_preview_region(C, ar_preview); + reinit_preview_region(C, region_preview); break; } if (main_visible) { - if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag &= ~RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) { + region_main->flag &= ~RGN_FLAG_HIDDEN; + region_main->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = true; } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; + if (region_main && region_main->alignment != RGN_ALIGN_NONE) { + region_main->alignment = RGN_ALIGN_NONE; view_changed = true; } } else { - if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag |= RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_main->handlers); + if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) { + region_main->flag |= RGN_FLAG_HIDDEN; + region_main->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_main->handlers); view_changed = true; } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; + if (region_main && region_main->alignment != RGN_ALIGN_NONE) { + region_main->alignment = RGN_ALIGN_NONE; view_changed = true; } } if (properties_visible) { - if (ar_properties && (ar_properties->flag & RGN_FLAG_HIDDEN)) { - ar_properties->flag &= ~RGN_FLAG_HIDDEN; - ar_properties->v2d.flag &= ~V2D_IS_INITIALISED; + if (region_properties && (region_properties->flag & RGN_FLAG_HIDDEN)) { + region_properties->flag &= ~RGN_FLAG_HIDDEN; + region_properties->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = true; } - if (ar_properties && ar_properties->alignment != RGN_ALIGN_RIGHT) { - ar_properties->alignment = RGN_ALIGN_RIGHT; + if (region_properties && region_properties->alignment != RGN_ALIGN_RIGHT) { + region_properties->alignment = RGN_ALIGN_RIGHT; view_changed = true; } } else { - if (ar_properties && !(ar_properties->flag & RGN_FLAG_HIDDEN)) { - ar_properties->flag |= RGN_FLAG_HIDDEN; - ar_properties->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_properties->handlers); + if (region_properties && !(region_properties->flag & RGN_FLAG_HIDDEN)) { + region_properties->flag |= RGN_FLAG_HIDDEN; + region_properties->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_properties->handlers); view_changed = true; } - if (ar_properties && ar_properties->alignment != RGN_ALIGN_NONE) { - ar_properties->alignment = RGN_ALIGN_NONE; + if (region_properties && region_properties->alignment != RGN_ALIGN_NONE) { + region_properties->alignment = RGN_ALIGN_NONE; view_changed = true; } } if (tools_visible) { - if (ar_tools && (ar_tools->flag & RGN_FLAG_HIDDEN)) { - ar_tools->flag &= ~RGN_FLAG_HIDDEN; - ar_tools->v2d.flag &= ~V2D_IS_INITIALISED; + if (region_tools && (region_tools->flag & RGN_FLAG_HIDDEN)) { + region_tools->flag &= ~RGN_FLAG_HIDDEN; + region_tools->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = true; } - if (ar_tools && ar_tools->alignment != RGN_ALIGN_LEFT) { - ar_tools->alignment = RGN_ALIGN_LEFT; + if (region_tools && region_tools->alignment != RGN_ALIGN_LEFT) { + region_tools->alignment = RGN_ALIGN_LEFT; view_changed = true; } } else { - if (ar_tools && !(ar_tools->flag & RGN_FLAG_HIDDEN)) { - ar_tools->flag |= RGN_FLAG_HIDDEN; - ar_tools->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_tools->handlers); + if (region_tools && !(region_tools->flag & RGN_FLAG_HIDDEN)) { + region_tools->flag |= RGN_FLAG_HIDDEN; + region_tools->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_tools->handlers); view_changed = true; } - if (ar_tools && ar_tools->alignment != RGN_ALIGN_NONE) { - ar_tools->alignment = RGN_ALIGN_NONE; + if (region_tools && region_tools->alignment != RGN_ALIGN_NONE) { + region_tools->alignment = RGN_ALIGN_NONE; view_changed = true; } } if (preview_visible) { - if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; + if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) { + region_preview->flag &= ~RGN_FLAG_HIDDEN; + region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.cur = region_preview->v2d.tot; view_changed = true; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - ar_preview->alignment = RGN_ALIGN_NONE; + if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) { + region_preview->alignment = RGN_ALIGN_NONE; view_changed = true; } } else { - if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag |= RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_preview->handlers); + if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) { + region_preview->flag |= RGN_FLAG_HIDDEN; + region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_preview->handlers); view_changed = true; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - ar_preview->alignment = RGN_ALIGN_NONE; + if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) { + region_preview->alignment = RGN_ALIGN_NONE; view_changed = true; } } if (channels_visible) { - if (ar_channels && (ar_channels->flag & RGN_FLAG_HIDDEN)) { - ar_channels->flag &= ~RGN_FLAG_HIDDEN; - ar_channels->v2d.flag &= ~V2D_IS_INITIALISED; + if (region_channels && (region_channels->flag & RGN_FLAG_HIDDEN)) { + region_channels->flag &= ~RGN_FLAG_HIDDEN; + region_channels->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = true; } - if (ar_channels && ar_channels->alignment != RGN_ALIGN_LEFT) { - ar_channels->alignment = RGN_ALIGN_LEFT; + if (region_channels && region_channels->alignment != RGN_ALIGN_LEFT) { + region_channels->alignment = RGN_ALIGN_LEFT; view_changed = true; } } else { - if (ar_channels && !(ar_channels->flag & RGN_FLAG_HIDDEN)) { - ar_channels->flag |= RGN_FLAG_HIDDEN; - ar_channels->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_channels->handlers); + if (region_channels && !(region_channels->flag & RGN_FLAG_HIDDEN)) { + region_channels->flag |= RGN_FLAG_HIDDEN; + region_channels->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_channels->handlers); view_changed = true; } - if (ar_channels && ar_channels->alignment != RGN_ALIGN_NONE) { - ar_channels->alignment = RGN_ALIGN_NONE; + if (region_channels && region_channels->alignment != RGN_ALIGN_NONE) { + region_channels->alignment = RGN_ALIGN_NONE; view_changed = true; } } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index cb574e35422..8c963e32046 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1869,7 +1869,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w { ScrArea *sa = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); - ARegion *region, *ar_ctx = CTX_wm_region(C); + ARegion *region, *region_ctx = CTX_wm_region(C); const bool is_horizontal = (sfile->layout->flag & FILE_LAYOUT_HOR) != 0; int i; @@ -2033,7 +2033,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w ED_region_tag_redraw(region); /* and restore context */ - CTX_wm_region_set(C, ar_ctx); + CTX_wm_region_set(C, region_ctx); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 1574dbbeb76..59383626972 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -55,7 +55,7 @@ #include "filelist.h" #include "fsmenu.h" -static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev) +static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *region_prev) { ARegion *region; @@ -64,7 +64,7 @@ static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev) } region = MEM_callocN(sizeof(ARegion), "execute region for file"); - BLI_insertlinkafter(&sa->regionbase, ar_prev, region); + BLI_insertlinkafter(&sa->regionbase, region_prev, region); region->regiontype = RGN_TYPE_EXECUTE; region->alignment = RGN_ALIGN_BOTTOM; region->flag = RGN_FLAG_DYNAMIC_SIZE; @@ -72,7 +72,7 @@ static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *ar_prev) return region; } -static ARegion *file_tool_props_region_ensure(ScrArea *sa, ARegion *ar_prev) +static ARegion *file_tool_props_region_ensure(ScrArea *sa, ARegion *region_prev) { ARegion *region; @@ -82,7 +82,7 @@ static ARegion *file_tool_props_region_ensure(ScrArea *sa, ARegion *ar_prev) /* add subdiv level; after execute region */ region = MEM_callocN(sizeof(ARegion), "tool props for file"); - BLI_insertlinkafter(&sa->regionbase, ar_prev, region); + BLI_insertlinkafter(&sa->regionbase, region_prev, region); region->regiontype = RGN_TYPE_TOOL_PROPS; region->alignment = RGN_ALIGN_RIGHT; @@ -232,31 +232,31 @@ static void file_ensure_valid_region_state(bContext *C, SpaceFile *sfile, FileSelectParams *params) { - ARegion *ar_ui = BKE_area_find_region_type(sa, RGN_TYPE_UI); - ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS); - ARegion *ar_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE); + ARegion *region_ui = BKE_area_find_region_type(sa, RGN_TYPE_UI); + ARegion *region_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS); + ARegion *region_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE); bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */ /* If there's an file-operation, ensure we have the option and execute region */ - if (sfile->op && (ar_props == NULL)) { - ar_execute = file_execute_region_ensure(sa, ar_ui); - ar_props = file_tool_props_region_ensure(sa, ar_execute); + if (sfile->op && (region_props == NULL)) { + region_execute = file_execute_region_ensure(sa, region_ui); + region_props = file_tool_props_region_ensure(sa, region_execute); if (params->flag & FILE_HIDE_TOOL_PROPS) { - ar_props->flag |= RGN_FLAG_HIDDEN; + region_props->flag |= RGN_FLAG_HIDDEN; } else { - ar_props->flag &= ~RGN_FLAG_HIDDEN; + region_props->flag &= ~RGN_FLAG_HIDDEN; } needs_init = true; } /* If there's _no_ file-operation, ensure we _don't_ have the option and execute region */ - else if ((sfile->op == NULL) && (ar_props != NULL)) { - BLI_assert(ar_execute != NULL); + else if ((sfile->op == NULL) && (region_props != NULL)) { + BLI_assert(region_execute != NULL); - ED_region_remove(C, sa, ar_props); - ED_region_remove(C, sa, ar_execute); + ED_region_remove(C, sa, region_props); + ED_region_remove(C, sa, region_execute); needs_init = true; } diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 0af94904ba6..34c1958734d 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -62,14 +62,14 @@ void ED_drivers_editor_init(bContext *C, ScrArea *sa) sipo->mode = SIPO_MODE_DRIVERS; /* Show Properties Region (or else the settings can't be edited) */ - ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); - if (ar_props) { - UI_panel_category_active_set(ar_props, "Drivers"); + ARegion *region_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (region_props) { + UI_panel_category_active_set(region_props, "Drivers"); - ar_props->flag &= ~RGN_FLAG_HIDDEN; + region_props->flag &= ~RGN_FLAG_HIDDEN; /* XXX: Adjust width of this too? */ - ED_region_visibility_change_update(C, sa, ar_props); + ED_region_visibility_change_update(C, sa, region_props); } else { printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa); @@ -79,15 +79,15 @@ void ED_drivers_editor_init(bContext *C, ScrArea *sa) /* TODO: Have a way of not resetting this every time? * (e.g. So that switching back and forth between editors doesn't keep jumping?) */ - ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar_main) { + ARegion *region_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (region_main) { /* XXX: Ideally we recenter based on the range instead... */ - ar_main->v2d.tot.xmin = -2.0f; - ar_main->v2d.tot.ymin = -2.0f; - ar_main->v2d.tot.xmax = 2.0f; - ar_main->v2d.tot.ymax = 2.0f; + region_main->v2d.tot.xmin = -2.0f; + region_main->v2d.tot.ymin = -2.0f; + region_main->v2d.tot.xmax = 2.0f; + region_main->v2d.tot.ymax = 2.0f; - ar_main->v2d.cur = ar_main->v2d.tot; + region_main->v2d.cur = region_main->v2d.tot; } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 447bf27099d..2cd3f624455 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -223,88 +223,88 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *window = CTX_wm_window(C); SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; - ARegion *ar_main = sequencer_find_region(sa, RGN_TYPE_WINDOW); - ARegion *ar_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW); + ARegion *region_main = sequencer_find_region(sa, RGN_TYPE_WINDOW); + ARegion *region_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW); bool view_changed = false; switch (sseq->view) { case SEQ_VIEW_SEQUENCE: - if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag &= ~RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) { + region_main->flag &= ~RGN_FLAG_HIDDEN; + region_main->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = true; } - if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag |= RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_preview->handlers); + if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) { + region_preview->flag |= RGN_FLAG_HIDDEN; + region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_preview->handlers); view_changed = true; } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; + if (region_main && region_main->alignment != RGN_ALIGN_NONE) { + region_main->alignment = RGN_ALIGN_NONE; view_changed = true; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - ar_preview->alignment = RGN_ALIGN_NONE; + if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) { + region_preview->alignment = RGN_ALIGN_NONE; view_changed = true; } break; case SEQ_VIEW_PREVIEW: - if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) { - ar_main->flag |= RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext *)C, &ar_main->handlers); + if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) { + region_main->flag |= RGN_FLAG_HIDDEN; + region_main->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, ®ion_main->handlers); view_changed = true; } - if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; + if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) { + region_preview->flag &= ~RGN_FLAG_HIDDEN; + region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.cur = region_preview->v2d.tot; view_changed = true; } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; + if (region_main && region_main->alignment != RGN_ALIGN_NONE) { + region_main->alignment = RGN_ALIGN_NONE; view_changed = true; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - ar_preview->alignment = RGN_ALIGN_NONE; + if (region_preview && region_preview->alignment != RGN_ALIGN_NONE) { + region_preview->alignment = RGN_ALIGN_NONE; view_changed = true; } break; case SEQ_VIEW_SEQUENCE_PREVIEW: - if (ar_main && ar_preview) { + if (region_main && region_preview) { /* Get available height (without DPI correction). */ const float height = (sa->winy - ED_area_headersize()) / UI_DPI_FAC; /* We reuse hidden region's size, allows to find same layout as before if we just switch * between one 'full window' view and the combined one. This gets lost if we switch to both * 'full window' views before, though... Better than nothing. */ - if (ar_main->flag & RGN_FLAG_HIDDEN) { - ar_main->flag &= ~RGN_FLAG_HIDDEN; - ar_main->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->sizey = (int)(height - ar_main->sizey); + if (region_main->flag & RGN_FLAG_HIDDEN) { + region_main->flag &= ~RGN_FLAG_HIDDEN; + region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->sizey = (int)(height - region_main->sizey); view_changed = true; } - if (ar_preview->flag & RGN_FLAG_HIDDEN) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; - ar_main->sizey = (int)(height - ar_preview->sizey); + if (region_preview->flag & RGN_FLAG_HIDDEN) { + region_preview->flag &= ~RGN_FLAG_HIDDEN; + region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.cur = region_preview->v2d.tot; + region_main->sizey = (int)(height - region_preview->sizey); view_changed = true; } - if (ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; + if (region_main->alignment != RGN_ALIGN_NONE) { + region_main->alignment = RGN_ALIGN_NONE; view_changed = true; } - if (ar_preview->alignment != RGN_ALIGN_TOP) { - ar_preview->alignment = RGN_ALIGN_TOP; + if (region_preview->alignment != RGN_ALIGN_TOP) { + region_preview->alignment = RGN_ALIGN_TOP; view_changed = true; } /* Final check that both preview and main height are reasonable! */ - if (ar_preview->sizey < 10 || ar_main->sizey < 10 || - ar_preview->sizey + ar_main->sizey > height) { - ar_preview->sizey = (int)(height * 0.4f + 0.5f); - ar_main->sizey = (int)(height - ar_preview->sizey); + if (region_preview->sizey < 10 || region_main->sizey < 10 || + region_preview->sizey + region_main->sizey > height) { + region_preview->sizey = (int)(height * 0.4f + 0.5f); + region_main->sizey = (int)(height - region_preview->sizey); view_changed = true; } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 13c5bddd3bf..e5f1de7d5eb 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -101,12 +101,12 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) /* ideally would return an rv3d but in some cases the region is needed too * so return that, the caller can then access the region->regiondata */ -bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) +bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region) { ScrArea *sa = CTX_wm_area(C); *r_v3d = NULL; - *r_ar = NULL; + *r_region = NULL; if (sa && sa->spacetype == SPACE_VIEW3D) { ARegion *region = CTX_wm_region(C); @@ -117,11 +117,11 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) if ((region->regiontype == RGN_TYPE_WINDOW) && (rv3d = region->regiondata) && (rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) { *r_v3d = v3d; - *r_ar = region; + *r_region = region; return true; } else { - if (ED_view3d_area_user_region(sa, v3d, r_ar)) { + if (ED_view3d_area_user_region(sa, v3d, r_region)) { *r_v3d = v3d; return true; } @@ -136,11 +136,11 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) * Similar to #ED_view3d_context_user_region() but does not use context. Always performs a lookup. * Also works if \a v3d is not the active space. */ -bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion **r_ar) +bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion **r_region) { RegionView3D *rv3d = NULL; - ARegion *ar_unlock_user = NULL; - ARegion *ar_unlock = NULL; + ARegion *region_unlock_user = NULL; + ARegion *region_unlock = NULL; const ListBase *region_list = (v3d == sa->spacedata.first) ? &sa->regionbase : &v3d->regionbase; BLI_assert(v3d->spacetype == SPACE_VIEW3D); @@ -150,9 +150,9 @@ bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion ** if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) { rv3d = region->regiondata; if ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) { - ar_unlock = region; + region_unlock = region; if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) { - ar_unlock_user = region; + region_unlock_user = region; break; } } @@ -160,13 +160,13 @@ bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion ** } /* camera/perspective view get priority when the active region is locked */ - if (ar_unlock_user) { - *r_ar = ar_unlock_user; + if (region_unlock_user) { + *r_region = region_unlock_user; return true; } - if (ar_unlock) { - *r_ar = ar_unlock; + if (region_unlock) { + *r_region = region_unlock; return true; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e650f5581ff..09be73c87d1 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -529,10 +529,10 @@ static void viewops_data_create(bContext *C, negate_v3_v3(rv3d->ofs, dvec); } else { - const float mval_ar_mid[2] = {(float)vod->region->winx / 2.0f, - (float)vod->region->winy / 2.0f}; + const float mval_region_mid[2] = {(float)vod->region->winx / 2.0f, + (float)vod->region->winy / 2.0f}; - ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_ar_mid, rv3d->ofs); + ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_region_mid, rv3d->ofs); negate_v3(rv3d->ofs); } negate_v3(vod->dyn_ofs); diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 2637fb6d1db..5db26e26f0b 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -866,7 +866,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *region) /* 'clip' is used to know if our clip setting has changed */ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) { - ARegion *ar_sync = NULL; + ARegion *region_sync = NULL; RegionView3D *rv3d = region->regiondata; short viewlock; /* this function copies flags from the first of the 3 other quadview @@ -892,15 +892,15 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) rv3d->rflag &= ~RV3D_BOXCLIP; } - /* use ar_sync so we sync with one of the aligned views below + /* use region_sync so we sync with one of the aligned views below * else the view jumps on changing view settings like 'clip' * since it copies from the perspective view */ - ar_sync = region; + region_sync = region; } } if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, ar_sync ? ar_sync : sa->regionbase.last); + view3d_boxview_sync(sa, region_sync ? region_sync : sa->regionbase.last); } /* ensure locked regions have an axis, locked user views don't make much sense */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 522d1a15e3f..3dc5b3025aa 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -615,17 +615,18 @@ static void sync_viewport_camera_smoothview(bContext *C, if (v3d->scenelock) { ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase : &space_link->regionbase; - for (ARegion *other_ar = lb->first; other_ar != NULL; other_ar = other_ar->next) { - if (other_ar->regiontype == RGN_TYPE_WINDOW) { - if (other_ar->regiondata) { - RegionView3D *other_rv3d = other_ar->regiondata; + for (ARegion *other_region = lb->first; other_region != NULL; + other_region = other_region->next) { + if (other_region->regiontype == RGN_TYPE_WINDOW) { + if (other_region->regiondata) { + RegionView3D *other_rv3d = other_region->regiondata; if (other_rv3d->persp == RV3D_CAMOB) { Object *other_camera_old = other_v3d->camera; other_v3d->camera = ob; ED_view3d_lastview_store(other_rv3d); ED_view3d_smooth_view(C, other_v3d, - other_ar, + other_region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = other_camera_old, @@ -704,9 +705,9 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) bool ED_operator_rv3d_user_region_poll(bContext *C) { View3D *v3d_dummy; - ARegion *ar_dummy; + ARegion *region_dummy; - return ED_view3d_context_user_region(C, &v3d_dummy, &ar_dummy); + return ED_view3d_context_user_region(C, &v3d_dummy, ®ion_dummy); } void VIEW3D_OT_object_as_camera(wmOperatorType *ot) diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 123fd5f35da..9db957f8031 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -558,11 +558,11 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) struct Scene *scene = CTX_data_scene(C); /* keep in sync with logic in view3d_panel_operator_redo() */ - ARegion *ar_orig = CTX_wm_region(C); - ARegion *ar_win = BKE_area_find_region_active_win(CTX_wm_area(C)); + ARegion *region_orig = CTX_wm_region(C); + ARegion *region_win = BKE_area_find_region_active_win(CTX_wm_area(C)); - if (ar_win) { - CTX_wm_region_set(C, ar_win); + if (region_win) { + CTX_wm_region_set(C, region_win); } if ((WM_operator_repeat_check(C, op)) && (WM_operator_poll(C, op->type)) && @@ -585,9 +585,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) if (op->type->check) { if (op->type->check(C, op)) { /* check for popup and re-layout buttons */ - ARegion *ar_menu = CTX_wm_menu(C); - if (ar_menu) { - ED_region_tag_refresh_ui(ar_menu); + ARegion *region_menu = CTX_wm_menu(C); + if (region_menu) { + ED_region_tag_refresh_ui(region_menu); } } } @@ -610,7 +610,7 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) } /* set region back */ - CTX_wm_region_set(C, ar_orig); + CTX_wm_region_set(C, region_orig); } else { CLOG_WARN(&LOG, "called with NULL 'op'"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index cf515792252..7bff13bf1a6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -576,31 +576,31 @@ static ScrArea *rna_area_from_space(PointerRNA *ptr) static void area_region_from_regiondata(bScreen *sc, void *regiondata, ScrArea **r_sa, - ARegion **r_ar) + ARegion **r_region) { ScrArea *sa; ARegion *region; *r_sa = NULL; - *r_ar = NULL; + *r_region = NULL; for (sa = sc->areabase.first; sa; sa = sa->next) { for (region = sa->regionbase.first; region; region = region->next) { if (region->regiondata == regiondata) { *r_sa = sa; - *r_ar = region; + *r_region = region; return; } } } } -static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARegion **r_ar) +static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARegion **r_region) { bScreen *sc = (bScreen *)ptr->owner_id; void *regiondata = ptr->data; - area_region_from_regiondata(sc, regiondata, r_sa, r_ar); + area_region_from_regiondata(sc, regiondata, r_sa, r_region); } /* -------------------------------------------------------------------- */ @@ -680,9 +680,9 @@ static void rna_Space_show_region_header_set(PointerRNA *ptr, bool value) bool value_for_tool_header = value; if (value == true) { ScrArea *sa = rna_area_from_space(ptr); - ARegion *ar_tool_header = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER); - if (ar_tool_header != NULL) { - value_for_tool_header = !(ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER); + ARegion *region_tool_header = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER); + if (region_tool_header != NULL) { + value_for_tool_header = !(region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER); } } rna_Space_bool_from_region_flag_set_by_type( diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index ebfdd8a5f6a..b8bee118e3e 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -213,7 +213,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C, gzgroup = gzgroup->next) { if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) { ScrArea *ctx_sa = CTX_wm_area(C); - ARegion *ctx_ar = CTX_wm_region(C); + ARegion *ctx_region = CTX_wm_region(C); CTX_wm_area_set(C, sa); CTX_wm_region_set(C, region); @@ -224,7 +224,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C, /* Reset. */ CTX_wm_area_set(C, ctx_sa); - CTX_wm_region_set(C, ctx_ar); + CTX_wm_region_set(C, ctx_region); } for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { @@ -1052,13 +1052,13 @@ void WM_redraw_windows(bContext *C) { wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); wm_draw_update(C); CTX_wm_window_set(C, win_prev); CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1a794e9bf0b..8d7155b5ea8 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -839,7 +839,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca /* FIXME, temp setting window, see other call to UI_popup_menu_reports for why */ wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); if (win_prev == NULL) { CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); @@ -849,7 +849,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca CTX_wm_window_set(C, win_prev); CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } } @@ -2296,7 +2296,7 @@ static int wm_handler_fileselect_do(bContext *C, * it can be removed without breaking anything but then no linking errors - campbell */ wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); if (win_prev == NULL) { CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); @@ -2314,7 +2314,7 @@ static int wm_handler_fileselect_do(bContext *C, CTX_wm_window_set(C, win_prev); CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } /* for WM_operator_pystring only, custom report handling is done above */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c3446a016f1..4a4e373d15e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3201,13 +3201,13 @@ static void redraw_timer_step(bContext *C, CTX_wm_menu_set(C, NULL); for (sa_iter = screen->areabase.first; sa_iter; sa_iter = sa_iter->next) { - ARegion *ar_iter; + ARegion *region_iter; CTX_wm_area_set(C, sa_iter); - for (ar_iter = sa_iter->regionbase.first; ar_iter; ar_iter = ar_iter->next) { - if (ar_iter->visible) { - CTX_wm_region_set(C, ar_iter); - wm_draw_region_test(C, sa_iter, ar_iter); + for (region_iter = sa_iter->regionbase.first; region_iter; region_iter = region_iter->next) { + if (region_iter->visible) { + CTX_wm_region_set(C, region_iter); + wm_draw_region_test(C, sa_iter, region_iter); } } } diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c index 9c7ed52b0f9..0a1553cb3e1 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.c +++ b/source/blender/windowmanager/intern/wm_splash_screen.c @@ -71,8 +71,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *arg_u static void wm_block_splash_refreshmenu(bContext *C, void *UNUSED(arg_block), void *UNUSED(arg)) { - ARegion *ar_menu = CTX_wm_menu(C); - ED_region_tag_refresh_ui(ar_menu); + ARegion *region_menu = CTX_wm_menu(C); + ED_region_tag_refresh_ui(region_menu); } static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, int *y) diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 551250ec747..1abef2ec173 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -759,7 +759,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) if (!BLI_listbase_is_single(&wm->windows)) { wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); for (wmWindow *win = wm->windows.first; win; win = win->next) { if (win != win_prev) { @@ -772,7 +772,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) CTX_wm_window_set(C, win_prev); CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } } } diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index da2afda5e24..4d64acefca4 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -119,7 +119,7 @@ void WM_tooltip_init(bContext *C, wmWindow *win) { ScrArea *area_prev = CTX_wm_area(C); - ARegion *ar_prev = CTX_wm_region(C); + ARegion *region_prev = CTX_wm_region(C); CTX_wm_area_set(C, screen->tool_tip->area_from); CTX_wm_region_set(C, screen->tool_tip->region_from); screen->tool_tip->region = screen->tool_tip->init(C, @@ -128,7 +128,7 @@ void WM_tooltip_init(bContext *C, wmWindow *win) &pass_delay, &screen->tool_tip->exit_on_event); CTX_wm_area_set(C, area_prev); - CTX_wm_region_set(C, ar_prev); + CTX_wm_region_set(C, region_prev); } copy_v2_v2_int(screen->tool_tip->event_xy, &win->eventstate->x); -- cgit v1.2.3 From 82a8da0ec38a70efde4a91957824c67d0e60b8ad Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 2 Apr 2020 14:28:01 +0200 Subject: Fix T74572: adaptive sampling not scaling render passes correctly --- intern/cycles/render/buffers.cpp | 89 +++++++++++++++++++++++++--------------- intern/cycles/render/film.cpp | 3 -- intern/cycles/render/film.h | 1 - 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 2d89fb9ffba..22db8e875dc 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -165,6 +165,35 @@ bool RenderBuffers::copy_from_device() return true; } +static const float *get_sample_count_pass(const vector &passes, device_vector &buffer) +{ + int sample_offset = 0; + + for (const Pass &pass : passes) { + if (pass.type != PASS_SAMPLE_COUNT) { + sample_offset += pass.components; + } + else { + return buffer.data() + sample_offset; + } + } + + return NULL; +} + +static float get_pixel_pass_scale(const float rcp_sample, + const float *sample_count, + const int i, + const int pass_stride) +{ + if (sample_count) { + return 1.0f / fabsf(sample_count[i * pass_stride]); + } + else { + return rcp_sample; + } +} + bool RenderBuffers::get_denoising_pass_rect( int type, float exposure, int sample, int components, float *pixels) { @@ -260,22 +289,7 @@ bool RenderBuffers::get_pass_rect( return false; } - float *sample_count = NULL; - if (name == "Combined") { - int sample_offset = 0; - for (size_t j = 0; j < params.passes.size(); j++) { - Pass &pass = params.passes[j]; - if (pass.type != PASS_SAMPLE_COUNT) { - sample_offset += pass.components; - continue; - } - else { - sample_count = buffer.data() + sample_offset; - break; - } - } - } - + const float *sample_count = get_sample_count_pass(params.passes, buffer); int pass_offset = 0; for (size_t j = 0; j < params.passes.size(); j++) { @@ -293,8 +307,8 @@ bool RenderBuffers::get_pass_rect( float *in = buffer.data() + pass_offset; int pass_stride = params.get_passes_size(); - float scale = (pass.filter) ? 1.0f / (float)sample : 1.0f; - float scale_exposure = (pass.exposure) ? scale * exposure : scale; + const float rcp_sample = 1.0f / (float)sample; + const float pass_exposure = (pass.exposure) ? exposure : 1.0f; int size = params.width * params.height; @@ -312,28 +326,36 @@ bool RenderBuffers::get_pass_rect( if (type == PASS_DEPTH) { for (int i = 0; i < size; i++, in += pass_stride, pixels++) { float f = *in; - pixels[0] = (f == 0.0f) ? 1e10f : f * scale_exposure; + pixels[0] = (f == 0.0f) ? 1e10f : f; + } + } + else if (type == PASS_OBJECT_ID || type == PASS_MATERIAL_ID) { + for (int i = 0; i < size; i++, in += pass_stride, pixels++) { + pixels[0] = *in; } } else if (type == PASS_MIST) { for (int i = 0; i < size; i++, in += pass_stride, pixels++) { - float f = *in; - pixels[0] = saturate(f * scale_exposure); + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float f = *in; + pixels[0] = saturate(f * scale); } } #ifdef WITH_CYCLES_DEBUG else if (type == PASS_BVH_TRAVERSED_NODES || type == PASS_BVH_TRAVERSED_INSTANCES || type == PASS_BVH_INTERSECTIONS || type == PASS_RAY_BOUNCES) { for (int i = 0; i < size; i++, in += pass_stride, pixels++) { - float f = *in; + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float f = *in; pixels[0] = f * scale; } } #endif else { for (int i = 0; i < size; i++, in += pass_stride, pixels++) { - float f = *in; - pixels[0] = f * scale_exposure; + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float f = *in; + pixels[0] = f * scale * pass_exposure; } } } @@ -367,7 +389,7 @@ bool RenderBuffers::get_pass_rect( float3 f = make_float3(in[0], in[1], in[2]); float3 f_divide = make_float3(in_divide[0], in_divide[1], in_divide[2]); - f = safe_divide_even_color(f * exposure, f_divide); + f = safe_divide_even_color(f * pass_exposure, f_divide); pixels[0] = f.x; pixels[1] = f.y; @@ -377,7 +399,9 @@ bool RenderBuffers::get_pass_rect( else { /* RGB/vector */ for (int i = 0; i < size; i++, in += pass_stride, pixels += 3) { - float3 f = make_float3(in[0], in[1], in[2]); + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float scale_exposure = scale * pass_exposure; + const float3 f = make_float3(in[0], in[1], in[2]); pixels[0] = f.x * scale_exposure; pixels[1] = f.y * scale_exposure; @@ -425,7 +449,9 @@ bool RenderBuffers::get_pass_rect( } else if (type == PASS_CRYPTOMATTE) { for (int i = 0; i < size; i++, in += pass_stride, pixels += 4) { - float4 f = make_float4(in[0], in[1], in[2], in[3]); + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float4 f = make_float4(in[0], in[1], in[2], in[3]); + /* x and z contain integer IDs, don't rescale them. y and w contain matte weights, they get scaled. */ pixels[0] = f.x; @@ -436,12 +462,9 @@ bool RenderBuffers::get_pass_rect( } else { for (int i = 0; i < size; i++, in += pass_stride, pixels += 4) { - if (sample_count && sample_count[i * pass_stride] < 0.0f) { - scale = (pass.filter) ? -1.0f / (sample_count[i * pass_stride]) : 1.0f; - scale_exposure = (pass.exposure) ? scale * exposure : scale; - } - - float4 f = make_float4(in[0], in[1], in[2], in[3]); + const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride); + const float scale_exposure = scale * pass_exposure; + const float4 f = make_float4(in[0], in[1], in[2], in[3]); pixels[0] = f.x * scale_exposure; pixels[1] = f.y * scale_exposure; diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index baf02901123..c29810d1494 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -76,7 +76,6 @@ void Pass::add(PassType type, vector &passes, const char *name) Pass pass; pass.type = type; - pass.filter = true; pass.exposure = false; pass.divide_type = PASS_NONE; if (name) { @@ -93,7 +92,6 @@ void Pass::add(PassType type, vector &passes, const char *name) break; case PASS_DEPTH: pass.components = 1; - pass.filter = false; break; case PASS_MIST: pass.components = 1; @@ -114,7 +112,6 @@ void Pass::add(PassType type, vector &passes, const char *name) case PASS_OBJECT_ID: case PASS_MATERIAL_ID: pass.components = 1; - pass.filter = false; break; case PASS_EMISSION: diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h index aae8fb404b0..0fe4fe89d5e 100644 --- a/intern/cycles/render/film.h +++ b/intern/cycles/render/film.h @@ -42,7 +42,6 @@ class Pass { public: PassType type; int components; - bool filter; bool exposure; PassType divide_type; string name; -- cgit v1.2.3 From 80513d85747c80f8c88800928885bae1f980580d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 3 Apr 2020 01:47:23 +0200 Subject: Fix T75287: other Cycles render passes wrong when using Cryptomatte --- intern/cycles/blender/addon/engine.py | 13 +++++++------ intern/cycles/blender/blender_sync.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 2b872bb5c39..a1b063430f5 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -260,15 +260,16 @@ def list_render_passes(srl): if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR') # Cryptomatte passes. + crypto_depth = (crl.pass_crypto_depth + 1) // 2 if crl.use_pass_crypto_object: - for i in range(0, crl.pass_crypto_depth, 2): - yield ("CryptoObject" + '{:02d}'.format(i//2), "RGBA", 'COLOR') + for i in range(0, crypto_depth): + yield ("CryptoObject" + '{:02d}'.format(i), "RGBA", 'COLOR') if crl.use_pass_crypto_material: - for i in range(0, crl.pass_crypto_depth, 2): - yield ("CryptoMaterial" + '{:02d}'.format(i//2), "RGBA", 'COLOR') + for i in range(0, crypto_depth): + yield ("CryptoMaterial" + '{:02d}'.format(i), "RGBA", 'COLOR') if srl.cycles.use_pass_crypto_asset: - for i in range(0, srl.cycles.pass_crypto_depth, 2): - yield ("CryptoAsset" + '{:02d}'.format(i//2), "RGBA", 'COLOR') + for i in range(0, crypto_depth): + yield ("CryptoAsset" + '{:02d}'.format(i), "RGBA", 'COLOR') # Denoising passes. if crl.use_denoising or crl.denoising_store_passes: diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 28a737c3341..9e95cdb3f20 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -633,12 +633,12 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, /* Cryptomatte stores two ID/weight pairs per RGBA layer. * User facing parameter is the number of pairs. */ - int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")); + int crypto_depth = divide_up(min(16, get_int(crp, "pass_crypto_depth")), 2); scene->film->cryptomatte_depth = crypto_depth; scene->film->cryptomatte_passes = CRYPT_NONE; if (get_boolean(crp, "use_pass_crypto_object")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Object%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Object%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -646,8 +646,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_OBJECT); } if (get_boolean(crp, "use_pass_crypto_material")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Material%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Material%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -655,8 +655,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_MATERIAL); } if (get_boolean(crp, "use_pass_crypto_asset")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Asset%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Asset%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } -- cgit v1.2.3 From 1a69384e76e2b1ab11c87a582eb2cdf26386ac59 Mon Sep 17 00:00:00 2001 From: Asad-ullah Khan Date: Fri, 3 Apr 2020 02:35:25 +0200 Subject: Fix T74205: crash cancelling transfrom operation in sculpt mode Differential Revision: https://developer.blender.org/D7018 --- source/blender/editors/sculpt_paint/sculpt.c | 6 +++++- source/blender/editors/sculpt_paint/sculpt_intern.h | 1 + source/blender/editors/sculpt_paint/sculpt_undo.c | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 8d4870f5dd8..db138bb907d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -11076,7 +11076,11 @@ void ED_sculpt_end_transform(struct bContext *C) if (ss->filter_cache) { sculpt_filter_cache_free(ss); } - SCULPT_undo_push_end(); + /* Force undo push to happen even inside transform operator, since the sculpt + * undo system works separate from regular undo and this is require to properly + * finish an undo step also when cancelling. */ + const bool use_nested_undo = true; + SCULPT_undo_push_end_ex(use_nested_undo); sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index f0481582571..60b51ce17fd 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -726,6 +726,7 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node); void SCULPT_undo_push_begin(const char *name); void SCULPT_undo_push_end(void); +void SCULPT_undo_push_end_ex(const bool use_nested_undo); void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f6ed4fa21e0..f21bfe245dd 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1289,6 +1289,11 @@ void SCULPT_undo_push_begin(const char *name) } void SCULPT_undo_push_end(void) +{ + SCULPT_undo_push_end_ex(false); +} + +void SCULPT_undo_push_end_ex(const bool use_nested_undo) { UndoSculpt *usculpt = sculpt_undo_get_nodes(); SculptUndoNode *unode; @@ -1307,7 +1312,7 @@ void SCULPT_undo_push_end(void) /* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */ wmWindowManager *wm = G_MAIN->wm.first; - if (wm->op_undo_depth == 0) { + if (wm->op_undo_depth == 0 || use_nested_undo) { UndoStack *ustack = ED_undo_stack_get(); BKE_undosys_step_push(ustack, NULL, NULL); WM_file_tag_modified(); -- cgit v1.2.3 From 905c0269f302e8e0e7a27dda8d5256fdcd06ce60 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 3 Apr 2020 13:25:03 +0200 Subject: Cleanup: Rename ScrArea variables from sa to area Follow up of b2ee1770d4c3 and 10c2254d412d, part of T74432. Now the area and region naming conventions should be less confusing. Mostly a careful batch rename but had to do few smaller fixes. Also ran clang-format on affected files. --- source/blender/blenkernel/BKE_context.h | 2 +- source/blender/blenkernel/BKE_screen.h | 43 +- source/blender/blenkernel/intern/anim_sys.c | 4 +- source/blender/blenkernel/intern/context.c | 118 +++--- source/blender/blenkernel/intern/image.c | 6 +- source/blender/blenkernel/intern/screen.c | 146 +++---- source/blender/blenlib/intern/delaunay_2d.c | 14 +- source/blender/blenloader/intern/readfile.c | 7 +- source/blender/blenloader/intern/versioning_250.c | 152 +++---- source/blender/blenloader/intern/versioning_260.c | 78 ++-- source/blender/blenloader/intern/versioning_270.c | 55 +-- source/blender/blenloader/intern/versioning_280.c | 233 ++++++----- .../blenloader/intern/versioning_defaults.c | 70 ++-- .../blender/blenloader/intern/versioning_legacy.c | 100 ++--- .../blender/editors/animation/anim_channels_edit.c | 32 +- source/blender/editors/animation/anim_filter.c | 6 +- source/blender/editors/animation/anim_markers.c | 24 +- source/blender/editors/animation/anim_ops.c | 20 +- source/blender/editors/animation/keyframing.c | 4 +- source/blender/editors/armature/armature_naming.c | 6 +- source/blender/editors/armature/pose_edit.c | 4 +- source/blender/editors/armature/pose_lib.c | 18 +- source/blender/editors/armature/pose_slide.c | 10 +- .../gizmo_library/gizmo_types/move3d_gizmo.c | 6 +- source/blender/editors/gpencil/annotate_draw.c | 14 +- source/blender/editors/gpencil/annotate_paint.c | 57 +-- source/blender/editors/gpencil/gpencil_convert.c | 4 +- source/blender/editors/gpencil/gpencil_data.c | 4 +- source/blender/editors/gpencil/gpencil_edit.c | 20 +- source/blender/editors/gpencil/gpencil_fill.c | 10 +- source/blender/editors/gpencil/gpencil_intern.h | 6 +- .../blender/editors/gpencil/gpencil_interpolate.c | 14 +- source/blender/editors/gpencil/gpencil_ops.c | 4 +- source/blender/editors/gpencil/gpencil_paint.c | 53 +-- source/blender/editors/gpencil/gpencil_primitive.c | 8 +- .../blender/editors/gpencil/gpencil_sculpt_paint.c | 8 +- source/blender/editors/gpencil/gpencil_select.c | 12 +- source/blender/editors/gpencil/gpencil_utils.c | 68 +-- source/blender/editors/gpencil/gpencil_uv.c | 12 +- source/blender/editors/include/ED_anim_api.h | 6 +- source/blender/editors/include/ED_gpencil.h | 10 +- source/blender/editors/include/ED_mask.h | 19 +- source/blender/editors/include/ED_node.h | 4 +- source/blender/editors/include/ED_render.h | 2 +- source/blender/editors/include/ED_screen.h | 58 +-- source/blender/editors/include/ED_util.h | 2 +- source/blender/editors/include/ED_view3d.h | 6 +- source/blender/editors/include/UI_interface.h | 4 +- source/blender/editors/include/UI_view2d.h | 2 +- .../editors/interface/interface_eyedropper.c | 4 +- .../editors/interface/interface_eyedropper_color.c | 22 +- .../interface/interface_eyedropper_datablock.c | 22 +- .../editors/interface/interface_eyedropper_depth.c | 12 +- source/blender/editors/interface/interface_icons.c | 8 +- source/blender/editors/interface/interface_ops.c | 6 +- source/blender/editors/interface/interface_panel.c | 80 ++-- .../editors/interface/interface_region_hud.c | 42 +- .../interface/interface_region_menu_popup.c | 8 +- .../editors/interface/interface_region_popover.c | 8 +- .../editors/interface/interface_region_popup.c | 6 +- .../editors/interface/interface_region_tooltip.c | 6 +- .../editors/interface/interface_templates.c | 25 +- source/blender/editors/interface/view2d.c | 11 +- source/blender/editors/interface/view2d_ops.c | 22 +- source/blender/editors/mask/mask_add.c | 22 +- source/blender/editors/mask/mask_draw.c | 4 +- source/blender/editors/mask/mask_edit.c | 12 +- source/blender/editors/mask/mask_ops.c | 26 +- source/blender/editors/mask/mask_query.c | 98 ++--- source/blender/editors/mask/mask_select.c | 26 +- source/blender/editors/mesh/editmesh_bevel.c | 6 +- source/blender/editors/mesh/editmesh_inset.c | 12 +- source/blender/editors/object/object_bake_api.c | 22 +- source/blender/editors/physics/particle_edit.c | 4 +- source/blender/editors/render/render_internal.c | 52 +-- source/blender/editors/render/render_preview.c | 20 +- source/blender/editors/render/render_shading.c | 12 +- source/blender/editors/render/render_update.c | 28 +- source/blender/editors/render/render_view.c | 114 ++--- source/blender/editors/screen/area.c | 462 ++++++++++----------- source/blender/editors/screen/area_utils.c | 2 +- source/blender/editors/screen/screen_context.c | 24 +- source/blender/editors/screen/screen_draw.c | 176 ++++---- source/blender/editors/screen/screen_edit.c | 375 ++++++++--------- source/blender/editors/screen/screen_geometry.c | 59 ++- source/blender/editors/screen/screen_intern.h | 11 +- source/blender/editors/screen/screen_ops.c | 366 ++++++++-------- source/blender/editors/screen/screendump.c | 6 +- .../blender/editors/screen/workspace_layout_edit.c | 8 +- source/blender/editors/sculpt_paint/paint_image.c | 22 +- .../editors/sculpt_paint/paint_image_proj.c | 8 +- source/blender/editors/sculpt_paint/paint_stroke.c | 7 +- source/blender/editors/sculpt_paint/paint_vertex.c | 8 +- source/blender/editors/sculpt_paint/sculpt.c | 20 +- source/blender/editors/space_action/action_data.c | 12 +- source/blender/editors/space_action/action_draw.c | 2 +- source/blender/editors/space_action/space_action.c | 96 ++--- source/blender/editors/space_api/spacetypes.c | 4 +- .../blender/editors/space_buttons/space_buttons.c | 102 ++--- .../editors/space_clip/clip_dopesheet_draw.c | 4 +- source/blender/editors/space_clip/clip_editor.c | 6 +- source/blender/editors/space_clip/clip_intern.h | 2 +- source/blender/editors/space_clip/clip_ops.c | 4 +- source/blender/editors/space_clip/clip_toolbar.c | 8 +- source/blender/editors/space_clip/space_clip.c | 130 +++--- source/blender/editors/space_console/console_ops.c | 8 +- .../blender/editors/space_console/space_console.c | 10 +- source/blender/editors/space_file/file_ops.c | 50 +-- source/blender/editors/space_file/space_file.c | 70 ++-- source/blender/editors/space_graph/graph_edit.c | 14 +- source/blender/editors/space_graph/graph_utils.c | 28 +- source/blender/editors/space_graph/space_graph.c | 56 +-- source/blender/editors/space_image/image_ops.c | 16 +- source/blender/editors/space_image/image_undo.c | 6 +- source/blender/editors/space_image/space_image.c | 98 ++--- source/blender/editors/space_info/space_info.c | 10 +- source/blender/editors/space_nla/nla_draw.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 28 +- source/blender/editors/space_nla/space_nla.c | 41 +- source/blender/editors/space_node/node_edit.c | 12 +- .../editors/space_node/node_relationships.c | 17 +- source/blender/editors/space_node/space_node.c | 80 ++-- .../blender/editors/space_outliner/outliner_edit.c | 12 +- .../blender/editors/space_outliner/outliner_sync.c | 4 +- .../editors/space_outliner/space_outliner.c | 18 +- source/blender/editors/space_script/space_script.c | 4 +- .../editors/space_sequencer/sequencer_edit.c | 26 +- .../editors/space_sequencer/sequencer_preview.c | 4 +- .../editors/space_sequencer/space_sequencer.c | 48 +-- .../editors/space_statusbar/space_statusbar.c | 6 +- source/blender/editors/space_text/space_text.c | 30 +- .../blender/editors/space_text/text_autocomplete.c | 6 +- source/blender/editors/space_text/text_draw.c | 8 +- source/blender/editors/space_text/text_header.c | 12 +- source/blender/editors/space_text/text_intern.h | 2 +- source/blender/editors/space_topbar/space_topbar.c | 8 +- .../editors/space_userpref/space_userpref.c | 10 +- source/blender/editors/space_view3d/space_view3d.c | 65 +-- source/blender/editors/space_view3d/view3d_draw.c | 6 +- source/blender/editors/space_view3d/view3d_edit.c | 70 ++-- .../editors/space_view3d/view3d_gizmo_ruler.c | 10 +- .../blender/editors/space_view3d/view3d_header.c | 2 +- .../blender/editors/space_view3d/view3d_intern.h | 6 +- .../blender/editors/space_view3d/view3d_select.c | 2 +- source/blender/editors/space_view3d/view3d_utils.c | 40 +- source/blender/editors/space_view3d/view3d_view.c | 44 +- source/blender/editors/transform/transform.c | 42 +- source/blender/editors/transform/transform.h | 2 +- .../editors/transform/transform_constraints.c | 2 +- .../blender/editors/transform/transform_convert.c | 22 +- .../editors/transform/transform_convert_cursor.c | 2 +- .../editors/transform/transform_convert_graph.c | 6 +- .../editors/transform/transform_convert_mask.c | 6 +- .../editors/transform/transform_convert_mesh.c | 2 +- .../editors/transform/transform_convert_node.c | 4 +- .../transform/transform_convert_sequencer.c | 2 +- .../editors/transform/transform_convert_tracking.c | 2 +- .../blender/editors/transform/transform_generics.c | 54 +-- .../blender/editors/transform/transform_gizmo_2d.c | 36 +- .../blender/editors/transform/transform_gizmo_3d.c | 44 +- source/blender/editors/transform/transform_mode.c | 6 +- .../editors/transform/transform_mode_align.c | 2 +- .../editors/transform/transform_mode_baketime.c | 2 +- .../transform/transform_mode_bbone_resize.c | 2 +- .../editors/transform/transform_mode_bend.c | 5 +- .../transform/transform_mode_boneenvelope.c | 2 +- .../editors/transform/transform_mode_boneroll.c | 2 +- .../transform/transform_mode_curveshrinkfatten.c | 2 +- .../transform/transform_mode_edge_bevelweight.c | 2 +- .../editors/transform/transform_mode_edge_crease.c | 2 +- .../transform/transform_mode_edge_rotate_normal.c | 2 +- .../transform/transform_mode_edge_seq_slide.c | 2 +- .../editors/transform/transform_mode_edge_slide.c | 10 +- .../editors/transform/transform_mode_gpopacity.c | 2 +- .../transform/transform_mode_gpshrinkfatten.c | 2 +- .../transform/transform_mode_maskshrinkfatten.c | 2 +- .../editors/transform/transform_mode_mirror.c | 6 +- .../editors/transform/transform_mode_push_pull.c | 2 +- .../editors/transform/transform_mode_resize.c | 2 +- .../editors/transform/transform_mode_rotate.c | 2 +- .../editors/transform/transform_mode_shear.c | 2 +- .../transform/transform_mode_shrink_fatten.c | 2 +- .../editors/transform/transform_mode_skin_resize.c | 2 +- .../editors/transform/transform_mode_tilt.c | 2 +- .../editors/transform/transform_mode_timescale.c | 2 +- .../editors/transform/transform_mode_timeslide.c | 6 +- .../transform/transform_mode_timetranslate.c | 2 +- .../editors/transform/transform_mode_tosphere.c | 2 +- .../editors/transform/transform_mode_trackball.c | 2 +- .../editors/transform/transform_mode_translate.c | 4 +- .../editors/transform/transform_mode_vert_slide.c | 2 +- source/blender/editors/transform/transform_ops.c | 4 +- source/blender/editors/transform/transform_snap.c | 6 +- source/blender/editors/undo/ed_undo.c | 6 +- source/blender/editors/util/ed_util.c | 4 +- source/blender/editors/util/gizmo_utils.c | 4 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 8 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 10 +- source/blender/makesrna/intern/rna_material.c | 6 +- source/blender/makesrna/intern/rna_object_api.c | 6 +- source/blender/makesrna/intern/rna_screen.c | 58 +-- source/blender/makesrna/intern/rna_sculpt_paint.c | 6 +- source/blender/makesrna/intern/rna_space.c | 126 +++--- source/blender/makesrna/intern/rna_space_api.c | 14 +- source/blender/makesrna/intern/rna_ui.c | 7 +- source/blender/makesrna/intern/rna_wm_gizmo.c | 4 +- source/blender/windowmanager/WM_api.h | 8 +- source/blender/windowmanager/WM_toolsystem.h | 8 +- source/blender/windowmanager/WM_types.h | 6 +- source/blender/windowmanager/gizmo/WM_gizmo_api.h | 2 +- .../windowmanager/gizmo/intern/wm_gizmo_group.c | 22 +- .../windowmanager/gizmo/intern/wm_gizmo_map.c | 29 +- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 6 +- source/blender/windowmanager/intern/wm_cursors.c | 4 +- source/blender/windowmanager/intern/wm_dragdrop.c | 4 +- source/blender/windowmanager/intern/wm_draw.c | 102 ++--- .../blender/windowmanager/intern/wm_event_system.c | 184 ++++---- source/blender/windowmanager/intern/wm_files.c | 8 +- source/blender/windowmanager/intern/wm_keymap.c | 14 +- .../windowmanager/intern/wm_operator_utils.c | 8 +- source/blender/windowmanager/intern/wm_operators.c | 43 +- .../blender/windowmanager/intern/wm_toolsystem.c | 100 ++--- source/blender/windowmanager/intern/wm_tooltip.c | 12 +- source/blender/windowmanager/intern/wm_window.c | 8 +- source/blender/windowmanager/wm_draw.h | 2 +- 225 files changed, 3206 insertions(+), 3164 deletions(-) diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 9e2a124491c..c4fb19ea355 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -178,7 +178,7 @@ struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C); void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm); void CTX_wm_window_set(bContext *C, struct wmWindow *win); void CTX_wm_screen_set(bContext *C, struct bScreen *screen); /* to be removed */ -void CTX_wm_area_set(bContext *C, struct ScrArea *sa); +void CTX_wm_area_set(bContext *C, struct ScrArea *area); void CTX_wm_region_set(bContext *C, struct ARegion *region); void CTX_wm_menu_set(bContext *C, struct ARegion *menu); void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 2231cc36861..ca25d7f8d95 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -72,25 +72,25 @@ typedef struct SpaceType { /* Initial allocation, after this WM will call init() too. Some editors need * area and scene data (e.g. frame range) to set their initial scrolling. */ - struct SpaceLink *(*new)(const struct ScrArea *sa, const struct Scene *scene); + struct SpaceLink *(*new)(const struct ScrArea *area, const struct Scene *scene); /* not free spacelink itself */ void (*free)(struct SpaceLink *sl); /* init is to cope with file load, screen (size) changes, check handlers */ - void (*init)(struct wmWindowManager *wm, struct ScrArea *sa); + void (*init)(struct wmWindowManager *wm, struct ScrArea *area); /* exit is called when the area is hidden or removed */ - void (*exit)(struct wmWindowManager *wm, struct ScrArea *sa); + void (*exit)(struct wmWindowManager *wm, struct ScrArea *area); /* Listeners can react to bContext changes */ void (*listener)(struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct wmNotifier *wmn, struct Scene *scene); /* called when the mouse moves out of the area */ - void (*deactivate)(struct ScrArea *sa); + void (*deactivate)(struct ScrArea *area); /* refresh context, called after filereads, ED_area_tag_refresh() */ - void (*refresh)(const struct bContext *C, struct ScrArea *sa); + void (*refresh)(const struct bContext *C, struct ScrArea *area); /* after a spacedata copy, an init should result in exact same situation */ struct SpaceLink *(*duplicate)(struct SpaceLink *sl); @@ -109,10 +109,13 @@ typedef struct SpaceType { int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result); /* Used when we want to replace an ID by another (or NULL). */ - void (*id_remap)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id); + void (*id_remap)(struct ScrArea *area, + struct SpaceLink *sl, + struct ID *old_id, + struct ID *new_id); - int (*space_subtype_get)(struct ScrArea *sa); - void (*space_subtype_set)(struct ScrArea *sa, int value); + int (*space_subtype_get)(struct ScrArea *area); + void (*space_subtype_set)(struct ScrArea *area, int value); void (*space_subtype_item_extend)(struct bContext *C, EnumPropertyItem **item, int *totitem); /* region type definitions */ @@ -144,7 +147,7 @@ typedef struct ARegionType { int (*snap_size)(const struct ARegion *region, int size, int axis); /* contextual changes should be handled here */ void (*listener)(struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmNotifier *wmn, const struct Scene *scene); @@ -153,7 +156,7 @@ typedef struct ARegionType { struct WorkSpace *workspace, struct Scene *scene, struct bScreen *sc, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); @@ -167,7 +170,7 @@ typedef struct ARegionType { /* add own items to keymap */ void (*keymap)(struct wmKeyConfig *keyconf); /* allows default cursor per region */ - void (*cursor)(struct wmWindow *win, struct ScrArea *sa, struct ARegion *region); + void (*cursor)(struct wmWindow *win, struct ScrArea *area, struct ARegion *region); /* return context data */ int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result); @@ -333,27 +336,27 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); void BKE_spacedata_draw_locks(int set); struct ARegion *BKE_spacedata_find_region_type(const struct SpaceLink *slink, - const struct ScrArea *sa, + const struct ScrArea *area, int region_type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -void BKE_spacedata_callback_id_remap_set( - void (*func)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id)); -void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id); +void BKE_spacedata_callback_id_remap_set(void (*func)( + struct ScrArea *area, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id)); +void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id); /* area/regions */ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *region); void BKE_area_region_free(struct SpaceType *st, struct ARegion *region); void BKE_area_region_panels_free(struct ListBase *panels); -void BKE_screen_area_free(struct ScrArea *sa); +void BKE_screen_area_free(struct ScrArea *area); /* Gizmo-maps of a region need to be freed with the region. * Uses callback to avoid low-level call. */ void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *)); void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *)); -struct ARegion *BKE_area_find_region_type(const struct ScrArea *sa, int type); -struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa); -struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y); +struct ARegion *BKE_area_find_region_type(const struct ScrArea *area, int type); +struct ARegion *BKE_area_find_region_active_win(struct ScrArea *area); +struct ARegion *BKE_area_find_region_xy(struct ScrArea *area, const int regiontype, int x, int y); struct ARegion *BKE_screen_find_region_xy(struct bScreen *sc, const int regiontype, int x, int y) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 2027dbe6c23..25582700e9e 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -674,7 +674,7 @@ char *BKE_animdata_driver_path_hack(bContext *C, char *base_path) { ID *id = ptr->owner_id; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* get standard path which may be extended */ char *basepath = base_path ? base_path : RNA_path_from_ID_to_property(ptr, prop); @@ -684,7 +684,7 @@ char *BKE_animdata_driver_path_hack(bContext *C, * restricts the subspace of options to the 'active' data (a manageable state) */ /* TODO: watch out for pinned context? */ - if ((sa) && (sa->spacetype == SPACE_PROPERTIES)) { + if ((area) && (area->spacetype == SPACE_PROPERTIES)) { Object *ob = CTX_data_active_object(C); if (ob && id) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index f6db23111a1..6beb95ca0b0 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -279,7 +279,7 @@ static void *ctx_wm_python_context_get(const bContext *C, static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) { bScreen *sc; - ScrArea *sa; + ScrArea *area; ARegion *region; int done = 0, recursion = C->data.recursion; int ret = 0; @@ -327,10 +327,10 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res } } } - if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) { + if (done != 1 && recursion < 3 && (area = CTX_wm_area(C))) { C->data.recursion = 3; - if (sa->type && sa->type->context) { - ret = sa->type->context(C, member, result); + if (area->type && area->type->context) { + ret = area->type->context(C, member, result); if (ret) { done = -(-ret | -done); } @@ -544,7 +544,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C, bContextDataResult result; ListBase lb; bScreen *sc; - ScrArea *sa; + ScrArea *area; ARegion *region; int a; @@ -588,9 +588,9 @@ ListBase CTX_data_dir_get_ex(const bContext *C, } } } - if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) { + if ((area = CTX_wm_area(C)) && area->type && area->type->context) { memset(&result, 0, sizeof(result)); - sa->type->context(C, "", &result); + area->type->context(C, "", &result); if (result.dir) { for (a = 0; result.dir[a]; a++) { @@ -716,8 +716,8 @@ ScrArea *CTX_wm_area(const bContext *C) SpaceLink *CTX_wm_space_data(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - return (sa) ? sa->spacedata.first : NULL; + ScrArea *area = CTX_wm_area(C); + return (area) ? area->spacedata.first : NULL; } ARegion *CTX_wm_region(const bContext *C) @@ -757,19 +757,19 @@ struct ReportList *CTX_wm_reports(const bContext *C) View3D *CTX_wm_view3d(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_VIEW3D) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_VIEW3D) { + return area->spacedata.first; } return NULL; } RegionView3D *CTX_wm_region_view3d(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (sa && sa->spacetype == SPACE_VIEW3D) { + if (area && area->spacetype == SPACE_VIEW3D) { if (region && region->regiontype == RGN_TYPE_WINDOW) { return region->regiondata; } @@ -779,135 +779,135 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C) struct SpaceText *CTX_wm_space_text(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_TEXT) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_TEXT) { + return area->spacedata.first; } return NULL; } struct SpaceConsole *CTX_wm_space_console(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_CONSOLE) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_CONSOLE) { + return area->spacedata.first; } return NULL; } struct SpaceImage *CTX_wm_space_image(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_IMAGE) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_IMAGE) { + return area->spacedata.first; } return NULL; } struct SpaceProperties *CTX_wm_space_properties(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_PROPERTIES) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_PROPERTIES) { + return area->spacedata.first; } return NULL; } struct SpaceFile *CTX_wm_space_file(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_FILE) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_FILE) { + return area->spacedata.first; } return NULL; } struct SpaceSeq *CTX_wm_space_seq(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_SEQ) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_SEQ) { + return area->spacedata.first; } return NULL; } struct SpaceOutliner *CTX_wm_space_outliner(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_OUTLINER) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_OUTLINER) { + return area->spacedata.first; } return NULL; } struct SpaceNla *CTX_wm_space_nla(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_NLA) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_NLA) { + return area->spacedata.first; } return NULL; } struct SpaceNode *CTX_wm_space_node(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_NODE) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_NODE) { + return area->spacedata.first; } return NULL; } struct SpaceGraph *CTX_wm_space_graph(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_GRAPH) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_GRAPH) { + return area->spacedata.first; } return NULL; } struct SpaceAction *CTX_wm_space_action(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_ACTION) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_ACTION) { + return area->spacedata.first; } return NULL; } struct SpaceInfo *CTX_wm_space_info(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_INFO) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_INFO) { + return area->spacedata.first; } return NULL; } struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_USERPREF) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_USERPREF) { + return area->spacedata.first; } return NULL; } struct SpaceClip *CTX_wm_space_clip(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_CLIP) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_CLIP) { + return area->spacedata.first; } return NULL; } struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_TOPBAR) { - return sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_TOPBAR) { + return area->spacedata.first; } return NULL; } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5dca9bf2ac5..0fb70869ac0 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -3199,9 +3199,9 @@ static void image_walk_id_all_users( for (wmWindow *win = wm->windows.first; win; win = win->next) { const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; callback(sima->image, NULL, &sima->iuser, customdata); } } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 6c888e7b19e..96615ced904 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -338,15 +338,17 @@ void BKE_spacedata_draw_locks(int set) /** * Version of #BKE_area_find_region_type that also works if \a slink - * is not the active space of \a sa. + * is not the active space of \a area. */ -ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *sa, int region_type) +ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, + const ScrArea *area, + int region_type) { - const bool is_slink_active = slink == sa->spacedata.first; - const ListBase *regionbase = (is_slink_active) ? &sa->regionbase : &slink->regionbase; + const bool is_slink_active = slink == area->spacedata.first; + const ListBase *regionbase = (is_slink_active) ? &area->regionbase : &slink->regionbase; ARegion *region = NULL; - BLI_assert(BLI_findindex(&sa->spacedata, slink) != -1); + BLI_assert(BLI_findindex(&area->spacedata, slink) != -1); for (region = regionbase->first; region; region = region->next) { if (region->regiontype == region_type) { break; @@ -354,26 +356,26 @@ ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *s } /* Should really unit test this instead. */ - BLI_assert(!is_slink_active || region == BKE_area_find_region_type(sa, region_type)); + BLI_assert(!is_slink_active || region == BKE_area_find_region_type(area, region_type)); return region; } -static void (*spacedata_id_remap_cb)(struct ScrArea *sa, +static void (*spacedata_id_remap_cb)(struct ScrArea *area, struct SpaceLink *sl, ID *old_id, ID *new_id) = NULL; -void BKE_spacedata_callback_id_remap_set(void (*func)(ScrArea *sa, SpaceLink *sl, ID *, ID *)) +void BKE_spacedata_callback_id_remap_set(void (*func)(ScrArea *area, SpaceLink *sl, ID *, ID *)) { spacedata_id_remap_cb = func; } /* UNUSED!!! */ -void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id) +void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id) { if (spacedata_id_remap_cb) { - spacedata_id_remap_cb(sa, sl, id, NULL); + spacedata_id_remap_cb(area, sl, id, NULL); } } @@ -393,10 +395,10 @@ void BKE_screen_gizmo_tag_refresh(struct bScreen *sc) return; } - ScrArea *sa; + ScrArea *area; ARegion *region; - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (region = sa->regionbase.first; region; region = region->next) { + for (area = sc->areabase.first; area; area = area->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->gizmo_map != NULL) { region_refresh_tag_gizmomap_callback(region->gizmo_map); } @@ -482,21 +484,21 @@ void BKE_area_region_free(SpaceType *st, ARegion *region) } /* not area itself */ -void BKE_screen_area_free(ScrArea *sa) +void BKE_screen_area_free(ScrArea *area) { - SpaceType *st = BKE_spacetype_from_id(sa->spacetype); + SpaceType *st = BKE_spacetype_from_id(area->spacetype); ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { BKE_area_region_free(st, region); } - MEM_SAFE_FREE(sa->global); - BLI_freelistN(&sa->regionbase); + MEM_SAFE_FREE(area->global); + BLI_freelistN(&area->regionbase); - BKE_spacedata_freelist(&sa->spacedata); + BKE_spacedata_freelist(&area->spacedata); - BLI_freelistN(&sa->actionzones); + BLI_freelistN(&area->actionzones); } void BKE_screen_area_map_free(ScrAreaMap *area_map) @@ -548,7 +550,7 @@ void BKE_screen_remove_double_scrverts(bScreen *sc) { ScrVert *v1, *verg; ScrEdge *se; - ScrArea *sa; + ScrArea *area; verg = sc->vertbase.first; while (verg) { @@ -580,21 +582,21 @@ void BKE_screen_remove_double_scrverts(bScreen *sc) BKE_screen_sort_scrvert(&(se->v1), &(se->v2)); se = se->next; } - sa = sc->areabase.first; - while (sa) { - if (sa->v1->newv) { - sa->v1 = sa->v1->newv; + area = sc->areabase.first; + while (area) { + if (area->v1->newv) { + area->v1 = area->v1->newv; } - if (sa->v2->newv) { - sa->v2 = sa->v2->newv; + if (area->v2->newv) { + area->v2 = area->v2->newv; } - if (sa->v3->newv) { - sa->v3 = sa->v3->newv; + if (area->v3->newv) { + area->v3 = area->v3->newv; } - if (sa->v4->newv) { - sa->v4 = sa->v4->newv; + if (area->v4->newv) { + area->v4 = area->v4->newv; } - sa = sa->next; + area = area->next; } /* remove */ @@ -632,41 +634,41 @@ void BKE_screen_remove_double_scredges(bScreen *sc) void BKE_screen_remove_unused_scredges(bScreen *sc) { ScrEdge *se, *sen; - ScrArea *sa; + ScrArea *area; int a = 0; /* sets flags when edge is used in area */ - sa = sc->areabase.first; - while (sa) { - se = BKE_screen_find_edge(sc, sa->v1, sa->v2); + area = sc->areabase.first; + while (area) { + se = BKE_screen_find_edge(sc, area->v1, area->v2); if (se == NULL) { printf("error: area %d edge 1 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, sa->v2, sa->v3); + se = BKE_screen_find_edge(sc, area->v2, area->v3); if (se == NULL) { printf("error: area %d edge 2 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, sa->v3, sa->v4); + se = BKE_screen_find_edge(sc, area->v3, area->v4); if (se == NULL) { printf("error: area %d edge 3 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, sa->v4, sa->v1); + se = BKE_screen_find_edge(sc, area->v4, area->v1); if (se == NULL) { printf("error: area %d edge 4 doesn't exist\n", a); } else { se->flag = 1; } - sa = sa->next; + area = area->next; a++; } se = sc->edgebase.first; @@ -714,15 +716,15 @@ void BKE_screen_remove_unused_scrverts(bScreen *sc) /* ***************** Utilities ********************** */ /** - * Find a region of type \a region_type in the currently active space of \a sa. + * Find a region of type \a region_type in the currently active space of \a area. * * \note This does _not_ work if the region to look up is not in the active * space. Use #BKE_spacedata_find_region_type if that may be the case. */ -ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type) +ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type) { - if (sa) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + if (area) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == region_type) { return region; } @@ -732,26 +734,26 @@ ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type) return NULL; } -ARegion *BKE_area_find_region_active_win(ScrArea *sa) +ARegion *BKE_area_find_region_active_win(ScrArea *area) { - if (sa) { - ARegion *region = BLI_findlink(&sa->regionbase, sa->region_active_win); + if (area) { + ARegion *region = BLI_findlink(&area->regionbase, area->region_active_win); if (region && (region->regiontype == RGN_TYPE_WINDOW)) { return region; } /* fallback to any */ - return BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + return BKE_area_find_region_type(area, RGN_TYPE_WINDOW); } return NULL; } -ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y) +ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int y) { ARegion *region_found = NULL; - if (sa) { + if (area) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { region_found = region; @@ -786,15 +788,15 @@ ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int */ ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (BLI_findindex(&sa->spacedata, sl) != -1) { + for (area = sc->areabase.first; area; area = area->next) { + if (BLI_findindex(&area->spacedata, sl) != -1) { break; } } - return sa; + return area; } /** @@ -803,16 +805,16 @@ ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl) */ ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short min) { - ScrArea *sa, *big = NULL; + ScrArea *area, *big = NULL; int size, maxsize = 0; - for (sa = sc->areabase.first; sa; sa = sa->next) { - if ((spacetype == SPACE_TYPE_ANY) || (sa->spacetype == spacetype)) { - if (min <= sa->winx && min <= sa->winy) { - size = sa->winx * sa->winy; + for (area = sc->areabase.first; area; area = area->next) { + if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { + if (min <= area->winx && min <= area->winy) { + size = area->winx * area->winy; if (size > maxsize) { maxsize = size; - big = sa; + big = area; } } } @@ -826,10 +828,10 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, int x, int y) { - for (ScrArea *sa = areamap->areabase.first; sa; sa = sa->next) { - if (BLI_rcti_isect_pt(&sa->totrct, x, y)) { - if ((spacetype == SPACE_TYPE_ANY) || (sa->spacetype == spacetype)) { - return sa; + for (ScrArea *area = areamap->areabase.first; area; area = area->next) { + if (BLI_rcti_isect_pt(&area->totrct, x, y)) { + if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { + return area; } break; } @@ -864,10 +866,10 @@ void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene) void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene) { /* are there cameras in the views that are not in the scene? */ - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; BKE_screen_view3d_sync(v3d, scene); @@ -913,17 +915,17 @@ bool BKE_screen_is_used(const bScreen *screen) void BKE_screen_header_alignment_reset(bScreen *screen) { int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { - if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) { + if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) { region->alignment = RGN_ALIGN_TOP; continue; } region->alignment = alignment; } if (region->regiontype == RGN_TYPE_FOOTER) { - if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) { + if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) { region->alignment = RGN_ALIGN_BOTTOM; continue; } diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c index 201c8a66d1a..836292e0c88 100644 --- a/source/blender/blenlib/intern/delaunay_2d.c +++ b/source/blender/blenlib/intern/delaunay_2d.c @@ -1992,25 +1992,25 @@ typedef struct EdgeVertLambda { /* For sorting first by edge id, then by lambda, then by vert id. */ static int evl_cmp(const void *a, const void *b) { - const EdgeVertLambda *sa = a; + const EdgeVertLambda *area = a; const EdgeVertLambda *sb = b; - if (sa->e_id < sb->e_id) { + if (area->e_id < sb->e_id) { return -1; } - else if (sa->e_id > sb->e_id) { + else if (area->e_id > sb->e_id) { return 1; } - else if (sa->lambda < sb->lambda) { + else if (area->lambda < sb->lambda) { return -1; } - else if (sa->lambda > sb->lambda) { + else if (area->lambda > sb->lambda) { return 1; } - else if (sa->v_id < sb->v_id) { + else if (area->v_id < sb->v_id) { return -1; } - else if (sa->v_id > sb->v_id) { + else if (area->v_id > sb->v_id) { return 1; } return 0; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index eb787a16387..9822c794f3a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8063,8 +8063,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, /* avoid conflicts with 2.8x branch */ { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; ARegion *region; @@ -8073,7 +8073,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, v3d->ob_center = restore_pointer_by_name(id_map, (ID *)v3d->ob_center, USER_REAL); /* Free render engines for now. */ - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; for (region = regionbase->first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 68e654a8cd5..83dc0e2ffe2 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -88,13 +88,13 @@ #define U (*((const UserDef *)&U)) /* 2.50 patch */ -static void area_add_header_region(ScrArea *sa, ListBase *lb) +static void area_add_header_region(ScrArea *area, ListBase *lb) { ARegion *region = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_HEADER; - if (sa->headertype == 1) { + if (area->headertype == 1) { region->alignment = RGN_ALIGN_BOTTOM; } else { @@ -133,7 +133,7 @@ static void sequencer_init_preview_region(ARegion *region) region->v2d.keeptot = V2D_KEEPTOT_FREE; } -static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) +static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) { ARegion *region; ARegion *region_main; @@ -256,7 +256,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) region = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, region); - region->winrct = sa->totrct; + region->winrct = area->totrct; region->regiontype = RGN_TYPE_WINDOW; @@ -303,7 +303,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) SpaceNla *snla = (SpaceNla *)sl; memcpy(®ion->v2d, &snla->v2d, sizeof(View2D)); - region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; region->v2d.tot.ymax = 0.0f; region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES); @@ -318,8 +318,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) /* We totally reinit the view for the Action Editor, * as some old instances had some weird cruft set. */ region->v2d.tot.xmin = -20.0f; - region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; - region->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120); + region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; + region->v2d.tot.xmax = (float)((area->winx > 120) ? (area->winx) : 120); region->v2d.tot.ymax = 0.0f; region->v2d.cur = region->v2d.tot; @@ -397,40 +397,40 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) static void do_versions_windowmanager_2_50(bScreen *screen) { - ScrArea *sa; + ScrArea *area; SpaceLink *sl; /* add regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + for (area = screen->areabase.first; area; area = area->next) { /* we keep headertype variable to convert old files only */ - if (sa->headertype) { - area_add_header_region(sa, &sa->regionbase); + if (area->headertype) { + area_add_header_region(area, &area->regionbase); } - area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase); + area_add_window_regions(area, area->spacedata.first, &area->regionbase); /* space imageselect is deprecated */ - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMASEL) { sl->spacetype = SPACE_EMPTY; /* spacedata then matches */ } } /* space sound is deprecated */ - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SOUND) { sl->spacetype = SPACE_EMPTY; /* spacedata then matches */ } } /* pushed back spaces also need regions! */ - if (sa->spacedata.first) { - sl = sa->spacedata.first; + if (area->spacedata.first) { + sl = area->spacedata.first; for (sl = sl->next; sl; sl = sl->next) { - if (sa->headertype) { - area_add_header_region(sa, &sl->regionbase); + if (area->headertype) { + area_add_header_region(area, &sl->regionbase); } - area_add_window_regions(sa, sl, &sl->regionbase); + area_add_window_regions(area, sl, &sl->regionbase); } } } @@ -455,12 +455,12 @@ static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) static void do_versions_gpencil_2_50(Main *main, bScreen *screen) { - ScrArea *sa; + ScrArea *area; SpaceLink *sl; /* add regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->gpd) { @@ -1079,12 +1079,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) { bScreen *screen; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->drawtype == OB_MATERIAL) { @@ -1188,19 +1188,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile == 250 && bmain->subversionfile == 10) { /* fix for new view type in sequencer */ bScreen *screen; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; /* remove all preview window in wrong spaces */ for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype != SPACE_SEQ) { ARegion *region; ListBase *regionbase; - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (sl == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &sl->regionbase; @@ -1227,20 +1227,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) { /* fix for new view type in sequencer */ bScreen *screen; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { ARegion *region; ARegion *region_main; ListBase *regionbase; SpaceSeq *sseq = (SpaceSeq *)sl; - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (sl == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &sl->regionbase; @@ -1360,17 +1360,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) { /* fix for bad View2D extents for Animation Editors */ bScreen *screen; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { ListBase *regionbase; ARegion *region; - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (sl == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &sl->regionbase; @@ -1380,7 +1380,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (region = (ARegion *)regionbase->first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { region->v2d.cur.ymax = region->v2d.tot.ymax = 0.0f; - region->v2d.cur.ymin = region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + region->v2d.cur.ymin = region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; } } } @@ -1426,18 +1426,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* sequencer changes */ { bScreen *screen; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { ARegion *region_preview; ListBase *regionbase; - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (sl == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &sl->regionbase; @@ -1467,10 +1467,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set, * which would cause cameras, lights, etc to become invisible */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->flag2 &= ~V3D_HIDE_OVERLAYS; @@ -1551,12 +1551,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* Image editor scopes */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; BKE_scopes_new(&sima->scopes); @@ -1574,18 +1574,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) Brush *brush; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; ListBase *regionbase; ARegion *region; - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (sl == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &sl->regionbase; @@ -1851,17 +1851,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_INFO) { SpaceInfo *sinfo = (SpaceInfo *)sl; ARegion *region; sinfo->rpt_mask = INFO_RPT_OP; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { region->v2d.scroll = (V2D_SCROLL_RIGHT); region->v2d.align = V2D_ALIGN_NO_NEG_X | @@ -1897,15 +1897,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile < 256) { bScreen *sc; - ScrArea *sa; + ScrArea *area; Key *key; /* Fix for sample line scope initializing with no height */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - sa = sc->areabase.first; - while (sa) { + area = sc->areabase.first; + while (area) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; if (sima->sample_line_hist.height == 0) { @@ -1913,7 +1913,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } } } - sa = sa->next; + area = area->next; } } @@ -2117,13 +2117,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) bScreen *screen; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; + ScrArea *area; /* add regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { - SpaceLink *sl = sa->spacedata.first; + for (area = screen->areabase.first; area; area = area->next) { + SpaceLink *sl = area->spacedata.first; if (sl->spacetype == SPACE_IMAGE) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { View2D *v2d = ®ion->v2d; v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = @@ -2132,7 +2132,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } } - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { ARegion *region; for (region = sl->regionbase.first; region; region = region->next) { @@ -2174,14 +2174,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) { bScreen *screen; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; + ScrArea *area; /* add regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { - SpaceLink *sl = sa->spacedata.first; + for (area = screen->areabase.first; area; area = area->next) { + SpaceLink *sl = area->spacedata.first; if (sl->spacetype == SPACE_SEQ) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { if (region->v2d.min[1] == 4.0f) { region->v2d.min[1] = 0.5f; @@ -2189,7 +2189,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } } } - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { ARegion *region; for (region = sl->regionbase.first; region; region = region->next) { diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index f1dcbba8e90..6f4dd88fcb6 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -769,10 +769,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) MovieClip *clip; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->bundle_size == 0.0f) { @@ -1191,17 +1191,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_CLIP) { SpaceClip *sclip = (SpaceClip *)sl; ARegion *region; bool hide = false; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_PREVIEW) { if (region->alignment != RGN_ALIGN_NONE) { region->flag |= RGN_FLAG_HIDDEN; @@ -1371,12 +1371,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_CLIP) { SpaceClip *sclip = (SpaceClip *)sl; @@ -1664,10 +1664,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f && @@ -1760,10 +1760,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) { bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { switch (sl->spacetype) { case SPACE_VIEW3D: { View3D *v3d = (View3D *)sl; @@ -1945,10 +1945,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (MAIN_VERSION_OLDER(bmain, 266, 2)) { bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; @@ -2119,10 +2119,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) bNodeInstanceKey active_viewer_key = {0}; /* simply pick the first node space and use that for the active viewer key */ for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; - for (sa = screen->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; bNodeTreePath *path = snode->treepath.last; @@ -2241,10 +2241,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) * We moved this check to the do versions to be sure the value makes any sense. */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { SpaceNode *snode = (SpaceNode *)sl; if (snode->zoom < 0.02f) { @@ -2258,22 +2258,22 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) { bScreen *sc; - ScrArea *sa; + ScrArea *area; /* add missing (+) expander in node editor */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { ARegion *region, *arnew; - if (sa->spacetype == SPACE_NODE) { - region = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); + if (area->spacetype == SPACE_NODE) { + region = BKE_area_find_region_type(area, RGN_TYPE_TOOLS); if (region) { continue; } /* add subdiv level; after header */ - region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); /* is error! */ if (region == NULL) { @@ -2282,7 +2282,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) arnew = MEM_callocN(sizeof(ARegion), "node tools"); - BLI_insertlinkafter(&sa->regionbase, region, arnew); + BLI_insertlinkafter(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_TOOLS; arnew->alignment = RGN_ALIGN_LEFT; @@ -2339,14 +2339,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) { bScreen *sc; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; Scene *scene; /* Update files using invalid (outdated) outlinevis Outliner values. */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = sc->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *so = (SpaceOutliner *)sl; @@ -2545,17 +2545,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *space_link; - for (space_link = sa->spacedata.first; space_link; space_link = space_link->next) { + for (space_link = area->spacedata.first; space_link; space_link = space_link->next) { if (space_link->spacetype == SPACE_IMAGE) { ARegion *region; ListBase *lb; - if (space_link == sa->spacedata.first) { - lb = &sa->regionbase; + if (space_link == area->spacedata.first) { + lb = &area->regionbase; } else { lb = &space_link->regionbase; diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 80f75a7ac4a..abe8326618b 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -522,13 +522,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { ARegion *region; - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (region = lb->first; region; region = region->next) { BLI_listbase_clear(®ion->ui_previews); @@ -853,14 +853,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) { bScreen *scr; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; ARegion *region; /* Make sure sequencer preview area limits zoom */ for (scr = bmain->screens.first; scr; scr = scr->id.next) { - for (sa = scr->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = scr->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { for (region = sl->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_PREVIEW) { @@ -942,11 +942,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; - for (sa = screen->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { switch (sl->spacetype) { case SPACE_VIEW3D: { View3D *v3d = (View3D *)sl; @@ -996,12 +996,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) { for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = screen->areabase.first; sa; sa = sa->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; @@ -1064,13 +1064,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) bScreen *screen; #define RV3D_VIEW_PERSPORTHO 7 for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; - for (sa = screen->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { ARegion *region; - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (region = lb->first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { if (region->regiondata) { @@ -1176,9 +1176,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; /* Bug: Was possible to add preview region to sequencer view by using AZones. */ if (sl->spacetype == SPACE_SEQ) { SpaceSeq *sseq = (SpaceSeq *)sl; @@ -1243,9 +1244,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Adding "Properties" region to DopeSheet */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { /* handle pushed-back space data first */ - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; do_version_action_editor_properties_region(&saction->regionbase); @@ -1253,8 +1254,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* active spacedata info must be handled too... */ - if (sa->spacetype == SPACE_ACTION) { - do_version_action_editor_properties_region(&sa->regionbase); + if (area->spacetype == SPACE_ACTION) { + do_version_action_editor_properties_region(&area->regionbase); } } } @@ -1650,9 +1651,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) { /* Fix for invalid state of screen due to bug in older versions. */ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->full && sc->state == SCREENNORMAL) { - sa->full = NULL; + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + if (area->full && sc->state == SCREENNORMAL) { + area->full = NULL; } } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ac0c0c3da39..7449d1c04c1 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -116,10 +116,10 @@ static bScreen *screen_parent_find(const bScreen *screen) /* Can avoid lookup if screen state isn't maximized/full * (parent and child store the same state). */ if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) { - for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->full && sa->full != screen) { - BLI_assert(sa->full->state == screen->state); - return sa->full; + for (const ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->full && area->full != screen) { + BLI_assert(area->full->state == screen->state); + return area->full; } } } @@ -649,13 +649,14 @@ static void do_versions_area_ensure_tool_region(Main *bmain, const short region_flag) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == space_type) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_TOOLS); if (!region) { - ARegion *header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ARegion *header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); region = do_versions_add_region(RGN_TYPE_TOOLS, "tools region"); BLI_insertlinkafter(regionbase, header, region); region->alignment = RGN_ALIGN_LEFT; @@ -1243,8 +1244,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) * so same layer as BKE_view_layer_default_view would return */ ViewLayer *layer = screen->scene->view_layers.first; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *space = sa->spacedata.first; space; space = space->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *space = area->spacedata.first; space; space = space->next) { if (space->spacetype == SPACE_OUTLINER) { SpaceOutliner *soutliner = (SpaceOutliner *)space; @@ -1273,8 +1274,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *space = sa->spacedata.first; space; space = space->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *space = area->spacedata.first; space; space = space->next) { if (space->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)space; if ((sima) && (sima->gpd)) { @@ -1928,13 +1929,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) { if (DNA_struct_elem_find(fd->filesdna, "SpaceOutliner", "int", "filter") == false) { bScreen *sc; - ScrArea *sa; + ScrArea *area; SpaceLink *sl; /* Update files using invalid (outdated) outlinevis Outliner values. */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (area = sc->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *so = (SpaceOutliner *)sl; @@ -1973,8 +1974,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.light = V3D_LIGHTING_STUDIO; @@ -2066,10 +2067,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) { /* Remove tool property regions. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; for (ARegion *region = regionbase->first, *region_next; region; region = region_next) { region_next = region->next; @@ -2095,8 +2097,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Initialize new view3D options. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.light = V3D_LIGHTING_STUDIO; @@ -2320,8 +2322,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *soops = (SpaceOutliner *)sl; soops->filter_id_type = ID_GR; @@ -2402,8 +2404,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT; @@ -2415,8 +2417,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.xray_alpha = 0.5f; @@ -2430,8 +2432,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* when loading the internal file is loaded before the matcaps */ if (default_matcap) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE); @@ -2443,8 +2445,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.wireframe_threshold = 0.5f; @@ -2455,8 +2457,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.cavity_valley_factor = 1.0f; @@ -2468,8 +2470,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.xray_alpha_bone = 0.5f; @@ -2494,8 +2496,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; /* "Dopesheet" should be default here, @@ -2510,8 +2512,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->drawtype == OB_TEXTURE) { @@ -2535,8 +2537,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { enum { V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15), @@ -2554,8 +2556,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; copy_v3_fl(v3d->shading.background_color, 0.05f); @@ -2619,8 +2621,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->drawtype == OB_RENDER) { @@ -2642,8 +2644,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* initialize grease pencil view data */ if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) { for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->vertex_opacity = 1.0f; @@ -2674,8 +2676,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_paper_opacity = 0.5f; @@ -2686,8 +2688,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_grid_opacity = 0.5f; @@ -2824,8 +2826,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS | @@ -2870,8 +2872,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_XRAY_WIREFRAME; @@ -2908,8 +2910,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { enum { V3D_OCCLUDE_WIRE = (1 << 14) }; View3D *v3d = (View3D *)sl; @@ -2931,9 +2933,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) */ if (!MAIN_VERSION_ATLEAST(bmain, 283, 1)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER); if (!region_header) { @@ -2954,10 +2957,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_PROPERTIES) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region = MEM_callocN(sizeof(ARegion), "navigation bar for properties"); ARegion *region_header = NULL; @@ -2981,8 +2985,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* grease pencil fade layer opacity */ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_fade_layer = 0.5f; @@ -3215,8 +3219,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) { if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.curvature_ridge_factor = 1.0f; @@ -3247,8 +3251,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Move studio_light selection to lookdev_light. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256); @@ -3520,8 +3524,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add wireframe color. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR; @@ -3700,10 +3704,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; /* Remove multiple footers that were added by mistake. */ do_versions_remove_regions_by_type(regionbase, RGN_TYPE_FOOTER); @@ -3740,8 +3745,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) { /* Enable Show Interpolation in dopesheet by default. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) { @@ -3793,9 +3798,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Keep un-versioned until we're finished adding space types. */ { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; /* All spaces that use tools must be eventually added. */ ARegion *region = NULL; if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ) && @@ -3840,8 +3846,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.sculpt_mode_mask_opacity = 0.75f; @@ -3904,10 +3910,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (ELEM(sl->spacetype, SPACE_CLIP, SPACE_GRAPH, SPACE_SEQ)) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region = NULL; if (sl->spacetype == SPACE_CLIP) { @@ -4056,10 +4063,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 3)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI); if (region) { region->alignment = RGN_ALIGN_RIGHT; @@ -4110,8 +4118,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 6)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER; @@ -4132,11 +4140,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 9)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); ARegion *region_toolprops = do_versions_find_region_or_null(regionbase, @@ -4188,8 +4197,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Added studiolight intensity */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_intensity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.studiolight_intensity = 1.0f; @@ -4226,13 +4235,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - for (ScrArea *sa_other = screen->areabase.first; sa_other; sa_other = sa_other->next) { - for (SpaceLink *sl_other = sa_other->spacedata.first; sl_other; + for (ScrArea *area_other = screen->areabase.first; area_other; + area_other = area_other->next) { + for (SpaceLink *sl_other = area_other->spacedata.first; sl_other; sl_other = sl_other->next) { if (sl != sl_other && sl_other->spacetype == SPACE_VIEW3D) { View3D *v3d_other = (View3D *)sl_other; @@ -4245,7 +4255,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } else if (sl->spacetype == SPACE_FILE) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; ARegion *region_tools = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOLS); ARegion *region_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); @@ -4282,8 +4293,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) do_version_curvemapping_walker(bmain, do_version_curvemapping_flag_extend_extrapolate); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - sa->flag &= ~AREA_FLAG_UNUSED_6; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + area->flag &= ~AREA_FLAG_UNUSED_6; } } @@ -4353,8 +4364,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.render_pass = SCE_PASS_COMBINED; @@ -4428,8 +4439,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* UDIM Image Editor change. */ if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; sima->tile_grid_shape[0] = 1; @@ -4503,8 +4514,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add Lookdev blur property. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_blur")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.studiolight_blur = 0.5f; @@ -4777,8 +4788,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "sculpt_mode_face_sets_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.sculpt_mode_face_sets_opacity = 1.0f; diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 80395177100..aa19b3feefb 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -101,8 +101,8 @@ static void blo_update_defaults_screen(bScreen *screen, const char *workspace_name) { /* For all app templates. */ - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { /* Some toolbars have been saved as initialized, * we don't want them to have odd zoom-level or scrolling set, see: T47047 */ if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { @@ -111,7 +111,7 @@ static void blo_update_defaults_screen(bScreen *screen, } /* Set default folder. */ - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; if (sfile->params) { @@ -130,8 +130,8 @@ static void blo_update_defaults_screen(bScreen *screen, return; } - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { /* Remove all stored panels, we want to use defaults * (order, open/closed) as defined by UI code here! */ BKE_area_region_panels_free(®ion->panels); @@ -142,48 +142,48 @@ static void blo_update_defaults_screen(bScreen *screen, region->sizey = 0; } - if (sa->spacetype == SPACE_IMAGE) { + if (area->spacetype == SPACE_IMAGE) { if (STREQ(workspace_name, "UV Editing")) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; if (sima->mode == SI_MODE_VIEW) { sima->mode = SI_MODE_UV; } } } - else if (sa->spacetype == SPACE_ACTION) { + else if (area->spacetype == SPACE_ACTION) { /* Show markers region, hide channels and collapse summary in timelines. */ - SpaceAction *saction = sa->spacedata.first; + SpaceAction *saction = area->spacedata.first; saction->flag |= SACTION_SHOW_MARKERS; if (saction->mode == SACTCONT_TIMELINE) { saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_CHANNELS) { region->flag |= RGN_FLAG_HIDDEN; } } } } - else if (sa->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = sa->spacedata.first; + else if (area->spacetype == SPACE_GRAPH) { + SpaceGraph *sipo = area->spacedata.first; sipo->flag |= SIPO_SHOW_MARKERS; } - else if (sa->spacetype == SPACE_NLA) { - SpaceNla *snla = sa->spacedata.first; + else if (area->spacetype == SPACE_NLA) { + SpaceNla *snla = area->spacedata.first; snla->flag |= SNLA_SHOW_MARKERS; } - else if (sa->spacetype == SPACE_SEQ) { - SpaceSeq *seq = sa->spacedata.first; + else if (area->spacetype == SPACE_SEQ) { + SpaceSeq *seq = area->spacedata.first; seq->flag |= SEQ_SHOW_MARKERS; } - else if (sa->spacetype == SPACE_TEXT) { + else if (area->spacetype == SPACE_TEXT) { /* Show syntax and line numbers in Script workspace text editor. */ - SpaceText *stext = sa->spacedata.first; + SpaceText *stext = area->spacedata.first; stext->showsyntax = true; stext->showlinenrs = true; } - else if (sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + else if (area->spacetype == SPACE_VIEW3D) { + View3D *v3d = area->spacedata.first; /* Screen space cavity by default for faster performance. */ v3d->shading.cavity_type = V3D_SHADING_CAVITY_CURVATURE; v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT; @@ -202,17 +202,17 @@ static void blo_update_defaults_screen(bScreen *screen, copy_v3_fl(v3d->shading.background_color, 0.05f); } } - else if (sa->spacetype == SPACE_CLIP) { - SpaceClip *sclip = sa->spacedata.first; + else if (area->spacetype == SPACE_CLIP) { + SpaceClip *sclip = area->spacedata.first; sclip->around = V3D_AROUND_CENTER_MEDIAN; } } /* Show tool-header by default (for most cases at least, hide for others). */ const bool hide_image_tool_header = STREQ(workspace_name, "Rendering"); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = regionbase->first; region; region = region->next) { if (region->regiontype == RGN_TYPE_TOOL_HEADER) { @@ -229,15 +229,15 @@ static void blo_update_defaults_screen(bScreen *screen, /* 2D animation template. */ if (app_template && STREQ(app_template, "2D_Animation")) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { - if (sa->spacetype == SPACE_ACTION) { - SpaceAction *saction = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { + if (area->spacetype == SPACE_ACTION) { + SpaceAction *saction = area->spacedata.first; /* Enable Sliders. */ saction->flag |= SACTION_SLIDERS; } - else if (sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + else if (area->spacetype == SPACE_VIEW3D) { + View3D *v3d = area->spacedata.first; /* Set Material Color by default. */ v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR; /* Enable Annotations. */ @@ -273,10 +273,10 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { bScreen *screen = layout->screen; if (screen) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { - if (sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { + if (area->spacetype == SPACE_VIEW3D) { + View3D *v3d = area->spacedata.first; v3d->shading.flag &= ~V3D_SHADING_CAVITY; copy_v3_fl(v3d->shading.single_color, 1.0f); STRNCPY(v3d->shading.matcap, "basic_1"); diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 29c4a0f3c9d..a35ef80e4d3 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -582,9 +582,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* new variable: gridlines */ bScreen *sc = bmain->screens.first; while (sc) { - ScrArea *sa = sc->areabase.first; - while (sa) { - SpaceLink *sl = sa->spacedata.first; + ScrArea *area = sc->areabase.first; + while (area) { + SpaceLink *sl = area->spacedata.first; while (sl) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -595,7 +595,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } sl = sl->next; } - sa = sa->next; + area = area->next; } sc = sc->id.next; } @@ -696,9 +696,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 169) { bScreen *sc = bmain->screens.first; while (sc) { - ScrArea *sa = sc->areabase.first; - while (sa) { - SpaceLink *sl = sa->spacedata.first; + ScrArea *area = sc->areabase.first; + while (area) { + SpaceLink *sl = area->spacedata.first; while (sl) { if (sl->spacetype == SPACE_GRAPH) { SpaceGraph *sipo = (SpaceGraph *)sl; @@ -706,7 +706,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } sl = sl->next; } - sa = sa->next; + area = area->next; } sc = sc->id.next; } @@ -729,9 +729,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 171) { bScreen *sc = bmain->screens.first; while (sc) { - ScrArea *sa = sc->areabase.first; - while (sa) { - SpaceLink *sl = sa->spacedata.first; + ScrArea *area = sc->areabase.first; + while (area) { + SpaceLink *sl = area->spacedata.first; while (sl) { if (sl->spacetype == SPACE_TEXT) { SpaceText *st = (SpaceText *)sl; @@ -739,7 +739,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } sl = sl->next; } - sa = sa->next; + area = area->next; } sc = sc->id.next; } @@ -890,12 +890,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* some oldfile patch, moved from set_func_space */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_GRAPH) { SpaceSeq *sseq = (SpaceSeq *)sl; sseq->v2d.keeptot = 0; @@ -963,12 +963,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* patch for old wrong max view2d settings, allows zooming out more */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *sac = (SpaceAction *)sl; sac->v2d.max[0] = 32000; @@ -1030,12 +1030,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* convert old mainb values for new button panels */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_PROPERTIES) { SpaceProperties *sbuts = (SpaceProperties *)sl; @@ -1100,12 +1100,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* new variable blockscale, for panels in any area */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { /* added: 5x better zoom in for action */ if (sl->spacetype == SPACE_ACTION) { SpaceAction *sac = (SpaceAction *)sl; @@ -1122,9 +1122,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* new bit flags for showing/hiding grid floor and axes */ while (sc) { - ScrArea *sa = sc->areabase.first; - while (sa) { - SpaceLink *sl = sa->spacedata.first; + ScrArea *area = sc->areabase.first; + while (area) { + SpaceLink *sl = area->spacedata.first; while (sl) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -1138,7 +1138,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } sl = sl->next; } - sa = sa->next; + area = area->next; } sc = sc->id.next; } @@ -1185,10 +1185,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) * areas didn't initialize it to 0.7 yet */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { /* added: 5x better zoom in for nla */ if (sl->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)sl; @@ -1203,10 +1203,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->flag |= V3D_SELECT_OUTLINE; @@ -1220,10 +1220,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { SpaceText *st = (SpaceText *)sl; if (st->tabnumber == 0) { @@ -1664,12 +1664,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) int a; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - sa = sc->areabase.first; - while (sa) { + ScrArea *area; + area = sc->areabase.first; + while (area) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->gridsubdiv == 0) { @@ -1677,7 +1677,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } } } - sa = sa->next; + area = area->next; } } @@ -1927,12 +1927,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile != 244 || bmain->subversionfile < 2) { /* correct older action editors - incorrect scrolling */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - sa = sc->areabase.first; - while (sa) { + ScrArea *area; + area = sc->areabase.first; + while (area) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; @@ -1943,7 +1943,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) saction->v2d.cur.ymax = 5.0; } } - sa = sa->next; + area = area->next; } } } @@ -2544,12 +2544,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* adjust default settings for Animation Editors */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { switch (sl->spacetype) { case SPACE_ACTION: { SpaceAction *sact = (SpaceAction *)sl; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f47ed85f5bf..28f80994c4d 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -695,15 +695,15 @@ bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt) /* poll callback for being in an Animation Editor channels list region */ static bool animedit_poll_channels_active(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, sa, CTX_wm_region(C))) { + if (ELEM(NULL, area, CTX_wm_region(C))) { return 0; } /* animation editor test */ - if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) { + if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) { return 0; } @@ -713,21 +713,21 @@ static bool animedit_poll_channels_active(bContext *C) /* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, sa, CTX_wm_region(C))) { + if (ELEM(NULL, area, CTX_wm_region(C))) { return 0; } /* animation editor test */ - if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) { + if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) { return 0; } /* NLA TweakMode test */ - if (sa->spacetype == SPACE_NLA) { + if (area->spacetype == SPACE_NLA) { if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) { return 0; } @@ -1518,19 +1518,19 @@ static void ANIM_OT_channels_move(wmOperatorType *ot) static bool animchannels_grouping_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceLink *sl; /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, sa, CTX_wm_region(C))) { + if (ELEM(NULL, area, CTX_wm_region(C))) { return 0; } /* animation editor test - must be suitable modes only */ sl = CTX_wm_space_data(C); - switch (sa->spacetype) { + switch (area->spacetype) { /* supported... */ case SPACE_ACTION: { SpaceAction *saction = (SpaceAction *)sl; @@ -2353,16 +2353,16 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) static bool animchannels_enable_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, sa, CTX_wm_region(C))) { + if (ELEM(NULL, area, CTX_wm_region(C))) { return 0; } /* animation editor test - Action/Dopesheet/etc. and Graph only */ - if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) { + if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) { return 0; } @@ -2431,14 +2431,14 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) /* XXX: make this generic? */ static bool animchannels_find_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (sa == NULL) { + if (area == NULL) { return 0; } /* animation editor with dopesheet */ - return ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA); + return ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA); } /* find_invoke() - Get initial channels */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index a09db0380e6..23c95f186d7 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -399,7 +399,7 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac) bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) { Main *bmain = CTX_data_main(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); SpaceLink *sl = CTX_wm_space_data(C); Scene *scene = CTX_data_scene(C); @@ -418,10 +418,10 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) } ac->view_layer = CTX_data_view_layer(C); ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; - ac->sa = sa; + ac->area = area; ac->region = region; ac->sl = sl; - ac->spacetype = (sa) ? sa->spacetype : 0; + ac->spacetype = (area) ? area->spacetype : 0; ac->regiontype = (region) ? region->regiontype : 0; /* initialise default y-scale factor */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 27d38cf625a..93d2d99effb 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -74,12 +74,12 @@ /* ************* Marker API **************** */ /* helper function for getting the list of markers to work on */ -static ListBase *context_get_markers(Scene *scene, ScrArea *sa) +static ListBase *context_get_markers(Scene *scene, ScrArea *area) { /* local marker sets... */ - if (sa) { - if (sa->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + if (area) { + if (area->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction *)area->spacedata.first; /* local markers can only be shown when there's only a single active action to grab them from * - flag only takes effect when there's an action, otherwise it can get too confusing? @@ -108,7 +108,7 @@ ListBase *ED_context_get_markers(const bContext *C) ListBase *ED_animcontext_get_markers(const bAnimContext *ac) { if (ac) { - return context_get_markers(ac->scene, ac->sa); + return context_get_markers(ac->scene, ac->area); } else { return NULL; @@ -234,35 +234,35 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float * */ static bool ED_operator_markers_region_active(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa == NULL) { + ScrArea *area = CTX_wm_area(C); + if (area == NULL) { return false; } - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_ACTION: { - SpaceAction *saction = sa->spacedata.first; + SpaceAction *saction = area->spacedata.first; if (saction->flag & SACTION_SHOW_MARKERS) { return true; } break; } case SPACE_GRAPH: { - SpaceGraph *sipo = sa->spacedata.first; + SpaceGraph *sipo = area->spacedata.first; if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) { return true; } break; } case SPACE_NLA: { - SpaceNla *snla = sa->spacedata.first; + SpaceNla *snla = area->spacedata.first; if (snla->flag & SNLA_SHOW_MARKERS) { return true; } break; } case SPACE_SEQ: { - SpaceSeq *seq = sa->spacedata.first; + SpaceSeq *seq = area->spacedata.first; if (seq->flag & SEQ_SHOW_MARKERS) { return true; } diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 6b0d11802f4..7689d121a0c 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -61,7 +61,7 @@ /* Check if the operator can be run from the current context */ static bool change_frame_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* XXX temp? prevent changes during render */ if (G.is_rendering) { @@ -71,11 +71,11 @@ static bool change_frame_poll(bContext *C) /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION, * this shouldn't show up in 3D editor (or others without 2D timeline view) via search */ - if (sa) { - if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { + if (area) { + if (ELEM(area->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { return true; } - else if (sa->spacetype == SPACE_GRAPH) { + else if (area->spacetype == SPACE_GRAPH) { /* NOTE: Graph Editor has special version which does some extra stuff. * No need to show the generic error message for that case though! */ @@ -151,10 +151,10 @@ static float frame_from_event(bContext *C, const wmEvent *event) static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bScreen *screen = CTX_wm_screen(C); - if (sa && sa->spacetype == SPACE_SEQ) { - SpaceSeq *sseq = sa->spacedata.first; + if (area && area->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = area->spacedata.first; if (ED_space_sequencer_check_show_strip(sseq)) { ED_sequencer_special_preview_set(C, event->mval); } @@ -282,7 +282,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) static bool anim_set_end_frames_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* XXX temp? prevent changes during render */ if (G.is_rendering) { @@ -292,8 +292,8 @@ static bool anim_set_end_frames_poll(bContext *C) /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION, * this shouldn't show up in 3D editor (or others without 2D timeline view) via search */ - if (sa) { - if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { + if (area) { + if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { return true; } } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index c22f1e0642b..4c3a2a36e0a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1793,11 +1793,11 @@ enum { */ static bool modify_key_op_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); /* if no area or active scene */ - if (ELEM(NULL, sa, scene)) { + if (ELEM(NULL, area, scene)) { return false; } diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index d36e6100bcf..b2c3d951b34 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -362,11 +362,11 @@ void ED_armature_bone_rename(Main *bmain, { bScreen *screen; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *sa; + ScrArea *area; /* add regions */ - for (sa = screen->areabase.first; sa; sa = sa->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->ob_center && v3d->ob_center->data == arm) { diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 5c75e8f6187..b86da6374be 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -75,12 +75,12 @@ /* matches logic with ED_operator_posemode_context() */ Object *ED_pose_object_from_context(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *ob; /* Since this call may also be used from the buttons window, * we need to check for where to get the object. */ - if (sa && sa->spacetype == SPACE_PROPERTIES) { + if (area && area->spacetype == SPACE_PROPERTIES) { ob = ED_object_context(C); } else { diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 455e7cb2733..aa57fb5844d 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -161,16 +161,16 @@ static TimeMarker *poselib_get_active_pose(bAction *act) /* XXX C can be zero */ static Object *get_poselib_object(bContext *C) { - ScrArea *sa; + ScrArea *area; /* sanity check */ if (C == NULL) { return NULL; } - sa = CTX_wm_area(C); + area = CTX_wm_area(C); - if (sa && (sa->spacetype == SPACE_PROPERTIES)) { + if (area && (area->spacetype == SPACE_PROPERTIES)) { return ED_object_context(C); } else { @@ -870,7 +870,7 @@ typedef struct tPoseLib_PreviewData { /** active scene. */ Scene *scene; /** active area. */ - ScrArea *sa; + ScrArea *area; /** RNA-Pointer to Object 'ob' .*/ PointerRNA rna_ptr; @@ -1171,7 +1171,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) /* do header print - if interactively previewing */ if (pld->state == PL_PREVIEW_RUNNING) { if (pld->flag & PL_PREVIEW_SHOWORIGINAL) { - ED_area_status_text(pld->sa, TIP_("PoseLib Previewing Pose: [Showing Original Pose]")); + ED_area_status_text(pld->area, TIP_("PoseLib Previewing Pose: [Showing Original Pose]")); ED_workspace_status_text(C, TIP_("Use Tab to start previewing poses again")); } else if (pld->searchstr[0]) { @@ -1200,7 +1200,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) "Current Pose - \"%s\""), tempstr, markern); - ED_area_status_text(pld->sa, pld->headerstr); + ED_area_status_text(pld->area, pld->headerstr); ED_workspace_status_text(C, TIP_("Use ScrollWheel or PageUp/Down to change pose")); } else { @@ -1208,7 +1208,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) sizeof(pld->headerstr), TIP_("PoseLib Previewing Pose: \"%s\""), pld->marker->name); - ED_area_status_text(pld->sa, pld->headerstr); + ED_area_status_text(pld->area, pld->headerstr); ED_workspace_status_text(C, NULL); } } @@ -1631,7 +1631,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op) pld->act = (ob) ? (ob->poselib) : NULL; pld->scene = CTX_data_scene(C); - pld->sa = CTX_wm_area(C); + pld->area = CTX_wm_area(C); /* get starting pose based on RNA-props for this operator */ if (pose_index == -1) { @@ -1702,7 +1702,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) TimeMarker *marker = pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ - ED_area_status_text(pld->sa, NULL); + ED_area_status_text(pld->area, NULL); ED_workspace_status_text(C, NULL); /* this signal does one recalc on pose, then unlocks, so ESC or edit will work */ diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 336d09f71b5..ae08aee3c47 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -86,7 +86,7 @@ typedef struct tPoseSlideOp { /** current scene */ Scene *scene; /** area that we're operating in (needed for modal()) */ - ScrArea *sa; + ScrArea *area; /** region that we're operating in (needed for modal()) */ ARegion *region; /** len of the PoseSlideObject array. */ @@ -197,7 +197,7 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) /* get info from context */ pso->scene = CTX_data_scene(C); - pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */ + pso->area = CTX_wm_area(C); /* only really needed when doing modal() */ pso->region = CTX_wm_region(C); /* only really needed when doing modal() */ pso->cframe = pso->scene->r.cfra; @@ -904,7 +904,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) limits_str); } - ED_area_status_text(pso->sa, status_str); + ED_area_status_text(pso->area, status_str); } /* common code for invoke() methods */ @@ -1071,7 +1071,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case EVT_PADENTER: { if (event->val == KM_PRESS) { /* return to normal cursor and header status */ - ED_area_status_text(pso->sa, NULL); + ED_area_status_text(pso->area, NULL); WM_cursor_modal_restore(win); /* insert keyframes as required... */ @@ -1088,7 +1088,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: { if (event->val == KM_PRESS) { /* return to normal cursor and header status */ - ED_area_status_text(pso->sa, NULL); + ED_area_status_text(pso->area, NULL); WM_cursor_modal_restore(win); /* reset transforms back to original state */ 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 4049a3b9dcb..39e0712a511 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c @@ -372,9 +372,9 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) WM_gizmo_calc_matrix_final(gz, inter->init.matrix_final); if (use_snap) { - ScrArea *sa = CTX_wm_area(C); - if (sa) { - switch (sa->spacetype) { + ScrArea *area = CTX_wm_area(C); + if (area) { + switch (area->spacetype) { case SPACE_VIEW3D: { inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d( CTX_data_main(C), CTX_data_scene(C), 0, CTX_wm_region(C), CTX_wm_view3d(C)); diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 3e2c3b17241..26ba2661072 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -1013,7 +1013,7 @@ static void annotation_draw_data_all(Scene *scene, void ED_annotation_draw_2dimage(const bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -1026,7 +1026,7 @@ void ED_annotation_draw_2dimage(const bContext *C) } /* calculate rect */ - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_IMAGE: /* image */ case SPACE_CLIP: /* clip */ { @@ -1075,7 +1075,7 @@ void ED_annotation_draw_2dimage(const bContext *C) } /* draw it! */ - annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); + annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, area->spacetype); } /** @@ -1088,13 +1088,13 @@ void ED_annotation_draw_2dimage(const bContext *C) void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) { wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); int dflag = 0; /* check that we have grease-pencil stuff to draw */ - if (sa == NULL) { + if (area == NULL) { return; } bGPdata *gpd = ED_annotation_data_get_active(C); @@ -1105,7 +1105,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) /* special hack for Image Editor */ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, * so disabled. */ - if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) { + if (ELEM(area->spacetype, SPACE_IMAGE, SPACE_CLIP)) { dflag |= GP_DRAWDATA_IEDITHACK; } @@ -1118,7 +1118,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) } annotation_draw_data_all( - scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, sa->spacetype); + scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, area->spacetype); /* draw status text (if in screen/pixel-space) */ if (!onlyv2d) { diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 53ada341cc9..cd4e161200d 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -114,7 +114,7 @@ typedef struct tGPsdata { /** window where painting originated. */ wmWindow *win; /** area where painting originated. */ - ScrArea *sa; + ScrArea *area; /** region where painting originated. */ ARegion *region; /** needed for GP_STROKE_2DSPACE. */ @@ -521,7 +521,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure * so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->region); ED_view3d_autodist_init(p->depsgraph, @@ -793,7 +793,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const int x, const int y) { - if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { + if ((p->area->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { RegionView3D *rv3d = p->region->regiondata; const int mval_i[2] = {x, y}; float mval_3d[3]; @@ -920,9 +920,9 @@ static void gp_stroke_doeraser(tGPsdata *p) rect.xmax = p->mval[0] + p->radius; rect.ymax = p->mval[1] + p->radius; - if (p->sa->spacetype == SPACE_VIEW3D) { + if (p->area->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->region); ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0); } @@ -936,7 +936,7 @@ static void gp_stroke_doeraser(tGPsdata *p) /* Not all strokes in the datablock may be valid in the current editor/context * (e.g. 2D space strokes in the 3D view, if the same datablock is shared) */ - if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) { + if (ED_gpencil_stroke_can_use_direct(p->area, gps)) { gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, p->radius, &rect); } } @@ -997,7 +997,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) * - must verify that region data is 3D-view (and not something else) */ /* CAUTION: If this is the "toolbar", then this will change on the first stroke */ - p->sa = curarea; + p->area = curarea; p->region = region; p->align_flag = &ts->annotate_v3d_align; @@ -1016,7 +1016,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* SpaceNode *snode = curarea->spacedata.first; */ /* set current area */ - p->sa = curarea; + p->area = curarea; p->region = region; p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_v2d_align; @@ -1026,7 +1026,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) SpaceSeq *sseq = curarea->spacedata.first; /* set current area */ - p->sa = curarea; + p->area = curarea; p->region = region; p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_seq_align; @@ -1045,7 +1045,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* SpaceImage *sima = curarea->spacedata.first; */ /* set the current area */ - p->sa = curarea; + p->area = curarea; p->region = region; p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_ima_align; @@ -1061,7 +1061,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) } /* set the current area */ - p->sa = curarea; + p->area = curarea; p->region = region; p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_v2d_align; @@ -1279,7 +1279,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps p->gpd->runtime.sbuffer_sflag |= GP_STROKE_ERASER; /* check if we should respect depth while erasing */ - if (p->sa->spacetype == SPACE_VIEW3D) { + if (p->area->spacetype == SPACE_VIEW3D) { if (p->gpl->flag & GP_LAYER_NO_XRAY) { p->flags |= GP_PAINTFLAG_V3D_ERASER_DEPTH; } @@ -1289,7 +1289,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* disable eraser flags - so that we can switch modes during a session */ p->gpd->runtime.sbuffer_sflag &= ~GP_STROKE_ERASER; - if (p->sa->spacetype == SPACE_VIEW3D) { + if (p->area->spacetype == SPACE_VIEW3D) { if (p->gpl->flag & GP_LAYER_NO_XRAY) { p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH; } @@ -1302,8 +1302,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* when drawing in the camera view, in 2D space, set the subrect */ p->subrect = NULL; if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) { - if (p->sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = p->sa->spacedata.first; + if (p->area->spacetype == SPACE_VIEW3D) { + View3D *v3d = p->area->spacedata.first; RegionView3D *rv3d = p->region->regiondata; /* for camera view set the subrect */ @@ -1320,7 +1320,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps p->gsc.gpd = p->gpd; p->gsc.gpl = p->gpl; - p->gsc.sa = p->sa; + p->gsc.area = p->area; p->gsc.region = p->region; p->gsc.v2d = p->v2d; @@ -1331,7 +1331,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* check if points will need to be made in view-aligned space */ if (*p->align_flag & GP_PROJECT_VIEWSPACE) { - switch (p->sa->spacetype) { + switch (p->area->spacetype) { case SPACE_VIEW3D: { p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE; break; @@ -1355,7 +1355,7 @@ static void gp_paint_strokeend(tGPsdata *p) * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->region); @@ -1931,10 +1931,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ -static bool gpencil_area_exists(bContext *C, ScrArea *sa_test) +static bool gpencil_area_exists(bContext *C, ScrArea *area_test) { bScreen *sc = CTX_wm_screen(C); - return (BLI_findindex(&sc->areabase, sa_test) != -1); + return (BLI_findindex(&sc->areabase, area_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) @@ -1944,7 +1944,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ - if (CTX_wm_area(C) != p->sa) { + if (CTX_wm_area(C) != p->area) { printf("\t\t\tGP - wrong area execution abort!\n"); p->status = GP_STATUS_ERROR; } @@ -2168,18 +2168,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) */ if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ - ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y); + ARegion *current_region = BKE_area_find_region_xy( + p->area, RGN_TYPE_ANY, event->x, event->y); if (G.debug & G_DEBUG) { - printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n", + printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n", current_region, p->region, event->x, event->y, - p->sa->totrct.xmin, - p->sa->totrct.ymin, - p->sa->totrct.xmax, - p->sa->totrct.ymax); + p->area->totrct.xmin, + p->area->totrct.ymin, + p->area->totrct.xmax, + p->area->totrct.ymax); } if (current_region) { @@ -2314,7 +2315,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ - if (0 == gpencil_area_exists(C, p->sa)) { + if (0 == gpencil_area_exists(C, p->area)) { estate = OPERATOR_CANCELLED; } else { diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 8470fcad9d7..28e632d2b82 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -1465,12 +1465,12 @@ static bool gp_convert_poll(bContext *C) bGPdata *gpd = (bGPdata *)ob->data; bGPDlayer *gpl = NULL; bGPDframe *gpf = NULL; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!), * and if we are not in edit mode! */ - return ((sa && sa->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) && + return ((area && area->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) && (gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV)) && (gpf->strokes.first) && (!GPENCIL_ANY_EDIT_MODE(gpd))); } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index a12f960c29e..1c93eed1cd6 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -240,10 +240,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) if ((ob != NULL) && (ob->type == OB_GPENCIL)) { gpd = (bGPdata *)ob->data; bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* In dopesheet add a new frame. */ - if ((gpl != NULL) && (sa->spacetype == SPACE_ACTION)) { + if ((gpl != NULL) && (area->spacetype == SPACE_ACTION)) { gpl->actframe = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW); } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 8c31df02a11..14fd54bf287 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1379,8 +1379,8 @@ void GPENCIL_OT_copy(wmOperatorType *ot) static bool gp_strokes_paste_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (!((sa != NULL) && (sa->spacetype == SPACE_VIEW3D))) { + ScrArea *area = CTX_wm_area(C); + if (!((area != NULL) && (area->spacetype == SPACE_VIEW3D))) { return false; } /* 1) Must have GP datablock to paste to @@ -2606,11 +2606,11 @@ void GPENCIL_OT_dissolve(wmOperatorType *ot) */ static bool gp_snap_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); return (ob != NULL) && (ob->type == OB_GPENCIL) && - ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D)); + ((area != NULL) && (area->spacetype == SPACE_VIEW3D)); } /* --------------------------------- */ @@ -3240,9 +3240,9 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, } /* define start and end points of each stroke */ - float sa[3], sb[3], ea[3], eb[3]; + float area[3], sb[3], ea[3], eb[3]; pt = &gps_a->points[0]; - copy_v3_v3(sa, &pt->x); + copy_v3_v3(area, &pt->x); pt = &gps_a->points[gps_a->totpoints - 1]; copy_v3_v3(ea, &pt->x); @@ -4625,7 +4625,7 @@ static int gpencil_cutter_lasso_select(bContext *C, void *user_data) { bGPdata *gpd = ED_gpencil_data_get_active(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ToolSettings *ts = CTX_data_tool_settings(C); const float scale = ts->gp_sculpt.isect_threshold; @@ -4636,7 +4636,7 @@ static int gpencil_cutter_lasso_select(bContext *C, bool changed = false; /* sanity checks */ - if (sa == NULL) { + if (area == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } @@ -4732,9 +4732,9 @@ static bool gpencil_cutter_poll(bContext *C) static int gpencil_cutter_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* sanity checks */ - if (sa == NULL) { + if (area == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index e56017d0bed..a3f6e10ccb0 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -92,7 +92,7 @@ typedef struct tGPDfill { /** current active gp object */ struct Object *ob; /** area where painting originated */ - struct ScrArea *sa; + struct ScrArea *area; /** region where painting originated */ struct RegionView3D *rv3d; /** view3 where painting originated */ @@ -1248,8 +1248,8 @@ static bool gpencil_fill_poll(bContext *C) Object *obact = CTX_data_active_object(C); if (ED_operator_regionactive(C)) { - ScrArea *sa = CTX_wm_area(C); - if (sa->spacetype == SPACE_VIEW3D) { + ScrArea *area = CTX_wm_area(C); + if (area->spacetype == SPACE_VIEW3D) { if ((obact == NULL) || (obact->type != OB_GPENCIL) || (obact->mode != OB_MODE_PAINT_GPENCIL)) { return false; @@ -1283,10 +1283,10 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) tgpf->bmain = CTX_data_main(C); tgpf->scene = CTX_data_scene(C); tgpf->ob = CTX_data_active_object(C); - tgpf->sa = CTX_wm_area(C); + tgpf->area = CTX_wm_area(C); tgpf->region = CTX_wm_region(C); tgpf->rv3d = tgpf->region->regiondata; - tgpf->v3d = tgpf->sa->spacedata.first; + tgpf->v3d = tgpf->area->spacedata.first; tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpf->win = CTX_wm_window(C); diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 61bca235d17..c5e5a0b79ef 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -116,7 +116,7 @@ typedef struct tGPDinterpolate { /** current scene from context */ struct Scene *scene; /** area where painting originated */ - struct ScrArea *sa; + struct ScrArea *area; /** region where painting originated */ struct ARegion *region; /** current GP datablock */ @@ -156,7 +156,7 @@ typedef struct tGPDprimitive { /** current evaluated gp object */ struct Object *ob_eval; /** area where painting originated */ - struct ScrArea *sa; + struct ScrArea *area; /** region where painting originated */ struct RegionView3D *rv3d; /** view3d where painting originated */ @@ -247,7 +247,7 @@ typedef struct GP_SpaceConversion { struct bGPdata *gpd; struct bGPDlayer *gpl; - struct ScrArea *sa; + struct ScrArea *area; struct ARegion *region; struct View2D *v2d; diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index fef88007542..e6661e886b1 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -86,8 +86,8 @@ static bool gpencil_view3d_poll(bContext *C) bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only 3D view */ - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype != SPACE_VIEW3D) { + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype != SPACE_VIEW3D) { return 0; } @@ -383,7 +383,7 @@ static void gpencil_interpolate_status_indicators(bContext *C, tGPDinterpolate * (int)((p->init_factor + p->shift) * 100.0f)); } - ED_area_status_text(p->sa, status_str); + ED_area_status_text(p->area, status_str); ED_workspace_status_text( C, TIP_("ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor")); } @@ -410,7 +410,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op) /* don't assume that operator data exists at all */ if (tgpi) { /* clear status message area */ - ED_area_status_text(tgpi->sa, NULL); + ED_area_status_text(tgpi->area, NULL); ED_workspace_status_text(C, NULL); /* Clear any temp stroke. */ @@ -445,7 +445,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte /* set current scene and window */ tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpi->scene = CTX_data_scene(C); - tgpi->sa = CTX_wm_area(C); + tgpi->area = CTX_wm_area(C); tgpi->region = CTX_wm_region(C); tgpi->flag = ts->gp_interpolate.flag; @@ -567,7 +567,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent case EVT_PADENTER: case EVT_RETKEY: { /* return to normal cursor and header status */ - ED_area_status_text(tgpi->sa, NULL); + ED_area_status_text(tgpi->area, NULL); ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); @@ -602,7 +602,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent case EVT_ESCKEY: /* cancel */ case RIGHTMOUSE: { /* return to normal cursor and header status */ - ED_area_status_text(tgpi->sa, NULL); + ED_area_status_text(tgpi->area, NULL); ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index 8b126912efc..0171a81f5eb 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -178,10 +178,10 @@ static bool gp_stroke_sculptmode_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); Object *ob = CTX_data_active_object(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* if not gpencil object and not view3d, need sculpt keys if edit mode */ - if (sa->spacetype != SPACE_VIEW3D) { + if (area->spacetype != SPACE_VIEW3D) { return ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); } else { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 1a169f9ec89..7f0d1029722 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -156,7 +156,7 @@ typedef struct tGPsdata { /** window where painting originated. */ wmWindow *win; /** area where painting originated. */ - ScrArea *sa; + ScrArea *area; /** region where painting originated. */ ARegion *region; /** needed for GP_STROKE_2DSPACE. */ @@ -297,9 +297,9 @@ static void gp_session_validatebuffer(tGPsdata *p); static bool gpencil_draw_poll(bContext *C) { if (ED_operator_regionactive(C)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* 3D Viewport */ - if (sa->spacetype != SPACE_VIEW3D) { + if (area->spacetype != SPACE_VIEW3D) { return false; } @@ -812,7 +812,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure pt->time = (float)(curtime - p->inittime); /* point uv (only 3d view) */ - if ((p->sa->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) { + if ((p->area->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) { tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1; bGPDspoint spt, spt2; @@ -1242,7 +1242,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, gp_settings = eraser->gpencil_settings; } - if ((gp_settings != NULL) && (p->sa->spacetype == SPACE_VIEW3D) && + if ((gp_settings != NULL) && (p->area->spacetype == SPACE_VIEW3D) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) { RegionView3D *rv3d = p->region->regiondata; bGPDlayer *gpl = p->gpl; @@ -1593,9 +1593,9 @@ static void gp_stroke_doeraser(tGPsdata *p) rect.xmax = p->mval[0] + calc_radius; rect.ymax = p->mval[1] + calc_radius; - if (p->sa->spacetype == SPACE_VIEW3D) { + if (p->area->spacetype == SPACE_VIEW3D) { if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->region); ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0); } @@ -1633,7 +1633,7 @@ static void gp_stroke_doeraser(tGPsdata *p) /* Not all strokes in the datablock may be valid in the current editor/context * (e.g. 2D space strokes in the 3D view, if the same datablock is shared) */ - if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) { + if (ED_gpencil_stroke_can_use_direct(p->area, gps)) { gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, calc_radius, &rect); } } @@ -1816,7 +1816,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) * - must verify that region data is 3D-view (and not something else) */ /* CAUTION: If this is the "toolbar", then this will change on the first stroke */ - p->sa = curarea; + p->area = curarea; p->region = region; p->align_flag = &ts->gpencil_v3d_align; @@ -1831,7 +1831,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) } if ((!obact) || (obact->type != OB_GPENCIL)) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; /* if active object doesn't exist or isn't a GP Object, create one */ const float *cur = p->scene->cursor.location; @@ -2058,8 +2058,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* when drawing in the camera view, in 2D space, set the subrect */ p->subrect = NULL; if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) { - if (p->sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = p->sa->spacedata.first; + if (p->area->spacetype == SPACE_VIEW3D) { + View3D *v3d = p->area->spacedata.first; RegionView3D *rv3d = p->region->regiondata; /* for camera view set the subrect */ @@ -2076,7 +2076,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps p->gsc.gpd = p->gpd; p->gsc.gpl = p->gpl; - p->gsc.sa = p->sa; + p->gsc.area = p->area; p->gsc.region = p->region; p->gsc.v2d = p->v2d; @@ -2087,7 +2087,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* check if points will need to be made in view-aligned space */ if (*p->align_flag & GP_PROJECT_VIEWSPACE) { - switch (p->sa->spacetype) { + switch (p->area->spacetype) { case SPACE_VIEW3D: { p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE; break; @@ -2112,7 +2112,7 @@ static void gp_paint_strokeend(tGPsdata *p) * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { - View3D *v3d = p->sa->spacedata.first; + View3D *v3d = p->area->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->region); @@ -2243,7 +2243,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) } /* restore cursor to indicate end of drawing */ - if (p->sa->spacetype != SPACE_VIEW3D) { + if (p->area->spacetype != SPACE_VIEW3D) { WM_cursor_modal_restore(CTX_wm_window(C)); } else { @@ -3096,10 +3096,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ -static bool gpencil_area_exists(bContext *C, ScrArea *sa_test) +static bool gpencil_area_exists(bContext *C, ScrArea *area_test) { bScreen *sc = CTX_wm_screen(C); - return (BLI_findindex(&sc->areabase, sa_test) != -1); + return (BLI_findindex(&sc->areabase, area_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) @@ -3109,7 +3109,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ - if (CTX_wm_area(C) != p->sa) { + if (CTX_wm_area(C) != p->area) { printf("\t\t\tGP - wrong area execution abort!\n"); p->status = GP_STATUS_ERROR; } @@ -3504,18 +3504,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) */ if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ - ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y); + ARegion *current_region = BKE_area_find_region_xy( + p->area, RGN_TYPE_ANY, event->x, event->y); if (G.debug & G_DEBUG) { - printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n", + printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n", current_region, p->region, event->x, event->y, - p->sa->totrct.xmin, - p->sa->totrct.ymin, - p->sa->totrct.xmax, - p->sa->totrct.ymax); + p->area->totrct.xmin, + p->area->totrct.ymin, + p->area->totrct.xmax, + p->area->totrct.ymax); } if (current_region) { @@ -3660,7 +3661,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ - if (0 == gpencil_area_exists(C, p->sa)) { + if (0 == gpencil_area_exists(C, p->area)) { estate = OPERATOR_CANCELLED; } else { diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index dfd11484d22..11aeeba5a24 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -240,8 +240,8 @@ static void gp_primitive_update_cps(tGPDprimitive *tgpi) static bool gpencil_primitive_add_poll(bContext *C) { /* only 3D view */ - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype != SPACE_VIEW3D) { + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype != SPACE_VIEW3D) { return 0; } @@ -1137,10 +1137,10 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) tgpi->scene = scene; tgpi->ob = CTX_data_active_object(C); tgpi->ob_eval = (Object *)DEG_get_evaluated_object(tgpi->depsgraph, tgpi->ob); - tgpi->sa = CTX_wm_area(C); + tgpi->area = CTX_wm_area(C); tgpi->region = CTX_wm_region(C); tgpi->rv3d = tgpi->region->regiondata; - tgpi->v3d = tgpi->sa->spacedata.first; + tgpi->v3d = tgpi->area->spacedata.first; tgpi->win = CTX_wm_window(C); /* save original type */ diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 8f3fc5fa268..7b6054e4156 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -91,7 +91,7 @@ typedef struct tGP_BrushEditData { Scene *scene; Object *object; - ScrArea *sa; + ScrArea *area; ARegion *region; /* Current GPencil datablock */ @@ -1181,7 +1181,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) gso->is_transformed = false; } - gso->sa = CTX_wm_area(C); + gso->area = CTX_wm_area(C); gso->region = CTX_wm_region(C); Paint *paint = &ts->gp_sculptpaint->paint; @@ -1307,8 +1307,8 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) /* poll callback for stroke sculpting operator(s) */ static bool gpsculpt_brush_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype != SPACE_VIEW3D) { + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype != SPACE_VIEW3D) { return false; } diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 97f0a578d9d..e25576f32aa 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1015,7 +1015,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); const int mx = RNA_int_get(op->ptr, "x"); const int my = RNA_int_get(op->ptr, "y"); @@ -1028,7 +1028,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) bool changed = false; /* sanity checks */ - if (sa == NULL) { + if (area == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } @@ -1126,7 +1126,7 @@ static int gpencil_generic_select_exec(bContext *C, Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); int selectmode; if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) { @@ -1153,7 +1153,7 @@ static int gpencil_generic_select_exec(bContext *C, bool changed = false; /* sanity checks */ - if (sa == NULL) { + if (area == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } @@ -1416,7 +1416,7 @@ static void deselect_all_selected(bContext *C) static int gpencil_select_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -1444,7 +1444,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) int hit_distance = radius_squared; /* sanity checks */ - if (sa == NULL) { + if (area == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index e153c22b17f..0048811d53a 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -93,13 +93,13 @@ * and an RNA-pointer to trace back to whatever owns it, * when context info is not available. */ -bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRNA *r_ptr) +bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *area, Object *ob, PointerRNA *r_ptr) { /* if there's an active area, check if the particular editor may * have defined any special Grease Pencil context for editing... */ - if (sa) { - switch (sa->spacetype) { + if (area) { + switch (area->spacetype) { case SPACE_PROPERTIES: /* properties */ case SPACE_INFO: /* header info */ case SPACE_TOPBAR: /* Topbar */ @@ -132,16 +132,16 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRN * when context info is not available. */ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id, - ScrArea *sa, + ScrArea *area, Scene *scene, PointerRNA *r_ptr) { /* If there's an active area, check if the particular editor may * have defined any special Grease Pencil context for editing. */ - if (sa) { - SpaceLink *sl = sa->spacedata.first; + if (area) { + SpaceLink *sl = area->spacedata.first; - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_PROPERTIES: /* properties */ case SPACE_INFO: /* header info */ { @@ -236,10 +236,10 @@ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id, * and an RNA-pointer to trace back to whatever owns it. */ bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *r_ptr) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); - return ED_gpencil_data_get_pointers_direct(sa, ob, r_ptr); + return ED_gpencil_data_get_pointers_direct(area, ob, r_ptr); } /* Get pointer to active Grease Pencil datablock, @@ -248,23 +248,23 @@ bGPdata **ED_annotation_data_get_pointers(const bContext *C, PointerRNA *r_ptr) { ID *screen_id = (ID *)CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - return ED_annotation_data_get_pointers_direct(screen_id, sa, scene, r_ptr); + return ED_annotation_data_get_pointers_direct(screen_id, area, scene, r_ptr); } /* -------------------------------------------------------- */ /* Get the active Grease Pencil datablock, when context is not available */ -bGPdata *ED_gpencil_data_get_active_direct(ScrArea *sa, Object *ob) +bGPdata *ED_gpencil_data_get_active_direct(ScrArea *area, Object *ob) { - bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, ob, NULL); + bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(area, ob, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; } /* Get the active Grease Pencil datablock, when context is not available */ -bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *sa, Scene *scene) +bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *area, Scene *scene) { - bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, sa, scene, NULL); + bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, area, scene, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; } @@ -299,13 +299,13 @@ bGPdata *ED_annotation_data_get_active(const bContext *C) */ bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - return ED_gpencil_data_get_active_direct(sa, ob_eval); + return ED_gpencil_data_get_active_direct(area, ob_eval); } /* -------------------------------------------------------- */ @@ -513,25 +513,25 @@ bool gp_stroke_inside_circle(const float mval[2], int rad, int x0, int y0, int x /* Check whether given stroke can be edited given the supplied context */ /* TODO: do we need additional flags for screenspace vs dataspace? */ -bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps) +bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps) { /* sanity check */ - if (ELEM(NULL, sa, gps)) { + if (ELEM(NULL, area, gps)) { return false; } /* filter stroke types by flags + spacetype */ if (gps->flag & GP_STROKE_3DSPACE) { /* 3D strokes - only in 3D view */ - return ((sa->spacetype == SPACE_VIEW3D) || (sa->spacetype == SPACE_PROPERTIES)); + return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES)); } else if (gps->flag & GP_STROKE_2DIMAGE) { /* Special "image" strokes - only in Image Editor */ - return (sa->spacetype == SPACE_IMAGE); + return (area->spacetype == SPACE_IMAGE); } else if (gps->flag & GP_STROKE_2DSPACE) { /* 2D strokes (dataspace) - for any 2D view (i.e. everything other than 3D view) */ - return (sa->spacetype != SPACE_VIEW3D); + return (area->spacetype != SPACE_VIEW3D); } else { /* view aligned - anything goes */ @@ -542,8 +542,8 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps) /* Check whether given stroke can be edited in the current context */ bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps) { - ScrArea *sa = CTX_wm_area(C); - return ED_gpencil_stroke_can_use_direct(sa, gps); + ScrArea *area = CTX_wm_area(C); + return ED_gpencil_stroke_can_use_direct(area, gps); } /* Check whether given stroke can be edited for the current color */ @@ -574,7 +574,7 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr */ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); /* zero out the storage (just in case) */ @@ -585,12 +585,12 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) r_gsc->scene = CTX_data_scene(C); r_gsc->ob = CTX_data_active_object(C); - r_gsc->sa = sa; + r_gsc->area = area; r_gsc->region = region; r_gsc->v2d = ®ion->v2d; /* init region-specific stuff */ - if (sa->spacetype == SPACE_VIEW3D) { + if (area->spacetype == SPACE_VIEW3D) { wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); @@ -685,8 +685,8 @@ void gp_point_to_xy( int xyval[2]; /* sanity checks */ - BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D)); - BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); + BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D)); + BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D)); if (gps->flag & GP_STROKE_3DSPACE) { if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == @@ -743,8 +743,8 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc, float xyval[2]; /* sanity checks */ - BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D)); - BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); + BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D)); + BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D)); if (gps->flag & GP_STROKE_3DSPACE) { if (ED_view3d_project_float_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == @@ -802,7 +802,7 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc, float xyval[2]; /* sanity checks */ - BLI_assert((gsc->sa->spacetype == SPACE_VIEW3D)); + BLI_assert((gsc->area->spacetype == SPACE_VIEW3D)); if (flag & GP_STROKE_3DSPACE) { if (ED_view3d_project_float_global(region, pt, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { @@ -1563,7 +1563,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) static bool gp_check_cursor_region(bContext *C, int mval_i[2]) { ARegion *region = CTX_wm_region(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); if ((ob == NULL) || (!ELEM(ob->mode, @@ -1575,7 +1575,7 @@ static bool gp_check_cursor_region(bContext *C, int mval_i[2]) } /* TODO: add more spacetypes */ - if (!ELEM(sa->spacetype, SPACE_VIEW3D)) { + if (!ELEM(area->spacetype, SPACE_VIEW3D)) { return false; } if ((region) && (region->regiontype != RGN_TYPE_WINDOW)) { diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c index 5f15a6f5411..114d916d1e2 100644 --- a/source/blender/editors/gpencil/gpencil_uv.c +++ b/source/blender/editors/gpencil/gpencil_uv.c @@ -92,9 +92,9 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C) const char *str = TIP_("Confirm: Enter/LClick, Cancel: (Esc/RClick) %s"); char msg[UI_MAX_DRAW_STR]; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (sa) { + if (area) { char flts_str[NUM_STR_REP_LEN * 2]; switch (mode) { case GP_UV_TRANSLATE: { @@ -120,7 +120,7 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C) break; } BLI_snprintf(msg, sizeof(msg), str, flts_str, flts_str + NUM_STR_REP_LEN); - ED_area_status_text(sa, msg); + ED_area_status_text(area, msg); } } @@ -214,7 +214,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op, const bool is static void gpencil_uv_transform_exit(bContext *C, wmOperator *op) { GpUvData *opdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); opdata = op->customdata; @@ -226,8 +226,8 @@ static void gpencil_uv_transform_exit(bContext *C, wmOperator *op) WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT); - if (sa) { - ED_area_status_text(sa, NULL); + if (area) { + ED_area_status_text(area, NULL); } WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 7f4c3470020..fe249ce8bfe 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -74,13 +74,13 @@ typedef struct bAnimContext { /** editor->mode */ short mode; - /** sa->spacetype */ + /** area->spacetype */ short spacetype; /** active region -> type (channels or main) */ short regiontype; /** editor host */ - struct ScrArea *sa; + struct ScrArea *area; /** editor data */ struct SpaceLink *sl; /** region within editor */ @@ -840,7 +840,7 @@ void ED_animedit_unlink_action(struct bContext *C, bool force_delete); /* Drivers Editor - Utility to set up UI correctly */ -void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa); +void ED_drivers_editor_init(struct bContext *C, struct ScrArea *area); /* ************************************************ */ diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 511e892f29a..d63353d3886 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -88,20 +88,20 @@ struct bGPdata *ED_gpencil_data_get_active(const struct bContext *C); struct bGPdata *ED_gpencil_data_get_active_evaluated(const struct bContext *C); /* Context independent (i.e. each required part is passed in instead) */ -struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ScrArea *sa, +struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ScrArea *area, struct Object *ob, struct PointerRNA *r_ptr); -struct bGPdata *ED_gpencil_data_get_active_direct(struct ScrArea *sa, struct Object *ob); +struct bGPdata *ED_gpencil_data_get_active_direct(struct ScrArea *area, struct Object *ob); struct bGPdata *ED_annotation_data_get_active(const struct bContext *C); struct bGPdata **ED_annotation_data_get_pointers(const struct bContext *C, struct PointerRNA *r_ptr); struct bGPdata **ED_annotation_data_get_pointers_direct(struct ID *screen_id, - struct ScrArea *sa, + struct ScrArea *area, struct Scene *scene, struct PointerRNA *r_ptr); struct bGPdata *ED_annotation_data_get_active_direct(struct ID *screen_id, - struct ScrArea *sa, + struct ScrArea *area, struct Scene *scene); bool ED_gpencil_data_owner_is_annotation(struct PointerRNA *owner_ptr); @@ -111,7 +111,7 @@ bool ED_gpencil_has_keyframe_v3d(struct Scene *scene, struct Object *ob, int cfr /* ----------- Stroke Editing Utilities ---------------- */ -bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *sa, const struct bGPDstroke *gps); +bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *area, const struct bGPDstroke *gps); bool ED_gpencil_stroke_can_use(const struct bContext *C, const struct bGPDstroke *gps); bool ED_gpencil_stroke_color_use(struct Object *ob, const struct bGPDlayer *gpl, diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 7d314c0c462..5aafc0702da 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -43,22 +43,25 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf); void ED_operatormacros_mask(void); /* mask_query.c */ -void ED_mask_get_size(struct ScrArea *sa, int *width, int *height); -void ED_mask_zoom(struct ScrArea *sa, struct ARegion *region, float *zoomx, float *zoomy); -void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *region, float *aspx, float *aspy); +void ED_mask_get_size(struct ScrArea *area, int *width, int *height); +void ED_mask_zoom(struct ScrArea *area, struct ARegion *region, float *zoomx, float *zoomy); +void ED_mask_get_aspect(struct ScrArea *area, struct ARegion *region, float *aspx, float *aspy); -void ED_mask_pixelspace_factor(struct ScrArea *sa, +void ED_mask_pixelspace_factor(struct ScrArea *area, struct ARegion *region, float *scalex, float *scaley); -void ED_mask_mouse_pos(struct ScrArea *sa, struct ARegion *region, const int mval[2], float co[2]); +void ED_mask_mouse_pos(struct ScrArea *area, + struct ARegion *region, + const int mval[2], + float co[2]); void ED_mask_point_pos( - struct ScrArea *sa, struct ARegion *region, float x, float y, float *xr, float *yr); + struct ScrArea *area, struct ARegion *region, float x, float y, float *xr, float *yr); void ED_mask_point_pos__reverse( - struct ScrArea *sa, struct ARegion *region, float x, float y, float *xr, float *yr); + struct ScrArea *area, struct ARegion *region, float x, float y, float *xr, float *yr); -void ED_mask_cursor_location_get(struct ScrArea *sa, float cursor[2]); +void ED_mask_cursor_location_get(struct ScrArea *area, float cursor[2]); bool ED_mask_selected_minmax(const struct bContext *C, float min[2], float max[2]); /* mask_draw.c */ diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index ae2b4989069..7a1f64b61d4 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -86,8 +86,8 @@ void ED_node_sort(struct bNodeTree *ntree); float ED_node_grid_size(void); /* node_relationships.c */ -void ED_node_link_intersect_test(struct ScrArea *sa, int test); -void ED_node_link_insert(struct Main *bmain, struct ScrArea *sa); +void ED_node_link_intersect_test(struct ScrArea *area, int test); +void ED_node_link_insert(struct Main *bmain, struct ScrArea *area); /* node_edit.c */ void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo); diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 0645b256a15..6db45a653b5 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -48,7 +48,7 @@ void ED_operatortypes_render(void); /* render_update.c */ void ED_render_engine_changed(struct Main *bmain); -void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *sa); +void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *area); void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *sc); /* Callbacks handling data update events coming from depsgraph. */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 7430f491d91..62d4324d37e 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -63,14 +63,14 @@ struct wmWindowManager; /* regions */ void ED_region_do_listen(struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmNotifier *note, const Scene *scene); void ED_region_do_layout(struct bContext *C, struct ARegion *region); void ED_region_do_draw(struct bContext *C, struct ARegion *region); void ED_region_exit(struct bContext *C, struct ARegion *region); -void ED_region_remove(struct bContext *C, struct ScrArea *sa, struct ARegion *region); +void ED_region_remove(struct bContext *C, struct ScrArea *area, struct ARegion *region); void ED_region_pixelspace(struct ARegion *region); void ED_region_update_rect(struct ARegion *region); void ED_region_floating_initialize(struct ARegion *region); @@ -104,14 +104,14 @@ void ED_region_header(const struct bContext *C, struct ARegion *region); void ED_region_header_layout(const struct bContext *C, struct ARegion *region); void ED_region_header_draw(const struct bContext *C, struct ARegion *region); -void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *region); +void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *area, struct ARegion *region); void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region); void ED_region_visibility_change_update(struct bContext *C, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region); /* screen_ops.c */ void ED_region_visibility_change_update_animated(struct bContext *C, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region); void ED_region_info_draw(struct ARegion *region, @@ -146,14 +146,14 @@ void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); void ED_area_do_mgs_subscribe_for_tool_ui(const struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); @@ -162,7 +162,7 @@ void ED_region_message_subscribe(struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); @@ -171,21 +171,21 @@ void ED_spacetypes_keymap(struct wmKeyConfig *keyconf); int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco); /* areas */ -void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa); -void ED_area_exit(struct bContext *C, struct ScrArea *sa); +void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); +void ED_area_exit(struct bContext *C, struct ScrArea *area); int ED_screen_area_active(const struct bContext *C); void ED_screen_global_areas_refresh(struct wmWindow *win); void ED_screen_global_areas_sync(struct wmWindow *win); -void ED_area_do_listen(struct wmWindow *win, ScrArea *sa, struct wmNotifier *note, Scene *scene); -void ED_area_tag_redraw(ScrArea *sa); -void ED_area_tag_redraw_no_rebuild(ScrArea *sa); -void ED_area_tag_redraw_regiontype(ScrArea *sa, int type); -void ED_area_tag_refresh(ScrArea *sa); -void ED_area_do_refresh(struct bContext *C, ScrArea *sa); -struct AZone *ED_area_azones_update(ScrArea *sa, const int mouse_xy[]); -void ED_area_status_text(ScrArea *sa, const char *str); -void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_region_exit); -void ED_area_prevspace(struct bContext *C, ScrArea *sa); +void ED_area_do_listen(struct wmWindow *win, ScrArea *area, struct wmNotifier *note, Scene *scene); +void ED_area_tag_redraw(ScrArea *area); +void ED_area_tag_redraw_no_rebuild(ScrArea *area); +void ED_area_tag_redraw_regiontype(ScrArea *area, int type); +void ED_area_tag_refresh(ScrArea *area); +void ED_area_do_refresh(struct bContext *C, ScrArea *area); +struct AZone *ED_area_azones_update(ScrArea *area, const int mouse_xy[]); +void ED_area_status_text(ScrArea *area, const char *str); +void ED_area_newspace(struct bContext *C, ScrArea *area, int type, const bool skip_region_exit); +void ED_area_prevspace(struct bContext *C, ScrArea *area); void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2); int ED_area_headersize(void); int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback); @@ -224,7 +224,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm); void ED_screen_draw_edges(struct wmWindow *win); void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2); -void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac); +void ED_screen_draw_split_preview(struct ScrArea *area, const int dir, const float fac); void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win); void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, @@ -236,13 +236,13 @@ void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); void ED_screen_animation_timer_update(struct bScreen *screen, int redraws); -void ED_screen_restore_temp_type(struct bContext *C, ScrArea *sa); -ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); -void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa); -void ED_screen_full_restore(struct bContext *C, ScrArea *sa); +void ED_screen_restore_temp_type(struct bContext *C, ScrArea *area); +ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *area, int type); +void ED_screen_full_prevspace(struct bContext *C, ScrArea *area); +void ED_screen_full_restore(struct bContext *C, ScrArea *area); struct ScrArea *ED_screen_state_toggle(struct bContext *C, struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, const short state); ScrArea *ED_screen_temp_space_open(struct bContext *C, const char *title, @@ -422,7 +422,7 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); int ED_region_generic_tools_region_snap_size(const struct ARegion *region, int size, int axis); @@ -449,8 +449,8 @@ bool ED_region_contains_xy(const struct ARegion *region, const int event_xy[2]); /* interface_region_hud.c */ struct ARegionType *ED_area_type_hud(int space_type); -void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *sa_keep); -void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *sa); +void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *area_keep); +void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *area); /* default keymaps, bitflags (matches order of evaluation). */ enum { diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 8b4829446c3..1f2706957a7 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -48,7 +48,7 @@ bool ED_editors_flush_edits_for_object(struct Main *bmain, struct Object *ob); bool ED_editors_flush_edits_ex(struct Main *bmain, bool for_render, bool check_needs_flush); bool ED_editors_flush_edits(struct Main *bmain); -void ED_spacedata_id_remap(struct ScrArea *sa, +void ED_spacedata_id_remap(struct ScrArea *area, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 86ad35cfa9f..668ca3c6437 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -561,7 +561,7 @@ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_region); -bool ED_view3d_area_user_region(const struct ScrArea *sa, +bool ED_view3d_area_user_region(const struct ScrArea *area, const struct View3D *v3d, struct ARegion **r_region); bool ED_operator_rv3d_user_region_poll(struct bContext *C); @@ -600,7 +600,7 @@ void ED_view3d_draw_setup_view(const struct wmWindowManager *wm, struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); struct Object *ED_view3d_give_object_under_cursor(struct bContext *C, const int mval[2]); bool ED_view3d_is_object_under_cursor(struct bContext *C, const int mval[2]); -void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *region, bool do_clip); +void ED_view3d_quadview_update(struct ScrArea *area, struct ARegion *region, bool do_clip); void ED_view3d_update_viewmat(struct Depsgraph *depsgraph, const struct Scene *scene, struct View3D *v3d, @@ -702,7 +702,7 @@ void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, /* render */ void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *region); -void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); +void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *area); #define XRAY_ALPHA(v3d) \ (((v3d)->shading.type == OB_WIRE) ? (v3d)->shading.xray_alpha_wire : (v3d)->shading.xray_alpha) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 1fa6e5b12c1..e8d50886c8b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1650,14 +1650,14 @@ void UI_panels_end(const struct bContext *C, struct ARegion *region, int *r_x, i void UI_panels_draw(const struct bContext *C, struct ARegion *region); struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt); -struct Panel *UI_panel_begin(struct ScrArea *sa, +struct Panel *UI_panel_begin(struct ScrArea *area, struct ARegion *region, struct ListBase *lb, uiBlock *block, struct PanelType *pt, struct Panel *pa, bool *r_open); -void UI_panel_end(const struct ScrArea *sa, +void UI_panel_end(const struct ScrArea *area, const struct ARegion *region, uiBlock *block, int width, diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index ff9719d4674..d4db1b14074 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -119,7 +119,7 @@ void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy) void UI_view2d_curRect_validate(struct View2D *v2d); void UI_view2d_curRect_reset(struct View2D *v2d); -void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag); +void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D *v2dcur, int flag); void UI_view2d_totRect_set(struct View2D *v2d, int width, int height); void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize); diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 5fd1cef6451..817cb44db29 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -139,8 +139,8 @@ void eyedropper_draw_cursor_text(const struct bContext *C, const ARegion *region uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y); - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_ANY, event->x, event->y); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y); + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->x, event->y); uiBut *but = ui_but_find_mouse_over(region, event); diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 372fd841bc1..7527a1e0662 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -137,15 +137,15 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) /* we could use some clever */ Main *bmain = CTX_data_main(C); bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); const char *display_device = CTX_data_scene(C)->display_settings.display_device; struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); - if (sa) { - if (sa->spacetype == SPACE_IMAGE) { - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + if (area) { + if (area->spacetype == SPACE_IMAGE) { + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; if (ED_space_image_color_sample(sima, region, mval, r_col)) { @@ -153,10 +153,10 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) } } } - else if (sa->spacetype == SPACE_NODE) { - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + else if (area->spacetype == SPACE_NODE) { + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) { @@ -164,10 +164,10 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) } } } - else if (sa->spacetype == SPACE_CLIP) { - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + else if (area->spacetype == SPACE_CLIP) { + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; if (ED_space_clip_color_sample(sc, region, mval, r_col)) { diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index bf118481be2..d9c77c26941 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -152,27 +152,27 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int { /* we could use some clever */ bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my); + ScrArea *area = BKE_screen_find_area_xy(screen, -1, mx, my); ScrArea *area_prev = CTX_wm_area(C); ARegion *region_prev = CTX_wm_region(C); ddr->name[0] = '\0'; - if (sa) { - if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) { - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + if (area) { + if (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) { + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; Base *base; - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); /* grr, always draw else we leave stale text */ ED_region_tag_redraw(region); - if (sa->spacetype == SPACE_VIEW3D) { + if (area->spacetype == SPACE_VIEW3D) { base = ED_view3d_give_base_under_cursor(C, mval); } else { @@ -250,11 +250,11 @@ static void datadropper_set_draw_callback_region(bContext *C, const int my) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my); + ScrArea *area = BKE_screen_find_area_xy(screen, -1, mx, my); - if (sa) { + if (area) { /* If spacetype changed */ - if (sa->spacetype != ddr->cursor_area->spacetype) { + if (area->spacetype != ddr->cursor_area->spacetype) { /* Remove old callback */ ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); @@ -263,9 +263,9 @@ static void datadropper_set_draw_callback_region(bContext *C, ED_region_tag_redraw(region); /* Set draw callback in new region */ - ARegionType *art = BKE_regiontype_from_id(sa->type, RGN_TYPE_WINDOW); + ARegionType *art = BKE_regiontype_from_id(area->type, RGN_TYPE_WINDOW); - ddr->cursor_area = sa; + ddr->cursor_area = area; ddr->art = art; ddr->draw_handle_pixel = ED_region_draw_cb_activate( art, datadropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL); diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index 26a6109e8cf..907da917e75 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -156,7 +156,7 @@ static void depthdropper_depth_sample_pt( { /* we could use some clever */ bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); Scene *scene = CTX_data_scene(C); ScrArea *area_prev = CTX_wm_area(C); @@ -164,19 +164,19 @@ static void depthdropper_depth_sample_pt( ddr->name[0] = '\0'; - if (sa) { - if (sa->spacetype == SPACE_VIEW3D) { - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + if (area) { + if (area->spacetype == SPACE_VIEW3D) { + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; RegionView3D *rv3d = region->regiondata; /* weak, we could pass in some reference point */ const float *view_co = v3d->camera ? v3d->camera->obmat[3] : rv3d->viewinv[3]; const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; float co[3]; - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); /* grr, always draw else we leave stale text */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 075bd8af906..084eb943665 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2015,8 +2015,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) Object *ob = CTX_data_active_object(C); const EnumPropertyItem *items = NULL; ePaintMode paint_mode = PAINT_MODE_INVALID; - ScrArea *sa = CTX_wm_area(C); - char space_type = sa->spacetype; + ScrArea *area = CTX_wm_area(C); + char space_type = area->spacetype; /* Fallback to 3D view. */ if (space_type == SPACE_PROPERTIES) { space_type = SPACE_VIEW3D; @@ -2041,8 +2041,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) } } else if (space_type == SPACE_IMAGE) { - if (sa->spacetype == space_type) { - const SpaceImage *sima = sa->spacedata.first; + if (area->spacetype == space_type) { + const SpaceImage *sima = area->spacedata.first; if (sima->mode == SI_MODE_PAINT) { paint_mode = PAINT_MODE_TEXTURE_2D; } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 5a4a549ea3e..ed5d02a5a03 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1308,9 +1308,9 @@ static int editsource_text_edit(bContext *C, else { /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ - ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); - if (sa) { - SpaceText *st = sa->spacedata.first; + ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); + if (area) { + SpaceText *st = area->spacedata.first; st->text = text; } else { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d57b4d444bd..04d1181a8a1 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -131,18 +131,18 @@ typedef enum eSpaceButtons_Align { BUT_AUTO = 2, } eSpaceButtons_Align; -static int panel_aligned(const ScrArea *sa, const ARegion *region) +static int panel_aligned(const ScrArea *area, const ARegion *region) { - if (sa->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) { + if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) { return BUT_VERTICAL; } - else if (sa->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) { + else if (area->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) { return BUT_VERTICAL; } - else if (sa->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) { + else if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) { return BUT_VERTICAL; } - else if (sa->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) { + else if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) { return BUT_VERTICAL; } else if (ELEM(region->regiontype, @@ -196,21 +196,21 @@ static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, b return false; } -static bool panels_need_realign(ScrArea *sa, ARegion *region, Panel **r_pa_animate) +static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_pa_animate) { *r_pa_animate = NULL; - if (sa->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) { - SpaceProperties *sbuts = sa->spacedata.first; + if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) { + SpaceProperties *sbuts = area->spacedata.first; if (sbuts->mainbo != sbuts->mainb) { return true; } } - else if (sa->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) { + else if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) { return true; } - else if (sa->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) { + else if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) { return true; } @@ -234,11 +234,11 @@ static bool panels_need_realign(ScrArea *sa, ARegion *region, Panel **r_pa_anima /****************************** panels ******************************/ -static void panels_collapse_all(ScrArea *sa, ARegion *region, const Panel *from_pa) +static void panels_collapse_all(ScrArea *area, ARegion *region, const Panel *from_pa) { const bool has_category_tabs = UI_panel_category_is_visible(region); const char *category = has_category_tabs ? UI_panel_category_active_get(region, false) : NULL; - const int flag = ((panel_aligned(sa, region) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY); + const int flag = ((panel_aligned(area, region) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY); const PanelType *from_pt = from_pa->type; Panel *pa; @@ -274,7 +274,7 @@ Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt) /** * \note \a pa should be return value from #UI_panel_find_by_type and can be NULL. */ -Panel *UI_panel_begin(ScrArea *sa, +Panel *UI_panel_begin(ScrArea *area, ARegion *region, ListBase *lb, uiBlock *block, @@ -286,7 +286,7 @@ Panel *UI_panel_begin(ScrArea *sa, const char *drawname = CTX_IFACE_(pt->translation_context, pt->label); const char *idname = pt->idname; const bool newpanel = (pa == NULL); - int align = panel_aligned(sa, region); + int align = panel_aligned(area, region); if (!newpanel) { pa->type = pt; @@ -385,7 +385,7 @@ static float panel_region_offset_x_get(const ARegion *region, int align) } void UI_panel_end( - const ScrArea *sa, const ARegion *region, uiBlock *block, int width, int height, bool open) + const ScrArea *area, const ARegion *region, uiBlock *block, int width, int height, bool open) { Panel *pa = block->panel; @@ -425,7 +425,7 @@ void UI_panel_end( pa->ofsy += old_sizey - pa->sizey; } - int align = panel_aligned(sa, region); + int align = panel_aligned(area, region); if (old_region_ofsx != panel_region_offset_x_get(region, align)) { pa->runtime_flag |= PNL_ANIM_ALIGN; } @@ -1021,13 +1021,13 @@ static void align_sub_panels(Panel *pa) /* this doesn't draw */ /* returns 1 when it did something */ -static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, const bool drag) +static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, const bool drag) { Panel *pa; PanelSort *ps, *panelsort, *psnext; int a, tot = 0; bool done; - int align = panel_aligned(sa, region); + int align = panel_aligned(area, region); /* count active, not tabbed panels */ for (pa = region->panels.first; pa; pa = pa->next) { @@ -1135,10 +1135,10 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *region, const float fac, cons return done; } -static void ui_panels_size(ScrArea *sa, ARegion *region, int *r_x, int *r_y) +static void ui_panels_size(ScrArea *area, ARegion *region, int *r_x, int *r_y) { Panel *pa; - int align = panel_aligned(sa, region); + int align = panel_aligned(area, region); int sizex = 0; int sizey = 0; @@ -1175,7 +1175,7 @@ static void ui_panels_size(ScrArea *sa, ARegion *region, int *r_x, int *r_y) static void ui_do_animate(const bContext *C, Panel *panel) { uiHandlePanelData *data = panel->activedata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float fac; @@ -1183,7 +1183,7 @@ static void ui_do_animate(const bContext *C, Panel *panel) fac = min_ff(sqrtf(fac), 1.0f); /* for max 1 second, interpolate positions */ - if (uiAlignPanelStep(sa, region, fac, false)) { + if (uiAlignPanelStep(area, region, fac, false)) { ED_region_tag_redraw(region); } else { @@ -1220,7 +1220,7 @@ void UI_panels_begin(const bContext *UNUSED(C), ARegion *region) /* only draws blocks with panels */ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); uiBlock *block; Panel *pa, *firstpa; @@ -1232,12 +1232,12 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) } /* re-align, possibly with animation */ - if (panels_need_realign(sa, region, &pa)) { + if (panels_need_realign(area, region, &pa)) { if (pa) { panel_activate_state(C, pa, PANEL_STATE_ANIMATION); } else { - uiAlignPanelStep(sa, region, 1.0, false); + uiAlignPanelStep(area, region, 1.0, false); } } @@ -1256,7 +1256,7 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) } /* compute size taken up by panel */ - ui_panels_size(sa, region, r_x, r_y); + ui_panels_size(area, region, r_x, r_y); } void UI_panels_draw(const bContext *C, ARegion *region) @@ -1347,9 +1347,9 @@ static void check_panel_overlap(ARegion *region, Panel *panel) static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) { uiHandlePanelData *data = panel->activedata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - short align = panel_aligned(sa, region), dx = 0, dy = 0; + short align = panel_aligned(area, region), dx = 0, dy = 0; /* first clip for window, no dragging outside */ if (!BLI_rcti_isect_pt_v(®ion->winrct, &event->x)) { @@ -1381,7 +1381,7 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) check_panel_overlap(region, panel); if (align) { - uiAlignPanelStep(sa, region, 0.2, true); + uiAlignPanelStep(area, region, 0.2, true); } } @@ -1441,7 +1441,7 @@ static void ui_panel_drag_collapse(bContext *C, uiPanelDragCollapseHandle *dragcol_data, const int xy_dst[2]) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); uiBlock *block; Panel *pa; @@ -1451,7 +1451,7 @@ static void ui_panel_drag_collapse(bContext *C, float xy_b_block[2] = {UNPACK2(xy_dst)}; rctf rect = block->rect; int oldflag; - const bool is_horizontal = (panel_aligned(sa, region) == BUT_HORIZONTAL); + const bool is_horizontal = (panel_aligned(area, region) == BUT_HORIZONTAL); if ((pa = block->panel) == 0 || (pa->type && (pa->type->flag & PNL_NO_HEADER))) { continue; @@ -1553,7 +1553,7 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was static void ui_handle_panel_header( const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); #ifdef USE_PIN_HIDDEN const bool show_pin = UI_panel_category_is_visible(region) && @@ -1565,7 +1565,7 @@ static void ui_handle_panel_header( const bool is_subpanel = (block->panel->type && block->panel->type->parent); const bool show_drag = !is_subpanel; - int align = panel_aligned(sa, region), button = 0; + int align = panel_aligned(area, region), button = 0; rctf rect_drag, rect_pin; float rect_leftmost; @@ -1620,7 +1620,7 @@ static void ui_handle_panel_header( } else { /* collapse */ if (ctrl) { - panels_collapse_all(sa, region, block->panel); + panels_collapse_all(area, region, block->panel); /* reset the view - we don't want to display a view without content */ UI_view2d_offset(®ion->v2d, 0.0f, 1.0f); @@ -2400,7 +2400,7 @@ int ui_handler_panel_region(bContext *C, /*XXX 2.50*/ #if 0 if (block->handler) { - rem_blockhandler(sa, block->handler); + rem_blockhandler(area, block->handler); ED_region_tag_redraw(region); retval = WM_UI_HANDLER_BREAK; } @@ -2421,10 +2421,10 @@ int ui_handler_panel_region(bContext *C, } if (zoom) { - ScrArea *sa = CTX_wm_area(C); - SpaceLink *sl = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + SpaceLink *sl = area->spacedata.first; - if (sa->spacetype != SPACE_PROPERTIES) { + if (area->spacetype != SPACE_PROPERTIES) { if (!(pa->control & UI_PNL_SCALE)) { if (event->type == PADPLUSKEY) { sl->blockscale += 0.1; @@ -2458,9 +2458,9 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) /* verify if we can stop */ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - int align = panel_aligned(sa, region); + int align = panel_aligned(area, region); if (align) { panel_activate_state(C, panel, PANEL_STATE_ANIMATION); diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index e0fc7a3ee71..a7508894c54 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -74,8 +74,8 @@ static bool last_redo_poll(const bContext *C, short region_type) * operator call. Otherwise we would be polling the operator with the * wrong context. */ - ScrArea *sa = CTX_wm_area(C); - ARegion *region_op = (region_type != -1) ? BKE_area_find_region_type(sa, region_type) : NULL; + ScrArea *area = CTX_wm_area(C); + ARegion *region_op = (region_type != -1) ? BKE_area_find_region_type(area, region_type) : NULL; ARegion *region_prev = CTX_wm_region(C); CTX_wm_region_set((bContext *)C, region_op); @@ -103,8 +103,8 @@ static void hud_region_hide(ARegion *region) static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt)) { - ScrArea *sa = CTX_wm_area(C); - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_HUD); + ScrArea *area = CTX_wm_area(C); + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HUD); if (region != NULL) { struct HudRegionData *hrd = region->regiondata; if (hrd != NULL) { @@ -250,15 +250,15 @@ ARegionType *ED_area_type_hud(int space_type) return art; } -static ARegion *hud_region_add(ScrArea *sa) +static ARegion *hud_region_add(ScrArea *area) { ARegion *region = MEM_callocN(sizeof(ARegion), "area region"); - ARegion *region_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region_win) { - BLI_insertlinkbefore(&sa->regionbase, region_win, region); + BLI_insertlinkbefore(&area->regionbase, region_win, region); } else { - BLI_addtail(&sa->regionbase, region); + BLI_addtail(&area->regionbase, region); } region->regiontype = RGN_TYPE_HUD; region->alignment = RGN_ALIGN_FLOAT; @@ -276,18 +276,18 @@ static ARegion *hud_region_add(ScrArea *sa) return region; } -void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *sa_keep) +void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *area_keep) { for (wmWindow *win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa != sa_keep) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area != area_keep) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_HUD) { if ((region->flag & RGN_FLAG_HIDDEN) == 0) { hud_region_hide(region); ED_region_tag_redraw(region); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } } } @@ -296,17 +296,17 @@ void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *sa_keep) } } -void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) +void ED_area_type_hud_ensure(bContext *C, ScrArea *area) { wmWindowManager *wm = CTX_wm_manager(C); - ED_area_type_hud_clear(wm, sa); + ED_area_type_hud_clear(wm, area); - ARegionType *art = BKE_regiontype_from_id(sa->type, RGN_TYPE_HUD); + ARegionType *art = BKE_regiontype_from_id(area->type, RGN_TYPE_HUD); if (art == NULL) { return; } - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_HUD); + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HUD); if (region && (region->flag & RGN_FLAG_HIDDEN_BY_USER)) { /* The region is intentionally hidden by the user, don't show it. */ @@ -328,18 +328,18 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) if (region == NULL) { init = true; - region = hud_region_add(sa); + region = hud_region_add(area); region->type = art; } /* Let 'ED_area_update_region_sizes' do the work of placing the region. * Otherwise we could set the 'region->winrct' & 'region->winx/winy' here. */ if (init) { - sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE; + area->flag |= AREA_FLAG_REGION_SIZE_UPDATE; } else { if (region->flag & RGN_FLAG_HIDDEN) { - sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE; + area->flag |= AREA_FLAG_REGION_SIZE_UPDATE; } region->flag &= ~RGN_FLAG_HIDDEN; } @@ -361,7 +361,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) if (init) { /* This is needed or 'winrct' will be invalid. */ wmWindow *win = CTX_wm_window(C); - ED_area_update_region_sizes(wm, win, sa); + ED_area_update_region_sizes(wm, win, area); } ED_region_floating_initialize(region); diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index b3c10e8d6b8..dbec8e6d653 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -276,17 +276,17 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi else { /* for a header menu we set the direction automatic */ if (!pup->slideout && flip) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (sa && region) { + if (area && region) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { - if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(sa)) == RGN_ALIGN_BOTTOM) { + if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) == RGN_ALIGN_BOTTOM) { UI_block_direction_set(block, UI_DIR_UP); UI_block_order_flip(block); } } if (region->regiontype == RGN_TYPE_FOOTER) { - if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(sa)) == RGN_ALIGN_BOTTOM) { + if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) == RGN_ALIGN_BOTTOM) { UI_block_direction_set(block, UI_DIR_UP); UI_block_order_flip(block); } diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index b889f1d6d01..0ad7e570e80 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -171,7 +171,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v } if (!slideout) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); if (region && region->panels.first) { @@ -180,14 +180,14 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X); } /* Prefer popover from header to be positioned into the editor. */ - else if (sa && region) { + else if (area && region) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { - if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(sa)) == RGN_ALIGN_BOTTOM) { + if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) == RGN_ALIGN_BOTTOM) { UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X); } } if (region->regiontype == RGN_TYPE_FOOTER) { - if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(sa)) == RGN_ALIGN_BOTTOM) { + if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) == RGN_ALIGN_BOTTOM) { UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X); } } diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 7e32a91d08d..e6381fd08e6 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -420,7 +420,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *region) * Use to refresh centered popups on screen resizing (for splash). */ static void ui_block_region_popup_window_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -525,7 +525,7 @@ void ui_popup_block_scrolltest(uiBlock *block) static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) { wmWindow *ctx_win = CTX_wm_window(C); - ScrArea *ctx_sa = CTX_wm_area(C); + ScrArea *ctx_area = CTX_wm_area(C); ARegion *ctx_region = CTX_wm_region(C); wmWindowManager *wm = CTX_wm_manager(C); @@ -550,7 +550,7 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) /* Reset context (area and region were NULL'ed when chaning context window). */ CTX_wm_window_set(C, ctx_win); - CTX_wm_area_set(C, ctx_sa); + CTX_wm_area_set(C, ctx_area); CTX_wm_region_set(C, ctx_region); /* reset to region cursor (only if there's not another menu open) */ diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index cf8ff51eccf..61676ba43d6 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -393,15 +393,15 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is bool has_valid_context = true; const char *has_valid_context_error = IFACE_("Unsupported context"); { - ScrArea *sa = CTX_wm_area(C); - if (sa == NULL) { + ScrArea *area = CTX_wm_area(C); + if (area == NULL) { has_valid_context = false; } else { PropertyRNA *prop = RNA_struct_find_property(but->opptr, "space_type"); if (RNA_property_is_set(but->opptr, prop)) { const int space_type_prop = RNA_property_enum_get(but->opptr, prop); - if (space_type_prop != sa->spacetype) { + if (space_type_prop != area->spacetype) { has_valid_context = false; } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c750187d7a3..6bd956c87b0 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6819,7 +6819,7 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d */ static void menu_types_add_from_keymap_items(bContext *C, wmWindow *win, - ScrArea *sa, + ScrArea *area, ARegion *region, LinkNode **menuid_stack_p, GHash *menu_to_kmi, @@ -6828,7 +6828,7 @@ static void menu_types_add_from_keymap_items(bContext *C, wmWindowManager *wm = CTX_wm_manager(C); ListBase *handlers[] = { region ? ®ion->handlers : NULL, - sa ? &sa->handlers : NULL, + area ? &area->handlers : NULL, &win->handlers, }; @@ -6883,7 +6883,7 @@ static void menu_types_add_from_keymap_items(bContext *C, */ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C, wmWindow *win, - ScrArea *sa, + ScrArea *area, ARegion *region) { MemArena *memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); @@ -6941,8 +6941,8 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C, case space_type: \ break - if (sa != NULL) { - switch (sa->spacetype) { + if (area != NULL) { + switch (area->spacetype) { SPACE_MENU_MAP(SPACE_VIEW3D, "VIEW3D_MT_editor_menus"); SPACE_MENU_MAP(SPACE_GRAPH, "GRAPH_MT_editor_menus"); SPACE_MENU_MAP(SPACE_OUTLINER, "OUTLINER_MT_editor_menus"); @@ -6958,13 +6958,13 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C, SPACE_MENU_MAP(SPACE_CONSOLE, "CONSOLE_MT_editor_menus"); SPACE_MENU_MAP(SPACE_USERPREF, "USERPREF_MT_editor_menus"); SPACE_MENU_MAP(SPACE_CLIP, - (((const SpaceClip *)sa->spacedata.first)->mode == SC_MODE_TRACKING) ? + (((const SpaceClip *)area->spacedata.first)->mode == SC_MODE_TRACKING) ? "CLIP_MT_tracking_editor_menus" : "CLIP_MT_masking_editor_menus"); SPACE_MENU_NOP(SPACE_TOPBAR); SPACE_MENU_NOP(SPACE_STATUSBAR); default: - printf("Unknown space type '%d'\n", sa->spacetype); + printf("Unknown space type '%d'\n", area->spacetype); } } for (int i = 0; i < idname_array_len; i++) { @@ -7110,7 +7110,8 @@ static struct MenuSearch_Data *menu_items_from_ui_create(bContext *C, * so all menus are accessed from the header & top-bar before key shortcuts are expanded. */ if ((menu_stack == NULL) && (has_keymap_menu_items == false)) { has_keymap_menu_items = true; - menu_types_add_from_keymap_items(C, win, sa, region, &menu_stack, menu_to_kmi, menu_tagged); + menu_types_add_from_keymap_items( + C, win, area, region, &menu_stack, menu_to_kmi, menu_tagged); } } @@ -7299,9 +7300,9 @@ void UI_but_func_menu_search(uiBut *but) { bContext *C = but->block->evil_C; wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - struct MenuSearch_Data *data = menu_items_from_ui_create(C, win, sa, region); + struct MenuSearch_Data *data = menu_items_from_ui_create(C, win, area, region); UI_but_func_search_set(but, ui_searchbox_create_menu, menu_search_cb, @@ -7586,7 +7587,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); uiBlock *block; void *owner = NULL; int handle_event, icon = 0; @@ -7660,7 +7661,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) * progress bar which is not being updated (bake jobs only need * to update NC_IMAGE context. */ - if (sa->spacetype != SPACE_NODE) { + if (area->spacetype != SPACE_NODE) { handle_event = B_STOPOTHER; icon = ICON_IMAGE; break; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index adf0d6e372c..6fcce3a18e1 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -865,7 +865,6 @@ void UI_view2d_curRect_validate(View2D *v2d) * to make sure 'related' views stay in synchrony */ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) { - ScrArea *sa; ARegion *region; /* don't continue if no view syncing to be done */ @@ -900,8 +899,8 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) /* check if doing whole screen syncing (i.e. time/horizontal) */ if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - for (region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area_iter = screen->areabase.first; area_iter; area_iter = area_iter->next) { + for (region = area_iter->regionbase.first; region; region = region->next) { /* don't operate on self */ if (v2dcur != ®ion->v2d) { /* only if view has horizontal locks enabled */ @@ -1915,17 +1914,17 @@ View2D *UI_view2d_fromcontext(const bContext *C) /* same as above, but it returns regionwindow. Utility for pulldowns or buttons */ View2D *UI_view2d_fromcontext_rwin(const bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (sa == NULL) { + if (area == NULL) { return NULL; } if (region == NULL) { return NULL; } if (region->regiontype != RGN_TYPE_WINDOW) { - ARegion *region_win = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); return region_win ? &(region_win->v2d) : NULL; } return &(region->v2d); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 2adf441514b..18e14798767 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -81,7 +81,7 @@ typedef struct v2dViewPanData { /** screen where view pan was initiated */ bScreen *sc; /** area where view pan was initiated */ - ScrArea *sa; + ScrArea *area; /** region where view pan was initiated */ ARegion *region; /** view2d we're operating in */ @@ -127,7 +127,7 @@ static int view_pan_init(bContext *C, wmOperator *op) /* set pointers to owners */ vpd->sc = CTX_wm_screen(C); - vpd->sa = CTX_wm_area(C); + vpd->area = CTX_wm_area(C); vpd->v2d = v2d; vpd->region = region; @@ -190,7 +190,7 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float /* request updates to be done... */ WM_event_add_mousemove(CTX_wm_window(C)); - UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY); + UI_view2d_sync(vpd->sc, vpd->area, v2d, V2D_LOCK_COPY); } static void view_pan_apply(bContext *C, wmOperator *op) @@ -589,13 +589,13 @@ typedef struct v2dViewZoomData { */ static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2]) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); r_do_zoom_xy[0] = true; r_do_zoom_xy[1] = true; /* default not to zoom the sequencer vertically */ - if (sa && sa->spacetype == SPACE_SEQ) { + if (area && area->spacetype == SPACE_SEQ) { ARegion *region = CTX_wm_region(C); if (region && region->regiontype == RGN_TYPE_WINDOW) { @@ -758,8 +758,8 @@ static void view_zoomstep_apply_ex( UI_view2d_curRect_validate(v2d); if (ED_region_snap_size_apply(region, snap_test)) { - ScrArea *sa = CTX_wm_area(C); - ED_area_tag_redraw(sa); + ScrArea *area = CTX_wm_area(C); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -1017,8 +1017,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) UI_view2d_curRect_validate(v2d); if (ED_region_snap_size_apply(vzd->region, snap_test)) { - ScrArea *sa = CTX_wm_area(C); - ED_area_tag_redraw(sa); + ScrArea *area = CTX_wm_area(C); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -2211,8 +2211,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) UI_view2d_curRect_validate(v2d); if (ED_region_snap_size_apply(region, snap_test)) { - ScrArea *sa = CTX_wm_area(C); - ED_area_tag_redraw(sa); + ScrArea *area = CTX_wm_area(C); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 9945383211a..767976b5ae6 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -444,11 +444,11 @@ static void mask_point_make_pixel_space(bContext *C, float point_normalized[2], float point_pixel[2]) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float scalex, scaley; - ED_mask_pixelspace_factor(sa, region, &scalex, &scaley); + ED_mask_pixelspace_factor(area, region, &scalex, &scaley); point_pixel[0] = point_normalized[0] * scalex; point_pixel[1] = point_normalized[1] * scaley; @@ -556,12 +556,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float co[2]; - ED_mask_mouse_pos(sa, region, event->mval, co); + ED_mask_mouse_pos(area, region, event->mval, co); RNA_float_set_array(op->ptr, "location", co); @@ -648,12 +648,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float co[2]; - ED_mask_mouse_pos(sa, region, event->mval, co); + ED_mask_mouse_pos(area, region, event->mval, co); RNA_float_set_array(op->ptr, "location", co); @@ -693,7 +693,7 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot) static int create_primitive_from_points( bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Mask *mask; MaskLayer *mask_layer; MaskSpline *new_spline; @@ -701,7 +701,7 @@ static int create_primitive_from_points( int i, width, height; int size = RNA_float_get(op->ptr, "size"); - ED_mask_get_size(sa, &width, &height); + ED_mask_get_size(area, &width, &height); scale = (float)size / max_ii(width, height); /* Get location in mask space. */ @@ -762,12 +762,12 @@ static int create_primitive_from_points( static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); float cursor[2]; int width, height; - ED_mask_get_size(sa, &width, &height); - ED_mask_cursor_location_get(sa, cursor); + ED_mask_get_size(area, &width, &height); + ED_mask_cursor_location_get(area, cursor); cursor[0] *= width; cursor[1] *= height; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 91c02408f95..88e9c7c3664 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -638,7 +638,7 @@ static void draw_mask_layers(const bContext *C, void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Mask *mask = CTX_data_edit_mask(C); int width, height; @@ -646,7 +646,7 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) return; } - ED_mask_get_size(sa, &width, &height); + ED_mask_get_size(area, &width, &height); draw_mask_layers(C, mask, draw_flag, draw_type, width, height); } diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index e696cc37bd3..663ae0097ad 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -44,9 +44,9 @@ bool ED_maskedit_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa) { - switch (sa->spacetype) { + ScrArea *area = CTX_wm_area(C); + if (area) { + switch (area->spacetype) { case SPACE_CLIP: return ED_space_clip_maskedit_poll(C); case SPACE_SEQ: @@ -60,9 +60,9 @@ bool ED_maskedit_poll(bContext *C) bool ED_maskedit_mask_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa) { - switch (sa->spacetype) { + ScrArea *area = CTX_wm_area(C); + if (area) { + switch (area->spacetype) { case SPACE_CLIP: return ED_space_clip_maskedit_mask_poll(C); case SPACE_SEQ: diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index c4e3763dd94..a0ece69bf17 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -55,16 +55,16 @@ Mask *ED_mask_new(bContext *C, const char *name) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Main *bmain = CTX_data_main(C); Mask *mask; mask = BKE_mask_new(bmain, name); - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_space_clip_set_mask(C, sc, mask); break; } @@ -73,7 +73,7 @@ Mask *ED_mask_new(bContext *C, const char *name) break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_space_image_set_mask(C, sima, mask); break; } @@ -260,7 +260,7 @@ static bool spline_under_mouse_get(const bContext *C, MaskSpline **r_mask_spline) { const float threshold = 19.0f; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float pixel_co[2]; @@ -270,7 +270,7 @@ static bool spline_under_mouse_get(const bContext *C, bool undistort = false; *r_mask_layer = NULL; *r_mask_spline = NULL; - ED_mask_get_size(sa, &width, &height); + ED_mask_get_size(area, &width, &height); pixel_co[0] = co[0] * width; pixel_co[1] = co[1] * height; if (sc != NULL) { @@ -420,7 +420,7 @@ static void check_sliding_handle_type(MaskSplinePoint *point, eMaskWhichHandle w static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); @@ -435,8 +435,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent * const float threshold = 19; eMaskWhichHandle which_handle; - ED_mask_mouse_pos(sa, region, event->mval, co); - ED_mask_get_size(sa, &width, &height); + ED_mask_mouse_pos(area, region, event->mval, co); + ED_mask_get_size(area, &width, &height); cv_point = ED_mask_point_find_nearest( C, mask, co, threshold, &cv_mask_layer, &cv_spline, &which_handle, &cv_score); @@ -534,7 +534,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent * } customdata->which_handle = which_handle; - ED_mask_mouse_pos(sa, region, event->mval, customdata->prev_mouse_coord); + ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord); } return customdata; @@ -658,11 +658,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_FALLTHROUGH; /* update CV position */ case MOUSEMOVE: { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float delta[2]; - ED_mask_mouse_pos(sa, region, event->mval, co); + ED_mask_mouse_pos(area, region, event->mval, co); sub_v2_v2v2(delta, co, data->prev_mouse_coord); if (data->is_accurate) { mul_v2_fl(delta, 0.2f); diff --git a/source/blender/editors/mask/mask_query.c b/source/blender/editors/mask/mask_query.c index 6b1bb0a08e2..cf5997d8a18 100644 --- a/source/blender/editors/mask/mask_query.c +++ b/source/blender/editors/mask/mask_query.c @@ -61,7 +61,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, float *r_u, float *r_score) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); MaskLayer *point_mask_layer; @@ -75,8 +75,8 @@ bool ED_mask_find_nearest_diff_point(const bContext *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); - ED_mask_pixelspace_factor(sa, region, &scalex, &scaley); + ED_mask_get_size(area, &width, &height); + ED_mask_pixelspace_factor(area, region, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -219,7 +219,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, eMaskWhichHandle *r_which_handle, float *r_score) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); MaskLayer *point_mask_layer = NULL; @@ -234,8 +234,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *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); - ED_mask_pixelspace_factor(sa, region, &scalex, &scaley); + ED_mask_get_size(area, &width, &height); + ED_mask_pixelspace_factor(area, region, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -374,7 +374,7 @@ bool ED_mask_feather_find_nearest(const bContext *C, MaskSplinePointUW **r_uw, float *r_score) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); MaskLayer *point_mask_layer = NULL; @@ -389,8 +389,8 @@ bool ED_mask_feather_find_nearest(const bContext *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); - ED_mask_pixelspace_factor(sa, region, &scalex, &scaley); + ED_mask_get_size(area, &width, &height); + ED_mask_pixelspace_factor(area, region, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -490,12 +490,12 @@ bool ED_mask_feather_find_nearest(const bContext *C, } /* takes event->mval */ -void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co[2]) +void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float co[2]) { - if (sa) { - switch (sa->spacetype) { + if (area) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_clip_mouse_pos(sc, region, mval, co); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; @@ -505,7 +505,7 @@ void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_image_mouse_pos(sima, region, mval, co); BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co); break; @@ -525,14 +525,14 @@ void ED_mask_mouse_pos(ScrArea *sa, ARegion *region, const int mval[2], float co /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr) { float co[2]; - if (sa) { - switch (sa->spacetype) { + if (area) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_clip_point_stable_pos(sc, region, x, y, &co[0], &co[1]); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; @@ -541,7 +541,7 @@ void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr zero_v2(co); /* MASKTODO */ break; case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_image_point_pos(sima, region, x, y, &co[0], &co[1]); BKE_mask_coord_from_image(sima->image, &sima->iuser, co, co); break; @@ -563,14 +563,14 @@ void ED_mask_point_pos(ScrArea *sa, ARegion *region, float x, float y, float *xr } void ED_mask_point_pos__reverse( - ScrArea *sa, ARegion *region, float x, float y, float *xr, float *yr) + ScrArea *area, ARegion *region, float x, float y, float *xr, float *yr) { float co[2]; - if (sa) { - switch (sa->spacetype) { + if (area) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); @@ -581,7 +581,7 @@ void ED_mask_point_pos__reverse( zero_v2(co); /* MASKTODO */ break; case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; co[0] = x; co[1] = y; BKE_mask_coord_to_image(sima->image, &sima->iuser, co, co); @@ -659,12 +659,12 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2]) /** \name Generic 2D View Queries * \{ */ -void ED_mask_get_size(ScrArea *sa, int *width, int *height) +void ED_mask_get_size(ScrArea *area, int *width, int *height) { - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_space_clip_get_size(sc, width, height); break; } @@ -675,7 +675,7 @@ void ED_mask_get_size(ScrArea *sa, int *width, int *height) break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_space_image_get_size(sima, width, height); break; } @@ -694,12 +694,12 @@ void ED_mask_get_size(ScrArea *sa, int *width, int *height) } } -void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy) +void ED_mask_zoom(ScrArea *area, ARegion *region, float *zoomx, float *zoomy) { - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_space_clip_get_zoom(sc, region, zoomx, zoomy); break; } @@ -708,7 +708,7 @@ void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy) break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_space_image_get_zoom(sima, region, zoomx, zoomy); break; } @@ -725,12 +725,12 @@ void ED_mask_zoom(ScrArea *sa, ARegion *region, float *zoomx, float *zoomy) } } -void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float *aspy) +void ED_mask_get_aspect(ScrArea *area, ARegion *UNUSED(region), float *aspx, float *aspy) { - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; ED_space_clip_get_aspect(sc, aspx, aspy); break; } @@ -739,7 +739,7 @@ void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ED_space_image_get_aspect(sima, aspx, aspy); break; } @@ -756,12 +756,12 @@ void ED_mask_get_aspect(ScrArea *sa, ARegion *UNUSED(region), float *aspx, float } } -void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(ScrArea *area, ARegion *region, float *scalex, float *scaley) { - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; float aspx, aspy; UI_view2d_scale_get(®ion->v2d, scalex, scaley); @@ -776,7 +776,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, floa break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; float aspx, aspy; UI_view2d_scale_get(®ion->v2d, scalex, scaley); @@ -799,12 +799,12 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *region, float *scalex, floa } } -void ED_mask_cursor_location_get(ScrArea *sa, float cursor[2]) +void ED_mask_cursor_location_get(ScrArea *area, float cursor[2]) { - if (sa) { - switch (sa->spacetype) { + if (area) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *space_clip = sa->spacedata.first; + SpaceClip *space_clip = area->spacedata.first; copy_v2_v2(cursor, space_clip->cursor); break; } @@ -813,7 +813,7 @@ void ED_mask_cursor_location_get(ScrArea *sa, float cursor[2]) break; } case SPACE_IMAGE: { - SpaceImage *space_image = sa->spacedata.first; + SpaceImage *space_image = area->spacedata.first; copy_v2_v2(cursor, space_image->cursor); break; } diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index b21d20b360a..12d8a9005a9 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -385,12 +385,12 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); float co[2]; - ED_mask_mouse_pos(sa, region, event->mval, co); + ED_mask_mouse_pos(area, region, event->mval, co); RNA_float_set_array(op->ptr, "location", co); @@ -435,7 +435,7 @@ void MASK_OT_select(wmOperatorType *ot) static int box_select_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); @@ -454,8 +454,8 @@ static int box_select_exec(bContext *C, wmOperator *op) /* get rectangle from operator */ WM_operator_properties_border_to_rcti(op, &rect); - ED_mask_point_pos(sa, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - ED_mask_point_pos(sa, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + ED_mask_point_pos(area, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); + ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); /* do actual selection */ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { @@ -525,7 +525,7 @@ static bool do_lasso_select_mask(bContext *C, short moves, const eSelectOp sel_op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); @@ -565,7 +565,7 @@ static bool do_lasso_select_mask(bContext *C, float screen_co[2]; /* point in screen coords */ - ED_mask_point_pos__reverse(sa, + ED_mask_point_pos__reverse(area, region, point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1], @@ -651,7 +651,7 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt, static int circle_select_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); @@ -667,14 +667,14 @@ static int circle_select_exec(bContext *C, wmOperator *op) const int radius = RNA_int_get(op->ptr, "radius"); /* compute ellipse and position in unified coordinates */ - ED_mask_get_size(sa, &width, &height); - ED_mask_zoom(sa, region, &zoomx, &zoomy); + ED_mask_get_size(area, &width, &height); + ED_mask_zoom(area, region, &zoomx, &zoomy); width = height = max_ii(width, height); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; - ED_mask_point_pos(sa, region, x, y, &offset[0], &offset[1]); + ED_mask_point_pos(area, region, x, y, &offset[0], &offset[1]); const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"), WM_gesture_is_modal_first(op->customdata)); @@ -748,7 +748,7 @@ void MASK_OT_select_circle(wmOperatorType *ot) static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); @@ -760,7 +760,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE const float threshold = 19; bool changed = false; - ED_mask_mouse_pos(sa, region, event->mval, co); + ED_mask_mouse_pos(area, region, event->mval, co); point = ED_mask_point_find_nearest(C, mask, co, threshold, &mask_layer, &spline, NULL, NULL); diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index e91aaea91e0..e94412233ff 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -416,10 +416,10 @@ static bool edbm_bevel_calc(wmOperator *op) static void edbm_bevel_exit(bContext *C, wmOperator *op) { BevelData *opdata = op->customdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (sa) { - ED_area_status_text(sa, NULL); + if (area) { + ED_area_status_text(area, NULL); } for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index f2983f06da6..2eeada95eda 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -88,10 +88,10 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) "(%s)"); char msg[UI_MAX_DRAW_STR]; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *sce = CTX_data_scene(C); - if (sa) { + if (area) { char flts_str[NUM_STR_REP_LEN * 2]; if (hasNumInput(&opdata->num_input)) { outputNumInput(&opdata->num_input, flts_str, &sce->unit); @@ -111,7 +111,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")), WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))); - ED_area_status_text(sa, msg); + ED_area_status_text(area, msg); } } @@ -189,7 +189,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) static void edbm_inset_exit(bContext *C, wmOperator *op) { InsetData *opdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); opdata = op->customdata; @@ -206,8 +206,8 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) G.moving = 0; } - if (sa) { - ED_area_status_text(sa, NULL); + if (area) { + ED_area_status_text(area, NULL); } MEM_SAFE_FREE(opdata->ob_store); diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 481d5dfb9a5..b6838f5d7af 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -116,7 +116,7 @@ typedef struct BakeAPIRender { short *do_update; /* for redrawing */ - ScrArea *sa; + ScrArea *area; } BakeAPIRender; /* callbacks */ @@ -161,10 +161,10 @@ static int bake_break(void *UNUSED(rjv)) return 0; } -static void bake_update_image(ScrArea *sa, Image *image) +static void bake_update_image(ScrArea *area, Image *image) { - if (sa && sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */ - SpaceImage *sima = sa->spacedata.first; + if (area && area->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */ + SpaceImage *sima = area->spacedata.first; if (sima) { sima->image = image; } @@ -743,7 +743,7 @@ static int bake(Render *re, const int width, const int height, const char *identifier, - ScrArea *sa, + ScrArea *area, const char *uv_layer) { /* We build a depsgraph for the baking, @@ -1146,7 +1146,7 @@ static int bake(Render *re, is_noncolor); /* might be read by UI to set active image for display */ - bake_update_image(sa, bk_image->image); + bake_update_image(area, bk_image->image); if (!ok) { BKE_reportf(reports, @@ -1289,7 +1289,7 @@ static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr) bkr->main = CTX_data_main(C); bkr->view_layer = CTX_data_view_layer(C); bkr->scene = CTX_data_scene(C); - bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; + bkr->area = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; bkr->pass_type = RNA_enum_get(op->ptr, "type"); bkr->pass_filter = RNA_enum_get(op->ptr, "pass_filter"); @@ -1400,7 +1400,7 @@ static int bake_exec(bContext *C, wmOperator *op) bkr.width, bkr.height, bkr.identifier, - bkr.sa, + bkr.area, bkr.uv_layer); } else { @@ -1432,7 +1432,7 @@ static int bake_exec(bContext *C, wmOperator *op) bkr.width, bkr.height, bkr.identifier, - bkr.sa, + bkr.area, bkr.uv_layer); } } @@ -1501,7 +1501,7 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa bkr->width, bkr->height, bkr->identifier, - bkr->sa, + bkr->area, bkr->uv_layer); } else { @@ -1533,7 +1533,7 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa bkr->width, bkr->height, bkr->identifier, - bkr->sa, + bkr->area, bkr->uv_layer); if (bkr->result == OPERATOR_CANCELLED) { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 8a40f65fc8a..75ae0299318 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -135,10 +135,10 @@ bool PE_hair_poll(bContext *C) bool PE_poll_view3d(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - return (PE_poll(C) && (sa && sa->spacetype == SPACE_VIEW3D) && + return (PE_poll(C) && (area && area->spacetype == SPACE_VIEW3D) && (region && region->regiontype == RGN_TYPE_WINDOW)); } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 8a8fd703845..3d87220979b 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -112,7 +112,7 @@ typedef struct RenderJob { ReportList *reports; int orig_layer; int last_layer; - ScrArea *sa; + ScrArea *area; ColorManagedViewSettings view_settings; ColorManagedDisplaySettings display_settings; bool supports_glsl_draw; @@ -543,24 +543,24 @@ static void render_progress_update(void *rjv, float progress) static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, ImageUser *iuser) { wmWindowManager *wm; - ScrArea *first_sa = NULL, *matched_sa = NULL; + ScrArea *first_area = NULL, *matched_area = NULL; /* image window, compo node users */ - for (wm = rj->main->wm.first; wm && matched_sa == NULL; wm = wm->id.next) { /* only 1 wm */ + for (wm = rj->main->wm.first; wm && matched_area == NULL; wm = wm->id.next) { /* only 1 wm */ wmWindow *win; - for (win = wm->windows.first; win && matched_sa == NULL; win = win->next) { + for (win = wm->windows.first; win && matched_area == NULL; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; - // sa->spacedata might be empty when toggling fullscreen mode. + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; + // area->spacedata might be empty when toggling fullscreen mode. if (sima != NULL && sima->image == rj->image) { - if (first_sa == NULL) { - first_sa = sa; + if (first_area == NULL) { + first_area = area; } - if (sa == rj->sa) { - matched_sa = sa; + if (area == rj->area) { + matched_area = area; break; } } @@ -569,12 +569,12 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, } } - if (matched_sa == NULL) { - matched_sa = first_sa; + if (matched_area == NULL) { + matched_area = first_area; } - if (matched_sa) { - SpaceImage *sima = matched_sa->spacedata.first; + if (matched_area) { + SpaceImage *sima = matched_area->spacedata.first; RenderResult *main_rr = RE_AcquireResultRead(rj->re); /* TODO(sergey): is there faster way to get the layer index? */ @@ -689,10 +689,10 @@ static void render_image_restore_layer(RenderJob *rj) for (win = wm->windows.first; win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa == rj->sa) { - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area == rj->area) { + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; if (RE_HasSingleLayer(rj->re)) { /* For single layer renders keep the active layer @@ -748,7 +748,7 @@ static void render_endjob(void *rjv) WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene); } - if (rj->sa) { + if (rj->area) { render_image_restore_layer(rj); } @@ -920,7 +920,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL; struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; const char *name; - ScrArea *sa; + ScrArea *area; /* Cannot do render if there is not this function. */ if (re_type->render == NULL) { @@ -970,7 +970,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even // store spare /* ensure at least 1 area shows result */ - sa = render_view_open(C, event->x, event->y, op->reports); + area = render_view_open(C, event->x, event->y, op->reports); /* job custom data */ rj = MEM_callocN(sizeof(RenderJob), "render job"); @@ -991,14 +991,14 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even rj->reports = op->reports; rj->orig_layer = 0; rj->last_layer = 0; - rj->sa = sa; + rj->area = area; rj->supports_glsl_draw = IMB_colormanagement_support_glsl_draw(&scene->view_settings); BKE_color_managed_display_settings_copy(&rj->display_settings, &scene->display_settings); BKE_color_managed_view_settings_copy(&rj->view_settings, &scene->view_settings); - if (sa) { - SpaceImage *sima = sa->spacedata.first; + if (area) { + SpaceImage *sima = area->spacedata.first; rj->orig_layer = sima->iuser.layer; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index fc22e3cd3e0..2c508472a9c 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -566,7 +566,7 @@ static Scene *preview_prepare_scene( /* new UI convention: draw is in pixel space already. */ /* uses UI_BTYPE_ROUNDBOX button in block to get the rect */ -static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, rcti *newrect) +static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect, rcti *newrect) { Render *re; RenderView *rv; @@ -578,10 +578,10 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, bool ok = false; if (!split || first) { - sprintf(name, "Preview %p", (void *)sa); + sprintf(name, "Preview %p", (void *)area); } else { - sprintf(name, "SecondPreview %p", (void *)sa); + sprintf(name, "SecondPreview %p", (void *)area); } if (split) { @@ -661,12 +661,12 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r { if (idp) { wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ID *id = (ID *)idp; ID *parent = (ID *)parentp; MTex *slot = (MTex *)slotp; SpaceProperties *sbuts = CTX_wm_space_properties(C); - ShaderPreview *sp = WM_jobs_customdata(wm, sa); + ShaderPreview *sp = WM_jobs_customdata(wm, area); rcti newrect; int ok; int newx = BLI_rcti_size_x(rect); @@ -678,11 +678,11 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r newrect.ymax = rect->ymin; if (parent) { - ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect); - ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect); + ok = ed_preview_draw_rect(area, 1, 1, rect, &newrect); + ok &= ed_preview_draw_rect(area, 1, 0, rect, &newrect); } else { - ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect); + ok = ed_preview_draw_rect(area, 0, 0, rect, &newrect); } if (ok) { @@ -693,12 +693,12 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r * if no render result was found and no preview render job is running, * or if the job is running and the size of preview changed */ if ((sbuts != NULL && sbuts->preview) || - (!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW)) || + (!ok && !WM_jobs_test(wm, area, WM_JOB_TYPE_RENDER_PREVIEW)) || (sp && (abs(sp->sizex - newx) >= 2 || abs(sp->sizey - newy) > 2))) { if (sbuts != NULL) { sbuts->preview = 0; } - ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER); + ED_preview_shader_job(C, area, id, parent, slot, newx, newy, PR_BUTS_RENDER); } } } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index a0dfa54f8f5..99d9d585a30 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -100,15 +100,15 @@ */ static Object **object_array_for_shading(bContext *C, uint *r_objects_len) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceProperties *sbuts = NULL; View3D *v3d = NULL; - if (sa != NULL) { - if (sa->spacetype == SPACE_PROPERTIES) { - sbuts = sa->spacedata.first; + if (area != NULL) { + if (area->spacetype == SPACE_PROPERTIES) { + sbuts = area->spacedata.first; } - else if (sa->spacetype == SPACE_VIEW3D) { - v3d = sa->spacedata.first; + else if (area->spacetype == SPACE_VIEW3D) { + v3d = area->spacedata.first; } } diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index d2bb53de06f..56b7e2a771d 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -106,17 +106,17 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update for (win = wm->windows.first; win; win = win->next) { bScreen *sc = WM_window_get_active_screen(win); - ScrArea *sa; + ScrArea *area; ARegion *region; CTX_wm_window_set(C, win); - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->spacetype != SPACE_VIEW3D) { + for (area = sc->areabase.first; area; area = area->next) { + if (area->spacetype != SPACE_VIEW3D) { continue; } - View3D *v3d = sa->spacedata.first; - for (region = sa->regionbase.first; region; region = region->next) { + View3D *v3d = area->spacedata.first; + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype != RGN_TYPE_WINDOW) { continue; } @@ -128,7 +128,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { CTX_wm_screen_set(C, sc); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); engine->flag &= ~RE_ENGINE_DO_UPDATE; @@ -146,7 +146,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update .scene = scene, .view_layer = view_layer, .region = region, - .v3d = (View3D *)sa->spacedata.first, + .v3d = (View3D *)area->spacedata.first, .engine_type = engine_type, })); } @@ -160,17 +160,17 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update recursive_check = false; } -void ED_render_engine_area_exit(Main *bmain, ScrArea *sa) +void ED_render_engine_area_exit(Main *bmain, ScrArea *area) { /* clear all render engines in this area */ ARegion *region; wmWindowManager *wm = bmain->wm.first; - if (sa->spacetype != SPACE_VIEW3D) { + if (area->spacetype != SPACE_VIEW3D) { return; } - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype != RGN_TYPE_WINDOW || !(region->regiondata)) { continue; } @@ -182,8 +182,8 @@ void ED_render_engine_changed(Main *bmain) { /* on changing the render engine type, clear all running render engines */ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - ED_render_engine_area_exit(bmain, sa); + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + ED_render_engine_area_exit(bmain, area); } } RE_FreePersistentData(); @@ -206,8 +206,8 @@ void ED_render_engine_changed(Main *bmain) void ED_render_view_layer_changed(Main *bmain, bScreen *sc) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - ED_render_engine_area_exit(bmain, sa); + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + ED_render_engine_area_exit(bmain, area); } } diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index a93ea343229..c0d35938787 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -57,22 +57,22 @@ static ScrArea *biggest_non_image_area(bContext *C) { bScreen *sc = CTX_wm_screen(C); - ScrArea *sa, *big = NULL; + ScrArea *area, *big = NULL; int size, maxsize = 0, bwmaxsize = 0; short foundwin = 0; - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->winx > 30 && sa->winy > 30) { - size = sa->winx * sa->winy; - if (!sa->full && sa->spacetype == SPACE_PROPERTIES) { + for (area = sc->areabase.first; area; area = area->next) { + if (area->winx > 30 && area->winy > 30) { + size = area->winx * area->winy; + if (!area->full && area->spacetype == SPACE_PROPERTIES) { if (foundwin == 0 && size > bwmaxsize) { bwmaxsize = size; - big = sa; + big = area; } } - else if (sa->spacetype != SPACE_IMAGE && size > maxsize) { + else if (area->spacetype != SPACE_IMAGE && size > maxsize) { maxsize = size; - big = sa; + big = area; foundwin = 1; } } @@ -84,7 +84,7 @@ static ScrArea *biggest_non_image_area(bContext *C) static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow **win) { wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = NULL; + ScrArea *area = NULL; SpaceImage *sima; /* find an imagewindow showing render result */ @@ -92,40 +92,40 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow * if (WM_window_get_active_scene(*win) == scene) { const bScreen *screen = WM_window_get_active_screen(*win); - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - sima = sa->spacedata.first; + for (area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + sima = area->spacedata.first; if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) { break; } } } - if (sa) { + if (area) { break; } } } - return sa; + return area; } static ScrArea *find_area_image_empty(bContext *C) { bScreen *sc = CTX_wm_screen(C); - ScrArea *sa; + ScrArea *area; SpaceImage *sima; /* find an imagewindow showing render result */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - sima = sa->spacedata.first; + for (area = sc->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + sima = area->spacedata.first; if ((sima->mode == SI_MODE_VIEW) && !sima->image) { break; } } } - return sa; + return area; } /********************** open image editor for render *************************/ @@ -136,7 +136,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindow *win = NULL; - ScrArea *sa = NULL; + ScrArea *area = NULL; SpaceImage *sima; bool area_was_image = false; @@ -163,34 +163,34 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) return NULL; } - sa = CTX_wm_area(C); - if (BLI_listbase_is_single(&sa->spacedata) == false) { - sima = sa->spacedata.first; + area = CTX_wm_area(C); + if (BLI_listbase_is_single(&area->spacedata) == false) { + sima = area->spacedata.first; sima->flag |= SI_PREVSPACE; } } else if (U.render_display_type == USER_RENDER_DISPLAY_SCREEN) { - sa = CTX_wm_area(C); + area = CTX_wm_area(C); /* if the active screen is already in fullscreen mode, skip this and * unset the area, so that the fullscreen area is just changed later */ - if (sa && sa->full) { - sa = NULL; + if (area && area->full) { + area = NULL; } else { - if (sa && sa->spacetype == SPACE_IMAGE) { + if (area && area->spacetype == SPACE_IMAGE) { area_was_image = true; } /* this function returns with changed context */ - sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE); + area = ED_screen_full_newspace(C, area, SPACE_IMAGE); } } - if (!sa) { - sa = find_area_showing_r_result(C, scene, &win); - if (sa == NULL) { - sa = find_area_image_empty(C); + if (!area) { + area = find_area_showing_r_result(C, scene, &win); + if (area == NULL) { + area = find_area_image_empty(C); } /* if area found in other window, we make that one show in front */ @@ -198,27 +198,27 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) wm_window_raise(win); } - if (sa == NULL) { + if (area == NULL) { /* find largest open non-image area */ - sa = biggest_non_image_area(C); - if (sa) { - ED_area_newspace(C, sa, SPACE_IMAGE, true); - sima = sa->spacedata.first; + area = biggest_non_image_area(C); + if (area) { + ED_area_newspace(C, area, SPACE_IMAGE, true); + sima = area->spacedata.first; /* makes ESC go back to prev space */ sima->flag |= SI_PREVSPACE; /* we already had a fullscreen here -> mark new space as a stacked fullscreen */ - if (sa->full) { - sa->flag |= AREA_FLAG_STACKED_FULLSCREEN; + if (area->full) { + area->flag |= AREA_FLAG_STACKED_FULLSCREEN; } } else { /* use any area of decent size */ - sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0); - if (sa->spacetype != SPACE_IMAGE) { - // XXX newspace(sa, SPACE_IMAGE); - sima = sa->spacedata.first; + area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0); + if (area->spacetype != SPACE_IMAGE) { + // XXX newspace(area, SPACE_IMAGE); + sima = area->spacedata.first; /* makes ESC go back to prev space */ sima->flag |= SI_PREVSPACE; @@ -226,7 +226,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) } } } - sima = sa->spacedata.first; + sima = area->spacedata.first; sima->link_flag |= SPACE_FLAG_TYPE_TEMPORARY; /* get the correct image, and scale it */ @@ -234,7 +234,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) /* If we're rendering to full screen, set appropriate hints on image editor * so it can restore properly on pressing escape. */ - if (sa->full) { + if (area->full) { sima->flag |= SI_FULLWINDOW; /* Tell the image editor to revert to previous space in space list on close @@ -253,7 +253,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) old_sl->link_flag |= SPACE_FLAG_TYPE_WAS_ACTIVE; } - return sa; + return area; } /*************************** cancel render viewer **********************/ @@ -261,11 +261,11 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); - SpaceImage *sima = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + SpaceImage *sima = area->spacedata.first; /* ensure image editor fullscreen and area fullscreen states are in sync */ - if ((sima->flag & SI_FULLWINDOW) && !sa->full) { + if ((sima->flag & SI_FULLWINDOW) && !area->full) { sima->flag &= ~SI_FULLWINDOW; } @@ -275,17 +275,17 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op)) if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; - ED_screen_full_prevspace(C, sa); + ED_screen_full_prevspace(C, area); } else { - ED_area_prevspace(C, sa); + ED_area_prevspace(C, area); } return OPERATOR_FINISHED; } else if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; - ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); + ED_screen_state_toggle(C, win, area, SCREENMAXIMIZED); return OPERATOR_FINISHED; } else if (WM_window_is_temp_screen(win)) { @@ -320,7 +320,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e } else { wmWindow *win, *winshow; - ScrArea *sa = find_area_showing_r_result(C, CTX_data_scene(C), &winshow); + ScrArea *area = find_area_showing_r_result(C, CTX_data_scene(C), &winshow); /* is there another window on current scene showing result? */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { @@ -335,20 +335,20 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e } /* determine if render already shows */ - if (sa) { + if (area) { /* but don't close it when rendering */ if (G.is_rendering == false) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; if (sima->flag & SI_PREVSPACE) { sima->flag &= ~SI_PREVSPACE; if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; - ED_screen_full_prevspace(C, sa); + ED_screen_full_prevspace(C, area); } else { - ED_area_prevspace(C, sa); + ED_area_prevspace(C, area); } } } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index efa98c358df..58e2bb8d037 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -146,7 +146,7 @@ void ED_region_pixelspace(ARegion *region) /* only exported for WM */ void ED_region_do_listen( - wmWindow *win, ScrArea *sa, ARegion *region, wmNotifier *note, const Scene *scene) + wmWindow *win, ScrArea *area, ARegion *region, wmNotifier *note, const Scene *scene) { /* generic notes first */ switch (note->category) { @@ -161,27 +161,27 @@ void ED_region_do_listen( } if (region->type && region->type->listener) { - region->type->listener(win, sa, region, note, scene); + region->type->listener(win, area, region, note, scene); } } /* only exported for WM */ -void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene) +void ED_area_do_listen(wmWindow *win, ScrArea *area, wmNotifier *note, Scene *scene) { /* no generic notes? */ - if (sa->type && sa->type->listener) { - sa->type->listener(win, sa, note, scene); + if (area->type && area->type->listener) { + area->type->listener(win, area, note, scene); } } /* only exported for WM */ -void ED_area_do_refresh(bContext *C, ScrArea *sa) +void ED_area_do_refresh(bContext *C, ScrArea *area) { /* no generic notes? */ - if (sa->type && sa->type->refresh) { - sa->type->refresh(C, sa); + if (area->type && area->type->refresh) { + area->type->refresh(C, area); } - sa->do_refresh = false; + area->do_refresh = false; } /** @@ -294,16 +294,16 @@ static void region_draw_azone_tab_arrow(AZone *az) draw_azone_arrow((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, az->edge); } -static void area_azone_tag_update(ScrArea *sa) +static void area_azone_tag_update(ScrArea *area) { - sa->flag |= AREA_FLAG_ACTIONZONES_UPDATE; + area->flag |= AREA_FLAG_ACTIONZONES_UPDATE; } -static void region_draw_azones(ScrArea *sa, ARegion *region) +static void region_draw_azones(ScrArea *area, ARegion *region) { AZone *az; - if (!sa) { + if (!area) { return; } @@ -315,7 +315,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *region) GPU_matrix_push(); GPU_matrix_translate_2f(-region->winrct.xmin, -region->winrct.ymin); - for (az = sa->actionzones.first; az; az = az->next) { + for (az = area->actionzones.first; az; az = az->next) { /* test if action zone is over this region */ rcti azrct; BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2); @@ -339,7 +339,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *region) } } if (!IS_EQF(az->alpha, 0.0f) && ELEM(az->type, AZONE_FULLSCREEN, AZONE_REGION_SCROLL)) { - area_azone_tag_update(sa); + area_azone_tag_update(area); } } @@ -348,9 +348,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *region) GPU_blend(false); } -static void region_draw_status_text(ScrArea *sa, ARegion *region) +static void region_draw_status_text(ScrArea *area, ARegion *region) { - bool overlap = ED_region_is_overlap(sa->spacetype, region->regiontype); + bool overlap = ED_region_is_overlap(area->spacetype, region->regiontype); if (overlap) { GPU_clear_color(0.0, 0.0, 0.0, 0.0); @@ -421,8 +421,8 @@ void ED_area_do_msg_notify_tag_refresh( wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { - ScrArea *sa = msg_val->user_data; - ED_area_tag_refresh(sa); + ScrArea *area = msg_val->user_data; + ED_area_tag_refresh(area); } void ED_area_do_mgs_subscribe_for_tool_header( @@ -431,7 +431,7 @@ void ED_area_do_mgs_subscribe_for_tool_header( struct WorkSpace *workspace, struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { @@ -451,7 +451,7 @@ void ED_area_do_mgs_subscribe_for_tool_ui( struct WorkSpace *workspace, struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { @@ -483,20 +483,20 @@ static bool area_is_pseudo_minimized(const ScrArea *area) void ED_region_do_layout(bContext *C, ARegion *region) { /* This is optional, only needed for dynamically sized regions. */ - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegionType *at = region->type; if (!at->layout) { return; } - if (at->do_lock || (sa && area_is_pseudo_minimized(sa))) { + if (at->do_lock || (area && area_is_pseudo_minimized(area))) { return; } region->do_draw |= RGN_DRAWING; - UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); + UI_SetTheme(area ? area->spacetype : 0, at->regionid); at->layout(C, region); } @@ -504,7 +504,7 @@ void ED_region_do_layout(bContext *C, ARegion *region) void ED_region_do_draw(bContext *C, ARegion *region) { wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegionType *at = region->type; /* see BKE_spacedata_draw_locks() */ @@ -519,16 +519,16 @@ void ED_region_do_draw(bContext *C, ARegion *region) wmOrtho2_region_pixelspace(region); - UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); + UI_SetTheme(area ? area->spacetype : 0, at->regionid); - if (sa && area_is_pseudo_minimized(sa)) { + if (area && area_is_pseudo_minimized(area)) { UI_ThemeClearColor(TH_EDITOR_OUTLINE); glClear(GL_COLOR_BUFFER_BIT); return; } /* optional header info instead? */ else if (region->headerstr) { - region_draw_status_text(sa, region); + region_draw_status_text(area, region); } else if (at->draw) { at->draw(C, region); @@ -540,7 +540,7 @@ void ED_region_do_draw(bContext *C, ARegion *region) ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_PIXEL); - region_draw_azones(sa, region); + region_draw_azones(area, region); /* for debugging unneeded area redraws and partial redraw */ if (G.debug_value == 888) { @@ -562,11 +562,11 @@ void ED_region_do_draw(bContext *C, ARegion *region) UI_blocklist_free_inactive(C, ®ion->uiblocks); - if (sa) { + if (area) { const bScreen *screen = WM_window_get_active_screen(win); /* Only region emboss for top-bar */ - if ((screen->state != SCREENFULL) && ED_area_is_global(sa)) { + if ((screen->state != SCREENFULL) && ED_area_is_global(area)) { region_draw_emboss(region, ®ion->winrct, (REGION_EMBOSS_LEFT | REGION_EMBOSS_RIGHT)); } else if ((region->regiontype == RGN_TYPE_WINDOW) && (region->alignment == RGN_ALIGN_QSPLIT)) { @@ -604,7 +604,7 @@ void ED_region_do_draw(bContext *C, ARegion *region) */ if (ELEM( region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS, RGN_TYPE_UI, RGN_TYPE_TOOLS)) { - SpaceLink *sl = sa->spacedata.first; + SpaceLink *sl = area->spacedata.first; PointerRNA ptr; RNA_pointer_create(&screen->id, &RNA_Space, sl, &ptr); @@ -618,7 +618,7 @@ void ED_region_do_draw(bContext *C, ARegion *region) WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_region_tag_redraw, __func__); } - ED_region_message_subscribe(C, workspace, scene, screen, sa, region, mbus); + ED_region_message_subscribe(C, workspace, scene, screen, area, region, mbus); } } @@ -705,34 +705,34 @@ void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild } } -void ED_area_tag_redraw(ScrArea *sa) +void ED_area_tag_redraw(ScrArea *area) { ARegion *region; - if (sa) { - for (region = sa->regionbase.first; region; region = region->next) { + if (area) { + for (region = area->regionbase.first; region; region = region->next) { ED_region_tag_redraw(region); } } } -void ED_area_tag_redraw_no_rebuild(ScrArea *sa) +void ED_area_tag_redraw_no_rebuild(ScrArea *area) { ARegion *region; - if (sa) { - for (region = sa->regionbase.first; region; region = region->next) { + if (area) { + for (region = area->regionbase.first; region; region = region->next) { ED_region_tag_redraw_no_rebuild(region); } } } -void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) +void ED_area_tag_redraw_regiontype(ScrArea *area, int regiontype) { ARegion *region; - if (sa) { - for (region = sa->regionbase.first; region; region = region->next) { + if (area) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == regiontype) { ED_region_tag_redraw(region); } @@ -740,26 +740,26 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) } } -void ED_area_tag_refresh(ScrArea *sa) +void ED_area_tag_refresh(ScrArea *area) { - if (sa) { - sa->do_refresh = true; + if (area) { + area->do_refresh = true; } } /* *************************************************************** */ /* use NULL to disable it */ -void ED_area_status_text(ScrArea *sa, const char *str) +void ED_area_status_text(ScrArea *area, const char *str) { ARegion *region; /* happens when running transform operators in background mode */ - if (sa == NULL) { + if (area == NULL) { return; } - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_HEADER) { if (str) { if (region->headerstr == NULL) { @@ -799,9 +799,9 @@ void ED_workspace_status_text(bContext *C, const char *str) } /* Redraw status bar. */ - for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_STATUSBAR) { - ED_area_tag_redraw(sa); + for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_STATUSBAR) { + ED_area_tag_redraw(area); break; } } @@ -809,12 +809,12 @@ void ED_workspace_status_text(bContext *C, const char *str) /* ************************************************************ */ -static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *sa) +static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *area) { AZone *az; /* reinitialize entirely, regions and fullscreen add azones too */ - BLI_freelistN(&sa->actionzones); + BLI_freelistN(&area->actionzones); if (screen->state != SCREENNORMAL) { return; @@ -824,7 +824,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea return; } - if (ED_area_is_global(sa)) { + if (ED_area_is_global(area)) { return; } @@ -834,25 +834,25 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea const float coords[4][4] = { /* Bottom-left. */ - {sa->totrct.xmin - U.pixelsize, - sa->totrct.ymin - U.pixelsize, - sa->totrct.xmin + AZONESPOTW, - sa->totrct.ymin + AZONESPOTH}, + {area->totrct.xmin - U.pixelsize, + area->totrct.ymin - U.pixelsize, + area->totrct.xmin + AZONESPOTW, + area->totrct.ymin + AZONESPOTH}, /* Bottom-right. */ - {sa->totrct.xmax - AZONESPOTW, - sa->totrct.ymin - U.pixelsize, - sa->totrct.xmax + U.pixelsize, - sa->totrct.ymin + AZONESPOTH}, + {area->totrct.xmax - AZONESPOTW, + area->totrct.ymin - U.pixelsize, + area->totrct.xmax + U.pixelsize, + area->totrct.ymin + AZONESPOTH}, /* Top-left. */ - {sa->totrct.xmin - U.pixelsize, - sa->totrct.ymax - AZONESPOTH, - sa->totrct.xmin + AZONESPOTW, - sa->totrct.ymax + U.pixelsize}, + {area->totrct.xmin - U.pixelsize, + area->totrct.ymax - AZONESPOTH, + area->totrct.xmin + AZONESPOTW, + area->totrct.ymax + U.pixelsize}, /* Top-right. */ - {sa->totrct.xmax - AZONESPOTW, - sa->totrct.ymax - AZONESPOTH, - sa->totrct.xmax + U.pixelsize, - sa->totrct.ymax + U.pixelsize}, + {area->totrct.xmax - AZONESPOTW, + area->totrct.ymax - AZONESPOTH, + area->totrct.xmax + U.pixelsize, + area->totrct.ymax + U.pixelsize}, }; for (int i = 0; i < 4; i++) { @@ -869,7 +869,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea /* set area action zones */ az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); - BLI_addtail(&(sa->actionzones), az); + BLI_addtail(&(area->actionzones), az); az->type = AZONE_AREA; az->x1 = coords[i][0]; az->y1 = coords[i][1]; @@ -879,16 +879,16 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea } } -static void fullscreen_azone_initialize(ScrArea *sa, ARegion *region) +static void fullscreen_azone_initialize(ScrArea *area, ARegion *region) { AZone *az; - if (ED_area_is_global(sa) || (region->regiontype != RGN_TYPE_WINDOW)) { + if (ED_area_is_global(area) || (region->regiontype != RGN_TYPE_WINDOW)) { return; } az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone"); - BLI_addtail(&(sa->actionzones), az); + BLI_addtail(&(area->actionzones), az); az->type = AZONE_FULLSCREEN; az->region = region; az->alpha = 0.0f; @@ -942,7 +942,7 @@ static void region_azone_edge(AZone *az, ARegion *region) } /* region already made zero sized, in shape of edge */ -static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region) +static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region) { AZone *azt; int tot = 0, add; @@ -952,7 +952,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region) const float tab_size_x = 0.7f * U.widget_unit; const float tab_size_y = 0.4f * U.widget_unit; - for (azt = sa->actionzones.first; azt; azt = azt->next) { + for (azt = area->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) { tot++; } @@ -960,7 +960,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *region) switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - add = (region->winrct.ymax == sa->totrct.ymin) ? 1 : 0; + add = (region->winrct.ymax == area->totrct.ymin) ? 1 : 0; az->x1 = region->winrct.xmax - ((edge_offset + 1.0f) * tab_size_x); az->y1 = region->winrct.ymax - add; az->x2 = region->winrct.xmax - (edge_offset * tab_size_x); @@ -1003,7 +1003,7 @@ static bool region_azone_edge_poll(const ARegion *region, const bool is_fullscre return true; } -static void region_azone_edge_initialize(ScrArea *sa, +static void region_azone_edge_initialize(ScrArea *area, ARegion *region, AZEdge edge, const bool is_fullscreen) @@ -1016,27 +1016,27 @@ static void region_azone_edge_initialize(ScrArea *sa, } az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); - BLI_addtail(&(sa->actionzones), az); + BLI_addtail(&(area->actionzones), az); az->type = AZONE_REGION; az->region = region; az->edge = edge; if (is_hidden) { - region_azone_tab_plus(sa, az, region); + region_azone_tab_plus(area, az, region); } else { region_azone_edge(az, region); } } -static void region_azone_scrollbar_initialize(ScrArea *sa, +static void region_azone_scrollbar_initialize(ScrArea *area, ARegion *region, AZScrollDirection direction) { rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? region->v2d.vert : region->v2d.hor; AZone *az = MEM_callocN(sizeof(*az), __func__); - BLI_addtail(&sa->actionzones, az); + BLI_addtail(&area->actionzones, az); az->type = AZONE_REGION_SCROLL; az->region = region; az->direction = direction; @@ -1057,21 +1057,21 @@ static void region_azone_scrollbar_initialize(ScrArea *sa, BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } -static void region_azones_scrollbars_initialize(ScrArea *sa, ARegion *region) +static void region_azones_scrollbars_initialize(ScrArea *area, ARegion *region) { const View2D *v2d = ®ion->v2d; if ((v2d->scroll & V2D_SCROLL_VERTICAL) && ((v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) { - region_azone_scrollbar_initialize(sa, region, AZ_SCROLL_VERT); + region_azone_scrollbar_initialize(area, region, AZ_SCROLL_VERT); } if ((v2d->scroll & V2D_SCROLL_HORIZONTAL) && ((v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) == 0)) { - region_azone_scrollbar_initialize(sa, region, AZ_SCROLL_HOR); + region_azone_scrollbar_initialize(area, region, AZ_SCROLL_HOR); } } /* *************************************************************** */ -static void region_azones_add_edge(ScrArea *sa, +static void region_azones_add_edge(ScrArea *area, ARegion *region, const int alignment, const bool is_fullscreen) @@ -1079,20 +1079,20 @@ static void region_azones_add_edge(ScrArea *sa, /* edge code (t b l r) is along which area edge azone will be drawn */ if (alignment == RGN_ALIGN_TOP) { - region_azone_edge_initialize(sa, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); + region_azone_edge_initialize(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); } else if (alignment == RGN_ALIGN_BOTTOM) { - region_azone_edge_initialize(sa, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); + region_azone_edge_initialize(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); } else if (alignment == RGN_ALIGN_RIGHT) { - region_azone_edge_initialize(sa, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen); + region_azone_edge_initialize(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen); } else if (alignment == RGN_ALIGN_LEFT) { - region_azone_edge_initialize(sa, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen); + region_azone_edge_initialize(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen); } } -static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *region) +static void region_azones_add(const bScreen *screen, ScrArea *area, ARegion *region) { const bool is_fullscreen = screen->state == SCREENFULL; @@ -1102,20 +1102,20 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *regio return; } - region_azones_add_edge(sa, region, RGN_ALIGN_ENUM_FROM_MASK(region->alignment), is_fullscreen); + region_azones_add_edge(area, region, RGN_ALIGN_ENUM_FROM_MASK(region->alignment), is_fullscreen); /* For a split region also continue the azone edge from the next region if this region is aligned * with the next */ if ((region->alignment & RGN_SPLIT_PREV) && region->prev) { region_azones_add_edge( - sa, region, RGN_ALIGN_ENUM_FROM_MASK(region->prev->alignment), is_fullscreen); + area, region, RGN_ALIGN_ENUM_FROM_MASK(region->prev->alignment), is_fullscreen); } if (is_fullscreen) { - fullscreen_azone_initialize(sa, region); + fullscreen_azone_initialize(area, region); } - region_azones_scrollbars_initialize(sa, region); + region_azones_scrollbars_initialize(area, region); } /* dir is direction to check, not the splitting edge direction! */ @@ -1133,7 +1133,7 @@ static int rct_fits(const rcti *rect, char dir, int size) /* region should be overlapping */ /* function checks if some overlapping region was defined before - on same place */ -static void region_overlap_fix(ScrArea *sa, ARegion *region) +static void region_overlap_fix(ScrArea *area, ARegion *region) { ARegion *ar1; const int align = RGN_ALIGN_ENUM_FROM_MASK(region->alignment); @@ -1168,7 +1168,7 @@ static void region_overlap_fix(ScrArea *sa, ARegion *region) /* translate or close */ if (ar1) { if (align1 == RGN_ALIGN_LEFT) { - if (region->winrct.xmax + ar1->winx > sa->winx - U.widget_unit) { + if (region->winrct.xmax + ar1->winx > area->winx - U.widget_unit) { region->flag |= RGN_FLAG_TOO_SMALL; return; } @@ -1235,7 +1235,7 @@ bool ED_region_is_overlap(int spacetype, int regiontype) } static void region_rect_recursive( - ScrArea *sa, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad) + ScrArea *area, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad) { rcti *remainder_prev = remainder; @@ -1259,7 +1259,7 @@ static void region_rect_recursive( int alignment = RGN_ALIGN_ENUM_FROM_MASK(region->alignment); /* set here, assuming userpref switching forces to call this again */ - region->overlap = ED_region_is_overlap(sa->spacetype, region->regiontype); + region->overlap = ED_region_is_overlap(area->spacetype, region->regiontype); /* clear state flags first */ region->flag &= ~(RGN_FLAG_TOO_SMALL | RGN_FLAG_SIZE_CLAMP_X | RGN_FLAG_SIZE_CLAMP_Y); @@ -1300,7 +1300,7 @@ static void region_rect_recursive( else if (region->regiontype == RGN_TYPE_FOOTER) { prefsizey = ED_area_footersize(); } - else if (ED_area_is_global(sa)) { + else if (ED_area_is_global(area)) { prefsizey = ED_region_global_size_y(); } else { @@ -1501,7 +1501,7 @@ static void region_rect_recursive( /* exception for multiple overlapping regions on same spot */ if (region->overlap && (alignment != RGN_ALIGN_FLOAT)) { - region_overlap_fix(sa, region); + region_overlap_fix(area, region); } /* set winrect for azones */ @@ -1548,7 +1548,7 @@ static void region_rect_recursive( BLI_assert(BLI_rcti_is_valid(®ion->winrct)); - region_rect_recursive(sa, region->next, remainder, overlap_remainder, quad); + region_rect_recursive(area, region->next, remainder, overlap_remainder, quad); /* Tag for redraw if size changes. */ if (region->winx != prev_winx || region->winy != prev_winy) { @@ -1559,42 +1559,42 @@ static void region_rect_recursive( memset(®ion->runtime.visible_rect, 0, sizeof(region->runtime.visible_rect)); } -static void area_calc_totrct(ScrArea *sa, const rcti *window_rect) +static void area_calc_totrct(ScrArea *area, const rcti *window_rect) { short px = (short)U.pixelsize; - sa->totrct.xmin = sa->v1->vec.x; - sa->totrct.xmax = sa->v4->vec.x; - sa->totrct.ymin = sa->v1->vec.y; - sa->totrct.ymax = sa->v2->vec.y; + area->totrct.xmin = area->v1->vec.x; + area->totrct.xmax = area->v4->vec.x; + area->totrct.ymin = area->v1->vec.y; + area->totrct.ymax = area->v2->vec.y; /* scale down totrct by 1 pixel on all sides not matching window borders */ - if (sa->totrct.xmin > window_rect->xmin) { - sa->totrct.xmin += px; + if (area->totrct.xmin > window_rect->xmin) { + area->totrct.xmin += px; } - if (sa->totrct.xmax < (window_rect->xmax - 1)) { - sa->totrct.xmax -= px; + if (area->totrct.xmax < (window_rect->xmax - 1)) { + area->totrct.xmax -= px; } - if (sa->totrct.ymin > window_rect->ymin) { - sa->totrct.ymin += px; + if (area->totrct.ymin > window_rect->ymin) { + area->totrct.ymin += px; } - if (sa->totrct.ymax < (window_rect->ymax - 1)) { - sa->totrct.ymax -= px; + if (area->totrct.ymax < (window_rect->ymax - 1)) { + area->totrct.ymax -= px; } /* Although the following asserts are correct they lead to a very unstable Blender. * And the asserts would fail even in 2.7x * (they were added in 2.8x as part of the top-bar commit). * For more details see T54864. */ #if 0 - BLI_assert(sa->totrct.xmin >= 0); - BLI_assert(sa->totrct.xmax >= 0); - BLI_assert(sa->totrct.ymin >= 0); - BLI_assert(sa->totrct.ymax >= 0); + BLI_assert(area->totrct.xmin >= 0); + BLI_assert(area->totrct.xmax >= 0); + BLI_assert(area->totrct.ymin >= 0); + BLI_assert(area->totrct.ymax >= 0); #endif /* for speedup */ - sa->winx = BLI_rcti_size_x(&sa->totrct) + 1; - sa->winy = BLI_rcti_size_y(&sa->totrct) + 1; + area->winx = BLI_rcti_size_x(&area->totrct) + 1; + area->winy = BLI_rcti_size_y(&area->totrct) + 1; } /* used for area initialize below */ @@ -1617,12 +1617,12 @@ static bool event_in_markers_region(const ARegion *region, const wmEvent *event) } /** - * \param region: Region, may be NULL when adding handlers for \a sa. + * \param region: Region, may be NULL when adding handlers for \a area. */ static void ed_default_handlers( - wmWindowManager *wm, ScrArea *sa, ARegion *region, ListBase *handlers, int flag) + wmWindowManager *wm, ScrArea *area, ARegion *region, ListBase *handlers, int flag) { - BLI_assert(region ? (®ion->handlers == handlers) : (&sa->handlers == handlers)); + BLI_assert(region ? (®ion->handlers == handlers) : (&area->handlers == handlers)); /* note, add-handler checks if it already exists */ @@ -1641,7 +1641,7 @@ static void ed_default_handlers( BLI_assert(®ion->handlers == handlers); if (region->gizmo_map == NULL) { region->gizmo_map = WM_gizmomap_new_from_type( - &(const struct wmGizmoMapType_Params){sa->spacetype, region->type->regionid}); + &(const struct wmGizmoMapType_Params){area->spacetype, region->type->regionid}); } WM_gizmomap_add_handlers(region, region->gizmo_map); } @@ -1668,9 +1668,9 @@ static void ed_default_handlers( } if (flag & ED_KEYMAP_TOOL) { WM_event_add_keymap_handler_dynamic( - ®ion->handlers, WM_event_get_keymap_from_toolsystem_fallback, sa); + ®ion->handlers, WM_event_get_keymap_from_toolsystem_fallback, area); WM_event_add_keymap_handler_dynamic( - ®ion->handlers, WM_event_get_keymap_from_toolsystem, sa); + ®ion->handlers, WM_event_get_keymap_from_toolsystem, area); } if (flag & ED_KEYMAP_FRAMES) { /* frame changing/jumping (for all spaces) */ @@ -1841,7 +1841,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar } /* called in screen_refresh, or screens_init, also area size changes */ -void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) +void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area) { WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); @@ -1850,49 +1850,49 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) rcti rect, overlap_rect; rcti window_rect; - if (ED_area_is_global(sa) && (sa->global->flag & GLOBAL_AREA_IS_HIDDEN)) { + if (ED_area_is_global(area) && (area->global->flag & GLOBAL_AREA_IS_HIDDEN)) { return; } WM_window_rect_calc(win, &window_rect); /* set typedefinitions */ - sa->type = BKE_spacetype_from_id(sa->spacetype); + area->type = BKE_spacetype_from_id(area->spacetype); - if (sa->type == NULL) { - sa->spacetype = SPACE_VIEW3D; - sa->type = BKE_spacetype_from_id(sa->spacetype); + if (area->type == NULL) { + area->spacetype = SPACE_VIEW3D; + area->type = BKE_spacetype_from_id(area->spacetype); } - for (region = sa->regionbase.first; region; region = region->next) { - region->type = BKE_regiontype_from_id_or_first(sa->type, region->regiontype); + for (region = area->regionbase.first; region; region = region->next) { + region->type = BKE_regiontype_from_id_or_first(area->type, region->regiontype); } /* area sizes */ - area_calc_totrct(sa, &window_rect); + area_calc_totrct(area, &window_rect); /* region rect sizes */ - rect = sa->totrct; + rect = area->totrct; overlap_rect = rect; - region_rect_recursive(sa, sa->regionbase.first, &rect, &overlap_rect, 0); - sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE; + region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0); + area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE; /* default area handlers */ - ed_default_handlers(wm, sa, NULL, &sa->handlers, sa->type->keymapflag); + ed_default_handlers(wm, area, NULL, &area->handlers, area->type->keymapflag); /* checks spacedata, adds own handlers */ - if (sa->type->init) { - sa->type->init(wm, sa); + if (area->type->init) { + area->type->init(wm, area); } /* clear all azones, add the area triangle widgets */ - area_azone_initialize(win, screen, sa); + area_azone_initialize(win, screen, area); /* region windows, default and own handlers */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { region_subwindow(region); if (region->visible) { /* default region handlers */ - ed_default_handlers(wm, sa, region, ®ion->handlers, region->type->keymapflag); + ed_default_handlers(wm, area, region, ®ion->handlers, region->type->keymapflag); /* own handlers */ if (region->type->init) { region->type->init(wm, region); @@ -1904,18 +1904,18 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } /* Some AZones use View2D data which is only updated in region init, so call that first! */ - region_azones_add(screen, sa, region); + region_azones_add(screen, area, region); } /* Avoid re-initializing tools while resizing the window. */ if ((G.moving & G_TRANSFORM_WM) == 0) { - if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { - WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); - sa->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE; + if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { + WM_toolsystem_refresh_screen_area(workspace, view_layer, area); + area->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE; } else { - sa->runtime.tool = NULL; - sa->runtime.is_tool_set = true; + area->runtime.tool = NULL; + area->runtime.is_tool_set = true; } } } @@ -1948,19 +1948,19 @@ void ED_region_floating_initialize(ARegion *region) region_update_rect(region); } -void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *region) +void ED_region_cursor_set(wmWindow *win, ScrArea *area, ARegion *region) { if (region != NULL) { if ((region->gizmo_map != NULL) && WM_gizmomap_cursor_set(region->gizmo_map, win)) { return; } - if (sa && region->type && region->type->cursor) { - region->type->cursor(win, sa, region); + if (area && region->type && region->type->cursor) { + region->type->cursor(win, area, region); return; } } - if (WM_cursor_set_from_tool(win, sa, region)) { + if (WM_cursor_set_from_tool(win, area, region)) { return; } @@ -1968,29 +1968,29 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *region) } /* for use after changing visibility of regions */ -void ED_region_visibility_change_update(bContext *C, ScrArea *sa, ARegion *region) +void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *region) { if (region->flag & RGN_FLAG_HIDDEN) { WM_event_remove_handlers(C, ®ion->handlers); } - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), area); + ED_area_tag_redraw(area); } /* for quick toggle, can skip fades */ void region_toggle_hidden(bContext *C, ARegion *region, const bool do_fade) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); region->flag ^= RGN_FLAG_HIDDEN; if (do_fade && region->overlap) { /* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */ - ED_region_visibility_change_update_animated(C, sa, region); + ED_region_visibility_change_update_animated(C, area, region); } else { - ED_region_visibility_change_update(C, sa, region); + ED_region_visibility_change_update(C, area, region); } } @@ -2003,48 +2003,48 @@ void ED_region_toggle_hidden(bContext *C, ARegion *region) /** * we swap spaces for fullscreen to keep all allocated data area vertices were set */ -void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free) +void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free) { SpaceType *st; ARegion *region; - const char spacetype = sa_dst->spacetype; + const char spacetype = area_dst->spacetype; const short flag_copy = HEADER_NO_PULLDOWN; - sa_dst->spacetype = sa_src->spacetype; - sa_dst->type = sa_src->type; + area_dst->spacetype = area_src->spacetype; + area_dst->type = area_src->type; - sa_dst->flag = (sa_dst->flag & ~flag_copy) | (sa_src->flag & flag_copy); + area_dst->flag = (area_dst->flag & ~flag_copy) | (area_src->flag & flag_copy); /* area */ if (do_free) { - BKE_spacedata_freelist(&sa_dst->spacedata); + BKE_spacedata_freelist(&area_dst->spacedata); } - BKE_spacedata_copylist(&sa_dst->spacedata, &sa_src->spacedata); + BKE_spacedata_copylist(&area_dst->spacedata, &area_src->spacedata); /* Note; SPACE_EMPTY is possible on new screens */ /* regions */ if (do_free) { st = BKE_spacetype_from_id(spacetype); - for (region = sa_dst->regionbase.first; region; region = region->next) { + for (region = area_dst->regionbase.first; region; region = region->next) { BKE_area_region_free(st, region); } - BLI_freelistN(&sa_dst->regionbase); + BLI_freelistN(&area_dst->regionbase); } - st = BKE_spacetype_from_id(sa_src->spacetype); - for (region = sa_src->regionbase.first; region; region = region->next) { + st = BKE_spacetype_from_id(area_src->spacetype); + for (region = area_src->regionbase.first; region; region = region->next) { ARegion *newar = BKE_area_region_copy(st, region); - BLI_addtail(&sa_dst->regionbase, newar); + BLI_addtail(&area_dst->regionbase, newar); } } -void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src) +void ED_area_data_swap(ScrArea *area_dst, ScrArea *area_src) { - SWAP(char, sa_dst->spacetype, sa_src->spacetype); - SWAP(SpaceType *, sa_dst->type, sa_src->type); + SWAP(char, area_dst->spacetype, area_src->spacetype); + SWAP(SpaceType *, area_dst->type, area_src->type); - SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata); - SWAP(ListBase, sa_dst->regionbase, sa_src->regionbase); + SWAP(ListBase, area_dst->spacedata, area_src->spacedata); + SWAP(ListBase, area_dst->regionbase, area_src->regionbase); } /* *********** Space switching code *********** */ @@ -2078,16 +2078,16 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) /** * \param skip_region_exit: Skip calling area exit callback. Set for opening temp spaces. */ -void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region_exit) +void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_region_exit) { wmWindow *win = CTX_wm_window(C); - if (sa->spacetype != type) { + if (area->spacetype != type) { SpaceType *st; - SpaceLink *slold = sa->spacedata.first; + SpaceLink *slold = area->spacedata.first; SpaceLink *sl; - /* store sa->type->exit callback */ - void *sa_exit = sa->type ? sa->type->exit : NULL; + /* store area->type->exit callback */ + void *area_exit = area->type ? area->type->exit : NULL; /* When the user switches between space-types from the type-selector, * changing the header-type is jarring (especially when using Ctrl-MouseWheel). * @@ -2098,34 +2098,34 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region * the space type defaults to in this case instead * (needed for preferences to have space-type on bottom). */ - int header_alignment = ED_area_header_alignment_or_fallback(sa, -1); + int header_alignment = ED_area_header_alignment_or_fallback(area, -1); const bool sync_header_alignment = ((header_alignment != -1) && ((slold->link_flag & SPACE_FLAG_TYPE_TEMPORARY) == 0)); /* in some cases (opening temp space) we don't want to * call area exit callback, so we temporarily unset it */ - if (skip_region_exit && sa->type) { - sa->type->exit = NULL; + if (skip_region_exit && area->type) { + area->type->exit = NULL; } - ED_area_exit(C, sa); + ED_area_exit(C, area); /* restore old area exit callback */ - if (skip_region_exit && sa->type) { - sa->type->exit = sa_exit; + if (skip_region_exit && area->type) { + area->type->exit = area_exit; } st = BKE_spacetype_from_id(type); - sa->spacetype = type; - sa->type = st; + area->spacetype = type; + area->type = st; /* If st->new may be called, don't use context until then. The - * sa->type->context() callback has changed but data may be invalid + * area->type->context() callback has changed but data may be invalid * (e.g. with properties editor) until space-data is properly created */ /* check previously stored space */ - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == type) { break; } @@ -2134,7 +2134,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region /* old spacedata... happened during work on 2.50, remove */ if (sl && BLI_listbase_is_empty(&sl->regionbase)) { st->free(sl); - BLI_freelinkN(&sa->spacedata, sl); + BLI_freelinkN(&area->spacedata, sl); if (slold == sl) { slold = NULL; } @@ -2143,8 +2143,8 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region if (sl) { /* swap regions */ - slold->regionbase = sa->regionbase; - sa->regionbase = sl->regionbase; + slold->regionbase = area->regionbase; + area->regionbase = sl->regionbase; BLI_listbase_clear(&sl->regionbase); /* SPACE_FLAG_TYPE_WAS_ACTIVE is only used to go back to a previously active space that is * overlapped by temporary ones. It's now properly activated, so the flag should be cleared @@ -2152,22 +2152,22 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region sl->link_flag &= ~SPACE_FLAG_TYPE_WAS_ACTIVE; /* put in front of list */ - BLI_remlink(&sa->spacedata, sl); - BLI_addhead(&sa->spacedata, sl); + BLI_remlink(&area->spacedata, sl); + BLI_addhead(&area->spacedata, sl); } else { /* new space */ if (st) { /* Don't get scene from context here which may depend on space-data. */ Scene *scene = WM_window_get_active_scene(win); - sl = st->new (sa, scene); - BLI_addhead(&sa->spacedata, sl); + sl = st->new (area, scene); + BLI_addhead(&area->spacedata, sl); /* swap regions */ if (slold) { - slold->regionbase = sa->regionbase; + slold->regionbase = area->regionbase; } - sa->regionbase = sl->regionbase; + area->regionbase = sl->regionbase; BLI_listbase_clear(&sl->regionbase); } } @@ -2176,7 +2176,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region if (sync_header_alignment) { /* Spaces with footer. */ if (st->spaceid == SPACE_TEXT) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { region->alignment = header_alignment; } @@ -2189,7 +2189,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region } } else { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { region->alignment = header_alignment; break; @@ -2198,24 +2198,24 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_region } } - ED_area_initialize(CTX_wm_manager(C), win, sa); + ED_area_initialize(CTX_wm_manager(C), win, area); /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(win); /* send space change notifier */ - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, area); - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } /* also redraw when re-used */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } -static SpaceLink *area_get_prevspace(ScrArea *sa) +static SpaceLink *area_get_prevspace(ScrArea *area) { - SpaceLink *sl = sa->spacedata.first; + SpaceLink *sl = area->spacedata.first; /* First toggle to the next temporary space in the list. */ for (SpaceLink *sl_iter = sl->next; sl_iter; sl_iter = sl_iter->next) { @@ -2235,13 +2235,13 @@ static SpaceLink *area_get_prevspace(ScrArea *sa) return sl->next; } -void ED_area_prevspace(bContext *C, ScrArea *sa) +void ED_area_prevspace(bContext *C, ScrArea *area) { - SpaceLink *sl = sa->spacedata.first; - SpaceLink *prevspace = sl ? area_get_prevspace(sa) : NULL; + SpaceLink *sl = area->spacedata.first; + SpaceLink *prevspace = sl ? area_get_prevspace(area) : NULL; if (prevspace) { - ED_area_newspace(C, sa, prevspace->spacetype, false); + ED_area_newspace(C, area, prevspace->spacetype, false); /* We've exited the space, so it can't be considered temporary anymore. */ sl->link_flag &= ~SPACE_FLAG_TYPE_TEMPORARY; } @@ -2251,23 +2251,23 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) } /* If this is a stacked fullscreen, changing to previous area exits it (meaning we're still in a * fullscreen, but not in a stacked one). */ - sa->flag &= ~AREA_FLAG_STACKED_FULLSCREEN; + area->flag &= ~AREA_FLAG_STACKED_FULLSCREEN; - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); /* send space change notifier */ - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, area); } /* returns offset for next button in header */ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bScreen *scr = CTX_wm_screen(C); PointerRNA areaptr; int xco = 0.4 * U.widget_unit; - RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr); + RNA_pointer_create(&(scr->id), &RNA_Area, area, &areaptr); uiDefButR(block, UI_BTYPE_MENU, @@ -2342,7 +2342,7 @@ BLI_INLINE bool streq_array_any(const char *s, const char *arr[]) } static void ed_panel_draw(const bContext *C, - ScrArea *sa, + ScrArea *area, ARegion *region, ListBase *lb, PanelType *pt, @@ -2357,7 +2357,7 @@ static void ed_panel_draw(const bContext *C, uiBlock *block = UI_block_begin(C, region, pt->idname, UI_EMBOSS); bool open; - panel = UI_panel_begin(sa, region, lb, block, pt, panel, &open); + panel = UI_panel_begin(area, region, lb, block, pt, panel, &open); /* bad fixed values */ int xco, yco, h = 0; @@ -2445,12 +2445,12 @@ static void ed_panel_draw(const bContext *C, Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt); if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) { - ed_panel_draw(C, sa, region, &panel->children, child_pt, child_panel, w, em, vertical); + ed_panel_draw(C, area, region, &panel->children, child_pt, child_panel, w, em, vertical); } } } - UI_panel_end(sa, region, block, w, h, open); + UI_panel_end(area, region, block, w, h, open); } /** @@ -2499,7 +2499,7 @@ void ED_region_panels_layout_ex(const bContext *C, region->runtime.category = NULL; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); View2D *v2d = ®ion->v2d; int x, y, w, em; @@ -2508,7 +2508,7 @@ void ED_region_panels_layout_ex(const bContext *C, bool use_category_tabs = (category_override == NULL) && ((((1 << region->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) || (region->regiontype == RGN_TYPE_TOOLS && - sa->spacetype == SPACE_CLIP))); + area->spacetype == SPACE_CLIP))); /* offset panels for small vertical tab area */ const char *category = NULL; const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH; @@ -2584,7 +2584,7 @@ void ED_region_panels_layout_ex(const bContext *C, } } - ed_panel_draw(C, sa, region, ®ion->panels, pt, panel, w, em, vertical); + ed_panel_draw(C, area, region, ®ion->panels, pt, panel, w, em, vertical); } /* align panels and return size */ @@ -2605,7 +2605,7 @@ void ED_region_panels_layout_ex(const bContext *C, if ((region->sizex != size_dyn[0]) || (region->sizey != size_dyn[1])) { region->sizex = size_dyn[0]; region->sizey = size_dyn[1]; - sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE; + area->flag |= AREA_FLAG_REGION_SIZE_UPDATE; } y = fabsf(region->sizey * UI_DPI_FAC - 1); } @@ -2799,10 +2799,10 @@ void ED_region_header_layout(const bContext *C, ARegion *region) if (region_layout_based && (region->sizex != new_sizex)) { /* region size is layout based and needs to be updated */ - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); region->sizex = new_sizex; - sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE; + area->flag |= AREA_FLAG_REGION_SIZE_UPDATE; } UI_block_end(C, block); @@ -3575,7 +3575,7 @@ void ED_region_message_subscribe(bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { @@ -3588,7 +3588,7 @@ void ED_region_message_subscribe(bContext *C, } if (region->type->message_subscribe != NULL) { - region->type->message_subscribe(C, workspace, scene, screen, sa, region, mbus); + region->type->message_subscribe(C, workspace, scene, screen, area, region, mbus); } } diff --git a/source/blender/editors/screen/area_utils.c b/source/blender/editors/screen/area_utils.c index cacd6b1edd7..075759f1120 100644 --- a/source/blender/editors/screen/area_utils.c +++ b/source/blender/editors/screen/area_utils.c @@ -46,7 +46,7 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *UNU struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 5ae1a89ba9b..778a3740622 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -114,7 +114,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult wmWindow *win = CTX_wm_window(C); View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ bScreen *sc = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL; @@ -533,7 +533,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult * That causes the get_active function to fail when called from context. * For that reason, we end up using an alternative where we pass everything in! */ - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); if (gpd) { CTX_data_id_pointer_set(result, &gpd->id); @@ -547,7 +547,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult PointerRNA ptr; /* get pointer to Grease Pencil Data */ - gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, obact, &ptr); + gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr); if (gpd_ptr) { CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); @@ -555,7 +555,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "annotation_data")) { - bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene); + bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, area, scene); if (gpd) { CTX_data_id_pointer_set(result, &gpd->id); @@ -568,7 +568,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult PointerRNA ptr; /* Get pointer to Grease Pencil Data. */ - gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)sc, sa, scene, &ptr); + gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)sc, area, scene, &ptr); if (gpd_ptr) { CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); @@ -576,7 +576,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_gpencil_layer")) { - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -588,7 +588,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_annotation_layer")) { - bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene); + bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, area, scene); if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -600,7 +600,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_gpencil_frame")) { - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -612,7 +612,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "visible_gpencil_layers")) { - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); if (gpd) { bGPDlayer *gpl; @@ -627,7 +627,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "editable_gpencil_layers")) { - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); if (gpd) { bGPDlayer *gpl; @@ -642,7 +642,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "editable_gpencil_strokes")) { - bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact); + bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); if (gpd) { @@ -660,7 +660,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult for (gpf = init_gpf; gpf; gpf = gpf->next) { if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { for (gps = gpf->strokes.first; gps; gps = gps->next) { - if (ED_gpencil_stroke_can_use_direct(sa, gps)) { + if (ED_gpencil_stroke_can_use_direct(area, gps)) { /* check if the color is editable */ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) { continue; diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index dbc7609722c..c1b6df07129 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -41,10 +41,10 @@ * Draw horizontal shape visualizing future joining * (left as well right direction of future joining). */ -static void draw_horizontal_join_shape(ScrArea *sa, char dir, uint pos) +static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) { - const float width = screen_geom_area_width(sa) - 1; - const float height = screen_geom_area_height(sa) - 1; + const float width = screen_geom_area_width(area) - 1; + const float height = screen_geom_area_height(area) - 1; vec2f points[10]; short i; float w, h; @@ -58,43 +58,43 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, uint pos) w = width / 4; } - points[0].x = sa->v1->vec.x; - points[0].y = sa->v1->vec.y + height / 2; + points[0].x = area->v1->vec.x; + points[0].y = area->v1->vec.y + height / 2; - points[1].x = sa->v1->vec.x; - points[1].y = sa->v1->vec.y; + points[1].x = area->v1->vec.x; + points[1].y = area->v1->vec.y; - points[2].x = sa->v4->vec.x - w; - points[2].y = sa->v4->vec.y; + points[2].x = area->v4->vec.x - w; + points[2].y = area->v4->vec.y; - points[3].x = sa->v4->vec.x - w; - points[3].y = sa->v4->vec.y + height / 2 - 2 * h; + points[3].x = area->v4->vec.x - w; + points[3].y = area->v4->vec.y + height / 2 - 2 * h; - points[4].x = sa->v4->vec.x - 2 * w; - points[4].y = sa->v4->vec.y + height / 2; + points[4].x = area->v4->vec.x - 2 * w; + points[4].y = area->v4->vec.y + height / 2; - points[5].x = sa->v4->vec.x - w; - points[5].y = sa->v4->vec.y + height / 2 + 2 * h; + points[5].x = area->v4->vec.x - w; + points[5].y = area->v4->vec.y + height / 2 + 2 * h; - points[6].x = sa->v3->vec.x - w; - points[6].y = sa->v3->vec.y; + points[6].x = area->v3->vec.x - w; + points[6].y = area->v3->vec.y; - points[7].x = sa->v2->vec.x; - points[7].y = sa->v2->vec.y; + points[7].x = area->v2->vec.x; + points[7].y = area->v2->vec.y; - points[8].x = sa->v4->vec.x; - points[8].y = sa->v4->vec.y + height / 2 - h; + points[8].x = area->v4->vec.x; + points[8].y = area->v4->vec.y + height / 2 - h; - points[9].x = sa->v4->vec.x; - points[9].y = sa->v4->vec.y + height / 2 + h; + points[9].x = area->v4->vec.x; + points[9].y = area->v4->vec.y + height / 2 + h; if (dir == 'l') { /* when direction is left, then we flip direction of arrow */ - float cx = sa->v1->vec.x + width; + float cx = area->v1->vec.x + width; for (i = 0; i < 10; i++) { points[i].x -= cx; points[i].x = -points[i].x; - points[i].x += sa->v1->vec.x; + points[i].x += area->v1->vec.x; } } @@ -122,10 +122,10 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, uint pos) /** * Draw vertical shape visualizing future joining (up/down direction). */ -static void draw_vertical_join_shape(ScrArea *sa, char dir, uint pos) +static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) { - const float width = screen_geom_area_width(sa) - 1; - const float height = screen_geom_area_height(sa) - 1; + const float width = screen_geom_area_width(area) - 1; + const float height = screen_geom_area_height(area) - 1; vec2f points[10]; short i; float w, h; @@ -139,43 +139,43 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, uint pos) w = width / 8; } - points[0].x = sa->v1->vec.x + width / 2; - points[0].y = sa->v3->vec.y; + points[0].x = area->v1->vec.x + width / 2; + points[0].y = area->v3->vec.y; - points[1].x = sa->v2->vec.x; - points[1].y = sa->v2->vec.y; + points[1].x = area->v2->vec.x; + points[1].y = area->v2->vec.y; - points[2].x = sa->v1->vec.x; - points[2].y = sa->v1->vec.y + h; + points[2].x = area->v1->vec.x; + points[2].y = area->v1->vec.y + h; - points[3].x = sa->v1->vec.x + width / 2 - 2 * w; - points[3].y = sa->v1->vec.y + h; + points[3].x = area->v1->vec.x + width / 2 - 2 * w; + points[3].y = area->v1->vec.y + h; - points[4].x = sa->v1->vec.x + width / 2; - points[4].y = sa->v1->vec.y + 2 * h; + points[4].x = area->v1->vec.x + width / 2; + points[4].y = area->v1->vec.y + 2 * h; - points[5].x = sa->v1->vec.x + width / 2 + 2 * w; - points[5].y = sa->v1->vec.y + h; + points[5].x = area->v1->vec.x + width / 2 + 2 * w; + points[5].y = area->v1->vec.y + h; - points[6].x = sa->v4->vec.x; - points[6].y = sa->v4->vec.y + h; + points[6].x = area->v4->vec.x; + points[6].y = area->v4->vec.y + h; - points[7].x = sa->v3->vec.x; - points[7].y = sa->v3->vec.y; + points[7].x = area->v3->vec.x; + points[7].y = area->v3->vec.y; - points[8].x = sa->v1->vec.x + width / 2 - w; - points[8].y = sa->v1->vec.y; + points[8].x = area->v1->vec.x + width / 2 - w; + points[8].y = area->v1->vec.y; - points[9].x = sa->v1->vec.x + width / 2 + w; - points[9].y = sa->v1->vec.y; + points[9].x = area->v1->vec.x + width / 2 + w; + points[9].y = area->v1->vec.y; if (dir == 'u') { /* when direction is up, then we flip direction of arrow */ - float cy = sa->v1->vec.y + height; + float cy = area->v1->vec.y + height; for (i = 0; i < 10; i++) { points[i].y -= cy; points[i].y = -points[i].y; - points[i].y += sa->v1->vec.y; + points[i].y += area->v1->vec.y; } } @@ -203,13 +203,13 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, uint pos) /** * Draw join shape due to direction of joining. */ -static void draw_join_shape(ScrArea *sa, char dir, uint pos) +static void draw_join_shape(ScrArea *area, char dir, uint pos) { if (dir == 'u' || dir == 'd') { - draw_vertical_join_shape(sa, dir, pos); + draw_vertical_join_shape(area, dir, pos); } else { - draw_horizontal_join_shape(sa, dir, pos); + draw_horizontal_join_shape(area, dir, pos); } } @@ -294,26 +294,26 @@ static GPUBatch *batch_screen_edges_get(int *corner_len) /** * Draw screen area darker with arrow (visualization of future joining). */ -static void scrarea_draw_shape_dark(ScrArea *sa, char dir, uint pos) +static void scrarea_draw_shape_dark(ScrArea *area, char dir, uint pos) { GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immUniformColor4ub(0, 0, 0, 50); - draw_join_shape(sa, dir, pos); + draw_join_shape(area, dir, pos); } /** * Draw screen area lighter with arrow shape ("eraser" of previous dark shape). */ -static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), uint pos) +static void scrarea_draw_shape_light(ScrArea *area, char UNUSED(dir), uint pos) { GPU_blend_set_func(GPU_DST_COLOR, GPU_SRC_ALPHA); /* value 181 was hardly computed: 181~105 */ immUniformColor4ub(255, 255, 255, 50); - /* draw_join_shape(sa, dir); */ + /* draw_join_shape(area, dir); */ - immRectf(pos, sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y); + immRectf(pos, area->v1->vec.x, area->v1->vec.y, area->v3->vec.x, area->v3->vec.y); } static void drawscredge_area_draw( @@ -350,12 +350,12 @@ static void drawscredge_area_draw( /** * \brief Screen edges drawing. */ -static void drawscredge_area(ScrArea *sa, int sizex, int sizey, float edge_thickness) +static void drawscredge_area(ScrArea *area, int sizex, int sizey, float edge_thickness) { - short x1 = sa->v1->vec.x; - short y1 = sa->v1->vec.y; - short x2 = sa->v3->vec.x; - short y2 = sa->v3->vec.y; + short x1 = area->v1->vec.x; + short y1 = area->v1->vec.y; + short x2 = area->v3->vec.x; + short y2 = area->v3->vec.y; drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, edge_thickness); } @@ -381,13 +381,13 @@ void ED_screen_draw_edges(wmWindow *win) float col[4], corner_scale, edge_thickness; int verts_per_corner = 0; - ScrArea *sa; + ScrArea *area; rcti scissor_rect; BLI_rcti_init_minmax(&scissor_rect); - for (sa = screen->areabase.first; sa; sa = sa->next) { - BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){sa->v1->vec.x, sa->v1->vec.y}); - BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){sa->v3->vec.x, sa->v3->vec.y}); + for (area = screen->areabase.first; area; area = area->next) { + BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v1->vec.x, area->v1->vec.y}); + BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v3->vec.x, area->v3->vec.y}); } if (GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_UNIX, GPU_DRIVER_ANY)) { @@ -422,8 +422,8 @@ void ED_screen_draw_edges(wmWindow *win) GPU_batch_uniform_1f(batch, "scale", corner_scale); GPU_batch_uniform_4fv(batch, "color", col); - for (sa = screen->areabase.first; sa; sa = sa->next) { - drawscredge_area(sa, winsize_x, winsize_y, edge_thickness); + for (area = screen->areabase.first; area; area = area->next) { + drawscredge_area(area, winsize_x, winsize_y, edge_thickness); } GPU_blend(false); @@ -480,7 +480,7 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) immUnbindProgram(); } -void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) +void ED_screen_draw_split_preview(ScrArea *area, const int dir, const float fac) { uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -495,10 +495,10 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immBegin(GPU_PRIM_LINES, 2); if (dir == 'h') { - const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax; + const float y = (1 - fac) * area->totrct.ymin + fac * area->totrct.ymax; - immVertex2f(pos, sa->totrct.xmin, y); - immVertex2f(pos, sa->totrct.xmax, y); + immVertex2f(pos, area->totrct.xmin, y); + immVertex2f(pos, area->totrct.xmax, y); immEnd(); @@ -506,17 +506,17 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immBegin(GPU_PRIM_LINES, 2); - immVertex2f(pos, sa->totrct.xmin, y + 1); - immVertex2f(pos, sa->totrct.xmax, y + 1); + immVertex2f(pos, area->totrct.xmin, y + 1); + immVertex2f(pos, area->totrct.xmax, y + 1); immEnd(); } else { BLI_assert(dir == 'v'); - const float x = (1 - fac) * sa->totrct.xmin + fac * sa->totrct.xmax; + const float x = (1 - fac) * area->totrct.xmin + fac * area->totrct.xmax; - immVertex2f(pos, x, sa->totrct.ymin); - immVertex2f(pos, x, sa->totrct.ymax); + immVertex2f(pos, x, area->totrct.ymin); + immVertex2f(pos, x, area->totrct.ymax); immEnd(); @@ -524,8 +524,8 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immBegin(GPU_PRIM_LINES, 2); - immVertex2f(pos, x + 1, sa->totrct.ymin); - immVertex2f(pos, x + 1, sa->totrct.ymax); + immVertex2f(pos, x + 1, area->totrct.ymin); + immVertex2f(pos, x + 1, area->totrct.ymax); immEnd(); } @@ -547,9 +547,9 @@ static void screen_preview_scale_get( { float max_x = 0, max_y = 0; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - max_x = MAX2(max_x, sa->totrct.xmax); - max_y = MAX2(max_y, sa->totrct.ymax); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + max_x = MAX2(max_x, area->totrct.xmax); + max_y = MAX2(max_y, area->totrct.ymax); } r_scale[0] = (size_x * asp[0]) / max_x; r_scale[1] = (size_y * asp[1]) / max_y; @@ -566,12 +566,12 @@ static void screen_preview_draw_areas(const bScreen *screen, immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { rctf rect = { - .xmin = sa->totrct.xmin * scale[0] + ofs_h, - .xmax = sa->totrct.xmax * scale[0] - ofs_h, - .ymin = sa->totrct.ymin * scale[1] + ofs_h, - .ymax = sa->totrct.ymax * scale[1] - ofs_h, + .xmin = area->totrct.xmin * scale[0] + ofs_h, + .xmax = area->totrct.xmax * scale[0] - ofs_h, + .ymin = area->totrct.ymin * scale[1] + ofs_h, + .ymax = area->totrct.ymax * scale[1] - ofs_h, }; immBegin(GPU_PRIM_TRI_FAN, 4); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 01a30f7d6a4..11a12452ce3 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -70,17 +70,17 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map, ScrVert *bottom_right, short spacetype) { - ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea"); + ScrArea *area = MEM_callocN(sizeof(ScrArea), "addscrarea"); - sa->v1 = bottom_left; - sa->v2 = top_left; - sa->v3 = top_right; - sa->v4 = bottom_right; - sa->spacetype = spacetype; + area->v1 = bottom_left; + area->v2 = top_left; + area->v3 = top_right; + area->v4 = bottom_right; + area->spacetype = spacetype; - BLI_addtail(&area_map->areabase, sa); + BLI_addtail(&area_map->areabase, area); - return sa; + return area; } static ScrArea *screen_addarea(bScreen *sc, ScrVert *left_bottom, @@ -93,31 +93,32 @@ static ScrArea *screen_addarea(bScreen *sc, AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom, spacetype); } -static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa) +static void screen_delarea(bContext *C, bScreen *sc, ScrArea *area) { - ED_area_exit(C, sa); + ED_area_exit(C, area); - BKE_screen_area_free(sa); + BKE_screen_area_free(area); - BLI_remlink(&sc->areabase, sa); - MEM_freeN(sa); + BLI_remlink(&sc->areabase, area); + MEM_freeN(area); } -ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge) +ScrArea *area_split( + const wmWindow *win, bScreen *sc, ScrArea *area, char dir, float fac, int merge) { ScrArea *newa = NULL; ScrVert *sv1, *sv2; short split; rcti window_rect; - if (sa == NULL) { + if (area == NULL) { return NULL; } WM_window_rect_calc(win, &window_rect); - split = screen_geom_find_area_split_point(sa, &window_rect, dir, fac); + split = screen_geom_find_area_split_point(area, &window_rect, dir, fac); if (split == 0) { return NULL; } @@ -128,65 +129,65 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo if (dir == 'h') { /* new vertices */ - sv1 = screen_geom_vertex_add(sc, sa->v1->vec.x, split); - sv2 = screen_geom_vertex_add(sc, sa->v4->vec.x, split); + sv1 = screen_geom_vertex_add(sc, area->v1->vec.x, split); + sv2 = screen_geom_vertex_add(sc, area->v4->vec.x, split); /* new edges */ - screen_geom_edge_add(sc, sa->v1, sv1); - screen_geom_edge_add(sc, sv1, sa->v2); - screen_geom_edge_add(sc, sa->v3, sv2); - screen_geom_edge_add(sc, sv2, sa->v4); + screen_geom_edge_add(sc, area->v1, sv1); + screen_geom_edge_add(sc, sv1, area->v2); + screen_geom_edge_add(sc, area->v3, sv2); + screen_geom_edge_add(sc, sv2, area->v4); screen_geom_edge_add(sc, sv1, sv2); if (fac > 0.5f) { /* new areas: top */ - newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->spacetype); + newa = screen_addarea(sc, sv1, area->v2, area->v3, sv2, area->spacetype); /* area below */ - sa->v2 = sv1; - sa->v3 = sv2; + area->v2 = sv1; + area->v3 = sv2; } else { /* new areas: bottom */ - newa = screen_addarea(sc, sa->v1, sv1, sv2, sa->v4, sa->spacetype); + newa = screen_addarea(sc, area->v1, sv1, sv2, area->v4, area->spacetype); /* area above */ - sa->v1 = sv1; - sa->v4 = sv2; + area->v1 = sv1; + area->v4 = sv2; } - ED_area_data_copy(newa, sa, true); + ED_area_data_copy(newa, area, true); } else { /* new vertices */ - sv1 = screen_geom_vertex_add(sc, split, sa->v1->vec.y); - sv2 = screen_geom_vertex_add(sc, split, sa->v2->vec.y); + sv1 = screen_geom_vertex_add(sc, split, area->v1->vec.y); + sv2 = screen_geom_vertex_add(sc, split, area->v2->vec.y); /* new edges */ - screen_geom_edge_add(sc, sa->v1, sv1); - screen_geom_edge_add(sc, sv1, sa->v4); - screen_geom_edge_add(sc, sa->v2, sv2); - screen_geom_edge_add(sc, sv2, sa->v3); + screen_geom_edge_add(sc, area->v1, sv1); + screen_geom_edge_add(sc, sv1, area->v4); + screen_geom_edge_add(sc, area->v2, sv2); + screen_geom_edge_add(sc, sv2, area->v3); screen_geom_edge_add(sc, sv1, sv2); if (fac > 0.5f) { /* new areas: right */ - newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->spacetype); + newa = screen_addarea(sc, sv1, sv2, area->v3, area->v4, area->spacetype); /* area left */ - sa->v3 = sv2; - sa->v4 = sv1; + area->v3 = sv2; + area->v4 = sv1; } else { /* new areas: left */ - newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->spacetype); + newa = screen_addarea(sc, area->v1, area->v2, sv2, sv1, area->spacetype); /* area right */ - sa->v1 = sv1; - sa->v2 = sv2; + area->v1 = sv1; + area->v2 = sv2; } - ED_area_data_copy(newa, sa, true); + ED_area_data_copy(newa, area, true); } /* remove double vertices en edges */ @@ -231,7 +232,7 @@ void screen_data_copy(bScreen *to, bScreen *from) { ScrVert *s1, *s2; ScrEdge *se; - ScrArea *sa, *saf; + ScrArea *area, *saf; /* free contents of 'to', is from blenkernel screen.c */ BKE_screen_free(to); @@ -255,18 +256,18 @@ void screen_data_copy(bScreen *to, bScreen *from) } saf = from->areabase.first; - for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { - sa->v1 = sa->v1->newv; - sa->v2 = sa->v2->newv; - sa->v3 = sa->v3->newv; - sa->v4 = sa->v4->newv; + for (area = to->areabase.first; area; area = area->next, saf = saf->next) { + area->v1 = area->v1->newv; + area->v2 = area->v2->newv; + area->v3 = area->v3->newv; + area->v4 = area->v4->newv; - BLI_listbase_clear(&sa->spacedata); - BLI_listbase_clear(&sa->regionbase); - BLI_listbase_clear(&sa->actionzones); - BLI_listbase_clear(&sa->handlers); + BLI_listbase_clear(&area->spacedata); + BLI_listbase_clear(&area->regionbase); + BLI_listbase_clear(&area->actionzones); + BLI_listbase_clear(&area->handlers); - ED_area_data_copy(sa, saf, true); + ED_area_data_copy(area, saf, true); } /* put at zero (needed?) */ @@ -285,19 +286,19 @@ void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new) screen_new->do_draw = true; } -/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ +/* with area as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ /* -1 = not valid check */ /* used with join operator */ -int area_getorientation(ScrArea *sa, ScrArea *sb) +int area_getorientation(ScrArea *area, ScrArea *sb) { - if (sa == NULL || sb == NULL) { + if (area == NULL || sb == NULL) { return -1; } - ScrVert *saBL = sa->v1; - ScrVert *saTL = sa->v2; - ScrVert *saTR = sa->v3; - ScrVert *saBR = sa->v4; + ScrVert *saBL = area->v1; + ScrVert *saTL = area->v2; + ScrVert *saTR = area->v3; + ScrVert *saBR = area->v4; ScrVert *sbBL = sb->v1; ScrVert *sbTL = sb->v2; @@ -306,25 +307,26 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) int tolerance = U.pixelsize * 4; - if (saBL->vec.x == sbBR->vec.x && saTL->vec.x == sbTR->vec.x) { /* sa to right of sb = W */ + if (saBL->vec.x == sbBR->vec.x && saTL->vec.x == sbTR->vec.x) { /* area to right of sb = W */ if ((abs(saBL->vec.y - sbBR->vec.y) <= tolerance) && (abs(saTL->vec.y - sbTR->vec.y) <= tolerance)) { return 0; } } - else if (saTL->vec.y == sbBL->vec.y && saTR->vec.y == sbBR->vec.y) { /* sa to bottom of sb = N */ + else if (saTL->vec.y == sbBL->vec.y && + saTR->vec.y == sbBR->vec.y) { /* area to bottom of sb = N */ if ((abs(saTL->vec.x - sbBL->vec.x) <= tolerance) && (abs(saTR->vec.x - sbBR->vec.x) <= tolerance)) { return 1; } } - else if (saTR->vec.x == sbTL->vec.x && saBR->vec.x == sbBL->vec.x) { /* sa to left of sb = E */ + else if (saTR->vec.x == sbTL->vec.x && saBR->vec.x == sbBL->vec.x) { /* area to left of sb = E */ if ((abs(saTR->vec.y - sbTL->vec.y) <= tolerance) && (abs(saBR->vec.y - sbBL->vec.y) <= tolerance)) { return 2; } } - else if (saBL->vec.y == sbTL->vec.y && saBR->vec.y == sbTR->vec.y) { /* sa on top of sb = S*/ + else if (saBL->vec.y == sbTL->vec.y && saBR->vec.y == sbTR->vec.y) { /* area on top of sb = S*/ if ((abs(saBL->vec.x - sbTL->vec.x) <= tolerance) && (abs(saBR->vec.x - sbTR->vec.x) <= tolerance)) { return 3; @@ -398,12 +400,12 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) /* ****************** EXPORTED API TO OTHER MODULES *************************** */ /* screen sets cursor based on active region */ -static void region_cursor_set_ex(wmWindow *win, ScrArea *sa, ARegion *region, bool swin_changed) +static void region_cursor_set_ex(wmWindow *win, ScrArea *area, ARegion *region, bool swin_changed) { BLI_assert(WM_window_get_active_screen(win)->active_region == region); if (win->tag_cursor_refresh || swin_changed || (region->type && region->type->event_cursor)) { win->tag_cursor_refresh = false; - ED_region_cursor_set(win, sa, region); + ED_region_cursor_set(win, area, region); } } @@ -411,11 +413,11 @@ static void region_cursor_set(wmWindow *win, bool swin_changed) { bScreen *screen = WM_window_get_active_screen(win); - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region == screen->active_region) { - region_cursor_set_ex(win, sa, region, swin_changed); + region_cursor_set_ex(win, area, region, swin_changed); return; } } @@ -522,11 +524,11 @@ void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *scree * Utility to exit and free an area-region. Screen level regions (menus/popups) need to be treated * slightly differently, see #ui_region_temp_remove(). */ -void ED_region_remove(bContext *C, ScrArea *sa, ARegion *region) +void ED_region_remove(bContext *C, ScrArea *area, ARegion *region) { ED_region_exit(C, region); - BKE_area_region_free(sa->type, region); - BLI_freelinkN(&sa->regionbase, region); + BKE_area_region_free(area->type, region); + BLI_freelinkN(&area->regionbase, region); } /* *********** exit calls are for closing running stuff ******** */ @@ -562,25 +564,25 @@ void ED_region_exit(bContext *C, ARegion *region) CTX_wm_region_set(C, prevar); } -void ED_area_exit(bContext *C, ScrArea *sa) +void ED_area_exit(bContext *C, ScrArea *area) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); ScrArea *prevsa = CTX_wm_area(C); ARegion *region; - if (sa->type && sa->type->exit) { - sa->type->exit(wm, sa); + if (area->type && area->type->exit) { + area->type->exit(wm, area); } - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { ED_region_exit(C, region); } - WM_event_remove_handlers(C, &sa->handlers); - WM_event_modal_handler_area_replace(win, sa, NULL); + WM_event_remove_handlers(C, &area->handlers); + WM_event_modal_handler_area_replace(win, area, NULL); CTX_wm_area_set(C, prevsa); } @@ -608,12 +610,12 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) for (ARegion *region = screen->regionbase.first; region; region = region->next) { ED_region_exit(C, region); } - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - ED_area_exit(C, sa); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + ED_area_exit(C, area); } /* Don't use ED_screen_areas_iter here, it skips hidden areas. */ - for (ScrArea *sa = window->global_areas.areabase.first; sa; sa = sa->next) { - ED_area_exit(C, sa); + for (ScrArea *area = window->global_areas.areabase.first; area; area = area->next) { + ED_area_exit(C, area); } /* mark it available for use for other windows */ @@ -636,15 +638,15 @@ static void screen_cursor_set(wmWindow *win, const int xy[2]) { const bScreen *screen = WM_window_get_active_screen(win); AZone *az = NULL; - ScrArea *sa; + ScrArea *area; - for (sa = screen->areabase.first; sa; sa = sa->next) { - if ((az = ED_area_actionzone_find_xy(sa, xy))) { + for (area = screen->areabase.first; area; area = area->next) { + if ((az = ED_area_actionzone_find_xy(area, xy))) { break; } } - if (sa) { + if (area) { if (az->type == AZONE_AREA) { WM_cursor_set(win, WM_CURSOR_EDIT); } @@ -685,7 +687,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) return; } - ScrArea *sa = NULL; + ScrArea *area = NULL; ARegion *region; ARegion *region_prev = scr->active_region; @@ -694,15 +696,15 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) { if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) { if (ED_area_azones_update(area_iter, xy) == NULL) { - sa = area_iter; + area = area_iter; break; } } } } - if (sa) { + if (area) { /* Make overlap active when mouse over. */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (ED_region_contains_xy(region, xy)) { scr->active_region = region; break; @@ -758,7 +760,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) } else { /* Notifier invokes freeing the buttons... causing a bit too much redraws. */ - region_cursor_set_ex(win, sa, scr->active_region, region_prev != scr->active_region); + region_cursor_set_ex(win, area, scr->active_region, region_prev != scr->active_region); if (region_prev != scr->active_region) { /* This used to be a notifier, but needs to be done immediate @@ -775,17 +777,17 @@ int ED_screen_area_active(const bContext *C) { wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (win && sc && sa) { - AZone *az = ED_area_actionzone_find_xy(sa, &win->eventstate->x); + if (win && sc && area) { + AZone *az = ED_area_actionzone_find_xy(area, &win->eventstate->x); ARegion *region; if (az && az->type == AZONE_REGION) { return 1; } - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region == sc->active_region) { return 1; } @@ -815,16 +817,16 @@ static ScrArea *screen_area_create_with_geometry(ScrAreaMap *area_map, return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, spacetype); } -static void screen_area_set_geometry_rect(ScrArea *sa, const rcti *rect) +static void screen_area_set_geometry_rect(ScrArea *area, const rcti *rect) { - sa->v1->vec.x = rect->xmin; - sa->v1->vec.y = rect->ymin; - sa->v2->vec.x = rect->xmin; - sa->v2->vec.y = rect->ymax; - sa->v3->vec.x = rect->xmax; - sa->v3->vec.y = rect->ymax; - sa->v4->vec.x = rect->xmax; - sa->v4->vec.y = rect->ymin; + area->v1->vec.x = rect->xmin; + area->v1->vec.y = rect->ymin; + area->v2->vec.x = rect->xmin; + area->v2->vec.y = rect->ymax; + area->v3->vec.x = rect->xmax; + area->v3->vec.y = rect->ymax; + area->v4->vec.x = rect->xmax; + area->v4->vec.y = rect->ymin; } static void screen_global_area_refresh(wmWindow *win, @@ -943,8 +945,8 @@ static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmai for (bScreen *screen_iter = bmain->screens.first; screen_iter; screen_iter = screen_iter->id.next) { if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) { - ScrArea *sa = screen_iter->areabase.first; - if (sa && sa->full == screen) { + ScrArea *area = screen_iter->areabase.first; + if (area && area->full == screen) { return screen_iter; } } @@ -976,8 +978,8 @@ bScreen *screen_change_prepare( wmTimer *wt = screen_old->animtimer; /* remove handlers referencing areas in old screen */ - for (ScrArea *sa = screen_old->areabase.first; sa; sa = sa->next) { - WM_event_remove_area_handler(&win->modalhandlers, sa); + for (ScrArea *area = screen_old->areabase.first; area; area = area->next) { + WM_event_remove_area_handler(&win->modalhandlers, area); } /* we put timer to sleep, so screen_exit has to think there's no timer */ @@ -1042,7 +1044,10 @@ bool ED_screen_change(bContext *C, bScreen *sc) return false; } -static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrArea *sa, View3D *v3d) +static void screen_set_3dview_camera(Scene *scene, + ViewLayer *view_layer, + ScrArea *area, + View3D *v3d) { /* fix any cameras that are used in the 3d view but not in the scene */ BKE_screen_view3d_sync(v3d, scene); @@ -1055,8 +1060,8 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre ListBase *regionbase; /* regionbase is in different place depending if space is active */ - if (v3d == sa->spacedata.first) { - regionbase = &sa->regionbase; + if (v3d == area->spacedata.first) { + regionbase = &area->regionbase; } else { regionbase = &v3d->regionbase; @@ -1104,28 +1109,28 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) /* Update 3D view cameras. */ const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - screen_set_3dview_camera(scene, view_layer, sa, v3d); + screen_set_3dview_camera(scene, view_layer, area, v3d); } } } } -ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) +ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type) { wmWindow *win = CTX_wm_window(C); ScrArea *newsa = NULL; SpaceLink *newsl; - if (!sa || sa->full == NULL) { - newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); + if (!area || area->full == NULL) { + newsa = ED_screen_state_toggle(C, win, area, SCREENMAXIMIZED); } if (!newsa) { - newsa = sa; + newsa = area; } BLI_assert(newsa); @@ -1144,40 +1149,40 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) /** * \a was_prev_temp for the case previous space was a temporary fullscreen as well */ -void ED_screen_full_prevspace(bContext *C, ScrArea *sa) +void ED_screen_full_prevspace(bContext *C, ScrArea *area) { - BLI_assert(sa->full); + BLI_assert(area->full); - if (sa->flag & AREA_FLAG_STACKED_FULLSCREEN) { + if (area->flag & AREA_FLAG_STACKED_FULLSCREEN) { /* stacked fullscreen -> only go back to previous area and don't toggle out of fullscreen */ - ED_area_prevspace(C, sa); + ED_area_prevspace(C, area); } else { - ED_screen_restore_temp_type(C, sa); + ED_screen_restore_temp_type(C, area); } } -void ED_screen_restore_temp_type(bContext *C, ScrArea *sa) +void ED_screen_restore_temp_type(bContext *C, ScrArea *area) { - SpaceLink *sl = sa->spacedata.first; + SpaceLink *sl = area->spacedata.first; /* In case nether functions below run. */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); if (sl->link_flag & SPACE_FLAG_TYPE_TEMPORARY) { - ED_area_prevspace(C, sa); + ED_area_prevspace(C, area); } - if (sa->full) { - ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED); + if (area->full) { + ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENMAXIMIZED); } } /* restore a screen / area back to default operation, after temp fullscreen modes */ -void ED_screen_full_restore(bContext *C, ScrArea *sa) +void ED_screen_full_restore(bContext *C, ScrArea *area) { wmWindow *win = CTX_wm_window(C); - SpaceLink *sl = sa->spacedata.first; + SpaceLink *sl = area->spacedata.first; bScreen *screen = CTX_wm_screen(C); short state = (screen ? screen->state : SCREENMAXIMIZED); @@ -1186,25 +1191,25 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa) if (sl->next) { if (sl->link_flag & SPACE_FLAG_TYPE_TEMPORARY) { - ED_screen_full_prevspace(C, sa); + ED_screen_full_prevspace(C, area); } else { - ED_screen_state_toggle(C, win, sa, state); + ED_screen_state_toggle(C, win, area, state); } - /* warning: 'sa' may be freed */ + /* warning: 'area' may be freed */ } /* otherwise just tile the area again */ else { - ED_screen_state_toggle(C, win, sa, state); + ED_screen_state_toggle(C, win, area, state); } } /** * this function toggles: if area is maximized/full then the parent will be restored * - * \warning \a sa may be freed. + * \warning \a area may be freed. */ -ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state) +ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const short state) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); @@ -1212,11 +1217,11 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s bScreen *sc, *oldscreen; ARegion *region; - if (sa) { + if (area) { /* ensure we don't have a button active anymore, can crash when * switching screens with tooltip open because region and tooltip * are no longer in the same screen */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { UI_blocklist_free(C, ®ion->uiblocks); if (region->regiontimer) { @@ -1226,14 +1231,14 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s } /* prevent hanging status prints */ - ED_area_status_text(sa, NULL); + ED_area_status_text(area, NULL); ED_workspace_status_text(C, NULL); } - if (sa && sa->full) { + if (area && area->full) { WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); /* restoring back to SCREENNORMAL */ - sc = sa->full; /* the old screen to restore */ + sc = area->full; /* the old screen to restore */ oldscreen = WM_window_get_active_screen(win); /* the one disappearing */ BLI_assert(BKE_workspace_layout_screen_get(layout_old) != sc); @@ -1254,7 +1259,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s old->full = NULL; } - sa->full = NULL; + area->full = NULL; if (fullsa == NULL) { if (G.debug & G_DEBUG) { @@ -1270,12 +1275,12 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s glob_area->global->flag &= ~GLOBAL_AREA_IS_HIDDEN; } /* restore the old side panels/header visibility */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { region->flag = region->flagfullscreen; } } - ED_area_data_swap(fullsa, sa); + ED_area_data_swap(fullsa, area); /* animtimer back */ sc->animtimer = oldscreen->animtimer; @@ -1318,15 +1323,15 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s /* use random area when we have no active one, e.g. when the * mouse is outside of the window and we open a file browser */ - if (!sa || sa->global) { - sa = oldscreen->areabase.first; + if (!area || area->global) { + area = oldscreen->areabase.first; } newa = (ScrArea *)sc->areabase.first; /* copy area */ - ED_area_data_swap(newa, sa); - newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */ + ED_area_data_swap(newa, area); + newa->flag = area->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */ if (state == SCREENFULL) { /* temporarily hide global areas */ @@ -1351,7 +1356,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s } } - sa->full = oldscreen; + area->full = oldscreen; newa->full = oldscreen; ED_screen_change(C, sc); @@ -1381,35 +1386,35 @@ ScrArea *ED_screen_temp_space_open(bContext *C, int display_type, bool dialog) { - ScrArea *sa = NULL; + ScrArea *area = NULL; switch (display_type) { case USER_TEMP_SPACE_DISPLAY_WINDOW: if (WM_window_open_temp(C, title, x, y, sizex, sizey, (int)space_type, dialog)) { - sa = CTX_wm_area(C); + area = CTX_wm_area(C); } break; case USER_TEMP_SPACE_DISPLAY_FULLSCREEN: { - ScrArea *ctx_sa = CTX_wm_area(C); + ScrArea *ctx_area = CTX_wm_area(C); - if (ctx_sa != NULL && ctx_sa->full) { - sa = ctx_sa; - ED_area_newspace(C, ctx_sa, space_type, true); - sa->flag |= AREA_FLAG_STACKED_FULLSCREEN; - ((SpaceLink *)sa->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY; + if (ctx_area != NULL && ctx_area->full) { + area = ctx_area; + ED_area_newspace(C, ctx_area, space_type, true); + area->flag |= AREA_FLAG_STACKED_FULLSCREEN; + ((SpaceLink *)area->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY; } - else if (ctx_sa != NULL && ctx_sa->spacetype == space_type) { - sa = ED_screen_state_toggle(C, CTX_wm_window(C), ctx_sa, SCREENMAXIMIZED); + else if (ctx_area != NULL && ctx_area->spacetype == space_type) { + area = ED_screen_state_toggle(C, CTX_wm_window(C), ctx_area, SCREENMAXIMIZED); } else { - sa = ED_screen_full_newspace(C, ctx_sa, (int)space_type); - ((SpaceLink *)sa->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY; + area = ED_screen_full_newspace(C, ctx_area, (int)space_type); + ((SpaceLink *)area->spacedata.first)->link_flag |= SPACE_FLAG_TYPE_TEMPORARY; } break; } } - return sa; + return area; } /* update frame rate info for viewport drawing */ @@ -1487,12 +1492,12 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) sad->flag |= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; sad->flag |= (sync == 0) ? ANIMPLAY_FLAG_NO_SYNC : (sync == 1) ? ANIMPLAY_FLAG_SYNC : 0; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); char spacetype = -1; - if (sa) { - spacetype = sa->spacetype; + if (area) { + spacetype = area->spacetype; } sad->from_anim_edit = (ELEM(spacetype, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)); @@ -1508,13 +1513,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) static ARegion *time_top_left_3dwindow(bScreen *screen) { ARegion *aret = NULL; - ScrArea *sa; + ScrArea *area; int min = 10000; - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_VIEW3D) { + for (area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_VIEW3D) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { if (region->winrct.xmin - region->winrct.ymin < min) { aret = region; @@ -1573,11 +1578,11 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph) */ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) { - ScrArea *sa; + ScrArea *area; const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; - for (sa = screen->areabase.first; sa; sa = sa->next) { - switch (sa->spacetype) { + for (area = screen->areabase.first; area; area = area->next) { + switch (area->spacetype) { case SPACE_VIEW3D: { View3D *v3d; @@ -1585,10 +1590,10 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) continue; } - v3d = sa->spacedata.first; + v3d = area->spacedata.first; if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; if (rv3d->persp == RV3D_CAMOB) { @@ -1604,7 +1609,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) /* images should always show in stereo, even if * the file doesn't have views enabled */ - sima = sa->spacedata.first; + sima = area->spacedata.first; if (sima->image && BKE_image_is_stereo(sima->image) && (sima->iuser.flag & IMA_SHOW_STEREO)) { return true; @@ -1618,7 +1623,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) continue; } - snode = sa->spacedata.first; + snode = area->spacedata.first; if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) { return true; } @@ -1631,7 +1636,7 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene) continue; } - sseq = sa->spacedata.first; + sseq = area->spacedata.first; if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) { return true; } @@ -1675,16 +1680,16 @@ ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen, const bool only_visible) { if (only_visible) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacedata.first == sl) { - return sa; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacedata.first == sl) { + return area; } } } else { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (BLI_findindex(&sa->spacedata, sl) != -1) { - return sa; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (BLI_findindex(&area->spacedata, sl) != -1) { + return area; } } } diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 25855382307..9169bf37116 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -163,7 +163,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) const int screen_size_x = BLI_rcti_size_x(&screen_rect); const int screen_size_y = BLI_rcti_size_y(&screen_rect); ScrVert *sv = NULL; - ScrArea *sa; int screen_size_x_prev, screen_size_y_prev; float min[2], max[2]; @@ -199,19 +198,19 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) if (facy > 1) { /* Keep timeline small in video edit workspace. */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_ACTION && sa->v1->vec.y == screen_rect.ymin && - screen_geom_area_height(sa) <= headery * facy + 1) { - ScrEdge *se = BKE_screen_find_edge(sc, sa->v2, sa->v3); + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect.ymin && + screen_geom_area_height(area) <= headery * facy + 1) { + ScrEdge *se = BKE_screen_find_edge(sc, area->v2, area->v3); if (se) { - const int yval = sa->v1->vec.y + headery - 1; + const int yval = area->v1->vec.y + headery - 1; screen_geom_select_connected_edge(win, se); /* all selected vertices get the right offset */ for (sv = sc->vertbase.first; sv; sv = sv->next) { /* if is a collapsed area */ - if (sv != sa->v1 && sv != sa->v4) { + if (sv != area->v1 && sv != area->v4) { if (sv->flag) { sv->vec.y = yval; } @@ -223,19 +222,19 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) } if (facy < 1) { /* make each window at least ED_area_headersize() high */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (screen_geom_area_height(sa) < headery) { + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + if (screen_geom_area_height(area) < headery) { /* lower edge */ - ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1); - if (se && sa->v1 != sa->v2) { - const int yval = sa->v2->vec.y - headery + 1; + ScrEdge *se = BKE_screen_find_edge(sc, area->v4, area->v1); + if (se && area->v1 != area->v2) { + const int yval = area->v2->vec.y - headery + 1; screen_geom_select_connected_edge(win, se); /* all selected vertices get the right offset */ for (sv = sc->vertbase.first; sv; sv = sv->next) { /* if is not a collapsed area */ - if (sv != sa->v2 && sv != sa->v3) { + if (sv != area->v2 && sv != area->v3) { if (sv->flag) { sv->vec.y = yval; } @@ -284,14 +283,14 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) /** * \return 0 if no split is possible, otherwise the screen-coordinate at which to split. */ -short screen_geom_find_area_split_point(const ScrArea *sa, +short screen_geom_find_area_split_point(const ScrArea *area, const rcti *window_rect, char dir, float fac) { short x, y; - const int cur_area_width = screen_geom_area_width(sa); - const int cur_area_height = screen_geom_area_height(sa); + const int cur_area_width = screen_geom_area_width(area); + const int cur_area_height = screen_geom_area_height(area); const short area_min_x = AREAMINX; const short area_min_y = ED_area_headersize(); int area_min; @@ -308,43 +307,43 @@ short screen_geom_find_area_split_point(const ScrArea *sa, CLAMP(fac, 0.0f, 1.0f); if (dir == 'h') { - y = sa->v1->vec.y + round_fl_to_short(fac * cur_area_height); + y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height); area_min = area_min_y; - if (sa->v1->vec.y > window_rect->ymin) { + if (area->v1->vec.y > window_rect->ymin) { area_min += U.pixelsize; } - if (sa->v2->vec.y < (window_rect->ymax - 1)) { + if (area->v2->vec.y < (window_rect->ymax - 1)) { area_min += U.pixelsize; } - if (y - sa->v1->vec.y < area_min) { - y = sa->v1->vec.y + area_min; + if (y - area->v1->vec.y < area_min) { + y = area->v1->vec.y + area_min; } - else if (sa->v2->vec.y - y < area_min) { - y = sa->v2->vec.y - area_min; + else if (area->v2->vec.y - y < area_min) { + y = area->v2->vec.y - area_min; } return y; } else { - x = sa->v1->vec.x + round_fl_to_short(fac * cur_area_width); + x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width); area_min = area_min_x; - if (sa->v1->vec.x > window_rect->xmin) { + if (area->v1->vec.x > window_rect->xmin) { area_min += U.pixelsize; } - if (sa->v4->vec.x < (window_rect->xmax - 1)) { + if (area->v4->vec.x < (window_rect->xmax - 1)) { area_min += U.pixelsize; } - if (x - sa->v1->vec.x < area_min) { - x = sa->v1->vec.x + area_min; + if (x - area->v1->vec.x < area_min) { + x = area->v1->vec.x + area_min; } - else if (sa->v4->vec.x - x < area_min) { - x = sa->v4->vec.x - area_min; + else if (area->v4->vec.x - x < area_min) { + x = area->v4->vec.x - area_min; } return x; diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index e1a75e51cf2..af57d95c086 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -36,7 +36,7 @@ struct bContextDataResult; #define AZONEFADEOUT (6.5f * U.widget_unit) /* when we start seeing the azone */ /* area.c */ -void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free); +void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free); void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2); void region_toggle_hidden(struct bContext *C, ARegion *region, const bool do_fade); @@ -50,11 +50,12 @@ bScreen *screen_change_prepare(bScreen *screen_old, struct Main *bmain, struct bContext *C, wmWindow *win); -ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge); +ScrArea *area_split( + const wmWindow *win, bScreen *sc, ScrArea *area, char dir, float fac, int merge); int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2); -int area_getorientation(ScrArea *sa, ScrArea *sb); +int area_getorientation(ScrArea *area, ScrArea *sb); -struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]); +struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); /* screen_geometry.c */ int screen_geom_area_height(const ScrArea *area); @@ -73,7 +74,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, const int mx, const int my); void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc); -short screen_geom_find_area_split_point(const ScrArea *sa, +short screen_geom_find_area_split_point(const ScrArea *area, const rcti *window_rect, char dir, float fac); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5eb676cd25c..2e4734e75a5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -590,20 +590,20 @@ bool ED_operator_editmball(bContext *C) bool ED_operator_mask(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacedata.first) { - switch (sa->spacetype) { + ScrArea *area = CTX_wm_area(C); + if (area && area->spacedata.first) { + switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = sa->spacedata.first; + SpaceClip *sc = area->spacedata.first; return ED_space_clip_check_show_maskedit(sc); } case SPACE_SEQ: { - SpaceSeq *sseq = sa->spacedata.first; + SpaceSeq *sseq = area->spacedata.first; Scene *scene = CTX_data_scene(C); return ED_space_sequencer_check_show_maskedit(sseq, scene); } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; ViewLayer *view_layer = CTX_data_view_layer(C); return ED_space_image_check_show_maskedit(sima, view_layer); } @@ -681,8 +681,8 @@ static bool actionzone_area_poll(bContext *C) const int *xy = &win->eventstate->x; AZone *az; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (az = sa->actionzones.first; az; az = az->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (az = area->actionzones.first; az; az = az->next) { if (BLI_rcti_isect_pt_v(&az->rect, xy)) { return 1; } @@ -743,11 +743,11 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip) return false; } -static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only) +static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const bool test_only) { AZone *az = NULL; - for (az = sa->actionzones.first; az; az = az->next) { + for (az = area->actionzones.first; az; az = az->next) { rcti az_rect_clip; if (BLI_rcti_isect_pt_v(&az->rect, xy) && /* Check clipping if this is clipped */ @@ -798,7 +798,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo } /* XXX force redraw to show/hide the action zone */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } } @@ -868,18 +868,18 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo else if (!test_only && !IS_EQF(az->alpha, 0.0f)) { if (az->type == AZONE_FULLSCREEN) { az->alpha = 0.0f; - sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; - ED_area_tag_redraw_no_rebuild(sa); + area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; + ED_area_tag_redraw_no_rebuild(area); } else if (az->type == AZONE_REGION_SCROLL) { if (az->direction == AZ_SCROLL_VERT) { az->alpha = az->region->v2d.alpha_vert = 0; - sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; + area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; ED_region_tag_redraw_no_rebuild(az->region); } else if (az->direction == AZ_SCROLL_HOR) { az->alpha = az->region->v2d.alpha_hor = 0; - sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; + area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE; ED_region_tag_redraw_no_rebuild(az->region); } else { @@ -895,8 +895,8 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo /* Finds an action-zone by position in entire screen so azones can overlap. */ static AZone *screen_actionzone_find_xy(bScreen *sc, const int xy[2]) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - AZone *az = area_actionzone_refresh_xy(sa, xy, true); + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + AZone *az = area_actionzone_refresh_xy(area, xy, true); if (az != NULL) { return az; } @@ -917,14 +917,14 @@ static ScrArea *screen_actionzone_area(bScreen *sc, const AZone *az) return NULL; } -AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]) +AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]) { - return area_actionzone_refresh_xy(sa, xy, true); + return area_actionzone_refresh_xy(area, xy, true); } -AZone *ED_area_azones_update(ScrArea *sa, const int xy[2]) +AZone *ED_area_azones_update(ScrArea *area, const int xy[2]) { - return area_actionzone_refresh_xy(sa, xy, false); + return area_actionzone_refresh_xy(area, xy, false); } static void actionzone_exit(wmOperator *op) @@ -1327,12 +1327,12 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); WorkSpaceLayout *layout_new; bScreen *newsc; - ScrArea *sa; + ScrArea *area; rcti rect; win = CTX_wm_window(C); scene = CTX_data_scene(C); - sa = CTX_wm_area(C); + area = CTX_wm_area(C); /* XXX hrmf! */ if (event->type == EVT_ACTIONZONE_AREA) { @@ -1342,11 +1342,11 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_PASS_THROUGH; } - sa = sad->sa1; + area = sad->sa1; } /* adds window to WM */ - rect = sa->totrct; + rect = area->totrct; BLI_rcti_translate(&rect, win->posx, win->posy); rect.xmax = rect.xmin + BLI_rcti_size_x(&rect) / U.pixelsize; rect.ymax = rect.ymin + BLI_rcti_size_y(&rect) / U.pixelsize; @@ -1371,7 +1371,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) WM_window_set_active_layout(newwin, workspace, layout_new); /* copy area to new screen */ - ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true); + ED_area_data_copy((ScrArea *)newsc->areabase.first, area, true); ED_area_tag_redraw((ScrArea *)newsc->areabase.first); @@ -1507,25 +1507,25 @@ static void area_move_set_limits( WM_window_rect_calc(win, &window_rect); - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (ScrArea *area = sc->areabase.first; area; area = area->next) { if (dir == 'h') { int y1; areamin = areaminy; - if (sa->v1->vec.y > window_rect.ymin) { + if (area->v1->vec.y > window_rect.ymin) { areamin += U.pixelsize; } - if (sa->v2->vec.y < (window_rect.ymax - 1)) { + if (area->v2->vec.y < (window_rect.ymax - 1)) { areamin += U.pixelsize; } - y1 = screen_geom_area_height(sa) - areamin; + y1 = screen_geom_area_height(area) - areamin; /* if top or down edge selected, test height */ - if (sa->v1->editflag && sa->v4->editflag) { + if (area->v1->editflag && area->v4->editflag) { *bigger = min_ii(*bigger, y1); } - else if (sa->v2->editflag && sa->v3->editflag) { + else if (area->v2->editflag && area->v3->editflag) { *smaller = min_ii(*smaller, y1); } } @@ -1533,20 +1533,20 @@ static void area_move_set_limits( int x1; areamin = AREAMINX; - if (sa->v1->vec.x > window_rect.xmin) { + if (area->v1->vec.x > window_rect.xmin) { areamin += U.pixelsize; } - if (sa->v4->vec.x < (window_rect.xmax - 1)) { + if (area->v4->vec.x < (window_rect.xmax - 1)) { areamin += U.pixelsize; } - x1 = screen_geom_area_width(sa) - areamin; + x1 = screen_geom_area_width(area) - areamin; /* if left or right edge selected, test width */ - if (sa->v1->editflag && sa->v2->editflag) { + if (area->v1->editflag && area->v2->editflag) { *bigger = min_ii(*bigger, x1); } - else if (sa->v3->editflag && sa->v4->editflag) { + else if (area->v3->editflag && area->v4->editflag) { *smaller = min_ii(*smaller, x1); } } @@ -1737,29 +1737,29 @@ static void area_move_apply_do(const bContext *C, /* only redraw if we actually moved a screen vert, for AREAGRID */ if (doredraw) { bool redraw_all = false; - ED_screen_areas_iter(win, sc, sa) + ED_screen_areas_iter(win, sc, area) { - if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) { - if (ED_area_is_global(sa)) { + if (area->v1->editflag || area->v2->editflag || area->v3->editflag || area->v4->editflag) { + if (ED_area_is_global(area)) { /* Snap to minimum or maximum for global areas. */ - int height = round_fl_to_int(screen_geom_area_height(sa) / UI_DPI_FAC); - if (abs(height - sa->global->size_min) < abs(height - sa->global->size_max)) { - sa->global->cur_fixed_height = sa->global->size_min; + int height = round_fl_to_int(screen_geom_area_height(area) / UI_DPI_FAC); + if (abs(height - area->global->size_min) < abs(height - area->global->size_max)) { + area->global->cur_fixed_height = area->global->size_min; } else { - sa->global->cur_fixed_height = sa->global->size_max; + area->global->cur_fixed_height = area->global->size_max; } sc->do_refresh = true; redraw_all = true; } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } } if (redraw_all) { - ED_screen_areas_iter(win, sc, sa) + ED_screen_areas_iter(win, sc, area) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } } @@ -1984,13 +1984,13 @@ static int area_split_menu_init(bContext *C, wmOperator *op) /* generic init, no UI stuff here, assumes active area */ static int area_split_init(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); sAreaSplitData *sd; int areaminy = ED_area_headersize(); int dir; /* required context */ - if (sa == NULL) { + if (area == NULL) { return 0; } @@ -1998,10 +1998,10 @@ static int area_split_init(bContext *C, wmOperator *op) dir = RNA_enum_get(op->ptr, "direction"); /* minimal size */ - if (dir == 'v' && sa->winx < 2 * AREAMINX) { + if (dir == 'v' && area->winx < 2 * AREAMINX) { return 0; } - if (dir == 'h' && sa->winy < 2 * areaminy) { + if (dir == 'h' && area->winy < 2 * areaminy) { return 0; } @@ -2009,42 +2009,42 @@ static int area_split_init(bContext *C, wmOperator *op) sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; - sd->sarea = sa; + sd->sarea = area; if (dir == 'v') { - sd->origmin = sa->v1->vec.x; - sd->origsize = sa->v4->vec.x - sd->origmin; + sd->origmin = area->v1->vec.x; + sd->origsize = area->v4->vec.x - sd->origmin; } else { - sd->origmin = sa->v1->vec.y; - sd->origsize = sa->v2->vec.y - sd->origmin; + sd->origmin = area->v1->vec.y; + sd->origsize = area->v2->vec.y - sd->origmin; } return 1; } -/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ +/* with area as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ /* used with split operator */ -static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) +static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *area, ScrArea *sb) { - ScrVert *sav1 = sa->v1; - ScrVert *sav2 = sa->v2; - ScrVert *sav3 = sa->v3; - ScrVert *sav4 = sa->v4; + ScrVert *sav1 = area->v1; + ScrVert *sav2 = area->v2; + ScrVert *sav3 = area->v3; + ScrVert *sav4 = area->v4; ScrVert *sbv1 = sb->v1; ScrVert *sbv2 = sb->v2; ScrVert *sbv3 = sb->v3; ScrVert *sbv4 = sb->v4; - if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ + if (sav1 == sbv4 && sav2 == sbv3) { /* area to right of sb = W */ return BKE_screen_find_edge(screen, sav1, sav2); } - else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ + else if (sav2 == sbv1 && sav3 == sbv4) { /* area to bottom of sb = N */ return BKE_screen_find_edge(screen, sav2, sav3); } - else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ + else if (sav3 == sbv2 && sav4 == sbv1) { /* area to left of sb = E */ return BKE_screen_find_edge(screen, sav3, sav4); } - else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ + else if (sav1 == sbv2 && sav4 == sbv3) { /* area on top of sb = S*/ return BKE_screen_find_edge(screen, sav1, sav4); } @@ -2198,18 +2198,18 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } else if (RNA_property_is_set(op->ptr, prop_dir)) { - ScrArea *sa = CTX_wm_area(C); - if (sa == NULL) { + ScrArea *area = CTX_wm_area(C); + if (area == NULL) { return OPERATOR_CANCELLED; } dir = RNA_property_enum_get(op->ptr, prop_dir); if (dir == 'h') { RNA_property_float_set( - op->ptr, prop_factor, ((float)(event->x - sa->v1->vec.x)) / (float)sa->winx); + op->ptr, prop_factor, ((float)(event->x - area->v1->vec.x)) / (float)area->winx); } else { RNA_property_float_set( - op->ptr, prop_factor, ((float)(event->y - sa->v1->vec.y)) / (float)sa->winy); + op->ptr, prop_factor, ((float)(event->y - area->v1->vec.y)) / (float)area->winy); } if (!area_split_init(C, op)) { @@ -2389,18 +2389,18 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) sd->sarea = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->x, event->y); if (sd->sarea) { - ScrArea *sa = sd->sarea; + ScrArea *area = sd->sarea; if (dir == 'v') { - sd->origmin = sa->v1->vec.x; - sd->origsize = sa->v4->vec.x - sd->origmin; + sd->origmin = area->v1->vec.x; + sd->origsize = area->v4->vec.x - sd->origmin; } else { - sd->origmin = sa->v1->vec.y; - sd->origsize = sa->v2->vec.y - sd->origmin; + sd->origmin = area->v1->vec.y; + sd->origsize = area->v2->vec.y - sd->origmin; } if (sd->do_snap) { - sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1; + area->v1->editflag = area->v2->editflag = area->v3->editflag = area->v4->editflag = 1; const int snap_loc = area_snap_calc_location(CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, @@ -2410,7 +2410,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) sd->origmin + sd->origsize, -sd->origmin); - sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0; + area->v1->editflag = area->v2->editflag = area->v3->editflag = area->v4->editflag = 0; sd->delta = snap_loc - sd->origval; } @@ -2465,7 +2465,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot) typedef struct RegionMoveData { AZone *az; ARegion *region; - ScrArea *sa; + ScrArea *area; int bigger, smaller, origval; int origx, origy; int maxsize; @@ -2473,7 +2473,7 @@ typedef struct RegionMoveData { } RegionMoveData; -static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) +static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge) { int dist; @@ -2492,15 +2492,15 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) } else { if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { - dist = BLI_rcti_size_x(&sa->totrct); + dist = BLI_rcti_size_x(&area->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ - dist = BLI_rcti_size_y(&sa->totrct); + dist = BLI_rcti_size_y(&area->totrct); } /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region == scalear) { continue; } @@ -2574,11 +2574,11 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event else { rmd->region = az->region; } - rmd->sa = sad->sa1; + rmd->area = sad->sa1; rmd->edge = az->edge; rmd->origx = event->x; rmd->origy = event->y; - rmd->maxsize = area_max_regionsize(rmd->sa, rmd->region, rmd->edge); + rmd->maxsize = area_max_regionsize(rmd->area, rmd->region, rmd->edge); /* if not set we do now, otherwise it uses type */ if (rmd->region->sizex == 0) { @@ -2641,7 +2641,7 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) { if (rmd->region->regiontype == RGN_TYPE_HEADER) { - ARegion *region_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER); + ARegion *region_tool_header = BKE_area_find_region_type(rmd->area, RGN_TYPE_TOOL_HEADER); if (region_tool_header != NULL) { if ((region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 && (region_tool_header->flag & RGN_FLAG_HIDDEN) != 0) { @@ -2732,7 +2732,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) rmd->region->sizey = rmd->origval; } } - ED_area_tag_redraw(rmd->sa); + ED_area_tag_redraw(rmd->area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); break; @@ -2747,7 +2747,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) region_scale_validate_size(rmd); } - ED_area_tag_redraw(rmd->sa); + ED_area_tag_redraw(rmd->area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -2800,13 +2800,13 @@ static void areas_do_frame_follow(bContext *C, bool middle) for (wmWindow *window = wm->windows.first; window; window = window->next) { const bScreen *screen = WM_window_get_active_screen(window); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { /* do follow here if editor type supports it */ if ((scr->redraws_flag & TIME_FOLLOW)) { if ((region->regiontype == RGN_TYPE_WINDOW && - ELEM(sa->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || - (sa->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { + ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || + (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { float w = BLI_rctf_size_x(®ion->v2d.cur); if (middle) { @@ -3155,32 +3155,32 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) static int screen_maximize_area_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = NULL; + ScrArea *area = NULL; const bool hide_panels = RNA_boolean_get(op->ptr, "use_hide_panels"); /* search current screen for 'fullscreen' areas */ /* prevents restoring info header, when mouse is over it */ - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->full) { + for (area = screen->areabase.first; area; area = area->next) { + if (area->full) { break; } } - if (sa == NULL) { - sa = CTX_wm_area(C); + if (area == NULL) { + area = CTX_wm_area(C); } if (hide_panels) { if (!ELEM(screen->state, SCREENNORMAL, SCREENFULL)) { return OPERATOR_CANCELLED; } - ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENFULL); + ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENFULL); } else { if (!ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) { return OPERATOR_CANCELLED; } - ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED); + ED_screen_state_toggle(C, CTX_wm_window(C), area, SCREENMAXIMIZED); } return OPERATOR_FINISHED; @@ -3396,24 +3396,24 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case MOUSEMOVE: { - ScrArea *sa = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y); + ScrArea *area = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y); int dir = -1; - if (sa) { - if (jd->sa1 != sa) { - dir = area_getorientation(jd->sa1, sa); + if (area) { + if (jd->sa1 != area) { + dir = area_getorientation(jd->sa1, area); if (dir != -1) { - jd->sa2 = sa; + jd->sa2 = area; } else { /* we are not bordering on the previously selected area * we check if area has common border with the one marked for removal * in this case we can swap areas. */ - dir = area_getorientation(sa, jd->sa2); + dir = area_getorientation(area, jd->sa2); if (dir != -1) { jd->sa1 = jd->sa2; - jd->sa2 = sa; + jd->sa2 = area; } else { jd->sa2 = NULL; @@ -3426,16 +3426,16 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) * we swap the areas if possible to allow user to choose */ if (jd->sa2 != NULL) { jd->sa1 = jd->sa2; - jd->sa2 = sa; + jd->sa2 = area; dir = area_getorientation(jd->sa1, jd->sa2); if (dir == -1) { printf("oops, didn't expect that!\n"); } } else { - dir = area_getorientation(jd->sa1, sa); + dir = area_getorientation(jd->sa1, area); if (dir != -1) { - jd->sa2 = sa; + jd->sa2 = area; } } WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -3612,18 +3612,18 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); bScreen *screen; - ScrArea *sa; + ScrArea *area; int tot = 0; for (screen = bmain->screens.first; screen; screen = screen->id.next) { - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacedata.first != sa->spacedata.last) { - SpaceLink *sl = sa->spacedata.first; - - BLI_remlink(&sa->spacedata, sl); - tot += BLI_listbase_count(&sa->spacedata); - BKE_spacedata_freelist(&sa->spacedata); - BLI_addtail(&sa->spacedata, sl); + for (area = screen->areabase.first; area; area = area->next) { + if (area->spacedata.first != area->spacedata.last) { + SpaceLink *sl = area->spacedata.first; + + BLI_remlink(&area->spacedata, sl); + tot += BLI_listbase_count(&area->spacedata); + BKE_spacedata_freelist(&area->spacedata); + BLI_addtail(&area->spacedata, sl); } } } @@ -3809,7 +3809,7 @@ static void view3d_localview_update_rv3d(struct RegionView3D *rv3d) } static void region_quadview_init_rv3d( - ScrArea *sa, ARegion *region, const char viewlock, const char view, const char persp) + ScrArea *area, ARegion *region, const char viewlock, const char view, const char persp) { RegionView3D *rv3d = region->regiondata; @@ -3826,7 +3826,7 @@ static void region_quadview_init_rv3d( ED_view3d_lock(rv3d); view3d_localview_update_rv3d(rv3d); if ((viewlock & RV3D_BOXCLIP) && (persp == RV3D_ORTHO)) { - ED_view3d_quadview_update(sa, region, true); + ED_view3d_quadview_update(area, region, true); } } @@ -3841,13 +3841,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } else if (region->alignment == RGN_ALIGN_QSPLIT) { /* Exit quad-view */ - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *arn; /* keep current region */ region->alignment = 0; - if (sa->spacetype == SPACE_VIEW3D) { + if (area->spacetype == SPACE_VIEW3D) { ARegion *region_iter; RegionView3D *rv3d = region->regiondata; @@ -3869,7 +3869,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op) rv3d->rflag &= ~RV3D_CLIPPING; /* Accumulate locks, in case they're mixed. */ - for (region_iter = sa->regionbase.first; region_iter; region_iter = region_iter->next) { + for (region_iter = area->regionbase.first; region_iter; region_iter = region_iter->next) { if (region_iter->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d_iter = region_iter->regiondata; rv3d->viewlock_quad |= rv3d_iter->viewlock; @@ -3877,13 +3877,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } } - for (region = sa->regionbase.first; region; region = arn) { + for (region = area->regionbase.first; region; region = arn) { arn = region->next; if (region->alignment == RGN_ALIGN_QSPLIT) { - ED_region_remove(C, sa, region); + ED_region_remove(C, area, region); } } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } else if (region->next) { @@ -3891,20 +3891,20 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } else { /* Enter quad-view */ - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *newar; int count; region->alignment = RGN_ALIGN_QSPLIT; for (count = 0; count < 3; count++) { - newar = BKE_area_region_copy(sa->type, region); - BLI_addtail(&sa->regionbase, newar); + newar = BKE_area_region_copy(area->type, region); + BLI_addtail(&area->regionbase, newar); } /* lock views and set them */ - if (sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + if (area->spacetype == SPACE_VIEW3D) { + View3D *v3d = area->spacedata.first; int index_qsplit = 0; /* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set, @@ -3919,13 +3919,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op) RV3D_LOCK_ROTATION; region_quadview_init_rv3d( - sa, region, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO); - region_quadview_init_rv3d(sa, + area, region, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO); + region_quadview_init_rv3d(area, (region = region->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO); - region_quadview_init_rv3d(sa, + region_quadview_init_rv3d(area, (region = region->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), @@ -3933,16 +3933,16 @@ static int region_quadview_exec(bContext *C, wmOperator *op) /* forcing camera is distracting */ #if 0 if (v3d->camera) { - region_quadview_init_rv3d(sa, (region = region->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB); + region_quadview_init_rv3d(area, (region = region->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB); } else { - region_quadview_init_rv3d(sa, (region = region->next), 0, RV3D_VIEW_USER, RV3D_PERSP); + region_quadview_init_rv3d(area, (region = region->next), 0, RV3D_VIEW_USER, RV3D_PERSP); } #else (void)v3d; #endif } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -4091,11 +4091,11 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* show/hide header text menus */ static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; + area->flag = area->flag ^ HEADER_NO_PULLDOWN; - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -4122,42 +4122,42 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) static bool screen_region_context_menu_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - return (sa && sa->spacetype != SPACE_STATUSBAR); + ScrArea *area = CTX_wm_area(C); + return (area && area->spacetype != SPACE_STATUSBAR); } void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top"); { PointerRNA ptr; - RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr); - if (!ELEM(sa->spacetype, SPACE_TOPBAR)) { + RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); + if (!ELEM(area->spacetype, SPACE_TOPBAR)) { uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE); } - ARegion *region_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); uiLayout *col = uiLayoutColumn(layout, 0); uiLayoutSetActive(col, (region_header->flag & RGN_FLAG_HIDDEN) == 0); - if (BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER)) { + if (BKE_area_find_region_type(area, RGN_TYPE_TOOL_HEADER)) { uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE); } uiItemO(col, IFACE_("Show Menus"), - (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT, + (area->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT, "SCREEN_OT_header_toggle_menus"); } /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - if (!ELEM(sa->spacetype, SPACE_TOPBAR)) { + if (!ELEM(area->spacetype, SPACE_TOPBAR)) { uiItemS(layout); uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); @@ -4165,24 +4165,24 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN /* File browser should be fullscreen all the time, top-bar should * never be. But other regions can be maximized/restored. */ - if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) { + if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) { uiItemS(layout); - const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); + const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area"); } } void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top"); { PointerRNA ptr; - RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr); + RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); uiItemR(layout, &ptr, "show_region_footer", 0, IFACE_("Show Footer"), ICON_NONE); } @@ -4193,10 +4193,10 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN /* File browser should be fullscreen all the time, top-bar should * never be. But other regions can be maximized/restored... */ - if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) { + if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) { uiItemS(layout); - const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); + const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area"); } } @@ -4383,7 +4383,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv ScreenAnimData *sad = wt->customdata; wmWindowManager *wm = CTX_wm_manager(C); wmWindow *window; - ScrArea *sa; + ScrArea *area; int sync; float time; @@ -4514,15 +4514,15 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv for (window = wm->windows.first; window; window = window->next) { const bScreen *win_screen = WM_window_get_active_screen(window); - for (sa = win_screen->areabase.first; sa; sa = sa->next) { + for (area = win_screen->areabase.first; area; area = area->next) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { bool redraw = false; if (region == sad->region) { redraw = true; } else if (match_region_with_redraws( - sa->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) { + area->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) { redraw = true; } @@ -4531,8 +4531,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv /* do follow here if editor type supports it */ if ((sad->redraws & TIME_FOLLOW)) { if ((region->regiontype == RGN_TYPE_WINDOW && - ELEM(sa->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || - (sa->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { + ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || + (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { float w = BLI_rctf_size_x(®ion->v2d.cur); if (scene->r.cfra < region->v2d.cur.xmin) { region->v2d.cur.xmax = scene->r.cfra; @@ -4803,20 +4803,20 @@ static void SCREEN_OT_box_select(wmOperatorType *ot) static int fullscreen_back_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = NULL; + ScrArea *area = NULL; /* search current screen for 'fullscreen' areas */ - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->full) { + for (area = screen->areabase.first; area; area = area->next) { + if (area->full) { break; } } - if (!sa) { + if (!area) { BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found"); return OPERATOR_CANCELLED; } - ED_screen_full_prevspace(C, sa); + ED_screen_full_prevspace(C, area); return OPERATOR_FINISHED; } @@ -5069,7 +5069,7 @@ static void SCREEN_OT_delete(wmOperatorType *ot) * \{ */ typedef struct RegionAlphaInfo { - ScrArea *sa; + ScrArea *area; ARegion *region, *child_region; /* other region */ int hidden; } RegionAlphaInfo; @@ -5120,10 +5120,10 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running else { if (rgi->hidden) { rgi->region->flag |= rgi->hidden; - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->sa); + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->area); } /* area decoration needs redraw in end */ - ED_area_tag_redraw(rgi->sa); + ED_area_tag_redraw(rgi->area); } WM_event_remove_timer(CTX_wm_manager(C), NULL, region->regiontimer); /* frees rgi */ region->regiontimer = NULL; @@ -5131,7 +5131,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running /** * \note Assumes that \a region itself is not a split version from previous region. */ -void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegion *region) +void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARegion *region) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); @@ -5145,13 +5145,13 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegi rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo"); rgi->hidden = region->flag & RGN_FLAG_HIDDEN; - rgi->sa = sa; + rgi->area = area; rgi->region = region; region->flag &= ~RGN_FLAG_HIDDEN; /* blend in, reinitialize regions because it got unhidden */ if (rgi->hidden == 0) { - ED_area_initialize(wm, win, sa); + ED_area_initialize(wm, win, area); } else { WM_event_remove_handlers(C, ®ion->handlers); @@ -5220,8 +5220,8 @@ static void SCREEN_OT_region_blend(wmOperatorType *ot) static bool space_type_set_or_cycle_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - return (sa && !ELEM(sa->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR)); + ScrArea *area = CTX_wm_area(C); + return (area && !ELEM(area->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR)); } static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op) @@ -5229,12 +5229,12 @@ static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op) const int space_type = RNA_enum_get(op->ptr, "space_type"); PointerRNA ptr; - ScrArea *sa = CTX_wm_area(C); - RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Area, sa, &ptr); + ScrArea *area = CTX_wm_area(C); + RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Area, area, &ptr); PropertyRNA *prop_type = RNA_struct_find_property(&ptr, "type"); PropertyRNA *prop_ui_type = RNA_struct_find_property(&ptr, "ui_type"); - if (sa->spacetype != space_type) { + if (area->spacetype != space_type) { /* Set the type. */ RNA_property_enum_set(&ptr, prop_type, space_type); RNA_property_update(C, &ptr, prop_type); @@ -5293,25 +5293,25 @@ static const EnumPropertyItem space_context_cycle_direction[] = { static bool space_context_cycle_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - /* sa might be NULL if called out of window bounds */ - return (sa && ELEM(sa->spacetype, SPACE_PROPERTIES, SPACE_USERPREF)); + ScrArea *area = CTX_wm_area(C); + /* area might be NULL if called out of window bounds */ + return (area && ELEM(area->spacetype, SPACE_PROPERTIES, SPACE_USERPREF)); } /** * Helper to get the correct RNA pointer/property pair for changing - * the display context of active space type in \a sa. + * the display context of active space type in \a area. */ static void context_cycle_prop_get(bScreen *screen, - const ScrArea *sa, + const ScrArea *area, PointerRNA *r_ptr, PropertyRNA **r_prop) { const char *propname; - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_PROPERTIES: - RNA_pointer_create(&screen->id, &RNA_SpaceProperties, sa->spacedata.first, r_ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceProperties, area->spacedata.first, r_ptr); propname = "context"; break; case SPACE_USERPREF: diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 89b83b3518a..83ded5b3503 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -76,13 +76,13 @@ static int screenshot_data_create(bContext *C, wmOperator *op) if (dumprect) { ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot"); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); scd->dumpsx = dumprect_size[0]; scd->dumpsy = dumprect_size[1]; scd->dumprect = dumprect; - if (sa) { - scd->crop = sa->totrct; + if (area) { + scd->crop = area->totrct; } BKE_imformat_defaults(&scd->im_format); diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c index 276e36b97dc..1e85a6e256f 100644 --- a/source/blender/editors/screen/workspace_layout_edit.c +++ b/source/blender/editors/screen/workspace_layout_edit.c @@ -172,9 +172,9 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon WorkSpaceLayout *old_layout = BKE_workspace_active_layout_get(win->workspace_hook); WorkSpaceLayout *new_layout; const bScreen *old_screen = BKE_workspace_layout_screen_get(old_layout); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (old_screen->temp || (sa && sa->full && sa->full->temp)) { + if (old_screen->temp || (area && area->full && area->full->temp)) { return false; } @@ -188,9 +188,9 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon if (new_layout && (old_layout != new_layout)) { bScreen *new_screen = BKE_workspace_layout_screen_get(new_layout); - if (sa && sa->full) { + if (area && area->full) { /* return to previous state before switching screens */ - ED_screen_full_restore(C, sa); /* may free screen of old_layout */ + ED_screen_full_restore(C, area); /* may free screen of old_layout */ } ED_screen_change(C, new_screen); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index cbb0ce84156..58a85fdff25 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -764,9 +764,9 @@ void PAINT_OT_image_paint(wmOperatorType *ot) bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; if (sima->mode == SI_MODE_PAINT) { ARegion *region = CTX_wm_region(C); ED_space_image_get_zoom(sima, region, zoomx, zoomy); @@ -811,9 +811,9 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene) for (wmWindow *win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - if (((SpaceImage *)sa->spacedata.first)->mode == SI_MODE_PAINT) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + if (((SpaceImage *)area->spacedata.first)->mode == SI_MODE_PAINT) { enabled = true; } } @@ -949,9 +949,9 @@ typedef struct { static void sample_color_update_header(SampleColorData *data, bContext *C) { char msg[UI_MAX_DRAW_STR]; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (sa) { + if (area) { BLI_snprintf(msg, sizeof(msg), TIP_("Sample color for %s"), @@ -1184,10 +1184,10 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) if (ima) { for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 6494e53e182..0b99806109a 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -6224,13 +6224,13 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) int maxsize; char err_out[256] = "unknown"; - ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); - if (!sa) { + ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); + if (!area) { BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); return OPERATOR_CANCELLED; } - ARegion *region = BKE_area_find_region_active_win(sa); + ARegion *region = BKE_area_find_region_active_win(area); if (!region) { BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); return OPERATOR_CANCELLED; @@ -6250,7 +6250,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) /* Create a copy of the overlays where they are all turned off, except the * texture paint overlay opacity */ - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; View3D v3d_copy = *v3d; v3d_copy.gridflag = 0; v3d_copy.flag2 = 0; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 935b9ef9506..e7bc75be45d 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1597,13 +1597,14 @@ bool paint_poll(bContext *C) { Paint *p = BKE_paint_get_active_from_context(C); Object *ob = CTX_data_active_object(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (p && ob && BKE_paint_brush(p) && (sa && ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) && + if (p && ob && BKE_paint_brush(p) && + (area && ELEM(area->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) && (region && region->regiontype == RGN_TYPE_WINDOW)) { /* Check the current tool is a brush. */ - bToolRef *tref = sa->runtime.tool; + bToolRef *tref = area->runtime.tool; if (tref && tref->runtime && tref->runtime->data_block[0]) { return true; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 8934f4d9668..d050a39ce68 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -214,8 +214,8 @@ bool vertex_paint_mode_poll(bContext *C) static bool vertex_paint_poll_ex(bContext *C, bool check_tool) { if (vertex_paint_mode_poll(C) && BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_VIEW3D) { + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_VIEW3D) { ARegion *region = CTX_wm_region(C); if (region->regiontype == RGN_TYPE_WINDOW) { if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) { @@ -247,11 +247,11 @@ bool weight_paint_mode_poll(bContext *C) static bool weight_paint_poll_ex(bContext *C, bool check_tool) { Object *ob = CTX_data_active_object(C); - ScrArea *sa; + ScrArea *area; if ((ob != NULL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && - (sa = CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D)) { + (area = CTX_wm_area(C)) && (area->spacetype == SPACE_VIEW3D)) { ARegion *region = CTX_wm_region(C); if (ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_HUD)) { if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index db138bb907d..d30dce666c4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7973,8 +7973,8 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate for (wmWindow *win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - SpaceLink *sl = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + SpaceLink *sl = area->spacedata.first; if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d != current_v3d) { @@ -7984,7 +7984,7 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate /* Tag all 3D viewports for redraw now that we are done. Others * viewports did not get a full redraw, and anti-aliasing for the * current viewport was deactivated. */ - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { ED_region_tag_redraw(region); } @@ -9267,16 +9267,16 @@ static int sample_detail(bContext *C, int mx, int my, int mode) { /* Find 3D view to pick from. */ bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my); - ARegion *region = (sa) ? BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my) : NULL; + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my); + ARegion *region = (area) ? BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my) : NULL; if (region == NULL) { return OPERATOR_CANCELLED; } /* Set context to 3D view. */ - ScrArea *prev_sa = CTX_wm_area(C); + ScrArea *prev_area = CTX_wm_area(C); ARegion *prev_region = CTX_wm_region(C); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); @@ -9294,7 +9294,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) switch (mode) { case SAMPLE_DETAIL_DYNTOPO: if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) { - CTX_wm_area_set(C, prev_sa); + CTX_wm_area_set(C, prev_area); CTX_wm_region_set(C, prev_region); return OPERATOR_CANCELLED; } @@ -9302,7 +9302,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) break; case SAMPLE_DETAIL_VOXEL: if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { - CTX_wm_area_set(C, prev_sa); + CTX_wm_area_set(C, prev_area); CTX_wm_region_set(C, prev_region); return OPERATOR_CANCELLED; } @@ -9311,7 +9311,7 @@ static int sample_detail(bContext *C, int mx, int my, int mode) } /* Restore context. */ - CTX_wm_area_set(C, prev_sa); + CTX_wm_area_set(C, prev_area); CTX_wm_region_set(C, prev_region); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 6c2cee4042b..beb5d6637ea 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -100,7 +100,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C) /* Create new action */ static bAction *action_create_new(bContext *C, bAction *oldact) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bAction *action; /* create action - the way to do this depends on whether we've got an @@ -124,8 +124,8 @@ static bAction *action_create_new(bContext *C, bAction *oldact) id_us_min(&action->id); /* set ID-Root type */ - if (sa->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + if (area->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction *)area->spacedata.first; if (saction->mode == SACTCONT_SHAPEKEY) { action->idroot = ID_KE; @@ -550,7 +550,7 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot) void ED_animedit_unlink_action( bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* If the old action only has a single user (that it's about to lose), * warn user about it @@ -609,13 +609,13 @@ void ED_animedit_unlink_action( BKE_nla_tweakmode_exit(adt); /* Flush this to the Action Editor (if that's where this change was initiated) */ - if (sa->spacetype == SPACE_ACTION) { + if (area->spacetype == SPACE_ACTION) { actedit_change_action(C, NULL); } } else { /* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */ - if (sa->spacetype == SPACE_ACTION) { + if (area->spacetype == SPACE_ACTION) { /* clear action editor -> action */ actedit_change_action(C, NULL); } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 7abbd2966a3..605d239133a 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -81,7 +81,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) v2d->tot.ymin = -height; /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ - UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); + UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY); /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 64c81797bb4..f3304a48cac 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -60,7 +60,7 @@ /* ******************** default callbacks for action space ***************** */ -static SpaceLink *action_new(const ScrArea *sa, const Scene *scene) +static SpaceLink *action_new(const ScrArea *area, const Scene *scene) { SpaceAction *saction; ARegion *region; @@ -113,7 +113,7 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene) region->regiontype = RGN_TYPE_WINDOW; region->v2d.tot.xmin = (float)(SFRA - 10); - region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; region->v2d.tot.xmax = (float)(EFRA + 10); region->v2d.tot.ymax = 0.0f; @@ -144,9 +144,9 @@ static void action_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback */ -static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *area) { - SpaceAction *saction = sa->spacedata.first; + SpaceAction *saction = area->spacedata.first; saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; } @@ -301,7 +301,7 @@ static void action_header_region_draw(const bContext *C, ARegion *region) } static void action_channel_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -355,12 +355,12 @@ static void saction_channel_region_message_subscribe(const struct bContext *UNUS struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { PointerRNA ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, @@ -397,7 +397,7 @@ static void saction_channel_region_message_subscribe(const struct bContext *UNUS } static void action_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -459,12 +459,12 @@ static void saction_main_region_message_subscribe(const struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { PointerRNA ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, @@ -497,16 +497,16 @@ static void saction_main_region_message_subscribe(const struct bContext *C, } /* Now run the general "channels region" one - since channels and main should be in sync */ - saction_channel_region_message_subscribe(C, workspace, scene, screen, sa, region, mbus); + saction_channel_region_message_subscribe(C, workspace, scene, screen, area, region, mbus); } /* editor level listener */ static void action_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -514,11 +514,11 @@ static void action_listener(wmWindow *UNUSED(win), /* only handle these events in GPencil mode for performance considerations */ if (saction->mode == SACTCONT_GPENCIL) { if (wmn->action == NA_EDITED) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } else if (wmn->action == NA_SELECTED) { saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } break; @@ -526,7 +526,7 @@ static void action_listener(wmWindow *UNUSED(win), /* for NLA tweakmode enter/exit, need complete refresh */ if (wmn->data == ND_NLA_ACTCHANGE) { saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } /* autocolor only really needs to change when channels are added/removed, * or previously hidden stuff appears @@ -534,14 +534,14 @@ static void action_listener(wmWindow *UNUSED(win), */ else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) || ((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED))) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } /* for simple edits to the curve data though (or just plain selections), * a simple redraw should work * (see T39851 for an example of how this can go wrong) */ else { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_SCENE: @@ -549,7 +549,7 @@ static void action_listener(wmWindow *UNUSED(win), case ND_SEQUENCER: if (wmn->action == NA_SELECTED) { saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case ND_OB_ACTIVE: @@ -557,13 +557,13 @@ static void action_listener(wmWindow *UNUSED(win), /* Selection changed, so force refresh to flush * (needs flag set to do syncing). */ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_RENDER_RESULT: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_FRAME_RANGE: - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { Scene *scene = wmn->reference; region->v2d.tot.xmin = (float)(SFRA - 4); @@ -575,7 +575,7 @@ static void action_listener(wmWindow *UNUSED(win), default: if (saction->mode != SACTCONT_TIMELINE) { /* Just redrawing the view will do. */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } @@ -586,7 +586,7 @@ static void action_listener(wmWindow *UNUSED(win), * (needs flag set to do syncing). */ case ND_BONE_ACTIVE: saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_TRANSFORM: /* moving object shouldn't need to redraw action */ @@ -596,12 +596,12 @@ static void action_listener(wmWindow *UNUSED(win), case ND_PARTICLE: /* only needed in timeline mode */ if (saction->mode == SACTCONT_TIMELINE) { - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); } break; default: /* just redrawing the view will do */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; @@ -609,11 +609,11 @@ static void action_listener(wmWindow *UNUSED(win), if (saction->mode == SACTCONT_MASK) { switch (wmn->data) { case ND_DATA: - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); break; default: /* just redrawing the view will do */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } } @@ -622,33 +622,33 @@ static void action_listener(wmWindow *UNUSED(win), if (wmn->action == NA_SELECTED) { /* selection changed, so force refresh to flush (needs flag set to do syncing) */ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_SPACE: switch (wmn->data) { case ND_SPACE_DOPESHEET: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_SPACE_TIME: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_SPACE_CHANGED: saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } break; case NC_WINDOW: if (saction->runtime.flag & SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC) { /* force redraw/refresh after undo/redo - [#28962] */ - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_WM: switch (wmn->data) { case ND_FILEREAD: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } break; @@ -656,12 +656,12 @@ static void action_listener(wmWindow *UNUSED(win), } static void action_header_region_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -733,7 +733,7 @@ static void action_buttons_area_draw(const bContext *C, ARegion *region) } static void action_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -769,9 +769,9 @@ static void action_region_listener(wmWindow *UNUSED(win), } } -static void action_refresh(const bContext *C, ScrArea *sa) +static void action_refresh(const bContext *C, ScrArea *area) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)area->spacedata.first; /* Update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, @@ -789,8 +789,8 @@ static void action_refresh(const bContext *C, ScrArea *sa) * - Regions (such as header) need to be manually tagged for redraw too * or else they don't update [#28962] */ - ED_area_tag_redraw(sa); - for (region = sa->regionbase.first; region; region = region->next) { + ED_area_tag_redraw(area); + for (region = area->regionbase.first; region; region = region->next) { ED_region_tag_redraw(region); } } @@ -799,7 +799,7 @@ static void action_refresh(const bContext *C, ScrArea *sa) // XXX re-sizing y-extents of tot should go here? } -static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void action_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceAction *sact = (SpaceAction *)slink; @@ -820,15 +820,15 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, I * The previous non-timeline mode is stored so switching back to the * dope-sheet doesn't always reset the sub-mode. */ -static int action_space_subtype_get(ScrArea *sa) +static int action_space_subtype_get(ScrArea *area) { - SpaceAction *sact = sa->spacedata.first; + SpaceAction *sact = area->spacedata.first; return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET; } -static void action_space_subtype_set(ScrArea *sa, int value) +static void action_space_subtype_set(ScrArea *area, int value) { - SpaceAction *sact = sa->spacedata.first; + SpaceAction *sact = area->spacedata.first; if (value == SACTCONT_TIMELINE) { if (sact->mode != SACTCONT_TIMELINE) { sact->mode_prev = sact->mode; diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 44d64bd750a..f81aaeb0ee4 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -279,7 +279,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) void ED_spacetype_xxx(void); /* allocate and init some vars */ -static SpaceLink *xxx_new(const ScrArea *UNUSED(sa), const Scene *UNUSED(scene)) +static SpaceLink *xxx_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { return NULL; } @@ -290,7 +290,7 @@ static void xxx_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback for usage, should be redoable */ -static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { /* link area to SpaceXXX struct */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 2fd54db667b..c8488fc13a4 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -110,7 +110,7 @@ static void buttons_free(SpaceLink *sl) } /* spacetype; init callback */ -static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -219,7 +219,7 @@ static void buttons_main_region_layout(const bContext *C, ARegion *region) } static void buttons_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -274,11 +274,11 @@ static void buttons_header_region_message_subscribe(const bContext *UNUSED(C), WorkSpace *UNUSED(workspace), Scene *UNUSED(scene), bScreen *UNUSED(screen), - ScrArea *sa, + ScrArea *area, ARegion *region, struct wmMsgBus *mbus) { - SpaceProperties *sbuts = sa->spacedata.first; + SpaceProperties *sbuts = area->spacedata.first; wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, .user_data = region, @@ -326,7 +326,7 @@ static void buttons_navigation_bar_region_message_subscribe(const bContext *UNUS WorkSpace *UNUSED(workspace), Scene *UNUSED(scene), bScreen *UNUSED(screen), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, struct wmMsgBus *mbus) { @@ -341,96 +341,96 @@ static void buttons_navigation_bar_region_message_subscribe(const bContext *UNUS /* draw a certain button set only if properties area is currently * showing that button set, to reduce unnecessary drawing. */ -static void buttons_area_redraw(ScrArea *sa, short buttons) +static void buttons_area_redraw(ScrArea *area, short buttons) { - SpaceProperties *sbuts = sa->spacedata.first; + SpaceProperties *sbuts = area->spacedata.first; /* if the area's current button set is equal to the one to redraw */ if (sbuts->mainb == buttons) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } } /* reused! */ static void buttons_area_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceProperties *sbuts = sa->spacedata.first; + SpaceProperties *sbuts = area->spacedata.first; /* context changes */ switch (wmn->category) { case NC_SCENE: switch (wmn->data) { case ND_RENDER_OPTIONS: - buttons_area_redraw(sa, BCONTEXT_RENDER); - buttons_area_redraw(sa, BCONTEXT_OUTPUT); - buttons_area_redraw(sa, BCONTEXT_VIEW_LAYER); + buttons_area_redraw(area, BCONTEXT_RENDER); + buttons_area_redraw(area, BCONTEXT_OUTPUT); + buttons_area_redraw(area, BCONTEXT_VIEW_LAYER); break; case ND_WORLD: - buttons_area_redraw(sa, BCONTEXT_WORLD); + buttons_area_redraw(area, BCONTEXT_WORLD); sbuts->preview = 1; break; case ND_FRAME: /* any buttons area can have animated properties so redraw all */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); sbuts->preview = 1; break; case ND_OB_ACTIVE: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); sbuts->preview = 1; break; case ND_KEYINGSET: - buttons_area_redraw(sa, BCONTEXT_SCENE); + buttons_area_redraw(area, BCONTEXT_SCENE); break; case ND_RENDER_RESULT: break; case ND_MODE: case ND_LAYER: default: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; case NC_OBJECT: switch (wmn->data) { case ND_TRANSFORM: - buttons_area_redraw(sa, BCONTEXT_OBJECT); - buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ + buttons_area_redraw(area, BCONTEXT_OBJECT); + buttons_area_redraw(area, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: case ND_BONE_ACTIVE: case ND_BONE_SELECT: - buttons_area_redraw(sa, BCONTEXT_BONE); - buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT); - buttons_area_redraw(sa, BCONTEXT_DATA); + buttons_area_redraw(area, BCONTEXT_BONE); + buttons_area_redraw(area, BCONTEXT_BONE_CONSTRAINT); + buttons_area_redraw(area, BCONTEXT_DATA); break; case ND_MODIFIER: if (wmn->action == NA_RENAME) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } else { - buttons_area_redraw(sa, BCONTEXT_MODIFIER); + buttons_area_redraw(area, BCONTEXT_MODIFIER); } - buttons_area_redraw(sa, BCONTEXT_PHYSICS); + buttons_area_redraw(area, BCONTEXT_PHYSICS); break; case ND_CONSTRAINT: - buttons_area_redraw(sa, BCONTEXT_CONSTRAINT); - buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT); + buttons_area_redraw(area, BCONTEXT_CONSTRAINT); + buttons_area_redraw(area, BCONTEXT_BONE_CONSTRAINT); break; case ND_PARTICLE: if (wmn->action == NA_EDITED) { - buttons_area_redraw(sa, BCONTEXT_PARTICLE); + buttons_area_redraw(area, BCONTEXT_PARTICLE); } sbuts->preview = 1; break; case ND_DRAW: - buttons_area_redraw(sa, BCONTEXT_OBJECT); - buttons_area_redraw(sa, BCONTEXT_DATA); - buttons_area_redraw(sa, BCONTEXT_PHYSICS); + buttons_area_redraw(area, BCONTEXT_OBJECT); + buttons_area_redraw(area, BCONTEXT_DATA); + buttons_area_redraw(area, BCONTEXT_PHYSICS); /* Needed to refresh context path when changing active particle system index. */ - buttons_area_redraw(sa, BCONTEXT_PARTICLE); + buttons_area_redraw(area, BCONTEXT_PARTICLE); break; case ND_SHADING: case ND_SHADING_DRAW: @@ -441,7 +441,7 @@ static void buttons_area_listener(wmWindow *UNUSED(win), break; default: /* Not all object RNA props have a ND_ notifier (yet) */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; @@ -450,12 +450,12 @@ static void buttons_area_listener(wmWindow *UNUSED(win), case ND_SELECT: case ND_DATA: case ND_VERTEX_GROUP: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; case NC_MATERIAL: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); switch (wmn->data) { case ND_SHADING: case ND_SHADING_DRAW: @@ -468,43 +468,43 @@ static void buttons_area_listener(wmWindow *UNUSED(win), } break; case NC_WORLD: - buttons_area_redraw(sa, BCONTEXT_WORLD); + buttons_area_redraw(area, BCONTEXT_WORLD); sbuts->preview = 1; break; case NC_LAMP: - buttons_area_redraw(sa, BCONTEXT_DATA); + buttons_area_redraw(area, BCONTEXT_DATA); sbuts->preview = 1; break; case NC_GROUP: - buttons_area_redraw(sa, BCONTEXT_OBJECT); + buttons_area_redraw(area, BCONTEXT_OBJECT); break; case NC_BRUSH: - buttons_area_redraw(sa, BCONTEXT_TEXTURE); - buttons_area_redraw(sa, BCONTEXT_TOOL); + buttons_area_redraw(area, BCONTEXT_TEXTURE); + buttons_area_redraw(area, BCONTEXT_TOOL); sbuts->preview = 1; break; case NC_TEXTURE: case NC_IMAGE: if (wmn->action != NA_PAINTING) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); sbuts->preview = 1; } break; case NC_SPACE: if (wmn->data == ND_SPACE_PROPERTIES) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_ID: if (wmn->action == NA_RENAME) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_ANIMATION: switch (wmn->data) { case ND_KEYFRAME: if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } @@ -513,14 +513,14 @@ static void buttons_area_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_DATA: if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } break; case NC_NODE: if (wmn->action == NA_SELECTED) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); /* new active node, update texture preview */ if (sbuts->mainb == BCONTEXT_TEXTURE) { sbuts->preview = 1; @@ -530,24 +530,24 @@ static void buttons_area_listener(wmWindow *UNUSED(win), /* Listener for preview render, when doing an global undo. */ case NC_WM: if (wmn->data == ND_UNDO) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); sbuts->preview = 1; } break; #ifdef WITH_FREESTYLE case NC_LINESTYLE: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); sbuts->preview = 1; break; #endif } if (wmn->data == ND_KEYS) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } } -static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void buttons_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceProperties *sbuts = (SpaceProperties *)slink; diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index aef6781ec47..84ab5e6524b 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -292,7 +292,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *region, Scene *scene) void clip_draw_dopesheet_channels(const bContext *C, ARegion *region) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); View2D *v2d = ®ion->v2d; MovieClip *clip = ED_space_clip_get_clip(sc); @@ -316,7 +316,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *region) /* need to do a view-sync here, so that the keys area doesn't jump around * (it must copy this) */ - UI_view2d_sync(NULL, sa, v2d, V2D_LOCK_COPY); + UI_view2d_sync(NULL, area, v2d, V2D_LOCK_COPY); /* loop through channels, and set up drawing depending on their type * first pass: just the standard GL-drawing for backdrop + text diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 62d4a6ae4f0..e174acdea02 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -313,9 +313,9 @@ void ED_clip_update_frame(const Main *mainp, int cfra) for (wmWindow *win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_CLIP) { - SpaceClip *sc = sa->spacedata.first; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_CLIP) { + SpaceClip *sc = area->spacedata.first; sc->scopes.ok = false; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 4dc8d367f2b..27493bb5ccd 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -112,7 +112,7 @@ void CLIP_OT_cursor_set(struct wmOperatorType *ot); void CLIP_OT_lock_selection_toggle(struct wmOperatorType *ot); /* clip_toolbar.c */ -struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa); +struct ARegion *ED_clip_has_properties_region(struct ScrArea *area); /* clip_utils.c */ diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 79050fb4797..48bc885405d 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1533,7 +1533,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) wmJob *wm_job; ProxyJob *pj; Scene *scene = CTX_data_scene(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); @@ -1570,7 +1570,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) G.is_break = false; WM_jobs_start(CTX_wm_manager(C), wm_job); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index 1e3911863fc..b02f3fe16f6 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -53,17 +53,17 @@ /************************** properties ******************************/ -ARegion *ED_clip_has_properties_region(ScrArea *sa) +ARegion *ED_clip_has_properties_region(ScrArea *area) { ARegion *region, *arnew; - region = BKE_area_find_region_type(sa, RGN_TYPE_UI); + region = BKE_area_find_region_type(area, RGN_TYPE_UI); if (region) { return region; } /* add subdiv level; after header */ - region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); /* is error! */ if (region == NULL) { @@ -72,7 +72,7 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa) arnew = MEM_callocN(sizeof(ARegion), "clip properties region"); - BLI_insertlinkafter(&sa->regionbase, region, arnew); + BLI_insertlinkafter(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 82fb429d36c..a68e06951f7 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -71,7 +71,7 @@ #include "clip_intern.h" /* own include */ static void init_preview_region(const Scene *scene, - const ScrArea *sa, + const ScrArea *area, const SpaceClip *sc, ARegion *region) { @@ -81,8 +81,8 @@ static void init_preview_region(const Scene *scene, if (sc->view == SC_VIEW_DOPESHEET) { region->v2d.tot.xmin = -10.0f; - region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; - region->v2d.tot.xmax = (float)(sa->winx); + region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; + region->v2d.tot.xmax = (float)(area->winx); region->v2d.tot.ymax = 0.0f; region->v2d.cur = region->v2d.tot; @@ -133,32 +133,32 @@ static void init_preview_region(const Scene *scene, static void reinit_preview_region(const bContext *C, ARegion *region) { Scene *scene = CTX_data_scene(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); if (sc->view == SC_VIEW_DOPESHEET) { if ((region->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0) { - init_preview_region(scene, sa, sc, region); + init_preview_region(scene, area, sc, region); } } else { if (region->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) { - init_preview_region(scene, sa, sc, region); + init_preview_region(scene, area, sc, region); } } } -static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa) +static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *area) { ARegion *region, *arnew; - region = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW); if (region) { return region; } /* add subdiv level; after header */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); /* is error! */ if (region == NULL) { @@ -167,23 +167,23 @@ static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa) arnew = MEM_callocN(sizeof(ARegion), "clip preview region"); - BLI_insertlinkbefore(&sa->regionbase, region, arnew); - init_preview_region(CTX_data_scene(C), sa, CTX_wm_space_clip(C), arnew); + BLI_insertlinkbefore(&area->regionbase, region, arnew); + init_preview_region(CTX_data_scene(C), area, CTX_wm_space_clip(C), arnew); return arnew; } -static ARegion *ED_clip_has_channels_region(ScrArea *sa) +static ARegion *ED_clip_has_channels_region(ScrArea *area) { ARegion *region, *arnew; - region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS); if (region) { return region; } /* add subdiv level; after header */ - region = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW); /* is error! */ if (region == NULL) { @@ -192,7 +192,7 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa) arnew = MEM_callocN(sizeof(ARegion), "clip channels region"); - BLI_insertlinkbefore(&sa->regionbase, region, arnew); + BLI_insertlinkbefore(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_CHANNELS; arnew->alignment = RGN_ALIGN_LEFT; @@ -202,9 +202,9 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa) return arnew; } -static void clip_scopes_tag_refresh(ScrArea *sa) +static void clip_scopes_tag_refresh(ScrArea *area) { - SpaceClip *sc = (SpaceClip *)sa->spacedata.first; + SpaceClip *sc = (SpaceClip *)area->spacedata.first; ARegion *region; if (sc->mode != SC_MODE_TRACKING) { @@ -212,7 +212,7 @@ static void clip_scopes_tag_refresh(ScrArea *sa) } /* only while properties are visible */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_UI && region->flag & RGN_FLAG_HIDDEN) { return; } @@ -221,24 +221,24 @@ static void clip_scopes_tag_refresh(ScrArea *sa) sc->scopes.ok = false; } -static void clip_scopes_check_gpencil_change(ScrArea *sa) +static void clip_scopes_check_gpencil_change(ScrArea *area) { - SpaceClip *sc = (SpaceClip *)sa->spacedata.first; + SpaceClip *sc = (SpaceClip *)area->spacedata.first; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { - clip_scopes_tag_refresh(sa); + clip_scopes_tag_refresh(area); } } -static void clip_area_sync_frame_from_scene(ScrArea *sa, Scene *scene) +static void clip_area_sync_frame_from_scene(ScrArea *area, Scene *scene) { - SpaceClip *space_clip = (SpaceClip *)sa->spacedata.first; + SpaceClip *space_clip = (SpaceClip *)area->spacedata.first; BKE_movieclip_user_set_frame(&space_clip->user, scene->r.cfra); } /* ******************** default callbacks for clip space ***************** */ -static SpaceLink *clip_new(const ScrArea *sa, const Scene *scene) +static SpaceLink *clip_new(const ScrArea *area, const Scene *scene) { ARegion *region; SpaceClip *sc; @@ -287,7 +287,7 @@ static SpaceLink *clip_new(const ScrArea *sa, const Scene *scene) region = MEM_callocN(sizeof(ARegion), "preview for clip"); BLI_addtail(&sc->regionbase, region); - init_preview_region(scene, sa, sc, region); + init_preview_region(scene, area, sc, region); /* main region */ region = MEM_callocN(sizeof(ARegion), "main region for clip"); @@ -315,12 +315,12 @@ static void clip_free(SpaceLink *sl) } /* spacetype; init callback */ -static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *area) { ListBase *lb = WM_dropboxmap_find("Clip", SPACE_CLIP, 0); /* add drop boxes */ - WM_event_add_dropbox_handler(&sa->handlers, lb); + WM_event_add_dropbox_handler(&area->handlers, lb); } static SpaceLink *clip_duplicate(SpaceLink *sl) @@ -335,18 +335,18 @@ static SpaceLink *clip_duplicate(SpaceLink *sl) return (SpaceLink *)scn; } -static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *scene) +static void clip_listener(wmWindow *UNUSED(win), ScrArea *area, wmNotifier *wmn, Scene *scene) { /* context changes */ switch (wmn->category) { case NC_SCENE: switch (wmn->data) { case ND_FRAME: - clip_scopes_tag_refresh(sa); + clip_scopes_tag_refresh(area); ATTR_FALLTHROUGH; case ND_FRAME_RANGE: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; @@ -354,8 +354,8 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S switch (wmn->data) { case ND_DISPLAY: case ND_SELECT: - clip_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + clip_scopes_tag_refresh(area); + ED_area_tag_redraw(area); break; } switch (wmn->action) { @@ -365,8 +365,8 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S /* fall-through */ case NA_SELECTED: - clip_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + clip_scopes_tag_refresh(area); + ED_area_tag_redraw(area); break; } break; @@ -375,56 +375,56 @@ static void clip_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, S case ND_SELECT: case ND_DATA: case ND_DRAW: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } switch (wmn->action) { case NA_SELECTED: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case NA_EDITED: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; case NC_GEOM: switch (wmn->data) { case ND_SELECT: - clip_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + clip_scopes_tag_refresh(area); + ED_area_tag_redraw(area); break; } break; case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_LAYOUTSET: - clip_area_sync_frame_from_scene(sa, scene); + clip_area_sync_frame_from_scene(area, scene); break; } break; case NC_SPACE: if (wmn->data == ND_SPACE_CLIP) { - clip_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + clip_scopes_tag_refresh(area); + ED_area_tag_redraw(area); } break; case NC_GPENCIL: if (wmn->action == NA_EDITED) { - clip_scopes_check_gpencil_change(sa); - ED_area_tag_redraw(sa); + clip_scopes_check_gpencil_change(area); + ED_area_tag_redraw(area); } else if (wmn->data & ND_GPENCIL_EDITMODE) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_WM: switch (wmn->data) { case ND_FILEREAD: case ND_UNDO: - clip_area_sync_frame_from_scene(sa, scene); + clip_area_sync_frame_from_scene(area, scene); break; } break; @@ -639,17 +639,17 @@ static void clip_dropboxes(void) WM_dropbox_add(lb, "CLIP_OT_open", clip_drop_poll, clip_drop_copy); } -static void clip_refresh(const bContext *C, ScrArea *sa) +static void clip_refresh(const bContext *C, ScrArea *area) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *window = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); - SpaceClip *sc = (SpaceClip *)sa->spacedata.first; - ARegion *region_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - ARegion *region_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); - ARegion *region_preview = ED_clip_has_preview_region(C, sa); - ARegion *region_properties = ED_clip_has_properties_region(sa); - ARegion *region_channels = ED_clip_has_channels_region(sa); + SpaceClip *sc = (SpaceClip *)area->spacedata.first; + ARegion *region_main = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + ARegion *region_tools = BKE_area_find_region_type(area, RGN_TYPE_TOOLS); + ARegion *region_preview = ED_clip_has_preview_region(C, area); + ARegion *region_properties = ED_clip_has_properties_region(area); + ARegion *region_channels = ED_clip_has_channels_region(area); bool main_visible = false, preview_visible = false, tools_visible = false; bool properties_visible = false, channels_visible = false; bool view_changed = false; @@ -805,8 +805,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa) } if (view_changed) { - ED_area_initialize(wm, window, sa); - ED_area_tag_redraw(sa); + ED_area_initialize(wm, window, area); + ED_area_tag_redraw(area); } BKE_movieclip_user_set_frame(&sc->user, scene->r.cfra); @@ -946,9 +946,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *region) if (sc->mode == SC_MODE_MASKEDIT) { Mask *mask = CTX_data_edit_mask(C); if (mask && clip) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); int mask_width, mask_height; - ED_mask_get_size(sa, &mask_width, &mask_height); + ED_mask_get_size(area, &mask_width, &mask_height); ED_mask_draw_region(CTX_data_expect_evaluated_depsgraph(C), mask, region, @@ -1001,7 +1001,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *region) } static void clip_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1145,7 +1145,7 @@ static void clip_preview_region_draw(const bContext *C, ARegion *region) } static void clip_preview_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -1191,7 +1191,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *region) } static void clip_channels_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -1212,7 +1212,7 @@ static void clip_header_region_draw(const bContext *C, ARegion *region) } static void clip_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1255,7 +1255,7 @@ static void clip_tools_region_draw(const bContext *C, ARegion *region) /****************** tool properties region ******************/ static void clip_props_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1308,7 +1308,7 @@ static void clip_properties_region_draw(const bContext *C, ARegion *region) } static void clip_properties_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1330,7 +1330,7 @@ static void clip_properties_region_listener(wmWindow *UNUSED(win), /********************* registration ********************/ -static void clip_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void clip_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceClip *sclip = (SpaceClip *)slink; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 58d6fb425b0..981e056fa63 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -353,10 +353,10 @@ static int console_move_exec(bContext *C, wmOperator *op) } if (done) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); console_scroll_bottom(region); } @@ -860,7 +860,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op) { SpaceConsole *sc = CTX_wm_space_console(C); ARegion *region = CTX_wm_region(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ConsoleLine *ci = console_history_verify(C); /* own this text in the new line, don't free */ char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); @@ -885,7 +885,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op) console_select_offset(sc, ci->len - prev_len); console_line_cursor_set(ci, cursor); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); /* when calling render modally this can be NULL when calling: * bpy.ops.render.render('INVOKE_DEFAULT') */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 66aa92275b4..d8c097cad37 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -98,7 +98,7 @@ static void console_free(SpaceLink *sl) } /* spacetype; init callback */ -static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -146,7 +146,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region) } /* same as 'text_cursor' */ -static void console_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *region) +static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region) { int wmcursor = WM_CURSOR_TEXT_EDIT; const wmEvent *event = win->eventstate; @@ -278,19 +278,19 @@ static void console_header_region_draw(const bContext *C, ARegion *region) } static void console_main_region_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { - // SpaceInfo *sinfo = sa->spacedata.first; + // SpaceInfo *sinfo = area->spacedata.first; /* context changes */ switch (wmn->category) { case NC_SPACE: { if (wmn->data == ND_SPACE_CONSOLE) { if (wmn->action == NA_EDITED) { - if ((wmn->reference && sa) && (wmn->reference == sa->spacedata.first)) { + if ((wmn->reference && area) && (wmn->reference == area->spacedata.first)) { /* we've modified the geometry (font size), re-calculate rect */ console_textview_update_rect(wmn->reference, region); ED_region_tag_redraw(region); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 8c963e32046..7cce243696d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -851,7 +851,7 @@ void FILE_OT_select_walk(wmOperatorType *ot) static int file_select_all_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); FileSelection sel; const int numfiles = filelist_files_ensure(sfile->files); @@ -900,7 +900,7 @@ static int file_select_all_exec(bContext *C, wmOperator *op) file_draw_check(C); WM_event_add_mousemove(CTX_wm_window(C)); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } @@ -975,7 +975,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); struct FSMenu *fsmenu = ED_fsmenu_get(); struct FileSelectParams *params = ED_fileselect_get_params(sfile); @@ -992,8 +992,8 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) fsmenu_write_file(fsmenu, name); } - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } @@ -1017,7 +1017,7 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) static int bookmark_delete_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); struct FSMenu *fsmenu = ED_fsmenu_get(); int nentries = ED_fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); @@ -1041,8 +1041,8 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); } } @@ -1075,7 +1075,7 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot) static int bookmark_cleanup_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); struct FSMenu *fsmenu = ED_fsmenu_get(); struct FSMenuEntry *fsme_next, *fsme = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); int index; @@ -1102,8 +1102,8 @@ static int bookmark_cleanup_exec(bContext *C, wmOperator *UNUSED(op)) BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); fsmenu_refresh_bookmarks_status(CTX_wm_manager(C), fsmenu); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); } return OPERATOR_FINISHED; @@ -1138,7 +1138,7 @@ enum { static int bookmark_move_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); struct FSMenu *fsmenu = ED_fsmenu_get(); struct FSMenuEntry *fsmentry = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); @@ -1187,7 +1187,7 @@ static int bookmark_move_exec(bContext *C, wmOperator *op) BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, fname); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } @@ -1228,7 +1228,7 @@ void FILE_OT_bookmark_move(wmOperatorType *ot) static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); char name[FILE_MAX]; struct FSMenu *fsmenu = ED_fsmenu_get(); @@ -1240,7 +1240,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } @@ -1867,7 +1867,7 @@ void FILE_OT_next(struct wmOperatorType *ot) /* only meant for timer usage */ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = CTX_wm_space_file(C); ARegion *region, *region_ctx = CTX_wm_region(C); const bool is_horizontal = (sfile->layout->flag & FILE_LAYOUT_HOR) != 0; @@ -1911,7 +1911,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w } /* we need the correct area for scrolling */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (!region || region->regiontype != RGN_TYPE_WINDOW) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); sfile->smoothscroll_timer = NULL; @@ -2521,12 +2521,12 @@ static void filenum_newname(char *name, size_t name_size, int add) static int file_filenum_exec(bContext *C, wmOperator *op) { SpaceFile *sfile = CTX_wm_space_file(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); if (sfile->params && (inc != 0)) { filenum_newname(sfile->params->file, sizeof(sfile->params->file), inc); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); file_draw_check(C); // WM_event_add_notifier(C, NC_WINDOW, NULL); } @@ -2576,12 +2576,12 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); if (sfile->params) { file_rename_state_activate(sfile, sfile->params->active_file, true); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } return OPERATOR_FINISHED; @@ -2589,12 +2589,12 @@ static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); if (sfile->params) { file_rename_state_activate(sfile, sfile->params->highlight_file, false); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } return OPERATOR_FINISHED; @@ -2708,8 +2708,8 @@ void FILE_OT_delete(struct wmOperatorType *ot) static int file_start_filter_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_UI); + ScrArea *area = CTX_wm_area(C); + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_UI); SpaceFile *sf = CTX_wm_space_file(C); UI_textbutton_activate_rna(C, region, sf->params, "filter_search"); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 59383626972..21b705cbb44 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -55,16 +55,16 @@ #include "filelist.h" #include "fsmenu.h" -static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *region_prev) +static ARegion *file_execute_region_ensure(ScrArea *area, ARegion *region_prev) { ARegion *region; - if ((region = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE)) != NULL) { + if ((region = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE)) != NULL) { return region; } region = MEM_callocN(sizeof(ARegion), "execute region for file"); - BLI_insertlinkafter(&sa->regionbase, region_prev, region); + BLI_insertlinkafter(&area->regionbase, region_prev, region); region->regiontype = RGN_TYPE_EXECUTE; region->alignment = RGN_ALIGN_BOTTOM; region->flag = RGN_FLAG_DYNAMIC_SIZE; @@ -72,17 +72,17 @@ static ARegion *file_execute_region_ensure(ScrArea *sa, ARegion *region_prev) return region; } -static ARegion *file_tool_props_region_ensure(ScrArea *sa, ARegion *region_prev) +static ARegion *file_tool_props_region_ensure(ScrArea *area, ARegion *region_prev) { ARegion *region; - if ((region = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS)) != NULL) { + if ((region = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS)) != NULL) { return region; } /* add subdiv level; after execute region */ region = MEM_callocN(sizeof(ARegion), "tool props for file"); - BLI_insertlinkafter(&sa->regionbase, region_prev, region); + BLI_insertlinkafter(&area->regionbase, region_prev, region); region->regiontype = RGN_TYPE_TOOL_PROPS; region->alignment = RGN_ALIGN_RIGHT; @@ -173,18 +173,18 @@ static void file_free(SpaceLink *sl) } /* spacetype; init callback, area size changes, screen set, etc */ -static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa) +static void file_init(wmWindowManager *UNUSED(wm), ScrArea *area) { - SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)area->spacedata.first; if (sfile->layout) { sfile->layout->dirty = true; } } -static void file_exit(wmWindowManager *wm, ScrArea *sa) +static void file_exit(wmWindowManager *wm, ScrArea *area) { - SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)area->spacedata.first; if (sfile->previews_timer) { WM_event_remove_timer_notifier(wm, NULL, sfile->previews_timer); @@ -228,19 +228,19 @@ static SpaceLink *file_duplicate(SpaceLink *sl) static void file_ensure_valid_region_state(bContext *C, wmWindowManager *wm, wmWindow *win, - ScrArea *sa, + ScrArea *area, SpaceFile *sfile, FileSelectParams *params) { - ARegion *region_ui = BKE_area_find_region_type(sa, RGN_TYPE_UI); - ARegion *region_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS); - ARegion *region_execute = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE); + ARegion *region_ui = BKE_area_find_region_type(area, RGN_TYPE_UI); + ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS); + ARegion *region_execute = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE); bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */ /* If there's an file-operation, ensure we have the option and execute region */ if (sfile->op && (region_props == NULL)) { - region_execute = file_execute_region_ensure(sa, region_ui); - region_props = file_tool_props_region_ensure(sa, region_execute); + region_execute = file_execute_region_ensure(area, region_ui); + region_props = file_tool_props_region_ensure(area, region_execute); if (params->flag & FILE_HIDE_TOOL_PROPS) { region_props->flag |= RGN_FLAG_HIDDEN; @@ -255,17 +255,17 @@ static void file_ensure_valid_region_state(bContext *C, else if ((sfile->op == NULL) && (region_props != NULL)) { BLI_assert(region_execute != NULL); - ED_region_remove(C, sa, region_props); - ED_region_remove(C, sa, region_execute); + ED_region_remove(C, area, region_props); + ED_region_remove(C, area, region_execute); needs_init = true; } if (needs_init) { - ED_area_initialize(wm, win, sa); + ED_area_initialize(wm, win, area); } } -static void file_refresh(const bContext *C, ScrArea *sa) +static void file_refresh(const bContext *C, ScrArea *area) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); @@ -333,34 +333,34 @@ static void file_refresh(const bContext *C, ScrArea *sa) sfile->layout->dirty = true; } - /* Might be called with NULL sa, see file_main_region_draw() below. */ - if (sa) { - file_ensure_valid_region_state((bContext *)C, wm, win, sa, sfile, params); + /* Might be called with NULL area, see file_main_region_draw() below. */ + if (area) { + file_ensure_valid_region_state((bContext *)C, wm, win, area, sfile, params); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } static void file_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)area->spacedata.first; /* context changes */ switch (wmn->category) { case NC_SPACE: switch (wmn->data) { case ND_SPACE_FILE_LIST: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_SPACE_FILE_PARAMS: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_SPACE_FILE_PREVIEW: if (sfile->files && filelist_cache_previews_update(sfile->files)) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; } @@ -384,7 +384,7 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *region) } static void file_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -408,18 +408,18 @@ static void file_main_region_message_subscribe(const struct bContext *UNUSED(C), struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { - SpaceFile *sfile = sa->spacedata.first; + SpaceFile *sfile = area->spacedata.first; FileSelectParams *params = ED_fileselect_get_params(sfile); /* This is a bit odd that a region owns the subscriber for an area, * keep for now since all subscribers for WM are regions. * May be worth re-visiting later. */ wmMsgSubscribeValue msg_sub_value_area_tag_refresh = { .owner = region, - .user_data = sa, + .user_data = area, .notify = ED_area_do_msg_notify_tag_refresh, }; @@ -575,7 +575,7 @@ static void file_tools_region_draw(const bContext *C, ARegion *region) } static void file_tools_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -643,7 +643,7 @@ static void file_execution_region_draw(const bContext *C, ARegion *region) } static void file_ui_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 6096c27fc8c..08053dba4d9 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1336,7 +1336,7 @@ static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float erro typedef struct tDecimateGraphOp { bAnimContext ac; Scene *scene; - ScrArea *sa; + ScrArea *area; ARegion *region; /** A 0-1 value for determining how much we should decimate. */ @@ -1409,7 +1409,7 @@ static void decimate_exit(bContext *C, wmOperator *op) return; } - ScrArea *sa = dgo->sa; + ScrArea *area = dgo->area; LinkData *link; for (link = dgo->bezt_arr_list.first; link != NULL; link = link->next) { @@ -1423,7 +1423,7 @@ static void decimate_exit(bContext *C, wmOperator *op) /* Return to normal cursor and header status. */ WM_cursor_modal_restore(win); - ED_area_status_text(sa, NULL); + ED_area_status_text(area, NULL); /* cleanup */ op->customdata = NULL; @@ -1450,7 +1450,7 @@ static void decimate_draw_status_header(wmOperator *op, tDecimateGraphOp *dgo) status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(percentage * 100.0f)); } - ED_area_status_text(dgo->sa, status_str); + ED_area_status_text(dgo->area, status_str); } /* Calculate percentage based on position of mouse (we only use x-axis for now. @@ -1482,7 +1482,7 @@ static int graphkeys_decimate_invoke(bContext *C, wmOperator *op, const wmEvent dgo->percentage_prop = RNA_struct_find_property(op->ptr, "remove_ratio"); dgo->scene = CTX_data_scene(C); - dgo->sa = CTX_wm_area(C); + dgo->area = CTX_wm_area(C); dgo->region = CTX_wm_region(C); /* initialise percentage so that it will have the correct value before the first mouse move. */ @@ -3623,10 +3623,10 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) static bool graph_driver_delete_invalid_poll(bContext *C) { bAnimContext ac; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* firstly, check if in Graph Editor */ - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { + if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) { return 0; } diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 34c1958734d..575cba07f04 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -54,32 +54,32 @@ /* Set up UI configuration for Drivers Editor */ /* NOTE: Currently called from windowmanager * (new drivers editor window) and RNA (mode switching) */ -void ED_drivers_editor_init(bContext *C, ScrArea *sa) +void ED_drivers_editor_init(bContext *C, ScrArea *area) { - SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first; /* Set mode */ sipo->mode = SIPO_MODE_DRIVERS; /* Show Properties Region (or else the settings can't be edited) */ - ARegion *region_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); + ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_UI); if (region_props) { UI_panel_category_active_set(region_props, "Drivers"); region_props->flag &= ~RGN_FLAG_HIDDEN; /* XXX: Adjust width of this too? */ - ED_region_visibility_change_update(C, sa, region_props); + ED_region_visibility_change_update(C, area, region_props); } else { - printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa); + printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, area); } /* Adjust framing in graph region */ /* TODO: Have a way of not resetting this every time? * (e.g. So that switching back and forth between editors doesn't keep jumping?) */ - ARegion *region_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *region_main = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region_main) { /* XXX: Ideally we recenter based on the range instead... */ region_main->v2d.tot.xmin = -2.0f; @@ -135,14 +135,14 @@ bool graphop_visible_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); size_t items; int filter; short found = 0; /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { + if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) { return 0; } @@ -188,14 +188,14 @@ bool graphop_editable_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); size_t items; int filter; short found = 0; /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { + if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) { return 0; } @@ -241,12 +241,12 @@ bool graphop_active_fcurve_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bool has_fcurve = 0; /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { + if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) { return 0; } @@ -293,13 +293,13 @@ bool graphop_selected_fcurve_poll(bContext *C) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); size_t items; int filter; /* firstly, check if in Graph Editor */ // TODO: also check for region? - if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) { + if ((area == NULL) || (area->spacetype != SPACE_GRAPH)) { return 0; } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 05edfccd6a8..bd82b8ecf2e 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -64,7 +64,7 @@ /* ******************** default callbacks for ipo space ***************** */ -static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene) +static SpaceLink *graph_new(const ScrArea *UNUSED(area), const Scene *scene) { ARegion *region; SpaceGraph *sipo; @@ -150,9 +150,9 @@ static void graph_free(SpaceLink *sl) } /* spacetype; init callback */ -static void graph_init(struct wmWindowManager *wm, ScrArea *sa) +static void graph_init(struct wmWindowManager *wm, ScrArea *area) { - SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first; /* init dopesheet data if non-existent (i.e. for old files) */ if (sipo->ads == NULL) { @@ -165,7 +165,7 @@ static void graph_init(struct wmWindowManager *wm, ScrArea *sa) * as this is run on each region resize; setting this here will cause selection * state to be lost on area/region resizing. [#35744] */ - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } static SpaceLink *graph_duplicate(SpaceLink *sl) @@ -413,7 +413,7 @@ static void graph_buttons_region_draw(const bContext *C, ARegion *region) } static void graph_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -483,12 +483,12 @@ static void graph_region_message_subscribe(const struct bContext *UNUSED(C), struct WorkSpace *UNUSED(workspace), struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { PointerRNA ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sa->spacedata.first, &ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, area->spacedata.first, &ptr); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, @@ -556,11 +556,11 @@ static void graph_region_message_subscribe(const struct bContext *UNUSED(C), /* editor level listener */ static void graph_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -568,10 +568,10 @@ static void graph_listener(wmWindow *UNUSED(win), /* for selection changes of animation data, we can just redraw... * otherwise autocolor might need to be done again */ if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } else { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_SCENE: @@ -580,11 +580,11 @@ static void graph_listener(wmWindow *UNUSED(win), * (needs flag set to do syncing). */ case ND_OB_SELECT: sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; default: /* just redrawing the view will do */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; @@ -594,13 +594,13 @@ static void graph_listener(wmWindow *UNUSED(win), * (needs flag set to do syncing). */ case ND_BONE_ACTIVE: sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_TRANSFORM: break; /*do nothing*/ default: /* just redrawing the view will do */ - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; @@ -608,26 +608,26 @@ static void graph_listener(wmWindow *UNUSED(win), if (wmn->action == NA_SELECTED) { /* selection changed, so force refresh to flush (needs flag set to do syncing) */ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_SPACE: if (wmn->data == ND_SPACE_GRAPH) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_WINDOW: if (sipo->runtime.flag & (SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC | SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR)) { /* force redraw/refresh after undo/redo - prevents "black curve" problem */ - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; // XXX: restore the case below if not enough updates occur... // default: // if (wmn->data == ND_KEYS) - // ED_area_tag_redraw(sa); + // ED_area_tag_redraw(area); } } @@ -754,9 +754,9 @@ static void graph_refresh_fcurve_colors(const bContext *C) ANIM_animdata_freelist(&anim_data); } -static void graph_refresh(const bContext *C, ScrArea *sa) +static void graph_refresh(const bContext *C, ScrArea *area) { - SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)area->spacedata.first; /* updates to data needed depends on Graph Editor mode... */ switch (sipo->mode) { @@ -780,7 +780,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC) { ANIM_sync_animchannels_to_data(C); sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC; - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } /* We could check 'SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR', but color is recalculated anyway. */ @@ -789,7 +789,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) #if 0 /* Done below. */ graph_refresh_fcurve_colors(C); #endif - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } sipo->runtime.flag &= ~(SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT | @@ -799,7 +799,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) graph_refresh_fcurve_colors(C); } -static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void graph_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceGraph *sgraph = (SpaceGraph *)slink; @@ -813,15 +813,15 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } -static int graph_space_subtype_get(ScrArea *sa) +static int graph_space_subtype_get(ScrArea *area) { - SpaceGraph *sgraph = sa->spacedata.first; + SpaceGraph *sgraph = area->spacedata.first; return sgraph->mode; } -static void graph_space_subtype_set(ScrArea *sa, int value) +static void graph_space_subtype_set(ScrArea *area, int value) { - SpaceGraph *sgraph = sa->spacedata.first; + SpaceGraph *sgraph = area->spacedata.first; sgraph->mode = value; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index c0b1efe0b73..38f67623c99 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1291,7 +1291,7 @@ static Image *image_open_single(Main *bmain, static int image_open_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); ImageUser *iuser = NULL; @@ -1345,8 +1345,8 @@ static int image_open_exec(bContext *C, wmOperator *op) if (iod->iuser) { iuser = iod->iuser; } - else if (sa && sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + else if (area && area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; ED_space_image_set(bmain, sima, obedit, ima, false); iuser = &sima->iuser; } @@ -3409,13 +3409,13 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event // XXX node curve integration .. #if 0 { - ScrArea *sa, *cur = curarea; + ScrArea *area, *cur = curarea; node_curvemap_sample(fp); /* sends global to node editor */ - for (sa = G.curscreen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_NODE) { - areawinset(sa->win); - scrarea_do_windraw(sa); + for (area = G.curscreen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_NODE) { + areawinset(area->win); + scrarea_do_windraw(area); } } node_curvemap_sample(NULL); /* clears global in node editor */ diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c index 8f9f4189c8a..5f81c19290b 100644 --- a/source/blender/editors/space_image/image_undo.c +++ b/source/blender/editors/space_image/image_undo.c @@ -733,9 +733,9 @@ static bool image_undosys_poll(bContext *C) { Object *obact = CTX_data_active_object(C); - ScrArea *sa = CTX_wm_area(C); - if (sa && (sa->spacetype == SPACE_IMAGE)) { - SpaceImage *sima = (SpaceImage *)sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area && (area->spacetype == SPACE_IMAGE)) { + SpaceImage *sima = (SpaceImage *)area->spacedata.first; if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { return true; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 12a1dce3a5f..af94b5b6e21 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -83,13 +83,13 @@ /**************************** common state *****************************/ -static void image_scopes_tag_refresh(ScrArea *sa) +static void image_scopes_tag_refresh(ScrArea *area) { - SpaceImage *sima = (SpaceImage *)sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)area->spacedata.first; ARegion *region; /* only while histogram is visible */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_TOOL_PROPS && region->flag & RGN_FLAG_HIDDEN) { return; } @@ -186,12 +186,12 @@ static void image_free(SpaceLink *sl) } /* spacetype; init callback, add handlers */ -static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *area) { ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0); /* add drop boxes */ - WM_event_add_dropbox_handler(&sa->handlers, lb); + WM_event_add_dropbox_handler(&area->handlers, lb); } static SpaceLink *image_duplicate(SpaceLink *sl) @@ -298,10 +298,10 @@ static void image_dropboxes(void) * \note take care not to get into feedback loop here, * calling composite job causes viewer to refresh. */ -static void image_refresh(const bContext *C, ScrArea *sa) +static void image_refresh(const bContext *C, ScrArea *area) { Scene *scene = CTX_data_scene(C); - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; Image *ima; ima = ED_space_image(sima); @@ -318,53 +318,53 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } -static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) +static void image_listener(wmWindow *win, ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceImage *sima = (SpaceImage *)sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)area->spacedata.first; /* context changes */ switch (wmn->category) { case NC_WINDOW: /* notifier comes from editing color space */ - image_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + image_scopes_tag_refresh(area); + ED_area_tag_redraw(area); break; case NC_SCENE: switch (wmn->data) { case ND_FRAME: - image_scopes_tag_refresh(sa); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + image_scopes_tag_refresh(area); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); break; case ND_MODE: if (wmn->subtype == NS_EDITMODE_MESH) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_RENDER_RESULT: case ND_RENDER_OPTIONS: case ND_COMPO_RESULT: if (ED_space_image_show_render(sima)) { - image_scopes_tag_refresh(sa); + image_scopes_tag_refresh(area); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } break; case NC_IMAGE: if (wmn->reference == sima->image || !wmn->reference) { if (wmn->action != NA_PAINTING) { - image_scopes_tag_refresh(sa); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + image_scopes_tag_refresh(area); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); } } break; case NC_SPACE: if (wmn->data == ND_SPACE_IMAGE) { - image_scopes_tag_refresh(sa); - ED_area_tag_redraw(sa); + image_scopes_tag_refresh(area); + ED_area_tag_redraw(area); } break; case NC_MASK: { @@ -374,23 +374,23 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U if (sima->mode == SI_MODE_MASK) { switch (wmn->data) { case ND_SELECT: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_DATA: case ND_DRAW: /* causes node-recalc */ - ED_area_tag_redraw(sa); - ED_area_tag_refresh(sa); + ED_area_tag_redraw(area); + ED_area_tag_refresh(area); break; } switch (wmn->action) { case NA_SELECTED: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case NA_EDITED: /* causes node-recalc */ - ED_area_tag_redraw(sa); - ED_area_tag_refresh(sa); + ED_area_tag_redraw(area); + ED_area_tag_refresh(area); break; } } @@ -400,9 +400,9 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U switch (wmn->data) { case ND_DATA: case ND_SELECT: - image_scopes_tag_refresh(sa); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + image_scopes_tag_refresh(area); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); break; } break; @@ -415,8 +415,8 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U Object *ob = OBACT(view_layer); if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) { if (sima->lock && (sima->flag & SI_DRAWSHADOW)) { - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + ED_area_tag_refresh(area); + ED_area_tag_redraw(area); } } break; @@ -427,14 +427,14 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U } case NC_ID: { if (wmn->action == NA_RENAME) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } case NC_WM: if (wmn->data == ND_UNDO) { - ED_area_tag_redraw(sa); - ED_area_tag_refresh(sa); + ED_area_tag_redraw(area); + ED_area_tag_refresh(area); } break; } @@ -756,7 +756,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region) } static void image_main_region_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -784,7 +784,7 @@ static void image_main_region_listener(wmWindow *UNUSED(win), break; case NC_MATERIAL: if (wmn->data == ND_SHADING_LINKS) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) { ED_region_tag_redraw(region); @@ -873,7 +873,7 @@ static void image_buttons_region_draw(const bContext *C, ARegion *region) } static void image_buttons_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -936,7 +936,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *region) } static void image_tools_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -984,8 +984,8 @@ static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *regio static void image_header_region_draw(const bContext *C, ARegion *region) { - ScrArea *sa = CTX_wm_area(C); - SpaceImage *sima = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + SpaceImage *sima = area->spacedata.first; image_user_refresh_scene(C, sima); @@ -993,7 +993,7 @@ static void image_header_region_draw(const bContext *C, ARegion *region) } static void image_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1024,7 +1024,7 @@ static void image_header_region_listener(wmWindow *UNUSED(win), } } -static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void image_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceImage *simg = (SpaceImage *)slink; @@ -1054,15 +1054,15 @@ static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID * The previous non-uv-edit mode is stored so switching back to the * image doesn't always reset the sub-mode. */ -static int image_space_subtype_get(ScrArea *sa) +static int image_space_subtype_get(ScrArea *area) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW; } -static void image_space_subtype_set(ScrArea *sa, int value) +static void image_space_subtype_set(ScrArea *area, int value) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; if (value == SI_MODE_UV) { if (sima->mode != SI_MODE_UV) { sima->mode_prev = sima->mode; diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 58ce3316c4b..04df0f0d4f0 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -97,7 +97,7 @@ static void info_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback */ -static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -209,12 +209,12 @@ static void info_header_region_draw(const bContext *C, ARegion *region) } static void info_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { - // SpaceInfo *sinfo = sa->spacedata.first; + // SpaceInfo *sinfo = area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -228,7 +228,7 @@ static void info_main_region_listener(wmWindow *UNUSED(win), } static void info_header_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -267,7 +267,7 @@ static void info_header_region_message_subscribe(const bContext *UNUSED(C), WorkSpace *UNUSED(workspace), Scene *UNUSED(scene), bScreen *UNUSED(screen), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, struct wmMsgBus *mbus) { diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index d3c93f6a5b6..5a59ba6b553 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -828,7 +828,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region) /* need to do a view-sync here, so that the keys area doesn't jump around * (it must copy this) */ - UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); + UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY); /* draw channels */ { /* first pass: just the standard GL-drawing for backdrop + text */ diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 2427001657a..5b949911158 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1506,7 +1506,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *stripN = NULL; - NlaStrip *sa = NULL, *sb = NULL; + NlaStrip *area = NULL, *sb = NULL; /* make temporary metastrips so that entire islands of selections can be moved around */ BKE_nlastrips_make_metas(&nlt->strips, 1); @@ -1533,9 +1533,9 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) if (strip->flag & NLASTRIP_FLAG_SELECT) { /* first or second strip? */ - if (sa == NULL) { + if (area == NULL) { /* store as first */ - sa = strip; + area = strip; } else if (sb == NULL) { /* store as second */ @@ -1556,7 +1556,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", nlt->name); } - else if (sa == NULL) { + else if (area == NULL) { /* no warning as this is just a common case, * and it may get annoying when doing multiple tracks */ } @@ -1573,24 +1573,24 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) /* remove these strips from the track, * so that we can test if they can fit in the proposed places */ - BLI_remlink(&nlt->strips, sa); + BLI_remlink(&nlt->strips, area); BLI_remlink(&nlt->strips, sb); /* calculate new extents for strips */ /* a --> b */ nsa[0] = sb->start; - nsa[1] = sb->start + (sa->end - sa->start); + nsa[1] = sb->start + (area->end - area->start); /* b --> a */ - nsb[0] = sa->start; - nsb[1] = sa->start + (sb->end - sb->start); + nsb[0] = area->start; + nsb[1] = area->start + (sb->end - sb->start); /* check if the track has room for the strips to be swapped */ if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) { /* set new extents for strips then */ - sa->start = nsa[0]; - sa->end = nsa[1]; - BKE_nlameta_flush_transforms(sa); + area->start = nsa[0]; + area->end = nsa[1]; + BKE_nlameta_flush_transforms(area); sb->start = nsb[0]; sb->end = nsb[1]; @@ -1598,7 +1598,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) } else { /* not enough room to swap, so show message */ - if ((sa->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) { + if ((area->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) { BKE_report( op->reports, RPT_WARNING, @@ -1609,13 +1609,13 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) RPT_WARNING, "Cannot swap '%s' and '%s' as one or both will not be able to fit in their " "new places", - sa->name, + area->name, sb->name); } } /* add strips back to track now */ - BKE_nlatrack_add_strip(nlt, sa); + BKE_nlatrack_add_strip(nlt, area); BKE_nlatrack_add_strip(nlt, sb); } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index c4e1431ee26..f060693d9f4 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -57,7 +57,7 @@ /* ******************** default callbacks for nla space ***************** */ -static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene) +static SpaceLink *nla_new(const ScrArea *area, const Scene *scene) { ARegion *region; SpaceNla *snla; @@ -105,7 +105,7 @@ static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene) region->regiontype = RGN_TYPE_WINDOW; region->v2d.tot.xmin = (float)(SFRA - 10); - region->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; region->v2d.tot.xmax = (float)(EFRA + 10); region->v2d.tot.ymax = 0.0f; @@ -141,9 +141,9 @@ static void nla_free(SpaceLink *sl) } /* spacetype; init callback */ -static void nla_init(struct wmWindowManager *wm, ScrArea *sa) +static void nla_init(struct wmWindowManager *wm, ScrArea *area) { - SpaceNla *snla = (SpaceNla *)sa->spacedata.first; + SpaceNla *snla = (SpaceNla *)area->spacedata.first; /* init dopesheet data if non-existent (i.e. for old files) */ if (snla->ads == NULL) { @@ -151,7 +151,7 @@ static void nla_init(struct wmWindowManager *wm, ScrArea *sa) snla->ads->source = (ID *)WM_window_get_active_scene(wm->winactive); } - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } static SpaceLink *nla_duplicate(SpaceLink *sl) @@ -325,7 +325,7 @@ static void nla_buttons_region_draw(const bContext *C, ARegion *region) } static void nla_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -365,7 +365,7 @@ static void nla_region_listener(wmWindow *UNUSED(win), } static void nla_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -427,12 +427,12 @@ static void nla_main_region_message_subscribe(const struct bContext *UNUSED(C), struct WorkSpace *UNUSED(workspace), struct Scene *scene, struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { PointerRNA ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceNLA, area->spacedata.first, &ptr); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, @@ -466,7 +466,7 @@ static void nla_main_region_message_subscribe(const struct bContext *UNUSED(C), } static void nla_channel_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -512,12 +512,12 @@ static void nla_channel_region_message_subscribe(const struct bContext *UNUSED(C struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *screen, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { PointerRNA ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceNLA, area->spacedata.first, &ptr); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, @@ -543,24 +543,27 @@ static void nla_channel_region_message_subscribe(const struct bContext *UNUSED(C } /* editor level listener */ -static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) +static void nla_listener(wmWindow *UNUSED(win), + ScrArea *area, + wmNotifier *wmn, + Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { case NC_ANIMATION: // TODO: filter specific types of changes? - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case NC_SCENE: #if 0 switch (wmn->data) { case ND_OB_ACTIVE: case ND_OB_SELECT: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } #endif - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case NC_OBJECT: switch (wmn->data) { @@ -568,19 +571,19 @@ static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Sc /* do nothing */ break; default: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } break; case NC_SPACE: if (wmn->data == ND_SPACE_NLA) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } } -static void nla_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void nla_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceNla *snla = (SpaceNla *)slink; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index e50f5a818aa..0e100080a11 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -128,11 +128,11 @@ static int compo_get_recalc_flags(const bContext *C) for (win = wm->windows.first; win; win = win->next) { const bScreen *sc = WM_window_get_active_screen(win); - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + for (area = sc->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; if (sima->image) { if (sima->image->type == IMA_TYPE_R_RESULT) { recalc_flags |= COM_RECALC_COMPOSITE; @@ -142,8 +142,8 @@ static int compo_get_recalc_flags(const bContext *C) } } } - else if (sa->spacetype == SPACE_NODE) { - SpaceNode *snode = sa->spacedata.first; + else if (area->spacetype == SPACE_NODE) { + SpaceNode *snode = area->spacedata.first; if (snode->flag & SNODE_BACKDRAW) { recalc_flags |= COM_RECALC_VIEWER; } diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 5dc98a3905a..8dfa99ca126 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1446,9 +1446,12 @@ void NODE_OT_detach(wmOperatorType *ot) /* ********************* automatic node insert on dragging ******************* */ /* prevent duplicate testing code below */ -static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, bNode **r_select) +static bool ed_node_link_conditions(ScrArea *area, + bool test, + SpaceNode **r_snode, + bNode **r_select) { - SpaceNode *snode = sa ? sa->spacedata.first : NULL; + SpaceNode *snode = area ? area->spacedata.first : NULL; bNode *node, *select = NULL; bNodeLink *link; @@ -1456,7 +1459,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, *r_select = NULL; /* no unlucky accidents */ - if (sa == NULL || sa->spacetype != SPACE_NODE) { + if (area == NULL || area->spacetype != SPACE_NODE) { return false; } @@ -1501,14 +1504,14 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, } /* test == 0, clear all intersect flags */ -void ED_node_link_intersect_test(ScrArea *sa, int test) +void ED_node_link_intersect_test(ScrArea *area, int test) { bNode *select; SpaceNode *snode; bNodeLink *link, *selink = NULL; float dist_best = FLT_MAX; - if (!ed_node_link_conditions(sa, test, &snode, &select)) { + if (!ed_node_link_conditions(area, test, &snode, &select)) { return; } @@ -1919,14 +1922,14 @@ void NODE_OT_insert_offset(wmOperatorType *ot) } /* assumes link with NODE_LINKFLAG_HILITE set */ -void ED_node_link_insert(Main *bmain, ScrArea *sa) +void ED_node_link_insert(Main *bmain, ScrArea *area) { bNode *node, *select; SpaceNode *snode; bNodeLink *link; bNodeSocket *sockto; - if (!ed_node_link_conditions(sa, true, &snode, &select)) { + if (!ed_node_link_conditions(area, true, &snode, &select)) { return; } diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 32007d5b971..d682cab7293 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -328,17 +328,17 @@ static void node_free(SpaceLink *sl) } /* spacetype; init callback */ -static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } static void node_area_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { /* note, ED_area_tag_refresh will re-execute compositor */ - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; /* shaderfrom is only used for new shading nodes, otherwise all shaders are from objects */ short shader_type = snode->shaderfrom; @@ -347,32 +347,32 @@ static void node_area_listener(wmWindow *UNUSED(win), case NC_SCENE: switch (wmn->data) { case ND_NODES: { - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); bNodeTreePath *path = snode->treepath.last; /* shift view to node tree center */ if (region && path) { UI_view2d_center_set(®ion->v2d, path->view_center[0], path->view_center[1]); } - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } case ND_FRAME: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case ND_COMPO_RESULT: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_TRANSFORM_DONE: if (ED_node_is_compositor(snode)) { if (snode->flag & SNODE_AUTO_RENDER) { snode->recalc = 1; - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } break; case ND_LAYER_CONTENT: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } break; @@ -381,13 +381,13 @@ static void node_area_listener(wmWindow *UNUSED(win), case NC_MATERIAL: if (ED_node_is_shader(snode)) { if (wmn->data == ND_SHADING) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } else if (wmn->data == ND_SHADING_DRAW) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } else if (wmn->data == ND_SHADING_LINKS) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } else if (wmn->action == NA_ADDED && snode->edittree) { nodeSetActiveID(snode->edittree, ID_MA, wmn->reference); @@ -397,49 +397,49 @@ static void node_area_listener(wmWindow *UNUSED(win), case NC_TEXTURE: if (ED_node_is_shader(snode) || ED_node_is_texture(snode)) { if (wmn->data == ND_NODES) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } break; case NC_WORLD: if (ED_node_is_shader(snode) && shader_type == SNODE_SHADER_WORLD) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_OBJECT: if (ED_node_is_shader(snode)) { if (wmn->data == ND_OB_SHADING) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } break; case NC_SPACE: if (wmn->data == ND_SPACE_NODE) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } else if (wmn->data == ND_SPACE_NODE_VIEW) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_NODE: if (wmn->action == NA_EDITED) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } else if (wmn->action == NA_SELECTED) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; } break; case NC_MASK: if (wmn->action == NA_EDITED) { if (snode->nodetree && snode->nodetree->type == NTREE_COMPOSIT) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } break; @@ -451,7 +451,7 @@ static void node_area_listener(wmWindow *UNUSED(win), * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ if (nodeUpdateID(snode->nodetree, wmn->reference)) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } } @@ -461,7 +461,7 @@ static void node_area_listener(wmWindow *UNUSED(win), if (wmn->action == NA_EDITED) { if (ED_node_is_compositor(snode)) { if (nodeUpdateID(snode->nodetree, wmn->reference)) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } } } @@ -469,26 +469,26 @@ static void node_area_listener(wmWindow *UNUSED(win), case NC_LINESTYLE: if (ED_node_is_shader(snode) && shader_type == SNODE_SHADER_LINESTYLE) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_WM: if (wmn->data == ND_UNDO) { - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } break; case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } } -static void node_area_refresh(const struct bContext *C, ScrArea *sa) +static void node_area_refresh(const struct bContext *C, ScrArea *area) { /* default now: refresh node is starting preview */ - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; snode_set_context(C); @@ -497,19 +497,19 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) if (GS(snode->id->name) == ID_MA) { Material *ma = (Material *)snode->id; if (ma->use_nodes) { - ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } else if (GS(snode->id->name) == ID_LA) { Light *la = (Light *)snode->id; if (la->use_nodes) { - ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } else if (GS(snode->id->name) == ID_WO) { World *wo = (World *)snode->id; if (wo->use_nodes) { - ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } } @@ -529,7 +529,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) else if (snode->nodetree->type == NTREE_TEXTURE) { Tex *tex = (Tex *)snode->id; if (tex->use_nodes) { - ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + ED_preview_shader_job(C, area, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } } @@ -585,9 +585,9 @@ static void node_toolbar_region_draw(const bContext *C, ARegion *region) ED_region_panels(C, region); } -static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *region) +static void node_cursor(wmWindow *win, ScrArea *area, ARegion *region) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(®ion->v2d, @@ -702,7 +702,7 @@ static void node_header_region_draw(const bContext *C, ARegion *region) /* used for header + main region */ static void node_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -851,7 +851,7 @@ static void node_widgets(void) WM_gizmogrouptype_append_and_link(gzmap_type, NODE_GGT_backdrop_corner_pin); } -static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void node_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceNode *snode = (SpaceNode *)slink; @@ -922,15 +922,15 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } -static int node_space_subtype_get(ScrArea *sa) +static int node_space_subtype_get(ScrArea *area) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; return rna_node_tree_idname_to_enum(snode->tree_idname); } -static void node_space_subtype_set(ScrArea *sa, int value) +static void node_space_subtype_set(ScrArea *area, int value) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; ED_node_set_tree_type(snode, rna_node_tree_type_from_enum(value)); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 57bf34f1e18..e4e8e2a1542 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1675,8 +1675,8 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* specialized poll callback for these operators to work in Datablocks view only */ static bool ed_operator_outliner_datablocks_active(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { + ScrArea *area = CTX_wm_area(C); + if ((area) && (area->spacetype == SPACE_OUTLINER)) { SpaceOutliner *so = CTX_wm_space_outliner(C); return (so->outlinevis == SO_DATA_API); } @@ -2179,8 +2179,8 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) static bool ed_operator_outliner_id_orphans_active(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa != NULL && sa->spacetype == SPACE_OUTLINER) { + ScrArea *area = CTX_wm_area(C); + if (area != NULL && area->spacetype == SPACE_OUTLINER) { SpaceOutliner *so = CTX_wm_space_outliner(C); return (so->outlinevis == SO_ID_ORPHANS); } @@ -2249,7 +2249,7 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceOutliner *soops = CTX_wm_space_outliner(C); int num_tagged[INDEX_ID_MAX] = {0}; @@ -2276,7 +2276,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) * outliner several mouse events can be handled in one cycle without * handling notifiers/redraw which leads to deleting the same object twice. * cleanup tree here to prevent such cases. */ - if ((sa != NULL) && (sa->spacetype == SPACE_OUTLINER)) { + if ((area != NULL) && (area->spacetype == SPACE_OUTLINER)) { outliner_cleanup_tree(soops); } diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index 745a527cc15..10075a8df58 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -95,8 +95,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C) wmWindowManager *wm = CTX_wm_manager(C); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *soutliner = (SpaceOutliner *)sl; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index cfeaf8aa897..9450136b6a6 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -106,7 +106,7 @@ static void outliner_main_region_free(ARegion *UNUSED(region)) } static void outliner_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -241,11 +241,11 @@ static void outliner_main_region_message_subscribe(const struct bContext *UNUSED struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { - SpaceOutliner *soops = sa->spacedata.first; + SpaceOutliner *soops = area->spacedata.first; wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = region, .user_data = region, @@ -275,7 +275,7 @@ static void outliner_header_region_free(ARegion *UNUSED(region)) } static void outliner_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -341,7 +341,7 @@ static void outliner_free(SpaceLink *sl) } /* spacetype; init callback */ -static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -360,7 +360,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) return (SpaceLink *)soutlinern; } -static void outliner_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void outliner_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceOutliner *so = (SpaceOutliner *)slink; @@ -393,12 +393,12 @@ static void outliner_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, } } -static void outliner_deactivate(struct ScrArea *sa) +static void outliner_deactivate(struct ScrArea *area) { /* Remove hover highlights */ - SpaceOutliner *soops = sa->spacedata.first; + SpaceOutliner *soops = area->spacedata.first; outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED, false); - ED_region_tag_redraw(BKE_area_find_region_type(sa, RGN_TYPE_WINDOW)); + ED_region_tag_redraw(BKE_area_find_region_type(area, RGN_TYPE_WINDOW)); } /* only called once, from space_api/spacetypes.c */ diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index d872facd488..343f35421a4 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -94,7 +94,7 @@ static void script_free(SpaceLink *sl) } /* spacetype; init callback */ -static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -160,7 +160,7 @@ static void script_header_region_draw(const bContext *C, ARegion *region) } static void script_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 29d8f213d7e..7eb08387bd6 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -185,7 +185,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports) 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); + ScrArea *area = CTX_wm_area(C); Sequence *seq; GSet *file_list; @@ -233,7 +233,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports) WM_jobs_start(CTX_wm_manager(C), wm_job); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } /* ********************************************************************** */ @@ -1631,11 +1631,11 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) } } -static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *data, int offset) +static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData *data, int offset) { char msg[UI_MAX_DRAW_STR]; - if (sa) { + if (area) { if (hasNumInput(&data->num_input)) { char num_str[NUM_STR_REP_LEN]; outputNumInput(&data->num_input, num_str, &scene->unit); @@ -1646,7 +1646,7 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *da } } - ED_area_status_text(sa, msg); + ED_area_status_text(area, msg); } static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -1654,7 +1654,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SlipData *data = (SlipData *)op->customdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); const bool has_numInput = hasNumInput(&data->num_input); bool handled = true; @@ -1663,7 +1663,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even float offset; applyNumInput(&data->num_input, &offset); - sequencer_slip_update_header(scene, sa, data, (int)offset); + sequencer_slip_update_header(scene, area, data, (int)offset); RNA_int_set(op->ptr, "offset", offset); @@ -1695,7 +1695,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]); offset = mouseloc[0] - data->init_mouseloc[0]; - sequencer_slip_update_header(scene, sa, data, offset); + sequencer_slip_update_header(scene, area, data, offset); RNA_int_set(op->ptr, "offset", offset); @@ -1714,8 +1714,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even MEM_freeN(data->ts); MEM_freeN(data); op->customdata = NULL; - if (sa) { - ED_area_status_text(sa, NULL); + if (area) { + ED_area_status_text(area, NULL); } DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1747,8 +1747,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); - if (sa) { - ED_area_status_text(sa, NULL); + if (area) { + ED_area_status_text(area, NULL); } return OPERATOR_CANCELLED; @@ -1777,7 +1777,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even float offset; applyNumInput(&data->num_input, &offset); - sequencer_slip_update_header(scene, sa, data, (int)offset); + sequencer_slip_update_header(scene, area, data, (int)offset); RNA_int_set(op->ptr, "offset", offset); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 7c8a5ff5981..d50047c4839 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -130,7 +130,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) /* first, get the preview job, if it exists */ wmJob *wm_job; PreviewJob *pj; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); PreviewJobAudio *audiojob = MEM_callocN(sizeof(PreviewJobAudio), "preview_audio"); wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), @@ -167,5 +167,5 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) WM_jobs_start(CTX_wm_manager(C), wm_job); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 2cd3f624455..73aa8e1be35 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -61,20 +61,20 @@ /**************************** common state *****************************/ -static void sequencer_scopes_tag_refresh(ScrArea *sa) +static void sequencer_scopes_tag_refresh(ScrArea *area) { - SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first; sseq->scopes.reference_ibuf = NULL; } /* ******************** manage regions ********************* */ -static ARegion *sequencer_find_region(ScrArea *sa, short type) +static ARegion *sequencer_find_region(ScrArea *area, short type) { ARegion *region = NULL; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == type) { return region; } @@ -85,7 +85,7 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type) /* ******************** default callbacks for sequencer space ***************** */ -static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene) +static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) { ARegion *region; SpaceSeq *sseq; @@ -214,17 +214,17 @@ static void sequencer_free(SpaceLink *sl) } /* spacetype; init callback */ -static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } -static void sequencer_refresh(const bContext *C, ScrArea *sa) +static void sequencer_refresh(const bContext *C, ScrArea *area) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *window = CTX_wm_window(C); - SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; - ARegion *region_main = sequencer_find_region(sa, RGN_TYPE_WINDOW); - ARegion *region_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW); + SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first; + ARegion *region_main = sequencer_find_region(area, RGN_TYPE_WINDOW); + ARegion *region_preview = sequencer_find_region(area, RGN_TYPE_PREVIEW); bool view_changed = false; switch (sseq->view) { @@ -274,7 +274,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa) case SEQ_VIEW_SEQUENCE_PREVIEW: if (region_main && region_preview) { /* Get available height (without DPI correction). */ - const float height = (sa->winy - ED_area_headersize()) / UI_DPI_FAC; + const float height = (area->winy - ED_area_headersize()) / UI_DPI_FAC; /* We reuse hidden region's size, allows to find same layout as before if we just switch * between one 'full window' view and the combined one. This gets lost if we switch to both @@ -312,8 +312,8 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa) } if (view_changed) { - ED_area_initialize(wm, window, sa); - ED_area_tag_redraw(sa); + ED_area_initialize(wm, window, area); + ED_area_tag_redraw(area); } } @@ -330,7 +330,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) } static void sequencer_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { @@ -340,19 +340,19 @@ static void sequencer_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_FRAME: case ND_SEQUENCER: - sequencer_scopes_tag_refresh(sa); + sequencer_scopes_tag_refresh(area); break; } break; case NC_WINDOW: case NC_SPACE: if (wmn->data == ND_SPACE_SEQUENCER) { - sequencer_scopes_tag_refresh(sa); + sequencer_scopes_tag_refresh(area); } break; case NC_GPENCIL: if (wmn->data & ND_GPENCIL_EDITMODE) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } @@ -522,7 +522,7 @@ static void sequencer_main_region_draw(const bContext *C, ARegion *region) } static void sequencer_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -570,7 +570,7 @@ static void sequencer_main_region_message_subscribe(const struct bContext *UNUSE struct WorkSpace *UNUSED(workspace), struct Scene *scene, struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { @@ -675,8 +675,8 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *region) static void sequencer_preview_region_draw(const bContext *C, ARegion *region) { - ScrArea *sa = CTX_wm_area(C); - SpaceSeq *sseq = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + SpaceSeq *sseq = area->spacedata.first; Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); const bool draw_overlay = (scene->ed && (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW)); @@ -717,7 +717,7 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *region) } static void sequencer_preview_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -787,7 +787,7 @@ static void sequencer_buttons_region_draw(const bContext *C, ARegion *region) } static void sequencer_buttons_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -820,7 +820,7 @@ static void sequencer_buttons_region_listener(wmWindow *UNUSED(win), } } -static void sequencer_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void sequencer_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceSeq *sseq = (SpaceSeq *)slink; diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c index 1efb18403de..34d7f8b0216 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.c +++ b/source/blender/editors/space_statusbar/space_statusbar.c @@ -65,7 +65,7 @@ static void statusbar_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback */ -static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -96,7 +96,7 @@ static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf)) } static void statusbar_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -135,7 +135,7 @@ static void statusbar_header_region_message_subscribe(const bContext *UNUSED(C), WorkSpace *UNUSED(workspace), Scene *UNUSED(scene), bScreen *UNUSED(screen), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, struct wmMsgBus *mbus) { diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index d5379a4e76d..76d61193ce0 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -107,7 +107,7 @@ static void text_free(SpaceLink *sl) } /* spacetype; init callback */ -static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -123,11 +123,11 @@ static SpaceLink *text_duplicate(SpaceLink *sl) } static void text_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, wmNotifier *wmn, Scene *UNUSED(scene)) { - SpaceText *st = sa->spacedata.first; + SpaceText *st = area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -141,14 +141,14 @@ static void text_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_DISPLAY: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case ND_CURSOR: if (st->text && st->text == wmn->reference) { - text_scroll_to_cursor__area(st, sa, true); + text_scroll_to_cursor__area(st, area, true); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; } @@ -159,15 +159,15 @@ static void text_listener(wmWindow *UNUSED(win), text_update_edited(st->text); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); ATTR_FALLTHROUGH; /* fall down to tag redraw */ case NA_ADDED: case NA_REMOVED: - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); break; case NA_SELECTED: if (st->text && st->text == wmn->reference) { - text_scroll_to_cursor__area(st, sa, true); + text_scroll_to_cursor__area(st, area, true); } break; @@ -176,7 +176,7 @@ static void text_listener(wmWindow *UNUSED(win), break; case NC_SPACE: if (wmn->data == ND_SPACE_TEXT) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } break; } @@ -309,9 +309,9 @@ static void text_main_region_draw(const bContext *C, ARegion *region) /* scrollers? */ } -static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *region) +static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region) { - SpaceText *st = sa->spacedata.first; + SpaceText *st = area->spacedata.first; int wmcursor = WM_CURSOR_TEXT_EDIT; if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle, @@ -413,14 +413,14 @@ static void text_properties_region_draw(const bContext *C, ARegion *region) if (st->flags & ST_FIND_ACTIVATE) { if (UI_textbutton_activate_rna(C, region, st, "find_text")) { /* if the panel was already open we need to do another redraw */ - ScrArea *sa = CTX_wm_area(C); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa); + ScrArea *area = CTX_wm_area(C); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, area); } st->flags &= ~ST_FIND_ACTIVATE; } } -static void text_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +static void text_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceText *stext = (SpaceText *)slink; diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index cb1861d8726..1f034bdbd09 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -335,8 +335,8 @@ static int doc_scroll = 0; static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event) { SpaceText *st = CTX_wm_space_text(C); - ScrArea *sa = CTX_wm_area(C); - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ScrArea *area = CTX_wm_area(C); + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); int draw = 0, tools = 0, swallow = 0, scroll = 1; Text *text = CTX_data_edit_text(C); @@ -577,7 +577,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e } if (draw) { - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } // if (swallow) { diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 777b6b1ef1d..a0339b35c57 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1812,7 +1812,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center) } /* takes an area instead of a region, use for listeners */ -void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center) +void text_scroll_to_cursor__area(SpaceText *st, ScrArea *area, const bool center) { ARegion *region; @@ -1820,7 +1820,7 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center) return; } - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { text_scroll_to_cursor(st, region, center); @@ -1829,10 +1829,10 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center) void text_update_cursor_moved(bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); SpaceText *st = CTX_wm_space_text(C); - text_scroll_to_cursor__area(st, sa, true); + text_scroll_to_cursor__area(st, area, true); } /** diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index da39ba3c5ad..c4052fcef84 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -42,17 +42,17 @@ /************************** properties ******************************/ -static ARegion *text_has_properties_region(ScrArea *sa) +static ARegion *text_has_properties_region(ScrArea *area) { ARegion *region, *arnew; - region = BKE_area_find_region_type(sa, RGN_TYPE_UI); + region = BKE_area_find_region_type(area, RGN_TYPE_UI); if (region) { return region; } /* add subdiv level; after header */ - region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); /* is error! */ if (region == NULL) { @@ -61,7 +61,7 @@ static ARegion *text_has_properties_region(ScrArea *sa) arnew = MEM_callocN(sizeof(ARegion), "properties region"); - BLI_insertlinkafter(&sa->regionbase, region, arnew); + BLI_insertlinkafter(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_LEFT; @@ -77,8 +77,8 @@ static bool text_properties_poll(bContext *C) static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - ARegion *region = text_has_properties_region(sa); + ScrArea *area = CTX_wm_area(C); + ARegion *region = text_has_properties_region(area); SpaceText *st = CTX_wm_space_text(C); if (region) { diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 5ad6a554188..d5114d8f6b5 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -41,7 +41,7 @@ void text_update_line_edited(struct TextLine *line); void text_update_edited(struct Text *text); void text_update_character_width(struct SpaceText *st); void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, const bool center); -void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *sa, const bool center); +void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *area, const bool center); void text_update_cursor_moved(struct bContext *C); /* Padding around line numbers in character widths. */ diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index cacf956aa84..d06c567988d 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -84,7 +84,7 @@ static void topbar_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback */ -static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -130,7 +130,7 @@ static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *regi } static void topbar_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -161,7 +161,7 @@ static void topbar_main_region_listener(wmWindow *UNUSED(win), } static void topbar_header_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -195,7 +195,7 @@ static void topbar_header_region_message_subscribe(const struct bContext *UNUSED struct WorkSpace *workspace, struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index d3bea4598ff..9eae722d5c8 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -97,7 +97,7 @@ static void userpref_free(SpaceLink *UNUSED(sl)) } /* spacetype; init callback */ -static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -185,7 +185,7 @@ static void userpref_execute_region_init(wmWindowManager *wm, ARegion *region) } static void userpref_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -194,7 +194,7 @@ static void userpref_main_region_listener(wmWindow *UNUSED(win), } static void userpref_header_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -209,7 +209,7 @@ static void userpref_header_listener(wmWindow *UNUSED(win), } static void userpref_navigation_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) @@ -218,7 +218,7 @@ static void userpref_navigation_region_listener(wmWindow *UNUSED(win), } static void userpref_execute_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *UNUSED(region), wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index e5f1de7d5eb..75717213cb1 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -88,9 +88,9 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d == NULL) { - ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype == SPACE_VIEW3D) { - ARegion *region = BKE_area_find_region_active_win(sa); + ScrArea *area = CTX_wm_area(C); + if (area && area->spacetype == SPACE_VIEW3D) { + ARegion *region = BKE_area_find_region_active_win(area); if (region) { rv3d = region->regiondata; } @@ -103,14 +103,14 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) * so return that, the caller can then access the region->regiondata */ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); *r_v3d = NULL; *r_region = NULL; - if (sa && sa->spacetype == SPACE_VIEW3D) { + if (area && area->spacetype == SPACE_VIEW3D) { ARegion *region = CTX_wm_region(C); - View3D *v3d = (View3D *)sa->spacedata.first; + View3D *v3d = (View3D *)area->spacedata.first; if (region) { RegionView3D *rv3d; @@ -121,7 +121,7 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_regi return true; } else { - if (ED_view3d_area_user_region(sa, v3d, r_region)) { + if (ED_view3d_area_user_region(area, v3d, r_region)) { *r_v3d = v3d; return true; } @@ -136,12 +136,13 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_regi * Similar to #ED_view3d_context_user_region() but does not use context. Always performs a lookup. * Also works if \a v3d is not the active space. */ -bool ED_view3d_area_user_region(const ScrArea *sa, const View3D *v3d, ARegion **r_region) +bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion **r_region) { RegionView3D *rv3d = NULL; ARegion *region_unlock_user = NULL; ARegion *region_unlock = NULL; - const ListBase *region_list = (v3d == sa->spacedata.first) ? &sa->regionbase : &v3d->regionbase; + const ListBase *region_list = (v3d == area->spacedata.first) ? &area->regionbase : + &v3d->regionbase; BLI_assert(v3d->spacetype == SPACE_VIEW3D); @@ -239,14 +240,14 @@ void ED_view3d_stop_render_preview(wmWindowManager *wm, ARegion *region) } } -void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) +void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area) { wmWindowManager *wm = bmain->wm.first; if (v3d->shading.type != OB_RENDER) { ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if ((region->regiontype == RGN_TYPE_WINDOW) && region->regiondata) { ED_view3d_stop_render_preview(wm, region); break; @@ -257,7 +258,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) /* ******************** default callbacks for view3d space ***************** */ -static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) +static SpaceLink *view3d_new(const ScrArea *UNUSED(area), const Scene *scene) { ARegion *region; View3D *v3d; @@ -336,7 +337,7 @@ static void view3d_free(SpaceLink *sl) } /* spacetype; init callback */ -static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -732,9 +733,9 @@ static void *view3d_main_region_duplicate(void *poin) } static void view3d_main_region_listener( - wmWindow *UNUSED(win), ScrArea *sa, ARegion *region, wmNotifier *wmn, const Scene *scene) + wmWindow *UNUSED(win), ScrArea *area, ARegion *region, wmNotifier *wmn, const Scene *scene) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; RegionView3D *rv3d = region->regiondata; wmGizmoMap *gzmap = region->gizmo_map; @@ -927,7 +928,7 @@ static void view3d_main_region_listener( } break; case NC_LIGHTPROBE: - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); break; case NC_IMAGE: /* this could be more fine grained checks if we had @@ -992,7 +993,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus) { @@ -1070,7 +1071,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, { wmMsgSubscribeValue msg_sub_value_region_tag_refresh = { .owner = region, - .user_data = sa, + .user_data = area, .notify = WM_toolsystem_do_msg_notify_tag_refresh, }; WM_msg_subscribe_rna_anon_prop(mbus, Object, mode, &msg_sub_value_region_tag_refresh); @@ -1078,9 +1079,9 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, } } -static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *region) +static void view3d_main_region_cursor(wmWindow *win, ScrArea *area, ARegion *region) { - if (!WM_cursor_set_from_tool(win, sa, region)) { + if (!WM_cursor_set_from_tool(win, area, region)) { WM_cursor_set(win, WM_CURSOR_DEFAULT); } } @@ -1101,7 +1102,7 @@ static void view3d_header_region_draw(const bContext *C, ARegion *region) } static void view3d_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1174,7 +1175,7 @@ static void view3d_header_region_message_subscribe(const struct bContext *UNUSED struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), - struct ScrArea *UNUSED(sa), + struct ScrArea *UNUSED(area), struct ARegion *region, struct wmMsgBus *mbus) { @@ -1318,7 +1319,7 @@ static void view3d_buttons_region_layout(const bContext *C, ARegion *region) } static void view3d_buttons_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(sa), + ScrArea *UNUSED(area), ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) @@ -1441,11 +1442,11 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *region) /* area (not region) level listener */ static void space_view3d_listener(wmWindow *UNUSED(win), - ScrArea *sa, + ScrArea *area, struct wmNotifier *wmn, Scene *UNUSED(scene)) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; /* context changes */ switch (wmn->category) { @@ -1453,7 +1454,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_WORLD: if (v3d->flag2 & V3D_HIDE_OVERLAYS) { - ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); + ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW); } break; } @@ -1463,7 +1464,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win), case ND_WORLD_DRAW: case ND_WORLD: if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD) { - ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); + ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW); } break; } @@ -1472,7 +1473,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_NODES: if (v3d->shading.type == OB_TEXTURE) { - ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); + ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW); } break; } @@ -1480,7 +1481,7 @@ static void space_view3d_listener(wmWindow *UNUSED(win), } } -static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa)) +static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area)) { Scene *scene = CTX_data_scene(C); LightCache *lcache = scene->eevee.light_cache_data; @@ -1538,7 +1539,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return -1; /* found but not available */ } -static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_id) +static void view3d_id_remap(ScrArea *area, SpaceLink *slink, ID *old_id, ID *new_id) { View3D *v3d; ARegion *region; @@ -1553,8 +1554,8 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_i v3d->camera = (Object *)new_id; if (!new_id) { /* 3D view might be inactive, in that case needs to use slink->regionbase */ - ListBase *regionbase = (slink == sa->spacedata.first) ? &sa->regionbase : - &slink->regionbase; + ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase : + &slink->regionbase; for (region = regionbase->first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = is_local ? ((RegionView3D *)region->regiondata)->localvd : diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 694cb7ee7d4..699ad40da9c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2396,9 +2396,9 @@ void ED_view3d_screen_datamask(const bContext *C, CustomData_MeshMasks_update(r_cddata_masks, &CD_MASK_BAREMESH); /* Check if we need tfaces & mcols due to view mode. */ - for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_VIEW3D) { - ED_view3d_datamask(C, scene, sa->spacedata.first, r_cddata_masks); + for (const ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_VIEW3D) { + ED_view3d_datamask(C, scene, area->spacedata.first, r_cddata_masks); } } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 09be73c87d1..0a30336aed8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -175,7 +175,7 @@ typedef struct ViewOpsData { /** Context pointers (assigned by #viewops_data_alloc). */ Main *bmain; Scene *scene; - ScrArea *sa; + ScrArea *area; ARegion *region; View3D *v3d; RegionView3D *rv3d; @@ -277,9 +277,9 @@ static void viewops_data_alloc(bContext *C, wmOperator *op) vod->bmain = CTX_data_main(C); vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vod->scene = CTX_data_scene(C); - vod->sa = CTX_wm_area(C); + vod->area = CTX_wm_area(C); vod->region = CTX_wm_region(C); - vod->v3d = vod->sa->spacedata.first; + vod->v3d = vod->area->spacedata.first; vod->rv3d = vod->region->regiondata; } @@ -1120,7 +1120,7 @@ static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d) * often `!rv3d->is_persp` since it doesn't make sense to dolly in ortho. */ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, - ScrArea *sa, + ScrArea *area, ARegion *region, const bool has_translate, const bool has_zoom) @@ -1161,7 +1161,7 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, /* all callers must check */ if (has_translate) { - BLI_assert(ED_view3d_offset_lock_check((View3D *)sa->spacedata.first, rv3d) == false); + BLI_assert(ED_view3d_offset_lock_check((View3D *)area->spacedata.first, rv3d) == false); } } @@ -1178,18 +1178,18 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, sub_v3_v3(rv3d->ofs, pan_vec); if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, region); + view3d_boxview_sync(area, region); } } } static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, - ScrArea *sa, + ScrArea *area, ARegion *region, ViewOpsData *vod, const bool apply_dyn_ofs) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; RegionView3D *rv3d = region->regiondata; float view_inv[4]; @@ -1422,12 +1422,12 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } if (has_rotation) { - view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, true); + view3d_ndof_orbit(ndof, vod->area, vod->region, vod, true); xform_flag |= HAS_ROTATE; } } @@ -1505,7 +1505,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d); if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, true); + view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, true); xform_flag |= HAS_TRANSLATE; } } @@ -1535,7 +1535,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev if (!is_orbit_around_pivot) { ED_view3d_distance_set(rv3d, 0.0f); } - view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, is_orbit_around_pivot); + view3d_ndof_orbit(ndof, vod->area, vod->region, vod, is_orbit_around_pivot); xform_flag |= HAS_ROTATE; if (!is_orbit_around_pivot) { ED_view3d_distance_set(rv3d, dist_backup); @@ -1543,7 +1543,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev } if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, vod->area, vod->region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } } @@ -1607,11 +1607,11 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); if (ndof->progress != P_FINISHING) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, sa, region, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, area, region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } } @@ -1751,7 +1751,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) add_v3_v3(vod->rv3d->ofs, dvec); if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->region); + view3d_boxview_sync(vod->area, vod->region); } } @@ -2189,7 +2189,7 @@ static void viewzoom_apply_3d(ViewOpsData *vod, CLAMP(vod->rv3d->dist, dist_range[0], dist_range[1]); if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->region); + view3d_boxview_sync(vod->area, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); @@ -2280,7 +2280,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); View3D *v3d; RegionView3D *rv3d; - ScrArea *sa; + ScrArea *area; ARegion *region; bool use_cam_zoom; float dist_range[2]; @@ -2291,15 +2291,15 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if (op->customdata) { ViewOpsData *vod = op->customdata; - sa = vod->sa; + area = vod->area; region = vod->region; } else { - sa = CTX_wm_area(C); + area = CTX_wm_area(C); region = CTX_wm_region(C); } - v3d = sa->spacedata.first; + v3d = area->spacedata.first; rv3d = region->regiondata; use_cam_zoom = (rv3d->persp == RV3D_CAMOB) && @@ -2342,7 +2342,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) } if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, region); + view3d_boxview_sync(area, region); } ED_view3d_depth_tag_update(rv3d); @@ -2538,7 +2538,7 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_ } if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->region); + view3d_boxview_sync(vod->area, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); @@ -2603,7 +2603,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) { View3D *v3d; RegionView3D *rv3d; - ScrArea *sa; + ScrArea *area; ARegion *region; float mousevec[3]; @@ -2612,18 +2612,18 @@ static int viewdolly_exec(bContext *C, wmOperator *op) if (op->customdata) { ViewOpsData *vod = op->customdata; - sa = vod->sa; + area = vod->area; region = vod->region; copy_v3_v3(mousevec, vod->init.mousevec); } else { - sa = CTX_wm_area(C); + area = CTX_wm_area(C); region = CTX_wm_region(C); negate_v3_v3(mousevec, ((RegionView3D *)region->regiondata)->viewinv[2]); normalize_v3(mousevec); } - v3d = sa->spacedata.first; + v3d = area->spacedata.first; rv3d = region->regiondata; const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); @@ -2636,7 +2636,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) view_dolly_to_vector_3d(region, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f); if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, region); + view3d_boxview_sync(area, region); } ED_view3d_depth_tag_update(rv3d); @@ -2886,9 +2886,9 @@ static void view3d_from_minmax_multi(bContext *C, const bool ok_dist, const int smooth_viewtx) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; /* when using all regions, don't jump out of camera view, @@ -4376,7 +4376,7 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y)) } if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->region); + view3d_boxview_sync(vod->area, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); @@ -5279,7 +5279,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); int type = RNA_enum_get(op->ptr, "type"); if (type == OB_SOLID) { @@ -5307,7 +5307,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op) } } - ED_view3d_shade_update(bmain, v3d, sa); + ED_view3d_shade_update(bmain, v3d, area); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; @@ -5340,7 +5340,7 @@ void VIEW3D_OT_toggle_shading(wmOperatorType *ot) static int toggle_xray_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Object *obact = CTX_data_active_object(C); if (obact && ((obact->mode & OB_MODE_POSE) || @@ -5362,7 +5362,7 @@ static int toggle_xray_exec(bContext *C, wmOperator *op) } } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 4b194d6687d..e4863c0cdeb 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -110,7 +110,7 @@ typedef struct RulerInfo { /* wm state */ wmWindow *win; - ScrArea *sa; + ScrArea *area; ARegion *region; /* re-assigned every modal update */ /* Track changes in state. */ @@ -299,7 +299,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], const int xy[2]) { - ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->region, r_co, xy, r_co); + ED_view3d_win_to_3d_int(ruler_info->area->spacedata.first, ruler_info->region, r_co, xy, r_co); } /* use for mousemove events */ @@ -323,7 +323,7 @@ static bool view3d_ruler_item_mousemove(struct Depsgraph *depsgraph, view3d_ruler_item_project(ruler_info, co, mval); if (do_thickness && inter->co_index != 1) { // Scene *scene = CTX_data_scene(C); - // View3D *v3d = ruler_info->sa->spacedata.first; + // View3D *v3d = ruler_info->area->spacedata.first; const float mval_fl[2] = {UNPACK2(mval)}; float ray_normal[3]; float ray_start[3]; @@ -1064,10 +1064,10 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup) } wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); ruler_info->win = win; - ruler_info->sa = sa; + ruler_info->area = area; ruler_info->region = region; gzgroup->customdata = ruler_info; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 57989680705..be0084d8869 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -105,7 +105,7 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) wmWindow *win = CTX_wm_window(C); const int ctrl = win->eventstate->ctrl, shift = win->eventstate->shift; - /* watch it: if sa->win does not exist, check that when calling direct drawing routines */ + /* watch it: if area->win does not exist, check that when calling direct drawing routines */ switch (event) { case B_SEL_VERT: diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 610c40c37eb..c16131c8317 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -91,8 +91,8 @@ void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot); void VIEW3D_OT_toggle_xray(struct wmOperatorType *ot); -void view3d_boxview_copy(struct ScrArea *sa, struct ARegion *region); -void view3d_boxview_sync(struct ScrArea *sa, struct ARegion *region); +void view3d_boxview_copy(struct ScrArea *area, struct ARegion *region); +void view3d_boxview_sync(struct ScrArea *area, struct ARegion *region); void view3d_orbit_apply_dyn_ofs(float r_ofs[3], const float ofs_old[3], @@ -181,7 +181,7 @@ typedef struct V3D_SmoothParams { void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph, struct wmWindowManager *wm, struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct View3D *v3d, struct ARegion *region, const int smooth_viewtx, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b8dbd277fbc..cd7db2ff23a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1226,7 +1226,7 @@ static bool do_lasso_select_paintface(ViewContext *vc, #if 0 static void do_lasso_select_node(int mcords[][2], short moves, const eSelectOp sel_op) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; bNode *node; rcti rect; diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 5db26e26f0b..acbd4b85ece 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -229,25 +229,25 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) bool ED_view3d_context_activate(bContext *C) { bScreen *sc = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region; - /* sa can be NULL when called from python */ - if (sa == NULL || sa->spacetype != SPACE_VIEW3D) { - sa = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0); + /* area can be NULL when called from python */ + if (area == NULL || area->spacetype != SPACE_VIEW3D) { + area = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0); } - if (sa == NULL) { + if (area == NULL) { return false; } - region = BKE_area_find_region_active_win(sa); + region = BKE_area_find_region_active_win(area); if (region == NULL) { return false; } /* bad context switch .. */ - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); return true; @@ -666,7 +666,7 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, * Use with quad-split so each view is clipped by the bounds of each view axis. * \{ */ -static void view3d_boxview_clip(ScrArea *sa) +static void view3d_boxview_clip(ScrArea *area) { ARegion *region; BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb"); @@ -675,7 +675,7 @@ static void view3d_boxview_clip(ScrArea *sa) int val; /* create bounding box */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; @@ -747,7 +747,7 @@ static void view3d_boxview_clip(ScrArea *sa) } /* create bounding box */ - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; @@ -812,13 +812,13 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_ } /* sync center/zoom view of region to others, for view transforms */ -void view3d_boxview_sync(ScrArea *sa, ARegion *region) +void view3d_boxview_sync(ScrArea *area, ARegion *region) { ARegion *artest; RegionView3D *rv3d = region->regiondata; short clip = 0; - for (artest = sa->regionbase.first; artest; artest = artest->next) { + for (artest = area->regionbase.first; artest; artest = artest->next) { if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3dtest = artest->regiondata; @@ -833,18 +833,18 @@ void view3d_boxview_sync(ScrArea *sa, ARegion *region) } if (clip) { - view3d_boxview_clip(sa); + view3d_boxview_clip(area); } } /* for home, center etc */ -void view3d_boxview_copy(ScrArea *sa, ARegion *region) +void view3d_boxview_copy(ScrArea *area, ARegion *region) { ARegion *artest; RegionView3D *rv3d = region->regiondata; bool clip = false; - for (artest = sa->regionbase.first; artest; artest = artest->next) { + for (artest = area->regionbase.first; artest; artest = artest->next) { if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3dtest = artest->regiondata; @@ -859,12 +859,12 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *region) } if (clip) { - view3d_boxview_clip(sa); + view3d_boxview_clip(area); } } /* 'clip' is used to know if our clip setting has changed */ -void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) +void ED_view3d_quadview_update(ScrArea *area, ARegion *region, bool do_clip) { ARegion *region_sync = NULL; RegionView3D *rv3d = region->regiondata; @@ -900,13 +900,13 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) } if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, region_sync ? region_sync : sa->regionbase.last); + view3d_boxview_sync(area, region_sync ? region_sync : area->regionbase.last); } /* ensure locked regions have an axis, locked user views don't make much sense */ if (viewlock & RV3D_LOCK_ROTATION) { int index_qsplit = 0; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->alignment == RGN_ALIGN_QSPLIT) { rv3d = region->regiondata; if (rv3d->viewlock) { @@ -922,7 +922,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) } } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 3dc5b3025aa..71a4c2e0780 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -128,7 +128,7 @@ void ED_view3d_smooth_view_ex( const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, - ScrArea *sa, + ScrArea *area, View3D *v3d, ARegion *region, const int smooth_viewtx, @@ -293,7 +293,7 @@ void ED_view3d_smooth_view_ex( } if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { - view3d_boxview_copy(sa, region); + view3d_boxview_copy(area, region); } ED_region_tag_redraw(region); @@ -309,9 +309,9 @@ void ED_view3d_smooth_view(bContext *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); + ScrArea *area = CTX_wm_area(C); - ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, region, smooth_viewtx, sview); + ED_view3d_smooth_view_ex(depsgraph, wm, win, area, v3d, region, smooth_viewtx, sview); } /* only meant for timer usage */ @@ -1200,7 +1200,7 @@ finally: static uint free_localview_bit(Main *bmain) { - ScrArea *sa; + ScrArea *area; bScreen *sc; ushort local_view_bits = 0; @@ -1208,8 +1208,8 @@ static uint free_localview_bit(Main *bmain) /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl = sa->spacedata.first; + for (area = sc->areabase.first; area; area = area->next) { + SpaceLink *sl = area->spacedata.first; for (; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -1235,12 +1235,12 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, wmWindow *win, Main *bmain, ViewLayer *view_layer, - ScrArea *sa, + ScrArea *area, const bool frame_selected, const int smooth_viewtx, ReportList *reports) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; Base *base; float min[3], max[3], box[3]; float size = 0.0f; @@ -1302,7 +1302,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, memcpy(v3d->localvd, v3d, sizeof(View3D)); v3d->local_view_uuid = local_view_bit; - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; bool ok_dist = true; @@ -1343,7 +1343,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, ED_view3d_smooth_view_ex(depsgraph, wm, win, - sa, + area, v3d, region, smooth_viewtx, @@ -1365,11 +1365,11 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ViewLayer *view_layer, - ScrArea *sa, + ScrArea *area, const bool frame_selected, const int smooth_viewtx) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; if (v3d->localvd == NULL) { return; @@ -1390,7 +1390,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, MEM_freeN(v3d->localvd); v3d->localvd = NULL; - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; @@ -1411,7 +1411,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, ED_view3d_smooth_view_ex(depsgraph, wm, win, - sa, + area, v3d, region, smooth_viewtx, @@ -1439,23 +1439,23 @@ static int localview_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); bool frame_selected = RNA_boolean_get(op->ptr, "frame_selected"); bool changed; if (v3d->localvd) { - view3d_localview_exit(depsgraph, wm, win, view_layer, sa, frame_selected, smooth_viewtx); + view3d_localview_exit(depsgraph, wm, win, view_layer, area, frame_selected, smooth_viewtx); changed = true; } else { changed = view3d_localview_init( - depsgraph, wm, win, bmain, view_layer, sa, frame_selected, smooth_viewtx, op->reports); + depsgraph, wm, win, bmain, view_layer, area, frame_selected, smooth_viewtx, op->reports); } if (changed) { DEG_id_type_tag(bmain, ID_OB); - ED_area_tag_redraw(sa); + ED_area_tag_redraw(area); /* Unselected objects become selected when exiting. */ if (v3d->localvd == NULL) { @@ -1558,15 +1558,15 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot) static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset) { - ScrArea *sa; + ScrArea *area; bScreen *sc; ushort local_view_bits = 0; /* Check all areas: which localviews are in use? */ for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl = sa->spacedata.first; + for (area = sc->areabase.first; area; area = area->next) { + SpaceLink *sl = area->spacedata.first; for (; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 965df86acc0..c48c86bd423 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -110,7 +110,7 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3]) copy_v3_fl(r_aspect, 1.0f); if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; if (t->options & CTX_MASK) { ED_space_image_get_aspect(sima, &r_aspect[0], &r_aspect[1]); @@ -123,7 +123,7 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3]) } } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sclip = t->sa->spacedata.first; + SpaceClip *sclip = t->area->spacedata.first; if (t->options & CTX_MOVIECLIP) { ED_space_clip_get_aspect_dimension_aware(sclip, &r_aspect[0], &r_aspect[1]); @@ -234,7 +234,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr } } else if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; if (t->options & CTX_MASK) { float v[2]; @@ -265,7 +265,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr else if (t->spacetype == SPACE_ACTION) { int out[2] = {0, 0}; #if 0 - SpaceAction *sact = t->sa->spacedata.first; + SpaceAction *sact = t->area->spacedata.first; if (sact->flag & SACTION_DRAWTIME) { //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); @@ -296,7 +296,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr adr[1] = out[1]; } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; if (t->options & CTX_MASK) { MovieClip *clip = ED_space_clip_get_clip(sc); @@ -377,7 +377,7 @@ void applyAspectRatio(TransInfo *t, float vec[2]) { if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) && !(t->options & CTX_PAINT_CURVE)) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; if ((sima->flag & SI_COORDFLOATS) == 0) { int width, height; @@ -401,7 +401,7 @@ void applyAspectRatio(TransInfo *t, float vec[2]) void removeAspectRatio(TransInfo *t, float vec[2]) { if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; if ((sima->flag & SI_COORDFLOATS) == 0) { int width, height; @@ -453,18 +453,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) } } else if (t->spacetype == SPACE_ACTION) { - // SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + // SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_GRAPH) { - // SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + // SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_NLA) { WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); } else if (t->spacetype == SPACE_NODE) { - // ED_area_tag_redraw(t->sa); + // ED_area_tag_redraw(t->area); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); } else if (t->spacetype == SPACE_SEQ) { @@ -483,21 +483,21 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) WM_paint_cursor_tag_redraw(window, t->region); } else if (t->flag & T_CURSOR) { - ED_area_tag_redraw(t->sa); + ED_area_tag_redraw(t->area); } else { // XXX how to deal with lock? - SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)t->area->spacedata.first; if (sima->lock) { WM_event_add_notifier(C, NC_GEOM | ND_DATA, OBEDIT_FROM_VIEW_LAYER(t->view_layer)->data); } else { - ED_area_tag_redraw(t->sa); + ED_area_tag_redraw(t->area); } } } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; + SpaceClip *sc = (SpaceClip *)t->area->spacedata.first; if (ED_space_clip_check_show_trackedit(sc)) { MovieClip *clip = ED_space_clip_get_clip(sc); @@ -517,7 +517,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) static void viewRedrawPost(bContext *C, TransInfo *t) { - ED_area_status_text(t->sa, NULL); + ED_area_status_text(t->area, NULL); if (t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ @@ -1160,9 +1160,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) break; case TFM_MODAL_INSERTOFS_TOGGLE_DIR: if (t->spacetype == SPACE_NODE) { - SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + SpaceNode *snode = (SpaceNode *)t->area->spacedata.first; - BLI_assert(t->sa->spacetype == t->spacetype); + BLI_assert(t->area->spacetype == t->spacetype); if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) { snode->insert_ofs_dir = SNODE_INSERTOFS_DIR_LEFT; @@ -1521,9 +1521,9 @@ static bool transinfo_show_overlay(const struct bContext *C, TransInfo *t, ARegi ok = true; } else { - ScrArea *sa = CTX_wm_area(C); - if (sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + if (area->spacetype == SPACE_VIEW3D) { + View3D *v3d = area->spacedata.first; if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) { ok = true; } @@ -1870,7 +1870,7 @@ static void initSnapSpatial(TransInfo *t, float r_snap[3]) RegionView3D *rv3d = t->region->regiondata; if (rv3d) { - View3D *v3d = t->sa->spacedata.first; + View3D *v3d = t->area->spacedata.first; r_snap[0] = 0.0f; r_snap[1] = ED_view3d_grid_view_scale(t->scene, v3d, rv3d, NULL) * 1.0f; r_snap[2] = r_snap[1] * 0.1f; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index a2c8caba0f5..9e225b842f1 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -581,7 +581,7 @@ typedef struct TransInfo { void *view; /** Only valid (non null) during an operator called function. */ struct bContext *context; - struct ScrArea *sa; + struct ScrArea *area; struct ARegion *region; struct Depsgraph *depsgraph; struct Scene *scene; diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 4b6932d977d..cdff9fdf750 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -171,7 +171,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3]) { if (t->spacetype == SPACE_VIEW3D) { - // View3D *v3d = t->sa->spacedata.first; + // View3D *v3d = t->area->spacedata.first; const float min_dist = 1.0f; /* v3d->clip_start; */ float dir[3]; float l; diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 665a279bdbe..af3cba65dda 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -1309,7 +1309,7 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve */ void remake_graph_transdata(TransInfo *t, ListBase *anim_data) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; bAnimListElem *ale; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; @@ -1749,7 +1749,7 @@ bool motionpath_need_update_pose(Scene *scene, Object *ob) static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t) { - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(&clip->tracking); const int framenr = ED_space_clip_get_clip_frame_number(sc); @@ -1791,11 +1791,11 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t) Mask *mask = NULL; if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; mask = ED_space_clip_get_mask(sc); } else if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; mask = ED_space_image_get_mask(sima); } else { @@ -1826,7 +1826,7 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t) if (canceled && t->remove_on_cancel) { /* remove selected nodes on cancel */ - SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + SpaceNode *snode = (SpaceNode *)t->area->spacedata.first; bNodeTree *ntree = snode->edittree; if (ntree) { bNode *node, *node_next; @@ -1949,7 +1949,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* freeSeqData in transform_conversions.c does this * keep here so the else at the end wont run... */ - SpaceSeq *sseq = (SpaceSeq *)t->sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)t->area->spacedata.first; /* Marker transform, not especially nice but we may want to move markers * at the same time as strips in the Video Sequencer. */ @@ -1975,16 +1975,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } else if (t->spacetype == SPACE_NODE) { - SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + SpaceNode *snode = (SpaceNode *)t->area->spacedata.first; special_aftertrans_update__node(C, t); if (canceled == 0) { ED_node_post_apply_transform(C, snode->edittree); - ED_node_link_insert(bmain, t->sa); + ED_node_link_insert(bmain, t->area); } /* clear link line */ - ED_node_link_intersect_test(t->sa, 0); + ED_node_link_intersect_test(t->area, 0); } else if (t->spacetype == SPACE_CLIP) { if (t->options & CTX_MOVIECLIP) { @@ -1995,7 +1995,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } else if (t->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; bAnimContext ac; /* initialize relevant anim-context 'context' data */ @@ -2159,7 +2159,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) saction->flag &= ~SACTION_MOVING; } else if (t->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; bAnimContext ac; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; diff --git a/source/blender/editors/transform/transform_convert_cursor.c b/source/blender/editors/transform/transform_convert_cursor.c index 621f9dd63e2..e6a972bfc7c 100644 --- a/source/blender/editors/transform/transform_convert_cursor.c +++ b/source/blender/editors/transform/transform_convert_cursor.c @@ -44,7 +44,7 @@ void createTransCursor_image(TransInfo *t) { TransData *td; - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; float *cursor_location = sima->cursor; { diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c index 95a385a5a50..5c2391d8dd0 100644 --- a/source/blender/editors/transform/transform_convert_graph.c +++ b/source/blender/editors/transform/transform_convert_graph.c @@ -167,7 +167,7 @@ static void graph_bezt_get_transform_selection(const TransInfo *t, bool *r_key, bool *r_right_handle) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; bool key = (bezt->f2 & SELECT) != 0; bool left = use_handle ? ((bezt->f1 & SELECT) != 0) : key; bool right = use_handle ? ((bezt->f3 & SELECT) != 0) : key; @@ -224,7 +224,7 @@ static void graph_key_shortest_dist( */ void createTransGraphEditData(bContext *C, TransInfo *t) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; Scene *scene = t->scene; ARegion *region = t->region; View2D *v2d = ®ion->v2d; @@ -642,7 +642,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t) */ void flushTransGraphData(TransInfo *t) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; TransData *td; TransData2D *td2d; TransDataGraph *tdg; diff --git a/source/blender/editors/transform/transform_convert_mask.c b/source/blender/editors/transform/transform_convert_mask.c index 65244a09b73..6c743da3e65 100644 --- a/source/blender/editors/transform/transform_convert_mask.c +++ b/source/blender/editors/transform/transform_convert_mask.c @@ -280,7 +280,7 @@ void createTransMaskingData(bContext *C, TransInfo *t) } if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; MovieClip *clip = ED_space_clip_get_clip(sc); if (!clip) { return; @@ -333,7 +333,7 @@ void createTransMaskingData(bContext *C, TransInfo *t) return; } - ED_mask_get_aspect(t->sa, t->region, &asp[0], &asp[1]); + ED_mask_get_aspect(t->area, t->region, &asp[0], &asp[1]); tc->data_len = (is_prop_edit) ? count : countsel; td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Mask Editing)"); @@ -409,7 +409,7 @@ void flushTransMasking(TransInfo *t) TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); - ED_mask_get_aspect(t->sa, t->region, &asp[0], &asp[1]); + ED_mask_get_aspect(t->area, t->region, &asp[0], &asp[1]); inv[0] = 1.0f / asp[0]; inv[1] = 1.0f / asp[1]; diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 29a74be8e2b..22bba9544cd 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -1608,7 +1608,7 @@ void createTransUVs(bContext *C, TransInfo *t) void flushTransUVs(TransInfo *t) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; const bool use_pixel_snap = ((sima->pixel_snap_mode != SI_PIXEL_SNAP_DISABLED) && (t->state != TRANS_CANCEL)); diff --git a/source/blender/editors/transform/transform_convert_node.c b/source/blender/editors/transform/transform_convert_node.c index ee4aa053444..d783bfdf40e 100644 --- a/source/blender/editors/transform/transform_convert_node.c +++ b/source/blender/editors/transform/transform_convert_node.c @@ -109,7 +109,7 @@ void createTransNodeData(bContext *UNUSED(C), TransInfo *t) const float dpi_fac = UI_DPI_FAC; TransData *td; TransData2D *td2d; - SpaceNode *snode = t->sa->spacedata.first; + SpaceNode *snode = t->area->spacedata.first; bNode *node; TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); @@ -188,7 +188,7 @@ void flushTransNodes(TransInfo *t) /* handle intersection with noodles */ if (tc->data_len == 1) { - ED_node_link_intersect_test(t->sa, 1); + ED_node_link_intersect_test(t->area, 1); } } } diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c index f2d0f4dfc43..a722f17db22 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.c +++ b/source/blender/editors/transform/transform_convert_sequencer.c @@ -379,7 +379,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c } if (overlap) { - const bool use_sync_markers = (((SpaceSeq *)t->sa->spacedata.first)->flag & + const bool use_sync_markers = (((SpaceSeq *)t->area->spacedata.first)->flag & SEQ_MARKER_TRANS) != 0; ListBase *markers = &t->scene->markers; diff --git a/source/blender/editors/transform/transform_convert_tracking.c b/source/blender/editors/transform/transform_convert_tracking.c index a8bde661342..6704567a76b 100644 --- a/source/blender/editors/transform/transform_convert_tracking.c +++ b/source/blender/editors/transform/transform_convert_tracking.c @@ -549,7 +549,7 @@ void createTransTrackingData(bContext *C, TransInfo *t) void cancelTransTracking(TransInfo *t) { TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; int i, framenr = ED_space_clip_get_clip_frame_number(sc); TransDataTracking *tdt_array = tc->custom.type.data; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 11b4600466c..6306e388f3f 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -356,7 +356,7 @@ static bool fcu_test_selected(FCurve *fcu) static void recalcData_actedit(TransInfo *t) { ViewLayer *view_layer = t->view_layer; - SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; bAnimContext ac = {NULL}; ListBase anim_data = {NULL, NULL}; @@ -369,10 +369,10 @@ static void recalcData_actedit(TransInfo *t) ac.scene = t->scene; ac.view_layer = t->view_layer; ac.obact = OBACT(view_layer); - ac.sa = t->sa; + ac.area = t->area; ac.region = t->region; - ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; - ac.spacetype = (t->sa) ? t->sa->spacetype : 0; + ac.sl = (t->area) ? t->area->spacedata.first : NULL; + ac.spacetype = (t->area) ? t->area->spacetype : 0; ac.regiontype = (t->region) ? t->region->regiontype : 0; ANIM_animdata_context_getdata(&ac); @@ -406,7 +406,7 @@ static void recalcData_actedit(TransInfo *t) /* helper for recalcData() - for Graph Editor transforms */ static void recalcData_graphedit(TransInfo *t) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; ViewLayer *view_layer = t->view_layer; ListBase anim_data = {NULL, NULL}; @@ -422,10 +422,10 @@ static void recalcData_graphedit(TransInfo *t) ac.scene = t->scene; ac.view_layer = t->view_layer; ac.obact = OBACT(view_layer); - ac.sa = t->sa; + ac.area = t->area; ac.region = t->region; - ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; - ac.spacetype = (t->sa) ? t->sa->spacetype : 0; + ac.sl = (t->area) ? t->area->spacedata.first : NULL; + ac.spacetype = (t->area) ? t->area->spacetype : 0; ac.regiontype = (t->region) ? t->region->regiontype : 0; ANIM_animdata_context_getdata(&ac); @@ -474,7 +474,7 @@ static void recalcData_graphedit(TransInfo *t) /* helper for recalcData() - for NLA Editor transforms */ static void recalcData_nla(TransInfo *t) { - SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; + SpaceNla *snla = (SpaceNla *)t->area->spacedata.first; Scene *scene = t->scene; double secf = FPS; int i; @@ -718,7 +718,7 @@ static void recalcData_image(TransInfo *t) flushTransPaintCurve(t); } else if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; flushTransUVs(t); if (sima->flag & SI_LIVE_UNWRAP) { @@ -736,7 +736,7 @@ static void recalcData_image(TransInfo *t) /* helper for recalcData() - for Movie Clip transforms */ static void recalcData_spaceclip(TransInfo *t) { - SpaceClip *sc = t->sa->spacedata.first; + SpaceClip *sc = t->area->spacedata.first; if (ED_space_clip_check_show_trackedit(sc)) { MovieClip *clip = ED_space_clip_get_clip(sc); @@ -1375,7 +1375,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT; ToolSettings *ts = CTX_data_tool_settings(C); ARegion *region = CTX_wm_region(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bGPdata *gpd = CTX_data_gpencil_data(C); PropertyRNA *prop; @@ -1383,7 +1383,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->depsgraph = CTX_data_depsgraph_pointer(C); t->scene = sce; t->view_layer = view_layer; - t->sa = sa; + t->area = area; t->region = region; t->settings = ts; t->reports = op ? op->reports : NULL; @@ -1465,17 +1465,17 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } /* Assign the space type, some exceptions for running in different mode */ - if (sa == NULL) { + if (area == NULL) { /* background mode */ t->spacetype = SPACE_EMPTY; } - else if ((region == NULL) && (sa->spacetype == SPACE_VIEW3D)) { + else if ((region == NULL) && (area->spacetype == SPACE_VIEW3D)) { /* running in the text editor */ t->spacetype = SPACE_EMPTY; } else { /* normal operation */ - t->spacetype = sa->spacetype; + t->spacetype = area->spacetype; } /* handle T_ALT_TRANSFORM initialization, we may use for different operators */ @@ -1491,7 +1491,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (t->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C)); t->view = v3d; @@ -1564,7 +1564,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } else if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; // XXX for now, get View2D from the active region t->view = ®ion->v2d; t->around = sima->around; @@ -1589,12 +1589,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->around = V3D_AROUND_CENTER_BOUNDS; } else if (t->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = sa->spacedata.first; + SpaceGraph *sipo = area->spacedata.first; t->view = ®ion->v2d; t->around = sipo->around; } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sclip = sa->spacedata.first; + SpaceClip *sclip = area->spacedata.first; t->view = ®ion->v2d; t->around = sclip->around; @@ -1876,14 +1876,14 @@ void postTrans(bContext *C, TransInfo *t) /* pass */ } else { - SpaceImage *sima = t->sa->spacedata.first; + SpaceImage *sima = t->area->spacedata.first; if (sima->flag & SI_LIVE_UNWRAP) { ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); } } } else if (t->spacetype == SPACE_VIEW3D) { - View3D *v3d = t->sa->spacedata.first; + View3D *v3d = t->area->spacedata.first; /* restore gizmo */ if (t->flag & T_MODAL) { v3d->gizmo_flag = t->gizmo_flag; @@ -2023,11 +2023,11 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2]) const float *cursor = NULL; if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)t->area->spacedata.first; cursor = sima->cursor; } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *space_clip = (SpaceClip *)t->sa->spacedata.first; + SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first; cursor = space_clip->cursor; } @@ -2036,11 +2036,11 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2]) float co[2]; if (t->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)t->area->spacedata.first; BKE_mask_coord_from_image(sima->image, &sima->iuser, co, cursor); } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *space_clip = (SpaceClip *)t->sa->spacedata.first; + SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first; BKE_mask_coord_from_movieclip(space_clip->clip, &space_clip->user, co, cursor); } else { @@ -2065,7 +2065,7 @@ void calculateCenterCursor2D(TransInfo *t, float r_center[2]) void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2]) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; Scene *scene = t->scene; /* cursor is combination of current frame, and graph-editor cursor value */ diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index e85b9f0bee1..50317d8b395 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -68,10 +68,10 @@ static bool gizmo2d_generic_poll(const bContext *C, wmGizmoGroupType *gzgt) return false; } - ScrArea *sa = CTX_wm_area(C); - switch (sa->spacetype) { + ScrArea *area = CTX_wm_area(C); + switch (area->spacetype) { case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; Object *obedit = CTX_data_edit_object(C); if (!ED_space_image_show_uvedit(sima, obedit)) { return false; @@ -86,7 +86,7 @@ static void gizmo2d_pivot_point_message_subscribe(struct wmGizmoGroup *gzgroup, struct wmMsgBus *mbus, /* Additional args. */ bScreen *screen, - ScrArea *sa, + ScrArea *area, ARegion *region) { wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { @@ -95,9 +95,9 @@ static void gizmo2d_pivot_point_message_subscribe(struct wmGizmoGroup *gzgroup, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; PointerRNA ptr; RNA_pointer_create(&screen->id, &RNA_SpaceImageEditor, sima, &ptr); { @@ -214,10 +214,10 @@ static bool gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min r_max = max_buf; } - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bool changed = false; - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Image *ima = ED_space_image(sima); @@ -241,11 +241,11 @@ static bool gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min static bool gizmo2d_calc_center(const bContext *C, float r_center[2]) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bool has_select = false; zero_v2(r_center); - if (sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = sa->spacedata.first; + if (area->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); ED_uvedit_center_from_pivot_ex(sima, scene, view_layer, r_center, sima->around, &has_select); @@ -509,9 +509,9 @@ static void gizmo2d_xform_no_cage_message_subscribe(const struct bContext *C, struct wmMsgBus *mbus) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region); + gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region); } void ED_widgetgroup_gizmo2d_xform_callbacks_set(wmGizmoGroupType *gzgt) @@ -671,9 +671,9 @@ static void gizmo2d_resize_message_subscribe(const struct bContext *C, struct wmMsgBus *mbus) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region); + gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region); } void ED_widgetgroup_gizmo2d_resize_callbacks_set(wmGizmoGroupType *gzgt) @@ -791,9 +791,9 @@ static void gizmo2d_rotate_message_subscribe(const struct bContext *C, struct wmMsgBus *mbus) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, sa, region); + gizmo2d_pivot_point_message_subscribe(gzgroup, mbus, screen, area, region); } void ED_widgetgroup_gizmo2d_rotate_callbacks_set(wmGizmoGroupType *gzgt) diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index de7b2ec02de..6af1989a509 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -734,14 +734,14 @@ int ED_transform_calc_gizmo_stats(const bContext *C, const struct TransformCalcParams *params, struct TransformBounds *tbounds) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(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; + View3D *v3d = area->spacedata.first; Object *obedit = CTX_data_edit_object(C); RegionView3D *rv3d = region->regiondata; Base *base; @@ -1244,7 +1244,7 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup, struct wmMsgBus *mbus, Scene *scene, bScreen *screen, - ScrArea *sa, + ScrArea *area, ARegion *region, const void *type_fn) { @@ -1334,7 +1334,7 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup, } PointerRNA view3d_ptr; - RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &view3d_ptr); + RNA_pointer_create(&screen->id, &RNA_SpaceView3D, area->spacedata.first, &view3d_ptr); if (type_fn == VIEW3D_GGT_xform_gizmo) { GizmoGroup *ggd = gzgroup->customdata; @@ -1701,8 +1701,8 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup) gzgroup->customdata = ggd; { - ScrArea *sa = CTX_wm_area(C); - const bToolRef *tref = sa->runtime.tool; + ScrArea *area = CTX_wm_area(C); + const bToolRef *tref = area->runtime.tool; ggd->twtype = 0; if (tref && STREQ(tref->idname, "builtin.move")) { @@ -1737,8 +1737,8 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup) { GizmoGroup *ggd = gzgroup->customdata; Scene *scene = CTX_data_scene(C); - ScrArea *sa = CTX_wm_area(C); - View3D *v3d = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + View3D *v3d = area->spacedata.first; ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = region->regiondata; struct TransformBounds tbounds; @@ -1844,17 +1844,18 @@ static void WIDGETGROUP_gizmo_message_subscribe(const bContext *C, { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_gizmo); + gizmo_xform_message_subscribe( + gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_gizmo); } static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { GizmoGroup *ggd = gzgroup->customdata; - // ScrArea *sa = CTX_wm_area(C); + // ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - // View3D *v3d = sa->spacedata.first; + // View3D *v3d = area->spacedata.first; RegionView3D *rv3d = region->regiondata; float viewinv_m3[3][3]; copy_m3_m4(viewinv_m3, rv3d->viewinv); @@ -1997,13 +1998,13 @@ static bool WIDGETGROUP_gizmo_poll_generic(View3D *v3d) static bool WIDGETGROUP_gizmo_poll_context(const struct bContext *C, struct wmGizmoGroupType *UNUSED(gzgt)) { - ScrArea *sa = CTX_wm_area(C); - View3D *v3d = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + View3D *v3d = area->spacedata.first; if (!WIDGETGROUP_gizmo_poll_generic(v3d)) { return false; } - const bToolRef *tref = sa->runtime.tool; + const bToolRef *tref = area->runtime.tool; if (v3d->gizmo_flag & V3D_GIZMO_HIDE_CONTEXT) { return false; } @@ -2025,8 +2026,8 @@ static bool WIDGETGROUP_gizmo_poll_tool(const struct bContext *C, struct wmGizmo return false; } - ScrArea *sa = CTX_wm_area(C); - View3D *v3d = sa->spacedata.first; + ScrArea *area = CTX_wm_area(C); + View3D *v3d = area->spacedata.first; if (!WIDGETGROUP_gizmo_poll_generic(v3d)) { return false; } @@ -2247,9 +2248,9 @@ static void WIDGETGROUP_xform_cage_message_subscribe(const bContext *C, { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_cage); + gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_cage); } static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) @@ -2460,9 +2461,10 @@ static void WIDGETGROUP_xform_shear_message_subscribe(const bContext *C, { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, region, VIEW3D_GGT_xform_shear); + gizmo_xform_message_subscribe( + gzgroup, mbus, scene, screen, area, region, VIEW3D_GGT_xform_shear); } static void WIDGETGROUP_xform_shear_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c index 31aae4f5b05..a2b3a891031 100644 --- a/source/blender/editors/transform/transform_mode.c +++ b/source/blender/editors/transform/transform_mode.c @@ -1028,21 +1028,21 @@ short getAnimEdit_SnapMode(TransInfo *t) short autosnap = SACTSNAP_OFF; if (t->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; if (saction) { autosnap = saction->autosnap; } } else if (t->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first; if (sipo) { autosnap = sipo->autosnap; } } else if (t->spacetype == SPACE_NLA) { - SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; + SpaceNla *snla = (SpaceNla *)t->area->spacedata.first; if (snla) { autosnap = snla->autosnap; diff --git a/source/blender/editors/transform/transform_mode_align.c b/source/blender/editors/transform/transform_mode_align.c index fbd5e87f034..9bce793809b 100644 --- a/source/blender/editors/transform/transform_mode_align.c +++ b/source/blender/editors/transform/transform_mode_align.c @@ -82,7 +82,7 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, TIP_("Align")); + ED_area_status_text(t->area, TIP_("Align")); } void initAlign(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_baketime.c b/source/blender/editors/transform/transform_mode_baketime.c index 0feaa27d4ce..bb8fd0df13d 100644 --- a/source/blender/editors/transform/transform_mode_baketime.c +++ b/source/blender/editors/transform/transform_mode_baketime.c @@ -119,7 +119,7 @@ static void applyBakeTime(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBakeTime(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c index 1a32a550cb0..c81049ac379 100644 --- a/source/blender/editors/transform/transform_mode_bbone_resize.c +++ b/source/blender/editors/transform/transform_mode_bbone_resize.c @@ -155,7 +155,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBoneSize(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c index bf80673fbb4..721d226050a 100644 --- a/source/blender/editors/transform/transform_mode_bend.c +++ b/source/blender/editors/transform/transform_mode_bend.c @@ -246,7 +246,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBend(TransInfo *t) @@ -289,7 +289,8 @@ void initBend(TransInfo *t) curs = t->scene->cursor.location; copy_v3_v3(data->warp_sta, curs); - ED_view3d_win_to_3d((View3D *)t->sa->spacedata.first, t->region, curs, mval_fl, data->warp_end); + ED_view3d_win_to_3d( + (View3D *)t->area->spacedata.first, t->region, curs, mval_fl, data->warp_end); copy_v3_v3(data->warp_nor, t->viewinv[2]); normalize_v3(data->warp_nor); diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c index 0886d4e01ef..aa20a5ade95 100644 --- a/source/blender/editors/transform/transform_mode_boneenvelope.c +++ b/source/blender/editors/transform/transform_mode_boneenvelope.c @@ -95,7 +95,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBoneEnvelope(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_boneroll.c b/source/blender/editors/transform/transform_mode_boneroll.c index 8e9d680f269..0564a946148 100644 --- a/source/blender/editors/transform/transform_mode_boneroll.c +++ b/source/blender/editors/transform/transform_mode_boneroll.c @@ -89,7 +89,7 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBoneRoll(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c index 6ccb0e757c3..057f13ac068 100644 --- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c @@ -94,7 +94,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initCurveShrinkFatten(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c b/source/blender/editors/transform/transform_mode_edge_bevelweight.c index 15a9e7384b1..5db7895232c 100644 --- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c +++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c @@ -105,7 +105,7 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initBevelWeight(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c b/source/blender/editors/transform/transform_mode_edge_crease.c index 8865721bc7e..4a92a57fef6 100644 --- a/source/blender/editors/transform/transform_mode_edge_crease.c +++ b/source/blender/editors/transform/transform_mode_edge_crease.c @@ -109,7 +109,7 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initCrease(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c index 69cd909cff9..18149a09f20 100644 --- a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c +++ b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c @@ -121,7 +121,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initNormalRotation(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.c b/source/blender/editors/transform/transform_mode_edge_seq_slide.c index e23e5c188c8..ee91459dcdd 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c @@ -120,7 +120,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initSeqSlide(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index b54e6afc9a1..5613a782529 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -334,7 +334,7 @@ static void calcEdgeSlide_mval_range(TransInfo *t, if (t->spacetype == SPACE_VIEW3D) { /* background mode support */ - v3d = t->sa ? t->sa->spacedata.first : NULL; + v3d = t->area ? t->area->spacedata.first : NULL; rv3d = t->region ? t->region->regiondata : NULL; } @@ -858,7 +858,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t /* use for visibility checks */ if (t->spacetype == SPACE_VIEW3D) { - v3d = t->sa ? t->sa->spacedata.first : NULL; + v3d = t->area ? t->area->spacedata.first : NULL; rv3d = t->region ? t->region->regiondata : NULL; use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && !XRAY_ENABLED(v3d)); @@ -899,7 +899,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t if (t->spacetype == SPACE_VIEW3D) { /* background mode support */ - v3d = t->sa ? t->sa->spacedata.first : NULL; + v3d = t->area ? t->area->spacedata.first : NULL; rv3d = t->region ? t->region->regiondata : NULL; } @@ -1043,7 +1043,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t /* use for visibility checks */ if (t->spacetype == SPACE_VIEW3D) { - v3d = t->sa ? t->sa->spacedata.first : NULL; + v3d = t->area ? t->area->spacedata.first : NULL; rv3d = t->region ? t->region->regiondata : NULL; use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && !XRAY_ENABLED(v3d)); @@ -1417,7 +1417,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initEdgeSlide_ex( diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c index 460e2b41da8..267d297a31c 100644 --- a/source/blender/editors/transform/transform_mode_gpopacity.c +++ b/source/blender/editors/transform/transform_mode_gpopacity.c @@ -90,7 +90,7 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) } } - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initGPOpacity(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c index edb353b343d..7c49d107703 100644 --- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c @@ -92,7 +92,7 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) } } - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initGPShrinkFatten(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c index b6719067f5b..e42439920db 100644 --- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c @@ -124,7 +124,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initMaskShrinkFatten(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_mirror.c b/source/blender/editors/transform/transform_mode_mirror.c index 2f305989f82..dae17374481 100644 --- a/source/blender/editors/transform/transform_mode_mirror.c +++ b/source/blender/editors/transform/transform_mode_mirror.c @@ -83,7 +83,7 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } else { size[0] = size[1] = size[2] = 1; @@ -108,10 +108,10 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); if (t->flag & T_2D_EDIT) { - ED_area_status_text(t->sa, TIP_("Select a mirror axis (X, Y)")); + ED_area_status_text(t->area, TIP_("Select a mirror axis (X, Y)")); } else { - ED_area_status_text(t->sa, TIP_("Select a mirror axis (X, Y, Z)")); + ED_area_status_text(t->area, TIP_("Select a mirror axis (X, Y, Z)")); } } } diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c index 890fc820cd5..6eb038ea9b0 100644 --- a/source/blender/editors/transform/transform_mode_push_pull.c +++ b/source/blender/editors/transform/transform_mode_push_pull.c @@ -114,7 +114,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initPushPull(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c index 59f2ab5c294..00644b9bfdc 100644 --- a/source/blender/editors/transform/transform_mode_resize.c +++ b/source/blender/editors/transform/transform_mode_resize.c @@ -131,7 +131,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initResize(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c index bea039194d0..6c2b3dc77d2 100644 --- a/source/blender/editors/transform/transform_mode_rotate.c +++ b/source/blender/editors/transform/transform_mode_rotate.c @@ -169,7 +169,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initRotation(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c index 8b7dc12f41b..ba79f5f3c7b 100644 --- a/source/blender/editors/transform/transform_mode_shear.c +++ b/source/blender/editors/transform/transform_mode_shear.c @@ -217,7 +217,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initShear(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c index e24e63f445c..ed082e86b6d 100644 --- a/source/blender/editors/transform/transform_mode_shrink_fatten.c +++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c @@ -115,7 +115,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initShrinkFatten(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_skin_resize.c b/source/blender/editors/transform/transform_mode_skin_resize.c index 23ba9a07f3e..b53dbb55c62 100644 --- a/source/blender/editors/transform/transform_mode_skin_resize.c +++ b/source/blender/editors/transform/transform_mode_skin_resize.c @@ -102,7 +102,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initSkinResize(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_tilt.c b/source/blender/editors/transform/transform_mode_tilt.c index 9ae0cfdf805..2f56f4bd162 100644 --- a/source/blender/editors/transform/transform_mode_tilt.c +++ b/source/blender/editors/transform/transform_mode_tilt.c @@ -93,7 +93,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTilt(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_timescale.c b/source/blender/editors/transform/transform_mode_timescale.c index b75ef4da0f2..ce46cc36276 100644 --- a/source/blender/editors/transform/transform_mode_timescale.c +++ b/source/blender/editors/transform/transform_mode_timescale.c @@ -109,7 +109,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTimeScale(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_timeslide.c b/source/blender/editors/transform/transform_mode_timeslide.c index fce526873f1..43e14a26930 100644 --- a/source/blender/editors/transform/transform_mode_timeslide.c +++ b/source/blender/editors/transform/transform_mode_timeslide.c @@ -82,7 +82,7 @@ static void applyTimeSlideValue(TransInfo *t, float sval, float cval) /* set value for drawing black line */ if (t->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; saction->timeslide = cval; } @@ -160,14 +160,14 @@ static void applyTimeSlide(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTimeSlide(TransInfo *t) { /* this tool is only really available in the Action Editor... */ if (t->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)t->area->spacedata.first; /* set flag for drawing stuff */ saction->flag |= SACTION_MOVING; diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c index 494609cafb0..c514df497bc 100644 --- a/source/blender/editors/transform/transform_mode_timetranslate.c +++ b/source/blender/editors/transform/transform_mode_timetranslate.c @@ -136,7 +136,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTimeTranslate(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c index 5a3b138823c..841ccf41365 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.c +++ b/source/blender/editors/transform/transform_mode_tosphere.c @@ -101,7 +101,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initToSphere(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_trackball.c b/source/blender/editors/transform/transform_mode_trackball.c index 758ee3b9cae..c6e0b205204 100644 --- a/source/blender/editors/transform/transform_mode_trackball.c +++ b/source/blender/editors/transform/transform_mode_trackball.c @@ -143,7 +143,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTrackball(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index aef5a999d18..0a7d8bd90d3 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -191,7 +191,7 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ } if (t->spacetype == SPACE_NODE) { - SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + SpaceNode *snode = (SpaceNode *)t->area->spacedata.first; if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { const char *str_old = BLI_strdup(str); @@ -370,7 +370,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initTranslation(TransInfo *t) diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c index 2325c4d1d26..7bee48337f9 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.c +++ b/source/blender/editors/transform/transform_mode_vert_slide.c @@ -602,7 +602,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_status_text(t->sa, str); + ED_area_status_text(t->area, str); } void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 7e56b34af2f..31b85cdf3a8 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -893,8 +893,8 @@ static bool transform_shear_poll(bContext *C) return false; } - ScrArea *sa = CTX_wm_area(C); - return sa && !ELEM(sa->spacetype, SPACE_ACTION); + ScrArea *area = CTX_wm_area(C); + return area && !ELEM(area->spacetype, SPACE_ACTION); } static void TRANSFORM_OT_shear(struct wmOperatorType *ot) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index dffe52745e4..cb4446deb99 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1106,7 +1106,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) } else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) { if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) { - Image *ima = ED_space_image(t->sa->spacedata.first); + Image *ima = ED_space_image(t->area->spacedata.first); float co[2]; UI_view2d_region_to_view(&t->region->v2d, t->mval[0], t->mval[1], &co[0], &co[1]); @@ -1581,7 +1581,7 @@ bool snapNodesTransform( TransInfo *t, const int mval[2], float r_loc[2], float *r_dist_px, char *r_node_border) { return snapNodes(t->settings, - t->sa->spacedata.first, + t->area->spacedata.first, t->region, mval, t->tsnap.modeSelect, @@ -1716,7 +1716,7 @@ static void applyGridIncrement( if (t->spacetype == SPACE_GRAPH) { View2D *v2d = &t->region->v2d; Scene *scene = t->scene; - SpaceGraph *sipo = t->sa->spacedata.first; + SpaceGraph *sipo = t->area->spacedata.first; asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds( v2d, scene, sipo->flag & SIPO_DRAWTIME); asp_local[1] = UI_view2d_grid_resolution_y__values(v2d); diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 9db957f8031..39ecbad1807 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -119,7 +119,7 @@ static int ed_undo_step_impl( CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step); wmWindowManager *wm = CTX_wm_manager(C); Scene *scene = CTX_data_scene(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* undo during jobs are running can easily lead to freeing data using by jobs, * or they can just lead to freezing job in some other cases */ @@ -138,7 +138,7 @@ static int ed_undo_step_impl( if (ED_gpencil_session_active()) { return ED_undo_gpencil_step(C, step, undoname); } - if (sa && (sa->spacetype == SPACE_VIEW3D)) { + if (area && (area->spacetype == SPACE_VIEW3D)) { Object *obact = CTX_data_active_object(C); if (obact && (obact->type == OB_GPENCIL)) { ED_gpencil_toggle_brush_cursor(C, false, NULL); @@ -195,7 +195,7 @@ static int ed_undo_step_impl( } /* Set special modes for grease pencil */ - if (sa && (sa->spacetype == SPACE_VIEW3D)) { + if (area && (area->spacetype == SPACE_VIEW3D)) { Object *obact = CTX_data_active_object(C); if (obact && (obact->type == OB_GPENCIL)) { /* set cursor */ diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index b88fcf5a328..358b3edde6b 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -472,12 +472,12 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_ * * \param new_id: may be NULL to unlink \a old_id. */ -void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, ID *new_id) +void ED_spacedata_id_remap(struct ScrArea *area, struct SpaceLink *sl, ID *old_id, ID *new_id) { SpaceType *st = BKE_spacetype_from_id(sl->spacetype); if (st && st->id_remap) { - st->id_remap(sa, sl, old_id, new_id); + st->id_remap(area, sl, old_id, new_id); } } diff --git a/source/blender/editors/util/gizmo_utils.c b/source/blender/editors/util/gizmo_utils.c index 85a7cc94ae3..08e7b3a9a0a 100644 --- a/source/blender/editors/util/gizmo_utils.c +++ b/source/blender/editors/util/gizmo_utils.c @@ -59,9 +59,9 @@ bool ED_gizmo_poll_or_unlink_delayed_from_tool_ex(const bContext *C, { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || !STREQ(gzgt_idname, tref_rt->gizmo_group)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); - WM_gizmo_group_unlink_delayed_ptr_from_space(gzgt, gzmap_type, sa); + WM_gizmo_group_unlink_delayed_ptr_from_space(gzgt, gzmap_type, area); if (gzgt->users == 0) { WM_gizmo_group_type_unlink_delayed_ptr(gzgt); } diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 7f05eba7c72..3a4f12acf9c 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -299,9 +299,9 @@ static void stitch_update_header(StitchStateContainer *ssc, bContext *C) "shift select vertices"); char msg[UI_MAX_DRAW_STR]; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); - if (sa) { + if (area) { BLI_snprintf(msg, sizeof(msg), str, @@ -2438,7 +2438,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) { Scene *scene = CTX_data_scene(C); SpaceImage *sima = CTX_wm_space_image(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); StitchStateContainer *ssc = (StitchStateContainer *)op->customdata; @@ -2492,7 +2492,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) MEM_freeN(objs_selection_count); } - if (sa) { + if (area) { ED_workspace_status_text(C, NULL); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 8ded2c16be8..c4dcaaaa8b2 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -708,7 +708,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op) static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interactive) { MinStretch *ms = op->customdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); const Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0; @@ -724,9 +724,9 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac param_flush(ms->handle); - if (sa) { + if (area) { BLI_snprintf(str, sizeof(str), TIP_("Minimize Stretch. Blend %.2f"), ms->blend); - ED_area_status_text(sa, str); + ED_area_status_text(area, str); ED_workspace_status_text(C, TIP_("Press + and -, or scroll wheel to set blending")); } @@ -749,12 +749,12 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel) { MinStretch *ms = op->customdata; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); const Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0; - ED_area_status_text(sa, NULL); + ED_area_status_text(area, NULL); ED_workspace_status_text(C, NULL); if (ms->timer) { diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 127341e6801..3464f6d7179 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -169,10 +169,10 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); } - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; if (!sima->pin) { diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index f4b64d2f812..194f5418e75 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -276,9 +276,9 @@ static void rna_Object_local_view_set(Object *ob, SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid); if (local_view_bits_prev != base->local_view_bits) { DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); - ScrArea *sa = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true); - if (sa) { - ED_area_tag_redraw(sa); + ScrArea *area = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true); + if (area) { + ED_area_tag_redraw(area); } } } diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index c6245f51e15..290404291ae 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -116,10 +116,10 @@ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), static int rna_Area_type_get(PointerRNA *ptr) { - ScrArea *sa = (ScrArea *)ptr->data; + ScrArea *area = (ScrArea *)ptr->data; /* Usually 'spacetype' is used. It lags behind a bit while switching area * type though, then we use 'butspacetype' instead (T41435). */ - return (sa->butspacetype == SPACE_EMPTY) ? sa->spacetype : sa->butspacetype; + return (area->butspacetype == SPACE_EMPTY) ? area->spacetype : area->butspacetype; } static void rna_Area_type_set(PointerRNA *ptr, int value) @@ -131,17 +131,17 @@ static void rna_Area_type_set(PointerRNA *ptr, int value) return; } - ScrArea *sa = (ScrArea *)ptr->data; - sa->butspacetype = value; + ScrArea *area = (ScrArea *)ptr->data; + area->butspacetype = value; } static void rna_Area_type_update(bContext *C, PointerRNA *ptr) { bScreen *sc = (bScreen *)ptr->owner_id; - ScrArea *sa = (ScrArea *)ptr->data; + ScrArea *area = (ScrArea *)ptr->data; /* Running update without having called 'set', see: T64049 */ - if (sa->butspacetype == SPACE_EMPTY) { + if (area->butspacetype == SPACE_EMPTY) { return; } @@ -155,17 +155,17 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) ARegion *prevar = CTX_wm_region(C); CTX_wm_window_set(C, win); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, NULL); - ED_area_newspace(C, sa, sa->butspacetype, true); - ED_area_tag_redraw(sa); + ED_area_newspace(C, area, area->butspacetype, true); + ED_area_tag_redraw(area); /* Unset so that rna_Area_type_get uses spacetype instead. */ - sa->butspacetype = SPACE_EMPTY; + area->butspacetype = SPACE_EMPTY; /* It is possible that new layers becomes visible. */ - if (sa->spacetype == SPACE_VIEW3D) { + if (area->spacetype == SPACE_VIEW3D) { DEG_on_visible_update(CTX_data_main(C), false); } @@ -213,51 +213,51 @@ static const EnumPropertyItem *rna_Area_ui_type_itemf(bContext *C, static int rna_Area_ui_type_get(PointerRNA *ptr) { - ScrArea *sa = ptr->data; + ScrArea *area = ptr->data; const int area_type = rna_Area_type_get(ptr); - const bool area_changing = sa->butspacetype != SPACE_EMPTY; + const bool area_changing = area->butspacetype != SPACE_EMPTY; int value = area_type << 16; - /* sa->type can be NULL (when not yet initialized), try to do it now. */ + /* area->type can be NULL (when not yet initialized), try to do it now. */ /* Copied from `ED_area_initialize()`.*/ - if (sa->type == NULL || area_changing) { - sa->type = BKE_spacetype_from_id(area_type); - if (sa->type == NULL) { - sa->spacetype = SPACE_VIEW3D; - sa->type = BKE_spacetype_from_id(sa->spacetype); + if (area->type == NULL || area_changing) { + area->type = BKE_spacetype_from_id(area_type); + if (area->type == NULL) { + area->spacetype = SPACE_VIEW3D; + area->type = BKE_spacetype_from_id(area->spacetype); } - BLI_assert(sa->type != NULL); + BLI_assert(area->type != NULL); } - if (sa->type->space_subtype_item_extend != NULL) { - value |= area_changing ? sa->butspacetype_subtype : sa->type->space_subtype_get(sa); + if (area->type->space_subtype_item_extend != NULL) { + value |= area_changing ? area->butspacetype_subtype : area->type->space_subtype_get(area); } return value; } static void rna_Area_ui_type_set(PointerRNA *ptr, int value) { - ScrArea *sa = ptr->data; + ScrArea *area = ptr->data; const int space_type = value >> 16; SpaceType *st = BKE_spacetype_from_id(space_type); rna_Area_type_set(ptr, space_type); if (st && st->space_subtype_item_extend != NULL) { - sa->butspacetype_subtype = value & 0xffff; + area->butspacetype_subtype = value & 0xffff; } } static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr) { - ScrArea *sa = ptr->data; - SpaceType *st = BKE_spacetype_from_id(sa->butspacetype); + ScrArea *area = ptr->data; + SpaceType *st = BKE_spacetype_from_id(area->butspacetype); rna_Area_type_update(C, ptr); - if ((sa->type == st) && (st->space_subtype_item_extend != NULL)) { - st->space_subtype_set(sa, sa->butspacetype_subtype); + if ((area->type == st) && (st->space_subtype_item_extend != NULL)) { + st->space_subtype_set(area, area->butspacetype_subtype); } - sa->butspacetype_subtype = 0; + area->butspacetype_subtype = 0; } static void rna_View2D_region_to_view(struct View2D *v2d, float x, float y, float result[2]) diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index f2d5c465dac..345d5ecf007 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -511,10 +511,10 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr)) Image *ima = scene->toolsettings->imapaint.canvas; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrArea *area; + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *slink; - for (slink = sa->spacedata.first; slink; slink = slink->next) { + for (slink = area->spacedata.first; slink; slink = slink->next) { if (slink->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)slink; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 7bff13bf1a6..da8827ee6bd 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -575,19 +575,19 @@ static ScrArea *rna_area_from_space(PointerRNA *ptr) static void area_region_from_regiondata(bScreen *sc, void *regiondata, - ScrArea **r_sa, + ScrArea **r_area, ARegion **r_region) { - ScrArea *sa; + ScrArea *area; ARegion *region; - *r_sa = NULL; + *r_area = NULL; *r_region = NULL; - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (region = sa->regionbase.first; region; region = region->next) { + for (area = sc->areabase.first; area; area = area->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region->regiondata == regiondata) { - *r_sa = sa; + *r_area = area; *r_region = region; return; } @@ -595,12 +595,12 @@ static void area_region_from_regiondata(bScreen *sc, } } -static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARegion **r_region) +static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_area, ARegion **r_region) { bScreen *sc = (bScreen *)ptr->owner_id; void *regiondata = ptr->data; - area_region_from_regiondata(sc, regiondata, r_sa, r_region); + area_region_from_regiondata(sc, regiondata, r_area, r_region); } /* -------------------------------------------------------------------- */ @@ -611,8 +611,8 @@ static bool rna_Space_bool_from_region_flag_get_by_type(PointerRNA *ptr, const int region_type, const int region_flag) { - ScrArea *sa = rna_area_from_space(ptr); - ARegion *region = BKE_area_find_region_type(sa, region_type); + ScrArea *area = rna_area_from_space(ptr); + ARegion *region = BKE_area_find_region_type(area, region_type); if (region) { return (region->flag & region_flag); } @@ -624,8 +624,8 @@ static void rna_Space_bool_from_region_flag_set_by_type(PointerRNA *ptr, const int region_flag, bool value) { - ScrArea *sa = rna_area_from_space(ptr); - ARegion *region = BKE_area_find_region_type(sa, region_type); + ScrArea *area = rna_area_from_space(ptr); + ARegion *region = BKE_area_find_region_type(area, region_type); if (region && (region->alignment != RGN_ALIGN_NONE)) { SET_FLAG_FROM_TEST(region->flag, value, region_flag); } @@ -637,16 +637,16 @@ static void rna_Space_bool_from_region_flag_update_by_type(bContext *C, const int region_type, const int region_flag) { - ScrArea *sa = rna_area_from_space(ptr); - ARegion *region = BKE_area_find_region_type(sa, region_type); + ScrArea *area = rna_area_from_space(ptr); + ARegion *region = BKE_area_find_region_type(area, region_type); if (region) { if (region_flag == RGN_FLAG_HIDDEN) { /* Only support animation when the area is in the current context. */ - if (region->overlap && (sa == CTX_wm_area(C))) { - ED_region_visibility_change_update_animated(C, sa, region); + if (region->overlap && (area == CTX_wm_area(C))) { + ED_region_visibility_change_update_animated(C, area, region); } else { - ED_region_visibility_change_update(C, sa, region); + ED_region_visibility_change_update(C, area, region); } } else if (region_flag == RGN_FLAG_HIDDEN_BY_USER) { @@ -654,7 +654,7 @@ static void rna_Space_bool_from_region_flag_update_by_type(bContext *C, ED_region_toggle_hidden(C, region); if ((region->flag & RGN_FLAG_HIDDEN_BY_USER) == 0) { - ED_area_type_hud_ensure(C, sa); + ED_area_type_hud_ensure(C, area); } } } @@ -679,8 +679,8 @@ static void rna_Space_show_region_header_set(PointerRNA *ptr, bool value) /* Special case, never show the tool properties when the header is invisible. */ bool value_for_tool_header = value; if (value == true) { - ScrArea *sa = rna_area_from_space(ptr); - ARegion *region_tool_header = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER); + ScrArea *area = rna_area_from_space(ptr); + ARegion *region_tool_header = BKE_area_find_region_type(area, RGN_TYPE_TOOL_HEADER); if (region_tool_header != NULL) { value_for_tool_header = !(region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER); } @@ -773,11 +773,11 @@ static void rna_Space_show_region_hud_update(bContext *C, PointerRNA *ptr) static bool rna_Space_view2d_sync_get(PointerRNA *ptr) { - ScrArea *sa; + ScrArea *area; ARegion *region; - sa = rna_area_from_space(ptr); /* can be NULL */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + area = rna_area_from_space(ptr); /* can be NULL */ + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { View2D *v2d = ®ion->v2d; return (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME) != 0; @@ -788,11 +788,11 @@ static bool rna_Space_view2d_sync_get(PointerRNA *ptr) static void rna_Space_view2d_sync_set(PointerRNA *ptr, bool value) { - ScrArea *sa; + ScrArea *area; ARegion *region; - sa = rna_area_from_space(ptr); /* can be NULL */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + area = rna_area_from_space(ptr); /* can be NULL */ + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { View2D *v2d = ®ion->v2d; if (value) { @@ -808,17 +808,17 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - ScrArea *sa; + ScrArea *area; ARegion *region; - sa = rna_area_from_space(ptr); /* can be NULL */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + area = rna_area_from_space(ptr); /* can be NULL */ + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { bScreen *sc = (bScreen *)ptr->owner_id; View2D *v2d = ®ion->v2d; - UI_view2d_sync(sc, sa, v2d, V2D_LOCK_SET); + UI_view2d_sync(sc, area, v2d, V2D_LOCK_SET); } } @@ -885,10 +885,10 @@ static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); - ScrArea *sa = rna_area_from_space(ptr); + ScrArea *area = rna_area_from_space(ptr); void *regiondata = NULL; - if (sa) { - ListBase *regionbase = (sa->spacedata.first == v3d) ? &sa->regionbase : &v3d->regionbase; + if (area) { + ListBase *regionbase = (area->spacedata.first == v3d) ? &area->regionbase : &v3d->regionbase; ARegion *region = regionbase->last; /* always last in list, weak .. */ regiondata = region->regiondata; } @@ -900,11 +900,11 @@ static void rna_SpaceView3D_region_quadviews_begin(CollectionPropertyIterator *i PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); - ScrArea *sa = rna_area_from_space(ptr); + ScrArea *area = rna_area_from_space(ptr); int i = 3; ARegion *region = - ((sa && sa->spacedata.first == v3d) ? &sa->regionbase : &v3d->regionbase)->last; + ((area && area->spacedata.first == v3d) ? &area->regionbase : &v3d->regionbase)->last; ListBase lb = {NULL, NULL}; if (region && region->alignment == RGN_ALIGN_QSPLIT) { @@ -931,12 +931,12 @@ static void rna_RegionView3D_quadview_update(Main *UNUSED(main), Scene *UNUSED(scene), PointerRNA *ptr) { - ScrArea *sa; + ScrArea *area; ARegion *region; - rna_area_region_from_regiondata(ptr, &sa, ®ion); - if (sa && region && region->alignment == RGN_ALIGN_QSPLIT) { - ED_view3d_quadview_update(sa, region, false); + rna_area_region_from_regiondata(ptr, &area, ®ion); + if (area && region && region->alignment == RGN_ALIGN_QSPLIT) { + ED_view3d_quadview_update(area, region, false); } } @@ -945,12 +945,12 @@ static void rna_RegionView3D_quadview_clip_update(Main *UNUSED(main), Scene *UNUSED(scene), PointerRNA *ptr) { - ScrArea *sa; + ScrArea *area; ARegion *region; - rna_area_region_from_regiondata(ptr, &sa, ®ion); - if (sa && region && region->alignment == RGN_ALIGN_QSPLIT) { - ED_view3d_quadview_update(sa, region, true); + rna_area_region_from_regiondata(ptr, &area, ®ion); + if (area && region && region->alignment == RGN_ALIGN_QSPLIT) { + ED_view3d_quadview_update(area, region, true); } } @@ -1027,12 +1027,12 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA rna_GPencil_update(bmain, scene, ptr); bScreen *screen = (bScreen *)ptr->owner_id; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (&v3d->shading == shading) { - ED_view3d_shade_update(bmain, v3d, sa); + ED_view3d_shade_update(bmain, v3d, area); return; } } @@ -1549,14 +1549,14 @@ static int rna_SpaceImageEditor_display_channels_get(PointerRNA *ptr) static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values) { SpaceImage *sima = (SpaceImage *)ptr->data; - ScrArea *sa; + ScrArea *area; ARegion *region; values[0] = values[1] = 1; /* find aregion */ - sa = rna_area_from_space(ptr); /* can be NULL */ - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + area = rna_area_from_space(ptr); /* can be NULL */ + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { ED_space_image_get_zoom(sima, region, &values[0], &values[1]); } @@ -2030,7 +2030,7 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr) static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obact = OBACT(view_layer); @@ -2070,8 +2070,8 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) saction->ads.filterflag |= ADS_FILTER_SUMMARY; } - if (sa && sa->spacedata.first == saction) { - ARegion *channels_region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + if (area && area->spacedata.first == saction) { + ARegion *channels_region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS); if (channels_region) { if (saction->mode == SACTCONT_TIMELINE) { channels_region->flag |= RGN_FLAG_HIDDEN; @@ -2079,7 +2079,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) else { channels_region->flag &= ~RGN_FLAG_HIDDEN; } - ED_region_visibility_change_update(C, sa, channels_region); + ED_region_visibility_change_update(C, area, channels_region); } } @@ -2097,19 +2097,19 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *ptr) { - ScrArea *sa = rna_area_from_space(ptr); + ScrArea *area = rna_area_from_space(ptr); SpaceGraph *sipo = (SpaceGraph *)ptr->data; /* for "Drivers" mode, enable all the necessary bits and pieces */ if (sipo->mode == SIPO_MODE_DRIVERS) { - ED_drivers_editor_init(C, sa); - ED_area_tag_redraw(sa); + ED_drivers_editor_init(C, area); + ED_area_tag_redraw(area); } /* after changing view mode, must force recalculation of F-Curve colors * which can only be achieved using refresh as opposed to redraw */ - ED_area_tag_refresh(sa); + ED_area_tag_refresh(area); } static bool rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr) @@ -2137,8 +2137,8 @@ static void rna_Sequencer_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - ScrArea *sa = rna_area_from_space(ptr); - ED_area_tag_refresh(sa); + ScrArea *area = rna_area_from_space(ptr); + ED_area_tag_refresh(area); } /* Space Node Editor */ @@ -2286,8 +2286,8 @@ static void rna_SpaceClipEditor_clip_mode_update(Main *UNUSED(bmain), if (sc->mode == SC_MODE_MASKEDIT && sc->view != SC_VIEW_CLIP) { /* Make sure we are in the right view for mask editing */ sc->view = SC_VIEW_CLIP; - ScrArea *sa = rna_area_from_space(ptr); - ED_area_tag_refresh(sa); + ScrArea *area = rna_area_from_space(ptr); + ED_area_tag_refresh(area); } sc->scopes.ok = 0; @@ -2307,8 +2307,8 @@ static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - ScrArea *sa = rna_area_from_space(ptr); - ED_area_tag_refresh(sa); + ScrArea *area = rna_area_from_space(ptr); + ED_area_tag_refresh(area); } /* File browser. */ diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index 84c80e56d0d..a8caf905c5f 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -34,14 +34,14 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C) { bScreen *sc = (bScreen *)id; - ScrArea *sa; + ScrArea *area; ARegion *region; - area_region_from_regiondata(sc, rv3d, &sa, ®ion); + area_region_from_regiondata(sc, rv3d, &area, ®ion); - if (sa && region && sa->spacetype == SPACE_VIEW3D) { + if (area && region && area->spacetype == SPACE_VIEW3D) { Main *bmain = CTX_data_main(C); - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; @@ -62,9 +62,9 @@ static void rna_SpaceTextEditor_region_location_from_cursor( ID *id, SpaceText *st, int line, int column, int r_pixel_pos[2]) { bScreen *sc = (bScreen *)id; - ScrArea *sa = BKE_screen_find_area_from_space(sc, (SpaceLink *)st); - if (sa) { - ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ScrArea *area = BKE_screen_find_area_from_space(sc, (SpaceLink *)st); + if (area) { + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); const int cursor_co[2] = {line, column}; ED_text_region_location_from_cursor(st, region, cursor_co, r_pixel_pos); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 273bef6d239..0800127fa9c 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -212,10 +212,11 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) BLI_freelinkN(&art->paneltypes, pt); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == space_type) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; for (ARegion *region = regionbase->first; region; region = region->next) { if (region->type == art) { for (Panel *pa = region->panels.first; pa; pa = pa->next) { diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 47d793382a7..104ad4c5e25 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -258,8 +258,8 @@ static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) /* We could try workaruond this lookup, but not trivial. */ for (bScreen *screen = G_MAIN->screens.first; screen; screen = screen->id.next) { IDProperty *properties = ptr->data; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->gizmo_map) { wmGizmoMap *gzmap = region->gizmo_map; for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 8047e5e2112..bd24ec87620 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -188,7 +188,7 @@ void WM_lib_reload(struct Library *lib, struct bContext *C, struct ReportList *r /* mouse cursors */ void WM_cursor_set(struct wmWindow *win, int curs); -bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *sa, const ARegion *region); +bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *area, const ARegion *region); void WM_cursor_modal_set(struct wmWindow *win, int curs); void WM_cursor_modal_restore(struct wmWindow *win); void WM_cursor_wait(bool val); @@ -841,18 +841,18 @@ typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *C, void WM_tooltip_immediate_init(struct bContext *C, struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, wmTooltipInitFn init); void WM_tooltip_timer_init_ex(struct bContext *C, struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, wmTooltipInitFn init, double delay); void WM_tooltip_timer_init(struct bContext *C, struct wmWindow *win, - struct ScrArea *sa, + struct ScrArea *area, struct ARegion *region, wmTooltipInitFn init); void WM_tooltip_timer_clear(struct bContext *C, struct wmWindow *win); diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 36cb5be7547..163f37be974 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -87,17 +87,17 @@ void WM_toolsystem_ref_sync_from_context(struct Main *bmain, void WM_toolsystem_init(struct bContext *C); int WM_toolsystem_mode_from_spacetype(struct ViewLayer *view_layer, - struct ScrArea *sa, + struct ScrArea *area, int space_type); bool WM_toolsystem_key_from_context(struct ViewLayer *view_layer, - struct ScrArea *sa, + struct ScrArea *area, bToolKey *tkey); void WM_toolsystem_update_from_context_view3d(struct bContext *C); void WM_toolsystem_update_from_context(struct bContext *C, struct WorkSpace *workspace, struct ViewLayer *view_layer, - struct ScrArea *sa); + struct ScrArea *area); bool WM_toolsystem_active_tool_is_brush(const struct bContext *C); @@ -134,7 +134,7 @@ void WM_toolsystem_refresh_active(struct bContext *C); void WM_toolsystem_refresh_screen_area(struct WorkSpace *workspace, struct ViewLayer *view_layer, - struct ScrArea *sa); + struct ScrArea *area); void WM_toolsystem_refresh_screen_all(struct Main *bmain); #ifdef __cplusplus diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index f27f3ccf71c..33b3ca5f2e2 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -81,7 +81,7 @@ * ScrArea's store a list of space data (SpaceLinks), each of unique type. * The first one is the displayed in the UI, others are added as needed. * - * +----------------------------+ <-- sa->spacedata.first; + * +----------------------------+ <-- area->spacedata.first; * | | * | |---+ <-- other inactive SpaceLink's stored. * | | | @@ -99,8 +99,8 @@ * * A common way to get the space from the ScrArea: * \code{.c} - * if (sa->spacetype == SPACE_VIEW3D) { - * View3D *v3d = sa->spacedata.first; + * if (area->spacetype == SPACE_VIEW3D) { + * View3D *v3d = area->spacedata.first; * ... * } * \endcode diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 44c1804aa4d..07a3f0445bb 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -373,7 +373,7 @@ void WM_gizmo_group_type_unlink_delayed(const char *idname); void WM_gizmo_group_unlink_delayed_ptr_from_space(struct wmGizmoGroupType *gzgt, struct wmGizmoMapType *gzmap_type, - struct ScrArea *sa); + struct ScrArea *area); /* Has the result of unlinking and linking (re-initializes gizmo's). */ void WM_gizmo_group_type_reinit_ptr_ex(struct Main *bmain, diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index b7fecb31f96..6be85539113 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -299,9 +299,9 @@ void WM_gizmo_group_remove_by_tool(bContext *C, { wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(&gzgt->gzmap_params); for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - if (sa->runtime.tool == tref) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + if (area->runtime.tool == tref) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { wmGizmoGroup *gzgroup, *gzgroup_next; @@ -909,9 +909,9 @@ void WM_gizmomaptype_group_init_runtime(const Main *bmain, /* now create a gizmo for all existing areas */ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { @@ -964,9 +964,9 @@ void WM_gizmomaptype_group_unlink(bContext *C, { /* Free instances. */ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { @@ -1132,9 +1132,9 @@ void WM_gizmo_group_type_unlink_delayed(const char *idname) void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type, - ScrArea *sa) + ScrArea *area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 286afe42158..ae7475c3661 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -577,9 +577,9 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, const int hotspot) { const wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); rcti rect; /* Almost certainly overkill, but allow for many custom gizmos. */ @@ -966,22 +966,22 @@ void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler) bScreen *screen = CTX_wm_screen(C); if (screen) { - ScrArea *sa; + ScrArea *area; - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa == handler->context.area) { + for (area = screen->areabase.first; area; area = area->next) { + if (area == handler->context.area) { break; } } - if (sa == NULL) { + if (area == NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ printf("internal error: modal gizmo-map handler has invalid area\n"); } else { ARegion *region; - CTX_wm_area_set(C, sa); - for (region = sa->regionbase.first; region; region = region->next) { + CTX_wm_area_set(C, area); + for (region = area->regionbase.first; region; region = region->next) { if (region == handler->context.region) { break; } @@ -1373,9 +1373,10 @@ void WM_gizmoconfig_update(struct Main *bmain) if (wm_gzmap_type_update_flag & WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; for (ARegion *region = regionbase->first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap != NULL && gzmap->tag_remove_group) { @@ -1410,9 +1411,9 @@ void WM_gizmoconfig_update(struct Main *bmain) void WM_reinit_gizmomap_all(Main *bmain) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = regionbase->first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if ((gzmap != NULL) && (gzmap->is_init == false)) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 93f3a04978f..61334e4b8d7 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -135,9 +135,9 @@ static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt) { /* Free instances. */ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap) { diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index aa80064fae7..58ca3bf1b95 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -183,13 +183,13 @@ void WM_cursor_set(wmWindow *win, int curs) } } -bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *sa, const ARegion *region) +bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *area, const ARegion *region) { if (region && (region->regiontype != RGN_TYPE_WINDOW)) { return false; } - bToolRef_Runtime *tref_rt = (sa && sa->runtime.tool) ? sa->runtime.tool->runtime : NULL; + bToolRef_Runtime *tref_rt = (area && area->runtime.tool) ? area->runtime.tool->runtime : NULL; if (tref_rt && tref_rt->cursor != WM_CURSOR_DEFAULT) { if (win->modalcursor == 0) { WM_cursor_set(win, tref_rt->cursor); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 6fcd757eba2..44c8e8cd61e 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -222,7 +222,7 @@ static const char *dropbox_active(bContext *C, static const char *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); const char *name; @@ -231,7 +231,7 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *e return name; } - name = dropbox_active(C, &sa->handlers, drag, event); + name = dropbox_active(C, &area->handlers, drag, event); if (name) { return name; } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index b8bee118e3e..bd255458ba8 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -77,7 +77,7 @@ /** \name Draw Paint Cursor * \{ */ -static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *region) +static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); @@ -87,7 +87,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *region) if (region->visible && region == screen->active_region) { for (pc = wm->paintcursors.first; pc; pc = pc->next) { - if ((pc->space_type != SPACE_TYPE_ANY) && (sa->spacetype != pc->space_type)) { + if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) { continue; } @@ -125,7 +125,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *region) * \{ */ static bool wm_draw_region_stereo_set(Main *bmain, - ScrArea *sa, + ScrArea *area, ARegion *region, eStereoViews sview) { @@ -135,10 +135,10 @@ static bool wm_draw_region_stereo_set(Main *bmain, return false; } - switch (sa->spacetype) { + switch (area->spacetype) { case SPACE_IMAGE: { if (region->regiontype == RGN_TYPE_WINDOW) { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; sima->iuser.multiview_eye = sview; return true; } @@ -146,7 +146,7 @@ static bool wm_draw_region_stereo_set(Main *bmain, } case SPACE_VIEW3D: { if (region->regiontype == RGN_TYPE_WINDOW) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; if (v3d->camera && v3d->camera->type == OB_CAMERA) { RegionView3D *rv3d = region->regiondata; RenderEngine *engine = rv3d->render_engine; @@ -167,7 +167,7 @@ static bool wm_draw_region_stereo_set(Main *bmain, } case SPACE_NODE: { if (region->regiontype == RGN_TYPE_WINDOW) { - SpaceNode *snode = sa->spacedata.first; + SpaceNode *snode = area->spacedata.first; if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) { Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ima->eye = sview; @@ -177,7 +177,7 @@ static bool wm_draw_region_stereo_set(Main *bmain, break; } case SPACE_SEQ: { - SpaceSeq *sseq = sa->spacedata.first; + SpaceSeq *sseq = area->spacedata.first; sseq->multiview_eye = sview; if (region->regiontype == RGN_TYPE_PREVIEW) { @@ -192,15 +192,15 @@ static bool wm_draw_region_stereo_set(Main *bmain, return false; } -static void wm_area_mark_invalid_backbuf(ScrArea *sa) +static void wm_area_mark_invalid_backbuf(ScrArea *area) { - if (sa->spacetype == SPACE_VIEW3D) { - ((View3D *)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; + if (area->spacetype == SPACE_VIEW3D) { + ((View3D *)area->spacedata.first)->flag |= V3D_INVALID_BACKBUF; } } static void wm_region_test_gizmo_do_draw(bContext *C, - ScrArea *sa, + ScrArea *area, ARegion *region, bool tag_redraw) { @@ -212,10 +212,10 @@ static void wm_region_test_gizmo_do_draw(bContext *C, for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; gzgroup = gzgroup->next) { if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) { - ScrArea *ctx_sa = CTX_wm_area(C); + ScrArea *ctx_area = CTX_wm_area(C); ARegion *ctx_region = CTX_wm_region(C); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); if (WM_gizmo_group_type_poll(C, gzgroup->type)) { @@ -223,7 +223,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C, } /* Reset. */ - CTX_wm_area_set(C, ctx_sa); + CTX_wm_area_set(C, ctx_area); CTX_wm_region_set(C, ctx_region); } @@ -240,17 +240,17 @@ static void wm_region_test_gizmo_do_draw(bContext *C, static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *depsgraph, - ScrArea *sa, + ScrArea *area, ARegion *region) { /* tag region for redraw from render engine preview running inside of it */ - if (sa->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) { + if (area->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; RenderEngine *engine = rv3d->render_engine; GPUViewport *viewport = WM_draw_region_get_viewport(region); if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) { - View3D *v3d = sa->spacedata.first; + View3D *v3d = area->spacedata.first; rcti border_rect; /* do partial redraw when possible */ @@ -287,9 +287,9 @@ static bool wm_region_use_viewport_by_type(short space_type, short region_type) return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE) && region_type == RGN_TYPE_WINDOW); } -static bool wm_region_use_viewport(ScrArea *sa, ARegion *region) +static bool wm_region_use_viewport(ScrArea *area, ARegion *region) { - return wm_region_use_viewport_by_type(sa->spacetype, region->regiontype); + return wm_region_use_viewport_by_type(area->spacetype, region->regiontype); } /** \} */ @@ -619,12 +619,12 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) bScreen *screen = WM_window_get_active_screen(win); /* Draw screen areas into own frame buffer. */ - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); /* Compute UI layouts for dynamically size regions. */ - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { /* Dynamic region may have been flagged as too small because their size on init is 0. * ARegion.visible is false then, as expected. The layout should still be created then, so * the region size can be updated (it may turn out to be not too small then). */ @@ -640,22 +640,22 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) } } - ED_area_update_region_sizes(wm, win, sa); + ED_area_update_region_sizes(wm, win, area); - if (sa->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { - if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { - WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), sa); + if (area->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { + if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { + WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), area); } - sa->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; + area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; } /* Then do actual drawing of regions. */ - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->visible && region->do_draw) { CTX_wm_region_set(C, region); - bool use_viewport = wm_region_use_viewport(sa, region); + bool use_viewport = wm_region_use_viewport(area, region); - if (stereo && wm_draw_region_stereo_set(bmain, sa, region, STEREO_LEFT_ID)) { + if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) { wm_draw_region_buffer_create(region, true, use_viewport); for (int view = 0; view < 2; view++) { @@ -665,7 +665,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) } else { sview = STEREO_RIGHT_ID; - wm_draw_region_stereo_set(bmain, sa, region, sview); + wm_draw_region_stereo_set(bmain, area, region, sview); } wm_draw_region_bind(region, view); @@ -689,7 +689,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) } } - wm_area_mark_invalid_backbuf(sa); + wm_area_mark_invalid_backbuf(area); CTX_wm_area_set(C, NULL); } @@ -735,9 +735,9 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) #endif /* Blit non-overlapping area regions. */ - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->visible && region->overlap == false) { /* Blit from offscreen buffer. */ wm_draw_region_blit(region, view); @@ -747,15 +747,15 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) /* Draw paint cursors. */ if (wm->paintcursors.first) { - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->visible && region == screen->active_region) { - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); /* make region ready for draw, scissor, pixelspace */ - wm_paintcursor_draw(C, sa, region); + wm_paintcursor_draw(C, area, region); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); @@ -767,9 +767,9 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) } /* Blend in overlapping area regions */ - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->visible && region->overlap) { wm_draw_region_blend(region, 0, true); } @@ -908,13 +908,13 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) } } - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (region = sa->regionbase.first; region; region = region->next) { - wm_region_test_gizmo_do_draw(C, sa, region, true); - wm_region_test_render_do_draw(scene, depsgraph, sa, region); + for (region = area->regionbase.first; region; region = region->next) { + wm_region_test_gizmo_do_draw(C, area, region, true); + wm_region_test_render_do_draw(scene, depsgraph, area, region); #ifdef WITH_XR_OPENXR - wm_region_test_xr_do_draw(wm, sa, region); + wm_region_test_xr_do_draw(wm, area, region); #endif if (region->visible && region->do_draw) { @@ -956,10 +956,10 @@ static void wm_draw_update_clear_window(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = sa->regionbase.first; region; region = region->next) { - wm_region_test_gizmo_do_draw(C, sa, region, false); + for (ARegion *region = area->regionbase.first; region; region = region->next) { + wm_region_test_gizmo_do_draw(C, area, region, false); } } @@ -1037,10 +1037,10 @@ void WM_draw_region_free(ARegion *region) region->visible = 0; } -void wm_draw_region_test(bContext *C, ScrArea *sa, ARegion *region) +void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region) { /* Function for redraw timer benchmark. */ - bool use_viewport = wm_region_use_viewport(sa, region); + bool use_viewport = wm_region_use_viewport(area, region); wm_draw_region_buffer_create(region, false, use_viewport); wm_draw_region_bind(region, 0); ED_region_do_draw(C, region); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8d7155b5ea8..6a9627decb7 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -288,13 +288,13 @@ void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id) bScreen *sc; for (sc = bmain->screens.first; sc; sc = sc->id.next) { - ScrArea *sa; + ScrArea *area; - for (sa = sc->areabase.first; sa; sa = sa->next) { + for (area = sc->areabase.first; area; area = area->next) { SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - ED_spacedata_id_remap(sa, sl, old_id, new_id); + for (sl = area->spacedata.first; sl; sl = sl->next) { + ED_spacedata_id_remap(area, sl, old_id, new_id); } } } @@ -371,13 +371,13 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) /* cached: editor refresh callbacks now, they get context */ for (wmWindow *win = wm->windows.first; win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa; + ScrArea *area; CTX_wm_window_set(C, win); - for (sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->do_refresh) { - CTX_wm_area_set(C, sa); - ED_area_do_refresh(C, sa); + for (area = screen->areabase.first; area; area = area->next) { + if (area->do_refresh) { + CTX_wm_area_set(C, area); + ED_area_do_refresh(C, area); } } } @@ -524,11 +524,11 @@ void wm_event_do_notifiers(bContext *C) ED_region_do_listen(win, NULL, region, note, scene); } - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - ED_area_do_listen(win, sa, note, scene); - for (region = sa->regionbase.first; region; region = region->next) { - ED_region_do_listen(win, sa, region, note, scene); + ED_area_do_listen(win, area, note, scene); + for (region = area->regionbase.first; region; region = region->next) { + ED_region_do_listen(win, area, region, note, scene); } } } @@ -822,11 +822,11 @@ bool WM_operator_check_ui_empty(wmOperatorType *ot) */ void WM_operator_region_active_win_set(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - if (sa) { + ScrArea *area = CTX_wm_area(C); + if (area) { ARegion *region = CTX_wm_region(C); if (region && region->regiontype == RGN_TYPE_WINDOW) { - sa->region_active_win = BLI_findindex(&sa->regionbase, region); + area->region_active_win = BLI_findindex(&area->regionbase, region); } } } @@ -948,9 +948,9 @@ static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat, if (hud_status != NOP) { if (hud_status == SET) { - ScrArea *sa = CTX_wm_area(C); - if (sa) { - ED_area_type_hud_ensure(C, sa); + ScrArea *area = CTX_wm_area(C); + if (area) { + ED_area_type_hud_ensure(C, area); } } else if (hud_status == CLEAR) { @@ -1335,7 +1335,7 @@ static int wm_operator_invoke(bContext *C, if (wrap) { const rcti *winrect = NULL; ARegion *region = CTX_wm_region(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); /* Wrap only in X for header. */ if (region && @@ -1347,8 +1347,8 @@ static int wm_operator_invoke(bContext *C, BLI_rcti_isect_pt_v(®ion->winrct, &event->x)) { winrect = ®ion->winrct; } - else if (sa && BLI_rcti_isect_pt_v(&sa->totrct, &event->x)) { - winrect = &sa->totrct; + else if (area && BLI_rcti_isect_pt_v(&area->totrct, &event->x)) { + winrect = &area->totrct; } if (winrect) { @@ -1653,17 +1653,17 @@ static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const CTX_wm_area_set(C, NULL); } else { - ScrArea *sa = NULL; + ScrArea *area = NULL; - ED_screen_areas_iter(win, screen, sa_iter) + ED_screen_areas_iter(win, screen, area_iter) { - if (sa_iter == handler->context.area) { - sa = sa_iter; + if (area_iter == handler->context.area) { + area = area_iter; break; } } - if (sa == NULL) { + if (area == NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ if (handler->op == NULL) { @@ -1675,10 +1675,10 @@ static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const else { ARegion *region; wmOperator *op = handler->op ? (handler->op->opm ? handler->op->opm : handler->op) : NULL; - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); if (op && (op->flag & OP_IS_MODAL_CURSOR_REGION)) { - region = BKE_area_find_region_xy(sa, handler->context.region_type, event->x, event->y); + region = BKE_area_find_region_xy(area, handler->context.region_type, event->x, event->y); if (region) { handler->context.region = region; } @@ -1688,7 +1688,7 @@ static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const } if (region == NULL) { - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (region == handler->context.region) { break; } @@ -2216,19 +2216,19 @@ static int wm_handler_fileselect_do(bContext *C, } else { wmWindow *temp_win; - ScrArea *ctx_sa = CTX_wm_area(C); + ScrArea *ctx_area = CTX_wm_area(C); for (temp_win = wm->windows.first; temp_win; temp_win = temp_win->next) { bScreen *screen = WM_window_get_active_screen(temp_win); - ScrArea *file_sa = screen->areabase.first; + ScrArea *file_area = screen->areabase.first; - if (screen->temp && (file_sa->spacetype == SPACE_FILE)) { + if (screen->temp && (file_area->spacetype == SPACE_FILE)) { int win_size[2]; bool is_maximized; ED_fileselect_window_params_get(temp_win, win_size, &is_maximized); - ED_fileselect_params_to_userdef(file_sa->spacedata.first, win_size, is_maximized); + ED_fileselect_params_to_userdef(file_area->spacedata.first, win_size, is_maximized); - if (BLI_listbase_is_single(&file_sa->spacedata)) { + if (BLI_listbase_is_single(&file_area->spacedata)) { BLI_assert(ctx_win != temp_win); wm_window_close(C, wm, temp_win); @@ -2244,20 +2244,20 @@ static int wm_handler_fileselect_do(bContext *C, handler->context.win = NULL; } } - else if (file_sa->full) { - ED_screen_full_prevspace(C, file_sa); + else if (file_area->full) { + ED_screen_full_prevspace(C, file_area); } else { - ED_area_prevspace(C, file_sa); + ED_area_prevspace(C, file_area); } break; } } - if (!temp_win && ctx_sa->full) { - ED_fileselect_params_to_userdef(ctx_sa->spacedata.first, NULL, false); - ED_screen_full_prevspace(C, ctx_sa); + if (!temp_win && ctx_area->full) { + ED_fileselect_params_to_userdef(ctx_area->spacedata.first, NULL, false); + ED_screen_full_prevspace(C, ctx_area); } } @@ -2988,10 +2988,10 @@ static ScrArea *area_event_inside(bContext *C, const int xy[2]) bScreen *screen = CTX_wm_screen(C); if (screen) { - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - if (BLI_rcti_isect_pt_v(&sa->totrct, xy)) { - return sa; + if (BLI_rcti_isect_pt_v(&area->totrct, xy)) { + return area; } } } @@ -3041,14 +3041,14 @@ static void wm_paintcursor_test(bContext *C, const wmEvent *event) /* if previous position was not in current region, we have to set a temp new context */ if (region == NULL || !BLI_rcti_isect_pt_v(®ion->winrct, &event->prevx)) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); CTX_wm_area_set(C, area_event_inside(C, &event->prevx)); CTX_wm_region_set(C, region_event_inside(C, &event->prevx)); wm_paintcursor_tag(C, wm->paintcursors.first, CTX_wm_region(C)); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); } } @@ -3266,7 +3266,7 @@ void wm_event_do_handlers(bContext *C) } #endif - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { /* after restoring a screen from SCREENMAXIMIZED we have to wait * with the screen handling till the region coordinates are updated */ @@ -3277,15 +3277,15 @@ void wm_event_do_handlers(bContext *C) } /* update azones if needed - done here because it needs to be independent from redraws */ - if (sa->flag & AREA_FLAG_ACTIONZONES_UPDATE) { - ED_area_azones_update(sa, &event->x); + if (area->flag & AREA_FLAG_ACTIONZONES_UPDATE) { + ED_area_azones_update(area, &event->x); } - if (wm_event_inside_rect(event, &sa->totrct)) { - CTX_wm_area_set(C, sa); + if (wm_event_inside_rect(event, &area->totrct)) { + CTX_wm_area_set(C, area); if ((action & WM_HANDLER_BREAK) == 0) { - for (region = sa->regionbase.first; region; region = region->next) { + for (region = area->regionbase.first; region; region = region->next) { if (wm_event_inside_region(event, region)) { CTX_wm_region_set(C, region); @@ -3319,7 +3319,7 @@ void wm_event_do_handlers(bContext *C) if ((action & WM_HANDLER_BREAK) == 0) { wm_region_mouse_co(C, event); /* only invalidates event->mval in this case */ - action |= wm_handlers_do(C, event, &sa->handlers); + action |= wm_handlers_do(C, event, &area->handlers); } CTX_wm_area_set(C, NULL); @@ -3437,13 +3437,13 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) bool cancel_handler = true; /* find the area with the file selector for this handler */ - ED_screen_areas_iter(win, screen, sa) + ED_screen_areas_iter(win, screen, area) { - if (sa->spacetype == SPACE_FILE) { - SpaceFile *sfile = sa->spacedata.first; + if (area->spacetype == SPACE_FILE) { + SpaceFile *sfile = area->spacedata.first; if (sfile->op == handler->op) { - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL); cancel_handler = false; break; @@ -3604,9 +3604,9 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, wmEventHandler_Keymap *handler) { - ScrArea *sa = handler->dynamic.user_data; + ScrArea *area = handler->dynamic.user_data; handler->keymap_tool = NULL; - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; + bToolRef_Runtime *tref_rt = area->runtime.tool ? area->runtime.tool->runtime : NULL; if (tref_rt && tref_rt->keymap_fallback[0]) { const char *keymap_id = NULL; @@ -3614,7 +3614,7 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, if (tref_rt->gizmo_group[0] != '\0' && tref_rt->keymap_fallback[0] != '\n') { wmGizmoMap *gzmap = NULL; wmGizmoGroup *gzgroup = NULL; - for (ARegion *region = sa->regionbase.first; region; region = region->next) { + for (ARegion *region = area->regionbase.first; region; region = region->next) { if (region->gizmo_map != NULL) { gzmap = region->gizmo_map; gzgroup = WM_gizmomap_group_find(gzmap, tref_rt->gizmo_group); @@ -3638,15 +3638,15 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, if (keymap_id && keymap_id[0]) { wmKeyMap *km = WM_keymap_list_find_spaceid_or_empty( - &wm->userconf->keymaps, keymap_id, sa->spacetype, RGN_TYPE_WINDOW); + &wm->userconf->keymaps, keymap_id, area->spacetype, RGN_TYPE_WINDOW); /* We shouldn't use keymaps from unrelated spaces. */ if (km != NULL) { - handler->keymap_tool = sa->runtime.tool; + handler->keymap_tool = area->runtime.tool; return km; } else { printf( - "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, sa->runtime.tool->idname); + "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); } } } @@ -3655,22 +3655,22 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, wmKeyMap *WM_event_get_keymap_from_toolsystem(wmWindowManager *wm, wmEventHandler_Keymap *handler) { - ScrArea *sa = handler->dynamic.user_data; + ScrArea *area = handler->dynamic.user_data; handler->keymap_tool = NULL; - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; + bToolRef_Runtime *tref_rt = area->runtime.tool ? area->runtime.tool->runtime : NULL; if (tref_rt && tref_rt->keymap[0]) { const char *keymap_id = tref_rt->keymap; { wmKeyMap *km = WM_keymap_list_find_spaceid_or_empty( - &wm->userconf->keymaps, keymap_id, sa->spacetype, RGN_TYPE_WINDOW); + &wm->userconf->keymaps, keymap_id, area->spacetype, RGN_TYPE_WINDOW); /* We shouldn't use keymaps from unrelated spaces. */ if (km != NULL) { - handler->keymap_tool = sa->runtime.tool; + handler->keymap_tool = area->runtime.tool; return km; } else { printf( - "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, sa->runtime.tool->idname); + "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname); } } } @@ -4880,30 +4880,30 @@ ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) if (screen->state == SCREENFULL) { return NULL; } - ScrArea *sa_statusbar = NULL; - for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { - if (sa->spacetype == SPACE_STATUSBAR) { - sa_statusbar = sa; + ScrArea *area_statusbar = NULL; + for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + if (area->spacetype == SPACE_STATUSBAR) { + area_statusbar = area; break; } } - return sa_statusbar; + return area_statusbar; } void WM_window_status_area_tag_redraw(wmWindow *win) { bScreen *sc = WM_window_get_active_screen(win); - ScrArea *sa = WM_window_status_area_find(win, sc); - if (sa != NULL) { - ED_area_tag_redraw(sa); + ScrArea *area = WM_window_status_area_find(win, sc); + if (area != NULL) { + ED_area_tag_redraw(area); } } void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa_statusbar = WM_window_status_area_find(win, screen); - if (sa_statusbar == NULL) { + ScrArea *area_statusbar = WM_window_status_area_find(win, screen); + if (area_statusbar == NULL) { MEM_SAFE_FREE(win->cursor_keymap_status); return; } @@ -4930,20 +4930,20 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) return; } - ScrArea *sa = NULL; - ED_screen_areas_iter(win, screen, sa_iter) + ScrArea *area = NULL; + ED_screen_areas_iter(win, screen, area_iter) { - if (BLI_findindex(&sa_iter->regionbase, region) != -1) { - sa = sa_iter; + if (BLI_findindex(&area_iter->regionbase, region) != -1) { + area = area_iter; break; } } - if (sa == NULL) { + if (area == NULL) { return; } /* Keep as-is. */ - if (ELEM(sa->spacetype, SPACE_STATUSBAR, SPACE_TOPBAR)) { + if (ELEM(area->spacetype, SPACE_STATUSBAR, SPACE_TOPBAR)) { return; } if (ELEM(region->regiontype, @@ -4956,23 +4956,23 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } /* Fallback to window. */ if (ELEM(region->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); } /* Detect changes to the state. */ { bToolRef *tref = NULL; if ((region->regiontype == RGN_TYPE_WINDOW) && - ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK)) { + ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK)) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); WorkSpace *workspace = WM_window_get_active_workspace(win); const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; tref = WM_toolsystem_ref_find(workspace, &tkey); } - wm_event_cursor_store(&cd->state, win->eventstate, sa->spacetype, region->regiontype, tref); + wm_event_cursor_store(&cd->state, win->eventstate, area->spacetype, region->regiontype, tref); if (memcmp(&cd->state, &cd_prev.state, sizeof(cd->state)) == 0) { return; } @@ -5004,12 +5004,12 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } CTX_wm_window_set(C, win); - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); ListBase *handlers[] = { ®ion->handlers, - &sa->handlers, + &area->handlers, &win->handlers, }; @@ -5039,7 +5039,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) { - ED_area_tag_redraw(sa_statusbar); + ED_area_tag_redraw(area_statusbar); } CTX_wm_window_set(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index fa59bad7a6b..3c8b6b1c9d4 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1219,7 +1219,7 @@ static ImBuf *blend_file_thumb(const bContext *C, char err_out[256] = "unknown"; /* screen if no camera found */ - ScrArea *sa = NULL; + ScrArea *area = NULL; ARegion *region = NULL; View3D *v3d = NULL; @@ -1235,10 +1235,10 @@ static ImBuf *blend_file_thumb(const bContext *C, } if ((scene->camera == NULL) && (screen != NULL)) { - sa = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0); - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { - v3d = sa->spacedata.first; + v3d = area->spacedata.first; } } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 890aeb71e1a..97a73d9dbfa 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1449,7 +1449,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, wmKeyMap **r_keymap) { wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); wmKeyMapItem *found = NULL; @@ -1463,16 +1463,16 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, } } - if (sa && found == NULL) { + if (area && found == NULL) { found = wm_keymap_item_find_handlers( - C, &sa->handlers, opname, opcontext, properties, is_strict, params, r_keymap); + C, &area->handlers, opname, opcontext, properties, is_strict, params, r_keymap); } if (found == NULL) { if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { - if (sa) { + if (area) { if (!(region && region->regiontype == RGN_TYPE_WINDOW)) { - region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); } if (region) { @@ -1483,7 +1483,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, } else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { if (!(region && region->regiontype == RGN_TYPE_CHANNELS)) { - region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS); } if (region) { @@ -1493,7 +1493,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, } else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { if (!(region && region->regiontype == RGN_TYPE_PREVIEW)) { - region = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW); } if (region) { diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c index 4a786329e1a..81b597f7484 100644 --- a/source/blender/windowmanager/intern/wm_operator_utils.c +++ b/source/blender/windowmanager/intern/wm_operator_utils.c @@ -62,7 +62,7 @@ typedef struct ValueInteraction { float range[2]; struct { - ScrArea *sa; + ScrArea *area; ARegion *region; } context_vars; } ValueInteraction; @@ -74,7 +74,7 @@ static void interactive_value_init(bContext *C, const float range[2]) { - inter->context_vars.sa = CTX_wm_area(C); + inter->context_vars.area = CTX_wm_area(C); inter->context_vars.region = CTX_wm_region(C); inter->init.mval[0] = event->mval[0]; @@ -97,7 +97,7 @@ static void interactive_value_init_from_property( static void interactive_value_exit(ValueInteraction *inter) { - ED_area_status_text(inter->context_vars.sa, NULL); + ED_area_status_text(inter->context_vars.area, NULL); } static bool interactive_value_update(ValueInteraction *inter, @@ -128,7 +128,7 @@ static bool interactive_value_update(ValueInteraction *inter, /* set the property for the operator and call its modal function */ char str[64]; SNPRINTF(str, "%.4f", value_final); - ED_area_status_text(inter->context_vars.sa, str); + ED_area_status_text(inter->context_vars.area, str); } inter->prev.prop_value = value_final; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4a4e373d15e..9a376390096 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1767,13 +1767,13 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve /* Exception for launching via spacebar */ if (event->type == EVT_SPACEKEY) { bool ok = true; - ScrArea *sa = CTX_wm_area(C); - if (sa) { - if (sa->spacetype == SPACE_CONSOLE) { + ScrArea *area = CTX_wm_area(C); + if (area) { + if (area->spacetype == SPACE_CONSOLE) { /* So we can use the shortcut in the console. */ ok = false; } - else if (sa->spacetype == SPACE_TEXT) { + else if (area->spacetype == SPACE_TEXT) { /* So we can use the spacebar in the text editor. */ ok = false; } @@ -2135,7 +2135,7 @@ static void radial_control_update_header(wmOperator *op, bContext *C) { RadialControl *rc = op->customdata; char msg[UI_MAX_DRAW_STR]; - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); if (hasNumInput(&rc->num_input)) { @@ -2172,7 +2172,7 @@ static void radial_control_update_header(wmOperator *op, bContext *C) } } - ED_area_status_text(sa, msg); + ED_area_status_text(area, msg); } static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *event) @@ -2788,14 +2788,14 @@ static void radial_control_cancel(bContext *C, wmOperator *op) { RadialControl *rc = op->customdata; wmWindowManager *wm = CTX_wm_manager(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); if (rc->dial) { MEM_freeN(rc->dial); rc->dial = NULL; } - ED_area_status_text(sa, NULL); + ED_area_status_text(area, NULL); WM_paint_cursor_end(wm, rc->cursor); @@ -3139,11 +3139,11 @@ static void WM_OT_radial_control(wmOperatorType *ot) static void redraw_timer_window_swap(bContext *C) { wmWindow *win = CTX_wm_window(C); - ScrArea *sa; + ScrArea *area; CTX_wm_menu_set(C, NULL); - for (sa = CTX_wm_screen(C)->areabase.first; sa; sa = sa->next) { - ED_area_tag_redraw(sa); + for (area = CTX_wm_screen(C)->areabase.first; area; area = area->next) { + ED_area_tag_redraw(area); } wm_draw_update(C); @@ -3176,14 +3176,14 @@ static void redraw_timer_step(bContext *C, Scene *scene, struct Depsgraph *depsgraph, wmWindow *win, - ScrArea *sa, + ScrArea *area, ARegion *region, const int type, const int cfra) { if (type == eRTDrawRegion) { if (region) { - wm_draw_region_test(C, sa, region); + wm_draw_region_test(C, area, region); } } else if (type == eRTDrawRegionSwap) { @@ -3196,25 +3196,26 @@ static void redraw_timer_step(bContext *C, } else if (type == eRTDrawWindow) { bScreen *screen = WM_window_get_active_screen(win); - ScrArea *sa_iter; + ScrArea *area_iter; CTX_wm_menu_set(C, NULL); - for (sa_iter = screen->areabase.first; sa_iter; sa_iter = sa_iter->next) { + for (area_iter = screen->areabase.first; area_iter; area_iter = area_iter->next) { ARegion *region_iter; - CTX_wm_area_set(C, sa_iter); + CTX_wm_area_set(C, area_iter); - for (region_iter = sa_iter->regionbase.first; region_iter; region_iter = region_iter->next) { + for (region_iter = area_iter->regionbase.first; region_iter; + region_iter = region_iter->next) { if (region_iter->visible) { CTX_wm_region_set(C, region_iter); - wm_draw_region_test(C, sa_iter, region_iter); + wm_draw_region_test(C, area_iter, region_iter); } } } CTX_wm_window_set(C, win); /* XXX context manipulation warning! */ - CTX_wm_area_set(C, sa); + CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); } else if (type == eRTDrawWindowSwap) { @@ -3250,7 +3251,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindow *win = CTX_wm_window(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); wmWindowManager *wm = CTX_wm_manager(C); double time_start, time_delta; @@ -3272,7 +3273,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) wm_window_make_drawable(wm, win); for (a = 0; a < iter; a++) { - redraw_timer_step(C, bmain, scene, depsgraph, win, sa, region, type, cfra); + redraw_timer_step(C, bmain, scene, depsgraph, win, area, region, type, cfra); iter_steps += 1; if (time_limit != 0.0) { diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 1abef2ec173..f1928819c26 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -72,18 +72,18 @@ struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) { WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); - ScrArea *sa = CTX_wm_area(C); - if ((sa == NULL) || ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { + ScrArea *area = CTX_wm_area(C); + if ((area == NULL) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { return NULL; } const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); - /* We could return 'sa->runtime.tool' in this case. */ - if (sa->runtime.is_tool_set) { - BLI_assert(tref == sa->runtime.tool); + /* We could return 'area->runtime.tool' in this case. */ + if (area->runtime.is_tool_set) { + BLI_assert(tref == area->runtime.tool); } return tref; } @@ -279,15 +279,15 @@ void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { continue; } WorkSpace *workspace = WM_window_get_active_workspace(win); const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref) { @@ -450,12 +450,12 @@ static bool toolsystem_key_ensure_check(const bToolKey *tkey) return false; } -int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *sa, int spacetype) +int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *area, int spacetype) { int mode = -1; switch (spacetype) { case SPACE_VIEW3D: { - /* 'sa' may be NULL in this case. */ + /* 'area' may be NULL in this case. */ Object *obact = OBACT(view_layer); if (obact != NULL) { Object *obedit = OBEDIT_FROM_OBACT(obact); @@ -467,7 +467,7 @@ int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *sa, int sp break; } case SPACE_IMAGE: { - SpaceImage *sima = sa->spacedata.first; + SpaceImage *sima = area->spacedata.first; mode = sima->mode; break; } @@ -476,7 +476,7 @@ int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *sa, int sp break; } case SPACE_SEQ: { - SpaceSeq *sseq = sa->spacedata.first; + SpaceSeq *sseq = area->spacedata.first; mode = sseq->view; break; } @@ -484,14 +484,14 @@ int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *sa, int sp return mode; } -bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *sa, bToolKey *tkey) +bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *area, bToolKey *tkey) { int space_type = SPACE_EMPTY; int mode = -1; - if (sa != NULL) { - space_type = sa->spacetype; - mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, space_type); + if (area != NULL) { + space_type = area->spacetype; + mode = WM_toolsystem_mode_from_spacetype(view_layer, area, space_type); } if (mode != -1) { @@ -520,18 +520,18 @@ void WM_toolsystem_refresh_active(bContext *C) ViewLayer *view_layer = WM_window_get_active_view_layer(win); /* Could skip loop for modes that don't depend on space type. */ int space_type_mask_handled = 0; - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { /* Don't change the space type of the active tool, only update it's mode. */ - const int space_type_mask = (1 << sa->spacetype); + const int space_type_mask = (1 << area->spacetype); if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) && ((space_type_mask_handled & space_type_mask) == 0)) { space_type_mask_handled |= space_type_mask; const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); - if (tref != sa->runtime.tool) { + if (tref != area->runtime.tool) { toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); } } @@ -554,15 +554,15 @@ void WM_toolsystem_refresh_active(bContext *C) } } -void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *sa) +void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *area) { - sa->runtime.tool = NULL; - sa->runtime.is_tool_set = true; - const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype); + area->runtime.tool = NULL; + area->runtime.is_tool_set = true; + const int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { - if (tref->space_type == sa->spacetype) { + if (tref->space_type == area->spacetype) { if (tref->mode == mode) { - sa->runtime.tool = tref; + area->runtime.tool = tref; break; } } @@ -581,11 +581,11 @@ void WM_toolsystem_refresh_screen_all(Main *bmain) } bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - sa->runtime.tool = NULL; - sa->runtime.is_tool_set = true; - if (space_type_has_tools[sa->spacetype]) { - WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + area->runtime.tool = NULL; + area->runtime.is_tool_set = true; + if (space_type_has_tools[area->spacetype]) { + WM_toolsystem_refresh_screen_area(workspace, view_layer, area); } } } @@ -602,12 +602,12 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain, if (workspace == WM_window_get_active_workspace(win)) { bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - if (sa->spacetype == tref->space_type) { - int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->spacetype == tref->space_type) { + int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); if (mode == tref->mode) { - sa->runtime.tool = tref; - sa->runtime.is_tool_set = true; + area->runtime.tool = tref; + area->runtime.is_tool_set = true; } } } @@ -649,9 +649,9 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex( bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name) { ViewLayer *view_layer = CTX_data_view_layer(C); - ScrArea *sa = CTX_wm_area(C); + ScrArea *area = CTX_wm_area(C); bToolKey tkey; - if (WM_toolsystem_key_from_context(view_layer, sa, &tkey)) { + if (WM_toolsystem_key_from_context(view_layer, area, &tkey)) { WorkSpace *workspace = CTX_wm_workspace(C); return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false); } @@ -782,11 +782,11 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) void WM_toolsystem_update_from_context(bContext *C, WorkSpace *workspace, ViewLayer *view_layer, - ScrArea *sa) + ScrArea *area) { const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; if (toolsystem_key_ensure_check(&tkey)) { toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); @@ -807,13 +807,13 @@ void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C, wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { - ScrArea *sa = msg_val->user_data; + ScrArea *area = msg_val->user_data; Main *bmain = CTX_data_main(C); wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first; if (win->next != NULL) { do { bScreen *screen = WM_window_get_active_screen(win); - if (BLI_findindex(&screen->areabase, sa) != -1) { + if (BLI_findindex(&screen->areabase, area) != -1) { break; } } while ((win = win->next)); @@ -823,11 +823,11 @@ void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C, ViewLayer *view_layer = WM_window_get_active_view_layer(win); const bToolKey tkey = { - .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + .space_type = area->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), }; WM_toolsystem_refresh(C, workspace, &tkey); - WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); + WM_toolsystem_refresh_screen_area(workspace, view_layer, area); } IDProperty *WM_toolsystem_ref_properties_ensure_idprops(bToolRef *tref) diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index 4d64acefca4..a9f0e01cfb5 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -43,7 +43,7 @@ double WM_tooltip_time_closed(void) } void WM_tooltip_immediate_init( - bContext *C, wmWindow *win, ScrArea *sa, ARegion *region, wmTooltipInitFn init) + bContext *C, wmWindow *win, ScrArea *area, ARegion *region, wmTooltipInitFn init) { WM_tooltip_timer_clear(C, win); @@ -51,14 +51,14 @@ void WM_tooltip_immediate_init( if (screen->tool_tip == NULL) { screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); } - screen->tool_tip->area_from = sa; + screen->tool_tip->area_from = area; screen->tool_tip->region_from = region; screen->tool_tip->init = init; WM_tooltip_init(C, win); } void WM_tooltip_timer_init_ex( - bContext *C, wmWindow *win, ScrArea *sa, ARegion *region, wmTooltipInitFn init, double delay) + bContext *C, wmWindow *win, ScrArea *area, ARegion *region, wmTooltipInitFn init, double delay) { WM_tooltip_timer_clear(C, win); @@ -67,16 +67,16 @@ void WM_tooltip_timer_init_ex( if (screen->tool_tip == NULL) { screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__); } - screen->tool_tip->area_from = sa; + screen->tool_tip->area_from = area; screen->tool_tip->region_from = region; screen->tool_tip->timer = WM_event_add_timer(wm, win, TIMER, delay); screen->tool_tip->init = init; } void WM_tooltip_timer_init( - bContext *C, wmWindow *win, ScrArea *sa, ARegion *region, wmTooltipInitFn init) + bContext *C, wmWindow *win, ScrArea *area, ARegion *region, wmTooltipInitFn init) { - WM_tooltip_timer_init_ex(C, win, sa, region, init, UI_TOOLTIP_DELAY); + WM_tooltip_timer_init_ex(C, win, area, region, init, UI_TOOLTIP_DELAY); } void WM_tooltip_timer_clear(bContext *C, wmWindow *win) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index c29fd24d4cd..694b3176f50 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -854,7 +854,7 @@ wmWindow *WM_window_open_temp(bContext *C, wmWindow *win_prev = CTX_wm_window(C); wmWindow *win; bScreen *screen; - ScrArea *sa; + ScrArea *area; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -932,10 +932,10 @@ wmWindow *WM_window_open_temp(bContext *C, */ /* ensure it shows the right spacetype editor */ - sa = screen->areabase.first; - CTX_wm_area_set(C, sa); + area = screen->areabase.first; + CTX_wm_area_set(C, area); - ED_area_newspace(C, sa, space_type, false); + ED_area_newspace(C, area, space_type, false); ED_screen_change(C, screen); ED_screen_refresh(wm, win); /* test scale */ diff --git a/source/blender/windowmanager/wm_draw.h b/source/blender/windowmanager/wm_draw.h index b19fdf97569..ff2fc25333a 100644 --- a/source/blender/windowmanager/wm_draw.h +++ b/source/blender/windowmanager/wm_draw.h @@ -46,7 +46,7 @@ struct wmWindow; void wm_draw_update(struct bContext *C); void wm_draw_region_clear(struct wmWindow *win, struct ARegion *region); void wm_draw_region_blend(struct ARegion *region, int view, bool blend); -void wm_draw_region_test(struct bContext *C, struct ScrArea *sa, struct ARegion *region); +void wm_draw_region_test(struct bContext *C, struct ScrArea *area, struct ARegion *region); struct GPUTexture *wm_draw_region_texture(struct ARegion *region, int view); -- cgit v1.2.3 From cff49e625f0379d8449d20147a645f90ef2d321a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Apr 2020 13:28:51 +0200 Subject: Cleanup: add missing #includes to some headers It should be possible to `#include` any header without having to worry about its dependencies. I didn't go and check all include files for this, just the ones that caused me errors while I was refactoring the `anim_sys.c` file. No functional changes. --- source/blender/blenkernel/BKE_animsys.h | 2 ++ source/blender/blenlib/BLI_compiler_typecheck.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 9da17d777cd..3debe94c264 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -28,6 +28,8 @@ extern "C" { #endif +#include "BLI_sys_types.h" /* for bool */ + struct AnimData; struct Depsgraph; struct FCurve; diff --git a/source/blender/blenlib/BLI_compiler_typecheck.h b/source/blender/blenlib/BLI_compiler_typecheck.h index 958ffeb0748..0a2eddc4ecc 100644 --- a/source/blender/blenlib/BLI_compiler_typecheck.h +++ b/source/blender/blenlib/BLI_compiler_typecheck.h @@ -24,6 +24,8 @@ * These depend on compiler extensions and c11 in some cases. */ +#include "BLI_utildefines_variadic.h" + /* Causes warning: * incompatible types when assigning to type 'Foo' from type 'Bar' * ... the compiler optimizes away the temp var */ -- cgit v1.2.3 From ad85989a3f8825eba990b73ce0ee59d71d9b585c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 3 Apr 2020 14:23:21 +0200 Subject: Cleanup: Rename bScreen variables from sc/scr to screen Part of T74432. Mostly a careful batch rename but had to do few smaller fixes. Also ran clang-format on affected files. --- source/blender/blenkernel/BKE_screen.h | 34 ++-- source/blender/blenkernel/intern/context.c | 12 +- source/blender/blenkernel/intern/screen.c | 74 ++++---- source/blender/blenloader/intern/readfile.c | 30 ++-- source/blender/blenloader/intern/versioning_250.c | 38 ++-- source/blender/blenloader/intern/versioning_260.c | 60 +++---- source/blender/blenloader/intern/versioning_270.c | 18 +- source/blender/blenloader/intern/versioning_280.c | 14 +- .../blender/blenloader/intern/versioning_legacy.c | 92 +++++----- source/blender/blenloader/intern/writefile.c | 12 +- source/blender/editors/animation/anim_markers.c | 8 +- source/blender/editors/gpencil/annotate_paint.c | 4 +- source/blender/editors/gpencil/gpencil_paint.c | 4 +- source/blender/editors/include/ED_render.h | 2 +- source/blender/editors/include/ED_screen.h | 2 +- source/blender/editors/include/UI_interface.h | 2 +- .../editors/interface/interface_context_menu.c | 4 +- .../blender/editors/interface/interface_handlers.c | 28 +-- source/blender/editors/interface/interface_ops.c | 5 +- .../editors/interface/interface_region_popup.c | 14 +- .../editors/interface/interface_region_tooltip.c | 4 +- .../blender/editors/interface/interface_regions.c | 10 +- .../editors/interface/interface_regions_intern.h | 4 +- source/blender/editors/interface/view2d_ops.c | 6 +- source/blender/editors/object/object_bake_api.c | 4 +- source/blender/editors/render/render_update.c | 14 +- source/blender/editors/render/render_view.c | 12 +- source/blender/editors/screen/area.c | 4 +- source/blender/editors/screen/screen_context.c | 8 +- source/blender/editors/screen/screen_edit.c | 196 ++++++++++----------- source/blender/editors/screen/screen_geometry.c | 32 ++-- source/blender/editors/screen/screen_intern.h | 12 +- source/blender/editors/screen/screen_ops.c | 106 +++++------ source/blender/editors/sculpt_paint/paint_image.c | 6 +- source/blender/editors/space_graph/graph_buttons.c | 8 +- source/blender/editors/space_node/node_edit.c | 4 +- .../editors/space_sequencer/sequencer_edit.c | 4 +- source/blender/editors/space_view3d/view3d_utils.c | 4 +- source/blender/editors/space_view3d/view3d_view.c | 12 +- source/blender/makesrna/intern/rna_material.c | 8 +- source/blender/makesrna/intern/rna_object_api.c | 10 +- source/blender/makesrna/intern/rna_scene.c | 4 +- source/blender/makesrna/intern/rna_scene_api.c | 4 +- source/blender/makesrna/intern/rna_screen.c | 8 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 6 +- source/blender/makesrna/intern/rna_space.c | 32 ++-- source/blender/makesrna/intern/rna_space_api.c | 10 +- source/blender/windowmanager/WM_api.h | 2 +- .../windowmanager/gizmo/intern/wm_gizmo_group.c | 12 +- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 4 +- .../blender/windowmanager/intern/wm_event_system.c | 10 +- 51 files changed, 514 insertions(+), 503 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index ca25d7f8d95..a3ff5c53828 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -155,7 +155,7 @@ typedef struct ARegionType { void (*message_subscribe)(const struct bContext *C, struct WorkSpace *workspace, struct Scene *scene, - struct bScreen *sc, + struct bScreen *screen, struct ScrArea *area, struct ARegion *region, struct wmMsgBus *mbus); @@ -357,23 +357,27 @@ void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizm struct ARegion *BKE_area_find_region_type(const struct ScrArea *area, int type); struct ARegion *BKE_area_find_region_active_win(struct ScrArea *area); struct ARegion *BKE_area_find_region_xy(struct ScrArea *area, const int regiontype, int x, int y); -struct ARegion *BKE_screen_find_region_xy(struct bScreen *sc, const int regiontype, int x, int y) - ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +struct ARegion *BKE_screen_find_region_xy(struct bScreen *screen, + const int regiontype, + int x, + int y) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, +struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *screen, struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); -struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min); +struct ScrArea *BKE_screen_find_big_area(struct bScreen *screen, + const int spacetype, + const short min); struct ScrArea *BKE_screen_area_map_find_area_xy(const struct ScrAreaMap *areamap, const int spacetype, int x, int y); -struct ScrArea *BKE_screen_find_area_xy(struct bScreen *sc, const int spacetype, int x, int y); +struct ScrArea *BKE_screen_find_area_xy(struct bScreen *screen, const int spacetype, int x, int y); -void BKE_screen_gizmo_tag_refresh(struct bScreen *sc); +void BKE_screen_gizmo_tag_refresh(struct bScreen *screen); void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); -void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene); +void BKE_screen_view3d_scene_sync(struct bScreen *screen, struct Scene *scene); bool BKE_screen_is_fullscreen_area(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); @@ -385,15 +389,17 @@ float BKE_screen_view3d_zoom_from_fac(float zoomfac); void BKE_screen_view3d_shading_init(struct View3DShading *shading); /* screen */ -void BKE_screen_free(struct bScreen *sc); +void BKE_screen_free(struct bScreen *screen); void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL(); -struct ScrEdge *BKE_screen_find_edge(struct bScreen *sc, struct ScrVert *v1, struct ScrVert *v2); +struct ScrEdge *BKE_screen_find_edge(struct bScreen *screen, + struct ScrVert *v1, + struct ScrVert *v2); void BKE_screen_sort_scrvert(struct ScrVert **v1, struct ScrVert **v2); -void BKE_screen_remove_double_scrverts(struct bScreen *sc); -void BKE_screen_remove_double_scredges(struct bScreen *sc); -void BKE_screen_remove_unused_scredges(struct bScreen *sc); -void BKE_screen_remove_unused_scrverts(struct bScreen *sc); +void BKE_screen_remove_double_scrverts(struct bScreen *screen); +void BKE_screen_remove_double_scredges(struct bScreen *screen); +void BKE_screen_remove_unused_scredges(struct bScreen *screen); +void BKE_screen_remove_unused_scrverts(struct bScreen *screen); void BKE_screen_header_alignment_reset(struct bScreen *screen); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 6beb95ca0b0..8de12139306 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -278,7 +278,7 @@ static void *ctx_wm_python_context_get(const bContext *C, static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) { - bScreen *sc; + bScreen *screen; ScrArea *area; ARegion *region; int done = 0, recursion = C->data.recursion; @@ -336,8 +336,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res } } } - if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) { - bContextDataCallback cb = sc->context; + if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) { + bContextDataCallback cb = screen->context; C->data.recursion = 4; if (cb) { ret = cb(C, member, result); @@ -543,7 +543,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C, { bContextDataResult result; ListBase lb; - bScreen *sc; + bScreen *screen; ScrArea *area; ARegion *region; int a; @@ -598,8 +598,8 @@ ListBase CTX_data_dir_get_ex(const bContext *C, } } } - if ((sc = CTX_wm_screen(C)) && sc->context) { - bContextDataCallback cb = sc->context; + if ((screen = CTX_wm_screen(C)) && screen->context) { + bContextDataCallback cb = screen->context; memset(&result, 0, sizeof(result)); cb(C, "", &result); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 96615ced904..7ad08dc1ad5 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -389,7 +389,7 @@ void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizm region_refresh_tag_gizmomap_callback = callback; } -void BKE_screen_gizmo_tag_refresh(struct bScreen *sc) +void BKE_screen_gizmo_tag_refresh(struct bScreen *screen) { if (region_refresh_tag_gizmomap_callback == NULL) { return; @@ -397,7 +397,7 @@ void BKE_screen_gizmo_tag_refresh(struct bScreen *sc) ScrArea *area; ARegion *region; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { for (region = area->regionbase.first; region; region = region->next) { if (region->gizmo_map != NULL) { region_refresh_tag_gizmomap_callback(region->gizmo_map); @@ -514,19 +514,19 @@ void BKE_screen_area_map_free(ScrAreaMap *area_map) } /** Free (or release) any data used by this screen (does not free the screen itself). */ -void BKE_screen_free(bScreen *sc) +void BKE_screen_free(bScreen *screen) { - screen_free_data(&sc->id); + screen_free_data(&screen->id); } /* ***************** Screen edges & verts ***************** */ -ScrEdge *BKE_screen_find_edge(bScreen *sc, ScrVert *v1, ScrVert *v2) +ScrEdge *BKE_screen_find_edge(bScreen *screen, ScrVert *v1, ScrVert *v2) { ScrEdge *se; BKE_screen_sort_scrvert(&v1, &v2); - for (se = sc->edgebase.first; se; se = se->next) { + for (se = screen->edgebase.first; se; se = se->next) { if (se->v1 == v1 && se->v2 == v2) { return se; } @@ -546,13 +546,13 @@ void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2) } } -void BKE_screen_remove_double_scrverts(bScreen *sc) +void BKE_screen_remove_double_scrverts(bScreen *screen) { ScrVert *v1, *verg; ScrEdge *se; ScrArea *area; - verg = sc->vertbase.first; + verg = screen->vertbase.first; while (verg) { if (verg->newv == NULL) { /* !!! */ v1 = verg->next; @@ -570,7 +570,7 @@ void BKE_screen_remove_double_scrverts(bScreen *sc) } /* replace pointers in edges and faces */ - se = sc->edgebase.first; + se = screen->edgebase.first; while (se) { if (se->v1->newv) { se->v1 = se->v1->newv; @@ -582,7 +582,7 @@ void BKE_screen_remove_double_scrverts(bScreen *sc) BKE_screen_sort_scrvert(&(se->v1), &(se->v2)); se = se->next; } - area = sc->areabase.first; + area = screen->areabase.first; while (area) { if (area->v1->newv) { area->v1 = area->v1->newv; @@ -600,29 +600,29 @@ void BKE_screen_remove_double_scrverts(bScreen *sc) } /* remove */ - verg = sc->vertbase.first; + verg = screen->vertbase.first; while (verg) { v1 = verg->next; if (verg->newv) { - BLI_remlink(&sc->vertbase, verg); + BLI_remlink(&screen->vertbase, verg); MEM_freeN(verg); } verg = v1; } } -void BKE_screen_remove_double_scredges(bScreen *sc) +void BKE_screen_remove_double_scredges(bScreen *screen) { ScrEdge *verg, *se, *sn; /* compare */ - verg = sc->edgebase.first; + verg = screen->edgebase.first; while (verg) { se = verg->next; while (se) { sn = se->next; if (verg->v1 == se->v1 && verg->v2 == se->v2) { - BLI_remlink(&sc->edgebase, se); + BLI_remlink(&screen->edgebase, se); MEM_freeN(se); } se = sn; @@ -631,37 +631,37 @@ void BKE_screen_remove_double_scredges(bScreen *sc) } } -void BKE_screen_remove_unused_scredges(bScreen *sc) +void BKE_screen_remove_unused_scredges(bScreen *screen) { ScrEdge *se, *sen; ScrArea *area; int a = 0; /* sets flags when edge is used in area */ - area = sc->areabase.first; + area = screen->areabase.first; while (area) { - se = BKE_screen_find_edge(sc, area->v1, area->v2); + se = BKE_screen_find_edge(screen, area->v1, area->v2); if (se == NULL) { printf("error: area %d edge 1 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, area->v2, area->v3); + se = BKE_screen_find_edge(screen, area->v2, area->v3); if (se == NULL) { printf("error: area %d edge 2 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, area->v3, area->v4); + se = BKE_screen_find_edge(screen, area->v3, area->v4); if (se == NULL) { printf("error: area %d edge 3 doesn't exist\n", a); } else { se->flag = 1; } - se = BKE_screen_find_edge(sc, area->v4, area->v1); + se = BKE_screen_find_edge(screen, area->v4, area->v1); if (se == NULL) { printf("error: area %d edge 4 doesn't exist\n", a); } @@ -671,11 +671,11 @@ void BKE_screen_remove_unused_scredges(bScreen *sc) area = area->next; a++; } - se = sc->edgebase.first; + se = screen->edgebase.first; while (se) { sen = se->next; if (se->flag == 0) { - BLI_remlink(&sc->edgebase, se); + BLI_remlink(&screen->edgebase, se); MEM_freeN(se); } else { @@ -685,25 +685,25 @@ void BKE_screen_remove_unused_scredges(bScreen *sc) } } -void BKE_screen_remove_unused_scrverts(bScreen *sc) +void BKE_screen_remove_unused_scrverts(bScreen *screen) { ScrVert *sv, *svn; ScrEdge *se; /* we assume edges are ok */ - se = sc->edgebase.first; + se = screen->edgebase.first; while (se) { se->v1->flag = 1; se->v2->flag = 1; se = se->next; } - sv = sc->vertbase.first; + sv = screen->vertbase.first; while (sv) { svn = sv->next; if (sv->flag == 0) { - BLI_remlink(&sc->vertbase, sv); + BLI_remlink(&screen->vertbase, sv); MEM_freeN(sv); } else { @@ -768,10 +768,10 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int /** * \note This is only for screen level regions (typically menus/popups). */ -ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int y) +ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y) { ARegion *region_found = NULL; - for (ARegion *region = sc->regionbase.first; region; region = region->next) { + for (ARegion *region = screen->regionbase.first; region; region = region->next) { if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { region_found = region; @@ -786,11 +786,11 @@ ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int * \note Ideally we can get the area from the context, * there are a few places however where this isn't practical. */ -ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl) +ScrArea *BKE_screen_find_area_from_space(struct bScreen *screen, SpaceLink *sl) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if (BLI_findindex(&area->spacedata, sl) != -1) { break; } @@ -803,12 +803,12 @@ ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl) * \note Using this function is generally a last resort, you really want to be * using the context when you can - campbell */ -ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short min) +ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min) { ScrArea *area, *big = NULL; int size, maxsize = 0; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { if (min <= area->winx && min <= area->winy) { size = area->winx * area->winy; @@ -838,9 +838,9 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, } return NULL; } -ScrArea *BKE_screen_find_area_xy(bScreen *sc, const int spacetype, int x, int y) +ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, int x, int y) { - return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(sc), spacetype, x, y); + return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, x, y); } void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene) @@ -863,11 +863,11 @@ void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene) } } -void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene) +void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene) { /* are there cameras in the views that are not in the scene? */ ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9822c794f3a..6bc920c26f9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7847,17 +7847,17 @@ static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowMa /* note: file read without screens option G_FILE_NO_UI; * check lib pointers in call below */ -static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *sc) +static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *screen) { /* deprecated, but needed for versioning (will be NULL'ed then) */ - sc->scene = newlibadr(fd, sc->id.lib, sc->scene); + screen->scene = newlibadr(fd, screen->id.lib, screen->scene); - sc->animtimer = NULL; /* saved in rare cases */ - sc->tool_tip = NULL; - sc->scrubbing = false; + screen->animtimer = NULL; /* saved in rare cases */ + screen->tool_tip = NULL; + screen->scrubbing = false; - for (ScrArea *area = sc->areabase.first; area; area = area->next) { - lib_link_area(fd, &sc->id, area); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + lib_link_area(fd, &screen->id, area); } } @@ -8195,7 +8195,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, scpt->script = restore_pointer_by_name(id_map, (ID *)scpt->script, USER_REAL); - /*sc->script = NULL; - 2.45 set to null, better re-run the script */ + /*screen->script = NULL; - 2.45 set to null, better re-run the script */ if (scpt->script) { SCRIPT_SET_NULL(scpt->script); } @@ -8378,18 +8378,18 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) } } -static bool direct_link_screen(FileData *fd, bScreen *sc) +static bool direct_link_screen(FileData *fd, bScreen *screen) { bool wrong_id = false; - sc->regionbase.first = sc->regionbase.last = NULL; - sc->context = NULL; - sc->active_region = NULL; + screen->regionbase.first = screen->regionbase.last = NULL; + screen->context = NULL; + screen->active_region = NULL; - sc->preview = direct_link_preview_image(fd, sc->preview); + screen->preview = direct_link_preview_image(fd, screen->preview); - if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) { - printf("Error reading Screen %s... removing it.\n", sc->id.name + 2); + if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(screen))) { + printf("Error reading Screen %s... removing it.\n", screen->id.name + 2); wrong_id = true; } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 83dc0e2ffe2..fe0d2293243 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -1460,15 +1460,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */ - bScreen *sc; + bScreen *screen; /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_HIDE_OVERLAYS. * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set, * which would cause cameras, lights, etc to become invisible */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -1547,13 +1547,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) { - bScreen *sc; + bScreen *screen; /* Image editor scopes */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1569,13 +1569,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile < 253) { Object *ob; Scene *scene; - bScreen *sc; + bScreen *screen; Tex *tex; Brush *brush; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1833,7 +1833,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) { Brush *br; ParticleSettings *part; - bScreen *sc; + bScreen *screen; for (br = bmain->brushes.first; br; br = br->id.next) { if (br->ob_mode == 0) { @@ -1850,9 +1850,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) part->kink_amp_clump = 1.f; /* keep old files looking similar */ } - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_INFO) { @@ -1896,13 +1896,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile < 256) { - bScreen *sc; + bScreen *screen; ScrArea *area; Key *key; /* Fix for sample line scope initializing with no height */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - area = sc->areabase.first; + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + area = screen->areabase.first; while (area) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -2040,18 +2040,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) { - bScreen *sc; + bScreen *screen; Brush *brush; Object *ob; ParticleSettings *part; /* redraws flag in SpaceTime has been moved to Screen level */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - if (sc->redraws_flag == 0) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + if (screen->redraws_flag == 0) { /* just initialize to default? */ /* XXX: we could also have iterated through areas, * and taken them from the first timeline available... */ - sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; + screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; } } diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 6f4dd88fcb6..98e10bef470 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -765,12 +765,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Tomato compatibility code. */ - bScreen *sc; + bScreen *screen; MovieClip *clip; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -1188,11 +1188,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1368,12 +1368,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1661,11 +1661,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) /* render border for viewport */ { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -1758,10 +1758,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) { - bScreen *sc; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + bScreen *screen; + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { switch (sl->spacetype) { @@ -1943,10 +1943,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (MAIN_VERSION_OLDER(bmain, 266, 2)) { - bScreen *sc; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + bScreen *screen; + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { @@ -2199,7 +2199,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) { - bScreen *sc; + bScreen *screen; Object *ob; for (ob = bmain->objects.first; ob; ob = ob->id.next) { @@ -2240,9 +2240,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) * * We moved this check to the do versions to be sure the value makes any sense. */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { @@ -2257,12 +2257,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) { - bScreen *sc; + bScreen *screen; ScrArea *area; /* add missing (+) expander in node editor */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (area = sc->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { ARegion *region, *arnew; if (area->spacetype == SPACE_NODE) { @@ -2338,14 +2338,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) { - bScreen *sc; + bScreen *screen; ScrArea *area; SpaceLink *sl; Scene *scene; /* Update files using invalid (outdated) outlinevis Outliner values. */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (area = sc->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *so = (SpaceOutliner *)sl; @@ -2542,11 +2542,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *space_link; for (space_link = area->spacedata.first; space_link; space_link = space_link->next) { diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index abe8326618b..7ae14a9b7ce 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -519,11 +519,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) * leading to corrupted files (see T39847). * This will always reset situation to a valid state. */ - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -852,14 +852,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) { - bScreen *scr; + bScreen *screen; ScrArea *area; SpaceLink *sl; ARegion *region; /* Make sure sequencer preview area limits zoom */ - for (scr = bmain->screens.first; scr; scr = scr->id.next) { - for (area = scr->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_SEQ) { for (region = sl->regionbase.first; region; region = region->next) { @@ -1650,9 +1650,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) { /* Fix for invalid state of screen due to bug in older versions. */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { - if (area->full && sc->state == SCREENNORMAL) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (area->full && screen->state == SCREENNORMAL) { area->full = NULL; } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 7449d1c04c1..3821b2ad48a 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1928,13 +1928,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) { if (DNA_struct_elem_find(fd->filesdna, "SpaceOutliner", "int", "filter") == false) { - bScreen *sc; + bScreen *screen; ScrArea *area; SpaceLink *sl; /* Update files using invalid (outdated) outlinevis Outliner values. */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (area = sc->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *so = (SpaceOutliner *)sl; @@ -1973,8 +1973,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -2643,8 +2643,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* initialize grease pencil view data */ if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) { - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index a35ef80e4d3..ce039182572 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -580,9 +580,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 109) { /* new variable: gridlines */ - bScreen *sc = bmain->screens.first; - while (sc) { - ScrArea *area = sc->areabase.first; + bScreen *screen = bmain->screens.first; + while (screen) { + ScrArea *area = screen->areabase.first; while (area) { SpaceLink *sl = area->spacedata.first; while (sl) { @@ -597,7 +597,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } area = area->next; } - sc = sc->id.next; + screen = screen->id.next; } } @@ -694,9 +694,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 169) { - bScreen *sc = bmain->screens.first; - while (sc) { - ScrArea *area = sc->areabase.first; + bScreen *screen = bmain->screens.first; + while (screen) { + ScrArea *area = screen->areabase.first; while (area) { SpaceLink *sl = area->spacedata.first; while (sl) { @@ -708,7 +708,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } area = area->next; } - sc = sc->id.next; + screen = screen->id.next; } } @@ -727,9 +727,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 171) { - bScreen *sc = bmain->screens.first; - while (sc) { - ScrArea *area = sc->areabase.first; + bScreen *screen = bmain->screens.first; + while (screen) { + ScrArea *area = screen->areabase.first; while (area) { SpaceLink *sl = area->spacedata.first; while (sl) { @@ -741,7 +741,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } area = area->next; } - sc = sc->id.next; + screen = screen->id.next; } } @@ -866,7 +866,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) bSound *sound; Scene *sce; Mesh *me; - bScreen *sc; + bScreen *screen; for (sound = bmain->sounds.first; sound; sound = sound->id.next) { if (sound->packedfile) { @@ -889,10 +889,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } /* some oldfile patch, moved from set_func_space */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -907,7 +907,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 227) { Scene *sce; - bScreen *sc; + bScreen *screen; Object *ob; /* As of now, this insures that the transition from the old Track system @@ -962,10 +962,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } /* patch for old wrong max view2d settings, allows zooming out more */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -983,7 +983,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 228) { - bScreen *sc; + bScreen *screen; Object *ob; /* As of now, this insures that the transition from the old Track system @@ -1029,10 +1029,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } /* convert old mainb values for new button panels */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1096,13 +1096,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) */ if (bmain->versionfile <= 230) { - bScreen *sc; + bScreen *screen; /* new variable blockscale, for panels in any area */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -1117,12 +1117,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 231) { - bScreen *sc = bmain->screens.first; + bScreen *screen = bmain->screens.first; /* new bit flags for showing/hiding grid floor and axes */ - while (sc) { - ScrArea *area = sc->areabase.first; + while (screen) { + ScrArea *area = screen->areabase.first; while (area) { SpaceLink *sl = area->spacedata.first; while (sl) { @@ -1140,14 +1140,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } area = area->next; } - sc = sc->id.next; + screen = screen->id.next; } } if (bmain->versionfile <= 232) { Tex *tex = bmain->textures.first; World *wrld = bmain->worlds.first; - bScreen *sc; + bScreen *screen; while (tex) { if ((tex->flag & (TEX_CHECKER_ODD + TEX_CHECKER_EVEN)) == 0) { @@ -1184,9 +1184,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* new variable blockscale, for panels in any area, do again because new * areas didn't initialize it to 0.7 yet */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { /* added: 5x better zoom in for nla */ @@ -1200,11 +1200,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 233) { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -1217,11 +1217,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 234) { - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { @@ -1651,7 +1651,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 242) { Scene *sce; - bScreen *sc; + bScreen *screen; Object *ob; Curve *cu; Material *ma; @@ -1663,9 +1663,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) bNodeTree *ntree; int a; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - area = sc->areabase.first; + area = screen->areabase.first; while (area) { SpaceLink *sl; @@ -1922,13 +1922,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile <= 244) { - bScreen *sc; + bScreen *screen; if (bmain->versionfile != 244 || bmain->subversionfile < 2) { /* correct older action editors - incorrect scrolling */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - area = sc->areabase.first; + area = screen->areabase.first; while (area) { SpaceLink *sl; @@ -2540,13 +2540,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) { - bScreen *sc; + bScreen *screen; /* adjust default settings for Animation Editors */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 6851fb67fed..43a27318d75 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3134,19 +3134,19 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm, const void * } } -static void write_screen(WriteData *wd, bScreen *sc, const void *id_address) +static void write_screen(WriteData *wd, bScreen *screen, const void *id_address) { /* Screens are reference counted, only saved if used by a workspace. */ - if (sc->id.us > 0 || wd->use_memfile) { + if (screen->id.us > 0 || wd->use_memfile) { /* write LibData */ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ - writestruct_at_address(wd, ID_SCRN, bScreen, 1, id_address, sc); - write_iddata(wd, &sc->id); + writestruct_at_address(wd, ID_SCRN, bScreen, 1, id_address, screen); + write_iddata(wd, &screen->id); - write_previews(wd, sc->preview); + write_previews(wd, screen->preview); /* direct data */ - write_area_map(wd, AREAMAP_FROM_SCREEN(sc)); + write_area_map(wd, AREAMAP_FROM_SCREEN(screen)); } } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 93d2d99effb..5523fd67dca 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -906,7 +906,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve static void ed_marker_move_apply(bContext *C, wmOperator *op) { #ifdef DURIAN_CAMERA_SWITCH - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); Object *camera = scene->camera; #endif @@ -930,7 +930,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) BKE_scene_camera_switch_update(scene); if (camera != scene->camera) { - BKE_screen_view3d_scene_sync(sc, scene); + BKE_screen_view3d_scene_sync(screen, scene); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); } #endif @@ -1621,7 +1621,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); ListBase *markers = ED_context_get_markers(C); @@ -1658,7 +1658,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) /* camera may have changes */ BKE_scene_camera_switch_update(scene); - BKE_screen_view3d_scene_sync(sc, scene); + BKE_screen_view3d_scene_sync(screen, scene); WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index cd4e161200d..8d50e24b7f0 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1933,8 +1933,8 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ static bool gpencil_area_exists(bContext *C, ScrArea *area_test) { - bScreen *sc = CTX_wm_screen(C); - return (BLI_findindex(&sc->areabase, area_test) != -1); + bScreen *screen = CTX_wm_screen(C); + return (BLI_findindex(&screen->areabase, area_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 7f0d1029722..40068b0fb85 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -3098,8 +3098,8 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ static bool gpencil_area_exists(bContext *C, ScrArea *area_test) { - bScreen *sc = CTX_wm_screen(C); - return (BLI_findindex(&sc->areabase, area_test) != -1); + bScreen *screen = CTX_wm_screen(C); + return (BLI_findindex(&screen->areabase, area_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 6db45a653b5..f03739c74c4 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -49,7 +49,7 @@ void ED_operatortypes_render(void); void ED_render_engine_changed(struct Main *bmain); void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *area); -void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *sc); +void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *screen); /* Callbacks handling data update events coming from depsgraph. */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 62d4324d37e..b0acc54f1ec 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -230,7 +230,7 @@ void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen); void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note); -bool ED_screen_change(struct bContext *C, struct bScreen *sc); +bool ED_screen_change(struct bContext *C, struct bScreen *screen); void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene); void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e8d50886c8b..56f7f0faad7 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2470,7 +2470,7 @@ struct ARegion *UI_tooltip_create_from_button(struct bContext *C, uiBut *but, bool is_label); struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz); -void UI_tooltip_free(struct bContext *C, struct bScreen *sc, struct ARegion *region); +void UI_tooltip_free(struct bContext *C, struct bScreen *screen, struct ARegion *region); /* How long before a tool-tip shows. */ #define UI_TOOLTIP_DELAY 0.5 diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 76107d190ba..3c5973a3f41 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -1233,7 +1233,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) */ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); const bool has_panel_category = UI_panel_category_is_visible(region); const bool any_item_visible = has_panel_category; PointerRNA ptr; @@ -1247,7 +1247,7 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa) return; } - RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); + RNA_pointer_create(&screen->id, &RNA_Panel, pa, &ptr); pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); layout = UI_popup_menu_layout(pup); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 61c59643bcd..04169b7d6dc 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -7707,8 +7707,8 @@ void UI_but_tooltip_refresh(bContext *C, uiBut *but) { uiHandleButtonData *data = but->active; if (data) { - bScreen *sc = WM_window_get_active_screen(data->window); - if (sc->tool_tip && sc->tool_tip->region) { + bScreen *screen = WM_window_get_active_screen(data->window); + if (screen->tool_tip && screen->tool_tip->region) { WM_tooltip_refresh(C, data->window); } } @@ -7768,9 +7768,9 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but) WM_tooltip_timer_init_ex( C, data->window, data->area, data->region, ui_but_tooltip_init, delay); if (is_label) { - bScreen *sc = WM_window_get_active_screen(data->window); - if (sc->tool_tip) { - sc->tool_tip->pass = 1; + bScreen *screen = WM_window_get_active_screen(data->window); + if (screen->tool_tip) { + screen->tool_tip->pass = 1; } } } @@ -8056,11 +8056,11 @@ static void button_activate_init(bContext *C, if (UI_but_has_tooltip_label(but)) { /* Show a label for this button. */ - bScreen *sc = WM_window_get_active_screen(data->window); + bScreen *screen = WM_window_get_active_screen(data->window); if ((PIL_check_seconds_timer() - WM_tooltip_time_closed()) < 0.1) { WM_tooltip_immediate_init(C, CTX_wm_window(C), data->area, region, ui_but_tooltip_init); - if (sc->tool_tip) { - sc->tool_tip->pass = 1; + if (screen->tool_tip) { + screen->tool_tip->pass = 1; } } } @@ -8343,10 +8343,10 @@ wmOperator *UI_context_active_operator_get(const struct bContext *C) /* scan popups */ { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ARegion *region; - for (region = sc->regionbase.first; region; region = region->next) { + for (region = screen->regionbase.first; region; region = region->next) { if (region == region_ctx) { continue; } @@ -10640,7 +10640,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata)) { - bScreen *sc; + bScreen *screen; ARegion *region; region = CTX_wm_region(C); @@ -10650,15 +10650,15 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata)) UI_blocklist_free(C, ®ion->uiblocks); - sc = CTX_wm_screen(C); - if (sc == NULL) { + screen = CTX_wm_screen(C); + if (screen == NULL) { return; } /* delayed apply callbacks, but not for screen level regions, those * we rather do at the very end after closing them all, which will * be done in ui_region_handler/window */ - if (BLI_findindex(&sc->regionbase, region) == -1) { + if (BLI_findindex(&screen->regionbase, region) == -1) { ui_apply_but_funcs_after(C); } } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index ed5d02a5a03..53ea51c9e97 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1620,10 +1620,11 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed"); ARegion *region_prev = CTX_wm_region(C); - ARegion *region = sc ? BKE_screen_find_region_xy(sc, RGN_TYPE_ANY, event->x, event->y) : NULL; + ARegion *region = screen ? BKE_screen_find_region_xy(screen, RGN_TYPE_ANY, event->x, event->y) : + NULL; if (region == NULL) { region = region_prev; diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index e6381fd08e6..a51558e4cfe 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -530,23 +530,23 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = ctx_win; - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); /* There may actually be a different window active than the one showing the popup, so lookup real * one. */ - if (BLI_findindex(&sc->regionbase, handle->region) == -1) { + if (BLI_findindex(&screen->regionbase, handle->region) == -1) { for (win = wm->windows.first; win; win = win->next) { - sc = WM_window_get_active_screen(win); - if (BLI_findindex(&sc->regionbase, handle->region) != -1) { + screen = WM_window_get_active_screen(win); + if (BLI_findindex(&screen->regionbase, handle->region) != -1) { break; } } } - BLI_assert(win && sc); + BLI_assert(win && screen); CTX_wm_window_set(C, win); - ui_region_temp_remove(C, sc, handle->region); + ui_region_temp_remove(C, screen, handle->region); /* Reset context (area and region were NULL'ed when chaning context window). */ CTX_wm_window_set(C, ctx_win); @@ -554,7 +554,7 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) CTX_wm_region_set(C, ctx_region); /* reset to region cursor (only if there's not another menu open) */ - if (BLI_listbase_is_empty(&sc->regionbase)) { + if (BLI_listbase_is_empty(&screen->regionbase)) { win->tag_cursor_refresh = true; } diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 61676ba43d6..7576db6b33b 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -1480,9 +1480,9 @@ ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) return ui_tooltip_create_with_data(C, data, init_position, NULL, aspect); } -void UI_tooltip_free(bContext *C, bScreen *sc, ARegion *region) +void UI_tooltip_free(bContext *C, bScreen *screen, ARegion *region) { - ui_region_temp_remove(C, sc, region); + ui_region_temp_remove(C, screen, region); } /** \} */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 2275f3fecdf..9ff58ddd24f 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -39,12 +39,12 @@ #include "interface_regions_intern.h" -ARegion *ui_region_temp_add(bScreen *sc) +ARegion *ui_region_temp_add(bScreen *screen) { ARegion *region; region = MEM_callocN(sizeof(ARegion), "area region"); - BLI_addtail(&sc->regionbase, region); + BLI_addtail(&screen->regionbase, region); region->regiontype = RGN_TYPE_TEMPORARY; region->alignment = RGN_ALIGN_FLOAT; @@ -52,17 +52,17 @@ ARegion *ui_region_temp_add(bScreen *sc) return region; } -void ui_region_temp_remove(bContext *C, bScreen *sc, ARegion *region) +void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region) { wmWindow *win = CTX_wm_window(C); BLI_assert(region->regiontype == RGN_TYPE_TEMPORARY); - BLI_assert(BLI_findindex(&sc->regionbase, region) != -1); + BLI_assert(BLI_findindex(&screen->regionbase, region) != -1); if (win) { wm_draw_region_clear(win, region); } ED_region_exit(C, region); BKE_area_region_free(NULL, region); /* NULL: no spacetype */ - BLI_freelinkN(&sc->regionbase, region); + BLI_freelinkN(&screen->regionbase, region); } diff --git a/source/blender/editors/interface/interface_regions_intern.h b/source/blender/editors/interface/interface_regions_intern.h index 329ee3c08dc..c299562a357 100644 --- a/source/blender/editors/interface/interface_regions_intern.h +++ b/source/blender/editors/interface/interface_regions_intern.h @@ -27,7 +27,7 @@ uint ui_popup_menu_hash(const char *str); /* interface_regions_intern.h */ -ARegion *ui_region_temp_add(bScreen *sc); -void ui_region_temp_remove(struct bContext *C, bScreen *sc, ARegion *region); +ARegion *ui_region_temp_add(bScreen *screen); +void ui_region_temp_remove(struct bContext *C, bScreen *screen, ARegion *region); #endif /* __INTERFACE_REGIONS_INTERN_H__ */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 18e14798767..5b1e5f746ef 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -79,7 +79,7 @@ static bool view2d_poll(bContext *C) */ typedef struct v2dViewPanData { /** screen where view pan was initiated */ - bScreen *sc; + bScreen *screen; /** area where view pan was initiated */ ScrArea *area; /** region where view pan was initiated */ @@ -126,7 +126,7 @@ static int view_pan_init(bContext *C, wmOperator *op) op->customdata = vpd; /* set pointers to owners */ - vpd->sc = CTX_wm_screen(C); + vpd->screen = CTX_wm_screen(C); vpd->area = CTX_wm_area(C); vpd->v2d = v2d; vpd->region = region; @@ -190,7 +190,7 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float /* request updates to be done... */ WM_event_add_mousemove(CTX_wm_window(C)); - UI_view2d_sync(vpd->sc, vpd->area, v2d, V2D_LOCK_COPY); + UI_view2d_sync(vpd->screen, vpd->area, v2d, V2D_LOCK_COPY); } static void view_pan_apply(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index b6838f5d7af..d625b770164 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -1283,13 +1283,13 @@ cleanup: static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr) { bool is_save_internal; - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); bkr->ob = CTX_data_active_object(C); bkr->main = CTX_data_main(C); bkr->view_layer = CTX_data_view_layer(C); bkr->scene = CTX_data_scene(C); - bkr->area = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; + bkr->area = screen ? BKE_screen_find_big_area(screen, SPACE_IMAGE, 10) : NULL; bkr->pass_type = RNA_enum_get(op->ptr, "type"); bkr->pass_filter = RNA_enum_get(op->ptr, "pass_filter"); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 56b7e2a771d..24b1c5a36f8 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -105,13 +105,13 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update wm = bmain->wm.first; for (win = wm->windows.first; win; win = win->next) { - bScreen *sc = WM_window_get_active_screen(win); + bScreen *screen = WM_window_get_active_screen(win); ScrArea *area; ARegion *region; CTX_wm_window_set(C, win); - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if (area->spacetype != SPACE_VIEW3D) { continue; } @@ -127,7 +127,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update * time of the last update) */ if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { - CTX_wm_screen_set(C, sc); + CTX_wm_screen_set(C, screen); CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); @@ -181,8 +181,8 @@ void ED_render_engine_area_exit(Main *bmain, ScrArea *area) void ED_render_engine_changed(Main *bmain) { /* on changing the render engine type, clear all running render engines */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { ED_render_engine_area_exit(bmain, area); } } @@ -204,9 +204,9 @@ void ED_render_engine_changed(Main *bmain) } } -void ED_render_view_layer_changed(Main *bmain, bScreen *sc) +void ED_render_view_layer_changed(Main *bmain, bScreen *screen) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { ED_render_engine_area_exit(bmain, area); } } diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index c0d35938787..a9c855b14b0 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -56,12 +56,12 @@ /* would use BKE_screen_find_big_area(...) but this is too specific */ static ScrArea *biggest_non_image_area(bContext *C) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area, *big = NULL; int size, maxsize = 0, bwmaxsize = 0; short foundwin = 0; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if (area->winx > 30 && area->winy > 30) { size = area->winx * area->winy; if (!area->full && area->spacetype == SPACE_PROPERTIES) { @@ -111,12 +111,12 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow * static ScrArea *find_area_image_empty(bContext *C) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area; SpaceImage *sima; /* find an imagewindow showing render result */ - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if (area->spacetype == SPACE_IMAGE) { sima = area->spacedata.first; if ((sima->mode == SI_MODE_VIEW) && !sima->image) { @@ -324,10 +324,10 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e /* is there another window on current scene showing result? */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { - const bScreen *sc = WM_window_get_active_screen(win); + const bScreen *screen = WM_window_get_active_screen(win); if ((WM_window_is_temp_screen(win) && - ((ScrArea *)sc->areabase.first)->spacetype == SPACE_IMAGE) || + ((ScrArea *)screen->areabase.first)->spacetype == SPACE_IMAGE) || (win == winshow && winshow != wincur)) { wm_window_raise(win); return OPERATOR_FINISHED; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 58e2bb8d037..751f37dc5ec 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2263,11 +2263,11 @@ void ED_area_prevspace(bContext *C, ScrArea *area) int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) { ScrArea *area = CTX_wm_area(C); - bScreen *scr = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); PointerRNA areaptr; int xco = 0.4 * U.widget_unit; - RNA_pointer_create(&(scr->id), &RNA_Area, area, &areaptr); + RNA_pointer_create(&(screen->id), &RNA_Area, area, &areaptr); uiDefButR(block, UI_BTYPE_MENU, diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 778a3740622..3e102a38a0d 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -113,7 +113,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult { wmWindow *win = CTX_wm_window(C); View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); @@ -555,7 +555,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "annotation_data")) { - bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, area, scene); + bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene); if (gpd) { CTX_data_id_pointer_set(result, &gpd->id); @@ -568,7 +568,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult PointerRNA ptr; /* Get pointer to Grease Pencil Data. */ - gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)sc, area, scene, &ptr); + gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr); if (gpd_ptr) { CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); @@ -588,7 +588,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_annotation_layer")) { - bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, area, scene); + bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene); if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 11a12452ce3..16ef93872ff 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -82,7 +82,7 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map, return area; } -static ScrArea *screen_addarea(bScreen *sc, +static ScrArea *screen_addarea(bScreen *screen, ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, @@ -90,22 +90,22 @@ static ScrArea *screen_addarea(bScreen *sc, short spacetype) { return screen_addarea_ex( - AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom, spacetype); + AREAMAP_FROM_SCREEN(screen), left_bottom, left_top, right_top, right_bottom, spacetype); } -static void screen_delarea(bContext *C, bScreen *sc, ScrArea *area) +static void screen_delarea(bContext *C, bScreen *screen, ScrArea *area) { ED_area_exit(C, area); BKE_screen_area_free(area); - BLI_remlink(&sc->areabase, area); + BLI_remlink(&screen->areabase, area); MEM_freeN(area); } ScrArea *area_split( - const wmWindow *win, bScreen *sc, ScrArea *area, char dir, float fac, int merge) + const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge) { ScrArea *newa = NULL; ScrVert *sv1, *sv2; @@ -129,19 +129,19 @@ ScrArea *area_split( if (dir == 'h') { /* new vertices */ - sv1 = screen_geom_vertex_add(sc, area->v1->vec.x, split); - sv2 = screen_geom_vertex_add(sc, area->v4->vec.x, split); + sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split); + sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split); /* new edges */ - screen_geom_edge_add(sc, area->v1, sv1); - screen_geom_edge_add(sc, sv1, area->v2); - screen_geom_edge_add(sc, area->v3, sv2); - screen_geom_edge_add(sc, sv2, area->v4); - screen_geom_edge_add(sc, sv1, sv2); + screen_geom_edge_add(screen, area->v1, sv1); + screen_geom_edge_add(screen, sv1, area->v2); + screen_geom_edge_add(screen, area->v3, sv2); + screen_geom_edge_add(screen, sv2, area->v4); + screen_geom_edge_add(screen, sv1, sv2); if (fac > 0.5f) { /* new areas: top */ - newa = screen_addarea(sc, sv1, area->v2, area->v3, sv2, area->spacetype); + newa = screen_addarea(screen, sv1, area->v2, area->v3, sv2, area->spacetype); /* area below */ area->v2 = sv1; @@ -149,7 +149,7 @@ ScrArea *area_split( } else { /* new areas: bottom */ - newa = screen_addarea(sc, area->v1, sv1, sv2, area->v4, area->spacetype); + newa = screen_addarea(screen, area->v1, sv1, sv2, area->v4, area->spacetype); /* area above */ area->v1 = sv1; @@ -160,19 +160,19 @@ ScrArea *area_split( } else { /* new vertices */ - sv1 = screen_geom_vertex_add(sc, split, area->v1->vec.y); - sv2 = screen_geom_vertex_add(sc, split, area->v2->vec.y); + sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y); + sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y); /* new edges */ - screen_geom_edge_add(sc, area->v1, sv1); - screen_geom_edge_add(sc, sv1, area->v4); - screen_geom_edge_add(sc, area->v2, sv2); - screen_geom_edge_add(sc, sv2, area->v3); - screen_geom_edge_add(sc, sv1, sv2); + screen_geom_edge_add(screen, area->v1, sv1); + screen_geom_edge_add(screen, sv1, area->v4); + screen_geom_edge_add(screen, area->v2, sv2); + screen_geom_edge_add(screen, sv2, area->v3); + screen_geom_edge_add(screen, sv1, sv2); if (fac > 0.5f) { /* new areas: right */ - newa = screen_addarea(sc, sv1, sv2, area->v3, area->v4, area->spacetype); + newa = screen_addarea(screen, sv1, sv2, area->v3, area->v4, area->spacetype); /* area left */ area->v3 = sv2; @@ -180,7 +180,7 @@ ScrArea *area_split( } else { /* new areas: left */ - newa = screen_addarea(sc, area->v1, area->v2, sv2, sv1, area->spacetype); + newa = screen_addarea(screen, area->v1, area->v2, sv2, sv1, area->spacetype); /* area right */ area->v1 = sv1; @@ -192,10 +192,10 @@ ScrArea *area_split( /* remove double vertices en edges */ if (merge) { - BKE_screen_remove_double_scrverts(sc); + BKE_screen_remove_double_scrverts(screen); } - BKE_screen_remove_double_scredges(sc); - BKE_screen_remove_unused_scredges(sc); + BKE_screen_remove_double_scredges(screen); + BKE_screen_remove_unused_scredges(screen); return newa; } @@ -205,27 +205,27 @@ ScrArea *area_split( */ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect) { - bScreen *sc; + bScreen *screen; ScrVert *sv1, *sv2, *sv3, *sv4; - sc = BKE_libblock_alloc(bmain, ID_SCR, name, 0); - sc->do_refresh = true; - sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; + screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0); + screen->do_refresh = true; + screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; - sv1 = screen_geom_vertex_add(sc, rect->xmin, rect->ymin); - sv2 = screen_geom_vertex_add(sc, rect->xmin, rect->ymax - 1); - sv3 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymax - 1); - sv4 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymin); + sv1 = screen_geom_vertex_add(screen, rect->xmin, rect->ymin); + sv2 = screen_geom_vertex_add(screen, rect->xmin, rect->ymax - 1); + sv3 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymax - 1); + sv4 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymin); - screen_geom_edge_add(sc, sv1, sv2); - screen_geom_edge_add(sc, sv2, sv3); - screen_geom_edge_add(sc, sv3, sv4); - screen_geom_edge_add(sc, sv4, sv1); + screen_geom_edge_add(screen, sv1, sv2); + screen_geom_edge_add(screen, sv2, sv3); + screen_geom_edge_add(screen, sv3, sv4); + screen_geom_edge_add(screen, sv4, sv1); /* dummy type, no spacedata */ - screen_addarea(sc, sv1, sv2, sv3, sv4, SPACE_EMPTY); + screen_addarea(screen, sv1, sv2, sv3, sv4, SPACE_EMPTY); - return sc; + return screen; } void screen_data_copy(bScreen *to, bScreen *from) @@ -339,7 +339,7 @@ int area_getorientation(ScrArea *area, ScrArea *sb) /* Helper function to join 2 areas, it has a return value, 0=failed 1=success * used by the split, join operators */ -int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) +int screen_area_join(bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2) { int dir = area_getorientation(sa1, sa2); @@ -367,32 +367,32 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) if (dir == 0) { /* sa1 to right of sa2 = W */ sa1->v1 = sa2->v1; /* BL */ sa1->v2 = sa2->v2; /* TL */ - screen_geom_edge_add(scr, sa1->v2, sa1->v3); - screen_geom_edge_add(scr, sa1->v1, sa1->v4); + screen_geom_edge_add(screen, sa1->v2, sa1->v3); + screen_geom_edge_add(screen, sa1->v1, sa1->v4); } else if (dir == 1) { /* sa1 to bottom of sa2 = N */ sa1->v2 = sa2->v2; /* TL */ sa1->v3 = sa2->v3; /* TR */ - screen_geom_edge_add(scr, sa1->v1, sa1->v2); - screen_geom_edge_add(scr, sa1->v3, sa1->v4); + screen_geom_edge_add(screen, sa1->v1, sa1->v2); + screen_geom_edge_add(screen, sa1->v3, sa1->v4); } else if (dir == 2) { /* sa1 to left of sa2 = E */ sa1->v3 = sa2->v3; /* TR */ sa1->v4 = sa2->v4; /* BR */ - screen_geom_edge_add(scr, sa1->v2, sa1->v3); - screen_geom_edge_add(scr, sa1->v1, sa1->v4); + screen_geom_edge_add(screen, sa1->v2, sa1->v3); + screen_geom_edge_add(screen, sa1->v1, sa1->v4); } else if (dir == 3) { /* sa1 on top of sa2 = S */ sa1->v1 = sa2->v1; /* BL */ sa1->v4 = sa2->v4; /* BR */ - screen_geom_edge_add(scr, sa1->v1, sa1->v2); - screen_geom_edge_add(scr, sa1->v3, sa1->v4); + screen_geom_edge_add(screen, sa1->v1, sa1->v2); + screen_geom_edge_add(screen, sa1->v3, sa1->v4); } - screen_delarea(C, scr, sa2); - BKE_screen_remove_double_scrverts(scr); + screen_delarea(C, screen, sa2); + BKE_screen_remove_double_scrverts(screen); /* Update preview thumbnail */ - BKE_icon_changed(scr->id.icon_id); + BKE_icon_changed(screen->id.icon_id); return 1; } @@ -682,16 +682,16 @@ static void screen_cursor_set(wmWindow *win, const int xy[2]) */ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) { - bScreen *scr = WM_window_get_active_screen(win); - if (scr == NULL) { + bScreen *screen = WM_window_get_active_screen(win); + if (screen == NULL) { return; } ScrArea *area = NULL; ARegion *region; - ARegion *region_prev = scr->active_region; + ARegion *region_prev = screen->active_region; - ED_screen_areas_iter(win, scr, area_iter) + ED_screen_areas_iter(win, screen, area_iter) { if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) { if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) { @@ -706,19 +706,19 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) /* Make overlap active when mouse over. */ for (region = area->regionbase.first; region; region = region->next) { if (ED_region_contains_xy(region, xy)) { - scr->active_region = region; + screen->active_region = region; break; } } } else { - scr->active_region = NULL; + screen->active_region = NULL; } /* Check for redraw headers. */ - if (region_prev != scr->active_region) { + if (region_prev != screen->active_region) { - ED_screen_areas_iter(win, scr, area_iter) + ED_screen_areas_iter(win, screen, area_iter) { bool do_draw = false; @@ -729,7 +729,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) area_iter->type->deactivate(area_iter); } - if (region == region_prev && region != scr->active_region) { + if (region == region_prev && region != screen->active_region) { wmGizmoMap *gzmap = region_prev->gizmo_map; if (gzmap) { if (WM_gizmo_highlight_set(gzmap, NULL)) { @@ -738,7 +738,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) } } - if (region == region_prev || region == scr->active_region) { + if (region == region_prev || region == screen->active_region) { do_draw = true; } } @@ -755,19 +755,19 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) /* Cursors, for time being set always on edges, * otherwise the active region doesn't switch. */ - if (scr->active_region == NULL) { + if (screen->active_region == NULL) { screen_cursor_set(win, xy); } else { /* Notifier invokes freeing the buttons... causing a bit too much redraws. */ - region_cursor_set_ex(win, area, scr->active_region, region_prev != scr->active_region); + region_cursor_set_ex(win, area, screen->active_region, region_prev != screen->active_region); - if (region_prev != scr->active_region) { + if (region_prev != screen->active_region) { /* This used to be a notifier, but needs to be done immediate * because it can undo setting the right button as active due * to delayed notifier handling. */ if (C) { - UI_screen_free_active_but(C, scr); + UI_screen_free_active_but(C, screen); } } } @@ -776,10 +776,10 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) int ED_screen_area_active(const bContext *C) { wmWindow *win = CTX_wm_window(C); - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); - if (win && sc && area) { + if (win && screen && area) { AZone *az = ED_area_actionzone_find_xy(area, &win->eventstate->x); ARegion *region; @@ -788,7 +788,7 @@ int ED_screen_area_active(const bContext *C) } for (region = area->regionbase.first; region; region = region->next) { - if (region == sc->active_region) { + if (region == screen->active_region) { return 1; } } @@ -1000,17 +1000,17 @@ bScreen *screen_change_prepare( return NULL; } -void screen_change_update(bContext *C, wmWindow *win, bScreen *sc) +void screen_change_update(bContext *C, wmWindow *win, bScreen *screen) { Scene *scene = WM_window_get_active_scene(win); WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc); + WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen); CTX_wm_window_set(C, win); /* stores C->wm.screen... hrmf */ ED_screen_refresh(CTX_wm_manager(C), win); - BKE_screen_view3d_scene_sync(sc, scene); /* sync new screen with scene data */ + BKE_screen_view3d_scene_sync(screen, scene); /* sync new screen with scene data */ WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTSET, layout); @@ -1026,16 +1026,16 @@ void screen_change_update(bContext *C, wmWindow *win, bScreen *sc) * \warning Do NOT call in area/region queues! * \returns if screen changing was successful. */ -bool ED_screen_change(bContext *C, bScreen *sc) +bool ED_screen_change(bContext *C, bScreen *screen) { Main *bmain = CTX_data_main(C); wmWindow *win = CTX_wm_window(C); bScreen *screen_old = CTX_wm_screen(C); - bScreen *screen_new = screen_change_prepare(screen_old, sc, bmain, C, win); + bScreen *screen_new = screen_change_prepare(screen_old, screen, bmain, C, win); if (screen_new) { WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - WM_window_set_active_screen(win, workspace, sc); + WM_window_set_active_screen(win, workspace, screen); screen_change_update(C, win, screen_new); return true; @@ -1054,7 +1054,7 @@ static void screen_set_3dview_camera(Scene *scene, if (!v3d->camera || !BKE_view_layer_base_find(view_layer, v3d->camera)) { v3d->camera = BKE_view_layer_camera_find(view_layer); - // XXX if (sc == curscreen) handle_view3d_lock(); + // XXX if (screen == curscreen) handle_view3d_lock(); if (!v3d->camera) { ARegion *region; ListBase *regionbase; @@ -1214,7 +1214,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); WorkSpace *workspace = WM_window_get_active_workspace(win); - bScreen *sc, *oldscreen; + bScreen *screen, *oldscreen; ARegion *region; if (area) { @@ -1238,18 +1238,18 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const if (area && area->full) { WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); /* restoring back to SCREENNORMAL */ - sc = area->full; /* the old screen to restore */ + screen = area->full; /* the old screen to restore */ oldscreen = WM_window_get_active_screen(win); /* the one disappearing */ - BLI_assert(BKE_workspace_layout_screen_get(layout_old) != sc); + BLI_assert(BKE_workspace_layout_screen_get(layout_old) != screen); BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL); - sc->state = SCREENNORMAL; - sc->flag = oldscreen->flag; + screen->state = SCREENNORMAL; + screen->flag = oldscreen->flag; /* find old area to restore from */ ScrArea *fullsa = NULL; - for (ScrArea *old = sc->areabase.first; old; old = old->next) { + for (ScrArea *old = screen->areabase.first; old; old = old->next) { /* area to restore from is always first */ if (old->full && !fullsa) { fullsa = old; @@ -1283,10 +1283,10 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const ED_area_data_swap(fullsa, area); /* animtimer back */ - sc->animtimer = oldscreen->animtimer; + screen->animtimer = oldscreen->animtimer; oldscreen->animtimer = NULL; - ED_screen_change(C, sc); + ED_screen_change(C, screen); BKE_workspace_layout_remove(CTX_data_main(C), workspace, layout_old); @@ -1294,7 +1294,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const * screen handling as it uses the area coords which aren't updated yet. * Without doing so, the screen handling gets wrong area coords, * which in worst case can lead to crashes (see T43139) */ - sc->skip_handling = true; + screen->skip_handling = true; } else { /* change from SCREENNORMAL to new state */ @@ -1311,14 +1311,14 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const layout_new = ED_workspace_layout_add(bmain, workspace, win, newname); - sc = BKE_workspace_layout_screen_get(layout_new); - sc->state = state; - sc->redraws_flag = oldscreen->redraws_flag; - sc->temp = oldscreen->temp; - sc->flag = oldscreen->flag; + screen = BKE_workspace_layout_screen_get(layout_new); + screen->state = state; + screen->redraws_flag = oldscreen->redraws_flag; + screen->temp = oldscreen->temp; + screen->flag = oldscreen->flag; /* timer */ - sc->animtimer = oldscreen->animtimer; + screen->animtimer = oldscreen->animtimer; oldscreen->animtimer = NULL; /* use random area when we have no active one, e.g. when the @@ -1327,7 +1327,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const area = oldscreen->areabase.first; } - newa = (ScrArea *)sc->areabase.first; + newa = (ScrArea *)screen->areabase.first; /* copy area */ ED_area_data_swap(newa, area); @@ -1359,13 +1359,13 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const area->full = oldscreen; newa->full = oldscreen; - ED_screen_change(C, sc); + ED_screen_change(C, screen); } /* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ - CTX_wm_area_set(C, sc->areabase.first); + CTX_wm_area_set(C, screen->areabase.first); - return sc->areabase.first; + return screen->areabase.first; } /** @@ -1557,11 +1557,11 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph) #ifdef DURIAN_CAMERA_SWITCH void *camera = BKE_scene_camera_switch_find(scene); if (camera && scene->camera != camera) { - bScreen *sc; + bScreen *screen; scene->camera = camera; /* are there cameras in the views that are not in the scene? */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - BKE_screen_view3d_scene_sync(sc, scene); + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + BKE_screen_view3d_scene_sync(screen, scene); } DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); } diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 9169bf37116..178c375c8ee 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -57,9 +57,9 @@ ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y) BLI_addtail(&area_map->vertbase, sv); return sv; } -ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y) +ScrVert *screen_geom_vertex_add(bScreen *screen, short x, short y) { - return screen_geom_vertex_add_ex(AREAMAP_FROM_SCREEN(sc), x, y); + return screen_geom_vertex_add_ex(AREAMAP_FROM_SCREEN(screen), x, y); } ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2) @@ -73,9 +73,9 @@ ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2) BLI_addtail(&area_map->edgebase, se); return se; } -ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2) +ScrEdge *screen_geom_edge_add(bScreen *screen, ScrVert *v1, ScrVert *v2) { - return screen_geom_edge_add_ex(AREAMAP_FROM_SCREEN(sc), v1, v2); + return screen_geom_edge_add_ex(AREAMAP_FROM_SCREEN(screen), v1, v2); } bool screen_geom_edge_is_horizontal(ScrEdge *se) @@ -153,7 +153,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, * * Ensure areas have a minimum height. * * Correctly set global areas to their fixed height. */ -void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) +void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) { rcti window_rect, screen_rect; @@ -170,7 +170,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) min[0] = min[1] = 20000.0f; max[0] = max[1] = 0.0f; - for (sv = sc->vertbase.first; sv; sv = sv->next) { + for (sv = screen->vertbase.first; sv; sv = sv->next) { const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; minmax_v2v2_v2(min, max, fv); } @@ -183,7 +183,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1); /* make sure it fits! */ - for (sv = sc->vertbase.first; sv; sv = sv->next) { + for (sv = screen->vertbase.first; sv; sv = sv->next) { sv->vec.x = screen_rect.xmin + round_fl_to_short((sv->vec.x - min[0]) * facx); CLAMP(sv->vec.x, screen_rect.xmin, screen_rect.xmax - 1); @@ -198,17 +198,17 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) if (facy > 1) { /* Keep timeline small in video edit workspace. */ - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect.ymin && screen_geom_area_height(area) <= headery * facy + 1) { - ScrEdge *se = BKE_screen_find_edge(sc, area->v2, area->v3); + ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3); if (se) { const int yval = area->v1->vec.y + headery - 1; screen_geom_select_connected_edge(win, se); /* all selected vertices get the right offset */ - for (sv = sc->vertbase.first; sv; sv = sv->next) { + for (sv = screen->vertbase.first; sv; sv = sv->next) { /* if is a collapsed area */ if (sv != area->v1 && sv != area->v4) { if (sv->flag) { @@ -222,17 +222,17 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) } if (facy < 1) { /* make each window at least ED_area_headersize() high */ - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { if (screen_geom_area_height(area) < headery) { /* lower edge */ - ScrEdge *se = BKE_screen_find_edge(sc, area->v4, area->v1); + ScrEdge *se = BKE_screen_find_edge(screen, area->v4, area->v1); if (se && area->v1 != area->v2) { const int yval = area->v2->vec.y - headery + 1; screen_geom_select_connected_edge(win, se); /* all selected vertices get the right offset */ - for (sv = sc->vertbase.first; sv; sv = sv->next) { + for (sv = screen->vertbase.first; sv; sv = sv->next) { /* if is not a collapsed area */ if (sv != area->v2 && sv != area->v3) { if (sv->flag) { @@ -355,7 +355,7 @@ short screen_geom_find_area_split_point(const ScrArea *area, */ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) { - bScreen *sc = WM_window_get_active_screen(win); + bScreen *screen = WM_window_get_active_screen(win); bool oneselected = true; char dir; @@ -369,7 +369,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) dir = 'h'; } - ED_screen_verts_iter(win, sc, sv) + ED_screen_verts_iter(win, screen, sv) { sv->flag = 0; } @@ -379,7 +379,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) while (oneselected) { oneselected = false; - for (ScrEdge *se = sc->edgebase.first; se; se = se->next) { + for (ScrEdge *se = screen->edgebase.first; se; se = se->next) { if (se->v1->flag + se->v2->flag == 1) { if (dir == 'h') { if (se->v1->vec.y == se->v2->vec.y) { diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index af57d95c086..3dfc147bc73 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -44,15 +44,15 @@ void region_toggle_hidden(struct bContext *C, ARegion *region, const bool do_fad bScreen *screen_add(struct Main *bmain, const char *name, const rcti *rect); void screen_data_copy(bScreen *to, bScreen *from); void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new); -void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc); +void screen_change_update(struct bContext *C, wmWindow *win, bScreen *screen); bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, struct Main *bmain, struct bContext *C, wmWindow *win); ScrArea *area_split( - const wmWindow *win, bScreen *sc, ScrArea *area, char dir, float fac, int merge); -int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2); + const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge); +int screen_area_join(struct bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2); int area_getorientation(ScrArea *area, ScrArea *sb); struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); @@ -61,9 +61,9 @@ struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); int screen_geom_area_height(const ScrArea *area); int screen_geom_area_width(const ScrArea *area); ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y); -ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y); +ScrVert *screen_geom_vertex_add(bScreen *screen, short x, short y); ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2); -ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2); +ScrEdge *screen_geom_edge_add(bScreen *screen, ScrVert *v1, ScrVert *v2); bool screen_geom_edge_is_horizontal(ScrEdge *se); ScrEdge *screen_geom_area_map_find_active_scredge(const struct ScrAreaMap *area_map, const rcti *bounds_rect, @@ -73,7 +73,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, const bScreen *screen, const int mx, const int my); -void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc); +void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen); short screen_geom_find_area_split_point(const ScrArea *area, const rcti *window_rect, char dir, diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 2e4734e75a5..08bf6f67215 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -594,8 +594,8 @@ bool ED_operator_mask(bContext *C) if (area && area->spacedata.first) { switch (area->spacetype) { case SPACE_CLIP: { - SpaceClip *sc = area->spacedata.first; - return ED_space_clip_check_show_maskedit(sc); + SpaceClip *screen = area->spacedata.first; + return ED_space_clip_check_show_maskedit(screen); } case SPACE_SEQ: { SpaceSeq *sseq = area->spacedata.first; @@ -893,9 +893,9 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b } /* Finds an action-zone by position in entire screen so azones can overlap. */ -static AZone *screen_actionzone_find_xy(bScreen *sc, const int xy[2]) +static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2]) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { AZone *az = area_actionzone_refresh_xy(area, xy, true); if (az != NULL) { return az; @@ -905,9 +905,9 @@ static AZone *screen_actionzone_find_xy(bScreen *sc, const int xy[2]) } /* Returns the area that the azone belongs to */ -static ScrArea *screen_actionzone_area(bScreen *sc, const AZone *az) +static ScrArea *screen_actionzone_area(bScreen *screen, const AZone *az) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (AZone *zone = area->actionzones.first; zone; zone = zone->next) { if (zone == az) { return area; @@ -968,8 +968,8 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - bScreen *sc = CTX_wm_screen(C); - AZone *az = screen_actionzone_find_xy(sc, &event->x); + bScreen *screen = CTX_wm_screen(C); + AZone *az = screen_actionzone_find_xy(screen, &event->x); sActionzoneData *sad; /* Quick escape - Scroll azones only hide/unhide the scroll-bars, @@ -980,7 +980,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* ok we do the action-zone */ sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); - sad->sa1 = screen_actionzone_area(sc, az); + sad->sa1 = screen_actionzone_area(screen, az); sad->az = az; sad->x = event->x; sad->y = event->y; @@ -1003,7 +1003,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); sActionzoneData *sad = op->customdata; switch (event->type) { @@ -1044,9 +1044,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Have we dragged off the zone and are not on an edge? */ if ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) && (screen_geom_area_map_find_active_scredge( - AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL)) { + AREAMAP_FROM_SCREEN(screen), &screen_rect, event->x, event->y) == NULL)) { /* Are we still in same area? */ - if (BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y) == sad->sa1) { + if (BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y) == sad->sa1) { /* Same area, so possible split. */ WM_cursor_set( win, (ELEM(sad->gesture_dir, 'n', 's')) ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT); @@ -1081,7 +1081,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* gesture is large enough? */ if (is_gesture) { /* second area, for join when (sa1 != sa2) */ - sad->sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y); + sad->sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y); /* apply sends event */ actionzone_apply(C, op, sad->az->type); actionzone_exit(op); @@ -1136,12 +1136,12 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C, ScrArea **r_sa2) { wmWindow *win = CTX_wm_window(C); - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrEdge *actedge; rcti window_rect; WM_window_rect_calc(win, &window_rect); actedge = screen_geom_area_map_find_active_scredge( - AREAMAP_FROM_SCREEN(sc), &window_rect, cursor[0], cursor[1]); + AREAMAP_FROM_SCREEN(screen), &window_rect, cursor[0], cursor[1]); *r_sa1 = NULL; *r_sa2 = NULL; if (actedge == NULL) { @@ -1150,12 +1150,12 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C, int borderwidth = (4 * UI_DPI_FAC); ScrArea *sa1, *sa2; if (screen_geom_edge_is_horizontal(actedge)) { - sa1 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0], cursor[1] + borderwidth); - sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0], cursor[1] - borderwidth); + sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0], cursor[1] + borderwidth); + sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0], cursor[1] - borderwidth); } else { - sa1 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0] + borderwidth, cursor[1]); - sa2 = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, cursor[0] - borderwidth, cursor[1]); + sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0] + borderwidth, cursor[1]); + sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, cursor[0] - borderwidth, cursor[1]); } bool isGlobal = ((sa1 && ED_area_is_global(sa1)) || (sa2 && ED_area_is_global(sa2))); if (!isGlobal) { @@ -1454,8 +1454,12 @@ typedef struct sAreaMoveData { /* helper call to move area-edge, sets limits * need window bounds in order to get correct limits */ -static void area_move_set_limits( - wmWindow *win, bScreen *sc, int dir, int *bigger, int *smaller, bool *use_bigger_smaller_snap) +static void area_move_set_limits(wmWindow *win, + bScreen *screen, + int dir, + int *bigger, + int *smaller, + bool *use_bigger_smaller_snap) { rcti window_rect; int areaminy = ED_area_headersize(); @@ -1507,7 +1511,7 @@ static void area_move_set_limits( WM_window_rect_calc(win, &window_rect); - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { if (dir == 'h') { int y1; areamin = areaminy; @@ -1557,7 +1561,7 @@ static void area_move_set_limits( /* return 0: init failed */ static int area_move_init(bContext *C, wmOperator *op) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); wmWindow *win = CTX_wm_window(C); ScrEdge *actedge; sAreaMoveData *md; @@ -1568,7 +1572,7 @@ static int area_move_init(bContext *C, wmOperator *op) y = RNA_int_get(op->ptr, "y"); /* setup */ - actedge = screen_geom_find_active_scredge(win, sc, x, y); + actedge = screen_geom_find_active_scredge(win, screen, x, y); if (actedge == NULL) { return 0; } @@ -1586,20 +1590,20 @@ static int area_move_init(bContext *C, wmOperator *op) screen_geom_select_connected_edge(win, actedge); /* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */ - ED_screen_verts_iter(win, sc, v1) + ED_screen_verts_iter(win, screen, v1) { v1->editflag = v1->flag; } bool use_bigger_smaller_snap = false; - area_move_set_limits(win, sc, md->dir, &md->bigger, &md->smaller, &use_bigger_smaller_snap); + area_move_set_limits(win, screen, md->dir, &md->bigger, &md->smaller, &use_bigger_smaller_snap); md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_AREAGRID; return 1; } -static int area_snap_calc_location(const bScreen *sc, +static int area_snap_calc_location(const bScreen *screen, const enum AreaMoveSnapType snap_type, const int delta, const int origval, @@ -1657,13 +1661,13 @@ static int area_snap_calc_location(const bScreen *sc, } } - for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) { + for (const ScrVert *v1 = screen->vertbase.first; v1; v1 = v1->next) { if (!v1->editflag) { continue; } const int v_loc = (&v1->vec.x)[!axis]; - for (const ScrVert *v2 = sc->vertbase.first; v2; v2 = v2->next) { + for (const ScrVert *v2 = screen->vertbase.first; v2; v2 = v2->next) { if (v2->editflag) { continue; } @@ -1702,7 +1706,7 @@ static void area_move_apply_do(const bContext *C, const enum AreaMoveSnapType snap_type) { wmWindow *win = CTX_wm_window(C); - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); short final_loc = -1; bool doredraw = false; @@ -1714,13 +1718,13 @@ static void area_move_apply_do(const bContext *C, final_loc = origval + delta; } else { - final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller); + final_loc = area_snap_calc_location(screen, snap_type, delta, origval, dir, bigger, smaller); } BLI_assert(final_loc != -1); short axis = (dir == 'v') ? 0 : 1; - ED_screen_verts_iter(win, sc, v1) + ED_screen_verts_iter(win, screen, v1) { if (v1->editflag) { short oldval = (&v1->vec.x)[axis]; @@ -1737,7 +1741,7 @@ static void area_move_apply_do(const bContext *C, /* only redraw if we actually moved a screen vert, for AREAGRID */ if (doredraw) { bool redraw_all = false; - ED_screen_areas_iter(win, sc, area) + ED_screen_areas_iter(win, screen, area) { if (area->v1->editflag || area->v2->editflag || area->v3->editflag || area->v4->editflag) { if (ED_area_is_global(area)) { @@ -1750,14 +1754,14 @@ static void area_move_apply_do(const bContext *C, area->global->cur_fixed_height = area->global->size_max; } - sc->do_refresh = true; + screen->do_refresh = true; redraw_all = true; } ED_area_tag_redraw(area); } } if (redraw_all) { - ED_screen_areas_iter(win, sc, area) + ED_screen_areas_iter(win, screen, area) { ED_area_tag_redraw(area); } @@ -1767,7 +1771,7 @@ static void area_move_apply_do(const bContext *C, WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */ /* Update preview thumbnail */ - BKE_icon_changed(sc->id.icon_id); + BKE_icon_changed(screen->id.icon_id); } } @@ -2055,7 +2059,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *area, ScrArea *sb) static int area_split_apply(bContext *C, wmOperator *op) { const wmWindow *win = CTX_wm_window(C); - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; @@ -2063,13 +2067,13 @@ static int area_split_apply(bContext *C, wmOperator *op) fac = RNA_float_get(op->ptr, "factor"); dir = RNA_enum_get(op->ptr, "direction"); - sd->narea = area_split(win, sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ + sd->narea = area_split(win, screen, sd->sarea, dir, fac, 0); /* 0 = no merge */ if (sd->narea) { - sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea); + sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - ED_screen_verts_iter(win, sc, sv) + ED_screen_verts_iter(win, screen, sv) { sv->editflag = 0; } @@ -2089,7 +2093,7 @@ static int area_split_apply(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* Update preview thumbnail */ - BKE_icon_changed(sc->id.icon_id); + BKE_icon_changed(screen->id.icon_id); return 1; } @@ -2137,12 +2141,12 @@ static void area_split_preview_update_cursor(bContext *C, wmOperator *op) static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); sAreaSplitData *sd; int dir; /* no full window splitting allowed */ - BLI_assert(sc->state == SCREENNORMAL); + BLI_assert(screen->state == SCREENNORMAL); PropertyRNA *prop_dir = RNA_struct_find_property(op->ptr, "direction"); PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor"); @@ -2232,7 +2236,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) WM_window_rect_calc(win, &window_rect); actedge = screen_geom_area_map_find_active_scredge( - AREAMAP_FROM_SCREEN(sc), &window_rect, event_co[0], event_co[1]); + AREAMAP_FROM_SCREEN(screen), &window_rect, event_co[0], event_co[1]); if (actedge == NULL) { return OPERATOR_CANCELLED; } @@ -2253,7 +2257,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* do the split */ if (area_split_apply(C, op)) { - area_move_set_limits(win, sc, dir, &sd->bigger, &sd->smaller, NULL); + area_move_set_limits(win, screen, dir, &sd->bigger, &sd->smaller, NULL); /* add temp handler for edge move or cancel */ G.moving |= G_TRANSFORM_WM; @@ -2794,7 +2798,7 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) static void areas_do_frame_follow(bContext *C, bool middle) { - bScreen *scr = CTX_wm_screen(C); + bScreen *screen_ctx = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); for (wmWindow *window = wm->windows.first; window; window = window->next) { @@ -2803,7 +2807,7 @@ static void areas_do_frame_follow(bContext *C, bool middle) for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (ARegion *region = area->regionbase.first; region; region = region->next) { /* do follow here if editor type supports it */ - if ((scr->redraws_flag & TIME_FOLLOW)) { + if ((screen_ctx->redraws_flag & TIME_FOLLOW)) { if ((region->regiontype == RGN_TYPE_WINDOW && ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { @@ -3381,7 +3385,7 @@ static void area_join_cancel(bContext *C, wmOperator *op) /* modal callback while selecting area (space) that will be removed */ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); wmWindow *win = CTX_wm_window(C); sAreaJoinData *jd; @@ -3396,7 +3400,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case MOUSEMOVE: { - ScrArea *area = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->x, event->y); int dir = -1; if (area) { @@ -5037,9 +5041,9 @@ static void SCREEN_OT_new(wmOperatorType *ot) static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); WorkSpace *workspace = CTX_wm_workspace(C); - WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc); + WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen); WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTDELETE, layout); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 58a85fdff25..9c41989fcd4 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1159,7 +1159,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) toggle_paint_cursor(C, 0); } else { - bScreen *sc; + bScreen *screen; Image *ima = NULL; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -1183,9 +1183,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) } if (ima) { - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index c2aa74a695e..5216bf357c4 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -113,7 +113,7 @@ static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) static void graph_panel_cursor_header(const bContext *C, Panel *pa) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); SpaceGraph *sipo = CTX_wm_space_graph(C); Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; @@ -121,7 +121,7 @@ static void graph_panel_cursor_header(const bContext *C, Panel *pa) /* get RNA pointers for use when creating the UI elements */ RNA_id_pointer_create(&scene->id, &sceneptr); - RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); + RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ col = uiLayoutColumn(pa->layout, false); @@ -130,7 +130,7 @@ static void graph_panel_cursor_header(const bContext *C, Panel *pa) static void graph_panel_cursor(const bContext *C, Panel *pa) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); SpaceGraph *sipo = CTX_wm_space_graph(C); Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; @@ -139,7 +139,7 @@ static void graph_panel_cursor(const bContext *C, Panel *pa) /* get RNA pointers for use when creating the UI elements */ RNA_id_pointer_create(&scene->id, &sceneptr); - RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); + RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 0e100080a11..c231314ba59 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -127,10 +127,10 @@ static int compo_get_recalc_flags(const bContext *C) int recalc_flags = 0; for (win = wm->windows.first; win; win = win->next) { - const bScreen *sc = WM_window_get_active_screen(win); + const bScreen *screen = WM_window_get_active_screen(win); ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { if (area->spacetype == SPACE_IMAGE) { SpaceImage *sima = area->spacedata.first; if (sima->image) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 7eb08387bd6..98565c7cc58 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2951,7 +2951,7 @@ void SEQUENCER_OT_view_frame(wmOperatorType *ot) /* view_all operator */ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); #if 0 ARegion *region = CTX_wm_region(C); @@ -2962,7 +2962,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) v2d->cur = v2d->tot; UI_view2d_curRect_validate(v2d); - UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY); + UI_view2d_sync(screen, area, v2d, V2D_LOCK_COPY); #if 0 /* Like zooming on an image view */ diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index acbd4b85ece..09e1dca3152 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -228,13 +228,13 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) bool ED_view3d_context_activate(bContext *C) { - bScreen *sc = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); ARegion *region; /* area can be NULL when called from python */ if (area == NULL || area->spacetype != SPACE_VIEW3D) { - area = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0); + area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0); } if (area == NULL) { diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 71a4c2e0780..ca9845b0b6e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1201,14 +1201,14 @@ finally: static uint free_localview_bit(Main *bmain) { ScrArea *area; - bScreen *sc; + bScreen *screen; ushort local_view_bits = 0; /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (area = sc->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl = area->spacedata.first; for (; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { @@ -1559,13 +1559,13 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot) static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset) { ScrArea *area; - bScreen *sc; + bScreen *screen; ushort local_view_bits = 0; /* Check all areas: which localviews are in use? */ - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - for (area = sc->areabase.first; area; area = area->next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl = area->spacedata.first; for (; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 3464f6d7179..5191869be3a 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -144,7 +144,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - bScreen *sc; + bScreen *screen; Material *ma = (Material *)ptr->owner_id; if (ma->use_nodes && ma->nodetree) { @@ -157,8 +157,8 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, if (ma->texpaintslot) { Image *image = ma->texpaintslot[ma->paint_active_slot].ima; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { - wmWindow *win = ED_screen_window_find(sc, bmain->wm.first); + for (screen = bmain->screens.first; screen; screen = screen->id.next) { + wmWindow *win = ED_screen_window_find(screen, bmain->wm.first); if (win == NULL) { continue; } @@ -170,7 +170,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, } ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 194f5418e75..bc8f6d4e3ae 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -221,7 +221,7 @@ static bool rna_Object_indirect_only_get(Object *ob, bContext *C, ViewLayer *vie return ((base->flag & BASE_INDIRECT_ONLY) != 0); } -static Base *rna_Object_local_view_property_helper(bScreen *sc, +static Base *rna_Object_local_view_property_helper(bScreen *screen, View3D *v3d, ViewLayer *view_layer, Object *ob, @@ -235,7 +235,7 @@ static Base *rna_Object_local_view_property_helper(bScreen *sc, } if (view_layer == NULL) { - win = ED_screen_window_find(sc, G_MAIN->wm.first); + win = ED_screen_window_find(screen, G_MAIN->wm.first); view_layer = WM_window_get_active_view_layer(win); } @@ -265,10 +265,10 @@ static void rna_Object_local_view_set(Object *ob, PointerRNA *v3d_ptr, bool state) { - bScreen *sc = (bScreen *)v3d_ptr->owner_id; + bScreen *screen = (bScreen *)v3d_ptr->owner_id; View3D *v3d = v3d_ptr->data; Scene *scene; - Base *base = rna_Object_local_view_property_helper(sc, v3d, NULL, ob, reports, &scene); + Base *base = rna_Object_local_view_property_helper(screen, v3d, NULL, ob, reports, &scene); if (base == NULL) { return; /* Error reported. */ } @@ -276,7 +276,7 @@ static void rna_Object_local_view_set(Object *ob, SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid); if (local_view_bits_prev != base->local_view_bits) { DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); - ScrArea *area = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true); + ScrArea *area = ED_screen_area_find_with_spacedata(screen, (SpaceLink *)v3d, true); if (area) { ED_area_tag_redraw(area); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 289c5eae869..2e0197bca48 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1679,10 +1679,10 @@ void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA static void rna_Scene_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Scene *sc = (Scene *)ptr->owner_id; + Scene *screen = (Scene *)ptr->owner_id; rna_Scene_glsl_update(bmain, scene, ptr); - WM_main_add_notifier(NC_WORLD | ND_WORLD, &sc->id); + WM_main_add_notifier(NC_WORLD | ND_WORLD, &screen->id); DEG_relations_tag_update(bmain); } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index c832c50bd5d..ce44765fb7b 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -89,8 +89,8 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf # endif if (BKE_scene_camera_switch_update(scene)) { - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - BKE_screen_view3d_scene_sync(sc, scene); + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + BKE_screen_view3d_scene_sync(screen, scene); } } diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 290404291ae..d9e3003c6f3 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -98,8 +98,8 @@ static int rna_region_alignment_get(PointerRNA *ptr) static bool rna_Screen_fullscreen_get(PointerRNA *ptr) { - bScreen *sc = (bScreen *)ptr->data; - return (sc->state == SCREENMAXIMIZED); + bScreen *screen = (bScreen *)ptr->data; + return (screen->state == SCREENMAXIMIZED); } /* UI compatible list: should not be needed, but for now we need to keep EMPTY @@ -137,7 +137,7 @@ static void rna_Area_type_set(PointerRNA *ptr, int value) static void rna_Area_type_update(bContext *C, PointerRNA *ptr) { - bScreen *sc = (bScreen *)ptr->owner_id; + bScreen *screen = (bScreen *)ptr->owner_id; ScrArea *area = (ScrArea *)ptr->data; /* Running update without having called 'set', see: T64049 */ @@ -149,7 +149,7 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) wmWindow *win; /* XXX this call still use context, so we trick it to work in the right context */ for (win = wm->windows.first; win; win = win->next) { - if (sc == WM_window_get_active_screen(win)) { + if (screen == WM_window_get_active_screen(win)) { wmWindow *prevwin = CTX_wm_window(C); ScrArea *prevsa = CTX_wm_area(C); ARegion *prevar = CTX_wm_region(C); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 345d5ecf007..381908f7ada 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -507,12 +507,12 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr)) ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); Object *obedit = OBEDIT_FROM_OBACT(ob); - bScreen *sc; + bScreen *screen; Image *ima = scene->toolsettings->imapaint.canvas; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *slink; for (slink = area->spacedata.first; slink; slink = slink->next) { if (slink->spacetype == SPACE_IMAGE) { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index da8827ee6bd..01ecbb6c118 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -568,12 +568,12 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr) static ScrArea *rna_area_from_space(PointerRNA *ptr) { - bScreen *sc = (bScreen *)ptr->owner_id; + bScreen *screen = (bScreen *)ptr->owner_id; SpaceLink *link = (SpaceLink *)ptr->data; - return BKE_screen_find_area_from_space(sc, link); + return BKE_screen_find_area_from_space(screen, link); } -static void area_region_from_regiondata(bScreen *sc, +static void area_region_from_regiondata(bScreen *screen, void *regiondata, ScrArea **r_area, ARegion **r_region) @@ -584,7 +584,7 @@ static void area_region_from_regiondata(bScreen *sc, *r_area = NULL; *r_region = NULL; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { for (region = area->regionbase.first; region; region = region->next) { if (region->regiondata == regiondata) { *r_area = area; @@ -597,10 +597,10 @@ static void area_region_from_regiondata(bScreen *sc, static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_area, ARegion **r_region) { - bScreen *sc = (bScreen *)ptr->owner_id; + bScreen *screen = (bScreen *)ptr->owner_id; void *regiondata = ptr->data; - area_region_from_regiondata(sc, regiondata, r_area, r_region); + area_region_from_regiondata(screen, regiondata, r_area, r_region); } /* -------------------------------------------------------------------- */ @@ -815,10 +815,10 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { - bScreen *sc = (bScreen *)ptr->owner_id; + bScreen *screen = (bScreen *)ptr->owner_id; View2D *v2d = ®ion->v2d; - UI_view2d_sync(sc, area, v2d, V2D_LOCK_SET); + UI_view2d_sync(screen, area, v2d, V2D_LOCK_SET); } } @@ -853,12 +853,12 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA static void rna_SpaceView3D_use_local_camera_set(PointerRNA *ptr, bool value) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->owner_id; + bScreen *screen = (bScreen *)ptr->owner_id; v3d->scenelock = !value; if (!value) { - Scene *scene = ED_screen_scene_find(sc, G_MAIN->wm.first); + Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); /* NULL if the screen isn't in an active window (happens when setting from Python). * This could be moved to the update function, in that case the scene wont relate to the screen * so keep it working this way. */ @@ -1455,8 +1455,8 @@ static bool rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); - bScreen *sc = (bScreen *)ptr->owner_id; - wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); + bScreen *screen = (bScreen *)ptr->owner_id; + wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); return ED_space_image_show_uvedit(sima, obedit); @@ -1465,8 +1465,8 @@ static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); - bScreen *sc = (bScreen *)ptr->owner_id; - wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); + bScreen *screen = (bScreen *)ptr->owner_id; + wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); ViewLayer *view_layer = WM_window_get_active_view_layer(win); return ED_space_image_check_show_maskedit(sima, view_layer); } @@ -1476,8 +1476,8 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, struct ReportList *UNUSED(reports)) { SpaceImage *sima = (SpaceImage *)(ptr->data); - bScreen *sc = (bScreen *)ptr->owner_id; - wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); + bScreen *screen = (bScreen *)ptr->owner_id; + wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index a8caf905c5f..28fdc5fb60f 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -32,12 +32,12 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C) { - bScreen *sc = (bScreen *)id; + bScreen *screen = (bScreen *)id; ScrArea *area; ARegion *region; - area_region_from_regiondata(sc, rv3d, &area, ®ion); + area_region_from_regiondata(screen, rv3d, &area, ®ion); if (area && region && area->spacetype == SPACE_VIEW3D) { Main *bmain = CTX_data_main(C); @@ -46,7 +46,7 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C) wmWindow *win; for (win = wm->windows.first; win; win = win->next) { - if (WM_window_get_active_screen(win) == sc) { + if (WM_window_get_active_screen(win) == screen) { Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true); @@ -61,8 +61,8 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C) static void rna_SpaceTextEditor_region_location_from_cursor( ID *id, SpaceText *st, int line, int column, int r_pixel_pos[2]) { - bScreen *sc = (bScreen *)id; - ScrArea *area = BKE_screen_find_area_from_space(sc, (SpaceLink *)st); + bScreen *screen = (bScreen *)id; + ScrArea *area = BKE_screen_find_area_from_space(screen, (SpaceLink *)st); if (area) { ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); const int cursor_co[2] = {line, column}; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index bd24ec87620..4118794d5b3 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -794,7 +794,7 @@ const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win, void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win); void WM_window_status_area_tag_redraw(struct wmWindow *win); -struct ScrArea *WM_window_status_area_find(struct wmWindow *win, struct bScreen *sc); +struct ScrArea *WM_window_status_area_find(struct wmWindow *win, struct bScreen *screen); bool WM_window_modal_keymap_status_draw(struct bContext *C, struct wmWindow *win, struct uiLayout *layout); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 6be85539113..90a3234abd5 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -298,8 +298,8 @@ void WM_gizmo_group_remove_by_tool(bContext *C, const bToolRef *tref) { wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(&gzgt->gzmap_params); - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { if (area->runtime.tool == tref) { for (ARegion *region = area->regionbase.first; region; region = region->next) { wmGizmoMap *gzmap = region->gizmo_map; @@ -908,8 +908,8 @@ void WM_gizmomaptype_group_init_runtime(const Main *bmain, } /* now create a gizmo for all existing areas */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { @@ -963,8 +963,8 @@ void WM_gizmomaptype_group_unlink(bContext *C, const wmGizmoGroupType *gzgt) { /* Free instances. */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 61334e4b8d7..7d4c3d40209 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -134,8 +134,8 @@ static void gizmotype_free(wmGizmoType *gzt) static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt) { /* Free instances. */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *area = sc->areabase.first; area; area = area->next) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; for (ARegion *region = lb->first; region; region = region->next) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6a9627decb7..7645ac6fdcf 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -285,12 +285,12 @@ void WM_main_remove_notifier_reference(const void *reference) void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id) { Main *bmain = G_MAIN; - bScreen *sc; + bScreen *screen; - for (sc = bmain->screens.first; sc; sc = sc->id.next) { + for (screen = bmain->screens.first; screen; screen = screen->id.next) { ScrArea *area; - for (area = sc->areabase.first; area; area = area->next) { + for (area = screen->areabase.first; area; area = area->next) { SpaceLink *sl; for (sl = area->spacedata.first; sl; sl = sl->next) { @@ -4892,8 +4892,8 @@ ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) void WM_window_status_area_tag_redraw(wmWindow *win) { - bScreen *sc = WM_window_get_active_screen(win); - ScrArea *area = WM_window_status_area_find(win, sc); + bScreen *screen = WM_window_get_active_screen(win); + ScrArea *area = WM_window_status_area_find(win, screen); if (area != NULL) { ED_area_tag_redraw(area); } -- cgit v1.2.3 From d8b0b8d3db6b2953db33d80390f1789f8700e145 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 3 Apr 2020 16:07:27 +0200 Subject: New Undo: Fix crash in some complex production files. There is no guarantee that depsgraph is ran between two undo steps, so when re-using an existing data-block we should never wipe completly its recalc flags, but instead complement them with new ones from accumulated 'storage' as needed. --- source/blender/blenloader/intern/readfile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6bc920c26f9..739c816ad45 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9418,19 +9418,21 @@ static BHead *read_libblock(FileData *fd, if (do_partial_undo) { /* Even though we re-use the old ID as-is, it does not mean that we are 100% safe from * needing some depsgraph updates for it (it could depend on another ID which address - * did - * not change, but which actual content might have been re-read from the memfile). */ + * did not change, but which actual content might have been re-read from the memfile). + * IMPORTANT: Do not fully overwrite recalc flag here, depsgraph may not have been ran + * yet for previous undo step(s), we do not want to erase flags set by those. + */ if (fd->undo_direction < 0) { /* We are coming from the future (i.e. do an actual undo, and not a redo), we use our * old reused ID's 'accumulated recalc flags since last memfile undo step saving' as * recalc flags. */ - id_old->recalc = id_old->recalc_undo_accumulated; + id_old->recalc |= id_old->recalc_undo_accumulated; } else { /* We are coming from the past (i.e. do a redo), we use the saved 'accumulated recalc * flags since last memfile undo step saving' from the newly read ID as recalc flags. */ - id_old->recalc = id->recalc_undo_accumulated; + id_old->recalc |= id->recalc_undo_accumulated; } /* There is no need to flush the depsgraph's CoWs here, since that ID's data itself did * not change. */ -- cgit v1.2.3 From 49289f31ffd2087b0ecc71f7100c8cb5cff413b5 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Fri, 3 Apr 2020 11:07:58 -0300 Subject: Fix T74495: Shrink/Fatten gives strange results with Individual Origins The island `axismtx` is only necessary in some transform modes. In the case of `Shrink/Fatten`, the calculated `axismtx` brings an undesirable result. This commit rearrange the struct `TransIslandData` in order to calculate and reference only the arrays that will be used for each transform mode. Differential Revision: https://developer.blender.org/D7305 --- .../editors/transform/transform_convert_mesh.c | 135 ++++++++++++--------- 1 file changed, 79 insertions(+), 56 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 22bba9544cd..7528f791130 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -61,8 +61,10 @@ /* when transforming islands */ struct TransIslandData { - float co[3]; - float axismtx[3][3]; + float (*center)[3]; + float (*axismtx)[3][3]; + int island_tot; + int *island_vert_map; }; /* -------------------------------------------------------------------- */ @@ -247,18 +249,19 @@ static void editmesh_set_connectivity_distance(BMesh *bm, } } -static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, - int *r_island_tot, - int **r_island_vert_map, - bool calc_single_islands) +static void editmesh_islands_info_calc(BMEditMesh *em, + const bool calc_single_islands, + const bool calc_island_axismtx, + struct TransIslandData *r_island_data) { BMesh *bm = em->bm; - struct TransIslandData *trans_islands; char htype; char itype; int i; /* group vars */ + float(*center)[3]; + float(*axismtx)[3][3] = NULL; int *groups_array; int(*group_index)[2]; int group_tot; @@ -283,7 +286,11 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, itype = BM_VERTS_OF_FACE; } - trans_islands = MEM_mallocN(sizeof(*trans_islands) * group_tot, __func__); + center = MEM_mallocN(sizeof(*center) * group_tot, __func__); + + if (calc_island_axismtx) { + axismtx = MEM_mallocN(sizeof(*axismtx) * group_tot, __func__); + } vert_map = MEM_mallocN(sizeof(*vert_map) * bm->totvert, __func__); /* we shouldn't need this, but with incorrect selection flushing @@ -311,7 +318,7 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, ese.htype = htype; - /* loop on each face in this group: + /* loop on each face or edge in this group: * - assign r_vert_map * - calculate (co, no) */ @@ -321,12 +328,14 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, ese.ele = ele_array[groups_array[fg_sta + j]]; BM_editselection_center(&ese, tmp_co); - BM_editselection_normal(&ese, tmp_no); - BM_editselection_plane(&ese, tmp_tangent); - add_v3_v3(co, tmp_co); - add_v3_v3(no, tmp_no); - add_v3_v3(tangent, tmp_tangent); + + if (axismtx) { + BM_editselection_normal(&ese, tmp_no); + BM_editselection_plane(&ese, tmp_tangent); + add_v3_v3(no, tmp_no); + add_v3_v3(tangent, tmp_tangent); + } { /* setup vertex map */ @@ -340,18 +349,20 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, } } - mul_v3_v3fl(trans_islands[i].co, co, 1.0f / (float)fg_len); + mul_v3_v3fl(center[i], co, 1.0f / (float)fg_len); - if (createSpaceNormalTangent(trans_islands[i].axismtx, no, tangent)) { - /* pass */ - } - else { - if (normalize_v3(no) != 0.0f) { - axis_dominant_v3_to_m3(trans_islands[i].axismtx, no); - invert_m3(trans_islands[i].axismtx); + if (axismtx) { + if (createSpaceNormalTangent(axismtx[i], no, tangent)) { + /* pass */ } else { - unit_m3(trans_islands[i].axismtx); + if (normalize_v3(no) != 0.0f) { + axis_dominant_v3_to_m3(axismtx[i], no); + invert_m3(axismtx[i]); + } + else { + unit_m3(axismtx[i]); + } } } } @@ -372,22 +383,24 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, } if (group_tot_single != 0) { - trans_islands = MEM_reallocN(trans_islands, - sizeof(*trans_islands) * (group_tot + group_tot_single)); + center = MEM_reallocN(center, sizeof(*center) * (group_tot + group_tot_single)); + if (axismtx) { + axismtx = MEM_reallocN(axismtx, sizeof(*axismtx) * (group_tot + group_tot_single)); + } BM_ITER_MESH_INDEX (v, &viter, bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(v, BM_ELEM_SELECT) && (vert_map[i] == -1)) { - struct TransIslandData *v_island = &trans_islands[group_tot]; vert_map[i] = group_tot; + copy_v3_v3(center[group_tot], v->co); - copy_v3_v3(v_island->co, v->co); - - if (is_zero_v3(v->no) != 0.0f) { - axis_dominant_v3_to_m3(v_island->axismtx, v->no); - invert_m3(v_island->axismtx); - } - else { - unit_m3(v_island->axismtx); + if (axismtx) { + if (is_zero_v3(v->no) != 0.0f) { + axis_dominant_v3_to_m3(axismtx[group_tot], v->no); + invert_m3(axismtx[group_tot]); + } + else { + unit_m3(axismtx[group_tot]); + } } group_tot += 1; @@ -396,10 +409,10 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, } } - *r_island_tot = group_tot; - *r_island_vert_map = vert_map; - - return trans_islands; + r_island_data->axismtx = axismtx; + r_island_data->center = center; + r_island_data->island_tot = group_tot; + r_island_data->island_vert_map = vert_map; } static bool is_in_quadrant_v3(const float co[3], const int quadrant[3], const float epsilon) @@ -567,7 +580,8 @@ static void VertsToTransData(TransInfo *t, BMEditMesh *em, BMVert *eve, float *bweight, - struct TransIslandData *v_island, + const struct TransIslandData *island_data, + const int island_index, const bool no_island_center) { float *no, _no[3]; @@ -589,14 +603,17 @@ static void VertsToTransData(TransInfo *t, no = eve->no; } - if (v_island) { + if (island_index != -1) { if (no_island_center) { copy_v3_v3(td->center, td->loc); } else { - copy_v3_v3(td->center, v_island->co); + copy_v3_v3(td->center, island_data->center[island_index]); } - copy_m3_m3(td->axismtx, v_island->axismtx); + } + + if ((island_index != -1) && island_data->axismtx) { + copy_m3_m3(td->axismtx, island_data->axismtx[island_index]); } else if (t->around == V3D_AROUND_LOCAL_ORIGINS) { copy_v3_v3(td->center, td->loc); @@ -654,9 +671,7 @@ void createTransEditVerts(TransInfo *t) const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0; int cd_vert_bweight_offset = -1; - struct TransIslandData *island_info = NULL; - int island_info_tot; - int *island_vert_map = NULL; + struct TransIslandData island_data = {NULL}; /* Snap rotation along normal needs a common axis for whole islands, * otherwise one get random crazy results, see T59104. @@ -758,8 +773,11 @@ void createTransEditVerts(TransInfo *t) (t->around == V3D_AROUND_LOCAL_ORIGINS) && (em->selectmode & SCE_SELECT_VERTEX)); - island_info = editmesh_islands_info_calc( - em, &island_info_tot, &island_vert_map, calc_single_islands); + /* The island axismtx is only necessary in some modes. + * TODO(Germano): Extend the list to exclude other modes. */ + const bool calc_island_axismtx = !ELEM(t->mode, TFM_SHRINKFATTEN); + + editmesh_islands_info_calc(em, calc_single_islands, calc_island_axismtx, &island_data); } /* detect CrazySpace [tm] */ @@ -809,21 +827,19 @@ void createTransEditVerts(TransInfo *t) continue; } if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - struct TransIslandData *v_island = NULL; float *bweight = (cd_vert_bweight_offset != -1) ? BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : NULL; - if (island_info) { + int island_index = -1; + if (island_data.island_vert_map) { const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a; - v_island = (island_vert_map[connected_index] != -1) ? - &island_info[island_vert_map[connected_index]] : - NULL; + island_index = island_data.island_vert_map[connected_index]; } /* Do not use the island center in case we are using islands * only to get axis for snap/rotate to normal... */ - VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate); + VertsToTransData(t, tob, tx, em, eve, bweight, &island_data, island_index, is_snap_rotate); if (tx) { tx++; } @@ -889,9 +905,16 @@ void createTransEditVerts(TransInfo *t) } } - if (island_info) { - MEM_freeN(island_info); - MEM_freeN(island_vert_map); + if (island_data.center) { + MEM_freeN(island_data.center); + } + + if (island_data.axismtx) { + MEM_freeN(island_data.axismtx); + } + + if (island_data.island_vert_map) { + MEM_freeN(island_data.island_vert_map); } cleanup: -- cgit v1.2.3 From 33ab613655fdba08948a79f0ffec28720add7dfb Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 3 Apr 2020 08:29:09 -0600 Subject: Cleanup: Fix build warning with MSVC SubdivCCG was unknown when compiling gpuinit_exit.c --- source/blender/gpu/GPU_buffers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index b02f6ed09b3..22086b8a9d6 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -42,6 +42,7 @@ struct MPoly; struct MVert; struct Mesh; struct PBVH; +struct SubdivCCG; /* Buffers for drawing from PBVH grids. */ typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers; -- cgit v1.2.3 From 3208454aa81f57d40f51ffc47e026d2a00c4f4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Apr 2020 13:07:36 +0200 Subject: Cleanup: Animation, move AnimData API to `anim_data.c`/`BKE_anim_data.h` The `BKE_animsys.h` and `anim_sys.c` files already had a an "AnimData API" section. The code in that section has now been split off, and placed into `BKE_anim_data.h` and `anim_data.c`. All files that used to include `BKE_animsys.h` have been adjusted to only include the animation headers they need (sometimes none). No functional changes. --- source/blender/blenkernel/BKE_anim_data.h | 95 ++ source/blender/blenkernel/BKE_animsys.h | 52 - source/blender/blenkernel/CMakeLists.txt | 2 + source/blender/blenkernel/intern/anim_data.c | 1435 ++++++++++++++++++++ source/blender/blenkernel/intern/anim_sys.c | 1377 +------------------ source/blender/blenkernel/intern/armature.c | 1 - source/blender/blenkernel/intern/cachefile.c | 1 - source/blender/blenkernel/intern/camera.c | 1 - source/blender/blenkernel/intern/curve.c | 1 - source/blender/blenkernel/intern/dynamicpaint.c | 1 - source/blender/blenkernel/intern/fcurve.c | 1 + source/blender/blenkernel/intern/hair.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/key.c | 1 - source/blender/blenkernel/intern/lattice.c | 1 - source/blender/blenkernel/intern/lib_id.c | 2 +- source/blender/blenkernel/intern/lib_id_delete.c | 2 +- source/blender/blenkernel/intern/lib_query.c | 2 +- source/blender/blenkernel/intern/light.c | 1 - source/blender/blenkernel/intern/lightprobe.c | 1 - source/blender/blenkernel/intern/linestyle.c | 1 - source/blender/blenkernel/intern/material.c | 1 - source/blender/blenkernel/intern/mball.c | 1 - source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/movieclip.c | 1 - source/blender/blenkernel/intern/node.c | 1 + source/blender/blenkernel/intern/object.c | 1 + source/blender/blenkernel/intern/object_dupli.c | 1 - source/blender/blenkernel/intern/object_update.c | 1 - source/blender/blenkernel/intern/paint.c | 1 - source/blender/blenkernel/intern/particle.c | 2 - source/blender/blenkernel/intern/pointcloud.c | 2 +- source/blender/blenkernel/intern/scene.c | 1 + source/blender/blenkernel/intern/seqprefetch.c | 1 + source/blender/blenkernel/intern/sequencer.c | 1 + source/blender/blenkernel/intern/speaker.c | 1 - source/blender/blenkernel/intern/texture.c | 1 - source/blender/blenkernel/intern/volume.cc | 2 +- source/blender/blenkernel/intern/world.c | 1 - source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/versioning_270.c | 1 + .../depsgraph/intern/builder/deg_builder.cc | 4 - .../depsgraph/intern/builder/deg_builder_nodes.cc | 1 + .../intern/builder/deg_builder_relations.cc | 2 +- source/blender/depsgraph/intern/depsgraph_tag.cc | 2 +- .../intern/eval/deg_eval_copy_on_write.cc | 1 + .../blender/depsgraph/intern/node/deg_node_id.cc | 1 - .../editors/animation/anim_channels_defines.c | 1 + .../blender/editors/animation/anim_channels_edit.c | 2 +- source/blender/editors/animation/anim_deps.c | 2 +- source/blender/editors/animation/anim_filter.c | 2 +- .../blender/editors/animation/anim_motion_paths.c | 2 +- source/blender/editors/animation/drivers.c | 1 + source/blender/editors/animation/fmodifier_ui.c | 1 - source/blender/editors/animation/keyframing.c | 1 + .../blender/editors/armature/armature_relations.c | 1 + source/blender/editors/armature/pose_utils.c | 2 +- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/curve/editcurve_undo.c | 2 +- source/blender/editors/gpencil/gpencil_data.c | 1 + source/blender/editors/interface/interface.c | 1 - .../blender/editors/interface/interface_layout.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/render/render_shading.c | 1 + source/blender/editors/space_action/action_data.c | 1 - source/blender/editors/space_graph/graph_buttons.c | 2 +- source/blender/editors/space_nla/nla_channels.c | 2 +- .../editors/space_node/node_relationships.c | 2 +- .../editors/space_outliner/outliner_tools.c | 1 + .../blender/editors/transform/transform_generics.c | 2 +- .../blender/io/alembic/intern/abc_writer_mesh.cc | 2 +- source/blender/io/collada/AnimationExporter.h | 1 - source/blender/io/collada/SceneExporter.h | 1 - .../io/usd/intern/abstract_hierarchy_iterator.cc | 2 +- source/blender/makesrna/intern/rna_ID.c | 2 +- source/blender/makesrna/intern/rna_access.c | 2 +- source/blender/makesrna/intern/rna_animation.c | 1 + source/blender/makesrna/intern/rna_fcurve.c | 2 +- source/blender/makesrna/intern/rna_fcurve_api.c | 1 - source/blender/makesrna/intern/rna_nla.c | 2 +- source/blender/makesrna/intern/rna_scene_api.c | 1 - source/blender/makesrna/intern/rna_sequencer.c | 1 + source/blender/makesrna/intern/rna_space.c | 2 +- source/blender/makesrna/intern/rna_tracking.c | 1 + source/blender/python/intern/bpy_rna_anim.c | 2 +- source/blender/render/intern/source/pipeline.c | 1 + .../blender/render/intern/source/render_texture.c | 1 - 89 files changed, 1587 insertions(+), 1496 deletions(-) create mode 100644 source/blender/blenkernel/BKE_anim_data.h create mode 100644 source/blender/blenkernel/intern/anim_data.c diff --git a/source/blender/blenkernel/BKE_anim_data.h b/source/blender/blenkernel/BKE_anim_data.h new file mode 100644 index 00000000000..071254be783 --- /dev/null +++ b/source/blender/blenkernel/BKE_anim_data.h @@ -0,0 +1,95 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung + * All rights reserved. + */ + +#ifndef __BKE_ANIM_DATA_H__ +#define __BKE_ANIM_DATA_H__ + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "BLI_sys_types.h" /* for bool */ + +struct AnimData; +struct ID; +struct Main; +struct ReportList; +struct bAction; + +/* ************************************* */ +/* AnimData API */ + +/* Check if the given ID-block can have AnimData */ +bool id_type_can_have_animdata(const short id_type); +bool id_can_have_animdata(const struct ID *id); + +/* Get AnimData from the given ID-block */ +struct AnimData *BKE_animdata_from_id(struct ID *id); + +/* Add AnimData to the given ID-block */ +struct AnimData *BKE_animdata_add_id(struct ID *id); + +/* Set active action used by AnimData from the given ID-block */ +bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act); + +/* Free AnimData */ +void BKE_animdata_free(struct ID *id, const bool do_id_user); + +/* Return true if the ID-block has non-empty AnimData. */ +bool BKE_animdata_id_is_animated(const struct ID *id); + +/* Copy AnimData */ +struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag); + +/* Copy AnimData */ +bool BKE_animdata_copy_id(struct Main *bmain, + struct ID *id_to, + struct ID *id_from, + const int flag); + +/* Copy AnimData Actions */ +void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool set_newid); + +/* Merge copies of data from source AnimData block */ +typedef enum eAnimData_MergeCopy_Modes { + /* Keep destination action */ + ADT_MERGECOPY_KEEP_DST = 0, + + /* Use src action (make a new copy) */ + ADT_MERGECOPY_SRC_COPY = 1, + + /* Use src action (but just reference the existing version) */ + ADT_MERGECOPY_SRC_REF = 2, +} eAnimData_MergeCopy_Modes; + +void BKE_animdata_merge_copy(struct Main *bmain, + struct ID *dst_id, + struct ID *src_id, + eAnimData_MergeCopy_Modes action_mode, + bool fix_drivers); + +#ifdef __cplusplus +} +#endif + +#endif /* __BKE_ANIM_DATA_H__*/ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 3debe94c264..a8915c178d4 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -48,58 +48,6 @@ struct bAction; struct bActionGroup; struct bContext; -/* ************************************* */ -/* AnimData API */ - -/* Check if the given ID-block can have AnimData */ -bool id_type_can_have_animdata(const short id_type); -bool id_can_have_animdata(const struct ID *id); - -/* Get AnimData from the given ID-block */ -struct AnimData *BKE_animdata_from_id(struct ID *id); - -/* Add AnimData to the given ID-block */ -struct AnimData *BKE_animdata_add_id(struct ID *id); - -/* Set active action used by AnimData from the given ID-block */ -bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act); - -/* Free AnimData */ -void BKE_animdata_free(struct ID *id, const bool do_id_user); - -/* Return true if the ID-block has non-empty AnimData. */ -bool BKE_animdata_id_is_animated(const struct ID *id); - -/* Copy AnimData */ -struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag); - -/* Copy AnimData */ -bool BKE_animdata_copy_id(struct Main *bmain, - struct ID *id_to, - struct ID *id_from, - const int flag); - -/* Copy AnimData Actions */ -void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id, const bool set_newid); - -/* Merge copies of data from source AnimData block */ -typedef enum eAnimData_MergeCopy_Modes { - /* Keep destination action */ - ADT_MERGECOPY_KEEP_DST = 0, - - /* Use src action (make a new copy) */ - ADT_MERGECOPY_SRC_COPY = 1, - - /* Use src action (but just reference the existing version) */ - ADT_MERGECOPY_SRC_REF = 2, -} eAnimData_MergeCopy_Modes; - -void BKE_animdata_merge_copy(struct Main *bmain, - struct ID *dst_id, - struct ID *src_id, - eAnimData_MergeCopy_Modes action_mode, - bool fix_drivers); - /* ************************************* */ /* KeyingSets API */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index ba4339f56ac..6e612df33d5 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -70,6 +70,7 @@ set(SRC intern/DerivedMesh.c intern/action.c intern/addon.c + intern/anim_data.c intern/anim_path.c intern/anim_sys.c intern/anim_visualization.c @@ -251,6 +252,7 @@ set(SRC BKE_DerivedMesh.h BKE_action.h BKE_addon.h + BKE_anim_data.h BKE_anim_path.h BKE_anim_visualization.h BKE_animsys.h diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c new file mode 100644 index 00000000000..cd56796c3cf --- /dev/null +++ b/source/blender/blenkernel/intern/anim_data.c @@ -0,0 +1,1435 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung + * All rights reserved. + */ + +/** \file + * \ingroup bke + */ +#include "MEM_guardedalloc.h" + +#include + +#include "BKE_action.h" +#include "BKE_anim_data.h" +#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_lib_id.h" +#include "BKE_main.h" +#include "BKE_nla.h" +#include "BKE_node.h" +#include "BKE_report.h" + +#include "DNA_ID.h" +#include "DNA_anim_types.h" +#include "DNA_light_types.h" +#include "DNA_node_types.h" +#include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" +#include "DNA_world_types.h" + +#include "BLI_alloca.h" +#include "BLI_dynstr.h" +#include "BLI_listbase.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "DEG_depsgraph.h" + +#include "RNA_access.h" + +#include "CLG_log.h" + +static CLG_LogRef LOG = {"bke.anim_sys"}; + +/* ***************************************** */ +/* AnimData API */ + +/* Getter/Setter -------------------------------------------- */ + +/* Check if ID can have AnimData */ +bool id_type_can_have_animdata(const short id_type) +{ + /* Only some ID-blocks have this info for now */ + /* TODO: finish adding this for the other blocktypes */ + switch (id_type) { + /* has AnimData */ + case ID_OB: + case ID_ME: + case ID_MB: + case ID_CU: + case ID_AR: + case ID_LT: + case ID_KE: + case ID_PA: + case ID_MA: + case ID_TE: + case ID_NT: + case ID_LA: + case ID_CA: + case ID_WO: + case ID_LS: + case ID_LP: + case ID_SPK: + case ID_SCE: + case ID_MC: + case ID_MSK: + case ID_GD: + case ID_CF: + case ID_HA: + case ID_PT: + case ID_VO: + return true; + + /* no AnimData */ + default: + return false; + } +} + +bool id_can_have_animdata(const ID *id) +{ + /* sanity check */ + if (id == NULL) { + return false; + } + + return id_type_can_have_animdata(GS(id->name)); +} + +/* Get AnimData from the given ID-block. In order for this to work, we assume that + * the AnimData pointer is stored immediately after the given ID-block in the struct, + * as per IdAdtTemplate. + */ +AnimData *BKE_animdata_from_id(ID *id) +{ + /* only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate, and extract the + * AnimData that way + */ + if (id_can_have_animdata(id)) { + IdAdtTemplate *iat = (IdAdtTemplate *)id; + return iat->adt; + } + else { + return NULL; + } +} + +/* Add AnimData to the given ID-block. In order for this to work, we assume that + * the AnimData pointer is stored immediately after the given ID-block in the struct, + * as per IdAdtTemplate. Also note that + */ +AnimData *BKE_animdata_add_id(ID *id) +{ + /* Only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate, and add the AnimData + * to it using the template + */ + if (id_can_have_animdata(id)) { + IdAdtTemplate *iat = (IdAdtTemplate *)id; + + /* check if there's already AnimData, in which case, don't add */ + if (iat->adt == NULL) { + AnimData *adt; + + /* add animdata */ + adt = iat->adt = MEM_callocN(sizeof(AnimData), "AnimData"); + + /* set default settings */ + adt->act_influence = 1.0f; + } + + return iat->adt; + } + else { + return NULL; + } +} + +/* Action Setter --------------------------------------- */ + +/** + * Called when user tries to change the active action of an AnimData block + * (via RNA, Outliner, etc.) + */ +bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) +{ + AnimData *adt = BKE_animdata_from_id(id); + bool ok = false; + + /* animdata validity check */ + if (adt == NULL) { + BKE_report(reports, RPT_WARNING, "No AnimData to set action on"); + return ok; + } + + /* active action is only editable when it is not a tweaking strip + * see rna_AnimData_action_editable() in rna_animation.c + */ + if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) { + /* cannot remove, otherwise things turn to custard */ + BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA"); + return ok; + } + + /* manage usercount for current action */ + if (adt->action) { + id_us_min((ID *)adt->action); + } + + /* assume that AnimData's action can in fact be edited... */ + if (act) { + /* action must have same type as owner */ + if (ELEM(act->idroot, 0, GS(id->name))) { + /* can set */ + adt->action = act; + id_us_plus((ID *)adt->action); + ok = true; + } + else { + /* cannot set */ + BKE_reportf( + reports, + RPT_ERROR, + "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths " + "for this purpose", + act->id.name + 2, + id->name); + /* ok = false; */ + } + } + else { + /* just clearing the action... */ + adt->action = NULL; + ok = true; + } + + return ok; +} + +/* Freeing -------------------------------------------- */ + +/* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ +void BKE_animdata_free(ID *id, const bool do_id_user) +{ + /* Only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate + */ + if (id_can_have_animdata(id)) { + IdAdtTemplate *iat = (IdAdtTemplate *)id; + AnimData *adt = iat->adt; + + /* check if there's any AnimData to start with */ + if (adt) { + if (do_id_user) { + /* unlink action (don't free, as it's in its own list) */ + if (adt->action) { + id_us_min(&adt->action->id); + } + /* same goes for the temporarily displaced action */ + if (adt->tmpact) { + id_us_min(&adt->tmpact->id); + } + } + + /* free nla data */ + BKE_nla_tracks_free(&adt->nla_tracks, do_id_user); + + /* free drivers - stored as a list of F-Curves */ + free_fcurves(&adt->drivers); + + /* free driver array cache */ + MEM_SAFE_FREE(adt->driver_array); + + /* free overrides */ + /* TODO... */ + + /* free animdata now */ + MEM_freeN(adt); + iat->adt = NULL; + } + } +} + +bool BKE_animdata_id_is_animated(const struct ID *id) +{ + if (id == NULL) { + return false; + } + + const AnimData *adt = BKE_animdata_from_id((ID *)id); + if (adt == NULL) { + return false; + } + + if (adt->action != NULL && !BLI_listbase_is_empty(&adt->action->curves)) { + return true; + } + + return !BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->nla_tracks) || + !BLI_listbase_is_empty(&adt->overrides); +} + +/* Copying -------------------------------------------- */ + +/** + * Make a copy of the given AnimData - to be used when copying data-blocks. + * \param flag: Control ID pointers management, + * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h + * \return The copied animdata. + */ +AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag) +{ + AnimData *dadt; + + const bool do_action = (flag & LIB_ID_COPY_ACTIONS) != 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0; + const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0; + + /* sanity check before duplicating struct */ + if (adt == NULL) { + return NULL; + } + dadt = MEM_dupallocN(adt); + + /* make a copy of action - at worst, user has to delete copies... */ + if (do_action) { + BLI_assert(bmain != NULL); + BLI_assert(dadt->action == NULL || dadt->action != dadt->tmpact); + BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, flag); + BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, flag); + } + else if (do_id_user) { + id_us_plus((ID *)dadt->action); + id_us_plus((ID *)dadt->tmpact); + } + + /* duplicate NLA data */ + BKE_nla_tracks_copy(bmain, &dadt->nla_tracks, &adt->nla_tracks, flag); + + /* duplicate drivers (F-Curves) */ + copy_fcurves(&dadt->drivers, &adt->drivers); + dadt->driver_array = NULL; + + /* don't copy overrides */ + BLI_listbase_clear(&dadt->overrides); + + /* return */ + return dadt; +} + +/** + * \param flag: Control ID pointers management, + * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h + * \return true is successfully copied. + */ +bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag) +{ + AnimData *adt; + + if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) { + return false; + } + + BKE_animdata_free(id_to, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0); + + adt = BKE_animdata_from_id(id_from); + if (adt) { + IdAdtTemplate *iat = (IdAdtTemplate *)id_to; + iat->adt = BKE_animdata_copy(bmain, adt, flag); + } + + return true; +} + +void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid) +{ + AnimData *adt = BKE_animdata_from_id(id); + if (adt) { + if (adt->action) { + id_us_min((ID *)adt->action); + adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_action_copy(bmain, adt->action)) : + BKE_action_copy(bmain, adt->action); + } + if (adt->tmpact) { + id_us_min((ID *)adt->tmpact); + adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_action_copy(bmain, adt->tmpact)) : + BKE_action_copy(bmain, adt->tmpact); + } + } + bNodeTree *ntree = ntreeFromID(id); + if (ntree) { + BKE_animdata_copy_id_action(bmain, &ntree->id, set_newid); + } +} + +/* Merge copies of the data from the src AnimData into the destination AnimData */ +void BKE_animdata_merge_copy( + Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers) +{ + AnimData *src = BKE_animdata_from_id(src_id); + AnimData *dst = BKE_animdata_from_id(dst_id); + + /* sanity checks */ + if (ELEM(NULL, dst, src)) { + return; + } + + // TODO: we must unset all "tweakmode" flags + if ((src->flag & ADT_NLA_EDIT_ON) || (dst->flag & ADT_NLA_EDIT_ON)) { + CLOG_ERROR( + &LOG, + "Merging AnimData blocks while editing NLA is dangerous as it may cause data corruption"); + return; + } + + /* handle actions... */ + if (action_mode == ADT_MERGECOPY_SRC_COPY) { + /* make a copy of the actions */ + dst->action = BKE_action_copy(bmain, src->action); + dst->tmpact = BKE_action_copy(bmain, src->tmpact); + } + else if (action_mode == ADT_MERGECOPY_SRC_REF) { + /* make a reference to it */ + dst->action = src->action; + id_us_plus((ID *)dst->action); + + dst->tmpact = src->tmpact; + id_us_plus((ID *)dst->tmpact); + } + + /* duplicate NLA data */ + if (src->nla_tracks.first) { + ListBase tracks = {NULL, NULL}; + + BKE_nla_tracks_copy(bmain, &tracks, &src->nla_tracks, 0); + BLI_movelisttolist(&dst->nla_tracks, &tracks); + } + + /* duplicate drivers (F-Curves) */ + if (src->drivers.first) { + ListBase drivers = {NULL, NULL}; + + copy_fcurves(&drivers, &src->drivers); + + /* Fix up all driver targets using the old target id + * - This assumes that the src ID is being merged into the dst ID + */ + if (fix_drivers) { + FCurve *fcu; + + for (fcu = drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; + DriverVar *dvar; + + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { + DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { + if (dtar->id == src_id) { + dtar->id = dst_id; + } + } + DRIVER_TARGETS_LOOPER_END; + } + } + } + + BLI_movelisttolist(&dst->drivers, &drivers); + } +} + +/* Sub-ID Regrouping ------------------------------------------- */ + +/** + * Helper heuristic for determining if a path is compatible with the basepath + * + * \param path: Full RNA-path from some data (usually an F-Curve) to compare + * \param basepath: Shorter path fragment to look for + * \return Whether there is a match + */ +static bool animpath_matches_basepath(const char path[], const char basepath[]) +{ + /* we need start of path to be basepath */ + return (path && basepath) && STRPREFIX(path, basepath); +} + +/* Move F-Curves in src action to dst action, setting up all the necessary groups + * for this to happen, but only if the F-Curves being moved have the appropriate + * "base path". + * - This is used when data moves from one data-block to another, causing the + * F-Curves to need to be moved over too + */ +void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[]) +{ + FCurve *fcu, *fcn = NULL; + + /* sanity checks */ + if (ELEM(NULL, srcAct, dstAct, basepath)) { + if (G.debug & G_DEBUG) { + CLOG_ERROR(&LOG, + "srcAct: %p, dstAct: %p, basepath: %p has insufficient info to work with", + (void *)srcAct, + (void *)dstAct, + (void *)basepath); + } + return; + } + + /* clear 'temp' flags on all groups in src, as we'll be needing them later + * to identify groups that we've managed to empty out here + */ + action_groups_clear_tempflags(srcAct); + + /* iterate over all src F-Curves, moving over the ones that need to be moved */ + for (fcu = srcAct->curves.first; fcu; fcu = fcn) { + /* store next pointer in case we move stuff */ + fcn = fcu->next; + + /* should F-Curve be moved over? + * - we only need the start of the path to match basepath + */ + if (animpath_matches_basepath(fcu->rna_path, basepath)) { + bActionGroup *agrp = NULL; + + /* if grouped... */ + if (fcu->grp) { + /* make sure there will be a matching group on the other side for the migrants */ + agrp = BKE_action_group_find_name(dstAct, fcu->grp->name); + + if (agrp == NULL) { + /* add a new one with a similar name (usually will be the same though) */ + agrp = action_groups_add_new(dstAct, fcu->grp->name); + } + + /* old groups should be tagged with 'temp' flags so they can be removed later + * if we remove everything from them + */ + fcu->grp->flag |= AGRP_TEMP; + } + + /* perform the migration now */ + action_groups_remove_channel(srcAct, fcu); + + if (agrp) { + action_groups_add_channel(dstAct, agrp, fcu); + } + else { + BLI_addtail(&dstAct->curves, fcu); + } + } + } + + /* cleanup groups (if present) */ + if (srcAct->groups.first) { + bActionGroup *agrp, *grp = NULL; + + for (agrp = srcAct->groups.first; agrp; agrp = grp) { + grp = agrp->next; + + /* only tagged groups need to be considered - clearing these tags or removing them */ + if (agrp->flag & AGRP_TEMP) { + /* if group is empty and tagged, then we can remove as this operation + * moved out all the channels that were formerly here + */ + if (BLI_listbase_is_empty(&agrp->channels)) { + BLI_freelinkN(&srcAct->groups, agrp); + } + else { + agrp->flag &= ~AGRP_TEMP; + } + } + } + } +} + +/* Transfer the animation data from srcID to dstID where the srcID + * animation data is based off "basepath", creating new AnimData and + * associated data as necessary + */ +void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths) +{ + AnimData *srcAdt = NULL, *dstAdt = NULL; + LinkData *ld; + + /* sanity checks */ + if (ELEM(NULL, srcID, dstID)) { + if (G.debug & G_DEBUG) { + CLOG_ERROR(&LOG, "no source or destination ID to separate AnimData with"); + } + return; + } + + /* get animdata from src, and create for destination (if needed) */ + srcAdt = BKE_animdata_from_id(srcID); + dstAdt = BKE_animdata_add_id(dstID); + + if (ELEM(NULL, srcAdt, dstAdt)) { + if (G.debug & G_DEBUG) { + CLOG_ERROR(&LOG, "no AnimData for this pair of ID's"); + } + return; + } + + /* active action */ + if (srcAdt->action) { + /* Set up an action if necessary, + * and name it in a similar way so that it can be easily found again. */ + if (dstAdt->action == NULL) { + dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2); + } + else if (dstAdt->action == srcAdt->action) { + CLOG_WARN(&LOG, + "Argh! Source and Destination share animation! " + "('%s' and '%s' both use '%s') Making new empty action", + srcID->name, + dstID->name, + srcAdt->action->id.name); + + /* TODO: review this... */ + id_us_min(&dstAdt->action->id); + dstAdt->action = BKE_action_add(bmain, dstAdt->action->id.name + 2); + } + + /* loop over base paths, trying to fix for each one... */ + for (ld = basepaths->first; ld; ld = ld->next) { + const char *basepath = (const char *)ld->data; + action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath); + } + } + + /* drivers */ + if (srcAdt->drivers.first) { + FCurve *fcu, *fcn = NULL; + + /* check each driver against all the base paths to see if any should go */ + for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) { + fcn = fcu->next; + + /* try each basepath in turn, but stop on the first one which works */ + for (ld = basepaths->first; ld; ld = ld->next) { + const char *basepath = (const char *)ld->data; + + if (animpath_matches_basepath(fcu->rna_path, basepath)) { + /* just need to change lists */ + BLI_remlink(&srcAdt->drivers, fcu); + BLI_addtail(&dstAdt->drivers, fcu); + + /* TODO: add depsgraph flushing calls? */ + + /* can stop now, as moved already */ + break; + } + } + } + } +} + +/** + * Temporary wrapper for driver operators for buttons to make it easier to create + * such drivers by rerouting all paths through the active object instead so that + * they will get picked up by the dependency system. + * + * \param C: Context pointer - for getting active data + * \param[in,out] ptr: RNA pointer for property's data-block. + * May be modified as result of path remapping. + * \param prop: RNA definition of property to add for + * \return MEM_alloc'd string representing the path to the property from the given #PointerRNA + */ +char *BKE_animdata_driver_path_hack(bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + char *base_path) +{ + ID *id = ptr->owner_id; + ScrArea *area = CTX_wm_area(C); + + /* get standard path which may be extended */ + char *basepath = base_path ? base_path : RNA_path_from_ID_to_property(ptr, prop); + char *path = basepath; /* in case no remapping is needed */ + + /* Remapping will only be performed in the Properties Editor, as only this + * restricts the subspace of options to the 'active' data (a manageable state) + */ + /* TODO: watch out for pinned context? */ + if ((area) && (area->spacetype == SPACE_PROPERTIES)) { + Object *ob = CTX_data_active_object(C); + + if (ob && id) { + /* TODO: after material textures were removed, this function serves + * no purpose anymore, but could be used again so was not removed. */ + + /* fix RNA pointer, as we've now changed the ID root by changing the paths */ + if (basepath != path) { + /* rebase provided pointer so that it starts from object... */ + RNA_pointer_create(&ob->id, ptr->type, ptr->data, ptr); + } + } + } + + /* the path should now have been corrected for use */ + return path; +} + +/* Path Validation -------------------------------------------- */ + +/* Check if a given RNA Path is valid, by tracing it from the given ID, + * and seeing if we can resolve it. */ +static bool check_rna_path_is_valid(ID *owner_id, const char *path) +{ + PointerRNA id_ptr, ptr; + PropertyRNA *prop = NULL; + + /* make initial RNA pointer to start resolving from */ + RNA_id_pointer_create(owner_id, &id_ptr); + + /* try to resolve */ + return RNA_path_resolve_property(&id_ptr, path, &ptr, &prop); +} + +/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate + * NOTE: we assume that oldName and newName have [" "] padding around them + */ +static char *rna_path_rename_fix(ID *owner_id, + const char *prefix, + const char *oldName, + const char *newName, + char *oldpath, + bool verify_paths) +{ + char *prefixPtr = strstr(oldpath, prefix); + char *oldNamePtr = strstr(oldpath, oldName); + int prefixLen = strlen(prefix); + int oldNameLen = strlen(oldName); + + /* only start fixing the path if the prefix and oldName feature in the path, + * and prefix occurs immediately before oldName + */ + if ((prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr)) { + /* if we haven't aren't able to resolve the path now, try again after fixing it */ + if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) { + DynStr *ds = BLI_dynstr_new(); + const char *postfixPtr = oldNamePtr + oldNameLen; + char *newPath = NULL; + + /* add the part of the string that goes up to the start of the prefix */ + if (prefixPtr > oldpath) { + BLI_dynstr_nappend(ds, oldpath, prefixPtr - oldpath); + } + + /* add the prefix */ + BLI_dynstr_append(ds, prefix); + + /* add the new name (complete with brackets) */ + BLI_dynstr_append(ds, newName); + + /* add the postfix */ + BLI_dynstr_append(ds, postfixPtr); + + /* create new path, and cleanup old data */ + newPath = BLI_dynstr_get_cstring(ds); + BLI_dynstr_free(ds); + + /* check if the new path will solve our problems */ + /* TODO: will need to check whether this step really helps in practice */ + if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { + /* free the old path, and return the new one, since we've solved the issues */ + MEM_freeN(oldpath); + return newPath; + } + else { + /* still couldn't resolve the path... so, might as well just leave it alone */ + MEM_freeN(newPath); + } + } + } + + /* the old path doesn't need to be changed */ + return oldpath; +} + +/* Check RNA-Paths for a list of F-Curves */ +static bool fcurves_path_rename_fix(ID *owner_id, + const char *prefix, + const char *oldName, + const char *newName, + const char *oldKey, + const char *newKey, + ListBase *curves, + bool verify_paths) +{ + FCurve *fcu; + bool is_changed = false; + /* We need to check every curve. */ + for (fcu = curves->first; fcu; fcu = fcu->next) { + if (fcu->rna_path == NULL) { + continue; + } + const char *old_path = fcu->rna_path; + /* Firstly, handle the F-Curve's own path. */ + fcu->rna_path = rna_path_rename_fix( + owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); + /* if path changed and the F-Curve is grouped, check if its group also needs renaming + * (i.e. F-Curve is first of a bone's F-Curves; + * hence renaming this should also trigger rename) */ + if (fcu->rna_path != old_path) { + bActionGroup *agrp = fcu->grp; + is_changed = true; + if ((agrp != NULL) && STREQ(oldName, agrp->name)) { + BLI_strncpy(agrp->name, newName, sizeof(agrp->name)); + } + } + } + return is_changed; +} + +/* Check RNA-Paths for a list of Drivers */ +static bool drivers_path_rename_fix(ID *owner_id, + ID *ref_id, + const char *prefix, + const char *oldName, + const char *newName, + const char *oldKey, + const char *newKey, + ListBase *curves, + bool verify_paths) +{ + bool is_changed = false; + FCurve *fcu; + /* We need to check every curve - drivers are F-Curves too. */ + for (fcu = curves->first; fcu; fcu = fcu->next) { + /* firstly, handle the F-Curve's own path */ + if (fcu->rna_path != NULL) { + const char *old_rna_path = fcu->rna_path; + fcu->rna_path = rna_path_rename_fix( + owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); + is_changed |= (fcu->rna_path != old_rna_path); + } + if (fcu->driver == NULL) { + continue; + } + ChannelDriver *driver = fcu->driver; + DriverVar *dvar; + /* driver variables */ + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { + /* only change the used targets, since the others will need fixing manually anyway */ + DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { + /* rename RNA path */ + if (dtar->rna_path && dtar->id) { + const char *old_rna_path = dtar->rna_path; + dtar->rna_path = rna_path_rename_fix( + dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths); + is_changed |= (dtar->rna_path != old_rna_path); + } + /* also fix the bone-name (if applicable) */ + if (strstr(prefix, "bones")) { + if (((dtar->id) && (GS(dtar->id->name) == ID_OB) && + (!ref_id || ((Object *)(dtar->id))->data == ref_id)) && + (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name)) { + is_changed = true; + BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); + } + } + } + DRIVER_TARGETS_LOOPER_END; + } + } + return is_changed; +} + +/* Fix all RNA-Paths for Actions linked to NLA Strips */ +static bool nlastrips_path_rename_fix(ID *owner_id, + const char *prefix, + const char *oldName, + const char *newName, + const char *oldKey, + const char *newKey, + ListBase *strips, + bool verify_paths) +{ + NlaStrip *strip; + bool is_changed = false; + /* Recursively check strips, fixing only actions. */ + for (strip = strips->first; strip; strip = strip->next) { + /* fix strip's action */ + if (strip->act != NULL) { + is_changed |= fcurves_path_rename_fix( + owner_id, prefix, oldName, newName, oldKey, newKey, &strip->act->curves, verify_paths); + } + /* Ignore own F-Curves, since those are local. */ + /* Check sub-strips (if metas) */ + is_changed |= nlastrips_path_rename_fix( + owner_id, prefix, oldName, newName, oldKey, newKey, &strip->strips, verify_paths); + } + return is_changed; +} + +/* Rename Sub-ID Entities in RNA Paths ----------------------- */ + +/* Fix up the given RNA-Path + * + * This is just an external wrapper for the RNA-Path fixing function, + * with input validity checks on top of the basic method. + * + * NOTE: it is assumed that the structure we're replacing is <["><"]> + * i.e. pose.bones["Bone"] + */ +char *BKE_animsys_fix_rna_path_rename(ID *owner_id, + char *old_path, + const char *prefix, + const char *oldName, + const char *newName, + int oldSubscript, + int newSubscript, + bool verify_paths) +{ + char *oldN, *newN; + char *result; + + /* if no action, no need to proceed */ + if (ELEM(NULL, owner_id, old_path)) { + if (G.debug & G_DEBUG) { + CLOG_WARN(&LOG, "early abort"); + } + return old_path; + } + + /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ + if ((oldName != NULL) && (newName != NULL)) { + /* pad the names with [" "] so that only exact matches are made */ + const size_t name_old_len = strlen(oldName); + const size_t name_new_len = strlen(newName); + char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); + char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); + + BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); + BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); + oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); + newN = BLI_sprintfN("[\"%s\"]", name_new_esc); + } + else { + oldN = BLI_sprintfN("[%d]", oldSubscript); + newN = BLI_sprintfN("[%d]", newSubscript); + } + + /* fix given path */ + if (G.debug & G_DEBUG) { + printf("%s | %s | oldpath = %p ", oldN, newN, old_path); + } + result = rna_path_rename_fix(owner_id, prefix, oldN, newN, old_path, verify_paths); + if (G.debug & G_DEBUG) { + printf("path rename result = %p\n", result); + } + + /* free the temp names */ + MEM_freeN(oldN); + MEM_freeN(newN); + + /* return the resulting path - may be the same path again if nothing changed */ + return result; +} + +/* Fix all RNA_Paths in the given Action, relative to the given ID block + * + * This is just an external wrapper for the F-Curve fixing function, + * with input validity checks on top of the basic method. + * + * NOTE: it is assumed that the structure we're replacing is <["><"]> + * i.e. pose.bones["Bone"] + */ +void BKE_action_fix_paths_rename(ID *owner_id, + bAction *act, + const char *prefix, + const char *oldName, + const char *newName, + int oldSubscript, + int newSubscript, + bool verify_paths) +{ + char *oldN, *newN; + + /* if no action, no need to proceed */ + if (ELEM(NULL, owner_id, act)) { + return; + } + + /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ + if ((oldName != NULL) && (newName != NULL)) { + /* pad the names with [" "] so that only exact matches are made */ + const size_t name_old_len = strlen(oldName); + const size_t name_new_len = strlen(newName); + char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); + char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); + + BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); + BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); + oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); + newN = BLI_sprintfN("[\"%s\"]", name_new_esc); + } + else { + oldN = BLI_sprintfN("[%d]", oldSubscript); + newN = BLI_sprintfN("[%d]", newSubscript); + } + + /* fix paths in action */ + fcurves_path_rename_fix( + owner_id, prefix, oldName, newName, oldN, newN, &act->curves, verify_paths); + + /* free the temp names */ + MEM_freeN(oldN); + MEM_freeN(newN); +} + +/* Fix all RNA-Paths in the AnimData block used by the given ID block + * NOTE: it is assumed that the structure we're replacing is <["><"]> + * i.e. pose.bones["Bone"] + */ +void BKE_animdata_fix_paths_rename(ID *owner_id, + AnimData *adt, + ID *ref_id, + const char *prefix, + const char *oldName, + const char *newName, + int oldSubscript, + int newSubscript, + bool verify_paths) +{ + NlaTrack *nlt; + char *oldN, *newN; + /* If no AnimData, no need to proceed. */ + if (ELEM(NULL, owner_id, adt)) { + return; + } + bool is_self_changed = false; + /* Name sanitation logic - shared with BKE_action_fix_paths_rename(). */ + if ((oldName != NULL) && (newName != NULL)) { + /* Pad the names with [" "] so that only exact matches are made. */ + const size_t name_old_len = strlen(oldName); + const size_t name_new_len = strlen(newName); + char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); + char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); + + BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); + BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); + oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); + newN = BLI_sprintfN("[\"%s\"]", name_new_esc); + } + else { + oldN = BLI_sprintfN("[%d]", oldSubscript); + newN = BLI_sprintfN("[%d]", newSubscript); + } + /* Active action and temp action. */ + if (adt->action != NULL) { + if (fcurves_path_rename_fix( + owner_id, prefix, oldName, newName, oldN, newN, &adt->action->curves, verify_paths)) { + DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE); + } + } + if (adt->tmpact) { + if (fcurves_path_rename_fix( + owner_id, prefix, oldName, newName, oldN, newN, &adt->tmpact->curves, verify_paths)) { + DEG_id_tag_update(&adt->tmpact->id, ID_RECALC_COPY_ON_WRITE); + } + } + /* Drivers - Drivers are really F-Curves */ + is_self_changed |= drivers_path_rename_fix( + owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths); + /* NLA Data - Animation Data for Strips */ + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + is_self_changed |= nlastrips_path_rename_fix( + owner_id, prefix, oldName, newName, oldN, newN, &nlt->strips, verify_paths); + } + /* Tag owner ID if it */ + if (is_self_changed) { + DEG_id_tag_update(owner_id, ID_RECALC_COPY_ON_WRITE); + } + /* free the temp names */ + MEM_freeN(oldN); + MEM_freeN(newN); +} + +/* Remove FCurves with Prefix -------------------------------------- */ + +/* Check RNA-Paths for a list of F-Curves */ +static bool fcurves_path_remove_fix(const char *prefix, ListBase *curves) +{ + FCurve *fcu, *fcn; + bool any_removed = false; + if (!prefix) { + return any_removed; + } + + /* we need to check every curve... */ + for (fcu = curves->first; fcu; fcu = fcn) { + fcn = fcu->next; + + if (fcu->rna_path) { + if (STRPREFIX(fcu->rna_path, prefix)) { + BLI_remlink(curves, fcu); + free_fcurve(fcu); + any_removed = true; + } + } + } + return any_removed; +} + +/* Check RNA-Paths for a list of F-Curves */ +static bool nlastrips_path_remove_fix(const char *prefix, ListBase *strips) +{ + NlaStrip *strip; + bool any_removed = false; + + /* recursively check strips, fixing only actions... */ + for (strip = strips->first; strip; strip = strip->next) { + /* fix strip's action */ + if (strip->act) { + any_removed |= fcurves_path_remove_fix(prefix, &strip->act->curves); + } + + /* check sub-strips (if metas) */ + any_removed |= nlastrips_path_remove_fix(prefix, &strip->strips); + } + return any_removed; +} + +bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix) +{ + /* Only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate + */ + if (!id_can_have_animdata(id)) { + return false; + } + bool any_removed = false; + IdAdtTemplate *iat = (IdAdtTemplate *)id; + AnimData *adt = iat->adt; + /* check if there's any AnimData to start with */ + if (adt) { + /* free fcurves */ + if (adt->action != NULL) { + any_removed |= fcurves_path_remove_fix(prefix, &adt->action->curves); + } + if (adt->tmpact != NULL) { + any_removed |= fcurves_path_remove_fix(prefix, &adt->tmpact->curves); + } + /* free drivers - stored as a list of F-Curves */ + any_removed |= fcurves_path_remove_fix(prefix, &adt->drivers); + /* NLA Data - Animation Data for Strips */ + for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + any_removed |= nlastrips_path_remove_fix(prefix, &nlt->strips); + } + } + return any_removed; +} + +/* Apply Op to All FCurves in Database --------------------------- */ + +/* "User-Data" wrapper used by BKE_fcurves_main_cb() */ +typedef struct AllFCurvesCbWrapper { + ID_FCurve_Edit_Callback func; /* Operation to apply on F-Curve */ + void *user_data; /* Custom data for that operation */ +} AllFCurvesCbWrapper; + +/* Helper for adt_apply_all_fcurves_cb() - Apply wrapped operator to list of F-Curves */ +static void fcurves_apply_cb(ID *id, + ListBase *fcurves, + ID_FCurve_Edit_Callback func, + void *user_data) +{ + FCurve *fcu; + + for (fcu = fcurves->first; fcu; fcu = fcu->next) { + func(id, fcu, user_data); + } +} + +/* Helper for adt_apply_all_fcurves_cb() - Recursively go through each NLA strip */ +static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper) +{ + NlaStrip *strip; + + for (strip = strips->first; strip; strip = strip->next) { + /* fix strip's action */ + if (strip->act) { + fcurves_apply_cb(id, &strip->act->curves, wrapper->func, wrapper->user_data); + } + + /* check sub-strips (if metas) */ + nlastrips_apply_all_curves_cb(id, &strip->strips, wrapper); + } +} + +/* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves */ +static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data) +{ + AllFCurvesCbWrapper *wrapper = wrapper_data; + NlaTrack *nlt; + + if (adt->action) { + fcurves_apply_cb(id, &adt->action->curves, wrapper->func, wrapper->user_data); + } + + if (adt->tmpact) { + fcurves_apply_cb(id, &adt->tmpact->curves, wrapper->func, wrapper->user_data); + } + + /* free drivers - stored as a list of F-Curves */ + fcurves_apply_cb(id, &adt->drivers, wrapper->func, wrapper->user_data); + + /* NLA Data - Animation Data for Strips */ + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + nlastrips_apply_all_curves_cb(id, &nlt->strips, wrapper); + } +} + +void BKE_fcurves_id_cb(ID *id, ID_FCurve_Edit_Callback func, void *user_data) +{ + AnimData *adt = BKE_animdata_from_id(id); + if (adt != NULL) { + AllFCurvesCbWrapper wrapper = {func, user_data}; + adt_apply_all_fcurves_cb(id, adt, &wrapper); + } +} + +/* apply the given callback function on all F-Curves attached to data in main database */ +void BKE_fcurves_main_cb(Main *bmain, ID_FCurve_Edit_Callback func, void *user_data) +{ + /* Wrap F-Curve operation stuff to pass to the general AnimData-level func */ + AllFCurvesCbWrapper wrapper = {func, user_data}; + + /* Use the AnimData-based function so that we don't have to reimplement all that stuff */ + BKE_animdata_main_cb(bmain, adt_apply_all_fcurves_cb, &wrapper); +} + +/* Whole Database Ops -------------------------------------------- */ + +/* apply the given callback function on all data in main database */ +void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *user_data) +{ + ID *id; + + /* standard data version */ +#define ANIMDATA_IDS_CB(first) \ + for (id = first; id; id = id->next) { \ + AnimData *adt = BKE_animdata_from_id(id); \ + if (adt) \ + func(id, adt, user_data); \ + } \ + (void)0 + + /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */ +#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \ + for (id = first; id; id = id->next) { \ + AnimData *adt = BKE_animdata_from_id(id); \ + NtId_Type *ntp = (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ + if (adt2) \ + func(id, adt2, user_data); \ + } \ + if (adt) \ + func(id, adt, user_data); \ + } \ + (void)0 + + /* nodes */ + ANIMDATA_IDS_CB(bmain->nodetrees.first); + + /* textures */ + ANIMDATA_NODETREE_IDS_CB(bmain->textures.first, Tex); + + /* lights */ + ANIMDATA_NODETREE_IDS_CB(bmain->lights.first, Light); + + /* materials */ + ANIMDATA_NODETREE_IDS_CB(bmain->materials.first, Material); + + /* cameras */ + ANIMDATA_IDS_CB(bmain->cameras.first); + + /* shapekeys */ + ANIMDATA_IDS_CB(bmain->shapekeys.first); + + /* metaballs */ + ANIMDATA_IDS_CB(bmain->metaballs.first); + + /* curves */ + ANIMDATA_IDS_CB(bmain->curves.first); + + /* armatures */ + ANIMDATA_IDS_CB(bmain->armatures.first); + + /* lattices */ + ANIMDATA_IDS_CB(bmain->lattices.first); + + /* meshes */ + ANIMDATA_IDS_CB(bmain->meshes.first); + + /* particles */ + ANIMDATA_IDS_CB(bmain->particles.first); + + /* speakers */ + ANIMDATA_IDS_CB(bmain->speakers.first); + + /* movie clips */ + ANIMDATA_IDS_CB(bmain->movieclips.first); + + /* objects */ + ANIMDATA_IDS_CB(bmain->objects.first); + + /* masks */ + ANIMDATA_IDS_CB(bmain->masks.first); + + /* worlds */ + ANIMDATA_NODETREE_IDS_CB(bmain->worlds.first, World); + + /* scenes */ + ANIMDATA_NODETREE_IDS_CB(bmain->scenes.first, Scene); + + /* line styles */ + ANIMDATA_IDS_CB(bmain->linestyles.first); + + /* grease pencil */ + ANIMDATA_IDS_CB(bmain->gpencils.first); + + /* palettes */ + ANIMDATA_IDS_CB(bmain->palettes.first); + + /* cache files */ + ANIMDATA_IDS_CB(bmain->cachefiles.first); + + /* hairs */ + ANIMDATA_IDS_CB(bmain->hairs.first); + + /* pointclouds */ + ANIMDATA_IDS_CB(bmain->pointclouds.first); + + /* volumes */ + ANIMDATA_IDS_CB(bmain->volumes.first); +} + +/* Fix all RNA-Paths throughout the database (directly access the Global.main version) + * NOTE: it is assumed that the structure we're replacing is <["><"]> + * i.e. pose.bones["Bone"] + */ +/* TODO: use BKE_animdata_main_cb for looping over all data */ +void BKE_animdata_fix_paths_rename_all(ID *ref_id, + const char *prefix, + const char *oldName, + const char *newName) +{ + Main *bmain = G.main; /* XXX UGLY! */ + ID *id; + + /* macro for less typing + * - whether animdata exists is checked for by the main renaming callback, though taking + * this outside of the function may make things slightly faster? + */ +#define RENAMEFIX_ANIM_IDS(first) \ + for (id = first; id; id = id->next) { \ + AnimData *adt = BKE_animdata_from_id(id); \ + BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ + } \ + (void)0 + + /* another version of this macro for nodetrees */ +#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \ + for (id = first; id; id = id->next) { \ + AnimData *adt = BKE_animdata_from_id(id); \ + NtId_Type *ntp = (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ + BKE_animdata_fix_paths_rename( \ + (ID *)ntp->nodetree, adt2, ref_id, prefix, oldName, newName, 0, 0, 1); \ + } \ + BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ + } \ + (void)0 + + /* nodes */ + RENAMEFIX_ANIM_IDS(bmain->nodetrees.first); + + /* textures */ + RENAMEFIX_ANIM_NODETREE_IDS(bmain->textures.first, Tex); + + /* lights */ + RENAMEFIX_ANIM_NODETREE_IDS(bmain->lights.first, Light); + + /* materials */ + RENAMEFIX_ANIM_NODETREE_IDS(bmain->materials.first, Material); + + /* cameras */ + RENAMEFIX_ANIM_IDS(bmain->cameras.first); + + /* shapekeys */ + RENAMEFIX_ANIM_IDS(bmain->shapekeys.first); + + /* metaballs */ + RENAMEFIX_ANIM_IDS(bmain->metaballs.first); + + /* curves */ + RENAMEFIX_ANIM_IDS(bmain->curves.first); + + /* armatures */ + RENAMEFIX_ANIM_IDS(bmain->armatures.first); + + /* lattices */ + RENAMEFIX_ANIM_IDS(bmain->lattices.first); + + /* meshes */ + RENAMEFIX_ANIM_IDS(bmain->meshes.first); + + /* particles */ + RENAMEFIX_ANIM_IDS(bmain->particles.first); + + /* speakers */ + RENAMEFIX_ANIM_IDS(bmain->speakers.first); + + /* movie clips */ + RENAMEFIX_ANIM_IDS(bmain->movieclips.first); + + /* objects */ + RENAMEFIX_ANIM_IDS(bmain->objects.first); + + /* masks */ + RENAMEFIX_ANIM_IDS(bmain->masks.first); + + /* worlds */ + RENAMEFIX_ANIM_NODETREE_IDS(bmain->worlds.first, World); + + /* linestyles */ + RENAMEFIX_ANIM_IDS(bmain->linestyles.first); + + /* grease pencil */ + RENAMEFIX_ANIM_IDS(bmain->gpencils.first); + + /* cache files */ + RENAMEFIX_ANIM_IDS(bmain->cachefiles.first); + + /* hairs */ + RENAMEFIX_ANIM_IDS(bmain->hairs.first); + + /* pointclouds */ + RENAMEFIX_ANIM_IDS(bmain->pointclouds.first); + + /* volumes */ + RENAMEFIX_ANIM_IDS(bmain->volumes.first); + + /* scenes */ + RENAMEFIX_ANIM_NODETREE_IDS(bmain->scenes.first, Scene); +} diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 25582700e9e..69efac37fbf 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -51,6 +51,7 @@ #include "DNA_world_types.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_fcurve.h" @@ -76,1382 +77,6 @@ static CLG_LogRef LOG = {"bke.anim_sys"}; -/* ***************************************** */ -/* AnimData API */ - -/* Getter/Setter -------------------------------------------- */ - -/* Check if ID can have AnimData */ -bool id_type_can_have_animdata(const short id_type) -{ - /* Only some ID-blocks have this info for now */ - /* TODO: finish adding this for the other blocktypes */ - switch (id_type) { - /* has AnimData */ - case ID_OB: - case ID_ME: - case ID_MB: - case ID_CU: - case ID_AR: - case ID_LT: - case ID_KE: - case ID_PA: - case ID_MA: - case ID_TE: - case ID_NT: - case ID_LA: - case ID_CA: - case ID_WO: - case ID_LS: - case ID_LP: - case ID_SPK: - case ID_SCE: - case ID_MC: - case ID_MSK: - case ID_GD: - case ID_CF: - case ID_HA: - case ID_PT: - case ID_VO: - return true; - - /* no AnimData */ - default: - return false; - } -} - -bool id_can_have_animdata(const ID *id) -{ - /* sanity check */ - if (id == NULL) { - return false; - } - - return id_type_can_have_animdata(GS(id->name)); -} - -/* Get AnimData from the given ID-block. In order for this to work, we assume that - * the AnimData pointer is stored immediately after the given ID-block in the struct, - * as per IdAdtTemplate. - */ -AnimData *BKE_animdata_from_id(ID *id) -{ - /* only some ID-blocks have this info for now, so we cast the - * types that do to be of type IdAdtTemplate, and extract the - * AnimData that way - */ - if (id_can_have_animdata(id)) { - IdAdtTemplate *iat = (IdAdtTemplate *)id; - return iat->adt; - } - else { - return NULL; - } -} - -/* Add AnimData to the given ID-block. In order for this to work, we assume that - * the AnimData pointer is stored immediately after the given ID-block in the struct, - * as per IdAdtTemplate. Also note that - */ -AnimData *BKE_animdata_add_id(ID *id) -{ - /* Only some ID-blocks have this info for now, so we cast the - * types that do to be of type IdAdtTemplate, and add the AnimData - * to it using the template - */ - if (id_can_have_animdata(id)) { - IdAdtTemplate *iat = (IdAdtTemplate *)id; - - /* check if there's already AnimData, in which case, don't add */ - if (iat->adt == NULL) { - AnimData *adt; - - /* add animdata */ - adt = iat->adt = MEM_callocN(sizeof(AnimData), "AnimData"); - - /* set default settings */ - adt->act_influence = 1.0f; - } - - return iat->adt; - } - else { - return NULL; - } -} - -/* Action Setter --------------------------------------- */ - -/** - * Called when user tries to change the active action of an AnimData block - * (via RNA, Outliner, etc.) - */ -bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) -{ - AnimData *adt = BKE_animdata_from_id(id); - bool ok = false; - - /* animdata validity check */ - if (adt == NULL) { - BKE_report(reports, RPT_WARNING, "No AnimData to set action on"); - return ok; - } - - /* active action is only editable when it is not a tweaking strip - * see rna_AnimData_action_editable() in rna_animation.c - */ - if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) { - /* cannot remove, otherwise things turn to custard */ - BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA"); - return ok; - } - - /* manage usercount for current action */ - if (adt->action) { - id_us_min((ID *)adt->action); - } - - /* assume that AnimData's action can in fact be edited... */ - if (act) { - /* action must have same type as owner */ - if (ELEM(act->idroot, 0, GS(id->name))) { - /* can set */ - adt->action = act; - id_us_plus((ID *)adt->action); - ok = true; - } - else { - /* cannot set */ - BKE_reportf( - reports, - RPT_ERROR, - "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths " - "for this purpose", - act->id.name + 2, - id->name); - /* ok = false; */ - } - } - else { - /* just clearing the action... */ - adt->action = NULL; - ok = true; - } - - return ok; -} - -/* Freeing -------------------------------------------- */ - -/* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ -void BKE_animdata_free(ID *id, const bool do_id_user) -{ - /* Only some ID-blocks have this info for now, so we cast the - * types that do to be of type IdAdtTemplate - */ - if (id_can_have_animdata(id)) { - IdAdtTemplate *iat = (IdAdtTemplate *)id; - AnimData *adt = iat->adt; - - /* check if there's any AnimData to start with */ - if (adt) { - if (do_id_user) { - /* unlink action (don't free, as it's in its own list) */ - if (adt->action) { - id_us_min(&adt->action->id); - } - /* same goes for the temporarily displaced action */ - if (adt->tmpact) { - id_us_min(&adt->tmpact->id); - } - } - - /* free nla data */ - BKE_nla_tracks_free(&adt->nla_tracks, do_id_user); - - /* free drivers - stored as a list of F-Curves */ - free_fcurves(&adt->drivers); - - /* free driver array cache */ - MEM_SAFE_FREE(adt->driver_array); - - /* free overrides */ - /* TODO... */ - - /* free animdata now */ - MEM_freeN(adt); - iat->adt = NULL; - } - } -} - -bool BKE_animdata_id_is_animated(const struct ID *id) -{ - if (id == NULL) { - return false; - } - - const AnimData *adt = BKE_animdata_from_id((ID *)id); - if (adt == NULL) { - return false; - } - - if (adt->action != NULL && !BLI_listbase_is_empty(&adt->action->curves)) { - return true; - } - - return !BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->nla_tracks) || - !BLI_listbase_is_empty(&adt->overrides); -} - -/* Copying -------------------------------------------- */ - -/** - * Make a copy of the given AnimData - to be used when copying data-blocks. - * \param flag: Control ID pointers management, - * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h - * \return The copied animdata. - */ -AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag) -{ - AnimData *dadt; - - const bool do_action = (flag & LIB_ID_COPY_ACTIONS) != 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0; - const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0; - - /* sanity check before duplicating struct */ - if (adt == NULL) { - return NULL; - } - dadt = MEM_dupallocN(adt); - - /* make a copy of action - at worst, user has to delete copies... */ - if (do_action) { - BLI_assert(bmain != NULL); - BLI_assert(dadt->action == NULL || dadt->action != dadt->tmpact); - BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, flag); - BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, flag); - } - else if (do_id_user) { - id_us_plus((ID *)dadt->action); - id_us_plus((ID *)dadt->tmpact); - } - - /* duplicate NLA data */ - BKE_nla_tracks_copy(bmain, &dadt->nla_tracks, &adt->nla_tracks, flag); - - /* duplicate drivers (F-Curves) */ - copy_fcurves(&dadt->drivers, &adt->drivers); - dadt->driver_array = NULL; - - /* don't copy overrides */ - BLI_listbase_clear(&dadt->overrides); - - /* return */ - return dadt; -} - -/** - * \param flag: Control ID pointers management, - * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h - * \return true is successfully copied. - */ -bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag) -{ - AnimData *adt; - - if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) { - return false; - } - - BKE_animdata_free(id_to, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0); - - adt = BKE_animdata_from_id(id_from); - if (adt) { - IdAdtTemplate *iat = (IdAdtTemplate *)id_to; - iat->adt = BKE_animdata_copy(bmain, adt, flag); - } - - return true; -} - -void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid) -{ - AnimData *adt = BKE_animdata_from_id(id); - if (adt) { - if (adt->action) { - id_us_min((ID *)adt->action); - adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_action_copy(bmain, adt->action)) : - BKE_action_copy(bmain, adt->action); - } - if (adt->tmpact) { - id_us_min((ID *)adt->tmpact); - adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_action_copy(bmain, adt->tmpact)) : - BKE_action_copy(bmain, adt->tmpact); - } - } - bNodeTree *ntree = ntreeFromID(id); - if (ntree) { - BKE_animdata_copy_id_action(bmain, &ntree->id, set_newid); - } -} - -/* Merge copies of the data from the src AnimData into the destination AnimData */ -void BKE_animdata_merge_copy( - Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers) -{ - AnimData *src = BKE_animdata_from_id(src_id); - AnimData *dst = BKE_animdata_from_id(dst_id); - - /* sanity checks */ - if (ELEM(NULL, dst, src)) { - return; - } - - // TODO: we must unset all "tweakmode" flags - if ((src->flag & ADT_NLA_EDIT_ON) || (dst->flag & ADT_NLA_EDIT_ON)) { - CLOG_ERROR( - &LOG, - "Merging AnimData blocks while editing NLA is dangerous as it may cause data corruption"); - return; - } - - /* handle actions... */ - if (action_mode == ADT_MERGECOPY_SRC_COPY) { - /* make a copy of the actions */ - dst->action = BKE_action_copy(bmain, src->action); - dst->tmpact = BKE_action_copy(bmain, src->tmpact); - } - else if (action_mode == ADT_MERGECOPY_SRC_REF) { - /* make a reference to it */ - dst->action = src->action; - id_us_plus((ID *)dst->action); - - dst->tmpact = src->tmpact; - id_us_plus((ID *)dst->tmpact); - } - - /* duplicate NLA data */ - if (src->nla_tracks.first) { - ListBase tracks = {NULL, NULL}; - - BKE_nla_tracks_copy(bmain, &tracks, &src->nla_tracks, 0); - BLI_movelisttolist(&dst->nla_tracks, &tracks); - } - - /* duplicate drivers (F-Curves) */ - if (src->drivers.first) { - ListBase drivers = {NULL, NULL}; - - copy_fcurves(&drivers, &src->drivers); - - /* Fix up all driver targets using the old target id - * - This assumes that the src ID is being merged into the dst ID - */ - if (fix_drivers) { - FCurve *fcu; - - for (fcu = drivers.first; fcu; fcu = fcu->next) { - ChannelDriver *driver = fcu->driver; - DriverVar *dvar; - - for (dvar = driver->variables.first; dvar; dvar = dvar->next) { - DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { - if (dtar->id == src_id) { - dtar->id = dst_id; - } - } - DRIVER_TARGETS_LOOPER_END; - } - } - } - - BLI_movelisttolist(&dst->drivers, &drivers); - } -} - -/* Sub-ID Regrouping ------------------------------------------- */ - -/** - * Helper heuristic for determining if a path is compatible with the basepath - * - * \param path: Full RNA-path from some data (usually an F-Curve) to compare - * \param basepath: Shorter path fragment to look for - * \return Whether there is a match - */ -static bool animpath_matches_basepath(const char path[], const char basepath[]) -{ - /* we need start of path to be basepath */ - return (path && basepath) && STRPREFIX(path, basepath); -} - -/* Move F-Curves in src action to dst action, setting up all the necessary groups - * for this to happen, but only if the F-Curves being moved have the appropriate - * "base path". - * - This is used when data moves from one data-block to another, causing the - * F-Curves to need to be moved over too - */ -void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[]) -{ - FCurve *fcu, *fcn = NULL; - - /* sanity checks */ - if (ELEM(NULL, srcAct, dstAct, basepath)) { - if (G.debug & G_DEBUG) { - CLOG_ERROR(&LOG, - "srcAct: %p, dstAct: %p, basepath: %p has insufficient info to work with", - (void *)srcAct, - (void *)dstAct, - (void *)basepath); - } - return; - } - - /* clear 'temp' flags on all groups in src, as we'll be needing them later - * to identify groups that we've managed to empty out here - */ - action_groups_clear_tempflags(srcAct); - - /* iterate over all src F-Curves, moving over the ones that need to be moved */ - for (fcu = srcAct->curves.first; fcu; fcu = fcn) { - /* store next pointer in case we move stuff */ - fcn = fcu->next; - - /* should F-Curve be moved over? - * - we only need the start of the path to match basepath - */ - if (animpath_matches_basepath(fcu->rna_path, basepath)) { - bActionGroup *agrp = NULL; - - /* if grouped... */ - if (fcu->grp) { - /* make sure there will be a matching group on the other side for the migrants */ - agrp = BKE_action_group_find_name(dstAct, fcu->grp->name); - - if (agrp == NULL) { - /* add a new one with a similar name (usually will be the same though) */ - agrp = action_groups_add_new(dstAct, fcu->grp->name); - } - - /* old groups should be tagged with 'temp' flags so they can be removed later - * if we remove everything from them - */ - fcu->grp->flag |= AGRP_TEMP; - } - - /* perform the migration now */ - action_groups_remove_channel(srcAct, fcu); - - if (agrp) { - action_groups_add_channel(dstAct, agrp, fcu); - } - else { - BLI_addtail(&dstAct->curves, fcu); - } - } - } - - /* cleanup groups (if present) */ - if (srcAct->groups.first) { - bActionGroup *agrp, *grp = NULL; - - for (agrp = srcAct->groups.first; agrp; agrp = grp) { - grp = agrp->next; - - /* only tagged groups need to be considered - clearing these tags or removing them */ - if (agrp->flag & AGRP_TEMP) { - /* if group is empty and tagged, then we can remove as this operation - * moved out all the channels that were formerly here - */ - if (BLI_listbase_is_empty(&agrp->channels)) { - BLI_freelinkN(&srcAct->groups, agrp); - } - else { - agrp->flag &= ~AGRP_TEMP; - } - } - } - } -} - -/* Transfer the animation data from srcID to dstID where the srcID - * animation data is based off "basepath", creating new AnimData and - * associated data as necessary - */ -void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths) -{ - AnimData *srcAdt = NULL, *dstAdt = NULL; - LinkData *ld; - - /* sanity checks */ - if (ELEM(NULL, srcID, dstID)) { - if (G.debug & G_DEBUG) { - CLOG_ERROR(&LOG, "no source or destination ID to separate AnimData with"); - } - return; - } - - /* get animdata from src, and create for destination (if needed) */ - srcAdt = BKE_animdata_from_id(srcID); - dstAdt = BKE_animdata_add_id(dstID); - - if (ELEM(NULL, srcAdt, dstAdt)) { - if (G.debug & G_DEBUG) { - CLOG_ERROR(&LOG, "no AnimData for this pair of ID's"); - } - return; - } - - /* active action */ - if (srcAdt->action) { - /* Set up an action if necessary, - * and name it in a similar way so that it can be easily found again. */ - if (dstAdt->action == NULL) { - dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2); - } - else if (dstAdt->action == srcAdt->action) { - CLOG_WARN(&LOG, - "Argh! Source and Destination share animation! " - "('%s' and '%s' both use '%s') Making new empty action", - srcID->name, - dstID->name, - srcAdt->action->id.name); - - /* TODO: review this... */ - id_us_min(&dstAdt->action->id); - dstAdt->action = BKE_action_add(bmain, dstAdt->action->id.name + 2); - } - - /* loop over base paths, trying to fix for each one... */ - for (ld = basepaths->first; ld; ld = ld->next) { - const char *basepath = (const char *)ld->data; - action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath); - } - } - - /* drivers */ - if (srcAdt->drivers.first) { - FCurve *fcu, *fcn = NULL; - - /* check each driver against all the base paths to see if any should go */ - for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) { - fcn = fcu->next; - - /* try each basepath in turn, but stop on the first one which works */ - for (ld = basepaths->first; ld; ld = ld->next) { - const char *basepath = (const char *)ld->data; - - if (animpath_matches_basepath(fcu->rna_path, basepath)) { - /* just need to change lists */ - BLI_remlink(&srcAdt->drivers, fcu); - BLI_addtail(&dstAdt->drivers, fcu); - - /* TODO: add depsgraph flushing calls? */ - - /* can stop now, as moved already */ - break; - } - } - } - } -} - -/** - * Temporary wrapper for driver operators for buttons to make it easier to create - * such drivers by rerouting all paths through the active object instead so that - * they will get picked up by the dependency system. - * - * \param C: Context pointer - for getting active data - * \param[in,out] ptr: RNA pointer for property's data-block. - * May be modified as result of path remapping. - * \param prop: RNA definition of property to add for - * \return MEM_alloc'd string representing the path to the property from the given #PointerRNA - */ -char *BKE_animdata_driver_path_hack(bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - char *base_path) -{ - ID *id = ptr->owner_id; - ScrArea *area = CTX_wm_area(C); - - /* get standard path which may be extended */ - char *basepath = base_path ? base_path : RNA_path_from_ID_to_property(ptr, prop); - char *path = basepath; /* in case no remapping is needed */ - - /* Remapping will only be performed in the Properties Editor, as only this - * restricts the subspace of options to the 'active' data (a manageable state) - */ - /* TODO: watch out for pinned context? */ - if ((area) && (area->spacetype == SPACE_PROPERTIES)) { - Object *ob = CTX_data_active_object(C); - - if (ob && id) { - /* TODO: after material textures were removed, this function serves - * no purpose anymore, but could be used again so was not removed. */ - - /* fix RNA pointer, as we've now changed the ID root by changing the paths */ - if (basepath != path) { - /* rebase provided pointer so that it starts from object... */ - RNA_pointer_create(&ob->id, ptr->type, ptr->data, ptr); - } - } - } - - /* the path should now have been corrected for use */ - return path; -} - -/* Path Validation -------------------------------------------- */ - -/* Check if a given RNA Path is valid, by tracing it from the given ID, - * and seeing if we can resolve it. */ -static bool check_rna_path_is_valid(ID *owner_id, const char *path) -{ - PointerRNA id_ptr, ptr; - PropertyRNA *prop = NULL; - - /* make initial RNA pointer to start resolving from */ - RNA_id_pointer_create(owner_id, &id_ptr); - - /* try to resolve */ - return RNA_path_resolve_property(&id_ptr, path, &ptr, &prop); -} - -/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate - * NOTE: we assume that oldName and newName have [" "] padding around them - */ -static char *rna_path_rename_fix(ID *owner_id, - const char *prefix, - const char *oldName, - const char *newName, - char *oldpath, - bool verify_paths) -{ - char *prefixPtr = strstr(oldpath, prefix); - char *oldNamePtr = strstr(oldpath, oldName); - int prefixLen = strlen(prefix); - int oldNameLen = strlen(oldName); - - /* only start fixing the path if the prefix and oldName feature in the path, - * and prefix occurs immediately before oldName - */ - if ((prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr)) { - /* if we haven't aren't able to resolve the path now, try again after fixing it */ - if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) { - DynStr *ds = BLI_dynstr_new(); - const char *postfixPtr = oldNamePtr + oldNameLen; - char *newPath = NULL; - - /* add the part of the string that goes up to the start of the prefix */ - if (prefixPtr > oldpath) { - BLI_dynstr_nappend(ds, oldpath, prefixPtr - oldpath); - } - - /* add the prefix */ - BLI_dynstr_append(ds, prefix); - - /* add the new name (complete with brackets) */ - BLI_dynstr_append(ds, newName); - - /* add the postfix */ - BLI_dynstr_append(ds, postfixPtr); - - /* create new path, and cleanup old data */ - newPath = BLI_dynstr_get_cstring(ds); - BLI_dynstr_free(ds); - - /* check if the new path will solve our problems */ - /* TODO: will need to check whether this step really helps in practice */ - if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { - /* free the old path, and return the new one, since we've solved the issues */ - MEM_freeN(oldpath); - return newPath; - } - else { - /* still couldn't resolve the path... so, might as well just leave it alone */ - MEM_freeN(newPath); - } - } - } - - /* the old path doesn't need to be changed */ - return oldpath; -} - -/* Check RNA-Paths for a list of F-Curves */ -static bool fcurves_path_rename_fix(ID *owner_id, - const char *prefix, - const char *oldName, - const char *newName, - const char *oldKey, - const char *newKey, - ListBase *curves, - bool verify_paths) -{ - FCurve *fcu; - bool is_changed = false; - /* We need to check every curve. */ - for (fcu = curves->first; fcu; fcu = fcu->next) { - if (fcu->rna_path == NULL) { - continue; - } - const char *old_path = fcu->rna_path; - /* Firstly, handle the F-Curve's own path. */ - fcu->rna_path = rna_path_rename_fix( - owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); - /* if path changed and the F-Curve is grouped, check if its group also needs renaming - * (i.e. F-Curve is first of a bone's F-Curves; - * hence renaming this should also trigger rename) */ - if (fcu->rna_path != old_path) { - bActionGroup *agrp = fcu->grp; - is_changed = true; - if ((agrp != NULL) && STREQ(oldName, agrp->name)) { - BLI_strncpy(agrp->name, newName, sizeof(agrp->name)); - } - } - } - return is_changed; -} - -/* Check RNA-Paths for a list of Drivers */ -static bool drivers_path_rename_fix(ID *owner_id, - ID *ref_id, - const char *prefix, - const char *oldName, - const char *newName, - const char *oldKey, - const char *newKey, - ListBase *curves, - bool verify_paths) -{ - bool is_changed = false; - FCurve *fcu; - /* We need to check every curve - drivers are F-Curves too. */ - for (fcu = curves->first; fcu; fcu = fcu->next) { - /* firstly, handle the F-Curve's own path */ - if (fcu->rna_path != NULL) { - const char *old_rna_path = fcu->rna_path; - fcu->rna_path = rna_path_rename_fix( - owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); - is_changed |= (fcu->rna_path != old_rna_path); - } - if (fcu->driver == NULL) { - continue; - } - ChannelDriver *driver = fcu->driver; - DriverVar *dvar; - /* driver variables */ - for (dvar = driver->variables.first; dvar; dvar = dvar->next) { - /* only change the used targets, since the others will need fixing manually anyway */ - DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { - /* rename RNA path */ - if (dtar->rna_path && dtar->id) { - const char *old_rna_path = dtar->rna_path; - dtar->rna_path = rna_path_rename_fix( - dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths); - is_changed |= (dtar->rna_path != old_rna_path); - } - /* also fix the bone-name (if applicable) */ - if (strstr(prefix, "bones")) { - if (((dtar->id) && (GS(dtar->id->name) == ID_OB) && - (!ref_id || ((Object *)(dtar->id))->data == ref_id)) && - (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name)) { - is_changed = true; - BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); - } - } - } - DRIVER_TARGETS_LOOPER_END; - } - } - return is_changed; -} - -/* Fix all RNA-Paths for Actions linked to NLA Strips */ -static bool nlastrips_path_rename_fix(ID *owner_id, - const char *prefix, - const char *oldName, - const char *newName, - const char *oldKey, - const char *newKey, - ListBase *strips, - bool verify_paths) -{ - NlaStrip *strip; - bool is_changed = false; - /* Recursively check strips, fixing only actions. */ - for (strip = strips->first; strip; strip = strip->next) { - /* fix strip's action */ - if (strip->act != NULL) { - is_changed |= fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldKey, newKey, &strip->act->curves, verify_paths); - } - /* Ignore own F-Curves, since those are local. */ - /* Check sub-strips (if metas) */ - is_changed |= nlastrips_path_rename_fix( - owner_id, prefix, oldName, newName, oldKey, newKey, &strip->strips, verify_paths); - } - return is_changed; -} - -/* Rename Sub-ID Entities in RNA Paths ----------------------- */ - -/* Fix up the given RNA-Path - * - * This is just an external wrapper for the RNA-Path fixing function, - * with input validity checks on top of the basic method. - * - * NOTE: it is assumed that the structure we're replacing is <["><"]> - * i.e. pose.bones["Bone"] - */ -char *BKE_animsys_fix_rna_path_rename(ID *owner_id, - char *old_path, - const char *prefix, - const char *oldName, - const char *newName, - int oldSubscript, - int newSubscript, - bool verify_paths) -{ - char *oldN, *newN; - char *result; - - /* if no action, no need to proceed */ - if (ELEM(NULL, owner_id, old_path)) { - if (G.debug & G_DEBUG) { - CLOG_WARN(&LOG, "early abort"); - } - return old_path; - } - - /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ - if ((oldName != NULL) && (newName != NULL)) { - /* pad the names with [" "] so that only exact matches are made */ - const size_t name_old_len = strlen(oldName); - const size_t name_new_len = strlen(newName); - char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); - char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); - - BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); - BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); - oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); - newN = BLI_sprintfN("[\"%s\"]", name_new_esc); - } - else { - oldN = BLI_sprintfN("[%d]", oldSubscript); - newN = BLI_sprintfN("[%d]", newSubscript); - } - - /* fix given path */ - if (G.debug & G_DEBUG) { - printf("%s | %s | oldpath = %p ", oldN, newN, old_path); - } - result = rna_path_rename_fix(owner_id, prefix, oldN, newN, old_path, verify_paths); - if (G.debug & G_DEBUG) { - printf("path rename result = %p\n", result); - } - - /* free the temp names */ - MEM_freeN(oldN); - MEM_freeN(newN); - - /* return the resulting path - may be the same path again if nothing changed */ - return result; -} - -/* Fix all RNA_Paths in the given Action, relative to the given ID block - * - * This is just an external wrapper for the F-Curve fixing function, - * with input validity checks on top of the basic method. - * - * NOTE: it is assumed that the structure we're replacing is <["><"]> - * i.e. pose.bones["Bone"] - */ -void BKE_action_fix_paths_rename(ID *owner_id, - bAction *act, - const char *prefix, - const char *oldName, - const char *newName, - int oldSubscript, - int newSubscript, - bool verify_paths) -{ - char *oldN, *newN; - - /* if no action, no need to proceed */ - if (ELEM(NULL, owner_id, act)) { - return; - } - - /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ - if ((oldName != NULL) && (newName != NULL)) { - /* pad the names with [" "] so that only exact matches are made */ - const size_t name_old_len = strlen(oldName); - const size_t name_new_len = strlen(newName); - char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); - char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); - - BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); - BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); - oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); - newN = BLI_sprintfN("[\"%s\"]", name_new_esc); - } - else { - oldN = BLI_sprintfN("[%d]", oldSubscript); - newN = BLI_sprintfN("[%d]", newSubscript); - } - - /* fix paths in action */ - fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &act->curves, verify_paths); - - /* free the temp names */ - MEM_freeN(oldN); - MEM_freeN(newN); -} - -/* Fix all RNA-Paths in the AnimData block used by the given ID block - * NOTE: it is assumed that the structure we're replacing is <["><"]> - * i.e. pose.bones["Bone"] - */ -void BKE_animdata_fix_paths_rename(ID *owner_id, - AnimData *adt, - ID *ref_id, - const char *prefix, - const char *oldName, - const char *newName, - int oldSubscript, - int newSubscript, - bool verify_paths) -{ - NlaTrack *nlt; - char *oldN, *newN; - /* If no AnimData, no need to proceed. */ - if (ELEM(NULL, owner_id, adt)) { - return; - } - bool is_self_changed = false; - /* Name sanitation logic - shared with BKE_action_fix_paths_rename(). */ - if ((oldName != NULL) && (newName != NULL)) { - /* Pad the names with [" "] so that only exact matches are made. */ - const size_t name_old_len = strlen(oldName); - const size_t name_new_len = strlen(newName); - char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); - char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); - - BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); - BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); - oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); - newN = BLI_sprintfN("[\"%s\"]", name_new_esc); - } - else { - oldN = BLI_sprintfN("[%d]", oldSubscript); - newN = BLI_sprintfN("[%d]", newSubscript); - } - /* Active action and temp action. */ - if (adt->action != NULL) { - if (fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &adt->action->curves, verify_paths)) { - DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE); - } - } - if (adt->tmpact) { - if (fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &adt->tmpact->curves, verify_paths)) { - DEG_id_tag_update(&adt->tmpact->id, ID_RECALC_COPY_ON_WRITE); - } - } - /* Drivers - Drivers are really F-Curves */ - is_self_changed |= drivers_path_rename_fix( - owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths); - /* NLA Data - Animation Data for Strips */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - is_self_changed |= nlastrips_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &nlt->strips, verify_paths); - } - /* Tag owner ID if it */ - if (is_self_changed) { - DEG_id_tag_update(owner_id, ID_RECALC_COPY_ON_WRITE); - } - /* free the temp names */ - MEM_freeN(oldN); - MEM_freeN(newN); -} - -/* Remove FCurves with Prefix -------------------------------------- */ - -/* Check RNA-Paths for a list of F-Curves */ -static bool fcurves_path_remove_fix(const char *prefix, ListBase *curves) -{ - FCurve *fcu, *fcn; - bool any_removed = false; - if (!prefix) { - return any_removed; - } - - /* we need to check every curve... */ - for (fcu = curves->first; fcu; fcu = fcn) { - fcn = fcu->next; - - if (fcu->rna_path) { - if (STRPREFIX(fcu->rna_path, prefix)) { - BLI_remlink(curves, fcu); - free_fcurve(fcu); - any_removed = true; - } - } - } - return any_removed; -} - -/* Check RNA-Paths for a list of F-Curves */ -static bool nlastrips_path_remove_fix(const char *prefix, ListBase *strips) -{ - NlaStrip *strip; - bool any_removed = false; - - /* recursively check strips, fixing only actions... */ - for (strip = strips->first; strip; strip = strip->next) { - /* fix strip's action */ - if (strip->act) { - any_removed |= fcurves_path_remove_fix(prefix, &strip->act->curves); - } - - /* check sub-strips (if metas) */ - any_removed |= nlastrips_path_remove_fix(prefix, &strip->strips); - } - return any_removed; -} - -bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix) -{ - /* Only some ID-blocks have this info for now, so we cast the - * types that do to be of type IdAdtTemplate - */ - if (!id_can_have_animdata(id)) { - return false; - } - bool any_removed = false; - IdAdtTemplate *iat = (IdAdtTemplate *)id; - AnimData *adt = iat->adt; - /* check if there's any AnimData to start with */ - if (adt) { - /* free fcurves */ - if (adt->action != NULL) { - any_removed |= fcurves_path_remove_fix(prefix, &adt->action->curves); - } - if (adt->tmpact != NULL) { - any_removed |= fcurves_path_remove_fix(prefix, &adt->tmpact->curves); - } - /* free drivers - stored as a list of F-Curves */ - any_removed |= fcurves_path_remove_fix(prefix, &adt->drivers); - /* NLA Data - Animation Data for Strips */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - any_removed |= nlastrips_path_remove_fix(prefix, &nlt->strips); - } - } - return any_removed; -} - -/* Apply Op to All FCurves in Database --------------------------- */ - -/* "User-Data" wrapper used by BKE_fcurves_main_cb() */ -typedef struct AllFCurvesCbWrapper { - ID_FCurve_Edit_Callback func; /* Operation to apply on F-Curve */ - void *user_data; /* Custom data for that operation */ -} AllFCurvesCbWrapper; - -/* Helper for adt_apply_all_fcurves_cb() - Apply wrapped operator to list of F-Curves */ -static void fcurves_apply_cb(ID *id, - ListBase *fcurves, - ID_FCurve_Edit_Callback func, - void *user_data) -{ - FCurve *fcu; - - for (fcu = fcurves->first; fcu; fcu = fcu->next) { - func(id, fcu, user_data); - } -} - -/* Helper for adt_apply_all_fcurves_cb() - Recursively go through each NLA strip */ -static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper) -{ - NlaStrip *strip; - - for (strip = strips->first; strip; strip = strip->next) { - /* fix strip's action */ - if (strip->act) { - fcurves_apply_cb(id, &strip->act->curves, wrapper->func, wrapper->user_data); - } - - /* check sub-strips (if metas) */ - nlastrips_apply_all_curves_cb(id, &strip->strips, wrapper); - } -} - -/* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves */ -static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data) -{ - AllFCurvesCbWrapper *wrapper = wrapper_data; - NlaTrack *nlt; - - if (adt->action) { - fcurves_apply_cb(id, &adt->action->curves, wrapper->func, wrapper->user_data); - } - - if (adt->tmpact) { - fcurves_apply_cb(id, &adt->tmpact->curves, wrapper->func, wrapper->user_data); - } - - /* free drivers - stored as a list of F-Curves */ - fcurves_apply_cb(id, &adt->drivers, wrapper->func, wrapper->user_data); - - /* NLA Data - Animation Data for Strips */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - nlastrips_apply_all_curves_cb(id, &nlt->strips, wrapper); - } -} - -void BKE_fcurves_id_cb(ID *id, ID_FCurve_Edit_Callback func, void *user_data) -{ - AnimData *adt = BKE_animdata_from_id(id); - if (adt != NULL) { - AllFCurvesCbWrapper wrapper = {func, user_data}; - adt_apply_all_fcurves_cb(id, adt, &wrapper); - } -} - -/* apply the given callback function on all F-Curves attached to data in main database */ -void BKE_fcurves_main_cb(Main *bmain, ID_FCurve_Edit_Callback func, void *user_data) -{ - /* Wrap F-Curve operation stuff to pass to the general AnimData-level func */ - AllFCurvesCbWrapper wrapper = {func, user_data}; - - /* Use the AnimData-based function so that we don't have to reimplement all that stuff */ - BKE_animdata_main_cb(bmain, adt_apply_all_fcurves_cb, &wrapper); -} - -/* Whole Database Ops -------------------------------------------- */ - -/* apply the given callback function on all data in main database */ -void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *user_data) -{ - ID *id; - - /* standard data version */ -#define ANIMDATA_IDS_CB(first) \ - for (id = first; id; id = id->next) { \ - AnimData *adt = BKE_animdata_from_id(id); \ - if (adt) \ - func(id, adt, user_data); \ - } \ - (void)0 - - /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */ -#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \ - for (id = first; id; id = id->next) { \ - AnimData *adt = BKE_animdata_from_id(id); \ - NtId_Type *ntp = (NtId_Type *)id; \ - if (ntp->nodetree) { \ - AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ - if (adt2) \ - func(id, adt2, user_data); \ - } \ - if (adt) \ - func(id, adt, user_data); \ - } \ - (void)0 - - /* nodes */ - ANIMDATA_IDS_CB(bmain->nodetrees.first); - - /* textures */ - ANIMDATA_NODETREE_IDS_CB(bmain->textures.first, Tex); - - /* lights */ - ANIMDATA_NODETREE_IDS_CB(bmain->lights.first, Light); - - /* materials */ - ANIMDATA_NODETREE_IDS_CB(bmain->materials.first, Material); - - /* cameras */ - ANIMDATA_IDS_CB(bmain->cameras.first); - - /* shapekeys */ - ANIMDATA_IDS_CB(bmain->shapekeys.first); - - /* metaballs */ - ANIMDATA_IDS_CB(bmain->metaballs.first); - - /* curves */ - ANIMDATA_IDS_CB(bmain->curves.first); - - /* armatures */ - ANIMDATA_IDS_CB(bmain->armatures.first); - - /* lattices */ - ANIMDATA_IDS_CB(bmain->lattices.first); - - /* meshes */ - ANIMDATA_IDS_CB(bmain->meshes.first); - - /* particles */ - ANIMDATA_IDS_CB(bmain->particles.first); - - /* speakers */ - ANIMDATA_IDS_CB(bmain->speakers.first); - - /* movie clips */ - ANIMDATA_IDS_CB(bmain->movieclips.first); - - /* objects */ - ANIMDATA_IDS_CB(bmain->objects.first); - - /* masks */ - ANIMDATA_IDS_CB(bmain->masks.first); - - /* worlds */ - ANIMDATA_NODETREE_IDS_CB(bmain->worlds.first, World); - - /* scenes */ - ANIMDATA_NODETREE_IDS_CB(bmain->scenes.first, Scene); - - /* line styles */ - ANIMDATA_IDS_CB(bmain->linestyles.first); - - /* grease pencil */ - ANIMDATA_IDS_CB(bmain->gpencils.first); - - /* palettes */ - ANIMDATA_IDS_CB(bmain->palettes.first); - - /* cache files */ - ANIMDATA_IDS_CB(bmain->cachefiles.first); - - /* hairs */ - ANIMDATA_IDS_CB(bmain->hairs.first); - - /* pointclouds */ - ANIMDATA_IDS_CB(bmain->pointclouds.first); - - /* volumes */ - ANIMDATA_IDS_CB(bmain->volumes.first); -} - -/* Fix all RNA-Paths throughout the database (directly access the Global.main version) - * NOTE: it is assumed that the structure we're replacing is <["><"]> - * i.e. pose.bones["Bone"] - */ -/* TODO: use BKE_animdata_main_cb for looping over all data */ -void BKE_animdata_fix_paths_rename_all(ID *ref_id, - const char *prefix, - const char *oldName, - const char *newName) -{ - Main *bmain = G.main; /* XXX UGLY! */ - ID *id; - - /* macro for less typing - * - whether animdata exists is checked for by the main renaming callback, though taking - * this outside of the function may make things slightly faster? - */ -#define RENAMEFIX_ANIM_IDS(first) \ - for (id = first; id; id = id->next) { \ - AnimData *adt = BKE_animdata_from_id(id); \ - BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ - } \ - (void)0 - - /* another version of this macro for nodetrees */ -#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \ - for (id = first; id; id = id->next) { \ - AnimData *adt = BKE_animdata_from_id(id); \ - NtId_Type *ntp = (NtId_Type *)id; \ - if (ntp->nodetree) { \ - AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ - BKE_animdata_fix_paths_rename( \ - (ID *)ntp->nodetree, adt2, ref_id, prefix, oldName, newName, 0, 0, 1); \ - } \ - BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ - } \ - (void)0 - - /* nodes */ - RENAMEFIX_ANIM_IDS(bmain->nodetrees.first); - - /* textures */ - RENAMEFIX_ANIM_NODETREE_IDS(bmain->textures.first, Tex); - - /* lights */ - RENAMEFIX_ANIM_NODETREE_IDS(bmain->lights.first, Light); - - /* materials */ - RENAMEFIX_ANIM_NODETREE_IDS(bmain->materials.first, Material); - - /* cameras */ - RENAMEFIX_ANIM_IDS(bmain->cameras.first); - - /* shapekeys */ - RENAMEFIX_ANIM_IDS(bmain->shapekeys.first); - - /* metaballs */ - RENAMEFIX_ANIM_IDS(bmain->metaballs.first); - - /* curves */ - RENAMEFIX_ANIM_IDS(bmain->curves.first); - - /* armatures */ - RENAMEFIX_ANIM_IDS(bmain->armatures.first); - - /* lattices */ - RENAMEFIX_ANIM_IDS(bmain->lattices.first); - - /* meshes */ - RENAMEFIX_ANIM_IDS(bmain->meshes.first); - - /* particles */ - RENAMEFIX_ANIM_IDS(bmain->particles.first); - - /* speakers */ - RENAMEFIX_ANIM_IDS(bmain->speakers.first); - - /* movie clips */ - RENAMEFIX_ANIM_IDS(bmain->movieclips.first); - - /* objects */ - RENAMEFIX_ANIM_IDS(bmain->objects.first); - - /* masks */ - RENAMEFIX_ANIM_IDS(bmain->masks.first); - - /* worlds */ - RENAMEFIX_ANIM_NODETREE_IDS(bmain->worlds.first, World); - - /* linestyles */ - RENAMEFIX_ANIM_IDS(bmain->linestyles.first); - - /* grease pencil */ - RENAMEFIX_ANIM_IDS(bmain->gpencils.first); - - /* cache files */ - RENAMEFIX_ANIM_IDS(bmain->cachefiles.first); - - /* hairs */ - RENAMEFIX_ANIM_IDS(bmain->hairs.first); - - /* pointclouds */ - RENAMEFIX_ANIM_IDS(bmain->pointclouds.first); - - /* volumes */ - RENAMEFIX_ANIM_IDS(bmain->volumes.first); - - /* scenes */ - RENAMEFIX_ANIM_NODETREE_IDS(bmain->scenes.first, Scene); -} - /* *********************************** */ /* KeyingSet API */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 38a9864fd36..b8d0f8c8c92 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -52,7 +52,6 @@ #include "BKE_action.h" #include "BKE_anim_visualization.h" -#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_curve.h" diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 605fba18d89..d23b643ce70 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -39,7 +39,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_cachefile.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 30c2822e08b..323bb597127 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -38,7 +38,6 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_camera.h" #include "BKE_idtype.h" #include "BKE_layer.h" diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index ba1c75196db..51912e3375a 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -46,7 +46,6 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" -#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_font.h" diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 1054988f22f..4c78c88d168 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -46,7 +46,6 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" -#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_collection.h" diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 4bd55c3c2ca..fbca09001d6 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -45,6 +45,7 @@ #include "BLT_translation.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c index e17c6a00144..5cdb7761540 100644 --- a/source/blender/blenkernel/intern/hair.c +++ b/source/blender/blenkernel/intern/hair.c @@ -30,7 +30,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_hair.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 269235176cd..b0b88a13a75 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -58,7 +58,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index e5567a43cd7..2ca6e54b5c8 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -43,7 +43,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_deform.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 65412493049..d371af93bb7 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -46,7 +46,6 @@ #include "DNA_scene_types.h" #include "BKE_anim_path.h" -#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index a524db3c909..21e27784684 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -81,7 +81,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_bpath.h" #include "BKE_brush.h" diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index e1f4f36b822..245e4f43452 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -57,7 +57,7 @@ #include "BLI_listbase.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_brush.h" #include "BKE_cachefile.h" diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 886fb4241a4..72ac9e77790 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -63,7 +63,7 @@ #include "BLI_linklist_stack.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index aec0f808f64..3ecd1c81b27 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -37,7 +37,6 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_colortools.h" #include "BKE_icons.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index 4675897cb0e..22f12831aa0 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -29,7 +29,6 @@ #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_lightprobe.h" diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index db39931a9d2..42506e0d7c8 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -39,7 +39,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_context.h" diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 16ec4c0a313..bcf4b29ec07 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -54,7 +54,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index b708c030152..79e70ad2741 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -50,7 +50,6 @@ #include "BKE_main.h" -#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a59337bc4a2..2a86b899290 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -41,7 +41,7 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index aeb8f29b084..1964dba7593 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -53,7 +53,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 06ddf4a8582..de5f9d34f6c 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -50,6 +50,7 @@ #include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_idprop.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3f94958c779..733f112f80c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -68,6 +68,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_anim_path.h" #include "BKE_anim_visualization.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index f093b8c4211..474142e8555 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -40,7 +40,6 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" -#include "BKE_animsys.h" #include "BKE_collection.h" #include "BKE_duplilist.h" #include "BKE_editmesh.h" diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 3e93ca96982..c5ef5acb08b 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -37,7 +37,6 @@ #include "BKE_DerivedMesh.h" #include "BKE_action.h" -#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_curve.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5224fa3f8f6..c5d60b29aca 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -44,7 +44,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_ccg.h" #include "BKE_colortools.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 067eb6ab18e..87ac4428594 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -51,8 +51,6 @@ #include "BLT_translation.h" #include "BKE_anim_path.h" -#include "BKE_animsys.h" - #include "BKE_boids.h" #include "BKE_cloth.h" #include "BKE_collection.h" diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index 3e4cc5c6185..31b8de53291 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -30,7 +30,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_idtype.h" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0011247fcd0..8cbc1ba4d8e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -59,6 +59,7 @@ #include "BLT_translation.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_cachefile.h" diff --git a/source/blender/blenkernel/intern/seqprefetch.c b/source/blender/blenkernel/intern/seqprefetch.c index 8c7d119857a..1bd02212908 100644 --- a/source/blender/blenkernel/intern/seqprefetch.c +++ b/source/blender/blenkernel/intern/seqprefetch.c @@ -39,6 +39,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_layer.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3501ac642c5..996a9f34b61 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -58,6 +58,7 @@ #include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_fcurve.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index d81ebe0fb64..980cc2a59fd 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -28,7 +28,6 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index b0f000d6e04..ff9d9d163a1 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -49,7 +49,6 @@ #include "BKE_main.h" -#include "BKE_animsys.h" #include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_icons.h" diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 6e00a942283..2af40c8e8fb 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -33,7 +33,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_global.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 3492a35b242..f2219ad1cf8 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -35,7 +35,6 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_icons.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 739c816ad45..259602ecec6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -109,7 +109,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_brush.h" #include "BKE_collection.h" diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 7ae14a9b7ce..f1f7b4cf353 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -52,6 +52,7 @@ #include "DNA_genfile.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_colortools.h" #include "BKE_fcurve.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 18ab9bf7e43..d880618753c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -37,10 +37,6 @@ #include "BKE_action.h" -extern "C" { -#include "BKE_animsys.h" -} - #include "intern/builder/deg_builder_cache.h" #include "intern/builder/deg_builder_remove_noop.h" #include "intern/depsgraph.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index eee1a9d2fc8..04333dbd038 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -66,6 +66,7 @@ extern "C" { #include "DNA_world_types.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_cachefile.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 9258af3e164..89def9e0bdc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -69,7 +69,7 @@ extern "C" { #include "DNA_world_types.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_collection.h" #include "BKE_collision.h" diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 3b0782cd5d6..f1180c16a87 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -44,7 +44,7 @@ extern "C" { #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_global.h" #include "BKE_idtype.h" #include "BKE_node.h" diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index f51def4caa9..b87a877ae99 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -82,6 +82,7 @@ extern "C" { #endif #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_editmesh.h" diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 0bb09390b4f..4b6120a6985 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -34,7 +34,6 @@ extern "C" { #include "DNA_ID.h" #include "DNA_anim_types.h" -#include "BKE_animsys.h" #include "BKE_lib_id.h" } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 2c1b7f3fb76..b569f909d7a 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -58,6 +58,7 @@ #include "RNA_access.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_curve.h" diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 28f80994c4d..a1b1c7815d8 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -42,7 +42,7 @@ #include "RNA_define.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_global.h" diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 6f7770d97f1..4fb68b614ff 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -38,7 +38,7 @@ #include "BLI_utildefines.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_gpencil.h" diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 23c95f186d7..5ea5b2aa1f6 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -82,7 +82,7 @@ #include "BLI_utildefines.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 7e36799ff1b..a4ecd346a01 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -31,7 +31,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_main.h" #include "BKE_scene.h" diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index ee0f403a155..3ae4e3bf998 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -36,6 +36,7 @@ #include "DNA_space_types.h" #include "DNA_texture_types.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 954daff560f..e795cb6e3ef 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -42,7 +42,6 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4c3a2a36e0a..49e936d22aa 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -45,6 +45,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_context.h" diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 4580d2c30ae..c592287c967 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -37,6 +37,7 @@ #include "BLT_translation.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index efb568178d9..e2038bdd2a3 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -32,7 +32,7 @@ #include "DNA_scene_types.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_idprop.h" #include "BKE_layer.h" diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index de2c3d44caf..45e278d691c 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -36,7 +36,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c index 94a0ef7a460..af492de638b 100644 --- a/source/blender/editors/curve/editcurve_undo.c +++ b/source/blender/editors/curve/editcurve_undo.c @@ -30,7 +30,7 @@ #include "BLI_blenlib.h" #include "BLI_ghash.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 1c93eed1cd6..24c3e9a0635 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -50,6 +50,7 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_context.h" diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 41b7683dff7..78db23a380a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -44,7 +44,6 @@ #include "BLI_utildefines.h" -#include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_idprop.h" #include "BKE_main.h" diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6c856a0e8dd..6e86b60dc53 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -39,7 +39,7 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_idprop.h" diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index e800203ae79..a74dc6a1384 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -53,7 +53,7 @@ #include "BLT_translation.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_camera.h" #include "BKE_collection.h" diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5d821308759..c5fccc5defd 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -55,7 +55,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_camera.h" #include "BKE_collection.h" diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 5a701ef8aa8..c23ce8a8a9e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -43,7 +43,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_customdata.h" diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 99d9d585a30..49ab2c485b1 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -42,6 +42,7 @@ #include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index beb5d6637ea..a356962946e 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -42,7 +42,6 @@ #include "RNA_enum_types.h" #include "BKE_action.h" -#include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_key.h" diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 5216bf357c4..b1f9da1cd5c 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -38,7 +38,7 @@ #include "BLT_translation.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index a69aed38cab..d08d39700d6 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -33,7 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_nla.h" diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 8dfa99ca126..03a99a74614 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -30,7 +30,7 @@ #include "BLI_easing.h" #include "BLI_math.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_lib_id.h" #include "BKE_main.h" diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 12be08550af..730d0019f77 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_collection.h" #include "BKE_constraint.h" diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6306e388f3f..05318a5c1d3 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -64,7 +64,7 @@ #include "BIK_api.h" #include "BKE_action.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_curve.h" diff --git a/source/blender/io/alembic/intern/abc_writer_mesh.cc b/source/blender/io/alembic/intern/abc_writer_mesh.cc index f81b9505048..a47fe55750e 100644 --- a/source/blender/io/alembic/intern/abc_writer_mesh.cc +++ b/source/blender/io/alembic/intern/abc_writer_mesh.cc @@ -28,7 +28,7 @@ extern "C" { #include "DNA_meshdata_types.h" #include "DNA_object_fluidsim_types.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_key.h" #include "BKE_lib_id.h" #include "BKE_material.h" diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h index e95a1b93163..3e40a485ddf 100644 --- a/source/blender/io/collada/AnimationExporter.h +++ b/source/blender/io/collada/AnimationExporter.h @@ -42,7 +42,6 @@ extern "C" { #include "BIK_api.h" #include "BKE_action.h" // pose functions -#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_fcurve.h" diff --git a/source/blender/io/collada/SceneExporter.h b/source/blender/io/collada/SceneExporter.h index 382f716e5a3..6effb54fd48 100644 --- a/source/blender/io/collada/SceneExporter.h +++ b/source/blender/io/collada/SceneExporter.h @@ -42,7 +42,6 @@ extern "C" { #include "DNA_texture_types.h" #include "DNA_userdef_types.h" -#include "BKE_animsys.h" #include "BKE_constraint.h" #include "BKE_fcurve.h" #include "BLI_fileops.h" diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc index 89f75a6ad80..71cab020e57 100644 --- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc @@ -24,7 +24,7 @@ #include extern "C" { -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_duplilist.h" #include "BKE_key.h" #include "BKE_particle.h" diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 42cec23975c..7a371a1a1d5 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -93,7 +93,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { # include "BLI_listbase.h" # include "BLI_math_base.h" -# include "BKE_animsys.h" +# include "BKE_anim_data.h" # include "BKE_font.h" # include "BKE_global.h" /* XXX, remove me */ # include "BKE_idprop.h" diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 48e4d758bba..b56a18c18a9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -40,7 +40,7 @@ #include "BLF_api.h" #include "BLT_translation.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_fcurve.h" diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 1ca1bf27156..86391bdc40d 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -113,6 +113,7 @@ const EnumPropertyItem rna_enum_keying_flag_items_api[] = { # include "BLI_math_base.h" +# include "BKE_anim_data.h" # include "BKE_animsys.h" # include "BKE_fcurve.h" # include "BKE_nla.h" diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index b6a2d38ba18..33f19153e3a 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -211,7 +211,7 @@ static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr) /* ****************************** */ -# include "BKE_animsys.h" +# include "BKE_anim_data.h" # include "BKE_fcurve.h" # include "DEG_depsgraph.h" diff --git a/source/blender/makesrna/intern/rna_fcurve_api.c b/source/blender/makesrna/intern/rna_fcurve_api.c index 4ee25be946c..f7be65b4e75 100644 --- a/source/blender/makesrna/intern/rna_fcurve_api.c +++ b/source/blender/makesrna/intern/rna_fcurve_api.c @@ -39,7 +39,6 @@ # include -# include "BKE_animsys.h" # include "BKE_fcurve.h" # include "BLI_math.h" diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 304cfb49594..230d62d2a23 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -43,7 +43,7 @@ # include /* needed for some of the validation stuff... */ -# include "BKE_animsys.h" +# include "BKE_anim_data.h" # include "BKE_fcurve.h" # include "BKE_nla.h" diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index ce44765fb7b..e770b669ca2 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -50,7 +50,6 @@ const EnumPropertyItem rna_enum_abc_compression_items[] = { #ifdef RNA_RUNTIME -# include "BKE_animsys.h" # include "BKE_editmesh.h" # include "BKE_global.h" # include "BKE_image.h" diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6677105b771..e0549a323a1 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -32,6 +32,7 @@ #include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_sequencer.h" #include "BKE_sound.h" diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 01ecbb6c118..f61d2dcf563 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -491,7 +491,7 @@ const EnumPropertyItem rna_enum_file_sort_items[] = { # include "BLI_path_util.h" # include "BLI_string.h" -# include "BKE_animsys.h" +# include "BKE_anim_data.h" # include "BKE_brush.h" # include "BKE_colortools.h" # include "BKE_context.h" diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index c8965f1a6fb..131c13c4d90 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -43,6 +43,7 @@ # include "DNA_anim_types.h" +# include "BKE_anim_data.h" # include "BKE_animsys.h" # include "BKE_node.h" diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index c8af6377d59..d8043ee2fdf 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -35,7 +35,7 @@ #include "ED_keyframes_edit.h" #include "ED_keyframing.h" -#include "BKE_animsys.h" +#include "BKE_anim_data.h" #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_global.h" diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 87568402df3..1a97332212d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -51,6 +51,7 @@ #include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ #include "BKE_callbacks.h" #include "BKE_camera.h" diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 22cc1f0eddf..eabba94ef29 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -46,7 +46,6 @@ #include "BKE_image.h" #include "BKE_node.h" -#include "BKE_animsys.h" #include "BKE_colorband.h" #include "BKE_material.h" #include "BKE_scene.h" -- cgit v1.2.3 From d1011c9e641220c335aab2456b0598e2c6707d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Apr 2020 10:39:57 +0200 Subject: Cleanup: clarification of 'name' in BKE_idtype functions The 'name' parameter of `BKE_idtype_idcode_from_name()`, and the `str` parameter of `idtype_get_info_from_name()`, are expected to be the 'user visible name' of an `IDTypeInfo` struct. This is made clearer in the code by renaming those parameters to `idtype_name` and mentioning it in the documentation of the `BKE_idtype_idcode_from_name()` function. Differential Revision: https://developer.blender.org/D7317 --- source/blender/blenkernel/BKE_idtype.h | 2 +- source/blender/blenkernel/intern/idtype.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h index 93bcfe5323d..05545216217 100644 --- a/source/blender/blenkernel/BKE_idtype.h +++ b/source/blender/blenkernel/BKE_idtype.h @@ -183,7 +183,7 @@ const char *BKE_idtype_idcode_to_translation_context(const short idcode); bool BKE_idtype_idcode_is_linkable(const short idcode); bool BKE_idtype_idcode_is_valid(const short idcode); -short BKE_idtype_idcode_from_name(const char *name); +short BKE_idtype_idcode_from_name(const char *idtype_name); uint64_t BKE_idtype_idcode_to_idfilter(const short idcode); short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter); diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index b7fc167cf33..5a6e8f532c9 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -124,10 +124,10 @@ const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id) return BKE_idtype_get_info_from_idcode(GS(id->name)); } -static const IDTypeInfo *idtype_get_info_from_name(const char *str) +static const IDTypeInfo *idtype_get_info_from_name(const char *idtype_name) { for (int i = ARRAY_SIZE(id_types); i--;) { - if (id_types[i] != NULL && STREQ(str, id_types[i]->name)) { + if (id_types[i] != NULL && STREQ(idtype_name, id_types[i]->name)) { return id_types[i]; } } @@ -179,14 +179,14 @@ const char *BKE_idtype_idcode_to_translation_context(const short idcode) } /** - * Convert a name into an idcode (ie. ID_SCE) + * Convert an IDType name into an idcode (ie. ID_SCE) * - * \param name: The name to convert. - * \return The code for the name, or 0 if invalid. + * \param idtype_name: The IDType's 'user visible name' to convert. + * \return The idcode for the name, or 0 if invalid. */ -short BKE_idtype_idcode_from_name(const char *name) +short BKE_idtype_idcode_from_name(const char *idtype_name) { - const IDTypeInfo *id_type = idtype_get_info_from_name(name); + const IDTypeInfo *id_type = idtype_get_info_from_name(idtype_name); BLI_assert(id_type); return id_type != NULL ? id_type->id_code : 0; } -- cgit v1.2.3 From bfdc42d9906a08ecc8033eeb9fe267e0a7e5265b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Thu, 2 Apr 2020 13:48:50 +0200 Subject: Fluid: Refactored MANTA class Refactored the caching system so that return values are no longer ignored. The aim of this refactor was to make the caching more robust. --- intern/mantaflow/intern/MANTA_main.cpp | 647 +++++++++++++++++++-------------- intern/mantaflow/intern/MANTA_main.h | 65 ++-- 2 files changed, 407 insertions(+), 305 deletions(-) diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index d14ab8d6dd3..3555e098caf 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -48,7 +48,6 @@ #include "MEM_guardedalloc.h" -std::atomic MANTA::mantaInitialized(false); std::atomic MANTA::solverID(0); int MANTA::with_debug(0); @@ -523,6 +522,7 @@ MANTA::~MANTA() // Destruction string for Python std::string tmpString = ""; std::vector pythonCommands; + bool result = false; tmpString += manta_import; tmpString += fluid_delete_all; @@ -530,11 +530,15 @@ MANTA::~MANTA() // Leave out mmd argument in parseScript since only looking up IDs std::string finalString = parseScript(tmpString); pythonCommands.push_back(finalString); - runPythonString(pythonCommands); + result = runPythonString(pythonCommands); + + assert(result); + (void)result; // not needed in release } -void MANTA::runPythonString(std::vector commands) +bool MANTA::runPythonString(std::vector commands) { + int success = -1; PyGILState_STATE gilstate = PyGILState_Ensure(); for (std::vector::iterator it = commands.begin(); it != commands.end(); ++it) { std::string command = *it; @@ -546,19 +550,23 @@ void MANTA::runPythonString(std::vector commands) memcpy(buffer, command.data(), cmdLength); buffer[cmdLength] = '\0'; - PyRun_SimpleString(buffer); + success = PyRun_SimpleString(buffer); delete[] buffer; #else - PyRun_SimpleString(command.c_str()); + success = PyRun_SimpleString(command.c_str()); #endif } PyGILState_Release(gilstate); + + /* PyRun_SimpleString returns 0 on success, -1 when an error occurred. */ + assert(success == 0); + return (success != -1); } void MANTA::initializeMantaflow() { if (with_debug) - std::cout << "Initializing Mantaflow" << std::endl; + std::cout << "Fluid: Initializing Mantaflow framework." << std::endl; std::string filename = "manta_scene_" + std::to_string(mCurrentID) + ".py"; std::vector fill = std::vector(); @@ -568,18 +576,16 @@ void MANTA::initializeMantaflow() PyGILState_STATE gilstate = PyGILState_Ensure(); Pb::setup(filename, fill); // Namespace from Mantaflow (registry) PyGILState_Release(gilstate); - mantaInitialized = true; } void MANTA::terminateMantaflow() { if (with_debug) - std::cout << "Terminating Mantaflow" << std::endl; + std::cout << "Fluid: Releasing Mantaflow framework." << std::endl; PyGILState_STATE gilstate = PyGILState_Ensure(); Pb::finalize(); // Namespace from Mantaflow (registry) PyGILState_Release(gilstate); - mantaInitialized = false; } static std::string getCacheFileEnding(char cache_format) @@ -599,8 +605,8 @@ static std::string getCacheFileEnding(char cache_format) case FLUID_DOMAIN_FILE_OBJECT: return ".obj"; default: - if (MANTA::with_debug) - std::cout << "Error: Could not find file extension" << std::endl; + std::cerr << "Fluid Error -- Could not find file extension. Using default file extension." + << std::endl; return ".uni"; } } @@ -618,8 +624,7 @@ std::string MANTA::getRealValue(const std::string &varName, FluidModifierData *m } if (!mmd) { - if (with_debug) - std::cout << "Invalid modifier data in getRealValue()" << std::endl; + std::cerr << "Fluid Error -- Invalid modifier data." << std::endl; ss << "ERROR - INVALID MODIFIER DATA"; return ss.str(); } @@ -994,7 +999,7 @@ std::string MANTA::getRealValue(const std::string &varName, FluidModifierData *m else if (varName == "USING_DIFFUSION") ss << (mmd->domain->flags & FLUID_DOMAIN_USE_DIFFUSION ? "True" : "False"); else - std::cout << "ERROR: Unknown option: " << varName << std::endl; + std::cerr << "Fluid Error -- Unknown option: " << varName << std::endl; return ss.str(); } @@ -1034,24 +1039,27 @@ std::string MANTA::parseScript(const std::string &setup_string, FluidModifierDat return res.str(); } -int MANTA::updateFlipStructures(FluidModifierData *mmd, int framenr) +bool MANTA::updateFlipStructures(FluidModifierData *mmd, int framenr) { if (MANTA::with_debug) std::cout << "MANTA::updateFlipStructures()" << std::endl; mFlipFromFile = false; + if (!mUsingLiquid) + return false; + if (BLI_path_is_rel(mmd->domain->cache_directory)) + return false; + + int result = 0; + int expected = 0; /* Expected number of read successes for this frame. */ + // Ensure empty data structures at start if (mFlipParticleData) mFlipParticleData->clear(); if (mFlipParticleVelocity) mFlipParticleVelocity->clear(); - if (!mUsingLiquid) - return 0; - if (BLI_path_is_rel(mmd->domain->cache_directory)) - return 0; - std::ostringstream ss; char cacheDir[FILE_MAX], targetFile[FILE_MAX]; cacheDir[0] = '\0'; @@ -1061,27 +1069,31 @@ int MANTA::updateFlipStructures(FluidModifierData *mmd, int framenr) BLI_path_join( cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_DATA, nullptr); + expected += 1; + ss.str(""); ss << "pp_####" << pformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateParticlesFromFile(targetFile, false, false); + result += updateParticlesFromFile(targetFile, false, false); + assert(result == expected); } + expected += 1; ss.str(""); ss << "pVel_####" << pformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateParticlesFromFile(targetFile, false, true); + result += updateParticlesFromFile(targetFile, false, true); + assert(result == expected); } + mFlipFromFile = true; - return 1; + return (result == expected); } -int MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr) +bool MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr) { if (MANTA::with_debug) std::cout << "MANTA::updateMeshStructures()" << std::endl; @@ -1089,9 +1101,12 @@ int MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr) mMeshFromFile = false; if (!mUsingMesh) - return 0; + return false; if (BLI_path_is_rel(mmd->domain->cache_directory)) - return 0; + return false; + + int result = 0; + int expected = 0; /* Expected number of read successes for this frame. */ // Ensure empty data structures at start if (mMeshNodes) @@ -1111,29 +1126,33 @@ int MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr) BLI_path_join( cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_MESH, nullptr); + expected += 1; + ss.str(""); ss << "lMesh_####" << mformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateMeshFromFile(targetFile); + result += updateMeshFromFile(targetFile); + assert(result == expected); } if (mUsingMVel) { + expected += 1; ss.str(""); ss << "lVelMesh_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateMeshFromFile(targetFile); + result += updateMeshFromFile(targetFile); + assert(result == expected); } } + mMeshFromFile = true; - return 1; + return (result == expected); } -int MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr) +bool MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr) { if (MANTA::with_debug) std::cout << "MANTA::updateParticleStructures()" << std::endl; @@ -1141,9 +1160,12 @@ int MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr) mParticlesFromFile = false; if (!mUsingDrops && !mUsingBubbles && !mUsingFloats && !mUsingTracers) - return 0; + return false; if (BLI_path_is_rel(mmd->domain->cache_directory)) - return 0; + return false; + + int result = 0; + int expected = 0; /* Expected number of read successes for this frame. */ // Ensure empty data structures at start if (mSndParticleData) @@ -1165,36 +1187,41 @@ int MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr) FLUID_DOMAIN_DIR_PARTICLES, nullptr); + expected += 1; + ss.str(""); ss << "ppSnd_####" << pformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateParticlesFromFile(targetFile, true, false); + result += updateParticlesFromFile(targetFile, true, false); + assert(result == expected); } + expected += 1; ss.str(""); ss << "pVelSnd_####" << pformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateParticlesFromFile(targetFile, true, true); + result += updateParticlesFromFile(targetFile, true, true); + assert(result == expected); } + expected += 1; ss.str(""); ss << "pLifeSnd_####" << pformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - updateParticlesFromFile(targetFile, true, false); + result += updateParticlesFromFile(targetFile, true, false); + assert(result == expected); } + mParticlesFromFile = true; - return 1; + return (result == expected); } -int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) +bool MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) { if (MANTA::with_debug) std::cout << "MANTA::updateGridStructures()" << std::endl; @@ -1202,9 +1229,9 @@ int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) mSmokeFromFile = false; if (!mUsingSmoke) - return 0; + return false; if (BLI_path_is_rel(mmd->domain->cache_directory)) - return 0; + return false; int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ @@ -1223,20 +1250,20 @@ int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) ss << "density_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mDensity, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mDensity, false); expected += 1; ss.str(""); ss << "shadow_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mShadow, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mShadow, false); if (mUsingHeat) { expected += 1; @@ -1244,10 +1271,10 @@ int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) ss << "heat_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mHeat, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mHeat, false); } if (mUsingColors) { @@ -1256,28 +1283,28 @@ int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) ss << "color_r_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorR, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorR, false); ss.str(""); ss << "color_g_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorG, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorG, false); ss.str(""); ss << "color_b_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorB, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorB, false); } if (mUsingFire) { @@ -1286,35 +1313,35 @@ int MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) ss << "flame_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mFlame, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mFlame, false); ss.str(""); ss << "fuel_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mFuel, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mFuel, false); ss.str(""); ss << "react_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mReact, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mReact, false); } mSmokeFromFile = true; - return (result == expected) ? 1 : 0; + return (result == expected); } -int MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) +bool MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) { if (MANTA::with_debug) std::cout << "MANTA::updateNoiseStructures()" << std::endl; @@ -1322,9 +1349,9 @@ int MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) mNoiseFromFile = false; if (!mUsingSmoke || !mUsingNoise) - return 0; + return false; if (BLI_path_is_rel(mmd->domain->cache_directory)) - return 0; + return false; int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ @@ -1353,20 +1380,20 @@ int MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) ss << "density_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mDensityHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mDensityHigh, true); expected += 1; ss.str(""); ss << "shadow_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mShadow, false); + assert(result == expected); } - result += updateGridFromFile(targetFile, mShadow, false); if (mUsingColors) { expected += 3; @@ -1374,28 +1401,28 @@ int MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) ss << "color_r_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorRHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorRHigh, true); ss.str(""); ss << "color_g_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorGHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorGHigh, true); ss.str(""); ss << "color_b_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mColorBHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mColorBHigh, true); } if (mUsingFire) { @@ -1404,32 +1431,32 @@ int MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) ss << "flame_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mFlameHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mFlameHigh, true); ss.str(""); ss << "fuel_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mFuelHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mFuelHigh, true); ss.str(""); ss << "react_noise_####" << nformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) { - return 0; + if (BLI_exists(targetFile)) { + result += updateGridFromFile(targetFile, mReactHigh, true); + assert(result == expected); } - result += updateGridFromFile(targetFile, mReactHigh, true); } mNoiseFromFile = true; - return (result == expected) ? 1 : 0; + return (result == expected); } /* Dirty hack: Needed to format paths from python code that is run via PyRun_SimpleString */ @@ -1446,7 +1473,7 @@ static std::string escapeSlashes(std::string const &s) return result; } -int MANTA::writeConfiguration(FluidModifierData *mmd, int framenr) +bool MANTA::writeConfiguration(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::writeConfiguration()" << std::endl; @@ -1470,8 +1497,10 @@ int MANTA::writeConfiguration(FluidModifierData *mmd, int framenr) BLI_path_frame(targetFile, framenr, 0); gzFile gzf = (gzFile)BLI_gzopen(targetFile, "wb1"); // do some compression - if (!gzf) - std::cerr << "writeConfiguration: can't open file: " << targetFile << std::endl; + if (!gzf) { + std::cerr << "Fluid Error -- Cannot open file " << targetFile << std::endl; + return false; + } gzwrite(gzf, &mds->active_fields, sizeof(int)); gzwrite(gzf, &mds->res, 3 * sizeof(int)); @@ -1488,12 +1517,10 @@ int MANTA::writeConfiguration(FluidModifierData *mmd, int framenr) gzwrite(gzf, &mds->res_max, 3 * sizeof(int)); gzwrite(gzf, &mds->active_color, 3 * sizeof(float)); - gzclose(gzf); - - return 1; + return (gzclose(gzf) == Z_OK); } -int MANTA::writeData(FluidModifierData *mmd, int framenr) +bool MANTA::writeData(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::writeData()" << std::endl; @@ -1534,11 +1561,10 @@ int MANTA::writeData(FluidModifierData *mmd, int framenr) << framenr << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); } - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::readConfiguration(FluidModifierData *mmd, int framenr) +bool MANTA::readConfiguration(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::readConfiguration()" << std::endl; @@ -1562,11 +1588,13 @@ int MANTA::readConfiguration(FluidModifierData *mmd, int framenr) BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; gzFile gzf = (gzFile)BLI_gzopen(targetFile, "rb"); // do some compression - if (!gzf) - std::cerr << "readConfiguration: can't open file: " << targetFile << std::endl; + if (!gzf) { + std::cerr << "Fluid Error -- Cannot open file " << targetFile << std::endl; + return false; + } gzread(gzf, &mds->active_fields, sizeof(int)); gzread(gzf, &mds->res, 3 * sizeof(int)); @@ -1584,17 +1612,16 @@ int MANTA::readConfiguration(FluidModifierData *mmd, int framenr) gzread(gzf, &mds->active_color, 3 * sizeof(float)); mds->total_cells = mds->res[0] * mds->res[1] * mds->res[2]; - gzclose(gzf); - return 1; + return (gzclose(gzf) == Z_OK); } -int MANTA::readData(FluidModifierData *mmd, int framenr) +bool MANTA::readData(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::readData()" << std::endl; if (!mUsingSmoke && !mUsingLiquid) - return 0; + return false; std::ostringstream ss; std::vector pythonCommands; @@ -1623,14 +1650,14 @@ int MANTA::readData(FluidModifierData *mmd, int framenr) BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; } if (mUsingLiquid) { ss << "phi_####" << dformat; BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; } ss.str(""); @@ -1651,17 +1678,16 @@ int MANTA::readData(FluidModifierData *mmd, int framenr) << framenr << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); } - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::readNoise(FluidModifierData *mmd, int framenr) +bool MANTA::readNoise(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::readNoise()" << std::endl; if (!mUsingSmoke || !mUsingNoise) - return 0; + return false; std::ostringstream ss; std::vector pythonCommands; @@ -1688,27 +1714,26 @@ int MANTA::readNoise(FluidModifierData *mmd, int framenr) BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; ss.str(""); ss << "smoke_load_noise_" << mCurrentID << "('" << escapeSlashes(cacheDirNoise) << "', " << framenr << ", '" << nformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -/* Deprecated! This function read mesh data via the Manta Python API. +/* Deprecated! This function reads mesh data via the Manta Python API. * MANTA:updateMeshStructures() reads cache files directly from disk * and is preferred due to its better performance. */ -int MANTA::readMesh(FluidModifierData *mmd, int framenr) +bool MANTA::readMesh(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::readMesh()" << std::endl; if (!mUsingLiquid || !mUsingMesh) - return 0; + return false; std::ostringstream ss; std::vector pythonCommands; @@ -1733,7 +1758,7 @@ int MANTA::readMesh(FluidModifierData *mmd, int framenr) BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirMesh, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; ss.str(""); ss << "liquid_load_mesh_" << mCurrentID << "('" << escapeSlashes(cacheDirMesh) << "', " @@ -1747,22 +1772,21 @@ int MANTA::readMesh(FluidModifierData *mmd, int framenr) pythonCommands.push_back(ss.str()); } - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } /* Deprecated! This function reads particle data via the Manta Python API. * MANTA:updateParticleStructures() reads cache files directly from disk * and is preferred due to its better performance. */ -int MANTA::readParticles(FluidModifierData *mmd, int framenr) +bool MANTA::readParticles(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::readParticles()" << std::endl; if (!mUsingLiquid) - return 0; + return false; if (!mUsingDrops && !mUsingBubbles && !mUsingFloats && !mUsingTracers) - return 0; + return false; std::ostringstream ss; std::vector pythonCommands; @@ -1789,26 +1813,25 @@ int MANTA::readParticles(FluidModifierData *mmd, int framenr) BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirParticles, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; ss.str(""); ss << "liquid_load_particles_" << mCurrentID << "('" << escapeSlashes(cacheDirParticles) << "', " << framenr << ", '" << pformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) +bool MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) { if (with_debug) std::cout << "MANTA::readGuiding()" << std::endl; if (!mUsingGuiding) - return 0; + return false; if (!mmd->domain) - return 0; + return false; std::ostringstream ss; std::vector pythonCommands; @@ -1830,7 +1853,7 @@ int MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirGuiding, ss.str().c_str()); BLI_path_frame(targetFile, framenr, 0); if (!BLI_exists(targetFile)) - return 0; + return false; if (sourceDomain) { ss.str(""); @@ -1844,11 +1867,10 @@ int MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) } pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::bakeData(FluidModifierData *mmd, int framenr) +bool MANTA::bakeData(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::bakeData()" << std::endl; @@ -1884,11 +1906,10 @@ int MANTA::bakeData(FluidModifierData *mmd, int framenr) << "', '" << gformat << "')"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::bakeNoise(FluidModifierData *mmd, int framenr) +bool MANTA::bakeNoise(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::bakeNoise()" << std::endl; @@ -1925,11 +1946,10 @@ int MANTA::bakeNoise(FluidModifierData *mmd, int framenr) << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::bakeMesh(FluidModifierData *mmd, int framenr) +bool MANTA::bakeMesh(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::bakeMesh()" << std::endl; @@ -1964,11 +1984,10 @@ int MANTA::bakeMesh(FluidModifierData *mmd, int framenr) << "', '" << pformat << "')"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::bakeParticles(FluidModifierData *mmd, int framenr) +bool MANTA::bakeParticles(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::bakeParticles()" << std::endl; @@ -2005,11 +2024,10 @@ int MANTA::bakeParticles(FluidModifierData *mmd, int framenr) << pformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -int MANTA::bakeGuiding(FluidModifierData *mmd, int framenr) +bool MANTA::bakeGuiding(FluidModifierData *mmd, int framenr) { if (with_debug) std::cout << "MANTA::bakeGuiding()" << std::endl; @@ -2037,11 +2055,10 @@ int MANTA::bakeGuiding(FluidModifierData *mmd, int framenr) << ", '" << gformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - runPythonString(pythonCommands); - return 1; + return runPythonString(pythonCommands); } -void MANTA::updateVariables(FluidModifierData *mmd) +bool MANTA::updateVariables(FluidModifierData *mmd) { std::string tmpString, finalString; std::vector pythonCommands; @@ -2068,7 +2085,7 @@ void MANTA::updateVariables(FluidModifierData *mmd) finalString = parseScript(tmpString, mmd); pythonCommands.push_back(finalString); - runPythonString(pythonCommands); + return runPythonString(pythonCommands); } void MANTA::exportSmokeScript(FluidModifierData *mmd) @@ -2436,7 +2453,7 @@ void MANTA::adaptTimestep() runPythonString(pythonCommands); } -void MANTA::updateMeshFromFile(const char *filename) +bool MANTA::updateMeshFromFile(const char *filename) { std::string fname(filename); std::string::size_type idx; @@ -2446,20 +2463,23 @@ void MANTA::updateMeshFromFile(const char *filename) std::string extension = fname.substr(idx + 1); if (extension.compare("gz") == 0) - updateMeshFromBobj(filename); + return updateMeshFromBobj(filename); else if (extension.compare("obj") == 0) - updateMeshFromObj(filename); + return updateMeshFromObj(filename); else if (extension.compare("uni") == 0) - updateMeshFromUni(filename); + return updateMeshFromUni(filename); else - std::cerr << "updateMeshFromFile: invalid file extension in file: " << filename << std::endl; + std::cerr << "Fluid Error -- updateMeshFromFile(): Invalid file extension in file: " + << filename << std::endl; } else { - std::cerr << "updateMeshFromFile: unable to open file: " << filename << std::endl; + std::cerr << "Fluid Error -- updateMeshFromFile(): Unable to open file: " << filename + << std::endl; } + return false; } -void MANTA::updateMeshFromBobj(const char *filename) +bool MANTA::updateMeshFromBobj(const char *filename) { if (with_debug) std::cout << "MANTA::updateMeshFromBobj()" << std::endl; @@ -2467,19 +2487,29 @@ void MANTA::updateMeshFromBobj(const char *filename) gzFile gzf; gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression - if (!gzf) - std::cerr << "updateMeshData: unable to open file: " << filename << std::endl; + if (!gzf) { + std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to open file: " << filename + << std::endl; + return false; + } - int numBuffer = 0; + int numBuffer = 0, readBytes = 0; // Num vertices - gzread(gzf, &numBuffer, sizeof(int)); + readBytes = gzread(gzf, &numBuffer, sizeof(int)); + if (!readBytes) { + std::cerr + << "Fluid Error -- updateMeshFromBobj(): Unable to read number of mesh vertices from " + << filename << std::endl; + gzclose(gzf); + return false; + } if (with_debug) std::cout << "read mesh , num verts: " << numBuffer << " , in file: " << filename << std::endl; int numChunks = (int)(ceil((float)numBuffer / NODE_CHUNK)); - int readLen, readStart, readEnd, readBytes, k; + int readLen, readStart, readEnd, k; if (numBuffer) { // Vertices @@ -2497,11 +2527,11 @@ void MANTA::updateMeshFromBobj(const char *filename) readBytes = gzread(gzf, bufferVerts, readLen * sizeof(float) * 3); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading vertices" << std::endl; + std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to read mesh vertices from " + << filename << std::endl; MEM_freeN(bufferVerts); gzclose(gzf); - return; + return false; } readStart = (numBuffer - todoVertices); @@ -2521,7 +2551,13 @@ void MANTA::updateMeshFromBobj(const char *filename) } // Num normals - gzread(gzf, &numBuffer, sizeof(int)); + readBytes = gzread(gzf, &numBuffer, sizeof(int)); + if (!readBytes) { + std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to read number of mesh normals from " + << filename << std::endl; + gzclose(gzf); + return false; + } if (with_debug) std::cout << "read mesh , num normals : " << numBuffer << " , in file: " << filename @@ -2544,11 +2580,11 @@ void MANTA::updateMeshFromBobj(const char *filename) readBytes = gzread(gzf, bufferNormals, readLen * sizeof(float) * 3); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading normals" << std::endl; + std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to read mesh normals from " + << filename << std::endl; MEM_freeN(bufferNormals); gzclose(gzf); - return; + return false; } readStart = (numBuffer - todoNormals); @@ -2568,10 +2604,17 @@ void MANTA::updateMeshFromBobj(const char *filename) } // Num triangles - gzread(gzf, &numBuffer, sizeof(int)); + readBytes = gzread(gzf, &numBuffer, sizeof(int)); + if (!readBytes) { + std::cerr + << "Fluid Error -- updateMeshFromBobj(): Unable to read number of mesh triangles from " + << filename << std::endl; + gzclose(gzf); + return false; + } if (with_debug) - std::cout << "read mesh , num triangles : " << numBuffer << " , in file: " << filename + std::cout << "Fluid: Read mesh , num triangles : " << numBuffer << " , in file: " << filename << std::endl; numChunks = (int)(ceil((float)numBuffer / TRIANGLE_CHUNK)); @@ -2592,11 +2635,11 @@ void MANTA::updateMeshFromBobj(const char *filename) readBytes = gzread(gzf, bufferTriangles, readLen * sizeof(int) * 3); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading triangles" << std::endl; + std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to read mesh triangles from " + << filename << std::endl; MEM_freeN(bufferTriangles); gzclose(gzf); - return; + return false; } readStart = (numBuffer - todoTriangles); @@ -2614,10 +2657,10 @@ void MANTA::updateMeshFromBobj(const char *filename) } MEM_freeN(bufferTriangles); } - gzclose(gzf); + return (gzclose(gzf) == Z_OK); } -void MANTA::updateMeshFromObj(const char *filename) +bool MANTA::updateMeshFromObj(const char *filename) { if (with_debug) std::cout << "MANTA::updateMeshFromObj()" << std::endl; @@ -2627,8 +2670,11 @@ void MANTA::updateMeshFromObj(const char *filename) int ibuffer[3]; int cntVerts = 0, cntNormals = 0, cntTris = 0; - if (!ifs.good()) - std::cerr << "updateMeshDataFromObj: unable to open file: " << filename << std::endl; + if (!ifs.good()) { + std::cerr << "Fluid Error -- updateMeshFromObj(): Unable to open file: " << filename + << std::endl; + return false; + } while (ifs.good() && !ifs.eof()) { std::string id; @@ -2644,8 +2690,11 @@ void MANTA::updateMeshFromObj(const char *filename) } else if (id == "vn") { // normals - if (getNumVertices() != cntVerts) - std::cerr << "updateMeshDataFromObj: invalid amount of mesh nodes" << std::endl; + if (getNumVertices() != cntVerts) { + std::cerr << "Fluid Error -- updateMeshFromObj(): Invalid number of mesh nodes in file: " + << filename << std::endl; + return false; + } ifs >> fbuffer[0] >> fbuffer[1] >> fbuffer[2]; MANTA::Node *node = &mMeshNodes->at(cntNormals); @@ -2677,8 +2726,11 @@ void MANTA::updateMeshFromObj(const char *filename) if (face.find('/') != std::string::npos) face = face.substr(0, face.find('/')); // ignore other indices int idx = atoi(face.c_str()) - 1; - if (idx < 0) - std::cerr << "updateMeshDataFromObj: invalid face encountered" << std::endl; + if (idx < 0) { + std::cerr << "Fluid Error -- updateMeshFromObj(): Invalid face encountered in file: " + << filename << std::endl; + return false; + } ibuffer[i] = idx; } MANTA::Triangle triangle; @@ -2695,9 +2747,10 @@ void MANTA::updateMeshFromObj(const char *filename) getline(ifs, id); } ifs.close(); + return true; } -void MANTA::updateMeshFromUni(const char *filename) +bool MANTA::updateMeshFromUni(const char *filename) { if (with_debug) std::cout << "MANTA::updateMeshFromUni()" << std::endl; @@ -2707,11 +2760,21 @@ void MANTA::updateMeshFromUni(const char *filename) int ibuffer[4]; gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression - if (!gzf) - std::cout << "updateMeshFromUni: unable to open file" << std::endl; + if (!gzf) { + std::cerr << "Fluid Error -- updateMeshFromUni(): Unable to open file: " << filename + << std::endl; + return false; + } + int readBytes = 0; char file_magic[5] = {0, 0, 0, 0, 0}; - gzread(gzf, file_magic, 4); + readBytes = gzread(gzf, file_magic, 4); + if (!readBytes) { + std::cerr << "Fluid Error -- updateMeshFromUni(): Unable to read header in file: " << filename + << std::endl; + gzclose(gzf); + return false; + } std::vector *velocityPointer = mMeshVelocities; @@ -2729,18 +2792,21 @@ void MANTA::updateMeshFromUni(const char *filename) gzread(gzf, ×tamp, sizeof(unsigned long long)); if (with_debug) - std::cout << "read " << ibuffer[0] << " vertices in file: " << filename << std::endl; + std::cout << "Fluid: Read " << ibuffer[0] << " vertices in file: " << filename << std::endl; // Sanity checks const int meshSize = sizeof(float) * 3 + sizeof(int); if (!(bytesPerElement == meshSize) && (elementType == 0)) { - std::cout << "particle type doesn't match" << std::endl; + std::cerr << "Fluid Error -- updateMeshFromUni(): Invalid header in file: " << filename + << std::endl; + gzclose(gzf); + return false; } if (!ibuffer[0]) { // Any vertices present? - if (with_debug) - std::cout << "no vertices present yet" << std::endl; + std::cerr << "Fluid Error -- updateMeshFromUni(): No vertices present in file: " << filename + << std::endl; gzclose(gzf); - return; + return false; } // Reading mesh @@ -2762,11 +2828,10 @@ void MANTA::updateMeshFromUni(const char *filename) it->pos[2] = bufferPVel->pos[2]; } } - - gzclose(gzf); + return (gzclose(gzf) == Z_OK); } -void MANTA::updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData) +bool MANTA::updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData) { if (with_debug) std::cout << "MANTA::updateParticlesFromFile()" << std::endl; @@ -2779,17 +2844,20 @@ void MANTA::updateParticlesFromFile(const char *filename, bool isSecondarySys, b std::string extension = fname.substr(idx + 1); if (extension.compare("uni") == 0) - updateParticlesFromUni(filename, isSecondarySys, isVelData); + return updateParticlesFromUni(filename, isSecondarySys, isVelData); else - std::cerr << "updateParticlesFromFile: invalid file extension in file: " << filename - << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromFile(): Invalid file extension in file: " + << filename << std::endl; + return false; } else { - std::cerr << "updateParticlesFromFile: unable to open file: " << filename << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromFile(): Unable to open file: " << filename + << std::endl; + return false; } } -void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData) +bool MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData) { if (with_debug) std::cout << "MANTA::updateParticlesFromUni()" << std::endl; @@ -2798,16 +2866,28 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo int ibuffer[4]; gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression - if (!gzf) - std::cerr << "updateParticlesFromUni: unable to open file" << std::endl; + if (!gzf) { + std::cerr << "Fluid Error -- updateParticlesFromUni(): Unable to open file: " << filename + << std::endl; + return false; + } + int readBytes = 0; char file_magic[5] = {0, 0, 0, 0, 0}; - gzread(gzf, file_magic, 4); + readBytes = gzread(gzf, file_magic, 4); + if (!readBytes) { + std::cerr << "Fluid Error -- updateParticlesFromUni(): Unable to read header in file: " + << filename << std::endl; + gzclose(gzf); + return false; + } if (!strcmp(file_magic, "PB01")) { - std::cerr << "particle uni file format v01 not supported anymore" << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromUni(): Particle uni file format v01 not " + "supported anymore." + << std::endl; gzclose(gzf); - return; + return false; } // Pointer to FLIP system or to secondary particle system @@ -2839,25 +2919,28 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo gzread(gzf, ×tamp, sizeof(unsigned long long)); if (with_debug) - std::cout << "read " << ibuffer[0] << " particles in file: " << filename << std::endl; + std::cout << "Fluid: Read " << ibuffer[0] << " particles in file: " << filename << std::endl; // Sanity checks const int partSysSize = sizeof(float) * 3 + sizeof(int); if (!(bytesPerElement == partSysSize) && (elementType == 0)) { - std::cout << "particle type doesn't match" << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromUni(): Invalid header in file: " << filename + << std::endl; + gzclose(gzf); + return false; } if (!ibuffer[0]) { // Any particles present? - if (with_debug) - std::cerr << "no particles present yet" << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromUni(): No particles present in file: " + << filename << std::endl; gzclose(gzf); - return; + return false; } numParticles = ibuffer[0]; const int numChunks = (int)(ceil((float)numParticles / PARTICLE_CHUNK)); int todoParticles, readLen; - int readStart, readEnd, readBytes; + int readStart, readEnd; // Reading base particle system file v2 if (!strcmp(file_magic, "PB02")) { @@ -2876,11 +2959,12 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo readBytes = gzread(gzf, bufferPData, readLen * sizeof(pData)); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading particle data" << std::endl; + std::cerr + << "Fluid Error -- updateParticlesFromUni(): Unable to read particle data in file: " + << filename << std::endl; MEM_freeN(bufferPData); gzclose(gzf); - return; + return false; } readStart = (numParticles - todoParticles); @@ -2916,11 +3000,12 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo readBytes = gzread(gzf, bufferPVel, readLen * sizeof(pVel)); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading particle velocities" << std::endl; + std::cerr << "Fluid Error -- updateParticlesFromUni(): Unable to read particle velocities " + "in file: " + << filename << std::endl; MEM_freeN(bufferPVel); gzclose(gzf); - return; + return false; } readStart = (numParticles - todoParticles); @@ -2954,11 +3039,12 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo readBytes = gzread(gzf, bufferPLife, readLen * sizeof(float)); if (!readBytes) { - if (with_debug) - std::cerr << "error while reading particle life" << std::endl; + std::cerr + << "Fluid Error -- updateParticlesFromUni(): Unable to read particle life in file: " + << filename << std::endl; MEM_freeN(bufferPLife); gzclose(gzf); - return; + return false; } readStart = (numParticles - todoParticles); @@ -2974,19 +3060,19 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo } MEM_freeN(bufferPLife); } - - gzclose(gzf); + return (gzclose(gzf) == Z_OK); } -int MANTA::updateGridFromFile(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromFile(const char *filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromFile()" << std::endl; if (!grid) { - std::cout << "MANTA::updateGridFromFile(): cannot read into uninitialized grid, grid is null" + std::cerr << "Fluid Error -- updateGridFromFile(): Cannot read into uninitialized grid (grid " + "is null)." << std::endl; - return 0; + return false; } std::string fname(filename); @@ -3005,17 +3091,18 @@ int MANTA::updateGridFromFile(const char *filename, float *grid, bool isNoise) else if (extension.compare("raw") == 0) return updateGridFromRaw(filename, grid, isNoise); else - std::cerr << "MANTA::updateGridFromFile(): invalid file extension in file: " << filename - << std::endl; - return 0; + std::cerr << "Fluid Error -- updateGridFromFile(): Invalid file extension in file: " + << filename << std::endl; + return false; } else { - std::cerr << "MANTA::updateGridFromFile(): unable to open file: " << filename << std::endl; - return 0; + std::cerr << "Fluid Error -- updateGridFromFile(): Unable to open file: " << filename + << std::endl; + return false; } } -int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromUni()" << std::endl; @@ -3025,30 +3112,43 @@ int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) gzf = (gzFile)BLI_gzopen(filename, "rb1"); if (!gzf) { - std::cout << "MANTA::updateGridFromUni(): unable to open file" << std::endl; - return 0; + std::cerr << "Fluid Error -- updateGridFromUni(): Unable to open file: " << filename + << std::endl; + return false; } + int readBytes = 0; char file_magic[5] = {0, 0, 0, 0, 0}; - gzread(gzf, file_magic, 4); + readBytes = gzread(gzf, file_magic, 4); + if (!readBytes) { + std::cerr << "Fluid Error -- updateGridFromUni(): Unable to read header in file: " << filename + << std::endl; + gzclose(gzf); + return false; + } if (!strcmp(file_magic, "DDF2")) { - std::cout << "MANTA::updateGridFromUni(): grid uni file format DDF2 not supported anymore" - << std::endl; + std::cerr + << "Fluid Error -- updateGridFromUni(): Grid uni file format DDF2 not supported anymore." + << std::endl; gzclose(gzf); - return 0; + return false; } + if (!strcmp(file_magic, "MNT1")) { - std::cout << "MANTA::updateGridFromUni(): grid uni file format MNT1 not supported anymore" - << std::endl; + std::cerr + << "Fluid Error -- updateGridFromUni(): Grid uni file format MNT1 not supported anymore." + << std::endl; gzclose(gzf); - return 0; + return false; } + if (!strcmp(file_magic, "MNT2")) { - std::cout << "MANTA::updateGridFromUni(): grid uni file format MNT2 not supported anymore" - << std::endl; + std::cerr + << "Fluid Error -- updateGridFromUni(): Grid uni file format MNT2 not supported anymore." + << std::endl; gzclose(gzf); - return 0; + return false; } // grid uni header @@ -3071,15 +3171,15 @@ int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) int resZ = (isNoise) ? mResZNoise : mResZ; if (with_debug) - std::cout << "read " << ibuffer[3] << " grid type in file: " << filename << std::endl; + std::cout << "Fluid: Read " << ibuffer[3] << " grid type in file: " << filename << std::endl; // Sanity checks if (ibuffer[0] != resX || ibuffer[1] != resY || ibuffer[2] != resZ) { - std::cout << "grid dim doesn't match, read: (" << ibuffer[0] << ", " << ibuffer[1] << ", " - << ibuffer[2] << ") vs setup: (" << resX << ", " << resY << ", " << resZ << ")" - << std::endl; + std::cout << "Fluid: Grid dim doesn't match, read: (" << ibuffer[0] << ", " << ibuffer[1] + << ", " << ibuffer[2] << ") vs setup: (" << resX << ", " << resY << ", " << resZ + << ")" << std::endl; gzclose(gzf); - return 0; + return false; } // Actual data reading @@ -3088,14 +3188,13 @@ int MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) } if (with_debug) - std::cout << "read successfully: " << filename << std::endl; + std::cout << "Fluid: Read successfully: " << filename << std::endl; - gzclose(gzf); - return 1; + return (gzclose(gzf) == Z_OK); } #if OPENVDB == 1 -int MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromVDB()" << std::endl; @@ -3106,9 +3205,9 @@ int MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) file.open(); } catch (const openvdb::IoError &) { - std::cout << "MANTA::updateGridFromVDB(): IOError, invalid OpenVDB file: " << filename + std::cerr << "Fluid Error -- updateGridFromVDB(): IOError, invalid OpenVDB file: " << filename << std::endl; - return 0; + return false; } openvdb::GridBase::Ptr baseGrid; @@ -3135,11 +3234,11 @@ int MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) } } } - return 1; + return true; } #endif -int MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromRaw()" << std::endl; @@ -3150,7 +3249,7 @@ int MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) gzf = (gzFile)BLI_gzopen(filename, "rb"); if (!gzf) { std::cout << "MANTA::updateGridFromRaw(): unable to open file" << std::endl; - return 0; + return false; } int resX = (isNoise) ? mResXNoise : mResX; @@ -3159,12 +3258,16 @@ int MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) expectedBytes = sizeof(float) * resX * resY * resZ; readBytes = gzread(gzf, grid, expectedBytes); + if (!readBytes) { + std::cerr << "Fluid Error -- updateGridFromRaw(): Unable to read raw file: " << filename + << std::endl; + gzclose(gzf); + return false; + } assert(expectedBytes == readBytes); - (void)readBytes; // Unused in release. - gzclose(gzf); - return 1; + return (gzclose(gzf) == Z_OK); } void MANTA::updatePointers() diff --git a/intern/mantaflow/intern/MANTA_main.h b/intern/mantaflow/intern/MANTA_main.h index dd003d13f51..e24b9dc6b23 100644 --- a/intern/mantaflow/intern/MANTA_main.h +++ b/intern/mantaflow/intern/MANTA_main.h @@ -24,10 +24,10 @@ #ifndef MANTA_A_H #define MANTA_A_H -#include -#include #include #include +#include +#include struct MANTA { public: @@ -77,32 +77,32 @@ struct MANTA { void updatePointers(); // Write cache - int writeConfiguration(FluidModifierData *mmd, int framenr); - int writeData(FluidModifierData *mmd, int framenr); + bool writeConfiguration(FluidModifierData *mmd, int framenr); + bool writeData(FluidModifierData *mmd, int framenr); // write call for noise, mesh and particles were left in bake calls for now // Read cache (via Manta save/load) - int readConfiguration(FluidModifierData *mmd, int framenr); - int readData(FluidModifierData *mmd, int framenr); - int readNoise(FluidModifierData *mmd, int framenr); - int readMesh(FluidModifierData *mmd, int framenr); - int readParticles(FluidModifierData *mmd, int framenr); - int readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain); + bool readConfiguration(FluidModifierData *mmd, int framenr); + bool readData(FluidModifierData *mmd, int framenr); + bool readNoise(FluidModifierData *mmd, int framenr); + bool readMesh(FluidModifierData *mmd, int framenr); + bool readParticles(FluidModifierData *mmd, int framenr); + bool readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain); // Read cache (via file read functions in MANTA - e.g. read .bobj.gz meshes, .uni particles) - int updateMeshStructures(FluidModifierData *mmd, int framenr); - int updateFlipStructures(FluidModifierData *mmd, int framenr); - int updateParticleStructures(FluidModifierData *mmd, int framenr); - int updateSmokeStructures(FluidModifierData *mmd, int framenr); - int updateNoiseStructures(FluidModifierData *mmd, int framenr); - void updateVariables(FluidModifierData *mmd); + bool updateMeshStructures(FluidModifierData *mmd, int framenr); + bool updateFlipStructures(FluidModifierData *mmd, int framenr); + bool updateParticleStructures(FluidModifierData *mmd, int framenr); + bool updateSmokeStructures(FluidModifierData *mmd, int framenr); + bool updateNoiseStructures(FluidModifierData *mmd, int framenr); + bool updateVariables(FluidModifierData *mmd); // Bake cache - int bakeData(FluidModifierData *mmd, int framenr); - int bakeNoise(FluidModifierData *mmd, int framenr); - int bakeMesh(FluidModifierData *mmd, int framenr); - int bakeParticles(FluidModifierData *mmd, int framenr); - int bakeGuiding(FluidModifierData *mmd, int framenr); + bool bakeData(FluidModifierData *mmd, int framenr); + bool bakeNoise(FluidModifierData *mmd, int framenr); + bool bakeMesh(FluidModifierData *mmd, int framenr); + bool bakeParticles(FluidModifierData *mmd, int framenr); + bool bakeGuiding(FluidModifierData *mmd, int framenr); // IO for Mantaflow scene script void exportSmokeScript(struct FluidModifierData *mmd); @@ -401,7 +401,6 @@ struct MANTA { return mPhi; } - static std::atomic mantaInitialized; static std::atomic solverID; static int with_debug; // on or off (1 or 0), also sets manta debug level @@ -858,20 +857,20 @@ struct MANTA { void initSmokeNoise(struct FluidModifierData *mmd); void initializeMantaflow(); void terminateMantaflow(); - void runPythonString(std::vector commands); + bool runPythonString(std::vector commands); std::string getRealValue(const std::string &varName, FluidModifierData *mmd); std::string parseLine(const std::string &line, FluidModifierData *mmd); std::string parseScript(const std::string &setup_string, FluidModifierData *mmd = NULL); - void updateMeshFromBobj(const char *filename); - void updateMeshFromObj(const char *filename); - void updateMeshFromUni(const char *filename); - void updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData); - int updateGridFromUni(const char *filename, float *grid, bool isNoise); - int updateGridFromVDB(const char *filename, float *grid, bool isNoise); - int updateGridFromRaw(const char *filename, float *grid, bool isNoise); - void updateMeshFromFile(const char *filename); - void updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData); - int updateGridFromFile(const char *filename, float *grid, bool isNoise); + bool updateMeshFromBobj(const char *filename); + bool updateMeshFromObj(const char *filename); + bool updateMeshFromUni(const char *filename); + bool updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData); + bool updateGridFromUni(const char *filename, float *grid, bool isNoise); + bool updateGridFromVDB(const char *filename, float *grid, bool isNoise); + bool updateGridFromRaw(const char *filename, float *grid, bool isNoise); + bool updateMeshFromFile(const char *filename); + bool updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData); + bool updateGridFromFile(const char *filename, float *grid, bool isNoise); }; #endif -- cgit v1.2.3 From 70b061b4fdd487c971b12fd0f772767387ebc8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Fri, 3 Apr 2020 16:38:38 +0200 Subject: Fluid: Refactored caching in main Mantaflow class This refactor cleans up code for the Manta file IO. It also improves the cache 'Replay' option. --- intern/mantaflow/extern/manta_fluid_API.h | 9 + intern/mantaflow/intern/MANTA_main.cpp | 623 +++++++++++----------------- intern/mantaflow/intern/MANTA_main.h | 34 +- intern/mantaflow/intern/manta_fluid_API.cpp | 35 ++ source/blender/blenkernel/intern/fluid.c | 38 +- source/blender/makesdna/DNA_fluid_types.h | 40 ++ 6 files changed, 377 insertions(+), 402 deletions(-) diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h index 48d42504994..939f24fbeef 100644 --- a/intern/mantaflow/extern/manta_fluid_API.h +++ b/intern/mantaflow/extern/manta_fluid_API.h @@ -62,6 +62,15 @@ int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int fra int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); int manta_bake_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); int manta_bake_guiding(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); +int manta_has_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); +int manta_has_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); +int manta_has_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); +int manta_has_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr); +int manta_has_guiding(struct MANTA *fluid, + struct FluidModifierData *mmd, + int framenr, + bool domain); + void manta_update_variables(struct MANTA *fluid, struct FluidModifierData *mmd); int manta_get_frame(struct MANTA *fluid); float manta_get_timestep(struct MANTA *fluid); diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 3555e098caf..54b728b734e 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -595,19 +595,19 @@ static std::string getCacheFileEnding(char cache_format) switch (cache_format) { case FLUID_DOMAIN_FILE_UNI: - return ".uni"; + return FLUID_DOMAIN_EXTENSION_UNI; case FLUID_DOMAIN_FILE_OPENVDB: - return ".vdb"; + return FLUID_DOMAIN_EXTENSION_OPENVDB; case FLUID_DOMAIN_FILE_RAW: - return ".raw"; + return FLUID_DOMAIN_EXTENSION_RAW; case FLUID_DOMAIN_FILE_BIN_OBJECT: - return ".bobj.gz"; + return FLUID_DOMAIN_EXTENSION_BINOBJ; case FLUID_DOMAIN_FILE_OBJECT: - return ".obj"; + return FLUID_DOMAIN_EXTENSION_OBJ; default: std::cerr << "Fluid Error -- Could not find file extension. Using default file extension." << std::endl; - return ".uni"; + return FLUID_DOMAIN_EXTENSION_UNI; } } @@ -1054,38 +1054,27 @@ bool MANTA::updateFlipStructures(FluidModifierData *mmd, int framenr) int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ - // Ensure empty data structures at start - if (mFlipParticleData) - mFlipParticleData->clear(); - if (mFlipParticleVelocity) - mFlipParticleVelocity->clear(); + /* Ensure empty data structures at start. */ + if (!mFlipParticleData || !mFlipParticleVelocity) + return false; - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; + mFlipParticleData->clear(); + mFlipParticleVelocity->clear(); std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format); - BLI_path_join( - cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_DATA, nullptr); + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PP, pformat.c_str(), framenr); expected += 1; - ss.str(""); - ss << "pp_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateParticlesFromFile(targetFile, false, false); + if (BLI_exists(file.c_str())) { + result += updateParticlesFromFile(file, false, false); assert(result == expected); } + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PVEL, pformat.c_str(), framenr); expected += 1; - ss.str(""); - ss << "pVel_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateParticlesFromFile(targetFile, false, true); + if (BLI_exists(file.c_str())) { + result += updateParticlesFromFile(file, false, true); assert(result == expected); } @@ -1108,42 +1097,29 @@ bool MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr) int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ - // Ensure empty data structures at start - if (mMeshNodes) - mMeshNodes->clear(); - if (mMeshTriangles) - mMeshTriangles->clear(); - if (mMeshVelocities) - mMeshVelocities->clear(); + /* Ensure empty data structures at start. */ + if (!mMeshNodes || !mMeshTriangles || !mMeshVelocities) + return false; - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; + mMeshNodes->clear(); + mMeshTriangles->clear(); + mMeshVelocities->clear(); std::string mformat = getCacheFileEnding(mmd->domain->cache_mesh_format); std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); - BLI_path_join( - cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_MESH, nullptr); + std::string file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_DOMAIN_FILE_MESH, mformat, framenr); expected += 1; - ss.str(""); - ss << "lMesh_####" << mformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateMeshFromFile(targetFile); + if (BLI_exists(file.c_str())) { + result += updateMeshFromFile(file); assert(result == expected); } if (mUsingMVel) { + file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_DOMAIN_FILE_MESHVEL, dformat, framenr); expected += 1; - ss.str(""); - ss << "lVelMesh_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateMeshFromFile(targetFile); + if (BLI_exists(file.c_str())) { + result += updateMeshFromFile(file); assert(result == expected); } } @@ -1167,53 +1143,35 @@ bool MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr) int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ - // Ensure empty data structures at start - if (mSndParticleData) - mSndParticleData->clear(); - if (mSndParticleVelocity) - mSndParticleVelocity->clear(); - if (mSndParticleLife) - mSndParticleLife->clear(); + /* Ensure empty data structures at start. */ + if (!mSndParticleData || !mSndParticleVelocity || !mSndParticleLife) + return false; - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; + mSndParticleData->clear(); + mSndParticleVelocity->clear(); + mSndParticleLife->clear(); std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format); - BLI_path_join(cacheDir, - sizeof(cacheDir), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_PARTICLES, - nullptr); + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PPSND, pformat, framenr); expected += 1; - ss.str(""); - ss << "ppSnd_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateParticlesFromFile(targetFile, true, false); + if (BLI_exists(file.c_str())) { + result += updateParticlesFromFile(file, true, false); assert(result == expected); } + file = getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PVELSND, pformat, framenr); expected += 1; - ss.str(""); - ss << "pVelSnd_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateParticlesFromFile(targetFile, true, true); + if (BLI_exists(file.c_str())) { + result += updateParticlesFromFile(file, true, true); assert(result == expected); } + file = getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PLIFESND, pformat, framenr); expected += 1; - ss.str(""); - ss << "pLifeSnd_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateParticlesFromFile(targetFile, true, false); + if (BLI_exists(file.c_str())) { + result += updateParticlesFromFile(file, true, false); assert(result == expected); } @@ -1236,103 +1194,70 @@ bool MANTA::updateSmokeStructures(FluidModifierData *mmd, int framenr) int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; - std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); - BLI_path_join( - cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_DATA, nullptr); + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_DENSITY, dformat, framenr); expected += 1; - ss.str(""); - ss << "density_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mDensity, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mDensity, false); assert(result == expected); } + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_SHADOW, dformat, framenr); expected += 1; - ss.str(""); - ss << "shadow_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mShadow, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mShadow, false); assert(result == expected); } if (mUsingHeat) { + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_HEAT, dformat, framenr); expected += 1; - ss.str(""); - ss << "heat_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mHeat, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mHeat, false); assert(result == expected); } } if (mUsingColors) { + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORR, dformat, framenr); expected += 3; - ss.str(""); - ss << "color_r_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorR, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorR, false); assert(result == expected); } - ss.str(""); - ss << "color_g_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorG, false); + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORG, dformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorG, false); assert(result == expected); } - ss.str(""); - ss << "color_b_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorB, false); + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORB, dformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorB, false); assert(result == expected); } } if (mUsingFire) { + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_FLAME, dformat, framenr); expected += 3; - ss.str(""); - ss << "flame_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mFlame, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mFlame, false); assert(result == expected); } - ss.str(""); - ss << "fuel_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mFuel, false); + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_FUEL, dformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mFuel, false); assert(result == expected); } - ss.str(""); - ss << "react_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mReact, false); + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_REACT, dformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mReact, false); assert(result == expected); } } @@ -1356,101 +1281,62 @@ bool MANTA::updateNoiseStructures(FluidModifierData *mmd, int framenr) int result = 0; int expected = 0; /* Expected number of read successes for this frame. */ - std::ostringstream ss; - char cacheDirData[FILE_MAX], cacheDirNoise[FILE_MAX], targetFile[FILE_MAX]; - cacheDirData[0] = '\0'; - cacheDirNoise[0] = '\0'; - targetFile[0] = '\0'; - std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); std::string nformat = getCacheFileEnding(mmd->domain->cache_noise_format); - BLI_path_join(cacheDirData, - sizeof(cacheDirData), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_DATA, - nullptr); - BLI_path_join(cacheDirNoise, - sizeof(cacheDirNoise), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_NOISE, - nullptr); + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_DENSITYNOISE, nformat, framenr); expected += 1; - ss.str(""); - ss << "density_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mDensityHigh, true); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mDensityHigh, true); assert(result == expected); } + file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_SHADOW, dformat, framenr); expected += 1; - ss.str(""); - ss << "shadow_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mShadow, false); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mShadow, false); assert(result == expected); } if (mUsingColors) { + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORRNOISE, nformat, framenr); expected += 3; - ss.str(""); - ss << "color_r_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorRHigh, true); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorRHigh, true); assert(result == expected); } - ss.str(""); - ss << "color_g_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorGHigh, true); + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORGNOISE, nformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorGHigh, true); assert(result == expected); } - ss.str(""); - ss << "color_b_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mColorBHigh, true); + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORBNOISE, nformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mColorBHigh, true); assert(result == expected); } } if (mUsingFire) { + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_FLAMENOISE, nformat, framenr); expected += 3; - ss.str(""); - ss << "flame_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mFlameHigh, true); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mFlameHigh, true); assert(result == expected); } - ss.str(""); - ss << "fuel_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mFuelHigh, true); + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_FUELNOISE, nformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mFuelHigh, true); assert(result == expected); } - ss.str(""); - ss << "react_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (BLI_exists(targetFile)) { - result += updateGridFromFile(targetFile, mReactHigh, true); + file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_REACTNOISE, nformat, framenr); + if (BLI_exists(file.c_str())) { + result += updateGridFromFile(file, mReactHigh, true); assert(result == expected); } } @@ -1479,26 +1365,18 @@ bool MANTA::writeConfiguration(FluidModifierData *mmd, int framenr) std::cout << "MANTA::writeConfiguration()" << std::endl; FluidDomainSettings *mds = mmd->domain; - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; - std::string dformat = ".uni"; + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_CONFIG); + std::string format = FLUID_DOMAIN_EXTENSION_UNI; + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_DOMAIN_FILE_CONFIG, format, framenr); - BLI_path_join( - cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, nullptr); - BLI_path_make_safe(cacheDir); - BLI_dir_create_recursive(cacheDir); /* Create 'config' subdir if it does not exist already */ - - ss.str(""); - ss << "config_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); + /* Create 'config' subdir if it does not exist already. */ + BLI_dir_create_recursive(directory.c_str()); - gzFile gzf = (gzFile)BLI_gzopen(targetFile, "wb1"); // do some compression + gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1"); // do some compression if (!gzf) { - std::cerr << "Fluid Error -- Cannot open file " << targetFile << std::endl; + std::cerr << "Fluid Error -- Cannot open file " << file << std::endl; return false; } @@ -1528,37 +1406,28 @@ bool MANTA::writeData(FluidModifierData *mmd, int framenr) std::ostringstream ss; std::vector pythonCommands; - char cacheDirData[FILE_MAX]; - cacheDirData[0] = '\0'; - + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_DATA); std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format); bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL); std::string resumable_cache = (final_cache) ? "False" : "True"; - BLI_path_join(cacheDirData, - sizeof(cacheDirData), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_DATA, - nullptr); - BLI_path_make_safe(cacheDirData); - ss.str(""); - ss << "fluid_save_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " << framenr + ss << "fluid_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); if (mUsingSmoke) { ss.str(""); - ss << "smoke_save_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " - << framenr << ", '" << dformat << "', " << resumable_cache << ")"; + ss << "smoke_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); } if (mUsingLiquid) { ss.str(""); - ss << "liquid_save_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " - << framenr << ", '" << dformat << "', " << resumable_cache << ")"; + ss << "liquid_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); } return runPythonString(pythonCommands); @@ -1570,29 +1439,19 @@ bool MANTA::readConfiguration(FluidModifierData *mmd, int framenr) std::cout << "MANTA::readConfiguration()" << std::endl; FluidDomainSettings *mds = mmd->domain; - std::ostringstream ss; - char cacheDir[FILE_MAX], targetFile[FILE_MAX]; - cacheDir[0] = '\0'; - targetFile[0] = '\0'; float dummy; - std::string dformat = ".uni"; - - BLI_path_join( - cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, nullptr); - BLI_path_make_safe(cacheDir); - - ss.str(""); - ss << "config_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_CONFIG); + std::string format = FLUID_DOMAIN_EXTENSION_UNI; + std::string file = getFile( + mmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_DOMAIN_FILE_CONFIG, format, framenr); - if (!BLI_exists(targetFile)) + if (!hasConfig(mmd, framenr)) return false; - gzFile gzf = (gzFile)BLI_gzopen(targetFile, "rb"); // do some compression + gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "rb"); // do some compression if (!gzf) { - std::cerr << "Fluid Error -- Cannot open file " << targetFile << std::endl; + std::cerr << "Fluid Error -- Cannot open file " << file << std::endl; return false; } @@ -1625,60 +1484,39 @@ bool MANTA::readData(FluidModifierData *mmd, int framenr) std::ostringstream ss; std::vector pythonCommands; + bool result = true; - char cacheDirData[FILE_MAX], targetFile[FILE_MAX]; - cacheDirData[0] = '\0'; - targetFile[0] = '\0'; - + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_DATA); std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format); bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL); std::string resumable_cache = (final_cache) ? "False" : "True"; - BLI_path_join(cacheDirData, - sizeof(cacheDirData), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_DATA, - nullptr); - BLI_path_make_safe(cacheDirData); - - /* Exit early if there is nothing present in the cache for this frame */ - ss.str(""); - if (mUsingSmoke) { - ss << "density_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) - return false; - } - if (mUsingLiquid) { - ss << "phi_####" << dformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) - return false; - } + /* Sanity check: Are cache files present? */ + if (!hasData(mmd, framenr)) + return false; ss.str(""); - ss << "fluid_load_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " << framenr + ss << "fluid_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); if (mUsingSmoke) { ss.str(""); - ss << "smoke_load_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " - << framenr << ", '" << dformat << "', " << resumable_cache << ")"; + ss << "smoke_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); + result &= runPythonString(pythonCommands); } if (mUsingLiquid) { - /* Exit early if there is nothing present in the cache for this frame */ ss.str(""); - ss << "liquid_load_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " - << framenr << ", '" << dformat << "', " << resumable_cache << ")"; + ss << "liquid_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << dformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); + result &= runPythonString(pythonCommands); } - return runPythonString(pythonCommands); + return result; } bool MANTA::readNoise(FluidModifierData *mmd, int framenr) @@ -1692,33 +1530,19 @@ bool MANTA::readNoise(FluidModifierData *mmd, int framenr) std::ostringstream ss; std::vector pythonCommands; - char cacheDirNoise[FILE_MAX], targetFile[FILE_MAX]; - cacheDirNoise[0] = '\0'; - targetFile[0] = '\0'; - + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_NOISE); std::string nformat = getCacheFileEnding(mmd->domain->cache_noise_format); bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL); std::string resumable_cache = (final_cache) ? "False" : "True"; - BLI_path_join(cacheDirNoise, - sizeof(cacheDirNoise), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_NOISE, - nullptr); - BLI_path_make_safe(cacheDirNoise); - - /* Exit early if there is nothing present in the cache for this frame */ - ss.str(""); - ss << "density_noise_####" << nformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirNoise, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) + /* Sanity check: Are cache files present? */ + if (!hasNoise(mmd, framenr)) return false; ss.str(""); - ss << "smoke_load_noise_" << mCurrentID << "('" << escapeSlashes(cacheDirNoise) << "', " - << framenr << ", '" << nformat << "', " << resumable_cache << ")"; + ss << "smoke_load_noise_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << nformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); return runPythonString(pythonCommands); @@ -1738,36 +1562,22 @@ bool MANTA::readMesh(FluidModifierData *mmd, int framenr) std::ostringstream ss; std::vector pythonCommands; - char cacheDirMesh[FILE_MAX], targetFile[FILE_MAX]; - cacheDirMesh[0] = '\0'; - targetFile[0] = '\0'; - + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_MESH); std::string mformat = getCacheFileEnding(mmd->domain->cache_mesh_format); std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format); - BLI_path_join(cacheDirMesh, - sizeof(cacheDirMesh), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_MESH, - nullptr); - BLI_path_make_safe(cacheDirMesh); - - /* Exit early if there is nothing present in the cache for this frame */ - ss.str(""); - ss << "lMesh_####" << mformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirMesh, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) + /* Sanity check: Are cache files present? */ + if (!hasMesh(mmd, framenr)) return false; ss.str(""); - ss << "liquid_load_mesh_" << mCurrentID << "('" << escapeSlashes(cacheDirMesh) << "', " - << framenr << ", '" << mformat << "')"; + ss << "liquid_load_mesh_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << mformat << "')"; pythonCommands.push_back(ss.str()); if (mUsingMVel) { ss.str(""); - ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapeSlashes(cacheDirMesh) << "', " + ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr << ", '" << dformat << "')"; pythonCommands.push_back(ss.str()); } @@ -1791,32 +1601,18 @@ bool MANTA::readParticles(FluidModifierData *mmd, int framenr) std::ostringstream ss; std::vector pythonCommands; - char cacheDirParticles[FILE_MAX], targetFile[FILE_MAX]; - cacheDirParticles[0] = '\0'; - targetFile[0] = '\0'; - + std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_PARTICLES); std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format); bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL); std::string resumable_cache = (final_cache) ? "False" : "True"; - BLI_path_join(cacheDirParticles, - sizeof(cacheDirParticles), - mmd->domain->cache_directory, - FLUID_DOMAIN_DIR_PARTICLES, - nullptr); - BLI_path_make_safe(cacheDirParticles); - - /* Exit early if there is nothing present in the cache for this frame */ - ss.str(""); - ss << "ppSnd_####" << pformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirParticles, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) + /* Sanity check: Are cache files present? */ + if (!hasParticles(mmd, framenr)) return false; ss.str(""); - ss << "liquid_load_particles_" << mCurrentID << "('" << escapeSlashes(cacheDirParticles) << "', " + ss << "liquid_load_particles_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr << ", '" << pformat << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); @@ -1836,33 +1632,22 @@ bool MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) std::ostringstream ss; std::vector pythonCommands; - char cacheDirGuiding[FILE_MAX], targetFile[FILE_MAX]; - cacheDirGuiding[0] = '\0'; - targetFile[0] = '\0'; - + std::string directory = (sourceDomain) ? getDirectory(mmd, FLUID_DOMAIN_DIR_DATA) : + getDirectory(mmd, FLUID_DOMAIN_DIR_GUIDE); std::string gformat = getCacheFileEnding(mmd->domain->cache_data_format); - const char *subdir = (sourceDomain) ? FLUID_DOMAIN_DIR_DATA : FLUID_DOMAIN_DIR_GUIDE; - BLI_path_join( - cacheDirGuiding, sizeof(cacheDirGuiding), mmd->domain->cache_directory, subdir, nullptr); - BLI_path_make_safe(cacheDirGuiding); - - /* Exit early if there is nothing present in the cache for this frame */ - ss.str(""); - ss << (sourceDomain ? "vel_####" : "guidevel_####") << gformat; - BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirGuiding, ss.str().c_str()); - BLI_path_frame(targetFile, framenr, 0); - if (!BLI_exists(targetFile)) + /* Sanity check: Are cache files present? */ + if (!hasGuiding(mmd, framenr, sourceDomain)) return false; if (sourceDomain) { ss.str(""); - ss << "fluid_load_vel_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " - << framenr << ", '" << gformat << "')"; + ss << "fluid_load_vel_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr + << ", '" << gformat << "')"; } else { ss.str(""); - ss << "fluid_load_guiding_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " + ss << "fluid_load_guiding_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr << ", '" << gformat << "')"; } pythonCommands.push_back(ss.str()); @@ -2453,7 +2238,7 @@ void MANTA::adaptTimestep() runPythonString(pythonCommands); } -bool MANTA::updateMeshFromFile(const char *filename) +bool MANTA::updateMeshFromFile(std::string filename) { std::string fname(filename); std::string::size_type idx; @@ -2479,14 +2264,14 @@ bool MANTA::updateMeshFromFile(const char *filename) return false; } -bool MANTA::updateMeshFromBobj(const char *filename) +bool MANTA::updateMeshFromBobj(std::string filename) { if (with_debug) std::cout << "MANTA::updateMeshFromBobj()" << std::endl; gzFile gzf; - gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression + gzf = (gzFile)BLI_gzopen(filename.c_str(), "rb1"); // do some compression if (!gzf) { std::cerr << "Fluid Error -- updateMeshFromBobj(): Unable to open file: " << filename << std::endl; @@ -2660,7 +2445,7 @@ bool MANTA::updateMeshFromBobj(const char *filename) return (gzclose(gzf) == Z_OK); } -bool MANTA::updateMeshFromObj(const char *filename) +bool MANTA::updateMeshFromObj(std::string filename) { if (with_debug) std::cout << "MANTA::updateMeshFromObj()" << std::endl; @@ -2750,7 +2535,7 @@ bool MANTA::updateMeshFromObj(const char *filename) return true; } -bool MANTA::updateMeshFromUni(const char *filename) +bool MANTA::updateMeshFromUni(std::string filename) { if (with_debug) std::cout << "MANTA::updateMeshFromUni()" << std::endl; @@ -2759,7 +2544,7 @@ bool MANTA::updateMeshFromUni(const char *filename) float fbuffer[4]; int ibuffer[4]; - gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression + gzf = (gzFile)BLI_gzopen(filename.c_str(), "rb1"); // do some compression if (!gzf) { std::cerr << "Fluid Error -- updateMeshFromUni(): Unable to open file: " << filename << std::endl; @@ -2831,7 +2616,7 @@ bool MANTA::updateMeshFromUni(const char *filename) return (gzclose(gzf) == Z_OK); } -bool MANTA::updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData) +bool MANTA::updateParticlesFromFile(std::string filename, bool isSecondarySys, bool isVelData) { if (with_debug) std::cout << "MANTA::updateParticlesFromFile()" << std::endl; @@ -2857,7 +2642,7 @@ bool MANTA::updateParticlesFromFile(const char *filename, bool isSecondarySys, b } } -bool MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData) +bool MANTA::updateParticlesFromUni(std::string filename, bool isSecondarySys, bool isVelData) { if (with_debug) std::cout << "MANTA::updateParticlesFromUni()" << std::endl; @@ -2865,7 +2650,7 @@ bool MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo gzFile gzf; int ibuffer[4]; - gzf = (gzFile)BLI_gzopen(filename, "rb1"); // do some compression + gzf = (gzFile)BLI_gzopen(filename.c_str(), "rb1"); // do some compression if (!gzf) { std::cerr << "Fluid Error -- updateParticlesFromUni(): Unable to open file: " << filename << std::endl; @@ -3063,7 +2848,7 @@ bool MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo return (gzclose(gzf) == Z_OK); } -bool MANTA::updateGridFromFile(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromFile(std::string filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromFile()" << std::endl; @@ -3102,7 +2887,7 @@ bool MANTA::updateGridFromFile(const char *filename, float *grid, bool isNoise) } } -bool MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromUni(std::string filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromUni()" << std::endl; @@ -3110,7 +2895,7 @@ bool MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) gzFile gzf; int ibuffer[4]; - gzf = (gzFile)BLI_gzopen(filename, "rb1"); + gzf = (gzFile)BLI_gzopen(filename.c_str(), "rb1"); if (!gzf) { std::cerr << "Fluid Error -- updateGridFromUni(): Unable to open file: " << filename << std::endl; @@ -3194,7 +2979,7 @@ bool MANTA::updateGridFromUni(const char *filename, float *grid, bool isNoise) } #if OPENVDB == 1 -bool MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromVDB(std::string filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromVDB()" << std::endl; @@ -3238,7 +3023,7 @@ bool MANTA::updateGridFromVDB(const char *filename, float *grid, bool isNoise) } #endif -bool MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) +bool MANTA::updateGridFromRaw(std::string filename, float *grid, bool isNoise) { if (with_debug) std::cout << "MANTA::updateGridFromRaw()" << std::endl; @@ -3246,7 +3031,7 @@ bool MANTA::updateGridFromRaw(const char *filename, float *grid, bool isNoise) gzFile gzf; int expectedBytes, readBytes; - gzf = (gzFile)BLI_gzopen(filename, "rb"); + gzf = (gzFile)BLI_gzopen(filename.c_str(), "rb"); if (!gzf) { std::cout << "MANTA::updateGridFromRaw(): unable to open file" << std::endl; return false; @@ -3406,3 +3191,71 @@ void MANTA::updatePointers() mSmokeFromFile = false; mNoiseFromFile = false; } + +bool MANTA::hasConfig(FluidModifierData *mmd, int framenr) +{ + std::string extension = getCacheFileEnding(mmd->domain->cache_data_format); + return BLI_exists( + getFile(mmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_DOMAIN_FILE_CONFIG, extension, framenr).c_str()); +} + +bool MANTA::hasData(FluidModifierData *mmd, int framenr) +{ + std::string filename = (mUsingSmoke) ? FLUID_DOMAIN_FILE_DENSITY : FLUID_DOMAIN_FILE_PHI; + std::string extension = getCacheFileEnding(mmd->domain->cache_data_format); + return BLI_exists(getFile(mmd, FLUID_DOMAIN_DIR_DATA, filename, extension, framenr).c_str()); +} + +bool MANTA::hasNoise(FluidModifierData *mmd, int framenr) +{ + std::string extension = getCacheFileEnding(mmd->domain->cache_noise_format); + return BLI_exists( + getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_DENSITYNOISE, extension, framenr) + .c_str()); +} + +bool MANTA::hasMesh(FluidModifierData *mmd, int framenr) +{ + std::string extension = getCacheFileEnding(mmd->domain->cache_mesh_format); + return BLI_exists( + getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_DOMAIN_FILE_MESH, extension, framenr).c_str()); +} + +bool MANTA::hasParticles(FluidModifierData *mmd, int framenr) +{ + std::string extension = getCacheFileEnding(mmd->domain->cache_particle_format); + return BLI_exists( + getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PPSND, extension, framenr) + .c_str()); +} + +bool MANTA::hasGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain) +{ + std::string subdirectory = (sourceDomain) ? FLUID_DOMAIN_DIR_DATA : FLUID_DOMAIN_DIR_GUIDE; + std::string filename = (sourceDomain) ? FLUID_DOMAIN_FILE_VEL : FLUID_DOMAIN_FILE_GUIDEVEL; + std::string extension = getCacheFileEnding(mmd->domain->cache_data_format); + return BLI_exists(getFile(mmd, subdirectory, filename, extension, framenr).c_str()); +} + +std::string MANTA::getDirectory(FluidModifierData *mmd, std::string subdirectory) +{ + char directory[FILE_MAX]; + BLI_path_join( + directory, sizeof(directory), mmd->domain->cache_directory, subdirectory.c_str(), nullptr); + BLI_path_make_safe(directory); + return directory; +} + +std::string MANTA::getFile(FluidModifierData *mmd, + std::string subdirectory, + std::string fname, + std::string extension, + int framenr) +{ + char targetFile[FILE_MAX]; + std::string path = getDirectory(mmd, subdirectory); + std::string filename = fname + extension; + BLI_join_dirfile(targetFile, sizeof(targetFile), path.c_str(), filename.c_str()); + BLI_path_frame(targetFile, framenr, 0); + return targetFile; +} diff --git a/intern/mantaflow/intern/MANTA_main.h b/intern/mantaflow/intern/MANTA_main.h index e24b9dc6b23..f4699e857ff 100644 --- a/intern/mantaflow/intern/MANTA_main.h +++ b/intern/mantaflow/intern/MANTA_main.h @@ -108,6 +108,14 @@ struct MANTA { void exportSmokeScript(struct FluidModifierData *mmd); void exportLiquidScript(struct FluidModifierData *mmd); + // Check cache status by frame + bool hasConfig(FluidModifierData *mmd, int framenr); + bool hasData(FluidModifierData *mmd, int framenr); + bool hasNoise(FluidModifierData *mmd, int framenr); + bool hasMesh(FluidModifierData *mmd, int framenr); + bool hasParticles(FluidModifierData *mmd, int framenr); + bool hasGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain); + inline size_t getTotalCells() { return mTotalCells; @@ -861,16 +869,22 @@ struct MANTA { std::string getRealValue(const std::string &varName, FluidModifierData *mmd); std::string parseLine(const std::string &line, FluidModifierData *mmd); std::string parseScript(const std::string &setup_string, FluidModifierData *mmd = NULL); - bool updateMeshFromBobj(const char *filename); - bool updateMeshFromObj(const char *filename); - bool updateMeshFromUni(const char *filename); - bool updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData); - bool updateGridFromUni(const char *filename, float *grid, bool isNoise); - bool updateGridFromVDB(const char *filename, float *grid, bool isNoise); - bool updateGridFromRaw(const char *filename, float *grid, bool isNoise); - bool updateMeshFromFile(const char *filename); - bool updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData); - bool updateGridFromFile(const char *filename, float *grid, bool isNoise); + bool updateMeshFromBobj(std::string filename); + bool updateMeshFromObj(std::string filename); + bool updateMeshFromUni(std::string filename); + bool updateParticlesFromUni(std::string filename, bool isSecondarySys, bool isVelData); + bool updateGridFromUni(std::string filename, float *grid, bool isNoise); + bool updateGridFromVDB(std::string filename, float *grid, bool isNoise); + bool updateGridFromRaw(std::string filename, float *grid, bool isNoise); + bool updateMeshFromFile(std::string filename); + bool updateParticlesFromFile(std::string filename, bool isSecondarySys, bool isVelData); + bool updateGridFromFile(std::string filename, float *grid, bool isNoise); + std::string getDirectory(struct FluidModifierData *mmd, std::string subdirectory); + std::string getFile(struct FluidModifierData *mmd, + std::string subdirectory, + std::string fname, + std::string extension, + int framenr); }; #endif diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp index 89c69bebc51..594f7a44e7f 100644 --- a/intern/mantaflow/intern/manta_fluid_API.cpp +++ b/intern/mantaflow/intern/manta_fluid_API.cpp @@ -192,6 +192,41 @@ int manta_bake_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr) return fluid->bakeGuiding(mmd, framenr); } +int manta_has_data(MANTA *fluid, FluidModifierData *mmd, int framenr) +{ + if (!fluid || !mmd) + return 0; + return fluid->hasData(mmd, framenr); +} + +int manta_has_noise(MANTA *fluid, FluidModifierData *mmd, int framenr) +{ + if (!fluid || !mmd) + return 0; + return fluid->hasNoise(mmd, framenr); +} + +int manta_has_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr) +{ + if (!fluid || !mmd) + return 0; + return fluid->hasMesh(mmd, framenr); +} + +int manta_has_particles(MANTA *fluid, FluidModifierData *mmd, int framenr) +{ + if (!fluid || !mmd) + return 0; + return fluid->hasParticles(mmd, framenr); +} + +int manta_has_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr, bool domain) +{ + if (!fluid || !mmd) + return 0; + return fluid->hasGuiding(mmd, framenr, domain); +} + void manta_update_variables(MANTA *fluid, FluidModifierData *mmd) { if (!fluid) diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index e8da4385fb9..cbb933725eb 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -3673,8 +3673,14 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, uint numobj = 0; FluidModifierData *mmd_parent = NULL; - bool is_startframe; + bool is_startframe, has_advanced; is_startframe = (scene_framenr == mds->cache_frame_start); + has_advanced = (scene_framenr == mmd->time + 1); + + /* Do not process modifier if current frame is out of cache range. */ + if (scene_framenr < mds->cache_frame_start || scene_framenr > mds->cache_frame_end) { + return; + } /* Reset fluid if no fluid present. */ if (!mds->fluid) { @@ -3766,6 +3772,20 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, read_cache = false; bake_cache = baking_data || baking_noise || baking_mesh || baking_particles || baking_guide; + bool next_data, next_noise, next_mesh, next_particles, next_guide; + next_data = manta_has_data(mds->fluid, mmd, scene_framenr + 1); + next_noise = manta_has_noise(mds->fluid, mmd, scene_framenr + 1); + next_mesh = manta_has_mesh(mds->fluid, mmd, scene_framenr + 1); + next_particles = manta_has_particles(mds->fluid, mmd, scene_framenr + 1); + next_guide = manta_has_guiding(mds->fluid, mmd, scene_framenr + 1, guide_parent); + + bool prev_data, prev_noise, prev_mesh, prev_particles, prev_guide; + prev_data = manta_has_data(mds->fluid, mmd, scene_framenr - 1); + prev_noise = manta_has_noise(mds->fluid, mmd, scene_framenr - 1); + prev_mesh = manta_has_mesh(mds->fluid, mmd, scene_framenr - 1); + prev_particles = manta_has_particles(mds->fluid, mmd, scene_framenr - 1); + prev_guide = manta_has_guiding(mds->fluid, mmd, scene_framenr - 1, guide_parent); + bool with_gdomain; with_gdomain = (mds->guide_source == FLUID_DOMAIN_GUIDE_SRC_DOMAIN); @@ -3824,6 +3844,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, default: /* Always trying to read the cache in replay mode. */ read_cache = true; + bake_cache = false; break; } @@ -3908,7 +3929,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, BKE_fluid_reallocate_fluid(mds, mds->res, 1); } /* Read data cache */ - if (!baking_data && !baking_particles && !baking_mesh && !mode_replay) { + if (!baking_data && !baking_particles && !baking_mesh && next_data) { has_data = manta_update_smoke_structures(mds->fluid, mmd, data_frame); } else { @@ -3933,18 +3954,21 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, break; case FLUID_DOMAIN_CACHE_REPLAY: default: - baking_data = !has_data; + baking_data = !has_data && (is_startframe || prev_data); if (with_smoke && with_noise) { - baking_noise = !has_noise; + baking_noise = !has_noise && (is_startframe || prev_noise); } if (with_liquid && with_mesh) { - baking_mesh = !has_mesh; + baking_mesh = !has_mesh && (is_startframe || prev_mesh); } if (with_liquid && with_particles) { - baking_particles = !has_particles; + baking_particles = !has_particles && (is_startframe || prev_particles); } - bake_cache = baking_data || baking_noise || baking_mesh || baking_particles; + /* Only bake if time advanced by one frame. */ + if (is_startframe || has_advanced) { + bake_cache = baking_data || baking_noise || baking_mesh || baking_particles; + } break; } diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h index f344e860d2e..bb85d8304ec 100644 --- a/source/blender/makesdna/DNA_fluid_types.h +++ b/source/blender/makesdna/DNA_fluid_types.h @@ -215,6 +215,46 @@ enum { #define FLUID_DOMAIN_SMOKE_SCRIPT "smoke_script.py" #define FLUID_DOMAIN_LIQUID_SCRIPT "liquid_script.py" +#define FLUID_DOMAIN_FILE_CONFIG "config_####" + +#define FLUID_DOMAIN_FILE_DENSITY "density_####" +#define FLUID_DOMAIN_FILE_SHADOW "shadow_####" +#define FLUID_DOMAIN_FILE_VEL "vel_####" +#define FLUID_DOMAIN_FILE_HEAT "heat_####" +#define FLUID_DOMAIN_FILE_COLORR "color_r_####" +#define FLUID_DOMAIN_FILE_COLORG "color_g_####" +#define FLUID_DOMAIN_FILE_COLORB "color_b_####" +#define FLUID_DOMAIN_FILE_FLAME "flame_####" +#define FLUID_DOMAIN_FILE_FUEL "fuel_####" +#define FLUID_DOMAIN_FILE_REACT "react_####" + +#define FLUID_DOMAIN_FILE_PHI "phi_####" +#define FLUID_DOMAIN_FILE_PP "pp_####" +#define FLUID_DOMAIN_FILE_PVEL "pVel_####" + +#define FLUID_DOMAIN_FILE_DENSITYNOISE "density_noise_####" +#define FLUID_DOMAIN_FILE_COLORRNOISE "color_r_noise_####" +#define FLUID_DOMAIN_FILE_COLORGNOISE "color_g_noise_####" +#define FLUID_DOMAIN_FILE_COLORBNOISE "color_b_noise_####" +#define FLUID_DOMAIN_FILE_FLAMENOISE "flame_noise_####" +#define FLUID_DOMAIN_FILE_FUELNOISE "fuel_noise_####" +#define FLUID_DOMAIN_FILE_REACTNOISE "react_noise_####" + +#define FLUID_DOMAIN_FILE_MESH "lMesh_####" +#define FLUID_DOMAIN_FILE_MESHVEL "lVelMesh_####" + +#define FLUID_DOMAIN_FILE_PPSND "ppSnd_####" +#define FLUID_DOMAIN_FILE_PVELSND "pVelSnd_####" +#define FLUID_DOMAIN_FILE_PLIFESND "pLifeSnd_####" + +#define FLUID_DOMAIN_FILE_GUIDEVEL "guidevel_####" + +#define FLUID_DOMAIN_EXTENSION_UNI ".uni" +#define FLUID_DOMAIN_EXTENSION_OPENVDB ".vdb" +#define FLUID_DOMAIN_EXTENSION_RAW ".raw" +#define FLUID_DOMAIN_EXTENSION_OBJ ".obj" +#define FLUID_DOMAIN_EXTENSION_BINOBJ ".bobj.gz" + enum { FLUID_DOMAIN_CACHE_REPLAY = 0, FLUID_DOMAIN_CACHE_MODULAR = 1, -- cgit v1.2.3 From 63922c5056d16cc91c30ec3476a28d523adbdbea Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 3 Apr 2020 18:24:08 +0200 Subject: Cleanup: Rename ExtensionRNA variables from ext to rna_ext Makes it more clear that code using this is related to the RNA integration of a type. Part of T74432. Also ran clang-format on affected files. --- source/blender/blenkernel/BKE_addon.h | 2 +- source/blender/blenkernel/BKE_keyconfig.h | 2 +- source/blender/blenkernel/BKE_node.h | 4 +- source/blender/blenkernel/BKE_screen.h | 8 +- source/blender/blenkernel/intern/node.c | 14 +-- source/blender/blenkernel/intern/screen.c | 8 +- source/blender/editors/animation/keyingsets.c | 4 +- source/blender/editors/include/ED_keyframing.h | 2 +- source/blender/editors/interface/interface.c | 8 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_script/script_edit.c | 2 +- source/blender/makesrna/RNA_define.h | 2 +- source/blender/makesrna/intern/rna_animation.c | 32 ++--- source/blender/makesrna/intern/rna_define.c | 6 +- source/blender/makesrna/intern/rna_nodetree.c | 100 ++++++++-------- source/blender/makesrna/intern/rna_render.c | 49 ++++---- source/blender/makesrna/intern/rna_ui.c | 133 +++++++++++---------- source/blender/makesrna/intern/rna_userdef.c | 20 ++-- source/blender/makesrna/intern/rna_wm.c | 96 +++++++-------- source/blender/makesrna/intern/rna_wm_gizmo.c | 97 +++++++-------- .../blender/nodes/composite/node_composite_tree.c | 2 +- .../nodes/composite/nodes/node_composite_common.c | 6 +- source/blender/nodes/shader/node_shader_tree.c | 2 +- .../nodes/shader/nodes/node_shader_common.c | 6 +- source/blender/nodes/texture/node_texture_tree.c | 2 +- .../nodes/texture/nodes/node_texture_common.c | 6 +- source/blender/python/intern/bpy_gizmo_wrap.c | 20 ++-- source/blender/python/intern/bpy_operator_wrap.c | 18 +-- source/blender/python/intern/bpy_rna.c | 2 +- source/blender/render/extern/include/RE_engine.h | 2 +- .../blender/render/intern/source/external_engine.c | 4 +- source/blender/windowmanager/WM_types.h | 2 +- .../blender/windowmanager/gizmo/WM_gizmo_types.h | 4 +- .../gizmo/intern/wm_gizmo_group_type.c | 2 +- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 2 +- source/blender/windowmanager/intern/wm_menu_type.c | 4 +- .../windowmanager/intern/wm_operator_type.c | 8 +- .../blender/windowmanager/intern/wm_uilist_type.c | 4 +- 38 files changed, 345 insertions(+), 342 deletions(-) diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h index 7bb1761dfbe..741be17bb25 100644 --- a/source/blender/blenkernel/BKE_addon.h +++ b/source/blender/blenkernel/BKE_addon.h @@ -33,7 +33,7 @@ typedef struct bAddonPrefType { char idname[64]; // best keep the same size as BKE_ST_MAXNAME /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } bAddonPrefType; #else diff --git a/source/blender/blenkernel/BKE_keyconfig.h b/source/blender/blenkernel/BKE_keyconfig.h index 711d0292f75..bc33cc2669e 100644 --- a/source/blender/blenkernel/BKE_keyconfig.h +++ b/source/blender/blenkernel/BKE_keyconfig.h @@ -37,7 +37,7 @@ typedef struct wmKeyConfigPrefType_Runtime { char idname[64]; /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } wmKeyConfigPrefType_Runtime; #else diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index dc06f56861a..38fe974c228 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -268,7 +268,7 @@ typedef struct bNodeType { NodeGPUExecFunction gpufunc; /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } bNodeType; /* nodetype->nclass, for add-menu and themes */ @@ -350,7 +350,7 @@ typedef struct bNodeTreeType { void (*node_add_init)(struct bNodeTree *ntree, struct bNode *bnode); /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } bNodeTreeType; /** \} */ diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index a3ff5c53828..d70718b4387 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -233,7 +233,7 @@ typedef struct PanelType { ListBase children; /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } PanelType; /* uilist types */ @@ -271,7 +271,7 @@ typedef struct uiListType { uiListFilterItemsFunc filter_items; /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } uiListType; /* header types */ @@ -288,7 +288,7 @@ typedef struct HeaderType { void (*draw)(const struct bContext *C, struct Header *header); /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } HeaderType; typedef struct Header { @@ -313,7 +313,7 @@ typedef struct MenuType { void (*draw)(const struct bContext *C, struct Menu *menu); /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } MenuType; typedef struct Menu { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index de5f9d34f6c..98a7673c9d5 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3625,9 +3625,9 @@ void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ case ID: \ BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \ - ntype->ext.srna = RNA_struct_find(#Category #StructName); \ - BLI_assert(ntype->ext.srna != NULL); \ - RNA_struct_blender_type_set(ntype->ext.srna, ntype); \ + ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \ + BLI_assert(ntype->rna_ext.srna != NULL); \ + RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \ break; switch (type) { @@ -4142,8 +4142,8 @@ void free_nodesystem(void) { if (nodetypes_hash) { NODE_TYPES_BEGIN (nt) { - if (nt->ext.free) { - nt->ext.free(nt->ext.data); + if (nt->rna_ext.free) { + nt->rna_ext.free(nt->rna_ext.data); } } NODE_TYPES_END; @@ -4169,8 +4169,8 @@ void free_nodesystem(void) if (nodetreetypes_hash) { NODE_TREE_TYPES_BEGIN (nt) { - if (nt->ext.free) { - nt->ext.free(nt->ext.data); + if (nt->rna_ext.free) { + nt->rna_ext.free(nt->rna_ext.data); } } NODE_TREE_TYPES_END; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 7ad08dc1ad5..37ea6c2cb4d 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -104,16 +104,16 @@ static void spacetype_free(SpaceType *st) BLI_freelistN(&art->drawcalls); for (pt = art->paneltypes.first; pt; pt = pt->next) { - if (pt->ext.free) { - pt->ext.free(pt->ext.data); + if (pt->rna_ext.free) { + pt->rna_ext.free(pt->rna_ext.data); } BLI_freelistN(&pt->children); } for (ht = art->headertypes.first; ht; ht = ht->next) { - if (ht->ext.free) { - ht->ext.free(ht->ext.data); + if (ht->rna_ext.free) { + ht->rna_ext.free(ht->rna_ext.data); } } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index d30d03a1c73..89c7860982b 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -646,8 +646,8 @@ void ANIM_keyingset_infos_exit(void) next = ksi->next; /* free extra RNA data, and remove from list */ - if (ksi->ext.free) { - ksi->ext.free(ksi->ext.data); + if (ksi->rna_ext.free) { + ksi->rna_ext.free(ksi->rna_ext.data); } BLI_freelinkN(&keyingset_type_infos, ksi); } diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 6cac3e60531..b362d35c09a 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -198,7 +198,7 @@ typedef struct KeyingSetInfo { cbKeyingSet_Generate generate; /* RNA integration */ - struct ExtensionRNA ext; + struct ExtensionRNA rna_ext; } KeyingSetInfo; /* -------- */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 78db23a380a..11dc8b3b8b4 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6607,8 +6607,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else { /* Not all menus are from Python. */ - if (mt->ext.srna) { - const char *t = RNA_struct_ui_description(mt->ext.srna); + if (mt->rna_ext.srna) { + const char *t = RNA_struct_ui_description(mt->rna_ext.srna); if (t && t[0]) { tmp = BLI_strdup(t); } @@ -6625,7 +6625,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else { /* Not all panels are from Python. */ - if (pt->ext.srna) { + if (pt->rna_ext.srna) { /* Panels don't yet have descriptions, this may be added. */ } } @@ -6644,7 +6644,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { MenuType *mt = UI_but_menutype_get(but); if (mt) { - _tmp = RNA_struct_translation_context(mt->ext.srna); + _tmp = RNA_struct_translation_context(mt->rna_ext.srna); } } if (BLT_is_default_context(_tmp)) { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 55a5a043014..e5ca2efb26f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3133,7 +3133,7 @@ static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), Poin static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocketTemplate *stemp) { - StructRNA *srna = ntype->ext.srna; + StructRNA *srna = ntype->rna_ext.srna; PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier); if (prop) { diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 79311cac6b5..e9ed1cec228 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -92,7 +92,7 @@ static bool script_test_modal_operators(bContext *C) wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; if (handler->op != NULL) { wmOperatorType *ot = handler->op->type; - if (ot->ext.srna) { + if (ot->rna_ext.srna) { return true; } } diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 558e490a16e..7a7ab1085dd 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -76,7 +76,7 @@ void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identi void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier); void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); void RNA_def_struct_ui_icon(StructRNA *srna, int icon); -void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext); +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext); void RNA_struct_free(BlenderRNA *brna, StructRNA *srna); void RNA_def_struct_translation_context(StructRNA *srna, const char *context); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 86391bdc40d..7ea44bce6db 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -194,7 +194,7 @@ static bool RKS_POLL_rna_internal(KeyingSetInfo *ksi, bContext *C) void *ret; int ok; - RNA_pointer_create(NULL, ksi->ext.srna, ksi, &ptr); + RNA_pointer_create(NULL, ksi->rna_ext.srna, ksi, &ptr); func = &rna_KeyingSetInfo_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); @@ -204,7 +204,7 @@ static bool RKS_POLL_rna_internal(KeyingSetInfo *ksi, bContext *C) RNA_parameter_set_lookup(&list, "context", &C); /* execute the function */ - ksi->ext.call(C, &ptr, func, &list); + ksi->rna_ext.call(C, &ptr, func, &list); /* read the result */ RNA_parameter_get_lookup(&list, "ok", &ret); @@ -224,7 +224,7 @@ static void RKS_ITER_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, ksi->ext.srna, ksi, &ptr); + RNA_pointer_create(NULL, ksi->rna_ext.srna, ksi, &ptr); func = &rna_KeyingSetInfo_iterator_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); @@ -235,7 +235,7 @@ static void RKS_ITER_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks RNA_parameter_set_lookup(&list, "ks", &ks); /* execute the function */ - ksi->ext.call(C, &ptr, func, &list); + ksi->rna_ext.call(C, &ptr, func, &list); } RNA_parameter_list_free(&list); } @@ -249,7 +249,7 @@ static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, ksi->ext.srna, ksi, &ptr); + RNA_pointer_create(NULL, ksi->rna_ext.srna, ksi, &ptr); func = &rna_KeyingSetInfo_generate_func; /* RNA_struct_find_generate(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); @@ -261,7 +261,7 @@ static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, RNA_parameter_set_lookup(&list, "data", data); /* execute the function */ - ksi->ext.call(C, &ptr, func, &list); + ksi->rna_ext.call(C, &ptr, func, &list); } RNA_parameter_list_free(&list); } @@ -273,7 +273,7 @@ static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr) { KeyingSetInfo *ksi = (KeyingSetInfo *)ptr->data; - return (ksi->ext.srna) ? ksi->ext.srna : &RNA_KeyingSetInfo; + return (ksi->rna_ext.srna) ? ksi->rna_ext.srna : &RNA_KeyingSetInfo; } static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type) @@ -285,7 +285,7 @@ static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type) } /* free RNA data referencing this */ - RNA_struct_free_extension(type, &ksi->ext); + RNA_struct_free_extension(type, &ksi->rna_ext); RNA_struct_free(&BLENDER_RNA, type); WM_main_add_notifier(NC_WINDOW, NULL); @@ -328,8 +328,8 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, /* check if we have registered this info before, and remove it */ ksi = ANIM_keyingset_info_find_name(dummyksi.idname); - if (ksi && ksi->ext.srna) { - rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna); + if (ksi && ksi->rna_ext.srna) { + rna_KeyingSetInfo_unregister(bmain, ksi->rna_ext.srna); } /* create a new KeyingSetInfo type */ @@ -337,11 +337,11 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, memcpy(ksi, &dummyksi, sizeof(KeyingSetInfo)); /* set RNA-extensions info */ - ksi->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ksi->idname, &RNA_KeyingSetInfo); - ksi->ext.data = data; - ksi->ext.call = call; - ksi->ext.free = free; - RNA_struct_blender_type_set(ksi->ext.srna, ksi); + ksi->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ksi->idname, &RNA_KeyingSetInfo); + ksi->rna_ext.data = data; + ksi->rna_ext.call = call; + ksi->rna_ext.free = free; + RNA_struct_blender_type_set(ksi->rna_ext.srna, ksi); /* set callbacks */ /* NOTE: we really should have all of these... */ @@ -355,7 +355,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, WM_main_add_notifier(NC_WINDOW, NULL); /* return the struct-rna added */ - return ksi->ext.srna; + return ksi->rna_ext.srna; } /* ****************************** */ diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index f5e7f87cfbd..7a439a11a54 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -760,10 +760,10 @@ void RNA_define_fallback_property_update(int noteflag, const char *updatefunc) } #endif -void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext) { #ifdef RNA_RUNTIME - ext->free(ext->data); /* decref's the PyObject that the srna owns */ + rna_ext->free(rna_ext->data); /* decref's the PyObject that the srna owns */ RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */ /* NULL the srna's value so RNA_struct_free wont complain of a leak */ @@ -771,7 +771,7 @@ void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) #else (void)srna; - (void)ext; + (void)rna_ext; #endif } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 29c36b21b7f..31d6ff80f34 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -681,8 +681,8 @@ static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->data; - if (ntree->typeinfo->ext.srna) { - return ntree->typeinfo->ext.srna; + if (ntree->typeinfo->rna_ext.srna) { + return ntree->typeinfo->rna_ext.srna; } else { return &RNA_NodeTree; @@ -699,12 +699,12 @@ static bool rna_NodeTree_poll(const bContext *C, bNodeTreeType *ntreetype) void *ret; bool visible; - RNA_pointer_create(NULL, ntreetype->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, ntreetype->rna_ext.srna, NULL, &ptr); /* dummy */ func = &rna_NodeTree_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - ntreetype->ext.call((bContext *)C, &ptr, func, &list); + ntreetype->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -726,7 +726,7 @@ static void rna_NodeTree_update_reg(bNodeTree *ntree) func = &rna_NodeTree_update_func; /* RNA_struct_find_function(&ptr, "update"); */ RNA_parameter_list_create(&list, &ptr, func); - ntree->typeinfo->ext.call(NULL, &ptr, func, &list); + ntree->typeinfo->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -741,13 +741,13 @@ static void rna_NodeTree_get_from_context( FunctionRNA *func; void *ret1, *ret2, *ret3; - RNA_pointer_create(NULL, ntreetype->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, ntreetype->rna_ext.srna, NULL, &ptr); /* dummy */ /* RNA_struct_find_function(&ptr, "get_from_context"); */ func = &rna_NodeTree_get_from_context_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - ntreetype->ext.call((bContext *)C, &ptr, func, &list); + ntreetype->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "result_1", &ret1); RNA_parameter_get_lookup(&list, "result_2", &ret2); @@ -767,7 +767,7 @@ static void rna_NodeTree_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &nt->ext); + RNA_struct_free_extension(type, &nt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); ntreeTypeFreeLink(nt); @@ -812,7 +812,7 @@ static StructRNA *rna_NodeTree_register(Main *bmain, /* check if we have registered this tree type before, and remove it */ nt = ntreeTypeFind(dummynt.idname); if (nt) { - rna_NodeTree_unregister(bmain, nt->ext.srna); + rna_NodeTree_unregister(bmain, nt->rna_ext.srna); } /* create a new node tree type */ @@ -821,14 +821,14 @@ static StructRNA *rna_NodeTree_register(Main *bmain, nt->type = NTREE_CUSTOM; - nt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, &RNA_NodeTree); - nt->ext.data = data; - nt->ext.call = call; - nt->ext.free = free; - RNA_struct_blender_type_set(nt->ext.srna, nt); + nt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, &RNA_NodeTree); + nt->rna_ext.data = data; + nt->rna_ext.call = call; + nt->rna_ext.free = free; + RNA_struct_blender_type_set(nt->rna_ext.srna, nt); - RNA_def_struct_ui_text(nt->ext.srna, nt->ui_name, nt->ui_description); - RNA_def_struct_ui_icon(nt->ext.srna, nt->ui_icon); + RNA_def_struct_ui_text(nt->rna_ext.srna, nt->ui_name, nt->ui_description); + RNA_def_struct_ui_icon(nt->rna_ext.srna, nt->ui_icon); nt->poll = (have_function[0]) ? rna_NodeTree_poll : NULL; nt->update = (have_function[1]) ? rna_NodeTree_update_reg : NULL; @@ -839,7 +839,7 @@ static StructRNA *rna_NodeTree_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static bool rna_NodeTree_check(bNodeTree *ntree, ReportList *reports) @@ -1323,8 +1323,8 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr) { bNode *node = (bNode *)ptr->data; - if (node->typeinfo->ext.srna) { - return node->typeinfo->ext.srna; + if (node->typeinfo->rna_ext.srna) { + return node->typeinfo->rna_ext.srna; } else { return ptr->type; @@ -1380,12 +1380,12 @@ static bool rna_Node_poll(bNodeType *ntype, bNodeTree *ntree) void *ret; bool visible; - RNA_pointer_create(NULL, ntype->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, ntype->rna_ext.srna, NULL, &ptr); /* dummy */ func = &rna_Node_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "node_tree", &ntree); - ntype->ext.call(NULL, &ptr, func, &list); + ntype->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -1405,12 +1405,12 @@ static bool rna_Node_poll_instance(bNode *node, bNodeTree *ntree) void *ret; bool visible; - RNA_pointer_create(NULL, node->typeinfo->ext.srna, node, &ptr); /* dummy */ + RNA_pointer_create(NULL, node->typeinfo->rna_ext.srna, node, &ptr); /* dummy */ func = &rna_Node_poll_instance_func; /* RNA_struct_find_function(&ptr, "poll_instance"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "node_tree", &ntree); - node->typeinfo->ext.call(NULL, &ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -1434,11 +1434,11 @@ static void rna_Node_update_reg(bNodeTree *ntree, bNode *node) ParameterList list; FunctionRNA *func; - RNA_pointer_create((ID *)ntree, node->typeinfo->ext.srna, node, &ptr); + RNA_pointer_create((ID *)ntree, node->typeinfo->rna_ext.srna, node, &ptr); func = &rna_Node_update_func; /* RNA_struct_find_function(&ptr, "update"); */ RNA_parameter_list_create(&list, &ptr, func); - node->typeinfo->ext.call(NULL, &ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1451,12 +1451,12 @@ static void rna_Node_insert_link(bNodeTree *ntree, bNode *node, bNodeLink *link) ParameterList list; FunctionRNA *func; - RNA_pointer_create((ID *)ntree, node->typeinfo->ext.srna, node, &ptr); + RNA_pointer_create((ID *)ntree, node->typeinfo->rna_ext.srna, node, &ptr); func = &rna_Node_insert_link_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "link", &link); - node->typeinfo->ext.call(NULL, &ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1472,7 +1472,7 @@ static void rna_Node_init(const bContext *C, PointerRNA *ptr) func = &rna_Node_init_func; /* RNA_struct_find_function(&ptr, "init"); */ RNA_parameter_list_create(&list, ptr, func); - node->typeinfo->ext.call((bContext *)C, ptr, func, &list); + node->typeinfo->rna_ext.call((bContext *)C, ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1489,7 +1489,7 @@ static void rna_Node_copy(PointerRNA *ptr, const struct bNode *copynode) RNA_parameter_list_create(&list, ptr, func); RNA_parameter_set_lookup(&list, "node", ©node); - node->typeinfo->ext.call(NULL, ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1505,7 +1505,7 @@ static void rna_Node_free(PointerRNA *ptr) func = &rna_Node_free_func; /* RNA_struct_find_function(&ptr, "free"); */ RNA_parameter_list_create(&list, ptr, func); - node->typeinfo->ext.call(NULL, ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1523,7 +1523,7 @@ static void rna_Node_draw_buttons(struct uiLayout *layout, bContext *C, PointerR RNA_parameter_list_create(&list, ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "layout", &layout); - node->typeinfo->ext.call(C, ptr, func, &list); + node->typeinfo->rna_ext.call(C, ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1541,7 +1541,7 @@ static void rna_Node_draw_buttons_ext(struct uiLayout *layout, bContext *C, Poin RNA_parameter_list_create(&list, ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "layout", &layout); - node->typeinfo->ext.call(C, ptr, func, &list); + node->typeinfo->rna_ext.call(C, ptr, func, &list); RNA_parameter_list_free(&list); } @@ -1560,7 +1560,7 @@ static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); RNA_parameter_list_create(&list, &ptr, func); - node->typeinfo->ext.call(NULL, &ptr, func, &list); + node->typeinfo->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_get_lookup(&list, "label", &ret); rlabel = (char *)ret; @@ -1591,7 +1591,7 @@ static void rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &nt->ext); + RNA_struct_free_extension(type, &nt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); /* this also frees the allocated nt pointer, no MEM_free call needed! */ @@ -1646,7 +1646,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, /* check if we have registered this node type before, and remove it */ nt = nodeTypeFind(dummynt.idname); if (nt) { - rna_Node_unregister(bmain, nt->ext.srna); + rna_Node_unregister(bmain, nt->rna_ext.srna); } /* create a new node type */ @@ -1654,17 +1654,17 @@ static bNodeType *rna_Node_register_base(Main *bmain, memcpy(nt, &dummynt, sizeof(dummynt)); nt->free_self = (void (*)(bNodeType *))MEM_freeN; - nt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, basetype); - nt->ext.data = data; - nt->ext.call = call; - nt->ext.free = free; - RNA_struct_blender_type_set(nt->ext.srna, nt); + nt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, nt->idname, basetype); + nt->rna_ext.data = data; + nt->rna_ext.call = call; + nt->rna_ext.free = free; + RNA_struct_blender_type_set(nt->rna_ext.srna, nt); - RNA_def_struct_ui_text(nt->ext.srna, nt->ui_name, nt->ui_description); - RNA_def_struct_ui_icon(nt->ext.srna, nt->ui_icon); + RNA_def_struct_ui_text(nt->rna_ext.srna, nt->ui_name, nt->ui_description); + RNA_def_struct_ui_icon(nt->rna_ext.srna, nt->ui_icon); func = RNA_def_function_runtime( - nt->ext.srna, "is_registered_node_type", rna_Node_is_registered_node_type_runtime); + nt->rna_ext.srna, "is_registered_node_type", rna_Node_is_registered_node_type_runtime); RNA_def_function_ui_description(func, "True if a registered node type"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_SELF_TYPE); parm = RNA_def_boolean(func, "result", false, "Result", ""); @@ -1716,7 +1716,7 @@ static StructRNA *rna_Node_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static StructRNA *rna_ShaderNode_register(Main *bmain, @@ -1738,7 +1738,7 @@ static StructRNA *rna_ShaderNode_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static StructRNA *rna_CompositorNode_register(Main *bmain, @@ -1760,7 +1760,7 @@ static StructRNA *rna_CompositorNode_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static StructRNA *rna_TextureNode_register(Main *bmain, @@ -1782,7 +1782,7 @@ static StructRNA *rna_TextureNode_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create) @@ -2845,7 +2845,7 @@ static StructRNA *rna_NodeCustomGroup_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static StructRNA *rna_ShaderNodeCustomGroup_register(Main *bmain, @@ -2872,7 +2872,7 @@ static StructRNA *rna_ShaderNodeCustomGroup_register(Main *bmain, WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static StructRNA *rna_CompositorNodeCustomGroup_register(Main *bmain, @@ -2898,7 +2898,7 @@ static StructRNA *rna_CompositorNodeCustomGroup_register(Main *bmain, WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static void rna_CompositorNode_tag_need_exec(bNode *node) diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 40a2aeb5bd5..8322c7ad5f4 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -148,13 +148,13 @@ static void engine_update(RenderEngine *engine, Main *bmain, Depsgraph *depsgrap ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_update_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "data", &bmain); RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -166,12 +166,12 @@ static void engine_render(RenderEngine *engine, Depsgraph *depsgraph) ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_render_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -192,7 +192,7 @@ static void engine_bake(RenderEngine *engine, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_bake_func; RNA_parameter_list_create(&list, &ptr, func); @@ -205,7 +205,7 @@ static void engine_bake(RenderEngine *engine, RNA_parameter_set_lookup(&list, "num_pixels", &num_pixels); RNA_parameter_set_lookup(&list, "depth", &depth); RNA_parameter_set_lookup(&list, "result", &result); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -219,13 +219,13 @@ static void engine_view_update(RenderEngine *engine, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_view_update_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &context); RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -239,13 +239,13 @@ static void engine_view_draw(RenderEngine *engine, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_view_draw_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &context); RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -259,13 +259,13 @@ static void engine_update_script_node(RenderEngine *engine, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &nodeptr); func = &rna_RenderEngine_update_script_node_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "node", &nodeptr); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -279,13 +279,13 @@ static void engine_update_render_passes(RenderEngine *engine, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create(NULL, engine->type->rna_ext.srna, engine, &ptr); func = &rna_RenderEngine_update_render_passes_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "scene", &scene); RNA_parameter_set_lookup(&list, "renderlayer", &view_layer); - engine->type->ext.call(NULL, &ptr, func, &list); + engine->type->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -300,7 +300,7 @@ static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type) return; } - RNA_struct_free_extension(type, &et->ext); + RNA_struct_free_extension(type, &et->rna_ext); RNA_struct_free(&BLENDER_RNA, type); BLI_freelinkN(&R_engines, et); @@ -343,8 +343,8 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, /* check if we have registered this engine type before, and remove it */ for (et = R_engines.first; et; et = et->next) { if (STREQ(et->idname, dummyet.idname)) { - if (et->ext.srna) { - rna_RenderEngine_unregister(bmain, et->ext.srna); + if (et->rna_ext.srna) { + rna_RenderEngine_unregister(bmain, et->rna_ext.srna); } break; } @@ -354,11 +354,11 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, et = MEM_mallocN(sizeof(RenderEngineType), "python render engine"); memcpy(et, &dummyet, sizeof(dummyet)); - et->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, et->idname, &RNA_RenderEngine); - et->ext.data = data; - et->ext.call = call; - et->ext.free = free; - RNA_struct_blender_type_set(et->ext.srna, et); + et->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, et->idname, &RNA_RenderEngine); + et->rna_ext.data = data; + et->rna_ext.call = call; + et->rna_ext.free = free; + RNA_struct_blender_type_set(et->rna_ext.srna, et); et->update = (have_function[0]) ? engine_update : NULL; et->render = (have_function[1]) ? engine_render : NULL; @@ -370,7 +370,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, RE_engines_register(et); - return et->ext.srna; + return et->rna_ext.srna; } static void **rna_RenderEngine_instance(PointerRNA *ptr) @@ -382,7 +382,8 @@ static void **rna_RenderEngine_instance(PointerRNA *ptr) static StructRNA *rna_RenderEngine_refine(PointerRNA *ptr) { RenderEngine *engine = (RenderEngine *)ptr->data; - return (engine->type && engine->type->ext.srna) ? engine->type->ext.srna : &RNA_RenderEngine; + return (engine->type && engine->type->rna_ext.srna) ? engine->type->rna_ext.srna : + &RNA_RenderEngine; } static PointerRNA rna_RenderEngine_render_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 0800127fa9c..0dbea196de0 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -111,12 +111,12 @@ static bool panel_poll(const bContext *C, PanelType *pt) void *ret; bool visible; - RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_Panel_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + RNA_pointer_create(NULL, pt->rna_ext.srna, NULL, &ptr); /* dummy */ + func = &rna_Panel_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pt->ext.call((bContext *)C, &ptr, func, &list); + pt->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -134,12 +134,12 @@ static void panel_draw(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); func = &rna_Panel_draw_func; /* RNA_struct_find_function(&ptr, "draw"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->ext.call((bContext *)C, &ptr, func, &list); + pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -152,12 +152,12 @@ static void panel_draw_header(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); func = &rna_Panel_draw_header_func; /* RNA_struct_find_function(&ptr, "draw_header"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->ext.call((bContext *)C, &ptr, func, &list); + pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -170,12 +170,12 @@ static void panel_draw_header_preset(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); func = &rna_Panel_draw_header_preset_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->ext.call((bContext *)C, &ptr, func, &list); + pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -192,7 +192,7 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) return; } - RNA_struct_free_extension(type, &pt->ext); + RNA_struct_free_extension(type, &pt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); if (pt->parent) { @@ -301,8 +301,8 @@ static StructRNA *rna_Panel_register(Main *bmain, for (pt = art->paneltypes.first; pt; pt = pt->next) { if (STREQ(pt->idname, dummypt.idname)) { PanelType *pt_next = pt->next; - if (pt->ext.srna) { - rna_Panel_unregister(bmain, pt->ext.srna); + if (pt->rna_ext.srna) { + rna_Panel_unregister(bmain, pt->rna_ext.srna); } else { BLI_freelinkN(&art->paneltypes, pt); @@ -345,13 +345,13 @@ static StructRNA *rna_Panel_register(Main *bmain, pt = MEM_mallocN(sizeof(PanelType), "python buttons panel"); memcpy(pt, &dummypt, sizeof(dummypt)); - pt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel); - RNA_def_struct_translation_context(pt->ext.srna, pt->translation_context); - pt->ext.data = data; - pt->ext.call = call; - pt->ext.free = free; - RNA_struct_blender_type_set(pt->ext.srna, pt); - RNA_def_struct_flag(pt->ext.srna, STRUCT_NO_IDPROPERTIES); + pt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel); + RNA_def_struct_translation_context(pt->rna_ext.srna, pt->translation_context); + pt->rna_ext.data = data; + pt->rna_ext.call = call; + pt->rna_ext.free = free; + RNA_struct_blender_type_set(pt->rna_ext.srna, pt); + RNA_def_struct_flag(pt->rna_ext.srna, STRUCT_NO_IDPROPERTIES); pt->poll = (have_function[0]) ? panel_poll : NULL; pt->draw = (have_function[1]) ? panel_draw : NULL; @@ -391,13 +391,13 @@ static StructRNA *rna_Panel_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return pt->ext.srna; + return pt->rna_ext.srna; } static StructRNA *rna_Panel_refine(PointerRNA *ptr) { Panel *menu = (Panel *)ptr->data; - return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Panel; + return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : &RNA_Panel; } /* UIList */ @@ -434,7 +434,7 @@ static void uilist_draw_item(uiList *ui_list, ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr); func = &rna_UIList_draw_item_func; /* RNA_struct_find_function(&ul_ptr, "draw_item"); */ RNA_parameter_list_create(&list, &ul_ptr, func); @@ -447,7 +447,7 @@ static void uilist_draw_item(uiList *ui_list, RNA_parameter_set_lookup(&list, "active_property", &active_propname); RNA_parameter_set_lookup(&list, "index", &index); RNA_parameter_set_lookup(&list, "flt_flag", &flt_flag); - ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list); + ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -460,13 +460,13 @@ static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr); func = &rna_UIList_draw_filter_func; /* RNA_struct_find_function(&ul_ptr, "draw_filter"); */ RNA_parameter_list_create(&list, &ul_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "layout", &layout); - ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list); + ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -489,7 +489,7 @@ static void uilist_filter_items(uiList *ui_list, int ret_len; int len = flt_data->items_len = RNA_collection_length(dataptr, propname); - RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr); func = &rna_UIList_filter_items_func; /* RNA_struct_find_function(&ul_ptr, "filter_items"); */ RNA_parameter_list_create(&list, &ul_ptr, func); @@ -497,7 +497,7 @@ static void uilist_filter_items(uiList *ui_list, RNA_parameter_set_lookup(&list, "data", dataptr); RNA_parameter_set_lookup(&list, "property", &propname); - ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list); + ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list); parm = RNA_function_find_parameter(NULL, func, "filter_flags"); ret_len = RNA_parameter_dynamic_length_get(&list, parm); @@ -600,7 +600,7 @@ static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &ult->ext); + RNA_struct_free_extension(type, &ult->rna_ext); RNA_struct_free(&BLENDER_RNA, type); WM_uilisttype_freelink(ult); @@ -643,8 +643,8 @@ static StructRNA *rna_UIList_register(Main *bmain, /* check if we have registered this uilist type before, and remove it */ ult = WM_uilisttype_find(dummyult.idname, true); - if (ult && ult->ext.srna) { - rna_UIList_unregister(bmain, ult->ext.srna); + if (ult && ult->rna_ext.srna) { + rna_UIList_unregister(bmain, ult->rna_ext.srna); } if (!RNA_struct_available_or_report(reports, dummyult.idname)) { return NULL; @@ -657,11 +657,11 @@ static StructRNA *rna_UIList_register(Main *bmain, ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist"); memcpy(ult, &dummyult, sizeof(dummyult)); - ult->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ult->idname, &RNA_UIList); - ult->ext.data = data; - ult->ext.call = call; - ult->ext.free = free; - RNA_struct_blender_type_set(ult->ext.srna, ult); + ult->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ult->idname, &RNA_UIList); + ult->rna_ext.data = data; + ult->rna_ext.call = call; + ult->rna_ext.free = free; + RNA_struct_blender_type_set(ult->rna_ext.srna, ult); ult->draw_item = (have_function[0]) ? uilist_draw_item : NULL; ult->draw_filter = (have_function[1]) ? uilist_draw_filter : NULL; @@ -672,13 +672,14 @@ static StructRNA *rna_UIList_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return ult->ext.srna; + return ult->rna_ext.srna; } static StructRNA *rna_UIList_refine(PointerRNA *ptr) { uiList *ui_list = (uiList *)ptr->data; - return (ui_list->type && ui_list->type->ext.srna) ? ui_list->type->ext.srna : &RNA_UIList; + return (ui_list->type && ui_list->type->rna_ext.srna) ? ui_list->type->rna_ext.srna : + &RNA_UIList; } /* Header */ @@ -691,12 +692,12 @@ static void header_draw(const bContext *C, Header *hdr) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->ext.srna, hdr, &htr); + RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->rna_ext.srna, hdr, &htr); func = &rna_Header_draw_func; /* RNA_struct_find_function(&htr, "draw"); */ RNA_parameter_list_create(&list, &htr, func); RNA_parameter_set_lookup(&list, "context", &C); - hdr->type->ext.call((bContext *)C, &htr, func, &list); + hdr->type->rna_ext.call((bContext *)C, &htr, func, &list); RNA_parameter_list_free(&list); } @@ -713,7 +714,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &ht->ext); + RNA_struct_free_extension(type, &ht->rna_ext); RNA_struct_free(&BLENDER_RNA, type); BLI_freelinkN(&art->headertypes, ht); @@ -762,8 +763,8 @@ static StructRNA *rna_Header_register(Main *bmain, /* check if we have registered this header type before, and remove it */ for (ht = art->headertypes.first; ht; ht = ht->next) { if (STREQ(ht->idname, dummyht.idname)) { - if (ht->ext.srna) { - rna_Header_unregister(bmain, ht->ext.srna); + if (ht->rna_ext.srna) { + rna_Header_unregister(bmain, ht->rna_ext.srna); } break; } @@ -779,11 +780,11 @@ static StructRNA *rna_Header_register(Main *bmain, ht = MEM_mallocN(sizeof(HeaderType), "python buttons header"); memcpy(ht, &dummyht, sizeof(dummyht)); - ht->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header); - ht->ext.data = data; - ht->ext.call = call; - ht->ext.free = free; - RNA_struct_blender_type_set(ht->ext.srna, ht); + ht->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header); + ht->rna_ext.data = data; + ht->rna_ext.call = call; + ht->rna_ext.free = free; + RNA_struct_blender_type_set(ht->rna_ext.srna, ht); ht->draw = (have_function[0]) ? header_draw : NULL; @@ -792,13 +793,13 @@ static StructRNA *rna_Header_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return ht->ext.srna; + return ht->rna_ext.srna; } static StructRNA *rna_Header_refine(PointerRNA *htr) { Header *hdr = (Header *)htr->data; - return (hdr->type && hdr->type->ext.srna) ? hdr->type->ext.srna : &RNA_Header; + return (hdr->type && hdr->type->rna_ext.srna) ? hdr->type->rna_ext.srna : &RNA_Header; } /* Menu */ @@ -813,12 +814,12 @@ static bool menu_poll(const bContext *C, MenuType *pt) void *ret; bool visible; - RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + RNA_pointer_create(NULL, pt->rna_ext.srna, NULL, &ptr); /* dummy */ + func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pt->ext.call((bContext *)C, &ptr, func, &list); + pt->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -836,12 +837,12 @@ static void menu_draw(const bContext *C, Menu *menu) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, menu->type->ext.srna, menu, &mtr); + RNA_pointer_create(&CTX_wm_screen(C)->id, menu->type->rna_ext.srna, menu, &mtr); func = &rna_Menu_draw_func; /* RNA_struct_find_function(&mtr, "draw"); */ RNA_parameter_list_create(&list, &mtr, func); RNA_parameter_set_lookup(&list, "context", &C); - menu->type->ext.call((bContext *)C, &mtr, func, &list); + menu->type->rna_ext.call((bContext *)C, &mtr, func, &list); RNA_parameter_list_free(&list); } @@ -854,7 +855,7 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &mt->ext); + RNA_struct_free_extension(type, &mt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); WM_menutype_freelink(mt); @@ -904,8 +905,8 @@ static StructRNA *rna_Menu_register(Main *bmain, /* check if we have registered this menu type before, and remove it */ mt = WM_menutype_find(dummymt.idname, true); - if (mt && mt->ext.srna) { - rna_Menu_unregister(bmain, mt->ext.srna); + if (mt && mt->rna_ext.srna) { + rna_Menu_unregister(bmain, mt->rna_ext.srna); } if (!RNA_struct_available_or_report(reports, dummymt.idname)) { return NULL; @@ -932,13 +933,13 @@ static StructRNA *rna_Menu_register(Main *bmain, mt->description = NULL; } - mt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, mt->idname, &RNA_Menu); - RNA_def_struct_translation_context(mt->ext.srna, mt->translation_context); - mt->ext.data = data; - mt->ext.call = call; - mt->ext.free = free; - RNA_struct_blender_type_set(mt->ext.srna, mt); - RNA_def_struct_flag(mt->ext.srna, STRUCT_NO_IDPROPERTIES); + mt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, mt->idname, &RNA_Menu); + RNA_def_struct_translation_context(mt->rna_ext.srna, mt->translation_context); + mt->rna_ext.data = data; + mt->rna_ext.call = call; + mt->rna_ext.free = free; + RNA_struct_blender_type_set(mt->rna_ext.srna, mt); + RNA_def_struct_flag(mt->rna_ext.srna, STRUCT_NO_IDPROPERTIES); mt->poll = (have_function[0]) ? menu_poll : NULL; mt->draw = (have_function[1]) ? menu_draw : NULL; @@ -955,13 +956,13 @@ static StructRNA *rna_Menu_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return mt->ext.srna; + return mt->rna_ext.srna; } static StructRNA *rna_Menu_refine(PointerRNA *mtr) { Menu *menu = (Menu *)mtr->data; - return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Menu; + return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : &RNA_Menu; } static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 3b2753518bb..b107c89388d 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -793,7 +793,7 @@ static PointerRNA rna_Addon_preferences_get(PointerRNA *ptr) IDPropertyTemplate val = {0}; addon->prop = IDP_New(IDP_GROUP, &val, addon->module); /* name is unimportant */ } - return rna_pointer_inherit_refine(ptr, apt->ext.srna, addon->prop); + return rna_pointer_inherit_refine(ptr, apt->rna_ext.srna, addon->prop); } else { return PointerRNA_NULL; @@ -808,7 +808,7 @@ static void rna_AddonPref_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &apt->ext); + RNA_struct_free_extension(type, &apt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); BKE_addon_pref_type_remove(apt); @@ -850,8 +850,8 @@ static StructRNA *rna_AddonPref_register(Main *bmain, /* check if we have registered this addon-pref type before, and remove it */ apt = BKE_addon_pref_type_find(dummy_addon.module, true); - if (apt && apt->ext.srna) { - rna_AddonPref_unregister(bmain, apt->ext.srna); + if (apt && apt->rna_ext.srna) { + rna_AddonPref_unregister(bmain, apt->rna_ext.srna); } /* create a new addon-pref type */ @@ -859,18 +859,18 @@ static StructRNA *rna_AddonPref_register(Main *bmain, memcpy(apt, &dummy_apt, sizeof(dummy_apt)); BKE_addon_pref_type_add(apt); - apt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_AddonPreferences); - apt->ext.data = data; - apt->ext.call = call; - apt->ext.free = free; - RNA_struct_blender_type_set(apt->ext.srna, apt); + apt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_AddonPreferences); + apt->rna_ext.data = data; + apt->rna_ext.call = call; + apt->rna_ext.free = free; + RNA_struct_blender_type_set(apt->rna_ext.srna, apt); // apt->draw = (have_function[0]) ? header_draw : NULL; /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return apt->ext.srna; + return apt->rna_ext.srna; } /* placeholder, doesn't do anything useful yet */ diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index b0d77a2e176..151c772f533 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1085,7 +1085,7 @@ static PointerRNA rna_wmKeyConfig_preferences_get(PointerRNA *ptr) wmKeyConfigPrefType_Runtime *kpt_rt = BKE_keyconfig_pref_type_find(kc->idname, true); if (kpt_rt) { wmKeyConfigPref *kpt = BKE_keyconfig_pref_ensure(&U, kc->idname); - return rna_pointer_inherit_refine(ptr, kpt_rt->ext.srna, kpt->prop); + return rna_pointer_inherit_refine(ptr, kpt_rt->rna_ext.srna, kpt->prop); } else { return PointerRNA_NULL; @@ -1109,7 +1109,7 @@ static void rna_wmKeyConfigPref_unregister(Main *UNUSED(bmain), StructRNA *type) return; } - RNA_struct_free_extension(type, &kpt_rt->ext); + RNA_struct_free_extension(type, &kpt_rt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); /* Possible we're not in the preferences if they have been reset. */ @@ -1152,8 +1152,8 @@ static StructRNA *rna_wmKeyConfigPref_register(Main *bmain, /* check if we have registered this keyconf-prefs type before, and remove it */ kpt_rt = BKE_keyconfig_pref_type_find(dummy_kpt.idname, true); - if (kpt_rt && kpt_rt->ext.srna) { - rna_wmKeyConfigPref_unregister(bmain, kpt_rt->ext.srna); + if (kpt_rt && kpt_rt->rna_ext.srna) { + rna_wmKeyConfigPref_unregister(bmain, kpt_rt->rna_ext.srna); } /* create a new keyconf-prefs type */ @@ -1162,18 +1162,18 @@ static StructRNA *rna_wmKeyConfigPref_register(Main *bmain, BKE_keyconfig_pref_type_add(kpt_rt); - kpt_rt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_KeyConfigPreferences); - kpt_rt->ext.data = data; - kpt_rt->ext.call = call; - kpt_rt->ext.free = free; - RNA_struct_blender_type_set(kpt_rt->ext.srna, kpt_rt); + kpt_rt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_KeyConfigPreferences); + kpt_rt->rna_ext.data = data; + kpt_rt->rna_ext.call = call; + kpt_rt->rna_ext.free = free; + RNA_struct_blender_type_set(kpt_rt->rna_ext.srna, kpt_rt); // kpt_rt->draw = (have_function[0]) ? header_draw : NULL; /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); - return kpt_rt->ext.srna; + return kpt_rt->rna_ext.srna; } /* placeholder, doesn't do anything useful yet */ @@ -1292,12 +1292,12 @@ static bool rna_operator_poll_cb(bContext *C, wmOperatorType *ot) void *ret; bool visible; - RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */ - func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + RNA_pointer_create(NULL, ot->rna_ext.srna, NULL, &ptr); /* dummy */ + func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - ot->ext.call(C, &ptr, func, &list); + ot->rna_ext.call(C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -1317,12 +1317,12 @@ static int rna_operator_execute_cb(bContext *C, wmOperator *op) void *ret; int result; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_get_lookup(&list, "result", &ret); result = *(int *)ret; @@ -1343,12 +1343,12 @@ static bool rna_operator_check_cb(bContext *C, wmOperator *op) void *ret; bool result; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_get_lookup(&list, "result", &ret); result = (*(bool *)ret) != 0; @@ -1368,13 +1368,13 @@ static int rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *ev void *ret; int result; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_get_lookup(&list, "result", &ret); result = *(int *)ret; @@ -1395,13 +1395,13 @@ static int rna_operator_modal_cb(bContext *C, wmOperator *op, const wmEvent *eve void *ret; int result; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_get_lookup(&list, "result", &ret); result = *(int *)ret; @@ -1419,12 +1419,12 @@ static void rna_operator_draw_cb(bContext *C, wmOperator *op) ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_list_free(&list); } @@ -1438,12 +1438,12 @@ static void rna_operator_cancel_cb(bContext *C, wmOperator *op) ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + RNA_pointer_create(NULL, op->type->rna_ext.srna, op, &opr); func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */ RNA_parameter_list_create(&list, &opr, func); RNA_parameter_set_lookup(&list, "context", &C); - op->type->ext.call(C, &opr, func, &list); + op->type->rna_ext.call(C, &opr, func, &list); RNA_parameter_list_free(&list); } @@ -1458,13 +1458,13 @@ static char *rna_operator_description_cb(bContext *C, wmOperatorType *ot, Pointe void *ret; char *result; - RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, ot->rna_ext.srna, NULL, &ptr); /* dummy */ func = &rna_Operator_description_func; /* RNA_struct_find_function(&ptr, "description"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "properties", prop_ptr); - ot->ext.call(C, &ptr, func, &list); + ot->rna_ext.call(C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "result", &ret); result = (char *)ret; @@ -1532,8 +1532,8 @@ static StructRNA *rna_Operator_register(Main *bmain, /* check if we have registered this operator type before, and remove it */ { wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); - if (ot && ot->ext.srna) { - rna_Operator_unregister(bmain, ot->ext.srna); + if (ot && ot->rna_ext.srna) { + rna_Operator_unregister(bmain, ot->rna_ext.srna); } } @@ -1574,16 +1574,16 @@ static StructRNA *rna_Operator_register(Main *bmain, * for now just remove from dir(bpy.types) */ /* create a new operator type */ - dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator); + dummyot.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator); /* Operator properties are registered separately. */ - RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); + RNA_def_struct_flag(dummyot.rna_ext.srna, STRUCT_NO_IDPROPERTIES); - RNA_def_struct_property_tags(dummyot.ext.srna, rna_enum_operator_property_tags); - RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context); - dummyot.ext.data = data; - dummyot.ext.call = call; - dummyot.ext.free = free; + RNA_def_struct_property_tags(dummyot.rna_ext.srna, rna_enum_operator_property_tags); + RNA_def_struct_translation_context(dummyot.rna_ext.srna, dummyot.translation_context); + dummyot.rna_ext.data = data; + dummyot.rna_ext.call = call; + dummyot.rna_ext.free = free; dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL; dummyot.exec = (have_function[1]) ? rna_operator_execute_cb : NULL; @@ -1598,7 +1598,7 @@ static StructRNA *rna_Operator_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - return dummyot.ext.srna; + return dummyot.rna_ext.srna; } static void rna_Operator_unregister(struct Main *bmain, StructRNA *type) @@ -1620,7 +1620,7 @@ static void rna_Operator_unregister(struct Main *bmain, StructRNA *type) } WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - RNA_struct_free_extension(type, &ot->ext); + RNA_struct_free_extension(type, &ot->rna_ext); idname = ot->idname; WM_operatortype_remove_ptr(ot); @@ -1692,8 +1692,8 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, /* check if we have registered this operator type before, and remove it */ { wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); - if (ot && ot->ext.srna) { - rna_Operator_unregister(bmain, ot->ext.srna); + if (ot && ot->rna_ext.srna) { + rna_Operator_unregister(bmain, ot->rna_ext.srna); } } @@ -1734,11 +1734,11 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, * for now just remove from dir(bpy.types) */ /* create a new operator type */ - dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator); - RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context); - dummyot.ext.data = data; - dummyot.ext.call = call; - dummyot.ext.free = free; + dummyot.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator); + RNA_def_struct_translation_context(dummyot.rna_ext.srna, dummyot.translation_context); + dummyot.rna_ext.data = data; + dummyot.rna_ext.call = call; + dummyot.rna_ext.free = free; dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL; dummyot.ui = (have_function[3]) ? rna_operator_draw_cb : NULL; @@ -1748,20 +1748,20 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - return dummyot.ext.srna; + return dummyot.rna_ext.srna; } # endif /* WITH_PYTHON */ static StructRNA *rna_Operator_refine(PointerRNA *opr) { wmOperator *op = (wmOperator *)opr->data; - return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Operator; + return (op->type && op->type->rna_ext.srna) ? op->type->rna_ext.srna : &RNA_Operator; } static StructRNA *rna_MacroOperator_refine(PointerRNA *opr) { wmOperator *op = (wmOperator *)opr->data; - return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Macro; + return (op->type && op->type->rna_ext.srna) ? op->type->rna_ext.srna : &RNA_Macro; } /* just to work around 'const char *' warning and to ensure this is a python op */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 104ad4c5e25..eb3de008e4c 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -78,12 +78,12 @@ static void rna_gizmo_draw_cb(const struct bContext *C, struct wmGizmo *gz) PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "draw"); */ func = &rna_Gizmo_draw_func; RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -94,13 +94,13 @@ static void rna_gizmo_draw_select_cb(const struct bContext *C, struct wmGizmo *g PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "draw_select"); */ func = &rna_Gizmo_draw_select_func; RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "select_id", &select_id); - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -111,13 +111,13 @@ static int rna_gizmo_test_select_cb(struct bContext *C, struct wmGizmo *gz, cons PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "test_select"); */ func = &rna_Gizmo_test_select_func; RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "location", location); - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "intersect_id", &ret); @@ -138,14 +138,14 @@ static int rna_gizmo_modal_cb(struct bContext *C, ParameterList list; FunctionRNA *func; const int tweak_flag_int = tweak_flag; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "modal"); */ func = &rna_Gizmo_modal_func; RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int); - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "result", &ret); @@ -162,11 +162,11 @@ static void rna_gizmo_setup_cb(struct wmGizmo *gz) PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "setup"); */ func = &rna_Gizmo_setup_func; RNA_parameter_list_create(&list, &gz_ptr, func); - gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)NULL, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -177,13 +177,13 @@ static int rna_gizmo_invoke_cb(struct bContext *C, struct wmGizmo *gz, const str PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "invoke"); */ func = &rna_Gizmo_invoke_func; RNA_parameter_list_create(&list, &gz_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "event", &event); - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); void *ret; RNA_parameter_get_lookup(&list, "result", &ret); @@ -200,7 +200,7 @@ static void rna_gizmo_exit_cb(struct bContext *C, struct wmGizmo *gz, bool cance PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "exit"); */ func = &rna_Gizmo_exit_func; RNA_parameter_list_create(&list, &gz_ptr, func); @@ -209,7 +209,7 @@ static void rna_gizmo_exit_cb(struct bContext *C, struct wmGizmo *gz, bool cance int cancel_i = cancel; RNA_parameter_set_lookup(&list, "cancel", &cancel_i); } - gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -220,11 +220,11 @@ static void rna_gizmo_select_refresh_cb(struct wmGizmo *gz) PointerRNA gz_ptr; ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr); /* RNA_struct_find_function(&gz_ptr, "select_refresh"); */ func = &rna_Gizmo_select_refresh_func; RNA_parameter_list_create(&list, &gz_ptr, func); - gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)NULL, &gz_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -475,8 +475,8 @@ static StructRNA *rna_Gizmo_register(Main *bmain, /* check if we have registered this gizmo type before, and remove it */ { const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true); - if (gzt && gzt->ext.srna) { - rna_Gizmo_unregister(bmain, gzt->ext.srna); + if (gzt && gzt->rna_ext.srna) { + rna_Gizmo_unregister(bmain, gzt->rna_ext.srna); } } if (!RNA_struct_available_or_report(reports, dummygt.idname)) { @@ -489,12 +489,12 @@ static StructRNA *rna_Gizmo_register(Main *bmain, } /* create a new gizmo type */ - dummygt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo); + dummygt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo); /* gizmo properties are registered separately */ - RNA_def_struct_flag(dummygt.ext.srna, STRUCT_NO_IDPROPERTIES); - dummygt.ext.data = data; - dummygt.ext.call = call; - dummygt.ext.free = free; + RNA_def_struct_flag(dummygt.rna_ext.srna, STRUCT_NO_IDPROPERTIES); + dummygt.rna_ext.data = data; + dummygt.rna_ext.call = call; + dummygt.rna_ext.free = free; { int i = 0; @@ -517,7 +517,7 @@ static StructRNA *rna_Gizmo_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); - return dummygt.ext.srna; + return dummygt.rna_ext.srna; } static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type) @@ -528,7 +528,7 @@ static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type) return; } - RNA_struct_free_extension(type, &gzt->ext); + RNA_struct_free_extension(type, &gzt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); @@ -547,7 +547,7 @@ static void **rna_Gizmo_instance(PointerRNA *ptr) static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) { wmGizmo *gz = mnp_ptr->data; - return (gz->type && gz->type->ext.srna) ? gz->type->ext.srna : &RNA_Gizmo; + return (gz->type && gz->type->rna_ext.srna) ? gz->type->rna_ext.srna : &RNA_Gizmo; } /** \} */ @@ -665,12 +665,12 @@ static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt) void *ret; bool visible; - RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, gzgt->rna_ext.srna, NULL, &ptr); /* dummy */ func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - gzgt->ext.call((bContext *)C, &ptr, func, &list); + gzgt->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_get_lookup(&list, "visible", &ret); visible = *(bool *)ret; @@ -688,12 +688,12 @@ static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup) ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -707,13 +707,13 @@ static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wm ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ + RNA_pointer_create(NULL, gzgt->rna_ext.srna, NULL, &ptr); /* dummy */ func = &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "keyconfig", &config); - gzgt->ext.call(NULL, &ptr, func, &list); + gzgt->rna_ext.call(NULL, &ptr, func, &list); RNA_parameter_get_lookup(&list, "keymap", &ret); wmKeyMap *keymap = *(wmKeyMap **)ret; @@ -731,12 +731,12 @@ static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup) ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -749,13 +749,13 @@ static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgr ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr); func = &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ RNA_parameter_list_create(&list, &gzgroup_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -771,7 +771,7 @@ static void rna_gizmogroup_invoke_prepare_cb(const bContext *C, ParameterList list; FunctionRNA *func; - RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr); /* RNA_struct_find_function(&wgroupr, "invoke_prepare"); */ func = &rna_GizmoGroup_invoke_prepare_func; @@ -779,7 +779,7 @@ static void rna_gizmogroup_invoke_prepare_cb(const bContext *C, RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "gizmo", &gz); RNA_parameter_set_lookup(&list, "event", &event); - gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list); RNA_parameter_list_free(&list); } @@ -846,8 +846,8 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain, /* check if we have registered this gizmogroup type before, and remove it */ { wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true); - if (gzgt && gzgt->ext.srna) { - rna_GizmoGroup_unregister(bmain, gzgt->ext.srna); + if (gzgt && gzgt->rna_ext.srna) { + rna_GizmoGroup_unregister(bmain, gzgt->rna_ext.srna); } } if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { @@ -869,14 +869,14 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain, } /* create a new gizmogroup type */ - dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup); + dummywgt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup); /* Gizmo group properties are registered separately. */ - RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); + RNA_def_struct_flag(dummywgt.rna_ext.srna, STRUCT_NO_IDPROPERTIES); - dummywgt.ext.data = data; - dummywgt.ext.call = call; - dummywgt.ext.free = free; + dummywgt.rna_ext.data = data; + dummywgt.rna_ext.call = call; + dummywgt.rna_ext.free = free; /* We used to register widget group types like this, now we do it similar to * operator types. Thus we should be able to do the same as operator types now. */ @@ -904,7 +904,7 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain, WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); } - return dummywgt.ext.srna; + return dummywgt.rna_ext.srna; } static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type) @@ -915,7 +915,7 @@ static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type) return; } - RNA_struct_free_extension(type, &gzgt->ext); + RNA_struct_free_extension(type, &gzgt->rna_ext); RNA_struct_free(&BLENDER_RNA, type); WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); @@ -934,7 +934,8 @@ static void **rna_GizmoGroup_instance(PointerRNA *ptr) static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr) { wmGizmoGroup *gzgroup = gzgroup_ptr->data; - return (gzgroup->type && gzgroup->type->ext.srna) ? gzgroup->type->ext.srna : &RNA_GizmoGroup; + return (gzgroup->type && gzgroup->type->rna_ext.srna) ? gzgroup->type->rna_ext.srna : + &RNA_GizmoGroup; } static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index a830f5f1bf9..00c279ab8f6 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -228,7 +228,7 @@ void register_node_tree_type_cmp(void) tt->get_from_context = composite_get_from_context; tt->node_add_init = composite_node_add_init; - tt->ext.srna = &RNA_CompositorNodeTree; + tt->rna_ext.srna = &RNA_CompositorNodeTree; ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index 15637506e77..f5eaaef8a31 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -46,9 +46,9 @@ void register_node_type_cmp_group(void) ntype.poll_instance = node_group_poll_instance; ntype.insert_link = node_insert_link_default; ntype.update_internal_links = node_update_internal_links_default; - ntype.ext.srna = RNA_struct_find("CompositorNodeGroup"); - BLI_assert(ntype.ext.srna != NULL); - RNA_struct_blender_type_set(ntype.ext.srna, &ntype); + ntype.rna_ext.srna = RNA_struct_find("CompositorNodeGroup"); + BLI_assert(ntype.rna_ext.srna != NULL); + RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index a19fb30c53b..f79edcadbda 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -206,7 +206,7 @@ void register_node_tree_type_sh(void) tt->get_from_context = shader_get_from_context; tt->validate_link = shader_validate_link; - tt->ext.srna = &RNA_ShaderNodeTree; + tt->rna_ext.srna = &RNA_ShaderNodeTree; ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 0ecb64cd1d1..a864bef60d9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -238,9 +238,9 @@ void register_node_type_sh_group(void) ntype.poll_instance = node_group_poll_instance; ntype.insert_link = node_insert_link_default; ntype.update_internal_links = node_update_internal_links_default; - ntype.ext.srna = RNA_struct_find("ShaderNodeGroup"); - BLI_assert(ntype.ext.srna != NULL); - RNA_struct_blender_type_set(ntype.ext.srna, &ntype); + ntype.rna_ext.srna = RNA_struct_find("ShaderNodeGroup"); + BLI_assert(ntype.rna_ext.srna != NULL); + RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index cf5d39847cf..31f67cb1ffa 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -172,7 +172,7 @@ void register_node_tree_type_tex(void) tt->local_merge = local_merge; tt->get_from_context = texture_get_from_context; - tt->ext.srna = &RNA_TextureNodeTree; + tt->rna_ext.srna = &RNA_TextureNodeTree; ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index c83166f5ed6..0324cb38a73 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -167,9 +167,9 @@ void register_node_type_tex_group(void) ntype.poll_instance = node_group_poll_instance; ntype.insert_link = node_insert_link_default; ntype.update_internal_links = node_update_internal_links_default; - ntype.ext.srna = RNA_struct_find("TextureNodeGroup"); - BLI_assert(ntype.ext.srna != NULL); - RNA_struct_blender_type_set(ntype.ext.srna, &ntype); + ntype.rna_ext.srna = RNA_struct_find("TextureNodeGroup"); + BLI_assert(ntype.rna_ext.srna != NULL); + RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index 8ff3af59930..774ad95c3eb 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -101,8 +101,8 @@ fail: static void gizmo_properties_init(wmGizmoType *gzt) { - PyTypeObject *py_class = gzt->ext.data; - RNA_struct_blender_type_set(gzt->ext.srna, gzt); + PyTypeObject *py_class = gzt->rna_ext.data; + RNA_struct_blender_type_set(gzt->rna_ext.srna, gzt); /* only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier @@ -160,9 +160,9 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) /* don't do translations here yet */ #if 0 - /* Use i18n context from ext.srna if possible (py gizmogroups). */ - if (gt->ext.srna) { - RNA_def_struct_translation_context(gt->srna, RNA_struct_translation_context(gt->ext.srna)); + /* Use i18n context from rna_ext.srna if possible (py gizmogroups). */ + if (gt->rna_ext.srna) { + RNA_def_struct_translation_context(gt->srna, RNA_struct_translation_context(gt->rna_ext.srna)); } #endif @@ -179,8 +179,8 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) static void gizmogroup_properties_init(wmGizmoGroupType *gzgt) { - PyTypeObject *py_class = gzgt->ext.data; - RNA_struct_blender_type_set(gzgt->ext.srna, gzgt); + PyTypeObject *py_class = gzgt->rna_ext.data; + RNA_struct_blender_type_set(gzgt->rna_ext.srna, gzgt); /* only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier @@ -203,9 +203,9 @@ void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata) /* don't do translations here yet */ #if 0 - /* Use i18n context from ext.srna if possible (py gizmogroups). */ - if (gzgt->ext.srna) { - RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->ext.srna)); + /* Use i18n context from rna_ext.srna if possible (py gizmogroups). */ + if (gzgt->rna_ext.srna) { + RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->rna_ext.srna)); } #endif diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index b7d3c99d3da..9fb25d41844 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -39,8 +39,8 @@ static void operator_properties_init(wmOperatorType *ot) { - PyTypeObject *py_class = ot->ext.data; - RNA_struct_blender_type_set(ot->ext.srna, ot); + PyTypeObject *py_class = ot->rna_ext.data; + RNA_struct_blender_type_set(ot->rna_ext.srna, ot); /* Only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier later. @@ -123,9 +123,9 @@ void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata) *ot = *((wmOperatorType *)userdata); ot->srna = srna; /* restore */ - /* Use i18n context from ext.srna if possible (py operators). */ - if (ot->ext.srna) { - RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->ext.srna)); + /* Use i18n context from rna_ext.srna if possible (py operators). */ + if (ot->rna_ext.srna) { + RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->rna_ext.srna)); } operator_properties_init(ot); @@ -142,11 +142,11 @@ void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata) ot->flag |= data->flag; /* append flags to the one set by registration */ ot->pyop_poll = data->pyop_poll; ot->ui = data->ui; - ot->ext = data->ext; + ot->rna_ext = data->rna_ext; - /* Use i18n context from ext.srna if possible (py operators). */ - if (ot->ext.srna) { - RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->ext.srna)); + /* Use i18n context from rna_ext.srna if possible (py operators). */ + if (ot->rna_ext.srna) { + RNA_def_struct_translation_context(ot->srna, RNA_struct_translation_context(ot->rna_ext.srna)); } operator_properties_init(ot); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9579f78be30..2c54b9ce1e1 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4091,7 +4091,7 @@ static PyObject *pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args) if (srna_base == &RNA_Node) { bNodeType *nt = nodeTypeFind(id); if (nt) { - RNA_pointer_create(NULL, &RNA_Struct, nt->ext.srna, &ptr); + RNA_pointer_create(NULL, &RNA_Struct, nt->rna_ext.srna, &ptr); return pyrna_struct_CreatePyObject(&ptr); } } diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h index 0b5b62e2f08..fd55a2a01df 100644 --- a/source/blender/render/extern/include/RE_engine.h +++ b/source/blender/render/extern/include/RE_engine.h @@ -110,7 +110,7 @@ typedef struct RenderEngineType { struct DrawEngineType *draw_engine; /* RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; } RenderEngineType; typedef void (*update_render_passes_cb_t)(void *userdata, diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 7c071bb6b04..ffd483a8b62 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -87,8 +87,8 @@ void RE_engines_exit(void) BLI_remlink(&R_engines, type); if (!(type->flag & RE_INTERNAL)) { - if (type->ext.free) { - type->ext.free(type->ext.data); + if (type->rna_ext.free) { + type->rna_ext.free(type->rna_ext.data); } MEM_freeN(type); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 33b3ca5f2e2..c7d1c4992e3 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -760,7 +760,7 @@ typedef struct wmOperatorType { bool (*pyop_poll)(struct bContext *, struct wmOperatorType *ot) ATTR_WARN_UNUSED_RESULT; /** RNA integration */ - ExtensionRNA ext; + ExtensionRNA rna_ext; /** Flag last for padding */ short flag; diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index d2953a56749..955fb959e92 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -381,7 +381,7 @@ typedef struct wmGizmoType { struct StructRNA *srna; /** RNA integration. */ - ExtensionRNA ext; + ExtensionRNA rna_ext; ListBase target_property_defs; int target_property_defs_len; @@ -436,7 +436,7 @@ typedef struct wmGizmoGroupType { struct StructRNA *srna; /** RNA integration. */ - ExtensionRNA ext; + ExtensionRNA rna_ext; eWM_GizmoFlagGroupTypeFlag flag; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index 560d73ec220..f594ced6b66 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -144,7 +144,7 @@ wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link(wmGizmoMapType *gzmap_typ */ static void gizmogrouptype_free(wmGizmoGroupType *gzgt) { - if (gzgt->ext.srna) { /* python gizmo group, allocs own string */ + if (gzgt->rna_ext.srna) { /* python gizmo group, allocs own string */ MEM_freeN((void *)gzgt->idname); } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 7d4c3d40209..fe7de6739e1 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -120,7 +120,7 @@ void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void */ static void gizmotype_free(wmGizmoType *gzt) { - if (gzt->ext.srna) { /* python gizmo, allocs own string */ + if (gzt->rna_ext.srna) { /* python gizmo, allocs own string */ MEM_freeN((void *)gzt->idname); } diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c index 28dd1984bf0..c4491423d82 100644 --- a/source/blender/windowmanager/intern/wm_menu_type.c +++ b/source/blender/windowmanager/intern/wm_menu_type.c @@ -87,8 +87,8 @@ void WM_menutype_free(void) GHASH_ITER (gh_iter, menutypes_hash) { MenuType *mt = BLI_ghashIterator_getValue(&gh_iter); - if (mt->ext.free) { - mt->ext.free(mt->ext.data); + if (mt->rna_ext.free) { + mt->rna_ext.free(mt->rna_ext.data); } } diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 015f2b0448d..650d5bbe015 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -199,7 +199,7 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot) wm_operatortype_free_macro(ot); } - if (ot->ext.srna) { + if (ot->rna_ext.srna) { /* python operator, allocs own string */ MEM_freeN((void *)ot->idname); } @@ -507,9 +507,9 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); - /* Use i18n context from ext.srna if possible (py operators). */ - i18n_context = ot->ext.srna ? RNA_struct_translation_context(ot->ext.srna) : - BLT_I18NCONTEXT_OPERATOR_DEFAULT; + /* Use i18n context from rna_ext.srna if possible (py operators). */ + i18n_context = ot->rna_ext.srna ? RNA_struct_translation_context(ot->rna_ext.srna) : + BLT_I18NCONTEXT_OPERATOR_DEFAULT; RNA_def_struct_translation_context(ot->srna, i18n_context); ot->translation_context = i18n_context; diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c index f886e01f5a3..801043a56d1 100644 --- a/source/blender/windowmanager/intern/wm_uilist_type.c +++ b/source/blender/windowmanager/intern/wm_uilist_type.c @@ -82,8 +82,8 @@ void WM_uilisttype_free(void) GHASH_ITER (gh_iter, uilisttypes_hash) { uiListType *ult = BLI_ghashIterator_getValue(&gh_iter); - if (ult->ext.free) { - ult->ext.free(ult->ext.data); + if (ult->rna_ext.free) { + ult->rna_ext.free(ult->rna_ext.data); } } -- cgit v1.2.3 From cfc8d73546239bf2e66f5ecf677374be4efb61ce Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 19:16:49 +0200 Subject: Cleanup: Move all Face Set functionality to its own file --- source/blender/editors/sculpt_paint/CMakeLists.txt | 1 + source/blender/editors/sculpt_paint/sculpt.c | 918 +------------------ .../blender/editors/sculpt_paint/sculpt_face_set.c | 975 +++++++++++++++++++++ .../blender/editors/sculpt_paint/sculpt_intern.h | 49 +- 4 files changed, 1028 insertions(+), 915 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_face_set.c diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index de9e70f8e06..fda9594835d 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -60,6 +60,7 @@ set(SRC paint_vertex_weight_utils.c sculpt.c sculpt_cloth.c + sculpt_face_set.c sculpt_multiplane_scrape.c sculpt_pose.c sculpt_undo.c diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d30dce666c4..490ec336ccc 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -216,7 +216,7 @@ static void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]) /* Sculpt Face Sets and Visibility. */ -static int SCULPT_active_face_set_get(SculptSession *ss) +int SCULPT_active_face_set_get(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -232,7 +232,7 @@ static int SCULPT_active_face_set_get(SculptSession *ss) return SCULPT_FACE_SET_NONE; } -static void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible) +void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -247,7 +247,7 @@ static void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible } } -static bool SCULPT_vertex_visible_get(SculptSession *ss, int index) +bool SCULPT_vertex_visible_get(SculptSession *ss, int index) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -260,7 +260,7 @@ static bool SCULPT_vertex_visible_get(SculptSession *ss, int index) return true; } -static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible) +void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -281,7 +281,7 @@ static void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool } } -static void SCULPT_face_sets_visibility_invert(SculptSession *ss) +void SCULPT_face_sets_visibility_invert(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -295,7 +295,7 @@ static void SCULPT_face_sets_visibility_invert(SculptSession *ss) } } -static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible) +void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -322,7 +322,7 @@ static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible) } } -static bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index) +bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: { @@ -342,7 +342,7 @@ static bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index) return true; } -static bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index) +bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: { @@ -366,7 +366,7 @@ static bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index return true; } -static void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set) +void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: { @@ -526,7 +526,7 @@ bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index) return false; } -static int SCULPT_face_set_next_available_get(SculptSession *ss) +int SCULPT_face_set_next_available_get(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -3676,155 +3676,6 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) BKE_pbvh_parallel_range(0, totnode, &data, do_draw_brush_task_cb_ex, &settings); } -static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - const Brush *brush = data->brush; - const float bstrength = ss->cache->bstrength; - - PBVHVertexIter vd; - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { - MeshElemMap *vert_map = &ss->pmap[vd.index]; - for (int j = 0; j < ss->pmap[vd.index].count; j++) { - const MPoly *p = &ss->mpoly[vert_map->indices[j]]; - - float poly_center[3]; - BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], ss->mvert, poly_center); - - if (sculpt_brush_test_sq_fn(&test, poly_center)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - vd.mask ? *vd.mask : 0.0f, - vd.index, - tls->thread_id); - - if (fade > 0.05f && ss->face_sets[vert_map->indices[j]] > 0) { - ss->face_sets[vert_map->indices[j]] = abs(ss->cache->paint_face_set); - } - } - } - } - - else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - vd.mask ? *vd.mask : 0.0f, - vd.index, - tls->thread_id); - - if (fade > 0.05f) { - SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set); - } - } - } - } - } - BKE_pbvh_vertex_iter_end; -} - -static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - const Brush *brush = data->brush; - float bstrength = ss->cache->bstrength; - - PBVHVertexIter vd; - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0); - /* This operations needs a stregth tweak as the relax deformation is too weak by default. */ - if (relax_face_sets) { - bstrength *= 2.0f; - } - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - if (relax_face_sets != SCULPT_vertex_has_unique_face_set(ss, vd.index)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - vd.mask ? *vd.mask : 0.0f, - vd.index, - tls->thread_id); - - SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co); - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - } - } - BKE_pbvh_vertex_iter_end; -} - -static void do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) -{ - SculptSession *ss = ob->sculpt; - Brush *brush = BKE_paint_brush(&sd->paint); - - if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && - ss->cache->radial_symmetry_pass == 0) { - if (ss->cache->invert) { - /* When inverting the brush, pick the paint face mask ID from the mesh. */ - ss->cache->paint_face_set = SCULPT_active_face_set_get(ss); - } - else { - /* By default create a new Face Sets. */ - ss->cache->paint_face_set = SCULPT_face_set_next_available_get(ss); - } - } - - BKE_curvemapping_initialize(brush->curve); - - /* Threaded loop over nodes. */ - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .brush = brush, - .nodes = nodes, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - if (ss->cache->alt_smooth) { - for (int i = 0; i < 4; i++) { - BKE_pbvh_parallel_range(0, totnode, &data, do_relax_face_sets_brush_task_cb_ex, &settings); - } - } - else { - BKE_pbvh_parallel_range(0, totnode, &data, do_draw_face_sets_brush_task_cb_ex, &settings); - } -} static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata, const int n, @@ -6405,7 +6256,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe SCULPT_do_cloth_brush(sd, ob, nodes, totnode); break; case SCULPT_TOOL_DRAW_FACE_SETS: - do_draw_face_sets_brush(sd, ob, nodes, totnode); + SCULPT_do_draw_face_sets_brush(sd, ob, nodes, totnode); break; } @@ -11259,753 +11110,6 @@ static void SCULPT_OT_set_pivot_position(wmOperatorType *ot) 10000.0f); } -typedef enum eSculptFaceGroupsCreateModes { - SCULPT_FACE_SET_MASKED = 0, - SCULPT_FACE_SET_VISIBLE = 1, - SCULPT_FACE_SET_ALL = 2, - SCULPT_FACE_SET_SELECTION = 3, -} eSculptFaceGroupsCreateModes; - -static EnumPropertyItem prop_sculpt_face_set_create_types[] = { - { - SCULPT_FACE_SET_MASKED, - "MASKED", - 0, - "Face Set From Masked", - "Create a new Face Set from the masked faces", - }, - { - SCULPT_FACE_SET_VISIBLE, - "VISIBLE", - 0, - "Face Set From Visible", - "Create a new Face Set from the visible vertices", - }, - { - SCULPT_FACE_SET_ALL, - "ALL", - 0, - "Face Set Full Mesh", - "Create an unique Face Set with all faces in the sculpt", - }, - { - SCULPT_FACE_SET_SELECTION, - "SELECTION", - 0, - "Face Set From Edit Mode Selection", - "Create an Face Set corresponding to the Edit Mode face selection", - }, - {0, NULL, 0, NULL, NULL}, -}; - -static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - ARegion *region = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - - const int mode = RNA_enum_get(op->ptr, "mode"); - - /* Dyntopo not suported. */ - if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { - return OPERATOR_CANCELLED; - } - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, mode == SCULPT_FACE_SET_MASKED); - - const int tot_vert = SCULPT_vertex_count_get(ss); - float threshold = 0.5f; - - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - int totnode; - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - - if (!nodes) { - return OPERATOR_CANCELLED; - } - - SCULPT_undo_push_begin("face set change"); - SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); - - const int next_face_set = SCULPT_face_set_next_available_get(ss); - - if (mode == SCULPT_FACE_SET_MASKED) { - for (int i = 0; i < tot_vert; i++) { - if (SCULPT_vertex_mask_get(ss, i) >= threshold && SCULPT_vertex_visible_get(ss, i)) { - SCULPT_vertex_face_set_set(ss, i, next_face_set); - } - } - } - - if (mode == SCULPT_FACE_SET_VISIBLE) { - for (int i = 0; i < tot_vert; i++) { - if (SCULPT_vertex_visible_get(ss, i)) { - SCULPT_vertex_face_set_set(ss, i, next_face_set); - } - } - } - - if (mode == SCULPT_FACE_SET_ALL) { - for (int i = 0; i < tot_vert; i++) { - SCULPT_vertex_face_set_set(ss, i, next_face_set); - } - } - - if (mode == SCULPT_FACE_SET_SELECTION) { - Mesh *mesh = ob->data; - BMesh *bm; - const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); - bm = BM_mesh_create(&allocsize, - &((struct BMeshCreateParams){ - .use_toolflags = true, - })); - - BM_mesh_bm_from_me(bm, - mesh, - (&(struct BMeshFromMeshParams){ - .calc_face_normal = true, - })); - - BMIter iter; - BMFace *f; - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { - ss->face_sets[BM_elem_index_get(f)] = next_face_set; - } - } - BM_mesh_free(bm); - } - - for (int i = 0; i < totnode; i++) { - BKE_pbvh_node_mark_redraw(nodes[i]); - } - - MEM_SAFE_FREE(nodes); - - SCULPT_undo_push_end(); - - ED_region_tag_redraw(region); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_face_sets_create(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Create Face Set"; - ot->idname = "SCULPT_OT_face_sets_create"; - ot->description = "Create a new Face Set"; - - /* api callbacks */ - ot->invoke = sculpt_face_set_create_invoke; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - RNA_def_enum( - ot->srna, "mode", prop_sculpt_face_set_create_types, SCULPT_FACE_SET_MASKED, "Mode", ""); -} - -typedef enum eSculptFaceSetsInitMode { - SCULPT_FACE_SETS_FROM_LOOSE_PARTS = 0, - SCULPT_FACE_SETS_FROM_MATERIALS = 1, - SCULPT_FACE_SETS_FROM_NORMALS = 2, - SCULPT_FACE_SETS_FROM_UV_SEAMS = 3, - SCULPT_FACE_SETS_FROM_CREASES = 4, - SCULPT_FACE_SETS_FROM_SHARP_EDGES = 5, - SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6, - SCULPT_FACE_SETS_FROM_FACE_MAPS = 7, -} eSculptFaceSetsInitMode; - -static EnumPropertyItem prop_sculpt_face_sets_init_types[] = { - { - SCULPT_FACE_SETS_FROM_LOOSE_PARTS, - "LOOSE_PARTS", - 0, - "Face Sets From Loose Parts", - "Create a Face Set per loose part in the mesh", - }, - { - SCULPT_FACE_SETS_FROM_MATERIALS, - "MATERIALS", - 0, - "Face Sets From Material Slots", - "Create a Face Set per Material Slot", - }, - { - SCULPT_FACE_SETS_FROM_NORMALS, - "NORMALS", - 0, - "Face Sets From Mesh Normals", - "Create Face Sets for Faces that have similar normal", - }, - { - SCULPT_FACE_SETS_FROM_UV_SEAMS, - "UV_SEAMS", - 0, - "Face Sets From UV Seams", - "Create Face Sets using UV Seams as boundaries", - }, - { - SCULPT_FACE_SETS_FROM_CREASES, - "CREASES", - 0, - "Face Sets From Edge Creases", - "Create Face Sets using Edge Creases as boundaries", - }, - { - SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT, - "BEVEL_WEIGHT", - 0, - "Face Sets From Bevel Weight", - "Create Face Sets using Bevel Weights as boundaries", - }, - { - SCULPT_FACE_SETS_FROM_SHARP_EDGES, - "SHARP_EDGES", - 0, - "Face Sets From Sharp Edges", - "Create Face Sets using Sharp Edges as boundaries", - }, - { - SCULPT_FACE_SETS_FROM_FACE_MAPS, - "FACE_MAPS", - 0, - "Face Sets From Face Maps", - "Create a Face Set per Face Map", - }, - {0, NULL, 0, NULL, NULL}, -}; - -typedef bool (*face_sets_flood_fill_test)( - BMesh *bm, BMFace *from_f, BMEdge *from_e, BMFace *to_f, const float threshold); - -static bool sculpt_face_sets_init_loose_parts_test(BMesh *UNUSED(bm), - BMFace *UNUSED(from_f), - BMEdge *UNUSED(from_e), - BMFace *UNUSED(to_f), - const float UNUSED(threshold)) -{ - return true; -} - -static bool sculpt_face_sets_init_normals_test( - BMesh *UNUSED(bm), BMFace *from_f, BMEdge *UNUSED(from_e), BMFace *to_f, const float threshold) -{ - return fabsf(dot_v3v3(from_f->no, to_f->no)) > threshold; -} - -static bool sculpt_face_sets_init_uv_seams_test(BMesh *UNUSED(bm), - BMFace *UNUSED(from_f), - BMEdge *from_e, - BMFace *UNUSED(to_f), - const float UNUSED(threshold)) -{ - return !BM_elem_flag_test(from_e, BM_ELEM_SEAM); -} - -static bool sculpt_face_sets_init_crease_test( - BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold) -{ - return BM_elem_float_data_get(&bm->edata, from_e, CD_CREASE) < threshold; -} - -static bool sculpt_face_sets_init_bevel_weight_test( - BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold) -{ - return BM_elem_float_data_get(&bm->edata, from_e, CD_BWEIGHT) < threshold; -} - -static bool sculpt_face_sets_init_sharp_edges_test(BMesh *UNUSED(bm), - BMFace *UNUSED(from_f), - BMEdge *from_e, - BMFace *UNUSED(to_f), - const float UNUSED(threshold)) -{ - return BM_elem_flag_test(from_e, BM_ELEM_SMOOTH); -} - -static void sculpt_face_sets_init_flood_fill(Object *ob, - face_sets_flood_fill_test test, - const float threshold) -{ - SculptSession *ss = ob->sculpt; - Mesh *mesh = ob->data; - BMesh *bm; - const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); - bm = BM_mesh_create(&allocsize, - &((struct BMeshCreateParams){ - .use_toolflags = true, - })); - - BM_mesh_bm_from_me(bm, - mesh, - (&(struct BMeshFromMeshParams){ - .calc_face_normal = true, - })); - - bool *visited_faces = MEM_callocN(sizeof(bool) * mesh->totpoly, "visited faces"); - const int totfaces = mesh->totpoly; - - int *face_sets = ss->face_sets; - - BM_mesh_elem_table_init(bm, BM_FACE); - BM_mesh_elem_table_ensure(bm, BM_FACE); - - int next_face_set = 1; - - for (int i = 0; i < totfaces; i++) { - if (!visited_faces[i]) { - GSQueue *queue; - queue = BLI_gsqueue_new(sizeof(int)); - - face_sets[i] = next_face_set; - visited_faces[i] = true; - BLI_gsqueue_push(queue, &i); - - while (!BLI_gsqueue_is_empty(queue)) { - int from_f; - BLI_gsqueue_pop(queue, &from_f); - - BMFace *f, *f_neighbor; - BMEdge *ed; - BMIter iter_a, iter_b; - - f = BM_face_at_index(bm, from_f); - - BM_ITER_ELEM (ed, &iter_a, f, BM_EDGES_OF_FACE) { - BM_ITER_ELEM (f_neighbor, &iter_b, ed, BM_FACES_OF_EDGE) { - if (f_neighbor != f) { - int neighbor_face_index = BM_elem_index_get(f_neighbor); - if (!visited_faces[neighbor_face_index]) { - if (test(bm, f, ed, f_neighbor, threshold)) { - face_sets[neighbor_face_index] = next_face_set; - visited_faces[neighbor_face_index] = true; - BLI_gsqueue_push(queue, &neighbor_face_index); - } - } - } - } - } - } - - next_face_set += 1; - - BLI_gsqueue_free(queue); - } - } - - MEM_SAFE_FREE(visited_faces); - - BM_mesh_free(bm); -} - -static void sculpt_face_sets_init_loop(Object *ob, const int mode) -{ - Mesh *mesh = ob->data; - SculptSession *ss = ob->sculpt; - BMesh *bm; - const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); - bm = BM_mesh_create(&allocsize, - &((struct BMeshCreateParams){ - .use_toolflags = true, - })); - - BM_mesh_bm_from_me(bm, - mesh, - (&(struct BMeshFromMeshParams){ - .calc_face_normal = true, - })); - BMIter iter; - BMFace *f; - - const int cd_fmaps_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP); - - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (mode == SCULPT_FACE_SETS_FROM_MATERIALS) { - ss->face_sets[BM_elem_index_get(f)] = (int)(f->mat_nr + 1); - } - else if (mode == SCULPT_FACE_SETS_FROM_FACE_MAPS) { - if (cd_fmaps_offset != -1) { - ss->face_sets[BM_elem_index_get(f)] = BM_ELEM_CD_GET_INT(f, cd_fmaps_offset) + 2; - } - else { - ss->face_sets[BM_elem_index_get(f)] = 1; - } - } - } - BM_mesh_free(bm); -} - -static int sculpt_face_set_init_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - ARegion *region = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - - const int mode = RNA_enum_get(op->ptr, "mode"); - - /* Dyntopo not supported. */ - if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { - return OPERATOR_CANCELLED; - } - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); - - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - int totnode; - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - - if (!nodes) { - return OPERATOR_CANCELLED; - } - - SCULPT_undo_push_begin("face set change"); - SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); - - const float threshold = RNA_float_get(op->ptr, "threshold"); - - switch (mode) { - case SCULPT_FACE_SETS_FROM_LOOSE_PARTS: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_loose_parts_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_MATERIALS: - sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_MATERIALS); - break; - case SCULPT_FACE_SETS_FROM_NORMALS: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_normals_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_UV_SEAMS: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_uv_seams_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_CREASES: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_crease_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_SHARP_EDGES: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_sharp_edges_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT: - sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_bevel_weight_test, threshold); - break; - case SCULPT_FACE_SETS_FROM_FACE_MAPS: - sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS); - break; - } - - SCULPT_undo_push_end(); - - /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); - - for (int i = 0; i < totnode; i++) { - BKE_pbvh_node_mark_update_visibility(nodes[i]); - } - - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); - - MEM_SAFE_FREE(nodes); - - if (BKE_pbvh_type(pbvh) == PBVH_FACES) { - BKE_mesh_flush_hidden_from_verts(ob->data); - } - - ED_region_tag_redraw(region); - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - - View3D *v3d = CTX_wm_view3d(C); - if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - } - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_face_sets_init(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Init Face Sets"; - ot->idname = "SCULPT_OT_face_sets_init"; - ot->description = "Initializes all Face Sets in the mesh"; - - /* api callbacks */ - ot->invoke = sculpt_face_set_init_invoke; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - RNA_def_enum( - ot->srna, "mode", prop_sculpt_face_sets_init_types, SCULPT_FACE_SET_MASKED, "Mode", ""); - RNA_def_float( - ot->srna, - "threshold", - 0.5f, - 0.0f, - 1.0f, - "Threshold", - "Minimum value to consider a certain atribute a boundary when creating the Face Sets", - 0.0f, - 1.0f); -} - -typedef enum eSculptFaceGroupVisibilityModes { - SCULPT_FACE_SET_VISIBILITY_TOGGLE = 0, - SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE = 1, - SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE = 2, - SCULPT_FACE_SET_VISIBILITY_INVERT = 3, - SCULPT_FACE_SET_VISIBILITY_SHOW_ALL = 4, -} eSculptFaceGroupVisibilityModes; - -static EnumPropertyItem prop_sculpt_face_sets_change_visibility_types[] = { - { - SCULPT_FACE_SET_VISIBILITY_TOGGLE, - "TOGGLE", - 0, - "Toggle Visibility", - "Hide all Face Sets except for the active one", - }, - { - SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE, - "SHOW_ACTIVE", - 0, - "Show Active Face Set", - "Show Active Face Set", - }, - { - SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE, - "HIDE_ACTIVE", - 0, - "Hide Active Face Sets", - "Hide Active Face Sets", - }, - { - SCULPT_FACE_SET_VISIBILITY_INVERT, - "INVERT", - 0, - "Invert Face Set Visibility", - "Invert Face Set Visibility", - }, - { - SCULPT_FACE_SET_VISIBILITY_SHOW_ALL, - "SHOW_ALL", - 0, - "Show All Face Sets", - "Show All Face Sets", - }, - {0, NULL, 0, NULL, NULL}, -}; - -static int sculpt_face_sets_change_visibility_invoke(bContext *C, - wmOperator *op, - const wmEvent *UNUSED(event)) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - ARegion *region = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - - /* Dyntopo not supported. */ - if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { - return OPERATOR_CANCELLED; - } - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); - - const int tot_vert = SCULPT_vertex_count_get(ss); - const int mode = RNA_enum_get(op->ptr, "mode"); - const int active_face_set = SCULPT_active_face_set_get(ss); - - SCULPT_undo_push_begin("Hide area"); - - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - int totnode; - - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - - if (totnode == 0) { - MEM_SAFE_FREE(nodes); - return OPERATOR_CANCELLED; - } - - SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); - - if (mode == SCULPT_FACE_SET_VISIBILITY_TOGGLE) { - bool hidden_vertex = false; - - /* This can fail with regular meshes with non-manifold geometry as the visibility state can't - * be synced from face sets to non-manifold vertices. */ - if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { - for (int i = 0; i < tot_vert; i++) { - if (!SCULPT_vertex_visible_get(ss, i)) { - hidden_vertex = true; - break; - } - } - } - - for (int i = 0; i < ss->totfaces; i++) { - if (ss->face_sets[i] <= 0) { - hidden_vertex = true; - break; - } - } - - if (hidden_vertex) { - SCULPT_face_sets_visibility_all_set(ss, true); - } - else { - SCULPT_face_sets_visibility_all_set(ss, false); - SCULPT_face_set_visibility_set(ss, active_face_set, true); - } - } - - if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) { - SCULPT_face_sets_visibility_all_set(ss, true); - } - - if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) { - SCULPT_face_sets_visibility_all_set(ss, false); - SCULPT_face_set_visibility_set(ss, active_face_set, true); - for (int i = 0; i < tot_vert; i++) { - SCULPT_vertex_visible_set(ss, - i, - SCULPT_vertex_visible_get(ss, i) && - SCULPT_vertex_has_face_set(ss, i, active_face_set)); - } - } - - if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) { - SCULPT_face_set_visibility_set(ss, active_face_set, false); - } - - if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) { - SCULPT_face_sets_visibility_invert(ss); - } - - /* For modes that use the cursor active vertex, update the rotation origin for viewport - * navigation. */ - if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) { - UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; - float location[3]; - copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); - mul_m4_v3(ob->obmat, location); - copy_v3_v3(ups->average_stroke_accum, location); - ups->average_stroke_counter = 1; - ups->last_stroke_valid = true; - } - - /* Sync face sets visibility and vertex visibility. */ - SCULPT_visibility_sync_all_face_sets_to_vertices(ss); - - SCULPT_undo_push_end(); - - for (int i = 0; i < totnode; i++) { - BKE_pbvh_node_mark_update_visibility(nodes[i]); - } - - BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); - - MEM_SAFE_FREE(nodes); - - if (BKE_pbvh_type(pbvh) == PBVH_FACES) { - BKE_mesh_flush_hidden_from_verts(ob->data); - } - - ED_region_tag_redraw(region); - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - - View3D *v3d = CTX_wm_view3d(C); - if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - } - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Face Sets Visibility"; - ot->idname = "SCULPT_OT_face_set_change_visibility"; - ot->description = "Change the visibility of the Face Sets of the sculpt"; - - /* Api callbacks. */ - ot->invoke = sculpt_face_sets_change_visibility_invoke; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - RNA_def_enum(ot->srna, - "mode", - prop_sculpt_face_sets_change_visibility_types, - SCULPT_FACE_SET_VISIBILITY_TOGGLE, - "Mode", - ""); -} - -static int sculpt_face_sets_randomize_colors_invoke(bContext *C, - wmOperator *UNUSED(op), - const wmEvent *UNUSED(event)) -{ - - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - ARegion *region = CTX_wm_region(C); - - /* Dyntopo and Multires not supported for now. */ - if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { - return OPERATOR_CANCELLED; - } - - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - int totnode; - Mesh *mesh = ob->data; - - mesh->face_sets_color_seed += 1; - if (ss->face_sets) { - const int random_index = clamp_i(ss->totfaces * BLI_hash_int_01(mesh->face_sets_color_seed), - 0, - max_ii(0, ss->totfaces - 1)); - mesh->face_sets_color_default = ss->face_sets[random_index]; - } - BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); - - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - for (int i = 0; i < totnode; i++) { - BKE_pbvh_node_mark_redraw(nodes[i]); - } - - MEM_SAFE_FREE(nodes); - - View3D *v3d = CTX_wm_view3d(C); - if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - } - - ED_region_tag_redraw(region); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Randomize Face Sets Colors"; - ot->idname = "SCULPT_OT_face_sets_randomize_colors"; - ot->description = "Generates a new set of random colors to render the Face Sets in the viewport"; - - /* Api callbacks. */ - ot->invoke = sculpt_face_sets_randomize_colors_invoke; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} void ED_operatortypes_sculpt(void) { diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c new file mode 100644 index 00000000000..a1bf2f7d7bd --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -0,0 +1,975 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_hash.h" +#include "BLI_task.h" + +#include "DNA_brush_types.h" +#include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_ccg.h" +#include "BKE_colortools.h" +#include "BKE_context.h" +#include "BKE_customdata.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_multires.h" +#include "BKE_node.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "ED_view3d.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "bmesh.h" + +#include +#include + +/* Draw Face Sets Brush. */ + +static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + const Brush *brush = data->brush; + const float bstrength = ss->cache->bstrength; + + PBVHVertexIter vd; + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + MeshElemMap *vert_map = &ss->pmap[vd.index]; + for (int j = 0; j < ss->pmap[vd.index].count; j++) { + const MPoly *p = &ss->mpoly[vert_map->indices[j]]; + + float poly_center[3]; + BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], ss->mvert, poly_center); + + if (sculpt_brush_test_sq_fn(&test, poly_center)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + vd.mask ? *vd.mask : 0.0f, + vd.index, + tls->thread_id); + + if (fade > 0.05f && ss->face_sets[vert_map->indices[j]] > 0) { + ss->face_sets[vert_map->indices[j]] = abs(ss->cache->paint_face_set); + } + } + } + } + + else if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + vd.mask ? *vd.mask : 0.0f, + vd.index, + tls->thread_id); + + if (fade > 0.05f) { + SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set); + } + } + } + } + } + BKE_pbvh_vertex_iter_end; +} + +static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + const Brush *brush = data->brush; + float bstrength = ss->cache->bstrength; + + PBVHVertexIter vd; + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + const bool relax_face_sets = !(ss->cache->iteration_count % 3 == 0); + /* This operations needs a stregth tweak as the relax deformation is too weak by default. */ + if (relax_face_sets) { + bstrength *= 2.0f; + } + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + if (relax_face_sets != SCULPT_vertex_has_unique_face_set(ss, vd.index)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + vd.mask ? *vd.mask : 0.0f, + vd.index, + tls->thread_id); + + SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co); + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + } + BKE_pbvh_vertex_iter_end; +} + +void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + + if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0) { + if (ss->cache->invert) { + /* When inverting the brush, pick the paint face mask ID from the mesh. */ + ss->cache->paint_face_set = SCULPT_active_face_set_get(ss); + } + else { + /* By default create a new Face Sets. */ + ss->cache->paint_face_set = SCULPT_face_set_next_available_get(ss); + } + } + + BKE_curvemapping_initialize(brush->curve); + + /* Threaded loop over nodes. */ + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .brush = brush, + .nodes = nodes, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + if (ss->cache->alt_smooth) { + for (int i = 0; i < 4; i++) { + BKE_pbvh_parallel_range(0, totnode, &data, do_relax_face_sets_brush_task_cb_ex, &settings); + } + } + else { + BKE_pbvh_parallel_range(0, totnode, &data, do_draw_face_sets_brush_task_cb_ex, &settings); + } +} + + +/* Face Sets Operators */ + +typedef enum eSculptFaceGroupsCreateModes { + SCULPT_FACE_SET_MASKED = 0, + SCULPT_FACE_SET_VISIBLE = 1, + SCULPT_FACE_SET_ALL = 2, + SCULPT_FACE_SET_SELECTION = 3, +} eSculptFaceGroupsCreateModes; + +static EnumPropertyItem prop_sculpt_face_set_create_types[] = { + { + SCULPT_FACE_SET_MASKED, + "MASKED", + 0, + "Face Set From Masked", + "Create a new Face Set from the masked faces", + }, + { + SCULPT_FACE_SET_VISIBLE, + "VISIBLE", + 0, + "Face Set From Visible", + "Create a new Face Set from the visible vertices", + }, + { + SCULPT_FACE_SET_ALL, + "ALL", + 0, + "Face Set Full Mesh", + "Create an unique Face Set with all faces in the sculpt", + }, + { + SCULPT_FACE_SET_SELECTION, + "SELECTION", + 0, + "Face Set From Edit Mode Selection", + "Create an Face Set corresponding to the Edit Mode face selection", + }, + {0, NULL, 0, NULL, NULL}, +}; + +static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *region = CTX_wm_region(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + + const int mode = RNA_enum_get(op->ptr, "mode"); + + /* Dyntopo not suported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { + return OPERATOR_CANCELLED; + } + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, mode == SCULPT_FACE_SET_MASKED); + + const int tot_vert = SCULPT_vertex_count_get(ss); + float threshold = 0.5f; + + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + if (!nodes) { + return OPERATOR_CANCELLED; + } + + SCULPT_undo_push_begin("face set change"); + SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); + + const int next_face_set = SCULPT_face_set_next_available_get(ss); + + if (mode == SCULPT_FACE_SET_MASKED) { + for (int i = 0; i < tot_vert; i++) { + if (SCULPT_vertex_mask_get(ss, i) >= threshold && SCULPT_vertex_visible_get(ss, i)) { + SCULPT_vertex_face_set_set(ss, i, next_face_set); + } + } + } + + if (mode == SCULPT_FACE_SET_VISIBLE) { + for (int i = 0; i < tot_vert; i++) { + if (SCULPT_vertex_visible_get(ss, i)) { + SCULPT_vertex_face_set_set(ss, i, next_face_set); + } + } + } + + if (mode == SCULPT_FACE_SET_ALL) { + for (int i = 0; i < tot_vert; i++) { + SCULPT_vertex_face_set_set(ss, i, next_face_set); + } + } + + if (mode == SCULPT_FACE_SET_SELECTION) { + Mesh *mesh = ob->data; + BMesh *bm; + const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); + bm = BM_mesh_create(&allocsize, + &((struct BMeshCreateParams){ + .use_toolflags = true, + })); + + BM_mesh_bm_from_me(bm, + mesh, + (&(struct BMeshFromMeshParams){ + .calc_face_normal = true, + })); + + BMIter iter; + BMFace *f; + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + ss->face_sets[BM_elem_index_get(f)] = next_face_set; + } + } + BM_mesh_free(bm); + } + + for (int i = 0; i < totnode; i++) { + BKE_pbvh_node_mark_redraw(nodes[i]); + } + + MEM_SAFE_FREE(nodes); + + SCULPT_undo_push_end(); + + ED_region_tag_redraw(region); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_face_sets_create(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Create Face Set"; + ot->idname = "SCULPT_OT_face_sets_create"; + ot->description = "Create a new Face Set"; + + /* api callbacks */ + ot->invoke = sculpt_face_set_create_invoke; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_enum( + ot->srna, "mode", prop_sculpt_face_set_create_types, SCULPT_FACE_SET_MASKED, "Mode", ""); +} + +typedef enum eSculptFaceSetsInitMode { + SCULPT_FACE_SETS_FROM_LOOSE_PARTS = 0, + SCULPT_FACE_SETS_FROM_MATERIALS = 1, + SCULPT_FACE_SETS_FROM_NORMALS = 2, + SCULPT_FACE_SETS_FROM_UV_SEAMS = 3, + SCULPT_FACE_SETS_FROM_CREASES = 4, + SCULPT_FACE_SETS_FROM_SHARP_EDGES = 5, + SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT = 6, + SCULPT_FACE_SETS_FROM_FACE_MAPS = 7, +} eSculptFaceSetsInitMode; + +static EnumPropertyItem prop_sculpt_face_sets_init_types[] = { + { + SCULPT_FACE_SETS_FROM_LOOSE_PARTS, + "LOOSE_PARTS", + 0, + "Face Sets From Loose Parts", + "Create a Face Set per loose part in the mesh", + }, + { + SCULPT_FACE_SETS_FROM_MATERIALS, + "MATERIALS", + 0, + "Face Sets From Material Slots", + "Create a Face Set per Material Slot", + }, + { + SCULPT_FACE_SETS_FROM_NORMALS, + "NORMALS", + 0, + "Face Sets From Mesh Normals", + "Create Face Sets for Faces that have similar normal", + }, + { + SCULPT_FACE_SETS_FROM_UV_SEAMS, + "UV_SEAMS", + 0, + "Face Sets From UV Seams", + "Create Face Sets using UV Seams as boundaries", + }, + { + SCULPT_FACE_SETS_FROM_CREASES, + "CREASES", + 0, + "Face Sets From Edge Creases", + "Create Face Sets using Edge Creases as boundaries", + }, + { + SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT, + "BEVEL_WEIGHT", + 0, + "Face Sets From Bevel Weight", + "Create Face Sets using Bevel Weights as boundaries", + }, + { + SCULPT_FACE_SETS_FROM_SHARP_EDGES, + "SHARP_EDGES", + 0, + "Face Sets From Sharp Edges", + "Create Face Sets using Sharp Edges as boundaries", + }, + { + SCULPT_FACE_SETS_FROM_FACE_MAPS, + "FACE_MAPS", + 0, + "Face Sets From Face Maps", + "Create a Face Set per Face Map", + }, + {0, NULL, 0, NULL, NULL}, +}; + +typedef bool (*face_sets_flood_fill_test)( + BMesh *bm, BMFace *from_f, BMEdge *from_e, BMFace *to_f, const float threshold); + +static bool sculpt_face_sets_init_loose_parts_test(BMesh *UNUSED(bm), + BMFace *UNUSED(from_f), + BMEdge *UNUSED(from_e), + BMFace *UNUSED(to_f), + const float UNUSED(threshold)) +{ + return true; +} + +static bool sculpt_face_sets_init_normals_test( + BMesh *UNUSED(bm), BMFace *from_f, BMEdge *UNUSED(from_e), BMFace *to_f, const float threshold) +{ + return fabsf(dot_v3v3(from_f->no, to_f->no)) > threshold; +} + +static bool sculpt_face_sets_init_uv_seams_test(BMesh *UNUSED(bm), + BMFace *UNUSED(from_f), + BMEdge *from_e, + BMFace *UNUSED(to_f), + const float UNUSED(threshold)) +{ + return !BM_elem_flag_test(from_e, BM_ELEM_SEAM); +} + +static bool sculpt_face_sets_init_crease_test( + BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold) +{ + return BM_elem_float_data_get(&bm->edata, from_e, CD_CREASE) < threshold; +} + +static bool sculpt_face_sets_init_bevel_weight_test( + BMesh *bm, BMFace *UNUSED(from_f), BMEdge *from_e, BMFace *UNUSED(to_f), const float threshold) +{ + return BM_elem_float_data_get(&bm->edata, from_e, CD_BWEIGHT) < threshold; +} + +static bool sculpt_face_sets_init_sharp_edges_test(BMesh *UNUSED(bm), + BMFace *UNUSED(from_f), + BMEdge *from_e, + BMFace *UNUSED(to_f), + const float UNUSED(threshold)) +{ + return BM_elem_flag_test(from_e, BM_ELEM_SMOOTH); +} + +static void sculpt_face_sets_init_flood_fill(Object *ob, + face_sets_flood_fill_test test, + const float threshold) +{ + SculptSession *ss = ob->sculpt; + Mesh *mesh = ob->data; + BMesh *bm; + const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); + bm = BM_mesh_create(&allocsize, + &((struct BMeshCreateParams){ + .use_toolflags = true, + })); + + BM_mesh_bm_from_me(bm, + mesh, + (&(struct BMeshFromMeshParams){ + .calc_face_normal = true, + })); + + bool *visited_faces = MEM_callocN(sizeof(bool) * mesh->totpoly, "visited faces"); + const int totfaces = mesh->totpoly; + + int *face_sets = ss->face_sets; + + BM_mesh_elem_table_init(bm, BM_FACE); + BM_mesh_elem_table_ensure(bm, BM_FACE); + + int next_face_set = 1; + + for (int i = 0; i < totfaces; i++) { + if (!visited_faces[i]) { + GSQueue *queue; + queue = BLI_gsqueue_new(sizeof(int)); + + face_sets[i] = next_face_set; + visited_faces[i] = true; + BLI_gsqueue_push(queue, &i); + + while (!BLI_gsqueue_is_empty(queue)) { + int from_f; + BLI_gsqueue_pop(queue, &from_f); + + BMFace *f, *f_neighbor; + BMEdge *ed; + BMIter iter_a, iter_b; + + f = BM_face_at_index(bm, from_f); + + BM_ITER_ELEM (ed, &iter_a, f, BM_EDGES_OF_FACE) { + BM_ITER_ELEM (f_neighbor, &iter_b, ed, BM_FACES_OF_EDGE) { + if (f_neighbor != f) { + int neighbor_face_index = BM_elem_index_get(f_neighbor); + if (!visited_faces[neighbor_face_index]) { + if (test(bm, f, ed, f_neighbor, threshold)) { + face_sets[neighbor_face_index] = next_face_set; + visited_faces[neighbor_face_index] = true; + BLI_gsqueue_push(queue, &neighbor_face_index); + } + } + } + } + } + } + + next_face_set += 1; + + BLI_gsqueue_free(queue); + } + } + + MEM_SAFE_FREE(visited_faces); + + BM_mesh_free(bm); +} + +static void sculpt_face_sets_init_loop(Object *ob, const int mode) +{ + Mesh *mesh = ob->data; + SculptSession *ss = ob->sculpt; + BMesh *bm; + const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); + bm = BM_mesh_create(&allocsize, + &((struct BMeshCreateParams){ + .use_toolflags = true, + })); + + BM_mesh_bm_from_me(bm, + mesh, + (&(struct BMeshFromMeshParams){ + .calc_face_normal = true, + })); + BMIter iter; + BMFace *f; + + const int cd_fmaps_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP); + + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + if (mode == SCULPT_FACE_SETS_FROM_MATERIALS) { + ss->face_sets[BM_elem_index_get(f)] = (int)(f->mat_nr + 1); + } + else if (mode == SCULPT_FACE_SETS_FROM_FACE_MAPS) { + if (cd_fmaps_offset != -1) { + ss->face_sets[BM_elem_index_get(f)] = BM_ELEM_CD_GET_INT(f, cd_fmaps_offset) + 2; + } + else { + ss->face_sets[BM_elem_index_get(f)] = 1; + } + } + } + BM_mesh_free(bm); +} + +static int sculpt_face_set_init_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *region = CTX_wm_region(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + + const int mode = RNA_enum_get(op->ptr, "mode"); + + /* Dyntopo not supported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { + return OPERATOR_CANCELLED; + } + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); + + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + if (!nodes) { + return OPERATOR_CANCELLED; + } + + SCULPT_undo_push_begin("face set change"); + SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); + + const float threshold = RNA_float_get(op->ptr, "threshold"); + + switch (mode) { + case SCULPT_FACE_SETS_FROM_LOOSE_PARTS: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_loose_parts_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_MATERIALS: + sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_MATERIALS); + break; + case SCULPT_FACE_SETS_FROM_NORMALS: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_normals_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_UV_SEAMS: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_uv_seams_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_CREASES: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_crease_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_SHARP_EDGES: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_sharp_edges_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_BEVEL_WEIGHT: + sculpt_face_sets_init_flood_fill(ob, sculpt_face_sets_init_bevel_weight_test, threshold); + break; + case SCULPT_FACE_SETS_FROM_FACE_MAPS: + sculpt_face_sets_init_loop(ob, SCULPT_FACE_SETS_FROM_FACE_MAPS); + break; + } + + SCULPT_undo_push_end(); + + /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */ + SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + + for (int i = 0; i < totnode; i++) { + BKE_pbvh_node_mark_update_visibility(nodes[i]); + } + + BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); + + MEM_SAFE_FREE(nodes); + + if (BKE_pbvh_type(pbvh) == PBVH_FACES) { + BKE_mesh_flush_hidden_from_verts(ob->data); + } + + ED_region_tag_redraw(region); + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); + + View3D *v3d = CTX_wm_view3d(C); + if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_face_sets_init(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Init Face Sets"; + ot->idname = "SCULPT_OT_face_sets_init"; + ot->description = "Initializes all Face Sets in the mesh"; + + /* api callbacks */ + ot->invoke = sculpt_face_set_init_invoke; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_enum( + ot->srna, "mode", prop_sculpt_face_sets_init_types, SCULPT_FACE_SET_MASKED, "Mode", ""); + RNA_def_float( + ot->srna, + "threshold", + 0.5f, + 0.0f, + 1.0f, + "Threshold", + "Minimum value to consider a certain atribute a boundary when creating the Face Sets", + 0.0f, + 1.0f); +} + +typedef enum eSculptFaceGroupVisibilityModes { + SCULPT_FACE_SET_VISIBILITY_TOGGLE = 0, + SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE = 1, + SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE = 2, + SCULPT_FACE_SET_VISIBILITY_INVERT = 3, + SCULPT_FACE_SET_VISIBILITY_SHOW_ALL = 4, +} eSculptFaceGroupVisibilityModes; + +static EnumPropertyItem prop_sculpt_face_sets_change_visibility_types[] = { + { + SCULPT_FACE_SET_VISIBILITY_TOGGLE, + "TOGGLE", + 0, + "Toggle Visibility", + "Hide all Face Sets except for the active one", + }, + { + SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE, + "SHOW_ACTIVE", + 0, + "Show Active Face Set", + "Show Active Face Set", + }, + { + SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE, + "HIDE_ACTIVE", + 0, + "Hide Active Face Sets", + "Hide Active Face Sets", + }, + { + SCULPT_FACE_SET_VISIBILITY_INVERT, + "INVERT", + 0, + "Invert Face Set Visibility", + "Invert Face Set Visibility", + }, + { + SCULPT_FACE_SET_VISIBILITY_SHOW_ALL, + "SHOW_ALL", + 0, + "Show All Face Sets", + "Show All Face Sets", + }, + {0, NULL, 0, NULL, NULL}, +}; + +static int sculpt_face_sets_change_visibility_invoke(bContext *C, + wmOperator *op, + const wmEvent *UNUSED(event)) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *region = CTX_wm_region(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + + /* Dyntopo not supported. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { + return OPERATOR_CANCELLED; + } + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); + + const int tot_vert = SCULPT_vertex_count_get(ss); + const int mode = RNA_enum_get(op->ptr, "mode"); + const int active_face_set = SCULPT_active_face_set_get(ss); + + SCULPT_undo_push_begin("Hide area"); + + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + if (totnode == 0) { + MEM_SAFE_FREE(nodes); + return OPERATOR_CANCELLED; + } + + SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS); + + if (mode == SCULPT_FACE_SET_VISIBILITY_TOGGLE) { + bool hidden_vertex = false; + + /* This can fail with regular meshes with non-manifold geometry as the visibility state can't + * be synced from face sets to non-manifold vertices. */ + if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) { + for (int i = 0; i < tot_vert; i++) { + if (!SCULPT_vertex_visible_get(ss, i)) { + hidden_vertex = true; + break; + } + } + } + + for (int i = 0; i < ss->totfaces; i++) { + if (ss->face_sets[i] <= 0) { + hidden_vertex = true; + break; + } + } + + if (hidden_vertex) { + SCULPT_face_sets_visibility_all_set(ss, true); + } + else { + SCULPT_face_sets_visibility_all_set(ss, false); + SCULPT_face_set_visibility_set(ss, active_face_set, true); + } + } + + if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ALL) { + SCULPT_face_sets_visibility_all_set(ss, true); + } + + if (mode == SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE) { + SCULPT_face_sets_visibility_all_set(ss, false); + SCULPT_face_set_visibility_set(ss, active_face_set, true); + for (int i = 0; i < tot_vert; i++) { + SCULPT_vertex_visible_set(ss, + i, + SCULPT_vertex_visible_get(ss, i) && + SCULPT_vertex_has_face_set(ss, i, active_face_set)); + } + } + + if (mode == SCULPT_FACE_SET_VISIBILITY_HIDE_ACTIVE) { + SCULPT_face_set_visibility_set(ss, active_face_set, false); + } + + if (mode == SCULPT_FACE_SET_VISIBILITY_INVERT) { + SCULPT_face_sets_visibility_invert(ss); + } + + /* For modes that use the cursor active vertex, update the rotation origin for viewport + * navigation. */ + if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) { + UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; + float location[3]; + copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); + mul_m4_v3(ob->obmat, location); + copy_v3_v3(ups->average_stroke_accum, location); + ups->average_stroke_counter = 1; + ups->last_stroke_valid = true; + } + + /* Sync face sets visibility and vertex visibility. */ + SCULPT_visibility_sync_all_face_sets_to_vertices(ss); + + SCULPT_undo_push_end(); + + for (int i = 0; i < totnode; i++) { + BKE_pbvh_node_mark_update_visibility(nodes[i]); + } + + BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility); + + MEM_SAFE_FREE(nodes); + + if (BKE_pbvh_type(pbvh) == PBVH_FACES) { + BKE_mesh_flush_hidden_from_verts(ob->data); + } + + ED_region_tag_redraw(region); + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); + + View3D *v3d = CTX_wm_view3d(C); + if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } + return OPERATOR_FINISHED; +} + +void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Face Sets Visibility"; + ot->idname = "SCULPT_OT_face_set_change_visibility"; + ot->description = "Change the visibility of the Face Sets of the sculpt"; + + /* Api callbacks. */ + ot->invoke = sculpt_face_sets_change_visibility_invoke; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_enum(ot->srna, + "mode", + prop_sculpt_face_sets_change_visibility_types, + SCULPT_FACE_SET_VISIBILITY_TOGGLE, + "Mode", + ""); +} + +static int sculpt_face_sets_randomize_colors_invoke(bContext *C, + wmOperator *UNUSED(op), + const wmEvent *UNUSED(event)) +{ + + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *region = CTX_wm_region(C); + + /* Dyntopo and Multires not supported for now. */ + if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { + return OPERATOR_CANCELLED; + } + + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + Mesh *mesh = ob->data; + + mesh->face_sets_color_seed += 1; + if (ss->face_sets) { + const int random_index = clamp_i(ss->totfaces * BLI_hash_int_01(mesh->face_sets_color_seed), + 0, + max_ii(0, ss->totfaces - 1)); + mesh->face_sets_color_default = ss->face_sets[random_index]; + } + BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + for (int i = 0; i < totnode; i++) { + BKE_pbvh_node_mark_redraw(nodes[i]); + } + + MEM_SAFE_FREE(nodes); + + View3D *v3d = CTX_wm_view3d(C); + if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); + } + + ED_region_tag_redraw(region); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Randomize Face Sets Colors"; + ot->idname = "SCULPT_OT_face_sets_randomize_colors"; + ot->description = "Generates a new set of random colors to render the Face Sets in the viewport"; + + /* Api callbacks. */ + ot->invoke = sculpt_face_sets_randomize_colors_invoke; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 60b51ce17fd..ba14c9ff011 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -128,6 +128,33 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss, int SCULPT_active_vertex_get(SculptSession *ss); const float *SCULPT_active_vertex_co_get(SculptSession *ss); +/* Sculpt Visibility API */ + +void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible); +bool SCULPT_vertex_visible_get(SculptSession *ss, int index); + +void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss); +void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss); + +/* Face Sets API */ + +int SCULPT_active_face_set_get(SculptSession *ss); +int SCULPT_vertex_face_set_get(SculptSession *ss, int index); +void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set); + +bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set); +bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index); + +int SCULPT_face_set_next_available_get(SculptSession *ss); + +void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible); +bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index); +bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index); + +void SCULPT_face_sets_visibility_invert(SculptSession *ss); +void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible); + + /* Sculpt Original Data */ typedef struct { struct BMLog *bm_log; @@ -146,11 +173,6 @@ typedef struct { void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node); void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter); -/* Face Sets */ -int SCULPT_vertex_face_set_get(SculptSession *ss, int index); -bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set); -bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index); - /* Dynamic topology */ void sculpt_pbvh_clear(Object *ob); void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); @@ -274,6 +296,8 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr, SculptSession *ss, const float outline_col[3], const float outline_alpha); +/* Draw Face Sets Brush. */ +void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); /* Slide/Relax */ void SCULPT_relax_vertex(struct SculptSession *ss, @@ -282,9 +306,8 @@ void SCULPT_relax_vertex(struct SculptSession *ss, bool filter_boundary_face_sets, float *r_final_pos); -/* Sculpt Visibility API */ -void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss); -void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss); + + /* Undo */ @@ -737,4 +760,14 @@ bool SCULPT_get_redraw_rect(struct ARegion *region, Object *ob, rcti *rect); + +/* Operators */ + +/* Face Sets */ +void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_init(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_create(struct wmOperatorType *ot); + + #endif -- cgit v1.2.3 From 200cc531bd2b66f886c1399da0f48f99619d39a5 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 19:23:05 +0200 Subject: Cleanup: Missing clang format in previous commit --- source/blender/editors/sculpt_paint/sculpt.c | 2 -- source/blender/editors/sculpt_paint/sculpt_face_set.c | 3 +-- source/blender/editors/sculpt_paint/sculpt_intern.h | 6 ------ 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 490ec336ccc..a981e722b1c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3676,7 +3676,6 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) BKE_pbvh_parallel_range(0, totnode, &data, do_draw_brush_task_cb_ex, &settings); } - static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls) @@ -11110,7 +11109,6 @@ static void SCULPT_OT_set_pivot_position(wmOperatorType *ot) 10000.0f); } - void ED_operatortypes_sculpt(void) { WM_operatortype_append(SCULPT_OT_brush_stroke); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index a1bf2f7d7bd..1dd1fcf721d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -24,8 +24,8 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_hash.h" +#include "BLI_math.h" #include "BLI_task.h" #include "DNA_brush_types.h" @@ -223,7 +223,6 @@ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in } } - /* Face Sets Operators */ typedef enum eSculptFaceGroupsCreateModes { diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index ba14c9ff011..7f926054ca7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -154,7 +154,6 @@ bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index); void SCULPT_face_sets_visibility_invert(SculptSession *ss); void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible); - /* Sculpt Original Data */ typedef struct { struct BMLog *bm_log; @@ -306,9 +305,6 @@ void SCULPT_relax_vertex(struct SculptSession *ss, bool filter_boundary_face_sets, float *r_final_pos); - - - /* Undo */ typedef enum { @@ -760,7 +756,6 @@ bool SCULPT_get_redraw_rect(struct ARegion *region, Object *ob, rcti *rect); - /* Operators */ /* Face Sets */ @@ -769,5 +764,4 @@ void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot); void SCULPT_OT_face_sets_init(struct wmOperatorType *ot); void SCULPT_OT_face_sets_create(struct wmOperatorType *ot); - #endif -- cgit v1.2.3 From b0c1184875d39abac4a65a5d20e263ea6d841009 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 3 Apr 2020 17:38:58 +0200 Subject: Cleanup: Including "BLI_listbase.h" for LISTBASE_FOREACH macro These headers are not needed right away, but will be in the upcoming commit. --- source/blender/blenkernel/intern/idprop_utils.c | 1 + source/blender/blenkernel/intern/lib_query.c | 1 + source/blender/blenkernel/intern/seqeffects.c | 1 + source/blender/blenkernel/intern/texture.c | 1 + source/blender/blenloader/intern/versioning_userdef.c | 1 + source/blender/draw/engines/eevee/eevee_materials.c | 1 + source/blender/draw/engines/eevee/eevee_volumes.c | 1 + source/blender/draw/engines/gpencil/gpencil_engine.c | 1 + source/blender/draw/engines/overlay/overlay_extra.c | 2 ++ source/blender/draw/engines/overlay/overlay_image.c | 2 ++ source/blender/draw/engines/overlay/overlay_motion_path.c | 1 + source/blender/draw/engines/workbench/workbench_volume.c | 1 + source/blender/draw/intern/draw_cache_impl_curve.c | 1 + source/blender/draw/intern/draw_cache_impl_displist.c | 1 + source/blender/draw/intern/draw_cache_impl_mesh.c | 1 + source/blender/draw/intern/draw_cache_impl_volume.c | 1 + source/blender/draw/intern/draw_manager_data.c | 1 + source/blender/draw/intern/draw_manager_profiling.c | 1 + source/blender/editors/animation/keyframes_draw.c | 1 + source/blender/editors/armature/editarmature_undo.c | 1 + source/blender/editors/curve/editcurve_select.c | 1 + source/blender/editors/interface/interface_eyedropper_gpencil_color.c | 1 + source/blender/editors/interface/interface_query.c | 1 + source/blender/editors/interface/interface_region_tooltip.c | 1 + source/blender/editors/interface/view2d.c | 1 + source/blender/editors/mask/mask_relationships.c | 1 + source/blender/editors/mask/mask_select.c | 1 + source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c | 1 + source/blender/editors/object/object_utils.c | 1 + source/blender/editors/screen/screen_context.c | 1 + source/blender/editors/space_clip/clip_editor.c | 1 + source/blender/editors/space_node/node_select.c | 1 + source/blender/editors/space_outliner/outliner_sync.c | 1 + source/blender/editors/space_outliner/outliner_utils.c | 1 + source/blender/editors/transform/transform_convert_armature.c | 1 + source/blender/editors/transform/transform_convert_curve.c | 1 + source/blender/editors/util/ed_util.c | 1 + source/blender/makesrna/intern/rna_access_compare_override.c | 1 + source/blender/makesrna/intern/rna_key.c | 1 + source/blender/makesrna/intern/rna_layer.c | 2 ++ source/blender/makesrna/intern/rna_particle.c | 2 ++ source/blender/makesrna/intern/rna_scene.c | 1 + source/blender/makesrna/intern/rna_space.c | 1 + source/blender/makesrna/intern/rna_ui.c | 2 ++ source/blender/makesrna/intern/rna_wm_gizmo.c | 1 + source/blender/modifiers/intern/MOD_dynamicpaint.c | 1 + source/blender/python/intern/bpy_capi_utils.c | 1 + source/blender/windowmanager/intern/wm_keymap_utils.c | 1 + 48 files changed, 53 insertions(+) diff --git a/source/blender/blenkernel/intern/idprop_utils.c b/source/blender/blenkernel/intern/idprop_utils.c index a7dd6afd10d..629fecf42f4 100644 --- a/source/blender/blenkernel/intern/idprop_utils.c +++ b/source/blender/blenkernel/intern/idprop_utils.c @@ -22,6 +22,7 @@ #include #include "BLI_dynstr.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 72ac9e77790..21d7bb137fc 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -61,6 +61,7 @@ #include "BLI_ghash.h" #include "BLI_linklist_stack.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_anim_data.h" diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 7c34b676e69..c471a6d254c 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -30,6 +30,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_path_util.h" #include "BLI_rect.h" diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index ff9d9d163a1..fd85e5ca212 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -29,6 +29,7 @@ #include "MEM_guardedalloc.h" #include "BLI_kdopbvh.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_math_color.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index a88e4e20d68..b566cf446ad 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -22,6 +22,7 @@ #define DNA_DEPRECATED_ALLOW #include +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_utildefines.h" diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 4a1f0a081b2..ba6aacf00d7 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -25,6 +25,7 @@ #include "BLI_alloca.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" +#include "BLI_listbase.h" #include "BLI_math_bits.h" #include "BLI_rand.h" #include "BLI_string_utils.h" diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 5ea7aaa7207..b97766d1ca2 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -24,6 +24,7 @@ #include "DRW_render.h" +#include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_string_utils.h" diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 9ebd20eb539..4963221743f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -33,6 +33,7 @@ #include "BKE_global.h" /* for G.debug */ #include "BLI_link_utils.h" +#include "BLI_listbase.h" #include "BLI_memblock.h" #include "DNA_camera_types.h" diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index 80691a6c2ad..19b88682c1d 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -36,6 +36,8 @@ #include "BKE_object.h" #include "BKE_tracking.h" +#include "BLI_listbase.h" + #include "DNA_camera_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index 057ab4990dd..7eda342d700 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -27,6 +27,8 @@ #include "BKE_movieclip.h" #include "BKE_object.h" +#include "BLI_listbase.h" + #include "DNA_camera_types.h" #include "DNA_screen_types.h" diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c index 29eb4fd12a4..997cc0fbbdb 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.c +++ b/source/blender/draw/engines/overlay/overlay_motion_path.c @@ -22,6 +22,7 @@ #include "DRW_render.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "DNA_armature_types.h" diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index 951712d6ba3..d505902d69c 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -28,6 +28,7 @@ #include "DNA_volume_types.h" #include "BLI_dynstr.h" +#include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_string_utils.h" diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 331f8073ed5..33571d82079 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index f1e5dbcc3cb..24a28022b70 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -27,6 +27,7 @@ #include "BLI_alloca.h" #include "BLI_edgehash.h" +#include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index f6ffb8a1b8d..a4b88d99a3c 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -29,6 +29,7 @@ #include "BLI_bitmap.h" #include "BLI_buffer.h" #include "BLI_edgehash.h" +#include "BLI_listbase.h" #include "BLI_math_bits.h" #include "BLI_math_vector.h" #include "BLI_string.h" diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c index cdac8b33fba..c64817413b8 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.c +++ b/source/blender/draw/intern/draw_cache_impl_volume.c @@ -27,6 +27,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index ae18636227d..50193dde7ee 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -38,6 +38,7 @@ #include "BLI_alloca.h" #include "BLI_hash.h" #include "BLI_link_utils.h" +#include "BLI_listbase.h" #include "BLI_memblock.h" #include "BLI_mempool.h" diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index 76382132230..b4bcfd3f600 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -20,6 +20,7 @@ * \ingroup draw */ +#include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_string.h" diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 37bfd7f396c..eae86d4990c 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_dlrbTree.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c index c73f8f69fdd..d3eeb311863 100644 --- a/source/blender/editors/armature/editarmature_undo.c +++ b/source/blender/editors/armature/editarmature_undo.c @@ -29,6 +29,7 @@ #include "DNA_object_types.h" #include "BLI_array_utils.h" +#include "BLI_listbase.h" #include "BKE_context.h" #include "BKE_layer.h" diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index e590eb64f84..e009add1acf 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -29,6 +29,7 @@ #include "BLI_bitmap.h" #include "BLI_heap_simple.h" #include "BLI_kdtree.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rand.h" diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index 2944186c701..925e9fdd6f9 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -28,6 +28,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLT_translation.h" diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index de68b192f67..8ba3e5db426 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -20,6 +20,7 @@ * Utilities to inspect the interface, extract information. */ +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 7576db6b33b..8b41d92ea74 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -42,6 +42,7 @@ #include "DNA_brush_types.h" #include "DNA_userdef_types.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_string.h" diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 6fcce3a18e1..97a3a7eefe4 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -33,6 +33,7 @@ #include "BLI_array.h" #include "BLI_link_utils.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_rect.h" diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 49eb4fbd4ca..5c824fef74d 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -21,6 +21,7 @@ * \ingroup edmask */ +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 12d8a9005a9..8d037258450 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -24,6 +24,7 @@ #include "MEM_guardedalloc.h" #include "BLI_lasso_2d.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index 75a36b68f8b..aa737a1701a 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -18,6 +18,7 @@ * \ingroup edmesh */ +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c index d6056f85932..8925d165b9b 100644 --- a/source/blender/editors/object/object_utils.c +++ b/source/blender/editors/object/object_utils.c @@ -28,6 +28,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 3e102a38a0d..089865bb60c 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -37,6 +37,7 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_action.h" diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index e174acdea02..0453e58d3fb 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -37,6 +37,7 @@ #include "DNA_mask_types.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_task.h" diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 051719fee3a..43daedfa1c2 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -26,6 +26,7 @@ #include "DNA_node_types.h" #include "BLI_lasso_2d.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_string.h" diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index 10075a8df58..c08c7f54405 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -32,6 +32,7 @@ #include "BLI_compiler_compat.h" #include "BLI_ghash.h" +#include "BLI_listbase.h" #include "BKE_armature.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 45b46788c8f..188a4e64897 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -23,6 +23,7 @@ #include +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c index 53dd54d4b53..9136f9edacc 100644 --- a/source/blender/editors/transform/transform_convert_armature.c +++ b/source/blender/editors/transform/transform_convert_armature.c @@ -26,6 +26,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_action.h" diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 24f0491c86c..18211eb447f 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 358b3edde6b..733cdad2212 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -35,6 +35,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_utildefines.h" diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 22d018c6025..4e238df4e3c 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -24,6 +24,7 @@ #include "DNA_constraint_types.h" #include "DNA_modifier_types.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index d8628097490..6755dd86a0a 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -46,6 +46,7 @@ # include "DNA_object_types.h" +# include "BLI_listbase.h" # include "BLI_string_utils.h" # include "BKE_animsys.h" diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 3883ffab246..f3e2e20ee3c 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -55,6 +55,8 @@ # include "BKE_node.h" # include "BKE_scene.h" +# include "BLI_listbase.h" + # include "DEG_depsgraph_build.h" # include "DEG_depsgraph_query.h" diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 47a20518648..d062642d3ce 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -41,6 +41,8 @@ #include "BKE_mesh.h" +#include "BLI_listbase.h" + #include "BLT_translation.h" #include "rna_internal.h" diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2e0197bca48..f68541dfc4a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -36,6 +36,7 @@ #include "IMB_imbuf_types.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLT_translation.h" diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index f61d2dcf563..e20bf263bee 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -34,6 +34,7 @@ #include "ED_text.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "DNA_action_types.h" diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 0dbea196de0..37cbeeb0d84 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -27,6 +27,8 @@ #include "BKE_idprop.h" +#include "BLI_listbase.h" + #include "RNA_define.h" #include "RNA_enum_types.h" diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index eb3de008e4c..8c1b48d2b07 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -26,6 +26,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BLT_translation.h" diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 457f47bf025..d9fe2504e22 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -20,6 +20,7 @@ #include +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "DNA_dynamicpaint_types.h" diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c index f63b77e1726..3a77e1ba797 100644 --- a/source/blender/python/intern/bpy_capi_utils.c +++ b/source/blender/python/intern/bpy_capi_utils.c @@ -24,6 +24,7 @@ #include #include "BLI_dynstr.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "bpy_capi_utils.h" diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 307ad444ffd..7d2d39963dd 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -27,6 +27,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_context.h" -- cgit v1.2.3 From d138cbfb47e379edc1ee915a8c6ff65b01f000d6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 3 Apr 2020 19:15:01 +0200 Subject: Code Quality: Replace for loops with LISTBASE_FOREACH Note this only changes cases where the variable was declared inside the for loop. To handle it outside as well is a different challenge. Differential Revision: https://developer.blender.org/D7320 --- source/blender/blenkernel/intern/anim_data.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 16 +- source/blender/blenkernel/intern/armature.c | 12 +- source/blender/blenkernel/intern/blender.c | 6 +- .../blender/blenkernel/intern/blender_user_menu.c | 2 +- source/blender/blenkernel/intern/blendfile.c | 2 +- source/blender/blenkernel/intern/camera.c | 2 +- source/blender/blenkernel/intern/collection.c | 42 ++- source/blender/blenkernel/intern/collision.c | 4 +- source/blender/blenkernel/intern/constraint.c | 6 +- source/blender/blenkernel/intern/curve.c | 8 +- source/blender/blenkernel/intern/effect.c | 6 +- source/blender/blenkernel/intern/fcurve.c | 6 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/gpencil.c | 4 +- source/blender/blenkernel/intern/gpencil_geom.c | 4 +- source/blender/blenkernel/intern/idprop.c | 2 +- source/blender/blenkernel/intern/idprop_utils.c | 2 +- source/blender/blenkernel/intern/image.c | 14 +- source/blender/blenkernel/intern/keyconfig.c | 2 +- source/blender/blenkernel/intern/layer.c | 117 ++++---- source/blender/blenkernel/intern/lib_id.c | 12 +- source/blender/blenkernel/intern/lib_override.c | 4 +- source/blender/blenkernel/intern/lib_query.c | 44 ++- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 23 +- source/blender/blenkernel/intern/node.c | 12 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 24 +- source/blender/blenkernel/intern/screen.c | 10 +- source/blender/blenkernel/intern/seqeffects.c | 1 - source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/text.c | 6 +- source/blender/blenkernel/intern/texture.c | 2 +- source/blender/blenkernel/intern/tracking_solver.c | 2 +- source/blender/blenkernel/intern/undo_system.c | 8 +- source/blender/blenkernel/intern/workspace.c | 2 +- source/blender/blenlib/intern/array_store.c | 18 +- source/blender/blenlib/intern/threads.c | 6 +- source/blender/blenloader/intern/readfile.c | 134 +++++---- source/blender/blenloader/intern/undofile.c | 2 +- source/blender/blenloader/intern/versioning_270.c | 40 +-- source/blender/blenloader/intern/versioning_280.c | 324 ++++++++++----------- .../blender/blenloader/intern/versioning_cycles.c | 48 +-- .../blenloader/intern/versioning_defaults.c | 34 +-- .../blender/blenloader/intern/versioning_userdef.c | 10 +- source/blender/blenloader/intern/writefile.c | 102 +++---- source/blender/bmesh/intern/bmesh_marking.c | 4 +- source/blender/bmesh/intern/bmesh_mesh.c | 2 +- .../blender/draw/engines/eevee/eevee_materials.c | 2 +- source/blender/draw/engines/eevee/eevee_volumes.c | 2 +- .../blender/draw/engines/gpencil/gpencil_engine.c | 12 +- .../blender/draw/engines/overlay/overlay_extra.c | 2 +- .../blender/draw/engines/overlay/overlay_image.c | 2 +- .../draw/engines/overlay/overlay_motion_path.c | 2 +- .../draw/engines/workbench/workbench_volume.c | 2 +- source/blender/draw/intern/draw_cache_impl_curve.c | 16 +- .../blender/draw/intern/draw_cache_impl_displist.c | 16 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 2 +- .../blender/draw/intern/draw_cache_impl_volume.c | 2 +- source/blender/draw/intern/draw_manager.c | 17 +- source/blender/draw/intern/draw_manager_data.c | 6 +- .../blender/draw/intern/draw_manager_profiling.c | 2 +- source/blender/draw/intern/draw_manager_shader.c | 2 +- source/blender/editors/animation/anim_filter.c | 4 +- source/blender/editors/animation/anim_markers.c | 12 +- .../blender/editors/animation/anim_motion_paths.c | 8 +- source/blender/editors/animation/keyframes_draw.c | 14 +- source/blender/editors/armature/armature_add.c | 4 +- source/blender/editors/armature/armature_edit.c | 12 +- source/blender/editors/armature/armature_naming.c | 9 +- .../blender/editors/armature/armature_relations.c | 14 +- source/blender/editors/armature/armature_select.c | 42 +-- source/blender/editors/armature/armature_utils.c | 10 +- .../blender/editors/armature/editarmature_undo.c | 2 +- source/blender/editors/armature/pose_select.c | 2 +- source/blender/editors/armature/pose_transform.c | 4 +- source/blender/editors/curve/editcurve.c | 4 +- source/blender/editors/curve/editcurve_select.c | 4 +- source/blender/editors/gpencil/gpencil_armature.c | 4 +- source/blender/editors/gpencil/gpencil_data.c | 24 +- source/blender/editors/gpencil/gpencil_edit.c | 2 +- .../editors/gpencil/gpencil_ops_versioning.c | 10 +- source/blender/editors/gpencil/gpencil_utils.c | 2 +- source/blender/editors/interface/interface.c | 22 +- .../interface/interface_eyedropper_gpencil_color.c | 2 +- .../blender/editors/interface/interface_handlers.c | 12 +- .../blender/editors/interface/interface_layout.c | 4 +- source/blender/editors/interface/interface_panel.c | 10 +- source/blender/editors/interface/interface_query.c | 18 +- .../interface/interface_region_color_picker.c | 2 +- .../editors/interface/interface_region_hud.c | 6 +- .../interface/interface_region_menu_popup.c | 6 +- .../editors/interface/interface_region_popup.c | 10 +- .../editors/interface/interface_region_tooltip.c | 4 +- .../editors/interface/interface_templates.c | 4 +- source/blender/editors/interface/view2d.c | 3 +- source/blender/editors/mask/mask_draw.c | 2 +- source/blender/editors/mask/mask_ops.c | 28 +- source/blender/editors/mask/mask_relationships.c | 8 +- source/blender/editors/mask/mask_select.c | 35 ++- source/blender/editors/mask/mask_shapekey.c | 16 +- .../editors/mesh/editmesh_extrude_spin_gizmo.c | 2 +- source/blender/editors/mesh/editmesh_utils.c | 3 +- source/blender/editors/mesh/meshtools.c | 6 +- source/blender/editors/metaball/mball_edit.c | 4 +- source/blender/editors/object/object_add.c | 4 +- .../blender/editors/object/object_data_transform.c | 4 +- source/blender/editors/object/object_edit.c | 10 +- source/blender/editors/object/object_relations.c | 8 +- source/blender/editors/object/object_select.c | 4 +- source/blender/editors/object/object_utils.c | 4 +- source/blender/editors/object/object_volume.c | 2 +- source/blender/editors/render/render_internal.c | 6 +- source/blender/editors/render/render_preview.c | 6 +- source/blender/editors/render/render_update.c | 4 +- source/blender/editors/scene/scene_edit.c | 4 +- source/blender/editors/screen/area.c | 14 +- source/blender/editors/screen/screen_context.c | 14 +- source/blender/editors/screen/screen_draw.c | 4 +- source/blender/editors/screen/screen_edit.c | 32 +- source/blender/editors/screen/screen_geometry.c | 10 +- source/blender/editors/screen/screen_ops.c | 30 +- source/blender/editors/screen/screen_user_menu.c | 8 +- source/blender/editors/screen/workspace_edit.c | 9 +- .../blender/editors/screen/workspace_layout_edit.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 4 +- source/blender/editors/sculpt_paint/paint_ops.c | 4 +- source/blender/editors/sculpt_paint/sculpt.c | 6 +- source/blender/editors/space_action/action_draw.c | 2 +- .../blender/editors/space_action/action_select.c | 4 +- source/blender/editors/space_action/space_action.c | 2 +- .../blender/editors/space_buttons/space_buttons.c | 2 +- source/blender/editors/space_clip/clip_editor.c | 4 +- source/blender/editors/space_image/image_ops.c | 6 +- .../blender/editors/space_image/image_sequence.c | 2 +- source/blender/editors/space_image/image_undo.c | 22 +- source/blender/editors/space_info/info_report.c | 4 +- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_draw.c | 8 +- source/blender/editors/space_nla/nla_select.c | 2 +- source/blender/editors/space_node/node_edit.c | 4 +- .../editors/space_node/node_relationships.c | 2 +- source/blender/editors/space_node/node_select.c | 2 +- .../editors/space_outliner/outliner_collections.c | 10 +- .../editors/space_outliner/outliner_dragdrop.c | 10 +- .../blender/editors/space_outliner/outliner_draw.c | 33 +-- .../blender/editors/space_outliner/outliner_edit.c | 4 +- .../editors/space_outliner/outliner_select.c | 4 +- .../blender/editors/space_outliner/outliner_sync.c | 8 +- .../editors/space_outliner/outliner_tools.c | 2 +- .../blender/editors/space_outliner/outliner_tree.c | 19 +- .../editors/space_outliner/outliner_utils.c | 10 +- .../editors/space_sequencer/sequencer_edit.c | 2 +- .../editors/space_sequencer/sequencer_select.c | 4 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 2 +- .../blender/editors/space_view3d/view3d_select.c | 12 +- source/blender/editors/space_view3d/view3d_view.c | 2 +- .../blender/editors/transform/transform_convert.c | 13 +- .../editors/transform/transform_convert_armature.c | 9 +- .../editors/transform/transform_convert_curve.c | 4 +- .../editors/transform/transform_convert_object.c | 18 +- .../blender/editors/transform/transform_gizmo_3d.c | 6 +- .../editors/transform/transform_snap_object.c | 4 +- source/blender/editors/undo/ed_undo.c | 8 +- source/blender/editors/util/ed_util.c | 2 +- source/blender/gpu/intern/gpu_batch_presets.c | 2 +- source/blender/gpu/intern/gpu_codegen.c | 20 +- source/blender/gpu/intern/gpu_material.c | 4 +- source/blender/gpu/intern/gpu_node_graph.c | 4 +- source/blender/gpu/intern/gpu_select_pick.c | 3 +- source/blender/gpu/intern/gpu_uniformbuffer.c | 6 +- source/blender/gpu/intern/gpu_viewport.c | 4 +- source/blender/ikplugin/intern/iksolver_plugin.c | 2 +- .../makesrna/intern/rna_access_compare_override.c | 8 +- source/blender/makesrna/intern/rna_key.c | 2 +- source/blender/makesrna/intern/rna_layer.c | 2 +- source/blender/makesrna/intern/rna_particle.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 4 +- source/blender/makesrna/intern/rna_space.c | 4 +- source/blender/makesrna/intern/rna_ui.c | 10 +- source/blender/makesrna/intern/rna_wm_gizmo.c | 9 +- source/blender/modifiers/intern/MOD_dynamicpaint.c | 3 +- source/blender/nodes/shader/node_shader_tree.c | 6 +- .../nodes/shader/nodes/node_shader_displacement.c | 2 +- .../nodes/shader/nodes/node_shader_tex_brick.c | 2 +- .../shader/nodes/node_shader_volume_principled.c | 4 +- source/blender/python/intern/bpy_capi_utils.c | 2 +- source/blender/render/intern/source/pipeline.c | 7 +- .../blender/render/intern/source/render_result.c | 16 +- .../windowmanager/gizmo/intern/wm_gizmo_group.c | 30 +- .../windowmanager/gizmo/intern/wm_gizmo_map.c | 51 ++-- .../windowmanager/gizmo/intern/wm_gizmo_type.c | 6 +- source/blender/windowmanager/intern/wm_dragdrop.c | 4 +- source/blender/windowmanager/intern/wm_draw.c | 25 +- .../blender/windowmanager/intern/wm_event_system.c | 22 +- source/blender/windowmanager/intern/wm_files.c | 8 +- source/blender/windowmanager/intern/wm_jobs.c | 2 +- source/blender/windowmanager/intern/wm_keymap.c | 6 +- .../blender/windowmanager/intern/wm_keymap_utils.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 8 +- source/blender/windowmanager/intern/wm_surface.c | 2 +- .../blender/windowmanager/intern/wm_toolsystem.c | 28 +- source/blender/windowmanager/intern/wm_window.c | 19 +- .../message_bus/intern/wm_message_bus.c | 11 +- 207 files changed, 1174 insertions(+), 1251 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index cd56796c3cf..41bfc5b59e4 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -1130,7 +1130,7 @@ bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix) /* free drivers - stored as a list of F-Curves */ any_removed |= fcurves_path_remove_fix(prefix, &adt->drivers); /* NLA Data - Animation Data for Strips */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { any_removed |= nlastrips_path_remove_fix(prefix, &nlt->strips); } } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 69efac37fbf..18320ef0f8d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -542,7 +542,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr, bool flush_to_original) { /* Calculate then execute each curve. */ - for (FCurve *fcu = list->first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, list) { /* Check if this F-Curve doesn't belong to a muted group. */ if ((fcu->grp != NULL) && (fcu->grp->flag & AGRP_MUTED)) { continue; @@ -1095,7 +1095,7 @@ static void nlaeval_free(NlaEvalData *nlaeval) nlaeval_snapshot_free_data(&nlaeval->eval_snapshot); /* Delete channels. */ - for (NlaEvalChannel *nec = nlaeval->channels.first; nec; nec = nec->next) { + LISTBASE_FOREACH (NlaEvalChannel *, nec, &nlaeval->channels) { nlaevalchan_free_data(nec); } @@ -1954,7 +1954,7 @@ void nladata_flush_channels(PointerRNA *ptr, } /* for each channel with accumulated values, write its value on the property it affects */ - for (NlaEvalChannel *nec = channels->channels.first; nec; nec = nec->next) { + LISTBASE_FOREACH (NlaEvalChannel *, nec, &channels->channels) { NlaEvalChannelSnapshot *nec_snapshot = nlaeval_snapshot_find_channel(snapshot, nec); PathResolvedRNA rna = {nec->key.ptr, nec->key.prop, -1}; @@ -1985,7 +1985,7 @@ static void nla_eval_domain_action(PointerRNA *ptr, return; } - for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, &act->curves) { /* check if this curve should be skipped */ if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) { continue; @@ -2020,7 +2020,7 @@ static void nla_eval_domain_strips(PointerRNA *ptr, ListBase *strips, GSet *touched_actions) { - for (NlaStrip *strip = strips->first; strip; strip = strip->next) { + LISTBASE_FOREACH (NlaStrip *, strip, strips) { /* check strip's action */ if (strip->act) { nla_eval_domain_action(ptr, channels, strip->act, touched_actions); @@ -2044,7 +2044,7 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels, } /* NLA Data - Animation Data for Strips */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { /* solo and muting are mutually exclusive... */ if (adt->flag & ADT_NLA_SOLO_TRACK) { /* skip if there is a solo track, but this isn't it */ @@ -2430,7 +2430,7 @@ bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, */ void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache) { - for (NlaKeyframingContext *ctx = cache->first; ctx; ctx = ctx->next) { + LISTBASE_FOREACH (NlaKeyframingContext *, ctx, cache) { MEM_SAFE_FREE(ctx->eval_strip); nlaeval_free(&ctx->nla_channels); } @@ -2738,7 +2738,7 @@ void BKE_animsys_update_driver_array(ID *id) adt->driver_array = MEM_mallocN(sizeof(FCurve *) * num_drivers, "adt->driver_array"); int driver_index = 0; - for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) { adt->driver_array[driver_index++] = fcu; } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b8d0f8c8c92..daf364432f4 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -190,7 +190,7 @@ bArmature *BKE_armature_from_object(Object *ob) int BKE_armature_bonelist_count(ListBase *lb) { int i = 0; - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { i += 1 + BKE_armature_bonelist_count(&bone->childbase); } @@ -303,7 +303,7 @@ static void armature_transform_recurse(ListBase *bonebase, const Bone *bone_parent, const float arm_mat_parent_inv[4][4]) { - for (Bone *bone = bonebase->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, bonebase) { /* Store the initial bone roll in a matrix, this is needed even for child bones * so any change in head/tail doesn't cause the roll to change. @@ -424,7 +424,7 @@ Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name) static void armature_bone_from_name_insert_recursive(GHash *bone_hash, ListBase *lb) { - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { BLI_ghash_insert(bone_hash, bone->name, bone); armature_bone_from_name_insert_recursive(bone_hash, &bone->childbase); } @@ -474,7 +474,7 @@ bool BKE_armature_bone_flag_test_recursive(const Bone *bone, int flag) static void armature_refresh_layer_used_recursive(bArmature *arm, ListBase *bones) { - for (Bone *bone = bones->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, bones) { arm->layer_used |= bone->layer; armature_refresh_layer_used_recursive(arm, &bone->childbase); } @@ -2701,7 +2701,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int */ void BKE_pose_clear_pointers(bPose *pose) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { pchan->bone = NULL; pchan->child = NULL; } @@ -2709,7 +2709,7 @@ void BKE_pose_clear_pointers(bPose *pose) void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { pchan->bone = BKE_armature_find_bone_name(armature, pchan->name); } } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 70ab52828f2..b3a4de02451 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -182,7 +182,7 @@ static void userdef_free_keymaps(UserDef *userdef) { for (wmKeyMap *km = userdef->user_keymaps.first, *km_next; km; km = km_next) { km_next = km->next; - for (wmKeyMapDiffItem *kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { + LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) { if (kmdi->add_item) { keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); @@ -193,7 +193,7 @@ static void userdef_free_keymaps(UserDef *userdef) } } - for (wmKeyMapItem *kmi = km->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) { keymap_item_free(kmi); } @@ -250,7 +250,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) userdef_free_addons(userdef); if (clear_fonts) { - for (uiFont *font = userdef->uifonts.first; font; font = font->next) { + LISTBASE_FOREACH (uiFont *, font, &userdef->uifonts) { BLF_unload_id(font->blf_id); } BLF_default_set(-1); diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c index ad34ef03e04..edd89357fd5 100644 --- a/source/blender/blenkernel/intern/blender_user_menu.c +++ b/source/blender/blenkernel/intern/blender_user_menu.c @@ -38,7 +38,7 @@ bUserMenu *BKE_blender_user_menu_find(ListBase *lb, char space_type, const char *context) { - for (bUserMenu *um = lb->first; um; um = um->next) { + LISTBASE_FOREACH (bUserMenu *, um, lb) { if ((space_type == um->space_type) && (STREQ(context, um->context))) { return um; } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 6bf47a8c280..d862132480a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -345,7 +345,7 @@ static void setup_app_data(bContext *C, wmWindowManager *wm = bmain->wm.first; if (wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->scene && win->scene != curscene) { BKE_scene_set_background(bmain, win->scene); } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 323bb597127..71a2b6f703a 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -912,7 +912,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con name[0] = '\0'; /* we need to take the better match, thus the len_suffix_max test */ - for (const SceneRenderView *srv = scene->r.views.first; srv; srv = srv->next) { + LISTBASE_FOREACH (const SceneRenderView *, srv, &scene->r.views) { const int len_suffix = strlen(srv->suffix); if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) { diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index d39df4cc6a3..83a6949430e 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -106,10 +106,10 @@ static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, cons BLI_listbase_clear(&collection_dst->children); BLI_listbase_clear(&collection_dst->parents); - for (CollectionChild *child = collection_src->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection_src->children) { collection_child_add(collection_dst, child->collection, flag, false); } - for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection_src->gobject) { collection_object_add(bmain, collection_dst, cob->ob, flag, false); } } @@ -223,9 +223,8 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) } else { /* Link child collections into parent collection. */ - for (CollectionChild *child = collection->children.first; child; child = child->next) { - for (CollectionParent *cparent = collection->parents.first; cparent; - cparent = cparent->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; collection_child_add(parent, child->collection, 0, true); } @@ -234,8 +233,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) CollectionObject *cob = collection->gobject.first; while (cob != NULL) { /* Link child object into parent collections. */ - for (CollectionParent *cparent = collection->parents.first; cparent; - cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; collection_object_add(bmain, parent, cob->ob, 0, true); } @@ -305,7 +303,7 @@ static Collection *collection_duplicate_recursive(Main *bmain, if (do_objects) { /* We can loop on collection_old's objects, that list is currently identical the collection_new * objects, and won't be changed here. */ - for (CollectionObject *cob = collection_old->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection_old->gobject) { Object *ob_old = cob->ob; Object *ob_new = (Object *)ob_old->id.newid; @@ -321,7 +319,7 @@ static Collection *collection_duplicate_recursive(Main *bmain, /* We can loop on collection_old's children, * that list is currently identical the collection_new' children, and won't be changed here. */ - for (CollectionChild *child = collection_old->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection_old->children) { Collection *child_collection_old = child->collection; collection_duplicate_recursive( @@ -440,7 +438,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i { int child_restrict = collection->flag | parent_restrict; - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Base *base = BLI_findptr(lb, cob->ob, offsetof(Base, object)); if (base == NULL) { @@ -460,7 +458,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i } } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { collection_object_cache_fill(lb, child->collection, child_restrict); } } @@ -487,7 +485,7 @@ static void collection_object_cache_free(Collection *collection) collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; BLI_freelistN(&collection->object_cache); - for (CollectionParent *parent = collection->parents.first; parent; parent = parent->next) { + LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { collection_object_cache_free(parent->collection); } } @@ -645,8 +643,7 @@ static void collection_tag_update_parent_recursive(Main *bmain, DEG_id_tag_update_ex(bmain, &collection->id, flag); - for (CollectionParent *collection_parent = collection->parents.first; collection_parent; - collection_parent = collection_parent->next) { + LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->parents) { if (collection_parent->collection->flag & COLLECTION_IS_MASTER) { /* We don't care about scene/master collection here. */ continue; @@ -952,7 +949,7 @@ bool BKE_collection_is_in_scene(Collection *collection) return true; } - for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { if (BKE_collection_is_in_scene(cparent->collection)) { return true; } @@ -977,7 +974,7 @@ bool BKE_collection_find_cycle(Collection *new_ancestor, Collection *collection) return true; } - for (CollectionParent *parent = new_ancestor->parents.first; parent; parent = parent->next) { + LISTBASE_FOREACH (CollectionParent *, parent, &new_ancestor->parents) { if (BKE_collection_find_cycle(parent->collection, collection)) { return true; } @@ -993,7 +990,7 @@ static CollectionChild *collection_find_child(Collection *parent, Collection *co static bool collection_find_child_recursive(Collection *parent, Collection *collection) { - for (CollectionChild *child = parent->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &parent->children) { if (child->collection == collection) { return true; } @@ -1168,7 +1165,7 @@ static Collection *collection_from_index_recursive(Collection *collection, (*index_current)++; - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { Collection *nested = collection_from_index_recursive(child->collection, index, index_current); if (nested != NULL) { return nested; @@ -1197,7 +1194,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect return false; } - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); if (base) { @@ -1216,7 +1213,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect } } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { if (collection_objects_select(view_layer, collection, deselect)) { changed = true; } @@ -1289,8 +1286,7 @@ bool BKE_collection_move(Main *bmain, GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); @@ -1352,7 +1348,7 @@ static void scene_collection_callback(Collection *collection, { callback(collection, data); - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { scene_collection_callback(child->collection, callback, data); } } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 9230746cd1d..7cc40007e26 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1380,7 +1380,7 @@ Object **BKE_collision_objects_create(Depsgraph *depsgraph, int num = 0; Object **objects = MEM_callocN(sizeof(Object *) * maxnum, __func__); - for (CollisionRelation *relation = relations->first; relation; relation = relation->next) { + LISTBASE_FOREACH (CollisionRelation *, relation, relations) { /* Get evaluated object. */ Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id); @@ -1418,7 +1418,7 @@ ListBase *BKE_collider_cache_create(Depsgraph *depsgraph, Object *self, Collecti return NULL; } - for (CollisionRelation *relation = relations->first; relation; relation = relation->next) { + LISTBASE_FOREACH (CollisionRelation *, relation, relations) { /* Get evaluated object. */ Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 28ce62c3de2..c91bf4e7f5b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2513,7 +2513,7 @@ static void armdef_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ /* Process all targets. This can't use ct->matrix, as armdef_get_tarmat is not * called in solve for efficiency because the constraint needs bone data anyway. */ - for (bConstraintTarget *ct = targets->first; ct; ct = ct->next) { + LISTBASE_FOREACH (bConstraintTarget *, ct, targets) { if (ct->weight <= 0.0f) { continue; } @@ -5497,7 +5497,7 @@ void BKE_constraints_active_set(ListBase *list, bConstraint *con) static bConstraint *constraint_list_find_from_target(ListBase *constraints, bConstraintTarget *tgt) { - for (bConstraint *con = constraints->first; con; con = con->next) { + LISTBASE_FOREACH (bConstraint *, con, constraints) { ListBase *targets = NULL; if (con->type == CONSTRAINT_TYPE_PYTHON) { @@ -5531,7 +5531,7 @@ bConstraint *BKE_constraint_find_from_target(Object *ob, } if (ob->pose != NULL) { - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { result = constraint_list_find_from_target(&pchan->constraints, tgt); if (result != NULL) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 51912e3375a..5b463059f18 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -4612,7 +4612,7 @@ void BKE_nurb_direction_switch(Nurb *nu) void BKE_curve_nurbs_vert_coords_get(ListBase *lb, float (*vert_coords)[3], int vert_len) { float *co = vert_coords[0]; - for (Nurb *nu = lb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, lb) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; for (int i = 0; i < nu->pntsu; i++, bezt++) { @@ -4692,7 +4692,7 @@ void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, { const float *co = vert_coords[0]; - for (Nurb *nu = lb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, lb) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; @@ -4730,7 +4730,7 @@ float (*BKE_curve_nurbs_key_vert_coords_alloc(ListBase *lb, float *key, int *r_v float(*cos)[3] = MEM_malloc_arrayN(vert_len, sizeof(*cos), __func__); float *co = cos[0]; - for (Nurb *nu = lb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, lb) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; @@ -5168,7 +5168,7 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3]) use_radius = false; } /* Do bounding box based on splines. */ - for (Nurb *nu = nurb_lb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, nurb_lb) { BKE_nurb_minmax(nu, use_radius, min, max); } const bool result = (BLI_listbase_is_empty(nurb_lb) == false); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 984a7a12b94..e1e818a5a34 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -247,7 +247,7 @@ ListBase *BKE_effector_relations_create(Depsgraph *depsgraph, add_effector_relation(relations, ob, NULL, ob->pd); } - for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { ParticleSettings *part = psys->part; if (psys_check_enabled(ob, psys, for_render)) { @@ -286,7 +286,7 @@ ListBase *BKE_effectors_create(Depsgraph *depsgraph, return NULL; } - for (EffectorRelation *relation = relations->first; relation; relation = relation->next) { + LISTBASE_FOREACH (EffectorRelation *, relation, relations) { /* Get evaluated object. */ Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id); @@ -329,7 +329,7 @@ ListBase *BKE_effectors_create(Depsgraph *depsgraph, void BKE_effectors_free(ListBase *lb) { if (lb) { - for (EffectorCache *eff = lb->first; eff; eff = eff->next) { + LISTBASE_FOREACH (EffectorCache *, eff, lb) { if (eff->guide_data) { MEM_freeN(eff->guide_data); } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index fbca09001d6..439992a4113 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1944,7 +1944,7 @@ void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars) BLI_assert(BLI_listbase_is_empty(dst_vars)); BLI_duplicatelist(dst_vars, src_vars); - for (DriverVar *dvar = dst_vars->first; dvar; dvar = dvar->next) { + LISTBASE_FOREACH (DriverVar *, dvar, dst_vars) { /* need to go over all targets so that we don't leave any dangling paths */ DRIVER_TARGETS_LOOPER_BEGIN (dvar) { /* make a copy of target's rna path if available */ @@ -2167,7 +2167,7 @@ static ExprPyLike_Parsed *driver_compile_simple_expr_impl(ChannelDriver *driver) names[VAR_INDEX_FRAME] = "frame"; - for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) { + LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { names[i++] = dvar->name; } @@ -2192,7 +2192,7 @@ static bool driver_evaluate_simple_expr(ChannelDriver *driver, vars[VAR_INDEX_FRAME] = time; - for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) { + LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { vars[i++] = driver_get_variable_value(driver, dvar); } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 1d5a908e226..c85283e3653 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1358,7 +1358,7 @@ uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers) uint max_size = 0; - for (FModifier *fcm = modifiers->first; fcm; fcm = fcm->next) { + LISTBASE_FOREACH (FModifier *, fcm, modifiers) { const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); if (fmi == NULL) { diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index b2fc91fd0a6..a0fa07f4a41 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -644,7 +644,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src) /* copy strokes */ BLI_listbase_clear(&gpf_dst->strokes); - for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) { + LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* make copy of source stroke */ gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); BLI_addtail(&gpf_dst->strokes, gps_dst); @@ -665,7 +665,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds /* copy strokes */ BLI_listbase_clear(&gpf_dst->strokes); - for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) { + LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* make copy of source stroke */ gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); BLI_addtail(&gpf_dst->strokes, gps_dst); diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 6bdcc9cfbcb..874672f4a73 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -1685,7 +1685,7 @@ static Collection *gpencil_get_parent_collection(Scene *scene, Object *ob) { Collection *mycol = NULL; FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { if ((mycol == NULL) && (cob->ob == ob)) { mycol = collection; } @@ -1976,7 +1976,7 @@ void BKE_gpencil_convert_curve(Main *bmain, bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_COPY); /* Read all splines of the curve and create a stroke for each. */ - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { gpencil_convert_spline(bmain, ob_gp, ob_cu, gpencil_lines, only_stroke, gpf, nu); } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 554b8d93db3..5530a126ffc 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -800,7 +800,7 @@ void IDP_RelinkProperty(struct IDProperty *prop) switch (prop->type) { case IDP_GROUP: { - for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) { + LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { IDP_RelinkProperty(loop); } break; diff --git a/source/blender/blenkernel/intern/idprop_utils.c b/source/blender/blenkernel/intern/idprop_utils.c index 629fecf42f4..f8a1113f69b 100644 --- a/source/blender/blenkernel/intern/idprop_utils.c +++ b/source/blender/blenkernel/intern/idprop_utils.c @@ -167,7 +167,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro } case IDP_GROUP: { STR_APPEND_STR("{"); - for (const IDProperty *subprop = prop->data.group.first; subprop; subprop = subprop->next) { + LISTBASE_FOREACH (const IDProperty *, subprop, &prop->data.group) { if (subprop != prop->data.group.first) { STR_APPEND_STR(", "); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0fb70869ac0..f58e7c06d7f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -3101,7 +3101,7 @@ static void image_walk_ntree_all_users( { switch (ntree->type) { case NTREE_SHADER: - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->id) { if (node->type == SH_NODE_TEX_IMAGE) { NodeTexImage *tex = node->storage; @@ -3117,7 +3117,7 @@ static void image_walk_ntree_all_users( } break; case NTREE_TEXTURE: - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->id && node->type == TEX_NODE_IMAGE) { Image *ima = (Image *)node->id; ImageUser *iuser = node->storage; @@ -3126,7 +3126,7 @@ static void image_walk_ntree_all_users( } break; case NTREE_COMPOSIT: - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->id && node->type == CMP_NODE_IMAGE) { Image *ima = (Image *)node->id; ImageUser *iuser = node->storage; @@ -3189,17 +3189,17 @@ static void image_walk_id_all_users( } case ID_CA: { Camera *cam = (Camera *)id; - for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) { callback(bgpic->ima, NULL, &bgpic->iuser, customdata); } break; } case ID_WM: { wmWindowManager *wm = (wmWindowManager *)id; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_IMAGE) { SpaceImage *sima = area->spacedata.first; callback(sima->image, NULL, &sima->iuser, customdata); @@ -3761,7 +3761,7 @@ static void image_init_multilayer_multiview(Image *ima, RenderResult *rr) BKE_image_free_views(ima); if (rr) { - for (RenderView *rv = rr->views.first; rv; rv = rv->next) { + LISTBASE_FOREACH (RenderView *, rv, &rr->views) { ImageView *iv = MEM_callocN(sizeof(ImageView), "Viewer Image View"); STRNCPY(iv->name, rv->name); BLI_addtail(&ima->views, iv); diff --git a/source/blender/blenkernel/intern/keyconfig.c b/source/blender/blenkernel/intern/keyconfig.c index 84f48441cf9..ada5fc5b6aa 100644 --- a/source/blender/blenkernel/intern/keyconfig.c +++ b/source/blender/blenkernel/intern/keyconfig.c @@ -209,7 +209,7 @@ void BKE_keyconfig_pref_filter_items(struct UserDef *userdef, bool (*filter_fn)(wmKeyMapItem *kmi, void *user_data), void *user_data) { - for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) { + LISTBASE_FOREACH (wmKeyMap *, keymap, &userdef->user_keymaps) { BKE_keyconfig_keymap_filter_item(keymap, params, filter_fn, user_data); } } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index ffa1eecc87b..d8f0bda8c22 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -83,7 +83,7 @@ static void layer_collection_free(ViewLayer *view_layer, LayerCollection *lc) view_layer->active_collection = NULL; } - for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) { + LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) { layer_collection_free(view_layer, nlc); } @@ -109,8 +109,7 @@ static Base *object_base_new(Object *ob) * none linked to the workspace yet. */ ViewLayer *BKE_view_layer_default_view(const Scene *scene) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (!(view_layer->flag & VIEW_LAYER_RENDER)) { return view_layer; } @@ -123,8 +122,7 @@ ViewLayer *BKE_view_layer_default_view(const Scene *scene) /* Returns the default view layer to render if we need to render just one. */ ViewLayer *BKE_view_layer_default_render(const Scene *scene) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (view_layer->flag & VIEW_LAYER_RENDER) { return view_layer; } @@ -137,8 +135,7 @@ ViewLayer *BKE_view_layer_default_render(const Scene *scene) /* Returns view layer with matching name, or NULL if not found. */ ViewLayer *BKE_view_layer_find(const Scene *scene, const char *layer_name) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (STREQ(view_layer->name, layer_name)) { return view_layer; } @@ -262,12 +259,12 @@ void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user) BLI_ghash_free(view_layer->object_bases_hash, NULL, NULL); } - for (LayerCollection *lc = view_layer->layer_collections.first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, &view_layer->layer_collections) { layer_collection_free(view_layer, lc); } BLI_freelistN(&view_layer->layer_collections); - for (ViewLayerEngineData *sled = view_layer->drawdata.first; sled; sled = sled->next) { + LISTBASE_FOREACH (ViewLayerEngineData *, sled, &view_layer->drawdata) { if (sled->storage) { if (sled->free) { sled->free(sled->storage); @@ -295,7 +292,7 @@ void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user) */ void BKE_view_layer_selected_objects_tag(ViewLayer *view_layer, const int tag) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if ((base->flag & BASE_SELECTED) != 0) { base->object->flag |= tag; } @@ -307,7 +304,7 @@ void BKE_view_layer_selected_objects_tag(ViewLayer *view_layer, const int tag) static bool find_scene_collection_in_scene_collections(ListBase *lb, const LayerCollection *lc) { - for (LayerCollection *lcn = lb->first; lcn; lcn = lcn->next) { + LISTBASE_FOREACH (LayerCollection *, lcn, lb) { if (lcn == lc) { return true; } @@ -327,7 +324,7 @@ static bool find_scene_collection_in_scene_collections(ListBase *lb, const Layer */ Object *BKE_view_layer_camera_find(ViewLayer *view_layer) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object->type == OB_CAMERA) { return base->object; } @@ -341,8 +338,7 @@ Object *BKE_view_layer_camera_find(ViewLayer *view_layer) */ ViewLayer *BKE_view_layer_find_from_collection(const Scene *scene, LayerCollection *lc) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (find_scene_collection_in_scene_collections(&view_layer->layer_collections, lc)) { return view_layer; } @@ -364,7 +360,7 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer) view_layer->object_bases_hash = BLI_ghash_new( BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object) { BLI_ghash_insert(view_layer->object_bases_hash, base->object, base); } @@ -455,7 +451,7 @@ void BKE_view_layer_copy_data(Scene *scene_dst, /* Copy layer collections and object bases. */ /* Inline 'BLI_duplicatelist' and update the active base. */ BLI_listbase_clear(&view_layer_dst->object_bases); - for (Base *base_src = view_layer_src->object_bases.first; base_src; base_src = base_src->next) { + LISTBASE_FOREACH (Base *, base_src, &view_layer_src->object_bases) { Base *base_dst = MEM_dupallocN(base_src); BLI_addtail(&view_layer_dst->object_bases, base_dst); if (view_layer_src->basact == base_src) { @@ -506,7 +502,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con /* WM can be missing on startup. */ wmWindowManager *wm = bmain->wm.first; if (wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->scene == scene && STREQ(win->view_layer_name, oldname)) { STRNCPY(win->view_layer_name, view_layer->name); } @@ -524,7 +520,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con */ static LayerCollection *collection_from_index(ListBase *lb, const int number, int *i) { - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { if (*i == number) { return lc; } @@ -532,7 +528,7 @@ static LayerCollection *collection_from_index(ListBase *lb, const int number, in (*i)++; } - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { LayerCollection *lc_nested = collection_from_index(&lc->layer_collections, number, i); if (lc_nested) { return lc_nested; @@ -635,7 +631,7 @@ LayerCollection *BKE_layer_collection_activate_parent(ViewLayer *view_layer, Lay static int collection_count(ListBase *lb) { int i = 0; - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { i += collection_count(&lc->layer_collections) + 1; } return i; @@ -655,7 +651,7 @@ int BKE_layer_collection_count(ViewLayer *view_layer) */ static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i) { - for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) { + LISTBASE_FOREACH (LayerCollection *, lcol, lb) { if (lcol == lc) { return *i; } @@ -663,7 +659,7 @@ static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i (*i)++; } - for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) { + LISTBASE_FOREACH (LayerCollection *, lcol, lb) { int i_nested = index_from_collection(&lcol->layer_collections, lc, i); if (i_nested != -1) { return i_nested; @@ -733,7 +729,7 @@ static short layer_collection_sync(ViewLayer *view_layer, ListBase new_lb_layer = {NULL, NULL}; short runtime_flag = 0; - for (const CollectionChild *child = lb_scene->first; child; child = child->next) { + LISTBASE_FOREACH (const CollectionChild *, child, lb_scene) { Collection *collection = child->collection; LayerCollection *lc = BLI_findptr(lb_layer, collection, offsetof(LayerCollection, collection)); @@ -792,7 +788,7 @@ static short layer_collection_sync(ViewLayer *view_layer, } /* Sync objects, except if collection was excluded. */ - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { if (cob->ob == NULL) { continue; } @@ -877,7 +873,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) } /* Clear visible and selectable flags to be reset. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { base->flag &= ~g_base_collection_flags; base->flag_from_collection &= ~g_base_collection_flags; } @@ -898,7 +894,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) ~(0)); /* Any remaining object bases are to be removed. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (view_layer->basact == base) { view_layer->basact = NULL; } @@ -911,7 +907,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) BLI_freelistN(&view_layer->object_bases); view_layer->object_bases = new_object_bases; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { BKE_base_eval_flags(base); } @@ -927,8 +923,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) void BKE_scene_collection_sync(const Scene *scene) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { BKE_layer_collection_sync(scene, view_layer); } } @@ -951,8 +946,7 @@ void BKE_main_collection_sync_remap(const Main *bmain) /* TODO: try to make this faster */ for (const Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { MEM_SAFE_FREE(view_layer->object_bases_array); if (view_layer->object_bases_hash) { @@ -988,7 +982,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection bool changed = false; if (!(lc->flag & LAYER_COLLECTION_EXCLUDE)) { - for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); if (base) { @@ -1008,7 +1002,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection } } - for (LayerCollection *iter = lc->layer_collections.first; iter; iter = iter->next) { + LISTBASE_FOREACH (LayerCollection *, iter, &lc->layer_collections) { changed |= BKE_layer_collection_objects_select(view_layer, iter, deselect); } @@ -1022,7 +1016,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle } if (!(lc->flag & LAYER_COLLECTION_EXCLUDE)) { - for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) { @@ -1031,7 +1025,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle } } - for (LayerCollection *iter = lc->layer_collections.first; iter; iter = iter->next) { + LISTBASE_FOREACH (LayerCollection *, iter, &lc->layer_collections) { if (BKE_layer_collection_has_selected_objects(view_layer, iter)) { return true; } @@ -1047,8 +1041,7 @@ bool BKE_layer_collection_has_layer_collection(LayerCollection *lc_parent, return true; } - for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, lc_child)) { return true; } @@ -1063,7 +1056,7 @@ void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool { if (!extend) { /* Make only one base visible. */ - for (Base *other = view_layer->object_bases.first; other; other = other->next) { + LISTBASE_FOREACH (Base *, other, &view_layer->object_bases) { other->flag |= BASE_HIDDEN; } @@ -1134,7 +1127,7 @@ bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Ob static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag) { lc->flag |= flag; - for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) { layer_collection_flag_set_recursive(lc_iter, flag); } } @@ -1142,7 +1135,7 @@ static void layer_collection_flag_set_recursive(LayerCollection *lc, const int f static void layer_collection_flag_unset_recursive(LayerCollection *lc, const int flag) { lc->flag &= ~flag; - for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) { layer_collection_flag_unset_recursive(lc_iter, flag); } } @@ -1165,8 +1158,7 @@ void BKE_layer_collection_isolate_global(Scene *scene, if (!extend) { /* Hide all collections . */ - for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { layer_collection_flag_set_recursive(lc_iter, LAYER_COLLECTION_HIDE); } } @@ -1177,8 +1169,7 @@ void BKE_layer_collection_isolate_global(Scene *scene, } else { LayerCollection *lc_parent = lc; - for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) { lc_parent = lc_iter; break; @@ -1188,8 +1179,7 @@ void BKE_layer_collection_isolate_global(Scene *scene, while (lc_parent != lc) { lc_parent->flag &= ~LAYER_COLLECTION_HIDE; - for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) { lc_parent = lc_iter; break; @@ -1210,8 +1200,7 @@ static void layer_collection_local_visibility_set_recursive(LayerCollection *lay const int local_collections_uuid) { layer_collection->local_collections_bits |= local_collections_uuid; - for (LayerCollection *child = layer_collection->layer_collections.first; child; - child = child->next) { + LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) { layer_collection_local_visibility_set_recursive(child, local_collections_uuid); } } @@ -1220,8 +1209,7 @@ static void layer_collection_local_visibility_unset_recursive(LayerCollection *l const int local_collections_uuid) { layer_collection->local_collections_bits &= ~local_collections_uuid; - for (LayerCollection *child = layer_collection->layer_collections.first; child; - child = child->next) { + LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) { layer_collection_local_visibility_unset_recursive(child, local_collections_uuid); } } @@ -1236,8 +1224,7 @@ static void layer_collection_local_sync(ViewLayer *view_layer, } if (visible) { - for (CollectionObject *cob = layer_collection->collection->gobject.first; cob; - cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &layer_collection->collection->gobject) { BLI_assert(cob->ob); Base *base = BKE_view_layer_base_find(view_layer, cob->ob); base->local_collections_bits |= local_collections_uuid; @@ -1256,7 +1243,7 @@ void BKE_layer_collection_local_sync(ViewLayer *view_layer, View3D *v3d) const unsigned short local_collections_uuid = v3d->local_collections_uuid; /* Reset flags and set the bases visible by default. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { base->local_collections_bits &= ~local_collections_uuid; } @@ -1280,8 +1267,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer, if (!extend) { /* Hide all collections. */ - for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uuid); } } @@ -1292,8 +1278,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer, } else { LayerCollection *lc_parent = lc; - for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) { lc_parent = lc_iter; break; @@ -1303,8 +1288,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer, while (lc_parent != lc) { lc_parent->local_collections_bits |= v3d->local_collections_uuid; - for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) { lc_parent = lc_iter; break; @@ -1322,12 +1306,12 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer, static void layer_collection_bases_show_recursive(ViewLayer *view_layer, LayerCollection *lc) { if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) { - for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); base->flag &= ~BASE_HIDDEN; } } - for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) { layer_collection_bases_show_recursive(view_layer, lc_iter); } } @@ -1335,12 +1319,12 @@ static void layer_collection_bases_show_recursive(ViewLayer *view_layer, LayerCo static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCollection *lc) { if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) { - for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); base->flag |= BASE_HIDDEN; } } - for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) { layer_collection_bases_hide_recursive(view_layer, lc_iter); } } @@ -1384,7 +1368,7 @@ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollectio return lc; } - for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) { + LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) { LayerCollection *found = find_layer_collection_by_scene_collection(nlc, collection); if (found) { return found; @@ -1425,8 +1409,7 @@ bool BKE_view_layer_has_collection(ViewLayer *view_layer, const Collection *coll */ bool BKE_scene_has_object(Scene *scene, Object *ob) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { Base *base = BKE_view_layer_base_find(view_layer, ob); if (base) { return true; @@ -1768,7 +1751,7 @@ static void layer_eval_view_layer(struct Depsgraph *depsgraph, view_layer->object_bases_array = MEM_malloc_arrayN( num_object_bases, sizeof(Base *), "view_layer->object_bases_array"); int base_index = 0; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { view_layer->object_bases_array[base_index++] = base; } } diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 21e27784684..286ee4a8723 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -901,7 +901,7 @@ void BKE_main_id_flag_all(Main *bmain, const int flag, const bool value) void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb) { int lb_len = 0; - for (ID *id = lb->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lb) { if (id->lib == NULL) { lb_len += 1; } @@ -914,7 +914,7 @@ void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb) ID **id_array = MEM_mallocN(sizeof(*id_array) * lb_len, __func__); GSet *gset = BLI_gset_str_new_ex(__func__, lb_len); int i = 0; - for (ID *id = lb->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lb) { if (id->lib == NULL) { id_array[i] = id; i++; @@ -2218,14 +2218,14 @@ void BKE_id_ordered_list(ListBase *ordered_lb, const ListBase *lb) { BLI_listbase_clear(ordered_lb); - for (ID *id = lb->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lb) { BLI_addtail(ordered_lb, BLI_genericNodeN(id)); } BLI_listbase_sort(ordered_lb, id_order_compare); int num = 0; - for (LinkData *link = ordered_lb->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, ordered_lb) { int *order = id_order_get(link->data); if (order) { *order = num++; @@ -2250,7 +2250,7 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after) if (after) { /* Insert after. */ - for (ID *other = lb->first; other; other = other->next) { + LISTBASE_FOREACH (ID *, other, lb) { int *order = id_order_get(other); if (*order > relative_order) { (*order)++; @@ -2261,7 +2261,7 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after) } else { /* Insert before. */ - for (ID *other = lb->first; other; other = other->next) { + LISTBASE_FOREACH (ID *, other, lb) { int *order = id_order_get(other); if (*order < relative_order) { (*order)--; diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 42d1806a41a..5b75b8ac181 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -153,7 +153,7 @@ void BKE_lib_override_library_clear(IDOverrideLibrary *override, const bool do_i BLI_ghash_clear(override->runtime, NULL, NULL); } - for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { lib_override_library_property_clear(op); } BLI_freelistN(&override->properties); @@ -371,7 +371,7 @@ void lib_override_library_property_clear(IDOverrideLibraryProperty *op) MEM_freeN(op->rna_path); - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { lib_override_library_property_operation_clear(opop); } BLI_freelistN(&op->operations); diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 21d7bb137fc..9c0fa33157c 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -182,7 +182,7 @@ static void library_foreach_idproperty_ID_link(LibraryForeachIDData *data, switch (prop->type) { case IDP_GROUP: { - for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) { + LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { library_foreach_idproperty_ID_link(data, loop, flag); } break; @@ -338,7 +338,7 @@ static void library_foreach_bone(LibraryForeachIDData *data, Bone *bone) { library_foreach_idproperty_ID_link(data, bone->prop, IDWALK_CB_USER); - for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) { + LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) { library_foreach_bone(data, curbone); } @@ -347,7 +347,7 @@ static void library_foreach_bone(LibraryForeachIDData *data, Bone *bone) static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb) { - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad * anyway... */ const int cb_flag = (lc->collection != NULL && @@ -365,13 +365,13 @@ static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBas */ static void library_foreach_collection(LibraryForeachIDData *data, Collection *collection) { - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { FOREACH_CALLBACK_INVOKE(data, cob->ob, IDWALK_CB_USER); } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { FOREACH_CALLBACK_INVOKE(data, child->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_USER); } - for (CollectionParent *parent = collection->parents.first; parent; parent = parent->next) { + LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad * anyway... */ const int cb_flag = ((parent->collection != NULL && @@ -399,7 +399,7 @@ static void library_foreach_screen_area(LibraryForeachIDData *data, ScrArea *are { FOREACH_CALLBACK_INVOKE(data, area->full, IDWALK_CB_NOP); - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_VIEW3D: { View3D *v3d = (View3D *)sl; @@ -678,7 +678,7 @@ static void library_foreach_ID_link(Main *bmain, CALLBACK_INVOKE(seq->mask, IDWALK_CB_USER); CALLBACK_INVOKE(seq->sound, IDWALK_CB_USER); library_foreach_idproperty_ID_link(&data, seq->prop, IDWALK_CB_USER); - for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) { + LISTBASE_FOREACH (SequenceModifierData *, smd, &seq->modifiers) { CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER); } @@ -699,21 +699,19 @@ static void library_foreach_ID_link(Main *bmain, for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { CALLBACK_INVOKE(view_layer->mat_override, IDWALK_CB_USER); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { CALLBACK_INVOKE(base->object, IDWALK_CB_NOP); } library_foreach_layer_collection(&data, &view_layer->layer_collections); - for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; - fmc = fmc->next) { + LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) { if (fmc->script) { CALLBACK_INVOKE(fmc->script, IDWALK_CB_NOP); } } - for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; - fls = fls->next) { + LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { if (fls->group) { CALLBACK_INVOKE(fls->group, IDWALK_CB_USER); } @@ -724,7 +722,7 @@ static void library_foreach_ID_link(Main *bmain, } } - for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) { CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP); } @@ -881,7 +879,7 @@ static void library_foreach_ID_link(Main *bmain, case ID_AR: { bArmature *arm = (bArmature *)id; - for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { library_foreach_bone(&data, bone); } break; @@ -968,7 +966,7 @@ static void library_foreach_ID_link(Main *bmain, case ID_CA: { Camera *camera = (Camera *)id; CALLBACK_INVOKE(camera->dof.focus_object, IDWALK_CB_NOP); - for (CameraBGImage *bgpic = camera->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &camera->bg_images) { if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { CALLBACK_INVOKE(bgpic->ima, IDWALK_CB_USER); } @@ -1100,7 +1098,7 @@ static void library_foreach_ID_link(Main *bmain, } } - for (ParticleDupliWeight *dw = psett->instance_weights.first; dw; dw = dw->next) { + LISTBASE_FOREACH (ParticleDupliWeight *, dw, &psett->instance_weights) { CALLBACK_INVOKE(dw->ob, IDWALK_CB_NOP); } break; @@ -1195,7 +1193,7 @@ static void library_foreach_ID_link(Main *bmain, case ID_AC: { bAction *act = (bAction *)id; - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP); } break; @@ -1204,7 +1202,7 @@ static void library_foreach_ID_link(Main *bmain, case ID_WM: { wmWindowManager *wm = (wmWindowManager *)id; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { CALLBACK_INVOKE(win->scene, IDWALK_CB_USER_ONE); /* This pointer can be NULL during old files reading, better be safe than sorry. */ @@ -1215,7 +1213,7 @@ static void library_foreach_ID_link(Main *bmain, BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace); } if (data.flag & IDWALK_INCLUDE_UI) { - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { library_foreach_screen_area(&data, area); } } @@ -1227,7 +1225,7 @@ static void library_foreach_ID_link(Main *bmain, WorkSpace *workspace = (WorkSpace *)id; ListBase *layouts = BKE_workspace_layouts_get(workspace); - for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) { bScreen *screen = BKE_workspace_layout_screen_get(layout); /* CALLBACK_INVOKE expects an actual pointer, not a variable holding the pointer. @@ -1280,7 +1278,7 @@ static void library_foreach_ID_link(Main *bmain, if (data.flag & IDWALK_INCLUDE_UI) { bScreen *screen = (bScreen *)id; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { library_foreach_screen_area(&data, area); } } @@ -1710,7 +1708,7 @@ void BKE_library_indirectly_used_data_tag_clear(Main *bmain) do_loop = false; while (i--) { - for (ID *id = lb_array[i]->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lb_array[i]) { if (id->lib == NULL || id->tag & LIB_TAG_DOIT) { /* Local or non-indirectly-used ID (so far), no need to check it further. */ continue; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index bcf4b29ec07..5516e877b10 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1121,7 +1121,7 @@ static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree, ForEachTexNodeCallback callback, void *userdata) { - for (bNode *node = nodetree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { if (!callback(node, userdata)) { diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 79e70ad2741..4294d279c36 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -430,9 +430,8 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis) BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.'); - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if ((ob->type == OB_MBALL) && !(base->flag & BASE_FROM_DUPLI)) { if (ob != bob) { @@ -463,7 +462,7 @@ bool BKE_mball_minmax_ex( INIT_MINMAX(min, max); - for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) { if ((ml->flag & flag) == flag) { const float scale_mb = (ml->rad * 0.5f) * scale; int i; @@ -493,7 +492,7 @@ bool BKE_mball_minmax(const MetaBall *mb, float min[3], float max[3]) { INIT_MINMAX(min, max); - for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) { minmax_v3v3_v3(min, max, &ml->x); } @@ -506,7 +505,7 @@ bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3]) zero_v3(r_cent); - for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) { add_v3_v3(r_cent, &ml->x); total++; } @@ -538,7 +537,7 @@ void BKE_mball_transform(MetaBall *mb, const float mat[4][4], const bool do_prop mat4_to_quat(quat, mat); - for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) { mul_m4_v3(mat, &ml->x); mul_qt_qtqt(ml->quat, quat, ml->quat); @@ -558,7 +557,7 @@ void BKE_mball_transform(MetaBall *mb, const float mat[4][4], const bool do_prop void BKE_mball_translate(MetaBall *mb, const float offset[3]) { - for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) { add_v3_v3(&ml->x, offset); } } @@ -567,7 +566,7 @@ void BKE_mball_translate(MetaBall *mb, const float offset[3]) int BKE_mball_select_count(const MetaBall *mb) { int sel = 0; - for (const MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (const MetaElem *, ml, mb->editelems) { if (ml->flag & SELECT) { sel++; } @@ -589,7 +588,7 @@ int BKE_mball_select_count_multi(Base **bases, int bases_len) bool BKE_mball_select_all(MetaBall *mb) { bool changed = false; - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { if ((ml->flag & SELECT) == 0) { ml->flag |= SELECT; changed = true; @@ -612,7 +611,7 @@ bool BKE_mball_select_all_multi_ex(Base **bases, int bases_len) bool BKE_mball_deselect_all(MetaBall *mb) { bool changed = false; - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { if ((ml->flag & SELECT) != 0) { ml->flag &= ~SELECT; changed = true; @@ -636,7 +635,7 @@ bool BKE_mball_deselect_all_multi_ex(Base **bases, int bases_len) bool BKE_mball_select_swap(MetaBall *mb) { bool changed = false; - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { ml->flag ^= SELECT; changed = true; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 98a7673c9d5..c3c538f3424 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -113,7 +113,7 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c /* Since source nodes and sockets are unique pointers we can put everything in a single map. */ GHash *new_pointers = BLI_ghash_ptr_new(__func__); - for (const bNode *node_src = ntree_src->nodes.first; node_src; node_src = node_src->next) { + LISTBASE_FOREACH (const bNode *, node_src, &ntree_src->nodes) { bNode *new_node = BKE_node_copy_ex(ntree_dst, node_src, flag_subdata, true); BLI_ghash_insert(new_pointers, (void *)node_src, new_node); /* Store mapping to inputs. */ @@ -1634,7 +1634,7 @@ void nodePositionRelative(bNode *from_node, void nodePositionPropagate(bNode *node) { - for (bNodeSocket *nsock = node->inputs.first; nsock; nsock = nsock->next) { + LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) { if (nsock->link != NULL) { bNodeLink *link = nsock->link; nodePositionRelative(link->fromnode, link->tonode, link->fromsock, link->tosock); @@ -2662,7 +2662,7 @@ void ntreeInterfaceTypeUpdate(bNodeTree *ntree) bNode *ntreeFindType(const bNodeTree *ntree, int type) { if (ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == type) { return node; } @@ -3396,7 +3396,7 @@ void ntreeUpdateAllNew(Main *main) * might have been set in file reading or versioning. */ FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { if (owner_id->tag & LIB_TAG_NEW) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->typeinfo->group_update_func) { node->typeinfo->group_update_func(ntree, node); } @@ -3414,7 +3414,7 @@ void ntreeUpdateAllUsers(Main *main, ID *ngroup) FOREACH_NODETREE_BEGIN (main, ntree, owner_id) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->id == ngroup) { if (node->typeinfo->group_update_func) { node->typeinfo->group_update_func(ntree, node); @@ -4245,7 +4245,7 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter, void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer_index) { BLI_assert(layer_index != -1); - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) { if (node->custom1 == layer_index) { node->custom1 = 0; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 87ac4428594..587dd5be2f2 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -479,7 +479,7 @@ void psys_find_group_weights(ParticleSettings *part) instance_collection_objects = BKE_collection_object_cache_get(part->instance_collection); } - for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { + LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { if (dw->ob == NULL) { Base *base = BLI_findlink(&instance_collection_objects, dw->index); if (base != NULL) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b1cff53d399..78e7dec9f38 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1839,7 +1839,7 @@ PTCacheID BKE_ptcache_id_find(Object *ob, Scene *scene, PointCache *cache) ListBase pidlist; BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) { + LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) { if (pid->cache == cache) { result = *pid; break; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8cbc1ba4d8e..20f7add0c74 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -669,10 +669,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) if (type == SCE_COPY_FULL) { /* Copy Freestyle LineStyle datablocks. */ - for (ViewLayer *view_layer_dst = sce_copy->view_layers.first; view_layer_dst; - view_layer_dst = view_layer_dst->next) { - for (FreestyleLineSet *lineset = view_layer_dst->freestyle_config.linesets.first; lineset; - lineset = lineset->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) { + LISTBASE_FOREACH ( + FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) { if (lineset->linestyle) { id_us_min(&lineset->linestyle->id); BKE_id_copy_ex( @@ -732,8 +731,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name) */ bool BKE_scene_object_find(Scene *scene, Object *ob) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (BLI_findptr(&view_layer->object_bases, ob, offsetof(Base, object))) { return true; } @@ -743,9 +741,8 @@ bool BKE_scene_object_find(Scene *scene, Object *ob) Object *BKE_scene_object_find_by_name(const Scene *scene, const char *name) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (STREQ(base->object->id.name + 2, name)) { return base->object; } @@ -773,9 +770,8 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) } /* copy layers and flags from bases to objects */ - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { ob = base->object; /* collection patch... */ BKE_scene_object_base_flag_sync_from_base(base); @@ -929,7 +925,7 @@ int BKE_scene_base_iter_next( Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection) { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - for (ViewLayer *layer = scene->view_layers.first; layer; layer = layer->next) { + LISTBASE_FOREACH (ViewLayer *, layer, &scene->view_layers) { if (BKE_view_layer_has_collection(layer, collection)) { return scene; } @@ -955,7 +951,7 @@ Object *BKE_scene_camera_switch_find(Scene *scene) Object *camera = NULL; Object *first_camera = NULL; - for (TimeMarker *m = scene->markers.first; m; m = m->next) { + LISTBASE_FOREACH (TimeMarker *, m, &scene->markers) { if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0) { if ((m->frame <= cfra) && (m->frame > frame)) { camera = m->camera; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 37ea6c2cb4d..38bd0211d15 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -724,7 +724,7 @@ void BKE_screen_remove_unused_scrverts(bScreen *screen) ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type) { if (area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == region_type) { return region; } @@ -771,7 +771,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y) { ARegion *region_found = NULL; - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { region_found = region; @@ -828,7 +828,7 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, int x, int y) { - for (ScrArea *area = areamap->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) { if (BLI_rcti_isect_pt(&area->totrct, x, y)) { if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { return area; @@ -915,8 +915,8 @@ bool BKE_screen_is_used(const bScreen *screen) void BKE_screen_header_alignment_reset(bScreen *screen) { int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) { region->alignment = RGN_ALIGN_TOP; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c471a6d254c..6acc50f30e9 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -3166,7 +3166,6 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for /* XXX - new in 2.5x. should we use the animation system this way? * The fcurve is needed because many frames need evaluating at once - campbell */ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); - if (!v->frameMap || v->length != seq->len) { if (v->frameMap) { MEM_freeN(v->frameMap); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 996a9f34b61..0e558db57cb 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1459,7 +1459,7 @@ static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfr memset(seq_arr, 0, sizeof(Sequence *) * (MAXSEQ + 1)); - for (Sequence *seq = seqbase->first; seq; seq = seq->next) { + LISTBASE_FOREACH (Sequence *, seq, seqbase) { if ((seq->startdisp <= cfra) && (seq->enddisp > cfra)) { if ((seq->type & SEQ_TYPE_EFFECT) && !(seq->flag & SEQ_MUTE)) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 94c41777cea..3cdf3b40ce3 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -164,7 +164,7 @@ static void text_copy_data(Main *UNUSED(bmain), text_dst->compiled = NULL; /* Walk down, reconstructing. */ - for (TextLine *line_src = text_src->lines.first; line_src; line_src = line_src->next) { + LISTBASE_FOREACH (TextLine *, line_src, &text_src->lines) { TextLine *line_dst = MEM_mallocN(sizeof(*line_dst), __func__); line_dst->line = BLI_strdup(line_src->line); @@ -1311,12 +1311,12 @@ void txt_sel_set(Text *text, int startl, int startc, int endl, int endc) char *txt_to_buf_for_undo(Text *text, int *r_buf_len) { int buf_len = 0; - for (const TextLine *l = text->lines.first; l; l = l->next) { + LISTBASE_FOREACH (const TextLine *, l, &text->lines) { buf_len += l->len + 1; } char *buf = MEM_mallocN(buf_len, __func__); char *buf_step = buf; - for (const TextLine *l = text->lines.first; l; l = l->next) { + LISTBASE_FOREACH (const TextLine *, l, &text->lines) { memcpy(buf_step, l->line, l->len); buf_step += l->len; *buf_step++ = '\n'; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index fd85e5ca212..fe10861f96e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -697,7 +697,7 @@ static void texture_nodes_fetch_images_for_pool(Tex *texture, bNodeTree *ntree, struct ImagePool *pool) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_IMAGE && node->id != NULL) { Image *image = (Image *)node->id; BKE_image_pool_acquire_ibuf(image, &texture->iuser, pool); diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c index 5c1f6caad9d..46870a03e62 100644 --- a/source/blender/blenkernel/intern/tracking_solver.c +++ b/source/blender/blenkernel/intern/tracking_solver.c @@ -600,7 +600,7 @@ static void tracking_scale_reconstruction(ListBase *tracksbase, sub_v3_v3(camera->mat[3], first_camera_delta); } - for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) { + LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) { if (track->flag & TRACK_HAS_BUNDLE) { mul_v3_v3(track->bundle_pos, scale); sub_v3_v3(track->bundle_pos, first_camera_delta); diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 847522a0a66..e776e9bedb0 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -110,7 +110,7 @@ static ListBase g_undo_types = {NULL, NULL}; static const UndoType *BKE_undosys_type_from_context(bContext *C) { - for (const UndoType *ut = g_undo_types.first; ut; ut = ut->next) { + LISTBASE_FOREACH (const UndoType *, ut, &g_undo_types) { /* No poll means we don't check context. */ if (ut->poll && ut->poll(C)) { return ut; @@ -143,7 +143,7 @@ static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref) * for now it's not too bad since it only runs when we access undo! */ Main *bmain = user_data; ListBase *lb = which_libbase(bmain, GS(id_ref->name)); - for (ID *id = lb->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lb) { if (STREQ(id_ref->name, id->name) && (id->lib == NULL)) { id_ref->ptr = id; break; @@ -857,7 +857,7 @@ static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)) { - for (UndoStep *us = ustack->steps.first; us; us = us->next) { + LISTBASE_FOREACH (UndoStep *, us, &ustack->steps) { const UndoType *ut = us->type; if (ut->step_foreach_ID_ref != NULL) { ut->step_foreach_ID_ref(us, foreach_ID_ref_fn, user_data); @@ -876,7 +876,7 @@ void BKE_undosys_print(UndoStack *ustack) printf("Undo %d Steps (*: active, #=applied, M=memfile-active, S=skip)\n", BLI_listbase_count(&ustack->steps)); int index = 0; - for (UndoStep *us = ustack->steps.first; us; us = us->next) { + LISTBASE_FOREACH (UndoStep *, us, &ustack->steps) { printf("[%c%c%c%c] %3d {%p} type='%s', name='%s'\n", (us == ustack->step_active) ? '*' : ' ', us->is_applied ? '#' : ' ', diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index 66a3c2cdced..c65d55785c1 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -396,7 +396,7 @@ void BKE_workspace_id_tag_all_visible(Main *bmain, int tag) { BKE_main_id_tag_listbase(&bmain->workspaces, tag, false); wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); workspace->id.tag |= tag; } diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c index c87dbee0f0e..85fbe7ece0f 100644 --- a/source/blender/blenlib/intern/array_store.c +++ b/source/blender/blenlib/intern/array_store.c @@ -406,7 +406,7 @@ static void bchunk_list_decref(BArrayMemory *bs_mem, BChunkList *chunk_list) static size_t bchunk_list_data_check(const BChunkList *chunk_list, const uchar *data) { size_t offset = 0; - for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) { if (memcmp(&data[offset], cref->link->data, cref->link->data_len) != 0) { return false; } @@ -1511,7 +1511,7 @@ void BLI_array_store_clear(BArrayStore *bs) size_t BLI_array_store_calc_size_expanded_get(const BArrayStore *bs) { size_t size_accum = 0; - for (const BArrayState *state = bs->states.first; state; state = state->next) { + LISTBASE_FOREACH (const BArrayState *, state, &bs->states) { size_accum += state->chunk_list->total_size; } return size_accum; @@ -1632,14 +1632,14 @@ void BLI_array_store_state_data_get(BArrayState *state, void *data) { #ifdef USE_PARANOID_CHECKS size_t data_test_len = 0; - for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) { data_test_len += cref->link->data_len; } BLI_assert(data_test_len == state->chunk_list->total_size); #endif uchar *data_step = (uchar *)data; - for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) { BLI_assert(cref->link->users > 0); memcpy(data_step, cref->link->data, cref->link->data_len); data_step += cref->link->data_len; @@ -1666,7 +1666,7 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le static size_t bchunk_list_size(const BChunkList *chunk_list) { size_t total_size = 0; - for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) { total_size += cref->link->data_len; } return total_size; @@ -1679,7 +1679,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs) /* Check Length * ------------ */ - for (BArrayState *state = bs->states.first; state; state = state->next) { + LISTBASE_FOREACH (BArrayState *, state, &bs->states) { BChunkList *chunk_list = state->chunk_list; if (!(bchunk_list_size(chunk_list) == chunk_list->total_size)) { return false; @@ -1692,7 +1692,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs) #ifdef USE_MERGE_CHUNKS /* ensure we merge all chunks that could be merged */ if (chunk_list->total_size > bs->info.chunk_byte_size_min) { - for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) { if (cref->link->data_len < bs->info.chunk_byte_size_min) { return false; } @@ -1734,7 +1734,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs) GHash *chunk_map = BLI_ghash_ptr_new(__func__); int totrefs = 0; - for (BArrayState *state = bs->states.first; state; state = state->next) { + LISTBASE_FOREACH (BArrayState *, state, &bs->states) { GHASH_PTR_ADD_USER(chunk_list_map, state->chunk_list); } GHASH_ITER (gh_iter, chunk_list_map) { @@ -1753,7 +1753,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs) /* count chunk's */ GHASH_ITER (gh_iter, chunk_list_map) { const struct BChunkList *chunk_list = BLI_ghashIterator_getKey(&gh_iter); - for (const BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) { + LISTBASE_FOREACH (const BChunkRef *, cref, &chunk_list->chunk_refs) { GHASH_PTR_ADD_USER(chunk_map, cref->link); totrefs += 1; } diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 0a574ea34ca..31e8581590a 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -93,11 +93,9 @@ static TaskScheduler *task_scheduler = NULL; * for (go over all jobs) * if (job is ready) { * if (job was not removed) { - * BLI_threadpool_remove(&lb, job); - * } + * BLI_threadpool_remove(&lb, job); * } * } - * else cont = 1; - * } + * else cont = 1; * } * // conditions to exit loop * if (if escape loop event) { * if (BLI_available_threadslots(&lb) == maxthreads) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 259602ecec6..84af4d1a3d4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2670,7 +2670,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd) } case IDP_GROUP: /* PointerProperty */ { - for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) { + LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { IDP_LibLinkProperty(loop, fd); } break; @@ -3030,7 +3030,7 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf) // XXX deprecated - old animation system static void lib_link_ipo(FileData *fd, Main *UNUSED(bmain), Ipo *ipo) { - for (IpoCurve *icu = ipo->curve.first; icu; icu = icu->next) { + LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { if (icu->driver) { icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob); } @@ -3251,7 +3251,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list) static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act) { // XXX deprecated - old animation system <<< - for (bActionChannel *chan = act->chanbase.first; chan; chan = chan->next) { + LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) { chan->ipo = newlibadr(fd, act->id.lib, chan->ipo); lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels); } @@ -3259,7 +3259,7 @@ static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act) lib_link_fcurves(fd, &act->id, &act->curves); - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if (marker->camera) { marker->camera = newlibadr(fd, act->id.lib, marker->camera); } @@ -3515,8 +3515,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main link_list(fd, &workspace->owner_ids); link_list(fd, &workspace->tools); - for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; relation; - relation = relation->next) { + LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) { /* data from window - need to access through global oldnew-map */ relation->parent = newglobadr(fd, relation->parent); @@ -3527,7 +3526,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data * when reading windows, so have to update windows after/when reading workspaces. */ for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpaceLayout *act_layout = newdataadr( fd, BKE_workspace_active_layout_get(win->workspace_hook)); if (act_layout) { @@ -3536,7 +3535,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main } } - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { tref->runtime = NULL; tref->properties = newdataadr(fd, tref->properties); IDP_DirectLinkGroup_OrFree(&tref->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); @@ -3564,25 +3563,25 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) ntree->gpd = newlibadr(fd, lib, ntree->gpd); - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ IDP_LibLinkProperty(node->prop, fd); node->id = newlibadr(fd, lib, node->id); - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { IDP_LibLinkProperty(sock->prop, fd); } - for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) { IDP_LibLinkProperty(sock->prop, fd); } } - for (bNodeSocket *sock = ntree->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) { IDP_LibLinkProperty(sock->prop, fd); } - for (bNodeSocket *sock = ntree->outputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) { IDP_LibLinkProperty(sock->prop, fd); } @@ -3595,7 +3594,7 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) /* For nodes with static socket layout, add/remove sockets as needed * to match the static layout. */ if (fd->memfile == NULL) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { node_verify_socket_templates(ntree, node); } } @@ -3929,7 +3928,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) } } - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { lib_link_constraints(fd, (ID *)ob, &pchan->constraints); pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); @@ -3958,14 +3957,14 @@ static void lib_link_bones(FileData *fd, Bone *bone) { IDP_LibLinkProperty(bone->prop, fd); - for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) { + LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) { lib_link_bones(fd, curbone); } } static void lib_link_armature(FileData *fd, Main *UNUSED(bmain), bArmature *arm) { - for (Bone *curbone = arm->bonebase.first; curbone; curbone = curbone->next) { + LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) { lib_link_bones(fd, curbone); } } @@ -4026,7 +4025,7 @@ static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca) ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */ ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object); - for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) { bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima); bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip); } @@ -4039,7 +4038,7 @@ static void direct_link_camera(FileData *fd, Camera *ca) link_list(fd, &ca->bg_images); - for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) { bgpic->iuser.ok = 1; bgpic->iuser.scene = NULL; } @@ -4614,7 +4613,7 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl } if (part->instance_weights.first && part->instance_collection) { - for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { + LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { dw->ob = newlibadr(fd, part->id.lib, dw->ob); } } @@ -5259,7 +5258,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) lib_link_nlastrips(fd, &ob->id, &ob->nlastrips); // >>> XXX deprecated - old animation system - for (PartEff *paf = ob->effect.first; paf; paf = paf->next) { + LISTBASE_FOREACH (PartEff *, paf, &ob->effect) { if (paf->type == EFF_PARTICLE) { paf->group = newlibadr(fd, ob->id.lib, paf->group); } @@ -6204,7 +6203,7 @@ static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *vi static void direct_link_layer_collections(FileData *fd, ListBase *lb, bool master) { link_list(fd, lb); - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { #ifdef USE_COLLECTION_COMPAT_28 lc->scene_collection = newdataadr(fd, lc->scene_collection); #endif @@ -6257,12 +6256,11 @@ static void lib_link_layer_collection(FileData *fd, static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer) { - for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; - fmc = fmc->next) { + LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) { fmc->script = newlibadr(fd, lib, fmc->script); } - for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) { + LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { fls->linestyle = newlibadr(fd, lib, fls->linestyle); fls->group = newlibadr(fd, lib, fls->group); } @@ -6305,19 +6303,19 @@ static void direct_link_scene_collection(FileData *fd, SceneCollection *sc) link_list(fd, &sc->objects); link_list(fd, &sc->scene_collections); - for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { + LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) { direct_link_scene_collection(fd, nsc); } } static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc) { - for (LinkData *link = sc->objects.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &sc->objects) { link->data = newlibadr(fd, lib, link->data); BLI_assert(link->data); } - for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { + LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) { lib_link_scene_collection(fd, lib, nsc); } } @@ -6625,7 +6623,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) } SEQ_END; - for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) { if (marker->camera) { marker->camera = newlibadr(fd, sce->id.lib, marker->camera); } @@ -6649,12 +6647,12 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) composite_patch(sce->nodetree, sce); } - for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { + LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) { srl->mat_override = newlibadr(fd, sce->id.lib, srl->mat_override); - for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { + LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) { fmc->script = newlibadr(fd, sce->id.lib, fmc->script); } - for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { + LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) { fls->linestyle = newlibadr(fd, sce->id.lib, fls->linestyle); fls->group = newlibadr(fd, sce->id.lib, fls->group); } @@ -6668,7 +6666,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) } #endif - for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { lib_link_view_layer(fd, sce->id.lib, view_layer); } @@ -7199,7 +7197,7 @@ static void direct_link_panel_list(FileData *fd, ListBase *lb) { link_list(fd, lb); - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { pa->runtime_flag = 0; pa->activedata = NULL; pa->type = NULL; @@ -7524,7 +7522,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) memset(&area->runtime, 0x0, sizeof(area->runtime)); - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_VIEW3D: { View3D *v3d = (View3D *)sl; @@ -7701,12 +7699,12 @@ static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map) link_list(fd, &area_map->vertbase); link_list(fd, &area_map->edgebase); link_list(fd, &area_map->areabase); - for (ScrArea *area = area_map->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) { direct_link_area(fd, area); } /* edges */ - for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) { + LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) { se->v1 = newdataadr(fd, se->v1); se->v2 = newdataadr(fd, se->v2); BKE_screen_sort_scrvert(&se->v1, &se->v2); @@ -7823,7 +7821,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowManager *wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->workspace_hook) { /* NULL for old files */ lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id); } @@ -7831,7 +7829,7 @@ static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowMa /* deprecated, but needed for versioning (will be NULL'ed then) */ win->screen = newlibadr(fd, NULL, win->screen); - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { lib_link_area(fd, &wm->id, area); } @@ -7856,7 +7854,7 @@ static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *screen) screen->tool_tip = NULL; screen->scrubbing = false; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { lib_link_area(fd, &screen->id, area); } } @@ -8010,8 +8008,8 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View { bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -8039,7 +8037,7 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View /* Regionbase storage is different depending if the space is active. */ ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; if (rv3d->localvd) { @@ -8063,8 +8061,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, /* avoid conflicts with 2.8x branch */ { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; ARegion *region; @@ -8303,12 +8301,12 @@ void blo_lib_link_restore(Main *oldmain, workspace = workspace->id.next) { ListBase *layouts = BKE_workspace_layouts_get(workspace); - for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) { lib_link_workspace_layout_restore(id_map, newmain, layout); } } - for (wmWindow *win = curwm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &curwm->windows) { WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); ID *workspace_id = (ID *)workspace; Scene *oldscene = win->scene; @@ -8686,7 +8684,7 @@ static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *cli lib_link_movieTracks(fd, clip, &tracking->tracks); lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks); - for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) { + LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) { lib_link_movieTracks(fd, clip, &object->tracks); lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks); } @@ -8763,7 +8761,7 @@ static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent) static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask) { - for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) { MaskSpline *spline; spline = masklay->splines.first; @@ -10119,14 +10117,14 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) } } - for (wmKeyConfigPref *kpt = user->user_keyconfig_prefs.first; kpt; kpt = kpt->next) { + LISTBASE_FOREACH (wmKeyConfigPref *, kpt, &user->user_keyconfig_prefs) { kpt->prop = newdataadr(fd, kpt->prop); IDP_DirectLinkGroup_OrFree(&kpt->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } - for (bUserMenu *um = user->user_menus.first; um; um = um->next) { + LISTBASE_FOREACH (bUserMenu *, um, &user->user_menus) { link_list(fd, &um->items); - for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) { if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; umi_op->prop = newdataadr(fd, umi_op->prop); @@ -10288,7 +10286,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ blo_split_main(&mainlist, bfd->main); - for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { + LISTBASE_FOREACH (Main *, mainvar, &mainlist) { BLI_assert(mainvar->versionfile != 0); do_versions_after_linking(mainvar, fd->reports); } @@ -10706,7 +10704,7 @@ static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop) break; } case IDP_GROUP: - for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) { + LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { expand_idprops(fd, mainvar, loop); } break; @@ -10766,7 +10764,7 @@ static void expand_action(FileData *fd, Main *mainvar, bAction *act) /* F-Curves in Action */ expand_fcurves(fd, mainvar, &act->curves); - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if (marker->camera) { expand_doit(fd, mainvar, marker->camera); } @@ -10834,18 +10832,18 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting } } - for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { + LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { expand_doit(fd, mainvar, dw->ob); } } static void expand_collection(FileData *fd, Main *mainvar, Collection *collection) { - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { expand_doit(fd, mainvar, cob->ob); } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { expand_doit(fd, mainvar, child->collection); } @@ -11030,14 +11028,14 @@ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone) { expand_idprops(fd, mainvar, bone->prop); - for (Bone *curBone = bone->childbase.first; curBone; curBone = curBone->next) { + LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) { expand_bones(fd, mainvar, curBone); } } static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm) { - for (Bone *curBone = arm->bonebase.first; curBone; curBone = curBone->next) { + LISTBASE_FOREACH (Bone *, curBone, &arm->bonebase) { expand_bones(fd, mainvar, curBone); } } @@ -11175,11 +11173,11 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) #ifdef USE_COLLECTION_COMPAT_28 static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc) { - for (LinkData *link = sc->objects.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &sc->objects) { expand_doit(fd, mainvar, link->data); } - for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { + LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) { expand_scene_collection(fd, mainvar, nsc); } } @@ -11191,7 +11189,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) FreestyleModuleConfig *module; FreestyleLineSet *lineset; - for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) { + LISTBASE_FOREACH (Base *, base_legacy, &sce->base) { expand_doit(fd, mainvar, base_legacy->object); } expand_doit(fd, mainvar, sce->camera); @@ -11218,7 +11216,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) } } - for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { expand_idprops(fd, mainvar, view_layer->id_properties); for (module = view_layer->freestyle_config.modules.first; module; module = module->next) { @@ -11274,7 +11272,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) expand_doit(fd, mainvar, sce->rigidbody_world->constraints); } - for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) { if (marker->camera) { expand_doit(fd, mainvar, marker->camera); } @@ -11297,7 +11295,7 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) { expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system - for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) { if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { expand_doit(fd, mainvar, bgpic->ima); } @@ -11403,7 +11401,7 @@ static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace) { ListBase *layouts = BKE_workspace_layouts_get(workspace); - for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) { expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout)); } } @@ -12145,7 +12143,7 @@ static int has_linked_ids_to_read(Main *mainvar) int a = set_listbasepointers(mainvar, lbarray); while (a--) { - for (ID *id = lbarray[a]->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lbarray[a]) { if ((id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) && !(id->flag & LIB_INDIRECT_WEAK_LINK)) { return true; } diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index 69c4ba2b1f2..d8780409e93 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -95,7 +95,7 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) /* Clear is_identical_future before adding next memfile. */ void BLO_memfile_clear_future(MemFile *memfile) { - for (MemFileChunk *chunk = memfile->chunks.first; chunk; chunk = chunk->next) { + LISTBASE_FOREACH (MemFileChunk *, chunk, &memfile->chunks) { chunk->is_identical_future = false; } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index f1f7b4cf353..98d2acbd938 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -258,7 +258,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase) static void do_version_bones_super_bbone(ListBase *lb) { - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { bone->scale_in_x = bone->scale_in_y = 1.0f; bone->scale_out_x = bone->scale_out_y = 1.0f; @@ -343,7 +343,7 @@ static void do_versions_compositor_render_passes_storage(bNode *node) static void do_versions_compositor_render_passes(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == CMP_NODE_R_LAYERS) { /* First we make sure existing sockets have proper names. * This is important because otherwise verification will @@ -392,7 +392,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), /* Driver -> Driver Vars (for bbone_in/out) */ if (fcu->driver) { - for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) { + LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) { DRIVER_TARGETS_LOOPER_BEGIN (dvar) { if (dtar->rna_path) { dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path); @@ -404,7 +404,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), /* FModifiers -> Stepped (for frame_start/end) */ if (fcu->modifiers.first) { - for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { + LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) { if (fcm->type == FMODIFIER_TYPE_STEPPED) { FMod_Stepped *data = fcm->data; @@ -1153,7 +1153,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) * otherwise they could collide with any new persistent flag we may add in the future. */ a = set_listbasepointers(bmain, lbarray); while (a--) { - for (ID *id = lbarray[a]->first; id; id = id->next) { + LISTBASE_FOREACH (ID *, id, lbarray[a]) { id->flag &= LIB_FAKEUSER; } } @@ -1177,15 +1177,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; /* Bug: Was possible to add preview region to sequencer view by using AZones. */ if (sl->spacetype == SPACE_SEQ) { SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->view == SEQ_VIEW_SEQUENCE) { - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { /* remove preview region for sequencer-only view! */ if (region->regiontype == RGN_TYPE_PREVIEW) { region->flag |= RGN_FLAG_HIDDEN; @@ -1197,7 +1197,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* Remove old deprecated region from filebrowsers */ else if (sl->spacetype == SPACE_FILE) { - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->regiontype == RGN_TYPE_CHANNELS) { /* Free old deprecated 'channel' region... */ BKE_area_region_free(NULL, region); @@ -1245,9 +1245,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Adding "Properties" region to DopeSheet */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { /* handle pushed-back space data first */ - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; do_version_action_editor_properties_region(&saction->regionbase); @@ -1271,7 +1271,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { if (ob->pose) { - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { /* see do_version_bones_super_bbone()... */ pchan->scale_in_x = pchan->scale_in_y = 1.0f; pchan->scale_out_x = pchan->scale_out_y = 1.0f; @@ -1561,8 +1561,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) { /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */ for (Mask *mask = bmain->masks.first; mask; mask = mask->id.next) { - for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) { - for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) { + LISTBASE_FOREACH (MaskLayer *, mlayer, &mask->masklayers) { + LISTBASE_FOREACH (MaskSpline *, mspline, &mlayer->splines) { int i = 0; for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) { @@ -1579,7 +1579,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { ntreeSetTypes(NULL, ntree); - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == CMP_NODE_GLARE) { NodeGlare *ndg = node->storage; switch (ndg->type) { @@ -1601,7 +1601,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_SurfaceDeform) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; unit_m4(smd->mat); @@ -1652,7 +1652,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) { /* Fix for invalid state of screen due to bug in older versions. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->full && screen->state == SCREENNORMAL) { area->full = NULL; } @@ -1683,7 +1683,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) * Must set previous defaults. */ if (!DNA_struct_elem_find(fd->filesdna, "SimpleDeformModifierData", "char", "deform_axis")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_SimpleDeform) { SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; smd->deform_axis = 2; @@ -1712,7 +1712,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_ParticleInstance) { ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; pimd->space = eParticleInstanceSpace_World; @@ -1731,7 +1731,7 @@ void do_versions_after_linking_270(Main *bmain) FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { ntreeSetTypes(NULL, ntree); - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == CMP_NODE_HUE_SAT) { do_version_hue_sat_node(ntree, node); } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3821b2ad48a..ff87756f436 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -116,7 +116,7 @@ static bScreen *screen_parent_find(const bScreen *screen) /* Can avoid lookup if screen state isn't maximized/full * (parent and child store the same state). */ if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) { - for (const ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) { if (area->full && area->full != screen) { BLI_assert(area->full->state == screen->state); return area->full; @@ -159,7 +159,7 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc ARegion *region_channels; /* Properly free current regions */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { BKE_area_region_free(area->type, region); } BLI_freelistN(&area->regionbase); @@ -199,7 +199,7 @@ static void do_version_workspaces_after_lib_link(Main *bmain) do_version_workspaces_create_from_screens(bmain); for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen_parent = screen_parent_find(win->screen); bScreen *screen = screen_parent ? screen_parent : win->screen; @@ -278,7 +278,7 @@ static void do_version_layer_collection_pre(ViewLayer *view_layer, GSet *selectable_set) { /* Convert from deprecated DISABLED to new layer collection and collection flags */ - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { if (lc->scene_collection) { if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) { BLI_gset_insert(enabled_set, lc->scene_collection); @@ -300,7 +300,7 @@ static void do_version_layer_collection_post(ViewLayer *view_layer, GHash *collection_map) { /* Apply layer collection exclude flags. */ - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { if (!(lc->collection->flag & COLLECTION_IS_MASTER)) { SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection); const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc)); @@ -334,7 +334,7 @@ static void do_version_scene_collection_convert( nsc = nsc_next; } - for (LinkData *link = sc->objects.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &sc->objects) { Object *ob = link->data; if (ob) { BKE_collection_object_add(bmain, collection, ob); @@ -422,7 +422,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) Collection *collections[20] = {NULL}; for (int layer = 0; layer < 20; layer++) { - for (Base *base = scene->base.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &scene->base) { if (base->lay & (1 << layer)) { /* Create collections when needed only. */ if (collections[layer] == NULL) { @@ -461,7 +461,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) bool have_override = false; const bool need_default_renderlayer = scene->r.layers.first == NULL; - for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) { + LISTBASE_FOREACH (SceneRenderLayer *, srl, &scene->r.layers) { ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name, NULL, VIEWLAYER_ADD_NEW); if (srl->layflag & SCE_LAY_DISABLE) { @@ -493,7 +493,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Disable excluded layer. */ have_override = true; lc->flag |= LAYER_COLLECTION_EXCLUDE; - for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) { + LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) { nlc->flag |= LAYER_COLLECTION_EXCLUDE; } } @@ -516,7 +516,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object); } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) { base->flag |= BASE_SELECTED; } @@ -542,7 +542,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } /* convert selected bases */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) { base->flag |= BASE_SELECTED; } @@ -553,7 +553,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } /* remove bases once and for all */ - for (Base *base = scene->base.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &scene->base) { id_us_min(&base->object->id); } @@ -577,8 +577,8 @@ static void do_version_collection_propagate_lib_to_children(Collection *collecti /** convert old annotations colors */ static void do_versions_fix_annotations(bGPdata *gpd) { - for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { - for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) { + LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) { + LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) { /* fix layers */ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { /* unlock/unhide layer */ @@ -620,7 +620,7 @@ static void do_versions_remove_regions_by_type(ListBase *regionbase, int regiont static ARegion *do_versions_find_region_or_null(ListBase *regionbase, int regiontype) { - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->regiontype == regiontype) { return region; } @@ -649,8 +649,8 @@ static void do_versions_area_ensure_tool_region(Main *bmain, const short region_flag) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == space_type) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -670,7 +670,7 @@ static void do_versions_area_ensure_tool_region(Main *bmain, static void do_version_bones_split_bbone_scale(ListBase *lb) { - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { bone->scale_in_y = bone->scale_in_x; bone->scale_out_y = bone->scale_out_x; @@ -680,7 +680,7 @@ static void do_version_bones_split_bbone_scale(ListBase *lb) static void do_version_bones_inherit_scale(ListBase *lb) { - for (Bone *bone = lb->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, lb) { if (bone->flag & BONE_NO_SCALE) { bone->inherit_scale_mode = BONE_INHERIT_SCALE_NONE_LEGACY; bone->flag &= ~BONE_NO_SCALE; @@ -750,7 +750,7 @@ static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id), static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb) { - for (bConstraint *con = lb->first; con; con = con->next) { + LISTBASE_FOREACH (bConstraint *, con, lb) { if (con->type == CONSTRAINT_TYPE_SAMEVOL) { bSameVolumeConstraint *data = (bSameVolumeConstraint *)con->data; data->mode = SAMEVOL_UNIFORM; @@ -760,7 +760,7 @@ static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb) static void do_version_constraints_copy_scale_power(ListBase *lb) { - for (bConstraint *con = lb->first; con; con = con->next) { + LISTBASE_FOREACH (bConstraint *, con, lb) { if (con->type == CONSTRAINT_TYPE_SIZELIKE) { bSizeLikeConstraint *data = (bSizeLikeConstraint *)con->data; data->power = 1.0f; @@ -770,7 +770,7 @@ static void do_version_constraints_copy_scale_power(ListBase *lb) static void do_version_constraints_copy_rotation_mix_mode(ListBase *lb) { - for (bConstraint *con = lb->first; con; con = con->next) { + LISTBASE_FOREACH (bConstraint *, con, lb) { if (con->type == CONSTRAINT_TYPE_ROTLIKE) { bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; data->mix_mode = (data->flag & ROTLIKE_OFFSET) ? ROTLIKE_MIX_OFFSET : ROTLIKE_MIX_REPLACE; @@ -1244,8 +1244,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) * so same layer as BKE_view_layer_default_view would return */ ViewLayer *layer = screen->scene->view_layers.first; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *space = area->spacedata.first; space; space = space->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) { if (space->spacetype == SPACE_OUTLINER) { SpaceOutliner *soutliner = (SpaceOutliner *)space; @@ -1274,8 +1274,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *space = area->spacedata.first; space; space = space->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) { if (space->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)space; if ((sima) && (sima->gpd)) { @@ -1305,7 +1305,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) /* Cleanup any remaining SceneRenderLayer data for files that were created * with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) { + LISTBASE_FOREACH (SceneRenderLayer *, srl, &scene->r.layers) { if (srl->prop) { IDP_FreeProperty(srl->prop); } @@ -1320,7 +1320,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) * no longer be visible. * Here we correct this by setting a default draw size for those files. */ for (Object *object = bmain->objects.first; object; object = object->id.next) { - for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) { + LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) { if (psys->part->draw_size == 0.0f) { psys->part->draw_size = 0.1f; } @@ -1332,7 +1332,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) for (Object *object = bmain->objects.first; object; object = object->id.next) { if (object->particlesystem.first) { object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT; - for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) { + LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) { if (psys->part->draw & PART_DRAW_EMITTER) { object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER; break; @@ -1363,9 +1363,9 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) * screens using the active scene of the window they're displayed in. * Next, update remaining screens using first scene in main listbase. */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { do_version_area_change_space_to_space_action(area, win->scene); @@ -1377,7 +1377,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) } if (scene != NULL) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { /* Areas that were already handled won't be handled again */ do_version_area_change_space_to_space_action(area, scene); @@ -1414,7 +1414,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) int new_count = BKE_keyblock_curve_element_count(&cu->nurb); - for (KeyBlock *block = cu->key->block.first; block; block = block->next) { + LISTBASE_FOREACH (KeyBlock *, block, &cu->key->block) { int old_count = block->totelem; void *old_data = block->data; @@ -1428,7 +1428,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) float *oldptr = old_data; float(*newptr)[3] = block->data; - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { if (nu->bezt) { BezTriple *bezt = nu->bezt; @@ -1481,7 +1481,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) if (ob->pose && arm && arm->id.lib == ob->id.lib) { bool rebuild = false; - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { /* If the 2.7 flag is enabled, processing is needed. */ if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) { /* If the settings in the Bone are not set, copy. */ @@ -1784,7 +1784,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && STREQ(node->idname, "ShaderNodeOutputMetallic")) { BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); @@ -1913,8 +1913,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* init grease pencil grids and paper */ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_color[3]")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_paper_opacity = 0.5f; @@ -1974,8 +1974,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.light = V3D_LIGHTING_STUDIO; @@ -2027,7 +2027,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { /* Calculate window width/height from screen vertices */ int win_width = 0, win_height = 0; - for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) { + LISTBASE_FOREACH (ScrVert *, vert, &screen->vertbase) { win_width = MAX2(win_width, vert->vec.x); win_height = MAX2(win_height, vert->vec.y); } @@ -2067,8 +2067,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) { /* Remove tool property regions. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -2097,8 +2097,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Initialize new view3D options. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.light = V3D_LIGHTING_STUDIO; @@ -2322,8 +2322,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *soops = (SpaceOutliner *)sl; soops->filter_id_type = ID_GR; @@ -2404,8 +2404,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT; @@ -2417,8 +2417,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.xray_alpha = 0.5f; @@ -2432,8 +2432,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* when loading the internal file is loaded before the matcaps */ if (default_matcap) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE); @@ -2445,8 +2445,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.wireframe_threshold = 0.5f; @@ -2457,8 +2457,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.cavity_valley_factor = 1.0f; @@ -2470,8 +2470,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.xray_alpha_bone = 0.5f; @@ -2496,8 +2496,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; /* "Dopesheet" should be default here, @@ -2512,8 +2512,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->drawtype == OB_TEXTURE) { @@ -2537,8 +2537,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { enum { V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15), @@ -2556,8 +2556,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; copy_v3_fl(v3d->shading.background_color, 0.05f); @@ -2621,8 +2621,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->drawtype == OB_RENDER) { @@ -2644,8 +2644,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* initialize grease pencil view data */ if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->vertex_opacity = 1.0f; @@ -2676,8 +2676,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_paper_opacity = 0.5f; @@ -2688,8 +2688,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_grid_opacity = 0.5f; @@ -2713,7 +2713,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Versioning code for Subsurf modifier. */ if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { - for (ModifierData *md = object->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *)md; if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) { @@ -2729,7 +2729,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "quality")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { - for (ModifierData *md = object->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *)md; smd->quality = min_ii(smd->renderLevels, 3); @@ -2740,7 +2740,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Versioning code for Multires modifier. */ if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { - for (ModifierData *md = object->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Multires) { MultiresModifierData *mmd = (MultiresModifierData *)md; mmd->quality = 3; @@ -2757,7 +2757,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { ClothModifierData *clmd = NULL; if (md->type == eModifierType_Cloth) { clmd = (ClothModifierData *)md; @@ -2797,7 +2797,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -2826,8 +2826,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS | @@ -2842,7 +2842,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Shrinkwrap) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) { @@ -2860,7 +2860,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) ob->pd->pdef_cfrict = 5.0f; } - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -2872,8 +2872,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_XRAY_WIREFRAME; @@ -2910,8 +2910,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { enum { V3D_OCCLUDE_WIRE = (1 << 14) }; View3D *v3d = (View3D *)sl; @@ -2933,8 +2933,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) */ if (!MAIN_VERSION_ATLEAST(bmain, 283, 1)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; ARegion *region_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER); @@ -2957,8 +2957,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_PROPERTIES) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -2985,8 +2985,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* grease pencil fade layer opacity */ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_fade_layer = 0.5f; @@ -3190,8 +3190,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) { if (slink->spacetype == SPACE_USERPREF) { ARegion *navigation_region = BKE_spacedata_find_region_type( slink, area, RGN_TYPE_NAV_BAR); @@ -3219,8 +3219,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) { if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.curvature_ridge_factor = 1.0f; @@ -3251,8 +3251,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Move studio_light selection to lookdev_light. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256); @@ -3305,8 +3305,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)sl; @@ -3422,8 +3422,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_VIEW3D: { enum { V3D_BACKFACE_CULLING = (1 << 10) }; @@ -3465,8 +3465,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_USERPREF) { ARegion *execute_region = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_EXECUTE); @@ -3524,8 +3524,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add wireframe color. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR; @@ -3627,7 +3627,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Triangulate) { TriangulateModifierData *smd = (TriangulateModifierData *)md; smd->min_vertices = 4; @@ -3638,7 +3638,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* Fix missing version patching from earlier changes. */ if (STREQ(node->idname, "ShaderNodeOutputLamp")) { STRNCPY(node->idname, "ShaderNodeOutputLight"); @@ -3677,7 +3677,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 54)) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { bool is_first_subdiv = true; - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *)md; if (is_first_subdiv) { @@ -3704,8 +3704,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_TEXT) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -3727,8 +3727,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 56)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->gizmo_show_armature = V3D_GIZMO_SHOW_ARMATURE_BBONE | @@ -3745,8 +3745,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) { /* Enable Show Interpolation in dopesheet by default. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) { @@ -3784,8 +3784,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* enable the axis aligned ortho grid by default */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->gridflag |= V3D_SHOW_ORTHO_GRID; @@ -3798,8 +3798,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Keep un-versioned until we're finished adding space types. */ { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; /* All spaces that use tools must be eventually added. */ @@ -3829,8 +3829,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { if (ob->pose) { - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (bConstraint *con = pchan->constraints.first; con; con = con->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { + LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) { if (con->type == CONSTRAINT_TYPE_SPLINEIK) { bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) { @@ -3846,8 +3846,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.sculpt_mode_mask_opacity = 0.75f; @@ -3910,8 +3910,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (ELEM(sl->spacetype, SPACE_CLIP, SPACE_GRAPH, SPACE_SEQ)) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -3936,8 +3936,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype != SPACE_OUTLINER) { continue; } @@ -4047,7 +4047,7 @@ 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) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_DataTransfer) { /* Now datatransfer's mix factor is multiplied with weights when any, * instead of being ignored, @@ -4063,8 +4063,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 3)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_TEXT) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; @@ -4118,8 +4118,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 6)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.flag |= V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER; @@ -4140,8 +4140,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 281, 9)) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : @@ -4197,8 +4197,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Added studiolight intensity */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_intensity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.studiolight_intensity = 1.0f; @@ -4235,15 +4235,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - for (ScrArea *area_other = screen->areabase.first; area_other; - area_other = area_other->next) { - for (SpaceLink *sl_other = area_other->spacedata.first; sl_other; - sl_other = sl_other->next) { + LISTBASE_FOREACH (ScrArea *, area_other, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl_other, &area_other->spacedata) { if (sl != sl_other && sl_other->spacetype == SPACE_VIEW3D) { View3D *v3d_other = (View3D *)sl_other; @@ -4293,7 +4291,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) do_version_curvemapping_walker(bmain, do_version_curvemapping_flag_extend_extrapolate); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { area->flag &= ~AREA_FLAG_UNUSED_6; } } @@ -4311,7 +4309,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add custom curve profile to bevel modifier */ if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "CurveProfile", "custom_profile")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { - for (ModifierData *md = object->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Bevel) { BevelModifierData *bmd = (BevelModifierData *)md; if (!bmd->custom_profile) { @@ -4339,7 +4337,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Cloth pressure */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -4364,8 +4362,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.render_pass = SCE_PASS_COMBINED; @@ -4377,8 +4375,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Make markers region visible by default. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_SEQ: { SpaceSeq *sseq = (SpaceSeq *)sl; @@ -4413,7 +4411,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Cloth internal springs */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -4439,8 +4437,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* UDIM Image Editor change. */ if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; sima->tile_grid_shape[0] = 1; @@ -4502,7 +4500,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add 2D transform to UV Warp modifier. */ if (!DNA_struct_elem_find(fd->filesdna, "UVWarpModifierData", "float", "scale[2]")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_UVWarp) { UVWarpModifierData *umd = (UVWarpModifierData *)md; copy_v2_fl(umd->scale, 1.0f); @@ -4514,8 +4512,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Add Lookdev blur property. */ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_blur")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->shading.studiolight_blur = 0.5f; @@ -4788,8 +4786,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "sculpt_mode_face_sets_opacity")) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.sculpt_mode_face_sets_opacity = 1.0f; @@ -4819,7 +4817,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Corrective smooth modifier scale*/ if (!DNA_struct_elem_find(fd->filesdna, "CorrectiveSmoothModifierData", "float", "scale")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_CorrectiveSmooth) { CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md; csmd->scale = 1.0f; @@ -4842,7 +4840,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 283, 11)) { if (!DNA_struct_elem_find(fd->filesdna, "OceanModifierData", "float", "fetch_jonswap")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { - for (ModifierData *md = object->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Ocean) { OceanModifierData *omd = (OceanModifierData *)md; omd->fetch_jonswap = 120.0f; @@ -4870,7 +4868,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Surface deform modifier strength*/ if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "strength")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_SurfaceDeform) { SurfaceDeformModifierData *sdmd = (SurfaceDeformModifierData *)md; sdmd->strength = 1.0f; @@ -4896,7 +4894,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Remesh Modifier Voxel Mode. */ if (!DNA_struct_elem_find(fd->filesdna, "RemeshModifierData", "float", "voxel_size")) { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Remesh) { RemeshModifierData *rmd = (RemeshModifierData *)md; rmd->voxel_size = 0.1f; diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 14a940b9297..ff3d4574561 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -173,7 +173,7 @@ static void square_roughness_node_insert(bNodeTree *ntree) bool need_update = false; /* Update default values */ - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node_has_roughness(node)) { bNodeSocket *roughness_input = nodeFindSocket(node, SOCK_IN, "Roughness"); float *roughness_value = cycles_node_socket_float_value(roughness_input); @@ -256,7 +256,7 @@ static void ambient_occlusion_node_relink(bNodeTree *ntree) bool need_update = false; /* Set default values. */ - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_AMBIENT_OCCLUSION) { node->custom1 = 1; /* samples */ node->custom2 &= ~SHD_AO_LOCAL; @@ -338,7 +338,7 @@ static void light_emission_node_to_energy(Light *light, float *energy, float col } bNode *emission_node = NULL; - for (bNodeLink *link = ntree->links.first; link; link = link->next) { + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { if (link->tonode == output_node && link->fromnode->type == SH_NODE_EMISSION) { emission_node = link->fromnode; break; @@ -410,7 +410,7 @@ static void update_math_node_single_operand_operators(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_MATH) { if (ELEM(node->custom1, NODE_MATH_SQRT, @@ -459,7 +459,7 @@ static void update_vector_math_node_add_and_subtract_operators(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { bNodeSocket *sockOutValue = nodeFindSocket(node, SOCK_OUT, "Value"); if (socket_is_used(sockOutValue) && @@ -511,7 +511,7 @@ static void update_vector_math_node_dot_product_operator(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { bNodeSocket *sockOutVector = nodeFindSocket(node, SOCK_OUT, "Vector"); if (socket_is_used(sockOutVector) && node->custom1 == NODE_VECTOR_MATH_DOT_PRODUCT) { @@ -550,7 +550,7 @@ static void update_vector_math_node_cross_product_operator(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { if (node->custom1 == NODE_VECTOR_MATH_CROSS_PRODUCT) { bNodeSocket *sockOutVector = nodeFindSocket(node, SOCK_OUT, "Vector"); @@ -616,7 +616,7 @@ static void update_vector_math_node_normalize_operator(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { bNodeSocket *sockOutValue = nodeFindSocket(node, SOCK_OUT, "Value"); if (node->custom1 == NODE_VECTOR_MATH_NORMALIZE && socket_is_used(sockOutValue)) { @@ -675,7 +675,7 @@ static void update_vector_math_node_normalize_operator(bNodeTree *ntree) */ static void update_vector_math_node_operators_enum_mapping(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { switch (node->custom1) { case 2: @@ -702,7 +702,7 @@ static void update_vector_math_node_average_operator(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_VECTOR_MATH) { /* See update_vector_math_node_operators_enum_mapping. */ if (node->custom1 == -1) { @@ -765,7 +765,7 @@ static void update_vector_math_node_average_operator(bNodeTree *ntree) */ static void update_noise_node_dimensions(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_NOISE && node->storage) { NodeTexNoise *tex = (NodeTexNoise *)node->storage; tex->dimensions = 3; @@ -853,7 +853,7 @@ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* If node->storage is NULL, then conversion has already taken place. * This can happen if a file with the new mapping node [saved from (2, 81, 8) or newer] * is opened in a blender version prior to (2, 81, 8) and saved from there again. */ @@ -949,7 +949,7 @@ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree) */ static void update_musgrave_node_dimensions(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_MUSGRAVE && node->storage) { NodeTexMusgrave *tex = (NodeTexMusgrave *)node->storage; tex->dimensions = 3; @@ -977,7 +977,7 @@ static void update_musgrave_node_color_output(bNodeTree *ntree) */ static void update_voronoi_node_dimensions(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_VORONOI && node->storage) { NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; tex->dimensions = 3; @@ -992,7 +992,7 @@ static void update_voronoi_node_dimensions(bNodeTree *ntree) */ static void update_voronoi_node_f3_and_f4(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_VORONOI && node->storage) { NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; if (ELEM(tex->feature, 2, 3)) { @@ -1010,7 +1010,7 @@ static void update_voronoi_node_f3_and_f4(bNodeTree *ntree) */ static void update_voronoi_node_fac_output(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_VORONOI) { bNodeSocket *facOutput = BLI_findlink(&node->outputs, 1); strcpy(facOutput->identifier, "Distance"); @@ -1040,7 +1040,7 @@ static void update_voronoi_node_crackle(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_VORONOI && node->storage) { NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance"); @@ -1169,7 +1169,7 @@ static void update_voronoi_node_square_distance(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_VORONOI && node->storage) { NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance"); @@ -1213,7 +1213,7 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree) { bool need_update = false; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_NOISE || node->type == SH_NODE_TEX_WAVE) { bNodeSocket *sockDistortion = nodeFindSocket(node, SOCK_IN, "Distortion"); @@ -1262,7 +1262,7 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree) */ static void update_wave_node_directions_and_offset(bNodeTree *ntree) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == SH_NODE_TEX_WAVE) { NodeTexWave *tex = (NodeTexWave *)node->storage; tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_DIAGONAL; @@ -1351,13 +1351,13 @@ void do_versions_after_linking_cycles(Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 273, 5)) { /* Euler order was ZYX in previous versions. */ - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { mapping_node_order_flip(node); } } if (!MAIN_VERSION_ATLEAST(bmain, 276, 6)) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { vector_curve_node_remap(node); } } @@ -1368,7 +1368,7 @@ void do_versions_after_linking_cycles(Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { displacement_principled_nodes(node); } } @@ -1384,7 +1384,7 @@ void do_versions_after_linking_cycles(Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 280, 66)) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { image_node_colorspace(node); } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index aa19b3feefb..035e6c88faa 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -71,7 +71,7 @@ static ID *rename_id_for_versioning(Main *bmain, /* We can ignore libraries */ ListBase *lb = which_libbase(bmain, id_type); ID *id = NULL; - for (ID *idtest = lb->first; idtest; idtest = idtest->next) { + LISTBASE_FOREACH (ID *, idtest, lb) { if (idtest->lib == NULL) { if (STREQ(idtest->name + 2, name_src)) { id = idtest; @@ -101,8 +101,8 @@ static void blo_update_defaults_screen(bScreen *screen, const char *workspace_name) { /* For all app templates. */ - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { /* Some toolbars have been saved as initialized, * we don't want them to have odd zoom-level or scrolling set, see: T47047 */ if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { @@ -111,7 +111,7 @@ static void blo_update_defaults_screen(bScreen *screen, } /* Set default folder. */ - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_FILE) { SpaceFile *sfile = (SpaceFile *)sl; if (sfile->params) { @@ -130,8 +130,8 @@ static void blo_update_defaults_screen(bScreen *screen, return; } - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { /* Remove all stored panels, we want to use defaults * (order, open/closed) as defined by UI code here! */ BKE_area_region_panels_free(®ion->panels); @@ -157,7 +157,7 @@ static void blo_update_defaults_screen(bScreen *screen, if (saction->mode == SACTCONT_TIMELINE) { saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_CHANNELS) { region->flag |= RGN_FLAG_HIDDEN; } @@ -210,11 +210,11 @@ static void blo_update_defaults_screen(bScreen *screen, /* Show tool-header by default (for most cases at least, hide for others). */ const bool hide_image_tool_header = STREQ(workspace_name, "Rendering"); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->regiontype == RGN_TYPE_TOOL_HEADER) { if ((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) { region->flag |= RGN_FLAG_HIDDEN; @@ -229,8 +229,8 @@ static void blo_update_defaults_screen(bScreen *screen, /* 2D animation template. */ if (app_template && STREQ(app_template, "2D_Animation")) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (area->spacetype == SPACE_ACTION) { SpaceAction *saction = area->spacedata.first; /* Enable Sliders. */ @@ -251,7 +251,7 @@ static void blo_update_defaults_screen(bScreen *screen, void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_template) { ListBase *layouts = BKE_workspace_layouts_get(workspace); - for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) { if (layout->screen) { blo_update_defaults_screen(layout->screen, app_template, workspace->id.name + 2); } @@ -270,11 +270,11 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat /* For Sculpting template. */ if (STREQ(workspace->id.name + 2, "Sculpting")) { - for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) { bScreen *screen = layout->screen; if (screen) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (area->spacetype == SPACE_VIEW3D) { View3D *v3d = area->spacedata.first; v3d->shading.flag &= ~V3D_SHADING_CAVITY; @@ -472,7 +472,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) ma->roughness = 0.4f; if (ma->nodetree) { - for (bNode *node = ma->nodetree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ma->nodetree->nodes) { if (node->type == SH_NODE_BSDF_PRINCIPLED) { bNodeSocket *roughness_socket = nodeFindSocket(node, SOCK_IN, "Roughness"); bNodeSocketValueFloat *roughness_data = roughness_socket->default_value; diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index b566cf446ad..28118d6e87a 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -534,7 +534,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) userdef->gpu_viewport_quality = 0.6f; /* Reset theme, old themes will not be compatible with minor version updates from now on. */ - for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) { + LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) { memcpy(btheme, &U_theme_default, sizeof(*btheme)); } @@ -552,8 +552,8 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) if (!USER_VERSION_ATLEAST(280, 31)) { /* Remove select/action mouse from user defined keymaps. */ - for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) { - for (wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) { + LISTBASE_FOREACH (wmKeyMap *, keymap, &userdef->user_keymaps) { + LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &keymap->diff_items) { if (kmdi->remove_item) { do_version_select_mouse(userdef, kmdi->remove_item); } @@ -562,7 +562,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) } } - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { do_version_select_mouse(userdef, kmi); } } @@ -757,7 +757,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) userdef->pixelsize = 1.0f; } - for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) { + LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) { do_versions_theme(userdef, btheme); } #undef USER_VERSION_ATLEAST diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 43a27318d75..aa8dc39f9c0 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -718,13 +718,11 @@ static void write_iddata(WriteData *wd, ID *id) writestruct(wd, DATA, IDOverrideLibrary, 1, id->override_library); writelist(wd, DATA, IDOverrideLibraryProperty, &id->override_library->properties); - for (IDOverrideLibraryProperty *op = id->override_library->properties.first; op; - op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) { writedata(wd, DATA, strlen(op->rna_path) + 1, op->rna_path); writelist(wd, DATA, IDOverrideLibraryPropertyOperation, &op->operations); - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; - opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { if (opop->subitem_reference_name) { writedata( wd, DATA, strlen(opop->subitem_reference_name) + 1, opop->subitem_reference_name); @@ -863,11 +861,11 @@ static void write_action(WriteData *wd, bAction *act, const void *id_address) write_fcurves(wd, &act->curves); - for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) { + LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) { writestruct(wd, DATA, bActionGroup, 1, grp); } - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { writestruct(wd, DATA, TimeMarker, 1, marker); } } @@ -1231,14 +1229,14 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) { writestruct(wd, USER, UserDef, 1, userdef); - for (const bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) { + LISTBASE_FOREACH (const bTheme *, btheme, &userdef->themes) { writestruct(wd, DATA, bTheme, 1, btheme); } - for (const wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) { + LISTBASE_FOREACH (const wmKeyMap *, keymap, &userdef->user_keymaps) { writestruct(wd, DATA, wmKeyMap, 1, keymap); - for (const wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) { + LISTBASE_FOREACH (const wmKeyMapDiffItem *, kmdi, &keymap->diff_items) { writestruct(wd, DATA, wmKeyMapDiffItem, 1, kmdi); if (kmdi->remove_item) { write_keymapitem(wd, kmdi->remove_item); @@ -1248,21 +1246,21 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) } } - for (const wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &keymap->items) { write_keymapitem(wd, kmi); } } - for (const wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first; kpt; kpt = kpt->next) { + LISTBASE_FOREACH (const wmKeyConfigPref *, kpt, &userdef->user_keyconfig_prefs) { writestruct(wd, DATA, wmKeyConfigPref, 1, kpt); if (kpt->prop) { IDP_WriteProperty(kpt->prop, wd); } } - for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) { + LISTBASE_FOREACH (const bUserMenu *, um, &userdef->user_menus) { writestruct(wd, DATA, bUserMenu, 1, um); - for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + LISTBASE_FOREACH (const bUserMenuItem *, umi, &um->items) { if (umi->type == USER_MENU_TYPE_OPERATOR) { const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi; writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op); @@ -1284,19 +1282,18 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) } } - for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) { + LISTBASE_FOREACH (const bAddon *, bext, &userdef->addons) { writestruct(wd, DATA, bAddon, 1, bext); if (bext->prop) { IDP_WriteProperty(bext->prop, wd); } } - for (const bPathCompare *path_cmp = userdef->autoexec_paths.first; path_cmp; - path_cmp = path_cmp->next) { + LISTBASE_FOREACH (const bPathCompare *, path_cmp, &userdef->autoexec_paths) { writestruct(wd, DATA, bPathCompare, 1, path_cmp); } - for (const uiStyle *style = userdef->uistyles.first; style; style = style->next) { + LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) { writestruct(wd, DATA, uiStyle, 1, style); } } @@ -1416,7 +1413,7 @@ static void write_particlesettings(WriteData *wd, ParticleSettings *part, const write_curvemapping(wd, part->twistcurve); } - for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) { + LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */ if (dw->ob != NULL) { dw->index = 0; @@ -1436,7 +1433,7 @@ static void write_particlesettings(WriteData *wd, ParticleSettings *part, const if (part->boids && part->phystype == PART_PHYS_BOIDS) { writestruct(wd, DATA, BoidSettings, 1, part->boids); - for (BoidState *state = part->boids->states.first; state; state = state->next) { + LISTBASE_FOREACH (BoidState *, state, &part->boids->states) { write_boid_state(wd, state); } } @@ -1621,14 +1618,14 @@ static void write_pose(WriteData *wd, bPose *pose) static void write_defgroups(WriteData *wd, ListBase *defbase) { - for (bDeformGroup *defgroup = defbase->first; defgroup; defgroup = defgroup->next) { + LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) { writestruct(wd, DATA, bDeformGroup, 1, defgroup); } } static void write_fmaps(WriteData *wd, ListBase *fbase) { - for (bFaceMap *fmap = fbase->first; fmap; fmap = fmap->next) { + LISTBASE_FOREACH (bFaceMap *, fmap, fbase) { writestruct(wd, DATA, bFaceMap, 1, fmap); } } @@ -2001,7 +1998,7 @@ static void write_key(WriteData *wd, Key *key, const void *id_address) } /* direct data */ - for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { writestruct(wd, DATA, KeyBlock, 1, kb); if (kb->data) { writedata(wd, DATA, kb->totelem * key->elemsize, kb->data); @@ -2021,7 +2018,7 @@ static void write_camera(WriteData *wd, Camera *cam, const void *id_address) write_animdata(wd, cam->adt); } - for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) { writestruct(wd, DATA, CameraBGImage, 1, bgpic); } } @@ -2048,7 +2045,7 @@ static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address) write_animdata(wd, mb->adt); } - for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) { writestruct(wd, DATA, MetaElem, 1, ml); } } @@ -2079,10 +2076,10 @@ static void write_curve(WriteData *wd, Curve *cu, const void *id_address) } else { /* is also the order of reading */ - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { writestruct(wd, DATA, Nurb, 1, nu); } - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { if (nu->type == CU_BEZIER) { writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt); } @@ -2327,7 +2324,7 @@ static void write_image(WriteData *wd, Image *ima, const void *id_address) write_previews(wd, ima->preview); - for (ImageView *iv = ima->views.first; iv; iv = iv->next) { + LISTBASE_FOREACH (ImageView *, iv, &ima->views) { writestruct(wd, DATA, ImageView, 1, iv); } writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format); @@ -2450,11 +2447,11 @@ static void write_collection_nolib(WriteData *wd, Collection *collection) /* Shared function for collection data-blocks and scene master collection. */ write_previews(wd, collection->preview); - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { writestruct(wd, DATA, CollectionObject, 1, cob); } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { writestruct(wd, DATA, CollectionChild, 1, child); } @@ -2532,7 +2529,7 @@ static void write_paint(WriteData *wd, Paint *p) static void write_layer_collections(WriteData *wd, ListBase *lb) { - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { writestruct(wd, DATA, LayerCollection, 1, lc); write_layer_collections(wd, &lc->layer_collections); @@ -2548,12 +2545,11 @@ static void write_view_layer(WriteData *wd, ViewLayer *view_layer) IDP_WriteProperty(view_layer->id_properties, wd); } - for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; - fmc = fmc->next) { + LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) { writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc); } - for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) { + LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { writestruct(wd, DATA, FreestyleLineSet, 1, fls); } write_layer_collections(wd, &view_layer->layer_collections); @@ -2739,7 +2735,7 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address) SEQ_END; /* new; meta stack too, even when its nasty restore code */ - for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) { + LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) { writestruct(wd, DATA, MetaStack, 1, ms); } } @@ -2758,17 +2754,17 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address) } /* writing dynamic list of TimeMarkers to the blend file */ - for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) { writestruct(wd, DATA, TimeMarker, 1, marker); } /* writing dynamic list of TransformOrientations to the blend file */ - for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) { + LISTBASE_FOREACH (TransformOrientation *, ts, &sce->transform_spaces) { writestruct(wd, DATA, TransformOrientation, 1, ts); } /* writing MultiView to the blend file */ - for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) { + LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) { writestruct(wd, DATA, SceneRenderView, 1, srv); } @@ -2794,7 +2790,7 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address) write_previews(wd, sce->preview); write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve); - for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { write_view_layer(wd, view_layer); } @@ -2947,7 +2943,7 @@ static void write_soops(WriteData *wd, SpaceOutliner *so) static void write_panel_list(WriteData *wd, ListBase *lb) { - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { writestruct(wd, DATA, Panel, 1, pa); write_panel_list(wd, &pa->children); } @@ -2955,27 +2951,25 @@ static void write_panel_list(WriteData *wd, ListBase *lb) static void write_area_regions(WriteData *wd, ScrArea *area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { write_region(wd, region, area->spacetype); write_panel_list(wd, ®ion->panels); - for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act; - pc_act = pc_act->next) { + LISTBASE_FOREACH (PanelCategoryStack *, pc_act, ®ion->panels_category_active) { writestruct(wd, DATA, PanelCategoryStack, 1, pc_act); } - for (uiList *ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) { + LISTBASE_FOREACH (uiList *, ui_list, ®ion->ui_lists) { write_uilist(wd, ui_list); } - for (uiPreview *ui_preview = region->ui_previews.first; ui_preview; - ui_preview = ui_preview->next) { + LISTBASE_FOREACH (uiPreview *, ui_preview, ®ion->ui_previews) { writestruct(wd, DATA, uiPreview, 1, ui_preview); } } - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { - for (ARegion *region = sl->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) { write_region(wd, region, sl->spacetype); } @@ -3088,7 +3082,7 @@ static void write_area_map(WriteData *wd, ScrAreaMap *area_map) { writelist(wd, DATA, ScrVert, &area_map->vertbase); writelist(wd, DATA, ScrEdge, &area_map->edgebase); - for (ScrArea *area = area_map->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) { area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */ writestruct(wd, DATA, ScrArea, 1, area); @@ -3109,7 +3103,7 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm, const void * write_iddata(wd, &wm->id); write_wm_xr_data(wd, &wm->xr); - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { #ifndef WITH_GLOBAL_AREA_WRITING /* Don't write global areas yet, while we make changes to them. */ ScrAreaMap global_areas = win->global_areas; @@ -3165,7 +3159,7 @@ static void write_bone(WriteData *wd, Bone *bone) } /* Write Children */ - for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) { + LISTBASE_FOREACH (Bone *, cbone, &bone->childbase) { write_bone(wd, cbone); } } @@ -3188,7 +3182,7 @@ static void write_armature(WriteData *wd, bArmature *arm, const void *id_address } /* Direct data */ - for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { write_bone(wd, bone); } } @@ -3214,11 +3208,11 @@ static void write_text(WriteData *wd, Text *text, const void *id_address) if (!(text->flags & TXT_ISEXT)) { /* now write the text data, in two steps for optimization in the readfunction */ - for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { + LISTBASE_FOREACH (TextLine *, tmp, &text->lines) { writestruct(wd, DATA, TextLine, 1, tmp); } - for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) { + LISTBASE_FOREACH (TextLine *, tmp, &text->lines) { writedata(wd, DATA, tmp->len + 1, tmp->line); } } @@ -3777,7 +3771,7 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace, const void *id_ writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); writelist(wd, DATA, wmOwnerID, &workspace->owner_ids); writelist(wd, DATA, bToolRef, &workspace->tools); - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { if (tref->properties) { IDP_WriteProperty(tref->properties, wd); } diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index d33f4e0a1d6..1bf419f4461 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -1083,12 +1083,12 @@ void BM_select_history_merge_from_targetmap( { #ifdef DEBUG - for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) { + LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) { BLI_assert(BM_ELEM_API_FLAG_TEST(ese->ele, _FLAG_OVERLAP) == 0); } #endif - for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) { + LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) { BM_ELEM_API_FLAG_ENABLE(ese->ele, _FLAG_OVERLAP); /* Only loop when (use_chain == true). */ diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index ff618142bfa..933223c3337 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -2593,7 +2593,7 @@ void BM_mesh_rebuild(BMesh *bm, } } - for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) { + LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) { switch (ese->htype) { case BM_VERT: if (remap & BM_VERT) { diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index ba6aacf00d7..10ad8f3f1be 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -2187,7 +2187,7 @@ void EEVEE_particle_hair_cache_populate(EEVEE_Data *vedata, if (ob->type == OB_MESH) { if (ob != draw_ctx->object_edit) { - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type != eModifierType_ParticleSystem) { continue; } diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index b97766d1ca2..63c96ac8c25 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -852,7 +852,7 @@ void EEVEE_volumes_resolve(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda void EEVEE_volumes_free_smoke_textures(void) { /* Free Smoke Textures after rendering */ - for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &e_data.smoke_domains) { FluidModifierData *mmd = (FluidModifierData *)link->data; GPU_free_smoke(mmd); } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 4963221743f..50e4e8d2ec4 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -744,8 +744,8 @@ static void GPENCIL_draw_scene_depth_only(void *ved) GPU_framebuffer_bind(dfbl->depth_only_fb); } - for (GPENCIL_tObject *ob = pd->tobjects.first; ob; ob = ob->next) { - for (GPENCIL_tLayer *layer = ob->layers.first; layer; layer = layer->next) { + LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) { + LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) { DRW_draw_pass(layer->geom_ps); } } @@ -826,7 +826,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob) GPU_framebuffer_multi_clear(fb_object, clear_cols); } - for (GPENCIL_tLayer *layer = ob->layers.first; layer; layer = layer->next) { + LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) { if (layer->mask_bits) { gpencil_draw_mask(vedata, ob, layer); } @@ -847,7 +847,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob) } } - for (GPENCIL_tVfx *vfx = ob->vfx.first; vfx; vfx = vfx->next) { + LISTBASE_FOREACH (GPENCIL_tVfx *, vfx, &ob->vfx) { GPU_framebuffer_bind(*(vfx->target_fb)); DRW_draw_pass(vfx->vfx_ps); } @@ -893,7 +893,7 @@ static void GPENCIL_fast_draw_end(GPENCIL_Data *vedata) pd->snapshot_buffer_dirty = false; } /* Draw the sbuffer stroke(s). */ - for (GPENCIL_tObject *ob = pd->sbuffer_tobjects.first; ob; ob = ob->next) { + LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->sbuffer_tobjects) { GPENCIL_draw_object(vedata, ob); } } @@ -934,7 +934,7 @@ void GPENCIL_draw_scene(void *ved) GPU_framebuffer_multi_clear(fbl->gpencil_fb, clear_cols); } - for (GPENCIL_tObject *ob = pd->tobjects.first; ob; ob = ob->next) { + LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) { GPENCIL_draw_object(vedata, ob); } diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index 19b88682c1d..566c8cad528 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -913,7 +913,7 @@ static void camera_view3d_reconstruction(OVERLAY_ExtraCallBuffers *cb, } ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); - for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) { + LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) { if ((track->flag & TRACK_HAS_BUNDLE) == 0) { continue; } diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index 7eda342d700..45d218b4959 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -313,7 +313,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) float norm_obmat[4][4]; normalize_m4_m4(norm_obmat, ob->obmat); - for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) { if (bgpic->flag & CAM_BGIMG_FLAG_DISABLED) { continue; } diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c index 997cc0fbbdb..531e1faf715 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.c +++ b/source/blender/draw/engines/overlay/overlay_motion_path.c @@ -212,7 +212,7 @@ void OVERLAY_motion_path_cache_populate(OVERLAY_Data *vedata, Object *ob) if (ob->type == OB_ARMATURE) { if (OVERLAY_armature_is_pose_mode(ob, draw_ctx)) { - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if (pchan->mpath) { motion_path_cache(vedata, ob, pchan, &ob->pose->avs, pchan->mpath); } diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index d505902d69c..21cb567aaae 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -291,7 +291,7 @@ void workbench_volume_draw_finish(WORKBENCH_Data *vedata) * modifier we don't want them to take precious VRAM if the * modifier is not used for display. We should share them for * all viewport in a redraw at least. */ - for (LinkData *link = wpd->smoke_domains.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &wpd->smoke_domains) { FluidModifierData *mmd = (FluidModifierData *)link->data; GPU_free_smoke(mmd); } diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 33571d82079..4f03ab04862 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -77,7 +77,7 @@ static void curve_render_overlay_verts_edges_len_get(ListBase *lb, BLI_assert(r_vert_len || r_edge_len); int vert_len = 0; int edge_len = 0; - for (Nurb *nu = lb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, lb) { if (nu->bezt) { vert_len += nu->pntsu * 3; /* 2x handles per point*/ @@ -107,7 +107,7 @@ static void curve_render_wire_verts_edges_len_get(const CurveCache *ob_curve_cac int vert_len = 0; int edge_len = 0; int curve_len = 0; - for (const BevList *bl = ob_curve_cache->bev.first; bl; bl = bl->next) { + LISTBASE_FOREACH (const BevList *, bl, &ob_curve_cache->bev) { if (bl->nr > 0) { const bool is_cyclic = bl->poly != -1; edge_len += (is_cyclic) ? bl->nr : bl->nr - 1; @@ -115,7 +115,7 @@ static void curve_render_wire_verts_edges_len_get(const CurveCache *ob_curve_cac curve_len += 1; } } - for (const DispList *dl = ob_curve_cache->disp.first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, &ob_curve_cache->disp) { if (ELEM(dl->type, DL_SEGM, DL_POLY)) { BLI_assert(dl->parts == 1); const bool is_cyclic = dl->type == DL_POLY; @@ -315,7 +315,7 @@ static void curve_cd_calc_used_gpu_layers(int *cd_layers, } ListBase gpu_attrs = GPU_material_attributes(gpumat); - for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) { const char *name = gpu_attr->name; int type = gpu_attr->type; @@ -566,7 +566,7 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv GPU_vertbuf_data_alloc(vbo_curves_pos, vert_len); int v_idx = 0; - for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { + LISTBASE_FOREACH (const BevList *, bl, &rdata->ob_curve_cache->bev) { if (bl->nr <= 0) { continue; } @@ -575,7 +575,7 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv GPU_vertbuf_attr_set(vbo_curves_pos, attr_id.pos, v_idx, bevp->vec); } } - for (const DispList *dl = rdata->ob_curve_cache->disp.first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, &rdata->ob_curve_cache->disp) { if (ELEM(dl->type, DL_SEGM, DL_POLY)) { for (int i = 0; i < dl->nr; v_idx++, i++) { GPU_vertbuf_attr_set(vbo_curves_pos, attr_id.pos, v_idx, &((float(*)[3])dl->verts)[i]); @@ -599,7 +599,7 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len); int v_idx = 0; - for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { + LISTBASE_FOREACH (const BevList *, bl, &rdata->ob_curve_cache->bev) { if (bl->nr <= 0) { continue; } @@ -613,7 +613,7 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c GPU_indexbuf_add_primitive_restart(&elb); v_idx += bl->nr; } - for (const DispList *dl = rdata->ob_curve_cache->disp.first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, &rdata->ob_curve_cache->disp) { if (ELEM(dl->type, DL_SEGM, DL_POLY)) { const bool is_cyclic = dl->type == DL_POLY; if (is_cyclic) { diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 24a28022b70..e09f78aa51f 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -72,7 +72,7 @@ static int dl_tri_len(const DispList *dl) static int curve_render_surface_vert_len_get(const ListBase *lb) { int vert_len = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { vert_len += dl_vert_len(dl); } return vert_len; @@ -81,7 +81,7 @@ static int curve_render_surface_vert_len_get(const ListBase *lb) static int curve_render_surface_tri_len_get(const ListBase *lb) { int tri_len = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { tri_len += dl_tri_len(dl); } return tri_len; @@ -193,7 +193,7 @@ void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo) BKE_displist_normals_add(lb); int vbo_len_used = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { const bool ndata_is_single = dl->type == DL_INDEX3; if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { const float *fp_co = dl->verts; @@ -263,7 +263,7 @@ void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf * GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); int ofs = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { displist_indexbufbuilder_set((SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, (SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, &elb, @@ -290,7 +290,7 @@ void DRW_displist_indexbuf_create_triangles_loop_split_by_material(ListBase *lb, /* calc each index buffer builder */ uint v_idx = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { v_idx = displist_indexbufbuilder_tess_set((SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, (SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, &elb[dl->col], @@ -328,7 +328,7 @@ void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo) GPU_indexbuf_init(&elb, GPU_PRIM_LINES, tri_len * 3, vert_len); int ofs = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { displist_indexbufbuilder_set( set_overlay_wires_tri_indices, set_overlay_wires_quad_tri_indices, &elb, dl, ofs); ofs += dl_vert_len(dl); @@ -508,7 +508,7 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb, BKE_displist_normals_add(lb); - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { const bool is_smooth = (dl->rt & CU_SMOOTH) != 0; if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { const float(*verts)[3] = (float(*)[3])dl->verts; @@ -780,7 +780,7 @@ void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, /* pack values to pass to `set_edges_adjacency_lines_indices` function. */ void *thunk[3] = {&elb, eh, r_is_manifold}; int v_idx = 0; - for (const DispList *dl = lb->first; dl; dl = dl->next) { + LISTBASE_FOREACH (const DispList *, dl, lb) { displist_indexbufbuilder_set((SetTriIndicesFn *)set_edges_adjacency_lines_indices, (SetTriIndicesFn *)set_edges_adjacency_lines_indices, thunk, diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index a4b88d99a3c..308d87f1385 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -144,7 +144,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me, GPUMaterial *gpumat = gpumat_array[i]; if (gpumat) { ListBase gpu_attrs = GPU_material_attributes(gpumat); - for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) { const char *name = gpu_attr->name; int type = gpu_attr->type; int layer = -1; diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c index c64817413b8..a7562b1b8ea 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.c +++ b/source/blender/draw/intern/draw_cache_impl_volume.c @@ -124,7 +124,7 @@ static void volume_batch_cache_clear(Volume *volume) return; } - for (DRWVolumeGrid *grid = cache->grids.first; grid; grid = grid->next) { + LISTBASE_FOREACH (DRWVolumeGrid *, grid, &cache->grids) { MEM_SAFE_FREE(grid->name); DRW_TEXTURE_FREE_SAFE(grid->texture); } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 280e82ef473..1434cac5f97 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -690,8 +690,7 @@ void **DRW_duplidata_get(void *vedata) void *DRW_view_layer_engine_data_get(DrawEngineType *engine_type) { - for (ViewLayerEngineData *sled = DST.draw_ctx.view_layer->drawdata.first; sled; - sled = sled->next) { + LISTBASE_FOREACH (ViewLayerEngineData *, sled, &DST.draw_ctx.view_layer->drawdata) { if (sled->engine_type == engine_type) { return sled->storage; } @@ -922,7 +921,7 @@ void DRW_cache_free_old_batches(Main *bmain) static void drw_engines_init(void) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); PROFILE_START(stime); @@ -966,7 +965,7 @@ static void drw_engines_world_update(Scene *scene) return; } - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); @@ -1032,7 +1031,7 @@ static void drw_engines_cache_finish(void) static void drw_engines_draw_scene(void) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); PROFILE_START(stime); @@ -1055,7 +1054,7 @@ static void drw_engines_draw_scene(void) static void drw_engines_draw_text(void) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); PROFILE_START(stime); @@ -1071,7 +1070,7 @@ static void drw_engines_draw_text(void) /* Draw render engine info. */ void DRW_draw_region_engine_info(int xoffset, int yoffset) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); @@ -1178,7 +1177,7 @@ static void drw_engines_data_validate(void) void **engine_handle_array = BLI_array_alloca(engine_handle_array, enabled_engines + 1); int i = 0; - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *engine = link->data; engine_handle_array[i++] = engine; } @@ -1245,7 +1244,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx) drw_engines_enable(view_layer, engine_type, gpencil_engine_needed); drw_engines_data_validate(); - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { DrawEngineType *draw_engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(draw_engine); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 50193dde7ee..0544bb3c49b 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1300,7 +1300,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, ListBase textures = GPU_material_textures(material); /* Bind all textures needed by the material. */ - for (GPUMaterialTexture *tex = textures.first; tex; tex = tex->next) { + LISTBASE_FOREACH (GPUMaterialTexture *, tex, &textures) { if (tex->ima) { /* Image */ if (tex->tiled_mapping_name[0]) { @@ -1903,7 +1903,7 @@ DRWPass *DRW_pass_create(const char *name, DRWState state) bool DRW_pass_is_empty(DRWPass *pass) { - for (DRWShadingGroup *shgroup = pass->shgroups.first; shgroup; shgroup = shgroup->next) { + LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) { if (!DRW_shgroup_is_empty(shgroup)) { return false; } @@ -1930,7 +1930,7 @@ void DRW_pass_foreach_shgroup(DRWPass *pass, void (*callback)(void *userData, DRWShadingGroup *shgrp), void *userData) { - for (DRWShadingGroup *shgroup = pass->shgroups.first; shgroup; shgroup = shgroup->next) { + LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) { callback(userData, shgroup); } } diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index b4bcfd3f600..57887c11c02 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -251,7 +251,7 @@ void DRW_stats_draw(const rcti *rect) /* Engines rows */ char time_to_txt[16]; - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) { u = 0; DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 89884d58099..b451cfb1d05 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -249,7 +249,7 @@ void DRW_deferred_shader_remove(GPUMaterial *mat) /* No job running, do not create a new one by calling WM_jobs_get. */ continue; } - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { wmJob *wm_job = WM_jobs_get( wm, win, scene, "Shaders Compilation", WM_JOB_PROGRESS, WM_JOB_TYPE_SHADER_COMPILATION); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 5ea5b2aa1f6..38a19e85661 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -3139,7 +3139,7 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, size_t num_bases = 0; Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases"); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (animdata_filter_base_is_ok(ads, base, filter_mode)) { sorted_bases[num_bases++] = base; } @@ -3233,7 +3233,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, /* Filter and add contents of each base (i.e. object) without them sorting first * NOTE: This saves performance in cases where order doesn't matter */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (animdata_filter_base_is_ok(ads, base, filter_mode)) { /* since we're still here, this object should be usable */ items += animdata_filter_dopesheet_ob(ac, anim_data, ads, base, filter_mode); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 5523fd67dca..46566feea91 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -358,7 +358,7 @@ void ED_markers_deselect_all(ListBase *markers, int action) action = ED_markers_get_first_selected(markers) ? SEL_DESELECT : SEL_SELECT; } - for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, markers) { if (action == SEL_SELECT) { marker->flag |= SELECT; } @@ -599,14 +599,14 @@ 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) { + LISTBASE_FOREACH (TimeMarker *, marker, markers) { if ((marker->flag & SELECT) == 0) { if (marker_is_in_frame_range(marker, clip_frame_range)) { draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy); } } } - for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, markers) { if (marker->flag & SELECT) { if (marker_is_in_frame_range(marker, clip_frame_range)) { draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy); @@ -1156,7 +1156,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) static void deselect_markers(ListBase *markers) { - for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, markers) { marker->flag &= ~SELECT; } } @@ -1373,7 +1373,7 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op) ED_markers_deselect_all(markers, SEL_DESELECT); } - for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, markers) { if (BLI_rctf_isect_x(&rect, marker->frame)) { SET_FLAG_FROM_TEST(marker->flag, select, SELECT); } @@ -1646,7 +1646,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) BLI_addtail(markers, marker); /* deselect all others, so that the user can then move it without problems */ - for (TimeMarker *m = markers->first; m; m = m->next) { + LISTBASE_FOREACH (TimeMarker *, m, markers) { if (m != marker) { m->flag &= ~SELECT; } diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index a4ecd346a01..4c10c66dfa6 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -228,7 +228,7 @@ static void motionpath_get_global_framerange(ListBase *targets, int *r_sfra, int { *r_sfra = INT_MAX; *r_efra = INT_MIN; - for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) { + LISTBASE_FOREACH (MPathTarget *, mpt, targets) { *r_sfra = min_ii(*r_sfra, mpt->mpath->start_frame); *r_efra = max_ii(*r_efra, mpt->mpath->end_frame); } @@ -348,7 +348,7 @@ static void motionpath_calculate_update_range(MPathTarget *mpt, static void motionpath_free_free_tree_data(ListBase *targets) { - for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) { + LISTBASE_FOREACH (MPathTarget *, mpt, targets) { BLI_dlrbTree_free(&mpt->keys); } } @@ -412,7 +412,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph, DEG_make_inactive(depsgraph); } - for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) { + LISTBASE_FOREACH (MPathTarget *, mpt, targets) { mpt->ob_eval = DEG_get_evaluated_object(depsgraph, mpt->ob); AnimData *adt = BKE_animdata_from_id(&mpt->ob_eval->id); @@ -492,7 +492,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph, } /* clear recalc flags from targets */ - for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) { + LISTBASE_FOREACH (MPathTarget *, mpt, targets) { bMotionPath *mpath = mpt->mpath; /* get pointer to animviz settings for each target */ diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index eae86d4990c..b921ba039be 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -506,14 +506,14 @@ static void update_keyblocks(DLRBT_Tree *keys, BezTriple *bezt, int bezt_len) /* Find the curve count */ int max_curve = 0; - for (ActKeyColumn *col = keys->first; col; col = col->next) { + LISTBASE_FOREACH (ActKeyColumn *, col, keys) { max_curve = MAX2(max_curve, col->totcurve); } /* Propagate blocks to inserted keys */ ActKeyColumn *prev_ready = NULL; - for (ActKeyColumn *col = keys->first; col; col = col->next) { + LISTBASE_FOREACH (ActKeyColumn *, col, keys) { /* Pre-existing column. */ if (col->totcurve > 0) { prev_ready = col; @@ -731,7 +731,7 @@ static void draw_keylist(View2D *v2d, ipo_color_mix[3] *= 0.5f; uint block_len = 0; - for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) { + LISTBASE_FOREACH (ActKeyColumn *, ab, keys) { if (actkeyblock_get_valid_hold(ab)) { block_len++; } @@ -747,7 +747,7 @@ static void draw_keylist(View2D *v2d, immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GPU_PRIM_TRIS, 6 * block_len); - for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) { + LISTBASE_FOREACH (ActKeyColumn *, ab, keys) { int valid_hold = actkeyblock_get_valid_hold(ab); if (valid_hold != 0) { if ((valid_hold & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) { @@ -792,7 +792,7 @@ static void draw_keylist(View2D *v2d, if (keys) { /* count keys */ uint key_len = 0; - for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { + LISTBASE_FOREACH (ActKeyColumn *, ak, keys) { /* Optimization: if keyframe doesn't appear within 5 units (screenspace) * in visible area, don't draw. * This might give some improvements, @@ -823,7 +823,7 @@ static void draw_keylist(View2D *v2d, short handle_type = KEYFRAME_HANDLE_NONE, extreme_type = KEYFRAME_EXTREME_NONE; - for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { + LISTBASE_FOREACH (ActKeyColumn *, ak, keys) { if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) { if (show_ipo) { handle_type = ak->handle_type; @@ -1154,7 +1154,7 @@ void cachefile_to_keylist(bDopeSheet *ads, ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag); } diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 1105633f47e..f6875a6e158 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -341,7 +341,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob) GHash *name_map = BLI_ghash_str_new(__func__); - for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) { + LISTBASE_FOREACH (EditBone *, ebone_src, editbones) { EditBone *ebone_dst = ebone_src->temp.ebone; if (!ebone_dst) { ebone_dst = ED_armature_ebone_get_mirrored(editbones, ebone_src); @@ -351,7 +351,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob) } } - for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) { + LISTBASE_FOREACH (EditBone *, ebone_src, editbones) { EditBone *ebone_dst = ebone_src->temp.ebone; if (ebone_dst) { bPoseChannel *pchan_src = BKE_pose_channel_find_name(ob->pose, ebone_src->name); diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 9a640952253..8a7afe13a2f 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -499,7 +499,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op) bArmature *arm = ob->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* Roll func is a callback which assumes that all is well. */ ebone->roll = roll; @@ -508,7 +508,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op) } if (arm->flag & ARM_MIRROR_EDIT) { - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { @@ -1189,13 +1189,13 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = objects[ob_index]; bArmature *arm = ob->data; - for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) { + LISTBASE_FOREACH (EditBone *, bone, arm->edbo) { if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) { bone->parent = NULL; bone->flag &= ~BONE_CONNECTED; } } - for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) { + LISTBASE_FOREACH (EditBone *, bone, arm->edbo) { ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0); } @@ -1508,7 +1508,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op) bArmature *arm = obedit->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_VISIBLE(arm, ebone)) { if ((ebone->flag & BONE_SELECTED) != invert) { ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); @@ -1567,7 +1567,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op) bArmature *arm = obedit->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { if (!(ebone->flag & BONE_UNSELECTABLE)) { diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index b2c3d951b34..aa1bceb2674 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -317,8 +317,7 @@ void ED_armature_bone_rename(Main *bmain, } } - for (GpencilModifierData *gp_md = ob->greasepencil_modifiers.first; gp_md; - gp_md = gp_md->next) { + LISTBASE_FOREACH (GpencilModifierData *, gp_md, &ob->greasepencil_modifiers) { switch (gp_md->type) { case eGpencilModifierType_Armature: { ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)gp_md; @@ -415,7 +414,7 @@ void ED_armature_bones_flip_names(Main *bmain, /* First pass: generate flip names, and blindly rename. * If rename did not yield expected result, * store both bone's name and expected flipped one into temp list for second pass. */ - for (LinkData *link = bones_names->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, bones_names) { char name_flip[MAXBONENAME]; char *name = link->data; @@ -470,7 +469,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op) ListBase bones_names = {NULL}; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_SELECTED) { BLI_addtail(&bones_names, BLI_genericNodeN(ebone->name)); @@ -557,7 +556,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) continue; } - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_EDITABLE(ebone)) { /* We first need to do the flipped bone, then the original one. diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index c592287c967..644e466e904 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -569,7 +569,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec if (is_select == (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_SELECTED))) { /* clear the bone->parent var of any bone that had this as its parent */ - for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { + LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { if (ebo->parent == curbone) { ebo->parent = NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */ @@ -579,7 +579,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec } /* clear the pchan->parent var of any pchan that had this as its parent */ - for (bPoseChannel *pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) { + LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) { if (pchn->parent == pchan) { pchn->parent = NULL; } @@ -630,7 +630,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) bArmature *arm_old = ob_old->data; bool has_selected_bone = false; bool has_selected_any = false; - for (EditBone *ebone = arm_old->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) { if (EBONE_VISIBLE(arm_old, ebone)) { if (ebone->flag & BONE_SELECTED) { has_selected_bone = true; @@ -836,7 +836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) bool is_active_only_selected = false; if (actbone->flag & BONE_SELECTED) { is_active_only_selected = true; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { if (ebone != actbone) { is_active_only_selected = false; @@ -868,7 +868,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) */ /* Parent selected bones to the active one. */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { if (ebone != actbone) { bone_connect_to_new_parent(arm->edbo, ebone, actbone, val); @@ -902,7 +902,7 @@ static int armature_parent_set_invoke(bContext *C, Object *ob = CTX_data_edit_object(C); bArmature *arm = ob->data; EditBone *actbone = arm->act_edbone; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { if (ebone != actbone) { if (ebone->parent != actbone) { @@ -984,7 +984,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) bArmature *arm = ob->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_EDITABLE(ebone)) { changed = true; break; diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 700fe14ade6..4b938fb0072 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -426,12 +426,12 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo (((ebone)->flag & BONE_CONNECTED) && \ ((ebone)->parent ? EBONE_SELECTABLE(arm, (ebone)->parent) : false)) - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { ebone->temp.i = 0; } /* Select parents. */ - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { if (ebone_iter->temp.i & TOUCH) { continue; } @@ -460,7 +460,7 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo } /* Select children. */ - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { /* No need to 'touch' this bone as it won't be walked over when scanning up the chain. */ if (!CHECK_PARENT(ebone_iter)) { continue; @@ -521,7 +521,7 @@ static int armature_select_linked_exec(bContext *C, wmOperator *op) bArmature *arm = ob->data; bool found = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL))) { ebone->flag |= BONE_DONE; @@ -591,7 +591,7 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const } /* Initialize flags. */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { ebone->flag &= ~BONE_DONE; } ebone_active->flag |= BONE_DONE; @@ -848,7 +848,7 @@ bool ED_armature_edit_deselect_all(Object *obedit) { bArmature *arm = obedit->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); changed = true; @@ -861,7 +861,7 @@ bool ED_armature_edit_deselect_all_visible(Object *obedit) { bArmature *arm = obedit->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { @@ -1138,7 +1138,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) /* Initialize flags. */ { - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { /* Flush the parent flag to this bone * so we don't need to check the parent when adjusting the selection. */ @@ -1160,7 +1160,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) } /* Apply selection from bone selection flags. */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->temp.i != 0) { int is_ignore_flag = ((ebone->temp.i << 16) & (BONESEL_ROOT | BONESEL_TIP)); int is_inside_flag = (ebone->temp.i & (BONESEL_ROOT | BONESEL_TIP | BONESEL_BONE)); @@ -1180,7 +1180,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) if (changed) { /* Cleanup flags. */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->flag & BONE_DONE) { SWAP(int, ebone->temp.i, ebone->flag); ebone->flag |= BONE_DONE; @@ -1193,7 +1193,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) } } - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->flag & BONE_DONE) { if ((ebone->flag & BONE_CONNECTED) && ebone->parent) { bool is_parent_tip_changed = (ebone->parent->flag & BONE_TIPSEL) != @@ -1539,7 +1539,7 @@ static void select_similar_length(bContext *C, const float thresh) bArmature *arm = ob->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { const float len_iter = bone_length_squared_worldspace_get(ob, ebone); if ((len_iter > len_min) && (len_iter < len_max)) { @@ -1587,7 +1587,7 @@ static void select_similar_direction(bContext *C, const float thresh) bArmature *arm = ob->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { float dir[3]; bone_direction_worldspace_get(ob, ebone, dir); @@ -1621,7 +1621,7 @@ static void select_similar_layer(bContext *C) bArmature *arm = ob->data; bool changed = false; - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { if (ebone->layer & ebone_act->layer) { ED_armature_ebone_select_set(ebone, true); @@ -1661,7 +1661,7 @@ static void select_similar_prefix(bContext *C) bool changed = false; /* Find matches */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { char prefix_other[MAXBONENAME]; BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name)); @@ -1703,7 +1703,7 @@ static void select_similar_suffix(bContext *C) bool changed = false; /* Find matches */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { char suffix_other[MAXBONENAME]; BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name)); @@ -1738,7 +1738,7 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons } const char *data_active = (const char *)POINTER_OFFSET(pchan_active, offset); - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { const bPoseChannel *pchan = BKE_pose_channel_find_name(obedit->pose, ebone->name); if (pchan) { @@ -1773,11 +1773,11 @@ static void select_similar_children(bContext *C) bArmature *arm = obedit->data; EditBone *ebone_act = CTX_data_active_bone(C); - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { ebone_iter->temp.ebone = ebone_iter->parent; } - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { is_ancestor(ebone_iter, ebone_act); if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { @@ -1795,7 +1795,7 @@ static void select_similar_children_immediate(bContext *C) bArmature *arm = obedit->data; EditBone *ebone_act = CTX_data_active_bone(C); - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { if (ebone_iter->parent == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { ED_armature_ebone_select_set(ebone_iter, true); } @@ -1815,7 +1815,7 @@ static void select_similar_siblings(bContext *C) return; } - for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { if (ebone_iter->parent == ebone_act->parent && EBONE_SELECTABLE(arm, ebone_iter)) { ED_armature_ebone_select_set(ebone_iter, true); } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index fe456324d9c..cf7f6699e5e 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -92,7 +92,7 @@ void ED_armature_edit_validate_active(struct bArmature *arm) void ED_armature_edit_refresh_layer_used(bArmature *arm) { arm->layer_used = 0; - for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { + LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { arm->layer_used |= ebo->layer; } } @@ -142,7 +142,7 @@ void bone_free(bArmature *arm, EditBone *bone) } /* Clear references from other edit bones. */ - for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->bbone_next == bone) { ebone->bbone_next = NULL; } @@ -472,7 +472,7 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo void ED_armature_edit_transform_mirror_update(Object *obedit) { bArmature *arm = obedit->data; - for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { + LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { ED_armature_ebone_transform_mirror_update(arm, ebo, true); } } @@ -580,7 +580,7 @@ static EditBone *make_boneList_recursive(ListBase *edbo, static EditBone *find_ebone_link(ListBase *edbo, Bone *link) { if (link != NULL) { - for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, edbo) { if (ebone->temp.bone == link) { return ebone; } @@ -596,7 +596,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone) EditBone *active = make_boneList_recursive(edbo, bones, NULL, actBone); - for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, edbo) { Bone *bone = ebone->temp.bone; /* Convert custom B-Bone handle links. */ diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c index d3eeb311863..a3a73f8d509 100644 --- a/source/blender/editors/armature/editarmature_undo.c +++ b/source/blender/editors/armature/editarmature_undo.c @@ -95,7 +95,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm) ED_armature_ebone_listbase_temp_clear(&uarm->lb); - for (EditBone *ebone = uarm->lb.first; ebone; ebone = ebone->next) { + LISTBASE_FOREACH (EditBone *, ebone, &uarm->lb) { uarm->undo_size += sizeof(EditBone); } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index f29900b0760..8df4f6b7dfc 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -323,7 +323,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility) { bArmature *arm = ob->data; - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) { return true; diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 3be5e033e00..31c89ca9f43 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -333,7 +333,7 @@ static void applyarmature_process_selected_recursive(bArmature *arm, pstate = &new_pstate; } - for (Bone *child = bone->childbase.first; child; child = child->next) { + LISTBASE_FOREACH (Bone *, child, &bone->childbase) { applyarmature_process_selected_recursive(arm, pose, pose_eval, child, selected, pstate); } } @@ -389,7 +389,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) if (use_selected) { /* The selected only mode requires a recursive walk to handle parent-child relations. */ - for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { applyarmature_process_selected_recursive( arm, pose, ob_eval->pose, bone, &selected_bones, NULL); } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 45e278d691c..8984c090a0e 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5168,7 +5168,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d) BKE_curve_nurb_vert_active_get(cu, &cu_actnu, &cu_actvert.p); int act_offset = 0; - for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) { BLI_assert(nu->pntsu > 0); int i; int pnt_len = nu->pntsu; @@ -6775,7 +6775,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) continue; } - for (Nurb *nu = editnurb->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, editnurb) { if (ED_curve_nurb_select_check(v3d, nu)) { if (!clear) { nu->flag |= CU_SMOOTH; diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index e009add1acf..9cf61d02677 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -199,7 +199,7 @@ bool ED_curve_nurb_select_all(const Nurb *nu) bool ED_curve_select_all(EditNurb *editnurb) { bool changed = false; - for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) { changed |= ED_curve_nurb_select_all(nu); } return changed; @@ -258,7 +258,7 @@ bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb) bool ED_curve_deselect_all(EditNurb *editnurb) { bool changed = false; - for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) { changed |= ED_curve_nurb_deselect_all(nu); } return changed; diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c index 9566495715a..1528c448c0b 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -543,7 +543,7 @@ static bool gpencil_generate_weights_poll(bContext *C) } /* need some armature in the view layer */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object->type == OB_ARMATURE) { return true; } @@ -630,7 +630,7 @@ static const EnumPropertyItem *gpencil_armatures_enum_itemf(bContext *C, RNA_enum_item_add(&item, &totitem, &item_tmp); i++; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if (ob->type == OB_ARMATURE) { item_tmp.identifier = item_tmp.name = ob->id.name + 2; diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 24c3e9a0635..1e49195140c 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -522,7 +522,7 @@ static bool gp_layer_duplicate_object_poll(bContext *C) } /* check there are more grease pencil objects */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if ((base->object != ob) && (base->object->type == OB_GPENCIL)) { return true; } @@ -571,7 +571,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op) gpl_dst->opacity = gpl_src->opacity; /* Create all frames. */ - for (bGPDframe *gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) { + LISTBASE_FOREACH (bGPDframe *, gpf_src, &gpl_src->frames) { if ((mode == GP_LAYER_COPY_OBJECT_ACT_FRAME) && (gpf_src != gpl_src->actframe)) { continue; @@ -581,7 +581,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op) bGPDframe *gpf_dst = BKE_gpencil_frame_addnew(gpl_dst, gpf_src->framenum); /* Copy strokes. */ - for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) { + LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* Make copy of source stroke. */ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); @@ -1184,12 +1184,12 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op) /* Collect frames of gpl_current in hash table to avoid O(n^2) lookups */ GHash *gh_frames_cur = BLI_ghash_int_new_ex(__func__, 64); - for (bGPDframe *gpf = gpl_current->frames.first; gpf; gpf = gpf->next) { + LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_current->frames) { BLI_ghash_insert(gh_frames_cur, POINTER_FROM_INT(gpf->framenum), gpf); } /* read all frames from next layer and add any missing in current layer */ - for (bGPDframe *gpf = gpl_next->frames.first; gpf; gpf = gpf->next) { + LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_next->frames) { /* try to find frame in current layer */ bGPDframe *frame = BLI_ghash_lookup(gh_frames_cur, POINTER_FROM_INT(gpf->framenum)); if (!frame) { @@ -1439,7 +1439,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op) switch (direction) { /* Bring to Front */ case GP_STROKE_MOVE_TOP: - for (LinkData *link = selected.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &selected) { gps = link->data; BLI_remlink(&gpf->strokes, gps); BLI_addtail(&gpf->strokes, gps); @@ -1454,7 +1454,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op) break; /* Send Backward */ case GP_STROKE_MOVE_DOWN: - for (LinkData *link = selected.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &selected) { gps = link->data; BLI_listbase_link_move(&gpf->strokes, gps, -1); } @@ -2529,7 +2529,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data) /* Fix driver targets */ if (fcu->driver) { /* Fix driver references to invalid ID's */ - for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) { + LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) { /* Only change the used targets, since the others will need fixing manually anyway. */ DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { /* Change the ID's used. */ @@ -2620,7 +2620,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) bGPdata *gpd_src = ob_iter->data; /* Apply all GP modifiers before */ - for (GpencilModifierData *md = ob_iter->greasepencil_modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (GpencilModifierData *, md, &ob_iter->greasepencil_modifiers) { const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type); if (mti->bakeModifier) { mti->bakeModifier(bmain, depsgraph, md, ob_iter); @@ -2629,7 +2629,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) /* copy vertex groups to the base one's */ int old_idx = 0; - for (bDeformGroup *dg = ob_iter->defbase.first; dg; dg = dg->next) { + LISTBASE_FOREACH (bDeformGroup *, dg, &ob_iter->defbase) { bDeformGroup *vgroup = MEM_dupallocN(dg); int idx = BLI_listbase_count(&ob_active->defbase); BKE_object_defgroup_unique_name(vgroup, ob_active); @@ -2681,7 +2681,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, offset_global); mul_v3_m3v3(offset_local, imat, offset_global); - for (bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) { + LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) { bGPDlayer *gpl_new = BKE_gpencil_layer_duplicate(gpl_src); float diff_mat[4][4]; float inverse_diff_mat[4][4]; @@ -2691,7 +2691,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) invert_m4_m4(inverse_diff_mat, diff_mat); Material *ma_src = NULL; - for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) { + LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_new->frames) { LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { /* Reassign material. Look old material and try to find in destination. */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 14fd54bf287..947da9e7877 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1333,7 +1333,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op) if (gp_strokes_copypastebuf.first) { gp_strokes_copypastebuf_colors = BLI_ghash_int_new("GPencil CopyBuf Colors"); GHash *ma_to_name = gp_strokes_copypastebuf_colors_material_to_name_create(bmain); - for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { + LISTBASE_FOREACH (bGPDstroke *, gps, &gp_strokes_copypastebuf) { if (ED_gpencil_stroke_can_use(C, gps)) { Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1); /* Avoid default material. */ diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c index 96146c60acb..2dd98bb8df1 100644 --- a/source/blender/editors/gpencil/gpencil_ops_versioning.c +++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c @@ -117,9 +117,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* added object */ /* convert grease pencil palettes (version >= 2.78) to materials and weights */ - for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { - for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; - palcolor = palcolor->next) { + LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) { + LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) { /* create material slot */ Material *ma = BKE_gpencil_object_material_new(bmain, ob, palcolor->info, NULL); @@ -168,9 +167,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op) } if (is_annotation) { - for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { - for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; - palcolor = palcolor->next) { + LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) { + LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) { /* fix layers */ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { /* unlock/unhide layer */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 0048811d53a..3d571773bc8 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2187,7 +2187,7 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl, /* Save list of strokes to check */ int totstrokes = 0; - for (bGPDstroke *gps_iter = gpf->strokes.first; gps_iter; gps_iter = gps_iter->next) { + LISTBASE_FOREACH (bGPDstroke *, gps_iter, &gpf->strokes) { if (gps_iter->totpoints < 2) { continue; } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 11dc8b3b8b4..339124db355 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -261,7 +261,7 @@ void ui_region_to_window(const ARegion *region, int *x, int *y) static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) { int sepr_flex_len = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_SEPR_SPACER) { sepr_flex_len++; } @@ -283,7 +283,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) /* We could get rid of this loop if we agree on a max number of spacer */ int *spacers_pos = alloca(sizeof(*spacers_pos) * (size_t)sepr_flex_len); int i = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_SEPR_SPACER) { ui_but_to_pixelrect(&rect, region, block, but); spacers_pos[i] = rect.xmax + UI_HEADER_OFFSET; @@ -294,7 +294,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) const float segment_width = region_width / (float)sepr_flex_len; float offset = 0, remaining_space = region_width - buttons_width; i = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { BLI_rctf_translate(&but->rect, offset, 0); if (but->type == UI_BTYPE_SEPR_SPACER) { /* How much the next block overlap with the current segment */ @@ -898,7 +898,7 @@ bool UI_but_active_only(const bContext *C, ARegion *region, uiBlock *block, uiBu bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, uiBlock *block) { bool done = false; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->flag & UI_BUT_ACTIVATE_ON_INIT) { but->flag &= ~UI_BUT_ACTIVATE_ON_INIT; if (ui_but_is_editable(but)) { @@ -913,7 +913,7 @@ bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, ui if (done) { /* Run this in a second pass since it's possible activating the button * removes the buttons being looped over. */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { but->flag &= ~UI_BUT_ACTIVATE_ON_INIT; } } @@ -970,7 +970,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) /* 2 Passes, on for first letter only, second for any letter if first fails * fun first pass on all buttons so first word chars always get first priority */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (!ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_BUT_MENU, @@ -1663,7 +1663,7 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but) } if (optype) { - for (uiButExtraOpIcon *op_icon = but->extra_op_icons.first; op_icon; op_icon = op_icon->next) { + LISTBASE_FOREACH (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) { if ((op_icon->optype_params->optype == optype) && (op_icon->icon == icon)) { /* Don't add the same operator icon twice (happens if button is kept alive while active). */ @@ -1934,7 +1934,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u { uiBut *but_prev = NULL; /* possibly we should keep the region this block is contained in? */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->rnapoin.type && but->rnaprop) { /* quick check to avoid adding buttons representing a vector, multiple times. */ if ((but_prev && (but_prev->rnaprop == but->rnaprop) && @@ -1959,7 +1959,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u void UI_region_message_subscribe(ARegion *region, struct wmMsgBus *mbus) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { ui_block_message_subscribe(region, mbus, block); } } @@ -3274,7 +3274,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb) ARegion *region = CTX_wm_region(C); wmWindow *window = CTX_wm_window(C); - for (uiBlock *block = lb->first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, lb) { if (block->active) { ui_update_window_matrix(window, region, block); } @@ -3283,7 +3283,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb) void UI_blocklist_draw(const bContext *C, const ListBase *lb) { - for (uiBlock *block = lb->first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, lb) { if (block->active) { UI_block_draw(C, block); } diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index 925e9fdd6f9..3d32ede60c2 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -212,7 +212,7 @@ static void eyedropper_add_palette_color(bContext *C, float col_conv[4]) } /* Check if the color exist already. */ Palette *palette = paint->palette; - for (PaletteColor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) { + LISTBASE_FOREACH (PaletteColor *, palcolor, &palette->colors) { if (compare_v3v3(palcolor->rgb, col_conv, 0.01f)) { return; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 04169b7d6dc..2b2d91f3a32 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1272,7 +1272,7 @@ static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *dat data->multi_data.bs_mbuts = UI_butstore_create(but_active->block); - for (uiBut *but = but_active->block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &but_active->block->buttons) { if (but->flag & UI_BUT_DRAG_MULTI) { ui_multibut_add(data, but); } @@ -9241,7 +9241,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float if (dy < 0.0f) { /* Stop at top item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ float ymax = -FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ymax = max_ff(ymax, bt->rect.ymax); } if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) { @@ -9251,7 +9251,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float else { /* Stop at bottom item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ float ymin = FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ymin = min_ff(ymin, bt->rect.ymin); } if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) { @@ -9264,7 +9264,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float block->handle->scrolloffset += dy; /* apply scroll offset */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { bt->rect.ymin += dy; bt->rect.ymax += dy; } @@ -9345,7 +9345,7 @@ static bool ui_menu_scroll_step(ARegion *region, uiBlock *block, const int scrol static void ui_region_auto_open_clear(ARegion *region) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { block->auto_open = false; } } @@ -10984,7 +10984,7 @@ void UI_screen_free_active_but(const bContext *C, bScreen *screen) ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { uiBut *but = ui_region_find_active_but(region); if (but) { uiHandleButtonData *data = but->active; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6e86b60dc53..a28da678728 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2897,7 +2897,7 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout, return; } - for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) { + LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) { /* Causes too many panels, check context. */ if (pt->parent_id[0] == '\0') { if (/* (*context == '\0') || */ STREQ(pt->context, context)) { @@ -5352,7 +5352,7 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout, MEM_freeN(panel); /* Draw child panels. */ - for (LinkData *link = pt->children.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &pt->children) { PanelType *child_pt = link->data; if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 04d1181a8a1..42179452279 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -160,7 +160,7 @@ static int panel_aligned(const ScrArea *area, const ARegion *region) static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation) { - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { /* Detect panel active flag changes. */ if (!(pa->type && pa->type->parent)) { if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) { @@ -394,7 +394,7 @@ void UI_panel_end( pa->blocksizey = height; /* Compute total panel size including children. */ - for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { + LISTBASE_FOREACH (Panel *, pachild, &pa->children) { if (pachild->runtime_flag & PNL_ACTIVE) { width = max_ii(width, pachild->sizex); height += get_panel_real_size_y(pachild); @@ -441,7 +441,7 @@ static void ui_offset_panel_block(uiBlock *block) int ofsy = block->panel->sizey - style->panelspace; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { but->rect.ymin += ofsy; but->rect.ymax += ofsy; } @@ -1006,7 +1006,7 @@ static void align_sub_panels(Panel *pa) /* Position sub panels. */ int ofsy = pa->ofsy + pa->sizey - pa->blocksizey; - for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { + LISTBASE_FOREACH (Panel *, pachild, &pa->children) { if (pachild->runtime_flag & PNL_ACTIVE) { pachild->ofsx = pa->ofsx; pachild->ofsy = ofsy - get_panel_size_y(pachild); @@ -1200,7 +1200,7 @@ static void panel_list_clear_active(ListBase *lb) { /* set all panels as inactive, so that at the end we know * which ones were used */ - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { if (pa->runtime_flag & PNL_ACTIVE) { pa->runtime_flag = PNL_WAS_ACTIVE; } diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 8ba3e5db426..70b4660e392 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -261,7 +261,7 @@ uiBut *ui_but_find_mouse_over_ex(ARegion *region, const int x, const int y, cons if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); @@ -309,7 +309,7 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px) BLI_rctf_rcti_copy(&rect_px_fl, rect_px); uiBut *butover = NULL; - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { rctf rect_block; ui_window_to_block_rctf(region, block, &rect_block, &rect_px_fl); @@ -340,7 +340,7 @@ uiBut *ui_list_find_mouse_over_ex(ARegion *region, int x, int y) if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); for (uiBut *but = block->buttons.last; but; but = but->prev) { @@ -517,7 +517,7 @@ uiBlock *ui_block_find_mouse_over_ex(const ARegion *region, if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { if (only_clip) { if ((block->flag & UI_BLOCK_CLIP_EVENTS) == 0) { continue; @@ -545,8 +545,8 @@ uiBlock *ui_block_find_mouse_over(const ARegion *region, const wmEvent *event, b uiBut *ui_region_find_active_but(ARegion *region) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->active) { return but; } @@ -558,8 +558,8 @@ uiBut *ui_region_find_active_but(ARegion *region) uiBut *ui_region_find_first_but_test_flag(ARegion *region, int flag_include, int flag_exclude) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (((but->flag & flag_include) == flag_include) && ((but->flag & flag_exclude) == 0)) { return but; } @@ -633,7 +633,7 @@ bool ui_region_contains_rect_px(const ARegion *region, const rcti *rect_px) /** Check if the cursor is over any popups. */ ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y) { - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { rcti winrct; ui_region_winrct_get_no_margin(region, &winrct); diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c index ecdcd575d5c..f9873f8b96f 100644 --- a/source/blender/editors/interface/interface_region_color_picker.c +++ b/source/blender/editors/interface/interface_region_color_picker.c @@ -332,7 +332,7 @@ static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) static void ui_colorpicker_hide_reveal(uiBlock *block, enum ePickerType colormode) { /* tag buttons */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { if ((bt->func == ui_colorpicker_rna_cb) && (bt->type == UI_BTYPE_NUM_SLIDER) && (bt->rnaindex != 3)) { /* RGB sliders (color circle and alpha are always shown) */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index a7508894c54..1963c76b96e 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -278,11 +278,11 @@ static ARegion *hud_region_add(ScrArea *area) void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *area_keep) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area != area_keep) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_HUD) { if ((region->flag & RGN_FLAG_HIDDEN) == 0) { hud_region_hide(region); diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index dbec8e6d653..a161a449ba0 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -669,7 +669,7 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) /* In the case we have nested popups, * closing one may need to redraw another, see: T48874 */ - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { ED_region_tag_refresh_ui(region); } } @@ -678,8 +678,8 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) bool UI_popup_block_name_exists(const bScreen *screen, const char *name) { - for (const ARegion *region = screen->regionbase.first; region; region = region->next) { - for (const uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (const ARegion *, region, &screen->regionbase) { + LISTBASE_FOREACH (const uiBlock *, block, ®ion->uiblocks) { if (STREQ(block->name, name)) { return true; } diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index a51558e4cfe..2ad7e517c60 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -118,7 +118,7 @@ static void ui_popup_block_position(wmWindow *window, if (block->buttons.first) { BLI_rctf_init_minmax(&block->rect); - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { if (block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT) { bt->rect.xmax += UI_MENU_SUBMENU_PADDING; } @@ -294,7 +294,7 @@ static void ui_popup_block_position(wmWindow *window, } /* Apply offset, buttons in window coords. */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect); BLI_rctf_translate(&bt->rect, offset_x, offset_y); @@ -698,7 +698,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, /* lastly set the buttons at the center of the pie menu, ready for animation */ if (U.pie_animation_timeout > 0) { - for (uiBut *but_iter = block->buttons.first; but_iter; but_iter = but_iter->next) { + LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { if (but_iter->pie_dir != UI_RADIAL_NONE) { BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned)); } @@ -742,7 +742,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, /* apply scroll offset */ if (handle->scrolloffset != 0.0f) { - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { bt->rect.ymin += handle->scrolloffset; bt->rect.ymax += handle->scrolloffset; } @@ -846,7 +846,7 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) * then close the popover too. We could extend this to other popup types too. */ ARegion *region = handle->popup_create_vars.butregion; if (region != NULL) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { if (block->handle && (block->flag & UI_BLOCK_POPOVER) && (block->flag & UI_BLOCK_KEEP_OPEN) == 0) { uiPopupBlockHandle *menu = block->handle; diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 8b41d92ea74..58a13c6c456 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -319,7 +319,7 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData *data, const int fields_len_init = data->fields_len; char buf[512]; - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, true); if (ot != NULL) { /* Tip */ @@ -597,7 +597,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else if (BPY_execute_string_as_intptr(C, expr_imports, expr, true, &expr_result)) { if (expr_result != 0) { wmKeyMap *keymap = (wmKeyMap *)expr_result; - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if (STREQ(kmi->idname, but->optype->idname)) { char tool_id_test[MAX_NAME]; RNA_string_get(kmi->ptr, "name", tool_id_test); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6bd956c87b0..ba7cd708bfa 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1159,7 +1159,7 @@ static void template_ID_tabs(bContext *C, ListBase ordered; BKE_id_ordered_list(&ordered, template->idlb); - for (LinkData *link = ordered.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ordered) { ID *id = link->data; const int name_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2); const int but_width = name_width + UI_UNIT_X; @@ -2428,7 +2428,7 @@ static void template_operator_redo_property_buts_draw( const bContext *C, wmOperator *op, uiLayout *layout, int layout_flags, bool *r_has_advanced) { if (op->type->flag & OPTYPE_MACRO) { - for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) { + LISTBASE_FOREACH (wmOperator *, macro_op, &op->macro) { template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced); } } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 97a3a7eefe4..c07166b9ad2 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -269,7 +269,6 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_BOUNDS; - if (do_init) { v2d->tot.xmin = v2d->tot.ymin = 0.0f; v2d->tot.xmax = (float)(winx - 1); @@ -900,7 +899,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) /* check if doing whole screen syncing (i.e. time/horizontal) */ if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) { - for (ScrArea *area_iter = screen->areabase.first; area_iter; area_iter = area_iter->next) { + LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) { for (region = area_iter->regionbase.first; region; region = region->next) { /* don't operate on self */ if (v2dcur != ®ion->v2d) { diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 88e9c7c3664..bea44ee89f8 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -610,7 +610,7 @@ static void draw_mask_layers(const bContext *C, continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { /* draw curve itself first... */ draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index a0ece69bf17..68dfe0d151f 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1293,12 +1293,12 @@ static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { if (ED_mask_spline_select_check(spline)) { spline->flag ^= MASK_SPLINE_CYCLIC; } @@ -1371,7 +1371,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) Mask *mask = CTX_data_edit_mask(C); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { MaskSpline *spline; int mask_layer_shape_ofs = 0; @@ -1493,14 +1493,14 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) bool changed = false; /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { bool changed_layer = false; if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { if (ED_mask_spline_select_check(spline)) { BKE_mask_spline_direction_switch(mask_layer, spline); changed = true; @@ -1551,14 +1551,14 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op) bool changed = false; /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { bool changed_layer = false; if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -1614,12 +1614,12 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -1695,7 +1695,7 @@ static int mask_hide_view_clear_exec(bContext *C, wmOperator *op) bool changed = false; const bool select = RNA_boolean_get(op->ptr, "select"); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & OB_RESTRICT_VIEWPORT) { ED_mask_layer_select_set(mask_layer, select); @@ -1739,7 +1739,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op) const bool unselected = RNA_boolean_get(op->ptr, "unselected"); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) { continue; @@ -1801,12 +1801,12 @@ static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op)) Mask *mask = CTX_data_edit_mask(C); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_SELECT | MASK_RESTRICT_VIEW)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -1935,7 +1935,7 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { for (MaskSpline *spline = mask_layer->splines.last; spline; spline = spline->prev) { MaskSplinePoint *point = spline->points; int i = 0; diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 5c824fef74d..971e1c948c9 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -45,12 +45,12 @@ static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -137,12 +137,12 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 8d037258450..a6dece91eb0 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -74,7 +74,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer) return false; } - for (const MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (const MaskSpline *, spline, &mask_layer->splines) { if (ED_mask_spline_select_check(spline)) { return true; } @@ -85,8 +85,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer) bool ED_mask_select_check(const Mask *mask) { - for (const MaskLayer *mask_layer = mask->masklayers.first; mask_layer; - mask_layer = mask_layer->next) { + LISTBASE_FOREACH (const MaskLayer *, mask_layer, &mask->masklayers) { if (ED_mask_layer_select_check(mask_layer)) { return true; } @@ -122,7 +121,7 @@ void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select) } } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { ED_mask_spline_select_set(spline, do_select); } } @@ -138,7 +137,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action) } } - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) { continue; @@ -151,7 +150,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action) if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { int i; for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -167,8 +166,8 @@ void ED_mask_select_toggle_all(Mask *mask, int action) void ED_mask_select_flush_all(Mask *mask) { - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { spline->flag &= ~SELECT; /* intentionally _dont_ do this in the mask layer loop @@ -459,12 +458,12 @@ static int box_select_exec(bContext *C, wmOperator *op) ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); for (int i = 0; i < spline->tot_point; i++) { @@ -544,12 +543,12 @@ static bool do_lasso_select_mask(bContext *C, BLI_lasso_boundbox(&rect, mcords, moves); /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); for (int i = 0; i < spline->tot_point; i++) { @@ -686,12 +685,12 @@ static int circle_select_exec(bContext *C, wmOperator *op) } /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); for (i = 0; i < spline->tot_point; i++) { @@ -815,12 +814,12 @@ static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) bool changed = false; /* do actual selection */ - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { if (ED_mask_spline_select_check(spline)) { ED_mask_spline_select_set(spline, true); changed = true; @@ -865,12 +864,12 @@ static int mask_select_more_less(bContext *C, bool more) { Mask *mask = CTX_data_edit_mask(C); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0; bool start_sel, end_sel, prev_sel, cur_sel; int i; diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 25b602d63c3..f264e67d35c 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -53,7 +53,7 @@ static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op)) Mask *mask = CTX_data_edit_mask(C); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { MaskLayerShape *mask_layer_shape; if (!ED_mask_layer_select_check(mask_layer)) { @@ -98,7 +98,7 @@ static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) Mask *mask = CTX_data_edit_mask(C); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { MaskLayerShape *mask_layer_shape; if (!ED_mask_layer_select_check(mask_layer)) { @@ -146,7 +146,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op) Mask *mask = CTX_data_edit_mask(C); bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; @@ -172,7 +172,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op) shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data; shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data; - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -243,7 +243,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) const bool do_feather = RNA_boolean_get(op->ptr, "feather"); const bool do_location = RNA_boolean_get(op->ptr, "location"); - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } @@ -324,7 +324,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data; shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data; - for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { + LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -404,7 +404,7 @@ bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame) { bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { ED_mask_layer_shape_auto_key(mask_layer, frame); changed = true; } @@ -416,7 +416,7 @@ bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame) { bool changed = false; - for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { + LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { if (!ED_mask_layer_select_check(mask_layer)) { continue; diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index aa737a1701a..feb6b5aaca9 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -1031,7 +1031,7 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo * could shift because of float precision. * Updates in this case are also redundant. */ bool is_modal = false; - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->state & WM_GIZMO_STATE_MODAL) { is_modal = true; break; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 08976cc46c4..998e0d736e6 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -370,8 +370,7 @@ void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data) * cycles. */ #if 0 - for (Object *other_object = bmain->objects.first; other_object != NULL; - other_object = other_object->id.next) { + for (Object *other_object = bmain->objects.first; other_object != NULL; other_object = other_object->id.next) { if (other_object->data == ob->data) { BKE_object_free_derived_caches(other_object); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 519822dd65c..4a1450eaccc 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -161,7 +161,7 @@ static void join_mesh_single(Depsgraph *depsgraph, */ if (key) { /* if this mesh has any shapekeys, check first, otherwise just copy coordinates */ - for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { /* get pointer to where to write data for this mesh in shapekey's data array */ float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; @@ -191,7 +191,7 @@ static void join_mesh_single(Depsgraph *depsgraph, * - otherwise, copy across plain coordinates (no need to transform coordinates) */ if (key) { - for (KeyBlock *kb = key->block.first; kb; kb = kb->next) { + LISTBASE_FOREACH (KeyBlock *, kb, &key->block) { /* get pointer to where to write data for this mesh in shapekey's data array */ float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs; @@ -440,7 +440,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } /* Join this object's face maps to the base one's. */ - for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) { + LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) { /* See if this group exists in the object (if it doesn't, add it to the end) */ if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) { bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap"); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index b96f225f660..9386c466f95 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -456,7 +456,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) RNG *rng = BLI_rng_new_srandom(seed_iter); - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { if (BLI_rng_get_float(rng) < randfac) { if (select) { ml->flag |= SELECT; @@ -656,7 +656,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op) const bool select = RNA_boolean_get(op->ptr, "select"); bool changed = false; - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { if (ml->flag & MB_HIDE) { SET_FLAG_FROM_TEST(ml->flag, select, SELECT); ml->flag &= ~MB_HIDE; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index a74dc6a1384..9119d1cac86 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2255,7 +2255,7 @@ static int convert_exec(bContext *C, wmOperator *op) * needed since re-evaluating single modifiers causes bugs if they depend * on other objects data masks too, see: T50950. */ { - for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) { + LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) { Base *base = link->ptr.data; Object *ob = base->object; @@ -2282,7 +2282,7 @@ static int convert_exec(bContext *C, wmOperator *op) scene->customdata_mask = customdata_mask_prev; } - for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) { + LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) { Object *newob = NULL; Base *base = link->ptr.data; Object *ob = base->object; diff --git a/source/blender/editors/object/object_data_transform.c b/source/blender/editors/object/object_data_transform.c index fc91cbb9666..54fd1fe6671 100644 --- a/source/blender/editors/object/object_data_transform.c +++ b/source/blender/editors/object/object_data_transform.c @@ -92,7 +92,7 @@ static struct ElemData_Armature *armature_coords_and_quats_get_recurse( const ListBase *bone_base, struct ElemData_Armature *elem_array) { struct ElemData_Armature *elem = elem_array; - for (const Bone *bone = bone_base->first; bone; bone = bone->next) { + LISTBASE_FOREACH (const Bone *, bone, bone_base) { #define COPY_PTR(member) memcpy(elem->member, bone->member, sizeof(bone->member)) #define COPY_VAL(member) memcpy(&elem->member, &bone->member, sizeof(bone->member)) @@ -125,7 +125,7 @@ static const struct ElemData_Armature *armature_coords_and_quats_apply_with_mat4 ListBase *bone_base, const struct ElemData_Armature *elem_array, const float mat[4][4]) { const struct ElemData_Armature *elem = elem_array; - for (Bone *bone = bone_base->first; bone; bone = bone->next) { + LISTBASE_FOREACH (Bone *, bone, bone_base) { #define COPY_PTR(member) memcpy(bone->member, elem->member, sizeof(bone->member)) #define COPY_VAL(member) memcpy(&bone->member, &elem->member, sizeof(bone->member)) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index ee9b6b411ce..5506895613b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -166,7 +166,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) const bool select = RNA_boolean_get(op->ptr, "select"); bool changed = false; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->flag & BASE_HIDDEN) { base->flag &= ~BASE_HIDDEN; changed = true; @@ -217,7 +217,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) bool changed = false; /* Hide selected or unselected objects. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) { continue; } @@ -321,7 +321,7 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - for (LayerCollection *lc = lc_scene->layer_collections.first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, &lc_scene->layer_collections) { int index = BKE_layer_collection_findindex(view_layer, lc); uiLayout *row = uiLayoutRow(layout, false); @@ -414,7 +414,7 @@ static bool mesh_needs_keyindex(Main *bmain, const Mesh *me) return true; } if (ob->data == me) { - for (const ModifierData *md = ob->modifiers.first; md; md = md->next) { + LISTBASE_FOREACH (const ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_Hook) { return true; } @@ -1593,7 +1593,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - for (LinkData *link = objects.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &objects) { Object *ob = link->data; if (!is_link) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index c5fccc5defd..256e32c7bfc 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1753,7 +1753,7 @@ static void libblock_relink_collection(Collection *collection, const bool do_col BKE_libblock_relink_to_newid(&cob->ob->id); } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { libblock_relink_collection(child->collection, true); } } @@ -1772,7 +1772,7 @@ static Collection *single_object_users_collection(Main *bmain, } /* We do not remap to new objects here, this is done in separate step. */ - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Object *ob = cob->ob; /* an object may be in more than one collection */ if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) { @@ -2106,7 +2106,7 @@ void ED_object_single_users(Main *bmain, if (scene->nodetree) { IDP_RelinkProperty(scene->nodetree->id.properties); - for (bNode *node = scene->nodetree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) { IDP_RelinkProperty(node->prop); } } @@ -2245,7 +2245,7 @@ static void make_local_animdata_tag(AnimData *adt) /* TODO: need to handle the ID-targets too? */ /* NLA Data */ - for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { make_local_animdata_tag_strips(&nlt->strips); } } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 8f01adb202e..5f9799710dc 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -246,7 +246,7 @@ Base *ED_object_find_first_by_data_id(ViewLayer *view_layer, ID *id) Base *base_best = NULL; int priority_best = 0; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object && base->object->data == id) { if (base->flag & BASE_SELECTED) { return base; @@ -1325,7 +1325,7 @@ static bool object_select_more_less(bContext *C, const bool select) { ViewLayer *view_layer = CTX_data_view_layer(C); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; ob->flag &= ~OB_DONE; ob->id.tag &= ~LIB_TAG_DOIT; diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c index 8925d165b9b..00aafc2120f 100644 --- a/source/blender/editors/object/object_utils.c +++ b/source/blender/editors/object/object_utils.c @@ -194,7 +194,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array( BLI_gset_add(objects_in_transdata, ob); } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if (ob->parent != NULL) { if (!BLI_gset_haskey(objects_in_transdata, ob)) { @@ -224,7 +224,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array( } } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if (BLI_gset_haskey(objects_in_transdata, ob)) { diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c index 92fb0788f6b..bb619972e80 100644 --- a/source/blender/editors/object/object_volume.c +++ b/source/blender/editors/object/object_volume.c @@ -96,7 +96,7 @@ static int volume_import_exec(bContext *C, wmOperator *op) bool imported = false; ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, false); - for (ImageFrameRange *range = ranges.first; range; range = range->next) { + LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) { char filename[FILE_MAX]; BLI_split_file_part(range->filepath, filename, sizeof(filename)); BLI_path_extension_replace(filename, sizeof(filename), ""); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 3d87220979b..1237c2c2eda 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -551,7 +551,7 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, for (win = wm->windows.first; win && matched_area == NULL; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_IMAGE) { SpaceImage *sima = area->spacedata.first; // area->spacedata might be empty when toggling fullscreen mode. @@ -689,7 +689,7 @@ static void render_image_restore_layer(RenderJob *rj) for (win = wm->windows.first; win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area == rj->area) { if (area->spacetype == SPACE_IMAGE) { SpaceImage *sima = area->spacedata.first; @@ -887,7 +887,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) /* Go over all the visible objects. */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (base = view_layer->object_bases.first; base; base = base->next) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 2c508472a9c..0432057bb47 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -304,7 +304,7 @@ static void set_preview_visibility(Scene *scene, } /* Hide floor for icon renders. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (STREQ(base->object->id.name + 2, "Floor")) { if (pr_method == PR_ICON_RENDER) { base->object->restrictflag |= OB_RESTRICT_RENDER; @@ -463,7 +463,7 @@ static Scene *preview_prepare_scene( sce->display.render_aa = SCE_DISPLAY_AA_OFF; } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object->id.name[2] == 'p') { /* copy over object color, in case material uses it */ copy_v4_v4(base->object->color, sp->color); @@ -522,7 +522,7 @@ static Scene *preview_prepare_scene( sce->world->horb = 0.0f; } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object->id.name[2] == 'p') { if (base->object->type == OB_LAMP) { base->object->data = la; diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 24b1c5a36f8..10f69f3fe9d 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -182,7 +182,7 @@ void ED_render_engine_changed(Main *bmain) { /* on changing the render engine type, clear all running render engines */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { ED_render_engine_area_exit(bmain, area); } } @@ -206,7 +206,7 @@ void ED_render_engine_changed(Main *bmain) void ED_render_view_layer_changed(Main *bmain, bScreen *screen) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { ED_render_engine_area_exit(bmain, area); } } diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 114cb54636a..d78b1532a39 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -99,7 +99,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene) return false; } - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->parent != NULL) { /* We only care about main windows here... */ continue; } @@ -175,7 +175,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep /* Remove from windows. */ wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) { ViewLayer *first_layer = BKE_view_layer_default_view(scene); STRNCPY(win->view_layer_name, first_layer->name); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 751f37dc5ec..49838b62b71 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -799,7 +799,7 @@ void ED_workspace_status_text(bContext *C, const char *str) } /* Redraw status bar. */ - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { if (area->spacetype == SPACE_STATUSBAR) { ED_area_tag_redraw(area); break; @@ -1824,7 +1824,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar /* Dynamically sized regions may have changed region sizes, so we have to force azone update. */ area_azone_initialize(win, screen, area); - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { region_subwindow(region); /* region size may have changed, init does necessary adjustments */ @@ -2176,7 +2176,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi if (sync_header_alignment) { /* Spaces with footer. */ if (st->spaceid == SPACE_TEXT) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { region->alignment = header_alignment; } @@ -2189,7 +2189,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi } } else { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { region->alignment = header_alignment; break; @@ -2440,7 +2440,7 @@ static void ed_panel_draw(const bContext *C, /* Draw child panels. */ if (open) { - for (LinkData *link = pt->children.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &pt->children) { PanelType *child_pt = link->data; Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt); @@ -2856,7 +2856,7 @@ int ED_area_headersize(void) int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_HEADER) { return region->alignment; } @@ -2877,7 +2877,7 @@ int ED_area_footersize(void) int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_FOOTER) { return region->alignment; } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 089865bb60c..2ac113d2ba7 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -130,7 +130,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "visible_objects")) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_VISIBLE(v3d, base)) { CTX_data_id_list_add(result, &base->object->id); } @@ -139,7 +139,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selectable_objects")) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_SELECTABLE(v3d, base)) { CTX_data_id_list_add(result, &base->object->id); } @@ -148,7 +148,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_objects")) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_SELECTED(v3d, base)) { CTX_data_id_list_add(result, &base->object->id); } @@ -157,7 +157,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_editable_objects")) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_SELECTED_EDITABLE(v3d, base)) { CTX_data_id_list_add(result, &base->object->id); } @@ -167,7 +167,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "editable_objects")) { /* Visible + Editable, but not necessarily selected */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_EDITABLE(v3d, base)) { CTX_data_id_list_add(result, &base->object->id); } @@ -726,7 +726,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data); } @@ -749,7 +749,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { CTX_data_pointer_set(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data); break; diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index c1b6df07129..2452302561b 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -547,7 +547,7 @@ static void screen_preview_scale_get( { float max_x = 0, max_y = 0; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { max_x = MAX2(max_x, area->totrct.xmax); max_y = MAX2(max_y, area->totrct.ymax); } @@ -566,7 +566,7 @@ static void screen_preview_draw_areas(const bScreen *screen, immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { rctf rect = { .xmin = area->totrct.xmin * scale[0] + ofs_h, .xmax = area->totrct.xmax * scale[0] - ofs_h, diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 16ef93872ff..8608c18c988 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -415,7 +415,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed) ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region == screen->active_region) { region_cursor_set_ex(win, area, region, swin_changed); return; @@ -607,14 +607,14 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) screen->active_region = NULL; - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { ED_region_exit(C, region); } - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { ED_area_exit(C, area); } /* Don't use ED_screen_areas_iter here, it skips hidden areas. */ - for (ScrArea *area = window->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &window->global_areas.areabase) { ED_area_exit(C, area); } @@ -912,7 +912,7 @@ void ED_screen_global_areas_sync(wmWindow *win) screen->flag &= ~SCREEN_COLLAPSE_STATUSBAR; - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { if (area->global->cur_fixed_height == area->global->size_min) { if (area->spacetype == SPACE_STATUSBAR) { screen->flag |= SCREEN_COLLAPSE_STATUSBAR; @@ -978,7 +978,7 @@ bScreen *screen_change_prepare( wmTimer *wt = screen_old->animtimer; /* remove handlers referencing areas in old screen */ - for (ScrArea *area = screen_old->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen_old->areabase) { WM_event_remove_area_handler(&win->modalhandlers, area); } @@ -1109,8 +1109,8 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) /* Update 3D view cameras. */ const bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; screen_set_3dview_camera(scene, view_layer, area, v3d); @@ -1249,7 +1249,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const /* find old area to restore from */ ScrArea *fullsa = NULL; - for (ScrArea *old = screen->areabase.first; old; old = old->next) { + LISTBASE_FOREACH (ScrArea *, old, &screen->areabase) { /* area to restore from is always first */ if (old->full && !fullsa) { fullsa = old; @@ -1270,8 +1270,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const if (state == SCREENFULL) { /* unhide global areas */ - for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area; - glob_area = glob_area->next) { + LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) { glob_area->global->flag &= ~GLOBAL_AREA_IS_HIDDEN; } /* restore the old side panels/header visibility */ @@ -1335,8 +1334,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const if (state == SCREENFULL) { /* temporarily hide global areas */ - for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area; - glob_area = glob_area->next) { + LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) { glob_area->global->flag |= GLOBAL_AREA_IS_HIDDEN; } /* temporarily hide the side panels/header */ @@ -1662,7 +1660,7 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen, const wmWindowManager *wm, struct wmWindow **r_window) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (WM_window_get_active_screen(win) == screen) { if (r_window) { *r_window = win; @@ -1680,14 +1678,14 @@ ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen, const bool only_visible) { if (only_visible) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacedata.first == sl) { return area; } } } else { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (BLI_findindex(&area->spacedata, sl) != -1) { return area; } @@ -1703,7 +1701,7 @@ Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm) wmWindow *ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (WM_window_get_active_screen(win) == screen) { return win; } diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 178c375c8ee..4069795657e 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -96,7 +96,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map, CLAMP_MIN(safety, 2); - for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) { + LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) { if (screen_geom_edge_is_horizontal(se)) { if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) { short min, max; @@ -198,7 +198,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) if (facy > 1) { /* Keep timeline small in video edit workspace. */ - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect.ymin && screen_geom_area_height(area) <= headery * facy + 1) { ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3); @@ -222,7 +222,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) } if (facy < 1) { /* make each window at least ED_area_headersize() high */ - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (screen_geom_area_height(area) < headery) { /* lower edge */ ScrEdge *se = BKE_screen_find_edge(screen, area->v4, area->v1); @@ -248,7 +248,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) /* Global areas have a fixed size that only changes with the DPI. * Here we ensure that exactly this size is set. */ - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) { continue; } @@ -379,7 +379,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) while (oneselected) { oneselected = false; - for (ScrEdge *se = screen->edgebase.first; se; se = se->next) { + LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) { if (se->v1->flag + se->v2->flag == 1) { if (dir == 'h') { if (se->v1->vec.y == se->v2->vec.y) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 08bf6f67215..452984f2333 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -681,7 +681,7 @@ static bool actionzone_area_poll(bContext *C) const int *xy = &win->eventstate->x; AZone *az; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { for (az = area->actionzones.first; az; az = az->next) { if (BLI_rcti_isect_pt_v(&az->rect, xy)) { return 1; @@ -895,7 +895,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b /* Finds an action-zone by position in entire screen so azones can overlap. */ static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2]) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { AZone *az = area_actionzone_refresh_xy(area, xy, true); if (az != NULL) { return az; @@ -907,8 +907,8 @@ static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2]) /* Returns the area that the azone belongs to */ static ScrArea *screen_actionzone_area(bScreen *screen, const AZone *az) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (AZone *zone = area->actionzones.first; zone; zone = zone->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (AZone *, zone, &area->actionzones) { if (zone == az) { return area; } @@ -1470,7 +1470,7 @@ static void area_move_set_limits(wmWindow *win, if (use_bigger_smaller_snap != NULL) { *use_bigger_smaller_snap = false; - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { int size_min = ED_area_global_min_size_y(area) - 1; int size_max = ED_area_global_max_size_y(area) - 1; @@ -1511,7 +1511,7 @@ static void area_move_set_limits(wmWindow *win, WM_window_rect_calc(win, &window_rect); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (dir == 'h') { int y1; areamin = areaminy; @@ -1661,13 +1661,13 @@ static int area_snap_calc_location(const bScreen *screen, } } - for (const ScrVert *v1 = screen->vertbase.first; v1; v1 = v1->next) { + LISTBASE_FOREACH (const ScrVert *, v1, &screen->vertbase) { if (!v1->editflag) { continue; } const int v_loc = (&v1->vec.x)[!axis]; - for (const ScrVert *v2 = screen->vertbase.first; v2; v2 = v2->next) { + LISTBASE_FOREACH (const ScrVert *, v2, &screen->vertbase) { if (v2->editflag) { continue; } @@ -2504,7 +2504,7 @@ static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge) /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region == scalear) { continue; } @@ -2801,11 +2801,11 @@ static void areas_do_frame_follow(bContext *C, bool middle) bScreen *screen_ctx = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); - for (wmWindow *window = wm->windows.first; window; window = window->next) { + LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { const bScreen *screen = WM_window_get_active_screen(window); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { /* do follow here if editor type supports it */ if ((screen_ctx->redraws_flag & TIME_FOLLOW)) { if ((region->regiontype == RGN_TYPE_WINDOW && @@ -4595,7 +4595,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* find window that owns the animation timer */ bScreen *ED_screen_animation_playing(const wmWindowManager *wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); if (screen->animtimer || screen->scrubbing) { @@ -4608,7 +4608,7 @@ bScreen *ED_screen_animation_playing(const wmWindowManager *wm) bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); if (screen->animtimer) { @@ -5388,7 +5388,7 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve ListBase ordered; BKE_id_ordered_list(&ordered, &bmain->workspaces); - for (LinkData *link = ordered.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ordered) { if (link->data == workspace_src) { if (direction == SPACE_CONTEXT_CYCLE_PREV) { workspace_dst = (link->prev) ? link->prev->data : NULL; diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c index 38d83801f2b..733e8b694a6 100644 --- a/source/blender/editors/screen/screen_user_menu.c +++ b/source/blender/editors/screen/screen_user_menu.c @@ -113,7 +113,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb, IDProperty *prop, short opcontext) { - for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) && @@ -128,7 +128,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb, struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb, const struct MenuType *mt) { - for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { if (umi->type == USER_MENU_TYPE_MENU) { bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; if (STREQ(mt->idname, umi_mt->mt_idname)) { @@ -144,7 +144,7 @@ struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *l const char *prop_id, int prop_index) { - for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { if (umi->type == USER_MENU_TYPE_PROP) { bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) && @@ -222,7 +222,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) if (um == NULL) { continue; } - for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) { const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 784fa60999d..8feef0c675a 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -198,8 +198,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo /* TODO(campbell): tools */ - for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; - layout_old = layout_old->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) { WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( bmain, workspace_new, layout_old, win); @@ -222,7 +221,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo ListBase ordered; BKE_id_ordered_list(&ordered, &bmain->workspaces); WorkSpace *prev = NULL, *next = NULL; - for (LinkData *link = ordered.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ordered) { if (link->data == workspace) { prev = link->prev ? link->prev->data : NULL; next = link->next ? link->next->data : NULL; @@ -232,7 +231,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo BLI_freelistN(&ordered); BLI_assert((prev != NULL) || (next != NULL)); - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace_active = WM_window_get_active_workspace(win); if (workspace_active == workspace) { ED_workspace_change((prev != NULL) ? prev : next, C, wm, win); @@ -481,7 +480,7 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS ListBase templates; BKE_appdir_app_templates(&templates); - for (LinkData *link = templates.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &templates) { char *template = link->data; char display_name[FILE_MAX]; diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c index 1e85a6e256f..cf9637788a9 100644 --- a/source/blender/editors/screen/workspace_layout_edit.c +++ b/source/blender/editors/screen/workspace_layout_edit.c @@ -68,7 +68,7 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(Main *bmain, screen_new = BKE_workspace_layout_screen_get(layout_new); if (BKE_screen_is_fullscreen_area(screen_old)) { - for (ScrArea *area_old = screen_old->areabase.first; area_old; area_old = area_old->next) { + LISTBASE_FOREACH (ScrArea *, area_old, &screen_old->areabase) { if (area_old->full) { ScrArea *area_new = (ScrArea *)screen_new->areabase.first; ED_area_data_copy(area_new, area_old, true); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9c41989fcd4..4d4af028570 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -808,10 +808,10 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene) ImagePaintSettings *imapaint = &settings->imapaint; bool enabled = false; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_IMAGE) { if (((SpaceImage *)area->spacedata.first)->mode == SI_MODE_PAINT) { enabled = true; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index cc848b80bb3..d607b6a9d6f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -397,7 +397,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op) color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__); /* Put all colors in an array. */ int t = 0; - for (PaletteColor *color = palette->colors.first; color; color = color->next) { + LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { float h, s, v; rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v); col_elm = &color_array[t]; @@ -543,7 +543,7 @@ static int palette_join_exec(bContext *C, wmOperator *op) const int totcol = BLI_listbase_count(&palette_join->colors); if (totcol > 0) { - for (PaletteColor *color = palette_join->colors.first; color; color = color->next) { + LISTBASE_FOREACH (PaletteColor *, color, &palette_join->colors) { PaletteColor *palcol = BKE_palette_color_add(palette); if (palcol) { copy_v3_v3(palcol->rgb, color->rgb); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a981e722b1c..2b5d576f7c2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7821,9 +7821,9 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate rv3d->rflag &= ~RV3D_PAINTING; } - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { SpaceLink *sl = area->spacedata.first; if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -7834,7 +7834,7 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate /* Tag all 3D viewports for redraw now that we are done. Others * viewports did not get a full redraw, and anti-aliasing for the * current viewport was deactivated. */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { ED_region_tag_redraw(region); } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 605d239133a..52287b07b28 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -561,7 +561,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) /* Iterate over pointcaches on the active object, and draw each one's range. */ float y_offset = 0.0f; const float cache_draw_height = 4.0f * UI_DPI_FAC * U.pixelsize; - for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) { + LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) { if (timeline_cache_is_hidden_by_setting(saction, pid)) { continue; } diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 173c2f1b5dc..26c29d6cbe7 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -437,7 +437,7 @@ static void box_select_elem( ListBase anim_data = {NULL, NULL}; ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype); - for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) { + LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) { box_select_elem(sel_data, ale2, xmin, xmax, true); } @@ -675,7 +675,7 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b ListBase anim_data = {NULL, NULL}; ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype); - for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) { + LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) { region_select_elem(sel_data, ale2, true); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index f3304a48cac..e92ea906237 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -563,7 +563,7 @@ static void action_listener(wmWindow *UNUSED(win), ED_area_tag_redraw(area); break; case ND_FRAME_RANGE: - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { Scene *scene = wmn->reference; region->v2d.tot.xmin = (float)(SFRA - 4); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index c8488fc13a4..c06c107d4a3 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -312,7 +312,7 @@ static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *reg static void buttons_navigation_bar_region_draw(const bContext *C, ARegion *region) { - for (PanelType *pt = region->type->paneltypes.first; pt; pt = pt->next) { + LISTBASE_FOREACH (PanelType *, pt, ®ion->type->paneltypes) { pt->flag |= PNL_LAYOUT_VERT_BAR; } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 0453e58d3fb..ffc50407917 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -311,10 +311,10 @@ void ED_clip_update_frame(const Main *mainp, int cfra) { /* image window, compo node users */ for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_CLIP) { SpaceClip *sc = area->spacedata.first; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 38f67623c99..67e64c52051 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1275,7 +1275,7 @@ static Image *image_open_single(Main *bmain, if ((range->length > 1) && (ima->source == IMA_SRC_FILE)) { if (range->udim_tiles.first && range->offset == 1001) { ima->source = IMA_SRC_TILED; - for (LinkData *node = range->udim_tiles.first; node; node = node->next) { + LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) { BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL); } } @@ -1309,7 +1309,7 @@ static int image_open_exec(bContext *C, wmOperator *op) } ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, use_udim); - for (ImageFrameRange *range = ranges.first; range; range = range->next) { + LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) { Image *ima_range = image_open_single( bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview); @@ -1359,7 +1359,7 @@ static int image_open_exec(bContext *C, wmOperator *op) if (iuser == NULL) { Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; if (cam) { - for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { + LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) { if (bgpic->ima == ima) { iuser = &bgpic->iuser; break; diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c index 245495bd179..8b298045597 100644 --- a/source/blender/editors/space_image/image_sequence.c +++ b/source/blender/editors/space_image/image_sequence.c @@ -226,7 +226,7 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo const bool was_relative = BLI_path_is_rel(filepath); image_sequence_get_frame_ranges(op, &ranges); - for (ImageFrameRange *range = ranges.first; range; range = range->next) { + LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) { image_detect_frame_range(range, detect_udim); BLI_freelistN(&range->frames); diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c index 5f81c19290b..056dd826238 100644 --- a/source/blender/editors/space_image/image_undo.c +++ b/source/blender/editors/space_image/image_undo.c @@ -145,7 +145,7 @@ static void ptile_free_list(ListBase *paint_tiles) static void ptile_invalidate_list(ListBase *paint_tiles) { - for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) { + LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) { ptile->valid = false; } } @@ -159,7 +159,7 @@ void *ED_image_paint_tile_find(ListBase *paint_tiles, ushort **r_mask, bool validate) { - for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) { + LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) { if (ptile->x_tile == x_tile && ptile->y_tile == y_tile) { if (ptile->image == image && ptile->ibuf == ibuf && ptile->iuser.tile == iuser->tile) { if (r_mask) { @@ -267,7 +267,7 @@ static void ptile_restore_runtime_list(ListBase *paint_tiles) { ImBuf *tmpibuf = imbuf_alloc_temp_tile(); - for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) { + LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) { Image *image = ptile->image; ImBuf *ibuf = BKE_image_acquire_ibuf(image, &ptile->iuser, NULL); const bool has_float = (ibuf->rect_float != NULL); @@ -542,7 +542,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init) { ImBuf *tmpibuf = imbuf_alloc_temp_tile(); - for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) { + LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) { /* Tiles only added to second set of tiles. */ Image *image = uh->image_ref.ptr; @@ -552,7 +552,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init) continue; } bool changed = false; - for (UndoImageBuf *ubuf_iter = uh->buffers.first; ubuf_iter; ubuf_iter = ubuf_iter->next) { + LISTBASE_FOREACH (UndoImageBuf *, ubuf_iter, &uh->buffers) { UndoImageBuf *ubuf = use_init ? ubuf_iter : ubuf_iter->post; ubuf_ensure_compat_ibuf(ubuf, ibuf); @@ -611,7 +611,7 @@ static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh, const Image *UNUSED(image), const char *ibuf_name) { - for (UndoImageBuf *ubuf = uh->buffers.first; ubuf; ubuf = ubuf->next) { + LISTBASE_FOREACH (UndoImageBuf *, ubuf, &uh->buffers) { if (STREQ(ubuf->ibuf_name, ibuf_name)) { return ubuf; } @@ -643,7 +643,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles, const Image *image, int tile_number) { - for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) { + LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) { if (STREQ(image->id.name + 2, uh->image_ref.name + 2) && uh->iuser.tile == tile_number) { return uh; } @@ -653,7 +653,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles, static UndoImageHandle *uhandle_lookup(ListBase *undo_handles, const Image *image, int tile_number) { - for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) { + LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) { if (image == uh->image_ref.ptr && uh->iuser.tile == tile_number) { return uh; } @@ -799,8 +799,8 @@ static bool image_undosys_step_encode(struct bContext *C, } BLI_listbase_clear(&us->paint_tiles); - for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) { - for (UndoImageBuf *ubuf_pre = uh->buffers.first; ubuf_pre; ubuf_pre = ubuf_pre->next) { + LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) { + LISTBASE_FOREACH (UndoImageBuf *, ubuf_pre, &uh->buffers) { ImBuf *ibuf = BKE_image_acquire_ibuf(uh->image_ref.ptr, &uh->iuser, NULL); @@ -979,7 +979,7 @@ static void image_undosys_foreach_ID_ref(UndoStep *us_p, void *user_data) { ImageUndoStep *us = (ImageUndoStep *)us_p; - for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) { + LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) { foreach_ID_ref_fn(user_data, ((UndoRefID *)&uh->image_ref)); } } diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 7499c057950..adc6391a0f6 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -250,7 +250,7 @@ static int box_select_exec(bContext *C, wmOperator *op) const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); const int select = (sel_op != SEL_OP_SUB); if (SEL_OP_USE_PRE_DESELECT(sel_op)) { - for (Report *report = reports->list.first; report; report = report->next) { + LISTBASE_FOREACH (Report *, report, &reports->list) { if ((report->type & report_mask) == 0) { continue; } @@ -264,7 +264,7 @@ static int box_select_exec(bContext *C, wmOperator *op) /* get the first report if none found */ if (report_min == NULL) { // printf("find_min\n"); - for (Report *report = reports->list.first; report; report = report->next) { + LISTBASE_FOREACH (Report *, report, &reports->list) { if (report->type & report_mask) { report_min = report; break; diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index d08d39700d6..5adcec8a5d7 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -146,7 +146,7 @@ static int mouse_nla_channels( else { /* deselect all */ /* TODO: should this deselect all other types of channels too? */ - for (Base *b = view_layer->object_bases.first; b; b = b->next) { + LISTBASE_FOREACH (Base *, b, &view_layer->object_bases) { ED_object_base_select(b, BA_DESELECT); if (b->object->adt) { b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 5a59ba6b553..5c4ccd96534 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -150,7 +150,7 @@ static void nla_action_draw_keyframes( /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction */ - for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) { + LISTBASE_FOREACH (ActKeyColumn *, ak, &keys) { draw_keyframe_shape(ak->cfra, y, 6.0f, @@ -207,7 +207,7 @@ static void nla_actionclip_draw_markers( immUniformThemeColorShade(TH_STRIP_SELECT, shade); immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); @@ -238,7 +238,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) /* just a solid color, so that it is very easy to spot */ int shade = 20; /* draw the markers in the first level of strips only (if they are actions) */ - for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) { + LISTBASE_FOREACH (NlaStrip *, nls, &strip->strips) { if (nls->type == NLASTRIP_TYPE_CLIP) { nla_actionclip_draw_markers(nls, yminc, ymaxc, shade, false); } @@ -565,7 +565,7 @@ static void nla_draw_strip(SpaceNla *snla, immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ - for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) { + LISTBASE_FOREACH (NlaStrip *, cs, &strip->strips) { /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 09abfc300c7..ec41368b9f0 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -308,7 +308,7 @@ static void nlaedit_strip_at_region_position( if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; - for (NlaStrip *strip = nlt->strips.first; strip; strip = strip->next) { + LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) { *r_ale = ale; *r_strip = strip; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index c231314ba59..a82acfc4dbe 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1326,7 +1326,7 @@ void NODE_OT_duplicate(wmOperatorType *ot) bool ED_node_select_check(ListBase *lb) { - for (bNode *node = lb->first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, lb) { if (node->flag & NODE_SELECT) { return true; } @@ -1346,7 +1346,7 @@ void ED_node_select_all(ListBase *lb, int action) } } - for (bNode *node = lb->first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, lb) { switch (action) { case SEL_SELECT: nodeSetSelected(node, true); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 03a99a74614..8f8f945a600 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -466,7 +466,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) if (tonode) { /* Find a selected socket that overrides the socket to connect to */ - for (bNodeSocket *sock2 = tonode->outputs.first; sock2; sock2 = sock2->next) { + LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) { if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) { sock = sock2; break; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 43daedfa1c2..38ec855e845 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -623,7 +623,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op) ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT); } - for (bNode *node = snode->edittree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) { bool is_inside; if (node->type == NODE_FRAME) { is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr); diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 8563b7d8c24..5a0ed954909 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -336,8 +336,7 @@ static int collection_delete_exec(bContext *C, wmOperator *op) skip = true; } else { - for (CollectionParent *cparent = collection->parents.first; cparent; - cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; if (ID_IS_LINKED(parent)) { skip = true; @@ -848,7 +847,7 @@ static bool collections_indirect_only_clear_poll(bContext *C) static void layer_collection_flag_recursive_set(LayerCollection *lc, int flag) { - for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) { + LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) { if (lc->flag & flag) { nlc->flag |= flag; } @@ -1468,14 +1467,13 @@ static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op)) /* Unhide all the collections. */ LayerCollection *lc_master = view_layer->layer_collections.first; - for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { lc_iter->flag &= ~LAYER_COLLECTION_HIDE; layer_collection_flag_recursive_set(lc_iter, LAYER_COLLECTION_HIDE); } /* Unhide all objects. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { base->flag &= ~BASE_HIDDEN; } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 6f071ca128e..b6f5ac25c3c 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -263,8 +263,7 @@ static bool parent_drop_allowed(TreeElement *te, Object *potential_child) * element for object it means that all displayed objects belong to * active scene and parenting them is allowed (sergey) */ if (scene) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { if (BKE_view_layer_base_find(view_layer, potential_child)) { return true; } @@ -481,7 +480,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven ListBase *lb = event->customdata; wmDrag *drag = lb->first; - for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { + LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { if (GS(drag_id->id->name) == ID_OB) { Object *object = (Object *)drag_id->id; @@ -548,8 +547,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent BKE_collection_object_add(bmain, collection, ob); - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { Base *base = BKE_view_layer_base_find(view_layer, ob); if (base) { ED_object_base_select(base, BA_SELECT); @@ -817,7 +815,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE TREESTORE(data.te)->flag &= ~TSE_CLOSED; } - for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { + LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { /* Ctrl enables linking, so we don't need a from collection then. */ Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 3c569a71e93..ce83cfc3c97 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -91,7 +91,7 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *soops, int *width, int *height) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { *width = MAX2(*width, te->xend); if (height != NULL) { *height += UI_UNIT_Y; @@ -387,8 +387,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene, if (base_or_object_prop) { /* Note: We can't use BKE_collection_object_cache_get() * otherwise we would not take collection exclusion into account. */ - for (CollectionObject *cob = layer_collection->collection->gobject.first; cob; - cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &layer_collection->collection->gobject) { outliner_base_or_object_pointer_create(view_layer, collection, cob->ob, &ptr); RNA_property_boolean_set(&ptr, base_or_object_prop, value); @@ -401,7 +400,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene, /* Keep going recursively. */ ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children); - for (Link *link = lb->first; link; link = link->next) { + LISTBASE_FOREACH (Link *, link, lb) { LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL; Collection *collection_iter = layer_collection ? (collection ? layer_collection_iter->collection : NULL) : @@ -467,7 +466,7 @@ static bool outliner_collection_is_isolated(Scene *scene, /* Keep going recursively. */ ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children); - for (Link *link = lb->first; link; link = link->next) { + LISTBASE_FOREACH (Link *, link, lb) { LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL; Collection *collection_iter = layer_collection ? (collection ? layer_collection_iter->collection : NULL) : @@ -542,8 +541,7 @@ void outliner_collection_isolate_flag(Scene *scene, /* Make this collection direct parents also "visible". */ if (layer_collection) { LayerCollection *lc_parent = layer_collection; - for (LayerCollection *lc_iter = top_layer_collection->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &top_layer_collection->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) { lc_parent = lc_iter; break; @@ -555,8 +553,7 @@ void outliner_collection_isolate_flag(Scene *scene, scene, lc_parent, collection ? lc_parent->collection : NULL, &ptr); RNA_property_boolean_set(&ptr, layer_or_collection_prop, !is_hide); - for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter; - lc_iter = lc_iter->next) { + LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) { if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) { lc_parent = lc_iter; break; @@ -1054,7 +1051,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, /* Create buttons. */ uiBut *bt; - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); RestrictPropertiesActive props_active = props_active_parent; @@ -1651,7 +1648,7 @@ static void outliner_draw_userbuts(uiBlock *block, ListBase *lb) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { if (tselem->type == 0) { @@ -1770,7 +1767,7 @@ static void outliner_draw_rnabuts( PointerRNA *ptr; PropertyRNA *prop; - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { if (tselem->type == TSE_RNA_PROPERTY) { @@ -2861,7 +2858,7 @@ static void outliner_draw_iconrow(bContext *C, { eOLDrawState active = OL_DRAWSEL_NONE; - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); /* object hierarchy always, further constrained on level */ @@ -3204,7 +3201,7 @@ static void outliner_draw_tree_element(bContext *C, if (TSELEM_OPEN(tselem, soops)) { *starty -= UI_UNIT_Y; - for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) { + LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) { /* check if element needs to be drawn grayed out, but also gray out * childs of a grayed out parent (pass on draw_grayed_out to childs) */ bool draw_childs_grayed_out = draw_grayed_out || (ten->flag & TE_DRAGGING); @@ -3223,7 +3220,7 @@ static void outliner_draw_tree_element(bContext *C, } } else { - for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) { + LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) { outliner_set_coord_tree_element(ten, startx, *starty); } @@ -3357,7 +3354,7 @@ static void outliner_draw_struct_marks(ARegion *region, ListBase *lb, int *starty) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); /* selection status */ @@ -3406,7 +3403,7 @@ static void outliner_draw_highlights_recursive(uint pos, const bool is_searching = (SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATA_API && soops->search_string[0] != 0)); - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { const TreeStoreElem *tselem = TREESTORE(te); const int start_y = *io_start_y; @@ -3555,7 +3552,7 @@ static void outliner_draw_tree(bContext *C, // items themselves starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; startx = 0; - for (TreeElement *te = soops->tree.first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, &soops->tree) { outliner_draw_tree_element(C, block, fstyle, diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index e4e8e2a1542..60e6b423720 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1292,7 +1292,7 @@ static void outliner_show_active(SpaceOutliner *so, ARegion *region, TreeElement return; } - for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) { + LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) { outliner_show_active(so, region, ten, id); } } @@ -1310,7 +1310,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) ID *id = TREESTORE(active_element)->id; /* Expand all elements in the outliner with matching ID */ - for (TreeElement *te = so->tree.first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, &so->tree) { outliner_show_active(so, region, te, id); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index d50a097e6f6..ec1595eb930 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1252,7 +1252,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb, TreeElement *cursor, bool selecting) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); if (selecting) { @@ -1496,7 +1496,7 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op) WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf); - for (TreeElement *te = soops->tree.first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, &soops->tree) { outliner_item_box_select(soops, scene, &rectf, te, select); } diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index c08c7f54405..35dd91ff061 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -96,8 +96,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C) wmWindowManager *wm = CTX_wm_manager(C); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *soutliner = (SpaceOutliner *)sl; @@ -319,7 +319,7 @@ static void outliner_sync_selection_from_outliner(Scene *scene, SelectedItems *selected_items) { - for (TreeElement *te = tree->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, tree) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { @@ -500,7 +500,7 @@ static void outliner_sync_selection_to_outliner(ViewLayer *view_layer, SyncSelectActiveData *active_data, const SyncSelectTypes *sync_types) { - for (TreeElement *te = tree->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, tree) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 730d0019f77..34ca2267b7a 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -518,7 +518,7 @@ static void merged_element_search_cb_recursive( char name[64]; int iconid; - for (TreeElement *te = tree->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, tree) { TreeStoreElem *tselem = TREESTORE(te); if (tree_element_id_type_to_index(te) == type && tselem_type == tselem->type) { diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index d89a755f1c6..b226d291188 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1254,7 +1254,7 @@ static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type) Collection *collection = (Collection *)id; bool has_non_scene_parent = false; - for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) { has_non_scene_parent = true; } @@ -1387,7 +1387,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops static void outliner_add_layer_collection_objects( SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten) { - for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { Base *base = BKE_view_layer_base_find(layer, cob->ob); TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0); te_object->directdata = base; @@ -1405,7 +1405,7 @@ static void outliner_add_layer_collections_recursive(SpaceOutliner *soops, TreeElement *parent_ten, const bool show_objects) { - for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, layer_collections) { const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; TreeElement *ten; @@ -1468,7 +1468,7 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops, Collection *collection, TreeElement *parent) { - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { outliner_add_element(soops, tree, cob->ob, parent, 0, 0); } } @@ -1479,7 +1479,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops, { outliner_add_collection_init(ten, collection); - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0); } @@ -1542,7 +1542,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo continue; } - for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, parent_ob_tree_elements) { TreeElement *parent_ob_tree_element = link->data; TreeElement *parent_ob_collection_tree_element = NULL; bool found = false; @@ -1556,8 +1556,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; } - for (LinkData *link_iter = child_ob_tree_elements->first; link_iter; - link_iter = link_iter->next) { + LISTBASE_FOREACH (LinkData *, link_iter, child_ob_tree_elements) { TreeElement *child_ob_tree_element = link_iter->data; if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { @@ -1589,7 +1588,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, TreeElement *te_parent) { - for (TreeElement *te = te_parent->subtree.first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, &te_parent->subtree) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == TSE_LAYER_COLLECTION) { @@ -2427,7 +2426,7 @@ void outliner_build_tree( else if (soops->outlinevis == SO_VIEW_LAYER) { if (soops->filter & SO_FILTER_NO_COLLECTION) { /* Show objects in the view layer. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { TreeElement *te_object = outliner_add_element( soops, &soops->tree, base->object, NULL, 0, 0); te_object->directdata = base; diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 188a4e64897..a058c30cef2 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -78,7 +78,7 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops, const ListBase *tree, float view_co_y) { - for (TreeElement *te_iter = tree->first; te_iter; te_iter = te_iter->next) { + LISTBASE_FOREACH (TreeElement *, te_iter, tree) { if (view_co_y < (te_iter->ys + UI_UNIT_Y)) { if (view_co_y >= te_iter->ys) { /* co_y is inside this element */ @@ -204,7 +204,7 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse) /* Find treestore that refers to given ID */ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == 0) { if (tselem->id == id) { @@ -222,7 +222,7 @@ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id) TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { if (te->directdata == pchan) { return te; } @@ -240,7 +240,7 @@ TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan) TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { if (te->directdata == ebone) { return te; } @@ -361,7 +361,7 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops) /* Find first tree element in tree with matching treestore flag */ TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag) { - for (TreeElement *te = lb->first; te; te = te->next) { + LISTBASE_FOREACH (TreeElement *, te, lb) { if ((TREESTORE(te)->flag & flag) == flag) { return te; } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 98565c7cc58..82331545a77 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -3477,7 +3477,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) seqbase_clipboard_frame = scene->r.cfra; /* Need to remove anything that references the current scene */ - for (Sequence *seq = seqbase_clipboard.first; seq; seq = seq->next) { + LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) { seq_copy_del_sound(scene, seq); } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index ccb18331c55..810e1009ecb 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -962,7 +962,7 @@ static int sequencer_select_side_exec(bContext *C, wmOperator *op) copy_vn_i(frame_ranges, ARRAY_SIZE(frame_ranges), frame_init); - for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) { + LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { if (UNLIKELY(seq->machine >= MAXSEQ)) { continue; } @@ -1037,7 +1037,7 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op) WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf); - for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) { + LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { rctf rq; seq_rectf(seq, &rq); if (BLI_rctf_isect(&rq, &rectf, NULL)) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 75717213cb1..226e6617a71 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -146,7 +146,7 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion BLI_assert(v3d->spacetype == SPACE_VIEW3D); - for (ARegion *region = region_list->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, region_list) { /* find the first unlocked rv3d */ if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) { rv3d = region->regiondata; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 699ad40da9c..c1995249c26 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2396,7 +2396,7 @@ void ED_view3d_screen_datamask(const bContext *C, CustomData_MeshMasks_update(r_cddata_masks, &CD_MASK_BAREMESH); /* Check if we need tfaces & mcols due to view mode. */ - for (const ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_VIEW3D) { ED_view3d_datamask(C, scene, area->spacedata.first, r_cddata_masks); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index cd7db2ff23a..0a272db1344 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -157,7 +157,7 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact) static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d) { bool changed = false; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->flag & BASE_SELECTED) { if (BASE_SELECTABLE(v3d, base)) { ED_object_base_select(base, BA_DESELECT); @@ -172,7 +172,7 @@ static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d) static bool object_deselect_all_except(ViewLayer *view_layer, Base *b) { bool changed = false; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->flag & BASE_SELECTED) { if (b != base) { ED_object_base_select(base, BA_DESELECT); @@ -617,7 +617,7 @@ static Base **do_pose_tag_select_op_prepare(ViewContext *vc, uint *r_bases_len) FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) { Object *ob_iter = base_iter->object; bArmature *arm = ob_iter->data; - for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) { Bone *bone = pchan->bone; bone->flag &= ~BONE_DONE; } @@ -659,7 +659,7 @@ static bool do_pose_tag_select_op_exec(Base **bases, const uint bases_len, const } bool changed = true; - for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) { Bone *bone = pchan->bone; if ((bone->flag & BONE_UNSELECTABLE) == 0) { const bool is_select = bone->flag & BONE_SELECTED; @@ -3076,7 +3076,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const const int hits = view3d_opengl_select( vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); - for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) { base->object->id.tag &= ~LIB_TAG_DOIT; } @@ -3092,7 +3092,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const goto finally; } - for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) { if (BASE_SELECTABLE(v3d, base)) { if ((base->object->runtime.select_id & 0x0000FFFF) != 0) { BLI_array_append(bases, base); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ca9845b0b6e..b90f7aa870e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1390,7 +1390,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, MEM_freeN(v3d->localvd); v3d->localvd = NULL; - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index af3cba65dda..1e751f67c9d 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -1026,7 +1026,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, } else { /* Compute the average values for each retained keyframe */ - for (tRetainedKeyframe *rk = retained_keys.first; rk; rk = rk->next) { + LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) { rk->val = rk->val / (float)rk->tot_count; } } @@ -1754,8 +1754,7 @@ static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t) ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(&clip->tracking); const int framenr = ED_space_clip_get_clip_frame_number(sc); /* Update coordinates of modified plane tracks. */ - for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track; - plane_track = plane_track->next) { + LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) { bool do_update = false; if (plane_track->flag & PLANE_TRACK_HIDDEN) { continue; @@ -2078,12 +2077,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t) const int filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ale->datatype == ALE_GPFRAME) { ale->id->tag |= LIB_TAG_DOIT; } } - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ale->datatype == ALE_GPFRAME) { if (ale->id->tag & LIB_TAG_DOIT) { ale->id->tag &= ~LIB_TAG_DOIT; @@ -2109,12 +2108,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t) const int filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ale->datatype == ALE_MASKLAY) { ale->id->tag |= LIB_TAG_DOIT; } } - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { if (ale->datatype == ALE_MASKLAY) { if (ale->id->tag & LIB_TAG_DOIT) { ale->id->tag &= ~LIB_TAG_DOIT; diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c index 9136f9edacc..e52bd15b0d5 100644 --- a/source/blender/editors/transform/transform_convert_armature.c +++ b/source/blender/editors/transform/transform_convert_armature.c @@ -531,8 +531,7 @@ void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, Object * unit_m4(flip_mtx); flip_mtx[0][0] = -1; - for (bPoseChannel *pchan_orig = ob->pose->chanbase.first; pchan_orig; - pchan_orig = pchan_orig->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan_orig, &ob->pose->chanbase) { /* Clear the MIRROR flag from previous runs. */ pchan_orig->bone->flag &= ~BONE_TRANSFORM_MIRROR; } @@ -655,7 +654,7 @@ void createTransPose(TransInfo *t) if (mirror) { int total_mirrored = 0; - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if ((pchan->bone->flag & BONE_TRANSFORM) && BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) { total_mirrored++; @@ -705,7 +704,7 @@ void createTransPose(TransInfo *t) } if (mirror) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { if (pchan->bone->flag & BONE_TRANSFORM) { bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name); if (pchan_mirror) { @@ -727,7 +726,7 @@ void createTransPose(TransInfo *t) /* use pose channels to fill trans data */ td = tc->data; - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if (pchan->bone->flag & BONE_TRANSFORM) { add_pose_transdata(t, pchan, ob, tc, td); td++; diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 18211eb447f..908cf7707f2 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -99,7 +99,7 @@ void createTransCurveVerts(TransInfo *t) /* count total of vertices, check identical as in 2nd loop for making transdata! */ ListBase *nurbs = BKE_curve_editNurbs_get(cu); - for (Nurb *nu = nurbs->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, nurbs) { if (nu->type == CU_BEZIER) { for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) { if (bezt->hide == 0) { @@ -174,7 +174,7 @@ void createTransCurveVerts(TransInfo *t) TransData *td = tc->data; ListBase *nurbs = BKE_curve_editNurbs_get(cu); - for (Nurb *nu = nurbs->first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, nurbs) { if (nu->type == CU_BEZIER) { TransData *head, *tail; head = tail = td; diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c index 4973b1cb268..9b76db7f265 100644 --- a/source/blender/editors/transform/transform_convert_object.c +++ b/source/blender/editors/transform/transform_convert_object.c @@ -290,7 +290,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { base->object->id.tag &= ~LIB_TAG_DOIT; } } @@ -324,7 +324,7 @@ static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *vi { if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) { - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object->id.tag & LIB_TAG_DOIT) { base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO; } @@ -355,7 +355,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* Clear all flags we need. It will be used to detect dependencies. */ trans_object_base_deps_flag_prepare(view_layer); /* Traverse all bases and set all possible flags. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { base->flag_legacy &= ~(BA_WAS_SEL | BA_TRANSFORM_LOCKED_IN_PLACE); if (BASE_SELECTED_EDITABLE(v3d, base)) { Object *ob = base->object; @@ -422,7 +422,7 @@ static int count_proportional_objects(TransInfo *t) if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) && (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) { /* Mark all parents. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { Object *parent = base->object->parent; /* flag all parents */ @@ -433,7 +433,7 @@ static int count_proportional_objects(TransInfo *t) } } /* Mark all children. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { /* all base not already selected or marked that is editable */ if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && (base->flag & BASE_SELECTED) == 0 && @@ -443,7 +443,7 @@ static int count_proportional_objects(TransInfo *t) } } /* Flush changed flags to all dependencies. */ - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; /* If base is not selected, not a parent of selection or not a child of * selection and it is editable and selectable. @@ -592,7 +592,7 @@ void createTransObject(bContext *C, TransInfo *t) ViewLayer *view_layer = t->view_layer; View3D *v3d = t->view; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; /* if base is not selected, not a parent of selection @@ -639,7 +639,7 @@ void createTransObject(bContext *C, TransInfo *t) ViewLayer *view_layer = t->view_layer; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if (ob->parent != NULL) { if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) && @@ -669,7 +669,7 @@ void createTransObject(bContext *C, TransInfo *t) } } - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if (BASE_XFORM_INDIRECT(base) || BLI_gset_haskey(objects_in_transdata, ob)) { diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 6af1989a509..aa298b04d1a 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -800,7 +800,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C, /* calculate difference matrix */ BKE_gpencil_parent_matrix_get(depsgraph, ob, gpl, diff_mat); - for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) { + LISTBASE_FOREACH (bGPDstroke *, gps, &gpl->actframe->strokes) { /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; @@ -883,7 +883,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C, if (use_mat_local) { mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat); } - for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { + LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { if (EBONE_VISIBLE(arm, ebo)) { if (ebo->flag & BONE_TIPSEL) { calc_tw_center_with_matrix(tbounds, ebo->tail, use_mat_local, mat_local); @@ -977,7 +977,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C, mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat); } - for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) { + LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { if (ml->flag & SELECT) { calc_tw_center_with_matrix(tbounds, &ml->x, use_mat_local, mat_local); totsel++; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 8e7e36d7cb7..2cfeedbb346 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1838,7 +1838,7 @@ static short snapArmature(SnapData *snapdata, bArmature *arm = ob->data; if (arm->edbo) { - for (EditBone *eBone = arm->edbo->first; eBone; eBone = eBone->next) { + LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) { if (eBone->layer & arm->layer) { /* skip hidden or moving (selected) bones */ if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) { @@ -1881,7 +1881,7 @@ static short snapArmature(SnapData *snapdata, } } else if (ob->pose && ob->pose->chanbase.first) { - for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { Bone *bone = pchan->bone; /* skip hidden bones */ if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 39ecbad1807..69e7c04b5e5 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -816,7 +816,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer, { const short object_type = obact->type; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { ID *id = ob->data; @@ -825,7 +825,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer, } int len = 0; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { if (ob == obact) { @@ -852,7 +852,7 @@ Object **ED_undo_editmode_objects_from_view_layer(ViewLayer *view_layer, uint *r const short object_type = obact->type; int i = 0; Object **objects = MEM_malloc_arrayN(len, sizeof(*objects), __func__); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { ID *id = ob->data; @@ -881,7 +881,7 @@ Base **ED_undo_editmode_bases_from_view_layer(ViewLayer *view_layer, uint *r_len const short object_type = obact->type; int i = 0; Base **base_array = MEM_malloc_arrayN(len, sizeof(*base_array), __func__); - for (Base *base = view_layer->object_bases.first; base; base = base->next) { + LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { ID *id = ob->data; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 733cdad2212..f8e19b742e4 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -83,7 +83,7 @@ void ED_editors_init_for_undo(Main *bmain) { wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); Base *base = BASACT(view_layer); if (base != NULL) { diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index e00b6f78c2e..e322b9fb9b8 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -241,7 +241,7 @@ void gpu_batch_presets_reset(void) BLI_mutex_lock(&g_presets_3d.mutex); /* Reset vao caches for these every time we switch opengl context. * This way they will draw correctly for each window. */ - for (LinkData *link = presets_list.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &presets_list) { GPUBatch *preset = link->data; GPU_batch_vao_cache_clear(preset); } diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index f279ab2c86c..8a46e24d459 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -75,7 +75,7 @@ static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, ListBase * BLI_HashMurmur2A hm2a; BLI_hash_mm2a_init(&hm2a, 0); BLI_hash_mm2a_add(&hm2a, (uchar *)frag_gen, strlen(frag_gen)); - for (GPUMaterialAttribute *attr = attributes->first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, attributes) { BLI_hash_mm2a_add(&hm2a, (uchar *)attr->name, strlen(attr->name)); } if (defs) { @@ -314,12 +314,12 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, ListBase ubo_inputs = {NULL, NULL}; /* Attributes */ - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { BLI_dynstr_appendf(ds, "in %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id); } /* Textures */ - for (GPUMaterialTexture *tex = graph->textures.first; tex; tex = tex->next) { + LISTBASE_FOREACH (GPUMaterialTexture *, tex, &graph->textures) { if (tex->colorband) { BLI_dynstr_appendf(ds, "uniform sampler1DArray %s;\n", tex->sampler_name); } @@ -333,7 +333,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, } /* Volume Grids */ - for (GPUMaterialVolumeGrid *grid = graph->volume_grids.first; grid; grid = grid->next) { + LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph->volume_grids) { BLI_dynstr_appendf(ds, "uniform sampler3D %s;\n", grid->sampler_name); BLI_dynstr_appendf(ds, "uniform mat4 %s = mat4(0.0);\n", grid->transform_name); } @@ -381,7 +381,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, /* Inputs are sorted */ BLI_dynstr_appendf(ds, "\nlayout (std140) uniform %s {\n", GPU_UBO_BLOCK_NAME); - for (LinkData *link = ubo_inputs.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ubo_inputs) { input = link->data; BLI_dynstr_appendf(ds, "\t%s unf%d;\n", gpu_data_type_to_string(input->type), input->id); } @@ -673,7 +673,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo "#define DEFINE_ATTR(type, attr) in type attr\n" "#endif\n"); - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { /* XXX FIXME : see notes in mesh_render_data_create() */ /* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */ if (attr->type == CD_ORCO) { @@ -787,7 +787,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo BLI_dynstr_append(ds, "\tbarycentricPosg = position;\n"); } - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { if (attr->type == CD_TANGENT) { /* Not supported by hairs */ BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n", attr->id, use_geom ? "g" : ""); @@ -820,7 +820,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo BLI_dynstr_append(ds, "\tbarycentricPosg = (ModelMatrix * vec4(position, 1.0)).xyz;\n"); } - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { if (attr->type == CD_TANGENT) { /* silly exception */ BLI_dynstr_appendf(ds, "\tvar%d%s.xyz = transpose(mat3(ModelMatrixInverse)) * att%d.xyz;\n", @@ -903,7 +903,7 @@ static char *code_generate_geometry(GPUNodeGraph *graph, } } - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { BLI_dynstr_appendf(ds, "in %s var%dg[];\n", gpu_data_type_to_string(attr->gputype), attr->id); BLI_dynstr_appendf(ds, "out %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id); } @@ -1010,7 +1010,7 @@ static char *code_generate_geometry(GPUNodeGraph *graph, BLI_dynstr_append(ds, "#endif\n"); } - for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) { + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) { /* TODO let shader choose what to do depending on what the attribute is. */ BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", attr->id, attr->id); } diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 3e73d156440..97e4c880644 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -191,7 +191,7 @@ static void gpu_material_free_single(GPUMaterial *material) void GPU_material_free(ListBase *gpumaterial) { - for (LinkData *link = gpumaterial->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, gpumaterial) { GPUMaterial *material = link->data; gpu_material_free_single(material); MEM_freeN(material); @@ -628,7 +628,7 @@ GPUMaterial *GPU_material_from_nodetree_find(ListBase *gpumaterials, const void *engine_type, int options) { - for (LinkData *link = gpumaterials->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, gpumaterials) { GPUMaterial *current_material = (GPUMaterial *)link->data; if (current_material->engine_type == engine_type && current_material->options == options) { return current_material; diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index 953b2eb40d8..876a6bef670 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -645,7 +645,7 @@ void gpu_node_graph_free(GPUNodeGraph *graph) { gpu_node_graph_free_nodes(graph); - for (GPUMaterialVolumeGrid *grid = graph->volume_grids.first; grid; grid = grid->next) { + LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph->volume_grids) { MEM_SAFE_FREE(grid->name); } BLI_freelistN(&graph->volume_grids); @@ -679,7 +679,7 @@ static void gpu_nodes_tag(GPUNodeLink *link) void gpu_node_graph_prune_unused(GPUNodeGraph *graph) { - for (GPUNode *node = graph->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) { node->tag = false; } diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 56fe1e40d87..674ca06d109 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -731,8 +731,7 @@ void gpu_select_pick_cache_load_id(void) #ifdef DEBUG_PRINT printf("%s (building depth from cache)\n", __func__); #endif - for (DepthBufCache *rect_depth = ps->cache.bufs.first; rect_depth; - rect_depth = rect_depth->next) { + LISTBASE_FOREACH (DepthBufCache *, rect_depth, &ps->cache.bufs) { if (rect_depth->next != NULL) { /* we know the buffers differ, but this sub-region may not. * double check before adding an id-pass */ diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c index 943793956d1..130e8fe7da1 100644 --- a/source/blender/gpu/intern/gpu_uniformbuffer.c +++ b/source/blender/gpu/intern/gpu_uniformbuffer.c @@ -147,7 +147,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou /* Make sure we comply to the ubo alignment requirements. */ gpu_uniformbuffer_inputs_sort(inputs); - for (LinkData *link = inputs->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, inputs) { const eGPUType gputype = get_padded_gpu_type(link); ubo->buffer.size += gputype * sizeof(float); } @@ -160,7 +160,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou /* Now that we know the total ubo size we can start populating it. */ float *offset = ubo->data; - for (LinkData *link = inputs->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, inputs) { GPUInput *input = link->data; memcpy(offset, input->vec, input->type * sizeof(float)); offset += get_padded_gpu_type(link); @@ -272,7 +272,7 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs) LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL}; eGPUType cur_type = MAX_UBO_GPU_TYPE + 1; - for (LinkData *link = inputs->first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, inputs) { GPUInput *input = link->data; if (input->type == GPU_MAT3) { diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 57efaf99b8b..b2e1cb17946 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -355,7 +355,7 @@ GPUTexture *GPU_viewport_texture_pool_query( { GPUTexture *tex; - for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) { + LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) { if ((GPU_texture_format(tmp_tex->texture) == format) && (GPU_texture_width(tmp_tex->texture) == width) && (GPU_texture_height(tmp_tex->texture) == height)) { @@ -412,7 +412,7 @@ static void gpu_viewport_texture_pool_clear_users(GPUViewport *viewport) static void gpu_viewport_texture_pool_free(GPUViewport *viewport) { - for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) { + LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) { GPU_texture_free(tmp_tex->texture); } diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index b72c32a8277..3646686e81f 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -654,7 +654,7 @@ void iksolver_release_tree(struct Scene *UNUSED(scene), struct Object *ob, float void iksolver_clear_data(bPose *pose) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { if ((pchan->flag & POSE_IKTREE) == 0) { continue; } diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 4e238df4e3c..199d22ee3dc 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -438,7 +438,7 @@ static bool rna_property_override_operation_store(Main *bmain, return changed; } - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { /* Only needed for diff operations. */ if (!ELEM(opop->operation, IDOVERRIDE_LIBRARY_OP_ADD, @@ -832,7 +832,7 @@ bool RNA_struct_override_store(Main *bmain, #ifdef DEBUG_OVERRIDE_TIMEIT TIMEIT_START_AVERAGED(RNA_struct_override_store); #endif - for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { /* Simplified for now! */ PointerRNA data_reference, data_local; PropertyRNA *prop_reference, *prop_local; @@ -880,7 +880,7 @@ static void rna_property_override_apply_ex(Main *bmain, IDOverrideLibraryProperty *op, const bool do_insert) { - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { if (!do_insert != !ELEM(opop->operation, IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) { @@ -999,7 +999,7 @@ void RNA_struct_override_apply(Main *bmain, */ bool do_insert = false; for (int i = 0; i < 2; i++, do_insert = true) { - for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { /* Simplified for now! */ PointerRNA data_src, data_dst; PointerRNA data_item_src, data_item_dst; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 6755dd86a0a..7955109d9bc 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -576,7 +576,7 @@ static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA NurbInfo info = {0}; /* Check if all sub-curves have the same type. */ - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { if (type == NULL) { type = rna_ShapeKey_curve_point_type(nu); rna_ShapeKey_NurbInfo_init(&info, nu); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index f3e2e20ee3c..46a32256114 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -301,7 +301,7 @@ static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value) static void rna_LayerCollection_exclude_update_recursive(ListBase *lb, const bool exclude) { - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { if (exclude) { lc->flag |= LAYER_COLLECTION_EXCLUDE; } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index d062642d3ce..c1fb3232bb3 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -697,7 +697,7 @@ static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerR /* Iterating over all object is slow, but no better solution exists at the moment. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { if (psys->part == part) { psys_changed_type(ob, psys); psys->recalc |= ID_RECALC_PSYS_RESET; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f68541dfc4a..27ebbe79085 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1811,7 +1811,7 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *valu /* Update select mode in all the workspaces in mesh edit mode. */ wmWindowManager *wm = G_MAIN->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); if (view_layer && view_layer->basact) { @@ -2435,7 +2435,7 @@ static const EnumPropertyItem *rna_TransformOrientation_impl_itemf(Scene *scene, if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { RNA_enum_item_add_separator(&item, &totitem); - for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { + LISTBASE_FOREACH (TransformOrientation *, ts, transform_orientations) { tmp.identifier = ts->name; tmp.name = ts->name; tmp.value = i++; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e20bf263bee..f69ba1a38c9 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1028,8 +1028,8 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA rna_GPencil_update(bmain, scene, ptr); bScreen *screen = (bScreen *)ptr->owner_id; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (&v3d->shading == shading) { diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 37cbeeb0d84..a94e3d26862 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -204,7 +204,7 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) WM_paneltype_remove(pt); - for (LinkData *link = pt->children.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &pt->children) { PanelType *child_pt = link->data; child_pt->parent = NULL; } @@ -214,14 +214,14 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) BLI_freelinkN(&art->paneltypes, pt); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == space_type) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->type == art) { - for (Panel *pa = region->panels.first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, ®ion->panels) { if (pa->type == pt) { pa->type = NULL; } diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 8c1b48d2b07..826d4039c55 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -259,13 +259,12 @@ static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) /* We could try workaruond this lookup, but not trivial. */ for (bScreen *screen = G_MAIN->screens.first; screen; screen = screen->id.next) { IDProperty *properties = ptr->data; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->gizmo_map) { wmGizmoMap *gzmap = region->gizmo_map; - for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; - gzgroup = gzgroup->next) { - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, WM_gizmomap_group_list(gzmap)) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->properties == properties) { return gz; } diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index d9fe2504e22..d36fce3752b 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -124,8 +124,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; /* Add relation from canvases to all brush objects. */ if (pmd->canvas != NULL && pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) { - for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface; - surface = surface->next) { + LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) { if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { DEG_add_forcefield_relations( ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field"); diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index f79edcadbda..d44cb8c7de1 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -229,7 +229,7 @@ bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target) * multiple, we prefer exact target match and active nodes. */ bNode *output_node = NULL; - for (bNode *node = ntree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT)) { continue; } @@ -344,7 +344,7 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc bool removed_link = false; for (node = group_ntree->nodes.first; node; node = node->next) { - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if ((sock->flag & SOCK_HIDE_VALUE) == 0) { continue; } @@ -553,7 +553,7 @@ static void ntree_shader_relink_node_normal(bNodeTree *ntree, /* TODO(sergey): Can we do something smarter here than just a name-based * matching? */ - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->identifier, "Normal") && sock->link == NULL) { /* It's a normal input and nothing is connected to it. */ nodeAddLink(ntree, node_from, socket_from, node, sock); diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c index 496b61c8c72..22fbe4e4da6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c @@ -39,7 +39,7 @@ static void node_shader_init_displacement(bNodeTree *UNUSED(ntree), bNode *node) node->custom1 = SHD_SPACE_OBJECT; /* space */ /* Set default value here for backwards compatibility. */ - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->name, "Midlevel")) { ((bNodeSocketValueFloat *)sock->default_value)->value = 0.5f; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c index eba9abc6e3c..1b802f1dfd7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c @@ -135,7 +135,7 @@ static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) node->storage = tex; - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->name, "Mortar Smooth")) { ((bNodeSocketValueFloat *)sock->default_value)->value = 0.1f; } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c index 92e1b3435c8..b581a4bd3a6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c @@ -44,7 +44,7 @@ static bNodeSocketTemplate sh_node_volume_principled_out[] = { static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *node) { - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (STREQ(sock->name, "Density Attribute")) { strcpy(((bNodeSocketValueString *)sock->default_value)->value, "density"); } @@ -66,7 +66,7 @@ static int node_shader_gpu_volume_principled(GPUMaterial *mat, /* Get volume attributes. */ GPUNodeLink *density = NULL, *color = NULL, *temperature = NULL; - for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { + LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { if (sock->typeinfo->type != SOCK_STRING) { continue; } diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c index 3a77e1ba797..89ef2f40a30 100644 --- a/source/blender/python/intern/bpy_capi_utils.c +++ b/source/blender/python/intern/bpy_capi_utils.c @@ -92,7 +92,7 @@ void BPy_reports_write_stdout(const ReportList *reports, const char *header) PySys_WriteStdout("%s\n", header); } - for (const Report *report = reports->list.first; report; report = report->next) { + LISTBASE_FOREACH (const Report *, report, &reports->list) { PySys_WriteStdout("%s: %s\n", report->typestr, report->message); } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 1a97332212d..f7901ebb7d0 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2095,14 +2095,13 @@ void RE_RenderFreestyleExternal(Render *re) FRS_init_stroke_renderer(re); - for (RenderView *rv = re->result->views.first; rv; rv = rv->next) { + LISTBASE_FOREACH (RenderView *, rv, &re->result->views) { RE_SetActiveRenderView(re, rv->name); ViewLayer *active_view_layer = BLI_findlink(&re->view_layers, re->active_view_layer); FRS_begin_stroke_rendering(re); - for (ViewLayer *view_layer = (ViewLayer *)re->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &re->view_layers) { if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer) { continue; } @@ -2866,7 +2865,7 @@ bool RE_layers_have_name(struct RenderResult *rr) bool RE_passes_have_name(struct RenderLayer *rl) { - for (RenderPass *rp = rl->passes.first; rp; rp = rp->next) { + LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) { if (!STREQ(rp->name, "Combined")) { return true; } diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 814e9b1c79e..b38c1b573f3 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -917,7 +917,7 @@ bool RE_WriteRenderResult(ReportList *reports, /* First add views since IMB_exr_add_channel checks number of views. */ if (render_result_has_views(rr)) { - for (RenderView *rview = rr->views.first; rview; rview = rview->next) { + LISTBASE_FOREACH (RenderView *, rview, &rr->views) { if (!view || STREQ(view, rview->name)) { IMB_exr_add_view(exrhandle, rview->name); } @@ -926,7 +926,7 @@ bool RE_WriteRenderResult(ReportList *reports, /* Compositing result. */ if (rr->have_combined) { - for (RenderView *rview = rr->views.first; rview; rview = rview->next) { + LISTBASE_FOREACH (RenderView *, rview, &rr->views) { if (!rview->rectf) { continue; } @@ -986,7 +986,7 @@ bool RE_WriteRenderResult(ReportList *reports, continue; } - for (RenderPass *rp = rl->passes.first; rp; rp = rp->next) { + LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) { /* Skip non-RGBA and Z passes if not using multi layer. */ if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") || (STREQ(rp->name, RE_PASSNAME_Z) && write_z))) { @@ -1240,7 +1240,7 @@ void render_result_exr_file_begin(Render *re, RenderEngine *engine) char str[FILE_MAX]; for (RenderResult *rr = re->result; rr; rr = rr->next) { - for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next) { + LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) { /* Get passes needed by engine. Normally we would wait for the * engine to create them, but for EXR file we need to know in * advance. */ @@ -1250,7 +1250,7 @@ void render_result_exr_file_begin(Render *re, RenderEngine *engine) /* Create render passes requested by engine. Only this part is * mutex locked to avoid deadlock with Python GIL. */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - for (RenderPass *pass = templates.first; pass; pass = pass->next) { + LISTBASE_FOREACH (RenderPass *, pass, &templates) { RE_create_render_pass( re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); } @@ -1271,7 +1271,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine) { /* Close EXR files. */ for (RenderResult *rr = re->result; rr; rr = rr->next) { - for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next) { + LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) { IMB_exr_close(rl->exrhandle); rl->exrhandle = NULL; } @@ -1285,7 +1285,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine) re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); BLI_rw_mutex_unlock(&re->resultmutex); - for (RenderLayer *rl = re->result->layers.first; rl; rl = rl->next) { + LISTBASE_FOREACH (RenderLayer *, rl, &re->result->layers) { /* Get passes needed by engine. */ ListBase templates; render_result_get_pass_templates(engine, re, rl, &templates); @@ -1293,7 +1293,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine) /* Create render passes requested by engine. Only this part is * mutex locked to avoid deadlock with Python GIL. */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - for (RenderPass *pass = templates.first; pass; pass = pass->next) { + LISTBASE_FOREACH (RenderPass *, pass, &templates) { RE_create_render_pass(re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 90a3234abd5..67f30f0d7ee 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -222,7 +222,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm, { int gzgroup_keymap_uses_modifier = -1; - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->type->test_select && (gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) { if (!wm_gizmo_keymap_uses_event_modifier( @@ -299,9 +299,9 @@ void WM_gizmo_group_remove_by_tool(bContext *C, { wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(&gzgt->gzmap_params); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->runtime.tool == tref) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { wmGizmoGroup *gzgroup, *gzgroup_next; @@ -337,7 +337,7 @@ bool wm_gizmogroup_is_visible_in_drawstep(const wmGizmoGroup *gzgroup, bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup) { if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) { - for (const wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (const wmGizmo *, gz, &gzgroup->gizmos) { if (gz->state & WM_GIZMO_STATE_SELECT) { return true; } @@ -850,8 +850,7 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(struct wmGizmoMapType const wmGizmoGroupType *gzgt) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; - gzgt_ref = gzgt_ref->next) { + LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) { if (gzgt_ref->type == gzgt) { return gzgt_ref; } @@ -863,8 +862,7 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(struct wmGizmoMapType *gz const char *idname) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; - gzgt_ref = gzgt_ref->next) { + LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) { if (STREQ(idname, gzgt_ref->type->idname)) { return gzgt_ref; } @@ -909,10 +907,10 @@ void WM_gizmomaptype_group_init_runtime(const Main *bmain, /* now create a gizmo for all existing areas */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = lb->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, lb) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { WM_gizmomaptype_group_init_runtime_with_region(gzmap_type, gzgt, region); @@ -964,10 +962,10 @@ void WM_gizmomaptype_group_unlink(bContext *C, { /* Free instances. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = lb->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, lb) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { wmGizmoGroup *gzgroup, *gzgroup_next; @@ -1134,10 +1132,10 @@ void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type, ScrArea *area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap && gzmap->type == gzmap_type) { - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (gzgroup->type == gzgt) { WM_gizmo_group_tag_remove(gzgroup); } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index ae7475c3661..6ed6c485e89 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -171,8 +171,7 @@ static wmGizmoMap *wm_gizmomap_new_from_type_ex(struct wmGizmoMapType *gzmap_typ /* create all gizmo-groups for this gizmo-map. We may create an empty one * too in anticipation of gizmos from operators etc */ - for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; - gzgt_ref = gzgt_ref->next) { + LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) { wm_gizmogroup_new_from_type(gzmap, gzgt_ref->type); } @@ -231,7 +230,7 @@ wmGizmoGroup *WM_gizmomap_group_find(struct wmGizmoMap *gzmap, const char *idnam wmGizmoGroup *WM_gizmomap_group_find_ptr(struct wmGizmoMap *gzmap, const struct wmGizmoGroupType *gzgt) { - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (gzgroup->type == gzgt) { return gzgroup; } @@ -290,9 +289,9 @@ static GHash *WM_gizmomap_gizmo_hash_new(const bContext *C, GHash *hash = BLI_ghash_ptr_new(__func__); /* collect gizmos */ - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (WM_gizmo_group_type_poll(C, gzgroup->type)) { - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) && (!poll || poll(gz, data))) { BLI_ghash_insert(hash, gz, gz); @@ -335,7 +334,7 @@ void WM_gizmomap_tag_refresh(wmGizmoMap *gzmap) bool WM_gizmomap_tag_delay_refresh_for_tweak_check(wmGizmoMap *gzmap) { - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (gzgroup->hide.delay_refresh_for_tweak) { return true; } @@ -403,7 +402,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap, const bool do_refresh = gzmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK; gzmap->update_flag[drawstep] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ if (!wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) || !WM_gizmo_group_type_poll(C, gzgroup->type)) { @@ -430,7 +429,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap, gzgroup->type->draw_prepare(C, gzgroup); } - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { gizmo_prepare_drawing(gzmap, gz, C, draw_gizmos, drawstep); } } @@ -751,7 +750,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap, const int event_modifier = WM_event_modifier_flag(event); - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { /* If it were important we could initialize here, * but this only happens when events are handled before drawing, @@ -1165,12 +1164,12 @@ void WM_gizmomap_message_subscribe(bContext *C, ARegion *region, struct wmMsgBus *mbus) { - for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if ((gzgroup->hide.any != 0) || (gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0 || !WM_gizmo_group_type_poll(C, gzgroup->type)) { continue; } - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->flag & WM_GIZMO_HIDDEN) { continue; } @@ -1220,8 +1219,7 @@ struct ARegion *WM_gizmomap_tooltip_init(struct bContext *C, wmGizmoMapType *WM_gizmomaptype_find(const struct wmGizmoMapType_Params *gzmap_params) { - for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; - gzmap_type = gzmap_type->next) { + LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) { if (gzmap_type->spaceid == gzmap_params->spaceid && gzmap_type->regionid == gzmap_params->regionid) { return gzmap_type; @@ -1269,10 +1267,8 @@ void wm_gizmos_keymap(wmKeyConfig *keyconf) /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */ WM_keymap_ensure(keyconf, "Gizmos", 0, 0); - for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; - gzmap_type = gzmap_type->next) { - for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; - gzgt_ref = gzgt_ref->next) { + LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) { + LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) { wm_gizmogrouptype_setup_keymap(gzgt_ref->type, keyconf); } } @@ -1328,8 +1324,7 @@ void WM_gizmoconfig_update(struct Main *bmain) } if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { - for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; - gzmap_type = gzmap_type->next) { + LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) { if (gzmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next; @@ -1348,13 +1343,11 @@ void WM_gizmoconfig_update(struct Main *bmain) } if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) { - for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; - gzmap_type = gzmap_type->next) { + LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) { const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT; if (gzmap_type->type_update_flag & type_update_all) { gzmap_type->type_update_flag &= ~type_update_all; - for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; - gzgt_ref = gzgt_ref->next) { + LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) { if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { WM_gizmomaptype_group_init_runtime_keymap(bmain, gzgt_ref->type); gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; @@ -1373,11 +1366,11 @@ void WM_gizmoconfig_update(struct Main *bmain) if (wm_gzmap_type_update_flag & WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap != NULL && gzmap->tag_remove_group) { gzmap->tag_remove_group = false; @@ -1411,10 +1404,10 @@ void WM_gizmoconfig_update(struct Main *bmain) void WM_reinit_gizmomap_all(Main *bmain) { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { wmGizmoMap *gzmap = region->gizmo_map; if ((gzmap != NULL) && (gzmap->is_init == false)) { WM_gizmomap_reinit(gzmap); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index fe7de6739e1..3956ff8fd36 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -135,10 +135,10 @@ static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt) { /* Free instances. */ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = lb->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, lb) { wmGizmoMap *gzmap = region->gizmo_map; if (gzmap) { wmGizmoGroup *gzgroup; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 44c8e8cd61e..ad3fc7a1302 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -204,7 +204,7 @@ static const char *dropbox_active(bContext *C, if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) { wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base; if (handler->dropboxes) { - for (wmDropBox *drop = handler->dropboxes->first; drop; drop = drop->next) { + LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) { const char *tooltip = NULL; if (drop->poll(C, drag, event, &tooltip)) { /* XXX Doing translation here might not be ideal, but later we have no more @@ -290,7 +290,7 @@ void wm_drags_check_ops(bContext *C, const wmEvent *event) void WM_drag_add_ID(wmDrag *drag, ID *id, ID *from_parent) { /* Don't drag the same ID twice. */ - for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { + LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) { if (drag_id->id == id) { if (drag_id->from_parent == NULL) { drag_id->from_parent = from_parent; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index bd255458ba8..d887d9b0eee 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -209,8 +209,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C, } wmGizmoMap *gzmap = region->gizmo_map; - for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; - gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, WM_gizmomap_group_list(gzmap)) { if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) { ScrArea *ctx_area = CTX_wm_area(C); ARegion *ctx_region = CTX_wm_region(C); @@ -227,7 +226,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C, CTX_wm_region_set(C, ctx_region); } - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->do_draw) { if (tag_redraw) { ED_region_tag_redraw_editor_overlays(region); @@ -323,7 +322,7 @@ void *WM_draw_cb_activate(wmWindow *win, void WM_draw_cb_exit(wmWindow *win, void *handle) { - for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) { + LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) { if (wdc == (WindowDrawCB *)handle) { BLI_remlink(&win->drawcalls, wdc); MEM_freeN(wdc); @@ -334,7 +333,7 @@ void WM_draw_cb_exit(wmWindow *win, void *handle) static void wm_draw_callbacks(wmWindow *win) { - for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) { + LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) { wdc->draw(win, wdc->customdata); } } @@ -624,7 +623,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) CTX_wm_area_set(C, area); /* Compute UI layouts for dynamically size regions. */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { /* Dynamic region may have been flagged as too small because their size on init is 0. * ARegion.visible is false then, as expected. The layout should still be created then, so * the region size can be updated (it may turn out to be not too small then). */ @@ -650,7 +649,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) } /* Then do actual drawing of regions. */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->visible && region->do_draw) { CTX_wm_region_set(C, region); bool use_viewport = wm_region_use_viewport(area, region); @@ -694,7 +693,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) } /* Draw menus into their own framebuffer. */ - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { if (region->visible) { CTX_wm_menu_set(C, region); @@ -737,7 +736,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) /* Blit non-overlapping area regions. */ ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->visible && region->overlap == false) { /* Blit from offscreen buffer. */ wm_draw_region_blit(region, view); @@ -749,7 +748,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) if (wm->paintcursors.first) { ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->visible && region == screen->active_region) { CTX_wm_area_set(C, area); CTX_wm_region_set(C, region); @@ -769,7 +768,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) /* Blend in overlapping area regions */ ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->visible && region->overlap) { wm_draw_region_blend(region, 0, true); } @@ -781,7 +780,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) wm_draw_callbacks(win); /* Blend in floating regions (menus). */ - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { if (region->visible) { wm_draw_region_blend(region, 0, true); } @@ -958,7 +957,7 @@ static void wm_draw_update_clear_window(bContext *C, wmWindow *win) ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { wm_region_test_gizmo_do_draw(C, area, region, false); } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7645ac6fdcf..15b6fe53417 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -192,7 +192,7 @@ void wm_event_init_from_window(wmWindow *win, wmEvent *event) static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, void *reference) { - for (wmNotifier *note = wm->queue.first; note; note = note->next) { + LISTBASE_FOREACH (wmNotifier *, note, &wm->queue) { if ((note->category | note->data | note->subtype | note->action) == type && note->reference == reference) { return 1; @@ -329,14 +329,14 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file) } /* Combine datamasks so 1 win doesn't disable UV's in another [#26448]. */ CustomData_MeshMasks win_combine_v3d_datamask = {0}; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { const Scene *scene = WM_window_get_active_scene(win); const bScreen *screen = WM_window_get_active_screen(win); ED_view3d_screen_datamask(C, scene, screen, &win_combine_v3d_datamask); } /* Update all the dependency graphs of visible view layers. */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Main *bmain = CTX_data_main(C); @@ -369,7 +369,7 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); /* cached: editor refresh callbacks now, they get context */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { const bScreen *screen = WM_window_get_active_screen(win); ScrArea *area; @@ -1867,7 +1867,7 @@ static wmKeyMapItem *wm_eventmatch_modal_keymap_items(const wmKeyMap *keymap, wmOperator *op, const wmEvent *event) { - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { /* Should already be handled by #wm_user_modal_keymap_set_items. */ BLI_assert(kmi->propvalue_str[0] == '\0'); if (wm_eventmatch(event, kmi)) { @@ -2405,7 +2405,7 @@ static int wm_handlers_do_keymap_with_keymap_handler( PRINT("pass\n"); - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if (wm_eventmatch(event, kmi)) { struct wmEventHandler_KeymapPost keymap_post = handler->post; @@ -2610,7 +2610,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C, event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE); event_test_tweak.val = KM_ANY; - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if ((kmi->flag & KMI_INACTIVE) == 0) { if (wm_eventmatch(&event_test_click, kmi) || wm_eventmatch(&event_test_click_drag, kmi) || @@ -2635,7 +2635,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C, if ((action & WM_HANDLER_BREAK) == 0) { if (WM_gizmomap_is_any_selected(gzmap)) { const ListBase *groups = WM_gizmomap_group_list(gzmap); - for (wmGizmoGroup *gzgroup = groups->first; gzgroup; gzgroup = gzgroup->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, groups) { if (wm_gizmogroup_is_any_selected(gzgroup)) { wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap); action |= wm_handlers_do_keymap_with_gizmo_handler( @@ -3614,7 +3614,7 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, if (tref_rt->gizmo_group[0] != '\0' && tref_rt->keymap_fallback[0] != '\n') { wmGizmoMap *gzmap = NULL; wmGizmoGroup *gzgroup = NULL; - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->gizmo_map != NULL) { gzmap = region->gizmo_map; gzgroup = WM_gizmomap_group_find(gzmap, tref_rt->gizmo_group); @@ -4774,7 +4774,7 @@ wmKeyMap *WM_event_get_keymap_from_handler(wmWindowManager *wm, wmEventHandler_K wmKeyMapItem *WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event) { - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if (wm_eventmatch(event, kmi)) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { @@ -4881,7 +4881,7 @@ ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) return NULL; } ScrArea *area_statusbar = NULL; - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { if (area->spacetype == SPACE_STATUSBAR) { area_statusbar = area; break; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 3c8b6b1c9d4..95c7afcbf15 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -236,7 +236,7 @@ static void wm_window_match_keep_current_wm(const bContext *C, /* when loading without UI, no matching needed */ if (load_ui && (screen = CTX_wm_screen(C))) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace; BKE_workspace_layout_find_global(bmain, screen, &workspace); @@ -294,8 +294,8 @@ static void wm_window_match_replace_by_file_wm(bContext *C, wm_window_clear_drawable(oldwm); /* only first wm in list has ghostwins */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { - for (wmWindow *oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + LISTBASE_FOREACH (wmWindow *, oldwin, &oldwm->windows) { if (oldwin->winid == win->winid) { has_match = true; @@ -1507,7 +1507,7 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt)) WM_event_remove_timer(wm, NULL, wm->autosavetimer); /* if a modal operator is running, don't autosave, but try again in 10 seconds */ - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) { if (handler_base->type == WM_HANDLER_TYPE_OP) { wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 33ea6dc54cc..245a8f28fec 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -254,7 +254,7 @@ static void wm_jobs_update_progress_bars(wmWindowManager *wm) float total_progress = 0.f; float jobs_progress = 0; - for (wmJob *wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) { if (wm_job->threads.first && !wm_job->ready) { if (wm_job->flag & WM_JOB_PROGRESS) { /* accumulate global progress for running jobs */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 97a73d9dbfa..5f2b492088e 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -278,7 +278,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user if (keyconf == wm->defaultconf) { /* For default configuration, we need to keep keymap * modal items and poll functions intact. */ - for (wmKeyMap *km = keyconf->keymaps.first; km; km = km->next) { + LISTBASE_FOREACH (wmKeyMap *, km, &keyconf->keymaps) { WM_keymap_clear(km); } } @@ -328,7 +328,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) void WM_keyconfig_clear(wmKeyConfig *keyconf) { - for (wmKeyMap *km = keyconf->keymaps.first; km; km = km->next) { + LISTBASE_FOREACH (wmKeyMap *, km, &keyconf->keymaps) { WM_keymap_clear(km); } @@ -1329,7 +1329,7 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap, const bool is_strict, const struct wmKeyMapItemFind_Params *params) { - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { /* skip disabled keymap items [T38447] */ if (kmi->flag & KMI_INACTIVE) { continue; diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 7d2d39963dd..5ab36b15666 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -486,7 +486,7 @@ static bool wm_keymap_item_uses_modifier(wmKeyMapItem *kmi, const int event_modi bool WM_keymap_uses_event_modifier(wmKeyMap *keymap, const int event_modifier) { - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if ((kmi->flag & KMI_INACTIVE) == 0) { if (wm_keymap_item_uses_modifier(kmi, event_modifier)) { return true; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9a376390096..f8e020b00d0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -769,7 +769,7 @@ bool WM_operator_last_properties_init(wmOperator *op) bool changed = false; if (op->type->last_properties) { changed |= operator_last_properties_init_impl(op, op->type->last_properties); - for (wmOperator *opm = op->macro.first; opm; opm = opm->next) { + LISTBASE_FOREACH (wmOperator *, opm, &op->macro) { IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, opm->idname); if (idp_src) { changed |= operator_last_properties_init_impl(opm, idp_src); @@ -792,7 +792,7 @@ bool WM_operator_last_properties_store(wmOperator *op) } if (op->macro.first != NULL) { - for (wmOperator *opm = op->macro.first; opm; opm = opm->next) { + LISTBASE_FOREACH (wmOperator *, opm, &op->macro) { if (opm->properties) { if (op->type->last_properties == NULL) { op->type->last_properties = IDP_New( @@ -3689,8 +3689,8 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data) const bool session_exists = WM_xr_session_exists(xr_data); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) { if (slink->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)slink; diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c index 043b584bbbd..e8850693d69 100644 --- a/source/blender/windowmanager/intern/wm_surface.c +++ b/source/blender/windowmanager/intern/wm_surface.c @@ -45,7 +45,7 @@ static wmSurface *g_drawable = NULL; void wm_surfaces_iter(bContext *C, void (*cb)(bContext *C, wmSurface *)) { - for (wmSurface *surf = global_surface_list.first; surf; surf = surf->next) { + LISTBASE_FOREACH (wmSurface *, surf, &global_surface_list) { cb(C, surf); } } diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index f1928819c26..38fa24f0416 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -178,7 +178,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre if (i != -1) { const int value = items[i].value; wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (workspace == WM_window_get_active_workspace(win)) { Scene *scene = WM_window_get_active_scene(win); ToolSettings *ts = scene->toolsettings; @@ -197,7 +197,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre if (i != -1) { const int slot_index = items[i].value; wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (workspace == WM_window_get_active_workspace(win)) { Scene *scene = WM_window_get_active_scene(win); BKE_paint_ensure_from_paintmode(scene, paint_mode); @@ -279,7 +279,7 @@ void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { continue; } @@ -372,7 +372,7 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo return; } wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (workspace != WM_window_get_active_workspace(win)) { continue; } @@ -514,13 +514,13 @@ void WM_toolsystem_refresh_active(bContext *C) { Main *bmain = CTX_data_main(C); for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace = WM_window_get_active_workspace(win); bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); /* Could skip loop for modes that don't depend on space type. */ int space_type_mask_handled = 0; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { /* Don't change the space type of the active tool, only update it's mode. */ const int space_type_mask = (1 << area->spacetype); if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) && @@ -547,7 +547,7 @@ void WM_toolsystem_refresh_active(bContext *C) /* Refresh to ensure data is initialized. * This is needed because undo can load a state which no longer has the underlying DNA data * needed for the tool (un-initialized paint-slots for eg), see: T64339. */ - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { toolsystem_refresh_ref(C, workspace, tref); } } @@ -559,7 +559,7 @@ void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_lay area->runtime.tool = NULL; area->runtime.is_tool_set = true; const int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { if (tref->space_type == area->spacetype) { if (tref->mode == mode) { area->runtime.tool = tref; @@ -573,15 +573,15 @@ void WM_toolsystem_refresh_screen_all(Main *bmain) { /* Update all ScrArea's tools */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace = WM_window_get_active_workspace(win); bool space_type_has_tools[SPACE_TYPE_LAST + 1] = {0}; - for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { + LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { space_type_has_tools[tref->space_type] = true; } bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { area->runtime.tool = NULL; area->runtime.is_tool_set = true; if (space_type_has_tools[area->spacetype]) { @@ -598,11 +598,11 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain, { /* Update all ScrArea's tools */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (workspace == WM_window_get_active_workspace(win)) { bScreen *screen = WM_window_get_active_screen(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == tref->space_type) { int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); if (mode == tref->mode) { @@ -761,7 +761,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) ScrArea *area_prev = CTX_wm_area(C); ARegion *region_prev = CTX_wm_region(C); - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win != win_prev) { WorkSpace *workspace_iter = WM_window_get_active_workspace(win); if (workspace_iter != workspace) { diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 694b3176f50..699f618f956 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -430,7 +430,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) /* Close child windows and bring windows back to front that dialogs have pushed behind the main * window. */ - for (wmWindow *iter_win = wm->windows.first; iter_win; iter_win = iter_win->next) { + LISTBASE_FOREACH (wmWindow *, iter_win, &wm->windows) { if (iter_win->parent == win) { wm_window_close(C, wm, iter_win); } @@ -781,7 +781,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) #endif } - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { wm_window_ghostwindow_ensure(wm, win, false); } } @@ -2169,8 +2169,7 @@ void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect) screen_rect = window_rect; /* Subtract global areas from screen rectangle. */ - for (ScrArea *global_area = win->global_areas.areabase.first; global_area; - global_area = global_area->next) { + LISTBASE_FOREACH (ScrArea *, global_area, &win->global_areas.areabase) { int height = ED_area_global_size_y(global_area) - 1; if (global_area->global->flag & GLOBAL_AREA_IS_HIDDEN) { @@ -2218,7 +2217,7 @@ bool WM_window_is_maximized(const wmWindow *win) */ void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene) { - for (wmWindow *win = win_lb->first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, win_lb) { if (WM_window_get_active_scene(win) == scene) { ED_workspace_scene_data_sync(win->workspace_hook, scene); } @@ -2227,7 +2226,7 @@ void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene) Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen *screen) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (WM_window_get_active_screen(win) == screen) { return WM_window_get_active_scene(win); } @@ -2238,7 +2237,7 @@ Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const bScreen *screen) { - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (WM_window_get_active_screen(win) == screen) { return WM_window_get_active_workspace(win); } @@ -2266,7 +2265,7 @@ void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene * changed = true; } - for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) { if (win_child->parent == win_parent && win_child->scene != scene) { ED_screen_scene_change(C, win_child, scene); changed = true; @@ -2312,7 +2311,7 @@ void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer) wmWindow *win_parent = (win->parent) ? win->parent : win; /* Set view layer in parent and child windows. */ - for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) { + LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) { if ((win_iter == win_parent) || (win_iter->parent == win_parent)) { STRNCPY(win_iter->view_layer_name, view_layer->name); bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook); @@ -2344,7 +2343,7 @@ void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *works ED_workspace_change(workspace, C, wm, win); - for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { + LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) { if (win_child->parent == win_parent) { bScreen *screen = WM_window_get_active_screen(win_child); /* Don't change temporary screens, they only serve a single purpose. */ diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c index fd5237a70a5..86a106462c3 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c @@ -111,7 +111,7 @@ void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner) void WM_msg_dump(struct wmMsgBus *mbus, const char *info_str) { printf(">>>> %s\n", info_str); - for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) { + LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key); const wmMsgTypeInfo *info = &wm_msg_types[msg->type]; info->repr(stdout, key); @@ -131,8 +131,8 @@ void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C) } // uint a = 0, b = 0; - for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) { - for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) { + LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { + LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) { if (msg_lnk->params.tag) { msg_lnk->params.notify(C, key, &msg_lnk->params); msg_lnk->params.tag = false; @@ -175,7 +175,7 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus, } else { key = *r_key; - for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) { + LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) { if ((msg_lnk->params.notify == msg_val_params->notify) && (msg_lnk->params.owner == msg_val_params->owner) && (msg_lnk->params.user_data == msg_val_params->user_data)) { @@ -198,8 +198,7 @@ void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *msg_key) msg_key, BLI_listbase_count(&msg_key->values)); - for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; - msg_lnk = msg_lnk->next) { + LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &msg_key->values) { if (false) { /* make an option? */ msg_lnk->params.notify(NULL, msg_key, &msg_lnk->params); } -- cgit v1.2.3 From 82774a9d24c4e355768b7f948ca18392141c31d2 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 19:42:48 +0200 Subject: Cleanup: Move all sculpt transform functionality to its own file --- source/blender/editors/sculpt_paint/CMakeLists.txt | 1 + source/blender/editors/sculpt_paint/sculpt.c | 367 ++------------------ .../blender/editors/sculpt_paint/sculpt_intern.h | 21 +- .../editors/sculpt_paint/sculpt_transform.c | 381 +++++++++++++++++++++ 4 files changed, 422 insertions(+), 348 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_transform.c diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index fda9594835d..f793a775e05 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -63,6 +63,7 @@ set(SRC sculpt_face_set.c sculpt_multiplane_scrape.c sculpt_pose.c + sculpt_transform.c sculpt_undo.c sculpt_uv.c diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2b5d576f7c2..da1174c3a0d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -6425,7 +6425,7 @@ static void sculpt_update_keyblock(Object *ob) } } -static void sculpt_flush_stroke_deform_task_cb(void *__restrict userdata, +static void SCULPT_flush_stroke_deform_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) { @@ -6449,7 +6449,7 @@ static void sculpt_flush_stroke_deform_task_cb(void *__restrict userdata, } /* Flush displacement from deformed PBVH to original layer. */ -static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_used) +void SCULPT_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_used) { SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); @@ -6483,7 +6483,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_use PBVHParallelSettings settings; BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - BKE_pbvh_parallel_range(0, totnode, &data, sculpt_flush_stroke_deform_task_cb, &settings); + BKE_pbvh_parallel_range(0, totnode, &data, SCULPT_flush_stroke_deform_task_cb, &settings); if (vertCos) { SCULPT_vertcos_to_key(ob, ss->shapekey_active, vertCos); @@ -7744,7 +7744,7 @@ void SCULPT_update_object_bounding_box(Object *ob) } } -static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags) +void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); @@ -7804,7 +7804,7 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags) } } -static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags) +void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags) { /* After we are done drawing the stroke, check if we need to do a more * expensive depsgraph tag to update geometry. */ @@ -7952,7 +7952,7 @@ static void sculpt_stroke_update_step(bContext *C, * sculpt_flush_update_step(). */ if (ss->deform_modifiers_active) { - sculpt_flush_stroke_deform(sd, ob, sculpt_tool_is_proxy_used(brush->sculpt_tool)); + SCULPT_flush_stroke_deform(sd, ob, sculpt_tool_is_proxy_used(brush->sculpt_tool)); } else if (ss->shapekey_active) { sculpt_update_keyblock(ob); @@ -7963,10 +7963,10 @@ static void sculpt_stroke_update_step(bContext *C, /* Cleanup. */ if (brush->sculpt_tool == SCULPT_TOOL_MASK) { - sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); } else { - sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS); + SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); } } @@ -8024,10 +8024,10 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str SCULPT_undo_push_end(); if (brush->sculpt_tool == SCULPT_TOOL_MASK) { - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); } else { - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -9311,7 +9311,7 @@ static void filter_cache_init_task_cb(void *__restrict userdata, SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); } -static void sculpt_filter_cache_init(Object *ob, Sculpt *sd) +void SCULPT_filter_cache_init(Object *ob, Sculpt *sd) { SculptSession *ss = ob->sculpt; PBVH *pbvh = ob->sculpt->pbvh; @@ -9357,7 +9357,7 @@ static void sculpt_filter_cache_init(Object *ob, Sculpt *sd) 0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings); } -static void sculpt_filter_cache_free(SculptSession *ss) +void SCULPT_filter_cache_free(SculptSession *ss) { if (ss->filter_cache->nodes) { MEM_freeN(ss->filter_cache->nodes); @@ -9638,9 +9638,9 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent * const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { - sculpt_filter_cache_free(ss); + SCULPT_filter_cache_free(ss); SCULPT_undo_push_end(); - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); return OPERATOR_FINISHED; } @@ -9680,7 +9680,7 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent * ss->filter_cache->iteration_count++; if (ss->deform_modifiers_active || ss->shapekey_active) { - sculpt_flush_stroke_deform(sd, ob, true); + SCULPT_flush_stroke_deform(sd, ob, true); } /* The relax mesh filter needs the updated normals of the modified mesh after each iteration. */ @@ -9688,7 +9688,7 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent * BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg); } - sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS); + SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); return OPERATOR_RUNNING_MODAL; } @@ -9729,7 +9729,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent SCULPT_undo_push_begin("Mesh filter"); - sculpt_filter_cache_init(ob, sd); + SCULPT_filter_cache_init(ob, sd); if (use_face_sets) { ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss, @@ -10284,11 +10284,11 @@ static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) } if (!create_face_set) { - sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); } - sculpt_filter_cache_free(ss); + SCULPT_filter_cache_free(ss); SCULPT_undo_push_end(); - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); ED_workspace_status_text(C, NULL); } @@ -10447,10 +10447,10 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); } - sculpt_filter_cache_free(ss); + SCULPT_filter_cache_free(ss); SCULPT_undo_push_end(); - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); ED_workspace_status_text(C, NULL); return OPERATOR_FINISHED; } @@ -10494,7 +10494,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * ss->filter_cache->mask_update_current_it = mask_expand_update_it; } - sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); return OPERATOR_RUNNING_MODAL; } @@ -10667,7 +10667,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent "cancel"); ED_workspace_status_text(C, status_str); - sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; } @@ -10789,325 +10789,6 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float ss->preview_vert_index_count = totpoints; } -void ED_sculpt_init_transform(struct bContext *C) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - - copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos); - copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot); - - SCULPT_undo_push_begin("Transform"); - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); - - ss->pivot_rot[3] = 1.0f; - - SCULPT_vertex_random_access_init(ss); - sculpt_filter_cache_init(ob, sd); -} - -static void sculpt_transform_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - - SculptOrigVertData orig_data; - SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]); - - PBVHVertexIter vd; - - SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - SCULPT_orig_vert_data_update(&orig_data, &vd); - float transformed_co[3], orig_co[3], disp[3]; - float fade = vd.mask ? *vd.mask : 0.0f; - copy_v3_v3(orig_co, orig_data.co); - char symm_area = SCULPT_get_vertex_symm_area(orig_co); - - copy_v3_v3(transformed_co, orig_co); - mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co); - sub_v3_v3v3(disp, transformed_co, orig_co); - mul_v3_fl(disp, 1.0f - fade); - - add_v3_v3v3(vd.co, orig_co, disp); - - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(node); -} - -void ED_sculpt_update_modal_transform(struct bContext *C) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; - - SCULPT_vertex_random_access_init(ss); - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - }; - - float final_pivot_pos[3], d_t[3], d_r[4]; - float t_mat[4][4], r_mat[4][4], s_mat[4][4], pivot_mat[4][4], pivot_imat[4][4], - transform_mat[4][4]; - - copy_v3_v3(final_pivot_pos, ss->pivot_pos); - for (int i = 0; i < PAINT_SYMM_AREAS; i++) { - ePaintSymmetryAreas v_symm = i; - - copy_v3_v3(final_pivot_pos, ss->pivot_pos); - - unit_m4(pivot_mat); - - unit_m4(t_mat); - unit_m4(r_mat); - unit_m4(s_mat); - - /* Translation matrix. */ - sub_v3_v3v3(d_t, ss->pivot_pos, ss->init_pivot_pos); - SCULPT_flip_v3_by_symm_area(d_t, symm, v_symm, ss->init_pivot_pos); - translate_m4(t_mat, d_t[0], d_t[1], d_t[2]); - - /* Rotation matrix. */ - sub_qt_qtqt(d_r, ss->pivot_rot, ss->init_pivot_rot); - normalize_qt(d_r); - SCULPT_flip_quat_by_symm_area(d_r, symm, v_symm, ss->init_pivot_pos); - quat_to_mat4(r_mat, d_r); - - /* Scale matrix. */ - size_to_mat4(s_mat, ss->pivot_scale); - - /* Pivot matrix. */ - SCULPT_flip_v3_by_symm_area(final_pivot_pos, symm, v_symm, ss->init_pivot_pos); - translate_m4(pivot_mat, final_pivot_pos[0], final_pivot_pos[1], final_pivot_pos[2]); - invert_m4_m4(pivot_imat, pivot_mat); - - /* Final transform matrix. */ - mul_m4_m4m4(transform_mat, r_mat, t_mat); - mul_m4_m4m4(transform_mat, transform_mat, s_mat); - mul_m4_m4m4(data.transform_mats[i], transform_mat, pivot_imat); - mul_m4_m4m4(data.transform_mats[i], pivot_mat, data.transform_mats[i]); - } - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range( - 0, ss->filter_cache->totnode, &data, sculpt_transform_task_cb, &settings); - - if (ss->deform_modifiers_active || ss->shapekey_active) { - sculpt_flush_stroke_deform(sd, ob, true); - } - - sculpt_flush_update_step(C, SCULPT_UPDATE_COORDS); -} - -void ED_sculpt_end_transform(struct bContext *C) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - if (ss->filter_cache) { - sculpt_filter_cache_free(ss); - } - /* Force undo push to happen even inside transform operator, since the sculpt - * undo system works separate from regular undo and this is require to properly - * finish an undo step also when cancelling. */ - const bool use_nested_undo = true; - SCULPT_undo_push_end_ex(use_nested_undo); - sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); -} - -typedef enum eSculptPivotPositionModes { - SCULPT_PIVOT_POSITION_ORIGIN = 0, - SCULPT_PIVOT_POSITION_UNMASKED = 1, - SCULPT_PIVOT_POSITION_MASK_BORDER = 2, - SCULPT_PIVOT_POSITION_ACTIVE_VERTEX = 3, - SCULPT_PIVOT_POSITION_CURSOR_SURFACE = 4, -} eSculptPivotPositionModes; - -static EnumPropertyItem prop_sculpt_pivot_position_types[] = { - {SCULPT_PIVOT_POSITION_ORIGIN, - "ORIGIN", - 0, - "Origin", - "Sets the pivot to the origin of the sculpt"}, - {SCULPT_PIVOT_POSITION_UNMASKED, - "UNMASKED", - 0, - "Unmasked", - "Sets the pivot position to the average position of the unmasked vertices"}, - {SCULPT_PIVOT_POSITION_MASK_BORDER, - "BORDER", - 0, - "Mask border", - "Sets the pivot position to the center of the border of the mask"}, - {SCULPT_PIVOT_POSITION_ACTIVE_VERTEX, - "ACTIVE", - 0, - "Active vertex", - "Sets the pivot position to the active vertex position"}, - {SCULPT_PIVOT_POSITION_CURSOR_SURFACE, - "SURFACE", - 0, - "Surface", - "Sets the pivot position to the surface under the cursor"}, - {0, NULL, 0, NULL, NULL}, -}; - -static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - ARegion *region = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; - - int mode = RNA_enum_get(op->ptr, "mode"); - - BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); - - /* Pivot to center. */ - if (mode == SCULPT_PIVOT_POSITION_ORIGIN) { - zero_v3(ss->pivot_pos); - } - /* Pivot to active vertex. */ - else if (mode == SCULPT_PIVOT_POSITION_ACTIVE_VERTEX) { - copy_v3_v3(ss->pivot_pos, SCULPT_active_vertex_co_get(ss)); - } - /* Pivot to raycast surface. */ - else if (mode == SCULPT_PIVOT_POSITION_CURSOR_SURFACE) { - float stroke_location[3]; - float mouse[2]; - mouse[0] = RNA_float_get(op->ptr, "mouse_x"); - mouse[1] = RNA_float_get(op->ptr, "mouse_y"); - if (SCULPT_stroke_get_location(C, stroke_location, mouse)) { - copy_v3_v3(ss->pivot_pos, stroke_location); - } - } - else { - PBVHNode **nodes; - int totnode; - BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); - - float avg[3]; - int total = 0; - zero_v3(avg); - - /* Pivot to unmasked. */ - if (mode == SCULPT_PIVOT_POSITION_UNMASKED) { - for (int n = 0; n < totnode; n++) { - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) - { - const float mask = (vd.mask) ? *vd.mask : 0.0f; - if (mask < 1.0f) { - if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) { - add_v3_v3(avg, vd.co); - total++; - } - } - } - BKE_pbvh_vertex_iter_end; - } - } - /* Pivot to mask border. */ - else if (mode == SCULPT_PIVOT_POSITION_MASK_BORDER) { - const float threshold = 0.2f; - - for (int n = 0; n < totnode; n++) { - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) - { - const float mask = (vd.mask) ? *vd.mask : 0.0f; - if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) { - if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) { - add_v3_v3(avg, vd.co); - total++; - } - } - } - BKE_pbvh_vertex_iter_end; - } - } - - if (total > 0) { - mul_v3_fl(avg, 1.0f / total); - copy_v3_v3(ss->pivot_pos, avg); - } - - MEM_SAFE_FREE(nodes); - } - - ED_region_tag_redraw(region); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); - - return OPERATOR_FINISHED; -} - -static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - RNA_float_set(op->ptr, "mouse_x", event->mval[0]); - RNA_float_set(op->ptr, "mouse_y", event->mval[1]); - return sculpt_set_pivot_position_exec(C, op); -} - -static void SCULPT_OT_set_pivot_position(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Set Pivot Position"; - ot->idname = "SCULPT_OT_set_pivot_position"; - ot->description = "Sets the sculpt transform pivot position"; - - /* API callbacks. */ - ot->invoke = sculpt_set_pivot_position_invoke; - ot->exec = sculpt_set_pivot_position_exec; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_enum(ot->srna, - "mode", - prop_sculpt_pivot_position_types, - SCULPT_PIVOT_POSITION_UNMASKED, - "Mode", - ""); - - RNA_def_float(ot->srna, - "mouse_x", - 0.0f, - 0.0f, - FLT_MAX, - "Mouse Position X", - "Position of the mouse used for \"Surface\" mode", - 0.0f, - 10000.0f); - RNA_def_float(ot->srna, - "mouse_y", - 0.0f, - 0.0f, - FLT_MAX, - "Mouse Position Y", - "Position of the mouse used for \"Surface\" mode", - 0.0f, - 10000.0f); -} void ED_operatortypes_sculpt(void) { diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 7f926054ca7..c300f011195 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -57,6 +57,10 @@ typedef enum SculptUpdateType { SCULPT_UPDATE_VISIBILITY = 1 << 2, } SculptUpdateType; +void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags); +void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags); +void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used); + /* Stroke */ typedef struct SculptCursorGeometryInfo { @@ -172,11 +176,6 @@ typedef struct { void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node); void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter); -/* Dynamic topology */ -void sculpt_pbvh_clear(Object *ob); -void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); -void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); - /* Utils. */ void SCULPT_calc_brush_plane(struct Sculpt *sd, struct Object *ob, @@ -239,9 +238,18 @@ void SCULPT_floodfill_execute( void *userdata); void SCULPT_floodfill_free(SculptFloodFill *flood); +/* Dynamic topology */ +void sculpt_pbvh_clear(Object *ob); +void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); +void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); + /* Automasking. */ float SCULPT_automasking_factor_get(SculptSession *ss, int vert); +/* Filters. */ +void SCULPT_filter_cache_init(Object *ob, Sculpt *sd); +void SCULPT_filter_cache_free(SculptSession *ss); + /* Brushes. */ /* Cloth Brush. */ @@ -764,4 +772,7 @@ void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot); void SCULPT_OT_face_sets_init(struct wmOperatorType *ot); void SCULPT_OT_face_sets_create(struct wmOperatorType *ot); +/* Transform */ +void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot); + #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c new file mode 100644 index 00000000000..c7cbb6672a4 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_transform.c @@ -0,0 +1,381 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "bmesh.h" + +#include +#include + +void ED_sculpt_init_transform(struct bContext *C) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + + copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos); + copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot); + + SCULPT_undo_push_begin("Transform"); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); + + ss->pivot_rot[3] = 1.0f; + + SCULPT_vertex_random_access_init(ss); + SCULPT_filter_cache_init(ob, sd); +} + +static void sculpt_transform_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + + SculptOrigVertData orig_data; + SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]); + + PBVHVertexIter vd; + + SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + SCULPT_orig_vert_data_update(&orig_data, &vd); + float transformed_co[3], orig_co[3], disp[3]; + float fade = vd.mask ? *vd.mask : 0.0f; + copy_v3_v3(orig_co, orig_data.co); + char symm_area = SCULPT_get_vertex_symm_area(orig_co); + + copy_v3_v3(transformed_co, orig_co); + mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co); + sub_v3_v3v3(disp, transformed_co, orig_co); + mul_v3_fl(disp, 1.0f - fade); + + add_v3_v3v3(vd.co, orig_co, disp); + + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_update(node); +} + +void ED_sculpt_update_modal_transform(struct bContext *C) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; + + SCULPT_vertex_random_access_init(ss); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = ss->filter_cache->nodes, + }; + + float final_pivot_pos[3], d_t[3], d_r[4]; + float t_mat[4][4], r_mat[4][4], s_mat[4][4], pivot_mat[4][4], pivot_imat[4][4], + transform_mat[4][4]; + + copy_v3_v3(final_pivot_pos, ss->pivot_pos); + for (int i = 0; i < PAINT_SYMM_AREAS; i++) { + ePaintSymmetryAreas v_symm = i; + + copy_v3_v3(final_pivot_pos, ss->pivot_pos); + + unit_m4(pivot_mat); + + unit_m4(t_mat); + unit_m4(r_mat); + unit_m4(s_mat); + + /* Translation matrix. */ + sub_v3_v3v3(d_t, ss->pivot_pos, ss->init_pivot_pos); + SCULPT_flip_v3_by_symm_area(d_t, symm, v_symm, ss->init_pivot_pos); + translate_m4(t_mat, d_t[0], d_t[1], d_t[2]); + + /* Rotation matrix. */ + sub_qt_qtqt(d_r, ss->pivot_rot, ss->init_pivot_rot); + normalize_qt(d_r); + SCULPT_flip_quat_by_symm_area(d_r, symm, v_symm, ss->init_pivot_pos); + quat_to_mat4(r_mat, d_r); + + /* Scale matrix. */ + size_to_mat4(s_mat, ss->pivot_scale); + + /* Pivot matrix. */ + SCULPT_flip_v3_by_symm_area(final_pivot_pos, symm, v_symm, ss->init_pivot_pos); + translate_m4(pivot_mat, final_pivot_pos[0], final_pivot_pos[1], final_pivot_pos[2]); + invert_m4_m4(pivot_imat, pivot_mat); + + /* Final transform matrix. */ + mul_m4_m4m4(transform_mat, r_mat, t_mat); + mul_m4_m4m4(transform_mat, transform_mat, s_mat); + mul_m4_m4m4(data.transform_mats[i], transform_mat, pivot_imat); + mul_m4_m4m4(data.transform_mats[i], pivot_mat, data.transform_mats[i]); + } + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); + BKE_pbvh_parallel_range( + 0, ss->filter_cache->totnode, &data, sculpt_transform_task_cb, &settings); + + if (ss->deform_modifiers_active || ss->shapekey_active) { + SCULPT_flush_stroke_deform(sd, ob, true); + } + + SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); +} + +void ED_sculpt_end_transform(struct bContext *C) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + if (ss->filter_cache) { + SCULPT_filter_cache_free(ss); + } + /* Force undo push to happen even inside transform operator, since the sculpt + * undo system works separate from regular undo and this is require to properly + * finish an undo step also when cancelling. */ + const bool use_nested_undo = true; + SCULPT_undo_push_end_ex(use_nested_undo); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); +} + +typedef enum eSculptPivotPositionModes { + SCULPT_PIVOT_POSITION_ORIGIN = 0, + SCULPT_PIVOT_POSITION_UNMASKED = 1, + SCULPT_PIVOT_POSITION_MASK_BORDER = 2, + SCULPT_PIVOT_POSITION_ACTIVE_VERTEX = 3, + SCULPT_PIVOT_POSITION_CURSOR_SURFACE = 4, +} eSculptPivotPositionModes; + +static EnumPropertyItem prop_sculpt_pivot_position_types[] = { + {SCULPT_PIVOT_POSITION_ORIGIN, + "ORIGIN", + 0, + "Origin", + "Sets the pivot to the origin of the sculpt"}, + {SCULPT_PIVOT_POSITION_UNMASKED, + "UNMASKED", + 0, + "Unmasked", + "Sets the pivot position to the average position of the unmasked vertices"}, + {SCULPT_PIVOT_POSITION_MASK_BORDER, + "BORDER", + 0, + "Mask border", + "Sets the pivot position to the center of the border of the mask"}, + {SCULPT_PIVOT_POSITION_ACTIVE_VERTEX, + "ACTIVE", + 0, + "Active vertex", + "Sets the pivot position to the active vertex position"}, + {SCULPT_PIVOT_POSITION_CURSOR_SURFACE, + "SURFACE", + 0, + "Surface", + "Sets the pivot position to the surface under the cursor"}, + {0, NULL, 0, NULL, NULL}, +}; + +static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *region = CTX_wm_region(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; + + int mode = RNA_enum_get(op->ptr, "mode"); + + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); + + /* Pivot to center. */ + if (mode == SCULPT_PIVOT_POSITION_ORIGIN) { + zero_v3(ss->pivot_pos); + } + /* Pivot to active vertex. */ + else if (mode == SCULPT_PIVOT_POSITION_ACTIVE_VERTEX) { + copy_v3_v3(ss->pivot_pos, SCULPT_active_vertex_co_get(ss)); + } + /* Pivot to raycast surface. */ + else if (mode == SCULPT_PIVOT_POSITION_CURSOR_SURFACE) { + float stroke_location[3]; + float mouse[2]; + mouse[0] = RNA_float_get(op->ptr, "mouse_x"); + mouse[1] = RNA_float_get(op->ptr, "mouse_y"); + if (SCULPT_stroke_get_location(C, stroke_location, mouse)) { + copy_v3_v3(ss->pivot_pos, stroke_location); + } + } + else { + PBVHNode **nodes; + int totnode; + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); + + float avg[3]; + int total = 0; + zero_v3(avg); + + /* Pivot to unmasked. */ + if (mode == SCULPT_PIVOT_POSITION_UNMASKED) { + for (int n = 0; n < totnode; n++) { + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + const float mask = (vd.mask) ? *vd.mask : 0.0f; + if (mask < 1.0f) { + if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) { + add_v3_v3(avg, vd.co); + total++; + } + } + } + BKE_pbvh_vertex_iter_end; + } + } + /* Pivot to mask border. */ + else if (mode == SCULPT_PIVOT_POSITION_MASK_BORDER) { + const float threshold = 0.2f; + + for (int n = 0; n < totnode; n++) { + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + const float mask = (vd.mask) ? *vd.mask : 0.0f; + if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) { + if (SCULPT_check_vertex_pivot_symmetry(vd.co, ss->pivot_pos, symm)) { + add_v3_v3(avg, vd.co); + total++; + } + } + } + BKE_pbvh_vertex_iter_end; + } + } + + if (total > 0) { + mul_v3_fl(avg, 1.0f / total); + copy_v3_v3(ss->pivot_pos, avg); + } + + MEM_SAFE_FREE(nodes); + } + + ED_region_tag_redraw(region); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); + + return OPERATOR_FINISHED; +} + +static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + RNA_float_set(op->ptr, "mouse_x", event->mval[0]); + RNA_float_set(op->ptr, "mouse_y", event->mval[1]); + return sculpt_set_pivot_position_exec(C, op); +} + +void SCULPT_OT_set_pivot_position(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Set Pivot Position"; + ot->idname = "SCULPT_OT_set_pivot_position"; + ot->description = "Sets the sculpt transform pivot position"; + + /* API callbacks. */ + ot->invoke = sculpt_set_pivot_position_invoke; + ot->exec = sculpt_set_pivot_position_exec; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + RNA_def_enum(ot->srna, + "mode", + prop_sculpt_pivot_position_types, + SCULPT_PIVOT_POSITION_UNMASKED, + "Mode", + ""); + + RNA_def_float(ot->srna, + "mouse_x", + 0.0f, + 0.0f, + FLT_MAX, + "Mouse Position X", + "Position of the mouse used for \"Surface\" mode", + 0.0f, + 10000.0f); + RNA_def_float(ot->srna, + "mouse_y", + 0.0f, + 0.0f, + FLT_MAX, + "Mouse Position Y", + "Position of the mouse used for \"Surface\" mode", + 0.0f, + 10000.0f); +} -- cgit v1.2.3 From d38023f2f38ccfc81a1c0394b0982514df352b3c Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Fri, 3 Apr 2020 15:08:54 -0300 Subject: fix (unreported): Weld Modifier: possible use of uninitialized variable --- source/blender/modifiers/intern/MOD_weld.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c index a7d3280b113..90b71b2d504 100644 --- a/source/blender/modifiers/intern/MOD_weld.c +++ b/source/blender/modifiers/intern/MOD_weld.c @@ -800,6 +800,8 @@ static bool weld_iter_loop_of_poly_begin(WeldLoopOfPolyIter *iter, iter->mloop = mloop; iter->loop_map = loop_map; iter->group = group_buffer; + + uint group_len = 0; if (group_buffer) { /* First loop group needs more attention. */ uint loop_start, loop_end, l; @@ -817,16 +819,14 @@ static bool weld_iter_loop_of_poly_begin(WeldLoopOfPolyIter *iter, break; } if (l != loop_end) { - iter->group_len = iter->loop_end - l; + group_len = loop_end - l; int i = 0; while (l < loop_end) { iter->group[i++] = ++l; } } } - else { - iter->group_len = 0; - } + iter->group_len = group_len; iter->l_next = iter->loop_start; #ifdef USE_WELD_DEBUG -- cgit v1.2.3 From f2f30db98dacf2821fce3389952798c597bffe11 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 21:05:20 +0200 Subject: Cleanup: Move Mesh Filter, Smooth and Automasking to their own files --- source/blender/editors/sculpt_paint/CMakeLists.txt | 3 + source/blender/editors/sculpt_paint/sculpt.c | 1470 +------------------- .../editors/sculpt_paint/sculpt_automasking.c | 304 ++++ .../editors/sculpt_paint/sculpt_filter_mesh.c | 571 ++++++++ .../blender/editors/sculpt_paint/sculpt_intern.h | 72 +- .../blender/editors/sculpt_paint/sculpt_smooth.c | 603 ++++++++ 6 files changed, 1598 insertions(+), 1425 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_automasking.c create mode 100644 source/blender/editors/sculpt_paint/sculpt_filter_mesh.c create mode 100644 source/blender/editors/sculpt_paint/sculpt_smooth.c diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index f793a775e05..81dafd5ded4 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -59,10 +59,13 @@ set(SRC paint_vertex_weight_ops.c paint_vertex_weight_utils.c sculpt.c + sculpt_automasking.c sculpt_cloth.c sculpt_face_set.c + sculpt_filter_mesh.c sculpt_multiplane_scrape.c sculpt_pose.c + sculpt_smooth.c sculpt_transform.c sculpt_undo.c sculpt_uv.c diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index da1174c3a0d..a53c9aed36d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -674,7 +674,7 @@ void SCULPT_vertex_neighbors_get(SculptSession *ss, } } -static bool sculpt_vertex_is_boundary(SculptSession *ss, const int index) +bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: { @@ -824,10 +824,10 @@ bool SCULPT_is_symmetry_iteration_valid(char i, char symm) } /* Checks if a vertex is inside the brush radius from any of its mirrored axis. */ -static bool sculpt_is_vertex_inside_brush_radius_symm(const float vertex[3], - const float br_co[3], - float radius, - char symm) +bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3], + const float br_co[3], + float radius, + char symm) { for (char i = 0; i <= symm; ++i) { if (SCULPT_is_symmetry_iteration_valid(i, symm)) { @@ -854,7 +854,7 @@ void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood) flood->visited_vertices = MEM_callocN(vertex_count * sizeof(char), "visited vertices"); } -void sculpt_floodfill_add_initial(SculptFloodFill *flood, int index) +void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index) { BLI_gsqueue_push(flood->queue, &index); } @@ -877,7 +877,7 @@ void SCULPT_floodfill_add_initial_with_symmetry( v = SCULPT_nearest_vertex_get(sd, ob, location, radius_squared, false); } if (v != -1) { - sculpt_floodfill_add_initial(flood, v); + SCULPT_floodfill_add_initial(flood, v); } } } @@ -901,7 +901,7 @@ void SCULPT_floodfill_add_active( v = SCULPT_nearest_vertex_get(sd, ob, location, radius_squared, false); } if (v != -1) { - sculpt_floodfill_add_initial(flood, v); + SCULPT_floodfill_add_initial(flood, v); } } } @@ -1196,7 +1196,7 @@ static void sculpt_project_v3(const SculptProjectVector *spvc, const float vec[3 * Factors: some brushes like grab cannot do dynamic topology. * Others, like smooth, are better without. Same goes for alt- * key smoothing. */ -static bool sculpt_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush) +bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush) { return ((BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) && @@ -1585,254 +1585,6 @@ static bool sculpt_brush_test_cyl(SculptBrushTest *test, #endif -/* Automasking */ - -static bool sculpt_is_automasking_mode_enabled(const Sculpt *sd, - const Brush *br, - const eAutomasking_flag mode) -{ - return br->automasking_flags & mode || sd->automasking_flags & mode; -} - -static bool sculpt_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br) -{ - if (sculpt_stroke_is_dynamic_topology(ss, br)) { - return false; - } - if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) { - return true; - } - if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_FACE_SETS)) { - return true; - } - if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { - return true; - } - if (sculpt_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { - return true; - } - return false; -} - -float SCULPT_automasking_factor_get(SculptSession *ss, int vert) -{ - if (ss->cache->automask) { - return ss->cache->automask[vert]; - } - else { - return 1.0f; - } -} - -static void sculpt_automasking_end(Object *ob) -{ - SculptSession *ss = ob->sculpt; - if (ss->cache && ss->cache->automask) { - MEM_freeN(ss->cache->automask); - } -} - -static bool sculpt_automasking_is_constrained_by_radius(Brush *br) -{ - /* 2D falloff is not constrained by radius. */ - if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { - return false; - } - - if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)) { - return true; - } - return false; -} - -typedef struct AutomaskFloodFillData { - float *automask_factor; - float radius; - bool use_radius; - float location[3]; - char symm; -} AutomaskFloodFillData; - -static bool automask_floodfill_cb( - SculptSession *ss, int UNUSED(from_v), int to_v, bool UNUSED(is_duplicate), void *userdata) -{ - AutomaskFloodFillData *data = userdata; - - data->automask_factor[to_v] = 1.0f; - return (!data->use_radius || - sculpt_is_vertex_inside_brush_radius_symm( - SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, data->symm)); -} - -static float *sculpt_topology_automasking_init(Sculpt *sd, Object *ob, float *automask_factor) -{ - SculptSession *ss = ob->sculpt; - Brush *brush = BKE_paint_brush(&sd->paint); - - if (!sculpt_automasking_enabled(sd, ss, brush)) { - return NULL; - } - - if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { - BLI_assert(!"Topology masking: pmap missing"); - return NULL; - } - - const int totvert = SCULPT_vertex_count_get(ss); - for (int i = 0; i < totvert; i++) { - ss->cache->automask[i] = 0.0f; - } - - /* Flood fill automask to connected vertices. Limited to vertices inside - * the brush radius if the tool requires it. */ - SculptFloodFill flood; - SCULPT_floodfill_init(ss, &flood); - SCULPT_floodfill_add_active(sd, ob, ss, &flood, ss->cache->radius); - - AutomaskFloodFillData fdata = { - .automask_factor = automask_factor, - .radius = ss->cache->radius, - .use_radius = sculpt_automasking_is_constrained_by_radius(brush), - .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL, - }; - copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss)); - SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata); - SCULPT_floodfill_free(&flood); - - return automask_factor; -} - -static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *automask_factor) -{ - SculptSession *ss = ob->sculpt; - Brush *brush = BKE_paint_brush(&sd->paint); - - if (!sculpt_automasking_enabled(sd, ss, brush)) { - return NULL; - } - - if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { - BLI_assert(!"Face Sets automasking: pmap missing"); - return NULL; - } - - int tot_vert = SCULPT_vertex_count_get(ss); - int active_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss)); - for (int i = 0; i < tot_vert; i++) { - if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) { - automask_factor[i] *= 0.0f; - } - } - - return automask_factor; -} - -#define EDGE_DISTANCE_INF -1 - -typedef enum eBoundaryAutomaskMode { - AUTOMASK_INIT_BOUNDARY_EDGES = 1, - AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2, -} eBoundaryAutomaskMode; - -static float *sculpt_boundary_automasking_init(Object *ob, - eBoundaryAutomaskMode mode, - int propagation_steps, - float *automask_factor) -{ - SculptSession *ss = ob->sculpt; - - if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { - BLI_assert(!"Boundary Edges masking: pmap missing"); - return NULL; - } - - const int totvert = SCULPT_vertex_count_get(ss); - int *edge_distance = MEM_callocN(sizeof(int) * totvert, "automask_factor"); - - for (int i = 0; i < totvert; i++) { - edge_distance[i] = EDGE_DISTANCE_INF; - switch (mode) { - case AUTOMASK_INIT_BOUNDARY_EDGES: - if (!sculpt_vertex_is_boundary(ss, i)) { - edge_distance[i] = 0; - } - break; - case AUTOMASK_INIT_BOUNDARY_FACE_SETS: - if (!SCULPT_vertex_has_unique_face_set(ss, i)) { - edge_distance[i] = 0; - } - break; - } - } - - for (int propagation_it = 0; propagation_it < propagation_steps; propagation_it++) { - for (int i = 0; i < totvert; i++) { - if (edge_distance[i] == EDGE_DISTANCE_INF) { - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) { - if (edge_distance[ni.index] == propagation_it) { - edge_distance[i] = propagation_it + 1; - } - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - } - } - } - - for (int i = 0; i < totvert; i++) { - if (edge_distance[i] != EDGE_DISTANCE_INF) { - const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps); - const float edge_boundary_automask = pow2f(p); - automask_factor[i] *= (1.0f - edge_boundary_automask); - } - } - - MEM_SAFE_FREE(edge_distance); - return automask_factor; -} - -static void sculpt_automasking_init(Sculpt *sd, Object *ob) -{ - SculptSession *ss = ob->sculpt; - Brush *brush = BKE_paint_brush(&sd->paint); - const int totvert = SCULPT_vertex_count_get(ss); - - if (!sculpt_automasking_enabled(sd, ss, brush)) { - return; - } - - ss->cache->automask = MEM_callocN(sizeof(float) * SCULPT_vertex_count_get(ss), - "automask_factor"); - - for (int i = 0; i < totvert; i++) { - ss->cache->automask[i] = 1.0f; - } - - if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_TOPOLOGY)) { - SCULPT_vertex_random_access_init(ss); - sculpt_topology_automasking_init(sd, ob, ss->cache->automask); - } - if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_FACE_SETS)) { - SCULPT_vertex_random_access_init(ss); - sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask); - } - - if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { - SCULPT_vertex_random_access_init(ss); - sculpt_boundary_automasking_init(ob, - AUTOMASK_INIT_BOUNDARY_EDGES, - brush->automasking_boundary_edges_propagation_steps, - ss->cache->automask); - } - if (sculpt_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { - SCULPT_vertex_random_access_init(ss); - sculpt_boundary_automasking_init(ob, - AUTOMASK_INIT_BOUNDARY_FACE_SETS, - brush->automasking_boundary_edges_propagation_steps, - ss->cache->automask); - } -} - /* ===== Sculpting ===== */ static void flip_v3(float v[3], const ePaintSymmetryFlags symm) @@ -2146,7 +1898,7 @@ static void calc_area_center( { const Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; - const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush); + const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush); int n; /* Intentionally set 'sd' to NULL since we share logic with vertex paint. */ @@ -2205,7 +1957,7 @@ bool SCULPT_pbvh_calc_area_normal(const Brush *brush, float r_area_no[3]) { SculptSession *ss = ob->sculpt; - const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush); + const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush); /* Intentionally set 'sd' to NULL since this is used for vertex paint too. */ SculptThreadedTaskData data = { @@ -2245,7 +1997,7 @@ static void calc_area_normal_and_center( { const Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; - const bool has_bm_orco = ss->bm && sculpt_stroke_is_dynamic_topology(ss, brush); + const bool has_bm_orco = ss->bm && SCULPT_stroke_is_dynamic_topology(ss, brush); int n; /* Intentionally set 'sd' to NULL since this is used for vertex paint too. */ @@ -2607,7 +2359,7 @@ bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v) } /* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags. */ -static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]) +void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]) { for (int i = 0; i < 3; i++) { if (sd->flags & (SCULPT_LOCK_X << i)) { @@ -2812,225 +2564,6 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob) } } -/* For the smooth brush, uses the neighboring vertices around vert to calculate - * a smoothed location for vert. Skips corner vertices (used by only one - * polygon). */ -static void neighbor_average(SculptSession *ss, float avg[3], uint vert) -{ - const MeshElemMap *vert_map = &ss->pmap[vert]; - const MVert *mvert = ss->mvert; - float(*deform_co)[3] = ss->deform_cos; - - /* Don't modify corner vertices. */ - if (vert_map->count > 1) { - int total = 0; - - zero_v3(avg); - - for (int i = 0; i < vert_map->count; i++) { - const MPoly *p = &ss->mpoly[vert_map->indices[i]]; - uint f_adj_v[2]; - - if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { - for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { - if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) { - add_v3_v3(avg, deform_co ? deform_co[f_adj_v[j]] : mvert[f_adj_v[j]].co); - - total++; - } - } - } - } - - if (total > 0) { - mul_v3_fl(avg, 1.0f / total); - return; - } - } - - copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co); -} - -/* Similar to neighbor_average(), but returns an averaged mask value - * instead of coordinate. Also does not restrict based on border or - * corner vertices. */ -static float neighbor_average_mask(SculptSession *ss, uint vert) -{ - const float *vmask = ss->vmask; - float avg = 0.0f; - int total = 0; - - for (int i = 0; i < ss->pmap[vert].count; i++) { - const MPoly *p = &ss->mpoly[ss->pmap[vert].indices[i]]; - uint f_adj_v[2]; - - if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { - for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { - avg += vmask[f_adj_v[j]]; - total++; - } - } - } - - if (total > 0) { - return avg / (float)total; - } - else { - return vmask[vert]; - } -} - -/* Same logic as neighbor_average(), but for bmesh rather than mesh. */ -static void bmesh_neighbor_average(float avg[3], BMVert *v) -{ - /* logic for 3 or more is identical. */ - const int vfcount = BM_vert_face_count_at_most(v, 3); - - /* Don't modify corner vertices. */ - if (vfcount > 1) { - BMIter liter; - BMLoop *l; - int total = 0; - - zero_v3(avg); - - BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { - const BMVert *adj_v[2] = {l->prev->v, l->next->v}; - - for (int i = 0; i < ARRAY_SIZE(adj_v); i++) { - const BMVert *v_other = adj_v[i]; - if (vfcount != 2 || BM_vert_face_count_at_most(v_other, 2) <= 2) { - add_v3_v3(avg, v_other->co); - total++; - } - } - } - - if (total > 0) { - mul_v3_fl(avg, 1.0f / total); - return; - } - } - - copy_v3_v3(avg, v->co); -} - -/* For bmesh: Average surrounding verts based on an orthogonality measure. - * Naturally converges to a quad-like structure. */ -static void bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert *v) -{ - - float avg_co[3] = {0.0f, 0.0f, 0.0f}; - float tot_co = 0.0f; - - BMIter eiter; - BMEdge *e; - - BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { - if (BM_edge_is_boundary(e)) { - copy_v3_v3(avg, v->co); - return; - } - BMVert *v_other = (e->v1 == v) ? e->v2 : e->v1; - float vec[3]; - sub_v3_v3v3(vec, v_other->co, v->co); - madd_v3_v3fl(vec, v->no, -dot_v3v3(vec, v->no)); - normalize_v3(vec); - - /* fac is a measure of how orthogonal or parallel the edge is - * relative to the direction. */ - float fac = dot_v3v3(vec, direction); - fac = fac * fac - 0.5f; - fac *= fac; - madd_v3_v3fl(avg_co, v_other->co, fac); - tot_co += fac; - } - - /* In case vert has no Edge s. */ - if (tot_co > 0.0f) { - mul_v3_v3fl(avg, avg_co, 1.0f / tot_co); - - /* Preserve volume. */ - float vec[3]; - sub_v3_v3(avg, v->co); - mul_v3_v3fl(vec, v->no, dot_v3v3(avg, v->no)); - sub_v3_v3(avg, vec); - add_v3_v3(avg, v->co); - } - else { - zero_v3(avg); - } -} - -/* Same logic as neighbor_average_mask(), but for bmesh rather than mesh. */ -static float bmesh_neighbor_average_mask(BMVert *v, const int cd_vert_mask_offset) -{ - BMIter liter; - BMLoop *l; - float avg = 0.0f; - int total = 0; - - BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { - /* Skip this vertex. */ - const BMVert *adj_v[2] = {l->prev->v, l->next->v}; - - for (int i = 0; i < ARRAY_SIZE(adj_v); i++) { - const BMVert *v_other = adj_v[i]; - const float *vmask = BM_ELEM_CD_GET_VOID_P(v_other, cd_vert_mask_offset); - avg += (*vmask); - total++; - } - } - - if (total > 0) { - return avg / (float)total; - } - else { - const float *vmask = BM_ELEM_CD_GET_VOID_P(v, cd_vert_mask_offset); - return (*vmask); - } -} - -static void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index) -{ - float avg[3] = {0.0f, 0.0f, 0.0f}; - int total = 0; - - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) { - add_v3_v3(avg, SCULPT_vertex_co_get(ss, ni.index)); - total++; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - - if (total > 0) { - mul_v3_v3fl(result, avg, 1.0f / (float)total); - } - else { - copy_v3_v3(result, SCULPT_vertex_co_get(ss, index)); - } -} - -static float grids_neighbor_average_mask(SculptSession *ss, int index) -{ - float avg = 0.0f; - int total = 0; - - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) { - avg += SCULPT_vertex_mask_get(ss, ni.index); - total++; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - - if (total > 0) { - return avg / (float)total; - } - else { - return SCULPT_vertex_mask_get(ss, index); - } -} - /* Note: uses after-struct allocated mem to store actual cache... */ typedef struct SculptDoBrushSmoothGridDataChunk { size_t tmpgrid_size; @@ -3070,119 +2603,6 @@ typedef struct { bool original; } SculptFindNearestToRayData; -static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - Sculpt *sd = data->sd; - const Brush *brush = data->brush; - const bool smooth_mask = data->smooth_mask; - float bstrength = data->strength; - - PBVHVertexIter vd; - - CLAMP(bstrength, 0.0f, 1.0f); - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor( - ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), - vd.index, - tls->thread_id); - if (smooth_mask) { - float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; - val *= fade * bstrength; - *vd.mask += val; - CLAMP(*vd.mask, 0.0f, 1.0f); - } - else { - float avg[3], val[3]; - - neighbor_average(ss, avg, vd.vert_indices[vd.i]); - sub_v3_v3v3(val, avg, vd.co); - - madd_v3_v3v3fl(val, vd.co, val, fade); - - sculpt_clip(sd, ss, vd.co, val); - } - - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - } - BKE_pbvh_vertex_iter_end; -} - -static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - Sculpt *sd = data->sd; - const Brush *brush = data->brush; - const bool smooth_mask = data->smooth_mask; - float bstrength = data->strength; - - PBVHVertexIter vd; - - CLAMP(bstrength, 0.0f, 1.0f); - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - smooth_mask ? 0.0f : *vd.mask, - vd.index, - tls->thread_id); - if (smooth_mask) { - float val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask; - val *= fade * bstrength; - *vd.mask += val; - CLAMP(*vd.mask, 0.0f, 1.0f); - } - else { - float avg[3], val[3]; - - bmesh_neighbor_average(avg, vd.bm_vert); - sub_v3_v3v3(val, avg, vd.co); - - madd_v3_v3v3fl(val, vd.co, val, fade); - - sculpt_clip(sd, ss, vd.co, val); - } - - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - } - BKE_pbvh_vertex_iter_end; -} - static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls) @@ -3231,13 +2651,13 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, float avg[3], val[3]; - bmesh_four_neighbor_average(avg, direction, vd.bm_vert); + SCULPT_bmesh_four_neighbor_average(avg, direction, vd.bm_vert); sub_v3_v3v3(val, avg, vd.co); madd_v3_v3v3fl(val, vd.co, val, fade); - sculpt_clip(sd, ss, vd.co, val); + SCULPT_clip(sd, ss, vd.co, val); if (vd.mvert) { vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -3247,111 +2667,6 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, BKE_pbvh_vertex_iter_end; } -static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - Sculpt *sd = data->sd; - const Brush *brush = data->brush; - const bool smooth_mask = data->smooth_mask; - float bstrength = data->strength; - - PBVHVertexIter vd; - - CLAMP(bstrength, 0.0f, 1.0f); - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor( - ss, - brush, - vd.co, - sqrtf(test.dist), - vd.no, - vd.fno, - smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), - vd.index, - tls->thread_id); - if (smooth_mask) { - float val = grids_neighbor_average_mask(ss, vd.index) - *vd.mask; - val *= fade * bstrength; - *vd.mask += val; - CLAMP(*vd.mask, 0.0f, 1.0f); - } - else { - float avg[3], val[3]; - SCULPT_neighbor_coords_average(ss, avg, vd.index); - sub_v3_v3v3(val, avg, vd.co); - madd_v3_v3v3fl(val, vd.co, val, fade); - sculpt_clip(sd, ss, vd.co, val); - } - } - } - BKE_pbvh_vertex_iter_end; -} - -static void smooth(Sculpt *sd, - Object *ob, - PBVHNode **nodes, - const int totnode, - float bstrength, - const bool smooth_mask) -{ - SculptSession *ss = ob->sculpt; - Brush *brush = BKE_paint_brush(&sd->paint); - - const int max_iterations = 4; - const float fract = 1.0f / max_iterations; - PBVHType type = BKE_pbvh_type(ss->pbvh); - int iteration, count; - float last; - - CLAMP(bstrength, 0.0f, 1.0f); - - count = (int)(bstrength * max_iterations); - last = max_iterations * (bstrength - count * fract); - - if (type == PBVH_FACES && !ss->pmap) { - BLI_assert(!"sculpt smooth: pmap missing"); - return; - } - - for (iteration = 0; iteration <= count; iteration++) { - const float strength = (iteration != count) ? 1.0f : last; - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .brush = brush, - .nodes = nodes, - .smooth_mask = smooth_mask, - .strength = strength, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - - switch (type) { - case PBVH_GRIDS: - BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_multires_task_cb_ex, &settings); - break; - case PBVH_FACES: - BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_mesh_task_cb_ex, &settings); - break; - case PBVH_BMESH: - BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_bmesh_task_cb_ex, &settings); - break; - } - } -} - static void bmesh_topology_rake( Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, float bstrength) { @@ -3361,177 +2676,23 @@ static void bmesh_topology_rake( /* Interactions increase both strength and quality. */ const int iterations = 3; - int iteration; - const int count = iterations * bstrength + 1; - const float factor = iterations * bstrength / count; - - for (iteration = 0; iteration <= count; iteration++) { - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .brush = brush, - .nodes = nodes, - .strength = factor, - }; - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - - BKE_pbvh_parallel_range(0, totnode, &data, do_topology_rake_bmesh_task_cb_ex, &settings); - } -} - -static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) -{ - SculptSession *ss = ob->sculpt; - smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false); -} -/* HC Smooth Algorithm. */ -/* From: Improved Laplacian Smoothing of Noisy Surface Meshes */ - -static void surface_smooth_laplacian_step(SculptSession *ss, - float *disp, - const float co[3], - float (*laplacian_disp)[3], - const int v_index, - const float origco[3], - const float alpha) -{ - float laplacian_smooth_co[3]; - float weigthed_o[3], weigthed_q[3], d[3]; - SCULPT_neighbor_coords_average(ss, laplacian_smooth_co, v_index); - - mul_v3_v3fl(weigthed_o, origco, alpha); - mul_v3_v3fl(weigthed_q, co, 1.0f - alpha); - add_v3_v3v3(d, weigthed_o, weigthed_q); - sub_v3_v3v3(laplacian_disp[v_index], laplacian_smooth_co, d); - - sub_v3_v3v3(disp, laplacian_smooth_co, co); -} - -static void surface_smooth_displace_step(SculptSession *ss, - float *co, - float (*laplacian_disp)[3], - const int v_index, - const float beta, - const float fade) -{ - float b_avg[3] = {0.0f, 0.0f, 0.0f}; - float b_current_vertex[3]; - int total = 0; - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_index, ni) { - add_v3_v3(b_avg, laplacian_disp[ni.index]); - total++; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - if (total > 0) { - mul_v3_v3fl(b_current_vertex, b_avg, (1.0f - beta) / (float)total); - madd_v3_v3fl(b_current_vertex, laplacian_disp[v_index], beta); - mul_v3_fl(b_current_vertex, clamp_f(fade, 0.0f, 1.0f)); - sub_v3_v3(co, b_current_vertex); - } -} - -static void do_surface_smooth_brush_laplacian_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - const Brush *brush = data->brush; - const float bstrength = ss->cache->bstrength; - float alpha = brush->surface_smooth_shape_preservation; - - PBVHVertexIter vd; - SculptOrigVertData orig_data; - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - SCULPT_orig_vert_data_update(&orig_data, &vd); - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = - bstrength * - SCULPT_brush_strength_factor( - ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id); - - float disp[3]; - surface_smooth_laplacian_step(ss, - disp, - vd.co, - ss->cache->surface_smooth_laplacian_disp, - vd.index, - orig_data.co, - alpha); - madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); - } - BKE_pbvh_vertex_iter_end; - } -} - -static void do_surface_smooth_brush_displace_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - const Brush *brush = data->brush; - const float bstrength = ss->cache->bstrength; - const float beta = brush->surface_smooth_current_vertex; - - PBVHVertexIter vd; - - SculptBrushTest test; - SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( - ss, &test, data->brush->falloff_shape); - - BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) - { - if (sculpt_brush_test_sq_fn(&test, vd.co)) { - const float fade = - bstrength * - SCULPT_brush_strength_factor( - ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id); - surface_smooth_displace_step( - ss, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.index, beta, fade); - } - } - BKE_pbvh_vertex_iter_end; -} - -static void do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) -{ - Brush *brush = BKE_paint_brush(&sd->paint); - SculptSession *ss = ob->sculpt; + int iteration; + const int count = iterations * bstrength + 1; + const float factor = iterations * bstrength / count; - if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && - ss->cache->radial_symmetry_pass == 0) { - BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL); - ss->cache->surface_smooth_laplacian_disp = MEM_callocN( - SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b"); - } + for (iteration = 0; iteration <= count; iteration++) { - /* Threaded loop over nodes. */ - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .brush = brush, - .nodes = nodes, - }; + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .brush = brush, + .nodes = nodes, + .strength = factor, + }; + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - for (int i = 0; i < brush->surface_smooth_iterations; i++) { - BKE_pbvh_parallel_range( - 0, totnode, &data, do_surface_smooth_brush_laplacian_task_cb_ex, &settings); - BKE_pbvh_parallel_range( - 0, totnode, &data, do_surface_smooth_brush_displace_task_cb_ex, &settings); + BKE_pbvh_parallel_range(0, totnode, &data, do_topology_rake_bmesh_task_cb_ex, &settings); } } @@ -3599,7 +2760,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) do_mask_brush_draw(sd, ob, nodes, totnode); break; case BRUSH_MASK_SMOOTH: - smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true); + SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, true); break; } } @@ -4977,7 +4138,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata, add_v3_v3(val, orig_data.co); } - sculpt_clip(sd, ss, vd.co, val); + SCULPT_clip(sd, ss, vd.co, val); if (vd.mvert) { vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -6150,8 +5311,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe } if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0) { - if (sculpt_automasking_enabled(sd, ss, brush)) { - sculpt_automasking_init(sd, ob); + if (SCULPT_is_automasking_enabled(sd, ss, brush)) { + SCULPT_automasking_init(sd, ob); } } @@ -6169,10 +5330,10 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe break; case SCULPT_TOOL_SMOOTH: if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_LAPLACIAN) { - do_smooth_brush(sd, ob, nodes, totnode); + SCULPT_do_smooth_brush(sd, ob, nodes, totnode); } else if (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_SURFACE) { - do_surface_smooth_brush(sd, ob, nodes, totnode); + SCULPT_do_surface_smooth_brush(sd, ob, nodes, totnode); } break; case SCULPT_TOOL_CREASE: @@ -6262,15 +5423,15 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) && brush->autosmooth_factor > 0) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { - smooth(sd, - ob, - nodes, - totnode, - brush->autosmooth_factor * (1.0f - ss->cache->pressure), - false); + SCULPT_smooth(sd, + ob, + nodes, + totnode, + brush->autosmooth_factor * (1.0f - ss->cache->pressure), + false); } else { - smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false); + SCULPT_smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false); } } @@ -6364,7 +5525,7 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata, add_v3_v3(val, proxies[p].co[vd.i]); } - sculpt_clip(sd, ss, vd.co, val); + SCULPT_clip(sd, ss, vd.co, val); if (ss->deform_modifiers_active) { sculpt_flush_pbvhvert_deform(ob, &vd); @@ -7322,7 +6483,7 @@ static bool sculpt_needs_connectivity_info(const Sculpt *sd, SculptSession *ss, int stroke_mode) { - if (ss && ss->pbvh && sculpt_automasking_enabled(sd, ss, brush)) { + if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) { return true; } return ((stroke_mode == BRUSH_STROKE_SMOOTH) || (ss && ss->cache && ss->cache->alt_smooth) || @@ -7931,7 +7092,7 @@ static void sculpt_stroke_update_step(bContext *C, (float)(sd->detail_size * U.pixelsize) / 0.4f); } - if (sculpt_stroke_is_dynamic_topology(ss, brush)) { + if (SCULPT_stroke_is_dynamic_topology(ss, brush)) { do_symmetrical_brush_actions(sd, ob, sculpt_topology_update, ups); } @@ -8014,8 +7175,8 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str } } - if (sculpt_automasking_enabled(sd, ss, brush)) { - sculpt_automasking_end(ob); + if (SCULPT_is_automasking_enabled(sd, ss, brush)) { + SCULPT_automasking_end(ob); } SCULPT_cache_free(ss->cache); @@ -8104,7 +7265,7 @@ static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) /* XXX Canceling strokes that way does not work with dynamic topology, * user will have to do real undo for now. See T46456. */ - if (ss->cache && !sculpt_stroke_is_dynamic_topology(ss, brush)) { + if (ss->cache && !SCULPT_stroke_is_dynamic_topology(ss, brush)) { paint_mesh_restore_co(sd, ob); } @@ -9301,527 +8462,6 @@ static void SCULPT_OT_set_detail_size(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static void filter_cache_init_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - PBVHNode *node = data->nodes[i]; - - SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); -} - -void SCULPT_filter_cache_init(Object *ob, Sculpt *sd) -{ - SculptSession *ss = ob->sculpt; - PBVH *pbvh = ob->sculpt->pbvh; - - ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); - - ss->filter_cache->random_seed = rand(); - - float center[3] = {0.0f}; - SculptSearchSphereData search_data = { - .original = true, - .center = center, - .radius_squared = FLT_MAX, - .ignore_fully_masked = true, - - }; - BKE_pbvh_search_gather(pbvh, - SCULPT_search_sphere_cb, - &search_data, - &ss->filter_cache->nodes, - &ss->filter_cache->totnode); - - for (int i = 0; i < ss->filter_cache->totnode; i++) { - BKE_pbvh_node_mark_normals_update(ss->filter_cache->nodes[i]); - } - - /* mesh->runtime.subdiv_ccg is not available. Updating of the normals is done during drawing. - * Filters can't use normals in multires. */ - if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) { - BKE_pbvh_update_normals(ss->pbvh, NULL); - } - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range( - 0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings); -} - -void SCULPT_filter_cache_free(SculptSession *ss) -{ - if (ss->filter_cache->nodes) { - MEM_freeN(ss->filter_cache->nodes); - } - if (ss->filter_cache->mask_update_it) { - MEM_freeN(ss->filter_cache->mask_update_it); - } - if (ss->filter_cache->prev_mask) { - MEM_freeN(ss->filter_cache->prev_mask); - } - if (ss->filter_cache->normal_factor) { - MEM_freeN(ss->filter_cache->normal_factor); - } - if (ss->filter_cache->prev_face_set) { - MEM_freeN(ss->filter_cache->prev_face_set); - } - if (ss->filter_cache->automask) { - MEM_freeN(ss->filter_cache->automask); - } - if (ss->filter_cache->surface_smooth_laplacian_disp) { - MEM_freeN(ss->filter_cache->surface_smooth_laplacian_disp); - } - MEM_freeN(ss->filter_cache); - ss->filter_cache = NULL; -} - -typedef enum eSculptMeshFilterTypes { - MESH_FILTER_SMOOTH = 0, - MESH_FILTER_SCALE = 1, - MESH_FILTER_INFLATE = 2, - MESH_FILTER_SPHERE = 3, - MESH_FILTER_RANDOM = 4, - MESH_FILTER_RELAX = 5, - MESH_FILTER_RELAX_FACE_SETS = 6, - MESH_FILTER_SURFACE_SMOOTH = 7, -} eSculptMeshFilterTypes; - -static EnumPropertyItem prop_mesh_filter_types[] = { - {MESH_FILTER_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth mesh"}, - {MESH_FILTER_SCALE, "SCALE", 0, "Scale", "Scale mesh"}, - {MESH_FILTER_INFLATE, "INFLATE", 0, "Inflate", "Inflate mesh"}, - {MESH_FILTER_SPHERE, "SPHERE", 0, "Sphere", "Morph into sphere"}, - {MESH_FILTER_RANDOM, "RANDOM", 0, "Random", "Randomize vertex positions"}, - {MESH_FILTER_RELAX, "RELAX", 0, "Relax", "Relax mesh"}, - {MESH_FILTER_RELAX_FACE_SETS, - "RELAX_FACE_SETS", - 0, - "Relax Face Sets", - "Smooth the edges of all the Face Sets"}, - {MESH_FILTER_SURFACE_SMOOTH, - "SURFACE_SMOOTH", - 0, - "Surface Smooth", - "Smooth the surface of the mesh, preserving the volume"}, - {0, NULL, 0, NULL, NULL}, -}; - -typedef enum eMeshFilterDeformAxis { - MESH_FILTER_DEFORM_X = 1 << 0, - MESH_FILTER_DEFORM_Y = 1 << 1, - MESH_FILTER_DEFORM_Z = 1 << 2, -} eMeshFilterDeformAxis; - -static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = { - {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"}, - {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"}, - {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"}, - {0, NULL, 0, NULL, NULL}, -}; - -static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets) -{ - return use_face_sets || ELEM(filter_type, - MESH_FILTER_SMOOTH, - MESH_FILTER_RELAX, - MESH_FILTER_RELAX_FACE_SETS, - MESH_FILTER_SURFACE_SMOOTH); -} - -static void mesh_filter_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - - const int filter_type = data->filter_type; - - SculptOrigVertData orig_data; - SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]); - - /* When using the relax face sets mehs filter, each 3 iterations, do a whole mesh relax to smooth - * the contents of the Face Set. */ - /* This produces better results as the relax operation is no completely focused on the - * boundaries. */ - const bool relax_face_sets = !(ss->filter_cache->iteration_count % 3 == 0); - - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - SCULPT_orig_vert_data_update(&orig_data, &vd); - float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3], final_pos[3]; - float fade = vd.mask ? *vd.mask : 0.0f; - fade = 1.0f - fade; - fade *= data->filter_strength; - - if (fade == 0.0f) { - continue; - } - - if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) { - if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) { - continue; - } - /* Skip the edges of the face set when relaxing or smoothing. There is a relax face set - * option to relax the boindaries independently. */ - if (filter_type == MESH_FILTER_RELAX) { - if (!SCULPT_vertex_has_unique_face_set(ss, vd.index)) { - continue; - } - } - } - - if (ELEM(filter_type, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) { - copy_v3_v3(orig_co, vd.co); - } - else { - copy_v3_v3(orig_co, orig_data.co); - } - - if (filter_type == MESH_FILTER_RELAX_FACE_SETS) { - if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) { - continue; - } - } - - switch (filter_type) { - case MESH_FILTER_SMOOTH: - CLAMP(fade, -1.0f, 1.0f); - switch (BKE_pbvh_type(ss->pbvh)) { - case PBVH_FACES: - neighbor_average(ss, avg, vd.index); - break; - case PBVH_BMESH: - bmesh_neighbor_average(avg, vd.bm_vert); - break; - case PBVH_GRIDS: - SCULPT_neighbor_coords_average(ss, avg, vd.index); - break; - } - sub_v3_v3v3(val, avg, orig_co); - madd_v3_v3v3fl(val, orig_co, val, fade); - sub_v3_v3v3(disp, val, orig_co); - break; - case MESH_FILTER_INFLATE: - normal_short_to_float_v3(normal, orig_data.no); - mul_v3_v3fl(disp, normal, fade); - break; - case MESH_FILTER_SCALE: - unit_m3(transform); - scale_m3_fl(transform, 1.0f + fade); - copy_v3_v3(val, orig_co); - mul_m3_v3(transform, val); - sub_v3_v3v3(disp, val, orig_co); - break; - case MESH_FILTER_SPHERE: - normalize_v3_v3(disp, orig_co); - if (fade > 0.0f) { - mul_v3_v3fl(disp, disp, fade); - } - else { - mul_v3_v3fl(disp, disp, -fade); - } - - unit_m3(transform); - if (fade > 0.0f) { - scale_m3_fl(transform, 1.0f - fade); - } - else { - scale_m3_fl(transform, 1.0f + fade); - } - copy_v3_v3(val, orig_co); - mul_m3_v3(transform, val); - sub_v3_v3v3(disp2, val, orig_co); - - mid_v3_v3v3(disp, disp, disp2); - break; - case MESH_FILTER_RANDOM: { - normal_short_to_float_v3(normal, orig_data.no); - /* Index is not unique for multires, so hash by vertex coordinates. */ - const uint *hash_co = (const uint *)orig_co; - const uint hash = BLI_hash_int_2d(hash_co[0], hash_co[1]) ^ - BLI_hash_int_2d(hash_co[2], ss->filter_cache->random_seed); - mul_v3_fl(normal, hash * (1.0f / (float)0xFFFFFFFF) - 0.5f); - mul_v3_v3fl(disp, normal, fade); - break; - } - case MESH_FILTER_RELAX: { - SCULPT_relax_vertex( - ss, &vd, clamp_f(fade * ss->filter_cache->automask[vd.index], 0.0f, 1.0f), false, val); - sub_v3_v3v3(disp, val, vd.co); - break; - } - case MESH_FILTER_RELAX_FACE_SETS: { - SCULPT_relax_vertex(ss, &vd, clamp_f(fade, 0.0f, 1.0f), relax_face_sets, val); - sub_v3_v3v3(disp, val, vd.co); - break; - } - case MESH_FILTER_SURFACE_SMOOTH: { - surface_smooth_laplacian_step(ss, - disp, - vd.co, - ss->filter_cache->surface_smooth_laplacian_disp, - vd.index, - orig_data.co, - ss->filter_cache->surface_smooth_shape_preservation); - break; - } - } - - for (int it = 0; it < 3; it++) { - if (!ss->filter_cache->enabled_axis[it]) { - disp[it] = 0.0f; - } - } - - if (filter_type == MESH_FILTER_SURFACE_SMOOTH) { - madd_v3_v3v3fl(final_pos, vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); - } - else { - add_v3_v3v3(final_pos, orig_co, disp); - } - copy_v3_v3(vd.co, final_pos); - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(node); -} - -static void mesh_filter_surface_smooth_displace_task_cb( - void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - PBVHVertexIter vd; - - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - float fade = vd.mask ? *vd.mask : 0.0f; - fade = 1.0f - fade; - fade *= data->filter_strength; - if (fade == 0.0f) { - continue; - } - surface_smooth_displace_step(ss, - vd.co, - ss->filter_cache->surface_smooth_laplacian_disp, - vd.index, - ss->filter_cache->surface_smooth_current_vertex, - clamp_f(fade, 0.0f, 1.0f)); - } - BKE_pbvh_vertex_iter_end; -} - -static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - SculptSession *ss = ob->sculpt; - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int filter_type = RNA_enum_get(op->ptr, "type"); - float filter_strength = RNA_float_get(op->ptr, "strength"); - const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); - - if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { - SCULPT_filter_cache_free(ss); - SCULPT_undo_push_end(); - SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); - return OPERATOR_FINISHED; - } - - if (event->type != MOUSEMOVE) { - return OPERATOR_RUNNING_MODAL; - } - - float len = event->prevclickx - event->mval[0]; - filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC; - - SCULPT_vertex_random_access_init(ss); - - bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); - BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - .filter_type = filter_type, - .filter_strength = filter_strength, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings); - - if (filter_type == MESH_FILTER_SURFACE_SMOOTH) { - BKE_pbvh_parallel_range(0, - ss->filter_cache->totnode, - &data, - mesh_filter_surface_smooth_displace_task_cb, - &settings); - } - - ss->filter_cache->iteration_count++; - - if (ss->deform_modifiers_active || ss->shapekey_active) { - SCULPT_flush_stroke_deform(sd, ob, true); - } - - /* The relax mesh filter needs the updated normals of the modified mesh after each iteration. */ - if (ELEM(MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) { - BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg); - } - - SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); - - return OPERATOR_RUNNING_MODAL; -} - -static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int filter_type = RNA_enum_get(op->ptr, "type"); - SculptSession *ss = ob->sculpt; - PBVH *pbvh = ob->sculpt->pbvh; - - int deform_axis = RNA_enum_get(op->ptr, "deform_axis"); - if (deform_axis == 0) { - return OPERATOR_CANCELLED; - } - - if (RNA_boolean_get(op->ptr, "use_face_sets")) { - /* Update the active vertex */ - float mouse[2]; - SculptCursorGeometryInfo sgi; - mouse[0] = event->mval[0]; - mouse[1] = event->mval[1]; - SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); - } - - const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); - - SCULPT_vertex_random_access_init(ss); - - bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); - BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); - - if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { - return OPERATOR_CANCELLED; - } - - SCULPT_undo_push_begin("Mesh filter"); - - SCULPT_filter_cache_init(ob, sd); - - if (use_face_sets) { - ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss, - SCULPT_active_vertex_get(ss)); - } - else { - ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE; - } - - if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) { - ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN( - 3 * sizeof(float) * SCULPT_vertex_count_get(ss), "surface smooth disp"); - ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get( - op->ptr, "surface_smooth_shape_preservation"); - ss->filter_cache->surface_smooth_current_vertex = RNA_float_get( - op->ptr, "surface_smooth_current_vertex"); - } - - ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X; - ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y; - ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z; - - if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_RELAX) { - const int totvert = SCULPT_vertex_count_get(ss); - ss->filter_cache->automask = MEM_mallocN(totvert * sizeof(float), - "Relax filter edge automask"); - for (int i = 0; i < totvert; i++) { - ss->filter_cache->automask[i] = 1.0f; - } - sculpt_boundary_automasking_init( - ob, AUTOMASK_INIT_BOUNDARY_EDGES, 1, ss->filter_cache->automask); - } - - WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; -} - -static void SCULPT_OT_mesh_filter(struct wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Filter mesh"; - ot->idname = "SCULPT_OT_mesh_filter"; - ot->description = "Applies a filter to modify the current mesh"; - - /* API callbacks. */ - ot->invoke = sculpt_mesh_filter_invoke; - ot->modal = sculpt_mesh_filter_modal; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* RNA. */ - RNA_def_enum(ot->srna, - "type", - prop_mesh_filter_types, - MESH_FILTER_INFLATE, - "Filter type", - "Operation that is going to be applied to the mesh"); - RNA_def_float( - ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f); - RNA_def_enum_flag(ot->srna, - "deform_axis", - prop_mesh_filter_deform_axis_items, - MESH_FILTER_DEFORM_X | MESH_FILTER_DEFORM_Y | MESH_FILTER_DEFORM_Z, - "Deform axis", - "Apply the deformation in the selected axis"); - ot->prop = RNA_def_boolean(ot->srna, - "use_face_sets", - false, - "Use Face Sets", - "Apply the filter only to the Face Mask under the cursor"); - - /* Surface Smooth Mesh Filter properties. */ - RNA_def_float(ot->srna, - "surface_smooth_shape_preservation", - 0.5f, - 0.0f, - 1.0f, - "Shape Preservation", - "How much of the original shape is preserved when smoothing", - 0.0f, - 1.0f); - RNA_def_float(ot->srna, - "surface_smooth_current_vertex", - 0.5f, - 0.0f, - 1.0f, - "Per Vertex Displacement", - "How much the position of each individual vertex influences the final result", - 0.0f, - 1.0f); -} typedef enum eSculptMaskFilterTypes { MASK_FILTER_SMOOTH = 0, @@ -9880,19 +8520,7 @@ static void mask_filter_task_cb(void *__restrict userdata, switch (mode) { case MASK_FILTER_SMOOTH: case MASK_FILTER_SHARPEN: { - float val = 0.0f; - - switch (BKE_pbvh_type(ss->pbvh)) { - case PBVH_FACES: - val = neighbor_average_mask(ss, vd.index); - break; - case PBVH_BMESH: - val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset); - break; - case PBVH_GRIDS: - val = grids_neighbor_average_mask(ss, vd.index); - break; - } + float val = SCULPT_neighbor_mask_average(ss, vd.index); val -= *vd.mask; diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.c new file mode 100644 index 00000000000..768b25a9a22 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c @@ -0,0 +1,304 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "DNA_brush_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "bmesh.h" + +#include +#include + +bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, + const Brush *br, + const eAutomasking_flag mode) +{ + return br->automasking_flags & mode || sd->automasking_flags & mode; +} + +bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br) +{ + if (SCULPT_stroke_is_dynamic_topology(ss, br)) { + return false; + } + if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) { + return true; + } + if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_FACE_SETS)) { + return true; + } + if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { + return true; + } + if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { + return true; + } + return false; +} + +float SCULPT_automasking_factor_get(SculptSession *ss, int vert) +{ + if (ss->cache->automask) { + return ss->cache->automask[vert]; + } + else { + return 1.0f; + } +} + +void SCULPT_automasking_end(Object *ob) +{ + SculptSession *ss = ob->sculpt; + if (ss->cache && ss->cache->automask) { + MEM_freeN(ss->cache->automask); + } +} + +static bool sculpt_automasking_is_constrained_by_radius(Brush *br) +{ + /* 2D falloff is not constrained by radius. */ + if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { + return false; + } + + if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)) { + return true; + } + return false; +} + +typedef struct AutomaskFloodFillData { + float *automask_factor; + float radius; + bool use_radius; + float location[3]; + char symm; +} AutomaskFloodFillData; + +static bool automask_floodfill_cb( + SculptSession *ss, int UNUSED(from_v), int to_v, bool UNUSED(is_duplicate), void *userdata) +{ + AutomaskFloodFillData *data = userdata; + + data->automask_factor[to_v] = 1.0f; + return (!data->use_radius || + SCULPT_is_vertex_inside_brush_radius_symm( + SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, data->symm)); +} + +static float *SCULPT_topology_automasking_init(Sculpt *sd, Object *ob, float *automask_factor) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + + if (!SCULPT_is_automasking_enabled(sd, ss, brush)) { + return NULL; + } + + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { + BLI_assert(!"Topology masking: pmap missing"); + return NULL; + } + + const int totvert = SCULPT_vertex_count_get(ss); + for (int i = 0; i < totvert; i++) { + ss->cache->automask[i] = 0.0f; + } + + /* Flood fill automask to connected vertices. Limited to vertices inside + * the brush radius if the tool requires it. */ + SculptFloodFill flood; + SCULPT_floodfill_init(ss, &flood); + SCULPT_floodfill_add_active(sd, ob, ss, &flood, ss->cache->radius); + + AutomaskFloodFillData fdata = { + .automask_factor = automask_factor, + .radius = ss->cache->radius, + .use_radius = sculpt_automasking_is_constrained_by_radius(brush), + .symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL, + }; + copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss)); + SCULPT_floodfill_execute(ss, &flood, automask_floodfill_cb, &fdata); + SCULPT_floodfill_free(&flood); + + return automask_factor; +} + +static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *automask_factor) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + + if (!SCULPT_is_automasking_enabled(sd, ss, brush)) { + return NULL; + } + + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { + BLI_assert(!"Face Sets automasking: pmap missing"); + return NULL; + } + + int tot_vert = SCULPT_vertex_count_get(ss); + int active_face_set = SCULPT_vertex_face_set_get(ss, SCULPT_active_vertex_get(ss)); + for (int i = 0; i < tot_vert; i++) { + if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) { + automask_factor[i] *= 0.0f; + } + } + + return automask_factor; +} + +#define EDGE_DISTANCE_INF -1 + +float *SCULPT_boundary_automasking_init(Object *ob, + eBoundaryAutomaskMode mode, + int propagation_steps, + float *automask_factor) +{ + SculptSession *ss = ob->sculpt; + + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) { + BLI_assert(!"Boundary Edges masking: pmap missing"); + return NULL; + } + + const int totvert = SCULPT_vertex_count_get(ss); + int *edge_distance = MEM_callocN(sizeof(int) * totvert, "automask_factor"); + + for (int i = 0; i < totvert; i++) { + edge_distance[i] = EDGE_DISTANCE_INF; + switch (mode) { + case AUTOMASK_INIT_BOUNDARY_EDGES: + if (!SCULPT_vertex_is_boundary(ss, i)) { + edge_distance[i] = 0; + } + break; + case AUTOMASK_INIT_BOUNDARY_FACE_SETS: + if (!SCULPT_vertex_has_unique_face_set(ss, i)) { + edge_distance[i] = 0; + } + break; + } + } + + for (int propagation_it = 0; propagation_it < propagation_steps; propagation_it++) { + for (int i = 0; i < totvert; i++) { + if (edge_distance[i] == EDGE_DISTANCE_INF) { + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) { + if (edge_distance[ni.index] == propagation_it) { + edge_distance[i] = propagation_it + 1; + } + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + } + } + } + + for (int i = 0; i < totvert; i++) { + if (edge_distance[i] != EDGE_DISTANCE_INF) { + const float p = 1.0f - ((float)edge_distance[i] / (float)propagation_steps); + const float edge_boundary_automask = pow2f(p); + automask_factor[i] *= (1.0f - edge_boundary_automask); + } + } + + MEM_SAFE_FREE(edge_distance); + return automask_factor; +} + +void SCULPT_automasking_init(Sculpt *sd, Object *ob) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + const int totvert = SCULPT_vertex_count_get(ss); + + if (!SCULPT_is_automasking_enabled(sd, ss, brush)) { + return; + } + + ss->cache->automask = MEM_callocN(sizeof(float) * SCULPT_vertex_count_get(ss), + "automask_factor"); + + for (int i = 0; i < totvert; i++) { + ss->cache->automask[i] = 1.0f; + } + + if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_TOPOLOGY)) { + SCULPT_vertex_random_access_init(ss); + SCULPT_topology_automasking_init(sd, ob, ss->cache->automask); + } + if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_FACE_SETS)) { + SCULPT_vertex_random_access_init(ss); + sculpt_face_sets_automasking_init(sd, ob, ss->cache->automask); + } + + if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_EDGES)) { + SCULPT_vertex_random_access_init(ss); + SCULPT_boundary_automasking_init(ob, + AUTOMASK_INIT_BOUNDARY_EDGES, + brush->automasking_boundary_edges_propagation_steps, + ss->cache->automask); + } + if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) { + SCULPT_vertex_random_access_init(ss); + SCULPT_boundary_automasking_init(ob, + AUTOMASK_INIT_BOUNDARY_FACE_SETS, + brush->automasking_boundary_edges_propagation_steps, + ss->cache->automask); + } +} diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c new file mode 100644 index 00000000000..b1dd7b87507 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -0,0 +1,571 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" + +#include "bmesh.h" + +#include +#include + +static void filter_cache_init_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + PBVHNode *node = data->nodes[i]; + + SCULPT_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); +} + +void SCULPT_filter_cache_init(Object *ob, Sculpt *sd) +{ + SculptSession *ss = ob->sculpt; + PBVH *pbvh = ob->sculpt->pbvh; + + ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); + + ss->filter_cache->random_seed = rand(); + + float center[3] = {0.0f}; + SculptSearchSphereData search_data = { + .original = true, + .center = center, + .radius_squared = FLT_MAX, + .ignore_fully_masked = true, + + }; + BKE_pbvh_search_gather(pbvh, + SCULPT_search_sphere_cb, + &search_data, + &ss->filter_cache->nodes, + &ss->filter_cache->totnode); + + for (int i = 0; i < ss->filter_cache->totnode; i++) { + BKE_pbvh_node_mark_normals_update(ss->filter_cache->nodes[i]); + } + + /* mesh->runtime.subdiv_ccg is not available. Updating of the normals is done during drawing. + * Filters can't use normals in multires. */ + if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) { + BKE_pbvh_update_normals(ss->pbvh, NULL); + } + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = ss->filter_cache->nodes, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); + BKE_pbvh_parallel_range( + 0, ss->filter_cache->totnode, &data, filter_cache_init_task_cb, &settings); +} + +void SCULPT_filter_cache_free(SculptSession *ss) +{ + MEM_SAFE_FREE(ss->filter_cache->nodes); + MEM_SAFE_FREE(ss->filter_cache->mask_update_it); + MEM_SAFE_FREE(ss->filter_cache->prev_mask); + MEM_SAFE_FREE(ss->filter_cache->normal_factor); + MEM_SAFE_FREE(ss->filter_cache->prev_face_set); + MEM_SAFE_FREE(ss->filter_cache->automask); + MEM_SAFE_FREE(ss->filter_cache->surface_smooth_laplacian_disp); + MEM_SAFE_FREE(ss->filter_cache); +} + +typedef enum eSculptMeshFilterTypes { + MESH_FILTER_SMOOTH = 0, + MESH_FILTER_SCALE = 1, + MESH_FILTER_INFLATE = 2, + MESH_FILTER_SPHERE = 3, + MESH_FILTER_RANDOM = 4, + MESH_FILTER_RELAX = 5, + MESH_FILTER_RELAX_FACE_SETS = 6, + MESH_FILTER_SURFACE_SMOOTH = 7, +} eSculptMeshFilterTypes; + +static EnumPropertyItem prop_mesh_filter_types[] = { + {MESH_FILTER_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth mesh"}, + {MESH_FILTER_SCALE, "SCALE", 0, "Scale", "Scale mesh"}, + {MESH_FILTER_INFLATE, "INFLATE", 0, "Inflate", "Inflate mesh"}, + {MESH_FILTER_SPHERE, "SPHERE", 0, "Sphere", "Morph into sphere"}, + {MESH_FILTER_RANDOM, "RANDOM", 0, "Random", "Randomize vertex positions"}, + {MESH_FILTER_RELAX, "RELAX", 0, "Relax", "Relax mesh"}, + {MESH_FILTER_RELAX_FACE_SETS, + "RELAX_FACE_SETS", + 0, + "Relax Face Sets", + "Smooth the edges of all the Face Sets"}, + {MESH_FILTER_SURFACE_SMOOTH, + "SURFACE_SMOOTH", + 0, + "Surface Smooth", + "Smooth the surface of the mesh, preserving the volume"}, + {0, NULL, 0, NULL, NULL}, +}; + +typedef enum eMeshFilterDeformAxis { + MESH_FILTER_DEFORM_X = 1 << 0, + MESH_FILTER_DEFORM_Y = 1 << 1, + MESH_FILTER_DEFORM_Z = 1 << 2, +} eMeshFilterDeformAxis; + +static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = { + {MESH_FILTER_DEFORM_X, "X", 0, "X", "Deform in the X axis"}, + {MESH_FILTER_DEFORM_Y, "Y", 0, "Y", "Deform in the Y axis"}, + {MESH_FILTER_DEFORM_Z, "Z", 0, "Z", "Deform in the Z axis"}, + {0, NULL, 0, NULL, NULL}, +}; + +static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets) +{ + return use_face_sets || ELEM(filter_type, + MESH_FILTER_SMOOTH, + MESH_FILTER_RELAX, + MESH_FILTER_RELAX_FACE_SETS, + MESH_FILTER_SURFACE_SMOOTH); +} + +static void mesh_filter_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + + const int filter_type = data->filter_type; + + SculptOrigVertData orig_data; + SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]); + + /* When using the relax face sets mehs filter, each 3 iterations, do a whole mesh relax to smooth + * the contents of the Face Set. */ + /* This produces better results as the relax operation is no completely focused on the + * boundaries. */ + const bool relax_face_sets = !(ss->filter_cache->iteration_count % 3 == 0); + + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + SCULPT_orig_vert_data_update(&orig_data, &vd); + float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3], final_pos[3]; + float fade = vd.mask ? *vd.mask : 0.0f; + fade = 1.0f - fade; + fade *= data->filter_strength; + + if (fade == 0.0f) { + continue; + } + + if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) { + if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) { + continue; + } + /* Skip the edges of the face set when relaxing or smoothing. There is a relax face set + * option to relax the boindaries independently. */ + if (filter_type == MESH_FILTER_RELAX) { + if (!SCULPT_vertex_has_unique_face_set(ss, vd.index)) { + continue; + } + } + } + + if (ELEM(filter_type, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) { + copy_v3_v3(orig_co, vd.co); + } + else { + copy_v3_v3(orig_co, orig_data.co); + } + + if (filter_type == MESH_FILTER_RELAX_FACE_SETS) { + if (relax_face_sets == SCULPT_vertex_has_unique_face_set(ss, vd.index)) { + continue; + } + } + + switch (filter_type) { + case MESH_FILTER_SMOOTH: + CLAMP(fade, -1.0f, 1.0f); + switch (BKE_pbvh_type(ss->pbvh)) { + case PBVH_FACES: + SCULPT_neighbor_average(ss, avg, vd.index); + break; + case PBVH_BMESH: + SCULPT_bmesh_neighbor_average(avg, vd.bm_vert); + break; + case PBVH_GRIDS: + SCULPT_neighbor_coords_average(ss, avg, vd.index); + break; + } + sub_v3_v3v3(val, avg, orig_co); + madd_v3_v3v3fl(val, orig_co, val, fade); + sub_v3_v3v3(disp, val, orig_co); + break; + case MESH_FILTER_INFLATE: + normal_short_to_float_v3(normal, orig_data.no); + mul_v3_v3fl(disp, normal, fade); + break; + case MESH_FILTER_SCALE: + unit_m3(transform); + scale_m3_fl(transform, 1.0f + fade); + copy_v3_v3(val, orig_co); + mul_m3_v3(transform, val); + sub_v3_v3v3(disp, val, orig_co); + break; + case MESH_FILTER_SPHERE: + normalize_v3_v3(disp, orig_co); + if (fade > 0.0f) { + mul_v3_v3fl(disp, disp, fade); + } + else { + mul_v3_v3fl(disp, disp, -fade); + } + + unit_m3(transform); + if (fade > 0.0f) { + scale_m3_fl(transform, 1.0f - fade); + } + else { + scale_m3_fl(transform, 1.0f + fade); + } + copy_v3_v3(val, orig_co); + mul_m3_v3(transform, val); + sub_v3_v3v3(disp2, val, orig_co); + + mid_v3_v3v3(disp, disp, disp2); + break; + case MESH_FILTER_RANDOM: { + normal_short_to_float_v3(normal, orig_data.no); + /* Index is not unique for multires, so hash by vertex coordinates. */ + const uint *hash_co = (const uint *)orig_co; + const uint hash = BLI_hash_int_2d(hash_co[0], hash_co[1]) ^ + BLI_hash_int_2d(hash_co[2], ss->filter_cache->random_seed); + mul_v3_fl(normal, hash * (1.0f / (float)0xFFFFFFFF) - 0.5f); + mul_v3_v3fl(disp, normal, fade); + break; + } + case MESH_FILTER_RELAX: { + SCULPT_relax_vertex( + ss, &vd, clamp_f(fade * ss->filter_cache->automask[vd.index], 0.0f, 1.0f), false, val); + sub_v3_v3v3(disp, val, vd.co); + break; + } + case MESH_FILTER_RELAX_FACE_SETS: { + SCULPT_relax_vertex(ss, &vd, clamp_f(fade, 0.0f, 1.0f), relax_face_sets, val); + sub_v3_v3v3(disp, val, vd.co); + break; + } + case MESH_FILTER_SURFACE_SMOOTH: { + SCULPT_surface_smooth_laplacian_step(ss, + disp, + vd.co, + ss->filter_cache->surface_smooth_laplacian_disp, + vd.index, + orig_data.co, + ss->filter_cache->surface_smooth_shape_preservation); + break; + } + } + + for (int it = 0; it < 3; it++) { + if (!ss->filter_cache->enabled_axis[it]) { + disp[it] = 0.0f; + } + } + + if (filter_type == MESH_FILTER_SURFACE_SMOOTH) { + madd_v3_v3v3fl(final_pos, vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); + } + else { + add_v3_v3v3(final_pos, orig_co, disp); + } + copy_v3_v3(vd.co, final_pos); + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_update(node); +} + +static void mesh_filter_surface_smooth_displace_task_cb( + void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + PBVHVertexIter vd; + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + float fade = vd.mask ? *vd.mask : 0.0f; + fade = 1.0f - fade; + fade *= data->filter_strength; + if (fade == 0.0f) { + continue; + } + SCULPT_surface_smooth_displace_step(ss, + vd.co, + ss->filter_cache->surface_smooth_laplacian_disp, + vd.index, + ss->filter_cache->surface_smooth_current_vertex, + clamp_f(fade, 0.0f, 1.0f)); + } + BKE_pbvh_vertex_iter_end; +} + +static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + Object *ob = CTX_data_active_object(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + SculptSession *ss = ob->sculpt; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int filter_type = RNA_enum_get(op->ptr, "type"); + float filter_strength = RNA_float_get(op->ptr, "strength"); + const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); + + if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { + SCULPT_filter_cache_free(ss); + SCULPT_undo_push_end(); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_COORDS); + return OPERATOR_FINISHED; + } + + if (event->type != MOUSEMOVE) { + return OPERATOR_RUNNING_MODAL; + } + + float len = event->prevclickx - event->mval[0]; + filter_strength = filter_strength * -len * 0.001f * UI_DPI_FAC; + + SCULPT_vertex_random_access_init(ss); + + bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); + BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = ss->filter_cache->nodes, + .filter_type = filter_type, + .filter_strength = filter_strength, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); + BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mesh_filter_task_cb, &settings); + + if (filter_type == MESH_FILTER_SURFACE_SMOOTH) { + BKE_pbvh_parallel_range(0, + ss->filter_cache->totnode, + &data, + mesh_filter_surface_smooth_displace_task_cb, + &settings); + } + + ss->filter_cache->iteration_count++; + + if (ss->deform_modifiers_active || ss->shapekey_active) { + SCULPT_flush_stroke_deform(sd, ob, true); + } + + /* The relax mesh filter needs the updated normals of the modified mesh after each iteration. */ + if (ELEM(MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS)) { + BKE_pbvh_update_normals(ss->pbvh, ss->subdiv_ccg); + } + + SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); + + return OPERATOR_RUNNING_MODAL; +} + +static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + Object *ob = CTX_data_active_object(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int filter_type = RNA_enum_get(op->ptr, "type"); + SculptSession *ss = ob->sculpt; + PBVH *pbvh = ob->sculpt->pbvh; + + int deform_axis = RNA_enum_get(op->ptr, "deform_axis"); + if (deform_axis == 0) { + return OPERATOR_CANCELLED; + } + + if (RNA_boolean_get(op->ptr, "use_face_sets")) { + /* Update the active vertex */ + float mouse[2]; + SculptCursorGeometryInfo sgi; + mouse[0] = event->mval[0]; + mouse[1] = event->mval[1]; + SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); + } + + const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets"); + + SCULPT_vertex_random_access_init(ss); + + bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets); + BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false); + + if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { + return OPERATOR_CANCELLED; + } + + SCULPT_undo_push_begin("Mesh filter"); + + SCULPT_filter_cache_init(ob, sd); + + if (use_face_sets) { + ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss, + SCULPT_active_vertex_get(ss)); + } + else { + ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE; + } + + if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) { + ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN( + 3 * sizeof(float) * SCULPT_vertex_count_get(ss), "surface smooth disp"); + ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get( + op->ptr, "surface_smooth_shape_preservation"); + ss->filter_cache->surface_smooth_current_vertex = RNA_float_get( + op->ptr, "surface_smooth_current_vertex"); + } + + ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X; + ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y; + ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z; + + if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_RELAX) { + const int totvert = SCULPT_vertex_count_get(ss); + ss->filter_cache->automask = MEM_mallocN(totvert * sizeof(float), + "Relax filter edge automask"); + for (int i = 0; i < totvert; i++) { + ss->filter_cache->automask[i] = 1.0f; + } + SCULPT_boundary_automasking_init( + ob, AUTOMASK_INIT_BOUNDARY_EDGES, 1, ss->filter_cache->automask); + } + + WM_event_add_modal_handler(C, op); + return OPERATOR_RUNNING_MODAL; +} + +void SCULPT_OT_mesh_filter(struct wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Filter mesh"; + ot->idname = "SCULPT_OT_mesh_filter"; + ot->description = "Applies a filter to modify the current mesh"; + + /* API callbacks. */ + ot->invoke = sculpt_mesh_filter_invoke; + ot->modal = sculpt_mesh_filter_modal; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* RNA. */ + RNA_def_enum(ot->srna, + "type", + prop_mesh_filter_types, + MESH_FILTER_INFLATE, + "Filter type", + "Operation that is going to be applied to the mesh"); + RNA_def_float( + ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f); + RNA_def_enum_flag(ot->srna, + "deform_axis", + prop_mesh_filter_deform_axis_items, + MESH_FILTER_DEFORM_X | MESH_FILTER_DEFORM_Y | MESH_FILTER_DEFORM_Z, + "Deform axis", + "Apply the deformation in the selected axis"); + ot->prop = RNA_def_boolean(ot->srna, + "use_face_sets", + false, + "Use Face Sets", + "Apply the filter only to the Face Mask under the cursor"); + + /* Surface Smooth Mesh Filter properties. */ + RNA_def_float(ot->srna, + "surface_smooth_shape_preservation", + 0.5f, + 0.0f, + 1.0f, + "Shape Preservation", + "How much of the original shape is preserved when smoothing", + 0.0f, + 1.0f); + RNA_def_float(ot->srna, + "surface_smooth_current_vertex", + 0.5f, + 0.0f, + 1.0f, + "Per Vertex Displacement", + "How much the position of each individual vertex influences the final result", + 0.0f, + 1.0f); +} diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index c300f011195..7c4142a807e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -24,6 +24,7 @@ #ifndef __SCULPT_INTERN_H__ #define __SCULPT_INTERN_H__ +#include "DNA_brush_types.h" #include "DNA_key_types.h" #include "DNA_listBase.h" #include "DNA_vec_types.h" @@ -132,6 +133,8 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss, int SCULPT_active_vertex_get(SculptSession *ss); const float *SCULPT_active_vertex_co_get(SculptSession *ss); +bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index); + /* Sculpt Visibility API */ void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible); @@ -197,11 +200,16 @@ int SCULPT_plane_point_side(const float co[3], const float plane[4]); int SCULPT_plane_trim(const struct StrokeCache *cache, const struct Brush *brush, const float val[3]); +void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]); float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss); ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3]); bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm); +bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3], + const float br_co[3], + float radius, + char symm); bool SCULPT_is_symmetry_iteration_valid(char i, char symm); void SCULPT_flip_v3_by_symm_area(float v[3], const ePaintSymmetryFlags symm, @@ -230,7 +238,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd, SculptFloodFill *flood, int index, float radius); -void sculpt_floodfill_add_initial(SculptFloodFill *flood, int index); +void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index); void SCULPT_floodfill_execute( struct SculptSession *ss, SculptFloodFill *flood, @@ -242,10 +250,28 @@ void SCULPT_floodfill_free(SculptFloodFill *flood); void sculpt_pbvh_clear(Object *ob); void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); +bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush); /* Automasking. */ float SCULPT_automasking_factor_get(SculptSession *ss, int vert); +void SCULPT_automasking_init(Sculpt *sd, Object *ob); +void SCULPT_automasking_end(Object *ob); + +bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, + const Brush *br, + const eAutomasking_flag mode); +bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br); + +typedef enum eBoundaryAutomaskMode { + AUTOMASK_INIT_BOUNDARY_EDGES = 1, + AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2, +} eBoundaryAutomaskMode; +float *SCULPT_boundary_automasking_init(Object *ob, + eBoundaryAutomaskMode mode, + int propagation_steps, + float *automask_factor); + /* Filters. */ void SCULPT_filter_cache_init(Object *ob, Sculpt *sd); void SCULPT_filter_cache_free(SculptSession *ss); @@ -306,6 +332,41 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr, /* Draw Face Sets Brush. */ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); +/* Smooth Brush. */ + +void SCULPT_neighbor_average(SculptSession *ss, float avg[3], uint vert); +void SCULPT_bmesh_neighbor_average(float avg[3], struct BMVert *v); + +void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v); + +void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index); +float SCULPT_neighbor_mask_average(SculptSession *ss, int index); + +void SCULPT_smooth(Sculpt *sd, + Object *ob, + PBVHNode **nodes, + const int totnode, + float bstrength, + const bool smooth_mask); +void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); + +/* Surface Smooth Brush. */ + +void SCULPT_surface_smooth_laplacian_step(SculptSession *ss, + float *disp, + const float co[3], + float (*laplacian_disp)[3], + const int v_index, + const float origco[3], + const float alpha); +void SCULPT_surface_smooth_displace_step(SculptSession *ss, + float *co, + float (*laplacian_disp)[3], + const int v_index, + const float beta, + const float fade); +void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); + /* Slide/Relax */ void SCULPT_relax_vertex(struct SculptSession *ss, struct PBVHVertexIter *vd, @@ -764,15 +825,18 @@ bool SCULPT_get_redraw_rect(struct ARegion *region, Object *ob, rcti *rect); -/* Operators */ +/* Operators. */ -/* Face Sets */ +/* Face Sets. */ void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot); void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot); void SCULPT_OT_face_sets_init(struct wmOperatorType *ot); void SCULPT_OT_face_sets_create(struct wmOperatorType *ot); -/* Transform */ +/* Transform. */ void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot); +/* Mesh Filter. */ +void SCULPT_OT_mesh_filter(struct wmOperatorType *ot); + #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c new file mode 100644 index 00000000000..0f629320333 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c @@ -0,0 +1,603 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "DNA_brush_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "bmesh.h" + +#include +#include + + + +/* For the smooth brush, uses the neighboring vertices around vert to calculate + * a smoothed location for vert. Skips corner vertices (used by only one + * polygon). */ +void SCULPT_neighbor_average(SculptSession *ss, float avg[3], uint vert) +{ + const MeshElemMap *vert_map = &ss->pmap[vert]; + const MVert *mvert = ss->mvert; + float(*deform_co)[3] = ss->deform_cos; + + /* Don't modify corner vertices. */ + if (vert_map->count > 1) { + int total = 0; + + zero_v3(avg); + + for (int i = 0; i < vert_map->count; i++) { + const MPoly *p = &ss->mpoly[vert_map->indices[i]]; + uint f_adj_v[2]; + + if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { + if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) { + add_v3_v3(avg, deform_co ? deform_co[f_adj_v[j]] : mvert[f_adj_v[j]].co); + + total++; + } + } + } + } + + if (total > 0) { + mul_v3_fl(avg, 1.0f / total); + return; + } + } + + copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co); +} + +/* Same logic as neighbor_average(), but for bmesh rather than mesh. */ +void SCULPT_bmesh_neighbor_average(float avg[3], BMVert *v) +{ + /* logic for 3 or more is identical. */ + const int vfcount = BM_vert_face_count_at_most(v, 3); + + /* Don't modify corner vertices. */ + if (vfcount > 1) { + BMIter liter; + BMLoop *l; + int total = 0; + + zero_v3(avg); + + BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { + const BMVert *adj_v[2] = {l->prev->v, l->next->v}; + + for (int i = 0; i < ARRAY_SIZE(adj_v); i++) { + const BMVert *v_other = adj_v[i]; + if (vfcount != 2 || BM_vert_face_count_at_most(v_other, 2) <= 2) { + add_v3_v3(avg, v_other->co); + total++; + } + } + } + + if (total > 0) { + mul_v3_fl(avg, 1.0f / total); + return; + } + } + + copy_v3_v3(avg, v->co); +} + +/* For bmesh: Average surrounding verts based on an orthogonality measure. + * Naturally converges to a quad-like structure. */ +void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert *v) +{ + + float avg_co[3] = {0.0f, 0.0f, 0.0f}; + float tot_co = 0.0f; + + BMIter eiter; + BMEdge *e; + + BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { + if (BM_edge_is_boundary(e)) { + copy_v3_v3(avg, v->co); + return; + } + BMVert *v_other = (e->v1 == v) ? e->v2 : e->v1; + float vec[3]; + sub_v3_v3v3(vec, v_other->co, v->co); + madd_v3_v3fl(vec, v->no, -dot_v3v3(vec, v->no)); + normalize_v3(vec); + + /* fac is a measure of how orthogonal or parallel the edge is + * relative to the direction. */ + float fac = dot_v3v3(vec, direction); + fac = fac * fac - 0.5f; + fac *= fac; + madd_v3_v3fl(avg_co, v_other->co, fac); + tot_co += fac; + } + + /* In case vert has no Edge s. */ + if (tot_co > 0.0f) { + mul_v3_v3fl(avg, avg_co, 1.0f / tot_co); + + /* Preserve volume. */ + float vec[3]; + sub_v3_v3(avg, v->co); + mul_v3_v3fl(vec, v->no, dot_v3v3(avg, v->no)); + sub_v3_v3(avg, vec); + add_v3_v3(avg, v->co); + } + else { + zero_v3(avg); + } +} + +/* Generic functions for laplacian smoothing. These functions do not take boundary vertices into account. */ + +void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index) +{ + float avg[3] = {0.0f, 0.0f, 0.0f}; + int total = 0; + + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) { + add_v3_v3(avg, SCULPT_vertex_co_get(ss, ni.index)); + total++; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + + if (total > 0) { + mul_v3_v3fl(result, avg, 1.0f / (float)total); + } + else { + copy_v3_v3(result, SCULPT_vertex_co_get(ss, index)); + } +} + +float SCULPT_neighbor_mask_average(SculptSession *ss, int index) +{ + float avg = 0.0f; + int total = 0; + + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, index, ni) { + avg += SCULPT_vertex_mask_get(ss, ni.index); + total++; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + + if (total > 0) { + return avg / (float)total; + } + else { + return SCULPT_vertex_mask_get(ss, index); + } +} + +static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + Sculpt *sd = data->sd; + const Brush *brush = data->brush; + const bool smooth_mask = data->smooth_mask; + float bstrength = data->strength; + + PBVHVertexIter vd; + + CLAMP(bstrength, 0.0f, 1.0f); + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = bstrength * SCULPT_brush_strength_factor( + ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), + vd.index, + tls->thread_id); + if (smooth_mask) { + float val = SCULPT_neighbor_mask_average(ss, vd.vert_indices[vd.i]) - *vd.mask; + val *= fade * bstrength; + *vd.mask += val; + CLAMP(*vd.mask, 0.0f, 1.0f); + } + else { + float avg[3], val[3]; + + SCULPT_neighbor_average(ss, avg, vd.vert_indices[vd.i]); + sub_v3_v3v3(val, avg, vd.co); + + madd_v3_v3v3fl(val, vd.co, val, fade); + + SCULPT_clip(sd, ss, vd.co, val); + } + + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + BKE_pbvh_vertex_iter_end; +} + +static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + Sculpt *sd = data->sd; + const Brush *brush = data->brush; + const bool smooth_mask = data->smooth_mask; + float bstrength = data->strength; + + PBVHVertexIter vd; + + CLAMP(bstrength, 0.0f, 1.0f); + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + smooth_mask ? 0.0f : *vd.mask, + vd.index, + tls->thread_id); + if (smooth_mask) { + float val = SCULPT_neighbor_mask_average(ss, vd.vert_indices[vd.i]) - *vd.mask; + val *= fade * bstrength; + *vd.mask += val; + CLAMP(*vd.mask, 0.0f, 1.0f); + } + else { + float avg[3], val[3]; + + SCULPT_bmesh_neighbor_average(avg, vd.bm_vert); + sub_v3_v3v3(val, avg, vd.co); + + madd_v3_v3v3fl(val, vd.co, val, fade); + + SCULPT_clip(sd, ss, vd.co, val); + } + + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + BKE_pbvh_vertex_iter_end; +} + +static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + Sculpt *sd = data->sd; + const Brush *brush = data->brush; + const bool smooth_mask = data->smooth_mask; + float bstrength = data->strength; + + PBVHVertexIter vd; + + CLAMP(bstrength, 0.0f, 1.0f); + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = bstrength * SCULPT_brush_strength_factor( + ss, + brush, + vd.co, + sqrtf(test.dist), + vd.no, + vd.fno, + smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), + vd.index, + tls->thread_id); + if (smooth_mask) { + float val = SCULPT_neighbor_mask_average(ss, vd.index) - *vd.mask; + val *= fade * bstrength; + *vd.mask += val; + CLAMP(*vd.mask, 0.0f, 1.0f); + } + else { + float avg[3], val[3]; + SCULPT_neighbor_coords_average(ss, avg, vd.index); + sub_v3_v3v3(val, avg, vd.co); + madd_v3_v3v3fl(val, vd.co, val, fade); + SCULPT_clip(sd, ss, vd.co, val); + } + } + } + BKE_pbvh_vertex_iter_end; +} + +void SCULPT_smooth(Sculpt *sd, + Object *ob, + PBVHNode **nodes, + const int totnode, + float bstrength, + const bool smooth_mask) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = BKE_paint_brush(&sd->paint); + + const int max_iterations = 4; + const float fract = 1.0f / max_iterations; + PBVHType type = BKE_pbvh_type(ss->pbvh); + int iteration, count; + float last; + + CLAMP(bstrength, 0.0f, 1.0f); + + count = (int)(bstrength * max_iterations); + last = max_iterations * (bstrength - count * fract); + + if (type == PBVH_FACES && !ss->pmap) { + BLI_assert(!"sculpt smooth: pmap missing"); + return; + } + + for (iteration = 0; iteration <= count; iteration++) { + const float strength = (iteration != count) ? 1.0f : last; + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .brush = brush, + .nodes = nodes, + .smooth_mask = smooth_mask, + .strength = strength, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + + switch (type) { + case PBVH_GRIDS: + BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_multires_task_cb_ex, &settings); + break; + case PBVH_FACES: + BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_mesh_task_cb_ex, &settings); + break; + case PBVH_BMESH: + BKE_pbvh_parallel_range(0, totnode, &data, do_smooth_brush_bmesh_task_cb_ex, &settings); + break; + } + } +} + +void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + SCULPT_smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false); +} + +/* HC Smooth Algorithm. */ +/* From: Improved Laplacian Smoothing of Noisy Surface Meshes */ + +void SCULPT_surface_smooth_laplacian_step(SculptSession *ss, + float *disp, + const float co[3], + float (*laplacian_disp)[3], + const int v_index, + const float origco[3], + const float alpha) +{ + float laplacian_smooth_co[3]; + float weigthed_o[3], weigthed_q[3], d[3]; + SCULPT_neighbor_coords_average(ss, laplacian_smooth_co, v_index); + + mul_v3_v3fl(weigthed_o, origco, alpha); + mul_v3_v3fl(weigthed_q, co, 1.0f - alpha); + add_v3_v3v3(d, weigthed_o, weigthed_q); + sub_v3_v3v3(laplacian_disp[v_index], laplacian_smooth_co, d); + + sub_v3_v3v3(disp, laplacian_smooth_co, co); +} + +void SCULPT_surface_smooth_displace_step(SculptSession *ss, + float *co, + float (*laplacian_disp)[3], + const int v_index, + const float beta, + const float fade) +{ + float b_avg[3] = {0.0f, 0.0f, 0.0f}; + float b_current_vertex[3]; + int total = 0; + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_index, ni) { + add_v3_v3(b_avg, laplacian_disp[ni.index]); + total++; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + if (total > 0) { + mul_v3_v3fl(b_current_vertex, b_avg, (1.0f - beta) / (float)total); + madd_v3_v3fl(b_current_vertex, laplacian_disp[v_index], beta); + mul_v3_fl(b_current_vertex, clamp_f(fade, 0.0f, 1.0f)); + sub_v3_v3(co, b_current_vertex); + } +} + +static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + const Brush *brush = data->brush; + const float bstrength = ss->cache->bstrength; + float alpha = brush->surface_smooth_shape_preservation; + + PBVHVertexIter vd; + SculptOrigVertData orig_data; + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + SCULPT_orig_vert_data_update(&orig_data, &vd); + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = + bstrength * + SCULPT_brush_strength_factor( + ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id); + + float disp[3]; + SCULPT_surface_smooth_laplacian_step(ss, + disp, + vd.co, + ss->cache->surface_smooth_laplacian_disp, + vd.index, + orig_data.co, + alpha); + madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); + } + BKE_pbvh_vertex_iter_end; + } +} + +static void SCULPT_do_surface_smooth_brush_displace_task_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + const Brush *brush = data->brush; + const float bstrength = ss->cache->bstrength; + const float beta = brush->surface_smooth_current_vertex; + + PBVHVertexIter vd; + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( + ss, &test, data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test_sq_fn(&test, vd.co)) { + const float fade = + bstrength * + SCULPT_brush_strength_factor( + ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id); + SCULPT_surface_smooth_displace_step( + ss, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.index, beta, fade); + } + } + BKE_pbvh_vertex_iter_end; +} + +void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + Brush *brush = BKE_paint_brush(&sd->paint); + SculptSession *ss = ob->sculpt; + + if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0) { + BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL); + ss->cache->surface_smooth_laplacian_disp = MEM_callocN( + SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b"); + } + + /* Threaded loop over nodes. */ + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .brush = brush, + .nodes = nodes, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + for (int i = 0; i < brush->surface_smooth_iterations; i++) { + BKE_pbvh_parallel_range( + 0, totnode, &data, SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex, &settings); + BKE_pbvh_parallel_range( + 0, totnode, &data, SCULPT_do_surface_smooth_brush_displace_task_cb_ex, &settings); + } +} + + -- cgit v1.2.3 From 17931f3b5125528e3d763ae8a80eae5e4730dcc3 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 21:46:08 +0200 Subject: Cleanup: Move Mask Filter and Mask Expand to their own files --- source/blender/editors/sculpt_paint/CMakeLists.txt | 2 + source/blender/editors/sculpt_paint/sculpt.c | 893 +-------------------- .../editors/sculpt_paint/sculpt_automasking.c | 10 +- .../editors/sculpt_paint/sculpt_filter_mask.c | 501 ++++++++++++ .../editors/sculpt_paint/sculpt_filter_mesh.c | 22 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 12 + .../editors/sculpt_paint/sculpt_mask_expand.c | 526 ++++++++++++ .../blender/editors/sculpt_paint/sculpt_smooth.c | 29 +- 8 files changed, 1071 insertions(+), 924 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_filter_mask.c create mode 100644 source/blender/editors/sculpt_paint/sculpt_mask_expand.c diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 81dafd5ded4..f9858804394 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -62,7 +62,9 @@ set(SRC sculpt_automasking.c sculpt_cloth.c sculpt_face_set.c + sculpt_filter_mask.c sculpt_filter_mesh.c + sculpt_mask_expand.c sculpt_multiplane_scrape.c sculpt_pose.c sculpt_smooth.c diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a53c9aed36d..5bd0f3f2f48 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -153,7 +153,7 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, int index) return NULL; } -static void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]) +void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -209,7 +209,7 @@ const float *SCULPT_active_vertex_co_get(SculptSession *ss) return SCULPT_vertex_co_get(ss, SCULPT_active_vertex_get(ss)); } -static void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]) +void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]) { SCULPT_vertex_normal_get(ss, SCULPT_active_vertex_get(ss), normal); } @@ -8463,895 +8463,6 @@ static void SCULPT_OT_set_detail_size(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -typedef enum eSculptMaskFilterTypes { - MASK_FILTER_SMOOTH = 0, - MASK_FILTER_SHARPEN = 1, - MASK_FILTER_GROW = 2, - MASK_FILTER_SHRINK = 3, - MASK_FILTER_CONTRAST_INCREASE = 5, - MASK_FILTER_CONTRAST_DECREASE = 6, -} eSculptMaskFilterTypes; - -static EnumPropertyItem prop_mask_filter_types[] = { - {MASK_FILTER_SMOOTH, "SMOOTH", 0, "Smooth Mask", "Smooth mask"}, - {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"}, - {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"}, - {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"}, - {MASK_FILTER_CONTRAST_INCREASE, - "CONTRAST_INCREASE", - 0, - "Increase contrast", - "Increase the contrast of the paint mask"}, - {MASK_FILTER_CONTRAST_DECREASE, - "CONTRAST_DECREASE", - 0, - "Decrease contrast", - "Decrease the contrast of the paint mask"}, - {0, NULL, 0, NULL, NULL}, -}; - -static void mask_filter_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - bool update = false; - - const int mode = data->filter_type; - float contrast = 0.0f; - - PBVHVertexIter vd; - - if (mode == MASK_FILTER_CONTRAST_INCREASE) { - contrast = 0.1f; - } - - if (mode == MASK_FILTER_CONTRAST_DECREASE) { - contrast = -0.1f; - } - - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - float delta, gain, offset, max, min; - float prev_val = *vd.mask; - SculptVertexNeighborIter ni; - switch (mode) { - case MASK_FILTER_SMOOTH: - case MASK_FILTER_SHARPEN: { - float val = SCULPT_neighbor_mask_average(ss, vd.index); - - val -= *vd.mask; - - if (mode == MASK_FILTER_SMOOTH) { - *vd.mask += val; - } - else if (mode == MASK_FILTER_SHARPEN) { - if (*vd.mask > 0.5f) { - *vd.mask += 0.05f; - } - else { - *vd.mask -= 0.05f; - } - *vd.mask += val / 2.0f; - } - break; - } - case MASK_FILTER_GROW: - max = 0.0f; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) { - float vmask_f = data->prev_mask[ni.index]; - if (vmask_f > max) { - max = vmask_f; - } - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - *vd.mask = max; - break; - case MASK_FILTER_SHRINK: - min = 1.0f; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) { - float vmask_f = data->prev_mask[ni.index]; - if (vmask_f < min) { - min = vmask_f; - } - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - *vd.mask = min; - break; - case MASK_FILTER_CONTRAST_INCREASE: - case MASK_FILTER_CONTRAST_DECREASE: - delta = contrast / 2.0f; - gain = 1.0f - delta * 2.0f; - if (contrast > 0) { - gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON); - offset = gain * (-delta); - } - else { - delta *= -1.0f; - offset = gain * (delta); - } - *vd.mask = gain * (*vd.mask) + offset; - break; - } - CLAMP(*vd.mask, 0.0f, 1.0f); - if (*vd.mask != prev_val) { - update = true; - } - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - BKE_pbvh_vertex_iter_end; - - if (update) { - BKE_pbvh_node_mark_update_mask(node); - } -} - -static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) -{ - ARegion *region = CTX_wm_region(C); - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int totnode; - int filter_type = RNA_enum_get(op->ptr, "filter_type"); - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); - - SCULPT_vertex_random_access_init(ss); - - if (!ob->sculpt->pmap) { - return OPERATOR_CANCELLED; - } - - int num_verts = SCULPT_vertex_count_get(ss); - - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - SCULPT_undo_push_begin("Mask filter"); - - for (int i = 0; i < totnode; i++) { - SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); - } - - float *prev_mask = NULL; - int iterations = RNA_int_get(op->ptr, "iterations"); - - /* Auto iteration count calculates the number of iteration based on the vertices of the mesh to - * avoid adding an unnecessary amount of undo steps when using the operator from a shortcut. - * One iteration per 50000 vertices in the mesh should be fine in most cases. - * Maybe we want this to be configurable. */ - if (RNA_boolean_get(op->ptr, "auto_iteration_count")) { - iterations = (int)(num_verts / 50000.0f) + 1; - } - - for (int i = 0; i < iterations; i++) { - if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { - prev_mask = MEM_mallocN(num_verts * sizeof(float), "prevmask"); - for (int j = 0; j < num_verts; j++) { - prev_mask[j] = SCULPT_vertex_mask_get(ss, j); - } - } - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = nodes, - .filter_type = filter_type, - .prev_mask = prev_mask, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings); - - if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { - MEM_freeN(prev_mask); - } - } - - MEM_SAFE_FREE(nodes); - - SCULPT_undo_push_end(); - - ED_region_tag_redraw(region); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_mask_filter(struct wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Mask Filter"; - ot->idname = "SCULPT_OT_mask_filter"; - ot->description = "Applies a filter to modify the current mask"; - - /* API callbacks. */ - ot->exec = sculpt_mask_filter_exec; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER; - - /* RNA. */ - RNA_def_enum(ot->srna, - "filter_type", - prop_mask_filter_types, - MASK_FILTER_SMOOTH, - "Type", - "Filter that is going to be applied to the mask"); - RNA_def_int(ot->srna, - "iterations", - 1, - 1, - 100, - "Iterations", - "Number of times that the filter is going to be applied", - 1, - 100); - RNA_def_boolean( - ot->srna, - "auto_iteration_count", - false, - "Auto Iteration Count", - "Use a automatic number of iterations based on the number of vertices of the sculpt"); -} - -static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd) -{ - int total = 0; - float avg[3]; - zero_v3(avg); - - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd->index, ni) { - float normalized[3]; - sub_v3_v3v3(normalized, SCULPT_vertex_co_get(ss, ni.index), vd->co); - normalize_v3(normalized); - add_v3_v3(avg, normalized); - total++; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - - if (total > 0) { - mul_v3_fl(avg, 1.0f / total); - float normal[3]; - if (vd->no) { - normal_short_to_float_v3(normal, vd->no); - } - else { - copy_v3_v3(normal, vd->fno); - } - float dot = dot_v3v3(avg, normal); - float angle = max_ff(saacosf(dot), 0.0f); - return angle; - } - return 0.0f; -} - -typedef struct DirtyMaskRangeData { - float min, max; -} DirtyMaskRangeData; - -static void dirty_mask_compute_range_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict tls) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - DirtyMaskRangeData *range = tls->userdata_chunk; - PBVHVertexIter vd; - - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - float dirty_mask = neighbor_dirty_mask(ss, &vd); - range->min = min_ff(dirty_mask, range->min); - range->max = max_ff(dirty_mask, range->max); - } - BKE_pbvh_vertex_iter_end; -} - -static void dirty_mask_compute_range_reduce(const void *__restrict UNUSED(userdata), - void *__restrict chunk_join, - void *__restrict chunk) -{ - DirtyMaskRangeData *join = chunk_join; - DirtyMaskRangeData *range = chunk; - join->min = min_ff(range->min, join->min); - join->max = max_ff(range->max, join->max); -} - -static void dirty_mask_apply_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - PBVHVertexIter vd; - - const bool dirty_only = data->dirty_mask_dirty_only; - const float min = data->dirty_mask_min; - const float max = data->dirty_mask_max; - - float range = max - min; - if (range < 0.0001f) { - range = 0.0f; - } - else { - range = 1.0f / range; - } - - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - float dirty_mask = neighbor_dirty_mask(ss, &vd); - float mask = *vd.mask + (1.0f - ((dirty_mask - min) * range)); - if (dirty_only) { - mask = fminf(mask, 0.5f) * 2.0f; - } - *vd.mask = CLAMPIS(mask, 0.0f, 1.0f); - - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - } - BKE_pbvh_vertex_iter_end; - BKE_pbvh_node_mark_update_mask(node); -} - -static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op) -{ - ARegion *region = CTX_wm_region(C); - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - PBVH *pbvh = ob->sculpt->pbvh; - PBVHNode **nodes; - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int totnode; - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); - - SCULPT_vertex_random_access_init(ss); - - if (!ob->sculpt->pmap) { - return OPERATOR_CANCELLED; - } - - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); - SCULPT_undo_push_begin("Dirty Mask"); - - for (int i = 0; i < totnode; i++) { - SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); - } - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = nodes, - .dirty_mask_dirty_only = RNA_boolean_get(op->ptr, "dirty_only"), - }; - DirtyMaskRangeData range = { - .min = FLT_MAX, - .max = -FLT_MAX, - }; - - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - - settings.func_reduce = dirty_mask_compute_range_reduce; - settings.userdata_chunk = ⦥ - settings.userdata_chunk_size = sizeof(DirtyMaskRangeData); - - BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_compute_range_task_cb, &settings); - data.dirty_mask_min = range.min; - data.dirty_mask_max = range.max; - BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_apply_task_cb, &settings); - - MEM_SAFE_FREE(nodes); - - BKE_pbvh_update_vertex_data(pbvh, PBVH_UpdateMask); - - SCULPT_undo_push_end(); - - ED_region_tag_redraw(region); - - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_dirty_mask(struct wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Dirty Mask"; - ot->idname = "SCULPT_OT_dirty_mask"; - ot->description = "Generates a mask based on the geometry cavity and pointiness"; - - /* API callbacks. */ - ot->exec = sculpt_dirty_mask_exec; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER; - - /* RNA. */ - RNA_def_boolean( - ot->srna, "dirty_only", false, "Dirty Only", "Don't calculate cleans for convex areas"); -} - -static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); - - MEM_freeN(op->customdata); - - for (int n = 0; n < ss->filter_cache->totnode; n++) { - PBVHNode *node = ss->filter_cache->nodes[n]; - if (create_face_set) { - for (int i = 0; i < ss->totfaces; i++) { - ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; - } - } - else { - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - *vd.mask = ss->filter_cache->prev_mask[vd.index]; - } - BKE_pbvh_vertex_iter_end; - } - - BKE_pbvh_node_mark_redraw(node); - } - - if (!create_face_set) { - SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); - } - SCULPT_filter_cache_free(ss); - SCULPT_undo_push_end(); - SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); - ED_workspace_status_text(C, NULL); -} - -static void sculpt_expand_task_cb(void *__restrict userdata, - const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) -{ - SculptThreadedTaskData *data = userdata; - SculptSession *ss = data->ob->sculpt; - PBVHNode *node = data->nodes[i]; - PBVHVertexIter vd; - int update_it = data->mask_expand_update_it; - - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) - { - int vi = vd.index; - float final_mask = *vd.mask; - if (data->mask_expand_use_normals) { - if (ss->filter_cache->normal_factor[SCULPT_active_vertex_get(ss)] < - ss->filter_cache->normal_factor[vd.index]) { - final_mask = 1.0f; - } - else { - final_mask = 0.0f; - } - } - else { - if (ss->filter_cache->mask_update_it[vi] <= update_it && - ss->filter_cache->mask_update_it[vi] != 0) { - final_mask = 1.0f; - } - else { - final_mask = 0.0f; - } - } - - if (data->mask_expand_create_face_set) { - if (final_mask == 1.0f) { - SCULPT_vertex_face_set_set(ss, vd.index, ss->filter_cache->new_face_set); - } - BKE_pbvh_node_mark_redraw(node); - } - else { - - if (data->mask_expand_keep_prev_mask) { - final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask); - } - - if (data->mask_expand_invert_mask) { - final_mask = 1.0f - final_mask; - } - - if (*vd.mask != final_mask) { - if (vd.mvert) { - vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - *vd.mask = final_mask; - BKE_pbvh_node_mark_update_mask(node); - } - } - } - BKE_pbvh_vertex_iter_end; -} - -static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - ARegion *region = CTX_wm_region(C); - float prevclick_f[2]; - copy_v2_v2(prevclick_f, op->customdata); - int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]}; - int len = (int)len_v2v2_int(prevclick, event->mval); - len = abs(len); - int mask_speed = RNA_int_get(op->ptr, "mask_speed"); - int mask_expand_update_it = len / mask_speed; - mask_expand_update_it = mask_expand_update_it + 1; - - const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); - - if (RNA_boolean_get(op->ptr, "use_cursor")) { - SculptCursorGeometryInfo sgi; - float mouse[2]; - mouse[0] = event->mval[0]; - mouse[1] = event->mval[1]; - SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); - mask_expand_update_it = ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)]; - } - - if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || - (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { - /* Returning OPERATOR_CANCELLED will leak memory due to not finishing - * undo. Better solution could be to make paint_mesh_restore_co work - * for this case. */ - sculpt_mask_expand_cancel(C, op); - return OPERATOR_FINISHED; - } - - if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || - (event->type == EVT_RETKEY && event->val == KM_PRESS) || - (event->type == EVT_PADENTER && event->val == KM_PRESS)) { - - /* Smooth iterations. */ - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - .filter_type = MASK_FILTER_SMOOTH, - }; - - int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations"); - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); - for (int i = 0; i < smooth_iterations; i++) { - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, mask_filter_task_cb, &settings); - } - - /* Pivot position. */ - if (RNA_boolean_get(op->ptr, "update_pivot")) { - const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; - const float threshold = 0.2f; - float avg[3]; - int total = 0; - zero_v3(avg); - - for (int n = 0; n < ss->filter_cache->totnode; n++) { - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, ss->filter_cache->nodes[n], vd, PBVH_ITER_UNIQUE) - { - const float mask = (vd.mask) ? *vd.mask : 0.0f; - if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) { - if (SCULPT_check_vertex_pivot_symmetry( - vd.co, ss->filter_cache->mask_expand_initial_co, symm)) { - add_v3_v3(avg, vd.co); - total++; - } - } - } - BKE_pbvh_vertex_iter_end; - } - - if (total > 0) { - mul_v3_fl(avg, 1.0f / total); - copy_v3_v3(ss->pivot_pos, avg); - } - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); - } - - MEM_freeN(op->customdata); - - for (int i = 0; i < ss->filter_cache->totnode; i++) { - BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); - } - - SCULPT_filter_cache_free(ss); - - SCULPT_undo_push_end(); - SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); - ED_workspace_status_text(C, NULL); - return OPERATOR_FINISHED; - } - - /* When pressing Ctrl, expand directly to the max number of iterations. This allows to flood fill - * mask and face sets by connectivity directly. */ - if (event->ctrl) { - mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1; - } - - if (!ELEM(event->type, MOUSEMOVE, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { - return OPERATOR_RUNNING_MODAL; - } - - if (mask_expand_update_it == ss->filter_cache->mask_update_current_it) { - ED_region_tag_redraw(region); - return OPERATOR_RUNNING_MODAL; - } - - if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) { - - if (create_face_set) { - for (int i = 0; i < ss->totfaces; i++) { - ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; - } - } - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - .mask_expand_update_it = mask_expand_update_it, - .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"), - .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"), - .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"), - .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"), - }; - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings); - ss->filter_cache->mask_update_current_it = mask_expand_update_it; - } - - SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); - - return OPERATOR_RUNNING_MODAL; -} - -typedef struct MaskExpandFloodFillData { - float original_normal[3]; - float edge_sensitivity; - bool use_normals; -} MaskExpandFloodFillData; - -static bool mask_expand_floodfill_cb( - SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata) -{ - MaskExpandFloodFillData *data = userdata; - - if (!is_duplicate) { - int to_it = ss->filter_cache->mask_update_it[from_v] + 1; - ss->filter_cache->mask_update_it[to_v] = to_it; - if (to_it > ss->filter_cache->mask_update_last_it) { - ss->filter_cache->mask_update_last_it = to_it; - } - - if (data->use_normals) { - float current_normal[3], prev_normal[3]; - SCULPT_vertex_normal_get(ss, to_v, current_normal); - SCULPT_vertex_normal_get(ss, from_v, prev_normal); - const float from_edge_factor = ss->filter_cache->edge_factor[from_v]; - ss->filter_cache->edge_factor[to_v] = dot_v3v3(current_normal, prev_normal) * - from_edge_factor; - ss->filter_cache->normal_factor[to_v] = dot_v3v3(data->original_normal, current_normal) * - powf(from_edge_factor, data->edge_sensitivity); - CLAMP(ss->filter_cache->normal_factor[to_v], 0.0f, 1.0f); - } - } - else { - /* PBVH_GRIDS duplicate handling. */ - ss->filter_cache->mask_update_it[to_v] = ss->filter_cache->mask_update_it[from_v]; - if (data->use_normals) { - ss->filter_cache->edge_factor[to_v] = ss->filter_cache->edge_factor[from_v]; - ss->filter_cache->normal_factor[to_v] = ss->filter_cache->normal_factor[from_v]; - } - } - - return true; -} - -static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - PBVH *pbvh = ob->sculpt->pbvh; - - const bool use_normals = RNA_boolean_get(op->ptr, "use_normals"); - const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); - - SculptCursorGeometryInfo sgi; - float mouse[2]; - mouse[0] = event->mval[0]; - mouse[1] = event->mval[1]; - - SCULPT_vertex_random_access_init(ss); - - op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position"); - copy_v2_v2(op->customdata, mouse); - - SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); - - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); - - int vertex_count = SCULPT_vertex_count_get(ss); - - ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); - - BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode); - - SCULPT_undo_push_begin("Mask Expand"); - - if (create_face_set) { - SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS); - for (int i = 0; i < ss->filter_cache->totnode; i++) { - BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); - } - } - else { - for (int i = 0; i < ss->filter_cache->totnode; i++) { - SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK); - BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); - } - } - - ss->filter_cache->mask_update_it = MEM_callocN(sizeof(int) * vertex_count, - "mask update iteration"); - if (use_normals) { - ss->filter_cache->normal_factor = MEM_callocN(sizeof(float) * vertex_count, - "mask update normal factor"); - ss->filter_cache->edge_factor = MEM_callocN(sizeof(float) * vertex_count, - "mask update normal factor"); - for (int i = 0; i < vertex_count; i++) { - ss->filter_cache->edge_factor[i] = 1.0f; - } - } - - if (create_face_set) { - ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totfaces, "prev face mask"); - for (int i = 0; i < ss->totfaces; i++) { - ss->filter_cache->prev_face_set[i] = ss->face_sets[i]; - } - ss->filter_cache->new_face_set = SCULPT_face_set_next_available_get(ss); - } - else { - ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask"); - for (int i = 0; i < vertex_count; i++) { - ss->filter_cache->prev_mask[i] = SCULPT_vertex_mask_get(ss, i); - } - } - - ss->filter_cache->mask_update_last_it = 1; - ss->filter_cache->mask_update_current_it = 1; - ss->filter_cache->mask_update_it[SCULPT_active_vertex_get(ss)] = 0; - - copy_v3_v3(ss->filter_cache->mask_expand_initial_co, SCULPT_active_vertex_co_get(ss)); - - SculptFloodFill flood; - SCULPT_floodfill_init(ss, &flood); - SCULPT_floodfill_add_active(sd, ob, ss, &flood, FLT_MAX); - - MaskExpandFloodFillData fdata = { - .use_normals = use_normals, - .edge_sensitivity = RNA_int_get(op->ptr, "edge_sensitivity"), - }; - SCULPT_active_vertex_normal_get(ss, fdata.original_normal); - SCULPT_floodfill_execute(ss, &flood, mask_expand_floodfill_cb, &fdata); - SCULPT_floodfill_free(&flood); - - if (use_normals) { - for (int repeat = 0; repeat < 2; repeat++) { - for (int i = 0; i < vertex_count; i++) { - float avg = 0.0f; - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) { - avg += ss->filter_cache->normal_factor[ni.index]; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - ss->filter_cache->normal_factor[i] = avg / ni.size; - } - } - - MEM_SAFE_FREE(ss->filter_cache->edge_factor); - } - - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = ss->filter_cache->nodes, - .mask_expand_update_it = 0, - .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"), - .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"), - .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"), - .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"), - }; - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); - BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings); - - const char *status_str = TIP_( - "Move the mouse to expand the mask from the active vertex. LMB: confirm mask, ESC/RMB: " - "cancel"); - ED_workspace_status_text(C, status_str); - - SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); - WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; -} - -static void SCULPT_OT_mask_expand(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Mask Expand"; - ot->idname = "SCULPT_OT_mask_expand"; - ot->description = "Expands a mask from the initial active vertex under the cursor"; - - /* API callbacks. */ - ot->invoke = sculpt_mask_expand_invoke; - ot->modal = sculpt_mask_expand_modal; - ot->cancel = sculpt_mask_expand_cancel; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ot->prop = RNA_def_boolean(ot->srna, "invert", true, "Invert", "Invert the new mask"); - ot->prop = RNA_def_boolean( - ot->srna, "use_cursor", true, "Use Cursor", "Expand the mask to the cursor position"); - ot->prop = RNA_def_boolean(ot->srna, - "update_pivot", - true, - "Update Pivot Position", - "Set the pivot position to the mask border after creating the mask"); - ot->prop = RNA_def_int(ot->srna, "smooth_iterations", 2, 0, 10, "Smooth iterations", "", 0, 10); - ot->prop = RNA_def_int(ot->srna, "mask_speed", 5, 1, 10, "Mask speed", "", 1, 10); - - ot->prop = RNA_def_boolean(ot->srna, - "use_normals", - true, - "Use Normals", - "Generate the mask using the normals and curvature of the model"); - ot->prop = RNA_def_boolean(ot->srna, - "keep_previous_mask", - false, - "Keep Previous Mask", - "Generate the new mask on top of the current one"); - ot->prop = RNA_def_int(ot->srna, - "edge_sensitivity", - 300, - 0, - 2000, - "Edge Detection Sensitivity", - "Sensitivity for expanding the mask across sculpted sharp edges when " - "using normals to generate the mask", - 0, - 2000); - ot->prop = RNA_def_boolean(ot->srna, - "create_face_set", - false, - "Expand Face Mask", - "Expand a new Face Mask instead of the sculpt mask"); -} - void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float radius) { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c b/source/blender/editors/sculpt_paint/sculpt_automasking.c index 768b25a9a22..68fa7ac01ae 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.c +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c @@ -63,8 +63,8 @@ #include bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, - const Brush *br, - const eAutomasking_flag mode) + const Brush *br, + const eAutomasking_flag mode) { return br->automasking_flags & mode || sd->automasking_flags & mode; } @@ -205,9 +205,9 @@ static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *a #define EDGE_DISTANCE_INF -1 float *SCULPT_boundary_automasking_init(Object *ob, - eBoundaryAutomaskMode mode, - int propagation_steps, - float *automask_factor) + eBoundaryAutomaskMode mode, + int propagation_steps, + float *automask_factor) { SculptSession *ss = ob->sculpt; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c new file mode 100644 index 00000000000..d895ecc7119 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c @@ -0,0 +1,501 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" + +#include "bmesh.h" + +#include +#include + +typedef enum eSculptMaskFilterTypes { + MASK_FILTER_SMOOTH = 0, + MASK_FILTER_SHARPEN = 1, + MASK_FILTER_GROW = 2, + MASK_FILTER_SHRINK = 3, + MASK_FILTER_CONTRAST_INCREASE = 5, + MASK_FILTER_CONTRAST_DECREASE = 6, +} eSculptMaskFilterTypes; + +static EnumPropertyItem prop_mask_filter_types[] = { + {MASK_FILTER_SMOOTH, "SMOOTH", 0, "Smooth Mask", "Smooth mask"}, + {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"}, + {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"}, + {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"}, + {MASK_FILTER_CONTRAST_INCREASE, + "CONTRAST_INCREASE", + 0, + "Increase contrast", + "Increase the contrast of the paint mask"}, + {MASK_FILTER_CONTRAST_DECREASE, + "CONTRAST_DECREASE", + 0, + "Decrease contrast", + "Decrease the contrast of the paint mask"}, + {0, NULL, 0, NULL, NULL}, +}; + +static void mask_filter_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + bool update = false; + + const int mode = data->filter_type; + float contrast = 0.0f; + + PBVHVertexIter vd; + + if (mode == MASK_FILTER_CONTRAST_INCREASE) { + contrast = 0.1f; + } + + if (mode == MASK_FILTER_CONTRAST_DECREASE) { + contrast = -0.1f; + } + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + float delta, gain, offset, max, min; + float prev_val = *vd.mask; + SculptVertexNeighborIter ni; + switch (mode) { + case MASK_FILTER_SMOOTH: + case MASK_FILTER_SHARPEN: { + float val = SCULPT_neighbor_mask_average(ss, vd.index); + + val -= *vd.mask; + + if (mode == MASK_FILTER_SMOOTH) { + *vd.mask += val; + } + else if (mode == MASK_FILTER_SHARPEN) { + if (*vd.mask > 0.5f) { + *vd.mask += 0.05f; + } + else { + *vd.mask -= 0.05f; + } + *vd.mask += val / 2.0f; + } + break; + } + case MASK_FILTER_GROW: + max = 0.0f; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) { + float vmask_f = data->prev_mask[ni.index]; + if (vmask_f > max) { + max = vmask_f; + } + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + *vd.mask = max; + break; + case MASK_FILTER_SHRINK: + min = 1.0f; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) { + float vmask_f = data->prev_mask[ni.index]; + if (vmask_f < min) { + min = vmask_f; + } + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + *vd.mask = min; + break; + case MASK_FILTER_CONTRAST_INCREASE: + case MASK_FILTER_CONTRAST_DECREASE: + delta = contrast / 2.0f; + gain = 1.0f - delta * 2.0f; + if (contrast > 0) { + gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON); + offset = gain * (-delta); + } + else { + delta *= -1.0f; + offset = gain * (delta); + } + *vd.mask = gain * (*vd.mask) + offset; + break; + } + CLAMP(*vd.mask, 0.0f, 1.0f); + if (*vd.mask != prev_val) { + update = true; + } + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BKE_pbvh_vertex_iter_end; + + if (update) { + BKE_pbvh_node_mark_update_mask(node); + } +} + +static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) +{ + ARegion *region = CTX_wm_region(C); + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int totnode; + int filter_type = RNA_enum_get(op->ptr, "filter_type"); + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); + + SCULPT_vertex_random_access_init(ss); + + if (!ob->sculpt->pmap) { + return OPERATOR_CANCELLED; + } + + int num_verts = SCULPT_vertex_count_get(ss); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + SCULPT_undo_push_begin("Mask filter"); + + for (int i = 0; i < totnode; i++) { + SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + } + + float *prev_mask = NULL; + int iterations = RNA_int_get(op->ptr, "iterations"); + + /* Auto iteration count calculates the number of iteration based on the vertices of the mesh to + * avoid adding an unnecessary amount of undo steps when using the operator from a shortcut. + * One iteration per 50000 vertices in the mesh should be fine in most cases. + * Maybe we want this to be configurable. */ + if (RNA_boolean_get(op->ptr, "auto_iteration_count")) { + iterations = (int)(num_verts / 50000.0f) + 1; + } + + for (int i = 0; i < iterations; i++) { + if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { + prev_mask = MEM_mallocN(num_verts * sizeof(float), "prevmask"); + for (int j = 0; j < num_verts; j++) { + prev_mask[j] = SCULPT_vertex_mask_get(ss, j); + } + } + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = nodes, + .filter_type = filter_type, + .prev_mask = prev_mask, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings); + + if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { + MEM_freeN(prev_mask); + } + } + + MEM_SAFE_FREE(nodes); + + SCULPT_undo_push_end(); + + ED_region_tag_redraw(region); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + return OPERATOR_FINISHED; +} + +void SCULPT_mask_filter_smooth_apply(Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations) { + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = nodes, + .filter_type = MASK_FILTER_SMOOTH, + }; + + for (int i = 0; i < smooth_iterations; i++) { + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings); + } +} + +void SCULPT_OT_mask_filter(struct wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Mask Filter"; + ot->idname = "SCULPT_OT_mask_filter"; + ot->description = "Applies a filter to modify the current mask"; + + /* API callbacks. */ + ot->exec = sculpt_mask_filter_exec; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER; + + /* RNA. */ + RNA_def_enum(ot->srna, + "filter_type", + prop_mask_filter_types, + MASK_FILTER_SMOOTH, + "Type", + "Filter that is going to be applied to the mask"); + RNA_def_int(ot->srna, + "iterations", + 1, + 1, + 100, + "Iterations", + "Number of times that the filter is going to be applied", + 1, + 100); + RNA_def_boolean( + ot->srna, + "auto_iteration_count", + false, + "Auto Iteration Count", + "Use a automatic number of iterations based on the number of vertices of the sculpt"); +} + +static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd) +{ + int total = 0; + float avg[3]; + zero_v3(avg); + + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd->index, ni) { + float normalized[3]; + sub_v3_v3v3(normalized, SCULPT_vertex_co_get(ss, ni.index), vd->co); + normalize_v3(normalized); + add_v3_v3(avg, normalized); + total++; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + + if (total > 0) { + mul_v3_fl(avg, 1.0f / total); + float normal[3]; + if (vd->no) { + normal_short_to_float_v3(normal, vd->no); + } + else { + copy_v3_v3(normal, vd->fno); + } + float dot = dot_v3v3(avg, normal); + float angle = max_ff(saacosf(dot), 0.0f); + return angle; + } + return 0.0f; +} + +typedef struct DirtyMaskRangeData { + float min, max; +} DirtyMaskRangeData; + +static void dirty_mask_compute_range_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + DirtyMaskRangeData *range = tls->userdata_chunk; + PBVHVertexIter vd; + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + float dirty_mask = neighbor_dirty_mask(ss, &vd); + range->min = min_ff(dirty_mask, range->min); + range->max = max_ff(dirty_mask, range->max); + } + BKE_pbvh_vertex_iter_end; +} + +static void dirty_mask_compute_range_reduce(const void *__restrict UNUSED(userdata), + void *__restrict chunk_join, + void *__restrict chunk) +{ + DirtyMaskRangeData *join = chunk_join; + DirtyMaskRangeData *range = chunk; + join->min = min_ff(range->min, join->min); + join->max = max_ff(range->max, join->max); +} + +static void dirty_mask_apply_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + PBVHVertexIter vd; + + const bool dirty_only = data->dirty_mask_dirty_only; + const float min = data->dirty_mask_min; + const float max = data->dirty_mask_max; + + float range = max - min; + if (range < 0.0001f) { + range = 0.0f; + } + else { + range = 1.0f / range; + } + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + float dirty_mask = neighbor_dirty_mask(ss, &vd); + float mask = *vd.mask + (1.0f - ((dirty_mask - min) * range)); + if (dirty_only) { + mask = fminf(mask, 0.5f) * 2.0f; + } + *vd.mask = CLAMPIS(mask, 0.0f, 1.0f); + + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BKE_pbvh_vertex_iter_end; + BKE_pbvh_node_mark_update_mask(node); +} + +static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op) +{ + ARegion *region = CTX_wm_region(C); + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int totnode; + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); + + SCULPT_vertex_random_access_init(ss); + + if (!ob->sculpt->pmap) { + return OPERATOR_CANCELLED; + } + + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + SCULPT_undo_push_begin("Dirty Mask"); + + for (int i = 0; i < totnode; i++) { + SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + } + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = nodes, + .dirty_mask_dirty_only = RNA_boolean_get(op->ptr, "dirty_only"), + }; + DirtyMaskRangeData range = { + .min = FLT_MAX, + .max = -FLT_MAX, + }; + + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + + settings.func_reduce = dirty_mask_compute_range_reduce; + settings.userdata_chunk = ⦥ + settings.userdata_chunk_size = sizeof(DirtyMaskRangeData); + + BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_compute_range_task_cb, &settings); + data.dirty_mask_min = range.min; + data.dirty_mask_max = range.max; + BKE_pbvh_parallel_range(0, totnode, &data, dirty_mask_apply_task_cb, &settings); + + MEM_SAFE_FREE(nodes); + + BKE_pbvh_update_vertex_data(pbvh, PBVH_UpdateMask); + + SCULPT_undo_push_end(); + + ED_region_tag_redraw(region); + + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_dirty_mask(struct wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Dirty Mask"; + ot->idname = "SCULPT_OT_dirty_mask"; + ot->description = "Generates a mask based on the geometry cavity and pointiness"; + + /* API callbacks. */ + ot->exec = sculpt_dirty_mask_exec; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER; + + /* RNA. */ + RNA_def_boolean( + ot->srna, "dirty_only", false, "Dirty Only", "Don't calculate cleans for convex areas"); +} diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index b1dd7b87507..f64e8ea609b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -316,12 +316,12 @@ static void mesh_filter_task_cb(void *__restrict userdata, } case MESH_FILTER_SURFACE_SMOOTH: { SCULPT_surface_smooth_laplacian_step(ss, - disp, - vd.co, - ss->filter_cache->surface_smooth_laplacian_disp, - vd.index, - orig_data.co, - ss->filter_cache->surface_smooth_shape_preservation); + disp, + vd.co, + ss->filter_cache->surface_smooth_laplacian_disp, + vd.index, + orig_data.co, + ss->filter_cache->surface_smooth_shape_preservation); break; } } @@ -365,11 +365,11 @@ static void mesh_filter_surface_smooth_displace_task_cb( continue; } SCULPT_surface_smooth_displace_step(ss, - vd.co, - ss->filter_cache->surface_smooth_laplacian_disp, - vd.index, - ss->filter_cache->surface_smooth_current_vertex, - clamp_f(fade, 0.0f, 1.0f)); + vd.co, + ss->filter_cache->surface_smooth_laplacian_disp, + vd.index, + ss->filter_cache->surface_smooth_current_vertex, + clamp_f(fade, 0.0f, 1.0f)); } BKE_pbvh_vertex_iter_end; } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 7c4142a807e..3858a990e97 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -82,6 +82,7 @@ void SCULPT_vertex_random_access_init(struct SculptSession *ss); int SCULPT_vertex_count_get(struct SculptSession *ss); const float *SCULPT_vertex_co_get(struct SculptSession *ss, int index); +void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]); float SCULPT_vertex_mask_get(struct SculptSession *ss, int index); #define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256 @@ -132,6 +133,7 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss, int SCULPT_active_vertex_get(SculptSession *ss); const float *SCULPT_active_vertex_co_get(SculptSession *ss); +void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]); bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index); @@ -276,6 +278,9 @@ float *SCULPT_boundary_automasking_init(Object *ob, void SCULPT_filter_cache_init(Object *ob, Sculpt *sd); void SCULPT_filter_cache_free(SculptSession *ss); +void SCULPT_mask_filter_smooth_apply( + Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations); + /* Brushes. */ /* Cloth Brush. */ @@ -839,4 +844,11 @@ void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot); /* Mesh Filter. */ void SCULPT_OT_mesh_filter(struct wmOperatorType *ot); +/* Mask filter and Dirty Mask. */ +void SCULPT_OT_mask_filter(struct wmOperatorType *ot); +void SCULPT_OT_dirty_mask(struct wmOperatorType *ot); + +/* Mask and Face Sets Expand. */ +void SCULPT_OT_mask_expand(struct wmOperatorType *ot); + #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c new file mode 100644 index 00000000000..2d4fc2b0258 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c @@ -0,0 +1,526 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "BLT_translation.h" + +#include "DNA_brush_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" + +#include "BKE_brush.h" +#include "BKE_ccg.h" +#include "BKE_colortools.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_multires.h" +#include "BKE_node.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "ED_view3d.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "bmesh.h" + +#include +#include + + +static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); + + MEM_freeN(op->customdata); + + for (int n = 0; n < ss->filter_cache->totnode; n++) { + PBVHNode *node = ss->filter_cache->nodes[n]; + if (create_face_set) { + for (int i = 0; i < ss->totfaces; i++) { + ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; + } + } + else { + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + *vd.mask = ss->filter_cache->prev_mask[vd.index]; + } + BKE_pbvh_vertex_iter_end; + } + + BKE_pbvh_node_mark_redraw(node); + } + + if (!create_face_set) { + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); + } + SCULPT_filter_cache_free(ss); + SCULPT_undo_push_end(); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); + ED_workspace_status_text(C, NULL); +} + +static void sculpt_expand_task_cb(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + PBVHVertexIter vd; + int update_it = data->mask_expand_update_it; + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) + { + int vi = vd.index; + float final_mask = *vd.mask; + if (data->mask_expand_use_normals) { + if (ss->filter_cache->normal_factor[SCULPT_active_vertex_get(ss)] < + ss->filter_cache->normal_factor[vd.index]) { + final_mask = 1.0f; + } + else { + final_mask = 0.0f; + } + } + else { + if (ss->filter_cache->mask_update_it[vi] <= update_it && + ss->filter_cache->mask_update_it[vi] != 0) { + final_mask = 1.0f; + } + else { + final_mask = 0.0f; + } + } + + if (data->mask_expand_create_face_set) { + if (final_mask == 1.0f) { + SCULPT_vertex_face_set_set(ss, vd.index, ss->filter_cache->new_face_set); + } + BKE_pbvh_node_mark_redraw(node); + } + else { + + if (data->mask_expand_keep_prev_mask) { + final_mask = MAX2(ss->filter_cache->prev_mask[vd.index], final_mask); + } + + if (data->mask_expand_invert_mask) { + final_mask = 1.0f - final_mask; + } + + if (*vd.mask != final_mask) { + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + *vd.mask = final_mask; + BKE_pbvh_node_mark_update_mask(node); + } + } + } + BKE_pbvh_vertex_iter_end; +} + +static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + ARegion *region = CTX_wm_region(C); + float prevclick_f[2]; + copy_v2_v2(prevclick_f, op->customdata); + int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]}; + int len = (int)len_v2v2_int(prevclick, event->mval); + len = abs(len); + int mask_speed = RNA_int_get(op->ptr, "mask_speed"); + int mask_expand_update_it = len / mask_speed; + mask_expand_update_it = mask_expand_update_it + 1; + + const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); + + if (RNA_boolean_get(op->ptr, "use_cursor")) { + SculptCursorGeometryInfo sgi; + float mouse[2]; + mouse[0] = event->mval[0]; + mouse[1] = event->mval[1]; + SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); + mask_expand_update_it = ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)]; + } + + if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || + (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { + /* Returning OPERATOR_CANCELLED will leak memory due to not finishing + * undo. Better solution could be to make paint_mesh_restore_co work + * for this case. */ + sculpt_mask_expand_cancel(C, op); + return OPERATOR_FINISHED; + } + + if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || + (event->type == EVT_RETKEY && event->val == KM_PRESS) || + (event->type == EVT_PADENTER && event->val == KM_PRESS)) { + + /* Smooth iterations. */ + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); + const int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations"); + SCULPT_mask_filter_smooth_apply(sd, ob, ss->filter_cache->nodes, ss->filter_cache->totnode, smooth_iterations); + + /* Pivot position. */ + if (RNA_boolean_get(op->ptr, "update_pivot")) { + const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; + const float threshold = 0.2f; + float avg[3]; + int total = 0; + zero_v3(avg); + + for (int n = 0; n < ss->filter_cache->totnode; n++) { + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, ss->filter_cache->nodes[n], vd, PBVH_ITER_UNIQUE) + { + const float mask = (vd.mask) ? *vd.mask : 0.0f; + if (mask < (0.5f + threshold) && mask > (0.5f - threshold)) { + if (SCULPT_check_vertex_pivot_symmetry( + vd.co, ss->filter_cache->mask_expand_initial_co, symm)) { + add_v3_v3(avg, vd.co); + total++; + } + } + } + BKE_pbvh_vertex_iter_end; + } + + if (total > 0) { + mul_v3_fl(avg, 1.0f / total); + copy_v3_v3(ss->pivot_pos, avg); + } + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); + } + + MEM_freeN(op->customdata); + + for (int i = 0; i < ss->filter_cache->totnode; i++) { + BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); + } + + SCULPT_filter_cache_free(ss); + + SCULPT_undo_push_end(); + SCULPT_flush_update_done(C, ob, SCULPT_UPDATE_MASK); + ED_workspace_status_text(C, NULL); + return OPERATOR_FINISHED; + } + + /* When pressing Ctrl, expand directly to the max number of iterations. This allows to flood fill + * mask and face sets by connectivity directly. */ + if (event->ctrl) { + mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1; + } + + if (!ELEM(event->type, MOUSEMOVE, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { + return OPERATOR_RUNNING_MODAL; + } + + if (mask_expand_update_it == ss->filter_cache->mask_update_current_it) { + ED_region_tag_redraw(region); + return OPERATOR_RUNNING_MODAL; + } + + if (mask_expand_update_it < ss->filter_cache->mask_update_last_it) { + + if (create_face_set) { + for (int i = 0; i < ss->totfaces; i++) { + ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; + } + } + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = ss->filter_cache->nodes, + .mask_expand_update_it = mask_expand_update_it, + .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"), + .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"), + .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"), + .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"), + }; + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); + BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings); + ss->filter_cache->mask_update_current_it = mask_expand_update_it; + } + + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); + + return OPERATOR_RUNNING_MODAL; +} + +typedef struct MaskExpandFloodFillData { + float original_normal[3]; + float edge_sensitivity; + bool use_normals; +} MaskExpandFloodFillData; + +static bool mask_expand_floodfill_cb( + SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata) +{ + MaskExpandFloodFillData *data = userdata; + + if (!is_duplicate) { + int to_it = ss->filter_cache->mask_update_it[from_v] + 1; + ss->filter_cache->mask_update_it[to_v] = to_it; + if (to_it > ss->filter_cache->mask_update_last_it) { + ss->filter_cache->mask_update_last_it = to_it; + } + + if (data->use_normals) { + float current_normal[3], prev_normal[3]; + SCULPT_vertex_normal_get(ss, to_v, current_normal); + SCULPT_vertex_normal_get(ss, from_v, prev_normal); + const float from_edge_factor = ss->filter_cache->edge_factor[from_v]; + ss->filter_cache->edge_factor[to_v] = dot_v3v3(current_normal, prev_normal) * + from_edge_factor; + ss->filter_cache->normal_factor[to_v] = dot_v3v3(data->original_normal, current_normal) * + powf(from_edge_factor, data->edge_sensitivity); + CLAMP(ss->filter_cache->normal_factor[to_v], 0.0f, 1.0f); + } + } + else { + /* PBVH_GRIDS duplicate handling. */ + ss->filter_cache->mask_update_it[to_v] = ss->filter_cache->mask_update_it[from_v]; + if (data->use_normals) { + ss->filter_cache->edge_factor[to_v] = ss->filter_cache->edge_factor[from_v]; + ss->filter_cache->normal_factor[to_v] = ss->filter_cache->normal_factor[from_v]; + } + } + + return true; +} + +static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + PBVH *pbvh = ob->sculpt->pbvh; + + const bool use_normals = RNA_boolean_get(op->ptr, "use_normals"); + const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); + + SculptCursorGeometryInfo sgi; + float mouse[2]; + mouse[0] = event->mval[0]; + mouse[1] = event->mval[1]; + + SCULPT_vertex_random_access_init(ss); + + op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position"); + copy_v2_v2(op->customdata, mouse); + + SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); + + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); + + int vertex_count = SCULPT_vertex_count_get(ss); + + ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode); + + SCULPT_undo_push_begin("Mask Expand"); + + if (create_face_set) { + SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS); + for (int i = 0; i < ss->filter_cache->totnode; i++) { + BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); + } + } + else { + for (int i = 0; i < ss->filter_cache->totnode; i++) { + SCULPT_undo_push_node(ob, ss->filter_cache->nodes[i], SCULPT_UNDO_MASK); + BKE_pbvh_node_mark_redraw(ss->filter_cache->nodes[i]); + } + } + + ss->filter_cache->mask_update_it = MEM_callocN(sizeof(int) * vertex_count, + "mask update iteration"); + if (use_normals) { + ss->filter_cache->normal_factor = MEM_callocN(sizeof(float) * vertex_count, + "mask update normal factor"); + ss->filter_cache->edge_factor = MEM_callocN(sizeof(float) * vertex_count, + "mask update normal factor"); + for (int i = 0; i < vertex_count; i++) { + ss->filter_cache->edge_factor[i] = 1.0f; + } + } + + if (create_face_set) { + ss->filter_cache->prev_face_set = MEM_callocN(sizeof(float) * ss->totfaces, "prev face mask"); + for (int i = 0; i < ss->totfaces; i++) { + ss->filter_cache->prev_face_set[i] = ss->face_sets[i]; + } + ss->filter_cache->new_face_set = SCULPT_face_set_next_available_get(ss); + } + else { + ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask"); + for (int i = 0; i < vertex_count; i++) { + ss->filter_cache->prev_mask[i] = SCULPT_vertex_mask_get(ss, i); + } + } + + ss->filter_cache->mask_update_last_it = 1; + ss->filter_cache->mask_update_current_it = 1; + ss->filter_cache->mask_update_it[SCULPT_active_vertex_get(ss)] = 0; + + copy_v3_v3(ss->filter_cache->mask_expand_initial_co, SCULPT_active_vertex_co_get(ss)); + + SculptFloodFill flood; + SCULPT_floodfill_init(ss, &flood); + SCULPT_floodfill_add_active(sd, ob, ss, &flood, FLT_MAX); + + MaskExpandFloodFillData fdata = { + .use_normals = use_normals, + .edge_sensitivity = RNA_int_get(op->ptr, "edge_sensitivity"), + }; + SCULPT_active_vertex_normal_get(ss, fdata.original_normal); + SCULPT_floodfill_execute(ss, &flood, mask_expand_floodfill_cb, &fdata); + SCULPT_floodfill_free(&flood); + + if (use_normals) { + for (int repeat = 0; repeat < 2; repeat++) { + for (int i = 0; i < vertex_count; i++) { + float avg = 0.0f; + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) { + avg += ss->filter_cache->normal_factor[ni.index]; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + ss->filter_cache->normal_factor[i] = avg / ni.size; + } + } + + MEM_SAFE_FREE(ss->filter_cache->edge_factor); + } + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = ss->filter_cache->nodes, + .mask_expand_update_it = 0, + .mask_expand_use_normals = RNA_boolean_get(op->ptr, "use_normals"), + .mask_expand_invert_mask = RNA_boolean_get(op->ptr, "invert"), + .mask_expand_keep_prev_mask = RNA_boolean_get(op->ptr, "keep_previous_mask"), + .mask_expand_create_face_set = RNA_boolean_get(op->ptr, "create_face_set"), + }; + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings( + &settings, (sd->flags & SCULPT_USE_OPENMP), ss->filter_cache->totnode); + BKE_pbvh_parallel_range(0, ss->filter_cache->totnode, &data, sculpt_expand_task_cb, &settings); + + const char *status_str = TIP_( + "Move the mouse to expand the mask from the active vertex. LMB: confirm mask, ESC/RMB: " + "cancel"); + ED_workspace_status_text(C, status_str); + + SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK); + WM_event_add_modal_handler(C, op); + return OPERATOR_RUNNING_MODAL; +} + +void SCULPT_OT_mask_expand(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Mask Expand"; + ot->idname = "SCULPT_OT_mask_expand"; + ot->description = "Expands a mask from the initial active vertex under the cursor"; + + /* API callbacks. */ + ot->invoke = sculpt_mask_expand_invoke; + ot->modal = sculpt_mask_expand_modal; + ot->cancel = sculpt_mask_expand_cancel; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->prop = RNA_def_boolean(ot->srna, "invert", true, "Invert", "Invert the new mask"); + ot->prop = RNA_def_boolean( + ot->srna, "use_cursor", true, "Use Cursor", "Expand the mask to the cursor position"); + ot->prop = RNA_def_boolean(ot->srna, + "update_pivot", + true, + "Update Pivot Position", + "Set the pivot position to the mask border after creating the mask"); + ot->prop = RNA_def_int(ot->srna, "smooth_iterations", 2, 0, 10, "Smooth iterations", "", 0, 10); + ot->prop = RNA_def_int(ot->srna, "mask_speed", 5, 1, 10, "Mask speed", "", 1, 10); + + ot->prop = RNA_def_boolean(ot->srna, + "use_normals", + true, + "Use Normals", + "Generate the mask using the normals and curvature of the model"); + ot->prop = RNA_def_boolean(ot->srna, + "keep_previous_mask", + false, + "Keep Previous Mask", + "Generate the new mask on top of the current one"); + ot->prop = RNA_def_int(ot->srna, + "edge_sensitivity", + 300, + 0, + 2000, + "Edge Detection Sensitivity", + "Sensitivity for expanding the mask across sculpted sharp edges when " + "using normals to generate the mask", + 0, + 2000); + ot->prop = RNA_def_boolean(ot->srna, + "create_face_set", + false, + "Expand Face Mask", + "Expand a new Face Mask instead of the sculpt mask"); +} diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c index 0f629320333..de3211abe08 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.c +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c @@ -62,8 +62,6 @@ #include #include - - /* For the smooth brush, uses the neighboring vertices around vert to calculate * a smoothed location for vert. Skips corner vertices (used by only one * polygon). */ @@ -185,7 +183,8 @@ void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert } } -/* Generic functions for laplacian smoothing. These functions do not take boundary vertices into account. */ +/* Generic functions for laplacian smoothing. These functions do not take boundary vertices into + * account. */ void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index) { @@ -498,9 +497,8 @@ void SCULPT_surface_smooth_displace_step(SculptSession *ss, } } -static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) +static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex( + void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -528,21 +526,20 @@ static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(void *__restrict float disp[3]; SCULPT_surface_smooth_laplacian_step(ss, - disp, - vd.co, - ss->cache->surface_smooth_laplacian_disp, - vd.index, - orig_data.co, - alpha); + disp, + vd.co, + ss->cache->surface_smooth_laplacian_disp, + vd.index, + orig_data.co, + alpha); madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); } BKE_pbvh_vertex_iter_end; } } -static void SCULPT_do_surface_smooth_brush_displace_task_cb_ex(void *__restrict userdata, - const int n, - const TaskParallelTLS *__restrict tls) +static void SCULPT_do_surface_smooth_brush_displace_task_cb_ex( + void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -599,5 +596,3 @@ void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in 0, totnode, &data, SCULPT_do_surface_smooth_brush_displace_task_cb_ex, &settings); } } - - -- cgit v1.2.3 From 7c0e285948408c39902b3349e3da9a2fbc1e2fc2 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 3 Apr 2020 23:41:54 +0200 Subject: Cleanup: Move Detail Operators and Dyntopo to their own files --- source/blender/editors/sculpt_paint/CMakeLists.txt | 2 + source/blender/editors/sculpt_paint/sculpt.c | 772 +-------------------- .../blender/editors/sculpt_paint/sculpt_detail.c | 428 ++++++++++++ .../blender/editors/sculpt_paint/sculpt_dyntopo.c | 443 ++++++++++++ .../editors/sculpt_paint/sculpt_filter_mask.c | 27 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 44 +- .../editors/sculpt_paint/sculpt_mask_expand.c | 4 +- source/blender/editors/sculpt_paint/sculpt_undo.c | 12 +- 8 files changed, 954 insertions(+), 778 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_detail.c create mode 100644 source/blender/editors/sculpt_paint/sculpt_dyntopo.c diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index f9858804394..b8754953741 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -61,6 +61,8 @@ set(SRC sculpt.c sculpt_automasking.c sculpt_cloth.c + sculpt_detail.c + sculpt_dyntopo.c sculpt_face_set.c sculpt_filter_mask.c sculpt_filter_mesh.c diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 5bd0f3f2f48..b304a476dec 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2585,15 +2585,6 @@ typedef struct { struct IsectRayPrecalc isect_precalc; } SculptRaycastData; -typedef struct { - const float *ray_start; - bool hit; - float depth; - float edge_length; - - struct IsectRayPrecalc isect_precalc; -} SculptDetailRaycastData; - typedef struct { SculptSession *ss; const float *ray_start, *ray_normal; @@ -6495,7 +6486,7 @@ static bool sculpt_needs_connectivity_info(const Sculpt *sd, (brush->sculpt_tool == SCULPT_TOOL_DRAW_FACE_SETS)); } -static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush) +void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush) { SculptSession *ss = ob->sculpt; View3D *v3d = CTX_wm_view3d(C); @@ -6578,24 +6569,12 @@ static void sculpt_find_nearest_to_ray_cb(PBVHNode *node, void *data_v, float *t } } -static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin) -{ - if (BKE_pbvh_node_get_tmin(node) < *tmin) { - SculptDetailRaycastData *srd = data_v; - if (BKE_pbvh_bmesh_node_raycast_detail( - node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) { - srd->hit = true; - *tmin = srd->depth; - } - } -} - -static float sculpt_raycast_init(ViewContext *vc, - const float mouse[2], - float ray_start[3], - float ray_end[3], - float ray_normal[3], - bool original) +float SCULPT_raycast_init(ViewContext *vc, + const float mouse[2], + float ray_start[3], + float ray_end[3], + float ray_normal[3], + bool original) { float obimat[4][4]; float dist; @@ -6661,8 +6640,8 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, } /* PBVH raycast to get active vertex and face normal. */ - depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original); - sculpt_stroke_modifiers_check(C, ob, brush); + depth = SCULPT_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original); + SCULPT_stroke_modifiers_check(C, ob, brush); SculptRaycastData srd = { .original = original, @@ -6781,9 +6760,9 @@ bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mouse[2]) const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); - sculpt_stroke_modifiers_check(C, ob, brush); + SCULPT_stroke_modifiers_check(C, ob, brush); - depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original); + depth = SCULPT_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original); if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { BM_mesh_elem_table_ensure(ss->bm, BM_VERT); @@ -7075,7 +7054,7 @@ static void sculpt_stroke_update_step(bContext *C, SculptSession *ss = ob->sculpt; const Brush *brush = BKE_paint_brush(&sd->paint); - sculpt_stroke_modifiers_check(C, ob, brush); + SCULPT_stroke_modifiers_check(C, ob, brush); sculpt_update_cache_variants(C, sd, ob, itemptr); sculpt_restore_mesh(sd, ob); @@ -7156,7 +7135,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str BLI_assert(brush == ss->cache->brush); /* const, so we shouldn't change. */ ups->draw_inverted = false; - sculpt_stroke_modifiers_check(C, ob, brush); + SCULPT_stroke_modifiers_check(C, ob, brush); /* Alt-Smooth. */ if (ss->cache->alt_smooth) { @@ -7337,401 +7316,18 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/************************** Dynamic Topology **************************/ - -static void sculpt_dynamic_topology_triangulate(BMesh *bm) -{ - if (bm->totloop != bm->totface * 3) { - BM_mesh_triangulate( - bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, 4, false, NULL, NULL, NULL); - } -} - -void sculpt_pbvh_clear(Object *ob) -{ - SculptSession *ss = ob->sculpt; - - /* Clear out any existing DM and PBVH. */ - if (ss->pbvh) { - BKE_pbvh_free(ss->pbvh); - ss->pbvh = NULL; - } - - if (ss->pmap) { - MEM_freeN(ss->pmap); - ss->pmap = NULL; - } - - if (ss->pmap_mem) { - MEM_freeN(ss->pmap_mem); - ss->pmap_mem = NULL; - } - - BKE_object_free_derived_caches(ob); - - /* Tag to rebuild PBVH in depsgraph. */ - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); -} - -void sculpt_dyntopo_node_layers_add(SculptSession *ss) -{ - int cd_node_layer_index; - - char layer_id[] = "_dyntopo_node_id"; - - cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id); - if (cd_node_layer_index == -1) { - BM_data_layer_add_named(ss->bm, &ss->bm->vdata, CD_PROP_INT, layer_id); - cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id); - } - - ss->cd_vert_node_offset = CustomData_get_n_offset( - &ss->bm->vdata, - CD_PROP_INT, - cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT)); - - ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY; - - cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id); - if (cd_node_layer_index == -1) { - BM_data_layer_add_named(ss->bm, &ss->bm->pdata, CD_PROP_INT, layer_id); - cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id); - } - - ss->cd_face_node_offset = CustomData_get_n_offset( - &ss->bm->pdata, - CD_PROP_INT, - cd_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT)); - - ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY; -} - -static void sculpt_dynamic_topology_enable_ex(Main *bmain, - Depsgraph *depsgraph, - Scene *scene, - Object *ob) -{ - SculptSession *ss = ob->sculpt; - Mesh *me = ob->data; - const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me); - - sculpt_pbvh_clear(ob); - - ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING) != - 0; - - /* Dynamic topology doesn't ensure selection state is valid, so remove [#36280]. */ - BKE_mesh_mselect_clear(me); - - /* Create triangles-only BMesh. */ - ss->bm = BM_mesh_create(&allocsize, - &((struct BMeshCreateParams){ - .use_toolflags = false, - })); - - BM_mesh_bm_from_me(ss->bm, - me, - (&(struct BMeshFromMeshParams){ - .calc_face_normal = true, - .use_shapekey = true, - .active_shapekey = ob->shapenr, - })); - sculpt_dynamic_topology_triangulate(ss->bm); - BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK); - sculpt_dyntopo_node_layers_add(ss); - /* Make sure the data for existing faces are initialized. */ - if (me->totpoly != ss->bm->totface) { - BM_mesh_normals_update(ss->bm); - } - - /* Enable dynamic topology. */ - me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; - - /* Enable logging for undo/redo. */ - ss->bm_log = BM_log_create(ss->bm); - - /* Update dependency graph, so modifiers that depend on dyntopo being enabled - * are re-evaluated and the PBVH is re-created. */ - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - BKE_scene_graph_update_tagged(depsgraph, bmain); -} - -/* Free the sculpt BMesh and BMLog - * - * If 'unode' is given, the BMesh's data is copied out to the unode - * before the BMesh is deleted so that it can be restored from. */ -static void sculpt_dynamic_topology_disable_ex( - Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode) -{ - SculptSession *ss = ob->sculpt; - Mesh *me = ob->data; - - sculpt_pbvh_clear(ob); - - if (unode) { - /* Free all existing custom data. */ - 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); - - /* Copy over stored custom data. */ - SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter; - me->totvert = geometry->totvert; - me->totloop = geometry->totloop; - me->totpoly = geometry->totpoly; - me->totedge = geometry->totedge; - me->totface = 0; - CustomData_copy( - &geometry->vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert); - CustomData_copy( - &geometry->edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge); - CustomData_copy( - &geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop); - CustomData_copy( - &geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly); - - BKE_mesh_update_customdata_pointers(me, false); - } - else { - BKE_sculptsession_bm_to_me(ob, true); - - /* Reset Face Sets as they are no longer valid. */ - if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { - CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); - } - ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); - for (int i = 0; i < me->totpoly; i++) { - ss->face_sets[i] = 1; - } - me->face_sets_color_default = 1; - - /* Sync the visibility to vertices manually as the pmap is still not initialized. */ - for (int i = 0; i < me->totvert; i++) { - me->mvert[i].flag &= ~ME_HIDE; - me->mvert[i].flag |= ME_VERT_PBVH_UPDATE; - } - } - - /* Clear data. */ - me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; - - /* Typically valid but with global-undo they can be NULL. [#36234] */ - if (ss->bm) { - BM_mesh_free(ss->bm); - ss->bm = NULL; - } - if (ss->bm_log) { - BM_log_free(ss->bm_log); - ss->bm_log = NULL; - } - - BKE_particlesystem_reset_all(ob); - BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED); - - /* Update dependency graph, so modifiers that depend on dyntopo being enabled - * are re-evaluated and the PBVH is re-created. */ - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - BKE_scene_graph_update_tagged(depsgraph, bmain); -} - -void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) -{ - Main *bmain = CTX_data_main(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); -} - -static void sculpt_dynamic_topology_disable_with_undo(Main *bmain, - Depsgraph *depsgraph, - Scene *scene, - Object *ob) -{ - SculptSession *ss = ob->sculpt; - if (ss->bm) { - SCULPT_undo_push_begin("Dynamic topology disable"); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); - sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); - SCULPT_undo_push_end(); - } -} - -static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, - Depsgraph *depsgraph, - Scene *scene, - Object *ob) -{ - SculptSession *ss = ob->sculpt; - if (ss->bm == NULL) { - SCULPT_undo_push_begin("Dynamic topology enable"); - sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); - SCULPT_undo_push_end(); - } -} - -static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Main *bmain = CTX_data_main(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; - - WM_cursor_wait(true); - - if (ss->bm) { - sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); - } - else { - sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob); - } - - WM_cursor_wait(false); - WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); - - return OPERATOR_FINISHED; -} - -enum eDynTopoWarnFlag { - DYNTOPO_WARN_VDATA = (1 << 0), - DYNTOPO_WARN_EDATA = (1 << 1), - DYNTOPO_WARN_LDATA = (1 << 2), - DYNTOPO_WARN_MODIFIER = (1 << 3), -}; - -static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag) -{ - uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Warning!"), ICON_ERROR); - uiLayout *layout = UI_popup_menu_layout(pup); - - if (flag & (DYNTOPO_WARN_VDATA | DYNTOPO_WARN_EDATA | DYNTOPO_WARN_LDATA)) { - const char *msg_error = TIP_("Vertex Data Detected!"); - const char *msg = TIP_("Dyntopo will not preserve vertex colors, UVs, or other customdata"); - uiItemL(layout, msg_error, ICON_INFO); - uiItemL(layout, msg, ICON_NONE); - uiItemS(layout); - } - - if (flag & DYNTOPO_WARN_MODIFIER) { - const char *msg_error = TIP_("Generative Modifiers Detected!"); - const char *msg = TIP_( - "Keeping the modifiers will increase polycount when returning to object mode"); - - uiItemL(layout, msg_error, ICON_INFO); - uiItemL(layout, msg, ICON_NONE); - uiItemS(layout); - } - - uiItemFullO_ptr(layout, ot, IFACE_("OK"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, NULL); - - UI_popup_menu_end(C, pup); - - return OPERATOR_INTERFACE; -} - -static enum eDynTopoWarnFlag sculpt_dynamic_topology_check(Scene *scene, Object *ob) -{ - Mesh *me = ob->data; - SculptSession *ss = ob->sculpt; - - enum eDynTopoWarnFlag flag = 0; - - BLI_assert(ss->bm == NULL); - UNUSED_VARS_NDEBUG(ss); - - for (int i = 0; i < CD_NUMTYPES; i++) { - if (!ELEM(i, CD_MVERT, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) { - if (CustomData_has_layer(&me->vdata, i)) { - flag |= DYNTOPO_WARN_VDATA; - } - if (CustomData_has_layer(&me->edata, i)) { - flag |= DYNTOPO_WARN_EDATA; - } - if (CustomData_has_layer(&me->ldata, i)) { - flag |= DYNTOPO_WARN_LDATA; - } - } - } - - { - VirtualModifierData virtualModifierData; - ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData); - - /* Exception for shape keys because we can edit those. */ - for (; md; md = md->next) { - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) { - continue; - } - - if (mti->type == eModifierTypeType_Constructive) { - flag |= DYNTOPO_WARN_MODIFIER; - break; - } - } - } - - return flag; -} - -static int sculpt_dynamic_topology_toggle_invoke(bContext *C, - wmOperator *op, - const wmEvent *UNUSED(event)) -{ - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - - if (!ss->bm) { - Scene *scene = CTX_data_scene(C); - enum eDynTopoWarnFlag flag = sculpt_dynamic_topology_check(scene, ob); - - if (flag) { - /* The mesh has customdata that will be lost, let the user confirm this is OK. */ - return dyntopo_warning_popup(C, op->type, flag); - } - } - - return sculpt_dynamic_topology_toggle_exec(C, op); -} - -static void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Dynamic Topology Toggle"; - ot->idname = "SCULPT_OT_dynamic_topology_toggle"; - ot->description = "Dynamic topology alters the mesh topology while sculpting"; - - /* API callbacks. */ - ot->invoke = sculpt_dynamic_topology_toggle_invoke; - ot->exec = sculpt_dynamic_topology_toggle_exec; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - /************************* SCULPT_OT_optimize *************************/ static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); - sculpt_pbvh_clear(ob); + SCULPT_pbvh_clear(ob); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } -static bool sculpt_and_dynamic_topology_poll(bContext *C) -{ - Object *ob = CTX_data_active_object(C); - - return SCULPT_mode_poll(C) && ob->sculpt->bm; -} - /* The BVH gets less optimal more quickly with dynamic topology than * regular sculpting. There is no doubt more clever stuff we can do to * optimize it on the fly, but for now this gives the user a nicer way @@ -7792,7 +7388,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op)) "symmetrize input=%avef direction=%i dist=%f", sd->symmetrize_direction, 0.00001f); - sculpt_dynamic_topology_triangulate(ss->bm); + SCULPT_dynamic_topology_triangulate(ss->bm); /* Bisect operator flags edges (keep tags clean for edge queue). */ BM_mesh_elem_hflag_disable_all(ss->bm, BM_EDGE, BM_ELEM_TAG, false); @@ -7853,7 +7449,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op)) } /* Redraw. */ - sculpt_pbvh_clear(ob); + SCULPT_pbvh_clear(ob); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; @@ -7959,7 +7555,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, message_unsupported = TIP_("multi-res modifier"); } else { - enum eDynTopoWarnFlag flag = sculpt_dynamic_topology_check(scene, ob); + enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob); if (flag == 0) { /* pass */ } @@ -7988,7 +7584,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, if (has_undo) { SCULPT_undo_push_begin("Dynamic topology enable"); } - sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); + SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); if (has_undo) { SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); SCULPT_undo_push_end(); @@ -8131,338 +7727,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) -{ - Object *ob = CTX_data_active_object(C); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - - return SCULPT_mode_poll(C) && ob->sculpt->bm && - (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)); -} - -static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Object *ob = CTX_data_active_object(C); - SculptSession *ss = ob->sculpt; - float size; - float bb_min[3], bb_max[3], center[3], dim[3]; - int totnodes; - PBVHNode **nodes; - - BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes); - - if (!totnodes) { - return OPERATOR_CANCELLED; - } - - for (int i = 0; i < totnodes; i++) { - BKE_pbvh_node_mark_topology_update(nodes[i]); - } - /* Get the bounding box, it's center and size. */ - BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max); - add_v3_v3v3(center, bb_min, bb_max); - mul_v3_fl(center, 0.5f); - sub_v3_v3v3(dim, bb_max, bb_min); - size = max_fff(dim[0], dim[1], dim[2]); - - /* Update topology size. */ - float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat)); - BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); - - SCULPT_undo_push_begin("Dynamic topology flood fill"); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS); - - while (BKE_pbvh_bmesh_update_topology( - ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) { - for (int i = 0; i < totnodes; i++) { - BKE_pbvh_node_mark_topology_update(nodes[i]); - } - } - - MEM_SAFE_FREE(nodes); - SCULPT_undo_push_end(); - - /* Force rebuild of pbvh for better BB placement. */ - sculpt_pbvh_clear(ob); - /* Redraw. */ - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_detail_flood_fill(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Detail Flood Fill"; - ot->idname = "SCULPT_OT_detail_flood_fill"; - ot->description = "Flood fill the mesh with the selected detail setting"; - - /* API callbacks. */ - ot->exec = sculpt_detail_flood_fill_exec; - ot->poll = sculpt_and_constant_or_manual_detail_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -typedef enum eSculptSampleDetailModeTypes { - SAMPLE_DETAIL_DYNTOPO = 0, - SAMPLE_DETAIL_VOXEL = 1, -} eSculptSampleDetailModeTypes; - -static EnumPropertyItem prop_sculpt_sample_detail_mode_types[] = { - {SAMPLE_DETAIL_DYNTOPO, "DYNTOPO", 0, "Dyntopo", "Sample dyntopo detail"}, - {SAMPLE_DETAIL_VOXEL, "VOXEL", 0, "Voxel", "Sample mesh voxel size"}, - {0, NULL, 0, NULL, NULL}, -}; - -static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my) -{ - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); - Object *ob = vc->obact; - Mesh *mesh = ob->data; - - SculptSession *ss = ob->sculpt; - SculptCursorGeometryInfo sgi; - SCULPT_vertex_random_access_init(ss); - - /* Update the active vertex. */ - float mouse[2] = {mx, my}; - SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); - BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); - - /* Average the edge length of the connected edges to the active vertex. */ - int active_vertex = SCULPT_active_vertex_get(ss); - const float *active_vertex_co = SCULPT_active_vertex_co_get(ss); - float edge_length = 0.0f; - int tot = 0; - SculptVertexNeighborIter ni; - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, active_vertex, ni) { - edge_length += len_v3v3(active_vertex_co, SCULPT_vertex_co_get(ss, ni.index)); - tot += 1; - } - SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); - if (tot > 0) { - mesh->remesh_voxel_size = edge_length / (float)tot; - } -} - -static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region, int mx, int my) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Object *ob = vc->obact; - Brush *brush = BKE_paint_brush(&sd->paint); - - sculpt_stroke_modifiers_check(C, ob, brush); - - float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; - float ray_start[3], ray_end[3], ray_normal[3]; - float depth = sculpt_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false); - - SculptDetailRaycastData srd; - srd.hit = 0; - srd.ray_start = ray_start; - srd.depth = depth; - srd.edge_length = 0.0f; - isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal); - - BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd, ray_start, ray_normal, false); - - if (srd.hit && srd.edge_length > 0.0f) { - /* Convert edge length to world space detail resolution. */ - sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->obmat)); - } -} - -static int sample_detail(bContext *C, int mx, int my, int mode) -{ - /* Find 3D view to pick from. */ - bScreen *screen = CTX_wm_screen(C); - ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my); - ARegion *region = (area) ? BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my) : NULL; - if (region == NULL) { - return OPERATOR_CANCELLED; - } - - /* Set context to 3D view. */ - ScrArea *prev_area = CTX_wm_area(C); - ARegion *prev_region = CTX_wm_region(C); - CTX_wm_area_set(C, area); - CTX_wm_region_set(C, region); - - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ViewContext vc; - ED_view3d_viewcontext_init(C, &vc, depsgraph); - - Object *ob = vc.obact; - SculptSession *ss = ob->sculpt; - - if (!ss->pbvh) { - return OPERATOR_CANCELLED; - } - - /* Pick sample detail. */ - switch (mode) { - case SAMPLE_DETAIL_DYNTOPO: - if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) { - CTX_wm_area_set(C, prev_area); - CTX_wm_region_set(C, prev_region); - return OPERATOR_CANCELLED; - } - sample_detail_dyntopo(C, &vc, region, mx, my); - break; - case SAMPLE_DETAIL_VOXEL: - if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { - CTX_wm_area_set(C, prev_area); - CTX_wm_region_set(C, prev_region); - return OPERATOR_CANCELLED; - } - sample_detail_voxel(C, &vc, mx, my); - break; - } - - /* Restore context. */ - CTX_wm_area_set(C, prev_area); - CTX_wm_region_set(C, prev_region); - - return OPERATOR_FINISHED; -} - -static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op) -{ - int ss_co[2]; - RNA_int_get_array(op->ptr, "location", ss_co); - int mode = RNA_enum_get(op->ptr, "mode"); - return sample_detail(C, ss_co[0], ss_co[1], mode); -} - -static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e)) -{ - ED_workspace_status_text(C, TIP_("Click on the mesh to set the detail")); - WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EYEDROPPER); - WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; -} - -static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - switch (event->type) { - case LEFTMOUSE: - if (event->val == KM_PRESS) { - int ss_co[2] = {event->x, event->y}; - - int mode = RNA_enum_get(op->ptr, "mode"); - sample_detail(C, ss_co[0], ss_co[1], mode); - - RNA_int_set_array(op->ptr, "location", ss_co); - WM_cursor_modal_restore(CTX_wm_window(C)); - ED_workspace_status_text(C, NULL); - WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); - - return OPERATOR_FINISHED; - } - break; - - case RIGHTMOUSE: { - WM_cursor_modal_restore(CTX_wm_window(C)); - ED_workspace_status_text(C, NULL); - - return OPERATOR_CANCELLED; - } - } - - return OPERATOR_RUNNING_MODAL; -} - -static void SCULPT_OT_sample_detail_size(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Sample Detail Size"; - ot->idname = "SCULPT_OT_sample_detail_size"; - ot->description = "Sample the mesh detail on clicked point"; - - /* API callbacks. */ - ot->invoke = sculpt_sample_detail_size_invoke; - ot->exec = sculpt_sample_detail_size_exec; - ot->modal = sculpt_sample_detail_size_modal; - ot->poll = SCULPT_mode_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - RNA_def_int_array(ot->srna, - "location", - 2, - NULL, - 0, - SHRT_MAX, - "Location", - "Screen Coordinates of sampling", - 0, - SHRT_MAX); - RNA_def_enum(ot->srna, - "mode", - prop_sculpt_sample_detail_mode_types, - SAMPLE_DETAIL_DYNTOPO, - "Detail Mode", - "Target sculpting workflow that is going to use the sampled size"); -} - -/* Dynamic-topology detail size. - * - * This should be improved further, perhaps by showing a triangle - * grid rather than brush alpha. */ -static void set_brush_rc_props(PointerRNA *ptr, const char *prop) -{ - char *path = BLI_sprintfN("tool_settings.sculpt.brush.%s", prop); - RNA_string_set(ptr, "data_path_primary", path); - MEM_freeN(path); -} - -static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - - PointerRNA props_ptr; - wmOperatorType *ot = WM_operatortype_find("WM_OT_radial_control", true); - - WM_operator_properties_create_ptr(&props_ptr, ot); - - if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { - set_brush_rc_props(&props_ptr, "constant_detail_resolution"); - RNA_string_set( - &props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution"); - } - else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) { - set_brush_rc_props(&props_ptr, "constant_detail_resolution"); - RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_percent"); - } - else { - set_brush_rc_props(&props_ptr, "detail_size"); - RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size"); - } - - WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); - - WM_operator_properties_free(&props_ptr); - - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_set_detail_size(wmOperatorType *ot) -{ - /* Identifiers. */ - ot->name = "Set Detail Size"; - ot->idname = "SCULPT_OT_set_detail_size"; - ot->description = - "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)"; - - /* API callbacks. */ - ot->exec = sculpt_set_detail_size_exec; - ot->poll = sculpt_and_dynamic_topology_poll; - - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float radius) { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c new file mode 100644 index 00000000000..a99aa3d1bcf --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_detail.c @@ -0,0 +1,428 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "BLT_translation.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_scene.h" +#include "BKE_screen.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "ED_view3d.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" + +#include "bmesh.h" + +#include +#include + +typedef struct { + const float *ray_start; + bool hit; + float depth; + float edge_length; + + struct IsectRayPrecalc isect_precalc; +} SculptDetailRaycastData; + +static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + return SCULPT_mode_poll(C) && ob->sculpt->bm && + (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)); +} + +static bool sculpt_and_dynamic_topology_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return SCULPT_mode_poll(C) && ob->sculpt->bm; +} + +static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + float size; + float bb_min[3], bb_max[3], center[3], dim[3]; + int totnodes; + PBVHNode **nodes; + + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes); + + if (!totnodes) { + return OPERATOR_CANCELLED; + } + + for (int i = 0; i < totnodes; i++) { + BKE_pbvh_node_mark_topology_update(nodes[i]); + } + /* Get the bounding box, it's center and size. */ + BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max); + add_v3_v3v3(center, bb_min, bb_max); + mul_v3_fl(center, 0.5f); + sub_v3_v3v3(dim, bb_max, bb_min); + size = max_fff(dim[0], dim[1], dim[2]); + + /* Update topology size. */ + float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat)); + BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); + + SCULPT_undo_push_begin("Dynamic topology flood fill"); + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS); + + while (BKE_pbvh_bmesh_update_topology( + ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) { + for (int i = 0; i < totnodes; i++) { + BKE_pbvh_node_mark_topology_update(nodes[i]); + } + } + + MEM_SAFE_FREE(nodes); + SCULPT_undo_push_end(); + + /* Force rebuild of pbvh for better BB placement. */ + SCULPT_pbvh_clear(ob); + /* Redraw. */ + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_detail_flood_fill(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Detail Flood Fill"; + ot->idname = "SCULPT_OT_detail_flood_fill"; + ot->description = "Flood fill the mesh with the selected detail setting"; + + /* API callbacks. */ + ot->exec = sculpt_detail_flood_fill_exec; + ot->poll = sculpt_and_constant_or_manual_detail_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +typedef enum eSculptSampleDetailModeTypes { + SAMPLE_DETAIL_DYNTOPO = 0, + SAMPLE_DETAIL_VOXEL = 1, +} eSculptSampleDetailModeTypes; + +static EnumPropertyItem prop_sculpt_sample_detail_mode_types[] = { + {SAMPLE_DETAIL_DYNTOPO, "DYNTOPO", 0, "Dyntopo", "Sample dyntopo detail"}, + {SAMPLE_DETAIL_VOXEL, "VOXEL", 0, "Voxel", "Sample mesh voxel size"}, + {0, NULL, 0, NULL, NULL}, +}; + +static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my) +{ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Object *ob = vc->obact; + Mesh *mesh = ob->data; + + SculptSession *ss = ob->sculpt; + SculptCursorGeometryInfo sgi; + SCULPT_vertex_random_access_init(ss); + + /* Update the active vertex. */ + float mouse[2] = {mx, my}; + SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); + + /* Average the edge length of the connected edges to the active vertex. */ + int active_vertex = SCULPT_active_vertex_get(ss); + const float *active_vertex_co = SCULPT_active_vertex_co_get(ss); + float edge_length = 0.0f; + int tot = 0; + SculptVertexNeighborIter ni; + SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, active_vertex, ni) { + edge_length += len_v3v3(active_vertex_co, SCULPT_vertex_co_get(ss, ni.index)); + tot += 1; + } + SCULPT_VERTEX_NEIGHBORS_ITER_END(ni); + if (tot > 0) { + mesh->remesh_voxel_size = edge_length / (float)tot; + } +} + +static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin) +{ + if (BKE_pbvh_node_get_tmin(node) < *tmin) { + SculptDetailRaycastData *srd = data_v; + if (BKE_pbvh_bmesh_node_raycast_detail( + node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) { + srd->hit = true; + *tmin = srd->depth; + } + } +} + +static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region, int mx, int my) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = vc->obact; + Brush *brush = BKE_paint_brush(&sd->paint); + + SCULPT_stroke_modifiers_check(C, ob, brush); + + float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + float ray_start[3], ray_end[3], ray_normal[3]; + float depth = SCULPT_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false); + + SculptDetailRaycastData srd; + srd.hit = 0; + srd.ray_start = ray_start; + srd.depth = depth; + srd.edge_length = 0.0f; + isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal); + + BKE_pbvh_raycast(ob->sculpt->pbvh, sculpt_raycast_detail_cb, &srd, ray_start, ray_normal, false); + + if (srd.hit && srd.edge_length > 0.0f) { + /* Convert edge length to world space detail resolution. */ + sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->obmat)); + } +} + +static int sample_detail(bContext *C, int mx, int my, int mode) +{ + /* Find 3D view to pick from. */ + bScreen *screen = CTX_wm_screen(C); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my); + ARegion *region = (area) ? BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my) : NULL; + if (region == NULL) { + return OPERATOR_CANCELLED; + } + + /* Set context to 3D view. */ + ScrArea *prev_area = CTX_wm_area(C); + ARegion *prev_region = CTX_wm_region(C); + CTX_wm_area_set(C, area); + CTX_wm_region_set(C, region); + + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + ViewContext vc; + ED_view3d_viewcontext_init(C, &vc, depsgraph); + + Object *ob = vc.obact; + SculptSession *ss = ob->sculpt; + + if (!ss->pbvh) { + return OPERATOR_CANCELLED; + } + + /* Pick sample detail. */ + switch (mode) { + case SAMPLE_DETAIL_DYNTOPO: + if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) { + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + return OPERATOR_CANCELLED; + } + sample_detail_dyntopo(C, &vc, region, mx, my); + break; + case SAMPLE_DETAIL_VOXEL: + if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) { + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + return OPERATOR_CANCELLED; + } + sample_detail_voxel(C, &vc, mx, my); + break; + } + + /* Restore context. */ + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + + return OPERATOR_FINISHED; +} + +static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op) +{ + int ss_co[2]; + RNA_int_get_array(op->ptr, "location", ss_co); + int mode = RNA_enum_get(op->ptr, "mode"); + return sample_detail(C, ss_co[0], ss_co[1], mode); +} + +static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e)) +{ + ED_workspace_status_text(C, TIP_("Click on the mesh to set the detail")); + WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EYEDROPPER); + WM_event_add_modal_handler(C, op); + return OPERATOR_RUNNING_MODAL; +} + +static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + switch (event->type) { + case LEFTMOUSE: + if (event->val == KM_PRESS) { + int ss_co[2] = {event->x, event->y}; + + int mode = RNA_enum_get(op->ptr, "mode"); + sample_detail(C, ss_co[0], ss_co[1], mode); + + RNA_int_set_array(op->ptr, "location", ss_co); + WM_cursor_modal_restore(CTX_wm_window(C)); + ED_workspace_status_text(C, NULL); + WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); + + return OPERATOR_FINISHED; + } + break; + + case RIGHTMOUSE: { + WM_cursor_modal_restore(CTX_wm_window(C)); + ED_workspace_status_text(C, NULL); + + return OPERATOR_CANCELLED; + } + } + + return OPERATOR_RUNNING_MODAL; +} + +void SCULPT_OT_sample_detail_size(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Sample Detail Size"; + ot->idname = "SCULPT_OT_sample_detail_size"; + ot->description = "Sample the mesh detail on clicked point"; + + /* API callbacks. */ + ot->invoke = sculpt_sample_detail_size_invoke; + ot->exec = sculpt_sample_detail_size_exec; + ot->modal = sculpt_sample_detail_size_modal; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_int_array(ot->srna, + "location", + 2, + NULL, + 0, + SHRT_MAX, + "Location", + "Screen Coordinates of sampling", + 0, + SHRT_MAX); + RNA_def_enum(ot->srna, + "mode", + prop_sculpt_sample_detail_mode_types, + SAMPLE_DETAIL_DYNTOPO, + "Detail Mode", + "Target sculpting workflow that is going to use the sampled size"); +} + +/* Dynamic-topology detail size. + * + * This should be improved further, perhaps by showing a triangle + * grid rather than brush alpha. */ +static void set_brush_rc_props(PointerRNA *ptr, const char *prop) +{ + char *path = BLI_sprintfN("tool_settings.sculpt.brush.%s", prop); + RNA_string_set(ptr, "data_path_primary", path); + MEM_freeN(path); +} + +static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + PointerRNA props_ptr; + wmOperatorType *ot = WM_operatortype_find("WM_OT_radial_control", true); + + WM_operator_properties_create_ptr(&props_ptr, ot); + + if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { + set_brush_rc_props(&props_ptr, "constant_detail_resolution"); + RNA_string_set( + &props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail_resolution"); + } + else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) { + set_brush_rc_props(&props_ptr, "constant_detail_resolution"); + RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_percent"); + } + else { + set_brush_rc_props(&props_ptr, "detail_size"); + RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size"); + } + + WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); + + WM_operator_properties_free(&props_ptr); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_set_detail_size(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Set Detail Size"; + ot->idname = "SCULPT_OT_set_detail_size"; + ot->description = + "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)"; + + /* API callbacks. */ + ot->exec = sculpt_set_detail_size_exec; + ot->poll = sculpt_and_dynamic_topology_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c new file mode 100644 index 00000000000..5f75c1d6813 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c @@ -0,0 +1,443 @@ +/* + * 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. + * + * The Original Code is Copyright (C) 2020 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_hash.h" +#include "BLI_math.h" +#include "BLI_task.h" + +#include "BLT_translation.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_modifier.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_particle.h" +#include "BKE_pointcache.h" +#include "BKE_scene.h" +#include "BKE_screen.h" + +#include "DEG_depsgraph.h" + +#include "WM_api.h" +#include "WM_message.h" +#include "WM_toolsystem.h" +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "ED_view3d.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "bmesh.h" +#include "bmesh_tools.h" + +#include +#include + +void SCULPT_dynamic_topology_triangulate(BMesh *bm) +{ + if (bm->totloop != bm->totface * 3) { + BM_mesh_triangulate( + bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, 4, false, NULL, NULL, NULL); + } +} + +void SCULPT_pbvh_clear(Object *ob) +{ + SculptSession *ss = ob->sculpt; + + /* Clear out any existing DM and PBVH. */ + if (ss->pbvh) { + BKE_pbvh_free(ss->pbvh); + ss->pbvh = NULL; + } + + if (ss->pmap) { + MEM_freeN(ss->pmap); + ss->pmap = NULL; + } + + if (ss->pmap_mem) { + MEM_freeN(ss->pmap_mem); + ss->pmap_mem = NULL; + } + + BKE_object_free_derived_caches(ob); + + /* Tag to rebuild PBVH in depsgraph. */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); +} + +void SCULPT_dyntopo_node_layers_add(SculptSession *ss) +{ + int cd_node_layer_index; + + char layer_id[] = "_dyntopo_node_id"; + + cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id); + if (cd_node_layer_index == -1) { + BM_data_layer_add_named(ss->bm, &ss->bm->vdata, CD_PROP_INT, layer_id); + cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->vdata, CD_PROP_INT, layer_id); + } + + ss->cd_vert_node_offset = CustomData_get_n_offset( + &ss->bm->vdata, + CD_PROP_INT, + cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT)); + + ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY; + + cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id); + if (cd_node_layer_index == -1) { + BM_data_layer_add_named(ss->bm, &ss->bm->pdata, CD_PROP_INT, layer_id); + cd_node_layer_index = CustomData_get_named_layer_index(&ss->bm->pdata, CD_PROP_INT, layer_id); + } + + ss->cd_face_node_offset = CustomData_get_n_offset( + &ss->bm->pdata, + CD_PROP_INT, + cd_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT)); + + ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY; +} + +void SCULPT_dynamic_topology_enable_ex(Main *bmain, + Depsgraph *depsgraph, + Scene *scene, + Object *ob) +{ + SculptSession *ss = ob->sculpt; + Mesh *me = ob->data; + const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me); + + SCULPT_pbvh_clear(ob); + + ss->bm_smooth_shading = (scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING) != + 0; + + /* Dynamic topology doesn't ensure selection state is valid, so remove [#36280]. */ + BKE_mesh_mselect_clear(me); + + /* Create triangles-only BMesh. */ + ss->bm = BM_mesh_create(&allocsize, + &((struct BMeshCreateParams){ + .use_toolflags = false, + })); + + BM_mesh_bm_from_me(ss->bm, + me, + (&(struct BMeshFromMeshParams){ + .calc_face_normal = true, + .use_shapekey = true, + .active_shapekey = ob->shapenr, + })); + SCULPT_dynamic_topology_triangulate(ss->bm); + BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK); + SCULPT_dyntopo_node_layers_add(ss); + /* Make sure the data for existing faces are initialized. */ + if (me->totpoly != ss->bm->totface) { + BM_mesh_normals_update(ss->bm); + } + + /* Enable dynamic topology. */ + me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; + + /* Enable logging for undo/redo. */ + ss->bm_log = BM_log_create(ss->bm); + + /* Update dependency graph, so modifiers that depend on dyntopo being enabled + * are re-evaluated and the PBVH is re-created. */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + BKE_scene_graph_update_tagged(depsgraph, bmain); +} + +/* Free the sculpt BMesh and BMLog + * + * If 'unode' is given, the BMesh's data is copied out to the unode + * before the BMesh is deleted so that it can be restored from. */ +static void SCULPT_dynamic_topology_disable_ex( + Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode) +{ + SculptSession *ss = ob->sculpt; + Mesh *me = ob->data; + + SCULPT_pbvh_clear(ob); + + if (unode) { + /* Free all existing custom data. */ + 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); + + /* Copy over stored custom data. */ + SculptUndoNodeGeometry *geometry = &unode->geometry_bmesh_enter; + me->totvert = geometry->totvert; + me->totloop = geometry->totloop; + me->totpoly = geometry->totpoly; + me->totedge = geometry->totedge; + me->totface = 0; + CustomData_copy( + &geometry->vdata, &me->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, geometry->totvert); + CustomData_copy( + &geometry->edata, &me->edata, CD_MASK_MESH.emask, CD_DUPLICATE, geometry->totedge); + CustomData_copy( + &geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop); + CustomData_copy( + &geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly); + + BKE_mesh_update_customdata_pointers(me, false); + } + else { + BKE_sculptsession_bm_to_me(ob, true); + + /* Reset Face Sets as they are no longer valid. */ + if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { + CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); + } + ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + for (int i = 0; i < me->totpoly; i++) { + ss->face_sets[i] = 1; + } + me->face_sets_color_default = 1; + + /* Sync the visibility to vertices manually as the pmap is still not initialized. */ + for (int i = 0; i < me->totvert; i++) { + me->mvert[i].flag &= ~ME_HIDE; + me->mvert[i].flag |= ME_VERT_PBVH_UPDATE; + } + } + + /* Clear data. */ + me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; + + /* Typically valid but with global-undo they can be NULL. [#36234] */ + if (ss->bm) { + BM_mesh_free(ss->bm); + ss->bm = NULL; + } + if (ss->bm_log) { + BM_log_free(ss->bm_log); + ss->bm_log = NULL; + } + + BKE_particlesystem_reset_all(ob); + BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED); + + /* Update dependency graph, so modifiers that depend on dyntopo being enabled + * are re-evaluated and the PBVH is re-created. */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + BKE_scene_graph_update_tagged(depsgraph, bmain); +} + +void SCULPT_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) +{ + Main *bmain = CTX_data_main(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); +} + +void sculpt_dynamic_topology_disable_with_undo(Main *bmain, + Depsgraph *depsgraph, + Scene *scene, + Object *ob) +{ + SculptSession *ss = ob->sculpt; + if (ss->bm) { + SCULPT_undo_push_begin("Dynamic topology disable"); + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); + SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); + SCULPT_undo_push_end(); + } +} + +static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, + Depsgraph *depsgraph, + Scene *scene, + Object *ob) +{ + SculptSession *ss = ob->sculpt; + if (ss->bm == NULL) { + SCULPT_undo_push_begin("Dynamic topology enable"); + SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); + SCULPT_undo_push_end(); + } +} + +static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Main *bmain = CTX_data_main(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; + + WM_cursor_wait(true); + + if (ss->bm) { + sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); + } + else { + sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob); + } + + WM_cursor_wait(false); + WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); + + return OPERATOR_FINISHED; +} + + +static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, enum eDynTopoWarnFlag flag) +{ + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Warning!"), ICON_ERROR); + uiLayout *layout = UI_popup_menu_layout(pup); + + if (flag & (DYNTOPO_WARN_VDATA | DYNTOPO_WARN_EDATA | DYNTOPO_WARN_LDATA)) { + const char *msg_error = TIP_("Vertex Data Detected!"); + const char *msg = TIP_("Dyntopo will not preserve vertex colors, UVs, or other customdata"); + uiItemL(layout, msg_error, ICON_INFO); + uiItemL(layout, msg, ICON_NONE); + uiItemS(layout); + } + + if (flag & DYNTOPO_WARN_MODIFIER) { + const char *msg_error = TIP_("Generative Modifiers Detected!"); + const char *msg = TIP_( + "Keeping the modifiers will increase polycount when returning to object mode"); + + uiItemL(layout, msg_error, ICON_INFO); + uiItemL(layout, msg, ICON_NONE); + uiItemS(layout); + } + + uiItemFullO_ptr(layout, ot, IFACE_("OK"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, NULL); + + UI_popup_menu_end(C, pup); + + return OPERATOR_INTERFACE; +} + +enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob) +{ + Mesh *me = ob->data; + SculptSession *ss = ob->sculpt; + + enum eDynTopoWarnFlag flag = 0; + + BLI_assert(ss->bm == NULL); + UNUSED_VARS_NDEBUG(ss); + + for (int i = 0; i < CD_NUMTYPES; i++) { + if (!ELEM(i, CD_MVERT, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) { + if (CustomData_has_layer(&me->vdata, i)) { + flag |= DYNTOPO_WARN_VDATA; + } + if (CustomData_has_layer(&me->edata, i)) { + flag |= DYNTOPO_WARN_EDATA; + } + if (CustomData_has_layer(&me->ldata, i)) { + flag |= DYNTOPO_WARN_LDATA; + } + } + } + + { + VirtualModifierData virtualModifierData; + ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData); + + /* Exception for shape keys because we can edit those. */ + for (; md; md = md->next) { + const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) { + continue; + } + + if (mti->type == eModifierTypeType_Constructive) { + flag |= DYNTOPO_WARN_MODIFIER; + break; + } + } + } + + return flag; +} + +static int sculpt_dynamic_topology_toggle_invoke(bContext *C, + wmOperator *op, + const wmEvent *UNUSED(event)) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + + if (!ss->bm) { + Scene *scene = CTX_data_scene(C); + enum eDynTopoWarnFlag flag = SCULPT_dynamic_topology_check(scene, ob); + + if (flag) { + /* The mesh has customdata that will be lost, let the user confirm this is OK. */ + return dyntopo_warning_popup(C, op->type, flag); + } + } + + return sculpt_dynamic_topology_toggle_exec(C, op); +} + +void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Dynamic Topology Toggle"; + ot->idname = "SCULPT_OT_dynamic_topology_toggle"; + ot->description = "Dynamic topology alters the mesh topology while sculpting"; + + /* API callbacks. */ + ot->invoke = sculpt_dynamic_topology_toggle_invoke; + ot->exec = sculpt_dynamic_topology_toggle_exec; + ot->poll = SCULPT_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c index d895ecc7119..38bbd083994 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c @@ -264,20 +264,21 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void SCULPT_mask_filter_smooth_apply(Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations) { - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = nodes, - .filter_type = MASK_FILTER_SMOOTH, - }; +void SCULPT_mask_filter_smooth_apply( + Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations) +{ + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = nodes, + .filter_type = MASK_FILTER_SMOOTH, + }; - for (int i = 0; i < smooth_iterations; i++) { - PBVHParallelSettings settings; - BKE_pbvh_parallel_range_settings( - &settings, (sd->flags & SCULPT_USE_OPENMP), totnode); - BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings); - } + for (int i = 0; i < smooth_iterations; i++) { + PBVHParallelSettings settings; + BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); + BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings); + } } void SCULPT_OT_mask_filter(struct wmOperatorType *ot) diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 3858a990e97..e2fd54596e7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -77,6 +77,14 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, bool use_sampled_normal); void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius); +void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush); +float SCULPT_raycast_init(struct ViewContext *vc, + const float mouse[2], + float ray_start[3], + float ray_end[3], + float ray_normal[3], + bool original); + /* Sculpt PBVH abstraction API */ void SCULPT_vertex_random_access_init(struct SculptSession *ss); @@ -249,11 +257,33 @@ void SCULPT_floodfill_execute( void SCULPT_floodfill_free(SculptFloodFill *flood); /* Dynamic topology */ -void sculpt_pbvh_clear(Object *ob); -void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); -void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); + +enum eDynTopoWarnFlag { + DYNTOPO_WARN_VDATA = (1 << 0), + DYNTOPO_WARN_EDATA = (1 << 1), + DYNTOPO_WARN_LDATA = (1 << 2), + DYNTOPO_WARN_MODIFIER = (1 << 3), +}; + +void SCULPT_dynamic_topology_enable_ex(struct Main *bmain, + struct Depsgraph *depsgraph, + Scene *scene, + Object *ob); +void SCULPT_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); +void sculpt_dynamic_topology_disable_with_undo(struct Main *bmain, + struct Depsgraph *depsgraph, + Scene *scene, + Object *ob); + bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush); +void SCULPT_dynamic_topology_triangulate(struct BMesh *bm); +void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss); + +enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob); + +void SCULPT_pbvh_clear(Object *ob); + /* Automasking. */ float SCULPT_automasking_factor_get(SculptSession *ss, int vert); @@ -851,4 +881,12 @@ void SCULPT_OT_dirty_mask(struct wmOperatorType *ot); /* Mask and Face Sets Expand. */ void SCULPT_OT_mask_expand(struct wmOperatorType *ot); +/* Detail size. */ +void SCULPT_OT_detail_flood_fill(struct wmOperatorType *ot); +void SCULPT_OT_sample_detail_size(struct wmOperatorType *ot); +void SCULPT_OT_set_detail_size(struct wmOperatorType *ot); + +/* Dyntopo. */ +void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot); + #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c index 2d4fc2b0258..34ca92acef9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c @@ -68,7 +68,6 @@ #include #include - static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); @@ -209,7 +208,8 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * /* Smooth iterations. */ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false); const int smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations"); - SCULPT_mask_filter_smooth_apply(sd, ob, ss->filter_cache->nodes, ss->filter_cache->totnode, smooth_iterations); + SCULPT_mask_filter_smooth_apply( + sd, ob, ss->filter_cache->nodes, ss->filter_cache->totnode, smooth_iterations); /* Pivot position. */ if (RNA_boolean_get(op->ptr, "update_pivot")) { diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f21bfe245dd..f78af10ad67 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -422,7 +422,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C, } } else { - sculpt_pbvh_clear(ob); + SCULPT_pbvh_clear(ob); } } @@ -432,7 +432,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode) SculptSession *ss = ob->sculpt; Mesh *me = ob->data; - sculpt_pbvh_clear(ob); + SCULPT_pbvh_clear(ob); /* Create empty BMesh and enable logging. */ ss->bm = BM_mesh_create(&bm_mesh_allocsize_default, @@ -440,7 +440,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode) .use_toolflags = false, })); BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK); - sculpt_dyntopo_node_layers_add(ss); + SCULPT_dyntopo_node_layers_add(ss); me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; /* Restore the BMLog using saved entries. */ @@ -453,7 +453,7 @@ static void sculpt_undo_bmesh_restore_begin(bContext *C, SculptSession *ss) { if (unode->applied) { - sculpt_dynamic_topology_disable(C, unode); + SCULPT_dynamic_topology_disable(C, unode); unode->applied = false; } else { @@ -481,7 +481,7 @@ static void sculpt_undo_bmesh_restore_end(bContext *C, } else { /* Disable dynamic topology sculpting. */ - sculpt_dynamic_topology_disable(C, NULL); + SCULPT_dynamic_topology_disable(C, NULL); unode->applied = true; } } @@ -552,7 +552,7 @@ static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry) static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *object) { - sculpt_pbvh_clear(object); + SCULPT_pbvh_clear(object); if (unode->applied) { sculpt_undo_geometry_restore_data(&unode->geometry_modified, object); -- cgit v1.2.3 From 6fa904765a92e1847f8b28b1062c91dcf37beb52 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 3 Apr 2020 22:20:25 -0500 Subject: Cleanup: Rename Panel * variables from pa to panel --- source/blender/blenkernel/BKE_screen.h | 6 +- source/blender/blenkernel/intern/screen.c | 22 +- source/blender/blenloader/intern/readfile.c | 10 +- source/blender/blenloader/intern/writefile.c | 6 +- source/blender/editors/include/UI_interface.h | 4 +- .../editors/interface/interface_context_menu.c | 6 +- .../blender/editors/interface/interface_intern.h | 4 +- source/blender/editors/interface/interface_panel.c | 450 +++++++++++---------- .../editors/interface/interface_region_hud.c | 10 +- source/blender/editors/space_file/file_panels.c | 18 +- source/blender/editors/space_graph/graph_buttons.c | 40 +- source/blender/editors/space_nla/nla_buttons.c | 40 +- source/blender/editors/space_node/node_buttons.c | 8 +- .../blender/editors/space_view3d/view3d_buttons.c | 14 +- source/blender/editors/uvedit/uvedit_buttons.c | 4 +- source/blender/makesrna/intern/rna_ui.c | 24 +- 16 files changed, 335 insertions(+), 331 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index d70718b4387..c49b6e27bba 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -222,11 +222,11 @@ typedef struct PanelType { /* verify if the panel should draw or not */ bool (*poll)(const struct bContext *C, struct PanelType *pt); /* draw header (optional) */ - void (*draw_header)(const struct bContext *C, struct Panel *pa); + void (*draw_header)(const struct bContext *C, struct Panel *panel); /* draw header preset (optional) */ - void (*draw_header_preset)(const struct bContext *C, struct Panel *pa); + void (*draw_header_preset)(const struct bContext *C, struct Panel *panel); /* draw entirely, view changes should be handled here */ - void (*draw)(const struct bContext *C, struct Panel *pa); + void (*draw)(const struct bContext *C, struct Panel *panel); /* sub panels */ struct PanelType *parent; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 38bd0211d15..997e807a253 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -230,11 +230,11 @@ static void panel_list_copy(ListBase *newlb, const ListBase *lb) BLI_duplicatelist(newlb, lb); /* copy panel pointers */ - Panel *newpa = newlb->first; - Panel *pa = lb->first; - for (; newpa; newpa = newpa->next, pa = pa->next) { - newpa->activedata = NULL; - panel_list_copy(&newpa->children, &pa->children); + Panel *new_panel = newlb->first; + Panel *panel = lb->first; + for (; new_panel; new_panel = new_panel->next, panel = panel->next) { + new_panel->activedata = NULL; + panel_list_copy(&new_panel->children, &panel->children); } } @@ -418,13 +418,13 @@ void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *) void BKE_area_region_panels_free(ListBase *lb) { - Panel *pa, *pa_next; - for (pa = lb->first; pa; pa = pa_next) { - pa_next = pa->next; - if (pa->activedata) { - MEM_freeN(pa->activedata); + Panel *panel, *panel_next; + for (panel = lb->first; panel; panel = panel_next) { + panel_next = panel->next; + if (panel->activedata) { + MEM_freeN(panel->activedata); } - BKE_area_region_panels_free(&pa->children); + BKE_area_region_panels_free(&panel->children); } BLI_freelistN(lb); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 84af4d1a3d4..a47c2e3ea13 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7197,11 +7197,11 @@ static void direct_link_panel_list(FileData *fd, ListBase *lb) { link_list(fd, lb); - LISTBASE_FOREACH (Panel *, pa, lb) { - pa->runtime_flag = 0; - pa->activedata = NULL; - pa->type = NULL; - direct_link_panel_list(fd, &pa->children); + LISTBASE_FOREACH (Panel *, panel, lb) { + panel->runtime_flag = 0; + panel->activedata = NULL; + panel->type = NULL; + direct_link_panel_list(fd, &panel->children); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index aa8dc39f9c0..f0280c78407 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2943,9 +2943,9 @@ static void write_soops(WriteData *wd, SpaceOutliner *so) static void write_panel_list(WriteData *wd, ListBase *lb) { - LISTBASE_FOREACH (Panel *, pa, lb) { - writestruct(wd, DATA, Panel, 1, pa); - write_panel_list(wd, &pa->children); + LISTBASE_FOREACH (Panel *, panel, lb) { + writestruct(wd, DATA, Panel, 1, panel); + write_panel_list(wd, &panel->children); } } diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 56f7f0faad7..eb134646649 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1655,7 +1655,7 @@ struct Panel *UI_panel_begin(struct ScrArea *area, struct ListBase *lb, uiBlock *block, struct PanelType *pt, - struct Panel *pa, + struct Panel *panel, bool *r_open); void UI_panel_end(const struct ScrArea *area, const struct ARegion *region, @@ -1665,7 +1665,7 @@ void UI_panel_end(const struct ScrArea *area, bool open); void UI_panels_scale(struct ARegion *region, float new_width); void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); -int UI_panel_size_y(const struct Panel *pa); +int UI_panel_size_y(const struct Panel *panel); bool UI_panel_category_is_visible(const struct ARegion *region); void UI_panel_category_add(struct ARegion *region, const char *name); diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 3c5973a3f41..5245b724da4 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -1231,7 +1231,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) /** * menu to show when right clicking on the panel header */ -void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa) +void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel) { bScreen *screen = CTX_wm_screen(C); const bool has_panel_category = UI_panel_category_is_visible(region); @@ -1243,11 +1243,11 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *pa) if (!any_item_visible) { return; } - if (pa->type->parent != NULL) { + if (panel->type->parent != NULL) { return; } - RNA_pointer_create(&screen->id, &RNA_Panel, pa, &ptr); + RNA_pointer_create(&screen->id, &RNA_Panel, panel, &ptr); pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); layout = UI_popup_menu_layout(pup); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 4a9c8a1ff54..942f19eb4e9 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -975,7 +975,9 @@ ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent /* 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 *region, struct Panel *pa); +void ui_popup_context_menu_for_panel(struct bContext *C, + struct ARegion *region, + struct Panel *panel); /* interface_eyedropper.c */ struct wmKeyMap *eyedropper_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 42179452279..b3854cfc4ae 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -105,8 +105,8 @@ typedef struct uiHandlePanelData { int startsizex, startsizey; } uiHandlePanelData; -static int get_panel_real_size_y(const Panel *pa); -static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state); +static int get_panel_real_size_y(const Panel *panel); +static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state); static void panel_title_color_get(bool show_background, uchar color[4]) { @@ -160,45 +160,45 @@ static int panel_aligned(const ScrArea *area, const ARegion *region) static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation) { - LISTBASE_FOREACH (Panel *, pa, lb) { + LISTBASE_FOREACH (Panel *, panel, lb) { /* Detect panel active flag changes. */ - if (!(pa->type && pa->type->parent)) { - if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) { + if (!(panel->type && panel->type->parent)) { + if ((panel->runtime_flag & PNL_WAS_ACTIVE) && !(panel->runtime_flag & PNL_ACTIVE)) { return true; } - if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) { + if (!(panel->runtime_flag & PNL_WAS_ACTIVE) && (panel->runtime_flag & PNL_ACTIVE)) { return true; } } - if ((pa->runtime_flag & PNL_ACTIVE) && !(pa->flag & PNL_CLOSED)) { - if (panel_active_animation_changed(&pa->children, pa_animation, no_animation)) { + if ((panel->runtime_flag & PNL_ACTIVE) && !(panel->flag & PNL_CLOSED)) { + if (panel_active_animation_changed(&panel->children, pa_animation, no_animation)) { return true; } } /* Detect animation. */ - if (pa->activedata) { - uiHandlePanelData *data = pa->activedata; + if (panel->activedata) { + uiHandlePanelData *data = panel->activedata; if (data->state == PANEL_STATE_ANIMATION) { - *pa_animation = pa; + *pa_animation = panel; } else { /* Don't animate while handling other interaction. */ *no_animation = true; } } - if ((pa->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) { - *pa_animation = pa; + if ((panel->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) { + *pa_animation = panel; } } return false; } -static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_pa_animate) +static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_panel_animation) { - *r_pa_animate = NULL; + *r_panel_animation = NULL; if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) { SpaceProperties *sbuts = area->spacedata.first; @@ -215,16 +215,16 @@ static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_pa_ani } /* Detect if a panel was added or removed. */ - Panel *pa_animation = NULL; + Panel *panel_animation = NULL; bool no_animation = false; - if (panel_active_animation_changed(®ion->panels, &pa_animation, &no_animation)) { + if (panel_active_animation_changed(®ion->panels, &panel_animation, &no_animation)) { return true; } /* Detect panel marked for animation, if we're not already animating. */ - if (pa_animation) { + if (panel_animation) { if (!no_animation) { - *r_pa_animate = pa_animation; + *r_panel_animation = panel_animation; } return true; } @@ -234,24 +234,24 @@ static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_pa_ani /****************************** panels ******************************/ -static void panels_collapse_all(ScrArea *area, ARegion *region, const Panel *from_pa) +static void panels_collapse_all(ScrArea *area, ARegion *region, const Panel *from_panel) { const bool has_category_tabs = UI_panel_category_is_visible(region); const char *category = has_category_tabs ? UI_panel_category_active_get(region, false) : NULL; const int flag = ((panel_aligned(area, region) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY); - const PanelType *from_pt = from_pa->type; - Panel *pa; + const PanelType *from_pt = from_panel->type; + Panel *panel; - for (pa = region->panels.first; pa; pa = pa->next) { - PanelType *pt = pa->type; + for (panel = region->panels.first; panel; panel = panel->next) { + PanelType *pt = panel->type; /* close panels with headers in the same context */ if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) { if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) { - if ((pa->flag & PNL_PIN) || !category || !pt->category[0] || + if ((panel->flag & PNL_PIN) || !category || !pt->category[0] || STREQ(pt->category, category)) { - pa->flag &= ~PNL_CLOSED; - pa->flag |= flag; + panel->flag &= ~PNL_CLOSED; + panel->flag |= flag; } } } @@ -260,116 +260,116 @@ static void panels_collapse_all(ScrArea *area, ARegion *region, const Panel *fro Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt) { - Panel *pa; + Panel *panel; const char *idname = pt->idname; - for (pa = lb->first; pa; pa = pa->next) { - if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) { - return pa; + for (panel = lb->first; panel; panel = panel->next) { + if (STREQLEN(panel->panelname, idname, sizeof(panel->panelname))) { + return panel; } } return NULL; } /** - * \note \a pa should be return value from #UI_panel_find_by_type and can be NULL. + * \note \a panel should be return value from #UI_panel_find_by_type and can be NULL. */ Panel *UI_panel_begin(ScrArea *area, ARegion *region, ListBase *lb, uiBlock *block, PanelType *pt, - Panel *pa, + Panel *panel, bool *r_open) { - Panel *palast, *panext; + Panel *panel_last, *panel_next; const char *drawname = CTX_IFACE_(pt->translation_context, pt->label); const char *idname = pt->idname; - const bool newpanel = (pa == NULL); + const bool newpanel = (panel == NULL); int align = panel_aligned(area, region); if (!newpanel) { - pa->type = pt; + panel->type = pt; } else { /* new panel */ - pa = MEM_callocN(sizeof(Panel), "new panel"); - pa->type = pt; - BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname)); + panel = MEM_callocN(sizeof(Panel), "new panel"); + panel->type = pt; + BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname)); if (pt->flag & PNL_DEFAULT_CLOSED) { if (align == BUT_VERTICAL) { - pa->flag |= PNL_CLOSEDY; + panel->flag |= PNL_CLOSEDY; } else { - pa->flag |= PNL_CLOSEDX; + panel->flag |= PNL_CLOSEDX; } } - pa->ofsx = 0; - pa->ofsy = 0; - pa->sizex = 0; - pa->sizey = 0; - pa->blocksizex = 0; - pa->blocksizey = 0; - pa->runtime_flag |= PNL_NEW_ADDED; + panel->ofsx = 0; + panel->ofsy = 0; + panel->sizex = 0; + panel->sizey = 0; + panel->blocksizex = 0; + panel->blocksizey = 0; + panel->runtime_flag |= PNL_NEW_ADDED; - BLI_addtail(lb, pa); + BLI_addtail(lb, panel); } /* Do not allow closed panels without headers! Else user could get "disappeared" UI! */ - if ((pt->flag & PNL_NO_HEADER) && (pa->flag & PNL_CLOSED)) { - pa->flag &= ~PNL_CLOSED; + if ((pt->flag & PNL_NO_HEADER) && (panel->flag & PNL_CLOSED)) { + panel->flag &= ~PNL_CLOSED; /* Force update of panels' positions! */ - pa->sizex = 0; - pa->sizey = 0; - pa->blocksizex = 0; - pa->blocksizey = 0; + panel->sizex = 0; + panel->sizey = 0; + panel->blocksizex = 0; + panel->blocksizey = 0; } - BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname)); + BLI_strncpy(panel->drawname, drawname, sizeof(panel->drawname)); /* if a new panel is added, we insert it right after the panel * that was last added. this way new panels are inserted in the * right place between versions */ - for (palast = lb->first; palast; palast = palast->next) { - if (palast->runtime_flag & PNL_LAST_ADDED) { - BLI_remlink(lb, pa); - BLI_insertlinkafter(lb, palast, pa); + for (panel_last = lb->first; panel_last; panel_last = panel_last->next) { + if (panel_last->runtime_flag & PNL_LAST_ADDED) { + BLI_remlink(lb, panel); + BLI_insertlinkafter(lb, panel_last, panel); break; } } if (newpanel) { - pa->sortorder = (palast) ? palast->sortorder + 1 : 0; + panel->sortorder = (panel_last) ? panel_last->sortorder + 1 : 0; - for (panext = lb->first; panext; panext = panext->next) { - if (panext != pa && panext->sortorder >= pa->sortorder) { - panext->sortorder++; + for (panel_next = lb->first; panel_next; panel_next = panel_next->next) { + if (panel_next != panel && panel_next->sortorder >= panel->sortorder) { + panel_next->sortorder++; } } } - if (palast) { - palast->runtime_flag &= ~PNL_LAST_ADDED; + if (panel_last) { + panel_last->runtime_flag &= ~PNL_LAST_ADDED; } /* assign to block */ - block->panel = pa; - pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED; + block->panel = panel; + panel->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED; if (region->alignment == RGN_ALIGN_FLOAT) { UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); } *r_open = false; - if (pa->flag & PNL_CLOSED) { - return pa; + if (panel->flag & PNL_CLOSED) { + return panel; } *r_open = true; - return pa; + return panel; } static float panel_region_offset_x_get(const ARegion *region, int align) @@ -387,14 +387,14 @@ static float panel_region_offset_x_get(const ARegion *region, int align) void UI_panel_end( const ScrArea *area, const ARegion *region, uiBlock *block, int width, int height, bool open) { - Panel *pa = block->panel; + Panel *panel = block->panel; /* Set panel size excluding children. */ - pa->blocksizex = width; - pa->blocksizey = height; + panel->blocksizex = width; + panel->blocksizey = height; /* Compute total panel size including children. */ - LISTBASE_FOREACH (Panel *, pachild, &pa->children) { + LISTBASE_FOREACH (Panel *, pachild, &panel->children) { if (pachild->runtime_flag & PNL_ACTIVE) { width = max_ii(width, pachild->sizex); height += get_panel_real_size_y(pachild); @@ -402,32 +402,32 @@ void UI_panel_end( } /* Update total panel size. */ - if (pa->runtime_flag & PNL_NEW_ADDED) { - pa->runtime_flag &= ~PNL_NEW_ADDED; - pa->sizex = width; - pa->sizey = height; + if (panel->runtime_flag & PNL_NEW_ADDED) { + panel->runtime_flag &= ~PNL_NEW_ADDED; + panel->sizex = width; + panel->sizey = height; } else { - int old_sizex = pa->sizex, old_sizey = pa->sizey; - int old_region_ofsx = pa->runtime.region_ofsx; + int old_sizex = panel->sizex, old_sizey = panel->sizey; + int old_region_ofsx = panel->runtime.region_ofsx; /* update width/height if non-zero */ if (width != 0) { - pa->sizex = width; + panel->sizex = width; } if (height != 0 || open) { - pa->sizey = height; + panel->sizey = height; } /* check if we need to do an animation */ - if (pa->sizex != old_sizex || pa->sizey != old_sizey) { - pa->runtime_flag |= PNL_ANIM_ALIGN; - pa->ofsy += old_sizey - pa->sizey; + if (panel->sizex != old_sizex || panel->sizey != old_sizey) { + panel->runtime_flag |= PNL_ANIM_ALIGN; + panel->ofsy += old_sizey - panel->sizey; } int align = panel_aligned(area, region); if (old_region_ofsx != panel_region_offset_x_get(region, align)) { - pa->runtime_flag |= PNL_ANIM_ALIGN; + panel->runtime_flag |= PNL_ANIM_ALIGN; } } } @@ -867,64 +867,64 @@ void ui_draw_aligned_panel(uiStyle *style, /************************** panel alignment *************************/ -static int get_panel_header(const Panel *pa) +static int get_panel_header(const Panel *panel) { - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { + if (panel->type && (panel->type->flag & PNL_NO_HEADER)) { return 0; } return PNL_HEADER; } -static int get_panel_size_y(const Panel *pa) +static int get_panel_size_y(const Panel *panel) { - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { - return pa->sizey; + if (panel->type && (panel->type->flag & PNL_NO_HEADER)) { + return panel->sizey; } - return PNL_HEADER + pa->sizey; + return PNL_HEADER + panel->sizey; } -static int get_panel_real_size_y(const Panel *pa) +static int get_panel_real_size_y(const Panel *panel) { - int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey; + int sizey = (panel->flag & PNL_CLOSED) ? 0 : panel->sizey; - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { + if (panel->type && (panel->type->flag & PNL_NO_HEADER)) { return sizey; } return PNL_HEADER + sizey; } -int UI_panel_size_y(const Panel *pa) +int UI_panel_size_y(const Panel *panel) { - return get_panel_real_size_y(pa); + return get_panel_real_size_y(panel); } /* this function is needed because uiBlock and Panel itself don't * change sizey or location when closed */ -static int get_panel_real_ofsy(Panel *pa) +static int get_panel_real_ofsy(Panel *panel) { - if (pa->flag & PNL_CLOSEDY) { - return pa->ofsy + pa->sizey; + if (panel->flag & PNL_CLOSEDY) { + return panel->ofsy + panel->sizey; } else { - return pa->ofsy; + return panel->ofsy; } } -static int get_panel_real_ofsx(Panel *pa) +static int get_panel_real_ofsx(Panel *panel) { - if (pa->flag & PNL_CLOSEDX) { - return pa->ofsx + get_panel_header(pa); + if (panel->flag & PNL_CLOSEDX) { + return panel->ofsx + get_panel_header(panel); } else { - return pa->ofsx + pa->sizex; + return panel->ofsx + panel->sizex; } } typedef struct PanelSort { - Panel *pa, *orig; + Panel *panel, *orig; } PanelSort; /** @@ -939,16 +939,16 @@ static int find_leftmost_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; - if (ps1->pa->ofsx > ps2->pa->ofsx) { + if (ps1->panel->ofsx > ps2->panel->ofsx) { return 1; } - else if (ps1->pa->ofsx < ps2->pa->ofsx) { + else if (ps1->panel->ofsx < ps2->panel->ofsx) { return -1; } - else if (ps1->pa->sortorder > ps2->pa->sortorder) { + else if (ps1->panel->sortorder > ps2->panel->sortorder) { return 1; } - else if (ps1->pa->sortorder < ps2->pa->sortorder) { + else if (ps1->panel->sortorder < ps2->panel->sortorder) { return -1; } @@ -961,26 +961,26 @@ static int find_highest_panel(const void *a1, const void *a2) /* stick uppermost header-less panels to the top of the region - * prevent them from being sorted (multiple header-less panels have to be sorted though) */ - if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) { + if (ps1->panel->type->flag & PNL_NO_HEADER && ps2->panel->type->flag & PNL_NO_HEADER) { /* skip and check for ofs and sortorder below */ } - else if (ps1->pa->type->flag & PNL_NO_HEADER) { + else if (ps1->panel->type->flag & PNL_NO_HEADER) { return -1; } - else if (ps2->pa->type->flag & PNL_NO_HEADER) { + else if (ps2->panel->type->flag & PNL_NO_HEADER) { return 1; } - if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) { + if (ps1->panel->ofsy + ps1->panel->sizey < ps2->panel->ofsy + ps2->panel->sizey) { return 1; } - else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) { + else if (ps1->panel->ofsy + ps1->panel->sizey > ps2->panel->ofsy + ps2->panel->sizey) { return -1; } - else if (ps1->pa->sortorder > ps2->pa->sortorder) { + else if (ps1->panel->sortorder > ps2->panel->sortorder) { return 1; } - else if (ps1->pa->sortorder < ps2->pa->sortorder) { + else if (ps1->panel->sortorder < ps2->panel->sortorder) { return -1; } @@ -991,24 +991,24 @@ static int compare_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; - if (ps1->pa->sortorder > ps2->pa->sortorder) { + if (ps1->panel->sortorder > ps2->panel->sortorder) { return 1; } - else if (ps1->pa->sortorder < ps2->pa->sortorder) { + else if (ps1->panel->sortorder < ps2->panel->sortorder) { return -1; } return 0; } -static void align_sub_panels(Panel *pa) +static void align_sub_panels(Panel *panel) { /* Position sub panels. */ - int ofsy = pa->ofsy + pa->sizey - pa->blocksizey; + int ofsy = panel->ofsy + panel->sizey - panel->blocksizey; - LISTBASE_FOREACH (Panel *, pachild, &pa->children) { + LISTBASE_FOREACH (Panel *, pachild, &panel->children) { if (pachild->runtime_flag & PNL_ACTIVE) { - pachild->ofsx = pa->ofsx; + pachild->ofsx = panel->ofsx; pachild->ofsy = ofsy - get_panel_size_y(pachild); ofsy -= get_panel_real_size_y(pachild); @@ -1023,15 +1023,15 @@ static void align_sub_panels(Panel *pa) /* returns 1 when it did something */ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, const bool drag) { - Panel *pa; + Panel *panel; PanelSort *ps, *panelsort, *psnext; int a, tot = 0; bool done; int align = panel_aligned(area, region); /* count active, not tabbed panels */ - for (pa = region->panels.first; pa; pa = pa->next) { - if (pa->runtime_flag & PNL_ACTIVE) { + for (panel = region->panels.first; panel; panel = panel->next) { + if (panel->runtime_flag & PNL_ACTIVE) { tot++; } } @@ -1041,13 +1041,13 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co } /* extra; change close direction? */ - for (pa = region->panels.first; pa; pa = pa->next) { - if (pa->runtime_flag & PNL_ACTIVE) { - if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { - pa->flag ^= PNL_CLOSED; + for (panel = region->panels.first; panel; panel = panel->next) { + if (panel->runtime_flag & PNL_ACTIVE) { + if ((panel->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { + panel->flag ^= PNL_CLOSED; } - else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { - pa->flag ^= PNL_CLOSED; + else if ((panel->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { + panel->flag ^= PNL_CLOSED; } } } @@ -1056,10 +1056,10 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort"); ps = panelsort; - for (pa = region->panels.first; pa; pa = pa->next) { - if (pa->runtime_flag & PNL_ACTIVE) { - ps->pa = MEM_dupallocN(pa); - ps->orig = pa; + for (panel = region->panels.first; panel; panel = panel->next) { + if (panel->runtime_flag & PNL_ACTIVE) { + ps->panel = MEM_dupallocN(panel); + ps->orig = panel; ps++; } } @@ -1084,21 +1084,22 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps = panelsort; - ps->pa->runtime.region_ofsx = panel_region_offset_x_get(region, align); - ps->pa->ofsx = 0; - ps->pa->ofsy = -get_panel_size_y(ps->pa); - ps->pa->ofsx += ps->pa->runtime.region_ofsx; + ps->panel->runtime.region_ofsx = panel_region_offset_x_get(region, align); + ps->panel->ofsx = 0; + ps->panel->ofsy = -get_panel_size_y(ps->panel); + ps->panel->ofsx += ps->panel->runtime.region_ofsx; for (a = 0; a < tot - 1; a++, ps++) { psnext = ps + 1; if (align == BUT_VERTICAL) { - psnext->pa->ofsx = ps->pa->ofsx; - psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); + psnext->panel->ofsx = ps->panel->ofsx; + psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel); } else { - psnext->pa->ofsx = get_panel_real_ofsx(ps->pa); - psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); + psnext->panel->ofsx = get_panel_real_ofsx(ps->panel); + psnext->panel->ofsy = ps->panel->ofsy + get_panel_size_y(ps->panel) - + get_panel_size_y(psnext->panel); } } @@ -1106,11 +1107,11 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co done = false; ps = panelsort; for (a = 0; a < tot; a++, ps++) { - if ((ps->pa->flag & PNL_SELECT) == 0) { - if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { - ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx + + if ((ps->panel->flag & PNL_SELECT) == 0) { + if ((ps->orig->ofsx != ps->panel->ofsx) || (ps->orig->ofsy != ps->panel->ofsy)) { + ps->orig->ofsx = round_fl_to_int(fac * (float)ps->panel->ofsx + (1.0f - fac) * (float)ps->orig->ofsx); - ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy + + ps->orig->ofsy = round_fl_to_int(fac * (float)ps->panel->ofsy + (1.0f - fac) * (float)ps->orig->ofsy); done = true; } @@ -1118,17 +1119,17 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co } /* set locations for tabbed and sub panels */ - for (pa = region->panels.first; pa; pa = pa->next) { - if (pa->runtime_flag & PNL_ACTIVE) { - if (pa->children.first) { - align_sub_panels(pa); + for (panel = region->panels.first; panel; panel = panel->next) { + if (panel->runtime_flag & PNL_ACTIVE) { + if (panel->children.first) { + align_sub_panels(panel); } } } /* free panelsort array */ for (ps = panelsort, a = 0; a < tot; a++, ps++) { - MEM_freeN(ps->pa); + MEM_freeN(ps->panel); } MEM_freeN(panelsort); @@ -1137,23 +1138,23 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co static void ui_panels_size(ScrArea *area, ARegion *region, int *r_x, int *r_y) { - Panel *pa; + Panel *panel; int align = panel_aligned(area, region); int sizex = 0; int sizey = 0; /* compute size taken up by panels, for setting in view2d */ - for (pa = region->panels.first; pa; pa = pa->next) { - if (pa->runtime_flag & PNL_ACTIVE) { + for (panel = region->panels.first; panel; panel = panel->next) { + if (panel->runtime_flag & PNL_ACTIVE) { int pa_sizex, pa_sizey; if (align == BUT_VERTICAL) { - pa_sizex = pa->ofsx + pa->sizex; - pa_sizey = get_panel_real_ofsy(pa); + pa_sizex = panel->ofsx + panel->sizex; + pa_sizey = get_panel_real_ofsy(panel); } else { - pa_sizex = get_panel_real_ofsx(pa) + pa->sizex; - pa_sizey = pa->ofsy + get_panel_size_y(pa); + pa_sizex = get_panel_real_ofsx(panel) + panel->sizex; + pa_sizey = panel->ofsy + get_panel_size_y(panel); } sizex = max_ii(sizex, pa_sizex); @@ -1200,15 +1201,15 @@ static void panel_list_clear_active(ListBase *lb) { /* set all panels as inactive, so that at the end we know * which ones were used */ - LISTBASE_FOREACH (Panel *, pa, lb) { - if (pa->runtime_flag & PNL_ACTIVE) { - pa->runtime_flag = PNL_WAS_ACTIVE; + LISTBASE_FOREACH (Panel *, panel, lb) { + if (panel->runtime_flag & PNL_ACTIVE) { + panel->runtime_flag = PNL_WAS_ACTIVE; } else { - pa->runtime_flag = 0; + panel->runtime_flag = 0; } - panel_list_clear_active(&pa->children); + panel_list_clear_active(&panel->children); } } @@ -1222,7 +1223,7 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) { ScrArea *area = CTX_wm_area(C); uiBlock *block; - Panel *pa, *firstpa; + Panel *panel, *panel_first; /* offset contents */ for (block = region->uiblocks.first; block; block = block->next) { @@ -1232,9 +1233,9 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) } /* re-align, possibly with animation */ - if (panels_need_realign(area, region, &pa)) { - if (pa) { - panel_activate_state(C, pa, PANEL_STATE_ANIMATION); + if (panels_need_realign(area, region, &panel)) { + if (panel) { + panel_activate_state(C, panel, PANEL_STATE_ANIMATION); } else { uiAlignPanelStep(area, region, 1.0, false); @@ -1242,17 +1243,17 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) } /* tag first panel */ - firstpa = NULL; + panel_first = NULL; for (block = region->uiblocks.first; block; block = block->next) { if (block->active && block->panel) { - if (!firstpa || block->panel->sortorder < firstpa->sortorder) { - firstpa = block->panel; + if (!panel_first || block->panel->sortorder < panel_first->sortorder) { + panel_first = block->panel; } } } - if (firstpa) { - firstpa->runtime_flag |= PNL_FIRST; + if (panel_first) { + panel_first->runtime_flag |= PNL_FIRST; } /* compute size taken up by panel */ @@ -1305,20 +1306,20 @@ void UI_panels_scale(ARegion *region, float new_width) static void check_panel_overlap(ARegion *region, Panel *panel) { - Panel *pa; + Panel *panel_list; /* also called with (panel == NULL) for clear */ - for (pa = region->panels.first; pa; pa = pa->next) { - pa->flag &= ~PNL_OVERLAP; - if (panel && (pa != panel)) { - if (pa->runtime_flag & PNL_ACTIVE) { + for (panel_list = region->panels.first; panel_list; panel_list = panel_list->next) { + panel_list->flag &= ~PNL_OVERLAP; + if (panel && (panel_list != panel)) { + if (panel_list->runtime_flag & PNL_ACTIVE) { float safex = 0.2, safey = 0.2; - if (pa->flag & PNL_CLOSEDX) { + if (panel_list->flag & PNL_CLOSEDX) { safex = 0.05; } - else if (pa->flag & PNL_CLOSEDY) { + else if (panel_list->flag & PNL_CLOSEDY) { safey = 0.05; } else if (panel->flag & PNL_CLOSEDX) { @@ -1328,11 +1329,12 @@ static void check_panel_overlap(ARegion *region, Panel *panel) safey = 0.05; } - if (pa->ofsx > panel->ofsx - safex * panel->sizex) { - if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) { - if (pa->ofsy > panel->ofsy - safey * panel->sizey) { - if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) { - pa->flag |= PNL_OVERLAP; + if (panel_list->ofsx > panel->ofsx - safex * panel->sizex) { + if (panel_list->ofsx + panel_list->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) { + if (panel_list->ofsy > panel->ofsy - safey * panel->sizey) { + if (panel_list->ofsy + panel_list->sizey < + panel->ofsy + (1.0f + safey) * panel->sizey) { + panel_list->flag |= PNL_OVERLAP; } } } @@ -1391,12 +1393,12 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) /******************* region level panel interaction *****************/ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block, - const Panel *pa, + const Panel *panel, const int mx, const int my) { /* open panel */ - if (pa->flag & PNL_CLOSEDX) { + if (panel->flag & PNL_CLOSEDX) { if ((block->rect.xmin <= mx) && (block->rect.xmin + PNL_HEADER >= mx)) { return PANEL_MOUSE_INSIDE_HEADER; } @@ -1409,8 +1411,8 @@ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block, return PANEL_MOUSE_INSIDE_HEADER; } /* open panel */ - else if (!(pa->flag & PNL_CLOSEDY)) { - if (pa->control & UI_PNL_SCALE) { + else if (!(panel->flag & PNL_CLOSEDY)) { + if (panel->control & UI_PNL_SCALE) { if (block->rect.xmax - PNL_HEADER <= mx) { if (block->rect.ymin + PNL_HEADER >= my) { return PANEL_MOUSE_INSIDE_SCALE; @@ -1444,7 +1446,7 @@ static void ui_panel_drag_collapse(bContext *C, ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); uiBlock *block; - Panel *pa; + Panel *panel; for (block = region->uiblocks.first; block; block = block->next) { float xy_a_block[2] = {UNPACK2(dragcol_data->xy_init)}; @@ -1453,10 +1455,10 @@ static void ui_panel_drag_collapse(bContext *C, int oldflag; const bool is_horizontal = (panel_aligned(area, region) == BUT_HORIZONTAL); - if ((pa = block->panel) == 0 || (pa->type && (pa->type->flag & PNL_NO_HEADER))) { + if ((panel = block->panel) == 0 || (panel->type && (panel->type->flag & PNL_NO_HEADER))) { continue; } - oldflag = pa->flag; + oldflag = panel->flag; /* lock one axis */ if (is_horizontal) { @@ -1473,7 +1475,7 @@ static void ui_panel_drag_collapse(bContext *C, /* set up rect to match header size */ rect.ymin = rect.ymax; rect.ymax = rect.ymin + PNL_HEADER; - if (pa->flag & PNL_CLOSEDX) { + if (panel->flag & PNL_CLOSEDX) { rect.xmax = rect.xmin + PNL_HEADER; } @@ -1481,16 +1483,16 @@ static void ui_panel_drag_collapse(bContext *C, if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) { /* force panel to close */ if (dragcol_data->was_first_open == true) { - pa->flag |= (is_horizontal ? PNL_CLOSEDX : PNL_CLOSEDY); + panel->flag |= (is_horizontal ? PNL_CLOSEDX : PNL_CLOSEDY); } /* force panel to open */ else { - pa->flag &= ~PNL_CLOSED; + panel->flag &= ~PNL_CLOSED; } - /* if pa->flag has changed this means a panel was opened/closed here */ - if (pa->flag != oldflag) { - panel_activate_state(C, pa, PANEL_STATE_ANIMATION); + /* if panel->flag has changed this means a panel was opened/closed here */ + if (panel->flag != oldflag) { + panel_activate_state(C, panel, PANEL_STATE_ANIMATION); } } } @@ -2279,7 +2281,7 @@ int ui_handler_panel_region(bContext *C, const uiBut *active_but) { uiBlock *block; - Panel *pa; + Panel *panel; int retval, mx, my; bool has_category_tabs = UI_panel_category_is_visible(region); @@ -2325,17 +2327,17 @@ int ui_handler_panel_region(bContext *C, ui_window_to_block(region, block, &mx, &my); /* checks for mouse position inside */ - pa = block->panel; + panel = block->panel; - if (!pa) { + if (!panel) { continue; } /* XXX - accessed freed panels when scripts reload, need to fix. */ - if (pa->type && pa->type->flag & PNL_NO_HEADER) { + if (panel->type && panel->type->flag & PNL_NO_HEADER) { continue; } - mouse_state = ui_panel_mouse_state_get(block, pa, mx, my); + mouse_state = ui_panel_mouse_state_get(block, panel, mx, my); /* XXX hardcoded key warning */ if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && @@ -2343,7 +2345,7 @@ int ui_handler_panel_region(bContext *C, if (event->type == EVT_AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) { - if (pa->flag & PNL_CLOSEDY) { + if (panel->flag & PNL_CLOSEDY) { if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); } @@ -2383,8 +2385,8 @@ int ui_handler_panel_region(bContext *C, retval = WM_UI_HANDLER_BREAK; break; } - else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) { - panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE); + else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(panel->flag & PNL_CLOSED)) { + panel_activate_state(C, panel, PANEL_STATE_DRAG_SCALE); retval = WM_UI_HANDLER_BREAK; break; } @@ -2411,7 +2413,7 @@ int ui_handler_panel_region(bContext *C, int zoom = 0; /* if panel is closed, only zoom if mouse is over the header */ - if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { + if (panel->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { if (inside_header) { zoom = 1; } @@ -2425,7 +2427,7 @@ int ui_handler_panel_region(bContext *C, SpaceLink *sl = area->spacedata.first; if (area->spacetype != SPACE_PROPERTIES) { - if (!(pa->control & UI_PNL_SCALE)) { + if (!(panel->control & UI_PNL_SCALE)) { if (event->type == PADPLUSKEY) { sl->blockscale += 0.1; } @@ -2495,14 +2497,14 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) static void ui_handler_remove_panel(bContext *C, void *userdata) { - Panel *pa = userdata; + Panel *panel = userdata; - panel_activate_state(C, pa, PANEL_STATE_EXIT); + panel_activate_state(C, panel, PANEL_STATE_EXIT); } -static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state) +static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state) { - uiHandlePanelData *data = pa->activedata; + uiHandlePanelData *data = panel->activedata; wmWindow *win = CTX_wm_window(C); ARegion *region = CTX_wm_region(C); @@ -2522,10 +2524,10 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat check_panel_overlap(region, NULL); /* clears */ } - pa->flag &= ~PNL_SELECT; + panel->flag &= ~PNL_SELECT; } else { - pa->flag |= PNL_SELECT; + panel->flag |= PNL_SELECT; } if (data && data->animtimer) { @@ -2535,18 +2537,18 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat if (state == PANEL_STATE_EXIT) { MEM_freeN(data); - pa->activedata = NULL; + panel->activedata = NULL; WM_event_remove_ui_handler( - &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, false); + &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, false); } else { if (!data) { data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData"); - pa->activedata = data; + panel->activedata = data; WM_event_add_ui_handler( - C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0); + C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0); } if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) { @@ -2556,10 +2558,10 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat data->state = state; data->startx = win->eventstate->x; data->starty = win->eventstate->y; - data->startofsx = pa->ofsx; - data->startofsy = pa->ofsy; - data->startsizex = pa->sizex; - data->startsizey = pa->sizey; + data->startofsx = panel->ofsx; + data->startofsy = panel->ofsy; + data->startsizex = panel->sizex; + data->startsizey = panel->sizey; data->starttime = PIL_check_seconds_timer(); } diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 1963c76b96e..34ac58c1dca 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -114,22 +114,22 @@ static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt return false; } -static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *pa) +static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *panel) { wmOperator *op = WM_operator_last_redo(C); - BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname)); + BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname)); } -static void hud_panel_operator_redo_draw(const bContext *C, Panel *pa) +static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel) { wmOperator *op = WM_operator_last_redo(C); if (op == NULL) { return; } if (!WM_operator_check_ui_enabled(C, op->type->name)) { - uiLayoutSetEnabled(pa->layout, false); + uiLayoutSetEnabled(panel->layout, false); } - uiLayout *col = uiLayoutColumn(pa->layout, false); + uiLayout *col = uiLayoutColumn(panel->layout, false); uiTemplateOperatorRedoProperties(col, C); } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 9ba098fcf45..ff9454cd922 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -57,20 +57,20 @@ static bool file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) return (sfile && sfile->op); } -static void file_panel_operator_header(const bContext *C, Panel *pa) +static void file_panel_operator_header(const bContext *C, Panel *panel) { SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname)); + BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname)); } -static void file_panel_operator(const bContext *C, Panel *pa) +static void file_panel_operator(const bContext *C, Panel *panel) { SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); + UI_block_func_set(uiLayoutGetBlock(panel->layout), file_draw_check_cb, NULL, NULL); /* Hack: temporary hide.*/ const char *hide[] = {"filepath", "files", "directory", "filename"}; @@ -82,7 +82,7 @@ static void file_panel_operator(const bContext *C, Panel *pa) } uiTemplateOperatorPropertyButs( - C, pa->layout, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_EMPTY); + C, panel->layout, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_EMPTY); /* Hack: temporary hide.*/ for (int i = 0; i < ARRAY_SIZE(hide); i++) { @@ -92,7 +92,7 @@ static void file_panel_operator(const bContext *C, Panel *pa) } } - UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL); + UI_block_func_set(uiLayoutGetBlock(panel->layout), NULL, NULL, NULL); } void file_tool_props_region_panels_register(ARegionType *art) @@ -128,12 +128,12 @@ static void file_panel_execution_execute_button(uiLayout *layout, const char *ti uiItemO(row, title, ICON_NONE, "FILE_OT_execute"); } -static void file_panel_execution_buttons_draw(const bContext *C, Panel *pa) +static void file_panel_execution_buttons_draw(const bContext *C, Panel *panel) { bScreen *screen = CTX_wm_screen(C); SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); - uiBlock *block = uiLayoutGetBlock(pa->layout); + uiBlock *block = uiLayoutGetBlock(panel->layout); uiBut *but; uiLayout *row; PointerRNA params_rna_ptr, *but_extra_rna_ptr; @@ -148,7 +148,7 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *pa) RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, ¶ms_rna_ptr); - row = uiLayoutRow(pa->layout, false); + row = uiLayoutRow(panel->layout, false); uiLayoutSetScaleY(row, 1.3f); /* callbacks for operator check functions */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index b1f9da1cd5c..8c931a0c4a3 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -111,7 +111,7 @@ static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* -------------- */ -static void graph_panel_cursor_header(const bContext *C, Panel *pa) +static void graph_panel_cursor_header(const bContext *C, Panel *panel) { bScreen *screen = CTX_wm_screen(C); SpaceGraph *sipo = CTX_wm_space_graph(C); @@ -124,17 +124,17 @@ static void graph_panel_cursor_header(const bContext *C, Panel *pa) RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col = uiLayoutColumn(pa->layout, false); + col = uiLayoutColumn(panel->layout, false); uiItemR(col, &spaceptr, "show_cursor", 0, "", ICON_NONE); } -static void graph_panel_cursor(const bContext *C, Panel *pa) +static void graph_panel_cursor(const bContext *C, Panel *panel) { bScreen *screen = CTX_wm_screen(C); SpaceGraph *sipo = CTX_wm_space_graph(C); Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *col, *sub; /* get RNA pointers for use when creating the UI elements */ @@ -164,12 +164,12 @@ static void graph_panel_cursor(const bContext *C, Panel *pa) /* ******************* active F-Curve ************** */ -static void graph_panel_properties(const bContext *C, Panel *pa) +static void graph_panel_properties(const bContext *C, Panel *panel) { bAnimListElem *ale; FCurve *fcu; PointerRNA fcu_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *col; char name[256]; int icon = 0; @@ -345,13 +345,13 @@ static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr bezt->f3 = f3; } -static void graph_panel_key_properties(const bContext *C, Panel *pa) +static void graph_panel_key_properties(const bContext *C, Panel *panel) { bAnimListElem *ale; FCurve *fcu; BezTriple *bezt, *prevbezt; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; const ARegion *region = CTX_wm_region(C); /* Just a width big enough so buttons use entire layout width (will be clamped by it then). */ const int but_max_width = region->winx; @@ -1227,7 +1227,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, /* Panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve, * but useful for clarity. */ -static void graph_panel_driven_property(const bContext *C, Panel *pa) +static void graph_panel_driven_property(const bContext *C, Panel *panel) { bAnimListElem *ale; FCurve *fcu; @@ -1236,14 +1236,14 @@ static void graph_panel_driven_property(const bContext *C, Panel *pa) return; } - graph_draw_driven_property_panel(pa->layout, ale->id, fcu); + graph_draw_driven_property_panel(panel->layout, ale->id, fcu); MEM_freeN(ale); } /* driver settings for active F-Curve * (only for 'Drivers' mode in Graph Editor, i.e. the full "Drivers Editor") */ -static void graph_panel_drivers(const bContext *C, Panel *pa) +static void graph_panel_drivers(const bContext *C, Panel *panel) { bAnimListElem *ale; FCurve *fcu; @@ -1253,7 +1253,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) return; } - graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false); + graph_draw_driver_settings_panel(panel->layout, ale->id, fcu, false); /* cleanup */ MEM_freeN(ale); @@ -1269,9 +1269,9 @@ static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSE } /* popover panel for driver editing anywhere in ui */ -static void graph_panel_drivers_popover(const bContext *C, Panel *pa) +static void graph_panel_drivers_popover(const bContext *C, Panel *panel) { - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; @@ -1303,7 +1303,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa) /* Driven Property Settings */ uiItemL(layout, IFACE_("Driven Property:"), ICON_NONE); - graph_draw_driven_property_panel(pa->layout, id, fcu); + graph_draw_driven_property_panel(panel->layout, id, fcu); /* TODO: All vs Single */ uiItemS(layout); @@ -1311,7 +1311,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa) /* Drivers Settings */ uiItemL(layout, IFACE_("Driver Settings:"), ICON_NONE); - graph_draw_driver_settings_panel(pa->layout, id, fcu, true); + graph_draw_driver_settings_panel(panel->layout, id, fcu, true); } } @@ -1334,7 +1334,7 @@ static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int } } -static void graph_panel_modifiers(const bContext *C, Panel *pa) +static void graph_panel_modifiers(const bContext *C, Panel *panel) { bAnimListElem *ale; FCurve *fcu; @@ -1347,12 +1347,12 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) return; } - block = uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(panel->layout); UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL); /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, false); + row = uiLayoutRow(panel->layout, false); /* this is an operator button which calls a 'add modifier' operator... * a menu might be nicer but would be tricky as we need some custom filtering @@ -1369,7 +1369,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) active = !(fcu->flag & FCURVE_MOD_OFF); /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, true); + col = uiLayoutColumn(panel->layout, true); uiLayoutSetActive(col, active); ANIM_uiTemplate_fmodifier_draw(col, ale->fcurve_owner_id, &fcu->modifiers, fcm); diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index ca7f8791f75..218e2be0362 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -242,11 +242,11 @@ static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* -------------- */ /* active AnimData */ -static void nla_panel_animdata(const bContext *C, Panel *pa) +static void nla_panel_animdata(const bContext *C, Panel *panel) { PointerRNA adt_ptr; /* AnimData *adt; */ - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *row; uiBlock *block; @@ -312,10 +312,10 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) } /* generic settings for active NLA-Strip */ -static void nla_panel_stripname(const bContext *C, Panel *pa) +static void nla_panel_stripname(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *row; uiBlock *block; @@ -350,10 +350,10 @@ static void nla_panel_stripname(const bContext *C, Panel *pa) } /* generic settings for active NLA-Strip */ -static void nla_panel_properties(const bContext *C, Panel *pa) +static void nla_panel_properties(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *column; uiBlock *block; short showEvalProps = 1; @@ -419,10 +419,10 @@ static void nla_panel_properties(const bContext *C, Panel *pa) } /* action-clip only settings for active NLA-Strip */ -static void nla_panel_actclip(const bContext *C, Panel *pa) +static void nla_panel_actclip(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *column, *row; uiBlock *block; @@ -461,10 +461,10 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) } /* evaluation settings for active NLA-Strip */ -static void nla_panel_animated_influence_header(const bContext *C, Panel *pa) +static void nla_panel_animated_influence_header(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *col; uiBlock *block; @@ -481,10 +481,10 @@ static void nla_panel_animated_influence_header(const bContext *C, Panel *pa) } /* evaluation settings for active NLA-Strip */ -static void nla_panel_evaluation(const bContext *C, Panel *pa) +static void nla_panel_evaluation(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiBlock *block; /* check context and also validity of pointer */ @@ -500,10 +500,10 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) uiItemR(layout, &strip_ptr, "influence", 0, NULL, ICON_NONE); } -static void nla_panel_animated_strip_time_header(const bContext *C, Panel *pa) +static void nla_panel_animated_strip_time_header(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiLayout *col; uiBlock *block; @@ -519,10 +519,10 @@ static void nla_panel_animated_strip_time_header(const bContext *C, Panel *pa) uiItemR(col, &strip_ptr, "use_animated_time", 0, "", ICON_NONE); } -static void nla_panel_animated_strip_time(const bContext *C, Panel *pa) +static void nla_panel_animated_strip_time(const bContext *C, Panel *panel) { PointerRNA strip_ptr; - uiLayout *layout = pa->layout; + uiLayout *layout = panel->layout; uiBlock *block; /* check context and also validity of pointer */ @@ -539,7 +539,7 @@ static void nla_panel_animated_strip_time(const bContext *C, Panel *pa) } /* F-Modifiers for active NLA-Strip */ -static void nla_panel_modifiers(const bContext *C, Panel *pa) +static void nla_panel_modifiers(const bContext *C, Panel *panel) { PointerRNA strip_ptr; NlaStrip *strip; @@ -553,12 +553,12 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) } strip = strip_ptr.data; - block = uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(panel->layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, false); + row = uiLayoutRow(panel->layout, false); block = uiLayoutGetBlock(row); // FIXME: we need to set the only-active property so that this @@ -574,7 +574,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* draw each modifier */ for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, true); + col = uiLayoutColumn(panel->layout, true); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.owner_id, &strip->modifiers, fcm); } diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index ee1d2b43c5f..4cf67dddb57 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -66,13 +66,13 @@ static bool node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) return (snode && snode->nodetree && G.debug_value == 777); } -static void node_sockets_panel(const bContext *C, Panel *pa) +static void node_sockets_panel(const bContext *C, Panel *panel) { SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = (snode) ? snode->edittree : NULL; bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; bNodeSocket *sock; - uiLayout *layout = pa->layout, *split; + uiLayout *layout = panel->layout, *split; char name[UI_MAX_NAME_STR]; if (ELEM(NULL, ntree, node)) { @@ -119,13 +119,13 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock, return false; } -static void node_tree_interface_panel(const bContext *C, Panel *pa) +static void node_tree_interface_panel(const bContext *C, Panel *panel) { SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = (snode) ? snode->edittree : NULL; bNodeSocket *sock; int in_out; - uiLayout *layout = pa->layout, *row, *split, *col; + uiLayout *layout = panel->layout, *row, *split, *col; PointerRNA ptr, sockptr, opptr; wmOperatorType *ot; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 80ab18cd3db..7965422c117 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1140,9 +1140,9 @@ static bool view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) return false; } -static void view3d_panel_vgroup(const bContext *C, Panel *pa) +static void view3d_panel_vgroup(const bContext *C, Panel *panel) { - uiBlock *block = uiLayoutAbsoluteBlock(pa->layout); + uiBlock *block = uiLayoutAbsoluteBlock(panel->layout); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = view_layer->basact->object; @@ -1171,7 +1171,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) UI_block_func_handle_set(block, do_view3d_vgroup_buttons, NULL); - bcol = uiLayoutColumn(pa->layout, true); + bcol = uiLayoutColumn(panel->layout, true); row = uiLayoutRow(bcol, true); /* The filter button row */ RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr); @@ -1269,7 +1269,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) yco -= 2; - col = uiLayoutColumn(pa->layout, true); + col = uiLayoutColumn(panel->layout, true); row = uiLayoutRow(col, true); ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active_vertex", 1); @@ -1555,7 +1555,7 @@ static bool view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt) return (view_layer->basact != NULL); } -static void view3d_panel_transform(const bContext *C, Panel *pa) +static void view3d_panel_transform(const bContext *C, Panel *panel) { uiBlock *block; ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1563,10 +1563,10 @@ static void view3d_panel_transform(const bContext *C, Panel *pa) Object *obedit = OBEDIT_FROM_OBACT(ob); uiLayout *col; - block = uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(panel->layout); UI_block_func_handle_set(block, do_view3d_region_buttons, NULL); - col = uiLayoutColumn(pa->layout, false); + col = uiLayoutColumn(panel->layout, false); if (ob == obedit) { if (ob->type == OB_ARMATURE) { diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 887ce274680..c072220842e 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -259,11 +259,11 @@ static bool image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) return ED_uvedit_test(obedit); } -static void image_panel_uv(const bContext *C, Panel *pa) +static void image_panel_uv(const bContext *C, Panel *panel) { uiBlock *block; - block = uiLayoutAbsoluteBlock(pa->layout); + block = uiLayoutAbsoluteBlock(panel->layout); UI_block_func_handle_set(block, do_uvedit_vertex, NULL); uvedit_vertex_buttons(C, block); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index a94e3d26862..ca466ce2821 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -128,7 +128,7 @@ static bool panel_poll(const bContext *C, PanelType *pt) return visible; } -static void panel_draw(const bContext *C, Panel *pnl) +static void panel_draw(const bContext *C, Panel *panel) { extern FunctionRNA rna_Panel_draw_func; @@ -136,17 +136,17 @@ static void panel_draw(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr); func = &rna_Panel_draw_func; /* RNA_struct_find_function(&ptr, "draw"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); + panel->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } -static void panel_draw_header(const bContext *C, Panel *pnl) +static void panel_draw_header(const bContext *C, Panel *panel) { extern FunctionRNA rna_Panel_draw_header_func; @@ -154,17 +154,17 @@ static void panel_draw_header(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr); func = &rna_Panel_draw_header_func; /* RNA_struct_find_function(&ptr, "draw_header"); */ RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); + panel->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } -static void panel_draw_header_preset(const bContext *C, Panel *pnl) +static void panel_draw_header_preset(const bContext *C, Panel *panel) { extern FunctionRNA rna_Panel_draw_header_preset_func; @@ -172,12 +172,12 @@ static void panel_draw_header_preset(const bContext *C, Panel *pnl) ParameterList list; FunctionRNA *func; - RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->rna_ext.srna, pnl, &ptr); + RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr); func = &rna_Panel_draw_header_preset_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &C); - pnl->type->rna_ext.call((bContext *)C, &ptr, func, &list); + panel->type->rna_ext.call((bContext *)C, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -221,9 +221,9 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) &sl->regionbase; LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->type == art) { - LISTBASE_FOREACH (Panel *, pa, ®ion->panels) { - if (pa->type == pt) { - pa->type = NULL; + LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { + if (panel->type == pt) { + panel->type = NULL; } } } -- cgit v1.2.3 From fe98d8c0eabcd287dc452c893e569e7448ad029a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sat, 4 Apr 2020 14:13:53 +0200 Subject: Cleanup: remove unused method --- source/blender/blenlib/BLI_string_map.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/source/blender/blenlib/BLI_string_map.h b/source/blender/blenlib/BLI_string_map.h index ed97a6ae349..f304b140bcc 100644 --- a/source/blender/blenlib/BLI_string_map.h +++ b/source/blender/blenlib/BLI_string_map.h @@ -450,15 +450,6 @@ template class StringMap { } ITER_SLOTS_END(offset); } - - template void add__impl(StringRef key, ForwardT &&value) - { - this->ensure_can_add(); - uint32_t hash = this->compute_string_hash(key); - ITER_SLOTS_BEGIN (hash, m_array, , item, offset) { - } - ITER_SLOTS_END(offset); - } }; #undef ITER_SLOTS_BEGIN -- cgit v1.2.3 From a702b095a1e2cb1b1cbb572ccb464e300f9fcb42 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sat, 4 Apr 2020 12:31:33 -0400 Subject: UI: Remove 'Simulation' from 'Fluid Simulation' modifier This is conistent with other modifiers and is reduntent with the 'Simulate' menu header. --- source/blender/makesrna/intern/rna_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 562fff1bf50..36db4e5b33a 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -275,7 +275,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_EXPLODE, "Explode", "Break apart the mesh faces and let them follow particles"}, - {eModifierType_Fluid, "FLUID", ICON_MOD_FLUIDSIM, "Fluid Simulation", ""}, + {eModifierType_Fluid, "FLUID", ICON_MOD_FLUIDSIM, "Fluid", ""}, {eModifierType_Ocean, "OCEAN", ICON_MOD_OCEAN, "Ocean", "Generate a moving ocean surface"}, {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", -- cgit v1.2.3 From e455536943a862334a765fdef7edfd16b2e9b5b1 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sat, 4 Apr 2020 12:41:58 -0400 Subject: UI: 3D Viewport text edit menus - Adds select menu - Removes undo/redo controls - Adds delete menu - Refactor - Combines font and text menu The goal is to match other edit menus better and match the text editor. --- .../keyconfig/keymap_data/blender_default.py | 2 +- .../keymap_data/industry_compatible_data.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 160 ++++++++++++--------- 3 files changed, 97 insertions(+), 67 deletions(-) diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 7ee42fc4dc4..3944f8f0817 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -4782,7 +4782,7 @@ def km_font(params): ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), ("font.text_insert", {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, {"properties": [("accent", True)]}), - *_template_items_context_menu("VIEW3D_MT_edit_text_context_menu", params.context_menu_event), + *_template_items_context_menu("VIEW3D_MT_edit_font_context_menu", params.context_menu_event), ]) return keymap diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index 46beda12033..729a1987ab7 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -3747,7 +3747,7 @@ def km_font(params): ("font.text_insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), ("font.text_insert", {"type": 'BACK_SPACE', "value": 'PRESS', "alt": True}, {"properties": [("accent", True)]}), - *_template_items_context_menu("VIEW3D_MT_edit_text_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), + *_template_items_context_menu("VIEW3D_MT_edit_font_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), ]) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c3245b943da..88b94a86f00 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1706,60 +1706,33 @@ class VIEW3D_MT_select_edit_surface(Menu): layout.operator("curve.select_less") -class VIEW3D_MT_edit_text_context_menu(Menu): - bl_label = "Text Context Menu" - - def draw(self, _context): - layout = self.layout - - layout.operator_context = 'INVOKE_DEFAULT' - - layout.operator("font.text_cut", text="Cut") - layout.operator("font.text_copy", text="Copy", icon='COPYDOWN') - layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN') - - layout.separator() - - layout.operator("font.select_all") - - layout.separator() - - layout.menu("VIEW3D_MT_edit_font") - - class VIEW3D_MT_select_edit_text(Menu): - # intentional name mismatch - # select menu for 3d-text doesn't make sense - bl_label = "Edit" + bl_label = "Select" def draw(self, _context): layout = self.layout - layout.operator("ed.undo") - layout.operator("ed.redo") - - layout.separator() - - layout.operator("font.text_cut", text="Cut") - layout.operator("font.text_copy", text="Copy", icon='COPYDOWN') - layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN') + layout.operator("font.select_all", text="All") layout.separator() - layout.operator("font.text_paste_from_file") + layout.operator("font.move_select", text="Previous Block").type = 'PREVIOUS_PAGE' + layout.operator("font.move_select", text="Next Block").type = 'NEXT_PAGE' layout.separator() - layout.operator("font.select_all") + layout.operator("font.move_select", text="Line Begin").type = 'LINE_BEGIN' + layout.operator("font.move_select", text="Line End").type = 'LINE_END' layout.separator() - layout.operator("font.case_set", text="To Uppercase").case = 'UPPER' - layout.operator("font.case_set", text="To Lowercase").case = 'LOWER' + layout.operator("font.move_select", text="Previous Line").type = 'PREVIOUS_LINE' + layout.operator("font.move_select", text="Next Line").type = 'NEXT_LINE' layout.separator() - layout.menu("VIEW3D_MT_edit_text_chars") + layout.operator("font.move_select", text="Previous Word").type = 'PREVIOUS_WORD' + layout.operator("font.move_select", text="Next Word").type = 'NEXT_WORD' class VIEW3D_MT_select_edit_metaball(Menu): @@ -4512,18 +4485,44 @@ class VIEW3D_MT_edit_surface(Menu): draw = draw_curve -class VIEW3D_MT_edit_font(Menu): - bl_label = "Font" +class VIEW3D_MT_edit_font_chars(Menu): + bl_label = "Special Characters" def draw(self, _context): layout = self.layout - layout.operator("font.style_toggle", text="Toggle Bold", icon='BOLD').style = 'BOLD' - layout.operator("font.style_toggle", text="Toggle Italic", icon='ITALIC').style = 'ITALIC' - layout.operator("font.style_toggle", text="Toggle Underline", icon='UNDERLINE').style = 'UNDERLINE' - layout.operator("font.style_toggle", text="Toggle Small Caps", icon='SMALL_CAPS').style = 'SMALL_CAPS' + layout.operator("font.text_insert", text="Copyright").text = "\u00A9" + layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE" - layout.menu("VIEW3D_MT_edit_font_kerning") + layout.separator() + + layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0" + layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7" + layout.operator("font.text_insert", text="Circle").text = "\u008A" + + layout.separator() + + layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9" + layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2" + layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3" + + layout.separator() + + layout.operator("font.text_insert", text="Double >>").text = "\u00BB" + layout.operator("font.text_insert", text="Double <<").text = "\u00AB" + layout.operator("font.text_insert", text="Promillage").text = "\u2030" + + layout.separator() + + layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4" + layout.operator("font.text_insert", text="British Pound").text = "\u00A3" + layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5" + + layout.separator() + + layout.operator("font.text_insert", text="German S").text = "\u00DF" + layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF" + layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1" class VIEW3D_MT_edit_font_kerning(Menu): @@ -4541,44 +4540,74 @@ class VIEW3D_MT_edit_font_kerning(Menu): layout.operator("font.change_spacing", text="Reset Kerning").delta = -kerning -class VIEW3D_MT_edit_text_chars(Menu): - bl_label = "Special Characters" +class VIEW3D_MT_edit_font_delete(Menu): + bl_label = "Delete" def draw(self, _context): layout = self.layout - layout.operator("font.text_insert", text="Copyright").text = "\u00A9" - layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE" + layout.operator("font.delete", text="Previous Character").type = 'PREVIOUS_CHARACTER' + layout.operator("font.delete", text="Next Character").type = 'NEXT_CHARACTER' + layout.operator("font.delete", text="Previous Word").type = 'PREVIOUS_WORD' + layout.operator("font.delete", text="Next Word").type = 'NEXT_WORD' + + +class VIEW3D_MT_edit_font(Menu): + bl_label = "Text" + + def draw(self, _context): + layout = self.layout + + layout.operator("font.text_cut", text="Cut") + layout.operator("font.text_copy", text="Copy", icon='COPYDOWN') + layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN') layout.separator() - layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0" - layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7" - layout.operator("font.text_insert", text="Circle").text = "\u008A" + layout.operator("font.text_paste_from_file") layout.separator() - layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9" - layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2" - layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3" + layout.operator("font.case_set", text="To Uppercase").case = 'UPPER' + layout.operator("font.case_set", text="To Lowercase").case = 'LOWER' layout.separator() - layout.operator("font.text_insert", text="Double >>").text = "\u00BB" - layout.operator("font.text_insert", text="Double <<").text = "\u00AB" - layout.operator("font.text_insert", text="Promillage").text = "\u2030" + layout.menu("VIEW3D_MT_edit_font_chars") layout.separator() - layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4" - layout.operator("font.text_insert", text="British Pound").text = "\u00A3" - layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5" + layout.operator("font.style_toggle", text="Toggle Bold", icon='BOLD').style = 'BOLD' + layout.operator("font.style_toggle", text="Toggle Italic", icon='ITALIC').style = 'ITALIC' + layout.operator("font.style_toggle", text="Toggle Underline", icon='UNDERLINE').style = 'UNDERLINE' + layout.operator("font.style_toggle", text="Toggle Small Caps", icon='SMALL_CAPS').style = 'SMALL_CAPS' + + layout.menu("VIEW3D_MT_edit_font_kerning") layout.separator() - layout.operator("font.text_insert", text="German S").text = "\u00DF" - layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF" - layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1" + layout.menu("VIEW3D_MT_edit_font_delete") + + +class VIEW3D_MT_edit_font_context_menu(Menu): + bl_label = "Text Context Menu" + + def draw(self, _context): + layout = self.layout + + layout.operator_context = 'INVOKE_DEFAULT' + + layout.operator("font.text_cut", text="Cut") + layout.operator("font.text_copy", text="Copy", icon='COPYDOWN') + layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN') + + layout.separator() + + layout.operator("font.select_all") + + layout.separator() + + layout.menu("VIEW3D_MT_edit_font") class VIEW3D_MT_edit_meta(Menu): @@ -7351,7 +7380,6 @@ classes = ( VIEW3D_MT_select_edit_mesh, VIEW3D_MT_select_edit_curve, VIEW3D_MT_select_edit_surface, - VIEW3D_MT_edit_text_context_menu, VIEW3D_MT_select_edit_text, VIEW3D_MT_select_edit_metaball, VIEW3D_MT_edit_lattice_context_menu, @@ -7465,8 +7493,10 @@ classes = ( VIEW3D_MT_edit_curve_showhide, VIEW3D_MT_edit_surface, VIEW3D_MT_edit_font, + VIEW3D_MT_edit_font_chars, VIEW3D_MT_edit_font_kerning, - VIEW3D_MT_edit_text_chars, + VIEW3D_MT_edit_font_delete, + VIEW3D_MT_edit_font_context_menu, VIEW3D_MT_edit_meta, VIEW3D_MT_edit_meta_showhide, VIEW3D_MT_edit_lattice, -- cgit v1.2.3 From 505a19ed75b2829a561475ab4acc075b715a8499 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Sat, 4 Apr 2020 02:17:49 +0200 Subject: Cleanup: Split up Window-Manager VR file (and related changes) Splits up wm_xr.c into multiple files in their own folder: source/blender/windowmanager/xr. So this matches how the message bus and gizmo code have their own folder and files. This allows better structuring and should make the code scale better. I rather do this early on than to wait until we end up with a single, huge file. Also improves a bit how data is prepared and updated for drawing. --- source/blender/windowmanager/CMakeLists.txt | 12 +- source/blender/windowmanager/intern/wm.c | 3 + source/blender/windowmanager/intern/wm_operators.c | 3 + source/blender/windowmanager/intern/wm_window.c | 3 + source/blender/windowmanager/intern/wm_xr.c | 737 --------------------- source/blender/windowmanager/wm.h | 12 +- source/blender/windowmanager/wm_surface.h | 2 +- source/blender/windowmanager/xr/intern/wm_xr.c | 163 +++++ .../blender/windowmanager/xr/intern/wm_xr_draw.c | 162 +++++ .../blender/windowmanager/xr/intern/wm_xr_intern.h | 91 +++ .../windowmanager/xr/intern/wm_xr_session.c | 411 ++++++++++++ source/blender/windowmanager/xr/wm_xr.h | 35 + 12 files changed, 884 insertions(+), 750 deletions(-) delete mode 100644 source/blender/windowmanager/intern/wm_xr.c create mode 100644 source/blender/windowmanager/xr/intern/wm_xr.c create mode 100644 source/blender/windowmanager/xr/intern/wm_xr_draw.c create mode 100644 source/blender/windowmanager/xr/intern/wm_xr_intern.h create mode 100644 source/blender/windowmanager/xr/intern/wm_xr_session.c create mode 100644 source/blender/windowmanager/xr/wm_xr.h diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index a1b67216f1a..90ff7bb8f85 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -191,8 +191,18 @@ endif() if(WITH_XR_OPENXR) add_definitions(-DWITH_XR_OPENXR) + + list(APPEND INC + xr + ) + list(APPEND SRC - intern/wm_xr.c + xr/intern/wm_xr.c + xr/intern/wm_xr_draw.c + xr/intern/wm_xr_session.c + + xr/wm_xr.h + xr/intern/wm_xr_intern.h ) endif() diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index e9d2ee9c662..54e6735175d 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -55,6 +55,9 @@ #include "wm_draw.h" #include "wm_event_system.h" #include "wm_window.h" +#ifdef WITH_XR_OPENXR +# include "wm_xr.h" +#endif #include "BKE_undo_system.h" #include "ED_screen.h" diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index f8e020b00d0..6d25874da45 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -106,6 +106,9 @@ #include "wm_event_types.h" #include "wm_files.h" #include "wm_window.h" +#ifdef WITH_XR_OPENXR +# include "wm_xr.h" +#endif #define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)") diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 699f618f956..a83432e0248 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -65,6 +65,9 @@ #include "wm_platform_support.h" #include "wm_window.h" #include "wm_window_private.h" +#ifdef WITH_XR_OPENXR +# include "wm_xr.h" +#endif #include "ED_anim_api.h" #include "ED_fileselect.h" diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c deleted file mode 100644 index be0c8b4798b..00000000000 --- a/source/blender/windowmanager/intern/wm_xr.c +++ /dev/null @@ -1,737 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** \file - * \ingroup wm - * - * \name Window-Manager XR API - * - * Implements Blender specific functionality for the GHOST_Xr API. - */ - -#include "BKE_context.h" -#include "BKE_global.h" -#include "BKE_idprop.h" -#include "BKE_main.h" -#include "BKE_object.h" -#include "BKE_report.h" -#include "BKE_screen.h" - -#include "BLI_ghash.h" -#include "BLI_math_geom.h" -#include "BLI_math_matrix.h" - -#include "CLG_log.h" - -#include "DNA_camera_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_view3d_types.h" -#include "DNA_xr_types.h" - -#include "DRW_engine.h" - -#include "ED_view3d.h" -#include "ED_view3d_offscreen.h" - -#include "GHOST_C-api.h" - -#include "GPU_context.h" -#include "GPU_draw.h" -#include "GPU_matrix.h" -#include "GPU_viewport.h" - -#include "MEM_guardedalloc.h" - -#include "UI_interface.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "wm.h" -#include "wm_surface.h" -#include "wm_window.h" - -struct wmXrRuntimeData *wm_xr_runtime_data_create(void); -void wm_xr_runtime_data_free(struct wmXrRuntimeData **runtime); -void wm_xr_draw_view(const GHOST_XrDrawViewInfo *, void *); -void *wm_xr_session_gpu_binding_context_create(void); -void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle); -wmSurface *wm_xr_session_surface_create(void); -void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]); - -/* -------------------------------------------------------------------- */ - -typedef struct wmXrSessionState { - bool is_started; - - /** Last known viewer pose (centroid of eyes, in world space) stored for queries. */ - GHOST_XrPose viewer_pose; - /** The last known view matrix, calculated from above's viewer pose. */ - float viewer_viewmat[4][4]; - float focal_len; - - /** Copy of XrSessionSettings.flag created on the last draw call, stored to detect changes. */ - int prev_settings_flag; - /** Copy of wmXrDrawData.eye_position_ofs. */ - float prev_eye_position_ofs[3]; - - bool is_view_data_set; -} wmXrSessionState; - -typedef struct wmXrRuntimeData { - GHOST_XrContextHandle context; - - /* Although this struct is internal, RNA gets a handle to this for state information queries. */ - wmXrSessionState session_state; - wmXrSessionExitFn exit_fn; -} wmXrRuntimeData; - -typedef struct wmXrDrawData { - /** The pose (location + rotation) to which eye deltas will be applied to when drawing (world - * space). With positional tracking enabled, it should be the same as the base pose, when - * disabled it also contains a location delta from the moment the option was toggled. */ - GHOST_XrPose base_pose; - float eye_position_ofs[3]; /* Local/view space. */ -} wmXrDrawData; - -typedef struct { - GPUOffScreen *offscreen; - GPUViewport *viewport; -} wmXrSurfaceData; - -typedef struct { - wmWindowManager *wm; -} wmXrErrorHandlerData; - -/* -------------------------------------------------------------------- */ - -static wmSurface *g_xr_surface = NULL; -static CLG_LogRef LOG = {"wm.xr"}; - -/* -------------------------------------------------------------------- */ -/** \name XR-Context - * - * All XR functionality is accessed through a #GHOST_XrContext handle. - * The lifetime of this context also determines the lifetime of the OpenXR instance, which is the - * representation of the OpenXR runtime connection within the application. - * - * \{ */ - -static void wm_xr_error_handler(const GHOST_XrError *error) -{ - wmXrErrorHandlerData *handler_data = error->customdata; - wmWindowManager *wm = handler_data->wm; - - BKE_reports_clear(&wm->reports); - WM_report(RPT_ERROR, error->user_message); - WM_report_banner_show(); - - if (wm->xr.runtime) { - /* Just play safe and destroy the entire runtime data, including context. */ - wm_xr_runtime_data_free(&wm->xr.runtime); - } -} - -bool wm_xr_init(wmWindowManager *wm) -{ - if (wm->xr.runtime && wm->xr.runtime->context) { - return true; - } - static wmXrErrorHandlerData error_customdata; - - /* Set up error handling */ - error_customdata.wm = wm; - GHOST_XrErrorHandler(wm_xr_error_handler, &error_customdata); - - { - const GHOST_TXrGraphicsBinding gpu_bindings_candidates[] = { - GHOST_kXrGraphicsOpenGL, -#ifdef WIN32 - GHOST_kXrGraphicsD3D11, -#endif - }; - GHOST_XrContextCreateInfo create_info = { - .gpu_binding_candidates = gpu_bindings_candidates, - .gpu_binding_candidates_count = ARRAY_SIZE(gpu_bindings_candidates), - }; - GHOST_XrContextHandle context; - - if (G.debug & G_DEBUG_XR) { - create_info.context_flag |= GHOST_kXrContextDebug; - } - if (G.debug & G_DEBUG_XR_TIME) { - create_info.context_flag |= GHOST_kXrContextDebugTime; - } - - if (!(context = GHOST_XrContextCreate(&create_info))) { - return false; - } - - /* Set up context callbacks */ - GHOST_XrGraphicsContextBindFuncs(context, - wm_xr_session_gpu_binding_context_create, - wm_xr_session_gpu_binding_context_destroy); - GHOST_XrDrawViewFunc(context, wm_xr_draw_view); - - if (!wm->xr.runtime) { - wm->xr.runtime = wm_xr_runtime_data_create(); - wm->xr.runtime->context = context; - } - } - BLI_assert(wm->xr.runtime && wm->xr.runtime->context); - - return true; -} - -void wm_xr_exit(wmWindowManager *wm) -{ - if (wm->xr.runtime != NULL) { - wm_xr_runtime_data_free(&wm->xr.runtime); - } - if (wm->xr.session_settings.shading.prop) { - IDP_FreeProperty(wm->xr.session_settings.shading.prop); - wm->xr.session_settings.shading.prop = NULL; - } -} - -bool wm_xr_events_handle(wmWindowManager *wm) -{ - if (wm->xr.runtime && wm->xr.runtime->context) { - return GHOST_XrEventsHandle(wm->xr.runtime->context); - } - return false; -} - -/** \} */ /* XR-Context */ - -/* -------------------------------------------------------------------- */ -/** \name XR Runtime Data - * - * \{ */ - -wmXrRuntimeData *wm_xr_runtime_data_create(void) -{ - wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__); - return runtime; -} - -void wm_xr_runtime_data_free(wmXrRuntimeData **runtime) -{ - /* Note that this function may be called twice, because of an indirect recursion: If a session is - * running while WM-XR calls this function, calling GHOST_XrContextDestroy() will call this - * again, because it's also set as the session exit callback. So NULL-check and NULL everything - * that is freed here. */ - - /* We free all runtime XR data here, so if the context is still alive, destroy it. */ - if ((*runtime)->context != NULL) { - GHOST_XrContextHandle context = (*runtime)->context; - /* Prevent recursive GHOST_XrContextDestroy() call by NULL'ing the context pointer before the - * first call, see comment above. */ - (*runtime)->context = NULL; - GHOST_XrContextDestroy(context); - } - MEM_SAFE_FREE(*runtime); -} - -static void wm_xr_base_pose_calc(const Scene *scene, - const XrSessionSettings *settings, - GHOST_XrPose *r_base_pose) -{ - const Object *base_pose_object = ((settings->base_pose_type == XR_BASE_POSE_OBJECT) && - settings->base_pose_object) ? - settings->base_pose_object : - scene->camera; - - if (settings->base_pose_type == XR_BASE_POSE_CUSTOM) { - float tmp_quatx[4], tmp_quatz[4]; - - copy_v3_v3(r_base_pose->position, settings->base_pose_location); - axis_angle_to_quat_single(tmp_quatx, 'X', M_PI_2); - axis_angle_to_quat_single(tmp_quatz, 'Z', settings->base_pose_angle); - mul_qt_qtqt(r_base_pose->orientation_quat, tmp_quatz, tmp_quatx); - } - else if (base_pose_object) { - float tmp_quat[4]; - float tmp_eul[3]; - - mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->obmat); - - /* Only use rotation around Z-axis to align view with floor. */ - quat_to_eul(tmp_eul, tmp_quat); - tmp_eul[0] = M_PI_2; - tmp_eul[1] = 0; - eul_to_quat(r_base_pose->orientation_quat, tmp_eul); - } - else { - copy_v3_fl(r_base_pose->position, 0.0f); - axis_angle_to_quat_single(r_base_pose->orientation_quat, 'X', M_PI_2); - } -} - -static void wm_xr_draw_data_populate(const wmXrSessionState *state, - const GHOST_XrDrawViewInfo *draw_view, - const XrSessionSettings *settings, - const Scene *scene, - wmXrDrawData *r_draw_data) -{ - const bool position_tracking_toggled = ((state->prev_settings_flag & - XR_SESSION_USE_POSITION_TRACKING) != - (settings->flag & XR_SESSION_USE_POSITION_TRACKING)); - const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING; - - memset(r_draw_data, 0, sizeof(*r_draw_data)); - - wm_xr_base_pose_calc(scene, settings, &r_draw_data->base_pose); - - /* Set the eye position offset, it's used to offset the base pose when changing positional - * tracking. */ - if (!state->is_view_data_set) { - /* Always use the exact base pose with no offset when starting the session. */ - copy_v3_fl(r_draw_data->eye_position_ofs, 0.0f); - } - else if (position_tracking_toggled) { - if (use_position_tracking) { - copy_v3_fl(r_draw_data->eye_position_ofs, 0.0f); - } - else { - /* Store the current local offset (local pose) so that we can apply that to the eyes. This - * way the eyes stay exactly where they are when disabling positional tracking. */ - copy_v3_v3(r_draw_data->eye_position_ofs, draw_view->local_pose.position); - } - } - else if (!use_position_tracking) { - /* Keep previous offset when positional tracking is disabled. */ - copy_v3_v3(r_draw_data->eye_position_ofs, state->prev_eye_position_ofs); - } -} - -/** - * Update information that is only stored for external state queries. E.g. for Python API to - * request the current (as in, last known) viewer pose. - */ -static void wm_xr_session_state_update(wmXrSessionState *state, - const GHOST_XrDrawViewInfo *draw_view, - const XrSessionSettings *settings, - const wmXrDrawData *draw_data) -{ - GHOST_XrPose viewer_pose; - const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING; - - mul_qt_qtqt(viewer_pose.orientation_quat, - draw_data->base_pose.orientation_quat, - draw_view->local_pose.orientation_quat); - copy_v3_v3(viewer_pose.position, draw_data->base_pose.position); - /* The local pose and the eye pose (which is copied from an earlier local pose) both are view - * space, so Y-up. In this case we need them in regular Z-up. */ - viewer_pose.position[0] += draw_data->eye_position_ofs[0]; - viewer_pose.position[1] -= draw_data->eye_position_ofs[2]; - viewer_pose.position[2] += draw_data->eye_position_ofs[1]; - if (use_position_tracking) { - viewer_pose.position[0] += draw_view->local_pose.position[0]; - viewer_pose.position[1] -= draw_view->local_pose.position[2]; - viewer_pose.position[2] += draw_view->local_pose.position[1]; - } - - copy_v3_v3(state->viewer_pose.position, viewer_pose.position); - copy_qt_qt(state->viewer_pose.orientation_quat, viewer_pose.orientation_quat); - wm_xr_pose_to_viewmat(&viewer_pose, state->viewer_viewmat); - /* No idea why, but multiplying by two seems to make it match the VR view more. */ - state->focal_len = 2.0f * - fov_to_focallength(draw_view->fov.angle_right - draw_view->fov.angle_left, - DEFAULT_SENSOR_WIDTH); - - copy_v3_v3(state->prev_eye_position_ofs, draw_data->eye_position_ofs); - state->prev_settings_flag = settings->flag; - state->is_view_data_set = true; -} - -wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr) -{ - return xr->runtime ? &xr->runtime->session_state : NULL; -} - -bool WM_xr_session_state_viewer_pose_location_get(const wmXrData *xr, float r_location[3]) -{ - if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { - zero_v3(r_location); - return false; - } - - copy_v3_v3(r_location, xr->runtime->session_state.viewer_pose.position); - return true; -} - -bool WM_xr_session_state_viewer_pose_rotation_get(const wmXrData *xr, float r_rotation[4]) -{ - if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { - unit_qt(r_rotation); - return false; - } - - copy_v4_v4(r_rotation, xr->runtime->session_state.viewer_pose.orientation_quat); - return true; -} - -bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr, - float r_viewmat[4][4], - float *r_focal_len) -{ - if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { - unit_m4(r_viewmat); - *r_focal_len = 0.0f; - return false; - } - - copy_m4_m4(r_viewmat, xr->runtime->session_state.viewer_viewmat); - *r_focal_len = xr->runtime->session_state.focal_len; - - return true; -} - -/** \} */ /* XR Runtime Data */ - -/* -------------------------------------------------------------------- */ -/** \name XR-Session - * - * \{ */ - -void *wm_xr_session_gpu_binding_context_create(void) -{ - wmSurface *surface = wm_xr_session_surface_create(); - - wm_surface_add(surface); - - /* Some regions may need to redraw with updated session state after the session is entirely up - * and running. */ - WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); - - return surface->ghost_ctx; -} - -void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(context)) -{ - if (g_xr_surface) { /* Might have been freed already */ - wm_surface_remove(g_xr_surface); - } - - wm_window_reset_drawable(); - - /* Some regions may need to redraw with updated session state after the session is entirely - * stopped. */ - WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); -} - -static void wm_xr_session_exit_cb(void *customdata) -{ - wmXrData *xr_data = customdata; - - xr_data->runtime->session_state.is_started = false; - if (xr_data->runtime->exit_fn) { - xr_data->runtime->exit_fn(xr_data); - } - - /* Free the entire runtime data (including session state and context), to play safe. */ - wm_xr_runtime_data_free(&xr_data->runtime); -} - -static void wm_xr_session_begin_info_create(wmXrData *xr_data, - GHOST_XrSessionBeginInfo *r_begin_info) -{ - /* WM-XR exit function, does some own stuff and calls callback passed to wm_xr_session_toggle(), - * to allow external code to execute its own session-exit logic. */ - r_begin_info->exit_fn = wm_xr_session_exit_cb; - r_begin_info->exit_customdata = xr_data; -} - -void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn) -{ - wmXrData *xr_data = &wm->xr; - - if (WM_xr_session_exists(xr_data)) { - GHOST_XrSessionEnd(xr_data->runtime->context); - } - else { - GHOST_XrSessionBeginInfo begin_info; - - xr_data->runtime->session_state.is_started = true; - xr_data->runtime->exit_fn = session_exit_fn; - - wm_xr_session_begin_info_create(xr_data, &begin_info); - GHOST_XrSessionStart(xr_data->runtime->context, &begin_info); - } -} - -/** - * Check if the XR-Session was triggered. - * If an error happened while trying to start a session, this returns false too. - */ -bool WM_xr_session_exists(const wmXrData *xr) -{ - return xr->runtime && xr->runtime->context && xr->runtime->session_state.is_started; -} - -/** - * Check if the session is running, according to the OpenXR definition. - */ -bool WM_xr_session_is_ready(const wmXrData *xr) -{ - return WM_xr_session_exists(xr) && GHOST_XrSessionIsRunning(xr->runtime->context); -} - -/** \} */ /* XR-Session */ - -/* -------------------------------------------------------------------- */ -/** \name XR-Session Surface - * - * A wmSurface is used to manage drawing of the VR viewport. It's created and destroyed with the - * session. - * - * \{ */ - -/** - * \brief Call Ghost-XR to draw a frame - * - * Draw callback for the XR-session surface. It's expected to be called on each main loop iteration - * and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing each view, - * #wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()). - */ -static void wm_xr_session_surface_draw(bContext *C) -{ - wmXrSurfaceData *surface_data = g_xr_surface->customdata; - wmWindowManager *wm = CTX_wm_manager(C); - - if (!GHOST_XrSessionIsRunning(wm->xr.runtime->context)) { - return; - } - DRW_xr_drawing_begin(); - GHOST_XrSessionDrawViews(wm->xr.runtime->context, C); - GPU_offscreen_unbind(surface_data->offscreen, false); - DRW_xr_drawing_end(); -} - -static void wm_xr_session_free_data(wmSurface *surface) -{ - wmXrSurfaceData *data = surface->customdata; - - if (data->viewport) { - GPU_viewport_free(data->viewport); - } - if (data->offscreen) { - GPU_offscreen_free(data->offscreen); - } - - MEM_freeN(surface->customdata); - - g_xr_surface = NULL; -} - -static bool wm_xr_session_surface_offscreen_ensure(const GHOST_XrDrawViewInfo *draw_view) -{ - wmXrSurfaceData *surface_data = g_xr_surface->customdata; - const bool size_changed = surface_data->offscreen && - (GPU_offscreen_width(surface_data->offscreen) != draw_view->width) && - (GPU_offscreen_height(surface_data->offscreen) != draw_view->height); - char err_out[256] = "unknown"; - bool failure = false; - - if (surface_data->offscreen) { - BLI_assert(surface_data->viewport); - - if (!size_changed) { - return true; - } - GPU_viewport_free(surface_data->viewport); - GPU_offscreen_free(surface_data->offscreen); - } - - if (!(surface_data->offscreen = GPU_offscreen_create( - draw_view->width, draw_view->height, 0, true, false, err_out))) { - failure = true; - } - - if (failure) { - /* Pass. */ - } - else if (!(surface_data->viewport = GPU_viewport_create())) { - GPU_offscreen_free(surface_data->offscreen); - failure = true; - } - - if (failure) { - CLOG_ERROR(&LOG, "Failed to get buffer, %s\n", err_out); - return false; - } - - return true; -} - -wmSurface *wm_xr_session_surface_create(void) -{ - if (g_xr_surface) { - BLI_assert(false); - return g_xr_surface; - } - - wmSurface *surface = MEM_callocN(sizeof(*surface), __func__); - wmXrSurfaceData *data = MEM_callocN(sizeof(*data), "XrSurfaceData"); - - surface->draw = wm_xr_session_surface_draw; - surface->free_data = wm_xr_session_free_data; - surface->ghost_ctx = DRW_xr_opengl_context_get(); - surface->gpu_ctx = DRW_xr_gpu_context_get(); - - surface->customdata = data; - - g_xr_surface = surface; - - return surface; -} - -/** \} */ /* XR-Session Surface */ - -/* -------------------------------------------------------------------- */ -/** \name XR Drawing - * - * \{ */ - -void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]) -{ - float iquat[4]; - invert_qt_qt_normalized(iquat, pose->orientation_quat); - quat_to_mat4(r_viewmat, iquat); - translate_m4(r_viewmat, -pose->position[0], -pose->position[1], -pose->position[2]); -} - -static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data, - const GHOST_XrDrawViewInfo *draw_view, - const XrSessionSettings *session_settings, - float r_view_mat[4][4], - float r_proj_mat[4][4]) -{ - GHOST_XrPose eye_pose; - - copy_qt_qt(eye_pose.orientation_quat, draw_view->eye_pose.orientation_quat); - copy_v3_v3(eye_pose.position, draw_view->eye_pose.position); - add_v3_v3(eye_pose.position, draw_data->eye_position_ofs); - if ((session_settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) { - sub_v3_v3(eye_pose.position, draw_view->local_pose.position); - } - - perspective_m4_fov(r_proj_mat, - draw_view->fov.angle_left, - draw_view->fov.angle_right, - draw_view->fov.angle_up, - draw_view->fov.angle_down, - session_settings->clip_start, - session_settings->clip_end); - - float eye_mat[4][4]; - float base_mat[4][4]; - - wm_xr_pose_to_viewmat(&eye_pose, eye_mat); - /* Calculate the base pose matrix (in world space!). */ - wm_xr_pose_to_viewmat(&draw_data->base_pose, base_mat); - - mul_m4_m4m4(r_view_mat, eye_mat, base_mat); -} - -static void wm_xr_draw_viewport_buffers_to_active_framebuffer( - const wmXrRuntimeData *runtime_data, - const wmXrSurfaceData *surface_data, - const GHOST_XrDrawViewInfo *draw_view) -{ - const bool is_upside_down = GHOST_XrSessionNeedsUpsideDownDrawing(runtime_data->context); - rcti rect = {.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1}; - - wmViewport(&rect); - - /* For upside down contexts, draw with inverted y-values. */ - if (is_upside_down) { - SWAP(int, rect.ymin, rect.ymax); - } - GPU_viewport_draw_to_screen_ex(surface_data->viewport, 0, &rect, draw_view->expects_srgb_buffer); -} - -/** - * \brief Draw a viewport for a single eye. - * - * This is the main viewport drawing function for VR sessions. It's assigned to Ghost-XR as a - * callback (see GHOST_XrDrawViewFunc()) and executed for each view (read: eye). - */ -void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) -{ - bContext *C = customdata; - wmWindowManager *wm = CTX_wm_manager(C); - wmXrSurfaceData *surface_data = g_xr_surface->customdata; - wmXrSessionState *session_state = &wm->xr.runtime->session_state; - XrSessionSettings *settings = &wm->xr.session_settings; - wmXrDrawData draw_data; - Scene *scene = CTX_data_scene(C); - - const int display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags; - - float viewmat[4][4], winmat[4][4]; - - BLI_assert(WM_xr_session_is_ready(&wm->xr)); - - wm_xr_draw_data_populate(session_state, draw_view, settings, scene, &draw_data); - wm_xr_draw_matrices_create(&draw_data, draw_view, settings, viewmat, winmat); - wm_xr_session_state_update(session_state, draw_view, settings, &draw_data); - - if (!wm_xr_session_surface_offscreen_ensure(draw_view)) { - return; - } - - /* In case a framebuffer is still bound from drawing the last eye. */ - GPU_framebuffer_restore(); - /* Some systems have drawing glitches without this. */ - GPU_clear(GPU_DEPTH_BIT); - - /* Draws the view into the surface_data->viewport's framebuffers */ - ED_view3d_draw_offscreen_simple(CTX_data_ensure_evaluated_depsgraph(C), - scene, - &wm->xr.session_settings.shading, - wm->xr.session_settings.shading.type, - draw_view->width, - draw_view->height, - display_flags, - viewmat, - winmat, - settings->clip_start, - settings->clip_end, - false, - true, - true, - NULL, - false, - surface_data->offscreen, - surface_data->viewport); - - /* The draw-manager uses both GPUOffscreen and GPUViewport to manage frame and texture buffers. A - * call to GPU_viewport_draw_to_screen() is still needed to get the final result from the - * viewport buffers composited together and potentially color managed for display on screen. - * It needs a bound frame-buffer to draw into, for which we simply reuse the GPUOffscreen one. - * - * In a next step, Ghost-XR will use the currently bound frame-buffer to retrieve the image - * to be submitted to the OpenXR swap-chain. So do not un-bind the off-screen yet! */ - - GPU_offscreen_bind(surface_data->offscreen, false); - - wm_xr_draw_viewport_buffers_to_active_framebuffer(wm->xr.runtime, surface_data, draw_view); -} - -/** \} */ /* XR Drawing */ diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 97403a0315a..e5df4a44bd4 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -96,14 +96,4 @@ void wm_stereo3d_set_cancel(bContext *C, wmOperator *op); void wm_open_init_load_ui(wmOperator *op, bool use_prefs); void wm_open_init_use_scripts(wmOperator *op, bool use_prefs); -#ifdef WITH_XR_OPENXR -typedef void (*wmXrSessionExitFn)(const wmXrData *xr_data); - -/* wm_xr.c */ -bool wm_xr_init(wmWindowManager *wm); -void wm_xr_exit(wmWindowManager *wm); -void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn); -bool wm_xr_events_handle(wmWindowManager *wm); -#endif - -#endif /* __WM_H__ */ +#endif \ No newline at end of file diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h index 98d67c55619..e1b00ae1ade 100644 --- a/source/blender/windowmanager/wm_surface.h +++ b/source/blender/windowmanager/wm_surface.h @@ -46,7 +46,7 @@ void wm_surface_remove(wmSurface *surface); void wm_surfaces_free(void); /* Utils */ -void wm_surfaces_iter(struct bContext *C, void (*cb)(bContext *, wmSurface *)); +void wm_surfaces_iter(struct bContext *C, void (*cb)(struct bContext *, wmSurface *)); /* Drawing */ void wm_surface_make_drawable(wmSurface *surface); diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c new file mode 100644 index 00000000000..69c9034d51f --- /dev/null +++ b/source/blender/windowmanager/xr/intern/wm_xr.c @@ -0,0 +1,163 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup wm + * + * All XR functionality is accessed through a #GHOST_XrContext handle. + * The lifetime of this context also determines the lifetime of the OpenXR instance, which is the + * representation of the OpenXR runtime connection within the application. + */ + +#include "BKE_global.h" +#include "BKE_idprop.h" +#include "BKE_report.h" + +#include "DNA_scene_types.h" +#include "DNA_windowmanager_types.h" + +#include "DEG_depsgraph.h" + +#include "MEM_guardedalloc.h" + +#include "GHOST_C-api.h" + +#include "WM_api.h" + +#include "wm_surface.h" +#include "wm_xr_intern.h" + +typedef struct { + wmWindowManager *wm; +} wmXrErrorHandlerData; + +/* -------------------------------------------------------------------- */ + +static void wm_xr_error_handler(const GHOST_XrError *error) +{ + wmXrErrorHandlerData *handler_data = error->customdata; + wmWindowManager *wm = handler_data->wm; + + BKE_reports_clear(&wm->reports); + WM_report(RPT_ERROR, error->user_message); + WM_report_banner_show(); + + if (wm->xr.runtime) { + /* Just play safe and destroy the entire runtime data, including context. */ + wm_xr_runtime_data_free(&wm->xr.runtime); + } +} + +bool wm_xr_init(wmWindowManager *wm) +{ + if (wm->xr.runtime && wm->xr.runtime->context) { + return true; + } + static wmXrErrorHandlerData error_customdata; + + /* Set up error handling */ + error_customdata.wm = wm; + GHOST_XrErrorHandler(wm_xr_error_handler, &error_customdata); + + { + const GHOST_TXrGraphicsBinding gpu_bindings_candidates[] = { + GHOST_kXrGraphicsOpenGL, +#ifdef WIN32 + GHOST_kXrGraphicsD3D11, +#endif + }; + GHOST_XrContextCreateInfo create_info = { + .gpu_binding_candidates = gpu_bindings_candidates, + .gpu_binding_candidates_count = ARRAY_SIZE(gpu_bindings_candidates), + }; + GHOST_XrContextHandle context; + + if (G.debug & G_DEBUG_XR) { + create_info.context_flag |= GHOST_kXrContextDebug; + } + if (G.debug & G_DEBUG_XR_TIME) { + create_info.context_flag |= GHOST_kXrContextDebugTime; + } + + if (!(context = GHOST_XrContextCreate(&create_info))) { + return false; + } + + /* Set up context callbacks */ + GHOST_XrGraphicsContextBindFuncs(context, + wm_xr_session_gpu_binding_context_create, + wm_xr_session_gpu_binding_context_destroy); + GHOST_XrDrawViewFunc(context, wm_xr_draw_view); + + if (!wm->xr.runtime) { + wm->xr.runtime = wm_xr_runtime_data_create(); + wm->xr.runtime->context = context; + } + } + BLI_assert(wm->xr.runtime && wm->xr.runtime->context); + + return true; +} + +void wm_xr_exit(wmWindowManager *wm) +{ + if (wm->xr.runtime != NULL) { + wm_xr_runtime_data_free(&wm->xr.runtime); + } + if (wm->xr.session_settings.shading.prop) { + IDP_FreeProperty(wm->xr.session_settings.shading.prop); + wm->xr.session_settings.shading.prop = NULL; + } +} + +bool wm_xr_events_handle(wmWindowManager *wm) +{ + if (wm->xr.runtime && wm->xr.runtime->context) { + return GHOST_XrEventsHandle(wm->xr.runtime->context); + } + return false; +} + +/* -------------------------------------------------------------------- */ +/** \name XR Runtime Data + * + * \{ */ + +wmXrRuntimeData *wm_xr_runtime_data_create(void) +{ + wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__); + return runtime; +} + +void wm_xr_runtime_data_free(wmXrRuntimeData **runtime) +{ + /* Note that this function may be called twice, because of an indirect recursion: If a session is + * running while WM-XR calls this function, calling GHOST_XrContextDestroy() will call this + * again, because it's also set as the session exit callback. So NULL-check and NULL everything + * that is freed here. */ + + /* We free all runtime XR data here, so if the context is still alive, destroy it. */ + if ((*runtime)->context != NULL) { + GHOST_XrContextHandle context = (*runtime)->context; + /* Prevent recursive GHOST_XrContextDestroy() call by NULL'ing the context pointer before the + * first call, see comment above. */ + (*runtime)->context = NULL; + GHOST_XrContextDestroy(context); + } + MEM_SAFE_FREE(*runtime); +} + +/** \} */ /* XR Runtime Data */ diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c new file mode 100644 index 00000000000..684e59eb8b2 --- /dev/null +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c @@ -0,0 +1,162 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup wm + * + * \name Window-Manager XR Drawing + * + * Implements Blender specific drawing functionality for use with the Ghost-XR API. + */ + +#include + +#include "BLI_math.h" + +#include "ED_view3d_offscreen.h" + +#include "GHOST_C-api.h" + +#include "GPU_viewport.h" + +#include "WM_api.h" + +#include "wm_surface.h" +#include "wm_xr_intern.h" + +void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]) +{ + float iquat[4]; + invert_qt_qt_normalized(iquat, pose->orientation_quat); + quat_to_mat4(r_viewmat, iquat); + translate_m4(r_viewmat, -pose->position[0], -pose->position[1], -pose->position[2]); +} + +static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data, + const GHOST_XrDrawViewInfo *draw_view, + const XrSessionSettings *session_settings, + float r_view_mat[4][4], + float r_proj_mat[4][4]) +{ + GHOST_XrPose eye_pose; + + copy_qt_qt(eye_pose.orientation_quat, draw_view->eye_pose.orientation_quat); + copy_v3_v3(eye_pose.position, draw_view->eye_pose.position); + add_v3_v3(eye_pose.position, draw_data->eye_position_ofs); + if ((session_settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) { + sub_v3_v3(eye_pose.position, draw_view->local_pose.position); + } + + perspective_m4_fov(r_proj_mat, + draw_view->fov.angle_left, + draw_view->fov.angle_right, + draw_view->fov.angle_up, + draw_view->fov.angle_down, + session_settings->clip_start, + session_settings->clip_end); + + float eye_mat[4][4]; + float base_mat[4][4]; + + wm_xr_pose_to_viewmat(&eye_pose, eye_mat); + /* Calculate the base pose matrix (in world space!). */ + wm_xr_pose_to_viewmat(&draw_data->base_pose, base_mat); + + mul_m4_m4m4(r_view_mat, eye_mat, base_mat); +} + +static void wm_xr_draw_viewport_buffers_to_active_framebuffer( + const wmXrRuntimeData *runtime_data, + const wmXrSurfaceData *surface_data, + const GHOST_XrDrawViewInfo *draw_view) +{ + const bool is_upside_down = GHOST_XrSessionNeedsUpsideDownDrawing(runtime_data->context); + rcti rect = {.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1}; + + wmViewport(&rect); + + /* For upside down contexts, draw with inverted y-values. */ + if (is_upside_down) { + SWAP(int, rect.ymin, rect.ymax); + } + GPU_viewport_draw_to_screen_ex(surface_data->viewport, 0, &rect, draw_view->expects_srgb_buffer); +} + +/** + * \brief Draw a viewport for a single eye. + * + * This is the main viewport drawing function for VR sessions. It's assigned to Ghost-XR as a + * callback (see GHOST_XrDrawViewFunc()) and executed for each view (read: eye). + */ +void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata) +{ + wmXrDrawData *draw_data = customdata; + wmXrData *xr_data = draw_data->xr_data; + wmXrSurfaceData *surface_data = draw_data->surface_data; + wmXrSessionState *session_state = &xr_data->runtime->session_state; + XrSessionSettings *settings = &xr_data->session_settings; + + const int display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags; + + float viewmat[4][4], winmat[4][4]; + + BLI_assert(WM_xr_session_is_ready(xr_data)); + + wm_xr_session_draw_data_update(session_state, settings, draw_view, draw_data); + wm_xr_draw_matrices_create(draw_data, draw_view, settings, viewmat, winmat); + wm_xr_session_state_update(settings, draw_data, draw_view, session_state); + + if (!wm_xr_session_surface_offscreen_ensure(surface_data, draw_view)) { + return; + } + + /* In case a framebuffer is still bound from drawing the last eye. */ + GPU_framebuffer_restore(); + /* Some systems have drawing glitches without this. */ + GPU_clear(GPU_DEPTH_BIT); + + /* Draws the view into the surface_data->viewport's framebuffers */ + ED_view3d_draw_offscreen_simple(draw_data->depsgraph, + draw_data->scene, + &settings->shading, + settings->shading.type, + draw_view->width, + draw_view->height, + display_flags, + viewmat, + winmat, + settings->clip_start, + settings->clip_end, + false, + true, + true, + NULL, + false, + surface_data->offscreen, + surface_data->viewport); + + /* The draw-manager uses both GPUOffscreen and GPUViewport to manage frame and texture buffers. A + * call to GPU_viewport_draw_to_screen() is still needed to get the final result from the + * viewport buffers composited together and potentially color managed for display on screen. + * It needs a bound frame-buffer to draw into, for which we simply reuse the GPUOffscreen one. + * + * In a next step, Ghost-XR will use the currently bound frame-buffer to retrieve the image + * to be submitted to the OpenXR swap-chain. So do not un-bind the off-screen yet! */ + + GPU_offscreen_bind(surface_data->offscreen, false); + + wm_xr_draw_viewport_buffers_to_active_framebuffer(xr_data->runtime, surface_data, draw_view); +} diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h b/source/blender/windowmanager/xr/intern/wm_xr_intern.h new file mode 100644 index 00000000000..b53ae45a29f --- /dev/null +++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.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. + */ + +/** \file + * \ingroup wm + */ + +#ifndef __WM_XR_INTERN_H__ +#define __WM_XR_INTERN_H__ + +#include "CLG_log.h" + +#include "wm_xr.h" + +typedef struct wmXrSessionState { + bool is_started; + + /** Last known viewer pose (centroid of eyes, in world space) stored for queries. */ + GHOST_XrPose viewer_pose; + /** The last known view matrix, calculated from above's viewer pose. */ + float viewer_viewmat[4][4]; + float focal_len; + + /** Copy of XrSessionSettings.flag created on the last draw call, stored to detect changes. */ + int prev_settings_flag; + /** Copy of wmXrDrawData.eye_position_ofs. */ + float prev_eye_position_ofs[3]; + + bool is_view_data_set; +} wmXrSessionState; + +typedef struct wmXrRuntimeData { + GHOST_XrContextHandle context; + + /* Although this struct is internal, RNA gets a handle to this for state information queries. */ + wmXrSessionState session_state; + wmXrSessionExitFn exit_fn; +} wmXrRuntimeData; + +typedef struct { + struct GPUOffScreen *offscreen; + struct GPUViewport *viewport; +} wmXrSurfaceData; + +typedef struct wmXrDrawData { + struct Scene *scene; + struct Depsgraph *depsgraph; + + wmXrData *xr_data; + wmXrSurfaceData *surface_data; + + /** The pose (location + rotation) to which eye deltas will be applied to when drawing (world + * space). With positional tracking enabled, it should be the same as the base pose, when + * disabled it also contains a location delta from the moment the option was toggled. */ + GHOST_XrPose base_pose; + float eye_position_ofs[3]; /* Local/view space. */ +} wmXrDrawData; + +wmXrRuntimeData *wm_xr_runtime_data_create(void); +void wm_xr_runtime_data_free(wmXrRuntimeData **runtime); + +void wm_xr_session_draw_data_update(const wmXrSessionState *state, + const XrSessionSettings *settings, + const GHOST_XrDrawViewInfo *draw_view, + wmXrDrawData *draw_data); +void wm_xr_session_state_update(const XrSessionSettings *settings, + const wmXrDrawData *draw_data, + const GHOST_XrDrawViewInfo *draw_view, + wmXrSessionState *state); +bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data, + const GHOST_XrDrawViewInfo *draw_view); +void *wm_xr_session_gpu_binding_context_create(void); +void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle context); + +void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]); +void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata); + +#endif diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c new file mode 100644 index 00000000000..dc228d1b18b --- /dev/null +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -0,0 +1,411 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup wm + */ + +#include "BKE_context.h" + +#include "BLI_math.h" + +#include "DEG_depsgraph.h" + +#include "DNA_camera_types.h" + +#include "DRW_engine.h" + +#include "GHOST_C-api.h" + +#include "GPU_viewport.h" + +#include "MEM_guardedalloc.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "wm_surface.h" +#include "wm_window.h" +#include "wm_xr_intern.h" + +wmSurface *g_xr_surface = NULL; +CLG_LogRef LOG = {"wm.xr"}; + +/* -------------------------------------------------------------------- */ + +static void wm_xr_session_exit_cb(void *customdata) +{ + wmXrData *xr_data = customdata; + + xr_data->runtime->session_state.is_started = false; + if (xr_data->runtime->exit_fn) { + xr_data->runtime->exit_fn(xr_data); + } + + /* Free the entire runtime data (including session state and context), to play safe. */ + wm_xr_runtime_data_free(&xr_data->runtime); +} + +static void wm_xr_session_begin_info_create(wmXrData *xr_data, + GHOST_XrSessionBeginInfo *r_begin_info) +{ + /* WM-XR exit function, does some own stuff and calls callback passed to wm_xr_session_toggle(), + * to allow external code to execute its own session-exit logic. */ + r_begin_info->exit_fn = wm_xr_session_exit_cb; + r_begin_info->exit_customdata = xr_data; +} + +void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn) +{ + wmXrData *xr_data = &wm->xr; + + if (WM_xr_session_exists(xr_data)) { + GHOST_XrSessionEnd(xr_data->runtime->context); + } + else { + GHOST_XrSessionBeginInfo begin_info; + + xr_data->runtime->session_state.is_started = true; + xr_data->runtime->exit_fn = session_exit_fn; + + wm_xr_session_begin_info_create(xr_data, &begin_info); + GHOST_XrSessionStart(xr_data->runtime->context, &begin_info); + } +} + +/** + * Check if the XR-Session was triggered. + * If an error happened while trying to start a session, this returns false too. + */ +bool WM_xr_session_exists(const wmXrData *xr) +{ + return xr->runtime && xr->runtime->context && xr->runtime->session_state.is_started; +} + +/** + * Check if the session is running, according to the OpenXR definition. + */ +bool WM_xr_session_is_ready(const wmXrData *xr) +{ + return WM_xr_session_exists(xr) && GHOST_XrSessionIsRunning(xr->runtime->context); +} + +static void wm_xr_session_base_pose_calc(const Scene *scene, + const XrSessionSettings *settings, + GHOST_XrPose *r_base_pose) +{ + const Object *base_pose_object = ((settings->base_pose_type == XR_BASE_POSE_OBJECT) && + settings->base_pose_object) ? + settings->base_pose_object : + scene->camera; + + if (settings->base_pose_type == XR_BASE_POSE_CUSTOM) { + float tmp_quatx[4], tmp_quatz[4]; + + copy_v3_v3(r_base_pose->position, settings->base_pose_location); + axis_angle_to_quat_single(tmp_quatx, 'X', M_PI_2); + axis_angle_to_quat_single(tmp_quatz, 'Z', settings->base_pose_angle); + mul_qt_qtqt(r_base_pose->orientation_quat, tmp_quatz, tmp_quatx); + } + else if (base_pose_object) { + float tmp_quat[4]; + float tmp_eul[3]; + + mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->obmat); + + /* Only use rotation around Z-axis to align view with floor. */ + quat_to_eul(tmp_eul, tmp_quat); + tmp_eul[0] = M_PI_2; + tmp_eul[1] = 0; + eul_to_quat(r_base_pose->orientation_quat, tmp_eul); + } + else { + copy_v3_fl(r_base_pose->position, 0.0f); + axis_angle_to_quat_single(r_base_pose->orientation_quat, 'X', M_PI_2); + } +} + +static void wm_xr_session_draw_data_populate(wmXrData *xr_data, + Scene *scene, + Depsgraph *depsgraph, + wmXrDrawData *r_draw_data) +{ + const XrSessionSettings *settings = &xr_data->session_settings; + + memset(r_draw_data, 0, sizeof(*r_draw_data)); + r_draw_data->scene = scene; + r_draw_data->depsgraph = depsgraph; + r_draw_data->xr_data = xr_data; + r_draw_data->surface_data = g_xr_surface->customdata; + + wm_xr_session_base_pose_calc(r_draw_data->scene, settings, &r_draw_data->base_pose); +} + +void wm_xr_session_draw_data_update(const wmXrSessionState *state, + const XrSessionSettings *settings, + const GHOST_XrDrawViewInfo *draw_view, + wmXrDrawData *draw_data) +{ + const bool position_tracking_toggled = ((state->prev_settings_flag & + XR_SESSION_USE_POSITION_TRACKING) != + (settings->flag & XR_SESSION_USE_POSITION_TRACKING)); + const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING; + + /* Set the eye position offset, it's used to offset the base pose when changing positional + * tracking. */ + if (!state->is_view_data_set) { + /* Always use the exact base pose with no offset when starting the session. */ + copy_v3_fl(draw_data->eye_position_ofs, 0.0f); + } + else if (position_tracking_toggled) { + if (use_position_tracking) { + copy_v3_fl(draw_data->eye_position_ofs, 0.0f); + } + else { + /* Store the current local offset (local pose) so that we can apply that to the eyes. This + * way the eyes stay exactly where they are when disabling positional tracking. */ + copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position); + } + } + else if (!use_position_tracking) { + /* Keep previous offset when positional tracking is disabled. */ + copy_v3_v3(draw_data->eye_position_ofs, state->prev_eye_position_ofs); + } +} + +/** + * Update information that is only stored for external state queries. E.g. for Python API to + * request the current (as in, last known) viewer pose. + */ +void wm_xr_session_state_update(const XrSessionSettings *settings, + const wmXrDrawData *draw_data, + const GHOST_XrDrawViewInfo *draw_view, + wmXrSessionState *state) +{ + GHOST_XrPose viewer_pose; + const bool use_position_tracking = settings->flag & XR_SESSION_USE_POSITION_TRACKING; + + mul_qt_qtqt(viewer_pose.orientation_quat, + draw_data->base_pose.orientation_quat, + draw_view->local_pose.orientation_quat); + copy_v3_v3(viewer_pose.position, draw_data->base_pose.position); + /* The local pose and the eye pose (which is copied from an earlier local pose) both are view + * space, so Y-up. In this case we need them in regular Z-up. */ + viewer_pose.position[0] += draw_data->eye_position_ofs[0]; + viewer_pose.position[1] -= draw_data->eye_position_ofs[2]; + viewer_pose.position[2] += draw_data->eye_position_ofs[1]; + if (use_position_tracking) { + viewer_pose.position[0] += draw_view->local_pose.position[0]; + viewer_pose.position[1] -= draw_view->local_pose.position[2]; + viewer_pose.position[2] += draw_view->local_pose.position[1]; + } + + copy_v3_v3(state->viewer_pose.position, viewer_pose.position); + copy_qt_qt(state->viewer_pose.orientation_quat, viewer_pose.orientation_quat); + wm_xr_pose_to_viewmat(&viewer_pose, state->viewer_viewmat); + /* No idea why, but multiplying by two seems to make it match the VR view more. */ + state->focal_len = 2.0f * + fov_to_focallength(draw_view->fov.angle_right - draw_view->fov.angle_left, + DEFAULT_SENSOR_WIDTH); + + copy_v3_v3(state->prev_eye_position_ofs, draw_data->eye_position_ofs); + state->prev_settings_flag = settings->flag; + state->is_view_data_set = true; +} + +wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr) +{ + return xr->runtime ? &xr->runtime->session_state : NULL; +} + +bool WM_xr_session_state_viewer_pose_location_get(const wmXrData *xr, float r_location[3]) +{ + if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { + zero_v3(r_location); + return false; + } + + copy_v3_v3(r_location, xr->runtime->session_state.viewer_pose.position); + return true; +} + +bool WM_xr_session_state_viewer_pose_rotation_get(const wmXrData *xr, float r_rotation[4]) +{ + if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { + unit_qt(r_rotation); + return false; + } + + copy_v4_v4(r_rotation, xr->runtime->session_state.viewer_pose.orientation_quat); + return true; +} + +bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr, + float r_viewmat[4][4], + float *r_focal_len) +{ + if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) { + unit_m4(r_viewmat); + *r_focal_len = 0.0f; + return false; + } + + copy_m4_m4(r_viewmat, xr->runtime->session_state.viewer_viewmat); + *r_focal_len = xr->runtime->session_state.focal_len; + + return true; +} + +/* -------------------------------------------------------------------- */ +/** \name XR-Session Surface + * + * A wmSurface is used to manage drawing of the VR viewport. It's created and destroyed with the + * session. + * + * \{ */ + +/** + * \brief Call Ghost-XR to draw a frame + * + * Draw callback for the XR-session surface. It's expected to be called on each main loop iteration + * and tells Ghost-XR to submit a new frame by drawing its views. Note that for drawing each view, + * #wm_xr_draw_view() will be called through Ghost-XR (see GHOST_XrDrawViewFunc()). + */ +static void wm_xr_session_surface_draw(bContext *C) +{ + wmXrSurfaceData *surface_data = g_xr_surface->customdata; + wmWindowManager *wm = CTX_wm_manager(C); + wmXrDrawData draw_data; + + if (!GHOST_XrSessionIsRunning(wm->xr.runtime->context)) { + return; + } + wm_xr_session_draw_data_populate( + &wm->xr, CTX_data_scene(C), CTX_data_ensure_evaluated_depsgraph(C), &draw_data); + + DRW_xr_drawing_begin(); + + GHOST_XrSessionDrawViews(wm->xr.runtime->context, &draw_data); + + GPU_offscreen_unbind(surface_data->offscreen, false); + DRW_xr_drawing_end(); +} + +bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data, + const GHOST_XrDrawViewInfo *draw_view) +{ + const bool size_changed = surface_data->offscreen && + (GPU_offscreen_width(surface_data->offscreen) != draw_view->width) && + (GPU_offscreen_height(surface_data->offscreen) != draw_view->height); + char err_out[256] = "unknown"; + bool failure = false; + + if (surface_data->offscreen) { + BLI_assert(surface_data->viewport); + + if (!size_changed) { + return true; + } + GPU_viewport_free(surface_data->viewport); + GPU_offscreen_free(surface_data->offscreen); + } + + if (!(surface_data->offscreen = GPU_offscreen_create( + draw_view->width, draw_view->height, 0, true, false, err_out))) { + failure = true; + } + + if (failure) { + /* Pass. */ + } + else if (!(surface_data->viewport = GPU_viewport_create())) { + GPU_offscreen_free(surface_data->offscreen); + failure = true; + } + + if (failure) { + CLOG_ERROR(&LOG, "Failed to get buffer, %s\n", err_out); + return false; + } + + return true; +} + +static void wm_xr_session_surface_free_data(wmSurface *surface) +{ + wmXrSurfaceData *data = surface->customdata; + + if (data->viewport) { + GPU_viewport_free(data->viewport); + } + if (data->offscreen) { + GPU_offscreen_free(data->offscreen); + } + + MEM_freeN(surface->customdata); + + g_xr_surface = NULL; +} + +static wmSurface *wm_xr_session_surface_create(void) +{ + if (g_xr_surface) { + BLI_assert(false); + return g_xr_surface; + } + + wmSurface *surface = MEM_callocN(sizeof(*surface), __func__); + wmXrSurfaceData *data = MEM_callocN(sizeof(*data), "XrSurfaceData"); + + surface->draw = wm_xr_session_surface_draw; + surface->free_data = wm_xr_session_surface_free_data; + surface->ghost_ctx = DRW_xr_opengl_context_get(); + surface->gpu_ctx = DRW_xr_gpu_context_get(); + + surface->customdata = data; + + g_xr_surface = surface; + + return surface; +} + +void *wm_xr_session_gpu_binding_context_create(void) +{ + wmSurface *surface = wm_xr_session_surface_create(); + + wm_surface_add(surface); + + /* Some regions may need to redraw with updated session state after the session is entirely up + * and running. */ + WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); + + return surface->ghost_ctx; +} + +void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(context)) +{ + if (g_xr_surface) { /* Might have been freed already */ + wm_surface_remove(g_xr_surface); + } + + wm_window_reset_drawable(); + + /* Some regions may need to redraw with updated session state after the session is entirely + * stopped. */ + WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL); +} + +/** \} */ /* XR-Session Surface */ diff --git a/source/blender/windowmanager/xr/wm_xr.h b/source/blender/windowmanager/xr/wm_xr.h new file mode 100644 index 00000000000..33f79bc75b2 --- /dev/null +++ b/source/blender/windowmanager/xr/wm_xr.h @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup wm + */ + +#ifndef __WM_XR_H__ +#define __WM_XR_H__ + +struct wmWindowManager; +struct wmXrData; + +typedef void (*wmXrSessionExitFn)(const wmXrData *xr_data); + +/* wm_xr.c */ +bool wm_xr_init(wmWindowManager *wm); +void wm_xr_exit(wmWindowManager *wm); +void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn); +bool wm_xr_events_handle(wmWindowManager *wm); + +#endif -- cgit v1.2.3 From 93806ba82b30683f3e459f0c77ea9b162e1287ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2020 21:47:56 +1100 Subject: Cleanup: differentiate the evaluation mesh --- source/blender/editors/mesh/meshtools.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 4a1450eaccc..8dbd468d04f 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -849,10 +849,10 @@ static int ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) /** \} */ -static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) +static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *me_eval, int index) { Mesh *me = ob->data; - MVert *mvert = mesh ? mesh->mvert : me->mvert; + MVert *mvert = me_eval ? me_eval->mvert : me->mvert; float vec[3]; mvert = &mvert[index]; @@ -860,7 +860,7 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - return ED_mesh_mirror_spatial_table_lookup(ob, NULL, mesh, vec); + return ED_mesh_mirror_spatial_table_lookup(ob, NULL, me_eval, vec); } static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) -- cgit v1.2.3 From 9fe0505db00f450333518238db6813ede046f45e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Apr 2020 13:53:24 +1000 Subject: Cleanup: macro hygiene, parenthesize arguments --- source/blender/blenkernel/BKE_gpencil.h | 18 ++++++++-------- source/blender/blenkernel/BKE_main.h | 4 ++-- source/blender/blenkernel/BKE_mask.h | 6 +++--- source/blender/blenkernel/BKE_rigidbody.h | 12 +++++------ source/blender/blenkernel/BKE_shader_fx.h | 6 +++--- source/blender/blenkernel/BKE_tracking.h | 2 +- source/blender/blenlib/BLI_link_utils.h | 2 +- source/blender/bmesh/intern/bmesh_edgeloop.h | 2 +- source/blender/editors/include/ED_anim_api.h | 19 ++++++++-------- source/blender/editors/include/ED_armature.h | 2 +- source/blender/editors/include/ED_keyframing.h | 6 +++--- source/blender/editors/include/ED_screen.h | 2 +- .../editors/space_outliner/outliner_intern.h | 3 ++- source/blender/editors/space_text/text_intern.h | 4 ++-- source/blender/editors/transform/transform.h | 8 +++---- source/blender/makesdna/DNA_gpencil_types.h | 25 +++++++++++----------- source/blender/makesdna/DNA_mesh_types.h | 4 ++-- source/blender/makesdna/DNA_view3d_types.h | 4 ++-- 18 files changed, 66 insertions(+), 63 deletions(-) diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 8cd3081389e..faa331aa02d 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -68,21 +68,21 @@ struct bGPdata; /* Vertex Color macros. */ #define GPENCIL_USE_VERTEX_COLOR(toolsettings) \ - ((toolsettings->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR)) + (((toolsettings)->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR)) #define GPENCIL_USE_VERTEX_COLOR_STROKE(toolsettings, brush) \ ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \ - ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \ - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)))) + (((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \ + ((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)))) #define GPENCIL_USE_VERTEX_COLOR_FILL(toolsettings, brush) \ ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \ - ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \ - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)))) + (((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \ + ((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)))) #define GPENCIL_TINT_VERTEX_COLOR_STROKE(brush) \ - ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \ - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)) + (((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \ + ((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)) #define GPENCIL_TINT_VERTEX_COLOR_FILL(brush) \ - ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \ - (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)) + (((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \ + ((brush)->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH)) /* ------------ Grease-Pencil API ------------------ */ diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 306d889fba4..ed1f67350c3 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -225,11 +225,11 @@ int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]); #define MAIN_VERSION_ATLEAST(main, ver, subver) \ ((main)->versionfile > (ver) || \ - (main->versionfile == (ver) && (main)->subversionfile >= (subver))) + ((main)->versionfile == (ver) && (main)->subversionfile >= (subver))) #define MAIN_VERSION_OLDER(main, ver, subver) \ ((main)->versionfile < (ver) || \ - (main->versionfile == (ver) && (main)->subversionfile < (subver))) + ((main)->versionfile == (ver) && (main)->subversionfile < (subver))) #define BLEN_THUMB_SIZE 128 diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index cef26345980..dca677343ce 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -238,10 +238,10 @@ void BKE_mask_clipboard_paste_to_layer(struct Main *bmain, struct MaskLayer *mas #define MASKPOINT_ISSEL_KNOT(p) (((p)->bezt.f2 & SELECT) != 0) #define MASKPOINT_ISSEL_HANDLE(point, which_handle) \ - (((which_handle == MASK_WHICH_HANDLE_STICK) ? \ + ((((which_handle) == MASK_WHICH_HANDLE_STICK) ? \ ((((point)->bezt.f1 | (point)->bezt.f3) & SELECT)) : \ - ((which_handle == MASK_WHICH_HANDLE_LEFT) ? ((point)->bezt.f1 & SELECT) : \ - ((point)->bezt.f3 & SELECT))) != 0) + (((which_handle) == MASK_WHICH_HANDLE_LEFT) ? ((point)->bezt.f1 & SELECT) : \ + ((point)->bezt.f3 & SELECT))) != 0) #define MASKPOINT_SEL_ALL(p) \ { \ diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h index 9d4d53bf27f..b4aa0ac2b93 100644 --- a/source/blender/blenkernel/BKE_rigidbody.h +++ b/source/blender/blenkernel/BKE_rigidbody.h @@ -121,16 +121,16 @@ void BKE_rigidbody_remove_constraint(struct Main *bmain, /* get mass of Rigid Body Object to supply to RigidBody simulators */ #define RBO_GET_MASS(rbo) \ - ((rbo && ((rbo->type == RBO_TYPE_PASSIVE) || (rbo->flag & RBO_FLAG_KINEMATIC) || \ - (rbo->flag & RBO_FLAG_DISABLED))) ? \ + (((rbo) && (((rbo)->type == RBO_TYPE_PASSIVE) || ((rbo)->flag & RBO_FLAG_KINEMATIC) || \ + ((rbo)->flag & RBO_FLAG_DISABLED))) ? \ (0.0f) : \ - (rbo->mass)) + ((rbo)->mass)) /* Get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin, * convex hull always uses custom margin. */ #define RBO_GET_MARGIN(rbo) \ - ((rbo->flag & RBO_FLAG_USE_MARGIN || rbo->shape == RB_SHAPE_CONVEXH || \ - rbo->shape == RB_SHAPE_TRIMESH || rbo->shape == RB_SHAPE_CONE) ? \ - (rbo->margin) : \ + (((rbo)->flag & RBO_FLAG_USE_MARGIN || (rbo)->shape == RB_SHAPE_CONVEXH || \ + (rbo)->shape == RB_SHAPE_TRIMESH || (rbo)->shape == RB_SHAPE_CONE) ? \ + ((rbo)->margin) : \ (0.04f)) /* -------------- */ diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h index d6d0f0f71de..c8386a42c9a 100644 --- a/source/blender/blenkernel/BKE_shader_fx.h +++ b/source/blender/blenkernel/BKE_shader_fx.h @@ -35,9 +35,9 @@ struct Object; struct ShaderFxData; #define SHADER_FX_ACTIVE(_fx, _is_render) \ - (((_fx->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \ - ((_fx->mode & eShaderFxMode_Render) && (_is_render == true))) -#define SHADER_FX_EDIT(_fx, _is_edit) (((_fx->mode & eShaderFxMode_Editmode) == 0) && (_is_edit)) + ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \ + (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true))) +#define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit)) typedef enum { /* Should not be used, only for None type */ diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 00498e30abc..20236745438 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -462,7 +462,7 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track( #define MARKER_VISIBLE(sc, track, marker) \ (((marker)->flag & MARKER_DISABLED) == 0 || ((sc)->flag & SC_HIDE_DISABLED) == 0 || \ - (sc->clip->tracking.act_track == track)) + ((sc)->clip->tracking.act_track == track)) #define TRACK_CLEAR_UPTO 0 #define TRACK_CLEAR_REMAINED 1 diff --git a/source/blender/blenlib/BLI_link_utils.h b/source/blender/blenlib/BLI_link_utils.h index f37841e3192..c0db53ca9a3 100644 --- a/source/blender/blenlib/BLI_link_utils.h +++ b/source/blender/blenlib/BLI_link_utils.h @@ -61,7 +61,7 @@ #define BLI_LINKS_FREE(list) \ { \ while (list) { \ - void *next = list->next; \ + void *next = (list)->next; \ MEM_freeN(list); \ list = next; \ } \ diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.h b/source/blender/bmesh/intern/bmesh_edgeloop.h index 7701c680ae9..4c76ea4f9cf 100644 --- a/source/blender/bmesh/intern/bmesh_edgeloop.h +++ b/source/blender/bmesh/intern/bmesh_edgeloop.h @@ -78,7 +78,7 @@ bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a, #define BM_EDGELINK_NEXT(el_store, elink) \ (elink)->next ? \ - elink->next : \ + (elink)->next : \ (BM_edgeloop_is_closed(el_store) ? BM_edgeloop_verts_get(el_store)->first : NULL) #define BM_EDGELOOP_NEXT(el_store) \ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index fe249ce8bfe..a9b34e3c735 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -337,17 +337,17 @@ typedef enum eAnimFilter_Flags { /* 'Object' channels */ #define SEL_OBJC(base) (CHECK_TYPE_INLINE(base, Base *), ((base->flag & SELECT))) #define EXPANDED_OBJC(ob) \ - (CHECK_TYPE_INLINE(ob, Object *), ((ob->nlaflag & OB_ADS_COLLAPSED) == 0)) + (CHECK_TYPE_INLINE(ob, Object *), (((ob)->nlaflag & OB_ADS_COLLAPSED) == 0)) /* 'Sub-object' channels (flags stored in Data block) */ #define FILTER_SKE_OBJD(key) (CHECK_TYPE_INLINE(key, Key *), ((key->flag & KEY_DS_EXPAND))) #define FILTER_MAT_OBJD(ma) (CHECK_TYPE_INLINE(ma, Material *), ((ma->flag & MA_DS_EXPAND))) #define FILTER_LAM_OBJD(la) (CHECK_TYPE_INLINE(la, Light *), ((la->flag & LA_DS_EXPAND))) #define FILTER_CAM_OBJD(ca) (CHECK_TYPE_INLINE(ca, Camera *), ((ca->flag & CAM_DS_EXPAND))) #define FILTER_CACHEFILE_OBJD(cf) \ - (CHECK_TYPE_INLINE(cf, CacheFile *), ((cf->flag & CACHEFILE_DS_EXPAND))) + (CHECK_TYPE_INLINE(cf, CacheFile *), (((cf)->flag & CACHEFILE_DS_EXPAND))) #define FILTER_CUR_OBJD(cu) (CHECK_TYPE_INLINE(cu, Curve *), ((cu->flag & CU_DS_EXPAND))) #define FILTER_PART_OBJD(part) \ - (CHECK_TYPE_INLINE(part, ParticleSettings *), ((part->flag & PART_DS_EXPAND))) + (CHECK_TYPE_INLINE(part, ParticleSettings *), (((part)->flag & PART_DS_EXPAND))) #define FILTER_MBALL_OBJD(mb) (CHECK_TYPE_INLINE(mb, MetaBall *), ((mb->flag2 & MB_DS_EXPAND))) #define FILTER_ARM_OBJD(arm) (CHECK_TYPE_INLINE(arm, bArmature *), ((arm->flag & ARM_DS_EXPAND))) #define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh *), ((me->flag & ME_DS_EXPAND))) @@ -358,7 +358,7 @@ typedef enum eAnimFilter_Flags { #define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND))) /* Variable use expanders */ #define FILTER_NTREE_DATA(ntree) \ - (CHECK_TYPE_INLINE(ntree, bNodeTree *), ((ntree->flag & NTREE_DS_EXPAND))) + (CHECK_TYPE_INLINE(ntree, bNodeTree *), (((ntree)->flag & NTREE_DS_EXPAND))) #define FILTER_TEX_DATA(tex) (CHECK_TYPE_INLINE(tex, Tex *), ((tex->flag & TEX_DS_EXPAND))) /* 'Sub-object/Action' channels (flags stored in Action) */ @@ -369,11 +369,11 @@ typedef enum eAnimFilter_Flags { /* Actions (also used for Dopesheet) */ /* Action Channel Group */ -#define EDITABLE_AGRP(agrp) ((agrp->flag & AGRP_PROTECTED) == 0) +#define EDITABLE_AGRP(agrp) (((agrp)->flag & AGRP_PROTECTED) == 0) #define EXPANDED_AGRP(ac, agrp) \ - (((!(ac) || ((ac)->spacetype != SPACE_GRAPH)) && (agrp->flag & AGRP_EXPANDED)) || \ - (((ac) && ((ac)->spacetype == SPACE_GRAPH)) && (agrp->flag & AGRP_EXPANDED_G))) -#define SEL_AGRP(agrp) ((agrp->flag & AGRP_SELECTED) || (agrp->flag & AGRP_ACTIVE)) + (((!(ac) || ((ac)->spacetype != SPACE_GRAPH)) && ((agrp)->flag & AGRP_EXPANDED)) || \ + (((ac) && ((ac)->spacetype == SPACE_GRAPH)) && ((agrp)->flag & AGRP_EXPANDED_G))) +#define SEL_AGRP(agrp) (((agrp)->flag & AGRP_SELECTED) || ((agrp)->flag & AGRP_ACTIVE)) /* F-Curve Channels */ #define EDITABLE_FCU(fcu) ((fcu->flag & FCURVE_PROTECTED) == 0) #define SEL_FCU(fcu) (fcu->flag & FCURVE_SELECTED) @@ -433,7 +433,8 @@ typedef enum eAnimFilter_Flags { #define NLACHANNEL_FIRST_TOP(ac) \ (UI_view2d_scale_get_y(&(ac)->region->v2d) * -UI_TIME_SCRUB_MARGIN_Y - NLACHANNEL_SKIP) #define NLACHANNEL_HEIGHT(snla) \ - ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit)) + (((snla) && ((snla)->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : \ + (1.2f * U.widget_unit)) #define NLACHANNEL_SKIP (0.1f * U.widget_unit) #define NLACHANNEL_STEP(snla) (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP) /* Additional offset to give some room at the end. */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 8e0103299eb..102c0dc0659 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -134,7 +134,7 @@ typedef struct EditBone { (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A))) #define EBONE_SELECTABLE(arm, ebone) \ - (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE)) + (EBONE_VISIBLE(arm, ebone) && !((ebone)->flag & BONE_UNSELECTABLE)) #define EBONE_EDITABLE(ebone) \ (CHECK_TYPE_INLINE(ebone, EditBone *), \ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index b362d35c09a..4225ecc6f3d 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -430,14 +430,14 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch /* Auto-Keying macros for use by various tools */ /* check if auto-keyframing is enabled (per scene takes precedence) */ #define IS_AUTOKEY_ON(scene) \ - ((scene) ? (scene->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON)) + ((scene) ? ((scene)->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON)) /* check the mode for auto-keyframing (per scene takes precedence) */ #define IS_AUTOKEY_MODE(scene, mode) \ - ((scene) ? (scene->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \ + ((scene) ? ((scene)->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \ (U.autokey_mode == AUTOKEY_MODE_##mode)) /* check if a flag is set for auto-keyframing (per scene takes precedence) */ #define IS_AUTOKEY_FLAG(scene, flag) \ - ((scene) ? ((scene->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || \ + ((scene) ? (((scene)->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || \ (U.autokey_flag & AUTOKEY_FLAG_##flag)) : \ (U.autokey_flag & AUTOKEY_FLAG_##flag)) diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index b0acc54f1ec..43f3a578bfe 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -215,7 +215,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); #define ED_screen_verts_iter(win, screen, vert_name) \ for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \ (win)->global_areas.vertbase.first : \ - screen->vertbase.first; \ + (screen)->vertbase.first; \ vert_name != NULL; \ vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : \ vert_name->next) diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index fb40ae195ef..90092817acc 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -193,7 +193,8 @@ typedef enum { /* is the current element open? if so we also show children */ #define TSELEM_OPEN(telm, sv) \ - ((telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH))) + (((telm)->flag & TSE_CLOSED) == 0 || \ + (SEARCHING_OUTLINER(sv) && ((telm)->flag & TSE_CHILDSEARCH))) /** * Container to avoid passing around these variables to many functions. diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index d5114d8f6b5..d6588dda797 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -48,13 +48,13 @@ void text_update_cursor_moved(struct bContext *C); #define TXT_NUMCOL_PAD 1.0f /* Total width of the optional line numbers column. */ #define TXT_NUMCOL_WIDTH(st) \ - (st->runtime.cwidth_px * (st->runtime.line_number_display_digits + (2 * TXT_NUMCOL_PAD))) + ((st)->runtime.cwidth_px * ((st)->runtime.line_number_display_digits + (2 * TXT_NUMCOL_PAD))) /* Padding on left of body text in character units. */ #define TXT_BODY_LPAD 1.0f /* Left position of body text. */ #define TXT_BODY_LEFT(st) \ - (st->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * st->runtime.cwidth_px) + ((st)->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * (st)->runtime.cwidth_px) #define TXT_SCROLL_WIDTH U.widget_unit #define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit)) diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 9e225b842f1..701e068d3fa 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -967,14 +967,14 @@ bool checkUseAxisMatrix(TransInfo *t); (BLI_assert((t)->data_container_len == 1), (&(t)->data_container[0])) #define FOREACH_TRANS_DATA_CONTAINER(t, th) \ - for (TransDataContainer *tc = t->data_container, \ - *tc_end = t->data_container + t->data_container_len; \ + for (TransDataContainer *tc = (t)->data_container, \ + *tc_end = (t)->data_container + (t)->data_container_len; \ th != tc_end; \ th++) #define FOREACH_TRANS_DATA_CONTAINER_INDEX(t, th, i) \ - for (TransDataContainer *tc = ((i = 0), t->data_container), \ - *tc_end = t->data_container + t->data_container_len; \ + for (TransDataContainer *tc = ((i = 0), (t)->data_container), \ + *tc_end = (t)->data_container + (t)->data_container_len; \ th != tc_end; \ th++, i++) diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index a3b1f315f04..d3d7ca1cc3b 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -702,31 +702,32 @@ typedef enum eGP_DrawMode { /* Check if 'multiedit sessions' is enabled */ #define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) \ ((gpd) && \ - (gpd->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ - GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) && \ - (gpd->flag & GP_DATA_STROKE_MULTIEDIT)) + ((gpd)->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ + GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) && \ + ((gpd)->flag & GP_DATA_STROKE_MULTIEDIT)) /* Macros to check grease pencil modes */ #define GPENCIL_ANY_MODE(gpd) \ - ((gpd) && \ - (gpd->flag & (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ - GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE))) + ((gpd) && ((gpd)->flag & \ + (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ + GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE))) #define GPENCIL_EDIT_MODE(gpd) ((gpd) && ((gpd)->flag & GP_DATA_STROKE_EDITMODE)) #define GPENCIL_ANY_EDIT_MODE(gpd) \ - ((gpd) && (gpd->flag & \ + ((gpd) && ((gpd)->flag & \ (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) #define GPENCIL_PAINT_MODE(gpd) ((gpd) && (gpd->flag & (GP_DATA_STROKE_PAINTMODE))) #define GPENCIL_SCULPT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_SCULPTMODE)) #define GPENCIL_WEIGHT_MODE(gpd) ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) #define GPENCIL_VERTEX_MODE(gpd) ((gpd) && (gpd->flag & (GP_DATA_STROKE_VERTEXMODE))) #define GPENCIL_SCULPT_OR_WEIGHT_MODE(gpd) \ - ((gpd) && (gpd->flag & (GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) + ((gpd) && ((gpd)->flag & (GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) #define GPENCIL_NONE_EDIT_MODE(gpd) \ - ((gpd) && ((gpd->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ - GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) == 0)) + ((gpd) && (((gpd)->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | \ + GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) == 0)) #define GPENCIL_LAZY_MODE(brush, shift) \ - (((brush) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) && (shift == 0))) || \ - (((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && (shift == 1))) + (((brush) && \ + (((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) && ((shift) == 0))) || \ + ((((brush)->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && ((shift) == 1))) #define GPENCIL_ANY_SCULPT_MASK(flag) \ ((flag & (GP_SCULPT_MASK_SELECTMODE_POINT | GP_SCULPT_MASK_SELECTMODE_STROKE | \ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index d8acf5bc493..dc1a2b5ff1d 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -248,9 +248,9 @@ enum { /* we cant have both flags enabled at once, * flags defined in DNA_scene_types.h */ #define ME_EDIT_PAINT_SEL_MODE(_me) \ - ((_me->editflag & ME_EDIT_PAINT_FACE_SEL) ? \ + (((_me)->editflag & ME_EDIT_PAINT_FACE_SEL) ? \ SCE_SELECT_FACE : \ - (_me->editflag & ME_EDIT_PAINT_VERT_SEL) ? SCE_SELECT_VERTEX : 0) + ((_me)->editflag & ME_EDIT_PAINT_VERT_SEL) ? SCE_SELECT_VERTEX : 0) /* me->flag */ enum { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 3e348f7f502..21def800e4a 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -421,8 +421,8 @@ enum { }; #define RV3D_CLIPPING_ENABLED(v3d, rv3d) \ - (rv3d && v3d && (rv3d->rflag & RV3D_CLIPPING) && ELEM(v3d->shading.type, OB_WIRE, OB_SOLID) && \ - rv3d->clipbb) + ((rv3d) && (v3d) && ((rv3d)->rflag & RV3D_CLIPPING) && \ + ELEM((v3d)->shading.type, OB_WIRE, OB_SOLID) && (rv3d)->clipbb) /** #View3D.flag2 (int) */ #define V3D_HIDE_OVERLAYS (1 << 2) -- cgit v1.2.3 From 3e8a81841931f2cdbe8349a2c7ce0f6b3a486c79 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Apr 2020 17:12:10 +1000 Subject: Cleanup: use const for 'clnors' argument where possible --- source/blender/blenkernel/intern/mesh_evaluate.c | 2 +- source/blender/bmesh/intern/bmesh_mesh.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 0b3650fd40a..17fd7b18bab 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -1012,7 +1012,7 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops, static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data) { MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr; - short(*clnors_data)[2] = common_data->clnors_data; + const short(*clnors_data)[2] = common_data->clnors_data; const MVert *mverts = common_data->mverts; const MEdge *medges = common_data->medges; diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 933223c3337..b65d563d441 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -676,7 +676,7 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, const float (*fnos)[3], float (*r_lnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, - short (*clnors_data)[2], + const short (*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild) { @@ -786,8 +786,9 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, BKE_lnor_space_add_loop(r_lnors_spacearr, lnor_space, l_curr_index, l_curr, true); if (has_clnors) { - short(*clnor)[2] = clnors_data ? &clnors_data[l_curr_index] : - BM_ELEM_CD_GET_VOID_P(l_curr, cd_loop_clnors_offset); + const short(*clnor)[2] = clnors_data ? &clnors_data[l_curr_index] : + (const void *)BM_ELEM_CD_GET_VOID_P( + l_curr, cd_loop_clnors_offset); BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor, r_lnos[l_curr_index]); } } @@ -820,7 +821,7 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, /* We validate clnors data on the fly - cheapest way to do! */ int clnors_avg[2] = {0, 0}; - short(*clnor_ref)[2] = NULL; + const short(*clnor_ref)[2] = NULL; int clnors_nbr = 0; bool clnors_invalid = false; @@ -886,9 +887,9 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, if (has_clnors) { /* Accumulate all clnors, if they are not all equal we have to fix that! */ - short(*clnor)[2] = clnors_data ? - &clnors_data[lfan_pivot_index] : - BM_ELEM_CD_GET_VOID_P(lfan_pivot, cd_loop_clnors_offset); + const short(*clnor)[2] = clnors_data ? &clnors_data[lfan_pivot_index] : + (const void *)BM_ELEM_CD_GET_VOID_P( + lfan_pivot, cd_loop_clnors_offset); if (clnors_nbr) { clnors_invalid |= ((*clnor_ref)[0] != (*clnor)[0] || (*clnor_ref)[1] != (*clnor)[1]); @@ -1049,7 +1050,7 @@ void BM_mesh_loop_normals_update(BMesh *bm, const float split_angle, float (*r_lnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, - short (*clnors_data)[2], + const short (*clnors_data)[2], const int cd_loop_clnors_offset) { const bool has_clnors = clnors_data || (cd_loop_clnors_offset != -1); -- cgit v1.2.3 From f1573731bc8b80c03ef5db4292568781969846c3 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Sun, 5 Apr 2020 14:19:24 +0200 Subject: UI: Support split property layout for pointer search buttons Pointer search buttons created with `uiItemPointerR()` (which allows also passing a collection property to search in) did not work with the split property layout (i.e. `uiLayout.use_property_split`). For example vertex group search buttons typically use this. Note that decorators (`uiLayout.use_property_decorate`) are not supported yet. Although if they are enabled, the decorator column is still created to keep the layout alignment visually intact. Also re-uses the existing hack to allow placing multiple items in the row before the decorator column. Needed for some in-progress changes to the modifier stack UI. --- .../blender/editors/interface/interface_layout.c | 58 ++++++++++++++-------- .../editors/interface/interface_templates.c | 2 +- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a28da678728..44def6a2c09 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -945,19 +945,25 @@ static uiBut *ui_item_with_label(uiLayout *layout, PropertyType type; PropertySubType subtype; int prop_but_width = w_hint; +#ifdef UI_PROP_DECORATE + uiLayout *layout_prop_decorate = NULL; const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0); +#endif /* Always align item with label since text is already given enough space not to overlap. */ sub = uiLayoutRow(layout, true); UI_block_layout_set_current(block, sub); +#ifdef UI_PROP_DECORATE if (name[0]) { - int w_label; - if (use_prop_sep) { - w_label = (int)((w_hint * 2) * UI_ITEM_PROP_SEP_DIVIDE); + layout_prop_decorate = uiItemL_respect_property_split(layout, name, 0); } - else { + else +#endif + { + int w_label; + if (ui_layout_variable_size(layout)) { /* w_hint is width for label in this case. * Use a default width for property button(s) */ @@ -967,13 +973,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, else { w_label = w_hint / 3; } - } - - uiBut *but_label = uiDefBut( - block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, ""); - if (use_prop_sep) { - but_label->drawflag |= UI_BUT_TEXT_RIGHT; - but_label->drawflag &= ~UI_BUT_TEXT_LEFT; + uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, ""); } } @@ -1053,7 +1053,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, if (layout->item.flag & UI_ITEM_PROP_SEP) { if ((layout->item.flag & UI_ITEM_PROP_DECORATE) && (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0) { - uiItemL(sub, NULL, ICON_BLANK1); + uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1); } } #endif /* UI_PROP_DECORATE */ @@ -1862,6 +1862,20 @@ static void ui_item_rna_size(uiLayout *layout, *r_h = h; } +/** + * Hack to add further items in a row into the second part of the split layout, so the label part + * keeps a fixed size. + * \return The layout to place further items in for the split layout. + */ +static uiLayout *ui_item_prop_split_layout_hack(uiLayout *layout_parent, uiLayout *layout_split) +{ + if (layout_parent->item.type == ITEM_LAYOUT_ROW) { + layout_parent->child_items_layout = uiLayoutRow(layout_split, true); + return layout_parent->child_items_layout; + } + return layout_split; +} + void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, @@ -2081,11 +2095,8 @@ void uiItemFullR(uiLayout *layout, } } - /* Hack to add further items in a row into the second part of - * the split layout, so the label part keeps a fixed size. */ - if (layout_parent && layout_parent->item.type == ITEM_LAYOUT_ROW) { - layout_split = uiLayoutRow(layout_split, true); - layout_parent->child_items_layout = layout_split; + if (layout_parent) { + layout_split = ui_item_prop_split_layout_hack(layout_parent, layout_split); } /* Watch out! We can only write into the new layout now. */ @@ -2989,21 +3000,26 @@ void uiItemL(uiLayout *layout, const char *name, int icon) * extended to support more cases. * Ideally, #uiItemFullR() could just call this, but it currently has too many special needs. * - * \return the layout to place the item(s) associated to the label in. + * \return A layout placed in the row after the split layout. Used to place decorator items. */ uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon) { if (layout->item.flag & UI_ITEM_PROP_SEP) { - uiLayout *layout_split = uiLayoutSplit(layout, UI_ITEM_PROP_SEP_DIVIDE, true); + uiBlock *block = uiLayoutGetBlock(layout); + uiLayout *layout_row = uiLayoutRow(layout, true); + uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true); uiLayout *layout_sub = uiLayoutColumn(layout_split, true); - layout_split->space = layout_sub->space = layout->space = 0; + layout_split->space = layout_sub->space = layout_row->space = 0; layout_sub->alignment = UI_LAYOUT_ALIGN_RIGHT; uiItemL_(layout_sub, text, icon); + layout_split = ui_item_prop_split_layout_hack(layout, layout_split); + UI_block_layout_set_current(block, layout_split); + /* Give caller a new sub-row to place items in. */ - return uiLayoutRow(layout_split, true); + return layout_row; } else { char namestr[UI_MAX_NAME_STR]; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ba7cd708bfa..98d5bae0ff1 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -831,7 +831,7 @@ static void template_ID(bContext *C, if (text) { /* Add label resepecting the separated layout property split state. */ - layout = uiItemL_respect_property_split(layout, text, ICON_NONE); + uiItemL_respect_property_split(layout, text, ICON_NONE); } if (flag & UI_ID_BROWSE) { -- cgit v1.2.3 From bae1c243cec809ac783c1b8f2fb65a570b526ef0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 5 Apr 2020 20:56:06 +0200 Subject: Build: hide USD symbols, make Blender symbols visible again Following up to b555b8d. Building Blender with hidden symbols but using libraries with visible symbols was giving linker warnings, specifically for USD. So revert that for now, as it was not needed for the bugfix. Hide USD symbols (some of which are not in the USD namespace) to avoid potential conflicts. May potentially help with AMD OpenCL issues in T74262. --- build_files/cmake/platform/platform_apple.cmake | 1 - build_files/cmake/platform/platform_unix.cmake | 1 - source/creator/blender.map | 3 +++ source/creator/osx_locals.map | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index f5f8c209d9d..d8ee82d4c10 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -453,7 +453,6 @@ endif() set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker '${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'" ) -set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++") diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 0bf790b34e6..cd304d65eac 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -603,7 +603,6 @@ endif() # Avoid conflicts with Mesa llvmpipe, Luxrender, and other plug-ins that may # use the same libraries as Blender with a different version or build options. -set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fvisibility=hidden") set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'" ) diff --git a/source/creator/blender.map b/source/creator/blender.map index 3e447ec9e89..fda6c37b10d 100644 --- a/source/creator/blender.map +++ b/source/creator/blender.map @@ -58,12 +58,15 @@ local: opj_*; opus_*; *OSL*; + *pathYy*; png_*; *SDL*; *squish*; *tbb*; + *textFileFormatYy*; *TIFF*; *tinyformat*; + *usdBlender*; vorbis*; vp8*; vp9*; diff --git a/source/creator/osx_locals.map b/source/creator/osx_locals.map index 908bfdae6cb..50e7e9838d4 100644 --- a/source/creator/osx_locals.map +++ b/source/creator/osx_locals.map @@ -49,12 +49,15 @@ ogg* opj_* opus_* *OSL* +*pathYy* png_* *SDL* *squish* *tbb* +*textFileFormatYy* *TIFF* *tinyformat* +*usdBlender* vorbis* vp8* vp9* -- cgit v1.2.3 From 9d4300b0c60047b56f84f28650eb39cd35cf386b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 5 Apr 2020 21:25:33 +0200 Subject: Volumes: add volume.grids.frame_filepath to get the current frame filepath This can be used by external renderers that can load OpenVDB files. --- source/blender/blenkernel/BKE_volume.h | 1 + source/blender/blenkernel/intern/volume.cc | 10 ++++++++++ source/blender/makesrna/intern/rna_volume.c | 25 ++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h index 3125ad0326e..224f3ede45d 100644 --- a/source/blender/blenkernel/BKE_volume.h +++ b/source/blender/blenkernel/BKE_volume.h @@ -85,6 +85,7 @@ bool BKE_volume_is_loaded(const struct Volume *volume); int BKE_volume_num_grids(const struct Volume *volume); const char *BKE_volume_grids_error_msg(const struct Volume *volume); +const char *BKE_volume_grids_frame_filepath(const struct Volume *volume); VolumeGrid *BKE_volume_grid_get(const struct Volume *volume, int grid_index); VolumeGrid *BKE_volume_grid_active_get(const struct Volume *volume); VolumeGrid *BKE_volume_grid_find(const struct Volume *volume, const char *name); diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 2af40c8e8fb..9d9e8423bcf 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -901,6 +901,16 @@ const char *BKE_volume_grids_error_msg(const Volume *volume) #endif } +const char *BKE_volume_grids_frame_filepath(const Volume *volume) +{ +#ifdef WITH_OPENVDB + return volume->runtime.grids->filepath; +#else + UNUSED_VARS(volume); + return ""; +#endif +} + VolumeGrid *BKE_volume_grid_get(const Volume *volume, int grid_index) { #ifdef WITH_OPENVDB diff --git a/source/blender/makesrna/intern/rna_volume.c b/source/blender/makesrna/intern/rna_volume.c index 0ee1dbc791b..25b5395b35c 100644 --- a/source/blender/makesrna/intern/rna_volume.c +++ b/source/blender/makesrna/intern/rna_volume.c @@ -194,6 +194,19 @@ static int rna_VolumeGrids_error_message_length(PointerRNA *ptr) return strlen(BKE_volume_grids_error_msg(volume)); } +/* Frame Filepath */ +static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value) +{ + Volume *volume = (Volume *)ptr->data; + strcpy(value, BKE_volume_grids_frame_filepath(volume)); +} + +static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr) +{ + Volume *volume = (Volume *)ptr->data; + return strlen(BKE_volume_grids_frame_filepath(volume)); +} + #else static void rna_def_volume_grid(BlenderRNA *brna) @@ -308,6 +321,16 @@ static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop) "Frame number that volume grids will be loaded at, based on scene time " "and volume parameters"); + prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs( + prop, "rna_VolumeGrids_frame_filepath_get", "rna_VolumeGrids_frame_filepath_length", NULL); + + RNA_def_property_ui_text(prop, + "Frame File Path", + "Volume file used for loading the volume at the current frame. Empty " + "if the volume has not be loaded or the frame only exists in memory"); + /* API */ FunctionRNA *func; PropertyRNA *parm; @@ -446,7 +469,7 @@ static void rna_def_volume(BlenderRNA *brna) /* File */ prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "File Path", "Volume sample file used by this Volume data-block"); + RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block"); RNA_def_property_update(prop, 0, "rna_Volume_update_filepath"); prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); -- cgit v1.2.3 From 43cc2f31959277c6c9ecb5b6b6d83c0af6d7923e Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Sun, 5 Apr 2020 23:39:20 +0200 Subject: Cleanup: Use `_fn` as a suffix for callbacks in VSE code --- source/blender/blenkernel/BKE_sequencer.h | 2 +- .../blender/blenkernel/BKE_sequencer_offscreen.h | 2 +- source/blender/blenkernel/intern/sequencer.c | 24 +++++++++++----------- source/blender/editors/sound/sound_ops.c | 4 ++-- .../editors/space_sequencer/sequencer_add.c | 10 ++++----- .../editors/space_sequencer/sequencer_draw.c | 10 ++++----- .../editors/space_sequencer/sequencer_edit.c | 8 ++++---- .../editors/space_sequencer/sequencer_scopes.c | 8 ++++---- .../editors/space_sequencer/space_sequencer.c | 2 +- source/blender/makesrna/intern/rna_sequencer.c | 20 +++++++++--------- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 556cd7105a9..1b4ca1350ad 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -493,7 +493,7 @@ typedef struct SeqLoadInfo { #define SEQ_DUPE_ALL (1 << 3) /* otherwise only selected are copied */ /* use as an api function */ -typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *); +typedef struct Sequence *(*SeqLoadFn)(struct bContext *, ListBase *, struct SeqLoadInfo *); struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine, int type); diff --git a/source/blender/blenkernel/BKE_sequencer_offscreen.h b/source/blender/blenkernel/BKE_sequencer_offscreen.h index c753b4b566f..cc822e97270 100644 --- a/source/blender/blenkernel/BKE_sequencer_offscreen.h +++ b/source/blender/blenkernel/BKE_sequencer_offscreen.h @@ -47,7 +47,7 @@ typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph, const char *viewname, struct GPUOffScreen *ofs, char err_out[256]); -extern SequencerDrawView sequencer_view3d_cb; +extern SequencerDrawView sequencer_view3d_fn; #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 0e558db57cb..bb1d8cb2e9b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -121,7 +121,7 @@ static ThreadMutex seq_render_mutex = BLI_MUTEX_INITIALIZER; #define SELECT 1 ListBase seqbase_clipboard; int seqbase_clipboard_frame; -SequencerDrawView sequencer_view3d_cb = NULL; /* NULL in background mode */ +SequencerDrawView sequencer_view3d_fn = NULL; /* NULL in background mode */ #if 0 /* unused function */ static void printf_strip(Sequence *seq) @@ -153,28 +153,28 @@ static void sequencer_state_init(SeqRenderState *state) } int BKE_sequencer_base_recursive_apply(ListBase *seqbase, - int (*apply_func)(Sequence *seq, void *), + int (*apply_fn)(Sequence *seq, void *), void *arg) { Sequence *iseq; for (iseq = seqbase->first; iseq; iseq = iseq->next) { - if (BKE_sequencer_recursive_apply(iseq, apply_func, arg) == -1) { + if (BKE_sequencer_recursive_apply(iseq, apply_fn, arg) == -1) { return -1; /* bail out */ } } return 1; } -int BKE_sequencer_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), void *arg) +int BKE_sequencer_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg) { - int ret = apply_func(seq, arg); + int ret = apply_fn(seq, arg); if (ret == -1) { return -1; /* bail out */ } if (ret && seq->seqbase.first) { - ret = BKE_sequencer_base_recursive_apply(&seq->seqbase, apply_func, arg); + ret = BKE_sequencer_base_recursive_apply(&seq->seqbase, apply_fn, arg); } return ret; @@ -1139,7 +1139,7 @@ int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b) return (seq_a->startdisp > seq_b->startdisp); } -static int clear_scene_in_allseqs_cb(Sequence *seq, void *arg_pt) +static int clear_scene_in_allseqs_fn(Sequence *seq, void *arg_pt) { if (seq->scene == (Scene *)arg_pt) { seq->scene = NULL; @@ -1155,7 +1155,7 @@ void BKE_sequencer_clear_scene_in_allseqs(Main *bmain, Scene *scene) for (scene_iter = bmain->scenes.first; scene_iter; scene_iter = scene_iter->id.next) { if (scene_iter != scene && scene_iter->ed) { BKE_sequencer_base_recursive_apply( - &scene_iter->ed->seqbase, clear_scene_in_allseqs_cb, scene); + &scene_iter->ed->seqbase, clear_scene_in_allseqs_fn, scene); } } } @@ -1185,7 +1185,7 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) } } -static int seqbase_unique_name_recursive_cb(Sequence *seq, void *arg_pt) +static int seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt) { if (seq->seqbase.first) { seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt); @@ -1217,7 +1217,7 @@ void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq) while (sui.match) { sui.match = 0; seqbase_unique_name(seqbasep, &sui); - BKE_sequencer_base_recursive_apply(seqbasep, seqbase_unique_name_recursive_cb, &sui); + BKE_sequencer_base_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui); } BLI_strncpy(seq->name + 2, sui.name_dest, sizeof(seq->name) - 2); @@ -3499,7 +3499,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, is_frame_update = (orig_data.cfra != scene->r.cfra) || (orig_data.subframe != scene->r.subframe); - if ((sequencer_view3d_cb && do_seq_gl && camera) && is_thread_main) { + if ((sequencer_view3d_fn && do_seq_gl && camera) && is_thread_main) { char err_out[256] = "unknown"; const int width = (scene->r.xsch * scene->r.size) / 100; const int height = (scene->r.ysch * scene->r.size) / 100; @@ -3520,7 +3520,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, /* opengl offscreen render */ depsgraph = BKE_scene_get_depsgraph(context->bmain, scene, view_layer, true); BKE_scene_graph_update_for_newframe(depsgraph, context->bmain); - ibuf = sequencer_view3d_cb( + ibuf = sequencer_view3d_fn( /* set for OpenGL render (NULL when scrubbing) */ depsgraph, scene, diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index e6e36309fec..81ac8a16d8a 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -206,7 +206,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot) static void sound_update_animation_flags(Scene *scene); -static int sound_update_animation_flags_cb(Sequence *seq, void *user_data) +static int sound_update_animation_flags_fn(Sequence *seq, void *user_data) { struct FCurve *fcu; Scene *scene = (Scene *)user_data; @@ -258,7 +258,7 @@ static void sound_update_animation_flags(Scene *scene) scene->id.tag |= LIB_TAG_DOIT; SEQ_BEGIN (scene->ed, seq) { - BKE_sequencer_recursive_apply(seq, sound_update_animation_flags_cb, scene); + BKE_sequencer_recursive_apply(seq, sound_update_animation_flags_fn, scene); } SEQ_END; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index ac9b605b193..278fb9fb683 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -587,7 +587,7 @@ void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot) ot->prop = prop; } -static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func) +static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFn seq_load_fn) { Scene *scene = CTX_data_scene(C); /* only for sound */ Editing *ed = BKE_sequencer_editing_get(scene, true); @@ -617,7 +617,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad /* Set seq_load.name, else all video/audio files get the same name! ugly! */ BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name)); - seq = seq_load_func(C, ed->seqbasep, &seq_load); + seq = seq_load_fn(C, ed->seqbasep, &seq_load); if (seq) { sequencer_add_apply_overlap(C, op, seq); if (seq_load.seq_sound) { @@ -631,7 +631,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad Sequence *seq; /* single file */ - seq = seq_load_func(C, ed->seqbasep, &seq_load); + seq = seq_load_fn(C, ed->seqbasep, &seq_load); if (seq) { sequencer_add_apply_overlap(C, op, seq); if (seq_load.seq_sound) { @@ -672,7 +672,7 @@ static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op) op->customdata = NULL; } -static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr), +static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr), PropertyRNA *prop, void *UNUSED(user_data)) { @@ -740,7 +740,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) /* main draw call */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); uiDefAutoButsRNA( - layout, &ptr, sequencer_add_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false); + layout, &ptr, sequencer_add_draw_check_fn, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false); /* image template */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index b50a3e1743e..db045b65d3f 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1239,7 +1239,7 @@ static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf) } } -static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb)(ImBuf *ibuf)) +static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_fn)(ImBuf *ibuf)) { ImBuf *display_ibuf = IMB_dupImBuf(ibuf); ImBuf *scope; @@ -1247,7 +1247,7 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop IMB_colormanagement_imbuf_make_display_space( display_ibuf, &scene->view_settings, &scene->display_settings); - scope = make_scope_cb(display_ibuf); + scope = make_scope_fn(display_ibuf); IMB_freeImBuf(display_ibuf); @@ -1980,7 +1980,7 @@ typedef struct CacheDrawData { } CacheDrawData; /* Called as a callback */ -static bool draw_cache_view_init_cb(void *userdata, size_t item_count) +static bool draw_cache_view_init_fn(void *userdata, size_t item_count) { if (item_count == 0) { return true; @@ -1998,7 +1998,7 @@ static bool draw_cache_view_init_cb(void *userdata, size_t item_count) } /* Called as a callback */ -static bool draw_cache_view_iter_cb( +static bool draw_cache_view_iter_fn( void *userdata, struct Sequence *seq, int nfra, int cache_type, float UNUSED(cost)) { CacheDrawData *drawdata = userdata; @@ -2162,7 +2162,7 @@ static void draw_cache_view(const bContext *C) userdata.composite_vbo = GPU_vertbuf_create_with_format(&format); userdata.final_out_vbo = GPU_vertbuf_create_with_format(&format); - BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_init_cb, draw_cache_view_iter_cb); + BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_init_fn, draw_cache_view_iter_fn); draw_cache_view_batch(userdata.raw_vbo, userdata.raw_vert_count, 1.0f, 0.1f, 0.02f, 0.4f); draw_cache_view_batch( diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 82331545a77..3d9de1f567c 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2359,7 +2359,7 @@ void SEQUENCER_OT_split(struct wmOperatorType *ot) #undef SEQ_SIDE_MOUSE /* duplicate operator */ -static int apply_unique_name_cb(Sequence *seq, void *arg_pt) +static int apply_unique_name_fn(Sequence *seq, void *arg_pt) { Scene *scene = (Scene *)arg_pt; char name[sizeof(seq->name) - 2]; @@ -2389,7 +2389,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &nseqbase); for (; seq; seq = seq->next) { - BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene); + BKE_sequencer_recursive_apply(seq, apply_unique_name_fn, scene); } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -3461,7 +3461,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) BLI_movelisttolist(ed->seqbasep, &nseqbase); for (seq = first_seq; seq; seq = seq->next) { - BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene); + BKE_sequencer_recursive_apply(seq, apply_unique_name_fn, scene); } seqbase_clipboard.first = first_seq; @@ -3538,7 +3538,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) /* make sure the pasted strips have unique names between them */ for (iseq = iseq_first; iseq; iseq = iseq->next) { - BKE_sequencer_recursive_apply(iseq, apply_unique_name_cb, scene); + BKE_sequencer_recursive_apply(iseq, apply_unique_name_fn, scene); } /* ensure pasted strips don't overlap */ diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 3dcbdb6c4b0..02912b2755f 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -450,7 +450,7 @@ typedef struct MakeHistogramViewData { uint32_t (*bins)[HIS_STEPS]; } MakeHistogramViewData; -static void make_histogram_view_from_ibuf_byte_cb_ex(void *__restrict userdata, +static void make_histogram_view_from_ibuf_byte_fn(void *__restrict userdata, const int y, const TaskParallelTLS *__restrict tls) { @@ -504,7 +504,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) settings.userdata_chunk = bins; settings.userdata_chunk_size = sizeof(bins); settings.func_finalize = make_histogram_view_from_ibuf_finalize; - BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_byte_cb_ex, &settings); + BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_byte_fn, &settings); nr = nb = ng = 0; for (x = 0; x < HIS_STEPS; x++) { @@ -551,7 +551,7 @@ BLI_INLINE int get_bin_float(float f) return (int)(((f + 0.25f) / 1.5f) * 512); } -static void make_histogram_view_from_ibuf_float_cb_ex(void *__restrict userdata, +static void make_histogram_view_from_ibuf_float_fn(void *__restrict userdata, const int y, const TaskParallelTLS *__restrict tls) { @@ -590,7 +590,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) settings.userdata_chunk = bins; settings.userdata_chunk_size = sizeof(bins); settings.func_finalize = make_histogram_view_from_ibuf_finalize; - BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_float_cb_ex, &settings); + BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_float_fn, &settings); nr = nb = ng = 0; for (x = 0; x < HIS_STEPS; x++) { diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 73aa8e1be35..ed8117fda31 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -935,6 +935,6 @@ void ED_spacetype_sequencer(void) /* set the sequencer callback when not in background mode */ if (G.background == 0) { - sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple; + sequencer_view3d_fn = ED_view3d_draw_offscreen_imbuf_simple; } } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index e0549a323a1..04729f87cab 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -427,7 +427,7 @@ static void rna_Sequence_use_crop_set(PointerRNA *ptr, bool value) } } -static int transform_seq_cmp_cb(Sequence *seq, void *arg_pt) +static int transform_seq_cmp_fn(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -446,7 +446,7 @@ static Sequence *sequence_get_by_transform(Editing *ed, StripTransform *transfor data.data = transform; /* irritating we need to search for our sequence! */ - BKE_sequencer_base_recursive_apply(&ed->seqbase, transform_seq_cmp_cb, &data); + BKE_sequencer_base_recursive_apply(&ed->seqbase, transform_seq_cmp_fn, &data); return data.seq; } @@ -479,7 +479,7 @@ static void rna_SequenceTransform_update(Main *UNUSED(bmain), BKE_sequence_invalidate_cache_preprocessed(scene, seq); } -static int crop_seq_cmp_cb(Sequence *seq, void *arg_pt) +static int crop_seq_cmp_fn(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -498,7 +498,7 @@ static Sequence *sequence_get_by_crop(Editing *ed, StripCrop *crop) data.data = crop; /* irritating we need to search for our sequence! */ - BKE_sequencer_base_recursive_apply(&ed->seqbase, crop_seq_cmp_cb, &data); + BKE_sequencer_base_recursive_apply(&ed->seqbase, crop_seq_cmp_fn, &data); return data.seq; } @@ -822,7 +822,7 @@ static void rna_Sequence_sound_update(Main *UNUSED(bmain), Scene *scene, Pointer DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS | ID_RECALC_AUDIO); } -static int seqproxy_seq_cmp_cb(Sequence *seq, void *arg_pt) +static int seqproxy_seq_cmp_fn(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -840,7 +840,7 @@ static Sequence *sequence_get_by_proxy(Editing *ed, StripProxy *proxy) data.seq = NULL; data.data = proxy; - BKE_sequencer_base_recursive_apply(&ed->seqbase, seqproxy_seq_cmp_cb, &data); + BKE_sequencer_base_recursive_apply(&ed->seqbase, seqproxy_seq_cmp_fn, &data); return data.seq; } @@ -876,7 +876,7 @@ static void rna_Sequence_opacity_set(PointerRNA *ptr, float value) seq->blend_opacity = value * 100.0f; } -static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) +static int colbalance_seq_cmp_fn(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -910,7 +910,7 @@ static Sequence *sequence_get_by_colorbalance(Editing *ed, data.data = cb; /* irritating we need to search for our sequence! */ - BKE_sequencer_base_recursive_apply(&ed->seqbase, colbalance_seq_cmp_cb, &data); + BKE_sequencer_base_recursive_apply(&ed->seqbase, colbalance_seq_cmp_fn, &data); *r_smd = data.smd; @@ -1014,7 +1014,7 @@ static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value) } } -static int modifier_seq_cmp_cb(Sequence *seq, void *arg_pt) +static int modifier_seq_cmp_fn(Sequence *seq, void *arg_pt) { SequenceSearchData *data = arg_pt; @@ -1034,7 +1034,7 @@ static Sequence *sequence_get_by_modifier(Editing *ed, SequenceModifierData *smd data.data = smd; /* irritating we need to search for our sequence! */ - BKE_sequencer_base_recursive_apply(&ed->seqbase, modifier_seq_cmp_cb, &data); + BKE_sequencer_base_recursive_apply(&ed->seqbase, modifier_seq_cmp_fn, &data); return data.seq; } -- cgit v1.2.3 From 0d0036cb53f83597aa8a52edd0e19fd915f4ed65 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Sun, 5 Apr 2020 23:55:51 +0200 Subject: Cleanup: Fix comment style and check if they are valid or make sense. --- .../editors/space_sequencer/sequencer_add.c | 238 +++----- .../editors/space_sequencer/sequencer_buttons.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 230 ++++---- .../editors/space_sequencer/sequencer_edit.c | 617 ++++++++++----------- .../editors/space_sequencer/sequencer_intern.h | 20 +- .../editors/space_sequencer/sequencer_modifier.c | 2 +- .../editors/space_sequencer/sequencer_ops.c | 2 +- .../editors/space_sequencer/sequencer_preview.c | 12 +- .../editors/space_sequencer/sequencer_scopes.c | 2 +- .../editors/space_sequencer/sequencer_select.c | 138 ++--- .../editors/space_sequencer/sequencer_view.c | 10 +- .../editors/space_sequencer/space_sequencer.c | 99 ++-- 12 files changed, 598 insertions(+), 774 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 278fb9fb683..049f3d76b53 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -51,8 +51,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -/* for menu/popup icons etc etc*/ - +/* For menu, popup, icons, etc. */ #include "ED_screen.h" #include "ED_sequencer.h" @@ -67,16 +66,16 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" typedef struct SequencerAddData { ImageFormatData im_format; } SequencerAddData; -/* Generic functions, reused by add strip operators */ +/* Generic functions, reused by add strip operators. */ -/* avoid passing multiple args and be more verbose */ +/* Avoid passing multiple args and be more verbose. */ #define SEQPROP_STARTFRAME (1 << 0) #define SEQPROP_ENDFRAME (1 << 1) #define SEQPROP_NOPATHS (1 << 2) @@ -101,7 +100,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) } if (flag & SEQPROP_ENDFRAME) { - /* not usual since most strips have a fixed length */ + /* Not usual since most strips have a fixed length. */ RNA_def_int(ot->srna, "frame_end", 0, @@ -119,7 +118,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_boolean( ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection"); - /* only for python scripts which import strips and place them after */ + /* Only for python scripts which import strips and place them after. */ prop = RNA_def_boolean( ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips"); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -175,7 +174,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i int cfra = (int)CFRA; - /* effect strips don't need a channel initialized from the mouse */ + /* Effect strips don't need a channel initialized from the mouse. */ if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) { RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type)); } @@ -203,18 +202,17 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato memset(seq_load, 0, sizeof(SeqLoadInfo)); seq_load->start_frame = RNA_int_get(op->ptr, "frame_start"); - seq_load->end_frame = seq_load->start_frame; /* un-set */ - + seq_load->end_frame = seq_load->start_frame; seq_load->channel = RNA_int_get(op->ptr, "channel"); - seq_load->len = 1; // images only, if endframe isn't set! + seq_load->len = 1; if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { - /* full path, file is set by the caller */ + /* Full path, file is set by the caller. */ RNA_property_string_get(op->ptr, prop, seq_load->path); is_file = 1; } else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { - /* full path, file is set by the caller */ + /* Full path, file is set by the caller. */ RNA_property_string_get(op->ptr, prop, seq_load->path); is_file = 0; } @@ -252,15 +250,13 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato seq_load->flag |= SEQ_LOAD_SYNC_FPS; } - /* always use this for ops */ + /* Create consecutive array of strips. */ seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE; if (is_file == 1) { BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name)); } else if ((prop = RNA_struct_find_property(op->ptr, "files"))) { - /* used for image strip */ - /* best guess, first images name */ RNA_PROP_BEGIN (op->ptr, itemptr, prop) { char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0); BLI_strncpy(seq_load->name, name, sizeof(seq_load->name)); @@ -278,9 +274,6 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato seq_load->views_format = imf->views_format; seq_load->flag |= SEQ_USE_VIEWS; - - /* operator custom data is always released after the SeqLoadInfo, - * no need to handle the memory here */ seq_load->stereo3d_format = &imf->stereo3d_format; } } @@ -332,22 +325,17 @@ static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), return true; } -/* add scene operator */ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - Scene *sce_seq; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); if (sce_seq == NULL) { @@ -356,11 +344,8 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) } seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_SCENE); - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ - + seq->blend_mode = SEQ_TYPE_CROSS; seq->scene = sce_seq; - - /* basic defaults */ seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2); @@ -388,26 +373,23 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const w sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE); return sequencer_add_scene_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Scene Strip"; ot->idname = "SEQUENCER_OT_scene_strip_add"; ot->description = "Add a strip to the sequencer using a blender scene as a source"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_scene_strip_invoke; ot->exec = sequencer_add_scene_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -417,22 +399,17 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) ot->prop = prop; } -/* add movieclip operator */ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - MovieClip *clip; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip")); if (clip == NULL) { @@ -443,12 +420,10 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MOVIECLIP); seq->blend_mode = SEQ_TYPE_CROSS; seq->clip = clip; + seq->len = BKE_movieclip_get_duration(clip); id_us_ensure_real(&seq->clip->id); - /* basic defaults */ - seq->len = BKE_movieclip_get_duration(clip); - BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); @@ -473,26 +448,23 @@ static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, con sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP); return sequencer_add_movieclip_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add MovieClip Strip"; ot->idname = "SEQUENCER_OT_movieclip_strip_add"; ot->description = "Add a movieclip strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_movieclip_strip_invoke; ot->exec = sequencer_add_movieclip_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -508,16 +480,12 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - Mask *mask; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask")); if (mask == NULL) { @@ -528,12 +496,10 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MASK); seq->blend_mode = SEQ_TYPE_CROSS; seq->mask = mask; + seq->len = BKE_mask_get_duration(mask); id_us_ensure_real(&seq->mask->id); - /* basic defaults */ - seq->len = BKE_mask_get_duration(mask); - BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); @@ -558,26 +524,23 @@ static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wm sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK); return sequencer_add_mask_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Mask Strip"; ot->idname = "SEQUENCER_OT_mask_strip_add"; ot->description = "Add a mask strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_mask_strip_invoke; ot->exec = sequencer_add_mask_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -589,7 +552,7 @@ void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot) static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFn seq_load_fn) { - Scene *scene = CTX_data_scene(C); /* only for sound */ + Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); SeqLoadInfo seq_load; int tot_files; @@ -603,7 +566,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); if (tot_files > 1) { - /* multiple files */ char dir_only[FILE_MAX]; char file_only[FILE_MAX]; @@ -614,7 +576,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad RNA_string_get(&itemptr, "name", file_only); BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only); - /* Set seq_load.name, else all video/audio files get the same name! ugly! */ + /* Set seq_load.name, otherwise all video/audio files get the same name. */ BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name)); seq = seq_load_fn(C, ed->seqbasep, &seq_load); @@ -627,11 +589,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } RNA_END; } - else { + else { /* Single file./ */ Sequence *seq; - - /* single file */ seq = seq_load_fn(C, ed->seqbasep, &seq_load); + if (seq) { sequencer_add_apply_overlap(C, op, seq); if (seq_load.seq_sound) { @@ -658,7 +619,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad return OPERATOR_FINISHED; } -/* add sequencer operators */ static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op) { op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__); @@ -673,8 +633,8 @@ static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op) } static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr), - PropertyRNA *prop, - void *UNUSED(user_data)) + PropertyRNA *prop, + void *UNUSED(user_data)) { const char *prop_id = RNA_property_identifier(prop); @@ -682,7 +642,6 @@ static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr), STREQ(prop_id, "filename")); } -/* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip); @@ -696,20 +655,12 @@ static int sequencer_add_movie_strip_invoke(bContext *C, Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); - /* only enable "use_framerate" if there aren't any existing strips - * - When there are no strips yet, there is no harm in enabling this, - * and it makes the single-strip case really nice for casual users - * - When there are strips, it's best we don't touch the framerate, - * as all hell may break loose (e.g. audio strips start overlapping - * and can't be restored) - * - These initial guesses can still be manually overridden by users - * from the modal options panel - */ + /* Only enable "use_framerate" if there aren't any existing strips, unless overriden by user. */ if (ed && ed->seqbasep && ed->seqbasep->first) { RNA_boolean_set(op->ptr, "use_framerate", false); } - /* This is for drag and drop */ + /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); @@ -717,17 +668,14 @@ static int sequencer_add_movie_strip_invoke(bContext *C, } sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE); - sequencer_add_init(C, op); - /* show multiview save options only if scene has multiviews */ + /* Show multiview save options only if scene use multiview. */ prop = RNA_struct_find_property(op->ptr, "show_multiview"); RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - // return sequencer_add_movie_strip_exec(C, op); } static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) @@ -737,15 +685,15 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) ImageFormatData *imf = &sad->im_format; PointerRNA imf_ptr, ptr; - /* main draw call */ + /* Main draw call. */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); uiDefAutoButsRNA( layout, &ptr, sequencer_add_draw_check_fn, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false); - /* image template */ + /* Image template. */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); - /* multiview template */ + /* Multiview template. */ if (RNA_boolean_get(op->ptr, "show_multiview")) { uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); } @@ -754,20 +702,19 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Movie Strip"; ot->idname = "SEQUENCER_OT_movie_strip_add"; ot->description = "Add a movie strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_movie_strip_invoke; ot->exec = sequencer_add_movie_strip_exec; ot->cancel = sequencer_add_cancel; ot->ui = sequencer_add_draw; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -787,8 +734,6 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) "Use framerate from the movie to keep sound and video in sync"); } -/* add sound operator */ - static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_sound_strip); @@ -798,7 +743,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - /* This is for drag and drop */ + /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); @@ -809,25 +754,22 @@ static int sequencer_add_sound_strip_invoke(bContext *C, WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - // return sequencer_add_sound_strip_exec(C, op); } void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Sound Strip"; ot->idname = "SEQUENCER_OT_sound_strip_add"; ot->description = "Add a sound strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_sound_strip_invoke; ot->exec = sequencer_add_sound_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -854,7 +796,6 @@ int sequencer_image_seq_get_minmax_frame(wmOperator *op, RNA_BEGIN (op->ptr, itemptr, "files") { char *filename; int frame; - /* just get the first filename */ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); if (filename) { @@ -885,7 +826,6 @@ void sequencer_image_seq_reserve_frames( int i; char *filename = NULL; RNA_BEGIN (op->ptr, itemptr, "files") { - /* just get the first filename */ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); break; } @@ -894,7 +834,7 @@ void sequencer_image_seq_reserve_frames( if (filename) { char ext[PATH_MAX]; char filename_stripped[PATH_MAX]; - /* strip the frame from filename and substitute with # */ + /* Strip the frame from filename and substitute with `#`. */ BLI_path_frame_strip(filename, ext); for (i = 0; i < len; i++, se++) { @@ -907,23 +847,20 @@ void sequencer_image_seq_reserve_frames( } } -/* add image operator */ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) { int minframe, numdigits; - /* cant use the generic function for this */ - Scene *scene = CTX_data_scene(C); /* only for sound */ + Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); SeqLoadInfo seq_load; Sequence *seq; - Strip *strip; StripElem *se; const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); seq_load_operator_info(&seq_load, C, op); - /* images are unique in how they handle this - 1 per strip elem */ + /* Images are unique in how they handle this - 1 per strip elem. */ if (use_placeholders) { seq_load.len = sequencer_image_seq_get_minmax_frame( op, seq_load.start_frame, &minframe, &numdigits); @@ -941,11 +878,10 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) ED_sequencer_deselect_all(scene); } - /* main adding function */ + /* Main adding function. */ seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load); strip = seq->strip; se = strip->stripdata; - seq->blend_mode = SEQ_TYPE_ALPHAOVER; if (use_placeholders) { @@ -968,21 +904,18 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } BKE_sequence_init_colorspace(seq); - BKE_sequence_calc_disp(scene, seq); - BKE_sequencer_sort(scene); - /* last active name */ + /* Last active name. */ BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir)); - sequencer_add_apply_overlap(C, op, seq); if (op->customdata) { MEM_freeN(op->customdata); } - BKE_sequence_invalidate_cache_composite(scene, seq); + BKE_sequence_invalidate_cache_composite(scene, seq); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -996,7 +929,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, PropertyRNA *prop; Scene *scene = CTX_data_scene(C); - /* drag drop has set the names */ + /* Name set already by drag and drop. */ if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { sequencer_generic_invoke_xy__internal( C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); @@ -1004,10 +937,9 @@ static int sequencer_add_image_strip_invoke(bContext *C, } sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE); - sequencer_add_init(C, op); - /* show multiview save options only if scene has multiviews */ + /* Show multiview save options only if scene use multiview. */ prop = RNA_struct_find_property(op->ptr, "show_multiview"); RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); @@ -1018,20 +950,19 @@ static int sequencer_add_image_strip_invoke(bContext *C, void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Image Strip"; ot->idname = "SEQUENCER_OT_image_strip_add"; ot->description = "Add an image or image sequence to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_image_strip_invoke; ot->exec = sequencer_add_image_strip_exec; ot->cancel = sequencer_add_cancel; ot->ui = sequencer_add_draw; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -1051,65 +982,54 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) "Use placeholders for missing frames of the strip"); } -/* add_effect_strip operator */ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - - Sequence *seq; /* generic strip vars */ + Sequence *seq; struct SeqEffectHandle sh; - - int start_frame, end_frame, channel, type; /* operator props */ - Sequence *seq1, *seq2, *seq3; const char *error_msg; + int start_frame, end_frame, channel, type; start_frame = RNA_int_get(op->ptr, "frame_start"); end_frame = RNA_int_get(op->ptr, "frame_end"); channel = RNA_int_get(op->ptr, "channel"); - type = RNA_enum_get(op->ptr, "type"); - // XXX move to invoke if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } - /* If seq1 is NULL and no error was raised it means the seq is standalone - * (like color strips) and we need to check its start and end frames are valid */ + /* Check its start and end frames are valid. */ if (seq1 == NULL && end_frame <= start_frame) { end_frame = start_frame + 1; RNA_int_set(op->ptr, "frame_end", end_frame); } seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, type); - BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); sh = BKE_sequence_get_effect(seq); - + sh.init(seq); seq->seq1 = seq1; seq->seq2 = seq2; seq->seq3 = seq3; - sh.init(seq); - - if (!seq1) { /* effect has no deps */ - seq->len = 1; + if (!seq1) { + seq->len = 1; /* Effect is generator, set non zero length. */ BKE_sequence_tx_set_final_right(seq, end_frame); } seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; - BKE_sequence_calc(scene, seq); if (seq->type == SEQ_TYPE_COLOR) { SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ + seq->blend_mode = SEQ_TYPE_CROSS; } else if (seq->type == SEQ_TYPE_ADJUSTMENT) { seq->blend_mode = SEQ_TYPE_CROSS; @@ -1118,8 +1038,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->blend_mode = SEQ_TYPE_ALPHAOVER; } - /* an unset channel is a special case where we automatically go above - * the other strips. */ + /* Set channel.*/ if (!RNA_struct_property_is_set(op->ptr, "channel")) { if (seq->seq1) { int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0, @@ -1134,20 +1053,16 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); - BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* runs BKE_sequence_calc */ - - /* not sure if this is needed with update_changed_seq_and_deps. - * it was NOT called in blender 2.4x, but wont hurt */ + BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs BKE_sequence_calc. */ BKE_sequencer_sort(scene); - BKE_sequence_invalidate_cache_composite(scene, seq); + BKE_sequence_invalidate_cache_composite(scene, seq); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; } -/* add color */ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -1159,10 +1074,8 @@ static int sequencer_add_effect_strip_invoke(bContext *C, if (is_type_set) { type = RNA_enum_get(op->ptr, "type"); - /* when invoking an effect strip which uses inputs, - * skip initializing the channel from the mouse. - * Instead leave the property unset so exec() initializes it to be - * above the strips its applied to. */ + /* When invoking an effect strip which uses inputs, skip initializing the channel from the + * mouse. */ if (BKE_sequence_effect_get_num_inputs(type) != 0) { prop_flag |= SEQPROP_NOCHAN; } @@ -1177,19 +1090,18 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Effect Strip"; ot->idname = "SEQUENCER_OT_effect_strip_add"; ot->description = "Add an effect to the sequencer, most are applied on top of existing strips"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_effect_strip_invoke; ot->exec = sequencer_add_effect_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; ot->poll_property = seq_effect_add_properties_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index a2568e2e827..dce8aa16985 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -54,7 +54,7 @@ static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNU { SpaceSeq *sseq = CTX_wm_space_seq(C); - /* don't show the gpencil if we are not showing the image */ + /* Don't show the gpencil if we are not showing the image. */ return ED_space_sequencer_check_show_imbuf(sseq); } #endif diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index db045b65d3f..2887113bdbe 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -79,20 +79,17 @@ #include "MEM_guardedalloc.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" #define SEQ_LEFTHANDLE 1 #define SEQ_RIGHTHANDLE 2 - #define SEQ_HANDLE_SIZE 8.0f - #define SEQ_SCROLLER_TEXT_OFFSET 8 - #define MUTE_ALPHA 120 /* Note, Don't use SEQ_BEGIN/SEQ_END while drawing! - * it messes up transform, - Campbell */ + * it messes up transform. */ #undef SEQ_BEGIN #undef SEQP_BEGIN #undef SEQ_END @@ -141,7 +138,7 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3]) col[2] = 130; break; - /* effects */ + /* Effects. */ case SEQ_TYPE_TRANSFORM: case SEQ_TYPE_SPEED: case SEQ_TYPE_ADD: @@ -234,13 +231,10 @@ static void draw_seq_waveform(View2D *v2d, float y2, float stepsize) { - /* - * x1 is the starting x value to draw the wave, - * x2 the end x value, same for y1 and y2 - * stepsize is width of a pixel. - */ + /* X1, x2 is the starting and end X value to draw the wave, same for y1 and y2. + * Stepsize is width of a pixel. */ - /* offset x1 and x2 values, to match view min/max, if strip is out of bounds */ + /* Offset x1 and x2 values, to match view min/max, if strip is out of bounds. */ int x1_offset = max_ff(v2d->cur.xmin, x1); int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2); @@ -254,8 +248,6 @@ static void draw_seq_waveform(View2D *v2d, float volume = seq->volume; float value1, value2; bSound *sound = seq->sound; - FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); - SoundWaveform *waveform; if (length < 2) { @@ -265,7 +257,7 @@ static void draw_seq_waveform(View2D *v2d, BLI_spin_lock(sound->spinlock); if (!sound->waveform) { if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) { - /* prevent sounds from reloading */ + /* Prevent sounds from reloading. */ sound->tags |= SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); sequencer_preview_add_sound(C, seq); @@ -273,15 +265,14 @@ static void draw_seq_waveform(View2D *v2d, else { BLI_spin_unlock(sound->spinlock); } - return; /* nothing to draw */ + return; /* Nothing to draw. */ } BLI_spin_unlock(sound->spinlock); waveform = sound->waveform; + /* Waveform could not be built. */ if (waveform->length == 0) { - /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a - * valid one. See T45726. */ return; } @@ -299,6 +290,9 @@ static void draw_seq_waveform(View2D *v2d, return; } + /* Fcurve lookup is quite expensive, so do this after precondition. */ + FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); + GPU_blend(true); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -325,7 +319,7 @@ static void draw_seq_waveform(View2D *v2d, } } else if (p + 1 < waveform->length) { - /* use simple linear interpolation */ + /* Use simple linear interpolation. */ float f = sampleoffset - p; value1 = (1.0f - f) * value1 + f * waveform->data[p * 3 + 3]; value2 = (1.0f - f) * value2 + f * waveform->data[p * 3 + 4]; @@ -361,10 +355,6 @@ static void draw_seq_waveform(View2D *v2d, static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2) { - /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the - * seq->depth value, (needed by transform when doing overlap checks) - * so for now, just use the meta's immediate children, could be fixed but - * its only drawing - campbell */ Sequence *seq; uchar col[4]; @@ -400,12 +390,12 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, chan_range = (chan_max - chan_min) + 1; draw_height = draw_range / chan_range; - col[3] = 196; /* alpha, used for all meta children */ + col[3] = 196; /* Alpha, used for all meta children. */ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + /* Draw only immediate children (1 level depth). */ for (seq = seqbase->first; seq; seq = seq->next) { const int startdisp = seq->startdisp + offset; const int enddisp = seq->enddisp + offset; @@ -433,7 +423,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, immUniformColor4ubv(col); - /* clamp within parent sequence strip bounds */ + /* Clamp within parent sequence strip bounds. */ if (x1_chan < x1) { x1_chan = x1; } @@ -453,16 +443,16 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, GPU_blend(false); } -/* clamp handles to defined size in pixel space */ +/* Get handle width in pixels. */ float sequence_handle_size_get_clamped(Sequence *seq, const float pixelx) { const float maxhandle = (pixelx * SEQ_HANDLE_SIZE) * U.pixelsize; - /* ensure we're not greater than half width */ + /* Ensure that handle is not wider, than half of strip. */ return min_ff(maxhandle, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx); } -/* draw a handle, for each end of a sequence strip */ +/* Draw a handle, on left or right side of strip. */ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, @@ -483,7 +473,7 @@ static void draw_seq_handle(View2D *v2d, y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - /* set up co-ordinates/dimensions for either left or right handle */ + /* Set up co-ordinates and dimensions for either left or right handle. */ if (direction == SEQ_LEFTHANDLE) { rx1 = x1; rx2 = x1 + handsize_clamped; @@ -495,7 +485,6 @@ static void draw_seq_handle(View2D *v2d, whichsel = SEQ_RIGHTSEL; } - /* draw! */ if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) { GPU_blend(true); @@ -522,9 +511,7 @@ static void draw_seq_handle(View2D *v2d, GPU_blend(false); } - /* Draw numbers for start and end of the strip next to its handles. - * - Draw only when handles are selected or while translating the strip. - */ + /* Draw numbers for start and end of the strip next to its handles. */ if (y_threshold && (((seq->flag & SELECT) && (G.moving & G_TRANSFORM_SEQ)) || (seq->flag & whichsel))) { @@ -575,8 +562,8 @@ static void draw_seq_outline(Sequence *seq, else if (seq->flag & SELECT) { UI_GetThemeColor3ubv(TH_SEQ_SELECTED, col); } - /* Regular color for unselected strips: a bit darker than the background. */ else { + /* Color for unselected strips is a bit darker than the background. */ UI_GetThemeColor3ubv(TH_BACK, col); UI_GetColorPtrShade3ubv(col, col, -40); } @@ -610,13 +597,13 @@ static void draw_seq_outline(Sequence *seq, /* Top */ immRectf(pos, x1 - pixelx, y2 - 2 * pixely, x2 + pixelx, y2); } - /* 1px wide outline for unselected strips. */ else { + /* 1px wide outline for unselected strips. */ imm_draw_box_wire_2d(pos, x1, y1, x2, y2); } } -/* draw info text on a sequence strip */ +/* Draw info text on a sequence strip. */ static void draw_seq_text(View2D *v2d, Sequence *seq, SpaceSeq *sseq, @@ -633,7 +620,7 @@ static void draw_seq_text(View2D *v2d, const char *name = seq->name + 2; uchar col[4]; - /* note, all strings should include 'name' */ + /* All strings should include name. */ if (name[0] == '\0') { name = BKE_sequence_give_name(seq); } @@ -723,7 +710,7 @@ static void draw_seq_text(View2D *v2d, seq->len); } else { - /* should never get here!, but might with files from future */ + /* Should never get here!, but might with files from future. */ BLI_assert(0); str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); @@ -888,7 +875,7 @@ static void draw_seq_background(Scene *scene, } } - /* Transition strips.. Draw right half. */ + /* Draw right half of transition strips. */ if (ELEM(seq->type, SEQ_TYPE_CROSS, SEQ_TYPE_GAMCROSS, SEQ_TYPE_WIPE)) { float vert_pos[3][2]; Sequence *seq1 = seq->seq1; @@ -966,7 +953,7 @@ static void calculate_seq_text_offsets( float scroller_vert_xoffs = (V2D_SCROLL_HANDLE_WIDTH + SEQ_SCROLLER_TEXT_OFFSET) * pixelx; - /* info text on the strip */ + /* Info text on the strip. */ if (*x1 < v2d->cur.xmin + scroller_vert_xoffs) { *x1 = v2d->cur.xmin + scroller_vert_xoffs; } @@ -981,11 +968,7 @@ static void calculate_seq_text_offsets( } } -/* - * Draw a sequence strip, bounds check already made - * ARegion is currently only used to get the windows width in pixels - * so wave file sample drawing precision is zoom adjusted - */ +/* Draw visible strips. */ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, @@ -999,20 +982,19 @@ static void draw_seq_strip(const bContext *C, const float handsize_clamped = sequence_handle_size_get_clamped(seq, pixelx); float pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); - /* We need to know if this is a single image/color or not for drawing. */ + /* Check if we are doing "solo preview". */ bool is_single_image = (char)BKE_sequence_single_check(seq); - /* body */ + /* Draw strip body. */ x1 = (seq->startstill) ? seq->start : seq->startdisp; y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; y2 = seq->machine + SEQ_STRIP_OFSTOP; - /* Position of the text, - * make sure that the strip content is visible also when the strip height gets lower. */ + /* Calculate height needed for drawing text on strip. */ float text_margin_y = y2 - min_ff(0.40f, 20 * U.dpi_fac * pixely); - /* Show some content only when the strip is high enough. */ + /* Is there enough space for drawing something else than text? */ bool y_threshold = ((y2 - y1) / pixely) > 20 * U.dpi_fac; uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1020,12 +1002,12 @@ static void draw_seq_strip(const bContext *C, draw_seq_background(scene, seq, pos, x1, x2, y1, y2, is_single_image); - /* Color strips.. Draw a band with the strip's color on its lower part. */ + /* Draw a color band inside color strip. */ if (seq->type == SEQ_TYPE_COLOR && y_threshold) { draw_color_strip_band(seq, pos, text_margin_y, y1); } - /* Draw strip's offsets when flag is enabled or during "solo preview". */ + /* Draw strip offsets when flag is enabled or during "solo preview". */ if (!is_single_image && (seq->startofs || seq->endofs) && pixely > 0) { if ((sseq->draw_flag & SEQ_DRAW_OFFSET_EXT) || (seq == special_seq_update)) { draw_sequence_extensions(scene, seq, pos, pixely); @@ -1042,7 +1024,7 @@ static void draw_seq_strip(const bContext *C, drawmeta_contents(scene, seq, x1, y1, x2, y2); } - /* Sound strips.. Draw waveforms. */ + /* Draw sound strip waveform. */ if ((seq->type == SEQ_TYPE_SOUND_RAM) && (sseq->flag & SEQ_NO_WAVEFORMS) == 0) { draw_seq_waveform(v2d, C, @@ -1061,7 +1043,7 @@ static void draw_seq_strip(const bContext *C, draw_seq_locked(x1, y1, x2, y2); } - /* Missing media indication.. Draw a red line on the top of the strip. */ + /* Draw Red line on the top of invalid strip (Missing media). */ if (!BKE_sequence_is_valid_check(seq)) { draw_seq_invalid(x1, x2, y2, text_margin_y); } @@ -1082,11 +1064,9 @@ static void draw_seq_strip(const bContext *C, calculate_seq_text_offsets(v2d, seq, &x1, &x2, pixelx); - /* Draw the text on the top section of the strip, - * - depending on the vertical space, move it to the center or don't draw it. - * - don't draw it when there is not enough horizontal space. - */ + /* Don't draw strip if there is not enough vertical or horizontal space. */ if (((x2 - x1) > 32 * pixelx * U.dpi_fac) && ((y2 - y1) > 8 * pixely * U.dpi_fac)) { + /* Depending on the vertical space, draw text on top or in the center of strip. */ draw_seq_text( v2d, seq, sseq, x1, x2, y_threshold ? text_margin_y : y1, y2, seq_active, y_threshold); } @@ -1203,7 +1183,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, GPU_framebuffer_bind(fb); } - /* restore state so real rendering would be canceled (if needed) */ + /* Restore state so real rendering would be canceled if needed. */ G.is_break = is_break; return ibuf; @@ -1264,17 +1244,17 @@ static void sequencer_display_size(Scene *scene, float r_viewrect[2]) static void sequencer_draw_gpencil(const bContext *C) { - /* draw grease-pencil (image aligned) */ + /* Draw grease-pencil (image aligned). */ ED_annotation_draw_2dimage(C); - /* ortho at pixel level */ + /* Ortho at pixel level. */ UI_view2d_view_restore(C); - /* draw grease-pencil (screen aligned) */ + /* Draw grease-pencil (screen aligned). */ ED_annotation_draw_view2d(C, 0); } -/* draws content borders plus safety borders if needed */ +/* Draw content and safety borders borders. */ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, const Scene *scene) { float x1 = v2d->tot.xmin; @@ -1284,7 +1264,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons GPU_line_width(1.0f); - /* border */ + /* Draw border. */ const uint shdr_pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1301,7 +1281,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons imm_draw_box_wire_2d(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f); - /* safety border */ + /* Draw safety border. */ if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) { immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f); @@ -1325,8 +1305,8 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons #if 0 void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *region, SpaceSeq *sseq) { - /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not, - * for now just disable drawing since the strip frame will likely be offset */ + /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not. + * For now just disable drawing since the strip frame will likely be offset. */ // if (sc->mode == SC_MODE_MASKEDIT) if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { @@ -1377,8 +1357,8 @@ static void *sequencer_OCIO_transform_ibuf( force_fallback |= (ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL); force_fallback |= (ibuf->dither != 0.0f); + /* Fallback to CPU based color space conversion. */ if (force_fallback) { - /* Fallback to CPU based color space conversion */ *r_glsl_used = false; *r_format = GL_RGBA; *r_type = GL_UNSIGNED_BYTE; @@ -1423,9 +1403,8 @@ static void *sequencer_OCIO_transform_ibuf( display_buffer = NULL; } - /* there's a data to be displayed, but GLSL is not initialized - * properly, in this case we fallback to CPU-based display transform - */ + /* There is data to be displayed, but GLSL is not initialized + * properly, in this case we fallback to CPU-based display transform. */ if ((ibuf->rect || ibuf->rect_float) && !*r_glsl_used) { display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); *r_format = GL_RGBA; @@ -1441,14 +1420,12 @@ static void *sequencer_OCIO_transform_ibuf( static void sequencer_stop_running_jobs(const bContext *C, Scene *scene) { if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) { - /* stop all running jobs, except screen one. currently previews frustrate Render - * needed to make so sequencer's rendering doesn't conflict with compositor - */ + /* Stop all running jobs, except screen one. Currently previews frustrate Render. + * Need to make so sequencer's rendering doesn't conflict with compositor. */ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE); - /* in case of final rendering used for preview, kill all previews, - * otherwise threading conflict will happen in rendering module - */ + /* In case of final rendering used for preview, kill all previews, + * otherwise threading conflict will happen in rendering module. */ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW); } } @@ -1521,8 +1498,7 @@ static void sequencer_draw_display_buffer(const bContext *C, } /* Format needs to be created prior to any immBindProgram call. - * Do it here because OCIO binds it's own shader. - */ + * Do it here because OCIO binds it's own shader. */ int format, type; bool glsl_used = false; GLuint texid; @@ -1671,7 +1647,7 @@ static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, boo break; } - /* future files may have new scopes we don't catch above */ + /* Future files may have new scopes we don't catch above. */ if (scope) { scopes->reference_ibuf = ibuf; } @@ -1708,13 +1684,13 @@ void sequencer_draw_preview(const bContext *C, return; } - /* Setup view */ + /* Setup view. */ sequencer_display_size(scene, viewrect); UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f); UI_view2d_curRect_validate(v2d); UI_view2d_view_ortho(v2d); - /* Draw background */ + /* Draw background. */ if (!draw_backdrop && (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)) { sequencer_preview_clear(); @@ -1722,18 +1698,18 @@ void sequencer_draw_preview(const bContext *C, imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); } } - /* Get image */ + /* Get image. */ ibuf = sequencer_ibuf_get( bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]); if (ibuf) { scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop); - /* Draw image */ + /* Draw image. */ sequencer_draw_display_buffer( C, scene, region, sseq, ibuf, scope, draw_overlay, draw_backdrop); - /* Draw over image */ + /* Draw over image. */ if (sseq->flag & SEQ_SHOW_METADATA) { ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0); } @@ -1746,12 +1722,11 @@ void sequencer_draw_preview(const bContext *C, if (draw_gpencil && show_imbuf) { sequencer_draw_gpencil(C); } +#if 0 + sequencer_draw_maskedit(C, scene, region, sseq); +#endif - /* TODO */ - /* sequencer_draw_maskedit(C, scene, region, sseq); */ - - /* Scope is freed in sequencer_check_scopes when ibuf changes and - * scope image is to be replaced. */ + /* Scope is freed in sequencer_check_scopes when ibuf changes and redraw is needed. */ if (ibuf) { IMB_freeImBuf(ibuf); } @@ -1760,7 +1735,7 @@ void sequencer_draw_preview(const bContext *C, seq_prefetch_wm_notify(C, scene); } -/* draw backdrop of the sequencer strips view */ +/* Draw backdrop in sequencer timeline. */ static void draw_seq_backdrop(View2D *v2d) { int i; @@ -1768,11 +1743,11 @@ static void draw_seq_backdrop(View2D *v2d) uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - /* darker gray overlay over the view backdrop */ + /* Darker gray overlay over the view backdrop. */ immUniformThemeColorShade(TH_BACK, -20); immRectf(pos, v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0); - /* Alternating horizontal stripes */ + /* Alternating horizontal stripes. */ i = max_ii(1, ((int)v2d->cur.ymin) - 1); while (i < v2d->cur.ymax) { @@ -1788,7 +1763,7 @@ static void draw_seq_backdrop(View2D *v2d) i++; } - /* Darker lines separating the horizontal bands */ + /* Darker lines separating the horizontal bands. */ i = max_ii(1, ((int)v2d->cur.ymin) - 1); int line_len = (int)v2d->cur.ymax - i + 1; immUniformThemeColor(TH_GRID); @@ -1802,7 +1777,6 @@ static void draw_seq_backdrop(View2D *v2d) immUnbindProgram(); } -/* draw the contents of the sequencer strips view */ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) { Scene *scene = CTX_data_scene(C); @@ -1812,12 +1786,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) int sel = 0, j; float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); - /* loop through twice, first unselected, then selected */ + /* Loop through twice, first unselected, then selected. */ for (j = 0; j < 2; j++) { Sequence *seq; - /* loop through strips, checking for those that are visible */ + /* Loop through strips, checking for those that are visible. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { - /* boundbox and selection tests for NOT drawing the strip... */ + /* Boundbox and selection tests for NOT drawing the strip. */ if ((seq->flag & SELECT) != sel) { continue; } @@ -1837,11 +1811,11 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) continue; } - /* strip passed all tests unscathed... so draw it now */ + /* Strip passed all tests, draw it now. */ draw_seq_strip(C, sseq, scene, region, seq, pixelx, seq == last_seq ? true : false); } - /* draw selected next time round */ + /* Draw selected next time round. */ sel = SELECT; } @@ -1872,7 +1846,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) } } - /* draw highlight when previewing a single strip */ + /* Draw highlight if "solo preview" is used. */ if (special_seq_update) { const Sequence *seq = special_seq_update; GPU_blend(true); @@ -1904,8 +1878,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - /* draw darkened area outside of active timeline - * frame range used is preview range or scene range */ + /* Draw overlay outside of frame range. */ immUniformThemeColorShadeAlpha(TH_BACK, -25, -100); if (frame_sta < frame_end) { @@ -1918,7 +1891,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUniformThemeColorShade(TH_BACK, -60); - /* thin lines where the actual frames are */ + /* Draw frame range boundary. */ immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, frame_sta, v2d->cur.ymin); @@ -1929,7 +1902,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immEnd(); - /* While inside a meta strip, draw a checkerboard pattern outside of its range. */ + /* While in meta strip, draw a checkerboard overlay outside of frame range. */ if (ed && !BLI_listbase_is_empty(&ed->metastack)) { MetaStack *ms = ed->metastack.last; immUnbindProgram(); @@ -1979,7 +1952,7 @@ typedef struct CacheDrawData { size_t final_out_vert_count; } CacheDrawData; -/* Called as a callback */ +/* Called as a callback. */ static bool draw_cache_view_init_fn(void *userdata, size_t item_count) { if (item_count == 0) { @@ -2175,7 +2148,7 @@ static void draw_cache_view(const bContext *C) GPU_blend(false); } -/* Draw Timeline/Strip Editor Mode for Sequencer */ +/* Draw sequencer timeline. */ void draw_timeline_seq(const bContext *C, ARegion *region) { Scene *scene = CTX_data_scene(C); @@ -2188,7 +2161,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region) seq_prefetch_wm_notify(C, scene); - /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); if (ed && ed->metastack.first) { GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f); @@ -2199,44 +2171,36 @@ void draw_timeline_seq(const bContext *C, ARegion *region) GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); - - /* calculate extents of sequencer strips/data - * NOTE: needed for the scrollers later - */ + /* Get timeline boundbox, needed for the scrollers. */ boundbox_seq(scene, &v2d->tot); - - /* draw backdrop */ draw_seq_backdrop(v2d); - - /* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */ UI_view2d_constant_grid_draw(v2d, FPS); - /* Only draw backdrop in pure sequence view. */ + /* Only draw backdrop in timeline view. */ if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) { sequencer_draw_preview(C, scene, region, sseq, scene->r.cfra, 0, false, true); UI_view2d_view_ortho(v2d); } + /* Draw attached callbacks. */ ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); - seq_draw_sfra_efra(scene, v2d); - /* sequence strips (if there is data available to be drawn) */ if (ed) { - /* draw the data */ draw_seq_strips(C, ed, region); - /* text draw cached (for sequence names), in pixelspace now */ + /* Draw text added in previous function. */ UI_view2d_text_cache_draw(region); } - /* current frame */ UI_view2d_view_ortho(v2d); if ((sseq->flag & SEQ_DRAWFRAMES) == 0) { cfra_flag |= DRAWCFRA_UNIT_SECONDS; } + + /* Draw playhead. */ ANIM_draw_cfra(C, v2d, cfra_flag); - /* overlap playhead */ + /* Draw overlap playhead. */ if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : @@ -2247,7 +2211,8 @@ void draw_timeline_seq(const bContext *C, ARegion *region) float viewport_size[4]; GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("colors_len", 0); /* "simple" mode */ + /* Shader may have color set from past usage - reset it. */ + immUniform1i("colors_len", 0); immUniform1f("dash_width", 20.0f * U.pixelsize); immUniform1f("dash_factor", 0.5f); immUniformThemeColor(TH_CFRAME); @@ -2260,7 +2225,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region) immUnbindProgram(); } - /* markers */ UI_view2d_view_orthoSpecial(region, v2d, 1); int marker_draw_flag = DRAW_MARKERS_MARGIN; if (sseq->flag & SEQ_SHOW_MARKERS) { @@ -2268,28 +2232,22 @@ void draw_timeline_seq(const bContext *C, ARegion *region) } UI_view2d_view_ortho(v2d); - /* draw cache on top of markers area */ + if (ed) { draw_cache_view(C); } - /* preview range */ + ANIM_draw_previewrange(C, v2d, 1); - /* callback */ + /* Draw registered callbacks. */ ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); - - /* reset view matrix */ UI_view2d_view_restore(C); - - /* scrubbing region */ ED_time_scrub_draw(region, scene, !(sseq->flag & SEQ_DRAWFRAMES), true); - - /* scrollers */ scrollers = UI_view2d_scrollers_calc(v2d, NULL); UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); - /* channel numbers */ + /* Draw channel numbers. */ { rcti rect; BLI_rcti_init( diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 3d9de1f567c..c2ffb2f55c2 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -52,7 +52,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -/* for menu/popup icons etc etc*/ +/* For menu, popup, icons, etc. */ #include "ED_anim_api.h" #include "ED_numinput.h" @@ -67,11 +67,11 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" /* XXX */ -/* RNA Enums, used in multiple files */ +/* RNA Enums, used in multiple files. */ EnumPropertyItem sequencer_prop_effect_types[] = { {SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"}, {SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"}, @@ -94,8 +94,6 @@ EnumPropertyItem sequencer_prop_effect_types[] = { {0, NULL, 0, NULL, NULL}, }; -/* mute operator */ - #define SEQ_SIDE_MOUSE -1 EnumPropertyItem prop_side_types[] = { @@ -144,7 +142,7 @@ static void proxy_freejob(void *pjv) MEM_freeN(pj); } -/* only this runs inside thread */ +/* Only this runs inside thread. */ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) { ProxyJob *pj = pjv; @@ -291,7 +289,7 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame) mval[0] = mouse_x; mval[1] = 0; - /* choose the side based on which side of the playhead the mouse is on */ + /* Choose the side based on which side of the playhead the mouse is on. */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]); return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT; @@ -299,7 +297,7 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame) Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel) { - /* sel - 0==unselected, 1==selected, -1==done care*/ + /* sel: 0==unselected, 1==selected, -1==don't care. */ Sequence *seq; Editing *ed = BKE_sequencer_editing_get(scene, false); @@ -334,7 +332,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel) { - /* sel - 0==unselected, 1==selected, -1==done care*/ + /* sel: 0==unselected, 1==selected, -1==don't care. */ Sequence *seq, *best_seq = NULL; Editing *ed = BKE_sequencer_editing_get(scene, false); @@ -375,7 +373,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i } seq = seq->next; } - return best_seq; /* can be null */ + return best_seq; /* Can be null. */ } Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2]) @@ -400,22 +398,21 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ while (seq) { if (seq->machine == (int)y) { - /* check for both normal strips, and strips that have been flipped horizontally */ + /* Check for both normal strips, and strips that have been flipped horizontally. */ if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) || ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x))) { if (BKE_sequence_tx_test(seq)) { - /* clamp handles to defined size in pixel space */ - + /* Clamp handles to defined size in pixel space. */ handsize = 2.0f * sequence_handle_size_get_clamped(seq, pixelx); displen = (float)abs(seq->startdisp - seq->enddisp); - /* don't even try to grab the handles of small strips */ + /* Don't even try to grab the handles of small strips. */ if (displen / pixelx > 16) { + /* Set the max value to handle to 1/3 of the total len when its * less than 28. This is important because otherwise selecting * handles happens even when you click in the middle. */ - if ((displen / 3) < 30 * pixelx) { handsize = displen / 3; } @@ -510,7 +507,6 @@ void recurs_sel_seq(Sequence *seqm) bool ED_space_sequencer_maskedit_mask_poll(bContext *C) { - /* in this case both funcs are the same, for clip editor not */ return ED_space_sequencer_maskedit_poll(C); } @@ -535,7 +531,7 @@ bool ED_space_sequencer_maskedit_poll(bContext *C) return false; } -/* are we displaying the seq output (not channels or histogram)*/ +/* Are we displaying the seq output (not channels or histogram). */ bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq) { return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) && @@ -589,8 +585,8 @@ int seq_effect_find_selected(Scene *scene, } } - /* make sequence selection a little bit more intuitive - * for 3 strips: the last-strip should be sequence3 */ + /* Make sequence selection a little bit more intuitive + * for 3 strips: the last-strip should be seq3. */ if (seq3 != NULL && seq2 != NULL) { Sequence *tmp = seq2; seq2 = seq3; @@ -600,7 +596,7 @@ int seq_effect_find_selected(Scene *scene, switch (BKE_sequence_effect_get_num_inputs(type)) { case 0: *r_selseq1 = *r_selseq2 = *r_selseq3 = NULL; - return 1; /* success */ + return 1; /* Success. */ case 1: if (seq2 == NULL) { *r_error_str = N_("At least one selected sequence strip is needed"); @@ -640,8 +636,8 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) { Sequence *seq1, *seq2, *seq3; - /* try to find a replacement input sequence, and flag for later deletion if - * no replacement can be found */ + /* Try to find a replacement input sequence, and flag for later deletion if + * no replacement can be found. */ if (!seq) { return NULL; @@ -650,13 +646,13 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) return ((seq->flag & SELECT) ? NULL : seq); } else if (!(seq->flag & SELECT)) { - /* try to find replacement for effect inputs */ + /* Try to find replacement for effect inputs. */ seq1 = del_seq_find_replace_recurs(scene, seq->seq1); seq2 = del_seq_find_replace_recurs(scene, seq->seq2); seq3 = del_seq_find_replace_recurs(scene, seq->seq3); if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) { - /* pass */ + /* Pass. */ } else if (seq1 || seq2 || seq3) { seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3; @@ -666,7 +662,7 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); } else { - seq->flag |= SELECT; /* mark for delete */ + seq->flag |= SELECT; /* Mark for delete. */ } } @@ -740,7 +736,7 @@ static Sequence *split_seq_hard( /* Unlike soft-split, it's important to use the same value for both strips. */ const bool is_end_exact = ((seq->start + seq->len) == split_frame); - /* backup values */ + /* Backup values. */ ts.start = seq->start; ts.machine = seq->machine; ts.startstill = seq->startstill; @@ -753,21 +749,19 @@ static Sequence *split_seq_hard( ts.anim_endofs = seq->anim_endofs; ts.len = seq->len; - /* First Strip! */ - /* strips with extended stillfames before */ - - /* Precaution, needed because the length saved on-disk may not match the length saved in the - * blend file, or our code may have minor differences reading file length between versions. - * This causes hard-split to fail, see: T47862 */ if (seq->type != SEQ_TYPE_META) { + /* Precaution, needed because the length saved on-disk may not match the length saved in the + * blend file, or our code may have minor differences reading file length between versions. + * This causes hard-split to fail, see: T47862. */ BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); } + /* First Strip. */ /* Important to offset the start when 'split_frame == seq->start' * because we need at least one frame of content after start/end still have clipped it. */ if ((seq->startstill) && (split_frame <= seq->start)) { - /* don't do funny things with METAs ... */ + /* Don't do funny things with METAs. */ if (seq->type == SEQ_TYPE_META) { skip_dup = true; seq->startstill = seq->start - split_frame; @@ -779,18 +773,18 @@ static Sequence *split_seq_hard( seq->endstill = 0; } } - /* normal strip */ + /* Normal strip. */ else if ((is_end_exact == false) && ((split_frame >= seq->start) && (split_frame <= (seq->start + seq->len)))) { seq->endofs = 0; seq->endstill = 0; seq->anim_endofs += (seq->start + seq->len) - split_frame; } - /* strips with extended stillframes after */ + /* Strips with extended stillframes. */ else if ((is_end_exact == true) || (((seq->start + seq->len) < split_frame) && (seq->endstill))) { seq->endstill -= seq->enddisp - split_frame; - /* don't do funny things with METAs ... */ + /* Don't do funny things with METAs. */ if (seq->type == SEQ_TYPE_META) { skip_dup = true; } @@ -800,7 +794,7 @@ static Sequence *split_seq_hard( BKE_sequence_calc(scene, seq); if (!skip_dup) { - /* Duplicate AFTER the first change */ + /* Duplicate AFTER the first change. */ seqn = BKE_sequence_dupli_recursive( scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } @@ -808,12 +802,11 @@ static Sequence *split_seq_hard( if (seqn) { seqn->flag |= SELECT; - /* Important not to re-assign this (unlike soft-split) */ #if 0 is_end_exact = ((seqn->start + seqn->len) == split_frame); #endif - /* Second Strip! */ - /* strips with extended stillframes before */ + /* Second Strip. */ + /* strips with extended stillframes. */ if ((seqn->startstill) && (split_frame == seqn->start + 1)) { seqn->start = ts.start; seqn->startstill = ts.start - split_frame; @@ -821,7 +814,7 @@ static Sequence *split_seq_hard( seqn->endstill = ts.endstill; } - /* normal strip */ + /* Normal strip. */ else if ((is_end_exact == false) && ((split_frame >= seqn->start) && (split_frame <= (seqn->start + seqn->len)))) { seqn->start = split_frame; @@ -833,7 +826,7 @@ static Sequence *split_seq_hard( seqn->endstill = ts.endstill; } - /* strips with extended stillframes after */ + /* Strips with extended stillframes after. */ else if ((is_end_exact == true) || (((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) { seqn->start = split_frame; @@ -858,7 +851,7 @@ static Sequence *split_seq_soft( bool is_end_exact = ((seq->start + seq->len) == split_frame); - /* backup values */ + /* Backup values. */ ts.start = seq->start; ts.machine = seq->machine; ts.startstill = seq->startstill; @@ -871,9 +864,8 @@ static Sequence *split_seq_soft( ts.anim_endofs = seq->anim_endofs; ts.len = seq->len; - /* First Strip! */ - /* strips with extended stillfames before */ - + /* First Strip. */ + /* Strips with extended stillfames. */ /* Important to offset the start when 'split_frame == seq->start' * because we need at least one frame of content after start/end still have clipped it. */ if ((seq->startstill) && (split_frame <= seq->start)) { @@ -889,16 +881,16 @@ static Sequence *split_seq_soft( seq->endstill = 0; } } - /* normal strip */ + /* Normal strip. */ else if ((is_end_exact == false) && (split_frame >= seq->start) && (split_frame <= (seq->start + seq->len))) { seq->endofs = (seq->start + seq->len) - split_frame; } - /* strips with extended stillframes after */ + /* Strips with extended stillframes. */ else if ((is_end_exact == true) || (((seq->start + seq->len) < split_frame) && (seq->endstill))) { seq->endstill -= seq->enddisp - split_frame; - /* don't do funny things with METAs ... */ + /* Don't do funny things with METAs. */ if (seq->type == SEQ_TYPE_META) { skip_dup = true; } @@ -907,7 +899,7 @@ static Sequence *split_seq_soft( BKE_sequence_calc(scene, seq); if (!skip_dup) { - /* Duplicate AFTER the first change */ + /* Duplicate AFTER the first change. */ seqn = BKE_sequence_dupli_recursive( scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } @@ -917,8 +909,8 @@ static Sequence *split_seq_soft( is_end_exact = ((seqn->start + seqn->len) == split_frame); - /* Second Strip! */ - /* strips with extended stillframes before */ + /* Second Strip. */ + /* Strips with extended stillframes. */ if ((seqn->startstill) && (split_frame == seqn->start + 1)) { seqn->start = ts.start; seqn->startstill = ts.start - split_frame; @@ -926,7 +918,7 @@ static Sequence *split_seq_soft( seqn->endstill = ts.endstill; } - /* normal strip */ + /* Normal strip. */ else if ((is_end_exact == false) && (split_frame >= seqn->start) && (split_frame <= (seqn->start + seqn->len))) { seqn->startstill = 0; @@ -935,7 +927,7 @@ static Sequence *split_seq_soft( seqn->endstill = ts.endstill; } - /* strips with extended stillframes after */ + /* Strips with extended stillframes. */ else if ((is_end_exact == true) || (((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) { seqn->start = split_frame - ts.len + 1; @@ -949,12 +941,12 @@ static Sequence *split_seq_soft( return seqn; } -/* like duplicate, but only duplicate and split overlapping strips, +/* Like duplicate, but only duplicate and split overlapping strips, * strips to the left of the split_frame are ignored and strips to the right - * are moved to the end of slist - * we have to work on the same slist (not using a separate list), since + * are moved to the end of slist. + * We have to work on the same slist (not using a separate list), since * otherwise dupli_seq can't check for duplicate names properly and - * may generate strips with the same name (which will mess up animdata) + * may generate strips with the same name which will mess up animdata. */ static bool split_seq_list( @@ -973,7 +965,7 @@ static bool split_seq_list( seq = slist->first; while (seq && seq != seq_first_new) { - seq_next_iter = seq->next; /* we need this because we may remove seq */ + seq_next_iter = seq->next; /* We need this because we may remove seq. */ seq->tmp = NULL; if (use_cursor_position) { if (seq->machine == channel && seq->startdisp < split_frame && seq->enddisp > split_frame) { @@ -996,10 +988,10 @@ static bool split_seq_list( } } else if (seq->enddisp <= split_frame) { - /* do nothing */ + /* Pass. */ } else if (seq->startdisp >= split_frame) { - /* move to tail */ + /* Move to tail. */ BLI_remlink(slist, seq); BLI_addtail(slist, seq); @@ -1022,7 +1014,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int bool done = false; TimeMarker *marker; - /* all strips >= cfra are shifted */ + /* All strips >= cfra are shifted. */ if (ed == NULL) { return 0; @@ -1085,12 +1077,12 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene) } BLI_strncpy(from, last_seq->strip->dir, sizeof(from)); - // XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: ")) - // return; + /* XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: ")) + * return; */ BLI_strncpy(to, from, sizeof(to)); - // XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: ")) - // return; + /* XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: ")) + * return; */ if (STREQ(to, from)) { return; @@ -1101,11 +1093,11 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene) if (STREQLEN(seq->strip->dir, from, strlen(from))) { printf("found %s\n", seq->strip->dir); - /* strip off the beginning */ + /* Strip off the beginning. */ stripped[0] = 0; BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX); - /* new path */ + /* New path. */ BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped); printf("new %s\n", seq->strip->dir); } @@ -1122,12 +1114,12 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) bool first = false, done; bool do_all = RNA_boolean_get(op->ptr, "all"); - /* get first and last frame */ + /* Get first and last frame. */ boundbox_seq(scene, &rectf); sfra = (int)rectf.xmin; efra = (int)rectf.xmax; - /* first check if the current frame has a gap already */ + /* Check if the current frame has a gap already. */ for (cfra = CFRA; cfra >= sfra; cfra--) { if (BKE_sequencer_evaluate_frame(scene, cfra)) { first = true; @@ -1136,7 +1128,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) } for (; cfra < efra; cfra++) { - /* first == 0 means there's still no strip to remove a gap for */ + /* There's still no strip to remove a gap for. */ if (first == false) { if (BKE_sequencer_evaluate_frame(scene, cfra)) { first = true; @@ -1164,19 +1156,19 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Remove Gaps"; ot->idname = "SEQUENCER_OT_gap_remove"; ot->description = "Remove gap at current frame to first strip at the right, independent of selection or " "locked state of strips"; - /* api callbacks */ + /* Api callbacks. */ // ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_gap_remove_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame"); @@ -1196,19 +1188,19 @@ static int sequencer_gap_insert_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Insert Gaps"; ot->idname = "SEQUENCER_OT_gap_insert"; ot->description = "Insert gap at current frame to first strips at the right, independent of selection or " "locked state of strips"; - /* api callbacks */ + /* Api callbacks. */ // ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_gap_insert_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, @@ -1238,7 +1230,7 @@ static int seq_get_snaplimit(View2D *v2d) } #endif -/* Operator functions */ +/* Operator functions. */ bool sequencer_edit_poll(bContext *C) { return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL); @@ -1282,7 +1274,7 @@ bool sequencer_view_strips_poll(bContext *C) return 0; } -/* snap operator*/ +/* Snap operator. */ static int sequencer_snap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1293,14 +1285,11 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) snap_frame = RNA_int_get(op->ptr, "frame"); - /* also check metas */ + /* Check metas. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) && BKE_sequence_tx_test(seq)) { if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) { - /* simple but no anim update */ - /* seq->start = snap_frame-seq->startofs+seq->startstill; */ - BKE_sequence_translate( scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start); } @@ -1318,8 +1307,8 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } } - /* test for effects and overlap - * don't use SEQP_BEGIN since that would be recursive */ + /* Test for effects and overlap. + * Don't use SEQP_BEGIN since that would be recursive. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) { seq->flag &= ~SEQ_OVERLAP; @@ -1340,7 +1329,6 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } } - /* as last: */ BKE_sequencer_sort(scene); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); @@ -1363,17 +1351,17 @@ static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNU void SEQUENCER_OT_snap(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Snap Strips to Playhead"; ot->idname = "SEQUENCER_OT_snap"; ot->description = "Frame where selected strips will be snapped"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_snap_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, @@ -1395,7 +1383,7 @@ typedef struct SlipData { bool *trim; int num_seq; bool slow; - int slow_offset; /* offset at the point where offset was turned on */ + int slow_offset; /* Offset at the point where offset was turned on. */ NumInput num_input; } SlipData; @@ -1442,7 +1430,7 @@ static int slip_add_sequences_recursive( num_items++; if (seq->type == SEQ_TYPE_META) { - /* trim the sub-sequences */ + /* Trim the sub-sequences. */ num_items += slip_add_sequences_recursive( &seq->seqbase, seq_array, trim, num_items + offset, false); } @@ -1465,7 +1453,7 @@ static int slip_count_sequences_recursive(ListBase *seqbasep, bool first_level) trimmed_sequences++; if (seq->type == SEQ_TYPE_META) { - /* trim the sub-sequences */ + /* Trim the sub-sequences. */ trimmed_sequences += slip_count_sequences_recursive(&seq->seqbase, false); } } @@ -1483,7 +1471,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve int num_seq, i; View2D *v2d = UI_view2d_fromcontext(C); - /* first recursively count the trimmed elements */ + /* Recursively count the trimmed elements. */ num_seq = slip_count_sequences_recursive(ed->seqbasep, true); if (num_seq == 0) { @@ -1517,7 +1505,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve WM_event_add_modal_handler(C, op); - /* notify so we draw extensions immediately */ + /* Notify so we draw extensions immediately. */ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_RUNNING_MODAL; @@ -1529,20 +1517,19 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) Editing *ed = BKE_sequencer_editing_get(scene, false); bool changed = false; - /* We iterate in reverse so meta-strips are iterated after their children. */ + /* Iterate in reverse so meta-strips are iterated after their children. */ for (int i = data->num_seq - 1; i >= 0; i--) { Sequence *seq = data->seq_array[i]; int endframe; - /* We have the offset, apply the values to the sequence strips. */ - /* first, do the offset */ + /* Offset seq start. */ seq->start = data->ts[i].start + offset; if (data->trim[i]) { /* Find the end-frame. */ endframe = seq->start + seq->len; - /* Now compute the sequence offsets. */ + /* Compute the sequence offsets. */ if (endframe > seq->enddisp) { seq->endstill = 0; seq->endofs = endframe - seq->enddisp; @@ -1566,7 +1553,7 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) } } else { - /* If no real trim, don't change the data, rather transform the strips themselves. */ + /* No transform data (likely effect strip). Only move start and end. */ seq->startdisp = data->ts[i].startdisp + offset; seq->enddisp = data->ts[i].enddisp + offset; changed = true; @@ -1575,7 +1562,7 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) /* Effects are only added if we they are in a meta-strip. * In this case, dependent strips will just be transformed and * we can skip calculating for effects. - * This way we can avoid an extra loop just for effects*/ + * This way we can avoid an extra loop just for effects. */ if (!(seq->type & SEQ_TYPE_EFFECT)) { BKE_sequence_calc(scene, seq); } @@ -1595,7 +1582,7 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) int offset = RNA_int_get(op->ptr, "offset"); bool success = false; - /* first recursively count the trimmed elements */ + /* Recursively count the trimmed elements. */ num_seq = slip_count_sequences_recursive(ed->seqbasep, true); if (num_seq == 0) { @@ -1658,7 +1645,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even const bool has_numInput = hasNumInput(&data->num_input); bool handled = true; - /* Modal numinput active, try to handle numeric inputs first... */ + /* Modal numinput active, try to handle numeric inputs. */ if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) { float offset; applyNumInput(&data->num_input, &offset); @@ -1691,7 +1678,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even mouse_x = event->mval[0]; } - /* choose the side based on which side of the playhead the mouse is on */ + /* Choose the side based on which side of the playhead the mouse is. */ UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]); offset = mouseloc[0] - data->init_mouseloc[0]; @@ -1772,7 +1759,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even break; } - /* Modal numinput inactive, try to handle numeric inputs last... */ + /* Modal numinput inactive, try to handle numeric inputs. */ if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) { float offset; applyNumInput(&data->num_input, &offset); @@ -1791,18 +1778,18 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even void SEQUENCER_OT_slip(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Trim Strips"; ot->idname = "SEQUENCER_OT_slip"; ot->description = "Trim the contents of the active strip"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_slip_invoke; ot->modal = sequencer_slip_modal; ot->exec = sequencer_slip_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, @@ -1816,7 +1803,7 @@ void SEQUENCER_OT_slip(struct wmOperatorType *ot) INT32_MAX); } -/* mute operator */ +/* Mute operator. */ static int sequencer_mute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1828,7 +1815,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SEQ_LOCK) == 0) { - if (selected) { /* mute unselected */ + if (selected) { if (seq->flag & SELECT) { seq->flag |= SEQ_MUTE; BKE_sequence_invalidate_dependent(scene, seq); @@ -1851,23 +1838,23 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_mute(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Mute Strips"; ot->idname = "SEQUENCER_OT_mute"; ot->description = "Mute (un)selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_mute_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean( ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips"); } -/* unmute operator */ +/* Unmute operator. */ static int sequencer_unmute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1879,7 +1866,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SEQ_LOCK) == 0) { - if (selected) { /* unmute unselected */ + if (selected) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_MUTE; BKE_sequence_invalidate_dependent(scene, seq); @@ -1902,23 +1889,23 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_unmute(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Unmute Strips"; ot->idname = "SEQUENCER_OT_unmute"; ot->description = "Unmute (un)selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_unmute_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean( ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips"); } -/* lock operator */ +/* Lock operator. */ static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -1938,20 +1925,20 @@ static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_lock(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Lock Strips"; ot->idname = "SEQUENCER_OT_lock"; ot->description = "Lock strips so they can't be transformed"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_lock_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* unlock operator */ +/* Unlock operator. */ static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -1971,20 +1958,20 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_unlock(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Unlock Strips"; ot->idname = "SEQUENCER_OT_unlock"; ot->description = "Unlock strips so they can be transformed"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_unlock_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* reload operator */ +/* Reload operator. */ static int sequencer_reload_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); @@ -2015,17 +2002,17 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Reload Strips"; ot->idname = "SEQUENCER_OT_reload"; ot->description = "Reload strips in the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_reload_exec; ot->poll = sequencer_edit_poll; - /* flags */ - ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */ + /* Flags. */ + ot->flag = OPTYPE_REGISTER; /* No undo, the data changed is stored outside 'main'. */ prop = RNA_def_boolean(ot->srna, "adjust_length", @@ -2035,7 +2022,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* reload operator */ +/* Reload operator. */ static bool sequencer_refresh_all_poll(bContext *C) { if (G.is_rendering) { @@ -2058,12 +2045,12 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Refresh Sequencer"; ot->idname = "SEQUENCER_OT_refresh_all"; ot->description = "Refresh the sequencer editor"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_refresh_all_exec; ot->poll = sequencer_refresh_all_poll; } @@ -2079,7 +2066,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } - /* see reassigning would create a cycle */ + /* Check if reassigning would create recursivity. */ if (seq_is_predecessor(seq1, last_seq) || seq_is_predecessor(seq2, last_seq) || seq_is_predecessor(seq3, last_seq)) { BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed"); @@ -2114,16 +2101,16 @@ static bool sequencer_effect_poll(bContext *C) void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Reassign Inputs"; ot->idname = "SEQUENCER_OT_reassign_inputs"; ot->description = "Reassign the inputs for the effect strip"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_reassign_inputs_exec; ot->poll = sequencer_effect_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2149,20 +2136,20 @@ static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op) } void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Swap Inputs"; ot->idname = "SEQUENCER_OT_swap_inputs"; ot->description = "Swap the first two inputs for the effect strip"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_swap_inputs_exec; ot->poll = sequencer_effect_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* split operator */ +/* Split operator. */ static const EnumPropertyItem prop_split_types[] = { {SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""}, {SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""}, @@ -2203,7 +2190,7 @@ static int sequencer_split_exec(bContext *C, wmOperator *op) use_cursor_position, split_seq_soft); } - if (changed) { /* got new strips ? */ + if (changed) { /* Got new strips? */ Sequence *seq; if (ignore_selection) { if (use_cursor_position) { @@ -2246,7 +2233,7 @@ static int sequencer_split_exec(bContext *C, wmOperator *op) } } SEQ_END; - /* as last: */ + BKE_sequencer_sort(scene); } if (changed) { @@ -2285,24 +2272,24 @@ static int sequencer_split_invoke(bContext *C, wmOperator *op, const wmEvent *ev } RNA_int_set(op->ptr, "channel", mouseloc[1]); RNA_enum_set(op->ptr, "side", split_side); - /*RNA_enum_set(op->ptr, "type", split_hard); */ /*This type is set from the key - shortsplit */ + /*RNA_enum_set(op->ptr, "type", split_hard); */ + return sequencer_split_exec(C, op); } void SEQUENCER_OT_split(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Split Strips"; ot->idname = "SEQUENCER_OT_split"; ot->description = "Split the selected strips in two"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_split_invoke; ot->exec = sequencer_split_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; PropertyRNA *prop; @@ -2358,7 +2345,7 @@ void SEQUENCER_OT_split(struct wmOperatorType *ot) #undef SEQ_SIDE_MOUSE -/* duplicate operator */ +/* Duplicate operator. */ static int apply_unique_name_fn(Sequence *seq, void *arg_pt) { Scene *scene = (Scene *)arg_pt; @@ -2385,7 +2372,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) if (nseqbase.first) { Sequence *seq = nseqbase.first; - /* rely on the nseqbase list being added at the end */ + /* Rely on the nseqbase list being added at the end. */ BLI_movelisttolist(ed->seqbasep, &nseqbase); for (; seq; seq = seq->next) { @@ -2401,20 +2388,20 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_duplicate(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Duplicate Strips"; ot->idname = "SEQUENCER_OT_duplicate"; ot->description = "Duplicate the selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_add_duplicate_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* delete operator */ +/* Delete operator. */ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); @@ -2425,7 +2412,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) bool nothing_selected = true; seq = BKE_sequencer_active_get(scene); - if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ + if (seq && seq->flag & SELECT) { /* Avoid a loop since this is likely to be selected. */ nothing_selected = false; } else { @@ -2441,7 +2428,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } - /* for effects and modifiers, try to find a replacement input */ + /* For effects and modifiers, try to find a replacement input. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (!(seq->flag & SELECT)) { if ((seq->type & SEQ_TYPE_EFFECT)) { @@ -2453,17 +2440,17 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) } } - /* delete all selected strips */ + /* Delete all selected strips. */ recurs_del_seq_flag(scene, ed->seqbasep, SELECT, 0); - /* updates lengths etc */ + /* Update lengths, etc. */ seq = ed->seqbasep->first; while (seq) { BKE_sequence_calc(scene, seq); seq = seq->next; } - /* free parent metas */ + /* Free parent metas. */ ms = ed->metastack.last; while (ms) { BKE_sequence_calc(scene, ms->parseq); @@ -2482,8 +2469,8 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e ARegion *region = CTX_wm_region(C); if (region->regiontype == RGN_TYPE_WINDOW) { - /* bounding box of 30 pixels is used for markers shortcuts, - * prevent conflict with markers shortcuts here + /* Bounding box of 30 pixels is used for markers shortcuts, + * prevent conflict with markers shortcuts here. */ if (event->mval[1] <= 30) { return OPERATOR_PASS_THROUGH; @@ -2496,35 +2483,35 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e void SEQUENCER_OT_delete(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Erase Strips"; ot->idname = "SEQUENCER_OT_delete"; ot->description = "Erase selected strips from the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_delete_invoke; ot->exec = sequencer_delete_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* offset clear operator */ +/* Offset clear operator. */ static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; - /* for effects, try to find a replacement input */ + /* For effects, try to find a replacement input. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) { seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0; } } - /* updates lengths etc */ + /* Update lengths, etc. */ seq = ed->seqbasep->first; while (seq) { BKE_sequence_calc(scene, seq); @@ -2547,20 +2534,20 @@ static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_offset_clear(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Clear Strip Offset"; ot->idname = "SEQUENCER_OT_offset_clear"; ot->description = "Clear strip offsets from the start and end frames"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_offset_clear_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* separate_images operator */ +/* Separate_images operator. */ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -2572,13 +2559,13 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) int start_ofs, cfra, frame_end; int step = RNA_int_get(op->ptr, "length"); - seq = ed->seqbasep->first; /* poll checks this is valid */ + seq = ed->seqbasep->first; /* Poll checks this is valid. */ while (seq) { if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) { Sequence *seq_next; - /* remove seq so overlap tests don't conflict, + /* Remove seq so overlap tests don't conflict, * see seq_free_sequence below for the real freeing. */ BLI_remlink(ed->seqbasep, seq); /* if (seq->ipo) id_us_min(&seq->ipo->id); */ @@ -2588,7 +2575,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) frame_end = BKE_sequence_tx_get_final_right(seq, false); while (cfra < frame_end) { - /* new seq */ + /* New seq. */ se = BKE_sequencer_give_stripelem(seq, cfra); seq_new = BKE_sequence_dupli_recursive( @@ -2599,11 +2586,11 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) seq_new->len = 1; seq_new->endstill = step - 1; - /* new strip */ + /* New strip. */ strip_new = seq_new->strip; strip_new->us = 1; - /* new stripdata (only one element now!) */ + /* New stripdata, only one element now. */ /* Note this assume all elements (images) have the same dimension, * since we only copy the name here. */ se_new = MEM_reallocN(strip_new->stripdata, sizeof(*se_new)); @@ -2634,7 +2621,6 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) } } - /* as last: */ BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2644,25 +2630,25 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_images_separate(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Separate Images"; ot->idname = "SEQUENCER_OT_images_separate"; ot->description = "On image sequence strips, it returns a strip for each image"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_separate_images_exec; ot->invoke = WM_operator_props_popup_confirm; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000); } -/* META Operators */ +/* META Operators. */ -/* separate_meta_toggle operator */ +/* Separate_meta_toggle operator. */ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -2671,7 +2657,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) MetaStack *ms; if (last_seq && last_seq->type == SEQ_TYPE_META && last_seq->flag & SELECT) { - /* Enter Metastrip */ + /* Enter metastrip. */ ms = MEM_mallocN(sizeof(MetaStack), "metastack"); BLI_addtail(&ed->metastack, ms); ms->parseq = last_seq; @@ -2683,7 +2669,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) BKE_sequencer_active_set(scene, NULL); } else { - /* Exit Metastrip (if possible) */ + /* Exit metastrip if possible. */ Sequence *seq; @@ -2696,18 +2682,18 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ed->seqbasep = ms->oldbasep; - /* for old files, update from meta */ + /* For old files, update from meta. */ if (ms->disp_range[0] == ms->disp_range[1]) { copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp); } - /* recalc all: the meta can have effects connected to it */ + /* Recalc all: the meta can have effects connected to it. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { BKE_sequence_calc(scene, seq); } /* 2.73+, keeping endpoints is important! - * moving them around means you can't usefully use metas in a complex edit. */ + * Moving them around means you can't usefully use metas in a complex edit. */ #if 1 BKE_sequence_tx_set_final_left(ms->parseq, ms->disp_range[0]); BKE_sequence_tx_set_final_right(ms->parseq, ms->disp_range[1]); @@ -2735,20 +2721,20 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_meta_toggle(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Toggle Meta Strip"; ot->idname = "SEQUENCER_OT_meta_toggle"; ot->description = "Toggle a metastrip (to edit enclosed strips)"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_meta_toggle_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* separate_meta_make operator */ +/* Separate_meta_make operator. */ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -2762,9 +2748,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* remove all selected from main list, and put in meta */ + /* Remove all selected from main list, and put in meta. */ - seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1, SEQ_TYPE_META); /* channel number set later */ + seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1, SEQ_TYPE_META); /* Channel number set later. */ strcpy(seqm->name + 2, "MetaStrip"); seqm->flag = SELECT; @@ -2799,16 +2785,16 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_meta_make(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Make Meta Strip"; ot->idname = "SEQUENCER_OT_meta_make"; ot->description = "Group selected strips into a metastrip"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_meta_make_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2831,7 +2817,7 @@ static int seq_depends_on_meta(Sequence *seq, Sequence *seqm) } } -/* separate_meta_make operator */ +/* Separate_meta_make operator. */ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -2854,7 +2840,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(ed->seqbasep, last_seq); BKE_sequence_free(scene, last_seq); - /* empty meta strip, delete all effects depending on it */ + /* Empty meta strip, delete all effects depending on it. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) { seq->flag |= SEQ_FLAG_DELETE; @@ -2863,8 +2849,8 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0); - /* test for effects and overlap - * don't use SEQP_BEGIN since that would be recursive */ + /* Test for effects and overlap + * don't use SEQP_BEGIN since that would be recursive. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_OVERLAP; @@ -2884,20 +2870,20 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_meta_separate(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "UnMeta Strip"; ot->idname = "SEQUENCER_OT_meta_separate"; ot->description = "Put the contents of a metastrip back in the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_meta_separate_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* view_all operator */ +/* View_all operator. */ static int sequencer_view_all_exec(bContext *C, wmOperator *op) { ARegion *region = CTX_wm_region(C); @@ -2912,16 +2898,16 @@ static int sequencer_view_all_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_view_all(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "View All"; ot->idname = "SEQUENCER_OT_view_all"; ot->description = "View all the strips in the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_all_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; } @@ -2935,20 +2921,20 @@ static int sequencer_view_frame_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_view_frame(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Go to Current Frame"; ot->idname = "SEQUENCER_OT_view_frame"; ot->description = "Move the view to the playhead"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_frame_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = 0; } -/* view_all operator */ +/* View_all operator. */ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) { bScreen *screen = CTX_wm_screen(C); @@ -2965,7 +2951,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) UI_view2d_sync(screen, area, v2d, V2D_LOCK_COPY); #if 0 - /* Like zooming on an image view */ + /* Like zooming on an image view. */ float zoomX, zoomY; int width, height, imgwidth, imgheight; @@ -2977,11 +2963,11 @@ 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, doesn't 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))) { - /* Find the zoom value that will fit the image in the image space */ + /* Find the zoom value that will fit the image in the image space. */ zoomX = ((float)width) / ((float)imgwidth); zoomY = ((float)height) / ((float)imgheight); sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY; @@ -2999,16 +2985,16 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_view_all_preview(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "View All"; ot->idname = "SEQUENCER_OT_view_all_preview"; ot->description = "Zoom preview to fit in the area"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_all_preview_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; } @@ -3034,16 +3020,16 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Sequencer View Zoom Ratio"; ot->idname = "SEQUENCER_OT_view_zoom_ratio"; ot->description = "Change zoom ratio of sequencer preview"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_zoom_ratio_exec; ot->poll = ED_operator_sequencer_active; - /* properties */ + /* Properties. */ RNA_def_float(ot->srna, "ratio", 1.0f, @@ -3068,7 +3054,7 @@ static const EnumPropertyItem view_type_items[] = { }; #endif -/* view_all operator */ +/* View_all operator. */ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); @@ -3085,20 +3071,20 @@ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_view_toggle(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "View Toggle"; ot->idname = "SEQUENCER_OT_view_toggle"; ot->description = "Toggle between sequencer views (sequence, preview, both)"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_toggle_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; } -/* view_selected operator */ +/* View_selected operator. */ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -3148,7 +3134,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) cur_new.ymin = ymin; cur_new.ymax = ymax; - /* only zoom out vertically */ + /* Only zoom out vertically. */ if (orig_height > BLI_rctf_size_y(&cur_new)) { ymid = BLI_rctf_cent_y(&cur_new); @@ -3167,16 +3153,16 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_view_selected(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Frame Selected"; ot->idname = "SEQUENCER_OT_view_selected"; ot->description = "Zoom the sequencer on the selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_view_selected_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; } @@ -3199,7 +3185,7 @@ static bool strip_jump_internal(Scene *scene, static bool sequencer_strip_jump_poll(bContext *C) { - /* prevent changes during render */ + /* Prevent changes during render. */ if (G.is_rendering) { return 0; } @@ -3207,14 +3193,14 @@ static bool sequencer_strip_jump_poll(bContext *C) return sequencer_edit_poll(C); } -/* jump frame to edit point operator */ +/* Jump frame to edit point operator. */ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); const bool next = RNA_boolean_get(op->ptr, "next"); const bool center = RNA_boolean_get(op->ptr, "center"); - /* currently do_skip_mute is always true */ + /* Currently do_skip_mute is always true. */ if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, true, center)) { return OPERATOR_CANCELLED; } @@ -3226,19 +3212,19 @@ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_strip_jump(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Jump to Strip"; ot->idname = "SEQUENCER_OT_strip_jump"; ot->description = "Move frame to previous edit point"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_strip_jump_exec; ot->poll = sequencer_strip_jump_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_UNDO; - /* properties */ + /* Properties. */ RNA_def_boolean(ot->srna, "next", true, "Next Strip", ""); RNA_def_boolean(ot->srna, "center", true, "Use strip center", ""); } @@ -3296,7 +3282,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) if (seq) { - /* disallow effect strips */ + /* Disallow effect strips. */ if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) { return OPERATOR_CANCELLED; @@ -3315,7 +3301,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) break; } - // XXX - should be a generic function + /* XXX - Should be a generic function. */ for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) { if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { @@ -3323,11 +3309,11 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) } } - /* do this in a new loop since both effects need to be calculated first */ + /* Do this in a new loop since both effects need to be calculated first. */ for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) { if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { - /* this may now overlap */ + /* This may now overlap. */ if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) { BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene); } @@ -3346,19 +3332,19 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_swap(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Swap Strip"; ot->idname = "SEQUENCER_OT_swap"; ot->description = "Swap active strip with strip to the right or left"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_swap_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties */ + /* Properties. */ RNA_def_enum( ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap"); } @@ -3392,7 +3378,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) } if (se) { - // prevent setting the render size if sequence values aren't initialized + /* Prevent setting the render size if sequence values aren't initialized. */ if ((se->orig_width > 0) && (se->orig_height > 0)) { scene->r.xsch = se->orig_width; scene->r.ysch = se->orig_height; @@ -3406,19 +3392,17 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_rendersize(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Set Render Size"; ot->idname = "SEQUENCER_OT_rendersize"; ot->description = "Set render size and aspect from active sequence"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_rendersize_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } static void seq_copy_del_sound(Scene *scene, Sequence *seq) @@ -3453,9 +3437,8 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) BKE_sequence_base_dupli_recursive( scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, LIB_ID_CREATE_NO_USER_REFCOUNT); - /* To make sure the copied strips have unique names between each other add - * them temporarily to the end of the original seqbase. (bug 25932) - */ + /* Make sure that copied strips have unique names. + * Add them temporarily to the end of the original seqbase (bug 25932). */ if (nseqbase.first) { Sequence *seq, *first_seq = nseqbase.first; BLI_movelisttolist(ed->seqbasep, &nseqbase); @@ -3476,7 +3459,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) seqbase_clipboard_frame = scene->r.cfra; - /* Need to remove anything that references the current scene */ + /* Remove anything that references the current scene. */ LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) { seq_copy_del_sound(scene, seq); } @@ -3490,26 +3473,24 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_copy(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Copy"; ot->idname = "SEQUENCER_OT_copy"; ot->description = "Copy selected strips to clipboard"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_copy_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; - - /* properties */ } static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Editing *ed = BKE_sequencer_editing_get(scene, true); /* create if needed */ + Editing *ed = BKE_sequencer_editing_get(scene, true); /* Create if needed. */ ListBase nseqbase = {NULL, NULL}; int ofs; Sequence *iseq, *iseq_first; @@ -3525,7 +3506,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0); BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard); - /* transform pasted strips before adding */ + /* Transform pasted strips before adding. */ if (ofs) { for (iseq = nseqbase.first; iseq; iseq = iseq->next) { BKE_sequence_translate(scene, iseq, ofs); @@ -3536,12 +3517,12 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &nseqbase); - /* make sure the pasted strips have unique names between them */ + /* Make sure, that pasted strips have unique names. */ for (iseq = iseq_first; iseq; iseq = iseq->next) { BKE_sequencer_recursive_apply(iseq, apply_unique_name_fn, scene); } - /* ensure pasted strips don't overlap */ + /* Ensure, that pasted strips don't overlap. */ for (iseq = iseq_first; iseq; iseq = iseq->next) { if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) { BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene); @@ -3556,19 +3537,17 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_paste(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Paste"; ot->idname = "SEQUENCER_OT_paste"; ot->description = "Paste strips from clipboard"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_paste_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } static int sequencer_swap_data_exec(bContext *C, wmOperator *op) @@ -3619,22 +3598,20 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_swap_data(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Sequencer Swap Data"; ot->idname = "SEQUENCER_OT_swap_data"; ot->description = "Swap 2 sequencer strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_swap_data_exec; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } -/* box select operator */ +/* Box select operator. */ static int view_ghost_border_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -3642,7 +3619,7 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) rctf rect; - /* convert coordinates of rect to 'tot' rect coordinates */ + /* Convert coordinates of rect to 'tot' rect coordinates. */ WM_operator_properties_border_to_rctf(op, &rect); UI_view2d_region_to_view_rctf(v2d, &rect, &rect); @@ -3669,30 +3646,28 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -/* ****** Box Select ****** */ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Border Offset View"; ot->idname = "SEQUENCER_OT_view_ghost_border"; ot->description = "Set the boundaries of the border used for offset-view"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = WM_gesture_box_invoke; ot->exec = view_ghost_border_exec; ot->modal = WM_gesture_box_modal; ot->poll = sequencer_view_preview_poll; ot->cancel = WM_gesture_box_cancel; - /* flags */ + /* Flags. */ ot->flag = 0; - /* rna */ + /* Properties. */ WM_operator_properties_gesture_box(ot); } -/* rebuild_proxy operator */ - +/* Rebuild_proxy operator. */ static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -3743,16 +3718,16 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Rebuild Proxy and Timecode Indices"; ot->idname = "SEQUENCER_OT_rebuild_proxy"; ot->description = "Rebuild all selected proxies and timecode indices using the job system"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_rebuild_proxy_invoke; ot->exec = sequencer_rebuild_proxy_exec; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; } @@ -3838,16 +3813,16 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Set Selected Strip Proxies"; ot->idname = "SEQUENCER_OT_enable_proxies"; ot->description = "Enable selected proxies on all selected Movie, Image and Meta strips"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_enable_proxies_invoke; ot->exec = sequencer_enable_proxies_exec; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER; RNA_def_boolean(ot->srna, "proxy_25", false, "25%", ""); @@ -3857,8 +3832,7 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", ""); } -/* change ops */ - +/* Change effect inputs operator. */ static const EnumPropertyItem prop_change_effect_input_types[] = { {0, "A_B", 0, "A -> B", ""}, {1, "B_C", 0, "B -> C", ""}, @@ -3899,9 +3873,8 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1); - /* important else we don't get the imbuf cache flushed */ + /* Invalidate cache. */ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); - WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -3909,21 +3882,22 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Change Effect Input"; ot->idname = "SEQUENCER_OT_change_effect_input"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_change_effect_input_exec; ot->poll = sequencer_effect_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum( ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap"); } +/* Change effect type operator. */ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -3931,14 +3905,14 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) Sequence *seq = BKE_sequencer_active_get(scene); const int new_type = RNA_enum_get(op->ptr, "type"); - /* free previous effect and init new effect */ + /* Free previous effect and init new effect. */ struct SeqEffectHandle sh; if ((seq->type & SEQ_TYPE_EFFECT) == 0) { return OPERATOR_CANCELLED; } - /* can someone explain the logic behind only allowing to increase this, + /* Can someone explain the logic behind only allowing to increase this, * copied from 2.4x - campbell */ if (BKE_sequence_effect_get_num_inputs(seq->type) < BKE_sequence_effect_get_num_inputs(new_type)) { @@ -3955,10 +3929,8 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) sh.init(seq); } - /* update */ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1); - - /* important else we don't get the imbuf cache flushed */ + /* Invalidate cache. */ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -3968,15 +3940,15 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Change Effect Type"; ot->idname = "SEQUENCER_OT_change_effect_type"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_change_effect_type_exec; ot->poll = sequencer_effect_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, @@ -3987,6 +3959,7 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) "Sequencer effect type"); } +/* Change path operator. */ static int sequencer_change_path_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); @@ -4002,7 +3975,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) int len; StripElem *se; - /* need to find min/max frame for placeholders */ + /* Need to find min/max frame for placeholders. */ if (use_placeholders) { len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe, &numdigits); } @@ -4040,16 +4013,16 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) RNA_END; } - /* reset these else we wont see all the images */ + /* Reset these else we wont see all the images. */ seq->anim_startofs = seq->anim_endofs = 0; - /* correct start/end frames so we don't move - * important not to set seq->len = len; allow the function to handle it */ + /* Correct start/end frames so we don't move. + * Important not to set seq->len = len; allow the function to handle it. */ BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); - /* important else we don't get the imbuf cache flushed */ + /* Invalidate cache. */ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); } else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { @@ -4063,7 +4036,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) BKE_sound_load(bmain, sound); } else { - /* lame, set rna filepath */ + /* Lame, set rna filepath. */ PointerRNA seq_ptr; PropertyRNA *prop; char filepath[FILE_MAX]; @@ -4092,7 +4065,7 @@ static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEve RNA_string_set(op->ptr, "directory", seq->strip->dir); RNA_string_set(op->ptr, "filepath", filepath); - /* set default display depending on seq type */ + /* Set default display depending on seq type. */ if (seq->type == SEQ_TYPE_IMAGE) { RNA_boolean_set(op->ptr, "filter_movie", false); } @@ -4107,16 +4080,16 @@ static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEve void SEQUENCER_OT_change_path(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Change Data/Files"; ot->idname = "SEQUENCER_OT_change_path"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_change_path_exec; ot->invoke = sequencer_change_path_invoke; ot->poll = sequencer_strip_has_path_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -4134,6 +4107,7 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot) "Use placeholders for missing frames of the strip"); } +/* Export subtitles operator. */ static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -4176,7 +4150,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filepath); BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt"); - /* Avoid File write exceptions */ + /* Avoid File write exceptions. */ if (!BLI_exists(filepath)) { BLI_make_existing_file(filepath); if (!BLI_file_touch(filepath)) { @@ -4203,7 +4177,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) BLI_listbase_sort(&text_seq, BKE_sequencer_cmp_time_startdisp); - /* time to open and write! */ + /* Open and write file. */ file = BLI_fopen(filepath, "w"); for (seq = text_seq.first; seq; seq = seq_next) { @@ -4246,17 +4220,17 @@ static bool sequencer_strip_is_text_poll(bContext *C) void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Export Subtitles"; ot->idname = "SEQUENCER_OT_export_subtitles"; ot->description = "Export .srt file containing text strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_export_subtitles_exec; ot->invoke = sequencer_export_subtitles_invoke; ot->poll = sequencer_strip_is_text_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -4268,6 +4242,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot) FILE_SORT_ALPHA); } +/* Set range to strips operator. */ static int sequencer_set_range_to_strips_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -4316,16 +4291,16 @@ void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Set Range to Strips"; ot->idname = "SEQUENCER_OT_set_range_to_strips"; ot->description = "Set the frame range to the selected strips start and end"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_set_range_to_strips_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_boolean(ot->srna, "preview", false, "Preview", "Set the preview range instead"); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index f70bc06caf7..708682cd04f 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -27,7 +27,7 @@ #include "DNA_sequence_types.h" #include "RNA_access.h" -/* internal exports only */ +/* Internal exports only. */ struct ARegion; struct ARegionType; @@ -57,7 +57,7 @@ void sequencer_special_update_set(Sequence *seq); float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx); /* UNUSED */ -// void seq_reset_imageofs(struct SpaceSeq *sseq); +/* void seq_reset_imageofs(struct SpaceSeq *sseq); */ struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Depsgraph *depsgraph, @@ -88,19 +88,19 @@ int seq_effect_find_selected(struct Scene *scene, struct Sequence **r_selseq3, const char **r_error_str); -/* operator helpers */ +/* Operator helpers. */ bool sequencer_edit_poll(struct bContext *C); /* UNUSED */ -// bool sequencer_strip_poll(struct bContext *C); +/* bool sequencer_strip_poll(struct bContext *C); */ bool sequencer_strip_has_path_poll(struct bContext *C); bool sequencer_view_preview_poll(struct bContext *C); bool sequencer_view_strips_poll(struct bContext *C); -/* externs */ +/* Externs. */ extern EnumPropertyItem sequencer_prop_effect_types[]; extern EnumPropertyItem prop_side_types[]; -/* operators */ +/* Operators. */ struct wmKeyConfig; struct wmOperatorType; @@ -152,7 +152,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot); void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot); -/* preview specific operators */ +/* Preview specific operators. */ void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot); /* sequencer_select.c */ @@ -193,8 +193,8 @@ enum { SEQ_SELECT_LR_RIGHT, }; -/* defines used internally */ -#define SCE_MARKERS 0 // XXX - dummy +/* Defines used internally. */ +#define SCE_MARKERS 0 /* XXX - dummy */ /* sequencer_ops.c */ void sequencer_operatortypes(void); @@ -222,7 +222,7 @@ void SEQUENCER_OT_sample(struct wmOperatorType *ot); /* sequencer_preview.c */ void sequencer_preview_add_sound(const struct bContext *C, struct Sequence *seq); -/* sequencer_add */ +/* sequencer_add.c */ int sequencer_image_seq_get_minmax_frame(struct wmOperator *op, int sfra, int *r_minframe, diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index b90dc5e10ff..e0f7179c3f9 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -35,7 +35,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" /*********************** Add modifier operator *************************/ diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 4296701366a..ac00838a079 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -32,7 +32,7 @@ #include "ED_markers.h" #include "ED_select_utils.h" #include "ED_sequencer.h" -#include "ED_transform.h" /* transform keymap */ +#include "ED_transform.h" /* Transform keymap. */ #include "BKE_sequencer.h" diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index d50047c4839..7d416884721 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -52,9 +52,9 @@ typedef struct PreviewJobAudio { struct PreviewJobAudio *next, *prev; struct Main *bmain; bSound *sound; - int lr; /* sample left or right */ + int lr; /* Sample left or right. */ int startframe; - bool waveform; /* reload sound or waveform */ + bool waveform; /* Reload sound or waveform. */ } PreviewJobAudio; static void free_preview_job(void *data) @@ -66,7 +66,7 @@ static void free_preview_job(void *data) MEM_freeN(pj); } -/* only this runs inside thread */ +/* Only this runs inside thread. */ static void preview_startjob(void *data, short *stop, short *do_update, float *progress) { PreviewJob *pj = data; @@ -89,7 +89,7 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p while (previewjb) { sound = previewjb->sound; - /* make sure we cleanup the loading flag! */ + /* Make sure we cleanup the loading flag! */ BLI_spin_lock(sound->spinlock); sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); @@ -127,7 +127,6 @@ static void preview_endjob(void *data) void sequencer_preview_add_sound(const bContext *C, Sequence *seq) { - /* first, get the preview job, if it exists */ wmJob *wm_job; PreviewJob *pj; ScrArea *area = CTX_wm_area(C); @@ -139,6 +138,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PREVIEW); + /* Get the preview job if it exists. */ pj = WM_jobs_customdata_get(wm_job); if (!pj) { @@ -152,8 +152,6 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob); } - /* attempt to lock mutex of job here */ - audiojob->bmain = CTX_data_main(C); audiojob->sound = seq->sound; diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 02912b2755f..b08c35623af 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -42,7 +42,7 @@ static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3]) yuv[1] = 0.492f * (rgb[2] - yuv[0]); yuv[2] = 0.877f * (rgb[0] - yuv[0]); - /* Normalize */ + /* Normalize. */ yuv[1] *= 255.0f / (122 * 2.0f); yuv[1] += 0.5f; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 810e1009ecb..c5472ed88e5 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -40,7 +40,7 @@ #include "RNA_define.h" -/* for menu/popup icons etc etc*/ +/* For menu, popup, icons, etc. */ #include "ED_outliner.h" #include "ED_screen.h" @@ -49,7 +49,7 @@ #include "UI_view2d.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" static void *find_nearest_marker(int UNUSED(d1), int UNUSED(d2)) @@ -147,7 +147,7 @@ static void select_active_side_range(ListBase *seqbase, } } -/* used for mouse selection in SEQUENCER_OT_select */ +/* Used for mouse selection in SEQUENCER_OT_select */ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) { Sequence *seq; @@ -158,7 +158,7 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0; if (left_match && right_match) { - /* a direct match, copy the selection settinhs */ + /* Direct match, copy the selection settings. */ seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL); seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL); @@ -166,7 +166,7 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) } else if (seq_link->flag & SELECT && (left_match || right_match)) { - /* clear for reselection */ + /* Clear for reselection. */ seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL); if (left_match && seq_link->flag & SEQ_LEFTSEL) { @@ -248,12 +248,11 @@ static void select_neighbor_from_last(Scene *scene, int lr) } } if (changed) { - /* pass */ + /* Pass. */ } } #endif -/* (de)select operator */ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); @@ -302,22 +301,21 @@ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_select_all(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "(De)select All"; ot->idname = "SEQUENCER_OT_select_all"; ot->description = "Select or deselect all strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_de_select_all_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_UNDO; WM_operator_properties_select_all(ot); } -/* (de)select operator */ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -343,16 +341,16 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Inverse"; ot->idname = "SEQUENCER_OT_select_inverse"; ot->description = "Select unselected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_inverse_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_UNDO; } @@ -385,18 +383,18 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) wait_to_deselect_others = false; } - marker = find_nearest_marker(SCE_MARKERS, 1); // XXX - dummy function for now + marker = find_nearest_marker(SCE_MARKERS, 1); /* XXX - dummy function for now */ seq = find_nearest_seq(scene, v2d, &hand, mval); - // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip + /* XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip */ if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) { left_right = SEQ_SELECT_LR_NONE; } if (marker) { int oldflag; - /* select timeline marker */ + /* Select timeline marker. */ if (extend) { oldflag = marker->flag; if (oldflag & SELECT) { @@ -415,7 +413,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) ret_value = OPERATOR_FINISHED; } else if (left_right != SEQ_SELECT_LR_NONE) { - /* use different logic for this */ + /* Use different logic for this. */ float x; if (extend == false) { ED_sequencer_deselect_all(scene); @@ -494,7 +492,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) } } - /* On Alt selection, select the strip and bordering handles */ + /* On Alt selection, select the strip and bordering handles. */ if (linked_handle) { if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) { /* First click selects the strip and its adjacent handles (if valid). @@ -510,7 +508,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) select_surrounding_handles(scene, seq); } else { - /* always select the strip under the cursor */ + /* Always select the strip under the cursor. */ seq->flag |= SELECT; /* First click selects adjacent handles on that side. @@ -635,21 +633,21 @@ void SEQUENCER_OT_select(wmOperatorType *ot) }; PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Select"; ot->idname = "SEQUENCER_OT_select"; ot->description = "Select a strip (last selected becomes the \"active strip\")"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_exec; ot->invoke = WM_generic_select_invoke; ot->modal = WM_generic_select_modal; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_UNDO; - /* properties */ + /* Properties. */ WM_operator_properties_generic_select(ot); RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); prop = RNA_def_boolean(ot->srna, @@ -660,7 +658,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_boolean( ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip"); - /* for animation this is an enum but atm having an enum isn't useful for us */ + /* For animation this is enum but atm having an enum isn't useful for us. */ RNA_def_enum(ot->srna, "left_right", sequencer_select_left_right_types, @@ -671,7 +669,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot) ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time"); } -/* run recursively to select linked */ +/* Run recursively to select linked. */ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool linked) { Editing *ed = BKE_sequencer_editing_get(scene, false); @@ -693,7 +691,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li } if (!linked) { - /* if not linked we only want to touch each seq once, newseq */ + /* If not linked we only want to touch each seq once, newseq. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { seq->tmp = NULL; } @@ -702,7 +700,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SELECT) == sel) { if (linked || (seq->tmp == NULL)) { - /* only get unselected neighbors */ + /* Only get unselected neighbors. */ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel); if (neighbor) { if (sel) { @@ -738,7 +736,6 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li return changed; } -/* select more operator */ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -756,22 +753,19 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_select_more(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select More"; ot->idname = "SEQUENCER_OT_select_more"; ot->description = "Select more strips adjacent to the current selection"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_more_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } -/* select less operator */ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -789,22 +783,19 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_select_less(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Less"; ot->idname = "SEQUENCER_OT_select_less"; ot->description = "Shrink the current selection of adjacent selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_less_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } -/* select pick linked operator (uses the mouse) */ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); @@ -815,10 +806,10 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons Sequence *mouse_seq; int selected, hand; - /* this works like UV, not mesh */ + /* This works like UV, not mesh. */ mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval); if (!mouse_seq) { - return OPERATOR_FINISHED; /* user error as with mesh?? */ + return OPERATOR_FINISHED; /* User error as with mesh?? */ } if (extend == 0) { @@ -842,23 +833,22 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Pick Linked"; ot->idname = "SEQUENCER_OT_select_linked_pick"; ot->description = "Select a chain of linked strips nearest to the mouse pointer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_select_linked_pick_invoke; ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties */ + /* Properties. */ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); } -/* select linked operator */ static int sequencer_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -878,22 +868,19 @@ static int sequencer_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) void SEQUENCER_OT_select_linked(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Linked"; ot->idname = "SEQUENCER_OT_select_linked"; ot->description = "Select all strips adjacent to the current selection"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_linked_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ } -/* select handles operator */ static int sequencer_select_handles_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -928,19 +915,19 @@ static int sequencer_select_handles_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_select_handles(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Handles"; ot->idname = "SEQUENCER_OT_select_handles"; ot->description = "Select gizmo handles on the sides of the selected strip"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_handles_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties */ + /* Properties. */ RNA_def_enum(ot->srna, "side", prop_side_types, @@ -949,7 +936,6 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) "The side of the handle that is selected"); } -/* select side operator */ static int sequencer_select_side_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -993,19 +979,19 @@ static int sequencer_select_side_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_select_side(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Side"; ot->idname = "SEQUENCER_OT_select_side"; ot->description = "Select strips on the nominated side of the selected strips"; - /* api callbacks */ + /* Api callbacks. */ ot->exec = sequencer_select_side_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties */ + /* Properties. */ RNA_def_enum(ot->srna, "side", prop_side_types, @@ -1014,7 +1000,6 @@ void SEQUENCER_OT_select_side(wmOperatorType *ot) "The side to which the selection is applied"); } -/* box_select operator */ static int sequencer_box_select_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1089,7 +1074,6 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -/* ****** Box Select ****** */ static int sequencer_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); @@ -1112,12 +1096,12 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Box Select"; ot->idname = "SEQUENCER_OT_select_box"; ot->description = "Select strips using box selection"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_box_select_invoke; ot->exec = sequencer_box_select_exec; ot->modal = WM_gesture_box_modal; @@ -1125,10 +1109,10 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot) ot->poll = ED_operator_sequencer_active; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_UNDO; - /* properties */ + /* Properties. */ WM_operator_properties_gesture_box(ot); WM_operator_properties_select_operation_simple(ot); @@ -1140,8 +1124,6 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ****** Selected Grouped ****** */ - enum { SEQ_SELECT_GROUP_TYPE, SEQ_SELECT_GROUP_TYPE_BASIC, @@ -1366,7 +1348,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int BKE_sequence_iterator_next(&iter)) { seq = iter.seq; - /* Ignore all seqs already selected! */ + /* Ignore all seqs already selected. */ /* Ignore all seqs not sharing some time with active one. */ /* Ignore all seqs of incompatible types (audio vs video). */ if (!SEQ_CHANNEL_CHECK(seq, channel) || (seq->flag & SELECT) || (seq->startdisp >= enddisp) || @@ -1375,7 +1357,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int continue; } - /* If the seq is an effect one, we need extra checking! */ + /* If the seq is an effect one, we need extra checking. */ if (SEQ_IS_EFFECT(seq) && ((seq->seq1 && seq->seq1->tmp) || (seq->seq2 && seq->seq2->tmp) || (seq->seq3 && seq->seq3->tmp))) { if (startdisp > seq->startdisp) { @@ -1398,7 +1380,7 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int BKE_sequence_iterator_begin(ed, &iter, true); } - /* Video strips below active one, or any strip for audio (order do no matters here!). */ + /* Video strips below active one, or any strip for audio (order doesn't matter here). */ else if (seq->machine < machine || is_audio) { seq->flag |= SELECT; changed = true; @@ -1476,20 +1458,20 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_select_grouped(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Select Grouped"; ot->description = "Select all strips grouped by various properties"; ot->idname = "SEQUENCER_OT_select_grouped"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = WM_menu_invoke; ot->exec = sequencer_select_grouped_exec; ot->poll = sequencer_edit_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties */ + /* Properties. */ ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", ""); RNA_def_boolean(ot->srna, "extend", diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index b2114eab62e..a890b770c83 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -46,7 +46,7 @@ #include "UI_view2d.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" /******************** sample backdrop operator ********************/ @@ -158,7 +158,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->colf[3] = fp[3]; info->colfp = info->colf; - /* sequencer's image buffers are in non-linear space, need to make them linear */ + /* Sequencer's image buffers are in non-linear space, need to make them linear. */ copy_v4_v4(info->linearcol, info->colf); BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->linearcol); @@ -236,17 +236,17 @@ static bool sample_poll(bContext *C) void SEQUENCER_OT_sample(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Sample Color"; ot->idname = "SEQUENCER_OT_sample"; ot->description = "Use mouse to sample color in current frame"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sample_invoke; ot->modal = sample_modal; ot->cancel = sample_cancel; ot->poll = sample_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_BLOCKING; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index ed8117fda31..e40fe91ae99 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -43,7 +43,7 @@ #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" -#include "ED_view3d_offscreen.h" /* only for sequencer view3d drawing callback */ +#include "ED_view3d_offscreen.h" /* Only for sequencer view3d drawing callback. */ #include "WM_api.h" #include "WM_message.h" @@ -57,7 +57,8 @@ #include "IMB_imbuf.h" -#include "sequencer_intern.h" // own include +/* Own include. */ +#include "sequencer_intern.h" /**************************** common state *****************************/ @@ -97,7 +98,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) sseq->mainb = SEQ_DRAW_IMG_IMBUF; sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS; - /* tool header */ + /* Tool header. */ region = MEM_callocN(sizeof(ARegion), "tool header for sequencer"); BLI_addtail(&sseq->regionbase, region); @@ -105,14 +106,14 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; - /* header */ + /* Header. */ region = MEM_callocN(sizeof(ARegion), "header for sequencer"); BLI_addtail(&sseq->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - /* buttons/list view */ + /* Buttons/list view. */ region = MEM_callocN(sizeof(ARegion), "buttons for sequencer"); BLI_addtail(&sseq->regionbase, region); @@ -120,7 +121,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) region->alignment = RGN_ALIGN_RIGHT; region->flag = RGN_FLAG_HIDDEN; - /* toolbar */ + /* Toolbar. */ region = MEM_callocN(sizeof(ARegion), "tools for sequencer"); BLI_addtail(&sseq->regionbase, region); @@ -128,19 +129,19 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) region->alignment = RGN_ALIGN_LEFT; region->flag = RGN_FLAG_HIDDEN; - /* preview region */ - /* NOTE: if you change values here, also change them in sequencer_init_preview_region */ + /* Preview region. */ + /* NOTE: if you change values here, also change them in sequencer_init_preview_region. */ region = MEM_callocN(sizeof(ARegion), "preview region for sequencer"); BLI_addtail(&sseq->regionbase, region); region->regiontype = RGN_TYPE_PREVIEW; region->alignment = RGN_ALIGN_TOP; region->flag |= RGN_FLAG_HIDDEN; - /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ + /* For now, aspect ratio should be maintained, and zoom is clamped within sane default limits. */ region->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM | V2D_LIMITZOOM; region->v2d.minzoom = 0.001f; region->v2d.maxzoom = 1000.0f; - region->v2d.tot.xmin = -960.0f; /* 1920 width centered */ - region->v2d.tot.ymin = -540.0f; /* 1080 height centered */ + region->v2d.tot.xmin = -960.0f; /* 1920 width centered. */ + region->v2d.tot.ymin = -540.0f; /* 1080 height centered. */ region->v2d.tot.xmax = 960.0f; region->v2d.tot.ymax = 540.0f; region->v2d.min[0] = 0.0f; @@ -151,14 +152,13 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) region->v2d.align = V2D_ALIGN_FREE; region->v2d.keeptot = V2D_KEEPTOT_FREE; - /* main region */ + /* Main region. */ region = MEM_callocN(sizeof(ARegion), "main region for sequencer"); BLI_addtail(&sseq->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; - /* seq space goes from (0,8) to (0, efra) */ - + /* Seq space goes from (0,8) to (0, efra). */ region->v2d.tot.xmin = 0.0f; region->v2d.tot.ymin = 0.0f; region->v2d.tot.xmax = scene->r.efra; @@ -184,13 +184,13 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) return (SpaceLink *)sseq; } -/* not spacelink itself */ +/* Not spacelink itself. */ static void sequencer_free(SpaceLink *sl) { SpaceSeq *sseq = (SpaceSeq *)sl; SequencerScopes *scopes = &sseq->scopes; - // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); + /* XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); */ if (scopes->zebra_ibuf) { IMB_freeImBuf(scopes->zebra_ibuf); @@ -213,7 +213,7 @@ static void sequencer_free(SpaceLink *sl) } } -/* spacetype; init callback */ +/* Spacetype init callback. */ static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) { } @@ -300,7 +300,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) region_preview->alignment = RGN_ALIGN_TOP; view_changed = true; } - /* Final check that both preview and main height are reasonable! */ + /* Final check that both preview and main height are reasonable. */ if (region_preview->sizey < 10 || region_main->sizey < 10 || region_preview->sizey + region_main->sizey > height) { region_preview->sizey = (int)(height * 0.4f + 0.5f); @@ -321,8 +321,8 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) { SpaceSeq *sseqn = MEM_dupallocN(sl); - /* clear or remove stuff from old */ - // XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false); + /* Clear or remove stuff from old. */ + /* XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false); */ memset(&sseqn->scopes, 0, sizeof(sseqn->scopes)); @@ -334,7 +334,7 @@ static void sequencer_listener(wmWindow *UNUSED(win), wmNotifier *wmn, Scene *UNUSED(scene)) { - /* context changes */ + /* Context changes. */ switch (wmn->category) { case NC_SCENE: switch (wmn->data) { @@ -370,7 +370,7 @@ static bool image_drop_poll(bContext *C, int hand; if (drag->type == WM_DRAG_PATH) { - if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */ + if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* Rule might not work? */ if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { return 1; } @@ -390,7 +390,7 @@ static bool movie_drop_poll(bContext *C, int hand; if (drag->type == WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */ + if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */ if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { return 1; } @@ -409,7 +409,7 @@ static bool sound_drop_poll(bContext *C, int hand; if (drag->type == WM_DRAG_PATH) { - if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */ + if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might not work? */ if (find_nearest_seq(scene, ®ion->v2d, &hand, event->mval) == NULL) { return 1; } @@ -420,7 +420,7 @@ static bool sound_drop_poll(bContext *C, static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) { - /* copy drag path to properties */ + /* Copy drag path to properties. */ if (RNA_struct_find_property(drop->ptr, "filepath")) { RNA_string_set(drop->ptr, "filepath", drag->path); } @@ -439,7 +439,7 @@ static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) } } -/* this region dropbox definition */ +/* This region dropbox definition. */ static void sequencer_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); @@ -452,7 +452,7 @@ static void sequencer_dropboxes(void) /* ************* end drop *********** */ /* DO NOT make this static, this hides the symbol and breaks API generation script. */ -extern const char *sequencer_context_dir[]; /* quiet warning. */ +extern const char *sequencer_context_dir[]; /* Quiet warning. */ const char *sequencer_context_dir[] = {"edit_mask", NULL}; static int sequencer_context(const bContext *C, const char *member, bContextDataResult *result) @@ -489,7 +489,7 @@ static void sequencer_gizmos(void) } /* *********************** sequencer (main) region ************************ */ -/* add handlers, stuff you only do once or on area/region changes */ +/* Add handlers, stuff you only do once or on area/region changes. */ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; @@ -505,19 +505,19 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *region) keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); - /* own keymap */ + /* Own keymap. */ keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0); WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); - /* add drop boxes */ + /* Add drop boxes. */ lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); WM_event_add_dropbox_handler(®ion->handlers, lb); } +/* Strip editing timeline. */ static void sequencer_main_region_draw(const bContext *C, ARegion *region) { - /* NLE - strip editing timeline interface */ draw_timeline_seq(C, region); } @@ -527,14 +527,14 @@ static void sequencer_main_region_listener(wmWindow *UNUSED(win), wmNotifier *wmn, const Scene *UNUSED(scene)) { - /* context changes */ + /* Context changes. */ switch (wmn->category) { case NC_SCENE: switch (wmn->data) { case ND_FRAME: case ND_FRAME_RANGE: case ND_MARKERS: - case ND_RENDER_OPTIONS: /* for FPS and FPS Base */ + case ND_RENDER_OPTIONS: /* For FPS and FPS Base. */ case ND_SEQUENCER: case ND_RENDER_RESULT: ED_region_tag_redraw(region); @@ -625,7 +625,7 @@ static void sequencer_main_region_message_subscribe(const struct bContext *UNUSE } /* *********************** header region ************************ */ -/* add handlers, stuff you only do once or on area/region changes */ +/* Add handlers, stuff you only do once or on area/region changes. */ static void sequencer_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region) { ED_region_header_init(region); @@ -637,7 +637,7 @@ static void sequencer_header_region_draw(const bContext *C, ARegion *region) } /* *********************** toolbar region ************************ */ -/* add handlers, stuff you only do once or on area/region changes */ +/* Add handlers, stuff you only do once or on area/region changes. */ static void sequencer_tools_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; @@ -668,7 +668,7 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *region) keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); - /* own keymap */ + /* Own keymap. */ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0); WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); } @@ -722,7 +722,7 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win), wmNotifier *wmn, const Scene *UNUSED(scene)) { - /* context changes */ + /* Context changes. */ switch (wmn->category) { case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { @@ -769,7 +769,7 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win), /* *********************** buttons region ************************ */ -/* add handlers, stuff you only do once or on area/region changes */ +/* Add handlers, stuff you only do once or on area/region changes. */ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; @@ -792,7 +792,7 @@ static void sequencer_buttons_region_listener(wmWindow *UNUSED(win), wmNotifier *wmn, const Scene *UNUSED(scene)) { - /* context changes */ + /* Context changes. */ switch (wmn->category) { case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { @@ -837,7 +837,7 @@ static void sequencer_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_ /* ************************************* */ -/* only called once, from space/spacetypes.c */ +/* Only called once, from space/spacetypes.c. */ void ED_spacetype_sequencer(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype sequencer"); @@ -859,7 +859,8 @@ void ED_spacetype_sequencer(void) st->listener = sequencer_listener; st->id_remap = sequencer_id_remap; - /* regions: main window */ + /* Create regions: */ + /* Main window. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); art->regionid = RGN_TYPE_WINDOW; art->init = sequencer_main_region_init; @@ -867,10 +868,9 @@ void ED_spacetype_sequencer(void) art->listener = sequencer_main_region_listener; art->message_subscribe = sequencer_main_region_message_subscribe; art->keymapflag = ED_KEYMAP_TOOL | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION; - BLI_addhead(&st->regiontypes, art); - /* preview */ + /* Preview. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); art->regionid = RGN_TYPE_PREVIEW; art->init = sequencer_preview_region_init; @@ -880,7 +880,7 @@ void ED_spacetype_sequencer(void) ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); - /* regions: listview/buttons */ + /* Listview/buttons. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_SIDEBAR_PANEL_WIDTH * 1.3f; @@ -892,7 +892,7 @@ void ED_spacetype_sequencer(void) BLI_addhead(&st->regiontypes, art); sequencer_buttons_register(art); - /* regions: tool(bar) */ + /* Toolbar. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = 58; /* XXX */ @@ -904,7 +904,7 @@ void ED_spacetype_sequencer(void) art->draw = sequencer_tools_region_draw; BLI_addhead(&st->regiontypes, art); - /* regions: tool header */ + /* Tool header. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tool header region"); art->regionid = RGN_TYPE_TOOL_HEADER; art->prefsizey = HEADERY; @@ -915,7 +915,7 @@ void ED_spacetype_sequencer(void) art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header; BLI_addhead(&st->regiontypes, art); - /* regions: header */ + /* Header. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; @@ -924,16 +924,15 @@ void ED_spacetype_sequencer(void) art->init = sequencer_header_region_init; art->draw = sequencer_header_region_draw; art->listener = sequencer_main_region_listener; - BLI_addhead(&st->regiontypes, art); - /* regions: hud */ + /* Hud. */ art = ED_area_type_hud(st->spaceid); BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); - /* set the sequencer callback when not in background mode */ + /* Set the sequencer callback when not in background mode. */ if (G.background == 0) { sequencer_view3d_fn = ED_view3d_draw_offscreen_imbuf_simple; } -- cgit v1.2.3 From 0e7599bc15d85d59072a945dba50d2e8c09666a6 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Mon, 6 Apr 2020 00:11:55 +0200 Subject: VSE: don't allow strip preview when clicking on the scrubbing region Don't set 'special preview' or Solo mode if scrubbing in scrubbing region. Author: a.monti Reviewed By: Severin Differential Revision: https://developer.blender.org/D7234 --- source/blender/editors/animation/anim_ops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 7689d121a0c..2db381dfc69 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -49,6 +49,7 @@ #include "ED_anim_api.h" #include "ED_screen.h" #include "ED_sequencer.h" +#include "ED_time_scrub_ui.h" #include "ED_util.h" #include "DEG_depsgraph.h" @@ -155,7 +156,9 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event) bScreen *screen = CTX_wm_screen(C); if (area && area->spacetype == SPACE_SEQ) { SpaceSeq *sseq = area->spacedata.first; - if (ED_space_sequencer_check_show_strip(sseq)) { + ARegion *region = CTX_wm_region(C); + if (ED_space_sequencer_check_show_strip(sseq) && + !ED_time_scrub_event_in_region(region, event)) { ED_sequencer_special_preview_set(C, event->mval); } } -- cgit v1.2.3 From d0d20de183f1afc77a97a119afb66e64799ebc6f Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Mon, 6 Apr 2020 00:38:48 +0200 Subject: VSE: Draw f-curves for opacity and volume values on the strips Feature can be enabled or disabled in timeline view menu item "Show F-Curves". Author a.monti Reviewed By: ISS Differential Revision: https://developer.blender.org/D7205 --- release/scripts/startup/bl_ui/space_sequencer.py | 1 + source/blender/blenloader/intern/versioning_280.c | 11 +++ .../blenloader/intern/versioning_defaults.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 97 ++++++++++++++++++++++ .../editors/space_sequencer/space_sequencer.c | 2 +- source/blender/makesdna/DNA_space_types.h | 2 +- source/blender/makesrna/intern/rna_space.c | 5 ++ 7 files changed, 117 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index f1a349d49b4..c0a2b8a1230 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -309,6 +309,7 @@ class SEQUENCER_MT_view(Menu): layout.prop(st, "show_seconds") layout.prop(st, "show_locked_time") layout.prop(st, "show_strip_offset") + layout.prop(st, "show_fcurves") layout.separator() layout.prop(st, "show_markers") diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ff87756f436..a95cb74af51 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -665,6 +665,17 @@ static void do_versions_area_ensure_tool_region(Main *bmain, } } } + /* Activate fcurves drawing in the vse. */ + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = (SpaceSeq *)sl; + sseq->flag |= SEQ_SHOW_FCURVES; + } + } + } + } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 035e6c88faa..f4288b1d174 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -174,7 +174,7 @@ static void blo_update_defaults_screen(bScreen *screen, } else if (area->spacetype == SPACE_SEQ) { SpaceSeq *seq = area->spacedata.first; - seq->flag |= SEQ_SHOW_MARKERS; + seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES; } else if (area->spacetype == SPACE_TEXT) { /* Show syntax and line numbers in Script workspace text editor. */ diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2887113bdbe..a2f4ab001e2 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -968,6 +968,99 @@ static void calculate_seq_text_offsets( } } +static void fcurve_batch_add_verts(GPUVertBuf *vbo, + float y1, + float y2, + float y_height, + int cfra, + float curve_val, + unsigned int *vert_count) +{ + float vert_pos[2][2]; + + copy_v2_fl2(vert_pos[0], cfra, (curve_val * y_height) + y1); + copy_v2_fl2(vert_pos[1], cfra, y2); + + GPU_vertbuf_vert_set(vbo, *vert_count, vert_pos[0]); + GPU_vertbuf_vert_set(vbo, *vert_count + 1, vert_pos[1]); + *vert_count += 2; +} + +/* Draw f-curves as darkened regions of the strip. + * - Volume for sound strips. + * - Opacity for the other types. */ +static void draw_seq_fcurve( + Scene *scene, View2D *v2d, Sequence *seq, float x1, float y1, float x2, float y2, float pixelx) +{ + FCurve *fcu; + + if (seq->type == SEQ_TYPE_SOUND_RAM) { + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); + } + else { + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "blend_alpha", 0, NULL); + } + + if (fcu && !BKE_fcurve_is_empty(fcu)) { + + /* Clamp curve evaluation to the editor's borders. */ + int eval_start = max_ff(x1, v2d->cur.xmin); + int eval_end = min_ff(x2, v2d->cur.xmax + 1); + + int eval_step = max_ii(1, floor(pixelx)); + + if (eval_start >= eval_end) { + return; + } + + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + + uint max_verts = 2 * ((eval_end - eval_start) / eval_step + 1); + GPU_vertbuf_data_alloc(vbo, max_verts); + uint vert_count = 0; + + const float y_height = y2 - y1; + float curve_val; + float prev_val = INT_MIN; + bool skip = false; + + for (int cfra = eval_start; cfra <= eval_end; cfra += eval_step) { + curve_val = evaluate_fcurve(fcu, cfra); + CLAMP(curve_val, 0.0f, 1.0f); + + /* Avoid adding adjacent verts that have the same value. */ + if (curve_val == prev_val && cfra < eval_end - eval_step) { + skip = true; + continue; + } + + /* If some frames were skipped above, we need to close the shape. */ + if (skip) { + fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra - eval_step, prev_val, &vert_count); + skip = false; + } + + fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra, curve_val, &vert_count); + prev_val = curve_val; + } + + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_vertbuf_data_len_set(vbo, vert_count); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(batch, "color", 0.0f, 0.0f, 0.0f, 0.15f); + GPU_blend(true); + + if (vert_count > 0) { + GPU_batch_draw(batch); + } + + GPU_blend(false); + GPU_batch_discard(batch); + } +} + /* Draw visible strips. */ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, @@ -1024,6 +1117,10 @@ static void draw_seq_strip(const bContext *C, drawmeta_contents(scene, seq, x1, y1, x2, y2); } + if (sseq->flag & SEQ_SHOW_FCURVES) { + draw_seq_fcurve(scene, v2d, seq, x1, y1, x2, y2, pixelx); + } + /* Draw sound strip waveform. */ if ((seq->type == SEQ_TYPE_SOUND_RAM) && (sseq->flag & SEQ_NO_WAVEFORMS) == 0) { draw_seq_waveform(v2d, diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index e40fe91ae99..f52cfdd34c0 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -96,7 +96,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene) sseq->chanshown = 0; sseq->view = SEQ_VIEW_SEQUENCE; sseq->mainb = SEQ_DRAW_IMG_IMBUF; - sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS; + sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES; /* Tool header. */ region = MEM_callocN(sizeof(ARegion), "tool header for sequencer"); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 3020e5a1708..648d35c9a2d 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -606,7 +606,7 @@ typedef enum eSpaceSeq_Flag { SEQ_DRAW_COLOR_SEPARATED = (1 << 2), SEQ_SHOW_SAFE_MARGINS = (1 << 3), SEQ_SHOW_GPENCIL = (1 << 4), - /* SEQ_NO_DRAW_CFRANUM = (1 << 5), DEPRECATED */ + SEQ_SHOW_FCURVES = (1 << 5), SEQ_USE_ALPHA = (1 << 6), /* use RGBA display mode for preview */ SEQ_ALL_WAVEFORMS = (1 << 7), /* draw all waveforms */ SEQ_NO_WAVEFORMS = (1 << 8), /* draw no waveforms */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index f69ba1a38c9..1f072d2eb26 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -4831,6 +4831,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_OFFSET_EXT); RNA_def_property_ui_text(prop, "Show Offsets", "Display strip in/out offsets"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "show_fcurves", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_FCURVES); + RNA_def_property_ui_text(prop, "Show F-Curves", "Display strip opacity/volume curve"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } static void rna_def_space_text(BlenderRNA *brna) -- cgit v1.2.3 From 0ca5b7b69b0349e8d074a4942e75ed5386ff3ada Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Mon, 6 Apr 2020 02:09:20 +0200 Subject: Fix T74602: Sequencer slip operator ignores offset constraints Limit offsets, so each strip contains at least 1 frame of content. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D7288 --- .../editors/space_sequencer/sequencer_edit.c | 40 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c2ffb2f55c2..d34eed622d4 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1573,6 +1573,28 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) return changed; } +/* Make sure, that each strip contains at least 1 frame of content. */ +static void sequencer_slip_apply_limits(SlipData *data, int *offset) +{ + for (int i = 0; i < data->num_seq; i++) { + if (data->trim[i]) { + Sequence *seq = data->seq_array[i]; + int seq_content_start = data->ts[i].start + *offset; + int seq_content_end = seq_content_start + seq->len + seq->anim_startofs + seq->anim_endofs; + int diff = 0; + + if (seq_content_start >= seq->enddisp) { + diff = seq->enddisp - seq_content_start - 1; + } + + if (seq_content_end <= seq->startdisp) { + diff = seq->startdisp - seq_content_end + 1; + } + *offset += diff; + } + } +} + static int sequencer_slip_exec(bContext *C, wmOperator *op) { SlipData *data; @@ -1601,6 +1623,7 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) transseq_backup(data->ts + i, data->seq_array[i]); } + sequencer_slip_apply_limits(data, &offset); success = sequencer_slip_recursively(scene, data, offset); MEM_freeN(data->seq_array); @@ -1647,10 +1670,12 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even /* Modal numinput active, try to handle numeric inputs. */ if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) { - float offset; - applyNumInput(&data->num_input, &offset); + float offset_fl; + applyNumInput(&data->num_input, &offset_fl); + int offset = round_fl_to_int(offset_fl); - sequencer_slip_update_header(scene, area, data, (int)offset); + sequencer_slip_apply_limits(data, &offset); + sequencer_slip_update_header(scene, area, data, offset); RNA_int_set(op->ptr, "offset", offset); @@ -1682,6 +1707,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]); offset = mouseloc[0] - data->init_mouseloc[0]; + sequencer_slip_apply_limits(data, &offset); sequencer_slip_update_header(scene, area, data, offset); RNA_int_set(op->ptr, "offset", offset); @@ -1761,10 +1787,12 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even /* Modal numinput inactive, try to handle numeric inputs. */ if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) { - float offset; - applyNumInput(&data->num_input, &offset); + float offset_fl; + applyNumInput(&data->num_input, &offset_fl); + int offset = round_fl_to_int(offset_fl); - sequencer_slip_update_header(scene, area, data, (int)offset); + sequencer_slip_apply_limits(data, &offset); + sequencer_slip_update_header(scene, area, data, offset); RNA_int_set(op->ptr, "offset", offset); -- cgit v1.2.3 From 6526c3ced8b52e5583ff12095e5a9fe30410062e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2020 15:23:01 +1000 Subject: Fix displaying edit-mesh measurements with deform modifiers Resolves regression from 2.7x --- source/blender/bmesh/intern/bmesh_polygon.c | 25 +++++ source/blender/bmesh/intern/bmesh_polygon.h | 8 +- source/blender/draw/intern/draw_manager_text.c | 127 ++++++++++++++++++++----- 3 files changed, 136 insertions(+), 24 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 9ab5106cec2..a40c293f1aa 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -595,6 +595,31 @@ void BM_face_calc_center_bounds(const BMFace *f, float r_cent[3]) mid_v3_v3v3(r_cent, min, max); } +/** + * computes center of face in 3d. uses center of bounding box. + */ +void BM_face_calc_center_bounds_vcos(const BMesh *bm, + const BMFace *f, + float r_cent[3], + float const (*vertexCos)[3]) +{ + /* must have valid index data */ + BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); + (void)bm; + + const BMLoop *l_iter, *l_first; + float min[3], max[3]; + + INIT_MINMAX(min, max); + + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + minmax_v3v3_v3(min, max, vertexCos[BM_elem_index_get(l_iter->v)]); + } while ((l_iter = l_iter->next) != l_first); + + mid_v3_v3v3(r_cent, min, max); +} + /** * computes the center of a face, using the mean average */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 2ae32777a7d..1611bc0b893 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -60,10 +60,14 @@ void BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_plane[3]) ATTR_ void BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_plane[3]) ATTR_NONNULL(); void BM_face_calc_tangent_auto(const BMFace *f, float r_plane[3]) ATTR_NONNULL(); void BM_face_calc_center_bounds(const BMFace *f, float center[3]) ATTR_NONNULL(); -void BM_face_calc_center_median(const BMFace *f, float center[3]) ATTR_NONNULL(); +void BM_face_calc_center_bounds_vcos(const BMesh *bm, + const BMFace *f, + float r_center[3], + float const (*vertexCos)[3]) ATTR_NONNULL(); +void BM_face_calc_center_median(const BMFace *f, float r_center[3]) ATTR_NONNULL(); void BM_face_calc_center_median_vcos(const BMesh *bm, const BMFace *f, - float r_cent[3], + float r_center[3], float const (*vertexCos)[3]) ATTR_NONNULL(); void BM_face_calc_center_median_weighted(const BMFace *f, float center[3]) ATTR_NONNULL(); diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 2692f7b4795..23956df71e8 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -27,6 +27,7 @@ #include "BLI_string.h" #include "BKE_editmesh.h" +#include "BKE_editmesh_cache.h" #include "BKE_global.h" #include "BKE_unit.h" @@ -48,6 +49,7 @@ #include "WM_api.h" #include "draw_manager_text.h" +#include "intern/bmesh_polygon.h" typedef struct ViewCachedString { float vec[3]; @@ -216,6 +218,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, float clip_planes[4][4]; /* allow for displaying shape keys and deform mods */ BMIter iter; + const float(*vert_coords)[3] = (me->runtime.edit_data ? me->runtime.edit_data->vertexCos : NULL); + const bool use_coords = (vert_coords != NULL); /* when 2 or more edge-info options are enabled, space apart */ short edge_tex_count = 0; @@ -261,6 +265,10 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); + if (use_coords) { + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + } + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { /* draw selected edges, or edges next to selected verts while dragging */ if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || @@ -268,8 +276,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))) { float v1_clip[3], v2_clip[3]; - copy_v3_v3(v1, eed->v1->co); - copy_v3_v3(v2, eed->v2->co); + if (vert_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(eed->v1)]); + copy_v3_v3(v2, vert_coords[BM_elem_index_get(eed->v2)]); + } + else { + copy_v3_v3(v1, eed->v1->co); + copy_v3_v3(v2, eed->v2->co); + } if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { @@ -306,6 +320,13 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col); + const float(*poly_normals)[3] = NULL; + if (use_coords) { + BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); + BKE_editmesh_cache_ensure_poly_normals(em, me->runtime.edit_data); + poly_normals = me->runtime.edit_data->polyNos; + } + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { BMLoop *l_a, *l_b; if (BM_edge_loop_pair(eed, &l_a, &l_b)) { @@ -321,8 +342,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)))) { float v1_clip[3], v2_clip[3]; - copy_v3_v3(v1, eed->v1->co); - copy_v3_v3(v2, eed->v2->co); + if (vert_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(eed->v1)]); + copy_v3_v3(v2, vert_coords[BM_elem_index_get(eed->v2)]); + } + else { + copy_v3_v3(v1, eed->v1->co); + copy_v3_v3(v2, eed->v2->co); + } if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { float no_a[3], no_b[3]; @@ -331,8 +358,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, mid_v3_v3v3(vmid, v1_clip, v2_clip); mul_m4_v3(ob->obmat, vmid); - copy_v3_v3(no_a, l_a->f->no); - copy_v3_v3(no_b, l_b->f->no); + if (use_coords) { + copy_v3_v3(no_a, poly_normals[BM_elem_index_get(l_a->f)]); + copy_v3_v3(no_b, poly_normals[BM_elem_index_get(l_b->f)]); + } + else { + copy_v3_v3(no_a, l_a->f->no); + copy_v3_v3(no_b, l_b->f->no); + } if (do_global) { mul_mat3_m4_v3(ob->imat, no_a); @@ -372,9 +405,17 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, zero_v3(vmid); BMLoop *(*l)[3] = &em->looptris[poly_to_tri_count(i, BM_elem_index_get(f->l_first))]; for (int j = 0; j < numtri; j++) { - copy_v3_v3(v1, l[j][0]->v->co); - copy_v3_v3(v2, l[j][1]->v->co); - copy_v3_v3(v3, l[j][2]->v->co); + + if (use_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(l[j][0]->v)]); + copy_v3_v3(v2, vert_coords[BM_elem_index_get(l[j][1]->v)]); + copy_v3_v3(v3, vert_coords[BM_elem_index_get(l[j][2]->v)]); + } + else { + copy_v3_v3(v1, l[j][0]->v->co); + copy_v3_v3(v2, l[j][1]->v->co); + copy_v3_v3(v3, l[j][2]->v->co); + } add_v3_v3(vmid, v1); add_v3_v3(vmid, v2); @@ -417,6 +458,10 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); + if (use_coords) { + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + } + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { const bool is_face_sel = BM_elem_flag_test_bool(efa, BM_ELEM_SELECT); @@ -433,12 +478,24 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, /* lazy init center calc */ if (is_first) { - BM_face_calc_center_bounds(efa, vmid); + if (use_coords) { + BM_face_calc_center_bounds_vcos(em->bm, efa, vmid, vert_coords); + } + else { + BM_face_calc_center_bounds(efa, vmid); + } is_first = false; } - copy_v3_v3(v1, loop->prev->v->co); - copy_v3_v3(v2, loop->v->co); - copy_v3_v3(v3, loop->next->v->co); + if (use_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(loop->prev->v)]); + copy_v3_v3(v2, vert_coords[BM_elem_index_get(loop->v)]); + copy_v3_v3(v3, vert_coords[BM_elem_index_get(loop->next->v)]); + } + else { + copy_v3_v3(v1, loop->prev->v->co); + copy_v3_v3(v2, loop->v->co); + copy_v3_v3(v3, loop->next->v->co); + } copy_v3_v3(v2_local, v2); @@ -475,29 +532,44 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (em->selectmode & SCE_SELECT_VERTEX) { BMVert *v; + if (use_coords) { + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + } BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { - float vec[3]; - mul_v3_m4v3(vec, ob->obmat, v->co); + if (use_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(v)]); + } + else { + copy_v3_v3(v1, v->co); + } + + mul_m4_v3(ob->obmat, v1); numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); - DRW_text_cache_add(dt, vec, numstr, numstr_len, 0, 0, txt_flag, col); + DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); } } } if (em->selectmode & SCE_SELECT_EDGE) { - BMEdge *e; + BMEdge *eed; const bool use_edge_tex_sep = (edge_tex_count == 2); const bool use_edge_tex_len = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN); - BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) { - if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { + BM_ITER_MESH_INDEX (eed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { float v1_clip[3], v2_clip[3]; - copy_v3_v3(v1, e->v1->co); - copy_v3_v3(v2, e->v2->co); + if (use_coords) { + copy_v3_v3(v1, vert_coords[BM_elem_index_get(eed->v1)]); + copy_v3_v3(v2, vert_coords[BM_elem_index_get(eed->v2)]); + } + else { + copy_v3_v3(v1, eed->v1->co); + copy_v3_v3(v2, eed->v2->co); + } if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { mid_v3_v3v3(vmid, v1_clip, v2_clip); @@ -521,9 +593,20 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (em->selectmode & SCE_SELECT_FACE) { BMFace *f; + if (use_coords) { + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + } + BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, i) { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { - BM_face_calc_center_median(f, v1); + + if (use_coords) { + BM_face_calc_center_median_vcos(em->bm, f, v1, vert_coords); + } + else { + BM_face_calc_center_median(f, v1); + } + mul_m4_v3(ob->obmat, v1); numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); -- cgit v1.2.3 From f1bf7bfa1b5b468514655a18fa99a6900948173f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2020 16:02:29 +1000 Subject: Cleanup: spelling --- source/blender/blenkernel/intern/multires_reshape_smooth.c | 2 +- source/blender/editors/sculpt_paint/sculpt_filter_mesh.c | 8 ++++---- source/blender/editors/sculpt_paint/sculpt_undo.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index fad5004ff4b..514608a0f1d 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -929,7 +929,7 @@ typedef void(ReshapeSubdivCoarsePositionCb)( const Vertex *vertex, float r_P[3]); -/* Refine subdivision surface topology at a reshape level for new coarse verticies positions. */ +/* Refine subdivision surface topology at a reshape level for new coarse vertices positions. */ static void reshape_subdiv_refine(const MultiresReshapeSmoothContext *reshape_smooth_context, ReshapeSubdivCoarsePositionCb coarse_position_cb) { diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index f64e8ea609b..7116ec77fa4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -197,8 +197,8 @@ static void mesh_filter_task_cb(void *__restrict userdata, SculptOrigVertData orig_data; SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[i]); - /* When using the relax face sets mehs filter, each 3 iterations, do a whole mesh relax to smooth - * the contents of the Face Set. */ + /* When using the relax face sets meshes filter, + * each 3 iterations, do a whole mesh relax to smooth the contents of the Face Set. */ /* This produces better results as the relax operation is no completely focused on the * boundaries. */ const bool relax_face_sets = !(ss->filter_cache->iteration_count % 3 == 0); @@ -220,8 +220,8 @@ static void mesh_filter_task_cb(void *__restrict userdata, if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) { continue; } - /* Skip the edges of the face set when relaxing or smoothing. There is a relax face set - * option to relax the boindaries independently. */ + /* Skip the edges of the face set when relaxing or smoothing. + * There is a relax face set option to relax the boundaries independently. */ if (filter_type == MESH_FILTER_RELAX) { if (!SCULPT_vertex_has_unique_face_set(ss, vd.index)) { continue; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f78af10ad67..340f7191b95 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -96,7 +96,7 @@ * behavior, but it uses more memory that it seems it should be. * * The dynamic topology undo nodes are handled somewhat separately from all - * other ones and the idea there is to store log of operations: which verticies + * other ones and the idea there is to store log of operations: which vertices * and faces have been added or removed. * * Begin of dynamic topology sculpting mode have own node type. It contains an -- cgit v1.2.3 From 999134b7ca6d3ad7b9c01141cc99d91a7ce8f98a Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Mon, 6 Apr 2020 09:57:56 +0200 Subject: Cleanup: Add some comments removed in rB0d0036cb53f8 --- source/blender/editors/space_sequencer/sequencer_add.c | 2 +- source/blender/editors/space_sequencer/sequencer_draw.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 049f3d76b53..80172c5462f 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -1038,7 +1038,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->blend_mode = SEQ_TYPE_ALPHAOVER; } - /* Set channel.*/ + /* Set channel. If unset, use lowest free one above strips. */ if (!RNA_struct_property_is_set(op->ptr, "channel")) { if (seq->seq1) { int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0, diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index a2f4ab001e2..93ff5263148 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -353,6 +353,8 @@ static void draw_seq_waveform(View2D *v2d, } } +/* Don't use SEQ_BEGIN/SEQ_END here, because it changes seq->depth, + * which is needed for tranform. */ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2) { Sequence *seq; @@ -1061,7 +1063,7 @@ static void draw_seq_fcurve( } } -/* Draw visible strips. */ +/* Draw visible strips. Bounds check are already made. */ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, -- cgit v1.2.3 From 480ff89bf7cfb1f9ffd5ce66fbd5c65288ef04c0 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 6 Apr 2020 10:21:29 +0200 Subject: Fix T75311, T75310: Edit Weight Paint Overlay Render Artifacts During recent refactoring of the edit weight overlay we moved a assignment before it was valid. Making everything one frame off what resulted in a flashing frame during TAA, not drawing the overlay until a second action happened, making overlays too bright. The reason whas that the painting overlay wasn't initialized in the first sample, but the draw passes and groups were filled. Resulting in rendering the overlay twice or not at all. This change moves the assignment to where it is valid. --- source/blender/draw/engines/overlay/overlay_engine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 19b0fa5e12b..207637fa131 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -106,11 +106,12 @@ static void OVERLAY_cache_init(void *vedata) OVERLAY_Data *data = vedata; OVERLAY_StorageList *stl = data->stl; OVERLAY_PrivateData *pd = stl->pd; - const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: OVERLAY_edit_mesh_cache_init(vedata); + /* `pd->edit_mesh.flag` is valid after calling `OVERLAY_edit_mesh_cache_init`. */ + const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); if (draw_edit_weights) { OVERLAY_paint_cache_init(vedata); } -- cgit v1.2.3 From 2cc55bcdc24683210a42e784cdb4636187a48077 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 6 Apr 2020 12:01:13 +0200 Subject: fix after merge --- source/blender/makesrna/intern/rna_nodetree.c | 2 +- source/blender/nodes/simulation/node_simulation_tree.cc | 2 +- source/blender/nodes/simulation/nodes/node_sim_common.cc | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index eeea12b64bc..4feb53f95bb 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1818,7 +1818,7 @@ static StructRNA *rna_SimulationNode_register(Main *bmain, /* update while blender is running */ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - return nt->ext.srna; + return nt->rna_ext.srna; } static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create) diff --git a/source/blender/nodes/simulation/node_simulation_tree.cc b/source/blender/nodes/simulation/node_simulation_tree.cc index b9af19b26cd..3f0e70259d6 100644 --- a/source/blender/nodes/simulation/node_simulation_tree.cc +++ b/source/blender/nodes/simulation/node_simulation_tree.cc @@ -39,7 +39,7 @@ void register_node_tree_type_sim(void) strcpy(tt->ui_name, N_("Simulation Editor")); tt->ui_icon = 0; /* defined in drawnode.c */ strcpy(tt->ui_description, N_("Simulation nodes")); - tt->ext.srna = &RNA_SimulationNodeTree; + tt->rna_ext.srna = &RNA_SimulationNodeTree; ntreeTypeAdd(tt); } diff --git a/source/blender/nodes/simulation/nodes/node_sim_common.cc b/source/blender/nodes/simulation/nodes/node_sim_common.cc index 1db7eb03cf3..fbc03905d4f 100644 --- a/source/blender/nodes/simulation/nodes/node_sim_common.cc +++ b/source/blender/nodes/simulation/nodes/node_sim_common.cc @@ -32,9 +32,9 @@ void register_node_type_sim_group(void) ntype.poll_instance = node_group_poll_instance; ntype.insert_link = node_insert_link_default; ntype.update_internal_links = node_update_internal_links_default; - ntype.ext.srna = RNA_struct_find("SimulationNodeGroup"); - BLI_assert(ntype.ext.srna != NULL); - RNA_struct_blender_type_set(ntype.ext.srna, &ntype); + ntype.rna_ext.srna = RNA_struct_find("SimulationNodeGroup"); + BLI_assert(ntype.rna_ext.srna != NULL); + RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); node_type_socket_templates(&ntype, NULL, NULL); node_type_size(&ntype, 140, 60, 400); -- cgit v1.2.3