Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_legacy.c24
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c125
-rw-r--r--source/blender/blenkernel/intern/armature.c36
-rw-r--r--source/blender/blenkernel/intern/blender.c1
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c2
-rw-r--r--source/blender/blenkernel/intern/blendfile.c75
-rw-r--r--source/blender/blenkernel/intern/brush.c33
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/collection.c8
-rw-r--r--source/blender/blenkernel/intern/collision.c8
-rw-r--r--source/blender/blenkernel/intern/colortools.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/context.c15
-rw-r--r--source/blender/blenkernel/intern/curve.c26
-rw-r--r--source/blender/blenkernel/intern/customdata.c3
-rw-r--r--source/blender/blenkernel/intern/displist.c4
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c118
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenkernel/intern/font.c4
-rw-r--r--source/blender/blenkernel/intern/gpencil.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c2
-rw-r--r--source/blender/blenkernel/intern/idcode.c4
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/lattice.c4
-rw-r--r--source/blender/blenkernel/intern/layer.c2
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/library_idmap.c2
-rw-r--r--source/blender/blenkernel/intern/library_query.c2
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c4
-rw-r--r--source/blender/blenkernel/intern/material.c148
-rw-r--r--source/blender/blenkernel/intern/mesh.c71
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c8
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c2
-rw-r--r--source/blender/blenkernel/intern/modifier.c2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c24
-rw-r--r--source/blender/blenkernel/intern/multires.c4
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c4
-rw-r--r--source/blender/blenkernel/intern/object.c25
-rw-r--r--source/blender/blenkernel/intern/ocean.c4
-rw-r--r--source/blender/blenkernel/intern/paint_toolslots.c20
-rw-r--r--source/blender/blenkernel/intern/particle.c6
-rw-r--r--source/blender/blenkernel/intern/particle_system.c21
-rw-r--r--source/blender/blenkernel/intern/pbvh.c10
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenkernel/intern/sequencer.c9
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c12
-rw-r--r--source/blender/blenkernel/intern/smoke.c18
-rw-r--r--source/blender/blenkernel/intern/softbody.c15
-rw-r--r--source/blender/blenkernel/intern/sound.c4
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c30
-rw-r--r--source/blender/blenkernel/intern/subdiv_foreach.c14
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c23
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c4
-rw-r--r--source/blender/blenkernel/intern/text.c17
-rw-r--r--source/blender/blenkernel/intern/tracking_auto.c8
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c23
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c17
-rw-r--r--source/blender/blenkernel/intern/undo_system.c181
-rw-r--r--source/blender/blenkernel/intern/unit.c17
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c157
61 files changed, 819 insertions, 619 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
index 720c828664a..d8b30c9d4ef 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
@@ -135,7 +135,7 @@ typedef struct CCGSubSurfCalcSubdivData {
} CCGSubSurfCalcSubdivData;
static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -234,7 +234,7 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(
}
static void ccgSubSurf__calcVertNormals_faces_finalize_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -273,7 +273,7 @@ static void ccgSubSurf__calcVertNormals_faces_finalize_cb(
}
static void ccgSubSurf__calcVertNormals_edges_accumulate_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -347,7 +347,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
};
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(
@@ -379,7 +379,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(
@@ -387,7 +387,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(
@@ -425,7 +425,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
}
static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -513,7 +513,7 @@ static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(
}
static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -619,7 +619,7 @@ static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_
}
static void ccgSubSurf__calcSubdivLevel_verts_copydata_cb(
- void *__restrict userdata, const int ptrIdx, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ptrIdx, const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGSubSurfCalcSubdivData *data = userdata;
@@ -691,7 +691,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
};
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(0,
@@ -991,7 +991,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(0,
@@ -1012,7 +1012,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
BLI_task_parallel_range(
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index a7159f85dc2..984de700ce7 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1612,6 +1612,6 @@ void what_does_obaction(
adt.action = act;
/* execute effects of Action on to workob (or it's PoseChannels) */
- BKE_animsys_evaluate_animdata(NULL, NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM, false);
}
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 08faae9874b..26a2018f015 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -330,7 +330,7 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
/**
* \param flag: Control ID pointers management,
* see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
- * \return true is succesfully copied.
+ * \return true is successfully copied.
*/
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag)
{
@@ -1882,12 +1882,11 @@ static void animsys_write_orig_anim_rna(PointerRNA *ptr,
* This performs a set of standard checks. If extra checks are required,
* separate code should be used.
*/
-static void animsys_evaluate_fcurves(Depsgraph *depsgraph,
- PointerRNA *ptr,
+static void animsys_evaluate_fcurves(PointerRNA *ptr,
ListBase *list,
- float ctime)
+ float ctime,
+ bool flush_to_original)
{
- const bool is_active_depsgraph = DEG_is_active(depsgraph);
/* Calculate then execute each curve. */
for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
/* Check if this F-Curve doesn't belong to a muted group. */
@@ -1906,7 +1905,7 @@ static void animsys_evaluate_fcurves(Depsgraph *depsgraph,
if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
animsys_write_rna_setting(&anim_rna, curval);
- if (is_active_depsgraph) {
+ if (flush_to_original) {
animsys_write_orig_anim_rna(ptr, fcu->rna_path, fcu->array_index, curval);
}
}
@@ -2025,10 +2024,10 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
}
/* Evaluate Action (F-Curve Bag) */
-static void animsys_evaluate_action_ex(Depsgraph *depsgraph,
- PointerRNA *ptr,
+static void animsys_evaluate_action_ex(PointerRNA *ptr,
bAction *act,
- float ctime)
+ float ctime,
+ const bool flush_to_original)
{
/* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
if (act == NULL) {
@@ -2038,12 +2037,15 @@ static void animsys_evaluate_action_ex(Depsgraph *depsgraph,
action_idcode_patch_check(ptr->id.data, act);
/* calculate then execute each curve */
- animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, ctime);
+ animsys_evaluate_fcurves(ptr, &act->curves, ctime, flush_to_original);
}
-void animsys_evaluate_action(Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, float ctime)
+void animsys_evaluate_action(PointerRNA *ptr,
+ bAction *act,
+ float ctime,
+ const bool flush_to_original)
{
- animsys_evaluate_action_ex(depsgraph, ptr, act, ctime);
+ animsys_evaluate_action_ex(ptr, act, ctime, flush_to_original);
}
/* ***************************************** */
@@ -2072,7 +2074,7 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe)
}
/* evaluate the evaluation time and influence for the strip, storing the results in the strip */
-static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, float ctime)
+static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime, const bool flush_to_original)
{
/* now strip's evaluate F-Curves for these settings (if applicable) */
if (strip->fcurves.first) {
@@ -2082,7 +2084,7 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
/* execute these settings as per normal */
- animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, ctime);
+ animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, ctime, flush_to_original);
}
/* analytically generate values for influence and time (if applicable)
@@ -2115,7 +2117,7 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
/* gets the strip active at the current time for a list of strips for evaluation purposes */
NlaEvalStrip *nlastrips_ctime_get_strip(
- Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime)
+ ListBase *list, ListBase *strips, short index, float ctime, const bool flush_to_original)
{
NlaStrip *strip, *estrip = NULL;
NlaEvalStrip *nes;
@@ -2198,7 +2200,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
*/
/* TODO: this sounds a bit hacky having a few isolated F-Curves
* stuck on some data it operates on... */
- nlastrip_evaluate_controls(depsgraph, estrip, ctime);
+ nlastrip_evaluate_controls(estrip, ctime, flush_to_original);
if (estrip->influence <= 0.0f) {
return NULL;
}
@@ -2220,8 +2222,8 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
}
/* evaluate controls for the relevant extents of the bordering strips... */
- nlastrip_evaluate_controls(depsgraph, estrip->prev, estrip->start);
- nlastrip_evaluate_controls(depsgraph, estrip->next, estrip->end);
+ nlastrip_evaluate_controls(estrip->prev, estrip->start, flush_to_original);
+ nlastrip_evaluate_controls(estrip->next, estrip->end, flush_to_original);
break;
}
@@ -3141,12 +3143,12 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
}
/* evaluate transition strip */
-static void nlastrip_evaluate_transition(Depsgraph *depsgraph,
- PointerRNA *ptr,
+static void nlastrip_evaluate_transition(PointerRNA *ptr,
NlaEvalData *channels,
ListBase *modifiers,
NlaEvalStrip *nes,
- NlaEvalSnapshot *snapshot)
+ NlaEvalSnapshot *snapshot,
+ const bool flush_to_original)
{
ListBase tmp_modifiers = {NULL, NULL};
NlaEvalSnapshot snapshot1, snapshot2;
@@ -3187,13 +3189,13 @@ static void nlastrip_evaluate_transition(Depsgraph *depsgraph,
tmp_nes.strip_mode = NES_TIME_TRANSITION_START;
tmp_nes.strip = s1;
nlaeval_snapshot_init(&snapshot1, channels, snapshot);
- nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot1);
+ nlastrip_evaluate(ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot1, flush_to_original);
/* second strip */
tmp_nes.strip_mode = NES_TIME_TRANSITION_END;
tmp_nes.strip = s2;
nlaeval_snapshot_init(&snapshot2, channels, snapshot);
- nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2);
+ nlastrip_evaluate(ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2, flush_to_original);
/* accumulate temp-buffer and full-buffer, using the 'real' strip */
nlaeval_snapshot_mix_and_free(channels, snapshot, &snapshot1, &snapshot2, nes->strip_time);
@@ -3203,12 +3205,12 @@ static void nlastrip_evaluate_transition(Depsgraph *depsgraph,
}
/* evaluate meta-strip */
-static void nlastrip_evaluate_meta(Depsgraph *depsgraph,
- PointerRNA *ptr,
+static void nlastrip_evaluate_meta(PointerRNA *ptr,
NlaEvalData *channels,
ListBase *modifiers,
NlaEvalStrip *nes,
- NlaEvalSnapshot *snapshot)
+ NlaEvalSnapshot *snapshot,
+ const bool flush_to_original)
{
ListBase tmp_modifiers = {NULL, NULL};
NlaStrip *strip = nes->strip;
@@ -3228,13 +3230,13 @@ static void nlastrip_evaluate_meta(Depsgraph *depsgraph,
/* find the child-strip to evaluate */
evaltime = (nes->strip_time * (strip->end - strip->start)) + strip->start;
- tmp_nes = nlastrips_ctime_get_strip(depsgraph, NULL, &strip->strips, -1, evaltime);
+ tmp_nes = nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime, flush_to_original);
/* directly evaluate child strip into accumulation buffer...
* - there's no need to use a temporary buffer (as it causes issues [T40082])
*/
if (tmp_nes) {
- nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, tmp_nes, snapshot);
+ nlastrip_evaluate(ptr, channels, &tmp_modifiers, tmp_nes, snapshot, flush_to_original);
/* free temp eval-strip */
MEM_freeN(tmp_nes);
@@ -3245,12 +3247,12 @@ static void nlastrip_evaluate_meta(Depsgraph *depsgraph,
}
/* evaluates the given evaluation strip */
-void nlastrip_evaluate(Depsgraph *depsgraph,
- PointerRNA *ptr,
+void nlastrip_evaluate(PointerRNA *ptr,
NlaEvalData *channels,
ListBase *modifiers,
NlaEvalStrip *nes,
- NlaEvalSnapshot *snapshot)
+ NlaEvalSnapshot *snapshot,
+ const bool flush_to_original)
{
NlaStrip *strip = nes->strip;
@@ -3272,10 +3274,10 @@ void nlastrip_evaluate(Depsgraph *depsgraph,
nlastrip_evaluate_actionclip(ptr, channels, modifiers, nes, snapshot);
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
- nlastrip_evaluate_transition(depsgraph, ptr, channels, modifiers, nes, snapshot);
+ nlastrip_evaluate_transition(ptr, channels, modifiers, nes, snapshot, flush_to_original);
break;
case NLASTRIP_TYPE_META: /* meta */
- nlastrip_evaluate_meta(depsgraph, ptr, channels, modifiers, nes, snapshot);
+ nlastrip_evaluate_meta(ptr, channels, modifiers, nes, snapshot, flush_to_original);
break;
default: /* do nothing */
@@ -3287,18 +3289,16 @@ void nlastrip_evaluate(Depsgraph *depsgraph,
}
/* write the accumulated settings to */
-void nladata_flush_channels(Depsgraph *depsgraph,
- PointerRNA *ptr,
+void nladata_flush_channels(PointerRNA *ptr,
NlaEvalData *channels,
- NlaEvalSnapshot *snapshot)
+ NlaEvalSnapshot *snapshot,
+ const bool flush_to_original)
{
/* sanity checks */
if (channels == NULL) {
return;
}
- const bool is_active_depsgraph = DEG_is_active(depsgraph);
-
/* for each channel with accumulated values, write its value on the property it affects */
for (NlaEvalChannel *nec = channels->channels.first; nec; nec = nec->next) {
NlaEvalChannelSnapshot *nec_snapshot = nlaeval_snapshot_find_channel(snapshot, nec);
@@ -3312,7 +3312,7 @@ void nladata_flush_channels(Depsgraph *depsgraph,
rna.prop_index = i;
}
animsys_write_rna_setting(&rna, value);
- if (is_active_depsgraph) {
+ if (flush_to_original) {
animsys_write_orig_anim_rna(ptr, nec->rna_path, rna.prop_index, value);
}
}
@@ -3422,11 +3422,11 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels,
* data about the currently edited strip is stored here and excluded from value calculation.
* \return false if NLA evaluation isn't actually applicable.
*/
-static bool animsys_evaluate_nla(Depsgraph *depsgraph,
- NlaEvalData *echannels,
+static bool animsys_evaluate_nla(NlaEvalData *echannels,
PointerRNA *ptr,
AnimData *adt,
float ctime,
+ const bool flush_to_original,
NlaKeyframingContext *r_context)
{
NlaTrack *nlt;
@@ -3473,7 +3473,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
}
/* otherwise, get strip to evaluate for this channel */
- nes = nlastrips_ctime_get_strip(depsgraph, &estrips, &nlt->strips, track_index, ctime);
+ nes = nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime, flush_to_original);
if (nes) {
nes->track = nlt;
}
@@ -3539,7 +3539,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* add this to our list of evaluation strips */
if (r_context == NULL) {
- nlastrips_ctime_get_strip(depsgraph, &estrips, &dummy_trackslist, -1, ctime);
+ nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime, flush_to_original);
}
/* If computing the context for keyframing, store data there instead of the list. */
else {
@@ -3549,7 +3549,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
NLASTRIP_EXTEND_HOLD;
r_context->eval_strip = nes = nlastrips_ctime_get_strip(
- depsgraph, NULL, &dummy_trackslist, -1, ctime);
+ NULL, &dummy_trackslist, -1, ctime, flush_to_original);
/* These setting combinations require no data from strips below, so exit immediately. */
if ((nes == NULL) ||
@@ -3574,7 +3574,7 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* 2. for each strip, evaluate then accumulate on top of existing channels,
* but don't set values yet. */
for (nes = estrips.first; nes; nes = nes->next) {
- nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes, &echannels->eval_snapshot);
+ nlastrip_evaluate(ptr, echannels, NULL, nes, &echannels->eval_snapshot, flush_to_original);
}
/* 3. free temporary evaluation data that's not used elsewhere */
@@ -3586,22 +3586,22 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
* - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
* some temp channels, where values can be accumulated in one go.
*/
-static void animsys_calculate_nla(Depsgraph *depsgraph,
- PointerRNA *ptr,
+static void animsys_calculate_nla(PointerRNA *ptr,
AnimData *adt,
- float ctime)
+ float ctime,
+ const bool flush_to_original)
{
NlaEvalData echannels;
nlaeval_init(&echannels);
/* evaluate the NLA stack, obtaining a set of values to flush */
- if (animsys_evaluate_nla(depsgraph, &echannels, ptr, adt, ctime, NULL)) {
+ if (animsys_evaluate_nla(&echannels, ptr, adt, ctime, flush_to_original, NULL)) {
/* reset any channels touched by currently inactive actions to default value */
animsys_evaluate_nla_domain(ptr, &echannels, adt);
/* flush effects of accumulating channels in NLA to the actual data they affect */
- nladata_flush_channels(depsgraph, ptr, &echannels, &echannels.eval_snapshot);
+ nladata_flush_channels(ptr, &echannels, &echannels.eval_snapshot, flush_to_original);
}
else {
/* special case - evaluate as if there isn't any NLA data */
@@ -3610,7 +3610,7 @@ static void animsys_calculate_nla(Depsgraph *depsgraph,
CLOG_WARN(&LOG, "NLA Eval: Stopgap for active action on NLA Stack - no strips case");
}
- animsys_evaluate_action(depsgraph, ptr, adt->action, ctime);
+ animsys_evaluate_action(ptr, adt->action, ctime, flush_to_original);
}
/* free temp data */
@@ -3629,10 +3629,10 @@ static void animsys_calculate_nla(Depsgraph *depsgraph,
* \return Keyframing context, or NULL if not necessary.
*/
NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *cache,
- struct Depsgraph *depsgraph,
struct PointerRNA *ptr,
struct AnimData *adt,
- float ctime)
+ float ctime,
+ const bool flush_to_original)
{
/* No remapping needed if NLA is off or no action. */
if ((adt == NULL) || (adt->action == NULL) || (adt->nla_tracks.first == NULL) ||
@@ -3655,7 +3655,7 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *ca
ctx->adt = adt;
nlaeval_init(&ctx->nla_channels);
- animsys_evaluate_nla(depsgraph, &ctx->nla_channels, ptr, adt, ctime, ctx);
+ animsys_evaluate_nla(&ctx->nla_channels, ptr, adt, ctime, flush_to_original, ctx);
BLI_assert(ELEM(ctx->strip.act, NULL, adt->action));
BLI_addtail(cache, ctx);
@@ -3846,7 +3846,7 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
* have been set already by the depsgraph. Now, we use the recalc
*/
void BKE_animsys_evaluate_animdata(
- Depsgraph *depsgraph, Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
+ Scene *scene, ID *id, AnimData *adt, float ctime, short recalc, const bool flush_to_original)
{
PointerRNA id_ptr;
@@ -3869,11 +3869,11 @@ void BKE_animsys_evaluate_animdata(
/* evaluate NLA-stack
* - active action is evaluated as part of the NLA stack as the last item
*/
- animsys_calculate_nla(depsgraph, &id_ptr, adt, ctime);
+ animsys_calculate_nla(&id_ptr, adt, ctime, flush_to_original);
}
/* evaluate Active Action only */
else if (adt->action) {
- animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, ctime);
+ animsys_evaluate_action_ex(&id_ptr, adt->action, ctime, flush_to_original);
}
}
@@ -3920,6 +3920,8 @@ void BKE_animsys_evaluate_all_animation(Main *main,
printf("Evaluate all animation - %f\n", ctime);
}
+ const bool flush_to_original = DEG_is_active(depsgraph);
+
/* macros for less typing
* - only evaluate animation data for id if it has users (and not just fake ones)
* - whether animdata exists is checked for by the evaluation function, though taking
@@ -3929,7 +3931,7 @@ void BKE_animsys_evaluate_all_animation(Main *main,
for (id = first; id; id = id->next) { \
if (ID_REAL_USERS(id) > 0) { \
AnimData *adt = BKE_animdata_from_id(id); \
- BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \
+ BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag, flush_to_original); \
} \
} \
(void)0
@@ -3948,9 +3950,9 @@ void BKE_animsys_evaluate_all_animation(Main *main,
if (ntp->nodetree) { \
AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
BKE_animsys_evaluate_animdata( \
- depsgraph, scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
+ scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM, flush_to_original); \
} \
- BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \
+ BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag, flush_to_original); \
} \
} \
(void)0
@@ -4055,7 +4057,8 @@ void BKE_animsys_eval_animdata(Depsgraph *depsgraph, ID *id)
* which should get handled as part of the dependency graph instead. */
Scene *scene = NULL;
DEG_debug_print_eval_time(depsgraph, __func__, id->name, id, ctime);
- BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, ADT_RECALC_ANIM);
+ const bool flush_to_original = DEG_is_active(depsgraph);
+ BKE_animsys_evaluate_animdata(scene, id, adt, ctime, ADT_RECALC_ANIM, flush_to_original);
}
void BKE_animsys_update_driver_array(ID *id)
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index c36acd1eae1..742e3634bf1 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -239,6 +239,35 @@ bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
return arm_copy;
}
+static void copy_bone_transform(Bone *bone_dst, const Bone *bone_src)
+{
+ bone_dst->roll = bone_src->roll;
+
+ copy_v3_v3(bone_dst->head, bone_src->head);
+ copy_v3_v3(bone_dst->tail, bone_src->tail);
+
+ copy_m3_m3(bone_dst->bone_mat, bone_src->bone_mat);
+
+ copy_v3_v3(bone_dst->arm_head, bone_src->arm_head);
+ copy_v3_v3(bone_dst->arm_tail, bone_src->arm_tail);
+
+ copy_m4_m4(bone_dst->arm_mat, bone_src->arm_mat);
+
+ bone_dst->arm_roll = bone_src->arm_roll;
+}
+
+void BKE_armature_copy_bone_transforms(bArmature *armature_dst, const bArmature *armature_src)
+{
+ Bone *bone_dst = armature_dst->bonebase.first;
+ const Bone *bone_src = armature_src->bonebase.first;
+ while (bone_dst != NULL) {
+ BLI_assert(bone_src != NULL);
+ copy_bone_transform(bone_dst, bone_src);
+ bone_dst = bone_dst->next;
+ bone_src = bone_src->next;
+ }
+}
+
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
{
Bone *curBone, *rbone;
@@ -1350,7 +1379,7 @@ typedef struct ArmatureUserdata {
static void armature_vert_task(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const ArmatureUserdata *data = userdata;
float(*const vertexCos)[3] = data->vertexCos;
@@ -1648,7 +1677,7 @@ void armature_deform_verts(Object *armOb,
mul_m4_m4m4(data.postmat, obinv, armOb->obmat);
invert_m4_m4(data.premat, data.postmat);
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = 32;
BLI_task_parallel_range(0, numVerts, &data, armature_vert_task, &settings);
@@ -2374,6 +2403,9 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
pchanw.mpath = pchan->mpath;
pchan->mpath = NULL;
+ /* Reset runtime data, we don't want to share that with the proxy. */
+ BKE_pose_channel_runtime_reset(&pchanw.runtime);
+
/* this is freed so copy a copy, else undo crashes */
if (pchanw.prop) {
pchanw.prop = IDP_CopyProperty(pchanw.prop);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 9fd3c24092c..805c098d238 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -306,6 +306,7 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
LIST_SWAP(themes);
LIST_SWAP(addons);
LIST_SWAP(user_keymaps);
+ LIST_SWAP(user_keyconfig_prefs);
DATA_SWAP(font_path_ui);
DATA_SWAP(font_path_ui_mono);
diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c
index 6c077ac75ba..7c12747283c 100644
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@ -73,7 +73,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C)
G.fileflags |= G_FILE_NO_UI;
if (UNDO_DISK) {
- success = (BKE_blendfile_read(C, mfu->filename, NULL, 0) != BKE_BLENDFILE_READ_FAIL);
+ success = BKE_blendfile_read(C, mfu->filename, NULL, 0);
}
else {
success = BKE_blendfile_read_from_memfile(
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index afbd2627a2a..bc62ad685ef 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -32,25 +32,30 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_system.h"
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
#include "IMB_colormanagement.h"
+#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_blender_version.h"
#include "BKE_blendfile.h"
#include "BKE_bpath.h"
+#include "BKE_colorband.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_ipo.h"
+#include "BKE_keyconfig.h"
#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
+#include "BKE_studiolight.h"
#include "BKE_workspace.h"
#include "BLO_readfile.h"
@@ -405,35 +410,31 @@ int BKE_blendfile_read(bContext *C,
ReportList *reports)
{
BlendFileData *bfd;
- int retval = BKE_BLENDFILE_READ_OK;
+ bool success = false;
- /* don't print user-pref loading */
- if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) {
+ /* Don't print startup file loading. */
+ if (params->is_startup == false) {
printf("Read blend: %s\n", filepath);
}
bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
if (bfd) {
- if (bfd->user) {
- retval = BKE_BLENDFILE_READ_OK_USERPREFS;
- }
-
if (0 == handle_subversion_warning(bfd->main, reports)) {
BKE_main_free(bfd->main);
MEM_freeN(bfd);
bfd = NULL;
- retval = BKE_BLENDFILE_READ_FAIL;
}
else {
setup_app_blend_file_data(C, bfd, filepath, params, reports);
BLO_blendfiledata_free(bfd);
+ success = true;
}
}
else {
BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
}
- return (bfd ? retval : BKE_BLENDFILE_READ_FAIL);
+ return success;
}
bool BKE_blendfile_read_from_memory(bContext *C,
@@ -556,6 +557,62 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
return userdef;
}
+UserDef *BKE_blendfile_userdef_from_defaults(void)
+{
+ UserDef *userdef = MEM_mallocN(sizeof(*userdef), __func__);
+ memcpy(userdef, &U_default, sizeof(*userdef));
+
+ /* Add-ons. */
+ {
+ const char *addons[] = {
+ "io_anim_bvh",
+ "io_curve_svg",
+ "io_mesh_ply",
+ "io_mesh_stl",
+ "io_mesh_uv_layout",
+ "io_scene_fbx",
+ "io_scene_gltf2",
+ "io_scene_obj",
+ "io_scene_x3d",
+ };
+ for (int i = 0; i < ARRAY_SIZE(addons); i++) {
+ bAddon *addon = BKE_addon_new();
+ STRNCPY(addon->module, addons[i]);
+ BLI_addtail(&userdef->addons, addon);
+ }
+ }
+
+ /* Theme. */
+ {
+ bTheme *btheme = MEM_mallocN(sizeof(*btheme), __func__);
+ memcpy(btheme, &U_theme_default, sizeof(*btheme));
+
+ BLI_addtail(&userdef->themes, btheme);
+ }
+
+#ifdef WITH_PYTHON_SECURITY
+ /* use alternative setting for security nuts
+ * otherwise we'd need to patch the binary blob - startup.blend.c */
+ userdef->flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
+#else
+ userdef->flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
+#endif
+
+ /* System-specific fonts directory. */
+ BKE_appdir_font_folder_default(userdef->fontdir);
+
+ userdef->memcachelimit = min_ii(BLI_system_memory_max_in_megabytes_int() / 2,
+ userdef->memcachelimit);
+
+ /* Init weight paint range. */
+ BKE_colorband_init(&userdef->coba_weight, true);
+
+ /* Default studio light. */
+ BKE_studiolight_default(userdef->light_param, userdef->light_ambient);
+
+ return userdef;
+}
+
/**
* Only write the userdef in a .blend
* \return success
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ec9a774a65c..709f74808a3 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1400,16 +1400,45 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
/* Uses the brush curve control to find a strength value */
float BKE_brush_curve_strength(const Brush *br, float p, const float len)
{
- float strength;
+ float strength = 1.0f;
if (p >= len) {
return 0;
}
else {
p = p / len;
+ p = 1.0f - p;
}
- strength = curvemapping_evaluateF(br->curve, 0, p);
+ switch (br->curve_preset) {
+ case BRUSH_CURVE_CUSTOM:
+ strength = curvemapping_evaluateF(br->curve, 0, 1.0f - p);
+ break;
+ case BRUSH_CURVE_SHARP:
+ strength = p * p;
+ break;
+ case BRUSH_CURVE_SMOOTH:
+ strength = 3.0f * p * p - 2.0f * p * p * p;
+ break;
+ case BRUSH_CURVE_ROOT:
+ strength = sqrtf(p);
+ break;
+ case BRUSH_CURVE_LIN:
+ strength = p;
+ break;
+ case BRUSH_CURVE_CONSTANT:
+ strength = 1.0f;
+ break;
+ case BRUSH_CURVE_SPHERE:
+ strength = sqrtf(2 * p - p * p);
+ break;
+ case BRUSH_CURVE_POW4:
+ strength = p * p * p * p;
+ break;
+ case BRUSH_CURVE_INVSQUARE:
+ strength = p * (2.0f - p);
+ break;
+ }
return strength;
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index a8f38c3c4ce..a563a8d581c 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -375,7 +375,7 @@ void BKE_camera_view_frame_ex(const Scene *scene,
float facx, facy;
float depth;
- /* aspect correcton */
+ /* aspect correction */
if (scene) {
float aspx = (float)scene->r.xsch * scene->r.xasp;
float aspy = (float)scene->r.ysch * scene->r.yasp;
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 965f6e4bc51..25f2797915a 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1100,7 +1100,7 @@ void BKE_collection_parent_relations_rebuild(Collection *collection)
static void collection_parents_rebuild_recursive(Collection *collection)
{
BKE_collection_parent_relations_rebuild(collection);
- collection->id.tag &= ~LIB_TAG_DOIT;
+ collection->tag &= ~COLLECTION_TAG_RELATION_REBUILD;
for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) {
collection_parents_rebuild_recursive(child->collection);
@@ -1109,8 +1109,6 @@ static void collection_parents_rebuild_recursive(Collection *collection)
/**
* Rebuild parent relationships from child ones, for all collections in given \a bmain.
- *
- * \note Uses LIB_TAG_DOIT internally...
*/
void BKE_main_collections_parent_relations_rebuild(Main *bmain)
{
@@ -1119,7 +1117,7 @@ void BKE_main_collections_parent_relations_rebuild(Main *bmain)
collection = collection->id.next) {
BLI_freelistN(&collection->parents);
- collection->id.tag |= LIB_TAG_DOIT;
+ collection->tag |= COLLECTION_TAG_RELATION_REBUILD;
}
/* Scene's master collections will be 'root' parent of most of our collections, so start with
@@ -1132,7 +1130,7 @@ void BKE_main_collections_parent_relations_rebuild(Main *bmain)
* lib_link_collection_data() seems to assume that, so do the same here. */
for (Collection *collection = bmain->collections.first; collection != NULL;
collection = collection->id.next) {
- if (collection->id.tag & LIB_TAG_DOIT) {
+ if (collection->tag & COLLECTION_TAG_RELATION_REBUILD) {
/* Note: we do not have easy access to 'which collections is root' info in that case, which
* means test for cycles in collection relationships may fail here. I don't think that is an
* issue in practice here, but worth keeping in mind... */
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index ff6258ac339..69afda9997a 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -851,7 +851,7 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
static void cloth_collision(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
ColDetectData *data = (ColDetectData *)userdata;
@@ -908,7 +908,7 @@ static void cloth_collision(void *__restrict userdata,
static void cloth_selfcollision(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
SelfColDetectData *data = (SelfColDetectData *)userdata;
@@ -1154,7 +1154,7 @@ static bool cloth_bvh_objcollisions_nearcheck(ClothModifierData *clmd,
.collided = false,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = true;
BLI_task_parallel_range(0, numresult, &data, cloth_collision, &settings);
@@ -1174,7 +1174,7 @@ static bool cloth_bvh_selfcollisions_nearcheck(ClothModifierData *clmd,
.collided = false,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = true;
BLI_task_parallel_range(0, numresult, &data, cloth_selfcollision, &settings);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 863d6351738..aa5f74c6297 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1385,7 +1385,7 @@ typedef struct ScopesUpdateDataChunk {
static void scopes_update_cb(void *__restrict userdata,
const int y,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
const ScopesUpdateData *data = userdata;
@@ -1634,7 +1634,7 @@ void scopes_update(Scopes *scopes,
ScopesUpdateDataChunk data_chunk = {{0}};
INIT_MINMAX(data_chunk.min, data_chunk.max);
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (ibuf->y > 256);
settings.userdata_chunk = &data_chunk;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 793dc910394..e1e4d138fd9 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -5273,7 +5273,7 @@ static void constraint_copy_data_ex(bConstraint *dst,
}
}
-/** Allocate and duplicate a single constraint, ouside of any object/pose context. */
+/** Allocate and duplicate a single constraint, outside of any object/pose context. */
bConstraint *BKE_constraint_duplicate_ex(bConstraint *src, const int flag, const bool do_extern)
{
bConstraint *dst = MEM_dupallocN(src);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 4ae87713aa5..2cb98d8d90b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1348,7 +1348,7 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, "editable_gpencil_strokes", list);
}
-Depsgraph *CTX_data_depsgraph(const bContext *C)
+Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1361,9 +1361,18 @@ Depsgraph *CTX_data_depsgraph(const bContext *C)
return depsgraph;
}
-Depsgraph *CTX_data_evaluated_depsgraph(const bContext *C)
+Depsgraph *CTX_data_expect_evaluated_depsgraph(const bContext *C)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ /* TODO(sergey): Assert that the dependency graph is fully evaluated.
+ * Note that first the depsgraph and scene post-eval hooks needs to run extra round of updates
+ * first to make check here really reliable. */
+ return depsgraph;
+}
+
+Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Main *bmain = CTX_data_main(C);
BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
return depsgraph;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 931c0ed73d3..efdfa2c19bb 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -5313,6 +5313,32 @@ void BKE_curve_material_index_remove(Curve *cu, int index)
}
}
+bool BKE_curve_material_index_used(Curve *cu, int index)
+{
+ const int curvetype = BKE_curve_type_get(cu);
+
+ if (curvetype == OB_FONT) {
+ struct CharInfo *info = cu->strinfo;
+ int i;
+ for (i = cu->len_wchar - 1; i >= 0; i--, info++) {
+ if (info->mat_nr == index) {
+ return true;
+ }
+ }
+ }
+ else {
+ Nurb *nu;
+
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu->mat_nr == index) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void BKE_curve_material_index_clear(Curve *cu)
{
const int curvetype = BKE_curve_type_get(cu);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 1fb29745dba..3c7ac5d8d2e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -4756,7 +4756,8 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap,
for (i = 0; i < totelem; i++, data_dst = POINTER_OFFSET(data_dst, data_step), mapit++) {
const int sources_num = mapit->sources_num;
- const float mix_factor = laymap->mix_weights ? laymap->mix_weights[i] : laymap->mix_factor;
+ const float mix_factor = laymap->mix_factor *
+ (laymap->mix_weights ? laymap->mix_weights[i] : 1.0f);
int j;
if (!sources_num) {
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index cf6f1fdeec1..83a10344b96 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -477,7 +477,7 @@ static void curve_to_displist(Curve *cu,
}
/**
- * \param normal_proj: Optional normal thats used to project the scanfill verts into 2d coords.
+ * \param normal_proj: Optional normal that's used to project the scanfill verts into 2d coords.
* Pass this along if known since it saves time calculating the normal.
* \param flipnormal: Flip the normal (same as passing \a normal_proj negated)
*/
@@ -1857,7 +1857,7 @@ void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
}
}
-/* this is confusing, there's also min_max_object, appplying the obmat... */
+/* this is confusing, there's also min_max_object, applying the obmat... */
static void boundbox_displist_object(Object *ob)
{
if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7e916feac24..03530fc76b6 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -645,7 +645,7 @@ static void freeGrid(PaintSurfaceData *data)
static void grid_bound_insert_cb_ex(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
PaintBakeData *bData = userdata;
@@ -667,7 +667,7 @@ static void grid_bound_insert_finalize(void *__restrict userdata, void *__restri
static void grid_cell_points_cb_ex(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
PaintBakeData *bData = userdata;
VolumeGrid *grid = bData->grid;
@@ -702,7 +702,7 @@ static void grid_cell_points_finalize(void *__restrict userdata, void *__restric
static void grid_cell_bounds_cb(void *__restrict userdata,
const int x,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
PaintBakeData *bData = userdata;
VolumeGrid *grid = bData->grid;
@@ -749,7 +749,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
/* Important to init correctly our ref grid_bound... */
boundInsert(&grid->grid_bounds, bData->realCoord[bData->s_pos[0]].v);
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
settings.userdata_chunk = &grid->grid_bounds;
@@ -810,7 +810,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
if (!error) {
/* calculate number of points within each cell */
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
settings.userdata_chunk = grid->s_num;
@@ -834,7 +834,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
/* calculate cell bounds */
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (grid_cells > 1000);
BLI_task_parallel_range(0, grid->dim[0], bData, grid_cell_bounds_cb, &settings);
@@ -1508,7 +1508,7 @@ typedef struct DynamicPaintSetInitColorData {
} DynamicPaintSetInitColorData;
static void dynamic_paint_set_init_color_tex_to_vcol_cb(
- void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintSetInitColorData *data = userdata;
@@ -1543,7 +1543,7 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(
}
static void dynamic_paint_set_init_color_tex_to_imseq_cb(
- void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintSetInitColorData *data = userdata;
@@ -1582,7 +1582,7 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(
}
static void dynamic_paint_set_init_color_vcol_to_imseq_cb(
- void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintSetInitColorData *data = userdata;
@@ -1667,7 +1667,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
.pool = pool,
.scene_color_manage = scene_color_manage,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (tottri > 1000);
BLI_task_parallel_range(
@@ -1681,7 +1681,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
.mloopuv = mloopuv,
.scene_color_manage = scene_color_manage,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -1718,7 +1718,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
.mlooptri = mlooptri,
.mloopcol = col,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -1820,7 +1820,7 @@ typedef struct DynamicPaintModifierApplyData {
static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
@@ -1854,7 +1854,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Mesh
.surface = surface,
.mvert = mvert,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 10000);
BLI_task_parallel_range(
@@ -1863,7 +1863,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Mesh
}
static void dynamic_paint_apply_surface_vpaint_blend_cb(
- void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
@@ -1877,7 +1877,7 @@ static void dynamic_paint_apply_surface_vpaint_blend_cb(
static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
const int p_index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
@@ -1913,7 +1913,7 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
static void dynamic_paint_apply_surface_wave_cb(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
@@ -1966,7 +1966,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
.fcolor = fcolor,
};
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(0,
@@ -2001,7 +2001,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
data.mloopcol_wet = mloopcol_wet;
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (totpoly > 1000);
BLI_task_parallel_range(
@@ -2053,7 +2053,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
.surface = surface,
.mvert = mvert,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -2236,7 +2236,7 @@ typedef struct DynamicPaintCreateUVSurfaceData {
} DynamicPaintCreateUVSurfaceData;
static void dynamic_paint_create_uv_surface_direct_cb(
- void *__restrict userdata, const int ty, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ty, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintCreateUVSurfaceData *data = userdata;
@@ -2330,7 +2330,7 @@ static void dynamic_paint_create_uv_surface_direct_cb(
}
static void dynamic_paint_create_uv_surface_neighbor_cb(
- void *__restrict userdata, const int ty, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int ty, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintCreateUVSurfaceData *data = userdata;
@@ -2739,7 +2739,7 @@ static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points)
int *new_n_num = MEM_callocN(sizeof(int) * active_points, "Surface Adj Counts");
if (new_n_num && new_n_index) {
- /* Count symmetrized neigbors */
+ /* Count symmetrized neighbors */
int total_targets = 0;
for (int index = 0; index < active_points; index++) {
@@ -2948,7 +2948,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
.faceBB = faceBB,
};
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (h > 64 || tottri > 1000);
BLI_task_parallel_range(0, h, &data, dynamic_paint_create_uv_surface_direct_cb, &settings);
@@ -2965,7 +2965,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
*/
data.active_points = &active_points;
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (h > 64);
BLI_task_parallel_range(0, h, &data, dynamic_paint_create_uv_surface_neighbor_cb, &settings);
@@ -3216,7 +3216,7 @@ typedef struct DynamicPaintOutputSurfaceImageData {
} DynamicPaintOutputSurfaceImageData;
static void dynamic_paint_output_surface_image_paint_cb(
- void *__restrict userdata, const int index, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintOutputSurfaceImageData *data = userdata;
@@ -3238,7 +3238,7 @@ static void dynamic_paint_output_surface_image_paint_cb(
}
static void dynamic_paint_output_surface_image_displace_cb(
- void *__restrict userdata, const int index, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintOutputSurfaceImageData *data = userdata;
@@ -3264,7 +3264,7 @@ static void dynamic_paint_output_surface_image_displace_cb(
}
static void dynamic_paint_output_surface_image_wave_cb(
- void *__restrict userdata, const int index, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintOutputSurfaceImageData *data = userdata;
@@ -3288,7 +3288,7 @@ static void dynamic_paint_output_surface_image_wave_cb(
}
static void dynamic_paint_output_surface_image_wetmap_cb(
- void *__restrict userdata, const int index, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintOutputSurfaceImageData *data = userdata;
@@ -3346,7 +3346,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
case MOD_DPAINT_SURFACE_T_PAINT:
switch (output_layer) {
case 0: {
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 10000);
BLI_task_parallel_range(0,
@@ -3357,7 +3357,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
break;
}
case 1: {
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 10000);
BLI_task_parallel_range(0,
@@ -3375,7 +3375,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
case MOD_DPAINT_SURFACE_T_DISPLACE:
switch (output_layer) {
case 0: {
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 10000);
BLI_task_parallel_range(0,
@@ -3395,7 +3395,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
case MOD_DPAINT_SURFACE_T_WAVE:
switch (output_layer) {
case 0: {
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 10000);
BLI_task_parallel_range(0,
@@ -3758,7 +3758,7 @@ typedef struct DynamicPaintBrushVelocityData {
static void dynamic_paint_brush_velocity_compute_cb(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintBrushVelocityData *data = userdata;
@@ -3857,7 +3857,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph,
.prev_obmat = prev_obmat,
.timescale = timescale,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (numOfVerts_c > 10000);
BLI_task_parallel_range(
@@ -3942,7 +3942,7 @@ typedef struct DynamicPaintPaintData {
* Paint a brush object mesh to the surface
*/
static void dynamic_paint_paint_mesh_cell_point_cb_ex(
- void *__restrict userdata, const int id, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int id, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintPaintData *data = userdata;
@@ -4365,7 +4365,7 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph,
.brushVelocity = brushVelocity,
.treeData = &treeData,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (grid->s_num[c_index] > 250);
BLI_task_parallel_range(0,
@@ -4393,7 +4393,7 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph,
* Paint a particle system to the surface
*/
static void dynamic_paint_paint_particle_cell_point_cb_ex(
- void *__restrict userdata, const int id, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int id, const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintPaintData *data = userdata;
@@ -4666,7 +4666,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
.c_index = c_index,
.treeData = tree,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (grid->s_num[c_index] > 250);
BLI_task_parallel_range(0,
@@ -4685,7 +4685,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
/* paint a single point of defined proximity radius to the surface */
static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintPaintData *data = userdata;
@@ -4808,7 +4808,7 @@ static int dynamicPaint_paintSinglePoint(Depsgraph *depsgraph,
.brushVelocity = &brushVel,
.pointCoord = pointCoord,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -4825,7 +4825,7 @@ static int dynamicPaint_paintSinglePoint(Depsgraph *depsgraph,
static void dynamic_paint_prepare_adjacency_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
PaintSurfaceData *sData = userdata;
PaintBakeData *bData = sData->bData;
@@ -4870,7 +4870,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
return;
}
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -5085,7 +5085,7 @@ typedef struct DynamicPaintEffectData {
*/
static void dynamic_paint_prepare_effect_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5167,7 +5167,7 @@ static int dynamicPaint_prepareEffectStep(struct Depsgraph *depsgraph,
.force = *force,
.effectors = effectors,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -5207,7 +5207,7 @@ static int dynamicPaint_prepareEffectStep(struct Depsgraph *depsgraph,
*/
static void dynamic_paint_effect_spread_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5266,7 +5266,7 @@ static void dynamic_paint_effect_spread_cb(void *__restrict userdata,
static void dynamic_paint_effect_shrink_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5327,7 +5327,7 @@ static void dynamic_paint_effect_shrink_cb(void *__restrict userdata,
static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5481,7 +5481,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface,
.prevPoint = prevPoint,
.eff_scale = eff_scale,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -5503,7 +5503,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface,
.prevPoint = prevPoint,
.eff_scale = eff_scale,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -5530,7 +5530,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface,
.force = force,
.point_locks = point_locks,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -5542,7 +5542,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface,
static void dynamic_paint_border_cb(void *__restrict userdata,
const int b_index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5613,7 +5613,7 @@ static void dynamicPaint_doBorderStep(DynamicPaintSurface *surface)
.surface = surface,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->adj_data->total_border > 1000);
BLI_task_parallel_range(
@@ -5622,7 +5622,7 @@ static void dynamicPaint_doBorderStep(DynamicPaintSurface *surface)
static void dynamic_paint_wave_step_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintEffectData *data = userdata;
@@ -5777,7 +5777,7 @@ static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescal
.damp_factor = damp_factor,
.reset_wave = (ss == steps - 1),
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(0, sData->total_points, &data, dynamic_paint_wave_step_cb, &settings);
@@ -5802,7 +5802,7 @@ typedef struct DynamicPaintDissolveDryData {
static void dynamic_paint_surface_pre_step_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintDissolveDryData *data = userdata;
@@ -5938,7 +5938,7 @@ typedef struct DynamicPaintGenerateBakeData {
static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const DynamicPaintGenerateBakeData *data = userdata;
@@ -6170,7 +6170,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface,
.do_velocity_data = do_velocity_data,
.new_bdata = new_bdata,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
@@ -6217,7 +6217,7 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
.surface = surface,
.timescale = timescale,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (sData->total_points > 1000);
BLI_task_parallel_range(
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 754b3f5876d..140d1f0d26c 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1113,7 +1113,7 @@ void calchandles_fcurve(FCurve *fcu)
first->f5 = last->f5 = HD_AUTOTYPE_SPECIAL;
}
- /* do a second pass for auto handle: compute the handle to have 0 accelaration step */
+ /* do a second pass for auto handle: compute the handle to have 0 acceleration step */
if (fcu->auto_smoothing != FCURVE_SMOOTH_NONE) {
BKE_nurb_handle_smooth_fcurve(fcu->bezt, fcu->totvert, cycle);
}
@@ -1744,7 +1744,7 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
/* ......... */
-/* Table of Driver Varaiable Type Info Data */
+/* Table of Driver Variable Type Info Data */
static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP) dvar_eval_singleProp, /* eval callback */
1, /* number of targets used */
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index a0216e9b413..78117a4f615 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1408,7 +1408,9 @@ static bool vfont_to_curve(Object *ob,
cha = towupper(cha);
}
- if (ob == NULL || info->mat_nr > (ob->totcol)) {
+ /* Only do that check in case we do have an object, otherwise all materials get erased every
+ * time that code is called without an object... */
+ if (ob != NULL && (info->mat_nr > (ob->totcol))) {
// CLOG_ERROR(
// &LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr);
info->mat_nr = 0;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 058c0d10b8e..133c6e7297b 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -414,7 +414,7 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
/* general flags */
gpd->flag |= GP_DATA_VIEWALIGN;
gpd->flag |= GP_DATA_STROKE_FORCE_RECALC;
- /* always enable object onion skin swith */
+ /* always enable object onion skin switch */
gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
/* GP object specific settings */
ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
@@ -1662,6 +1662,22 @@ void BKE_gpencil_material_index_reassign(bGPdata *gpd, int totcol, int index)
}
}
+/* remove strokes using a material */
+bool BKE_gpencil_material_index_used(bGPdata *gpd, int index)
+{
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ if (gps->mat_nr == index) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
void BKE_gpencil_material_remap(struct bGPdata *gpd,
const unsigned int *remap,
unsigned int remap_len)
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 7907be40984..34daba385f6 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -361,7 +361,7 @@ void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph,
if (mti && mti->deformStroke) {
mti->deformStroke(md, depsgraph, ob, gpl, gps);
- /* subdivide allways requires update */
+ /* subdivide always requires update */
if (md->type == eGpencilModifierType_Subdiv) {
gps->flag |= GP_STROKE_RECALC_GEOMETRY;
}
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 0a9178a8b6d..6b7cb181374 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -47,8 +47,8 @@ typedef struct {
/* Keep alignment for readability. */
/* clang-format off */
/**
- * When editing enusre that:
- * - Plural need to match rna_main.c's #MainCollectionDef.
+ * When editing ensure that:
+ * - Plural needs to match rna_main.c's #MainCollectionDef.
* - Keep it in sync with i18n contexts in BLT_translation.h
*/
static IDType idtypes[] = {
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index e03b61bfba1..adf5d55efaa 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1097,7 +1097,7 @@ static char *get_rna_access(ID *id,
BLI_dynstr_append(path, buf);
- /* need to add dot before property if there was anything precceding this */
+ /* need to add dot before property if there was anything preceding this */
if (buf[0]) {
BLI_dynstr_append(path, ".");
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index b8178bec52f..83b354ffb4a 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -889,7 +889,7 @@ typedef struct LatticeDeformUserdata {
static void lattice_deform_vert_task(void *__restrict userdata,
const int index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
const LatticeDeformUserdata *data = userdata;
@@ -948,7 +948,7 @@ void lattice_deform_verts(Object *laOb,
.defgrp_index = defgrp_index,
.fac = fac};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = 32;
BLI_task_parallel_range(0, numVerts, &data, lattice_deform_vert_task, &settings);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 7dc04214ba5..40608285785 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -797,7 +797,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
parent_restrict,
parent_layer_restrict);
- /* Any remaning object bases are to be removed. */
+ /* Any remaining object bases are to be removed. */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (view_layer->basact == base) {
view_layer->basact = NULL;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index b62ec88ed24..3f095d923b1 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1130,7 +1130,7 @@ void BKE_main_lib_objects_recalc_all(Main *bmain)
* **************************** */
/**
- * Get allocation size fo a given data-block type and optionally allocation name.
+ * Get allocation size of a given data-block type and optionally allocation name.
*/
size_t BKE_libblock_get_alloc_info(short type, const char **name)
{
diff --git a/source/blender/blenkernel/intern/library_idmap.c b/source/blender/blenkernel/intern/library_idmap.c
index cc7e2e31d07..ab0ff5b0096 100644
--- a/source/blender/blenkernel/intern/library_idmap.c
+++ b/source/blender/blenkernel/intern/library_idmap.c
@@ -85,7 +85,7 @@ static struct IDNameLib_TypeMap *main_idmap_from_idcode(struct IDNameLib_Map *id
*
* \note When used during undo/redo, there is no guaranty that ID pointers from UI area
* are not pointing to freed memory (when some IDs have been deleted). To avoid crashes
- * in those cases, one can provide the 'old' (aka current) Main databse as reference.
+ * in those cases, one can provide the 'old' (aka current) Main database as reference.
* #BKE_main_idmap_lookup_id will then check that given ID does exist in \a old_bmain
* before trying to use it.
*
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 691ef4a4dba..db4265d0894 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -376,7 +376,7 @@ static void library_foreach_ID_link(Main *bmain,
int i;
if (flag & IDWALK_RECURSE) {
- /* For now, recusion implies read-only. */
+ /* For now, recursion implies read-only. */
flag |= IDWALK_READONLY;
data.ids_handled = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 2ab5b69a022..e03903c05e4 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -1462,7 +1462,7 @@ typedef struct MaskRasterizeBufferData {
static void maskrasterize_buffer_cb(void *__restrict userdata,
const int y,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
MaskRasterizeBufferData *data = userdata;
@@ -1503,7 +1503,7 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
.width = width,
.buffer = buffer,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = ((size_t)height * width > 10000);
BLI_task_parallel_range(0, (int)height, &data, maskrasterize_buffer_cb, &settings);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index e845271d802..b01c1189fd1 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -366,6 +366,26 @@ static void material_data_index_remove_id(ID *id, short index)
}
}
+bool BKE_object_material_slot_used(ID *id, short actcol)
+{
+ /* ensure we don't try get materials from non-obdata */
+ BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
+
+ switch (GS(id->name)) {
+ case ID_ME:
+ return BKE_mesh_material_index_used((Mesh *)id, actcol - 1);
+ case ID_CU:
+ return BKE_curve_material_index_used((Curve *)id, actcol - 1);
+ case ID_MB:
+ /* meta-elems don't have materials atm */
+ return false;
+ case ID_GD:
+ return BKE_gpencil_material_index_used((bGPdata *)id, actcol - 1);
+ default:
+ return false;
+ }
+}
+
static void material_data_index_clear_id(ID *id)
{
/* ensure we don't try get materials from non-obdata */
@@ -496,6 +516,7 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool update_data)
MEM_freeN(*matar);
*matar = NULL;
}
+ test_all_objects_materials(bmain, id);
if (update_data) {
/* decrease mat_nr index */
@@ -1085,65 +1106,93 @@ static bNode *nodetree_uv_node_recursive(bNode *node)
return NULL;
}
-static int count_texture_nodes_recursive(bNodeTree *nodetree)
+typedef bool (*ForEachTexNodeCallback)(bNode *node, void *userdata);
+static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree,
+ ForEachTexNodeCallback callback,
+ void *userdata)
{
- int tex_nodes = 0;
-
for (bNode *node = nodetree->nodes.first; node; node = node->next) {
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE &&
node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
- tex_nodes++;
+ if (!callback(node, userdata)) {
+ return false;
+ }
}
else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
/* recurse into the node group and see if it contains any textures */
- tex_nodes += count_texture_nodes_recursive((bNodeTree *)node->id);
+ if (!ntree_foreach_texnode_recursive((bNodeTree *)node->id, callback, userdata)) {
+ return false;
+ }
}
}
+ return true;
+}
+
+static bool count_texture_nodes_cb(bNode *UNUSED(node), void *userdata)
+{
+ (*((int *)userdata))++;
+ return true;
+}
+
+static int count_texture_nodes_recursive(bNodeTree *nodetree)
+{
+ int tex_nodes = 0;
+ ntree_foreach_texnode_recursive(nodetree, count_texture_nodes_cb, &tex_nodes);
return tex_nodes;
}
-static void fill_texpaint_slots_recursive(bNodeTree *nodetree,
- bNode *active_node,
- Material *ma,
- int *index)
+struct FillTexPaintSlotsData {
+ bNode *active_node;
+ Material *ma;
+ int index;
+ int slot_len;
+};
+
+static bool fill_texpaint_slots_cb(bNode *node, void *userdata)
{
- for (bNode *node = nodetree->nodes.first; node; node = node->next) {
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE &&
- node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
- if (active_node == node) {
- ma->paint_active_slot = *index;
- }
+ struct FillTexPaintSlotsData *fill_data = userdata;
- ma->texpaintslot[*index].ima = (Image *)node->id;
- ma->texpaintslot[*index].interp = ((NodeTexImage *)node->storage)->interpolation;
+ Material *ma = fill_data->ma;
+ int index = fill_data->index;
+ fill_data->index++;
- /* for new renderer, we need to traverse the treeback in search of a UV node */
- bNode *uvnode = nodetree_uv_node_recursive(node);
+ if (fill_data->active_node == node) {
+ ma->paint_active_slot = index;
+ }
- if (uvnode) {
- NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage;
- ma->texpaintslot[*index].uvname = storage->uv_map;
- /* set a value to index so UI knows that we have a valid pointer for the mesh */
- ma->texpaintslot[*index].valid = true;
- }
- else {
- /* just invalidate the index here so UV map does not get displayed on the UI */
- ma->texpaintslot[*index].valid = false;
- }
- (*index)++;
- }
- else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
- /* recurse into the node group and see if it contains any textures */
- fill_texpaint_slots_recursive((bNodeTree *)node->id, active_node, ma, index);
- }
+ ma->texpaintslot[index].ima = (Image *)node->id;
+ ma->texpaintslot[index].interp = ((NodeTexImage *)node->storage)->interpolation;
+
+ /* for new renderer, we need to traverse the treeback in search of a UV node */
+ bNode *uvnode = nodetree_uv_node_recursive(node);
+
+ if (uvnode) {
+ NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage;
+ ma->texpaintslot[index].uvname = storage->uv_map;
+ /* set a value to index so UI knows that we have a valid pointer for the mesh */
+ ma->texpaintslot[index].valid = true;
}
+ else {
+ /* just invalidate the index here so UV map does not get displayed on the UI */
+ ma->texpaintslot[index].valid = false;
+ }
+
+ return fill_data->index != fill_data->slot_len;
+}
+
+static void fill_texpaint_slots_recursive(bNodeTree *nodetree,
+ bNode *active_node,
+ Material *ma,
+ int slot_len)
+{
+ struct FillTexPaintSlotsData fill_data = {active_node, ma, 0, slot_len};
+ ntree_foreach_texnode_recursive(nodetree, fill_texpaint_slots_cb, &fill_data);
}
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
{
int count = 0;
- int index = 0;
if (!ma) {
return;
@@ -1182,7 +1231,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
bNode *active_node = nodeGetActiveTexture(ma->nodetree);
- fill_texpaint_slots_recursive(ma->nodetree, active_node, ma, &index);
+ fill_texpaint_slots_recursive(ma->nodetree, active_node, ma, count);
ma->tot_slots = count;
@@ -1207,6 +1256,31 @@ void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob)
}
}
+struct FindTexPaintNodeData {
+ bNode *node;
+ short iter_index;
+ short index;
+};
+
+static bool texpaint_slot_node_find_cb(bNode *node, void *userdata)
+{
+ struct FindTexPaintNodeData *find_data = userdata;
+ if (find_data->iter_index++ == find_data->index) {
+ find_data->node = node;
+ return false;
+ }
+
+ return true;
+}
+
+bNode *BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot)
+{
+ struct FindTexPaintNodeData find_data = {NULL, 0, texpaint_slot};
+ ntree_foreach_texnode_recursive(ma->nodetree, texpaint_slot_node_find_cb, &find_data);
+
+ return find_data.node;
+}
+
/* r_col = current value, col = new value, (fac == 0) is no change */
void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
{
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index f5e93dcf9b7..7e755e54eaa 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -40,6 +40,7 @@
#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BKE_global.h"
+#include "BKE_key.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_library.h"
@@ -479,20 +480,38 @@ bool BKE_mesh_has_custom_loop_normals(Mesh *me)
/** Free (or release) any data used by this mesh (does not free the mesh itself). */
void BKE_mesh_free(Mesh *me)
{
- BKE_animdata_free(&me->id, false);
+ BKE_mesh_clear_geometry(me);
+ MEM_SAFE_FREE(me->mat);
+}
- BKE_mesh_runtime_clear_cache(me);
+void BKE_mesh_clear_geometry(Mesh *mesh)
+{
+ BKE_animdata_free(&mesh->id, false);
+ BKE_mesh_runtime_clear_cache(mesh);
- 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);
+ 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);
- MEM_SAFE_FREE(me->mat);
- MEM_SAFE_FREE(me->bb);
- MEM_SAFE_FREE(me->mselect);
- MEM_SAFE_FREE(me->edit_mesh);
+ MEM_SAFE_FREE(mesh->bb);
+ MEM_SAFE_FREE(mesh->mselect);
+ MEM_SAFE_FREE(mesh->edit_mesh);
+
+ /* Note that materials and shape keys are not freed here. This is intentional, as freeing
+ * shape keys requires tagging the depsgraph for updated relations, which is expensive.
+ * Material slots should be kept in sync with the object.*/
+
+ mesh->totvert = 0;
+ mesh->totedge = 0;
+ mesh->totface = 0;
+ mesh->totloop = 0;
+ mesh->totpoly = 0;
+ mesh->act_face = -1;
+ mesh->totselect = 0;
+
+ BKE_mesh_update_customdata_pointers(mesh, false);
}
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
@@ -697,6 +716,15 @@ Mesh *BKE_mesh_new_nomain_from_template(const Mesh *me_src,
me_src, verts_len, edges_len, tessface_len, loops_len, polys_len, CD_MASK_EVERYTHING);
}
+void BKE_mesh_eval_delete(struct Mesh *mesh_eval)
+{
+ /* Evaluated mesh may point to edit mesh, but never owns it. */
+ mesh_eval->edit_mesh = NULL;
+ BKE_mesh_free(mesh_eval);
+ BKE_libblock_free_data(&mesh_eval->id, false);
+ MEM_freeN(mesh_eval);
+}
+
Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
{
int flags = LIB_ID_COPY_LOCALIZE;
@@ -1178,6 +1206,27 @@ void BKE_mesh_material_index_remove(Mesh *me, short index)
}
}
+bool BKE_mesh_material_index_used(Mesh *me, short index)
+{
+ MPoly *mp;
+ MFace *mf;
+ int i;
+
+ for (mp = me->mpoly, i = 0; i < me->totpoly; i++, mp++) {
+ if (mp->mat_nr == index) {
+ return true;
+ }
+ }
+
+ for (mf = me->mface, i = 0; i < me->totface; i++, mf++) {
+ if (mf->mat_nr == index) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void BKE_mesh_material_index_clear(Mesh *me)
{
MPoly *mp;
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 17b22a6d095..e28d50cbde4 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -220,7 +220,7 @@ typedef struct MeshCalcNormalsData {
static void mesh_calc_normals_poly_cb(void *__restrict userdata,
const int pidx,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
MeshCalcNormalsData *data = userdata;
const MPoly *mp = &data->mpolys[pidx];
@@ -230,7 +230,7 @@ static void mesh_calc_normals_poly_cb(void *__restrict userdata,
static void mesh_calc_normals_poly_prepare_cb(void *__restrict userdata,
const int pidx,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
MeshCalcNormalsData *data = userdata;
const MPoly *mp = &data->mpolys[pidx];
@@ -294,7 +294,7 @@ static void mesh_calc_normals_poly_prepare_cb(void *__restrict userdata,
static void mesh_calc_normals_poly_finalize_cb(void *__restrict userdata,
const int vidx,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
MeshCalcNormalsData *data = userdata;
@@ -321,7 +321,7 @@ void BKE_mesh_calc_normals_poly(MVert *mverts,
{
float(*pnors)[3] = r_polynors;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = 1024;
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index dac12233539..c8e75532075 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -1200,7 +1200,7 @@ void BKE_mesh_strip_loose_polysloops(Mesh *me)
int i = p->loopstart;
int stop = i + p->totloop;
- if (stop > me->totloop || stop < i) {
+ if (stop > me->totloop || stop < i || p->loopstart < 0) {
invalid = true;
}
else {
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index c23fe30d311..656ec50f31b 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -802,7 +802,7 @@ bool modifiers_usesSubsurfFacedots(struct Scene *scene, Object *ob)
}
}
else if (mti->type == eModifierTypeType_OnlyDeform) {
- /* Theses modifiers do not reset the subdiv flag nor change the topology.
+ /* These modifiers do not reset the subdiv flag nor change the topology.
* We can still search for a subsurf modifier. */
}
else {
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 6bc83f8dd09..f67bc419210 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -53,6 +53,7 @@
#include "BKE_animsys.h"
#include "BKE_colortools.h"
+#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_movieclip.h"
@@ -1772,9 +1773,17 @@ static void movieclip_selection_synchronize(MovieClip *clip_dst, const MovieClip
}
}
-void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, MovieClip *clip)
+static void movieclip_eval_update_reload(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
+{
+ BKE_movieclip_reload(bmain, clip);
+ if (DEG_is_active(depsgraph)) {
+ MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
+ BKE_movieclip_reload(bmain, clip_orig);
+ }
+}
+
+static void movieclip_eval_update_generic(struct Depsgraph *depsgraph, MovieClip *clip)
{
- DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
BKE_tracking_dopesheet_tag_update(&clip->tracking);
if (DEG_is_active(depsgraph)) {
MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
@@ -1782,6 +1791,17 @@ void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, MovieClip *clip)
}
}
+void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, Main *bmain, MovieClip *clip)
+{
+ DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
+ if (clip->id.recalc & ID_RECALC_SOURCE) {
+ movieclip_eval_update_reload(depsgraph, bmain, clip);
+ }
+ else {
+ movieclip_eval_update_generic(depsgraph, clip);
+ }
+}
+
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip *clip)
{
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 29337ca9985..bbae1f4d3bc 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1078,7 +1078,7 @@ typedef struct MultiresThreadedData {
static void multires_disp_run_cb(void *__restrict userdata,
const int pidx,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
MultiresThreadedData *tdata = userdata;
@@ -1230,7 +1230,7 @@ static void multiresModifier_disp_run(
}
}
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = CCG_TASK_LIMIT;
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index 749cedb5388..d939267ac5a 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -955,7 +955,7 @@ typedef struct ReshapeFromCCGTaskData {
static void reshape_from_ccg_task(void *__restrict userdata,
const int coarse_poly_index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
ReshapeFromCCGTaskData *data = userdata;
const CCGKey *key = data->key;
@@ -1045,7 +1045,7 @@ bool multiresModifier_reshapeFromCCG(const int tot_level, Mesh *coarse_mesh, Sub
MultiresPropagateData propagate_data;
multires_reshape_propagate_prepare(&propagate_data, coarse_mesh, key.level, top_level);
/* Threaded grids iteration. */
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
BLI_task_parallel_range(
0, coarse_mesh->totpoly, &data, reshape_from_ccg_task, &parallel_range_settings);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d7256cc9604..eb2f23a7b2a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -442,19 +442,13 @@ void BKE_object_free_derived_caches(Object *ob)
if (ob->runtime.mesh_eval != NULL) {
if (ob->runtime.is_mesh_eval_owned) {
Mesh *mesh_eval = ob->runtime.mesh_eval;
- /* Evaluated mesh points to edit mesh, but does not own it. */
- mesh_eval->edit_mesh = NULL;
- BKE_mesh_free(mesh_eval);
- BKE_libblock_free_data(&mesh_eval->id, false);
- MEM_freeN(mesh_eval);
+ BKE_mesh_eval_delete(mesh_eval);
}
ob->runtime.mesh_eval = NULL;
}
if (ob->runtime.mesh_deform_eval != NULL) {
Mesh *mesh_deform_eval = ob->runtime.mesh_deform_eval;
- BKE_mesh_free(mesh_deform_eval);
- BKE_libblock_free_data(&mesh_deform_eval->id, false);
- MEM_freeN(mesh_deform_eval);
+ BKE_mesh_eval_delete(mesh_deform_eval);
ob->runtime.mesh_deform_eval = NULL;
}
@@ -1829,7 +1823,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
else {
/* only on local objects because this causes indirect links
* 'a -> b -> c', blend to point directly to a.blend
- * when a.blend has a proxy thats linked into c.blend */
+ * when a.blend has a proxy that's linked into c.blend */
if (!ID_IS_LINKED(ob)) {
id_lib_extern((ID *)dtar->id);
}
@@ -2568,7 +2562,8 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph,
void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
/* Execute drivers and animation. */
- BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
+ const bool flush_to_original = DEG_is_active(depsgraph);
+ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL, flush_to_original);
object_where_is_calc_ex(depsgraph, scene, ob, ctime, NULL, NULL);
}
@@ -4341,6 +4336,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
float frame,
int type)
{
+ const bool flush_to_original = DEG_is_active(depsgraph);
ModifierData *md = modifiers_findByType(ob, (ModifierType)type);
bConstraint *con;
@@ -4405,7 +4401,8 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
/* TODO(sergey): What about animation? */
ob->id.recalc |= ID_RECALC_ALL;
if (update_mesh) {
- BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(
+ scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM, flush_to_original);
/* ignore cache clear during subframe updates
* to not mess up cache validity */
object_cacheIgnoreClear(ob, 1);
@@ -4419,12 +4416,14 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
/* for curve following objects, parented curve has to be updated too */
if (ob->type == OB_CURVE) {
Curve *cu = ob->data;
- BKE_animsys_evaluate_animdata(depsgraph, scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(
+ scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM, flush_to_original);
}
/* and armatures... */
if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
- BKE_animsys_evaluate_animdata(depsgraph, scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(
+ scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM, flush_to_original);
BKE_pose_where_is(depsgraph, scene, ob);
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index b5df7d5fe9b..39fb668c873 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -510,7 +510,7 @@ typedef struct OceanSimulateData {
static void ocean_compute_htilda(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
OceanSimulateData *osd = userdata;
const Ocean *o = osd->o;
@@ -779,7 +779,7 @@ void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount
* but remains reasonably simple and should be OK most of the time. */
/* compute a new htilda */
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (o->_M > 16);
BLI_task_parallel_range(0, o->_M, &osd, ocean_compute_htilda, &settings);
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index fbf586e3f49..a252329b635 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -67,11 +67,21 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
paint_toolslots_init(bmain, &ts->imapaint.paint);
- paint_toolslots_init(bmain, &ts->sculpt->paint);
- paint_toolslots_init(bmain, &ts->vpaint->paint);
- paint_toolslots_init(bmain, &ts->wpaint->paint);
- paint_toolslots_init(bmain, &ts->uvsculpt->paint);
- paint_toolslots_init(bmain, &ts->gp_paint->paint);
+ if (ts->sculpt) {
+ paint_toolslots_init(bmain, &ts->sculpt->paint);
+ }
+ if (ts->vpaint) {
+ paint_toolslots_init(bmain, &ts->vpaint->paint);
+ }
+ if (ts->wpaint) {
+ paint_toolslots_init(bmain, &ts->wpaint->paint);
+ }
+ if (ts->uvsculpt) {
+ paint_toolslots_init(bmain, &ts->uvsculpt->paint);
+ }
+ if (ts->gp_paint) {
+ paint_toolslots_init(bmain, &ts->gp_paint->paint);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 079a348745c..64616af945f 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3112,7 +3112,7 @@ typedef struct CacheEditrPathsIterData {
static void psys_cache_edit_paths_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
CacheEditrPathsIterData *iter_data = (CacheEditrPathsIterData *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -3334,7 +3334,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph,
iter_data.nosel_col[2] = (float)edit->nosel_col[2] / 255.0f;
}
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, edit->totpoint, &iter_data, psys_cache_edit_paths_iter, &settings);
@@ -4259,7 +4259,7 @@ static void get_child_modifier_parameters(ParticleSettings *part,
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_twist);
}
}
-/* get's hair (or keyed) particles state at the "path time" specified in state->time */
+/* gets hair (or keyed) particles state at the "path time" specified in state->time */
void psys_get_particle_on_path(ParticleSimulationData *sim,
int p,
ParticleKey *state,
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 27722aab2d9..5685e5cd05e 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3685,7 +3685,7 @@ typedef struct DynamicStepSolverTaskData {
static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata,
const int p,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
DynamicStepSolverTaskData *data = userdata;
ParticleSimulationData *sim = data->sim;
@@ -3720,7 +3720,7 @@ static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata,
}
static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
- void *__restrict userdata, const int p, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int p, const TaskParallelTLS *__restrict UNUSED(tls))
{
DynamicStepSolverTaskData *data = userdata;
ParticleSimulationData *sim = data->sim;
@@ -3736,7 +3736,7 @@ static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
}
static void dynamics_step_sph_classical_calc_density_task_cb_ex(
- void *__restrict userdata, const int p, const ParallelRangeTLS *__restrict tls)
+ void *__restrict userdata, const int p, const TaskParallelTLS *__restrict tls)
{
DynamicStepSolverTaskData *data = userdata;
ParticleSimulationData *sim = data->sim;
@@ -3753,8 +3753,9 @@ static void dynamics_step_sph_classical_calc_density_task_cb_ex(
sphclassical_calc_dens(pa, pa->state.time, sphdata);
}
-static void dynamics_step_sph_classical_integrate_task_cb_ex(
- void *__restrict userdata, const int p, const ParallelRangeTLS *__restrict tls)
+static void dynamics_step_sph_classical_integrate_task_cb_ex(void *__restrict userdata,
+ const int p,
+ const TaskParallelTLS *__restrict tls)
{
DynamicStepSolverTaskData *data = userdata;
ParticleSimulationData *sim = data->sim;
@@ -3963,7 +3964,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* Apply SPH forces using double-density relaxation algorithm
* (Clavat et. al.) */
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (psys->totpart > 100);
settings.userdata_chunk = &sphdata;
@@ -3980,7 +3981,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
* this algorithm is separated into distinct loops. */
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (psys->totpart > 100);
BLI_task_parallel_range(0,
@@ -3994,7 +3995,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* Note that we could avoid copying sphdata for each thread here (it's only read here),
* but doubt this would gain us anything except confusion... */
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (psys->totpart > 100);
settings.userdata_chunk = &sphdata;
@@ -4008,7 +4009,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* do global forces & effectors */
{
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (psys->totpart > 100);
settings.userdata_chunk = &sphdata;
@@ -4662,7 +4663,7 @@ void particle_system_update(struct Depsgraph *depsgraph,
hcfra = 100.0f * (float)i / (float)psys->part->hair_step;
if ((part->flag & PART_HAIR_REGROW) == 0) {
BKE_animsys_evaluate_animdata(
- depsgraph, scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM);
+ scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM, false);
}
system_step(&sim, hcfra, use_render_params);
psys->cfra = hcfra;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index ffc4ec65d4d..860e2bdaa93 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -995,7 +995,7 @@ typedef struct PBVHUpdateData {
static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
const int n,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
PBVHUpdateData *data = userdata;
@@ -1045,7 +1045,7 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
static void pbvh_update_normals_store_task_cb(void *__restrict userdata,
const int n,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
PBVHUpdateData *data = userdata;
PBVH *bvh = data->bvh;
@@ -1094,7 +1094,7 @@ static void pbvh_faces_update_normals(PBVH *bvh, PBVHNode **nodes, int totnode)
.vnors = vnors,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (totnode > PBVH_THREADED_LIMIT);
@@ -1107,7 +1107,7 @@ static void pbvh_faces_update_normals(PBVH *bvh, PBVHNode **nodes, int totnode)
static void pbvh_update_BB_redraw_task_cb(void *__restrict userdata,
const int n,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
PBVHUpdateData *data = userdata;
PBVH *bvh = data->bvh;
@@ -1138,7 +1138,7 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
.flag = flag,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (totnode > PBVH_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index b577efd2a22..bf33e076e32 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3810,7 +3810,7 @@ void BKE_ptcache_remove(void)
closedir(dir);
}
else {
- rmdir = 0; /* path dosnt exist */
+ rmdir = 0; /* path doesn't exist */
}
if (rmdir) {
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index c2d51b72b29..b29e07bb56d 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3336,8 +3336,7 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
/* anim-data */
adt = BKE_animdata_from_id(&mask->id);
- BKE_animsys_evaluate_animdata(
- context->depsgraph, context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(context->scene, &mask_temp->id, adt, nr, ADT_RECALC_ANIM, false);
maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
@@ -3711,7 +3710,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
case SEQ_TYPE_SCENE: {
if (seq->flag & SEQ_SCENE_STRIPS) {
if (seq->scene && (context->scene != seq->scene)) {
- /* recusrive check */
+ /* recursive check */
if (BLI_linklist_index(state->scene_parents, seq->scene) != -1) {
break;
}
@@ -4645,7 +4644,7 @@ void BKE_sequence_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
BKE_sequence_tx_set_final_left(seq, seq_tx_get_end(seq) - 1);
}
- /* dosnt work now - TODO */
+ /* doesn't work now - TODO */
#if 0
if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) {
int ofs;
@@ -5836,7 +5835,7 @@ static Sequence *seq_dupli(const Scene *scene_src,
/* When using SEQ_DUPE_UNIQUE_NAME, it is mandatory to add new sequences in relevant container
* (scene or meta's one), *before* checking for unique names. Otherwise the meta's list is empty
* and hence we miss all seqs in that meta that have already been duplicated (see T55668).
- * Note that unique name check itslef could be done at a later step in calling code, once all
+ * Note that unique name check itself could be done at a later step in calling code, once all
* seqs have bee duplicated (that was first, simpler solution), but then handling of animation
* data will be broken (see T60194). */
if (new_seq_list != NULL) {
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 6a72b46a8f2..9b9fd33f52d 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -344,7 +344,7 @@ void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh)
*/
static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
ShrinkwrapCalcCBData *data = userdata;
@@ -416,7 +416,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
.calc = calc,
.tree = calc->tree,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
settings.userdata_chunk = &nearest;
@@ -510,7 +510,7 @@ bool BKE_shrinkwrap_project_normal(char options,
static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
ShrinkwrapCalcCBData *data = userdata;
@@ -703,7 +703,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
.proj_axis = proj_axis,
.local2aux = &local2aux,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
settings.userdata_chunk = &hit;
@@ -1115,7 +1115,7 @@ void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree,
*/
static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdata,
const int i,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
ShrinkwrapCalcCBData *data = userdata;
@@ -1363,7 +1363,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
.calc = calc,
.tree = calc->tree,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (calc->numVerts > BKE_MESH_OMP_LIMIT);
settings.userdata_chunk = &nearest;
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index bb8fd18ea58..688af539bbb 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -819,7 +819,7 @@ typedef struct ObstaclesFromDMData {
static void obstacles_from_mesh_task_cb(void *__restrict userdata,
const int z,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
ObstaclesFromDMData *data = userdata;
SmokeDomainSettings *sds = data->sds;
@@ -974,7 +974,7 @@ static void obstacles_from_mesh(Object *coll_ob,
.velocityZ = velocityZ,
.num_obstacles = num_obstacles,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(
@@ -1328,7 +1328,7 @@ typedef struct EmitFromParticlesData {
static void emit_from_particles_task_cb(void *__restrict userdata,
const int z,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
EmitFromParticlesData *data = userdata;
SmokeFlowSettings *sfs = data->sfs;
@@ -1567,7 +1567,7 @@ static void emit_from_particles(Object *flow_ob,
.hr_smooth = hr_smooth,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(min[2], max[2], &data, emit_from_particles_task_cb, &settings);
@@ -1770,7 +1770,7 @@ typedef struct EmitFromDMData {
static void emit_from_mesh_task_cb(void *__restrict userdata,
const int z,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
EmitFromDMData *data = userdata;
EmissionMap *em = data->em;
@@ -1975,7 +1975,7 @@ static void emit_from_mesh(
.res = res,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(min[2], max[2], &data, emit_from_mesh_task_cb, &settings);
@@ -2893,7 +2893,7 @@ typedef struct UpdateEffectorsData {
static void update_effectors_task_cb(void *__restrict userdata,
const int x,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
UpdateEffectorsData *data = userdata;
SmokeDomainSettings *sds = data->sds;
@@ -2967,7 +2967,7 @@ static void update_effectors(
data.velocity_z = smoke_get_velocity_z(sds->fluid);
data.obstacle = smoke_get_obstacle(sds->fluid);
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, sds->res[0], &data, update_effectors_task_cb, &settings);
@@ -3523,7 +3523,7 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la
// get starting cell (light pos)
if (BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON) {
- // we're ouside -> use point on side of domain
+ // we're outside -> use point on side of domain
cell[0] = (int)floor(pos[0]);
cell[1] = (int)floor(pos[1]);
cell[2] = (int)floor(pos[2]);
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 03fbdc24ce4..2024a507ebb 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -258,7 +258,7 @@ static float _final_mass(Object *ob, BodyPoint *bp)
/* just an ID here to reduce the prob for killing objects
* ob->sumohandle points to we should not kill :)
*/
-static const int CCD_SAVETY = 190561;
+static const int CCD_SAFETY = 190561;
typedef struct ccdf_minmax {
float minx, miny, minz, maxx, maxy, maxz;
@@ -269,7 +269,7 @@ typedef struct ccd_Mesh {
const MVert *mvert;
const MVert *mprevvert;
const MVertTri *tri;
- int savety;
+ int safety;
ccdf_minmax *mima;
/* Axis Aligned Bounding Box AABB */
float bbmin[3];
@@ -298,7 +298,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
pccd_M = MEM_mallocN(sizeof(ccd_Mesh), "ccd_Mesh");
pccd_M->mvert_num = cmd->mvert_num;
pccd_M->tri_num = cmd->tri_num;
- pccd_M->savety = CCD_SAVETY;
+ pccd_M->safety = CCD_SAFETY;
pccd_M->bbmin[0] = pccd_M->bbmin[1] = pccd_M->bbmin[2] = 1e30f;
pccd_M->bbmax[0] = pccd_M->bbmax[1] = pccd_M->bbmax[2] = -1e30f;
pccd_M->mprevvert = NULL;
@@ -486,7 +486,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
static void ccd_mesh_free(ccd_Mesh *ccdm)
{
- if (ccdm && (ccdm->savety == CCD_SAVETY)) { /*make sure we're not nuking objects we don't know*/
+ /* Make sure we're not nuking objects we don't know. */
+ if (ccdm && (ccdm->safety == CCD_SAFETY)) {
MEM_freeN((void *)ccdm->mvert);
MEM_freeN((void *)ccdm->tri);
if (ccdm->mprevvert) {
@@ -751,7 +752,7 @@ static void build_bps_springlist(Object *ob)
int a, b;
if (sb == NULL) {
- return; /* paranoya check */
+ return; /* paranoia check */
}
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
@@ -781,7 +782,7 @@ static void calculate_collision_balls(Object *ob)
float min, max, akku;
if (sb == NULL) {
- return; /* paranoya check */
+ return; /* paranoia check */
}
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
@@ -3322,7 +3323,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
copy_v3_v3(bp->prevdv, bp->vec);
}
- /* make a nice clean scratch struc */
+ /* make a nice clean scratch struct */
free_scratch(sb); /* clear if any */
sb_new_scratch(sb); /* make a new */
sb->scratch->needstobuildcollider = 1;
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 6d782726e07..6cbb01861e2 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -898,7 +898,7 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop)
{
bool need_close_audio_handles = false;
if (sound->playback_handle == NULL) {
- /* TOOD(sergey): Make it fully independent audio handle. */
+ /* TODO(sergey): Make it fully independent audio handle. */
sound_load_audio(bmain, sound);
need_close_audio_handles = true;
}
@@ -1092,7 +1092,7 @@ bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *soun
if (sound->playback_handle != NULL) {
return sound_info_from_playback_handle(sound->playback_handle, sound_info);
}
- /* TOOD(sergey): Make it fully independent audio handle. */
+ /* TODO(sergey): Make it fully independent audio handle. */
sound_load_audio(main, sound);
const bool result = sound_info_from_playback_handle(sound->playback_handle, sound_info);
sound_free_audio(sound);
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index fac1e1dbe75..d346d4d6f8d 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -267,7 +267,7 @@ static void subdiv_ccg_eval_special_grid(CCGEvalGridsData *data, const int face_
static void subdiv_ccg_eval_grids_task(void *__restrict userdata_v,
const int face_index,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
CCGEvalGridsData *data = userdata_v;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
@@ -295,7 +295,7 @@ static bool subdiv_ccg_evaluate_grids(SubdivCCG *subdiv_ccg,
data.mask_evaluator = mask_evaluator;
data.material_flags_evaluator = material_flags_evaluator;
/* Threaded grids evaluation. */
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
BLI_task_parallel_range(
0, num_faces, &data, subdiv_ccg_eval_grids_task, &parallel_range_settings);
@@ -747,7 +747,7 @@ static void subdiv_ccg_average_inner_face_normals(SubdivCCG *subdiv_ccg,
static void subdiv_ccg_recalc_inner_normal_task(void *__restrict userdata_v,
const int grid_index,
- const ParallelRangeTLS *__restrict tls_v)
+ const TaskParallelTLS *__restrict tls_v)
{
RecalcInnerNormalsData *data = userdata_v;
RecalcInnerNormalsTLSData *tls = tls_v->userdata_chunk;
@@ -772,7 +772,7 @@ static void subdiv_ccg_recalc_inner_grid_normals(SubdivCCG *subdiv_ccg)
.key = &key,
};
RecalcInnerNormalsTLSData tls_data = {NULL};
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
parallel_range_settings.userdata_chunk = &tls_data;
parallel_range_settings.userdata_chunk_size = sizeof(tls_data);
@@ -802,7 +802,7 @@ typedef struct RecalcModifiedInnerNormalsData {
static void subdiv_ccg_recalc_modified_inner_normal_task(void *__restrict userdata_v,
const int face_index,
- const ParallelRangeTLS *__restrict tls_v)
+ const TaskParallelTLS *__restrict tls_v)
{
RecalcModifiedInnerNormalsData *data = userdata_v;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
@@ -838,7 +838,7 @@ static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg,
.effected_ccg_faces = (SubdivCCGFace **)effected_faces,
};
RecalcInnerNormalsTLSData tls_data = {NULL};
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
parallel_range_settings.userdata_chunk = &tls_data;
parallel_range_settings.userdata_chunk_size = sizeof(tls_data);
@@ -973,7 +973,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg,
prev_grid = grid;
}
/* Average all grids centers into a single accumulator, and share it.
- * Guarantees corrent and smooth averaging in the center. */
+ * Guarantees correct and smooth averaging in the center. */
GridElementAccumulator center_accumulator;
element_accumulator_init(&center_accumulator);
for (int corner = 0; corner < num_face_grids; corner++) {
@@ -991,7 +991,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg,
static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v,
const int face_index,
- const ParallelRangeTLS *__restrict UNUSED(tls_v))
+ const TaskParallelTLS *__restrict UNUSED(tls_v))
{
AverageInnerGridsData *data = userdata_v;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
@@ -1050,7 +1050,7 @@ static void subdiv_ccg_average_grids_boundary(SubdivCCG *subdiv_ccg,
static void subdiv_ccg_average_grids_boundaries_task(void *__restrict userdata_v,
const int adjacent_edge_index,
- const ParallelRangeTLS *__restrict tls_v)
+ const TaskParallelTLS *__restrict tls_v)
{
AverageGridsBoundariesData *data = userdata_v;
AverageGridsBoundariesTLSData *tls = tls_v->userdata_chunk;
@@ -1097,7 +1097,7 @@ static void subdiv_ccg_average_grids_corners(SubdivCCG *subdiv_ccg,
static void subdiv_ccg_average_grids_corners_task(void *__restrict userdata_v,
const int adjacent_vertex_index,
- const ParallelRangeTLS *__restrict UNUSED(tls_v))
+ const TaskParallelTLS *__restrict UNUSED(tls_v))
{
AverageGridsCornerData *data = userdata_v;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
@@ -1108,7 +1108,7 @@ static void subdiv_ccg_average_grids_corners_task(void *__restrict userdata_v,
static void subdiv_ccg_average_all_boundaries(SubdivCCG *subdiv_ccg, CCGKey *key)
{
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
AverageGridsBoundariesData boundaries_data = {
.subdiv_ccg = subdiv_ccg,
@@ -1127,7 +1127,7 @@ static void subdiv_ccg_average_all_boundaries(SubdivCCG *subdiv_ccg, CCGKey *key
static void subdiv_ccg_average_all_corners(SubdivCCG *subdiv_ccg, CCGKey *key)
{
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
AverageGridsCornerData corner_data = {
.subdiv_ccg = subdiv_ccg,
@@ -1150,7 +1150,7 @@ void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
{
CCGKey key;
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
/* Average inner boundaries of grids (within one face), across faces
* from different face-corners. */
@@ -1175,7 +1175,7 @@ typedef struct StitchFacesInnerGridsData {
static void subdiv_ccg_stitch_face_inner_grids_task(
void *__restrict userdata_v,
const int face_index,
- const ParallelRangeTLS *__restrict UNUSED(tls_v))
+ const TaskParallelTLS *__restrict UNUSED(tls_v))
{
StitchFacesInnerGridsData *data = userdata_v;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
@@ -1197,7 +1197,7 @@ void BKE_subdiv_ccg_average_stitch_faces(SubdivCCG *subdiv_ccg,
.key = &key,
.effected_ccg_faces = effected_faces,
};
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
BLI_task_parallel_range(0,
num_effected_faces,
diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c
index 98afbef6c0a..f9039767f53 100644
--- a/source/blender/blenkernel/intern/subdiv_foreach.c
+++ b/source/blender/blenkernel/intern/subdiv_foreach.c
@@ -172,7 +172,7 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
const MPoly *coarse_mpoly = coarse_mesh->mpoly;
ctx->num_subdiv_vertices = coarse_mesh->totvert;
ctx->num_subdiv_edges = coarse_mesh->totedge * (num_subdiv_vertices_per_coarse_edge + 1);
- /* Calculate extra vertices and edges createdd by non-loose geometry. */
+ /* Calculate extra vertices and edges created by non-loose geometry. */
for (int poly_index = 0; poly_index < coarse_mesh->totpoly; poly_index++) {
const MPoly *coarse_poly = &coarse_mpoly[poly_index];
const int num_ptex_faces_per_poly = num_ptex_faces_per_poly_get(coarse_poly);
@@ -206,7 +206,7 @@ static void subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
num_polys_per_ptex_get(no_quad_patch_resolution);
}
}
- /* Calculate extra vertices createdd by loose edges. */
+ /* Calculate extra vertices created by loose edges. */
for (int edge_index = 0; edge_index < coarse_mesh->totedge; edge_index++) {
if (!BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, edge_index)) {
ctx->num_subdiv_vertices += num_subdiv_vertices_per_coarse_edge;
@@ -1681,7 +1681,7 @@ static void subdiv_foreach_polys(SubdivForeachTaskContext *ctx, void *tls, int p
static void subdiv_foreach_loose_vertices_task(void *__restrict userdata,
const int coarse_vertex_index,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
SubdivForeachTaskContext *ctx = userdata;
if (BLI_BITMAP_TEST_BOOL(ctx->coarse_vertices_used_map, coarse_vertex_index)) {
@@ -1695,7 +1695,7 @@ static void subdiv_foreach_loose_vertices_task(void *__restrict userdata,
static void subdiv_foreach_vertices_of_loose_edges_task(void *__restrict userdata,
const int coarse_edge_index,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
SubdivForeachTaskContext *ctx = userdata;
if (BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, coarse_edge_index)) {
@@ -1767,7 +1767,7 @@ static void subdiv_foreach_single_thread_tasks(SubdivForeachTaskContext *ctx)
static void subdiv_foreach_task(void *__restrict userdata,
const int poly_index,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
SubdivForeachTaskContext *ctx = userdata;
/* Traverse hi-poly vertex coordinates and normals. */
@@ -1786,7 +1786,7 @@ static void subdiv_foreach_task(void *__restrict userdata,
static void subdiv_foreach_boundary_edges_task(void *__restrict userdata,
const int edge_index,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
SubdivForeachTaskContext *ctx = userdata;
subdiv_foreach_boundary_edges(ctx, tls->userdata_chunk, edge_index);
@@ -1821,7 +1821,7 @@ bool BKE_subdiv_foreach_subdiv_geometry(Subdiv *subdiv,
/* Run all the code which is not supposed to be run from threads. */
subdiv_foreach_single_thread_tasks(&ctx);
/* Threaded traversal of the rest of topology. */
- ParallelRangeSettings parallel_range_settings;
+ TaskParallelSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
parallel_range_settings.userdata_chunk = context->user_data_tls;
parallel_range_settings.userdata_chunk_size = context->user_data_tls_size;
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index 75e05f8ffab..1ff9140681f 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -1086,20 +1086,27 @@ static void subdiv_mesh_vertex_of_loose_edge(const struct SubdivForeachContext *
const MEdge *coarse_edge = &coarse_mesh->medge[coarse_edge_index];
Mesh *subdiv_mesh = ctx->subdiv_mesh;
MVert *subdiv_mvert = subdiv_mesh->mvert;
+ const bool is_simple = ctx->subdiv->settings.is_simple;
/* Find neighbors of the current loose edge. */
const MEdge *neighbors[2];
find_edge_neighbors(ctx, coarse_edge, neighbors);
- /* Get points for b-spline interpolation. */
- float points[4][3];
- points_for_loose_edges_interpolation_get(ctx, coarse_edge, neighbors, points);
- /* Perform interpolation. */
- float weights[4];
- key_curve_position_weights(u, weights, KEY_BSPLINE);
/* Interpolate custom data. */
subdiv_mesh_vertex_of_loose_edge_interpolate(ctx, coarse_edge, u, subdiv_vertex_index);
- /* Initialize */
+ /* Interpolate coordinate. */
MVert *subdiv_vertex = &subdiv_mvert[subdiv_vertex_index];
- interp_v3_v3v3v3v3(subdiv_vertex->co, points[0], points[1], points[2], points[3], weights);
+ if (is_simple) {
+ const MVert *coarse_mvert = coarse_mesh->mvert;
+ const MVert *vert_1 = &coarse_mvert[coarse_edge->v1];
+ const MVert *vert_2 = &coarse_mvert[coarse_edge->v2];
+ interp_v3_v3v3(subdiv_vertex->co, vert_1->co, vert_2->co, u);
+ }
+ else {
+ float points[4][3];
+ points_for_loose_edges_interpolation_get(ctx, coarse_edge, neighbors, points);
+ float weights[4];
+ key_curve_position_weights(u, weights, KEY_BSPLINE);
+ interp_v3_v3v3v3v3(subdiv_vertex->co, points[0], points[1], points[2], points[3], weights);
+ }
/* Reset flags and such. */
subdiv_vertex->flag = 0;
/* TODO(sergey): This matches old behavior, but we can as well interpolate
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 4171c1aac4f..09a073e3ca6 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1459,7 +1459,7 @@ typedef struct CopyFinalLoopArrayData {
static void copyFinalLoopArray_task_cb(void *__restrict userdata,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
CopyFinalLoopArrayData *data = userdata;
CCGDerivedMesh *ccgdm = data->ccgdm;
@@ -1536,7 +1536,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
*/
data.mloop_index = data.grid_size >= 5 ? 1 : 8;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.min_iter_per_thread = 1;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 056229ceb1c..29aa3ca1659 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2045,11 +2045,12 @@ static void txt_select_prefix(Text *text, const char *add)
*
* \note caller must handle undo.
*/
-static void txt_select_unprefix(Text *text, const char *remove)
+static bool txt_select_unprefix(Text *text, const char *remove)
{
int num = 0;
const int indentlen = strlen(remove);
bool unindented_first = false;
+ bool changed_any = false;
BLI_assert(!ELEM(NULL, text->curl, text->sell));
@@ -2062,6 +2063,7 @@ static void txt_select_unprefix(Text *text, const char *remove)
text->curl->len -= indentlen;
memmove(text->curl->line, text->curl->line + indentlen, text->curl->len + 1);
changed = true;
+ changed_any = true;
}
txt_make_dirty(text);
@@ -2089,6 +2091,7 @@ static void txt_select_unprefix(Text *text, const char *remove)
}
/* caller must handle undo */
+ return changed_any;
}
void txt_comment(Text *text)
@@ -2102,15 +2105,15 @@ void txt_comment(Text *text)
txt_select_prefix(text, prefix);
}
-void txt_uncomment(Text *text)
+bool txt_uncomment(Text *text)
{
const char *prefix = "#";
if (ELEM(NULL, text->curl, text->sell)) {
- return;
+ return false;
}
- txt_select_unprefix(text, prefix);
+ return txt_select_unprefix(text, prefix);
}
void txt_indent(Text *text)
@@ -2124,15 +2127,15 @@ void txt_indent(Text *text)
txt_select_prefix(text, prefix);
}
-void txt_unindent(Text *text)
+bool txt_unindent(Text *text)
{
const char *prefix = (text->flags & TXT_TABSTOSPACES) ? tab_to_spaces : "\t";
if (ELEM(NULL, text->curl, text->sell)) {
- return;
+ return false;
}
- txt_select_unprefix(text, prefix);
+ return txt_select_unprefix(text, prefix);
}
void txt_move_lines(struct Text *text, const int direction)
diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c
index 8a474725b0c..47c12b329dc 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -42,7 +42,7 @@
#include "tracking_private.h"
typedef struct AutoTrackOptions {
- int clip_index; /** Index of the clip this track belogs to. */
+ int clip_index; /** Index of the clip this track belongs to. */
int track_index; /* Index of the track in AutoTrack tracks structure. */
MovieTrackingTrack *track; /* Pointer to an original track/ */
libmv_TrackRegionOptions track_region_options; /* Options for the region tracker. */
@@ -50,7 +50,7 @@ typedef struct AutoTrackOptions {
/* TODO(sergey): A bit awkward to keep it in here, only used to
* place a disabled marker once the tracking fails,
- * Wither find a more clear way to do it or call it track context
+ * Either find a clearer way to do it or call it track context
* or state, not options.
*/
bool is_failed;
@@ -377,7 +377,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
static void autotrack_context_step_cb(void *__restrict userdata,
const int track,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
AutoTrackContext *context = userdata;
const int frame_delta = context->backwards ? -1 : 1;
@@ -446,7 +446,7 @@ bool BKE_autotrack_context_step(AutoTrackContext *context)
const int frame_delta = context->backwards ? -1 : 1;
context->step_ok = false;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (context->num_tracks > 1);
BLI_task_parallel_range(0, context->num_tracks, context, autotrack_context_step_cb, &settings);
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index cfa41cb7d92..7e7a839b645 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -65,6 +65,9 @@ typedef struct MovieReconstructContext {
TracksMap *tracks_map;
int sfra, efra;
+
+ /* Details about reconstruction error, reported by Libmv. */
+ char error_message[1024];
} MovieReconstructContext;
typedef struct ReconstructProgressData {
@@ -426,9 +429,26 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip
context->keyframe2 = keyframe2;
context->refine_flags = reconstruct_refine_intrinsics_get_flags(tracking, object);
+ context->error_message[0] = '\0';
+
return context;
}
+void BKE_tracking_reconstruction_report_error_message(MovieReconstructContext *context,
+ const char *error_message)
+{
+ if (context->error_message[0]) {
+ /* Only keep initial error message, the rest are inducted ones. */
+ return;
+ }
+ BLI_strncpy(context->error_message, error_message, sizeof(context->error_message));
+}
+
+const char *BKE_tracking_reconstruction_error_message_get(const MovieReconstructContext *context)
+{
+ return context->error_message;
+}
+
/* Free memory used by a reconstruction process. */
void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
{
@@ -534,7 +554,8 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT
MovieTrackingObject *object;
if (!libmv_reconstructionIsValid(context->reconstruction)) {
- printf("Failed solve the motion: most likely there are no good keyframes\n");
+ BKE_tracking_reconstruction_report_error_message(
+ context, "Failed to solve the motion: most likely there are no good keyframes");
return false;
}
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index b852e8a12cd..03229c654fb 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -611,16 +611,19 @@ static bool average_track_contributions(StabContext *ctx,
float rotation, scale, quality;
quality = rotation_contribution(
stabilization_base, marker, aspect, r_pivot, &rotation, &scale);
- weight *= quality;
- weight_sum += weight;
- *r_angle += rotation * weight;
+ const float quality_weight = weight * quality;
+ weight_sum += quality_weight;
+ *r_angle += rotation * quality_weight;
if (stab->flag & TRACKING_STABILIZE_SCALE) {
- *r_scale_step += logf(scale) * weight;
+ *r_scale_step += logf(scale) * quality_weight;
}
else {
*r_scale_step = 0;
}
- ok |= (weight_sum > EPSILON_WEIGHT);
+ /* NOTE: Use original marker weight and not the scaled one with the proximity here to allow
+ * simple stabilization setups when there is a single track in a close proximity of the
+ * center. */
+ ok |= (weight > EPSILON_WEIGHT);
}
}
}
@@ -1338,7 +1341,7 @@ typedef struct TrackingStabilizeFrameInterpolationData {
} TrackingStabilizeFrameInterpolationData;
static void tracking_stabilize_frame_interpolation_cb(
- void *__restrict userdata, const int j, const ParallelRangeTLS *__restrict UNUSED(tls))
+ void *__restrict userdata, const int j, const TaskParallelTLS *__restrict UNUSED(tls))
{
TrackingStabilizeFrameInterpolationData *data = userdata;
ImBuf *ibuf = data->ibuf;
@@ -1443,7 +1446,7 @@ ImBuf *BKE_tracking_stabilize_frame(
.interpolation = interpolation,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (tmpibuf->y > 128);
BLI_task_parallel_range(
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 8ea5b47de5f..07cf5205cab 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -560,12 +560,15 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack,
}
if (use_memfile_step) {
- const char *name_internal = "MemFile Internal (post)";
+ /* Make this the user visible undo state, so redo always applies
+ * on top of the mem-file undo instead of skipping it. see: T67256. */
+ UndoStep *us_prev = ustack->step_active;
+ const char *name_internal = us_prev->name;
const bool ok = undosys_stack_push_main(ustack, name_internal, G_MAIN);
if (ok) {
UndoStep *us = ustack->steps.last;
BLI_assert(STREQ(us->name, name_internal));
- us->skip = true;
+ us_prev->skip = true;
#ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
ustack->step_active_memfile = us;
#endif
@@ -845,10 +848,6 @@ void BKE_undosys_type_free_all(void)
* Unfortunately we need this for a handful of places.
*/
-/* Disable for now since it accesses freed memory.
- * The pointer can only be a key, we can't read it's contents. */
-#define USE_LIB_SKIP
-
static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack,
UndoTypeForEachIDRefFn foreach_ID_ref_fn,
void *user_data))
@@ -861,176 +860,6 @@ static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack,
}
}
-typedef struct UndoIDPtrMapItem {
- /** Never changes (matches undo data). Use as sort key for binary search. */
- const void *ptr;
- /** Write the new pointers here. */
- uint index;
-} UndoIDPtrMapItem;
-
-typedef struct UndoIDPtrMap {
- UndoRefID *refs;
- /**
- * Pointer map, update 'dst' members before use.
- * This is always sorted (adds some overhead when adding, in practice it's acceptable since).
- */
- UndoIDPtrMapItem *pmap;
-
- /** Length for both 'refs' & 'pmap' */
- uint len;
- uint len_alloc;
-} UndoIDPtrMap;
-
-#ifdef DEBUG
-# define PMAP_DEFAULT_ALLOC 1
-#else
-# define PMAP_DEFAULT_ALLOC 32
-#endif
-
-void BKE_undosys_ID_map_foreach_ID_ref(UndoIDPtrMap *map,
- UndoTypeForEachIDRefFn foreach_ID_ref_fn,
- void *user_data)
-{
- for (uint i = 0; i < map->len; i++) {
- foreach_ID_ref_fn(user_data, &map->refs[i]);
- }
-}
-
-/**
- * Return true when found, otherwise index is set to the index we should insert.
- */
-static bool undosys_ID_map_lookup_index(const UndoIDPtrMap *map, const void *key, uint *r_index)
-{
- const UndoIDPtrMapItem *pmap = map->pmap;
- const uint len = map->len;
- if (len == 0) {
- if (r_index) {
- *r_index = 0;
- }
- return false;
- }
- int min = 0, max = len - 1;
- while (min <= max) {
- const uint mid = (min + max) / 2;
- if (pmap[mid].ptr < key) {
- min = mid + 1;
- }
- else if (pmap[mid].ptr == key) {
- if (r_index) {
- *r_index = mid;
- }
- return true;
- }
- else if (pmap[mid].ptr > key) {
- max = mid - 1;
- }
- }
- if (r_index) {
- *r_index = min;
- }
- return false;
-}
-
-/**
- * A set of ID's use for efficient decoding, so we can map pointers back to the newly loaded data
- * without performing full look ups each time.
- *
- * This can be used as an old_pointer -> new_pointer lookup.
- */
-UndoIDPtrMap *BKE_undosys_ID_map_create(void)
-{
- UndoIDPtrMap *map = MEM_mallocN(sizeof(*map), __func__);
- map->len_alloc = PMAP_DEFAULT_ALLOC;
- map->refs = MEM_mallocN(sizeof(*map->refs) * map->len_alloc, __func__);
- map->pmap = MEM_mallocN(sizeof(*map->pmap) * map->len_alloc, __func__);
- map->len = 0;
- return map;
-}
-void BKE_undosys_ID_map_destroy(UndoIDPtrMap *idpmap)
-{
- MEM_SAFE_FREE(idpmap->refs);
- MEM_SAFE_FREE(idpmap->pmap);
- MEM_freeN(idpmap);
-}
-
-void BKE_undosys_ID_map_add(UndoIDPtrMap *map, ID *id)
-{
- uint index;
-#ifdef USE_LIB_SKIP
- if (id->lib != NULL) {
- return;
- }
-#endif
-
- if (undosys_ID_map_lookup_index(map, id, &index)) {
- return; /* exists. */
- }
-
- const uint len_src = map->len;
- const uint len_dst = map->len + 1;
- if (len_dst > map->len_alloc) {
- map->len_alloc *= 2;
- BLI_assert(map->len_alloc >= len_dst);
- map->pmap = MEM_reallocN(map->pmap, sizeof(*map->pmap) * map->len_alloc);
- map->refs = MEM_reallocN(map->refs, sizeof(*map->refs) * map->len_alloc);
- }
-
-#if 0 /* Will be done automatically in callback. */
- BLI_strncpy(map->refs[len_src].name, id->name, sizeof(id->name));
-#else
- map->refs[len_src].name[0] = '\0';
-#endif
- map->refs[len_src].ptr = id;
-
- if (len_src != 0 && index != len_src) {
- memmove(&map->pmap[index + 1], &map->pmap[index], sizeof(*map->pmap) * (len_src - index));
- }
- map->pmap[index].ptr = id;
- map->pmap[index].index = len_src;
-
- map->len = len_dst;
-}
-
-ID *BKE_undosys_ID_map_lookup(const UndoIDPtrMap *map, const ID *id_src)
-{
- /* We should only ever lookup indices which exist! */
- uint index;
- if (!undosys_ID_map_lookup_index(map, id_src, &index)) {
- BLI_assert(0);
- }
- index = map->pmap[index].index;
- ID *id_dst = map->refs[index].ptr;
- BLI_assert(id_dst != NULL);
- BLI_assert(STREQ(id_dst->name, map->refs[index].name));
- return id_dst;
-}
-
-void BKE_undosys_ID_map_add_with_prev(UndoIDPtrMap *map, ID *id, ID **id_prev)
-{
- if (id == *id_prev) {
- return;
- }
- *id_prev = id;
- BKE_undosys_ID_map_add(map, id);
-}
-
-ID *BKE_undosys_ID_map_lookup_with_prev(const UndoIDPtrMap *map, ID *id_src, ID *id_prev_match[2])
-{
- if (id_src == id_prev_match[0]) {
- return id_prev_match[1];
- }
- else {
-#ifdef USE_LIB_SKIP
- ID *id_dst = BKE_undosys_ID_map_lookup(map, id_src);
-#else
- ID *id_dst = (id_src->lib == NULL) ? BKE_undosys_ID_map_lookup(map, id_src) : id_src;
-#endif
- id_prev_match[0] = id_src;
- id_prev_match[1] = id_dst;
- return id_dst;
- }
-}
-
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 7e7d5c82654..375721057c3 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -112,6 +112,8 @@ enum {
B_UNIT_DEF_TENTH = 2,
/** Short unit name is case sensitive, for example to distinguish mW and MW */
B_UNIT_DEF_CASE_SENSITIVE = 4,
+ /** Short unit name does not have space between it and preceding number */
+ B_UNIT_DEF_NO_SPACE = 8,
};
/* define a single unit */
@@ -161,8 +163,8 @@ static struct bUnitDef buImperialLenDef[] = {
{"furlong", "furlongs", "fur", NULL, "Furlongs", "FURLONGS", UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS},
{"chain", "chains", "ch", NULL, "Chains", "CHAINS", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS},
{"yard", "yards", "yd", NULL, "Yards", "YARDS", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS},
- {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */
- {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE},
+ {"foot", "feet", "'", "ft", "Feet", "FEET", UN_SC_FT, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE}, /* base unit */
+ {"inch", "inches", "\"", "in", "Inches", "INCHES", UN_SC_IN, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE},
{"thou", "thou", "thou", "mil", "Thou", "THOU", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */
NULL_UNIT,
};
@@ -289,10 +291,10 @@ static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0,
static struct bUnitDef buNaturalRotDef[] = {
- {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE},
+ {"degree", "degrees", "°", "d", "Degrees", "DEGREES", M_PI / 180.0, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_NO_SPACE},
/* arcminutes/arcseconds are used in Astronomy/Navigation areas... */
- {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS},
- {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS},
+ {"arcminute", "arcminutes", "'", NULL, "Arcminutes", "ARCMINUTES", (M_PI / 180.0) / 60.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE},
+ {"arcsecond", "arcseconds", "\"", NULL, "Arcseconds", "ARCSECONDS", (M_PI / 180.0) / 3600.0, 0.0, B_UNIT_DEF_SUPPRESS | B_UNIT_DEF_NO_SPACE},
{"radian", "radians", "r", NULL, "Radians", "RADIANS", 1.0, 0.0, B_UNIT_DEF_NONE},
// {"turn", "turns", "t", NULL, "Turns", NULL, 1.0 / (M_PI * 2.0), 0.0, B_UNIT_DEF_NONE},
NULL_UNIT,
@@ -451,6 +453,11 @@ static size_t unit_as_string(char *str,
}
}
+ /* Now add a space for all units except foot, inch, degree, arcminute, arcsecond */
+ if (!(unit->flag & B_UNIT_DEF_NO_SPACE)) {
+ str[++i] = ' ';
+ }
+
/* Now add the suffix */
if (i < len_max) {
int j = 0;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index f3336adda30..5152643aaa1 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -54,6 +54,7 @@
* like M_SQRT1_2 leading to warnings with MSVC */
# include <libavformat/avformat.h>
# include <libavcodec/avcodec.h>
+# include <libavutil/imgutils.h>
# include <libavutil/rational.h>
# include <libavutil/samplefmt.h>
# include <libswscale/swscale.h>
@@ -80,7 +81,10 @@ typedef struct FFMpegContext {
AVFormatContext *outfile;
AVStream *video_stream;
AVStream *audio_stream;
- AVFrame *current_frame;
+ AVFrame *current_frame; /* Image frame in output pixel format. */
+
+ /* Image frame in Blender's own pixel format, may need conversion to the output pixel format. */
+ AVFrame *img_convert_frame;
struct SwsContext *img_convert_ctx;
uint8_t *audio_input_buffer;
@@ -264,6 +268,10 @@ static AVFrame *alloc_picture(int pix_fmt, int width, int height)
return NULL;
}
avpicture_fill((AVPicture *)f, buf, pix_fmt, width, height);
+ f->format = pix_fmt;
+ f->width = width;
+ f->height = height;
+
return f;
}
@@ -319,6 +327,10 @@ static const char **get_file_extensions(int format)
static const char *rv[] = {".ogv", ".ogg", NULL};
return rv;
}
+ case FFMPEG_WEBM: {
+ static const char *rv[] = {".webm", NULL};
+ return rv;
+ }
default:
return NULL;
}
@@ -371,67 +383,52 @@ static int write_video_frame(
}
/* read and encode a frame of audio from the buffer */
-static AVFrame *generate_video_frame(FFMpegContext *context, uint8_t *pixels, ReportList *reports)
+static AVFrame *generate_video_frame(FFMpegContext *context,
+ const uint8_t *pixels,
+ ReportList *reports)
{
- uint8_t *rendered_frame;
-
AVCodecContext *c = context->video_stream->codec;
- int width = c->width;
int height = c->height;
AVFrame *rgb_frame;
- if (c->pix_fmt != AV_PIX_FMT_BGR32) {
- rgb_frame = alloc_picture(AV_PIX_FMT_BGR32, width, height);
- if (!rgb_frame) {
- BKE_report(reports, RPT_ERROR, "Could not allocate temporary frame");
- return NULL;
- }
+ if (context->img_convert_frame != NULL) {
+ /* Pixel format conversion is needed. */
+ rgb_frame = context->img_convert_frame;
}
else {
+ /* The output pixel format is Blender's internal pixel format. */
rgb_frame = context->current_frame;
}
- rendered_frame = pixels;
+ /* Copy the Blender pixels into the FFmpeg datastructure, taking care of endianness and flipping
+ * the image vertically. */
+ int linesize = rgb_frame->linesize[0];
+ for (int y = 0; y < height; y++) {
+ uint8_t *target = rgb_frame->data[0] + linesize * (height - y - 1);
+ const uint8_t *src = pixels + linesize * y;
- /* Do RGBA-conversion and flipping in one step depending
- * on CPU-Endianess */
+# if ENDIAN_ORDER == L_ENDIAN
+ memcpy(target, src, linesize);
- if (ENDIAN_ORDER == L_ENDIAN) {
- int y;
- for (y = 0; y < height; y++) {
- uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1);
- uint8_t *src = rendered_frame + width * 4 * y;
- uint8_t *end = src + width * 4;
- while (src != end) {
- target[3] = src[3];
- target[2] = src[2];
- target[1] = src[1];
- target[0] = src[0];
+# elif ENDIAN_ORDER == B_ENDIAN
+ const uint8_t *end = src + linesize;
+ while (src != end) {
+ target[3] = src[0];
+ target[2] = src[1];
+ target[1] = src[2];
+ target[0] = src[3];
- target += 4;
- src += 4;
- }
- }
- }
- else {
- int y;
- for (y = 0; y < height; y++) {
- uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1);
- uint8_t *src = rendered_frame + width * 4 * y;
- uint8_t *end = src + width * 4;
- while (src != end) {
- target[3] = src[0];
- target[2] = src[1];
- target[1] = src[2];
- target[0] = src[3];
-
- target += 4;
- src += 4;
- }
+ target += 4;
+ src += 4;
}
+# else
+# error ENDIAN_ORDER should either be L_ENDIAN or B_ENDIAN.
+# endif
}
- if (c->pix_fmt != AV_PIX_FMT_BGR32) {
+ /* Convert to the output pixel format, if it's different that Blender's internal one. */
+ if (context->img_convert_frame != NULL) {
+ BLI_assert(context->img_convert_ctx != NULL);
sws_scale(context->img_convert_ctx,
(const uint8_t *const *)rgb_frame->data,
rgb_frame->linesize,
@@ -439,13 +436,8 @@ static AVFrame *generate_video_frame(FFMpegContext *context, uint8_t *pixels, Re
c->height,
context->current_frame->data,
context->current_frame->linesize);
- delete_picture(rgb_frame);
}
- context->current_frame->format = AV_PIX_FMT_BGR32;
- context->current_frame->width = width;
- context->current_frame->height = height;
-
return context->current_frame;
}
@@ -696,9 +688,15 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
if (codec_id == AV_CODEC_ID_QTRLE) {
- /* Always write to ARGB. The default pixel format of QTRLE is RGB24, which uses 3 bytes per
- * pixels, which breaks the export. */
- c->pix_fmt = AV_PIX_FMT_ARGB;
+ if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
+ c->pix_fmt = AV_PIX_FMT_ARGB;
+ }
+ }
+
+ if (codec_id == AV_CODEC_ID_VP9) {
+ if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
+ c->pix_fmt = AV_PIX_FMT_YUVA420P;
+ }
}
if (codec_id == AV_CODEC_ID_PNG) {
@@ -727,18 +725,29 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
av_dict_free(&opts);
+ /* FFmpeg expects its data in the output pixel format. */
context->current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
- context->img_convert_ctx = sws_getContext(c->width,
- c->height,
- AV_PIX_FMT_BGR32,
- c->width,
- c->height,
- c->pix_fmt,
- SWS_BICUBIC,
- NULL,
- NULL,
- NULL);
+ if (c->pix_fmt == AV_PIX_FMT_RGBA) {
+ /* Output pixel format is the same we use internally, no conversion necessary. */
+ context->img_convert_frame = NULL;
+ context->img_convert_ctx = NULL;
+ }
+ else {
+ /* Output pixel format is different, allocate frame for conversion. */
+ context->img_convert_frame = alloc_picture(AV_PIX_FMT_RGBA, c->width, c->height);
+ context->img_convert_ctx = sws_getContext(c->width,
+ c->height,
+ AV_PIX_FMT_RGBA,
+ c->width,
+ c->height,
+ c->pix_fmt,
+ SWS_BICUBIC,
+ NULL,
+ NULL,
+ NULL);
+ }
+
return st;
}
@@ -1427,6 +1436,11 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit)
delete_picture(context->current_frame);
context->current_frame = NULL;
}
+ if (context->img_convert_frame != NULL) {
+ delete_picture(context->img_convert_frame);
+ context->img_convert_frame = NULL;
+ }
+
if (context->outfile != NULL && context->outfile->oformat) {
if (!(context->outfile->oformat->flags & AVFMT_NOFILE)) {
avio_close(context->outfile->pb);
@@ -1836,25 +1850,14 @@ bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
{
int codec = rd->ffcodecdata.codec;
- if (codec == AV_CODEC_ID_QTRLE) {
- return true;
- }
-
- if (codec == AV_CODEC_ID_PNG) {
- return true;
- }
-
- if (codec == AV_CODEC_ID_HUFFYUV) {
- return true;
- }
-
# ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
+ /* Visual Studio 2019 doesn't like #ifdef within ELEM(). */
if (codec == AV_CODEC_ID_FFV1) {
return true;
}
# endif
- return false;
+ return ELEM(codec, AV_CODEC_ID_QTRLE, AV_CODEC_ID_PNG, AV_CODEC_ID_VP9, AV_CODEC_ID_HUFFYUV);
}
void *BKE_ffmpeg_context_create(void)