diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 19:42:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 19:42:27 +0400 |
commit | e2c453b5f9d3a0a26333b6585f07ebf9e3a24819 (patch) | |
tree | 837b0b4f8756f9b0dec4b8bae1891e21cd230227 /source/blender/editors/object/object_lattice.c | |
parent | ef054e165cad35715a5b2388aac3db68a65ea275 (diff) |
style cleanup: editors / mesh & object
Diffstat (limited to 'source/blender/editors/object/object_lattice.c')
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 4ba62541c60..648f530881a 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -68,45 +68,45 @@ void free_editLatt(Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; if (lt->editlatt) { - Lattice *editlt= lt->editlatt->latt; + Lattice *editlt = lt->editlatt->latt; if (editlt->def) MEM_freeN(editlt->def); if (editlt->dvert) - free_dverts(editlt->dvert, editlt->pntsu*editlt->pntsv*editlt->pntsw); + free_dverts(editlt->dvert, editlt->pntsu * editlt->pntsv * editlt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); - lt->editlatt= NULL; + lt->editlatt = NULL; } } void make_editLatt(Object *obedit) { - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; KeyBlock *actkey; free_editLatt(obedit); - actkey= ob_get_keyblock(obedit); + actkey = ob_get_keyblock(obedit); if (actkey) key_to_latt(actkey, lt); - lt->editlatt= MEM_callocN(sizeof(EditLatt), "editlatt"); - lt->editlatt->latt= MEM_dupallocN(lt); - lt->editlatt->latt->def= MEM_dupallocN(lt->def); + lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt"); + lt->editlatt->latt = MEM_dupallocN(lt); + lt->editlatt->latt->def = MEM_dupallocN(lt->def); if (lt->dvert) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; - lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + int tot = lt->pntsu * lt->pntsv * lt->pntsw; + lt->editlatt->latt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } - if (lt->key) lt->editlatt->shapenr= obedit->shapenr; + if (lt->key) lt->editlatt->shapenr = obedit->shapenr; } void load_editLatt(Object *obedit) @@ -117,52 +117,52 @@ void load_editLatt(Object *obedit) float *fp; int tot; - lt= obedit->data; - editlt= lt->editlatt->latt; + lt = obedit->data; + editlt = lt->editlatt->latt; if (lt->editlatt->shapenr) { - actkey= BLI_findlink(<->key->block, lt->editlatt->shapenr-1); + actkey = BLI_findlink(<->key->block, lt->editlatt->shapenr - 1); /* active key: vertices */ - tot= editlt->pntsu*editlt->pntsv*editlt->pntsw; + tot = editlt->pntsu * editlt->pntsv * editlt->pntsw; if (actkey->data) MEM_freeN(actkey->data); - fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data"); - actkey->totelem= tot; + fp = actkey->data = MEM_callocN(lt->key->elemsize * tot, "actkey->data"); + actkey->totelem = tot; - bp= editlt->def; + bp = editlt->def; while (tot--) { copy_v3_v3(fp, bp->vec); - fp+= 3; + fp += 3; bp++; } } else { MEM_freeN(lt->def); - lt->def= MEM_dupallocN(editlt->def); + lt->def = MEM_dupallocN(editlt->def); - lt->flag= editlt->flag; + lt->flag = editlt->flag; - lt->pntsu= editlt->pntsu; - lt->pntsv= editlt->pntsv; - lt->pntsw= editlt->pntsw; + lt->pntsu = editlt->pntsu; + lt->pntsv = editlt->pntsv; + lt->pntsw = editlt->pntsw; - lt->typeu= editlt->typeu; - lt->typev= editlt->typev; - lt->typew= editlt->typew; + lt->typeu = editlt->typeu; + lt->typev = editlt->typev; + lt->typew = editlt->typew; } if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); - lt->dvert= NULL; + free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + lt->dvert = NULL; } if (editlt->dvert) { - tot= lt->pntsu*lt->pntsv*lt->pntsw; + tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + lt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); } } @@ -171,17 +171,17 @@ void load_editLatt(Object *obedit) void ED_setflagsLatt(Object *obedit, int flag) { - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; BPoint *bp; int a; - bp= lt->editlatt->latt->def; + bp = lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; while (a--) { - if (bp->hide==0) { - bp->f1= flag; + if (bp->hide == 0) { + bp->f1 = flag; } bp++; } @@ -189,8 +189,8 @@ void ED_setflagsLatt(Object *obedit, int flag) static int lattice_select_all_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Lattice *lt= obedit->data; + Object *obedit = CTX_data_edit_object(C); + Lattice *lt = obedit->data; BPoint *bp; int a; int action = RNA_enum_get(op->ptr, "action"); @@ -198,11 +198,11 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - bp= lt->editlatt->latt->def; - 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; while (a--) { - if (bp->hide==0) { + if (bp->hide == 0) { if (bp->f1) { action = SEL_DESELECT; break; @@ -213,26 +213,26 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) } switch (action) { - case SEL_SELECT: - ED_setflagsLatt(obedit, 1); - break; - case SEL_DESELECT: - ED_setflagsLatt(obedit, 0); - break; - case SEL_INVERT: - bp= lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - - while (a--) { - if (bp->hide==0) { - bp->f1 ^= 1; + case SEL_SELECT: + ED_setflagsLatt(obedit, 1); + break; + case SEL_DESELECT: + ED_setflagsLatt(obedit, 0); + break; + case SEL_INVERT: + bp = lt->editlatt->latt->def; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + + while (a--) { + if (bp->hide == 0) { + bp->f1 ^= 1; + } + bp++; } - bp++; - } - break; + break; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -249,7 +249,7 @@ void LATTICE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editlattice; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -260,27 +260,27 @@ static int make_regular_poll(bContext *C) if (ED_operator_editlattice(C)) return 1; - ob= CTX_data_active_object(C); - return (ob && ob->type==OB_LATTICE); + ob = CTX_data_active_object(C); + return (ob && ob->type == OB_LATTICE); } static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); Lattice *lt; if (ob) { - lt= ob->data; + lt = ob->data; resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { - ob= CTX_data_active_object(C); - lt= ob->data; + ob = CTX_data_active_object(C); + lt = ob->data; resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -297,7 +297,7 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) ot->poll = make_regular_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************************** Mouse Selection *************************/ @@ -305,12 +305,12 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y) { struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData; - float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); + float temp = abs(data->mval[0] - x) + abs(data->mval[1] - y); - if ((bp->f1 & SELECT)==data->select) + if ((bp->f1 & SELECT) == data->select) temp += 5; - if (temp<data->dist) { + if (temp < data->dist) { data->dist = temp; data->bp = bp; @@ -319,15 +319,15 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) { - /* sel==1: selected gets a disadvantage */ - /* in nurb and bezt or bp the nearest is written */ - /* return 0 1 2: handlepunt */ + /* sel==1: selected gets a disadvantage */ + /* in nurb and bezt or bp the nearest is written */ + /* return 0 1 2: handlepunt */ struct { BPoint *bp; short dist, select; int mval[2]; } data = {NULL}; data.dist = 100; data.select = sel; - data.mval[0]= mval[0]; - data.mval[1]= mval[1]; + data.mval[0] = mval[0]; + data.mval[1] = mval[1]; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data); @@ -338,20 +338,20 @@ static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) int mouse_lattice(bContext *C, const int mval[2], int extend) { ViewContext vc; - BPoint *bp= NULL; + BPoint *bp = NULL; view3d_set_viewcontext(C, &vc); - bp= findnearestLattvert(&vc, mval, 1); + bp = findnearestLattvert(&vc, mval, 1); if (bp) { - if (extend==0) { + if (extend == 0) { ED_setflagsLatt(vc.obedit, 0); bp->f1 |= SELECT; } else - bp->f1 ^= SELECT; /* swap */ + bp->f1 ^= SELECT; /* swap */ - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); return 1; } @@ -368,29 +368,29 @@ typedef struct UndoLattice { static void undoLatt_to_editLatt(void *data, void *edata, void *UNUSED(obdata)) { - UndoLattice *ult= (UndoLattice*)data; - EditLatt *editlatt= (EditLatt *)edata; - int a= editlatt->latt->pntsu*editlatt->latt->pntsv*editlatt->latt->pntsw; + UndoLattice *ult = (UndoLattice *)data; + EditLatt *editlatt = (EditLatt *)edata; + int a = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw; - memcpy(editlatt->latt->def, ult->def, a*sizeof(BPoint)); + memcpy(editlatt->latt->def, ult->def, a * sizeof(BPoint)); } static void *editLatt_to_undoLatt(void *edata, void *UNUSED(obdata)) { - UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice"); - EditLatt *editlatt= (EditLatt *)edata; + UndoLattice *ult = MEM_callocN(sizeof(UndoLattice), "UndoLattice"); + EditLatt *editlatt = (EditLatt *)edata; - ult->def= MEM_dupallocN(editlatt->latt->def); - ult->pntsu= editlatt->latt->pntsu; - ult->pntsv= editlatt->latt->pntsv; - ult->pntsw= editlatt->latt->pntsw; + ult->def = MEM_dupallocN(editlatt->latt->def); + ult->pntsu = editlatt->latt->pntsu; + ult->pntsv = editlatt->latt->pntsv; + ult->pntsw = editlatt->latt->pntsw; return ult; } static void free_undoLatt(void *data) { - UndoLattice *ult= (UndoLattice*)data; + UndoLattice *ult = (UndoLattice *)data; if (ult->def) MEM_freeN(ult->def); MEM_freeN(ult); @@ -398,20 +398,20 @@ static void free_undoLatt(void *data) static int validate_undoLatt(void *data, void *edata) { - UndoLattice *ult= (UndoLattice*)data; - EditLatt *editlatt= (EditLatt *)edata; + UndoLattice *ult = (UndoLattice *)data; + EditLatt *editlatt = (EditLatt *)edata; return (ult->pntsu == editlatt->latt->pntsu && - ult->pntsv == editlatt->latt->pntsv && - ult->pntsw == editlatt->latt->pntsw); + ult->pntsv == editlatt->latt->pntsv && + ult->pntsw == editlatt->latt->pntsw); } static void *get_editlatt(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); - if (obedit && obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; + if (obedit && obedit->type == OB_LATTICE) { + Lattice *lt = obedit->data; return lt->editlatt; } |