Object *bc_add_object(Scene *scene, int type, const char *name) { Object *ob = add_only_object(type, name); ob->data= add_obdata_from_type(type); ob->lay= scene->lay; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; scene_select_base(scene, scene_add_base(scene, ob)); return ob; }
Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) { Object *ob; int type= OB_EMPTY; if(data) { switch(GS(data->name)) { case ID_ME: type= OB_MESH; break; case ID_CU: type= curve_type((struct 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_AR: type= OB_ARMATURE; break; default: { const char *idname; if(RNA_enum_id_from_value(id_type_items, GS(data->name), &idname) == 0) idname= "UNKNOWN"; BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for a object.", idname); return NULL; } } id_us_plus(data); } ob= add_only_object(type, name); id_us_min(&ob->id); ob->data= data; test_object_materials(ob->data); return ob; }