diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-30 11:15:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-30 11:29:41 +0300 |
commit | e054b7f25172d433f536130e0b814b5921bd25ec (patch) | |
tree | cc78cc3afd1393201e41fd7974c4f679cd349ee3 | |
parent | 01f9e13c301c850cf4b07725ac5e24b8d15dd53a (diff) |
BKE_object: Add BKE_object_data_is_in_editmode
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 4621f2fbe31..ab9af27bec3 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -85,6 +85,8 @@ bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob); bool BKE_object_has_mode_data(const struct Object *ob, eObjectMode object_mode); bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode); +bool BKE_object_data_is_in_editmode(const struct ID *id); + typedef enum eObjectVisibilityCheck { OB_VISIBILITY_CHECK_FOR_VIEWPORT, OB_VISIBILITY_CHECK_FOR_RENDER, diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 87417ccc6b0..1a491f63249 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -508,6 +508,30 @@ bool BKE_object_is_in_editmode_vgroup(const Object *ob) BKE_object_is_in_editmode(ob)); } +bool BKE_object_data_is_in_editmode(const ID *id) +{ + const short type = GS(id->name); + BLI_assert(OB_DATA_SUPPORT_EDITMODE(type)); + switch (type) { + case ID_ME: + return ((const Mesh *)id)->edit_btmesh != NULL; + case ID_CU: + return ( + (((const Curve *)id)->editnurb != NULL) || + (((const Curve *)id)->editfont != NULL) + ); + case ID_MB: + return ((const MetaBall *)id)->editelems != NULL; + case ID_LT: + return ((const Lattice *)id)->editlatt != NULL; + case ID_AR: + return ((const bArmature *)id)->edbo != NULL; + default: + BLI_assert(0); + return false; + } +} + bool BKE_object_is_in_wpaint_select_vert(const Object *ob) { if (ob->type == OB_MESH) { |