Fix 3D tracks to mesh not aligning mesh properly
Also fixed wrong frame number used for reconstructed object visualization in 3D viewport.
This commit is contained in:
@@ -189,6 +189,15 @@ class CLIP_OT_bundles_to_mesh(Operator):
|
||||
|
||||
new_verts = []
|
||||
|
||||
scene = context.scene
|
||||
camera = scene.camera
|
||||
matrix = Matrix.Identity(4)
|
||||
if camera:
|
||||
reconstruction = tracking_object.reconstruction
|
||||
framenr = scene.frame_current - clip.frame_start + 1
|
||||
reconstructed_matrix = reconstruction.cameras.matrix_for_frame(framenr)
|
||||
matrix = camera.matrix_world * reconstructed_matrix.inverted()
|
||||
|
||||
mesh = bpy.data.meshes.new(name="Tracks")
|
||||
for track in tracking_object.tracks:
|
||||
if track.has_bundle:
|
||||
@@ -200,6 +209,8 @@ class CLIP_OT_bundles_to_mesh(Operator):
|
||||
|
||||
ob = bpy.data.objects.new(name="Tracks", object_data=mesh)
|
||||
|
||||
ob.matrix_world = matrix
|
||||
|
||||
context.scene.objects.link(ob)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
Reference in New Issue
Block a user