Object Mode: pass eval_ctx to ED_object_iter_other

This commit is contained in:
2018-02-06 17:57:07 +11:00
parent 2a184f3d2b
commit fa588e9ef4
3 changed files with 40 additions and 22 deletions

View File

@@ -55,6 +55,7 @@ struct wmOperatorType;
struct PointerRNA;
struct PropertyRNA;
struct EnumPropertyItem;
struct EvaluationContext;
/* object_edit.c */
struct Object *ED_object_context(struct bContext *C); /* context.object */
@@ -200,11 +201,15 @@ int ED_object_modifier_apply(struct ReportList *reports, const struct bContext *
struct Object *ob, struct ModifierData *md, int mode);
int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
bool ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, const bool include_orig,
bool (*callback)(struct Object *ob, void *callback_data),
void *callback_data);
bool ED_object_iter_other(
const struct EvaluationContext *eval_ctx, struct Main *bmain,
struct Object *orig_ob, const bool include_orig,
bool (*callback)(const struct EvaluationContext *eval_ctx, struct Object *ob, void *callback_data),
void *callback_data);
bool ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v);
bool ED_object_multires_update_totlevels_cb(
const struct EvaluationContext *eval_ctx,
struct Object *ob, void *totlevel_v);
/* object_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);

View File

@@ -222,9 +222,10 @@ static void join_mesh_single(
multiresModifier_prepare_join(&eval_ctx, scene, ob_src, ob_dst);
if ((mmd = get_multires_modifier(scene, ob_src, true))) {
ED_object_iter_other(bmain, ob_src, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
ED_object_iter_other(
&eval_ctx, bmain, ob_src, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
}
}

View File

@@ -202,9 +202,11 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude,
* If the callback ever returns true, iteration will stop and the
* function value will be true. Otherwise the function returns false.
*/
bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig,
bool (*callback)(Object *ob, void *callback_data),
void *callback_data)
bool ED_object_iter_other(
const EvaluationContext *eval_ctx,
Main *bmain, Object *orig_ob, const bool include_orig,
bool (*callback)(const EvaluationContext *eval_ctx, Object *ob, void *callback_data),
void *callback_data)
{
ID *ob_data_id = orig_ob->data;
int users = ob_data_id->us;
@@ -223,7 +225,7 @@ bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig,
if (((ob != orig_ob) || include_orig) &&
(ob->data == orig_ob->data))
{
if (callback(ob, callback_data))
if (callback(eval_ctx, ob, callback_data))
return true;
totfound++;
@@ -231,13 +233,15 @@ bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig,
}
}
else if (include_orig) {
return callback(orig_ob, callback_data);
return callback(eval_ctx, orig_ob, callback_data);
}
return false;
}
static bool object_has_modifier_cb(Object *ob, void *data)
static bool object_has_modifier_cb(
const EvaluationContext *UNUSED(eval_ctx),
Object *ob, void *data)
{
ModifierType type = *((ModifierType *)data);
@@ -247,7 +251,9 @@ static bool object_has_modifier_cb(Object *ob, void *data)
/* Use with ED_object_iter_other(). Sets the total number of levels
* for any multires modifiers on the object to the int pointed to by
* callback_data. */
bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v)
bool ED_object_multires_update_totlevels_cb(
const struct EvaluationContext *UNUSED(eval_ctx),
Object *ob, void *totlevel_v)
{
ModifierData *md;
int totlevel = *((char *)totlevel_v);
@@ -267,7 +273,7 @@ static bool object_modifier_safe_to_delete(Main *bmain, Object *ob,
ModifierType type)
{
return (!object_has_modifier(ob, exclude, type) &&
!ED_object_iter_other(bmain, ob, false,
!ED_object_iter_other(NULL, bmain, ob, false,
object_has_modifier_cb, &type));
}
@@ -1153,10 +1159,13 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
multiresModifier_del_levels(mmd, ob, 1);
ED_object_iter_other(CTX_data_main(C), ob, true,
ED_object_iter_other(&eval_ctx, CTX_data_main(C), ob, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
@@ -1197,17 +1206,20 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
multiresModifier_subdivide(mmd, ob, 0, mmd->simple);
ED_object_iter_other(CTX_data_main(C), ob, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
ED_object_iter_other(
&eval_ctx, CTX_data_main(C), ob, true,
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
if (ob->mode & OB_MODE_SCULPT) {
if (eval_ctx.mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
BKE_sculpt_mask_layers_ensure(ob, mmd);
}