2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-30 20:18:55 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-30 20:18:55 +00:00
|
|
|
*
|
2009-07-29 12:35:09 +00:00
|
|
|
* Contributor(s): Blender Foundation (2008), Juho Vepsalainen, Jiri Hnidek
|
2008-11-30 20:18:55 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_meta.c
|
|
|
|
|
* \ingroup RNA
|
|
|
|
|
*/
|
|
|
|
|
|
2008-11-30 20:18:55 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
#include "RNA_access.h"
|
2008-11-30 20:18:55 +00:00
|
|
|
#include "RNA_define.h"
|
2010-11-18 04:26:50 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2008-11-30 20:18:55 +00:00
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
2010-04-12 05:04:49 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
|
|
2010-08-23 00:57:19 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2009-07-29 12:35:09 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
2009-08-03 14:40:10 +00:00
|
|
|
#include "BKE_mball.h"
|
2009-07-29 12:35:09 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-08-10 21:10:09 +00:00
|
|
|
#include "BKE_main.h"
|
2009-07-29 12:35:09 +00:00
|
|
|
|
|
|
|
|
#include "WM_types.h"
|
2009-07-29 14:07:51 +00:00
|
|
|
#include "WM_api.h"
|
2009-07-29 12:35:09 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
static int rna_Meta_texspace_editable(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
MetaBall *mb = (MetaBall *)ptr->data;
|
|
|
|
|
return (mb->texflag & MB_AUTOSPACE) ? 0 : PROP_EDITABLE;
|
2010-04-12 05:04:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Meta_texspace_loc_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
MetaBall *mb = (MetaBall *)ptr->data;
|
2010-04-12 05:04:49 +00:00
|
|
|
|
|
|
|
|
/* tex_space_mball() needs object.. ugh */
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(values, mb->loc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Meta_texspace_loc_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
MetaBall *mb = (MetaBall *)ptr->data;
|
2010-04-12 05:04:49 +00:00
|
|
|
|
|
|
|
|
copy_v3_v3(mb->loc, values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Meta_texspace_size_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
MetaBall *mb = (MetaBall *)ptr->data;
|
2010-04-12 05:04:49 +00:00
|
|
|
|
|
|
|
|
/* tex_space_mball() needs object.. ugh */
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(values, mb->size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Meta_texspace_size_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
MetaBall *mb = (MetaBall *)ptr->data;
|
2010-04-12 05:04:49 +00:00
|
|
|
|
|
|
|
|
copy_v3_v3(mb->size, values);
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 05:04:49 +00:00
|
|
|
|
2009-12-08 17:23:48 +00:00
|
|
|
static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
2009-08-03 14:40:10 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
MetaBall *mb = ptr->id.data;
|
2009-08-10 21:10:09 +00:00
|
|
|
Object *ob;
|
|
|
|
|
|
2010-08-23 00:57:19 +00:00
|
|
|
/* cheating way for importers to avoid slow updates */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (mb->id.us > 0) {
|
|
|
|
|
for (ob = bmain->object.first; ob; ob = ob->id.next)
|
|
|
|
|
if (ob->data == mb)
|
2012-05-07 06:38:41 +00:00
|
|
|
BKE_mball_properties_copy(scene, ob);
|
2010-08-23 00:57:19 +00:00
|
|
|
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&mb->id, 0);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, mb);
|
2010-08-23 00:57:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-08 13:02:16 +00:00
|
|
|
static void rna_MetaBall_update_rotation(Main *bmain, Scene *scene, PointerRNA *ptr)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
MetaElem *ml = ptr->data;
|
2010-12-08 13:02:16 +00:00
|
|
|
normalize_qt(ml->quat);
|
|
|
|
|
rna_MetaBall_update_data(bmain, scene, ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-23 00:57:19 +00:00
|
|
|
static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type)
|
|
|
|
|
{
|
2012-05-07 06:38:41 +00:00
|
|
|
MetaElem *ml = BKE_mball_element_add(mb, type);
|
2010-08-23 00:57:19 +00:00
|
|
|
|
|
|
|
|
/* cheating way for importers to avoid slow updates */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (mb->id.us > 0) {
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&mb->id, 0);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id);
|
2010-08-23 00:57:19 +00:00
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
|
2010-08-23 00:57:19 +00:00
|
|
|
return ml;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, PointerRNA *ml_ptr)
|
2010-08-23 00:57:19 +00:00
|
|
|
{
|
2012-11-02 09:41:26 +00:00
|
|
|
MetaElem *ml = ml_ptr->data;
|
2010-08-23 00:57:19 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (BLI_remlink_safe(&mb->elems, ml) == false) {
|
2012-10-20 10:28:34 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Metaball '%s' does not contain spline given", mb->id.name + 2);
|
2010-08-23 00:57:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(ml);
|
2012-11-02 09:41:26 +00:00
|
|
|
RNA_POINTER_INVALIDATE(ml_ptr);
|
2010-08-23 00:57:19 +00:00
|
|
|
|
|
|
|
|
/* cheating way for importers to avoid slow updates */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (mb->id.us > 0) {
|
2011-01-03 12:41:16 +00:00
|
|
|
DAG_id_tag_update(&mb->id, 0);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id);
|
2010-08-23 00:57:19 +00:00
|
|
|
}
|
2009-07-29 12:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-23 16:12:11 +00:00
|
|
|
static void rna_MetaBall_elements_clear(MetaBall *mb)
|
|
|
|
|
{
|
|
|
|
|
BLI_freelistN(&mb->elems);
|
|
|
|
|
|
|
|
|
|
/* cheating way for importers to avoid slow updates */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (mb->id.us > 0) {
|
2011-11-23 16:12:11 +00:00
|
|
|
DAG_id_tag_update(&mb->id, 0);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id);
|
2011-11-23 16:12:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 22:57:00 +00:00
|
|
|
static int rna_Meta_is_editmode_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
MetaBall *mb = ptr->id.data;
|
|
|
|
|
return (mb->editelems != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 17:22:49 +00:00
|
|
|
static char *rna_MetaElement_path(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
MetaBall *mb = ptr->id.data;
|
|
|
|
|
MetaElem *ml = ptr->data;
|
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
|
|
if (mb->editelems)
|
|
|
|
|
index = BLI_findindex(mb->editelems, ml);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
index = BLI_findindex(&mb->elems, ml);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return BLI_sprintfN("elements[%d]", index);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 20:18:55 +00:00
|
|
|
#else
|
|
|
|
|
|
2009-09-14 16:52:06 +00:00
|
|
|
static void rna_def_metaelement(BlenderRNA *brna)
|
2008-11-30 20:18:55 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2010-08-23 00:57:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "MetaElement", NULL);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_struct_sdna(srna, "MetaElem");
|
2015-10-24 02:44:43 +11:00
|
|
|
RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a Metaball data-block");
|
2013-08-08 17:22:49 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_MetaElement_path");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_META);
|
2010-11-18 04:26:50 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* enums */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_metaelem_type_items);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "Metaball types");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* number values */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "x");
|
|
|
|
|
RNA_def_property_array(prop, 3);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Location", "");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "quat");
|
2010-12-08 13:02:16 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Rotation", "Normalized quaternion rotation");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_rotation");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED | PROP_UNIT_LENGTH);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "rad");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Radius", "");
|
2009-11-05 02:21:04 +00:00
|
|
|
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_DISTANCE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expx");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2009-07-30 18:32:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expy");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Size Y", "Size of element, use of components depends on element type");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2009-07-30 18:32:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_DISTANCE);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expz");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "s");
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 10.0f);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-01 19:02:27 +00:00
|
|
|
/* flags */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_HIDE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hide", "Hide element");
|
2009-08-10 21:10:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-23 00:57:19 +00:00
|
|
|
/* mball.elements */
|
|
|
|
|
static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
|
|
|
|
RNA_def_property_srna(cprop, "MetaBallElements");
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "MetaBallElements", NULL);
|
2010-08-23 00:57:19 +00:00
|
|
|
RNA_def_struct_sdna(srna, "MetaBall");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Meta Elements", "Collection of metaball elements");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "rna_MetaBall_elements_new");
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Add a new element to the metaball");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(func, "type", rna_enum_metaelem_type_items, MB_BALL, "", "type for the new meta-element");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "element", "MetaElement", "", "The newly created meta-element");
|
2010-08-23 00:57:19 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_MetaBall_elements_remove");
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Remove an element from the metaball");
|
2010-08-23 00:57:19 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove");
|
2012-11-02 09:41:26 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
|
|
|
|
|
RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
|
2010-08-23 00:57:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear");
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Remove all elements from the metaball");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
2010-08-23 00:57:19 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "lastelem");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Active Element", "Last selected element");
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 16:52:06 +00:00
|
|
|
static void rna_def_metaball(BlenderRNA *brna)
|
2008-11-30 20:18:55 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
static EnumPropertyItem prop_update_items[] = {
|
2010-02-11 01:11:52 +00:00
|
|
|
{MB_UPDATE_ALWAYS, "UPDATE_ALWAYS", 0, "Always", "While editing, update metaball always"},
|
|
|
|
|
{MB_UPDATE_HALFRES, "HALFRES", 0, "Half", "While editing, update metaball in half resolution"},
|
|
|
|
|
{MB_UPDATE_FAST, "FAST", 0, "Fast", "While editing, update metaball without polygonization"},
|
|
|
|
|
{MB_UPDATE_NEVER, "NEVER", 0, "Never", "While editing, don't update metaball at all"},
|
2012-05-12 11:01:29 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "MetaBall", "ID");
|
2015-10-24 02:44:43 +11:00
|
|
|
RNA_def_struct_ui_text(srna, "MetaBall", "Metaball data-block to defined blobby surfaces");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_META_DATA);
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "elems", NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "MetaElement");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Elements", "Meta elements");
|
2010-08-23 00:57:19 +00:00
|
|
|
rna_def_metaball_elements(brna, prop);
|
2008-12-02 23:45:11 +00:00
|
|
|
|
|
|
|
|
/* enums */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "update_method", PROP_ENUM, PROP_NONE);
|
2010-08-18 07:14:10 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "flag");
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_enum_items(prop, prop_update_items);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Update", "Metaball edit update behavior");
|
2009-07-29 12:35:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* number values */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "resolution", PROP_FLOAT, PROP_DISTANCE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "wiresize");
|
2013-08-19 17:58:28 +00:00
|
|
|
RNA_def_property_range(prop, 0.005f, 10000.0f);
|
2013-10-08 12:52:01 +00:00
|
|
|
RNA_def_property_ui_range(prop, 0.05f, 1000.0f, 2.5f, 3);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport");
|
2009-07-29 12:35:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "render_resolution", PROP_FLOAT, PROP_DISTANCE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "rendersize");
|
2013-08-19 17:58:28 +00:00
|
|
|
RNA_def_property_range(prop, 0.005f, 10000.0f);
|
2013-10-08 12:52:01 +00:00
|
|
|
RNA_def_property_ui_range(prop, 0.025f, 1000.0f, 2.5f, 3);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "thresh");
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 5.0f);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Threshold", "Influence of meta elements");
|
2009-07-29 12:35:09 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2010-04-12 05:04:49 +00:00
|
|
|
/* texture space */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "texflag", MB_AUTOSPACE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Auto Texture Space",
|
|
|
|
|
"Adjust active object's texture space automatically when transforming object");
|
2010-04-12 05:04:49 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2010-05-04 05:15:53 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_Meta_texspace_loc_get", "rna_Meta_texspace_loc_set", NULL);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
|
|
|
|
|
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_Meta_texspace_size_get", "rna_Meta_texspace_size_set", NULL);
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
|
|
|
|
|
2012-04-22 11:54:53 +00:00
|
|
|
/* not supported yet */
|
|
|
|
|
#if 0
|
2012-05-12 11:01:29 +00:00
|
|
|
prop = RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
|
2011-11-11 13:09:14 +00:00
|
|
|
RNA_def_property_float(prop, NULL, "rot");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
|
|
|
|
|
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
|
2012-04-22 11:54:53 +00:00
|
|
|
#endif
|
2010-04-12 05:04:49 +00:00
|
|
|
|
|
|
|
|
/* materials */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
|
2010-04-12 05:04:49 +00:00
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
|
|
|
|
|
RNA_def_property_struct_type(prop, "Material");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Materials", "");
|
2011-10-01 17:54:33 +00:00
|
|
|
RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
|
2013-09-11 21:27:14 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
|
2009-08-03 13:09:23 +00:00
|
|
|
|
2013-07-03 22:57:00 +00:00
|
|
|
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", NULL);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
|
|
|
|
|
|
2009-08-03 13:09:23 +00:00
|
|
|
/* anim */
|
|
|
|
|
rna_def_animdata_common(srna);
|
2013-02-11 10:56:21 +00:00
|
|
|
|
|
|
|
|
RNA_api_meta(srna);
|
2008-11-30 20:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-01 19:02:27 +00:00
|
|
|
void RNA_def_meta(BlenderRNA *brna)
|
|
|
|
|
{
|
2008-12-02 23:45:11 +00:00
|
|
|
rna_def_metaelement(brna);
|
2008-12-01 19:02:27 +00:00
|
|
|
rna_def_metaball(brna);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 20:18:55 +00:00
|
|
|
#endif
|