Avoid passing context to motion path calculation
This commit is contained in:
parent
a8777f9058
commit
0b413e406d
|
@ -41,7 +41,7 @@ struct bAnimVizSettings;
|
|||
struct bMotionPath;
|
||||
struct bPoseChannel;
|
||||
struct ReportList;
|
||||
struct bContext;
|
||||
struct Main;
|
||||
|
||||
/* ---------------------------------------------------- */
|
||||
/* Animation Visualization */
|
||||
|
@ -54,7 +54,7 @@ void animviz_free_motionpath(struct bMotionPath *mpath);
|
|||
struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan);
|
||||
|
||||
void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
|
||||
void animviz_calc_motionpaths(struct bContext *C, struct Scene *scene, ListBase *targets);
|
||||
void animviz_calc_motionpaths(struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *scene, ListBase *targets);
|
||||
|
||||
/* ---------------------------------------------------- */
|
||||
/* Curve Paths */
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "BKE_anim.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_build.h"
|
||||
|
||||
// XXX bad level call...
|
||||
|
@ -341,15 +342,11 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
|
|||
* - recalc: whether we need to
|
||||
*/
|
||||
/* TODO: include reports pointer? */
|
||||
void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
|
||||
void animviz_calc_motionpaths(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, ListBase *targets)
|
||||
{
|
||||
MPathTarget *mpt;
|
||||
int sfra, efra;
|
||||
int cfra;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
/* TODO(sergey): Should we mabe pass scene layer explicitly? */
|
||||
SceneLayer *scene_layer = CTX_data_scene_layer(C);
|
||||
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
|
||||
/* sanity check */
|
||||
if (ELEM(NULL, targets, targets->first))
|
||||
|
@ -372,7 +369,7 @@ void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
|
|||
/* calculate path over requested range */
|
||||
for (CFRA = sfra; CFRA <= efra; CFRA++) {
|
||||
/* update relevant data for new frame */
|
||||
motionpaths_calc_update_scene(bmain, scene, scene_layer, depsgraph);
|
||||
motionpaths_calc_update_scene(bmain, scene, eval_ctx->scene_layer, eval_ctx->depsgraph);
|
||||
|
||||
/* perform baking for targets */
|
||||
motionpaths_calc_bake_targets(scene, targets);
|
||||
|
@ -380,7 +377,7 @@ void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
|
|||
|
||||
/* reset original environment */
|
||||
CFRA = cfra;
|
||||
motionpaths_calc_update_scene(bmain, scene, scene_layer, depsgraph);
|
||||
motionpaths_calc_update_scene(bmain, scene, eval_ctx->scene_layer, eval_ctx->depsgraph);
|
||||
|
||||
/* clear recalc flags from targets */
|
||||
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
||||
|
|
|
@ -161,6 +161,9 @@ static bool pose_has_protected_selected(Object *ob, short warn)
|
|||
*/
|
||||
void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
|
||||
{
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
EvaluationContext eval_ctx;
|
||||
CTX_data_eval_ctx(C, &eval_ctx);
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
/* set flag to force recalc, then grab the relevant bones to target */
|
||||
|
@ -168,7 +171,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
|
|||
animviz_get_object_motionpaths(ob, &targets);
|
||||
|
||||
/* recalculate paths, then free */
|
||||
animviz_calc_motionpaths(C, scene, &targets);
|
||||
animviz_calc_motionpaths(&eval_ctx, bmain, scene, &targets);
|
||||
BLI_freelistN(&targets);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ struct SceneLayer;
|
|||
struct ViewContext;
|
||||
struct wmKeyConfig;
|
||||
struct wmOperator;
|
||||
struct Main;
|
||||
|
||||
typedef struct EditBone {
|
||||
struct EditBone *next, *prev;
|
||||
|
|
|
@ -1033,6 +1033,9 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
|
|||
*/
|
||||
void ED_objects_recalculate_paths(bContext *C, Scene *scene)
|
||||
{
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
EvaluationContext eval_ctx;
|
||||
CTX_data_eval_ctx(C, &eval_ctx);
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
/* loop over objects in scene */
|
||||
|
@ -1045,7 +1048,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
|
|||
CTX_DATA_END;
|
||||
|
||||
/* recalculate paths, then free */
|
||||
animviz_calc_motionpaths(C, scene, &targets);
|
||||
animviz_calc_motionpaths(&eval_ctx, bmain, scene, &targets);
|
||||
BLI_freelistN(&targets);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue