fix: 运动相机时间交叠时所有段依次作用

之前只取了第一个活动段 active[0],时间交叠时后面的段被忽略。
改为遍历所有段,按文件顺序依次施加平移和旋转。
排在前面的段优先作用于相机位置(矩阵非对易性保证)。
This commit is contained in:
2026-06-12 08:06:15 +08:00
parent c454162d0b
commit b4fed4fbb8
2 changed files with 16 additions and 15 deletions
+9 -9
View File
@@ -598,23 +598,23 @@ if _CAM_MOTION:
def _update_motion_camera(f_idx): def _update_motion_camera(f_idx):
"""速度段驱动:每帧累加平移/旋转。""" """速度段驱动:每帧累加平移/旋转。
时间交叠时所有段同时生效,按文件中出现的顺序依次作用。
矩阵操作不具有对易性,排在前面的段优先作用于相机位置。
"""
if not _CAM_MOTION: if not _CAM_MOTION:
return return
global _cam_center, _cam_elev, _cam_azim, _cam_dist global _cam_center, _cam_elev, _cam_azim, _cam_dist
# 找当前帧属于哪个段 # 找当前帧所有活动的段(时间交叠=同时作用),按文件顺序依次应用
active = [seg for seg in _CAM_MOTION for seg in _CAM_MOTION:
if seg["start"] <= f_idx < seg["end"]] if seg["start"] <= f_idx < seg["end"]:
if not active:
return
seg = active[0]
_cam_center[0] += seg["v"][0] _cam_center[0] += seg["v"][0]
_cam_center[1] += seg["v"][1] _cam_center[1] += seg["v"][1]
_cam_center[2] += seg["v"][2] _cam_center[2] += seg["v"][2]
# rx → elevation, ry → azimuth, rz → 距离变化(绕z=roll/螺旋)
_cam_elev += seg["r"][0] _cam_elev += seg["r"][0]
_cam_azim += seg["r"][1] _cam_azim += seg["r"][1]
_cam_dist += seg["r"][2] * 0 # rz 可以忽略或做其他用途 # rz 预留
view.camera.center = tuple(_cam_center) view.camera.center = tuple(_cam_center)
view.camera.distance = _cam_dist view.camera.distance = _cam_dist
+2 -1
View File
@@ -5,4 +5,5 @@
# rx → elevation(俯仰), ry → azimuth(方位), rz → (预留) # rx → elevation(俯仰), ry → azimuth(方位), rz → (预留)
# #
# 示例:前60帧向右平移+绕x旋转,30-90帧向上平移+绕y绕z旋转 # 示例:前60帧向右平移+绕x旋转,30-90帧向上平移+绕y绕z旋转
1-200 vx=0.01 1-60 vx=0.02 rx=1
30-90 vy=0.02 ry=1 rz=1