Cleanup: Nuke moar G.main usages...

This commit is contained in:
Bastien Montagne 2018-06-06 15:50:24 +02:00
parent bfbd85e9d6
commit 48e871ab1d
35 changed files with 148 additions and 124 deletions

View File

@ -62,10 +62,11 @@ ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSett
}
// write bone nodes
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
void ArmatureExporter::add_armature_bones(bContext *C, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
Main *bmain = CTX_data_main(C);
// write bone nodes
bArmature * armature = (bArmature *)ob_arm->data;
@ -77,11 +78,11 @@ void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
add_bone_node(bone, ob_arm, sce, se, child_objects);
add_bone_node(C, bone, ob_arm, sce, se, child_objects);
}
if (!is_edited) {
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
}
}
@ -160,7 +161,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
#endif
// parent_mat is armature-space
void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
void ArmatureExporter::add_bone_node(bContext *C, Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
@ -234,7 +235,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
}
se->writeNodes(*i, sce);
se->writeNodes(C, *i, sce);
copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++);
@ -243,13 +244,13 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
}
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
add_bone_node(C, child, ob_arm, sce, se, child_objects);
}
node.end();
}
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
add_bone_node(C, child, ob_arm, sce, se, child_objects);
}
}
}

View File

@ -60,7 +60,7 @@ public:
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
// write bone nodes
void add_armature_bones(Object *ob_arm, Scene *sce, SceneExporter *se,
void add_armature_bones(bContext *C, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
bool add_instance_controller(Object *ob);
@ -85,7 +85,7 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
void add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
void add_bone_node(bContext *C, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);

View File

@ -446,7 +446,7 @@ ArmatureJoints& ArmatureImporter::get_armature_joints(Object *ob_arm)
return armature_joints.back();
}
#endif
void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *> &ob_arms)
{
std::vector<COLLADAFW::Node *>::iterator ri;
std::vector<std::string> layer_labels;
@ -479,7 +479,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
}
/* exit armature edit mode to populate the Armature object */
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
ED_armature_to_edit(armature);
@ -487,7 +487,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
fix_leaf_bone_hierarchy(armature, (Bone *)armature->bonebase.first, this->import_settings->fix_orientation);
unskinned_armature_map[(*ri)->getUniqueId()] = ob_arm;
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
int index = std::find(ob_arms.begin(), ob_arms.end(), ob_arm) - ob_arms.begin();
@ -499,7 +499,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms)
}
}
Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin)
{
// just do like so:
// - get armature
@ -617,7 +617,7 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
}
/* exit armature edit mode to populate the Armature object */
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
ED_armature_to_edit(armature);
@ -625,7 +625,7 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
connect_bone_chains(armature, (Bone *)armature->bonebase.first, UNLIMITED_CHAIN_MAX);
}
fix_leaf_bone_hierarchy(armature, (Bone *)armature->bonebase.first, this->import_settings->fix_orientation);
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
@ -707,6 +707,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
// here we add bones to armatures, having armatures previously created in write_controller
void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &objects_to_scale)
{
Main *bmain = CTX_data_main(C);
std::vector<Object *> ob_arms;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
@ -716,7 +717,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
SkinInfo& skin = it->second;
Object *ob_arm = create_armature_bones(skin);
Object *ob_arm = create_armature_bones(bmain, skin);
// link armature with a mesh object
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
@ -757,7 +758,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
}
//for bones without skins
create_armature_bones(ob_arms);
create_armature_bones(bmain, ob_arms);
// Fix bone relations
std::vector<Object *>::iterator ob_arm_it;
@ -771,7 +772,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
fix_parent_connect(armature, (Bone *)armature->bonebase.first);
ED_armature_from_edit(armature);
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
}
}

View File

@ -129,8 +129,8 @@ private:
ArmatureJoints& get_armature_joints(Object *ob_arm);
#endif
Object *create_armature_bones(SkinInfo& skin);
void create_armature_bones(std::vector<Object *> &arm_objs);
Object *create_armature_bones(Main *bmain, SkinInfo& skin);
void create_armature_bones(Main *bmain, std::vector<Object *> &arm_objs);
/** TagsMap typedef for uid_tags_map. */
typedef std::map<std::string, ExtraTags*> TagsMap;

View File

@ -181,7 +181,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
// COLLADA allows this through multiple <channel>s in <animation>.
// For this to work, we need to know objects that use a certain action.
int DocumentExporter::exportCurrentScene(const EvaluationContext *eval_ctx, Scene *sce)
int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *eval_ctx, Scene *sce)
{
PointerRNA sceneptr, unit_settings;
PropertyRNA *system; /* unused , *scale; */
@ -307,7 +307,7 @@ int DocumentExporter::exportCurrentScene(const EvaluationContext *eval_ctx, Scen
AnimationExporter ae(writer, this->export_settings);
ae.exportAnimations(sce);
}
se.exportScene(sce);
se.exportScene(C, sce);
// <scene>
std::string scene_name(translate_id(id_name(sce)));

View File

@ -40,7 +40,7 @@ class DocumentExporter
{
public:
DocumentExporter(const ExportSettings *export_settings);
int exportCurrentScene(const EvaluationContext *eval_ctx, Scene *sce);
int exportCurrentScene(bContext *C, const EvaluationContext *eval_ctx, Scene *sce);
void exportScenes(const char *filename);
private:
const ExportSettings *export_settings;

View File

@ -38,17 +38,17 @@ SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm,
{
}
void SceneExporter::exportScene(Scene *sce)
void SceneExporter::exportScene(bContext *C, Scene *sce)
{
// <library_visual_scenes> <visual_scene>
std::string id_naming = id_name(sce);
openVisualScene(translate_id(id_naming), id_naming);
exportHierarchy(sce);
exportHierarchy(C, sce);
closeVisualScene();
closeLibrary();
}
void SceneExporter::exportHierarchy(Scene *sce)
void SceneExporter::exportHierarchy(bContext *C, Scene *sce)
{
LinkNode *node;
std::vector<Object *> base_objects;
@ -80,13 +80,13 @@ void SceneExporter::exportHierarchy(Scene *sce)
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
bc_remove_mark(ob);
writeNodes(ob, sce);
writeNodes(C, ob, sce);
}
}
}
void SceneExporter::writeNodes(Object *ob, Scene *sce)
void SceneExporter::writeNodes(bContext *C, Object *ob, Scene *sce)
{
// Add associated armature first if available
bool armature_exported = false;
@ -95,7 +95,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
if (armature_exported && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm);
writeNodes(ob_arm, sce);
writeNodes(C, ob_arm, sce);
armature_exported = true;
}
}
@ -157,7 +157,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
// <instance_controller>
else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, sce, this, child_objects);
arm_exporter->add_armature_bones(C, ob, sce, this, child_objects);
}
// <instance_camera>
@ -235,7 +235,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) {
bc_remove_mark(*i);
writeNodes(*i, sce);
writeNodes(C, *i, sce);
}
}

View File

@ -96,12 +96,12 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
{
public:
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
void exportScene(Scene *sce);
void exportScene(bContext *C, Scene *sce);
private:
friend class ArmatureExporter;
void exportHierarchy(Scene *sce);
void writeNodes(Object *ob, Scene *sce);
void exportHierarchy(bContext *C, Scene *sce);
void writeNodes(bContext *C, Object *ob, Scene *sce);
ArmatureExporter *arm_exporter;
const ExportSettings *export_settings;

View File

@ -48,7 +48,8 @@ int collada_import(bContext *C, ImportSettings *import_settings)
return (imp.import())? 1:0;
}
int collada_export(EvaluationContext *eval_ctx,
int collada_export(bContext *C,
EvaluationContext *eval_ctx,
Scene *sce,
ExportSettings *export_settings)
{
@ -75,7 +76,7 @@ int collada_export(EvaluationContext *eval_ctx,
}
DocumentExporter exporter(export_settings);
int status = exporter.exportCurrentScene(eval_ctx, sce);
int status = exporter.exportCurrentScene(C, eval_ctx, sce);
BLI_linklist_free(export_settings->export_set, NULL);

View File

@ -52,7 +52,8 @@ struct Scene;
int collada_import(struct bContext *C,
ImportSettings *import_settings);
int collada_export(struct EvaluationContext *eval_ctx,
int collada_export(struct bContext *C,
struct EvaluationContext *eval_ctx,
struct Scene *sce,
ExportSettings *export_settings);

View File

@ -49,6 +49,7 @@
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "RNA_access.h"
@ -66,7 +67,7 @@
/* ************************** Object Tools Exports ******************************* */
/* NOTE: these functions are exported to the Object module to be called from the tools there */
void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_props)
void ED_armature_transform_apply(Main *bmain, Object *ob, float mat[4][4], const bool do_props)
{
bArmature *arm = ob->data;
@ -77,7 +78,7 @@ void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_prop
ED_armature_transform_bones(arm, mat, do_props);
/* Turn the list into an armature */
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}
@ -118,7 +119,7 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b
}
}
void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props)
void ED_armature_transform(Main *bmain, bArmature *arm, float mat[4][4], const bool do_props)
{
if (arm->edbo) {
ED_armature_transform_bones(arm, mat, do_props);
@ -131,14 +132,14 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do
ED_armature_transform_bones(arm, mat, do_props);
/* Go back to object mode*/
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}
}
/* exported for use in editors/object/ */
/* 0 == do center, 1 == center new, 2 == center cursor */
void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int centermode, int around)
void ED_armature_origin_set(Main *bmain, Scene *scene, Object *ob, float cursor[3], int centermode, int around)
{
Object *obedit = scene->obedit; // XXX get from context
EditBone *ebone;
@ -189,7 +190,7 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente
/* Turn the list into an armature */
if (obedit == NULL) {
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
}

View File

@ -397,7 +397,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
DAG_relations_tag_update(bmain); /* because we removed object(s) */
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
@ -513,7 +513,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
* sel: remove selected bones from the armature, otherwise the unselected bones are removed
* (ob is not in editmode)
*/
static void separate_armature_bones(Object *ob, short sel)
static void separate_armature_bones(Main *bmain, Object *ob, short sel)
{
bArmature *arm = (bArmature *)ob->data;
bPoseChannel *pchan, *pchann;
@ -560,7 +560,7 @@ static void separate_armature_bones(Object *ob, short sel)
}
/* exit editmode (recalculates pchans too) */
ED_armature_from_edit(ob->data);
ED_armature_from_edit(bmain, ob->data);
ED_armature_edit_free(ob->data);
}
@ -603,7 +603,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
oldob->mode &= ~OB_MODE_POSE;
//oldbase->flag &= ~OB_POSEMODE;
ED_armature_from_edit(obedit->data);
ED_armature_from_edit(bmain, obedit->data);
ED_armature_edit_free(obedit->data);
/* 2) duplicate base */
@ -615,8 +615,8 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* 3) remove bones that shouldn't still be around on both armatures */
separate_armature_bones(oldob, 1);
separate_armature_bones(newob, 0);
separate_armature_bones(bmain, oldob, 1);
separate_armature_bones(bmain, newob, 0);
/* 4) fix links before depsgraph flushes */ // err... or after?

View File

@ -584,7 +584,7 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis
}
/* put EditMode back in Object */
void ED_armature_from_edit(bArmature *arm)
void ED_armature_from_edit(Main *bmain, bArmature *arm)
{
EditBone *eBone, *neBone;
Bone *newBone;
@ -678,7 +678,7 @@ void ED_armature_from_edit(bArmature *arm)
armature_finalize_restpose(&arm->bonebase, arm->edbo);
/* so all users of this armature should get rebuilt */
for (obt = G.main->object.first; obt; obt = obt->id.next) {
for (obt = bmain->object.first; obt; obt = obt->id.next) {
if (obt->data == arm) {
BKE_pose_rebuild(obt, arm);
}

View File

@ -40,6 +40,7 @@
#include "BKE_constraint.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "ED_armature.h"
#include "ED_undo.h"
@ -2413,6 +2414,7 @@ static void finishRetarget(RigGraph *rigg)
static void adjustGraphs(bContext *C, RigGraph *rigg)
{
Main *bmain = CTX_data_main(C);
bArmature *arm = rigg->ob->data;
RigArc *arc;
@ -2426,13 +2428,14 @@ static void adjustGraphs(bContext *C, RigGraph *rigg)
/* Turn the list into an armature */
arm->edbo = rigg->editbones;
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_undo_push(C, "Retarget Skeleton");
}
static void retargetGraphs(bContext *C, RigGraph *rigg)
{
Main *bmain = CTX_data_main(C);
bArmature *arm = rigg->ob->data;
ReebGraph *reebg = rigg->link_mesh;
RigNode *inode;
@ -2453,7 +2456,7 @@ static void retargetGraphs(bContext *C, RigGraph *rigg)
/* Turn the list into an armature */
arm->edbo = rigg->editbones;
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
}
const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)

View File

@ -92,6 +92,7 @@ static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
/* set the current pose as the restpose */
static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
bArmature *arm = BKE_armature_from_object(ob);
@ -185,7 +186,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
}
/* convert editbones back to bones, and then free the edit-data */
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
/* flush positions of posebones */

View File

@ -1102,7 +1102,7 @@ static int *initialize_index_map(Object *obedit, int *r_old_totvert)
return old_to_new_map;
}
static void remap_hooks_and_vertex_parents(Object *obedit)
static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
{
Object *object;
Curve *curve = (Curve *) obedit->data;
@ -1118,7 +1118,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
return;
}
for (object = G.main->object.first; object; object = object->id.next) {
for (object = bmain->object.first; object; object = object->id.next) {
ModifierData *md;
int index;
if ((object->parent) &&
@ -1181,7 +1181,7 @@ static void remap_hooks_and_vertex_parents(Object *obedit)
}
/* load editNurb in object */
void ED_curve_editnurb_load(Object *obedit)
void ED_curve_editnurb_load(Main *bmain, Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
@ -1192,7 +1192,7 @@ void ED_curve_editnurb_load(Object *obedit)
Nurb *nu, *newnu;
ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb;
remap_hooks_and_vertex_parents(obedit);
remap_hooks_and_vertex_parents(bmain, obedit);
for (nu = editnurb->first; nu; nu = nu->next) {
newnu = BKE_nurb_duplicate(nu);
@ -1321,7 +1321,7 @@ static int separate_exec(bContext *C, wmOperator *op)
BLI_movelisttolist(&newedit->nurbs, &newnurb);
/* 4. put old object out of editmode and delete separated geometry */
ED_curve_editnurb_load(newob);
ED_curve_editnurb_load(bmain, newob);
ED_curve_editnurb_free(newob);
curve_delete_segments(oldob, true);

View File

@ -41,6 +41,7 @@ struct Bone;
struct bPoseChannel;
struct IDProperty;
struct ListBase;
struct Main;
struct MeshDeformModifierData;
struct DerivedMesh;
struct Object;
@ -126,7 +127,7 @@ void ED_operatormacros_armature(void);
void ED_keymap_armature(struct wmKeyConfig *keyconf);
/* editarmature.c */
void ED_armature_from_edit(struct bArmature *arm);
void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm);
void ED_armature_to_edit(struct bArmature *arm);
void ED_armature_edit_free(struct bArmature *arm);
@ -162,11 +163,11 @@ void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
void ED_armature_edit_transform_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
void ED_armature_origin_set(struct Main *bmain, struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
void ED_armature_transform_apply(struct Object *ob, float mat[4][4], const bool do_props);
void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props);
void ED_armature_transform_apply(struct Main *bmain, struct Object *ob, float mat[4][4], const bool do_props);
void ED_armature_transform(struct Main *bmain, struct bArmature *arm, float mat[4][4], const bool do_props);
#define ARM_GROUPS_NAME 1
#define ARM_GROUPS_ENVELOPE 2

View File

@ -32,15 +32,16 @@
#define __ED_CURVE_H__
struct bContext;
struct BezTriple;
struct BPoint;
struct Curve;
struct EditNurb;
struct Main;
struct Nurb;
struct Object;
struct Text;
struct wmOperator;
struct wmKeyConfig;
struct Curve;
struct EditNurb;
struct BezTriple;
struct BPoint;
struct UndoType;
/* curve_ops.c */
@ -51,7 +52,7 @@ void ED_keymap_curve(struct wmKeyConfig *keyconf);
/* editcurve.c */
struct ListBase *object_editcurve_get(struct Object *ob);
void ED_curve_editnurb_load(struct Object *obedit);
void ED_curve_editnurb_load(struct Main *bmain, struct Object *obedit);
void ED_curve_editnurb_make(struct Object *obedit);
void ED_curve_editnurb_free(struct Object *obedit);

View File

@ -117,7 +117,7 @@ enum {
EM_WAITCURSOR = (1 << 1),
EM_IGNORE_LAYER = (1 << 3),
};
bool ED_object_editmode_exit_ex(struct Scene *scene, struct Object *obedit, int flag);
bool ED_object_editmode_exit_ex(struct Main *bmain, struct Scene *scene, struct Object *obedit, int flag);
bool ED_object_editmode_exit(struct bContext *C, int flag);
bool ED_object_editmode_enter(struct bContext *C, int flag);
bool ED_object_editmode_load(struct Main *bmain, struct Object *obedit);

View File

@ -98,14 +98,14 @@ void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
int ED_area_headersize(void);
/* screens */
void ED_screens_initialize(struct wmWindowManager *wm);
void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm);
void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc);
bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, const char *name);
bScreen *ED_screen_duplicate(struct Main *bmain, struct wmWindow *win, struct bScreen *sc);
bScreen *ED_screen_add(struct Main *bmain, struct wmWindow *win, struct Scene *scene, const char *name);
bool ED_screen_set(struct bContext *C, struct bScreen *sc);
bool ED_screen_delete(struct bContext *C, struct bScreen *sc);
void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene);

View File

@ -205,10 +205,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
export_count = collada_export(eval_ctx,
scene,
&export_settings
);
export_count = collada_export(
C,
eval_ctx,
scene,
&export_settings);
if (export_count == 0) {
BKE_report(op->reports, RPT_WARNING, "No objects selected -- Created empty export file");

View File

@ -150,7 +150,7 @@ bConstraint *get_active_constraint(Object *ob)
/* ------------- PyConstraints ------------------ */
/* this callback sets the text-file to be used for selected menu item */
static void validate_pyconstraint_cb(void *arg1, void *arg2)
static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
{
bPythonConstraint *data = arg1;
Text *text = NULL;
@ -160,13 +160,13 @@ static void validate_pyconstraint_cb(void *arg1, void *arg2)
/* exception for no script */
if (index) {
/* innovative use of a for...loop to search */
for (text = G.main->text.first, i = 1; text && index != i; i++, text = text->id.next) ;
for (text = bmain->text.first, i = 1; text && index != i; i++, text = text->id.next) ;
}
data->text = text;
}
/* this returns a string for the list of usable pyconstraint script names */
static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex)
static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconindex)
{
DynStr *pupds = BLI_dynstr_new();
Text *text;
@ -183,7 +183,7 @@ static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex)
*pyconindex = 0;
/* loop through markers, adding them */
for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) {
for (text = bmain->text.first, i = 1; text; i++, text = text->id.next) {
/* this is important to ensure that right script is shown as active */
if (text == con_text) *pyconindex = i;
@ -1792,14 +1792,14 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
char *menustr;
int scriptint = 0;
/* popup a list of usable scripts */
menustr = buildmenu_pyconstraints(NULL, &scriptint);
menustr = buildmenu_pyconstraints(bmain, NULL, &scriptint);
/* XXX scriptint = pupmenu(menustr); */
MEM_freeN(menustr);
/* only add constraint if a script was chosen */
if (scriptint) {
/* add constraint */
validate_pyconstraint_cb(con->data, &scriptint);
validate_pyconstraint_cb(bmain, con->data, &scriptint);
/* make sure target allowance is set correctly */
BPY_pyconstraint_update(ob, con);

View File

@ -383,7 +383,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (arm->edbo == NULL) {
return false;
}
ED_armature_from_edit(obedit->data);
ED_armature_from_edit(bmain, obedit->data);
if (freedata) {
ED_armature_edit_free(obedit->data);
}
@ -398,7 +398,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
if (cu->editnurb == NULL) {
return false;
}
ED_curve_editnurb_load(obedit);
ED_curve_editnurb_load(bmain, obedit);
if (freedata) {
ED_curve_editnurb_free(obedit);
}
@ -446,13 +446,13 @@ bool ED_object_editmode_load(Main *bmain, Object *obedit)
* \param flag:
* - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
*/
bool ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
{
const bool freedata = (flag & EM_FREEDATA) != 0;
if (flag & EM_WAITCURSOR) waitcursor(1);
if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
if (ED_object_editmode_load_ex(bmain, obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
if (UNLIKELY(scene->basact && (scene->basact->object->mode & OB_MODE_EDIT))) {
@ -495,9 +495,10 @@ bool ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag)
bool ED_object_editmode_exit(bContext *C, int flag)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
return ED_object_editmode_exit_ex(scene, obedit, flag);
return ED_object_editmode_exit_ex(bmain, scene, obedit, flag);
}
bool ED_object_editmode_enter(bContext *C, int flag)

View File

@ -301,7 +301,7 @@ static int return_editcurve_indexar(
return totvert;
}
static bool object_hook_index_array(Scene *scene, Object *obedit,
static bool object_hook_index_array(Main *bmain, Scene *scene, Object *obedit,
int *r_tot, int **r_indexar, char *r_name, float r_cent[3])
{
*r_indexar = NULL;
@ -333,7 +333,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit,
}
case OB_CURVE:
case OB_SURF:
ED_curve_editnurb_load(obedit);
ED_curve_editnurb_load(bmain, obedit);
ED_curve_editnurb_make(obedit);
return return_editcurve_indexar(obedit, r_tot, r_indexar, r_cent);
case OB_LATTICE:
@ -473,7 +473,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
int tot, ok, *indexar;
char name[MAX_NAME];
ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
ok = object_hook_index_array(bmain, scene, obedit, &tot, &indexar, name, cent);
if (!ok) {
BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group");
@ -809,6 +809,7 @@ void OBJECT_OT_hook_recenter(wmOperatorType *ot)
static int object_hook_assign_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier);
int num = RNA_enum_get(op->ptr, "modifier");
@ -826,7 +827,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
/* assign functionality */
if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) {
if (!object_hook_index_array(bmain, scene, ob, &tot, &indexar, name, cent)) {
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}

View File

@ -1759,7 +1759,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object *
MEM_freeN(emap);
MEM_freeN(emap_mem);
ED_armature_from_edit(arm);
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
return arm_ob;

View File

@ -547,7 +547,7 @@ static int apply_objects_internal(
BKE_mesh_calc_normals(me);
}
else if (ob->type == OB_ARMATURE) {
ED_armature_transform_apply(ob, mat, do_props);
ED_armature_transform_apply(bmain, ob, mat, do_props);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@ -994,7 +994,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* Function to recenter armatures in editarmature.c
* Bone + object locations are handled there.
*/
ED_armature_origin_set(scene, ob, cursor, centermode, around);
ED_armature_origin_set(bmain, scene, ob, cursor, centermode, around);
tot_change++;
arm->id.tag |= LIB_TAG_DOIT;

View File

@ -459,7 +459,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
/* empty screen, with 1 dummy area without spacedata */
/* uses window size */
bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
bScreen *ED_screen_add(Main *bmain, wmWindow *win, Scene *scene, const char *name)
{
const int winsize_x = WM_window_pixels_x(win);
const int winsize_y = WM_window_pixels_y(win);
@ -467,7 +467,7 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
sc = BKE_libblock_alloc(G.main, ID_SCR, name, 0);
sc = BKE_libblock_alloc(bmain, ID_SCR, name, 0);
sc->scene = scene;
sc->do_refresh = true;
sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
@ -837,14 +837,14 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc)
bScreen *ED_screen_duplicate(Main *bmain, wmWindow *win, bScreen *sc)
{
bScreen *newsc;
if (sc->state != SCREENNORMAL) return NULL; /* XXX handle this case! */
/* make new empty screen: */
newsc = ED_screen_add(win, sc->scene, sc->id.name + 2);
newsc = ED_screen_add(bmain, win, sc->scene, sc->id.name + 2);
/* copy all data */
screen_copy(newsc, sc);
@ -951,14 +951,14 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
}
/* file read, set all screens, ... */
void ED_screens_initialize(wmWindowManager *wm)
void ED_screens_initialize(Main *bmain, wmWindowManager *wm)
{
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
if (win->screen == NULL)
win->screen = G.main->screen.first;
win->screen = bmain->screen.first;
ED_screen_refresh(wm, win);
}
@ -1566,6 +1566,7 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
*/
ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *sc, *oldscreen;
ARegion *ar;
@ -1648,7 +1649,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
oldscreen->state = state;
BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal");
sc = ED_screen_add(win, oldscreen->scene, newname);
sc = ED_screen_add(bmain, win, oldscreen->scene, newname);
sc->state = state;
sc->redraws_flag = oldscreen->redraws_flag;
sc->temp = oldscreen->temp;

View File

@ -1007,6 +1007,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
/* operator callback */
static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
wmWindow *newwin, *win;
bScreen *newsc, *sc;
ScrArea *sa;
@ -1041,7 +1042,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
*newwin->stereo3d_format = *win->stereo3d_format;
/* allocs new screen and adds to newly created window, using window size */
newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2);
newsc = ED_screen_add(bmain, newwin, CTX_data_scene(C), sc->id.name + 2);
newwin->screen = newsc;
/* copy area to new screen */
@ -4066,10 +4067,11 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sc = ED_screen_duplicate(win, sc);
sc = ED_screen_duplicate(bmain, win, sc);
WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc);
return OPERATOR_FINISHED;

View File

@ -2313,7 +2313,7 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const
#if 0
/* Kept for reference here, in case we want to add back that feature later. We do not need it currently. */
/* Code ***NOT*** updated for job stuff! */
static void filelist_readjob_main_rec(struct FileList *filelist)
static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
{
ID *id;
FileDirEntry *files, *firstlib = NULL;
@ -2375,7 +2375,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist)
/* make files */
idcode = groupname_to_code(filelist->filelist.root);
lb = which_libbase(G.main, idcode);
lb = which_libbase(bmain, idcode);
if (lb == NULL) return;
filelist->filelist.nbr_entries = 0;

View File

@ -478,9 +478,9 @@ static int rna_Armature_is_editmode_get(PointerRNA *ptr)
return (arm->edbo != NULL);
}
static void rna_Armature_transform(struct bArmature *arm, float *mat)
static void rna_Armature_transform(struct bArmature *arm, Main *bmain, float *mat)
{
ED_armature_transform(arm, (float (*)[4])mat, true);
ED_armature_transform(bmain, arm, (float (*)[4])mat, true);
}
#else
@ -1011,6 +1011,7 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "bArmature");
func = RNA_def_function(srna, "transform", "rna_Armature_transform");
RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Transform armature bones by a matrix");
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);

View File

@ -283,7 +283,7 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA
break;
case OB_CURVE:
case OB_SURF:
ED_curve_editnurb_load(ob);
ED_curve_editnurb_load(bmain, ob);
ED_curve_editnurb_make(ob);
break;
case OB_LATTICE:

View File

@ -381,6 +381,7 @@ void WM_keymap_init(bContext *C)
void WM_check(bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
/* wm context */
@ -407,7 +408,7 @@ void WM_check(bContext *C)
/* case: fileread */
/* note: this runs in bg mode to set the screen context cb */
if ((wm->initialized & WM_INIT_WINDOW) == 0) {
ED_screens_initialize(wm);
ED_screens_initialize(bmain, wm);
wm->initialized |= WM_INIT_WINDOW;
}
}

View File

@ -226,14 +226,14 @@ static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWi
* 4- current wm, and wm in file: try match ghostwin
*/
static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
static void wm_window_match_do(Main *bmain, bContext *C, ListBase *oldwmlist)
{
wmWindowManager *oldwm, *wm;
wmWindow *oldwin, *win;
/* cases 1 and 2 */
if (BLI_listbase_is_empty(oldwmlist)) {
if (G.main->wm.first) {
if (bmain->wm.first) {
/* nothing todo */
}
else {
@ -244,7 +244,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* cases 3 and 4 */
/* we've read file without wm..., keep current one entirely alive */
if (BLI_listbase_is_empty(&G.main->wm)) {
if (BLI_listbase_is_empty(&bmain->wm)) {
bScreen *screen = NULL;
/* when loading without UI, no matching needed */
@ -258,7 +258,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
if (screen->winid == 0)
win->screen = screen;
else
win->screen = ED_screen_duplicate(win, screen);
win->screen = ED_screen_duplicate(bmain, win, screen);
BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
win->screen->winid = win->winid;
@ -266,10 +266,10 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
}
}
G.main->wm = *oldwmlist;
bmain->wm = *oldwmlist;
/* screens were read from file! */
ED_screens_initialize(G.main->wm.first);
ED_screens_initialize(bmain, bmain->wm.first);
}
else {
bool has_match = false;
@ -277,7 +277,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* what if old was 3, and loaded 1? */
/* this code could move to setup_appdata */
oldwm = oldwmlist->first;
wm = G.main->wm.first;
wm = bmain->wm.first;
/* preserve key configurations in new wm, to preserve their keymaps */
wm->keyconfigs = oldwm->keyconfigs;
@ -559,7 +559,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* we didn't succeed, now try to read Blender file */
if (retval == BKE_READ_EXOTIC_OK_BLEND) {
Main *bmain = CTX_data_main(C);
int G_f = G.f;
ListBase wmbase;
@ -570,6 +569,10 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* confusing this global... */
G.relbase_valid = 1;
retval = BKE_blendfile_read(C, filepath, reports, 0);
/* BKE_file_read sets new Main into context. */
Main *bmain = CTX_data_main(C);
/* when loading startup.blend's, we can be left with a blank path */
if (BKE_main_blendfile_path(bmain)) {
G.save_over = 1;
@ -587,12 +590,12 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
/* match the read WM with current WM */
wm_window_match_do(C, &wmbase);
wm_window_match_do(bmain, C, &wmbase);
WM_check(C); /* opens window(s), checks keymaps */
if (retval == BKE_BLENDFILE_READ_OK_USERPREFS) {
/* in case a userdef is read from regular .blend */
wm_init_userdef(G.main, false);
wm_init_userdef(bmain, false);
}
if (retval != BKE_BLENDFILE_READ_FAIL) {
@ -856,7 +859,7 @@ int wm_homefile_read(
}
/* match the read WM with current WM */
wm_window_match_do(C, &wmbase);
wm_window_match_do(bmain, C, &wmbase);
WM_check(C); /* opens window(s), checks keymaps */
bmain->name[0] = '\0';

View File

@ -249,6 +249,7 @@ wmWindow *wm_window_new(bContext *C)
/* part of wm_window.c api */
wmWindow *wm_window_copy(bContext *C, wmWindow *win_src)
{
Main *bmain = CTX_data_main(C);
wmWindow *win_dst = wm_window_new(C);
win_dst->posx = win_src->posx + 10;
@ -257,7 +258,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src)
win_dst->sizey = win_src->sizey;
/* duplicate assigns to window */
win_dst->screen = ED_screen_duplicate(win_dst, win_src->screen);
win_dst->screen = ED_screen_duplicate(bmain, win_dst, win_src->screen);
BLI_strncpy(win_dst->screenname, win_dst->screen->id.name + 2, sizeof(win_dst->screenname));
win_dst->screen->winid = win_dst->winid;
@ -793,6 +794,7 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
*/
wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, int type)
{
Main *bmain = CTX_data_main(C);
wmWindow *win_prev = CTX_wm_window(C);
wmWindow *win;
ScrArea *sa;
@ -839,7 +841,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
if (win->screen == NULL) {
/* add new screen */
win->screen = ED_screen_add(win, scene, "temp");
win->screen = ED_screen_add(bmain, win, scene, "temp");
}
else {
/* switch scene for rendering */

View File

@ -358,7 +358,7 @@ int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struc
void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference) RET_NONE
void WM_main_add_notifier(unsigned int type, void *reference) RET_NONE
void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep) RET_NONE
void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props) RET_NONE
void ED_armature_transform(struct Main *bmain, struct bArmature *arm, float mat[4][4], const bool do_props) RET_NONE
struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op) RET_NULL
struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep) RET_NULL
void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE
@ -562,7 +562,7 @@ bool ED_transform_snap_object_project_ray_ex(
float r_loc[3], float r_no[3], int *r_index,
struct Object **r_ob, float r_obmat[4][4]) RET_ZERO
void ED_curve_editnurb_load(struct Object *obedit) RET_NONE
void ED_curve_editnurb_load(struct Main *bmain, struct Object *obedit) RET_NONE
void ED_curve_editnurb_make(struct Object *obedit) RET_NONE
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon) RET_NONE