@@ -371,13 +371,16 @@ def math_eval(s, f3d):
371371 def _eval (node ):
372372 if isinstance (node , ast .Expression ):
373373 return _eval (node .body )
374- elif isinstance (node , ast .Str ):
375- return node .s
374+ elif isinstance (node , ast .Constant ):
375+ if isinstance (node .value , str ):
376+ return node .value
377+ elif isinstance (node .value , int ):
378+ return int (node .value )
379+ else :
380+ raise Exception ("Unsupported constant type {}" .format (type (node .value )))
376381 elif isinstance (node , ast .Name ):
377382 if hasattr (f3d , node .id ):
378383 return getattr (f3d , node .id )
379- elif isinstance (node , ast .Num ):
380- return node .n
381384 elif isinstance (node , ast .UnaryOp ):
382385 if isinstance (node .op , ast .USub ):
383386 return - 1 * _eval (node .operand )
@@ -1861,7 +1864,7 @@ def deleteMaterialContext(self):
18611864 raise PluginError ("Attempting to delete material context that is None." )
18621865
18631866 # if deleteMaterialContext is False, then manually call self.deleteMaterialContext() later.
1864- def createMesh (self , obj , removeDoubles , importNormals , callDeleteMaterialContext : bool ):
1867+ def createMesh (self , obj : bpy . types . Object , removeDoubles , importNormals , callDeleteMaterialContext : bool ):
18651868 mesh = obj .data
18661869 if len (self .verts ) % 3 != 0 :
18671870 print (len (self .verts ))
@@ -1899,13 +1902,26 @@ def createMesh(self, obj, removeDoubles, importNormals, callDeleteMaterialContex
18991902 # There will be one loop for every vertex
19001903 uv_layer [i ].uv = self .verts [i ].uv
19011904
1902- color_layer = mesh .vertex_colors .new (name = "Col" ).data
1903- for i in range (len (mesh .loops )):
1904- color_layer [i ].color = self .verts [i ].rgb .to_4d ()
1905-
1906- alpha_layer = mesh .vertex_colors .new (name = "Alpha" ).data
1907- for i in range (len (mesh .loops )):
1908- alpha_layer [i ].color = [self .verts [i ].alpha ] * 3 + [1 ]
1905+ # The mesh.vertex_colors API is deprecated since Blender 3.2,
1906+ # and its usage by fast64 here breaks in Blender 5.1 somehow.
1907+ # (can't replicate in simple cases)
1908+ if bpy .app .version < (3 , 2 , 0 ):
1909+ color_layer = mesh .vertex_colors .new (name = "Col" ).data
1910+ for i in range (len (mesh .loops )):
1911+ color_layer [i ].color = self .verts [i ].rgb .to_4d ()
1912+
1913+ alpha_layer = mesh .vertex_colors .new (name = "Alpha" ).data
1914+ for i in range (len (mesh .loops )):
1915+ alpha_layer [i ].color = [self .verts [i ].alpha ] * 3 + [1 ]
1916+ else :
1917+ col_attr = mesh .color_attributes .new ("Col" , "BYTE_COLOR" , "CORNER" )
1918+ for i in range (len (mesh .loops )):
1919+ col_attr .data [i ].color = (* self .verts [i ].rgb , 1 )
1920+
1921+ alpha_attr = mesh .color_attributes .new ("Alpha" , "BYTE_COLOR" , "CORNER" )
1922+ for i in range (len (mesh .loops )):
1923+ a = self .verts [i ].alpha
1924+ alpha_attr .data [i ].color = (a , a , a , 1 )
19091925
19101926 if bpy .context .mode != "OBJECT" :
19111927 bpy .ops .object .mode_set (mode = "OBJECT" )
0 commit comments