Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-09-03 09:23:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-09-03 09:27:15 +0300
commit3cbfe96681f69fcbccd1519d731168700dbf878a (patch)
treeb603e609537172bd41139eb42c9ca1711aa22cc0 /source/blender/makesrna/intern/rna_main_api.c
parentc017e1cb676314690a8c0b7da154a0815024171e (diff)
Object: add BKE_object_obdata_to_type utility function
Move functionality to get the object type from an ID into it's own function.
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c58
1 files changed, 9 insertions, 49 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 7c941ddb524..8a34bf0245b 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -228,57 +228,17 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char
Object *ob;
int type = OB_EMPTY;
+
if (data) {
- /* keep in sync with OB_DATA_SUPPORT_ID() macro */
- switch (GS(data->name)) {
- case ID_ME:
- type = OB_MESH;
- break;
- case ID_CU:
- type = BKE_curve_type_get((Curve *)data);
- break;
- case ID_MB:
- type = OB_MBALL;
- break;
- case ID_LA:
- type = OB_LAMP;
- break;
- case ID_SPK:
- type = OB_SPEAKER;
- break;
- case ID_CA:
- type = OB_CAMERA;
- break;
- case ID_LT:
- type = OB_LATTICE;
- break;
- case ID_GD:
- type = OB_GPENCIL;
- break;
- case ID_AR:
- type = OB_ARMATURE;
- break;
- case ID_LP:
- type = OB_LIGHTPROBE;
- break;
- case ID_HA:
- type = OB_HAIR;
- break;
- case ID_PT:
- type = OB_POINTCLOUD;
- break;
- case ID_VO:
- type = OB_VOLUME;
- break;
- default: {
- const char *idname;
- if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) {
- idname = "UNKNOWN";
- }
-
- BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname);
- return NULL;
+ type = BKE_object_obdata_to_type(data);
+ if (type == -1) {
+ const char *idname;
+ if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) {
+ idname = "UNKNOWN";
}
+
+ BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname);
+ return NULL;
}
id_us_plus(data);