fix batch reproject frame issue

master
pullusb 2024-11-27 18:01:18 +01:00
parent abb61ca6d4
commit 86fb848e4a
1 changed files with 14 additions and 14 deletions

View File

@ -69,19 +69,22 @@ def batch_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=False
# matrix = np.array(obj.matrix_world, dtype='float64')
# matrix_inv = np.array(obj.matrix_world.inverted(), dtype='float64')
#mat = src.matrix_world
for l in obj.data.layers:
for layer in obj.data.layers:
if not all_strokes:
if not l.select:
if not layer.select:
continue
if l.hide or l.lock:
if layer.hide or layer.lock:
continue
f = next((f for f in l.frames if f.frame_number == i), None)
if f is None:
# FIXME: some strokes are ingored
# print(f'skip {l.name}, no frame at {i}')
frame = next((f for f in layer.frames if f.frame_number == i), None)
if frame is None:
print(layer.name, 'Not found')
# FIXME: some strokes are ignored
# print(frame'skip {layer.name}, no frame at {i}')
continue
for s in f.drawing.strokes:
# print(l.name, s.material_index)
for s in frame.drawing.strokes:
# print(layer.name, s.material_index)
## Batch matrix apply (Here is slower than list comprehension).
# nb_points = len(s.points)
@ -96,8 +99,8 @@ def batch_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=False
# Basic method (Slower than foreach_set and compatible with GPv3)
## TODO: use low level api with curve offsets...
for i, p in enumerate(s.points):
p.position = matrix_inv @ new_world_co_3d[i]
for pt_index, point in enumerate(s.points):
point.position = matrix_inv @ new_world_co_3d[pt_index]
## GPv2: ravel and use foreach_set
## Ravel new coordinate on the fly
@ -416,9 +419,6 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator):
box = layout.box()
axis = context.scene.tool_settings.gpencil_sculpt.lock_axis
box.label(text=orient[axis][0], icon=orient[axis][1])
def execute(self, context):
t0 = time()