Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c839
1 files changed, 418 insertions, 421 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index a666f04034b..077ae2830a9 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -110,9 +110,9 @@ static int vertex_parent_set_poll(bContext *C)
static int vertex_parent_set_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *obedit= CTX_data_edit_object(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
BMVert *eve;
BMIter iter;
Curve *cu;
@@ -120,18 +120,18 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
BezTriple *bezt;
BPoint *bp;
Object *par;
- int a, v1=0, v2=0, v3=0, v4=0, nr=1;
+ int a, v1 = 0, v2 = 0, v3 = 0, v4 = 0, nr = 1;
/* we need 1 to 3 selected vertices */
- if (obedit->type==OB_MESH) {
- Mesh *me= obedit->data;
+ if (obedit->type == OB_MESH) {
+ Mesh *me = obedit->data;
BMEditMesh *em;
EDBM_mesh_load(obedit);
EDBM_mesh_make(scene->toolsettings, scene, obedit);
- em= me->edit_btmesh;
+ em = me->edit_btmesh;
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
@@ -139,31 +139,31 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- if (v1==0) v1= nr;
- else if (v2==0) v2= nr;
- else if (v3==0) v3= nr;
- else if (v4==0) v4= nr;
+ if (v1 == 0) v1 = nr;
+ else if (v2 == 0) v2 = nr;
+ else if (v3 == 0) v3 = nr;
+ else if (v4 == 0) v4 = nr;
else break;
}
nr++;
}
}
else if (ELEM(obedit->type, OB_SURF, OB_CURVE)) {
- ListBase *editnurb= object_editcurve_get(obedit);
+ ListBase *editnurb = object_editcurve_get(obedit);
- cu= obedit->data;
+ cu = obedit->data;
- nu= editnurb->first;
+ nu = editnurb->first;
while (nu) {
if (nu->type == CU_BEZIER) {
- bezt= nu->bezt;
- a= nu->pntsu;
+ bezt = nu->bezt;
+ a = nu->pntsu;
while (a--) {
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
- if (v1==0) v1= nr;
- else if (v2==0) v2= nr;
- else if (v3==0) v3= nr;
- else if (v4==0) v4= nr;
+ if (v1 == 0) v1 = nr;
+ else if (v2 == 0) v2 = nr;
+ else if (v3 == 0) v3 = nr;
+ else if (v4 == 0) v4 = nr;
else break;
}
nr++;
@@ -171,34 +171,34 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
}
}
else {
- bp= nu->bp;
- a= nu->pntsu*nu->pntsv;
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1==0) v1= nr;
- else if (v2==0) v2= nr;
- else if (v3==0) v3= nr;
- else if (v4==0) v4= nr;
+ if (v1 == 0) v1 = nr;
+ else if (v2 == 0) v2 = nr;
+ else if (v3 == 0) v3 = nr;
+ else if (v4 == 0) v4 = nr;
else break;
}
nr++;
bp++;
}
}
- nu= nu->next;
+ nu = nu->next;
}
}
- else if (obedit->type==OB_LATTICE) {
- Lattice *lt= obedit->data;
+ else if (obedit->type == OB_LATTICE) {
+ Lattice *lt = obedit->data;
- a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
- bp= lt->editlatt->latt->def;
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+ bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1==0) v1= nr;
- else if (v2==0) v2= nr;
- else if (v3==0) v3= nr;
- else if (v4==0) v4= nr;
+ if (v1 == 0) v1 = nr;
+ else if (v2 == 0) v2 = nr;
+ else if (v3 == 0) v3 = nr;
+ else if (v4 == 0) v4 = nr;
else break;
}
nr++;
@@ -206,19 +206,19 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
}
}
- if (v4 || !((v1 && v2==0 && v3==0) || (v1 && v2 && v3)) ) {
+ if (v4 || !((v1 && v2 == 0 && v3 == 0) || (v1 && v2 && v3)) ) {
BKE_report(op->reports, RPT_ERROR, "Select either 1 or 3 vertices to parent to");
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (ob != obedit) {
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
- par= obedit->parent;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
+ par = obedit->parent;
while (par) {
- if (par==ob) break;
- par= par->parent;
+ if (par == ob) break;
+ par = par->parent;
}
if (par) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
@@ -226,20 +226,20 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
else {
Object workob;
- ob->parent= BASACT->object;
+ ob->parent = BASACT->object;
if (v3) {
- ob->partype= PARVERT3;
- ob->par1= v1-1;
- ob->par2= v2-1;
- ob->par3= v3-1;
+ ob->partype = PARVERT3;
+ ob->par1 = v1 - 1;
+ ob->par2 = v2 - 1;
+ ob->par3 = v3 - 1;
/* inverse parent matrix */
what_does_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
- ob->partype= PARVERT1;
- ob->par1= v1-1;
+ ob->partype = PARVERT1;
+ ob->par1 = v1 - 1;
/* inverse parent matrix */
what_does_parent(scene, ob, &workob);
@@ -270,16 +270,16 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot)
ot->exec = vertex_parent_set_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** Make Proxy Operator *************************/
/* set the object to proxify */
-static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt)
+static int make_proxy_invoke(bContext *C, wmOperator *op, wmEvent *evt)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ED_object_active_context(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = ED_object_active_context(C);
/* sanity checks */
if (!scene || scene->id.lib || !ob)
@@ -294,8 +294,8 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt)
}
else if (ob->id.lib) {
- uiPopupMenu *pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION);
- uiLayout *layout= uiPupMenuLayout(pup);
+ uiPopupMenu *pup = uiPupMenuBegin(C, "OK?", ICON_QUESTION);
+ uiLayout *layout = uiPupMenuLayout(pup);
/* create operator menu item with relevant properties filled in */
uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
@@ -312,41 +312,41 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt)
return OPERATOR_CANCELLED;
}
-static int make_proxy_exec (bContext *C, wmOperator *op)
+static int make_proxy_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Object *ob, *gob= ED_object_active_context(C);
+ Main *bmain = CTX_data_main(C);
+ Object *ob, *gob = ED_object_active_context(C);
GroupObject *go;
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
if (gob->dup_group != NULL) {
- go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "object"));
- ob= go->ob;
+ go = BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "object"));
+ ob = go->ob;
}
else {
- ob= gob;
+ ob = gob;
gob = NULL;
}
if (ob) {
Object *newob;
- Base *newbase, *oldbase= BASACT;
- char name[MAX_ID_NAME+4];
+ Base *newbase, *oldbase = BASACT;
+ char name[MAX_ID_NAME + 4];
/* Add new object for the proxy */
- newob= add_object(scene, OB_EMPTY);
+ newob = add_object(scene, OB_EMPTY);
- BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name+2);
+ BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2);
rename_id(&newob->id, name);
/* set layers OK */
- newbase= BASACT; /* add_object sets active... */
- newbase->lay= oldbase->lay;
- newob->lay= newbase->lay;
+ newbase = BASACT; /* add_object sets active... */
+ newbase->lay = oldbase->lay;
+ newob->lay = newbase->lay;
/* remove base, leave user count of object, it gets linked in object_make_proxy */
- if (gob==NULL) {
+ if (gob == NULL) {
BLI_remlink(&scene->base, oldbase);
MEM_freeN(oldbase);
}
@@ -355,8 +355,8 @@ static int make_proxy_exec (bContext *C, wmOperator *op)
/* depsgraph flushes are needed for the new data */
DAG_scene_sort(bmain, scene);
- DAG_id_tag_update(&newob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob);
+ DAG_id_tag_update(&newob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob);
}
else {
BKE_report(op->reports, RPT_ERROR, "No object to make proxy for");
@@ -369,29 +369,29 @@ static int make_proxy_exec (bContext *C, wmOperator *op)
/* Generic itemf's for operators that take library args */
static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
{
- EnumPropertyItem item_tmp= {0}, *item= NULL;
- int totitem= 0;
- int i= 0;
- Object *ob= ED_object_active_context(C);
+ EnumPropertyItem item_tmp = {0}, *item = NULL;
+ int totitem = 0;
+ int i = 0;
+ Object *ob = ED_object_active_context(C);
GroupObject *go;
if (!ob || !ob->dup_group)
return DummyRNA_DEFAULT_items;
/* find the object to affect */
- for (go= ob->dup_group->gobject.first; go; go= go->next) {
- item_tmp.identifier= item_tmp.name= go->ob->id.name+2;
- item_tmp.value= i++;
+ for (go = ob->dup_group->gobject.first; go; go = go->next) {
+ item_tmp.identifier = item_tmp.name = go->ob->id.name + 2;
+ item_tmp.value = i++;
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
RNA_enum_item_end(&item, &totitem);
- *free= 1;
+ *free = 1;
return item;
}
-void OBJECT_OT_proxy_make (wmOperatorType *ot)
+void OBJECT_OT_proxy_make(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -406,10 +406,10 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot)
ot->poll = ED_operator_object_active;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop= RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */
+ prop = RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */
RNA_def_enum_funcs(prop, proxy_group_object_itemf);
ot->prop = prop;
}
@@ -425,32 +425,31 @@ EnumPropertyItem prop_clear_parent_types[] = {
void ED_object_parent_clear(bContext *C, int type)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
- {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (ob->parent == NULL)
continue;
if (type == 0) {
- ob->parent= NULL;
+ ob->parent = NULL;
}
else if (type == 1) {
- ob->parent= NULL;
+ ob->parent = NULL;
object_apply_mat4(ob, ob->obmat, TRUE, FALSE);
}
else if (type == 2)
unit_m4(ob->parentinv);
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
}
CTX_DATA_END;
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
}
/* note, poll should check for editable scene */
@@ -475,7 +474,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
}
@@ -485,15 +484,15 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot)
void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
{
if (!par || BKE_object_parent_loop_check(par, ob)) {
- ob->parent= NULL;
- ob->partype= PAROBJECT;
- ob->parsubstr[0]= 0;
+ ob->parent = NULL;
+ ob->partype = PAROBJECT;
+ ob->parsubstr[0] = 0;
return;
}
/* this could use some more checks */
- ob->parent= par;
+ ob->parent = par;
ob->partype &= ~PARTYPE;
ob->partype |= type;
BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr));
@@ -518,20 +517,20 @@ EnumPropertyItem prop_make_parent_types[] = {
int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, int partype)
{
- bPoseChannel *pchan= NULL;
- int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
+ bPoseChannel *pchan = NULL;
+ int pararm = ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
par->recalc |= OB_RECALC_OB;
/* preconditions */
- if (partype==PAR_FOLLOW || partype==PAR_PATH_CONST) {
- if (par->type!=OB_CURVE)
+ if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) {
+ if (par->type != OB_CURVE)
return 0;
else {
- Curve *cu= par->data;
+ Curve *cu = par->data;
- if ((cu->flag & CU_PATH)==0) {
- cu->flag |= CU_PATH|CU_FOLLOW;
+ if ((cu->flag & CU_PATH) == 0) {
+ cu->flag |= CU_PATH | CU_FOLLOW;
makeDispListCurveTypes(scene, par, 0); /* force creation of path data */
}
else cu->flag |= CU_FOLLOW;
@@ -549,19 +548,19 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* fall back on regular parenting now (for follow only) */
if (partype == PAR_FOLLOW)
- partype= PAR_OBJECT;
+ partype = PAR_OBJECT;
}
}
- else if (partype==PAR_BONE) {
- pchan= get_active_posechannel(par);
+ else if (partype == PAR_BONE) {
+ pchan = get_active_posechannel(par);
- if (pchan==NULL) {
+ if (pchan == NULL) {
BKE_report(reports, RPT_ERROR, "No active Bone");
return 0;
}
}
- if (ob!=par) {
+ if (ob != par) {
if (BKE_object_parent_loop_check(par, ob)) {
BKE_report(reports, RPT_ERROR, "Loop in parents");
return 0;
@@ -574,14 +573,14 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* set the parent (except for follow-path constraint option) */
if (partype != PAR_PATH_CONST) {
- ob->parent= par;
+ ob->parent = par;
}
/* handle types */
if (pchan)
BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr));
else
- ob->parsubstr[0]= 0;
+ ob->parsubstr[0] = 0;
if (partype == PAR_PATH_CONST) {
/* don't do anything here, since this is not technically "parenting" */
@@ -590,7 +589,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created
* NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
*/
- ob->partype= PAROBJECT; /* note, dna define, not operator property */
+ ob->partype = PAROBJECT; /* note, dna define, not operator property */
//ob->partype= PARSKEL; /* note, dna define, not operator property */
/* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */
@@ -599,25 +598,25 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
ModifierData *md;
switch (partype) {
- case PAR_CURVE: /* curve deform */
- md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
- ((CurveModifierData *)md)->object= par;
- break;
- case PAR_LATTICE: /* lattice deform */
- md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
- ((LatticeModifierData *)md)->object= par;
- break;
- default: /* armature deform */
- md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
- ((ArmatureModifierData *)md)->object= par;
- break;
+ case PAR_CURVE: /* curve deform */
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
+ ((CurveModifierData *)md)->object = par;
+ break;
+ case PAR_LATTICE: /* lattice deform */
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
+ ((LatticeModifierData *)md)->object = par;
+ break;
+ default: /* armature deform */
+ md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
+ ((ArmatureModifierData *)md)->object = par;
+ break;
}
}
}
else if (partype == PAR_BONE)
- ob->partype= PARBONE; /* note, dna define, not operator property */
+ ob->partype = PARBONE; /* note, dna define, not operator property */
else
- ob->partype= PAROBJECT; /* note, dna define, not operator property */
+ ob->partype = PAROBJECT; /* note, dna define, not operator property */
/* constraint */
if (partype == PAR_PATH_CONST) {
@@ -637,7 +636,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
ob->loc[1] = vec[1];
ob->loc[2] = vec[2];
}
- else if (pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) {
+ else if (pararm && ob->type == OB_MESH && par->type == OB_ARMATURE) {
if (partype == PAR_ARMATURE_NAME)
create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, 0);
else if (partype == PAR_ARMATURE_ENVELOPE)
@@ -648,7 +647,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
WM_cursor_wait(0);
}
/* get corrected inverse */
- ob->partype= PAROBJECT;
+ ob->partype = PAROBJECT;
what_does_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
@@ -659,7 +658,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
invert_m4_m4(ob->parentinv, workob.obmat);
}
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA;
}
}
@@ -668,14 +667,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
static int parent_set_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *par= ED_object_active_context(C);
- int partype= RNA_enum_get(op->ptr, "type");
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *par = ED_object_active_context(C);
+ int partype = RNA_enum_get(op->ptr, "type");
int ok = 1;
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
- {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) {
ok = 0;
break;
@@ -688,8 +686,8 @@ static int parent_set_exec(bContext *C, wmOperator *op)
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
return OPERATOR_FINISHED;
}
@@ -697,22 +695,22 @@ static int parent_set_exec(bContext *C, wmOperator *op)
static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
- Object *ob= ED_object_active_context(C);
- uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NONE);
- uiLayout *layout= uiPupMenuLayout(pup);
+ Object *ob = ED_object_active_context(C);
+ uiPopupMenu *pup = uiPupMenuBegin(C, "Set Parent To", ICON_NONE);
+ uiLayout *layout = uiPupMenuLayout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_OBJECT);
/* ob becomes parent, make the associated menus */
- if (ob->type==OB_ARMATURE) {
+ if (ob->type == OB_ARMATURE) {
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_NAME);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_ENVELOPE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_AUTO);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_BONE);
}
- else if (ob->type==OB_CURVE) {
+ else if (ob->type == OB_CURVE) {
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_CURVE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_FOLLOW);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_PATH_CONST);
@@ -741,7 +739,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot)
ot->poll = ED_operator_object_active;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", "");
}
@@ -750,13 +748,13 @@ void OBJECT_OT_parent_set(wmOperatorType *ot)
static int parent_noinv_set_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Object *par= ED_object_active_context(C);
+ Main *bmain = CTX_data_main(C);
+ Object *par = ED_object_active_context(C);
par->recalc |= OB_RECALC_OB;
/* context iterator */
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (ob != par) {
if (BKE_object_parent_loop_check(par, ob)) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
@@ -764,14 +762,14 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
else {
/* clear inverse matrix and also the object location */
unit_m4(ob->parentinv);
- memset(ob->loc, 0, 3*sizeof(float));
+ memset(ob->loc, 0, 3 * sizeof(float));
/* set recalc flags */
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA;
/* set parenting type for object - object only... */
- ob->parent= par;
- ob->partype= PAROBJECT; /* note, dna define, not operator property */
+ ob->parent = par;
+ ob->partype = PAROBJECT; /* note, dna define, not operator property */
}
}
}
@@ -779,7 +777,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
DAG_scene_sort(bmain, CTX_data_scene(C));
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
@@ -797,17 +795,17 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/************************ Clear Slow Parent Operator *********************/
static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (ob->parent) {
if (ob->partype & PARSLOW) {
ob->partype -= PARSLOW;
@@ -839,17 +837,17 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** Make Slow Parent Operator *********************/
static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
if (ob->parent)
ob->partype |= PARSLOW;
@@ -878,7 +876,7 @@ void OBJECT_OT_slow_parent_set(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ******************** Clear Track Operator ******************* */
@@ -892,24 +890,24 @@ static EnumPropertyItem prop_clear_track_types[] = {
/* note, poll should check for editable scene */
static int object_track_clear_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- int type= RNA_enum_get(op->ptr, "type");
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ int type = RNA_enum_get(op->ptr, "type");
if (CTX_data_edit_object(C)) {
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
bConstraint *con, *pcon;
/* remove track-object for old track */
- ob->track= NULL;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->track = NULL;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
/* also remove all tracking constraints */
- for (con= ob->constraints.last; con; con= pcon) {
- pcon= con->prev;
+ for (con = ob->constraints.last; con; con = pcon) {
+ pcon = con->prev;
if (ELEM3(con->type, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_DAMPTRACK))
remove_constraint(&ob->constraints, con);
}
@@ -921,7 +919,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
DAG_ids_flush_update(bmain, 0);
DAG_scene_sort(bmain, scene);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
@@ -940,7 +938,7 @@ void OBJECT_OT_track_clear(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", "");
}
@@ -956,23 +954,23 @@ static EnumPropertyItem prop_make_track_types[] = {
static int track_set_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *obact= ED_object_active_context(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *obact = ED_object_active_context(C);
- int type= RNA_enum_get(op->ptr, "type");
+ int type = RNA_enum_get(op->ptr, "type");
if (type == 1) {
bConstraint *con;
bDampTrackConstraint *data;
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if (ob!=obact) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ if (ob != obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK);
data = con->data;
data->tar = obact;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
/* Lamp, Camera and Speaker track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER)
@@ -985,13 +983,13 @@ static int track_set_exec(bContext *C, wmOperator *op)
bConstraint *con;
bTrackToConstraint *data;
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if (ob!=obact) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ if (ob != obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
data = con->data;
data->tar = obact;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
/* Lamp, Camera and Speaker track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) {
@@ -1006,13 +1004,13 @@ static int track_set_exec(bContext *C, wmOperator *op)
bConstraint *con;
bLockTrackConstraint *data;
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if (ob!=obact) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ if (ob != obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK);
data = con->data;
data->tar = obact;
- ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
+ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
/* Lamp, Camera and Speaker track differently by default */
if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) {
@@ -1026,7 +1024,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
@@ -1045,7 +1043,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", "");
@@ -1056,24 +1054,24 @@ void OBJECT_OT_track_set(wmOperatorType *ot)
static unsigned int move_to_layer_init(bContext *C, wmOperator *op)
{
int values[20], a;
- unsigned int lay= 0;
+ unsigned int lay = 0;
if (!RNA_struct_property_is_set(op->ptr, "layers")) {
/* note: layers are set in bases, library objects work for this */
- CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
+ CTX_DATA_BEGIN (C, Base *, base, selected_bases) {
lay |= base->lay;
}
CTX_DATA_END;
- for (a=0; a<20; a++)
- values[a]= (lay & (1<<a));
+ for (a = 0; a < 20; a++)
+ values[a] = (lay & (1 << a));
RNA_boolean_set_array(op->ptr, "layers", values);
}
else {
RNA_boolean_get_array(op->ptr, "layers", values);
- for (a=0; a<20; a++)
+ for (a = 0; a < 20; a++)
if (values[a])
lay |= (1 << a);
}
@@ -1083,7 +1081,7 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op)
static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- View3D *v3d= CTX_wm_view3d(C);
+ View3D *v3d = CTX_wm_view3d(C);
if (v3d && v3d->localvd) {
return WM_operator_confirm_message(C, op, "Move from localview");
}
@@ -1095,24 +1093,24 @@ static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int move_to_layer_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
unsigned int lay, local;
/* int islamp= 0; */ /* UNUSED */
- lay= move_to_layer_init(C, op);
+ lay = move_to_layer_init(C, op);
lay &= 0xFFFFFF;
- if (lay==0) return OPERATOR_CANCELLED;
+ if (lay == 0) return OPERATOR_CANCELLED;
if (v3d && v3d->localvd) {
/* now we can move out of localview. */
/* note: layers are set in bases, library objects work for this */
- CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
- lay= base->lay & ~v3d->lay;
- base->lay= lay;
- base->object->lay= lay;
+ CTX_DATA_BEGIN (C, Base *, base, selected_bases) {
+ lay = base->lay & ~v3d->lay;
+ base->lay = lay;
+ base->object->lay = lay;
base->object->flag &= ~SELECT;
base->flag &= ~SELECT;
/* if (base->object->type==OB_LAMP) islamp= 1; */
@@ -1122,11 +1120,11 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
else {
/* normal non localview operation */
/* note: layers are set in bases, library objects work for this */
- CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
+ CTX_DATA_BEGIN (C, Base *, base, selected_bases) {
/* upper byte is used for local view */
- local= base->lay & 0xFF000000;
- base->lay= lay + local;
- base->object->lay= lay;
+ local = base->lay & 0xFF000000;
+ base->lay = lay + local;
+ base->object->lay = lay;
/* if (base->object->type==OB_LAMP) islamp= 1; */
}
CTX_DATA_END;
@@ -1134,8 +1132,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
/* warning, active object may be hidden now */
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, scene);
- WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
DAG_scene_sort(bmain, scene);
@@ -1155,7 +1153,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", "");
@@ -1166,18 +1164,18 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot)
#if 0
static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr))
{
- Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1);
+ Scene *sce = (Scene *) BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1);
Base *base, *nbase;
- if (sce==0) return;
+ if (sce == 0) return;
if (sce->id.lib) return;
- for (base= FIRSTBASE; base; base= base->next) {
+ for (base = FIRSTBASE; base; base = base->next) {
if (TESTBASE(v3d, base)) {
- nbase= MEM_mallocN( sizeof(Base), "newbase");
- *nbase= *base;
- BLI_addhead( &(sce->base), nbase);
+ nbase = MEM_mallocN(sizeof(Base), "newbase");
+ *nbase = *base;
+ BLI_addhead(&(sce->base), nbase);
id_us_plus((ID *)base->object);
}
}
@@ -1186,10 +1184,10 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr))
static int make_links_scene_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
+ Main *bmain = CTX_data_main(C);
+ Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
- if (scene_to==NULL) {
+ if (scene_to == NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
return OPERATOR_CANCELLED;
}
@@ -1204,12 +1202,11 @@ static int make_links_scene_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN(C, Base*, base, selected_bases)
- {
+ CTX_DATA_BEGIN (C, Base *, base, selected_bases) {
if (!object_in_scene(base->object, scene_to)) {
- Base *nbase= MEM_mallocN( sizeof(Base), "newbase");
- *nbase= *base;
- BLI_addhead( &(scene_to->base), nbase);
+ Base *nbase = MEM_mallocN(sizeof(Base), "newbase");
+ *nbase = *base;
+ BLI_addhead(&(scene_to->base), nbase);
id_us_plus((ID *)base->object);
}
}
@@ -1232,14 +1229,14 @@ enum {
/* Return 1 if make link data is allow, zero otherwise */
static int allow_make_links_data(int ev, Object *ob, Object *obt)
{
- switch(ev) {
+ switch (ev) {
case MAKE_LINKS_OBDATA:
if (ob->type == obt->type && ob->type != OB_EMPTY)
return 1;
break;
case MAKE_LINKS_MATERIALS:
if (OB_TYPE_SUPPORT_MATERIAL(ob->type) &&
- OB_TYPE_SUPPORT_MATERIAL(obt->type))
+ OB_TYPE_SUPPORT_MATERIAL(obt->type))
{
return 1;
}
@@ -1257,53 +1254,53 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt)
static int make_links_data_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
+ Main *bmain = CTX_data_main(C);
int event = RNA_enum_get(op->ptr, "type");
Object *ob;
ID *id;
int a;
- ob= ED_object_active_context(C);
+ ob = ED_object_active_context(C);
- CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) {
+ CTX_DATA_BEGIN (C, Object *, obt, selected_editable_objects) {
if (ob != obt) {
if (allow_make_links_data(event, ob, obt)) {
- switch(event) {
- case MAKE_LINKS_OBDATA: /* obdata */
- id= obt->data;
- id->us--;
-
- id= ob->data;
- id_us_plus(id);
- obt->data= id;
-
- /* if amount of material indices changed: */
- test_object_materials(obt->data);
-
- obt->recalc |= OB_RECALC_DATA;
- break;
- case MAKE_LINKS_MATERIALS:
- /* new approach, using functions from kernel */
- for (a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
- assign_material(obt, ma, a+1); /* also works with ma==NULL */
- }
- break;
- case MAKE_LINKS_ANIMDATA:
- BKE_copy_animdata_id((ID *)obt, (ID *)ob, FALSE);
- BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data, FALSE);
- break;
- case MAKE_LINKS_DUPLIGROUP:
- obt->dup_group= ob->dup_group;
- if (obt->dup_group) {
- id_lib_extern(&obt->dup_group->id);
- obt->transflag |= OB_DUPLIGROUP;
- }
- break;
- case MAKE_LINKS_MODIFIERS:
- object_link_modifiers(obt, ob);
- obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
- break;
+ switch (event) {
+ case MAKE_LINKS_OBDATA: /* obdata */
+ id = obt->data;
+ id->us--;
+
+ id = ob->data;
+ id_us_plus(id);
+ obt->data = id;
+
+ /* if amount of material indices changed: */
+ test_object_materials(obt->data);
+
+ obt->recalc |= OB_RECALC_DATA;
+ break;
+ case MAKE_LINKS_MATERIALS:
+ /* new approach, using functions from kernel */
+ for (a = 0; a < ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a + 1);
+ assign_material(obt, ma, a + 1); /* also works with ma==NULL */
+ }
+ break;
+ case MAKE_LINKS_ANIMDATA:
+ BKE_copy_animdata_id((ID *)obt, (ID *)ob, FALSE);
+ BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data, FALSE);
+ break;
+ case MAKE_LINKS_DUPLIGROUP:
+ obt->dup_group = ob->dup_group;
+ if (obt->dup_group) {
+ id_lib_extern(&obt->dup_group->id);
+ obt->transflag |= OB_DUPLIGROUP;
+ }
+ break;
+ case MAKE_LINKS_MODIFIERS:
+ object_link_modifiers(obt, ob);
+ obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
+ break;
}
}
}
@@ -1313,7 +1310,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
DAG_scene_sort(bmain, CTX_data_scene(C));
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
return OPERATOR_FINISHED;
}
@@ -1333,22 +1330,22 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot)
/* better not run the poll check */
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
+ prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_local_itemf);
ot->prop = prop;
}
void OBJECT_OT_make_links_data(wmOperatorType *ot)
{
- static EnumPropertyItem make_links_items[]= {
- {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""},
- {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""},
- {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""},
- {MAKE_LINKS_DUPLIGROUP, "DUPLIGROUP", 0, "DupliGroup", ""},
- {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""},
+ static EnumPropertyItem make_links_items[] = {
+ {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""},
+ {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""},
+ {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""},
+ {MAKE_LINKS_DUPLIGROUP, "DUPLIGROUP", 0, "DupliGroup", ""},
+ {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""},
{0, NULL, 0, NULL, NULL}};
/* identifiers */
@@ -1361,7 +1358,7 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot)
ot->poll = ED_operator_object_active;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", "");
@@ -1375,22 +1372,22 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
Base *base;
Object *ob, *obn;
- clear_sca_new_poins(); /* sensor/contr/act */
+ clear_sca_new_poins(); /* sensor/contr/act */
/* duplicate (must set newid) */
- for (base= FIRSTBASE; base; base= base->next) {
- ob= base->object;
+ for (base = FIRSTBASE; base; base = base->next) {
+ ob = base->object;
/* newid may still have some trash from Outliner tree building,
* so clear that first to avoid errors [#26002]
*/
ob->id.newid = NULL;
- if ( (base->flag & flag)==flag ) {
- if (ob->id.lib==NULL && ob->id.us>1) {
+ if ( (base->flag & flag) == flag) {
+ if (ob->id.lib == NULL && ob->id.us > 1) {
/* base gets copy of object */
- obn= copy_object(ob);
- base->object= obn;
+ obn = copy_object(ob);
+ base->object = obn;
ob->id.us--;
}
}
@@ -1400,7 +1397,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
if (v3d) ID_NEW(v3d->camera);
/* object pointers */
- for (base= FIRSTBASE; base; base= base->next) {
+ for (base = FIRSTBASE; base; base = base->next) {
object_relink(base->object);
}
@@ -1413,9 +1410,9 @@ void ED_object_single_user(Scene *scene, Object *ob)
{
Base *base;
- for (base= FIRSTBASE; base; base= base->next) {
- if (base->object == ob) base->flag |= OB_DONE;
- else base->flag &= ~OB_DONE;
+ for (base = FIRSTBASE; base; base = base->next) {
+ if (base->object == ob) base->flag |= OB_DONE;
+ else base->flag &= ~OB_DONE;
}
single_object_users(scene, NULL, OB_DONE);
@@ -1426,18 +1423,18 @@ static void new_id_matar(Material **matar, int totcol)
ID *id;
int a;
- for (a=0; a<totcol; a++) {
- id= (ID *)matar[a];
+ for (a = 0; a < totcol; a++) {
+ id = (ID *)matar[a];
if (id && id->lib == NULL) {
if (id->newid) {
- matar[a]= (Material *)id->newid;
+ matar[a] = (Material *)id->newid;
id_us_plus(id->newid);
id->us--;
}
- else if (id->us>1) {
- matar[a]= copy_material(matar[a]);
+ else if (id->us > 1) {
+ matar[a] = copy_material(matar[a]);
id->us--;
- id->newid= (ID *)matar[a];
+ id->newid = (ID *)matar[a];
}
}
}
@@ -1454,73 +1451,73 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
ID *id;
int a;
- for (base= FIRSTBASE; base; base= base->next) {
- ob= base->object;
- if (ob->id.lib==NULL && (base->flag & flag)==flag ) {
- id= ob->data;
+ for (base = FIRSTBASE; base; base = base->next) {
+ ob = base->object;
+ if (ob->id.lib == NULL && (base->flag & flag) == flag) {
+ id = ob->data;
- if (id && id->us>1 && id->lib==NULL) {
- ob->recalc= OB_RECALC_DATA;
+ if (id && id->us > 1 && id->lib == NULL) {
+ ob->recalc = OB_RECALC_DATA;
BKE_copy_animdata_id_action(id);
- switch(ob->type) {
- case OB_LAMP:
- ob->data= la= copy_lamp(ob->data);
- for (a=0; a<MAX_MTEX; a++) {
- if (la->mtex[a]) {
- ID_NEW(la->mtex[a]->object);
+ switch (ob->type) {
+ case OB_LAMP:
+ ob->data = la = copy_lamp(ob->data);
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (la->mtex[a]) {
+ ID_NEW(la->mtex[a]->object);
+ }
}
- }
- break;
- case OB_CAMERA:
- ob->data= copy_camera(ob->data);
- break;
- case OB_MESH:
- ob->data= copy_mesh(ob->data);
- //me= ob->data;
- //if (me && me->key)
- // ipo_idnew(me->key->ipo); /* drivers */
- break;
- case OB_MBALL:
- ob->data= copy_mball(ob->data);
- break;
- case OB_CURVE:
- case OB_SURF:
- case OB_FONT:
- ob->data= cu= copy_curve(ob->data);
- ID_NEW(cu->bevobj);
- ID_NEW(cu->taperobj);
- break;
- case OB_LATTICE:
- ob->data= copy_lattice(ob->data);
- break;
- case OB_ARMATURE:
- ob->recalc |= OB_RECALC_DATA;
- ob->data= copy_armature(ob->data);
- armature_rebuild_pose(ob, ob->data);
- break;
- case OB_SPEAKER:
- ob->data= copy_speaker(ob->data);
- break;
- default:
- if (G.debug & G_DEBUG)
- printf("ERROR %s: can't copy %s\n", __func__, id->name);
- return;
+ break;
+ case OB_CAMERA:
+ ob->data = copy_camera(ob->data);
+ break;
+ case OB_MESH:
+ ob->data = copy_mesh(ob->data);
+ //me= ob->data;
+ //if (me && me->key)
+ // ipo_idnew(me->key->ipo); /* drivers */
+ break;
+ case OB_MBALL:
+ ob->data = BKE_metaball_copy(ob->data);
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_FONT:
+ ob->data = cu = BKE_curve_copy(ob->data);
+ ID_NEW(cu->bevobj);
+ ID_NEW(cu->taperobj);
+ break;
+ case OB_LATTICE:
+ ob->data = copy_lattice(ob->data);
+ break;
+ case OB_ARMATURE:
+ ob->recalc |= OB_RECALC_DATA;
+ ob->data = copy_armature(ob->data);
+ armature_rebuild_pose(ob, ob->data);
+ break;
+ case OB_SPEAKER:
+ ob->data = copy_speaker(ob->data);
+ break;
+ default:
+ if (G.debug & G_DEBUG)
+ printf("ERROR %s: can't copy %s\n", __func__, id->name);
+ return;
}
id->us--;
- id->newid= ob->data;
+ id->newid = ob->data;
}
}
}
- me= bmain->mesh.first;
+ me = bmain->mesh.first;
while (me) {
ID_NEW(me->texcomesh);
- me= me->id.next;
+ me = me->id.next;
}
}
@@ -1529,10 +1526,10 @@ static void single_object_action_users(Scene *scene, int flag)
Object *ob;
Base *base;
- for (base= FIRSTBASE; base; base= base->next) {
- ob= base->object;
- if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
- ob->recalc= OB_RECALC_DATA;
+ for (base = FIRSTBASE; base; base = base->next) {
+ ob = base->object;
+ if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) {
+ ob->recalc = OB_RECALC_DATA;
BKE_copy_animdata_id_action(&ob->id);
}
}
@@ -1546,30 +1543,30 @@ static void single_mat_users(Scene *scene, int flag, int do_textures)
Tex *tex;
int a, b;
- for (base= FIRSTBASE; base; base= base->next) {
- ob= base->object;
- if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
+ for (base = FIRSTBASE; base; base = base->next) {
+ ob = base->object;
+ if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) {
- for (a=1; a<=ob->totcol; a++) {
- ma= give_current_material(ob, a);
+ for (a = 1; a <= ob->totcol; a++) {
+ ma = give_current_material(ob, a);
if (ma) {
/* do not test for LIB_NEW: this functions guaranteed delivers single_users! */
- if (ma->id.us>1) {
- man= copy_material(ma);
+ if (ma->id.us > 1) {
+ man = copy_material(ma);
BKE_copy_animdata_id_action(&man->id);
- man->id.us= 0;
+ man->id.us = 0;
assign_material(ob, man, a);
if (do_textures) {
- for (b=0; b<MAX_MTEX; b++) {
- if (ma->mtex[b] && (tex= ma->mtex[b]->tex)) {
- if (tex->id.us>1) {
+ for (b = 0; b < MAX_MTEX; b++) {
+ if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) {
+ if (tex->id.us > 1) {
tex->id.us--;
- tex= copy_texture(tex);
+ tex = copy_texture(tex);
BKE_copy_animdata_id_action(&tex->id);
- man->mtex[b]->tex= tex;
+ man->mtex[b]->tex = tex;
}
}
}
@@ -1585,20 +1582,20 @@ static void do_single_tex_user(Tex **from)
{
Tex *tex, *texn;
- tex= *from;
- if (tex==NULL) return;
+ tex = *from;
+ if (tex == NULL) return;
if (tex->id.newid) {
- *from= (Tex *)tex->id.newid;
+ *from = (Tex *)tex->id.newid;
id_us_plus(tex->id.newid);
tex->id.us--;
}
- else if (tex->id.us>1) {
- texn= copy_texture(tex);
+ else if (tex->id.us > 1) {
+ texn = copy_texture(tex);
BKE_copy_animdata_id_action(&texn->id);
- tex->id.newid= (ID *)texn;
+ tex->id.newid = (ID *)texn;
tex->id.us--;
- *from= texn;
+ *from = texn;
}
}
@@ -1610,31 +1607,31 @@ static void single_tex_users_expand(Main *bmain)
World *wo;
int b;
- for (ma= bmain->mat.first; ma; ma=ma->id.next) {
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (ma->id.flag & LIB_NEW) {
- for (b=0; b<MAX_MTEX; b++) {
+ for (b = 0; b < MAX_MTEX; b++) {
if (ma->mtex[b] && ma->mtex[b]->tex) {
- do_single_tex_user( &(ma->mtex[b]->tex) );
+ do_single_tex_user(&(ma->mtex[b]->tex) );
}
}
}
}
- for (la= bmain->lamp.first; la; la=la->id.next) {
+ for (la = bmain->lamp.first; la; la = la->id.next) {
if (la->id.flag & LIB_NEW) {
- for (b=0; b<MAX_MTEX; b++) {
+ for (b = 0; b < MAX_MTEX; b++) {
if (la->mtex[b] && la->mtex[b]->tex) {
- do_single_tex_user( &(la->mtex[b]->tex) );
+ do_single_tex_user(&(la->mtex[b]->tex) );
}
}
}
}
- for (wo= bmain->world.first; wo; wo=wo->id.next) {
+ for (wo = bmain->world.first; wo; wo = wo->id.next) {
if (wo->id.flag & LIB_NEW) {
- for (b=0; b<MAX_MTEX; b++) {
+ for (b = 0; b < MAX_MTEX; b++) {
if (wo->mtex[b] && wo->mtex[b]->tex) {
- do_single_tex_user( &(wo->mtex[b]->tex) );
+ do_single_tex_user(&(wo->mtex[b]->tex) );
}
}
}
@@ -1651,26 +1648,26 @@ static void single_mat_users_expand(Main *bmain)
Material *ma;
int a;
- for (ob=bmain->object.first; ob; ob=ob->id.next)
+ for (ob = bmain->object.first; ob; ob = ob->id.next)
if (ob->id.flag & LIB_NEW)
new_id_matar(ob->mat, ob->totcol);
- for (me=bmain->mesh.first; me; me=me->id.next)
+ for (me = bmain->mesh.first; me; me = me->id.next)
if (me->id.flag & LIB_NEW)
new_id_matar(me->mat, me->totcol);
- for (cu=bmain->curve.first; cu; cu=cu->id.next)
+ for (cu = bmain->curve.first; cu; cu = cu->id.next)
if (cu->id.flag & LIB_NEW)
new_id_matar(cu->mat, cu->totcol);
- for (mb=bmain->mball.first; mb; mb=mb->id.next)
+ for (mb = bmain->mball.first; mb; mb = mb->id.next)
if (mb->id.flag & LIB_NEW)
new_id_matar(mb->mat, mb->totcol);
/* material imats */
- for (ma=bmain->mat.first; ma; ma=ma->id.next)
+ for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->id.flag & LIB_NEW)
- for (a=0; a<MAX_MTEX; a++)
+ for (a = 0; a < MAX_MTEX; a++)
if (ma->mtex[a])
ID_NEW(ma->mtex[a]->object);
}
@@ -1700,11 +1697,11 @@ static void make_local_makelocalmaterial(Material *ma)
id_make_local(&ma->id, 0);
- for (b=0; b<MAX_MTEX; b++)
+ for (b = 0; b < MAX_MTEX; b++)
if (ma->mtex[b] && ma->mtex[b]->tex)
id_make_local(&ma->mtex[b]->tex->id, 0);
- adt= BKE_animdata_from_id(&ma->id);
+ adt = BKE_animdata_from_id(&ma->id);
if (adt) BKE_animdata_make_local(adt);
/* nodetree? XXX */
@@ -1712,83 +1709,83 @@ static void make_local_makelocalmaterial(Material *ma)
static int make_local_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
+ Main *bmain = CTX_data_main(C);
AnimData *adt;
ParticleSystem *psys;
Material *ma, ***matarar;
Lamp *la;
ID *id;
- int a, b, mode= RNA_enum_get(op->ptr, "type");
+ int a, b, mode = RNA_enum_get(op->ptr, "type");
- if (mode==3) {
- BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */
+ if (mode == 3) {
+ BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
clear_id_newpoins();
- CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
if (ob->id.lib)
id_make_local(&ob->id, 0);
}
CTX_DATA_END;
/* maybe object pointers */
- CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- if (ob->id.lib==NULL) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
+ if (ob->id.lib == NULL) {
ID_NEW(ob->parent);
}
}
CTX_DATA_END;
- CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- id= ob->data;
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
+ id = ob->data;
- if (id && mode>1) {
+ if (id && mode > 1) {
id_make_local(id, 0);
- adt= BKE_animdata_from_id(id);
+ adt = BKE_animdata_from_id(id);
if (adt) BKE_animdata_make_local(adt);
/* tag indirect data direct */
- matarar= (Material ***)give_matarar(ob);
+ matarar = (Material ***)give_matarar(ob);
if (matarar) {
- for (a=0; a<ob->totcol; a++) {
- ma= (*matarar)[a];
+ for (a = 0; a < ob->totcol; a++) {
+ ma = (*matarar)[a];
if (ma)
id_lib_extern(&ma->id);
}
}
}
- for (psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys = ob->particlesystem.first; psys; psys = psys->next)
id_make_local(&psys->part->id, 0);
- adt= BKE_animdata_from_id(&ob->id);
+ adt = BKE_animdata_from_id(&ob->id);
if (adt) BKE_animdata_make_local(adt);
}
CTX_DATA_END;
- if (mode>1) {
- CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- if (ob->type==OB_LAMP) {
- la= ob->data;
+ if (mode > 1) {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
+ if (ob->type == OB_LAMP) {
+ la = ob->data;
- for (b=0; b<MAX_MTEX; b++)
+ for (b = 0; b < MAX_MTEX; b++)
if (la->mtex[b] && la->mtex[b]->tex)
id_make_local(&la->mtex[b]->tex->id, 0);
}
else {
- for (a=0; a<ob->totcol; a++) {
- ma= ob->mat[a];
+ for (a = 0; a < ob->totcol; a++) {
+ ma = ob->mat[a];
if (ma)
make_local_makelocalmaterial(ma);
}
- matarar= (Material ***)give_matarar(ob);
+ matarar = (Material ***)give_matarar(ob);
if (matarar) {
- for (a=0; a<ob->totcol; a++) {
- ma= (*matarar)[a];
+ for (a = 0; a < ob->totcol; a++) {
+ ma = (*matarar)[a];
if (ma)
make_local_makelocalmaterial(ma);
}
@@ -1805,7 +1802,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
void OBJECT_OT_make_local(wmOperatorType *ot)
{
- static EnumPropertyItem type_items[]= {
+ static EnumPropertyItem type_items[] = {
{1, "SELECTED_OBJECTS", 0, "Selected Objects", ""},
{2, "SELECTED_OBJECTS_DATA", 0, "Selected Objects and Data", ""},
{3, "ALL", 0, "All", ""},
@@ -1822,7 +1819,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
@@ -1830,10 +1827,10 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
static int make_single_user_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */
- int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C); /* ok if this is NULL */
+ int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
if (RNA_boolean_get(op->ptr, "object"))
single_object_users(scene, v3d, flag);
@@ -1859,7 +1856,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
void OBJECT_OT_make_single_user(wmOperatorType *ot)
{
- static EnumPropertyItem type_items[]= {
+ static EnumPropertyItem type_items[] = {
{SELECT, "SELECTED_OBJECTS", 0, "Selected Objects", ""},
{0, "ALL", 0, "All", ""},
{0, NULL, 0, NULL, NULL}};
@@ -1875,7 +1872,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", type_items, SELECT, "Type", "");
@@ -1889,20 +1886,20 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- Main *bmain= CTX_data_main(C);
- Base *base= ED_view3d_give_base_under_cursor(C, event->mval);
+ Main *bmain = CTX_data_main(C);
+ Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
Material *ma;
- char name[MAX_ID_NAME-2];
+ char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "name", name);
- ma= (Material *)find_id("MA", name);
- if (base==NULL || ma==NULL)
+ ma = (Material *)find_id("MA", name);
+ if (base == NULL || ma == NULL)
return OPERATOR_CANCELLED;
assign_material(base->object, ma, 1);
DAG_ids_flush_update(bmain, 0);
- WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
return OPERATOR_FINISHED;
}
@@ -1925,5 +1922,5 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
- RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME-2, "Name", "Material name to assign");
+ RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME - 2, "Name", "Material name to assign");
}