diff options
Diffstat (limited to 'source/blender/editors/space_view3d/drawarmature.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 115574a5ffe..191dfed01bf 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -54,6 +54,9 @@ #include "BKE_modifier.h" #include "BKE_nla.h" #include "BKE_curve.h" +#include "BKE_context.h" + +#include "DEG_depsgraph.h" #include "BIF_glutil.h" @@ -1607,7 +1610,7 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag } } -static void draw_custom_bone(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob, +static void draw_custom_bone(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Object *ob, const short dt, int armflag, int boneflag, unsigned int id, float length) { if (ob == NULL) return; @@ -1623,7 +1626,7 @@ static void draw_custom_bone(Scene *scene, SceneLayer *sl, View3D *v3d, RegionVi GPU_select_load_id((GLuint) id | BONESEL_BONE); } - draw_object_instance(scene, sl, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE, fcolor); + draw_object_instance(C, scene, sl, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE, fcolor); } @@ -1927,7 +1930,7 @@ static void bone_matrix_translate_y(float mat[4][4], float y) } /* assumes object is Armature with pose */ -static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base, +static void draw_pose_bones(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base, const short dt, const unsigned char ob_wire_col[4], const bool do_const_color, const bool is_outline) { @@ -2054,7 +2057,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * glDisable(GL_CULL_FACE); } - draw_custom_bone(scene, sl, v3d, rv3d, pchan->custom, + draw_custom_bone(C, scene, sl, v3d, rv3d, pchan->custom, OB_SOLID, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); } } @@ -2150,7 +2153,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * if (bone == arm->act_bone) flag |= BONE_DRAW_ACTIVE; - draw_custom_bone(scene, sl, v3d, rv3d, pchan->custom, + draw_custom_bone(C, scene, sl, v3d, rv3d, pchan->custom, OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); gpuPopMatrix(); @@ -2656,8 +2659,9 @@ static void ghost_poses_tag_unselected(Object *ob, short unset) /* draw ghosts that occur within a frame range * note: object should be in posemode */ -static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base) +static void draw_ghost_poses_range(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base) { + EvaluationContext eval_ctx; Object *ob = base->object; AnimData *adt = BKE_animdata_from_id(&ob->id); bArmature *arm = ob->data; @@ -2665,6 +2669,8 @@ static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, AR float start, end, stepsize, range, colfac; int cfrao, flago; unsigned char col[4]; + + CTX_data_eval_ctx(C, &eval_ctx); start = (float)arm->ghostsf; end = (float)arm->ghostef; @@ -2700,8 +2706,8 @@ static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, AR UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false); + BKE_pose_where_is(&eval_ctx, scene, ob); + draw_pose_bones(C, scene, sl, v3d, ar, base, OB_WIRE, col, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2723,8 +2729,9 @@ static void draw_ghost_poses_range(Scene *scene, SceneLayer *sl, View3D *v3d, AR /* draw ghosts on keyframes in action within range * - object should be in posemode */ -static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, BaseLegacy *base) +static void draw_ghost_poses_keys(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, BaseLegacy *base) { + EvaluationContext eval_ctx; Object *ob = base->object; AnimData *adt = BKE_animdata_from_id(&ob->id); bAction *act = (adt) ? adt->action : NULL; @@ -2735,6 +2742,8 @@ static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARe float start, end, range, colfac, i; int cfrao, flago; unsigned char col[4]; + + CTX_data_eval_ctx(C, &eval_ctx); start = (float)arm->ghostsf; end = (float)arm->ghostef; @@ -2781,8 +2790,8 @@ static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARe CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false); + BKE_pose_where_is(&eval_ctx, scene, ob); + draw_pose_bones(C, scene, sl, v3d, ar, base, OB_WIRE, col, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2805,8 +2814,9 @@ static void draw_ghost_poses_keys(Scene *scene, SceneLayer *sl, View3D *v3d, ARe /* draw ghosts around current frame * - object is supposed to be armature in posemode */ -static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base) +static void draw_ghost_poses(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base) { + EvaluationContext eval_ctx; Object *ob = base->object; AnimData *adt = BKE_animdata_from_id(&ob->id); bArmature *arm = ob->data; @@ -2814,6 +2824,8 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion float cur, start, end, stepsize, range, colfac, actframe, ctime; int cfrao, flago; unsigned char col[4]; + + CTX_data_eval_ctx(C, &eval_ctx); /* pre conditions, get an action with sufficient frames */ if (ELEM(NULL, adt, adt->action)) @@ -2859,8 +2871,8 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false); + BKE_pose_where_is(&eval_ctx, scene, ob); + draw_pose_bones(C, scene, sl, v3d, ar, base, OB_WIRE, col, true, false); } } @@ -2874,8 +2886,8 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, sl, v3d, ar, base, OB_WIRE, col, true, false); + BKE_pose_where_is(&eval_ctx, scene, ob); + draw_pose_bones(C, scene, sl, v3d, ar, base, OB_WIRE, col, true, false); } } } @@ -2900,7 +2912,7 @@ static void draw_ghost_poses(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion /* called from drawobject.c, return true if nothing was drawn * (ob_wire_col == NULL) when drawing ghost */ -bool draw_armature(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base, +bool draw_armature(const bContext *C, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base *base, const short dt, const short dflag, const unsigned char ob_wire_col[4], const bool is_outline) { @@ -2960,14 +2972,14 @@ bool draw_armature(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base } else if (ob->mode & OB_MODE_POSE) { if (arm->ghosttype == ARM_GHOST_RANGE) { - draw_ghost_poses_range(scene, sl, v3d, ar, base); + draw_ghost_poses_range(C, scene, sl, v3d, ar, base); } else if (arm->ghosttype == ARM_GHOST_KEYS) { - draw_ghost_poses_keys(scene, sl, v3d, ar, base); + draw_ghost_poses_keys(C, scene, sl, v3d, ar, base); } else if (arm->ghosttype == ARM_GHOST_CUR) { if (arm->ghostep) - draw_ghost_poses(scene, sl, v3d, ar, base); + draw_ghost_poses(C, scene, sl, v3d, ar, base); } if ((dflag & DRAW_SCENESET) == 0) { if (ob == OBACT_NEW) @@ -2980,7 +2992,7 @@ bool draw_armature(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, Base } } } - draw_pose_bones(scene, sl, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline); + draw_pose_bones(C, scene, sl, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline); arm->flag &= ~ARM_POSEMODE; } else { |