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>2013-02-11 14:56:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-02-11 14:56:21 +0400
commit3a192ca3591d0ed5a6356f791c86cbd2a3d0209a (patch)
treea3fa776da8d43d4d058984b9f863b72a880f384f /source/blender/editors/metaball
parentc1ca09b8c80a4fc063f7b804f68cd5c86db9f517 (diff)
patch [#33697] Apply transformation added to metaballs.
from Jesse Werner (vidjogamer), with own addition of RNA function, scale and rotation support.
Diffstat (limited to 'source/blender/editors/metaball')
-rw-r--r--source/blender/editors/metaball/mball_edit.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 8633a7a9b38..477a6dd815e 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -586,3 +586,27 @@ void undo_push_mball(bContext *C, const char *name)
undo_editmode_push(C, name, get_data, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL);
}
+/* matrix is 4x4 */
+void ED_mball_transform(MetaBall *mb, float *mat)
+{
+ MetaElem *me;
+ float quat[4];
+ const float scale = mat4_to_scale((float (*)[4])mat);
+ const float scale_sqrt = sqrtf(scale);
+
+ mat4_to_quat(quat, (float (*)[4])mat);
+
+ for (me = mb->elems.first; me; me = me->next) {
+ mul_m4_v3((float (*)[4])mat, &me->x);
+ mul_qt_qtqt(me->quat, quat, me->quat);
+ me->rad *= scale;
+ /* hrmf, probably elems shouldn't be
+ * treating scale differently - campbell */
+ if (ELEM3(me->type, MB_CUBE, MB_PLANE, MB_TUBE)) {
+ mul_v3_fl(&me->expx, scale);
+ }
+ else {
+ mul_v3_fl(&me->expx, scale_sqrt);
+ }
+ }
+}