2.5 MetaBalls
authorJiri Hnidek <jiri.hnidek@tul.cz>
Wed, 29 Jul 2009 12:35:09 +0000 (12:35 +0000)
committerJiri Hnidek <jiri.hnidek@tul.cz>
Wed, 29 Jul 2009 12:35:09 +0000 (12:35 +0000)
 - It is possible to work with MetaBalls in edit mode now
 - Added basic UI to the button window (feel free to change it :-))
 - Header menus should work
 - Undo & redo should work
 - Removed global variable editelems and lastelem (moved it to the MetaBall struct)
 - All tools from old editmball.c was converted to the operators
 - Added lastelem to the RNA
 - Experimental: mb->editelems is only pointer at mb->elems or NULL (depends on Mode). ListBase of MetaElems is not duplicated in edit mode.

Tested with scons at Linux and mac OS X

TODO:
 - Recalc data after Undo or Redo
 - Solve issue with basic MetaBall and Python UI script (only base MetaBall object influence Wiresize and Threshold)
 - Fix orientation of manipulator in "Normal mode"

25 files changed:
release/ui/buttons_data_metaball.py [new file with mode: 0644]
source/blender/blenloader/intern/readfile.c
source/blender/editors/Makefile
source/blender/editors/SConscript
source/blender/editors/include/ED_mball.h [new file with mode: 0644]
source/blender/editors/include/ED_screen.h
source/blender/editors/metaball/Makefile [new file with mode: 0644]
source/blender/editors/metaball/SConscript [new file with mode: 0644]
source/blender/editors/metaball/editmball.c [new file with mode: 0644]
source/blender/editors/metaball/mball_intern.h [new file with mode: 0644]
source/blender/editors/metaball/mball_ops.c [new file with mode: 0644]
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/util/undo.c
source/blender/makesdna/DNA_meta_types.h
source/blender/makesrna/intern/rna_meta.c

diff --git a/release/ui/buttons_data_metaball.py b/release/ui/buttons_data_metaball.py
new file mode 100644 (file)
index 0000000..12d44ff
--- /dev/null
@@ -0,0 +1,71 @@
+import bpy
+
+class DataButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "data"
+       
+       def poll(self, context):
+               return (context.meta_ball != None)
+
+class DATA_PT_context_metaball(DataButtonsPanel):
+       __show_header__ = False
+       
+       def draw(self, context):
+               layout = self.layout
+               
+               ob = context.object
+               mball = context.meta_ball
+               space = context.space_data
+
+               split = layout.split(percentage=0.65)
+
+               if ob:
+                       split.template_ID(ob, "data")
+                       split.itemS()
+               elif mball:
+                       split.template_ID(space, "pin_id")
+                       split.itemS()
+
+class DATA_PT_metaball(DataButtonsPanel):
+       __label__ = "Metaball"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               mball = context.meta_ball
+               
+               split = layout.split()
+               sub = split.column()
+               
+               sub.itemL(text="Settings:")
+               sub.itemR(mball, "threshold", text="Threshold")
+               sub.itemR(mball, "wire_size", text="View Resolution")
+               sub.itemR(mball, "render_size", text="Render Resolution")
+               
+               sub.itemL(text="Update:")               
+               sub.itemR(mball, "flag", expand=True)
+
+class DATA_PT_metaball_metaelem(DataButtonsPanel):
+       __label__ = "MetaElem"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               metaelem = context.meta_ball.last_selected_element
+               
+               if(metaelem != None):
+                       split = layout.split()
+                       sub = split.column()
+                       
+                       sub.itemL(text="Settings:")
+                       sub.itemR(metaelem, "stiffness", text="Stiffness")
+                       sub.itemR(metaelem, "size", text="Size")
+                       sub.itemL(text="Type:")
+                       sub.itemR(metaelem, "type", expand=True)
+                       sub.itemR(metaelem, "negative", text="Negative")
+
+               
+bpy.types.register(DATA_PT_context_metaball)
+bpy.types.register(DATA_PT_metaball)
+bpy.types.register(DATA_PT_metaball_metaelem)
\ No newline at end of file
index 9d42777881033db23a42e2b3dff4e528055d1420..bdb98a8ae724a66d36c87fc0aea21305aba47217 100644 (file)
@@ -2508,6 +2508,8 @@ static void direct_link_mball(FileData *fd, MetaBall *mb)
        mb->disp.first= mb->disp.last= NULL;
        mb->editelems= NULL;
        mb->bb= NULL;
+/*     mb->edit_elems.first= mb->edit_elems.last= NULL;*/
+       mb->lastelem= NULL;
 }
 
 /* ************ READ WORLD ***************** */
index 6463815a268a04c3cf91518b11d0345625be43cf..dbd0ca779aa53d89934f9659049845ff2dc39a79 100644 (file)
@@ -40,6 +40,7 @@ DIRS = armature \
   transform \
   screen \
   curve \
+  metaball \
   gpencil \
   physics \
   preview \
index d7bb567e3ebbbe5daac71741bb5a5d35a5dad3c9..0a13082faaf7122b8d5155a6cf0bafe7bd1ed39d 100644 (file)
@@ -9,6 +9,7 @@ SConscript(['datafiles/SConscript',
                        'animation/SConscript',
                        'armature/SConscript',
                        'mesh/SConscript',
+                       'metaball/SConscript',
                        'object/SConscript',
                        'curve/SConscript',
                        'gpencil/SConscript',
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
new file mode 100644 (file)
index 0000000..adb5086
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * $Id$
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+void ED_operatortypes_metaball(void);
+void ED_keymap_metaball(struct wmWindowManager *wm);
+
+struct MetaElem *add_metaball_primitive(struct bContext *C, int type, int newname);
+
+void mouse_mball(struct bContext *C, short mval[2], int extend);
+
+void free_editMball(struct Object *obedit);
+void make_editMball(struct Object *obedit);
+void load_editMball(struct Object *obedit);
+
index a2e8f3a4ec14141f46c42beb63c5b6d9864c18d8..d2e058f9f6d4fbe8101f2111276ae166444ce625 100644 (file)
@@ -134,6 +134,7 @@ int         ED_operator_editsurf(struct bContext *C);
 int            ED_operator_editsurfcurve(struct bContext *C);
 int            ED_operator_editfont(struct bContext *C);
 int            ED_operator_editlattice(struct bContext *C);
+int            ED_operator_editmball(struct bContext *C);
 int            ED_operator_uvedit(struct bContext *C);
 int            ED_operator_uvmap(struct bContext *C);
 int            ED_operator_posemode(struct bContext *C);
diff --git a/source/blender/editors/metaball/Makefile b/source/blender/editors/metaball/Makefile
new file mode 100644 (file)
index 0000000..d971ec9
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# $Id$
+#
+# ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2007 Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+# Makes module object directory and bounces make to subdirectories.
+
+LIBNAME = ed_metaball
+DIR = $(OCGDIR)/blender/$(LIBNAME)
+
+include nan_compile.mk
+
+CFLAGS += $(LEVEL_1_C_WARNINGS)
+
+CPPFLAGS += -I$(NAN_GLEW)/include
+CPPFLAGS += -I$(OPENGL_HEADERS)
+
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+CPPFLAGS += -I$(NAN_ELBEEM)/include
+
+CPPFLAGS += -I../../windowmanager
+CPPFLAGS += -I../../blenkernel
+CPPFLAGS += -I../../blenloader
+CPPFLAGS += -I../../blenlib
+CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I../../makesrna
+CPPFLAGS += -I../../imbuf
+CPPFLAGS += -I../../gpu
+CPPFLAGS += -I../../render/extern/include
+
+# own include 
+
+CPPFLAGS += -I../include 
diff --git a/source/blender/editors/metaball/SConscript b/source/blender/editors/metaball/SConscript
new file mode 100644 (file)
index 0000000..4b1b409
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+Import ('env')
+
+sources = env.Glob('*.c')
+
+incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
+incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
+incs += ' #/intern/guardedalloc ../../gpu'
+incs += ' ../../makesrna ../../render/extern/include  #/intern/elbeem/extern'
+
+env.BlenderLib ( 'bf_editors_metaball', sources, Split(incs), [], libtype=['core'], priority=[45] )
diff --git a/source/blender/editors/metaball/editmball.c b/source/blender/editors/metaball/editmball.c
new file mode 100644 (file)
index 0000000..7b9175f
--- /dev/null
@@ -0,0 +1,676 @@
+/**
+ * $Id$
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <math.h>
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_rand.h"
+
+#include "DNA_meta_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include "BKE_utildefines.h"
+#include "BKE_depsgraph.h"
+#include "BKE_object.h"
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+#include "ED_view3d.h"
+#include "ED_transform.h"
+#include "ED_util.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+/* This function is used to free all MetaElems from MetaBall */
+void free_editMball(Object *obedit)
+{
+}
+
+/* This function is called, when MetaBall Object is
+ * switched from object mode to edit mode */
+void make_editMball(Object *obedit)
+{
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml;/*, *newml;*/
+
+       ml= mb->elems.first;
+       
+       while(ml) {
+               if(ml->flag & SELECT) mb->lastelem = ml;
+               ml= ml->next;
+       }
+
+       mb->editelems = &mb->elems;
+}
+
+/* This function is called, when MetaBall Object switched from
+ * edit mode to object mode. List od MetaElements is copied
+ * from object->data->edit_elems to to object->data->elems. */
+void load_editMball(Object *obedit)
+{
+       MetaBall *mb = (MetaBall*)obedit->data;
+       
+       mb->editelems= NULL;
+       mb->lastelem= NULL;
+}
+
+/* Add metaelem primitive to metaball object (which is in edit mode) */
+MetaElem *add_metaball_primitive(bContext *C, int type, int newname)
+{
+       Scene *scene= CTX_data_scene(C);
+       View3D *v3d= CTX_wm_view3d(C);
+       RegionView3D *rv3d = CTX_wm_region_view3d(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mball = (MetaBall*)obedit->data;
+       MetaElem *ml;
+       float *curs, mat[3][3], cent[3], imat[3][3], cmat[3][3];
+
+       /* Deselect all existing metaelems */
+       ml= mball->editelems->first;
+       while(ml) {
+               ml->flag &= ~SELECT;
+               ml= ml->next;
+       }
+
+       Mat3CpyMat4(mat, obedit->obmat);
+
+       if(v3d) {
+               curs= give_cursor(scene, v3d);
+               VECCOPY(cent, curs);
+       }
+       else
+               cent[0]= cent[1]= cent[2]= 0.0f;
+       
+       cent[0]-= obedit->obmat[3][0];
+       cent[1]-= obedit->obmat[3][1];
+       cent[2]-= obedit->obmat[3][2];
+
+       if (rv3d) {
+               Mat3CpyMat4(imat, rv3d->viewmat);
+               Mat3MulVecfl(imat, cent);
+               Mat3MulMat3(cmat, imat, mat);
+               Mat3Inv(imat,cmat);
+               Mat3MulVecfl(imat, cent);
+       }
+
+       ml= MEM_callocN(sizeof(MetaElem), "metaelem");
+
+       ml->x= cent[0];
+       ml->y= cent[1];
+       ml->z= cent[2];
+       ml->quat[0]= 1.0;
+       ml->quat[1]= 0.0;
+       ml->quat[2]= 0.0;
+       ml->quat[3]= 0.0;
+       ml->rad= 2.0;
+       ml->s= 2.0;
+       ml->flag= SELECT | MB_SCALE_RAD;
+
+       switch(type) {
+       case MB_BALL:
+               ml->type = MB_BALL;
+               ml->expx= ml->expy= ml->expz= 1.0;
+               break;
+       case MB_TUBE:
+               ml->type = MB_TUBE;
+               ml->expx= ml->expy= ml->expz= 1.0;
+               break;
+       case MB_PLANE:
+               ml->type = MB_PLANE;
+               ml->expx= ml->expy= ml->expz= 1.0;
+               break;
+       case MB_ELIPSOID:
+               ml->type = MB_ELIPSOID;
+               ml->expx= 1.2f;
+               ml->expy= 0.8f;
+               ml->expz= 1.0;
+               break;
+       case MB_CUBE:
+               ml->type = MB_CUBE;
+               ml->expx= ml->expy= ml->expz= 1.0;
+               break;
+       default:
+               break;
+       }
+       
+       mball->lastelem= ml;
+       
+       return ml;
+}
+
+/***************************** Select/Deselect operator *****************************/
+
+/* Select or deselect all MetaElements */
+static int select_deselect_all_metaelems_exec(bContext *C, wmOperator *op)
+{
+       //Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml;
+       int any_sel= 0;
+       
+       /* Is any metaelem selected? */
+       ml= mb->editelems->first;
+       if(ml) {
+               while(ml) {
+                       if(ml->flag & SELECT) break;
+                       ml= ml->next;
+               }
+               if(ml) any_sel= 1;
+
+               ml= mb->editelems->first;
+               while(ml) {
+                       if(any_sel) ml->flag &= ~SELECT;
+                       else ml->flag |= SELECT;
+                       ml= ml->next;
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               //DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_select_deselect_all_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select/Deselect All";
+       ot->idname= "MBALL_OT_select_deselect_all_metaelems";
+
+       /* callback functions */
+       ot->exec= select_deselect_all_metaelems_exec;
+       ot->poll= ED_operator_editmball;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;  
+}
+
+/***************************** Select inverse operator *****************************/
+
+/* Invert metaball selection */
+static int select_inverse_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml;
+       
+       ml= mb->editelems->first;
+       if(ml) {
+               while(ml) {
+                       if(ml->flag & SELECT)
+                               ml->flag &= ~SELECT;
+                       else
+                               ml->flag |= SELECT;
+                       ml= ml->next;
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_select_inverse_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Inverse";
+       ot->idname= "MBALL_OT_select_inverse_metaelems";
+
+       /* callback functions */
+       ot->exec= select_inverse_metaelems_exec;
+       ot->poll= ED_operator_editmball;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;  
+}
+
+/***************************** Select random operator *****************************/
+
+/* Random metaball selection */
+static int select_random_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml;
+       float percent= RNA_float_get(op->ptr, "percent");
+       
+       if(percent == 0.0)
+               return OPERATOR_CANCELLED;
+       
+       ml= mb->editelems->first;
+       BLI_srand( BLI_rand() );        /* Random seed */
+       
+       /* Stupid version of random selection. Should be improved. */
+       while(ml) {
+               if(BLI_frand() < percent)
+                       ml->flag |= SELECT;
+               else
+                       ml->flag &= ~SELECT;
+               ml= ml->next;
+       }
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;
+}
+
+
+void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Random...";
+       ot->idname= "MBALL_OT_select_random_metaelems";
+       
+       /* callback functions */
+       ot->exec= select_random_metaelems_exec;
+       ot->invoke= WM_operator_props_popup;
+       ot->poll= ED_operator_editmball;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       /* properties */
+       RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly.", 0.0001f, 1.0f);
+}
+
+/***************************** Duplicate operator *****************************/
+
+/* Duplicate selected MetaElements */
+static int duplicate_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml, *newml;
+       
+       ml= mb->editelems->last;
+       if(ml) {
+               while(ml) {
+                       if(ml->flag & SELECT) {
+                               newml= MEM_dupallocN(ml);
+                               BLI_addtail(mb->editelems, newml);
+                               mb->lastelem= newml;
+                               ml->flag &= ~SELECT;
+                       }
+                       ml= ml->prev;
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       int retv= duplicate_metaelems_exec(C, op);
+       
+       if (retv == OPERATOR_FINISHED) {
+               RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
+               WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
+       }
+       
+       return retv;
+}
+
+
+void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Duplicate";
+       ot->idname= "MBALL_OT_duplicate_metaelems";
+
+       /* callback functions */
+       ot->exec= duplicate_metaelems_exec;
+       ot->invoke= duplicate_metaelems_invoke;
+       ot->poll= ED_operator_editmball;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       /* to give to transform */
+       RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
+}
+
+/***************************** Delete operator *****************************/
+
+/* Delete all selected MetaElems (not MetaBall) */
+static int delete_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb= (MetaBall*)obedit->data;
+       MetaElem *ml, *next;
+       
+       ml= mb->editelems->first;
+       if(ml) {
+               while(ml) {
+                       next= ml->next;
+                       if(ml->flag & SELECT) {
+                               if(mb->lastelem==ml) mb->lastelem= NULL;
+                               BLI_remlink(mb->editelems, ml);
+                               MEM_freeN(ml);
+                       }
+                       ml= next;
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_delete_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Delete";
+       ot->idname= "MBALL_OT_delete_metaelems";
+
+       /* callback functions */
+       ot->exec= delete_metaelems_exec;
+       ot->poll= ED_operator_editmball;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;  
+}
+
+/***************************** Hide operator *****************************/
+
+/* Hide selected MetaElems */
+static int hide_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb= (MetaBall*)obedit->data;
+       MetaElem *ml;
+       int hide_unselected= RNA_boolean_get(op->ptr, "unselected");
+
+       ml= mb->editelems->first;
+
+       if(ml) {
+               /* Hide unselected metaelems */
+               if(hide_unselected) {
+                       while(ml){
+                               if(!(ml->flag & SELECT))
+                                       ml->flag |= MB_HIDE;
+                               ml= ml->next;
+                       }
+               /* Hide selected metaelems */   
+               } else {
+                       while(ml){
+                               if(ml->flag & SELECT)
+                                       ml->flag |= MB_HIDE;
+                               ml= ml->next;
+                       }
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_hide_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Hide";
+       ot->idname= "MBALL_OT_hide_metaelems";
+
+       /* callback functions */
+       ot->exec= hide_metaelems_exec;
+       ot->poll= ED_operator_editmball;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       /* props */
+       RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected.");
+}
+
+/***************************** Unhide operator *****************************/
+
+/* Unhide all edited MetaElems */
+static int reveal_metaelems_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mb= (MetaBall*)obedit->data;
+       MetaElem *ml;
+
+       ml= mb->editelems->first;
+
+       if(ml) {
+               while(ml) {
+                       ml->flag &= ~MB_HIDE;
+                       ml= ml->next;
+               }
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Reveal";
+       ot->idname= "MBALL_OT_reveal_metaelems";
+       
+       /* callback functions */
+       ot->exec= reveal_metaelems_exec;
+       ot->poll= ED_operator_editmball;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;  
+}
+
+/* Select MetaElement with mouse click (user can select radius circle or
+ * stiffness circle) */
+void mouse_mball(bContext *C, short mval[2], int extend)
+{
+       static MetaElem *startelem=NULL;
+       Object *obedit= CTX_data_edit_object(C);
+       ViewContext vc;
+       MetaBall *mb = (MetaBall*)obedit->data;
+       MetaElem *ml, *act=NULL;
+       int a, hits;
+       unsigned int buffer[4*MAXPICKBUF];
+       rcti rect;
+
+       view3d_set_viewcontext(C, &vc);
+
+       rect.xmin= mval[0]-12;
+       rect.xmax= mval[0]+12;
+       rect.ymin= mval[1]-12;
+       rect.ymax= mval[1]+12;
+
+       hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
+
+       /* does startelem exist? */
+       ml= mb->editelems->first;
+       while(ml) {
+               if(ml==startelem) break;
+               ml= ml->next;
+       }
+
+       if(ml==NULL) startelem= mb->editelems->first;
+       
+       if(hits>0) {
+               ml= startelem;
+               while(ml) {
+                       for(a=0; a<hits; a++) {
+                               /* index converted for gl stuff */
+                               if(ml->selcol1==buffer[ 4 * a + 3 ]){
+                                       ml->flag |= MB_SCALE_RAD;
+                                       act= ml;
+                               }
+                               if(ml->selcol2==buffer[ 4 * a + 3 ]){
+                                       ml->flag &= ~MB_SCALE_RAD;
+                                       act= ml;
+                               }
+                       }
+                       if(act) break;
+                       ml= ml->next;
+                       if(ml==NULL) ml= mb->editelems->first;
+                       if(ml==startelem) break;
+               }
+               
+               /* When some metaelem was found, then it is neccessary to select or
+                * deselet it. */
+               if(act) {
+                       if(extend==0) {
+                               /* Deselect all existing metaelems */
+                               ml= mb->editelems->first;
+                               while(ml) {
+                                       ml->flag &= ~SELECT;
+                                       ml= ml->next;
+                               }
+                               /* Select only metaelem clicked on */
+                               act->flag |= SELECT;
+                       }
+                       else {
+                               if(act->flag & SELECT)
+                                       act->flag &= ~SELECT;
+                               else
+                                       act->flag |= SELECT;
+                       }
+                       mb->lastelem= act;
+                       
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               }
+       }
+}
+
+
+/*  ************* undo for MetaBalls ************* */
+
+/* free all MetaElems from ListBase */
+static void freeMetaElemlist(ListBase *lb)
+{
+       MetaElem *ml, *next;
+
+       if(lb==NULL) return;
+
+       ml= lb->first;
+       while(ml){
+               next= ml->next;
+               BLI_remlink(lb, ml);
+               MEM_freeN(ml);
+               ml= next;
+       }
+
+       lb->first= lb->last= NULL;
+}
+
+
+static void undoMball_to_editMball(void *lbu, void *lbe)
+{
+       ListBase *lb= lbu;
+       ListBase *editelems= lbe;
+       MetaElem *ml, *newml;
+       
+       freeMetaElemlist(editelems);
+
+       /* copy 'undo' MetaElems to 'edit' MetaElems */
+       ml= lb->first;
+       while(ml){
+               newml= MEM_dupallocN(ml);
+               BLI_addtail(editelems, newml);
+               ml= ml->next;
+       }
+       
+}
+
+static void *editMball_to_undoMball(void *lbe)
+{
+       ListBase *editelems= lbe;
+       ListBase *lb;
+       MetaElem *ml, *newml;
+
+       /* allocate memory for undo ListBase */
+       lb= MEM_callocN(sizeof(ListBase), "listbase undo");
+       lb->first= lb->last= NULL;
+       
+       /* copy contents of current ListBase to the undo ListBase */
+       ml= editelems->first;
+       while(ml){
+               newml= MEM_dupallocN(ml);
+               BLI_addtail(lb, newml);
+               ml= ml->next;
+       }
+       
+       return lb;
+}
+
+/* free undo ListBase of MetaElems */
+static void free_undoMball(void *lbv)
+{
+       ListBase *lb= lbv;
+       
+       freeMetaElemlist(lb);
+       MEM_freeN(lb);
+}
+
+ListBase *metaball_get_editelems(Object *ob)
+{
+       if(ob && ob->type==OB_MBALL) {
+               struct MetaBall *mb= (struct MetaBall*)ob->data;
+               return mb->editelems;
+       }
+       return NULL;
+}
+
+
+static void *get_data(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       return metaball_get_editelems(obedit);
+}
+
+/* this is undo system for MetaBalls */
+void undo_push_mball(bContext *C, char *name)
+{
+       undo_editmode_push(C, name, get_data, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL);
+}
+
diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h
new file mode 100644 (file)
index 0000000..8cf7497
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * $Id$
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef ED_MBALL_INTERN_H
+#define ED_MBALL_INTERN_H
+
+#include "DNA_object_types.h"
+
+#include "DNA_windowmanager_types.h"
+
+void MBALL_OT_hide_metaelems(struct wmOperatorType *ot);
+void MBALL_OT_reveal_metaelems(struct wmOperatorType *ot);
+
+void MBALL_OT_delete_metaelems(struct wmOperatorType *ot);
+void MBALL_OT_duplicate_metaelems(struct wmOperatorType *ot);
+
+void MBALL_OT_select_deselect_all_metaelems(struct wmOperatorType *ot);
+void MBALL_OT_select_inverse_metaelems(struct wmOperatorType *ot);
+void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot);
+
+#endif
+
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
new file mode 100644 (file)
index 0000000..38593af
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id$
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+
+#include "DNA_listBase.h"
+#include "DNA_windowmanager_types.h"
+
+#include "mball_intern.h"
+
+void ED_operatortypes_metaball(void)
+{
+       WM_operatortype_append(MBALL_OT_delete_metaelems);
+       WM_operatortype_append(MBALL_OT_duplicate_metaelems);
+       
+       WM_operatortype_append(MBALL_OT_hide_metaelems);
+       WM_operatortype_append(MBALL_OT_reveal_metaelems);
+       
+       WM_operatortype_append(MBALL_OT_select_deselect_all_metaelems);
+       WM_operatortype_append(MBALL_OT_select_inverse_metaelems);
+       WM_operatortype_append(MBALL_OT_select_random_metaelems);
+}
+
+void ED_keymap_metaball(wmWindowManager *wm)
+{
+       ListBase *keymap= WM_keymap_listbase(wm, "Metaball", 0, 0);
+
+       WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0);
+       
+       WM_keymap_add_item(keymap, "MBALL_OT_reveal_metaelems", HKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
+       
+       WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0);
+       
+       WM_keymap_add_item(keymap, "MBALL_OT_select_deselect_all_metaelems", AKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "MBALL_OT_select_inverse_metaelems", IKEY, KM_PRESS, KM_CTRL, 0);
+}
+
index 0d3118fd654f07b73e18c35ae1c67450bdc95231..f699ae93a08ace9a3cf5f11084c040d7de22472e 100644 (file)
 #include "ED_curve.h"
 #include "ED_particle.h"
 #include "ED_mesh.h"
+#include "ED_mball.h"
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_transform.h"
@@ -538,6 +539,78 @@ void OBJECT_OT_surface_add(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "type", prop_surface_types, 0, "Primitive", "");
 }
 
+static EnumPropertyItem prop_metaball_types[]= {
+       {MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""},
+       {MB_TUBE, "MBALL_TUBE", ICON_META_TUBE, "Meta Tube", ""},
+       {MB_PLANE, "MBALL_PLANE", ICON_META_PLANE, "Meta Plane", ""},
+       {MB_CUBE, "MBALL_CUBE", ICON_META_CUBE, "Meta Cube", ""},
+       {MB_ELIPSOID, "MBALL_ELLIPSOID", ICON_META_ELLIPSOID, "Meta Ellipsoid", ""},
+       {0, NULL, 0, NULL, NULL}
+};
+
+static int object_metaball_add_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       MetaBall *mball;
+       MetaElem *elem;
+       int newob= 0;
+       
+       if(obedit==NULL || obedit->type!=OB_MBALL) {
+               object_add_type(C, OB_MBALL);
+               ED_object_enter_editmode(C, 0);
+               newob = 1;
+       }
+       else DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);
+       
+       obedit= CTX_data_edit_object(C);
+       elem= (MetaElem*)add_metaball_primitive(C, RNA_enum_get(op->ptr, "type"), newob);
+       mball= (MetaBall*)obedit->data;
+       BLI_addtail(mball->editelems, elem);
+       
+       /* userdef */
+       if (newob && (U.flag & USER_ADD_EDITMODE)==0) {
+               ED_object_exit_editmode(C, EM_FREEDATA);
+       }
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;
+}
+
+static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       uiPopupMenu *pup;
+       uiLayout *layout;
+
+       pup= uiPupMenuBegin(C, op->type->name, 0);
+       layout= uiPupMenuLayout(pup);
+       if(!obedit || obedit->type == OB_MBALL)
+               uiItemsEnumO(layout, op->type->idname, "type");
+       else
+               uiItemsEnumO(layout, "OBJECT_OT_metaball_add", "type");
+       uiPupMenuEnd(C, pup);
+
+       return OPERATOR_CANCELLED;
+}
+
+void OBJECT_OT_metaball_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Metaball";
+       ot->description= "Add an metaball object to the scene.";
+       ot->idname= "OBJECT_OT_metaball_add";
+
+       /* api callbacks */
+       ot->invoke= object_metaball_add_invoke;
+       ot->exec= object_metaball_add_exec;
+       ot->poll= ED_operator_scene_editable;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", "");
+}
 static int object_add_text_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
@@ -616,7 +689,6 @@ void OBJECT_OT_armature_add(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-
 static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        uiPopupMenu *pup= uiPupMenuBegin(C, "Add Object", 0);
@@ -625,7 +697,7 @@ static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *eve
        uiItemMenuEnumO(layout, "Mesh", ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type");
        uiItemMenuEnumO(layout, "Curve", ICON_OUTLINER_OB_CURVE, "OBJECT_OT_curve_add", "type");
        uiItemMenuEnumO(layout, "Surface", ICON_OUTLINER_OB_SURFACE, "OBJECT_OT_surface_add", "type");
-       uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_META, "OBJECT_OT_object_add", "type", OB_MBALL);
+       uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_META, "OBJECT_OT_metaball_add", "type");
        uiItemO(layout, "Text", ICON_OUTLINER_OB_FONT, "OBJECT_OT_text_add");
        uiItemS(layout);
        uiItemO(layout, "Armature", ICON_OUTLINER_OB_ARMATURE, "OBJECT_OT_armature_add");
@@ -3629,9 +3701,8 @@ void ED_object_exit_editmode(bContext *C, int flag)
                if(freedata) free_editLatt(obedit);
        }
        else if(obedit->type==OB_MBALL) {
-//             extern ListBase editelems;
-//             load_editMball();
-//             if(freedata) BLI_freelistN(&editelems);
+               load_editMball(obedit);
+               if(freedata) free_editMball(obedit);
        }
        
        /* freedata only 0 now on file saves */
@@ -3721,14 +3792,15 @@ void ED_object_enter_editmode(bContext *C, int flag)
                scene->obedit= ob; // XXX for context
                ok= 1;
                make_editText(ob);
+
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_TEXT, scene);
        }
        else if(ob->type==OB_MBALL) {
                scene->obedit= ob; // XXX for context
-//             ok= 1;
-// XXX         make_editMball();
+               ok= 1;
+               make_editMball(ob);
+
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MBALL, scene);
-               
        }
        else if(ob->type==OB_LATTICE) {
                scene->obedit= ob; // XXX for context
index da34f35e6479cb418cb3b61a60aae642c24a5a21..17d4f5deaae6540dd7a9ccab3bcdfce80e6f158f 100644 (file)
@@ -73,6 +73,7 @@ void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
 void OBJECT_OT_mesh_add(struct wmOperatorType *ot);
 void OBJECT_OT_curve_add(struct wmOperatorType *ot);
 void OBJECT_OT_surface_add(struct wmOperatorType *ot);
+void OBJECT_OT_metaball_add(wmOperatorType *ot);
 void OBJECT_OT_text_add(struct wmOperatorType *ot);
 void OBJECT_OT_armature_add(struct wmOperatorType *ot);
        /* only used as menu */
index f4407de60dbbf08938adb3d25fb43161e9c496b8..fe09284718309f6f9839c1d277fee48c57b098ff 100644 (file)
@@ -104,6 +104,8 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(OBJECT_OT_armature_add);
        WM_operatortype_append(OBJECT_OT_object_add);
        WM_operatortype_append(OBJECT_OT_primitive_add);
+       WM_operatortype_append(OBJECT_OT_mesh_add);
+       WM_operatortype_append(OBJECT_OT_metaball_add);
 
        WM_operatortype_append(OBJECT_OT_modifier_add);
        WM_operatortype_append(OBJECT_OT_modifier_remove);
index f5c639745a351f246fe94b438c6befadf3883d19..07454088604570f316536dbab238caf87987f568 100644 (file)
@@ -40,6 +40,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_meta_types.h"
 
 #include "BKE_blender.h"
 #include "BKE_colortools.h"
@@ -312,6 +313,14 @@ int ED_operator_editlattice(bContext *C)
        return 0;
 }
 
+int ED_operator_editmball(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_MBALL)
+               return NULL != ((MetaBall *)obedit->data)->editelems;
+       return 0;
+}
+
 /* *************************** action zone operator ************************** */
 
 /* operator state vars used:  
index b427742077aff44ce201d931fea6d1a3c99915f8..5c33b64894745c2a24a3e50b6466ca56c2f399c0 100644 (file)
@@ -51,6 +51,7 @@
 #include "ED_sculpt.h"
 #include "ED_space_api.h"
 #include "ED_uvedit.h"
+#include "ED_mball.h"
 
 /* only call once on startup, storage is global in BKE kernel listbase */
 void ED_spacetypes_init(void)
@@ -93,6 +94,7 @@ void ED_spacetypes_init(void)
        ED_operatortypes_marker();
        ED_operatortypes_pointcache();
        ED_operatortypes_fluid();
+       ED_operatortypes_metaball();
        ED_operatortypes_boids();
        
        ui_view2d_operatortypes();
@@ -120,6 +122,7 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
        ED_keymap_curve(wm);
        ED_keymap_armature(wm);
        ED_keymap_particle(wm);
+       ED_keymap_metaball(wm);
        ED_marker_keymap(wm);
 
        UI_view2d_keymap(wm);
index 0f498810fb5fbeddaa6d3ca26f699fe21b4fbaea..53630b2bee0c31dfd73409be83dccd19b510f555 100644 (file)
        (((vd->drawtype==OB_SOLID) && (dt>=OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX) && (vd->flag & V3D_ZBUF_SELECT)) == 0) \
        )
 
-
-/* pretty stupid */
-/* editmball.c */
-extern ListBase editelems;
-
 static void draw_bounding_volume(Scene *scene, Object *ob);
 
 static void drawcube_size(float size);
index a99c227ae1f937033f0a6e00ceb508f0ff92da9d..fa6bbb476da8a96558d960fede6a4aa2e10fb847 100644 (file)
@@ -305,6 +305,12 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
        else
                WM_event_remove_keymap_handler(&ar->handlers, keymap);
 
+       keymap= WM_keymap_listbase(wm, "Metaball", 0, 0);
+       if(stype==NS_EDITMODE_MBALL)
+               WM_event_add_keymap_handler(&ar->handlers, keymap);
+       else
+               WM_event_remove_keymap_handler(&ar->handlers, keymap);
+       
        keymap= WM_keymap_listbase(wm, "Lattice", 0, 0);
        if(stype==NS_EDITMODE_LATTICE)
                WM_event_add_keymap_handler(&ar->handlers, keymap);
index 218011054d527807a7368683e8b63dfdb93dc443..26ca5a07973a345fe22213f47b697850c905822a 100644 (file)
@@ -1069,58 +1069,14 @@ static void view3d_select_curvemenu(bContext *C, uiLayout *layout, void *arg_unu
 #endif
 }
 
-void do_view3d_select_metaballmenu(bContext *C, void *arg, int event)
+static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-#if 0
-
-       switch(event) {
-               case 0: /* border select */
-                       borderselect();
-                       break;
-               case 2: /* Select/Deselect all */
-                       deselectall_mball();
-                       break;
-               case 3: /* Inverse */
-                       selectinverse_mball();
-                       break;
-               case 4: /* Select Random */
-                       selectrandom_mball();
-                       break;
-       }
-#endif
-}
-
-
-static uiBlock *view3d_select_metaballmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, ar, "view3d_select_metaballmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_view3d_select_metaballmenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-       
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-               
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
-
-       if(ar->alignment==RGN_ALIGN_TOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-
-       uiTextBoundsBlock(block, 50);
-       return block;
+       uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
+       uiItemS(layout);
+       uiItemO(layout, NULL, 0, "MBALL_OT_select_deselect_all_metaelems");
+       uiItemO(layout, NULL, 0, "MBALL_OT_select_inverse_metaelems");
+       uiItemS(layout);
+       uiItemO(layout, NULL, 0, "MBALL_OT_select_random_metaelems");
 }
 
 static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused)
@@ -2557,112 +2513,41 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse
        uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu);
 }
 
-static void do_view3d_edit_mball_showhidemenu(bContext *C, void *arg, int event)
+static void view3d_edit_metaball_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-#if 0
-       switch(event) {
-       case 10: /* show hidden control points */
-               reveal_mball();
-               break;
-       case 11: /* hide selected control points */
-               hide_mball(0);
-               break;
-       case 12: /* hide selected control points */
-               hide_mball(1);
-               break;
-               }
-#endif
+       uiItemO(layout, NULL, 0, "MBALL_OT_hide_metaelems");
+       uiItemO(layout, NULL, 0, "MBALL_OT_reveal_metaelems");
+       uiItemBooleanO(layout, "Hide Unselected", 0, "MBALL_OT_hide_metaelems", "unselected", 1);
 }
 
-static uiBlock *view3d_edit_mball_showhidemenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       short yco = 20, menuwidth = 120;
-
-       block= uiBeginBlock(C, ar, "view3d_edit_mball_showhidemenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_view3d_edit_mball_showhidemenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected|H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Unselected|Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
-
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       return block;
-}
-static void do_view3d_edit_metaballmenu(bContext *C, void *arg, int event)
+static void view3d_edit_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-#if 0
        Scene *scene= CTX_data_scene(C);
-       ScrArea *sa= CTX_wm_area(C);
-       View3D *v3d= sa->spacedata.first;
+       ToolSettings *ts= CTX_data_tool_settings(C);
+       PointerRNA tsptr;
        
-       switch(event) {
-       case 1: /* undo */
-               BIF_undo();
-               break;
-       case 2: /* redo */
-               BIF_redo();
-               break;
-       case 3: /* duplicate */
-               duplicate_context_selected();
-               break;
-       case 4: /* delete */
-               delete_context_selected();
-               break;
-       case 5: /* Shear */
-               initTransform(TFM_SHEAR, CTX_NONE);
-               Transform();
-               break;
-       case 6: /* Warp */
-               initTransform(TFM_WARP, CTX_NONE);
-               Transform();
-               break;
-       case 7: /* Transform Properties */
-               add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, 0);
-               break;  
-       }
-#endif
-}
+       RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr);
 
-static uiBlock *view3d_edit_metaballmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-               
-       block= uiBeginBlock(C, ar, "view3d_edit_metaballmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_view3d_edit_metaballmenu, NULL);
+       uiItemO(layout, "Undo Editing", 0, "ED_OT_undo");
+       uiItemO(layout, "Redo Editing", 0, "ED_OT_redo");
 
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|Ctrl Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Redo Editing|Shift Ctrl Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-// XXX uiDefIconTextBlockBut(block, editmode_undohistorymenu, NULL, ICON_RIGHTARROW_THIN, "Undo History", 0, yco-=20, 120, 19, "");
+       uiItemS(layout);
 
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties|N",0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
-       uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
-       uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");
-       // XXX uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, "");
+       uiItemS(layout);
        
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+       uiItemO(layout, NULL, 0, "MBALL_OT_delete_metaelems");
+       uiItemO(layout, NULL, 0, "MBALL_OT_duplicate_metaelems");
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete...|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
-
-       uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-
-       uiDefIconTextBlockBut(block, view3d_edit_mball_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Hide MetaElems", 0, yco-=20, 120, 19, "");
-
-       if(ar->alignment==RGN_ALIGN_TOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-
-       uiTextBoundsBlock(block, 50);
-       return block;
+       uiItemS(layout);
+       
+       uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O
+       uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O
+       
+       uiItemS(layout);
+       
+       uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_metaball_showhidemenu);
 }
 
 static void view3d_edit_text_charsmenu(bContext *C, uiLayout *layout, void *arg_unused)
@@ -3894,7 +3779,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                } else if (ob && ob->type == OB_FONT) {
                        xmax= 0;
                } else if (ob && ob->type == OB_MBALL) {
-                       uiDefPulldownBut(block, view3d_select_metaballmenu, NULL, "Select",     xco,yco, xmax-3, 20, "");
+                       uiDefMenuBut(block, view3d_select_metaballmenu, NULL, "Select", xco,yco, xmax-3, 20, "");
                } else if (ob && ob->type == OB_LATTICE) {
                        uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 20, "");
                } else if (ob && ob->type == OB_ARMATURE) {
@@ -3936,7 +3821,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                        xco+= xmax;
                } else if (ob && ob->type == OB_MBALL) {
                        xmax= GetButStringLength("Metaball");
-                       uiDefPulldownBut(block, view3d_edit_metaballmenu, NULL, "Metaball",     xco,yco, xmax-3, 20, "");
+                       uiDefMenuBut(block, view3d_edit_metaballmenu, NULL, "Metaball", xco,yco, xmax-3, 20, "");
                        xco+= xmax;
                } else if (ob && ob->type == OB_LATTICE) {
                        xmax= GetButStringLength("Lattice");
index 8182069c142e4172c9c6f36c56debb8a4f5023f4..4a702665c8858b8d6eb28c1d8ebda7c445f0a47e 100644 (file)
@@ -82,6 +82,7 @@
 #include "ED_screen.h"
 #include "ED_types.h"
 #include "ED_util.h"
+#include "ED_mball.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -1361,9 +1362,10 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
                        do_nurbs_box_select(&vc, &rect, val==LEFTMOUSE);
                }
                else if(obedit->type==OB_MBALL) {
+                       MetaBall *mb = (MetaBall*)obedit->data;
                        hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
                        
-                       ml= NULL; // XXX editelems.first;
+                       ml= mb->editelems->first;
                        
                        while(ml) {
                                for(a=0; a<hits; a++) {
@@ -1569,6 +1571,8 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        mouse_lattice(C, event->mval, extend);
                else if(ELEM(obedit->type, OB_CURVE, OB_SURF))
                        mouse_nurb(C, event->mval, extend);
+               else if(obedit->type==OB_MBALL)
+                       mouse_mball(C, event->mval, extend);
                        
        }
        else if(G.f & G_PARTICLEEDIT)
index c14b8c8a646621024e6fc19246a89bda04761735..40e133f554fae23d30f8c6d04bac744005a02905 100644 (file)
@@ -1217,8 +1217,7 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
 
 static void createTransMBallVerts(bContext *C, TransInfo *t)
 {
-       // TRANSFORM_FIX_ME
-#if 0
+       MetaBall *mb = (MetaBall*)t->obedit->data;
        MetaElem *ml;
        TransData *td;
        TransDataExtension *tx;
@@ -1227,7 +1226,7 @@ static void createTransMBallVerts(bContext *C, TransInfo *t)
        int propmode = t->flag & T_PROP_EDIT;
 
        /* count totals */
-       for(ml= editelems.first; ml; ml= ml->next) {
+       for(ml= mb->editelems->first; ml; ml= ml->next) {
                if(ml->flag & SELECT) countsel++;
                if(propmode) count++;
        }
@@ -1244,7 +1243,7 @@ static void createTransMBallVerts(bContext *C, TransInfo *t)
        Mat3CpyMat4(mtx, t->obedit->obmat);
        Mat3Inv(smtx, mtx);
 
-       for(ml= editelems.first; ml; ml= ml->next) {
+       for(ml= mb->editelems->first; ml; ml= ml->next) {
                if(propmode || (ml->flag & SELECT)) {
                        td->loc= &ml->x;
                        VECCOPY(td->iloc, td->loc);
@@ -1285,7 +1284,6 @@ static void createTransMBallVerts(bContext *C, TransInfo *t)
                        tx++;
                }
        }
-#endif
 }
 
 /* ********************* curve/surface ********* */
index 78837b3b0bba5bf75f6bfa3eacfe5b4e345bb6dc..3366f8d72d749f1a61281cf53ee28a7e9e9dc3e8 100644 (file)
@@ -301,11 +301,10 @@ int calc_manipulator_stats(const bContext *C)
                        }
                }
                else if(obedit->type==OB_MBALL) {
-                       /* editmball.c */
-                       ListBase editelems= {NULL, NULL};  /* XXX */
+                       MetaBall *mb = (MetaBall*)obedit->data;
                        MetaElem *ml, *ml_sel=NULL;
 
-                       ml= editelems.first;
+                       ml= mb->editelems->first;
                        while(ml) {
                                if(ml->flag & SELECT) {
                                        calc_tw_center(scene, &ml->x);
index 6f742d70440c47b312fb0cb95339320388d66d28..be04cdecac60293a7ce873d2f80ee0c3d6ead0b2 100644 (file)
@@ -74,7 +74,6 @@
 /* ***************** generic undo system ********************* */
 
 /* ********* XXX **************** */
-static void undo_push_mball() {}
 static void sound_initialize_sounds() {}
 /* ********* XXX **************** */
 
@@ -93,7 +92,7 @@ void ED_undo_push(bContext *C, char *str)
                else if (obedit->type==OB_FONT)
                        undo_push_font(C, str);
                else if (obedit->type==OB_MBALL)
-                       undo_push_mball(str);
+                       undo_push_mball(C, str);
                else if (obedit->type==OB_LATTICE)
                        undo_push_lattice(C, str);
                else if (obedit->type==OB_ARMATURE)
index 862f3ca184b1ed78a73f379a5e9508208aac7e24..2da4e9ab5a653f4ae6052131b9fe57ec3dfdf0b1 100644 (file)
@@ -85,8 +85,10 @@ typedef struct MetaBall {
        mother ball changes will effect other objects thresholds,
        but these may also have their own thresh as an offset */
        float thresh;
-       
-       
+
+       /* used in editmode */
+       /*ListBase edit_elems;*/
+       MetaElem *lastelem;     
 } MetaBall;
 
 /* **************** METABALL ********************* */
index 5f95336af2d560c7bf2a01be79f4f6a17e3c3908..beb5bbaf51b6cbb4cf7c1d17431dd4d11ecda1dd 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * Contributor(s): Blender Foundation (2008), Juho Vepsäläinen
+ * Contributor(s): Blender Foundation (2008), Juho Vepsalainen, Jiri Hnidek
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_depsgraph.h"
+
+#include "WM_types.h"
+
 static int rna_Meta_texspace_editable(PointerRNA *ptr)
 {
        MetaBall *mb= (MetaBall*)ptr->data;
        return (mb->texflag & AUTOSPACE)? 0: PROP_EDITABLE;
 }
 
+static void rna_MetaBall_update_data(bContext *C, PointerRNA *ptr)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+}
+
 #else
 
 void rna_def_metaelement(BlenderRNA *brna)
@@ -61,43 +77,50 @@ void rna_def_metaelement(BlenderRNA *brna)
        
        /* enums */
        prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_enum_items(prop, prop_type_items);
        RNA_def_property_ui_text(prop, "Type", "Metaball types.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        /* number values */
        prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR);
        RNA_def_property_float_sdna(prop, NULL, "x");
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Location", "");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 
        prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION);
        RNA_def_property_float_sdna(prop, NULL, "quat");
        RNA_def_property_ui_text(prop, "Rotation", "");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 
        prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED);
        RNA_def_property_float_sdna(prop, NULL, "rad");
        RNA_def_property_ui_text(prop, "Radius", "");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 
        prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "expx");
        RNA_def_property_range(prop, 0.0f, 20.0f);
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Size", "Size of element, use of components depends on element type.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        prop= RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "s");
        RNA_def_property_range(prop, 0.0f, 10.0f);
        RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        /* flags */
        prop= RNA_def_property(srna, "negative", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE);
        RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_HIDE);
        RNA_def_property_ui_text(prop, "Hide", "Hide element.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 }
 
 void rna_def_metaball(BlenderRNA *brna)
@@ -120,16 +143,22 @@ void rna_def_metaball(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "MetaElement");
        RNA_def_property_ui_text(prop, "Elements", "Meta elements.");
 
+       prop= RNA_def_property(srna, "last_selected_element", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "lastelem");
+       RNA_def_property_ui_text(prop, "Last selected element.", "Last selected element.");
+       
        /* enums */
        prop= RNA_def_property(srna, "flag", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_update_items);
        RNA_def_property_ui_text(prop, "Update", "Metaball edit update behavior.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        /* number values */
        prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "wiresize");
        RNA_def_property_range(prop, 0.050f, 1.0f);
        RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
        
        prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "rendersize");
@@ -140,6 +169,7 @@ void rna_def_metaball(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "thresh");
        RNA_def_property_range(prop, 0.0f, 5.0f);
        RNA_def_property_ui_text(prop, "Threshold", "Influence of meta elements.");
+       RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
 
        /* materials, textures */
        rna_def_texmat_common(srna, "rna_Meta_texspace_editable");