From b3a7a75a266de6765d8c04953c0dabce3c30c359 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Jun 2018 12:47:00 +0200 Subject: Cleanup: remove moar G.main usages. Notes: * Really need to address RNA setters case, end up adding way too much G.main here these days... :/ * Added Main pointer into bAnimContext, helps a lot in anim code ;) --- source/blender/collada/AnimationImporter.cpp | 37 ++++++++++++++-------------- source/blender/collada/AnimationImporter.h | 10 ++++---- source/blender/collada/DocumentImporter.cpp | 4 +-- 3 files changed, 25 insertions(+), 26 deletions(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 31dbef998d9..13bd5c16053 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -180,11 +180,11 @@ void AnimationImporter::fcurve_is_used(FCurve *fcu) } -void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated) +void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated) { bAction *act; - if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1); + if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1); else act = ob->adt->action; std::vector::iterator it; @@ -725,7 +725,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid } } -void AnimationImporter::apply_matrix_curves(Object *ob, std::vector& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, +void AnimationImporter::apply_matrix_curves(Main *bmain, Object *ob, std::vector& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm) { bool is_joint = node->getType() == COLLADAFW::Node::JOINT; @@ -840,7 +840,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob, std::vector& a add_bezt(newcu[i], fra, scale[i - 7]); } } - verify_adt_action((ID *)&ob->id, 1); + verify_adt_action(bmain, (ID *)&ob->id, 1); ListBase *curves = &ob->adt->action->curves; @@ -897,18 +897,18 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera) return aspect; } -static ListBase &get_animation_curves(Material *ma) +static ListBase &get_animation_curves(Main *bmain, Material *ma) { bAction *act; if (!ma->adt || !ma->adt->action) - act = verify_adt_action((ID *)&ma->id, 1); + act = verify_adt_action(bmain, (ID *)&ma->id, 1); else act = ma->adt->action; return act->curves; } -void AnimationImporter::translate_Animations(COLLADAFW::Node *node, +void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node, std::map& root_map, std::multimap& object_map, std::map FW_object_map, @@ -941,7 +941,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); - if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1); + if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1); else act = ob->adt->action; //Get the list of animation curves of the object @@ -972,12 +972,11 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; if (is_matrix) { - apply_matrix_curves(ob, animcurves, root, node, transform); + apply_matrix_curves(bmain, ob, animcurves, root, node, transform); } - else { - + else { if (is_joint) { - add_bone_animation_sampled(ob, animcurves, root, node, transform); + add_bone_animation_sampled(bmain, ob, animcurves, root, node, transform); } else { //calculate rnapaths and array index of fcurves according to transformation and animation class @@ -1005,7 +1004,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, if ((animType->light) != 0) { Lamp *lamp = (Lamp *) ob->data; - if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID *)&lamp->id, 1); + if (!lamp->adt || !lamp->adt->action) act = verify_adt_action(bmain, (ID *)&lamp->id, 1); else act = lamp->adt->action; ListBase *AnimCurves = &(act->curves); @@ -1039,7 +1038,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, if (animType->camera != 0) { Camera *cam = (Camera *) ob->data; if (!cam->adt || !cam->adt->action) - act = verify_adt_action((ID *)&cam->id, 1); + act = verify_adt_action(bmain, (ID *)&cam->id, 1); else act = cam->adt->action; @@ -1103,7 +1102,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, fprintf(stderr, "Collada: Node %s refers to undefined material\n", node->getName().c_str()); continue; } - ListBase &AnimCurves = get_animation_curves(ma); + ListBase &AnimCurves = get_animation_curves(bmain, ma); const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects(); COLLADAFW::EffectCommon *efc = commonEffects[0]; if ((animType->material & MATERIAL_SHININESS) != 0) { @@ -1137,7 +1136,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, delete animType; } -void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm) +void AnimationImporter::add_bone_animation_sampled(Main *bmain, Object *ob, std::vector& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm) { const char *bone_name = bc_get_joint_name(node); char joint_path[200]; @@ -1260,7 +1259,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vectorid, 1); + verify_adt_action(bmain, (ID *)&ob->id, 1); // add curves for (int i = 0; i < totcu; i++) { @@ -1436,7 +1435,7 @@ void AnimationImporter::find_frames_old(std::vector *frames, COLLADAFW::N // prerequisites: // animlist_map - map animlist id -> animlist // curve_map - map anim id -> curve(s) -Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, +Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node *node, std::map& object_map, std::map& root_map, COLLADAFW::Transformation::TransformationType tm_type, @@ -1659,7 +1658,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, #endif } - verify_adt_action((ID *)&ob->id, 1); + verify_adt_action(bmain, (ID *)&ob->id, 1); ListBase *curves = &ob->adt->action->curves; diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index e25116cac9f..0957b1e6e06 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -87,7 +87,7 @@ private: void fcurve_is_used(FCurve *fcu); - void add_fcurves_to_object(Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated); + void add_fcurves_to_object(Main *bmain, Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated); int typeFlag; @@ -153,7 +153,7 @@ public: virtual void change_eul_to_quat(Object *ob, bAction *act); #endif - void translate_Animations(COLLADAFW::Node * Node, + void translate_Animations(Main *bmain, COLLADAFW::Node * Node, std::map& root_map, std::multimap& object_map, std::map FW_object_map, @@ -161,10 +161,10 @@ public: AnimMix* get_animation_type( const COLLADAFW::Node * node, std::map FW_object_map ); - void apply_matrix_curves(Object *ob, std::vector& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, + void apply_matrix_curves(Main *bmain, Object *ob, std::vector& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm ); - void add_bone_animation_sampled(Object *ob, std::vector& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm); + void add_bone_animation_sampled(Main *bmain, Object *ob, std::vector& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm); void Assign_transform_animations(COLLADAFW::Transformation* transform, const COLLADAFW::AnimationList::AnimationBinding *binding, @@ -181,7 +181,7 @@ public: // prerequisites: // animlist_map - map animlist id -> animlist // curve_map - map anim id -> curve(s) - Object * translate_animation_OLD(COLLADAFW::Node *node, + Object * translate_animation_OLD(Main *bmain, COLLADAFW::Node *node, std::map& object_map, std::map& root_map, COLLADAFW::Transformation::TransformationType tm_type, diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index ce0d296843b..03fcc2e5037 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -285,7 +285,7 @@ void DocumentImporter::finish() void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL) { - + Main *bmain = CTX_data_main(mContext); // The split in #29246, rootmap must point at actual root when // calculating bones in apply_curves_as_matrix. - actual root is the root node. // This has to do with inverse bind poses being world space @@ -320,7 +320,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW translate_anim_recursive(node, node, parob); } else { - anim_importer.translate_Animations(node, root_map, object_map, FW_object_map, uid_material_map); + anim_importer.translate_Animations(bmain, node, root_map, object_map, FW_object_map, uid_material_map); COLLADAFW::NodePointerArray &children = node->getChildNodes(); for (i = 0; i < children.getCount(); i++) { translate_anim_recursive(children[i], node, NULL); -- cgit v1.2.3