Fix #104672: FBX Byte type unsupported #104681
@ -4,6 +4,7 @@
|
||||
# Script copyright (C) 2013 Blender Foundation
|
||||
|
||||
BOOL = b'C'[0]
|
||||
INT8 = b'Z'[0]
|
||||
INT16 = b'Y'[0]
|
||||
INT32 = b'I'[0]
|
||||
INT64 = b'L'[0]
|
||||
|
@ -56,6 +56,13 @@ class FBXElem:
|
||||
self.props_type.append(data_types.BOOL)
|
||||
self.props.append(data)
|
||||
|
||||
def add_int8(self, data):
|
||||
assert(isinstance(data, int))
|
||||
data = pack('<b', data)
|
||||
|
||||
self.props_type.append(data_types.INT8)
|
||||
self.props.append(data)
|
||||
|
||||
def add_int16(self, data):
|
||||
assert(isinstance(data, int))
|
||||
data = pack('<h', data)
|
||||
|
@ -28,6 +28,7 @@ for each property.
|
||||
|
||||
The types are as follows:
|
||||
|
||||
* 'Z': - INT8
|
||||
* 'Y': - INT16
|
||||
* 'C': - BOOL
|
||||
* 'I': - INT32
|
||||
@ -106,6 +107,7 @@ def unpack_array(read, array_type, array_stride, array_byteswap):
|
||||
|
||||
|
||||
read_data_dict = {
|
||||
b'Z'[0]: lambda read: unpack(b'<b', read(1))[0], # 8 bit int
|
||||
b'Y'[0]: lambda read: unpack(b'<h', read(2))[0], # 16 bit int
|
||||
b'C'[0]: lambda read: unpack(b'?', read(1))[0], # 1 bit bool (yes/no)
|
||||
b'I'[0]: lambda read: unpack(b'<i', read(4))[0], # 32 bit int
|
||||
@ -221,6 +223,7 @@ def parse(fn, use_namedtuple=True):
|
||||
data_types = type(array)("data_types")
|
||||
data_types.__dict__.update(
|
||||
dict(
|
||||
INT8 = b'Z'[0],
|
||||
INT16 = b'Y'[0],
|
||||
BOOL = b'C'[0],
|
||||
INT32 = b'I'[0],
|
||||
|
@ -722,6 +722,10 @@ def elem_data_single_bool(elem, name, value):
|
||||
return _elem_data_single(elem, name, value, "add_bool")
|
||||
|
||||
|
||||
def elem_data_single_int8(elem, name, value):
|
||||
return _elem_data_single(elem, name, value, "add_int8")
|
||||
|
||||
|
||||
def elem_data_single_int16(elem, name, value):
|
||||
return _elem_data_single(elem, name, value, "add_int16")
|
||||
|
||||
|
@ -27,6 +27,7 @@ for each property.
|
||||
|
||||
The types are as follows:
|
||||
|
||||
* 'Z': - INT8
|
||||
* 'Y': - INT16
|
||||
* 'C': - BOOL
|
||||
* 'I': - INT32
|
||||
@ -65,6 +66,8 @@ def parse_json_rec(fbx_root, json_node):
|
||||
for d, dt in zip(data, data_types):
|
||||
if dt == "C":
|
||||
e.add_bool(d)
|
||||
elif dt == "Z":
|
||||
e.add_int8(d)
|
||||
elif dt == "Y":
|
||||
e.add_int16(d)
|
||||
elif dt == "I":
|
||||
|
@ -67,6 +67,7 @@ def unpack_array(read, array_type, array_stride, array_byteswap):
|
||||
|
||||
|
||||
read_data_dict = {
|
||||
b'Z'[0]: lambda read: unpack(b'<b', read(1))[0], # byte
|
||||
b'Y'[0]: lambda read: unpack(b'<h', read(2))[0], # 16 bit int
|
||||
b'C'[0]: lambda read: unpack(b'?', read(1))[0], # 1 bit bool (yes/no)
|
||||
b'I'[0]: lambda read: unpack(b'<i', read(4))[0], # 32 bit int
|
||||
|
Loading…
Reference in New Issue
Block a user