diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-10-26 19:21:54 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-10-26 19:39:51 +0300 |
commit | 4af280ac90d7f32d68cc6523ec5f3219eaa0ece5 (patch) | |
tree | 90767eafb90b2dcbf466dd09baa6e8239e2cfa2d /source/blender/blenkernel/intern/object.c | |
parent | a2dc4d253293fd79d29d22222554b6ad35d9a790 (diff) |
Refactor cleanup: BKE_object_is_in_editmode
Using switch and keep it concise.
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c5e1c0cff87..745c907a9af 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -608,45 +608,27 @@ void BKE_object_free(Object *ob) /* actual check for internal data, not context or flags */ bool BKE_object_is_in_editmode(const Object *ob) { - if (ob->data == NULL) + if (ob->data == NULL) { return false; - - if (ob->type == OB_MESH) { - Mesh *me = ob->data; - if (me->edit_btmesh) - return true; - } - else if (ob->type == OB_ARMATURE) { - bArmature *arm = ob->data; - - if (arm->edbo) - return true; } - else if (ob->type == OB_FONT) { - Curve *cu = ob->data; - if (cu->editfont) - return true; - } - else if (ob->type == OB_MBALL) { - MetaBall *mb = ob->data; - - if (mb->editelems) - return true; - } - else if (ob->type == OB_LATTICE) { - Lattice *lt = ob->data; - - if (lt->editlatt) - return true; - } - else if (ob->type == OB_SURF || ob->type == OB_CURVE) { - Curve *cu = ob->data; - - if (cu->editnurb) - return true; + switch (ob->type) { + case OB_MESH: + return ((Mesh *)ob->data)->edit_btmesh != NULL; + case OB_ARMATURE: + return ((bArmature *)ob->data)->edbo != NULL; + case OB_FONT: + return ((Curve *)ob->data)->editfont != NULL; + case OB_MBALL: + return ((MetaBall *)ob->data)->editelems != NULL; + case OB_LATTICE: + return ((Lattice *)ob->data)->editlatt != NULL; + case OB_SURF: + case OB_CURVE: + return ((Curve *)ob->data)->editnurb != NULL; + default: + return false; } - return false; } bool BKE_object_is_in_editmode_vgroup(const Object *ob) |