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:
authorCampbell Barton <ideasman42@gmail.com>2019-08-22 06:45:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-08-24 00:34:43 +0300
commitacdb14d264c8b4eced645673f8ae8af1a96b1a90 (patch)
tree0be0b3490fe79105892e309be48f608e6ed19fc5 /source/blender/blenkernel
parent71c43e92257c671065125330f93ed4d03b2b8250 (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')
-rw-r--r--source/blender/blenkernel/BKE_curve.h9
-rw-r--r--source/blender/blenkernel/BKE_lattice.h3
-rw-r--r--source/blender/blenkernel/BKE_mesh.h3
-rw-r--r--source/blender/blenkernel/intern/curve.c51
-rw-r--r--source/blender/blenkernel/intern/displist.c2
-rw-r--r--source/blender/blenkernel/intern/lattice.c10
-rw-r--r--source/blender/blenkernel/intern/mesh.c13
7 files changed, 88 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 67efeea02cb..af783a6ae8a 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -127,7 +127,14 @@ void BKE_curve_nurb_vert_active_validate(struct Curve *cu);
float (*BKE_curve_nurbs_vert_coords_alloc(struct ListBase *lb, int *r_vert_len))[3];
void BKE_curve_nurbs_vert_coords_get(struct ListBase *lb, float (*vert_coords)[3], int vert_len);
-void BKE_curve_nurbs_vert_coords_apply(struct ListBase *lb, const float (*vert_coords)[3]);
+void BKE_curve_nurbs_vert_coords_apply_with_mat4(struct ListBase *lb,
+ const float (*vert_coords)[3],
+ const float mat[4][4],
+ const bool constrain_2d);
+
+void BKE_curve_nurbs_vert_coords_apply(struct ListBase *lb,
+ const float (*vert_coords)[3],
+ const bool constrain_2d);
float (*BKE_curve_nurbs_key_vert_coords_alloc(struct ListBase *lb,
float *key,
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 8395b182171..a3befa6f3bb 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -90,6 +90,9 @@ void armature_deform_verts(struct Object *armOb,
float (*BKE_lattice_vert_coords_alloc(const struct Lattice *lt, int *r_vert_len))[3];
void BKE_lattice_vert_coords_get(const struct Lattice *lt, float (*vert_coords)[3]);
+void BKE_lattice_vert_coords_apply_with_mat4(struct Lattice *lt,
+ const float (*vert_coords)[3],
+ const float mat[4][4]);
void BKE_lattice_vert_coords_apply(struct Lattice *lt, const float (*vert_coords)[3]);
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph,
struct Scene *scene,
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index b2ae7a6dac0..7986bf947e5 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -269,6 +269,9 @@ void BKE_mesh_count_selected_items(const struct Mesh *mesh, int r_count[3]);
float (*BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3];
void BKE_mesh_vert_coords_get(const struct Mesh *mesh, float (*vert_coords)[3]);
+void BKE_mesh_vert_coords_apply_with_mat4(struct Mesh *mesh,
+ const float (*vert_coords)[3],
+ const float mat[4][4]);
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]);
void BKE_mesh_vert_normals_apply(struct Mesh *mesh, const short (*vertNormals)[3]);
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. */