@@ -80,8 +80,9 @@ def apply_transformation(meshio_mesh, obj, depsgraph):
80
80
81
81
# evaluate the rigid body transformations (only relevant for .bin format)
82
82
rigid_body_transformation = mathutils .Matrix .Identity (4 )
83
- if meshio_mesh .field_data .get ("transformation_matrix" ) is not None :
84
- rigid_body_transformation = meshio_mesh .field_data ["transformation_matrix" ]
83
+ if meshio_mesh is not None :
84
+ if meshio_mesh .field_data .get ("transformation_matrix" ) is not None :
85
+ rigid_body_transformation = meshio_mesh .field_data ["transformation_matrix" ]
85
86
86
87
# multiply everything together (with custom transform matrix)
87
88
obj .matrix_world = rigid_body_transformation @ eval_transform_matrix
@@ -256,9 +257,6 @@ def update_obj(scene, depsgraph=None):
256
257
257
258
for obj in bpy .data .objects :
258
259
start_time = time .perf_counter ()
259
-
260
- isObj = obj .BSEQ .pattern .endswith (".obj" )
261
- print ("isObj: " , isObj )
262
260
263
261
if obj .BSEQ .init == False :
264
262
continue
@@ -284,6 +282,24 @@ def update_obj(scene, depsgraph=None):
284
282
pattern = bpy .path .native_pathsep (pattern )
285
283
fs = fileseq .FileSequence (pattern )
286
284
285
+ if pattern .endswith (".obj" ):
286
+ filepath = fs [current_frame % len (fs )]
287
+
288
+ # Reload the object
289
+ tmp_transform = obj .matrix_world
290
+ obj .select_set (True )
291
+ bpy .ops .object .delete ()
292
+ bpy .ops .import_scene .obj (filepath = filepath )
293
+ obj = bpy .context .selected_objects [- 1 ]
294
+ obj .name = fs .basename () + "@" + fs .extension ()
295
+ obj .data .name = fs .basename () + "@" + fs .extension ()
296
+ obj .matrix_world = tmp_transform
297
+ apply_transformation (meshio_mesh , obj , depsgraph )
298
+
299
+ end_time = time .perf_counter ()
300
+ obj .BSEQ .last_benchmark = (end_time - start_time ) * 1000
301
+ return
302
+
287
303
if obj .BSEQ .use_advance and obj .BSEQ .script_name :
288
304
script = bpy .data .texts [obj .BSEQ .script_name ]
289
305
try :
@@ -316,23 +332,14 @@ def update_obj(scene, depsgraph=None):
316
332
else :
317
333
filepath = fs [current_frame % len (fs )]
318
334
try :
319
- if filepath .endswith (".obj" ):
320
- # Reload the object
321
- obj .select_set (True )
322
- bpy .ops .object .delete ()
323
- # bpy.ops.import_scene.obj(filepath=filepath)
324
- # object = bpy.context.selected_objects[-1]
325
- # object.name = fileseq.basename() + "@" + fileseq.extension()
326
- # object.data.name = fileseq.basename() + "@" + fileseq.extension()
327
- else :
328
- meshio_mesh = meshio .read (filepath )
335
+ meshio_mesh = meshio .read (filepath )
329
336
except Exception as e :
330
337
show_message_box ("Error when reading: " + filepath + ",\n " + traceback .format_exc (),
331
338
"Meshio Loading Error" + str (e ),
332
339
icon = "ERROR" )
333
340
continue
334
341
335
- if not isinstance (meshio_mesh , meshio .Mesh ) or not isObj :
342
+ if not isinstance (meshio_mesh , meshio .Mesh ):
336
343
show_message_box ('function preprocess does not return meshio object' , "ERROR" )
337
344
continue
338
345
update_mesh (meshio_mesh , obj .data )
0 commit comments