diff options
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 13 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_skinning.c | 41 | ||||
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 12 | ||||
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.h | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_select.c | 2 |
5 files changed, 46 insertions, 32 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 24f6a2dab2c..6df0a1cd302 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1579,6 +1579,9 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + bool changed = false; CTX_DATA_BEGIN (C, Object *, ob, selected_objects) @@ -1595,7 +1598,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) fcn = fcu->next; /* in pose mode, only delete the F-Curve if it belongs to a selected bone */ - if (ob->mode & OB_MODE_POSE) { + if (eval_ctx.object_mode & OB_MODE_POSE) { if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) { bPoseChannel *pchan; char *bone_name; @@ -1658,8 +1661,10 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot) static int delete_key_v3d_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - float cfra = (float)CFRA; + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + + const float cfra = eval_ctx.ctime; CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { @@ -1687,7 +1692,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) /* special exception for bones, as this makes this operator more convenient to use * NOTE: This is only done in pose mode. In object mode, we're dealign with the entire object. */ - if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) { + if ((eval_ctx.object_mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) { bPoseChannel *pchan; char *bone_name; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 72b4837c1b8..8900da900c0 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -66,7 +66,7 @@ /* ********************************** Bone Skinning *********************************************** */ -static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) +static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) { /* Bones that are deforming * are regarded to be "skinnable" and are eligible for @@ -92,9 +92,9 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) */ Bone ***hbone; int a, segments; - struct { Object *armob; void *list; int heat; } *data = datap; + struct { Object *armob; void *list; int heat; bool is_weight_paint; } *data = datap; - if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(data->is_weight_paint) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; @@ -157,18 +157,17 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) */ bDeformGroup ***hgroup, *defgroup = NULL; int a, segments; - struct { Object *armob; void *list; int heat; } *data = datap; - int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); + struct { Object *armob; void *list; int heat; bool is_weight_paint; } *data = datap; bArmature *arm = data->armob->data; - if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) { + if (!data->is_weight_paint || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; - if (!wpmode || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) { + if (!data->is_weight_paint || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) { if (!(defgroup = defgroup_find_name(ob, bone->name))) { defgroup = BKE_object_defgroup_add_name(ob, bone->name); } @@ -192,9 +191,11 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) return 0; } -static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, - bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, - float (*root)[3], float (*tip)[3], const int *selected, float scale) +static void envelope_bone_weighting( + const EvaluationContext *eval_ctx, + Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, + bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, + float (*root)[3], float (*tip)[3], const int *selected, float scale) { /* Create vertex group weights from envelopes */ @@ -205,7 +206,7 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0; bool use_mask = false; - if ((ob->mode & OB_MODE_WEIGHT_PAINT) && + if ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) && (mesh->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL))) { use_mask = true; @@ -276,12 +277,12 @@ static void add_verts_to_dgroups( float (*root)[3], (*tip)[3], (*verts)[3]; int *selected; int numbones, vertsfilled = 0, i, j, segments = 0; - int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); - struct { Object *armob; void *list; int heat; } looper_data; + struct { Object *armob; void *list; int heat; bool is_weight_paint; } looper_data; looper_data.armob = par; looper_data.heat = heat; looper_data.list = NULL; + looper_data.is_weight_paint = (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT); /* count the number of skinnable bones */ numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); @@ -354,7 +355,7 @@ static void add_verts_to_dgroups( mul_m4_v3(par->obmat, tip[j]); /* set selected */ - if (wpmode) { + if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) selected[j] = 1; } @@ -374,7 +375,7 @@ static void add_verts_to_dgroups( mesh = (Mesh *)ob->data; verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"); - if (wpmode) { + if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { /* if in weight paint mode, use final verts from derivedmesh */ DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH); @@ -404,15 +405,17 @@ static void add_verts_to_dgroups( if (heat) { const char *error = NULL; - heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip, - root, tip, selected, &error); + heat_bone_weighting( + eval_ctx, ob, mesh, verts, numbones, dgrouplist, dgroupflip, + root, tip, selected, &error); if (error) { BKE_report(reports, RPT_WARNING, error); } } else { - envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist, - dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); + envelope_bone_weighting( + eval_ctx, ob, mesh, verts, numbones, bonelist, dgrouplist, + dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); } /* only generated in some cases but can call anyway */ diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 9500fd59b8b..d53350ab3cb 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -46,6 +46,8 @@ #include "ED_mesh.h" #include "ED_armature.h" +#include "DEG_depsgraph.h" + #include "eigen_capi.h" #include "meshlaplacian.h" @@ -600,9 +602,11 @@ static float heat_limit_weight(float weight) return weight; } -void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, - bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, - float (*root)[3], float (*tip)[3], int *selected, const char **err_str) +void heat_bone_weighting( + const EvaluationContext *eval_ctx, + Object *ob, Mesh *me, float (*verts)[3], int numsource, + bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, + float (*root)[3], float (*tip)[3], int *selected, const char **err_str) { LaplacianSystem *sys; MLoopTri *mlooptri; @@ -623,7 +627,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, tottri = poly_to_tri_count(me->totpoly, me->totloop); /* count triangles and create mask */ - if (ob->mode & OB_MODE_WEIGHT_PAINT && + if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT && (use_face_sel || use_vert_sel)) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index bba8c739abf..c790c2fbee7 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -52,10 +52,12 @@ float laplacian_system_get_solution(LaplacianSystem *sys, int v); /* Heat Weighting */ -void heat_bone_weighting(struct Object *ob, struct Mesh *me, float (*verts)[3], - int numbones, struct bDeformGroup **dgrouplist, - struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - int *selected, const char **error); +void heat_bone_weighting( + const struct EvaluationContext *eval_ctx, + struct Object *ob, struct Mesh *me, float (*verts)[3], + int numbones, struct bDeformGroup **dgrouplist, + struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], + int *selected, const char **error); #ifdef RIGID_DEFORM /* As-Rigid-As-Possible Deformation */ diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index e7107ca5b20..14baa1fb179 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -196,7 +196,7 @@ bool ED_do_pose_selectbuffer( if (ob_act) { /* in weightpaint we select the associated vertex group too */ - if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { + if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { if (nearBone == arm->act_bone) { ED_vgroup_select_by_name(ob_act, nearBone->name); DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA); |