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 Scene *scene, ListBase *targets);
+void animviz_calc_motionpaths(struct Main *bmain, struct Scene *scene, ListBase *targets);
/* ---------------------------------------------------- */
/* Curve Paths */
*/
/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
-static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
+static void motionpaths_calc_optimise_depsgraph(Main *bmain, Scene *scene, ListBase *targets)
{
Base *base, *baseNext;
MPathTarget *mpt;
}
/* "brew me a list that's sorted a bit faster now depsy" */
- DAG_scene_relations_rebuild(G.main, scene);
+ DAG_scene_relations_rebuild(bmain, scene);
}
/* update scene for current frame */
-static void motionpaths_calc_update_scene(Scene *scene)
+static void motionpaths_calc_update_scene(Main *bmain, Scene *scene)
{
#if 1 // 'production' optimizations always on
/* rigid body simulation needs complete update to work correctly for now */
/* RB_TODO investigate if we could avoid updating everything */
if (BKE_scene_check_rigidbody_active(scene)) {
- BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay);
+ BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay);
}
else { /* otherwise we can optimize by restricting updates */
Base *base, *last = NULL;
/* only stuff that moves or needs display still */
- DAG_scene_update_flags(G.main, scene, scene->lay, true, false);
+ DAG_scene_update_flags(bmain, scene, scene->lay, true, false);
/* find the last object with the tag
* - all those afterwards are assumed to not be relevant for our calculations
* is animated but not attached to/updatable from objects */
for (base = scene->base.first; base; base = base->next) {
/* update this object */
- BKE_object_handle_update(G.main, G.main->eval_ctx, scene, base->object);
+ BKE_object_handle_update(bmain, bmain->eval_ctx, scene, base->object);
/* if this is the last one we need to update, let's stop to save some time */
if (base == last)
* that doesn't force complete update, but for now, this is the
* most accurate way!
*/
- BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay); /* XXX this is the best way we can get anything moving */
+ BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay); /* XXX this is the best way we can get anything moving */
#endif
}
* - recalc: whether we need to
*/
/* TODO: include reports pointer? */
-void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
+void animviz_calc_motionpaths(Main *bmain, Scene *scene, ListBase *targets)
{
MPathTarget *mpt;
int sfra, efra;
/* optimize the depsgraph for faster updates */
/* TODO: whether this is used should depend on some setting for the level of optimizations used */
- motionpaths_calc_optimise_depsgraph(scene, targets);
+ motionpaths_calc_optimise_depsgraph(bmain, scene, targets);
/* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) {
/* update relevant data for new frame */
- motionpaths_calc_update_scene(scene);
+ motionpaths_calc_update_scene(bmain, scene);
/* perform baking for targets */
motionpaths_calc_bake_targets(scene, targets);
/* reset original environment */
CFRA = cfra;
- motionpaths_calc_update_scene(scene);
+ motionpaths_calc_update_scene(bmain, scene);
/* clear recalc flags from targets */
for (mpt = targets->first; mpt; mpt = mpt->next) {
*
* To be called from various tools that do incremental updates
*/
-void ED_pose_recalculate_paths(Scene *scene, Object *ob)
+void ED_pose_recalculate_paths(Main *bmain, Scene *scene, Object *ob)
{
ListBase targets = {NULL, NULL};
animviz_get_object_motionpaths(ob, &targets);
/* recalculate paths, then free */
- animviz_calc_motionpaths(scene, &targets);
+ animviz_calc_motionpaths(bmain, scene, &targets);
BLI_freelistN(&targets);
}
*/
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
static int pose_paste_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
bPoseChannel *chan;
/* Recalculate paths if any of the bones have paths... */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
}
/* Notifiers for updates, */
static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(bPoseChannel *), const char default_ksName[])
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
short autokey = 0;
/* now recalculate paths */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
+#include "BKE_main.h"
#include "BKE_context.h"
/* perform autokeyframing after changes were made + confirmed */
void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBase *pfLinks, float cframe)
{
+ Main *bmain = CTX_data_main(C);
+
/* insert keyframes as necessary if autokeyframing */
if (autokeyframe_cfra_can_key(scene, &ob->id)) {
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
*/
if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
}
}
}
bool ED_object_posemode_enter(struct bContext *C, struct Object *ob);
void ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
-void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
+void ED_pose_recalculate_paths(struct Main *bmain, struct Scene *scene, struct Object *ob);
struct Object *ED_pose_object_from_context(struct bContext *C);
/* sketch */
*/
void ED_objects_recalculate_paths(bContext *C, Scene *scene)
{
+ Main *bmain = CTX_data_main(C);
ListBase targets = {NULL, NULL};
/* loop over objects in scene */
CTX_DATA_END;
/* recalculate paths, then free */
- animviz_calc_motionpaths(scene, &targets);
+ animviz_calc_motionpaths(bmain, scene, &targets);
BLI_freelistN(&targets);
}
*/
if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
- ED_pose_recalculate_paths(scene, ob);
+ ED_pose_recalculate_paths(bmain, scene, ob);
}
}
else {