diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-08-22 06:45:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-08-24 00:34:43 +0300 |
commit | acdb14d264c8b4eced645673f8ae8af1a96b1a90 (patch) | |
tree | 0be0b3490fe79105892e309be48f608e6ed19fc5 /source/blender/blenkernel/intern | |
parent | 71c43e92257c671065125330f93ed4d03b2b8250 (diff) |
Transform: option to transform origins in object mode
Currently supports mesh, armature, lattice, curve & metaballs.
Access from pivot popover.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 51 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 13 |
4 files changed, 74 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1f21d796220..0126c261fa1 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -4641,7 +4641,50 @@ float (*BKE_curve_nurbs_vert_coords_alloc(ListBase *lb, int *r_vert_len))[3] return vert_coords; } -void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, const float (*vert_coords)[3]) +void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBase *lb, + const float (*vert_coords)[3], + const float mat[4][4], + const bool constrain_2d) +{ + const float *co = vert_coords[0]; + Nurb *nu; + int i; + + for (nu = lb->first; nu; nu = nu->next) { + if (nu->type == CU_BEZIER) { + BezTriple *bezt = nu->bezt; + + for (i = 0; i < nu->pntsu; i++, bezt++) { + mul_v3_m4v3(bezt->vec[0], mat, co); + co += 3; + mul_v3_m4v3(bezt->vec[1], mat, co); + co += 3; + mul_v3_m4v3(bezt->vec[2], mat, co); + co += 3; + } + } + else { + BPoint *bp = nu->bp; + + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + mul_v3_m4v3(bp->vec, mat, co); + co += 3; + } + } + + if (constrain_2d) { + if (nu->flag & CU_2D) { + BKE_nurb_test_2d(nu); + } + } + + calchandlesNurb_intern(nu, true); + } +} + +void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, + const float (*vert_coords)[3], + const bool constrain_2d) { const float *co = vert_coords[0]; @@ -4667,6 +4710,12 @@ void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, const float (*vert_coords)[ } } + if (constrain_2d) { + if (nu->flag & CU_2D) { + BKE_nurb_test_2d(nu); + } + } + calchandlesNurb_intern(nu, true); } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index bc235768bc7..5904fa2d814 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -920,7 +920,7 @@ static void curve_calc_modifiers_pre( } if (deformedVerts) { - BKE_curve_nurbs_vert_coords_apply(nurb, deformedVerts); + BKE_curve_nurbs_vert_coords_apply(nurb, deformedVerts, false); MEM_freeN(deformedVerts); } if (keyVerts) { /* these are not passed through modifier stack */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 0ceca1206f6..e46b7ca5130 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1073,6 +1073,16 @@ float (*BKE_lattice_vert_coords_alloc(const Lattice *lt, int *r_vert_len))[3] return vert_coords; } +void BKE_lattice_vert_coords_apply_with_mat4(struct Lattice *lt, + const float (*vertexCos)[3], + const float mat[4][4]) +{ + int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw; + for (i = 0; i < numVerts; i++) { + mul_v3_m4v3(lt->def[i].vec, mat, vertexCos[i]); + } +} + void BKE_lattice_vert_coords_apply(Lattice *lt, const float (*vert_coords)[3]) { const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9c5ae9b8ca6..38e4527fd17 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1675,6 +1675,19 @@ void BKE_mesh_vert_coords_apply(Mesh *mesh, const float (*vert_coords)[3]) mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; } +void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh, + const float (*vert_coords)[3], + const float mat[4][4]) +{ + /* This will just return the pointer if it wasn't a referenced layer. */ + MVert *mv = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); + mesh->mvert = mv; + for (int i = 0; i < mesh->totvert; i++, mv++) { + mul_v3_m4v3(mv->co, mat, vert_coords[i]); + } + mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; +} + void BKE_mesh_vert_normals_apply(Mesh *mesh, const short (*vert_normals)[3]) { /* This will just return the pointer if it wasn't a referenced layer. */ |