Fixes #4 interpolation offset with camera move
parent
1a6da5c4fa
commit
5590753550
|
@ -1,7 +1,7 @@
|
|||
bl_info = {
|
||||
"name": "gp interpolate",
|
||||
"author": "Christophe Seux, Samuel Bernou",
|
||||
"version": (0, 4, 1),
|
||||
"version": (0, 4, 2),
|
||||
"blender": (3, 6, 0),
|
||||
"location": "Sidebar > Gpencil Tab > Interpolate",
|
||||
"description": "Interpolate Grease pencil strokes over 3D",
|
||||
|
|
|
@ -22,7 +22,7 @@ from mathutils.geometry import (barycentric_transform,
|
|||
tessellate_polygon)
|
||||
|
||||
## /!\ Old code kept for testing
|
||||
## use pseudo plane coordinate instead of rayvast on real mesh plane
|
||||
## use pseudo plane coordinate instead of raycast on real mesh plane
|
||||
|
||||
|
||||
class GP_OT_interpolate_stroke_simple(bpy.types.Operator):
|
||||
|
|
|
@ -63,7 +63,9 @@ class GP_OT_interpolate_stroke(bpy.types.Operator):
|
|||
|
||||
gp = context.object
|
||||
|
||||
matrix = np.array(gp.matrix_world, dtype='float64')#.inverted()
|
||||
# matrix = gp.matrix_world
|
||||
# origin = scn.camera.matrix_world.to_translation()
|
||||
matrix = np.array(gp.matrix_world, dtype='float64')
|
||||
origin = np.array(scn.camera.matrix_world.to_translation(), 'float64')
|
||||
|
||||
col = settings.target_collection
|
||||
|
@ -239,6 +241,8 @@ class GP_OT_interpolate_stroke(bpy.types.Operator):
|
|||
for f in frames_to_jump:
|
||||
wm.progress_update(f) # Pgs
|
||||
scn.frame_set(f)
|
||||
# origin = scn.camera.matrix_world.to_translation()
|
||||
origin = np.array(scn.camera.matrix_world.to_translation(), 'float64')
|
||||
plan_co, plane_no = get_gp_draw_plane(gp)
|
||||
bpy.ops.gpencil.paste()
|
||||
|
||||
|
@ -271,7 +275,12 @@ class GP_OT_interpolate_stroke(bpy.types.Operator):
|
|||
|
||||
world_co_3d.append(new_loc)
|
||||
|
||||
# Reproject on plane
|
||||
## Test with point in 3D space (Debug)
|
||||
# nb_points = len(new_stroke.points)
|
||||
# new_stroke.points.foreach_set('co', np.array(world_co_3d).reshape(nb_points*3))
|
||||
# new_stroke.points.update()
|
||||
|
||||
## Reproject on plane
|
||||
new_world_co_3d = [intersect_line_plane(origin, p, plan_co, plane_no) for p in world_co_3d]
|
||||
new_local_co_3d = matrix_transform(new_world_co_3d, matrix_inv)
|
||||
|
||||
|
|
Loading…
Reference in New Issue