blob: 6074ba8514750bfebef3906ff8e5d99a1c40f891 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
* Modifier stack implementation.
*
* BKE_modifier.h contains the function prototypes for this file.
*/
/** \file
* \ingroup bke
*/
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "CLG_log.h"
#include "BLT_translation.h"
#include "DNA_ID.h"
#include "BKE_idcode.h"
#include "BKE_idtype.h"
// static CLG_LogRef LOG = {"bke.idtype"};
static IDTypeInfo *id_types[INDEX_ID_MAX] = {NULL};
static void id_type_init(void)
{
#define INIT_TYPE(_id_code) \
{ \
BLI_assert(IDType_##_id_code.main_listbase_index == INDEX_##_id_code); \
id_types[INDEX_##_id_code] = &IDType_##_id_code; \
} \
(void)0
INIT_TYPE(ID_SCE);
INIT_TYPE(ID_LI);
INIT_TYPE(ID_OB);
INIT_TYPE(ID_ME);
INIT_TYPE(ID_CU);
INIT_TYPE(ID_MB);
INIT_TYPE(ID_MA);
INIT_TYPE(ID_TE);
INIT_TYPE(ID_IM);
INIT_TYPE(ID_LT);
INIT_TYPE(ID_LA);
INIT_TYPE(ID_CA);
// INIT_TYPE(ID_IP);
INIT_TYPE(ID_KE);
INIT_TYPE(ID_WO);
INIT_TYPE(ID_SCR);
INIT_TYPE(ID_VF);
INIT_TYPE(ID_TXT);
INIT_TYPE(ID_SPK);
INIT_TYPE(ID_SO);
INIT_TYPE(ID_GR);
INIT_TYPE(ID_AR);
INIT_TYPE(ID_AC);
INIT_TYPE(ID_NT);
INIT_TYPE(ID_BR);
INIT_TYPE(ID_PA);
// INIT_TYPE(ID_GD);
INIT_TYPE(ID_WM);
INIT_TYPE(ID_MC);
INIT_TYPE(ID_MSK);
INIT_TYPE(ID_LS);
// INIT_TYPE(ID_PAL);
INIT_TYPE(ID_PC);
INIT_TYPE(ID_CF);
INIT_TYPE(ID_WS);
INIT_TYPE(ID_LP);
#undef INIT_TYPE
}
void BKE_idtype_init(void)
{
/* Initialize data-block types. */
id_type_init();
}
const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code)
{
int id_index = BKE_idcode_to_index(id_code);
if (id_index >= 0 && id_index < INDEX_ID_MAX && id_types[id_index] != NULL &&
id_types[id_index]->name[0] != '\0') {
return id_types[id_index];
}
else {
return NULL;
}
}
const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id)
{
return BKE_idtype_get_info_from_idcode(GS(id->name));
}
|