[Bf-blender-cvs] [acdb14d264c] master: Transform: option to transform origins in object mode
Campbell Barton
noreply at git.blender.org
Fri Aug 23 23:35:12 CEST 2019
Commit: acdb14d264c8b4eced645673f8ae8af1a96b1a90
Author: Campbell Barton
Date: Thu Aug 22 13:45:31 2019 +1000
Branches: master
https://developer.blender.org/rBacdb14d264c8b4eced645673f8ae8af1a96b1a90
Transform: option to transform origins in object mode
Currently supports mesh, armature, lattice, curve & metaballs.
Access from pivot popover.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/BKE_curve.h
M source/blender/blenkernel/BKE_lattice.h
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/intern/curve.c
M source/blender/blenkernel/intern/displist.c
M source/blender/blenkernel/intern/lattice.c
M source/blender/blenkernel/intern/mesh.c
M source/blender/editors/include/ED_object.h
M source/blender/editors/object/CMakeLists.txt
A source/blender/editors/object/object_data_transform.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_conversions.c
M source/blender/editors/transform/transform_generics.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 6ef268f9321..b684e4aa2dd 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5890,7 +5890,9 @@ class VIEW3D_PT_pivot_point(Panel):
if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
col.separator()
- col.prop(tool_settings, "use_transform_pivot_point_align")
+ col.label(text="Affect Only")
+ col.prop(tool_settings, "use_transform_data_origin", text="Origins")
+ col.prop(tool_settings, "use_transform_pivot_point_align", text="Locations")
class VIEW3D_PT_snapping(Panel):
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. */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 7b9a96e4d07..de590d124ea 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -44,6 +44,7 @@ struct Scene;
struct ShaderFxData;
struct View3D;
struct ViewLayer;
+struct XFormObjectData;
struct bConstraint;
struct bContext;
struct bFaceMap;
@@ -403,6 +404,12 @@ bool ED_object_jump_to_bone(struct bContext *C,
void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum);
void ED_object_facemap_face_remove(struct Object *ob, struct bFaceMap *fmap, int facenum);
+/* object_data_transform.c */
+struct XFormObjectData *ED_object_data_xform_create(struct ID *id);
+void ED_object_data_xform_destroy(struct XFormObjectData *xod);
+
+void ED_object_data_xform_by_mat4(struct XFormObjectData *xod, const float mat[4][4]);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 2490f88b5eb..aabfa78cf58 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -48,6 +48,7 @@ set(SRC
object_collection.c
object_constraint.c
object_data_transfer.c
+ object_data_transform.c
object_edit.c
object_facemap_ops.c
object_gpencil_modifier.c
diff --git a/source/blender/editors/object/object_data_transform.c b/source/blender/editors/object/object_data_transform.c
new file mode 100644
index 00000000000..ee86c79ead5
--- /dev/null
+++ b/source/blender/editors/object/object_data_transform.c
@@ -0,0 +1,333 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list