2008-11-30 20:18:55 +00:00
|
|
|
/**
|
|
|
|
|
* $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.
|
|
|
|
|
*
|
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 *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
2009-01-08 13:57:29 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2008-11-30 20:18:55 +00:00
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
MetaBall *mb= (MetaBall*)ptr->data;
|
2009-03-23 13:24:48 +00:00
|
|
|
return (mb->texflag & AUTOSPACE)? 0: PROP_EDITABLE;
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:35:09 +00:00
|
|
|
static void rna_MetaBall_update_data(bContext *C, PointerRNA *ptr)
|
2009-08-03 14:40:10 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *active_object = CTX_data_active_object(C);
|
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
|
|
|
|
|
|
if(obedit) {
|
|
|
|
|
copy_mball_properties(scene, obedit);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
|
|
|
|
|
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
|
|
|
|
|
}
|
|
|
|
|
else if(active_object) {
|
|
|
|
|
copy_mball_properties(scene, active_object);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, active_object);
|
|
|
|
|
DAG_object_flush_update(scene, active_object, OB_RECALC_DATA);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_MetaElem_update_data(bContext *C, PointerRNA *ptr)
|
2009-07-29 12:35:09 +00:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-30 20:18:55 +00:00
|
|
|
#else
|
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
void rna_def_metaelement(BlenderRNA *brna)
|
2008-11-30 20:18:55 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
static EnumPropertyItem prop_type_items[] = {
|
2009-07-29 20:56:22 +00:00
|
|
|
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
|
|
|
|
|
{MB_TUBE, "TUBE", ICON_META_TUBE, "Tube", ""},
|
|
|
|
|
{MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
|
|
|
|
|
{MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition!
|
|
|
|
|
{MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "MetaElement", NULL);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_struct_sdna(srna, "MetaElem");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock.");
|
|
|
|
|
RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_META);
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* enums */
|
2008-11-30 20:18:55 +00:00
|
|
|
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(prop, prop_type_items);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Type", "Metaball types.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* 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", "");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
|
|
|
|
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", "");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
|
|
|
|
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", "");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2009-08-07 01:05:33 +00:00
|
|
|
prop= RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expx");
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2009-07-30 18:32:20 +00:00
|
|
|
|
2009-08-07 01:05:33 +00:00
|
|
|
prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_NONE);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expy");
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Size Y", "Size of element, use of components depends on element type.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2009-07-30 18:32:20 +00:00
|
|
|
|
2009-08-07 01:05:33 +00:00
|
|
|
prop= RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_NONE);
|
2009-07-30 18:32:20 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "expz");
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 20.0f);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
|
|
|
|
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);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-01 19:02:27 +00:00
|
|
|
/* flags */
|
2008-12-02 23:45:11 +00:00
|
|
|
prop= RNA_def_property(srna, "negative", PROP_BOOLEAN, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-02 23:45:11 +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);
|
2008-12-02 23:45:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Hide", "Hide element.");
|
2009-08-03 14:40:10 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_MetaElem_update_data");
|
2008-11-30 20:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-01 19:02:27 +00:00
|
|
|
void rna_def_metaball(BlenderRNA *brna)
|
2008-11-30 20:18:55 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
static EnumPropertyItem prop_update_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{MB_UPDATE_ALWAYS, "UPDATE_ALWAYS", 0, "Always", "While editing, update metaball always."},
|
2009-07-29 18:44:54 +00:00
|
|
|
{MB_UPDATE_HALFRES, "HALFRES", 0, "Half", "While editing, update metaball in half resolution."},
|
2009-06-16 00:52:21 +00:00
|
|
|
{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."},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-11-30 20:18:55 +00:00
|
|
|
|
2008-12-19 04:06:24 +00:00
|
|
|
srna= RNA_def_struct(brna, "MetaBall", "ID");
|
2009-01-10 22:57:33 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "MetaBall", "Metaball datablock 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
|
|
|
|
|
|
|
|
prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "elems", NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "MetaElement");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Elements", "Meta elements.");
|
|
|
|
|
|
2009-08-07 01:05:33 +00:00
|
|
|
prop= RNA_def_property(srna, "active_element", PROP_POINTER, PROP_NONE);
|
2009-07-29 12:35:09 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "lastelem");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Last selected element.", "Last selected element.");
|
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
/* enums */
|
2008-11-30 20:18:55 +00:00
|
|
|
prop= RNA_def_property(srna, "flag", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(prop, prop_update_items);
|
2008-12-02 23:45:11 +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 */
|
|
|
|
|
prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "wiresize");
|
|
|
|
|
RNA_def_property_range(prop, 0.050f, 1.0f);
|
2008-12-02 23:45:11 +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
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_NONE);
|
2008-11-30 20:18:55 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "rendersize");
|
|
|
|
|
RNA_def_property_range(prop, 0.050f, 1.0f);
|
2008-12-02 23:45:11 +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
|
|
|
|
2008-12-01 06:52:18 +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);
|
2008-12-02 23:45:11 +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
|
|
|
|
|
|
|
|
/* materials, textures */
|
|
|
|
|
rna_def_texmat_common(srna, "rna_Meta_texspace_editable");
|
2009-08-03 13:09:23 +00:00
|
|
|
|
|
|
|
|
/* anim */
|
|
|
|
|
rna_def_animdata_common(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
|