There is a type mismatch for the length parameter of aiString between

the strings used in materials and elsewhere in assimp. Because of this,
in PyAssimp3 strings in materials don't work properly on 64 bits
platforms. This commit adds a StringUInt32 ctypes structure and use it
in GetMaterialProperties as a workaround.
pull/4/head
Gellule Xg 2011-12-12 20:38:26 -10:00
parent 48e72d7851
commit cadeeae0f2
1 changed files with 15 additions and 2 deletions

View File

@ -120,6 +120,19 @@ class aiTuple:
def __repr__(self):
return str([x for x in self])
class StringUInt32(ctypes.Structure):
"""
A ctypes structure used for material strings.
This is a workaround for a type mismatch for the length field between strings used for materials and elsewhere.
"""
MAXLEN = 1024
_fields_ = [
("length", ctypes.c_uint32),
("data", ctypes.c_char*MAXLEN),
]
def _init(self):
"""
Custom initialize() for C structs, adds safely accessable member functionality.
@ -253,7 +266,7 @@ def GetMaterialProperties(material):
value = [x for x in arr]
elif p.mType == 3: #string can't be an array
try:
value = cast(p.mData, POINTER(structs.String)).contents.data
value = cast(p.mData, POINTER(StringUInt32)).contents.data
except UnicodeDecodeError:
print('UnicodeDecodeError reading material property, ignoring.')
continue