diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-08-11 01:10:09 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-08-11 01:10:09 +0400 |
commit | 6e5b78a2774b3d10226e3c48e558a9059086e416 (patch) | |
tree | ec1e51b628b659d9be4429cd539ed7b596ccf345 /source/blender/makesrna/intern/rna_meta.c | |
parent | 8dd523a154d1adfa28453c1fab00e7fd8e7e502d (diff) |
RNA: make curve and metaball update functions consistent with
others, these cannot assume the existence of an edit object
or active object.
Diffstat (limited to 'source/blender/makesrna/intern/rna_meta.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index ad16c5a7c5c..75922fdf2a0 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -39,6 +39,7 @@ #include "BKE_mball.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "WM_types.h" #include "WM_api.h" @@ -51,29 +52,19 @@ static int rna_Meta_texspace_editable(PointerRNA *ptr) static void rna_MetaBall_update_data(bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); 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); + 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); + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } } - 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) -{ - 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 @@ -99,59 +90,59 @@ void rna_def_metaelement(BlenderRNA *brna) 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."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + 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_MetaElem_update_data"); + 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_MetaElem_update_data"); + 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_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "expx"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_NONE); 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."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_NONE); 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."); - RNA_def_property_update(prop, 0, "rna_MetaElem_update_data"); + 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_MetaElem_update_data"); + 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_MetaElem_update_data"); + 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_MetaElem_update_data"); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); } void rna_def_metaball(BlenderRNA *brna) |