diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 18:57:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 18:57:19 +0400 |
commit | 32254596d4de9558b7af81bfe69db5d160a97769 (patch) | |
tree | 022629de72b05ce7bf7165ed43a123435de7b9ab /source/blender | |
parent | 82688e61fc330022bd8685a5a137fca024a60b8a (diff) |
replace ELEM8(gs, ID_ME, ID_CU, ID_MB, ID_LT, ID_LA, ID_CA, ID_TXT, ID_SPK) with macro: OB_DATA_SUPPORT_ID()
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 11 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 9 |
6 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 87ebc597ecd..b22e24e15d4 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2596,7 +2596,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) if (id) { idtype = GS(id->name); - if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) { + + if (OB_DATA_SUPPORT_ID(idtype)) { for (obt = bmain->object.first; obt; obt = obt->id.next) { if (!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index f97dd2f859d..f888cf60a24 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -494,6 +494,9 @@ short *give_totcolp(Object *ob) /* same as above but for ID's */ Material ***give_matarar_id(ID *id) { + /* ensure we don't try get materials from non-obdata */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->mat); @@ -510,6 +513,9 @@ Material ***give_matarar_id(ID *id) short *give_totcolp_id(ID *id) { + /* ensure we don't try get materials from non-obdata */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->totcol); @@ -526,6 +532,9 @@ short *give_totcolp_id(ID *id) static void data_delete_material_index_id(ID *id, short index) { + /* ensure we don't try get materials from non-obdata */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); + switch (GS(id->name)) { case ID_ME: BKE_mesh_delete_material_index((Mesh *)id, index); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ac3210348de..ff7728d4f68 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -388,21 +388,22 @@ static int object_select_all_by_library_obdata(bContext *C, Library *lib) void ED_object_select_linked_by_id(bContext *C, ID *id) { - int gs = GS(id->name); + int idtype = GS(id->name); int changed = FALSE; - if (ELEM8(gs, ID_ME, ID_CU, ID_MB, ID_LT, ID_LA, ID_CA, ID_TXT, ID_SPK)) { + if (OB_DATA_SUPPORT_ID(idtype)) { changed = object_select_all_by_obdata(C, id); } - else if (gs == ID_MA) { + else if (idtype == ID_MA) { changed = object_select_all_by_material_texture(C, FALSE, (Material *)id, NULL); } - else if (gs == ID_LI) { + else if (idtype == ID_LI) { changed = object_select_all_by_library(C, (Library *) id); } - if (changed) + if (changed) { WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); + } } static int object_select_linked_exec(bContext *C, wmOperator *op) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 3da6d0fc99d..597103a78df 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -343,6 +343,10 @@ typedef struct DupliObject { #define OB_TYPE_SUPPORT_EDITMODE(_type) \ (ELEM7(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) +/* is this ID type used as object data */ +#define OB_DATA_SUPPORT_ID(_id_type) \ + (ELEM8(_id_type, ID_ME, ID_CU, ID_MB, ID_LA, ID_SPK, ID_CA, ID_LT, ID_AR)) + /* partype: first 4 bits: type */ #define PARTYPE 15 #define PAROBJECT 0 diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index c702972b3b7..59eae3259b4 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -140,6 +140,7 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha 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; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 7aedbf40eba..9770b51654c 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -355,10 +355,14 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) set_mesh(ob, (Mesh *)id); } else { - if (ob->data) + if (ob->data) { id_us_min((ID *)ob->data); - if (id) + } + if (id) { + /* no need to type-check here ID. this is done in the _typef() function */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); id_us_plus(id); + } ob->data = id; test_object_materials(id); @@ -374,6 +378,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) { Object *ob = (Object *)ptr->data; + /* keep in sync with OB_DATA_SUPPORT_ID() macro */ switch (ob->type) { case OB_EMPTY: return &RNA_Image; case OB_MESH: return &RNA_Mesh; |