From 596f33f801f872df22460ad864da193e1a44e36f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Mar 2018 22:19:56 +0100 Subject: Fix T54206: bevel and inset operations repeat did not remember offset. Now repeating the operator will use the previously chosen offset, either with the modal operator or typed in. The modal operator will still start at zero. --- source/blender/editors/mesh/editmesh_bevel.c | 5 ++++- source/blender/editors/mesh/editmesh_inset.c | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index d4d7d92d5ad..c8d33a9cc60 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -139,6 +139,10 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) return false; } + if (is_modal) { + RNA_float_set(op->ptr, "offset", 0.0f); + } + op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator"); opdata->em = em; @@ -622,7 +626,6 @@ void MESH_OT_bevel(wmOperatorType *ot) RNA_def_enum(ot->srna, "offset_type", offset_type_items, 0, "Amount Type", "What distance Amount measures"); prop = RNA_def_float(ot->srna, "offset", 0.0f, -1e6f, 1e6f, "Amount", "", 0.0f, 1.0f); RNA_def_property_float_array_funcs_runtime(prop, NULL, NULL, mesh_ot_bevel_offset_range_func); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_int(ot->srna, "segments", 1, 1, SEGMENTS_HARD_MAX, "Segments", "Segments for curved edge", 1, 8); RNA_def_float(ot->srna, "profile", 0.5f, PROFILE_HARD_MIN, 1.0f, "Profile", "Controls profile shape (0.5 = round)", PROFILE_HARD_MIN, 1.0f); diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 6fd4203e085..3833b84b5d2 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -122,6 +122,11 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) return false; } + if (is_modal) { + RNA_float_set(op->ptr, "thickness", 0.01f); + RNA_float_set(op->ptr, "depth", 0.0f); + } + op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data"); opdata->old_thickness = 0.01; @@ -527,11 +532,9 @@ void MESH_OT_inset(wmOperatorType *ot) prop = RNA_def_float_distance(ot->srna, "thickness", 0.01f, 0.0f, 1e12f, "Thickness", "", 0.0f, 10.0f); /* use 1 rather then 10 for max else dragging the button moves too far */ RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_float_distance(ot->srna, "depth", 0.0f, -1e12f, 1e12f, "Depth", "", -10.0f, 10.0f); RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.01, 4); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset"); RNA_def_boolean(ot->srna, "use_select_inset", false, "Select Outer", "Select the new inset faces"); -- cgit v1.2.3 From a5d63624dee121b96cc6611bdd3242548aec4668 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 5 Mar 2018 15:58:07 +1300 Subject: Cleanup: Fix invalid name prefix --- source/blender/makesrna/intern/rna_object_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 836c077aaf3..be63fc4abc8 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -91,7 +91,7 @@ static const EnumPropertyItem space_items[] = { #include "DEG_depsgraph.h" /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ -static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, +static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, float *mat, float *mat_ret, int from, int to) { copy_m4_m4((float (*)[4])mat_ret, (float (*)[4])mat); @@ -508,7 +508,7 @@ void RNA_api_object(StructRNA *srna) #endif /* Matrix space conversion */ - func = RNA_def_function(srna, "convert_space", "rna_Scene_mat_convert_space"); + func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "pose_bone", "PoseBone", "", -- cgit v1.2.3 From fb70f9bf997114a55cdfebe47fa42005c2112927 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 Mar 2018 15:17:53 +1300 Subject: Fix crash if NLA strip with "Use Animated Influence" setting is enabled without the Influence Strip F-Curve existing --- source/blender/editors/space_nla/nla_draw.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 255fc0d6f8f..d33b84f76c0 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -285,16 +285,20 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) float cfra; /* plot the curve (over the strip's main region) */ - glBegin(GL_LINE_STRIP); - /* sample at 1 frame intervals, and draw - * - min y-val is yminc, max is y-maxc, so clamp in those regions - */ - for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) { - float y = evaluate_fcurve(fcu, cfra); - CLAMP(y, 0.0f, 1.0f); - glVertex2f(cfra, ((y * yheight) + yminc)); + if (fcu) { + glBegin(GL_LINE_STRIP); + + /* sample at 1 frame intervals, and draw + * - min y-val is yminc, max is y-maxc, so clamp in those regions + */ + for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) { + float y = evaluate_fcurve(fcu, cfra); + CLAMP(y, 0.0f, 1.0f); + glVertex2f(cfra, ((y * yheight) + yminc)); + } + + glEnd(); // GL_LINE_STRIP } - glEnd(); // GL_LINE_STRIP } else { /* use blend in/out values only if both aren't zero */ -- cgit v1.2.3 From 7e2100e49914e5d32973b3d28134340e0404f1bf Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 Mar 2018 16:49:33 +1300 Subject: T54233: NLA "Push Down" discards Blend Mode, Extrapolation, and Influence Each AnimData block has a set of Blend/Extrapolation/Influence settings that can be used to control how the active action is blended with the NLA stack. However, these settings were not getting copied over to the newly created strips (as the push-down code existed long before these settings were added). This commit solves this in several ways: * Active Action Blend/Extrapolation/Influence settings now get copied to the new strips when adding them to the NLA stack via Push Down. Note: This doesn't happen when there are no existing NLA tracks, as these settings don't get used in that case. * Strip Influence will be copied across when inf < 1.0 (i.e. when a non-default value is used), to maintain the effect. To make this work, the influence value will get added as a keyframe to the strip's "Influence" Control FCurve. - See code comments for an alternative approach and why that was not chosen - Strip Time still doesn't get keyframes added automatically yet. * To ensure the "extrapolation mode" settings don't get always overwritten, I've put in place a compromise: the extrapolation will only get changed if the chosen setting will cause problmes (i.e. hold forward & back -> hold forward if there are other tracks before it already). Not safe for backporting to 2.79[x] stable releases. --- source/blender/blenkernel/intern/nla.c | 39 +++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 2363eb525d5..6a0effd5ed2 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1392,7 +1392,12 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("influence", 9); - /* TODO: insert a few keyframes to ensure default behavior? */ + /* insert keyframe to ensure current value stays on first refresh */ + fcu->bezt = MEM_callocN(sizeof(BezTriple), "nlastrip influence bezt"); + fcu->totvert = 1; + + fcu->bezt->vec[1][0] = strip->start; + fcu->bezt->vec[1][1] = strip->influence; } } @@ -1760,7 +1765,8 @@ bool BKE_nla_action_stash(AnimData *adt) void BKE_nla_action_pushdown(AnimData *adt) { NlaStrip *strip; - + const bool is_first = (adt) && (adt->nla_tracks.first == NULL); + /* sanity checks */ /* TODO: need to report the error for this */ if (ELEM(NULL, adt, adt->action)) @@ -1784,6 +1790,32 @@ void BKE_nla_action_pushdown(AnimData *adt) id_us_min(&adt->action->id); adt->action = NULL; + /* copy current "action blending" settings from adt to the strip, + * as it was keyframed with these settings, so omitting them will + * change the effect [T54233] + * + * NOTE: We only do this when there are no tracks + */ + if (is_first == false) { + strip->blendmode = adt->act_blendmode; + strip->influence = adt->act_influence; + strip->extendmode = adt->act_extendmode; + + if (adt->act_influence < 1.0f) { + /* enable "user-controlled" influence (which will insert a default keyframe) + * so that the influence doesn't get lost on the new update + * + * NOTE: An alternative way would have been to instead hack the influence + * to not get always get reset to full strength if NLASTRIP_FLAG_USR_INFLUENCE + * is disabled but auto-blending isn't being used. However, that approach + * is a bit hacky/hard to discover, and may cause backwards compatability issues, + * so it's better to just do it this way. + */ + strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE; + BKE_nlastrip_validate_fcurves(strip); + } + } + /* if the strip is the first one in the track it lives in, check if there * are strips in any other tracks that may be before this, and set the extend * mode accordingly @@ -1793,7 +1825,8 @@ void BKE_nla_action_pushdown(AnimData *adt) * so that it doesn't override strips in previous tracks */ /* FIXME: this needs to be more automated, since user can rearrange strips */ - strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; + if (strip->extendmode == NLASTRIP_EXTEND_HOLD) + strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; } /* make strip the active one... */ -- cgit v1.2.3 From 5331581ea4cd382ce0c133a99bf50c0aea257aac Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 Mar 2018 17:14:46 +1300 Subject: Cleanup: Use BKE_ prefix for all public functions exposed by the NLA module --- source/blender/blenkernel/BKE_nla.h | 24 +++++------ source/blender/blenkernel/intern/anim_sys.c | 6 +-- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/nla.c | 46 +++++++++++----------- source/blender/editors/object/object_add.c | 4 +- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/space_action/action_data.c | 4 +- source/blender/editors/space_nla/nla_channels.c | 8 ++-- source/blender/editors/space_nla/nla_edit.c | 22 +++++------ .../blender/editors/transform/transform_generics.c | 2 +- source/blender/makesrna/intern/rna_animation.c | 4 +- source/blender/makesrna/intern/rna_nla.c | 6 +-- 12 files changed, 65 insertions(+), 65 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 8d9fc8ff6cf..4509d374b02 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -46,18 +46,18 @@ struct PropertyRNA; /* ----------------------------- */ /* Data Management */ -void free_nlastrip(ListBase *strips, struct NlaStrip *strip); -void free_nlatrack(ListBase *tracks, struct NlaTrack *nlt); -void free_nladata(ListBase *tracks); - -struct NlaStrip *copy_nlastrip(struct NlaStrip *strip, const bool use_same_action); -struct NlaTrack *copy_nlatrack(struct NlaTrack *nlt, const bool use_same_actions); -void copy_nladata(ListBase *dst, ListBase *src); - -struct NlaTrack *add_nlatrack(struct AnimData *adt, struct NlaTrack *prev); -struct NlaStrip *add_nlastrip(struct bAction *act); -struct NlaStrip *add_nlastrip_to_stack(struct AnimData *adt, struct bAction *act); -struct NlaStrip *add_nla_soundstrip(struct Scene *scene, struct Speaker *spk); +void BKE_nlastrip_free(ListBase *strips, struct NlaStrip *strip); +void BKE_nlatrack_free(ListBase *tracks, struct NlaTrack *nlt); +void BKE_nla_tracks_free(ListBase *tracks); + +struct NlaStrip *BKE_nlastrip_copy(struct NlaStrip *strip, const bool use_same_action); +struct NlaTrack *BKE_nlatrack_copy(struct NlaTrack *nlt, const bool use_same_actions); +void BKE_nla_tracks_copy(ListBase *dst, ListBase *src); + +struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt, struct NlaTrack *prev); +struct NlaStrip *BKE_nlastrip_new(struct bAction *act); +struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt, struct bAction *act); +struct NlaStrip *BKE_nla_add_soundstrip(struct Scene *scene, struct Speaker *spk); /* ----------------------------- */ /* API */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 95d9a769749..095ef6fa1bd 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -243,7 +243,7 @@ void BKE_animdata_free(ID *id, const bool do_id_user) } /* free nla data */ - free_nladata(&adt->nla_tracks); + BKE_nla_tracks_free(&adt->nla_tracks); /* free drivers - stored as a list of F-Curves */ free_fcurves(&adt->drivers); @@ -282,7 +282,7 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action) } /* duplicate NLA data */ - copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); + BKE_nla_tracks_copy(&dadt->nla_tracks, &adt->nla_tracks); /* duplicate drivers (F-Curves) */ copy_fcurves(&dadt->drivers, &adt->drivers); @@ -364,7 +364,7 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes a if (src->nla_tracks.first) { ListBase tracks = {NULL, NULL}; - copy_nladata(&tracks, &src->nla_tracks); + BKE_nla_tracks_copy(&tracks, &src->nla_tracks); BLI_movelisttolist(&dst->nla_tracks, &tracks); } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 00cf40f06cd..fcbc25ebad5 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1663,7 +1663,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips) /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt = add_nlatrack(adt, NULL); + nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 6a0effd5ed2..e239037df70 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -75,7 +75,7 @@ /* Remove the given NLA strip from the NLA track it occupies, free the strip's data, * and the strip itself. */ -void free_nlastrip(ListBase *strips, NlaStrip *strip) +void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip) { NlaStrip *cs, *csn; @@ -86,7 +86,7 @@ void free_nlastrip(ListBase *strips, NlaStrip *strip) /* free child-strips */ for (cs = strip->strips.first; cs; cs = csn) { csn = cs->next; - free_nlastrip(&strip->strips, cs); + BKE_nlastrip_free(&strip->strips, cs); } /* remove reference to action */ @@ -113,7 +113,7 @@ void free_nlastrip(ListBase *strips, NlaStrip *strip) /* Remove the given NLA track from the set of NLA tracks, free the track's data, * and the track itself. */ -void free_nlatrack(ListBase *tracks, NlaTrack *nlt) +void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt) { NlaStrip *strip, *stripn; @@ -124,7 +124,7 @@ void free_nlatrack(ListBase *tracks, NlaTrack *nlt) /* free strips */ for (strip = nlt->strips.first; strip; strip = stripn) { stripn = strip->next; - free_nlastrip(&nlt->strips, strip); + BKE_nlastrip_free(&nlt->strips, strip); } /* free NLA track itself now */ @@ -137,7 +137,7 @@ void free_nlatrack(ListBase *tracks, NlaTrack *nlt) /* Free the elements of type NLA Tracks provided in the given list, but do not free * the list itself since that is not free-standing */ -void free_nladata(ListBase *tracks) +void BKE_nla_tracks_free(ListBase *tracks) { NlaTrack *nlt, *nltn; @@ -148,7 +148,7 @@ void free_nladata(ListBase *tracks) /* free tracks one by one */ for (nlt = tracks->first; nlt; nlt = nltn) { nltn = nlt->next; - free_nlatrack(tracks, nlt); + BKE_nlatrack_free(tracks, nlt); } /* clear the list's pointers to be safe */ @@ -162,7 +162,7 @@ void free_nladata(ListBase *tracks) * * \param use_same_action When true, the existing action is used (instead of being duplicated) */ -NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action) +NlaStrip *BKE_nlastrip_copy(NlaStrip *strip, const bool use_same_action) { NlaStrip *strip_d; NlaStrip *cs, *cs_d; @@ -195,7 +195,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action) BLI_listbase_clear(&strip_d->strips); for (cs = strip->strips.first; cs; cs = cs->next) { - cs_d = copy_nlastrip(cs, use_same_action); + cs_d = BKE_nlastrip_copy(cs, use_same_action); BLI_addtail(&strip_d->strips, cs_d); } @@ -204,7 +204,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip, const bool use_same_action) } /* Copy NLA Track */ -NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions) +NlaTrack *BKE_nlatrack_copy(NlaTrack *nlt, const bool use_same_actions) { NlaStrip *strip, *strip_d; NlaTrack *nlt_d; @@ -221,7 +221,7 @@ NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions) BLI_listbase_clear(&nlt_d->strips); for (strip = nlt->strips.first; strip; strip = strip->next) { - strip_d = copy_nlastrip(strip, use_same_actions); + strip_d = BKE_nlastrip_copy(strip, use_same_actions); BLI_addtail(&nlt_d->strips, strip_d); } @@ -230,7 +230,7 @@ NlaTrack *copy_nlatrack(NlaTrack *nlt, const bool use_same_actions) } /* Copy all NLA data */ -void copy_nladata(ListBase *dst, ListBase *src) +void BKE_nla_tracks_copy(ListBase *dst, ListBase *src) { NlaTrack *nlt, *nlt_d; @@ -245,7 +245,7 @@ void copy_nladata(ListBase *dst, ListBase *src) for (nlt = src->first; nlt; nlt = nlt->next) { /* make a copy, and add the copy to the destination list */ // XXX: we need to fix this sometime - nlt_d = copy_nlatrack(nlt, true); + nlt_d = BKE_nlatrack_copy(nlt, true); BLI_addtail(dst, nlt_d); } } @@ -255,7 +255,7 @@ void copy_nladata(ListBase *dst, ListBase *src) /* Add a NLA Track to the given AnimData * - prev: NLA-Track to add the new one after */ -NlaTrack *add_nlatrack(AnimData *adt, NlaTrack *prev) +NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev) { NlaTrack *nlt; @@ -285,8 +285,8 @@ NlaTrack *add_nlatrack(AnimData *adt, NlaTrack *prev) return nlt; } -/* Add a NLA Strip referencing the given Action */ -NlaStrip *add_nlastrip(bAction *act) +/* Create a NLA Strip referencing the given Action */ +NlaStrip *BKE_nlastrip_new(bAction *act) { NlaStrip *strip; @@ -327,7 +327,7 @@ NlaStrip *add_nlastrip(bAction *act) } /* Add new NLA-strip to the top of the NLA stack - i.e. into the last track if space, or a new one otherwise */ -NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act) +NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act) { NlaStrip *strip; NlaTrack *nlt; @@ -337,7 +337,7 @@ NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act) return NULL; /* create a new NLA strip */ - strip = add_nlastrip(act); + strip = BKE_nlastrip_new(act); if (strip == NULL) return NULL; @@ -346,7 +346,7 @@ NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act) /* trying to add to the last track failed (no track or no space), * so add a new track to the stack, and add to that... */ - nlt = add_nlatrack(adt, NULL); + nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -358,7 +358,7 @@ NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act) } /* Add a NLA Strip referencing the given speaker's sound */ -NlaStrip *add_nla_soundstrip(Scene *scene, Speaker *speaker) +NlaStrip *BKE_nla_add_soundstrip(Scene *scene, Speaker *speaker) { NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip"); @@ -751,7 +751,7 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip) } /* free the meta-strip now */ - free_nlastrip(strips, strip); + BKE_nlastrip_free(strips, strip); } /* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips @@ -1714,7 +1714,7 @@ bool BKE_nla_action_stash(AnimData *adt) } } - nlt = add_nlatrack(adt, prev_track); + nlt = BKE_nlatrack_add(adt, prev_track); BLI_assert(nlt != NULL); /* we need to ensure that if there wasn't any previous instance, it must go to tbe bottom of the stack */ @@ -1729,7 +1729,7 @@ bool BKE_nla_action_stash(AnimData *adt) /* add the action as a strip in this new track * NOTE: a new user is created here */ - strip = add_nlastrip(adt->action); + strip = BKE_nlastrip_new(adt->action); BLI_assert(strip != NULL); BKE_nlatrack_add_strip(nlt, strip); @@ -1782,7 +1782,7 @@ void BKE_nla_action_pushdown(AnimData *adt) } /* add a new NLA strip to the track, which references the active action */ - strip = add_nlastrip_to_stack(adt, adt->action); + strip = BKE_nlastack_add_strip(adt, adt->action); /* do other necessary work on strip */ if (strip) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8d5c4684c2b..0b486f8e5a3 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1059,8 +1059,8 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) { /* create new data for NLA hierarchy */ AnimData *adt = BKE_animdata_add_id(&ob->id); - NlaTrack *nlt = add_nlatrack(adt, NULL); - NlaStrip *strip = add_nla_soundstrip(scene, ob->data); + NlaTrack *nlt = BKE_nlatrack_add(adt, NULL); + NlaStrip *strip = BKE_nla_add_soundstrip(scene, ob->data); strip->start = CFRA; strip->end += strip->start; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 84808817b94..32f0f1f9bec 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1096,7 +1096,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } else if (event == 26) { #if 0 // XXX old animation system - copy_nlastrips(&base->object->nlastrips, &ob->nlastrips); + BKE_nlastrip_copy(s(&base->object->nlastrips, &ob->nlastrips); #endif // XXX old animation system } else if (event == 27) { /* autosmooth */ diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 29b3c6f2f6c..fbef14c07c4 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -568,11 +568,11 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, if (strip->act == act) { /* Remove this strip, and the track too if it doesn't have anything else */ - free_nlastrip(&nlt->strips, strip); + BKE_nlastrip_free(&nlt->strips, strip); if (nlt->strips.first == NULL) { BLI_assert(nstrip == NULL); - free_nlatrack(&adt->nla_tracks, nlt); + BKE_nlatrack_free(&adt->nla_tracks, nlt); } } } diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index c261821db16..27f275c15dd 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -596,12 +596,12 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel) */ if (above_sel) { /* just add a new one above this one */ - add_nlatrack(adt, nlt); + BKE_nlatrack_add(adt, nlt); added = true; } else if ((lastAdt == NULL) || (adt != lastAdt)) { /* add one track to the top of the owning AnimData's stack, then don't add anymore to this stack */ - add_nlatrack(adt, NULL); + BKE_nlatrack_add(adt, NULL); lastAdt = adt; added = true; } @@ -636,7 +636,7 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac) /* ensure it is empty */ if (BLI_listbase_is_empty(&adt->nla_tracks)) { /* add new track to this AnimData block then */ - add_nlatrack(adt, NULL); + BKE_nlatrack_add(adt, NULL); added = true; } } @@ -731,7 +731,7 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) adt->flag &= ~ADT_NLA_SOLO_TRACK; /* call delete on this track - deletes all strips too */ - free_nlatrack(&adt->nla_tracks, nlt); + BKE_nlatrack_free(&adt->nla_tracks, nlt); } } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 31524f8450a..87b7599ec66 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -645,7 +645,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) } /* create a new strip, and offset it to start on the current frame */ - strip = add_nlastrip(act); + strip = BKE_nlastrip_new(act); strip->end += (cfra - strip->start); strip->start = cfra; @@ -655,7 +655,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt = add_nlatrack(adt, NULL); + nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -858,7 +858,7 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) continue; /* create a new strip, and offset it to start on the current frame */ - strip = add_nla_soundstrip(ac.scene, ob->data); + strip = BKE_nla_add_soundstrip(ac.scene, ob->data); strip->start += cfra; strip->end += cfra; @@ -868,7 +868,7 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt = add_nlatrack(adt, NULL); + nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -1057,7 +1057,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* make a copy (assume that this is possible) */ - nstrip = copy_nlastrip(strip, linked); + nstrip = BKE_nlastrip_copy(strip, linked); /* in case there's no space in the track above, or we haven't got a reference to it yet, try adding */ if (BKE_nlatrack_add_strip(nlt->next, nstrip) == 0) { @@ -1065,7 +1065,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) * - if the current one is the last one, nlt->next will be NULL, which defaults to adding * at the top of the stack anyway... */ - track = add_nlatrack(adt, nlt->next); + track = BKE_nlatrack_add(adt, nlt->next); BKE_nlatrack_add_strip(track, nstrip); } @@ -1160,14 +1160,14 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) if (strip->flag & NLASTRIP_FLAG_SELECT) { /* if a strip either side of this was a transition, delete those too */ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) - free_nlastrip(&nlt->strips, strip->prev); + BKE_nlastrip_free(&nlt->strips, strip->prev); if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { nstrip = nstrip->next; - free_nlastrip(&nlt->strips, strip->next); + BKE_nlastrip_free(&nlt->strips, strip->next); } /* finally, delete this strip */ - free_nlastrip(&nlt->strips, strip); + BKE_nlastrip_free(&nlt->strips, strip); } } } @@ -1242,7 +1242,7 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip * /* make a copy (assume that this is possible) and append * it immediately after the current strip */ - nstrip = copy_nlastrip(strip, true); + nstrip = BKE_nlastrip_copy(strip, true); BLI_insertlinkafter(&nlt->strips, strip, nstrip); /* set the endpoint of the first strip and the start of the new strip @@ -2186,7 +2186,7 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op) /* in case there's no space in the current track, try adding */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* need to add a new track above the current one */ - track = add_nlatrack(adt, nlt); + track = BKE_nlatrack_add(adt, nlt); BKE_nlatrack_add_strip(track, strip); /* clear temp meta-strips on this new track, as we may not be able to get back to it */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 277e01d1e2b..618b8a37320 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -276,7 +276,7 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) /* only push down if action is more than 1-2 frames long */ calc_action_range(adt->action, &astart, &aend, 1); if (aend > astart + 2.0f) { - NlaStrip *strip = add_nlastrip_to_stack(adt, adt->action); + NlaStrip *strip = BKE_nlastack_add_strip(adt, adt->action); /* clear reference to action now that we've pushed it onto the stack */ id_us_min(&adt->action->id); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index c9c8a791545..6779e74700d 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -519,7 +519,7 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports) /* needs wrapper function to push notifier */ static NlaTrack *rna_NlaTrack_new(AnimData *adt, bContext *C, NlaTrack *track) { - NlaTrack *new_track = add_nlatrack(adt, track); + NlaTrack *new_track = BKE_nlatrack_add(adt, track); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL); @@ -535,7 +535,7 @@ static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports, return; } - free_nlatrack(&adt->nla_tracks, track); + BKE_nlatrack_free(&adt->nla_tracks, track); RNA_POINTER_INVALIDATE(track_ptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 20d5e1e959c..f1c02896447 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -371,7 +371,7 @@ static FCurve *rna_NlaStrip_fcurve_find(NlaStrip *strip, ReportList *reports, co static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *reports, const char *UNUSED(name), int start, bAction *action) { - NlaStrip *strip = add_nlastrip(action); + NlaStrip *strip = BKE_nlastrip_new(action); if (strip == NULL) { BKE_report(reports, RPT_ERROR, "Unable to create new strip"); @@ -384,7 +384,7 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) { BKE_report(reports, RPT_ERROR, "Unable to add strip (the track does not have any space to accommodate this new strip)"); - free_nlastrip(NULL, strip); + BKE_nlastrip_free(NULL, strip); return NULL; } @@ -425,7 +425,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report return; } - free_nlastrip(&track->strips, strip); + BKE_nlastrip_free(&track->strips, strip); RNA_POINTER_INVALIDATE(strip_ptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); -- cgit v1.2.3 From cb8311fecfaaf2b755fcf8e8d52af83f512688b0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Mar 2018 17:21:39 +1100 Subject: Cleanup: set the view-context once --- .../blender/editors/space_view3d/view3d_select.c | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 4e96ea63808..e6b93f634dd 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -2778,21 +2778,19 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m /* not a real operator, only for circle test */ static int view3d_circle_select_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - Object *obact = CTX_data_active_object(C); + ViewContext vc; + view3d_set_viewcontext(C, &vc); + Object *obact = vc.obact; + Object *obedit = vc.obedit; const int radius = RNA_int_get(op->ptr, "radius"); const bool select = !RNA_boolean_get(op->ptr, "deselect"); const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; - if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) || + if (obedit || BKE_paint_select_elem_test(obact) || (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { - ViewContext vc; - view3d_operator_needs_opengl(C); - - view3d_set_viewcontext(C, &vc); if (CTX_data_edit_object(C)) { obedit_circle_select(&vc, select, mval, (float)radius); @@ -2806,23 +2804,22 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) paint_vertsel_circle_select(&vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (obact->mode & OB_MODE_POSE) + else if (obact->mode & OB_MODE_POSE) { pose_circle_select(&vc, select, mval, (float)radius); - else + } + else { return PE_circle_select(C, select, mval, (float)radius); + } } else if (obact && obact->mode & OB_MODE_SCULPT) { return OPERATOR_CANCELLED; } else { - ViewContext vc; - view3d_set_viewcontext(C, &vc); - if (object_circle_select(&vc, select, mval, (float)radius)) { - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene); } } - + return OPERATOR_FINISHED; } -- cgit v1.2.3 From 28f86bf117e9d9d10089ef758a5ec4ade65084c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Mar 2018 17:26:02 +1100 Subject: Cleanup: use edit/active objects from view context Needed to implement multiple edit-objects. --- source/blender/editors/space_view3d/view3d_draw.c | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7e613e36119..cc046eebc68 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1318,31 +1318,30 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* *********************** backdraw for selection *************** */ -static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d) +static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d, Object *obact, Object *obedit) { RegionView3D *rv3d = ar->regiondata; - struct Base *base = scene->basact; int multisample_enabled; BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); - if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || - BKE_paint_select_face_test(base->object))) + if (obact && (obact->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || + BKE_paint_select_face_test(obact))) { /* do nothing */ } /* texture paint mode sampling */ - else if (base && (base->object->mode & OB_MODE_TEXTURE_PAINT) && + else if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT) && (v3d->drawtype > OB_WIRE)) { /* do nothing */ } - else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && + else if ((obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) && V3D_IS_ZBUF(v3d)) { /* do nothing */ } - else if (scene->obedit && + else if (obedit && V3D_IS_ZBUF(v3d)) { /* do nothing */ @@ -1417,10 +1416,11 @@ static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d ED_view3d_clipping_set(rv3d); G.f |= G_BACKBUFSEL; - - if (base && (base->lay & v3d->lay)) - draw_object_backbufsel(scene, v3d, rv3d, base->object); - + + if (obact && (obact->lay & v3d->lay)) { + draw_object_backbufsel(scene, v3d, rv3d, obact); + } + if (rv3d->gpuoffscreen) GPU_offscreen_unbind(rv3d->gpuoffscreen, true); else @@ -1463,8 +1463,9 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h, void ED_view3d_backbuf_validate(ViewContext *vc) { - if (vc->v3d->flag & V3D_INVALID_BACKBUF) - backdrawview3d(vc->scene, vc->win, vc->ar, vc->v3d); + if (vc->v3d->flag & V3D_INVALID_BACKBUF) { + backdrawview3d(vc->scene, vc->win, vc->ar, vc->v3d, vc->obact, vc->obedit); + } } /** -- cgit v1.2.3