Cleanup: moar G.main removal from BKE area.

This commit is contained in:
Bastien Montagne 2018-06-12 17:57:24 +02:00
parent f27ecd56ef
commit 2788202417
8 changed files with 30 additions and 22 deletions

View File

@ -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 Scene *scene, ListBase *targets);
void animviz_calc_motionpaths(struct Main *bmain, struct Scene *scene, ListBase *targets);
/* ---------------------------------------------------- */
/* Curve Paths */

View File

@ -281,7 +281,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
*/
/* 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;
@ -308,23 +308,23 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
}
/* "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
@ -340,7 +340,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
* 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)
@ -353,7 +353,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
* 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
}
@ -404,7 +404,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
* - 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;
@ -430,12 +430,12 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
/* 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);
@ -443,7 +443,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *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) {

View File

@ -168,7 +168,7 @@ static bool pose_has_protected_selected(Object *ob, short warn)
*
* 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};
@ -177,7 +177,7 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob)
animviz_get_object_motionpaths(ob, &targets);
/* recalculate paths, then free */
animviz_calc_motionpaths(scene, &targets);
animviz_calc_motionpaths(bmain, scene, &targets);
BLI_freelistN(&targets);
}
@ -212,6 +212,7 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
*/
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);
@ -240,7 +241,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
/* 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);
@ -288,6 +289,7 @@ static int pose_update_paths_poll(bContext *C)
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);
@ -296,7 +298,7 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
/* 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);

View File

@ -502,6 +502,7 @@ void POSE_OT_copy(wmOperatorType *ot)
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;
@ -570,7 +571,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
/* 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, */
@ -754,6 +755,7 @@ static void pchan_clear_transforms(bPoseChannel *pchan)
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;
@ -797,7 +799,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* 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);

View File

@ -41,6 +41,7 @@
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
#include "BKE_context.h"
@ -235,6 +236,8 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
/* 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);
@ -266,7 +269,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
*/
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);
}
}
}

View File

@ -203,7 +203,7 @@ bool ED_object_posemode_enter_ex(struct Object *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 */

View File

@ -1255,6 +1255,7 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
*/
void ED_objects_recalculate_paths(bContext *C, Scene *scene)
{
Main *bmain = CTX_data_main(C);
ListBase targets = {NULL, NULL};
/* loop over objects in scene */
@ -1267,7 +1268,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
CTX_DATA_END;
/* recalculate paths, then free */
animviz_calc_motionpaths(scene, &targets);
animviz_calc_motionpaths(bmain, scene, &targets);
BLI_freelistN(&targets);
}

View File

@ -6025,7 +6025,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
*/
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 {