diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mball.h | 4 | ||||
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 24 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta_api.c | 60 |
8 files changed, 103 insertions, 2 deletions
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 1321765588d..4655188a3dd 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -32,6 +32,7 @@ #define __ED_MBALL_H__ struct bContext; +struct MetaBall; struct Object; struct wmKeyConfig; @@ -48,5 +49,6 @@ void load_editMball(struct Object *obedit); void undo_push_mball(struct bContext *C, const char *name); -#endif +void ED_mball_transform(struct MetaBall *mb, float *mat); +#endif /* __ED_MBALL_H__ */ 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); + } + } +} diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 68075e7b6f9..9dd34623739 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -67,6 +67,7 @@ #include "ED_armature.h" #include "ED_keyframing.h" +#include "ED_mball.h" #include "ED_mesh.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -407,6 +408,12 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo change = 0; } } + else if (ob->type == OB_MBALL) { + if (ID_REAL_USERS(ob->data) > 1) { + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user metaball, doing nothing"); + change = 0; + } + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu; @@ -516,6 +523,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo bp++; } } + else if (ob->type == OB_MBALL) { + MetaBall *mb = ob->data; + ED_mball_transform(mb, (float *)mat); + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 849c61f30b3..7b6fb30d692 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -105,6 +105,7 @@ set(APISRC rna_main_api.c rna_material_api.c rna_mesh_api.c + rna_meta_api.c rna_texture_api.c rna_object_api.c rna_pose_api.c diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index e1844faf6e9..96ca3805d3e 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3248,7 +3248,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_main.c", "rna_main_api.c", RNA_def_main}, {"rna_material.c", "rna_material_api.c", RNA_def_material}, {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, - {"rna_meta.c", NULL, RNA_def_meta}, + {"rna_meta.c", "rna_meta_api.c", RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, {"rna_nla.c", NULL, RNA_def_nla}, {"rna_nodetree.c", NULL, RNA_def_nodetree}, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index c1f5698016c..9161f7932e6 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -264,6 +264,7 @@ void RNA_api_keymapitems(struct StructRNA *srna); void RNA_api_main(struct StructRNA *srna); void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); +void RNA_api_meta(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); void RNA_api_object_base(struct StructRNA *srna); void RNA_api_pose(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 08eefc082bf..4813f25dea7 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -351,6 +351,8 @@ static void rna_def_metaball(BlenderRNA *brna) /* anim */ rna_def_animdata_common(srna); + + RNA_api_meta(srna); } void RNA_def_meta(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_meta_api.c b/source/blender/makesrna/intern/rna_meta_api.c new file mode 100644 index 00000000000..500e202b16f --- /dev/null +++ b/source/blender/makesrna/intern/rna_meta_api.c @@ -0,0 +1,60 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * 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 the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_meta_api.c + * \ingroup RNA + */ + + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" + +#include "BLO_sys_types.h" + +#include "BLI_utildefines.h" + +#include "ED_mball.h" + +#include "rna_internal.h" /* own include */ + +#ifdef RNA_RUNTIME +/* none */ +#else + +void RNA_api_meta(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "transform", "ED_mball_transform"); + RNA_def_function_ui_description(func, "Transform meta elements by a matrix"); + parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +#endif |