Commit: 4af280ac90d7f32d68cc6523ec5f3219eaa0ece5
Author: Dalai Felinto
Date:   Fri Oct 26 13:21:54 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB4af280ac90d7f32d68cc6523ec5f3219eaa0ece5

Refactor cleanup: BKE_object_is_in_editmode

Using switch and keep it concise.

===================================================================

M       source/blender/blenkernel/intern/object.c

===================================================================

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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to