game-smooth-curves-and-motion

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Game Smooth Curves And Motion

游戏平滑曲线与运动

Use this skill to design path and curve systems where continuity, control, and game feel matter more than exact mathematical purity.
Primary source: Geometry for Programmers by Oleksandr Kaleniuk (https://www.manning.com/books/geometry-for-programmers), transformed and paraphrased, especially chapters 5-7. Additional source: A Primer on Bezier Curves by Pomax (https://pomax.github.io/bezierinfo/).
使用此技能设计路径和曲线系统,其中连续性、控制和游戏体验比精确的数学纯粹性更重要。

Core Workflow

核心工作流

  1. Identify what must be smooth: position, tangent direction, speed, curvature, camera orientation, banking, or animation value.
  2. Choose the curve family that gives the needed controls with the least state: linear segments, cubic Hermite, Catmull-Rom, Bezier, B-spline, NURBS, or a custom polynomial piece.
  3. Define continuity targets:
    • C0: pieces meet at positions.
    • C1: tangents match for visually smooth direction.
    • C2: curvature changes smoothly.
  4. Decide parameterization: uniform
    t
    , chord length, centripetal, explicit timing, or arc-length lookup.
  5. Separate authoring controls from runtime samples. Designers may edit points and handles; the game may use baked lookup tables.
  6. Test extreme control points, sharp turns, closed loops, repeated points, and speed variation.
  1. 确定需要平滑的对象:位置、切线方向、速度、曲率、相机朝向、倾斜角度或动画数值。
  2. 选择能以最少状态提供所需控制的曲线系列:线性段、三次Hermite曲线、Catmull-Rom样条、Bezier曲线、B-spline、NURBS或自定义多项式分段。
  3. 定义连续性目标:
    • C0:分段在位置处衔接。
    • C1:切线匹配,实现视觉上的平滑方向。
    • C2:曲率变化平滑。
  4. 确定参数化方式:均匀
    t
    、弦长、向心参数化、显式计时或弧长查找。
  5. 将创作控件与运行时采样分离。设计师可编辑点和控制柄;游戏可使用预烘焙的查找表。
  6. 测试极端控制点、急转弯、闭合回路、重复点和速度变化场景。

Curve Selection

曲线选择

  • Use linear segments for grid motion, debug paths, and intentionally sharp routes.
  • Use cubic Hermite when you know endpoint positions and tangent vectors.
  • Use Bezier curves when control handles are the natural authoring interface.
  • Use Catmull-Rom-style splines when paths should pass through waypoints with minimal handle authoring.
  • Use B-splines or NURBS when many control points, high continuity, or exact conic sections matter.
  • Avoid one high-degree global polynomial through many points. Split into pieces to avoid oscillation and poor local control.
  • 线性段适用于网格运动、调试路径和刻意设计的尖锐路线。
  • 当已知端点位置和切向量时,使用三次Hermite曲线。
  • 当控制柄是自然创作界面时,使用Bezier曲线。
  • 当路径需要经过航点且控制柄创作工作量最小时,使用Catmull-Rom风格的样条。
  • 当涉及大量控制点、高连续性或精确圆锥曲线时,使用B-spline或NURBS。
  • 避免使用通过多个点的高次全局多项式。将其拆分为分段,以避免振荡和局部控制不佳的问题。

Motion Rules

运动规则

  • Smooth position does not imply smooth speed. Check derivative length along the path.
  • Constant
    t
    increments rarely produce constant world-space speed.
  • For nearly constant speed, precompute an arc-length table and map distance traveled back to curve parameter.
  • Tangent length affects both speed and curve shape in Hermite-like systems.
  • Normalize tangent direction only when speed should be controlled separately.
  • Keep gameplay collision separate from visual smoothing when curves are only a presentation layer.
  • 平滑的位置并不意味着平滑的速度。检查路径上的导数长度。
  • 恒定的
    t
    增量很少能产生恒定的世界空间速度。
  • 若要实现近乎恒定的速度,预计算弧长表,并将行驶距离映射回曲线参数。
  • 在类Hermite系统中,切线长度会影响速度和曲线形状。
  • 仅当需要单独控制速度时,才对切线方向进行归一化。
  • 当曲线仅作为展示层时,将游戏玩法碰撞与视觉平滑处理分离。

Implementation Checklist

实现检查清单

  • Curve type and continuity target are documented.
  • Parameter range and units are explicit.
  • Closed paths handle first/last continuity deliberately.
  • Runtime evaluation is bounded and allocation-free in hot paths.
  • Baked samples include position, tangent, optional normal/binormal, and cumulative distance when needed.
  • Debug view shows control points, handles, samples, tangents, and speed heat.
  • 记录曲线类型和连续性目标。
  • 明确参数范围和单位。
  • 闭合路径需刻意处理首尾连续性。
  • 运行时评估在热点路径中需有界且无内存分配。
  • 预烘焙采样需包含位置、切线、可选的法向量/副法向量,必要时还需包含累积距离。
  • 调试视图需显示控制点、控制柄、采样点、切线和速度热力图。

Common Mistakes

常见误区

  • Using interpolation that passes through every point when approximation would be smoother and more stable.
  • Assuming Bezier handles are points on the curve.
  • Letting repeated or near-repeated points create undefined tangents.
  • Moving a camera at constant parameter speed and calling the result constant motion.
  • Adding more control points to fix a curve that needs a different parameterization or continuity target.
  • 当近似处理会更平滑、更稳定时,却使用了经过每个点的插值方式。
  • 假设Bezier控制柄是曲线上的点。
  • 重复或近乎重复的点导致切线未定义。
  • 以恒定参数速度移动相机,并认为这是恒定运动。
  • 通过添加更多控制点来修复需要调整参数化方式或连续性目标的曲线。