diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-23 04:57:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-23 04:57:19 +0400 |
commit | 11228cb4031c8e0a324d2ffa4463e2fb272f517c (patch) | |
tree | 96b641f7b939eb3c2ba355b5e47053418b0360a3 /source/blender/makesrna | |
parent | 8a320974f1b3e6004db3b3ad64f97742f878cbee (diff) |
rna: move metaball.active_element to metaball.elements.active
added rna funcs...
elem = metaball.elements.new()
metaball.elements.remove(elem)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 104 | ||||
-rw-r--r-- | source/blender/makesrna/rna_cleanup/rna_properties.txt | 3 |
3 files changed, 87 insertions, 21 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index cfca29aaa83..4995a50fff6 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -482,7 +482,6 @@ static Nurb *rna_Curve_spline_new(Curve *cu, int type) static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) { - /* todo, check we're in the list */ int found= 0; ListBase *nurbs= BKE_curve_nurbs(cu); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 0de8455bdb7..59fff17b1ea 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -35,6 +35,8 @@ #include "BLI_math.h" +#include "MEM_guardedalloc.h" + #include "DNA_scene_types.h" #include "DNA_object_types.h" @@ -89,28 +91,66 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) MetaBall *mb= ptr->id.data; Object *ob; - for(ob=bmain->object.first; ob; ob= ob->id.next) - if(ob->data == mb) - copy_mball_properties(scene, ob); + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + for(ob=bmain->object.first; ob; ob= ob->id.next) + if(ob->data == mb) + copy_mball_properties(scene, ob); + + DAG_id_flush_update(&mb->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, mb); + } +} + +static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) +{ + MetaElem *ml= add_metaball_element(mb, type); + + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + DAG_id_flush_update(&mb->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); + } - DAG_id_flush_update(&mb->id, OB_RECALC_DATA); - WM_main_add_notifier(NC_GEOM|ND_DATA, mb); + return ml; +} + +static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, MetaElem *ml) +{ + int found= 0; + + found= BLI_remlink_safe(&mb->elems, ml); + + if(!found) { + BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" does not contain spline given", mb->id.name+2); + return; + } + + MEM_freeN(ml); + /* invalidate pointer!, no can do */ + + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + DAG_id_flush_update(&mb->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); + } } #else +static EnumPropertyItem metaelem_type_items[] = { + {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", ""}, + {0, NULL, 0, NULL, NULL}}; + static void rna_def_metaelement(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_type_items[] = { - {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", ""}, - {0, NULL, 0, NULL, NULL}}; - + srna= RNA_def_struct(brna, "MetaElement", NULL); RNA_def_struct_sdna(srna, "MetaElem"); RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock"); @@ -118,7 +158,7 @@ static void rna_def_metaelement(BlenderRNA *brna) /* enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_items(prop, metaelem_type_items); RNA_def_property_ui_text(prop, "Type", "Metaball types"); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); @@ -176,6 +216,37 @@ static void rna_def_metaelement(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); } +/* 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"); + srna= RNA_def_struct(brna, "MetaBallElements", NULL); + RNA_def_struct_sdna(srna, "MetaBall"); + RNA_def_struct_ui_text(srna, "Meta Elements", "Collection of metaball elements"); + + func= RNA_def_function(srna, "new", "rna_MetaBall_elements_new"); + RNA_def_function_ui_description(func, "Add a new spline to the curve."); + parm= RNA_def_enum(func, "type", metaelem_type_items, MB_BALL, "", "type for the new meta element."); + parm= RNA_def_pointer(func, "element", "MetaElement", "", "The newly created metaelement."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_MetaBall_elements_remove"); + RNA_def_function_ui_description(func, "Remove a spline from a curve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); + RNA_def_property_ui_text(prop, "Active Element", "Last selected element"); +} + static void rna_def_metaball(BlenderRNA *brna) { StructRNA *srna; @@ -195,11 +266,8 @@ static void rna_def_metaball(BlenderRNA *brna) 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"); + rna_def_metaball_elements(brna, prop); - prop= RNA_def_property(srna, "active_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, "update_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "flag"); diff --git a/source/blender/makesrna/rna_cleanup/rna_properties.txt b/source/blender/makesrna/rna_cleanup/rna_properties.txt index b319ce15ba1..87e0021bd5c 100644 --- a/source/blender/makesrna/rna_cleanup/rna_properties.txt +++ b/source/blender/makesrna/rna_cleanup/rna_properties.txt @@ -620,7 +620,7 @@ #+ * CurveMapping.curves -> curves: collection, "(read-only)" #CurveMapping.use_clip -> use_clip: boolean "Force the curve view to fit a defined boundary" #+ * CurveMapping.white_level -> white_level: float[3] "For RGB curves, the color that white is mapped to" -#TODO MOVE TO COLLECTION * CurveSplines.active -> active: pointer "Active curve spline" +#+ * CurveSplines.active -> active: pointer "Active curve spline" #DopeSheet.filter_group -> filter_group: pointer "Group that included Object should be a member of" #DopeSheet.show_armatures -> show_armatures: boolean "Include visualization of Armature related Animation data" #DopeSheet.show_cameras -> show_cameras: boolean "Include visualization of Camera related Animation data" @@ -1476,7 +1476,6 @@ #+ * ID|Mesh.uv_textures -> uv_textures: collection, "(read-only)" #+ * ID|Mesh.vertex_colors -> vertex_colors: collection, "(read-only)" #ID|Mesh.vertices -> vertices: collection, "(read-only) Vertices of the mesh" -#TODO MOVE TO ELEMENTS * ID|MetaBall.active_element -> active_element: pointer, "(read-only) Last selected element" #+ * ID|MetaBall.animation_data -> animation_data: pointer, "(read-only) Animation data for this datablock" #+ * ID|MetaBall.elements -> elements: collection, "(read-only) Meta elements" #+ * ID|MetaBall.materials -> materials: collection, "(read-only)" |