[Bf-blender-cvs] [e054b7f2517] blender2.8: BKE_object: Add BKE_object_data_is_in_editmode

Campbell Barton noreply at git.blender.org
Wed May 30 10:31:01 CEST 2018


Commit: e054b7f25172d433f536130e0b814b5921bd25ec
Author: Campbell Barton
Date:   Wed May 30 10:15:36 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBe054b7f25172d433f536130e0b814b5921bd25ec

BKE_object: Add BKE_object_data_is_in_editmode

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

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

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

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) {



More information about the Bf-blender-cvs mailing list