Sun Position: Fix crash when Blender was started in background
[blender-addons.git] / io_scene_fbx / data_types.py
blob38d3fec4ddd8b67391c3bf84205c25307c114a05
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Script copyright (C) 2006-2012, assimp team
4 # Script copyright (C) 2013 Blender Foundation
6 BOOL = b'C'[0]
7 INT16 = b'Y'[0]
8 INT32 = b'I'[0]
9 INT64 = b'L'[0]
10 FLOAT32 = b'F'[0]
11 FLOAT64 = b'D'[0]
12 BYTES = b'R'[0]
13 STRING = b'S'[0]
14 INT32_ARRAY = b'i'[0]
15 INT64_ARRAY = b'l'[0]
16 FLOAT32_ARRAY = b'f'[0]
17 FLOAT64_ARRAY = b'd'[0]
18 BOOL_ARRAY = b'b'[0]
19 BYTE_ARRAY = b'c'[0]
21 # Some other misc defines
22 # Known combinations so far - supposed meaning: A = animatable, A+ = animated, U = UserProp
23 # VALID_NUMBER_FLAGS = {b'A', b'A+', b'AU', b'A+U'} # Not used...
25 # array types - actual length may vary (depending on underlying C implementation)!
26 import array
28 # For now, bytes and bool are assumed always 1byte.
29 ARRAY_BOOL = 'b'
30 ARRAY_BYTE = 'B'
32 ARRAY_INT32 = None
33 ARRAY_INT64 = None
34 for _t in 'ilq':
35 size = array.array(_t).itemsize
36 if size == 4:
37 ARRAY_INT32 = _t
38 elif size == 8:
39 ARRAY_INT64 = _t
40 if ARRAY_INT32 and ARRAY_INT64:
41 break
42 if not ARRAY_INT32:
43 raise Exception("Impossible to get a 4-bytes integer type for array!")
44 if not ARRAY_INT64:
45 raise Exception("Impossible to get an 8-bytes integer type for array!")
47 ARRAY_FLOAT32 = None
48 ARRAY_FLOAT64 = None
49 for _t in 'fd':
50 size = array.array(_t).itemsize
51 if size == 4:
52 ARRAY_FLOAT32 = _t
53 elif size == 8:
54 ARRAY_FLOAT64 = _t
55 if ARRAY_FLOAT32 and ARRAY_FLOAT64:
56 break
57 if not ARRAY_FLOAT32:
58 raise Exception("Impossible to get a 4-bytes float type for array!")
59 if not ARRAY_FLOAT64:
60 raise Exception("Impossible to get an 8-bytes float type for array!")