Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_lattice.c
| Show All 26 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_convert.h" | #include "transform_convert.h" | ||||
| #include "transform_data.h" | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Curve/Surfaces Transform Creation | /** \name Curve/Surfaces Transform Creation | ||||
| * | * | ||||
| * \{ */ | * \{ */ | ||||
| void createTransLatticeVerts(TransInfo *t) | void createTransLatticeVerts(TransInfo *t) | ||||
| { | { | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt; | Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt; | ||||
| TransData *td = NULL; | |||||
| BPoint *bp; | BPoint *bp; | ||||
| float mtx[3][3], smtx[3][3]; | float mtx[3][3], smtx[3][3]; | ||||
| int a; | int a; | ||||
| int count = 0, countsel = 0; | int count = 0, countsel = 0; | ||||
| const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; | ||||
| bp = latt->def; | bp = latt->def; | ||||
| a = latt->pntsu * latt->pntsv * latt->pntsw; | a = latt->pntsu * latt->pntsv * latt->pntsw; | ||||
| Show All 15 Lines | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| } | } | ||||
| if (is_prop_edit) { | if (is_prop_edit) { | ||||
| tc->data_len = count; | tc->data_len = count; | ||||
| } | } | ||||
| else { | else { | ||||
| tc->data_len = countsel; | tc->data_len = countsel; | ||||
| } | } | ||||
| tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)"); | |||||
| TransData *td = tc->data = transform_data_alloc(tc->data_len, TD_BASIC_COMP); | |||||
| int tdi = 0; | |||||
| copy_m3_m4(mtx, tc->obedit->obmat); | copy_m3_m4(mtx, tc->obedit->obmat); | ||||
| pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); | pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); | ||||
| td = tc->data; | |||||
| bp = latt->def; | bp = latt->def; | ||||
| a = latt->pntsu * latt->pntsv * latt->pntsw; | a = latt->pntsu * latt->pntsv * latt->pntsw; | ||||
| while (a--) { | while (a--) { | ||||
| if (is_prop_edit || (bp->f1 & SELECT)) { | if (is_prop_edit || (bp->f1 & SELECT)) { | ||||
| if (bp->hide == 0) { | if (bp->hide == 0) { | ||||
| copy_v3_v3(td->iloc, bp->vec); | copy_v3_v3(td->basic[tdi].iloc, bp->vec); | ||||
| td->loc = bp->vec; | td->basic[tdi].loc = bp->vec; | ||||
| copy_v3_v3(td->center, td->loc); | copy_v3_v3(td->center[tdi], td->basic[tdi].loc); | ||||
| if (bp->f1 & SELECT) { | if (bp->f1 & SELECT) { | ||||
| td->flag = TD_SELECTED; | td->basic[tdi].flag = TD_SELECTED; | ||||
| } | } | ||||
| else { | else { | ||||
| td->flag = 0; | td->basic[tdi].flag = 0; | ||||
| } | } | ||||
| copy_m3_m3(td->smtx, smtx); | copy_m3_m3(td->space[tdi].smtx, smtx); | ||||
| copy_m3_m3(td->mtx, mtx); | copy_m3_m3(td->space[tdi].mtx, mtx); | ||||
| td->ext = NULL; | td->special[tdi].val = NULL; | ||||
| td->val = NULL; | |||||
| td++; | tdi++; | ||||
| } | } | ||||
| } | } | ||||
| bp++; | bp++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||