diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
commit | 67474a7e622957044bc708119a7cfa49a82790fd (patch) | |
tree | 1689263da79f08b1c3c9725ac56c3da8b5d91fbb /source/blender/editors/physics/rigidbody_constraint.c | |
parent | b091542fe91353c15dd7240ba7ce8ecf72d4011b (diff) | |
parent | 553b581f25c1782c4231816965cd3f6ce58a449a (diff) |
Merge master to soc-2019-cycles-procedural.soc-2019-cycles-procedural
Diffstat (limited to 'source/blender/editors/physics/rigidbody_constraint.c')
-rw-r--r-- | source/blender/editors/physics/rigidbody_constraint.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index 2c454448b9b..a1d76174cc8 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -46,6 +46,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_object.h" #include "ED_physics.h" #include "ED_screen.h" @@ -56,12 +57,37 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C) { + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + return false; + } + 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_constraint); } else { - return 0; + return false; + } +} + +static bool ED_operator_rigidbody_con_add_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + return false; + } + + if (ED_operator_object_active_editable(C)) { + Object *ob = ED_object_active_context(C); + return (ob && ob->type == OB_MESH); + } + else { + return false; } } @@ -152,7 +178,7 @@ void RIGIDBODY_OT_constraint_add(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_con_add_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_rigidbody_con_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |