diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-09 05:43:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-09 05:43:39 +0400 |
commit | 28826d22e9cf2464d8f6bc84e5273de4d38ce3ab (patch) | |
tree | 37967558c17850f0e0de2b7bdea18a96ebc59852 /source/blender | |
parent | 9e5a670b1d2285826bf33a177b32eb5862c771db (diff) |
rigidbody operators poll functions were mixing up CTX_data_active_object/ED_object_active_context.
- replace ED_operator_rigidbody_add_poll with ED_operator_object_active_editable_mesh
- replace ED_operator_rigidbody_active_poll with ED_operator_scene_editable for operators that use the entire selection.
- remove rigid-body from objects that are converted from meshes to curves, while this isnt crashing it is confusing to see in the UI.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_add.c | 5 | ||||
-rw-r--r-- | source/blender/editors/physics/rigidbody_object.c | 27 |
2 files changed, 13 insertions, 19 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d63a964c26a..08282da5245 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -101,6 +101,7 @@ #include "ED_mesh.h" #include "ED_node.h" #include "ED_object.h" +#include "ED_physics.h" #include "ED_render.h" #include "ED_screen.h" #include "ED_transform.h" @@ -1489,8 +1490,10 @@ static int convert_exec(bContext *C, wmOperator *op) BKE_mesh_to_curve(scene, newob); - if (newob->type == OB_CURVE) + if (newob->type == OB_CURVE) { BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ + ED_rigidbody_object_remove(scene, newob); + } } else if (ob->type == OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 6670422a70d..7761ab0a42d 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -61,6 +61,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_object.h" #include "ED_physics.h" #include "ED_screen.h" @@ -72,23 +73,13 @@ static int ED_operator_rigidbody_active_poll(bContext *C) { if (ED_operator_object_active_editable(C)) { - Object *ob = CTX_data_active_object(C); + Object *ob = ED_object_active_context(C); return (ob && ob->rigidbody_object); } else return 0; } -static int ED_operator_rigidbody_add_poll(bContext *C) -{ - if (ED_operator_object_active_editable(C)) { - Object *ob = CTX_data_active_object(C); - return (ob && ob->type == OB_MESH); - } - else - return 0; -} - /* ----------------- */ bool ED_rigidbody_object_add(Scene *scene, Object *ob, int type, ReportList *reports) @@ -152,7 +143,7 @@ void ED_rigidbody_object_remove(Scene *scene, Object *ob) static int rigidbody_object_add_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); + Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); bool change; @@ -180,7 +171,7 @@ void RIGIDBODY_OT_object_add(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_object_add_exec; - ot->poll = ED_operator_rigidbody_add_poll; + ot->poll = ED_operator_object_active_editable_mesh; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -194,7 +185,7 @@ void RIGIDBODY_OT_object_add(wmOperatorType *ot) static int rigidbody_object_remove_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); + Object *ob = ED_object_active_context(C); bool change = false; /* apply to active object */ @@ -270,7 +261,7 @@ void RIGIDBODY_OT_objects_add(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_objects_add_exec; - ot->poll = ED_operator_rigidbody_add_poll; + ot->poll = ED_operator_object_active_editable_mesh; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -317,7 +308,7 @@ void RIGIDBODY_OT_objects_remove(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_objects_remove_exec; - ot->poll = ED_operator_rigidbody_active_poll; + ot->poll = ED_operator_scene_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -372,7 +363,7 @@ void RIGIDBODY_OT_shape_change(wmOperatorType *ot) /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = rigidbody_objects_shape_change_exec; - ot->poll = ED_operator_rigidbody_active_poll; + ot->poll = ED_operator_scene_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -627,7 +618,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot) /* callbacks */ ot->invoke = WM_menu_invoke; // XXX ot->exec = rigidbody_objects_calc_mass_exec; - ot->poll = ED_operator_rigidbody_active_poll; + ot->poll = ED_operator_scene_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |