Mass Battle Frameworkv1.20.0

运动模型Movement Model

分层图解Layered Diagrams 主动避障 + 物理碰撞Active Avoidance + Physics

依据运动相关源码(Move.h / Avoidance.h / Traffic.h) · 插图为示意图Based on the movement sources (Move.h / Avoidance.h / Traffic.h) · diagrams are schematic

概述 Overview

Mass Battle 的每个单位每 tick 走一条四层管线:① 期望速度——寻路给出方向,乘上单位移速得到"我想怎么走"(意图);② 交通偏置——一套交通规则在远场把意图改写成"按让行文化该怎么走"(车道、侧让、绕行、贴墙);③ 避障解算——ORCA 速度空间求解器在近场算出"不撞人的可行速度"(主动避障);④ 碰撞修正——PBD 作为最后防线,把已经穿透的身体分开(被动碰撞)。前三层只生产速度,第四层只修正位置——职责单一、逐层兜底。

Every Mass Battle unit walks a four-layer pipeline each tick: ① Desired velocity — pathfinding supplies the direction, multiplied by the unit's move speed ("where I want to go" — intent); ② Traffic bias — a rule set rewrites that intent at long range into "how the traffic culture says to go" (lanes, side-stepping, flanking, wall-sliding); ③ Avoidance solve — the ORCA velocity-space solver computes a collision-free feasible speed at short range (active avoidance); ④ Collision correction — PBD is the last line of defense, separating already-overlapping bodies (passive collision). The first three layers only produce velocity; the fourth only corrects position — single responsibilities, layered fallbacks.

交通规则在远处起作用(决定"谁让、怎么让"),避障求解在近处起作用(保证不撞人),碰撞修正是底线(万一穿透必被分开)。"谁让"的判定只做一次,两层共用——所以你不会看到两个单位因为"该你让/该我让"判定不一致而顶牛。

Traffic rules act at range (deciding "who yields and how"), the avoidance solve acts up close (guaranteeing no collisions), and collision correction is the floor (any overlap gets separated). "Who yields" is decided once and shared by both layers — you never see two units deadlock over disagreeing responsibility.

① + ② 外环 · 交通规则① + ② Outer Ring · Traffic Rules 远处:决定"怎么走"At Range: Sets "How to Go" ③ 内环 · ORCA 避障③ Inner Ring · ORCA Avoidance 近处:保证不撞人Up Close: Never Collides ④ 底线④ Floor PBD 分开穿透PBD Separates Overlap 单位由远及近:先被交通规则塑形 → 近场避障 → 万一穿透由碰撞层分开Units go far to near: traffic shapes, avoidance protects, collision separates "谁让"只判一次 —— 交通层与避障层共用同一份责任判定"Who yields" is decided once — the traffic and avoidance layers share one verdict 意图速度 = 方向 × 移速链Intent = direction × speed chain "我想怎么走""Where I want to go" 交通规则改写意图Traffic Rules Reshape Intent 车道 / 侧让 / 绕行 / 贴墙 (默认关)Lanes / SideStep / Flank / WallSlide (off) 解出"不撞人"的速度Solves a collision-free velocity 只管近场,远处不提前减速Near field only — no early braking 穿透必被分开Overlap Always Separated 墙/地绝对优先 · 前三层只产速度Walls/floor first · layers 1–3 = speed only
图 0 · 分层职责:交通规则在远处决定"怎么走",ORCA 在近处保证不撞人,PBD 是穿透后的底线;"谁让"的判定两层共用。Fig 0 · Layered responsibilities: traffic rules decide "how to go" at range, ORCA guarantees no collisions up close, and PBD is the post-penetration floor; the "who yields" verdict is shared by both layers.

分层管线总图 The Layered Pipeline

移动在每帧模拟的最后阶段执行,因此击退、发射等施加会在同一逻辑帧内生效。四个层次从上到下依次是:先算出"我想怎么走"(期望速度),再按让行惯例改写它(交通偏置),然后解出"不撞人的最近速度"(避障),最后修正穿透(碰撞):

Movement runs in the final stage of each simulation frame, so knockback and launches land within the same logic tick. The four layers run top to bottom: first "where I want to go" (desired velocity), then the yielding conventions rewrite it (traffic bias), then the solver picks the nearest collision-free speed (avoidance), and finally any penetration is corrected (collision):

① 期望速度 Desired Velocity① Desired Velocity 方向: 流场 / A* 路径 / 直线 (临目标自然刹停)Direction: flow field / A* path / straight line (natural brake near goal) 速度: 移速 × 行为 × 减速 × 变异 × 转角 × 距离 × 坡度Speed: MoveSpeed × behavior × decel × mutation × turn × distance × slope "我想怎么走""Where I want to go" ② 交通偏置 Traffic Bias (默认关)② Traffic Bias (default off) 按"谁让、怎么让"的惯例改写前进方向: 车道 · 侧让 · 绕行 · 贴墙 · 路权Rewrites heading by yielding conventions: lanes · side-step · flank · wall-slide · priority 只改意图方向; 贴墙时让位给避障层Rewrites intent direction only; wall-slide yields to avoidance bUseTrafficRules 总闸 → 打开即获完整交通层bUseTrafficRules master → on = full traffic layer ③ 避障解算 Active Avoidance (ORCA)③ Active Avoidance (ORCA) 每个会碰撞的邻居产生一条"让多少"约束 → 解出不撞人的最近速度Each colliding neighbor adds a "how much" constraint → nearest collision-free speed 只管近场、远处不提前减速; 被围死可找回速度 · 压力场偏置(可选)Near field only, no early braking; boxed-in units recover speed · pressure bias (optional) 备选求解器: ForceField 斥力场 (Avoidance.AvoidMethod)Alternative solver: ForceField repulsion (Avoidance.AvoidMethod) 以 加/减速度 平滑趋近最终速度 (载具/飞机另有执行模型)Eases to final velocity at accel/decel (vehicles/aircraft differ) 位置按速度逐帧推进Position advances by velocity each frame ④ 碰撞修正 Passive Collision (PBD)④ Passive Collision (PBD) 两阶段优先级: 场景硬约束(墙/地/顶, 绝不可穿) > 单位互推Two-phase priority: scene hard constraints (wall/floor/ceiling, never crossed) > agent push 站定不被推走 · 修正以自身节奏回馈速度 · Substeps>1 更稳Planted units are not shoved · fix feeds back at own pace · Substeps>1 steadier 意图Intent 让后意图Yielded intent 避让速度Avoid velocity 位置修正Position fix
图 1 · 四层流程总图:期望速度先被交通规则改写,再交给避障求解;速度按加/减速度平滑趋近并推进位置;碰撞层修正穿透。Fig 1 · The layered flow: the desired velocity is reshaped by traffic rules, then handed to the avoidance solve; speed eases toward the result and position advances; the collision layer corrects any penetration.

① 期望速度层 Layer 1 — Desired Velocity

意图 = 方向 × 速度。方向来自寻路,按导航模式三选一:流场跟随(人群共享方向)、A* 路径(单体路径,目标移动时只打补丁、不全量重算)、直线。攻击瞄准、坠落、发射、濒死时寻路整体暂停。速度由六个配置项连乘决定,再经 XYSpeedLimit 钳制——每一项都在兵种 DataAsset 里可调:

Intent = direction × speed. Direction comes from pathfinding, one of three modes: flow-field following (crowd-shared), A* polyline (per-unit paths; a moving goal gets a patch, not a full recalc), or straight line. Aiming, falling, launching and dying pause pathfinding entirely. Speed is the product of six configurable factors, clamped by XYSpeedLimit — every one lives in the unit DataAsset:

行为倍率Behavior multiplier

按 ActiveBehavior 取 Patrol / Chase / Return 的 MoveSpeedMult,Idle 默认 1.0。

Takes Patrol / Chase / Return MoveSpeedMult by ActiveBehavior; Idle defaults to 1.0.

减速 debuffSlow debuffs

多个 SlowDebuff 取最大强度;CombinedSlowMult = lerp(1−强度, 1, 慢免疫)。

Takes the max strength among SlowDebuffs; CombinedSlowMult = lerp(1−strength, 1, slow immunity).

出生变异Spawn variation

出生时从随机流掷出的 FMoving.MoveSpeedMult——同种单位速度有个体差异。

FMoving.MoveSpeedMult rolled from the spawn-time random stream — per-individual speed variety.

转角映射(生物模型)Turn-angle map (Creature)

朝向与速度夹角经 MoveSpeedRangeMapByAngle 映射——急转弯自动掉速。

The heading–velocity angle maps through MoveSpeedRangeMapByAngle — sharp turns automatically shed speed.

距离坡化Distance ramp

距目标距离经 MoveSpeedRangeMapByDist 二次插值——临抵达自然减速到零。

Distance-to-goal maps through a quadratic MoveSpeedRangeMapByDist — natural deceleration into arrival.

坡度恒速Slope constant-speed

bMaintainConstantSpeedOnSlope 时按地面法线在前进方向的分量除回去——上下坡视觉等速。

With bMaintainConstantSpeedOnSlope the ground-normal component along travel is divided out — visually constant speed on slopes.

接近目标时,单位按自身刹车距离自然减停,不会在终点附近来回抖动。玩家驱动的单位不走这条链——它们的期望速度直接来自玩家输入。

Approaching the goal, units decelerate naturally to a stop based on their own braking distance — no jitter around the destination. Player-driven units bypass the chain — their desired velocity comes straight from player input.

方向 DirectionDirection agent 起点Agent start 折线切向 = DesiredMoveDirectionPolyline tangent = DesiredMoveDirection 接受半径Accept radius Goal 前瞻圆Lookahead circle A* 折线取方向 · 目标可动态更新 · 进入接受半径即到达A* polyline sets direction · goals can move · inside accept radius = arrived 速度 Speed = 移速 × 倍率链Speed = MoveSpeed × multiplier chain 行为 ×0.8~1.2Behavior ×0.8~1.2 减速 ×0.55Decel ×0.55 出生变异 ×0.95Spawn variation ×0.95 转角 ×0.7Turn ×0.7 距离坡化 ×0.4Distance ramp ×0.4 XYSpeedLimit 钳制XYSpeedLimit clamp 累计倍率(示例)Running product (example) .90 .50 .47 .33 .13 .13 倍率逐级相乘 → DesiredSpeed · 临目标按刹车距离自然减停Multipliers compose → DesiredSpeed · natural braking into the goal
图 2 · 期望速度的构成:左——从 A* 折线按前瞻圆取方向;右——六段倍率链连乘出 DesiredSpeed(数值为示意),最后经速度上下限钳制。Fig 2 · Building the desired velocity: left — direction taken from the A* polyline against the lookahead circle; right — the six-factor multiplier chain yields DesiredSpeed (illustrative numbers), finally clamped by the speed limits.

② 交通偏置层 Layer 2 — Traffic Bias

交通层在避障求解之前,把期望速度改写成符合让行惯例的方向——车道化、给通行者让位、绕开挡路者、贴墙滑行。全局总闸 FAvoidance::bUseTrafficRules 默认关闭;打开后由模板上的 FTrafficShared 逐规则配置(Arbitration / Flank / LaneShift / SideStep / WallSlide 与 Combat 路权默认开,LivingVsDying 与 Pressure 默认关)。

The traffic layer rewrites the desired velocity toward yielding conventions before the avoidance solve — lane formation, yielding the corridor, flanking blockers, wall sliding. The master gate FAvoidance::bUseTrafficRules defaults OFF; once on, each rule is configured per template via FTrafficShared (Arbitration / Flank / LaneShift / SideStep / WallSlide and Combat right-of-way default ON; LivingVsDying and Pressure default OFF).

LaneShift 车道偏移 LaneShift

对向人流会自发分成两条车道:移动中的单位把前进方向从来车方向旋开、向行进侧约定(默认靠右)偏转;交叉的两股人流各让己侧,自然涌现真实人群里的对角条纹。每个对头邻居贡献的旋转角、总量上限、判侧死区带宽与交叉带扩展都是可调参数,判侧死区防止单位逐帧换边抖动。

Oncoming streams self-organize into two lanes: moving units rotate their heading away from oncoming traffic toward the traffic-side convention (drive-on-the-right by default); crossing streams each yield to their own side, self-organizing into the diagonal stripes seen in real crowds. Per-neighbor rotation, the total cap, the side-pick dead-zone band and the crossing-band extension are all tunable; the dead zone prevents frame-by-frame side flipping.

对头分道 Head-On → lanesHead-On → Lanes 靠右车道 lane ← (并入中)Right-hand lane ← (merging in) → lane 靠右车道 (并入中)→ Right-hand lane (merging in) TrafficSide 约定靠哪边 · CommitBand 滞回锁定选择TrafficSide convention · CommitBand hysteresis locks the side 交叉条纹 CrossShift stripesCrossShift stripes 每股都让向己方行进侧 → 对角条纹自组织Each stream yields to its own travel side → diagonal stripes
图 3 · LaneShift:左——对头两流按靠右约定各让出一条车道(旋转角随邻居数累积);右——交叉带(45°–135°)里两股垂直流各让己侧,涌现行人式的对角条纹。Fig 3 · LaneShift: left — two head-on streams part into lanes per the keep-right convention (rotation accumulates per neighbor); right — in the crossing band (45°–135°) perpendicular streams each yield to their own side, self-organizing into pedestrian-style diagonal stripes.

SideStep 侧让 SideStep

静止单位面对来袭者会主动侧身让出通道,而不是被推着走:让多少由对方体型与实际净空缺口决定——步兵路过人群几乎不动它,坦克路过会让出整条通道。让出时间、净空余量与强度可调;追击锁定中的单位会站定不让(优先输出)。

Idle units step aside for oncoming traffic instead of being shoved along: how far they step follows the passer's size and the actual clearance deficit — infantry passing a crowd barely nudge it, a tank gets a whole lane. Step time, clearance margin and strength are tunable; units locked on a chase stand their ground (output first).

扫掠走廊 = 坦克半宽 + 步兵厚度 + ClearanceMarginCorridor = tank half-width + infantry + margin 坦克Tank 侧让速度 = 缺口 / ClearanceTimeSideStep speed = deficit / ClearanceTime 步兵(小)只微让 · 坦克(大)让出整条通道Infantry (small) yields a little · tank (big) yields the whole lane
图 4 · SideStep:静止单位按"对方扫掠走廊 + 余量"计算侧让距离——幅度由体型与净空缺口决定,而非固定值。Fig 4 · SideStep: idle units compute the step from the passer's swept corridor plus margin — magnitude follows body size and the actual clearance deficit, not a fixed constant.

Flank 绕行 Flank

被挡住去路的单位会绕行:把前进方向旋出阻挡者的影响锥,以接近全速绕过挡路者(绕行期间有配套提速);能倒车的载具甚至可以倒着完成绕行。相邻阻挡者之间的缝隙,只有宽于"自身直径 + 余量"才会钻,否则整簇绕开——不硬挤。紧贴障碍物时本规则自动让位给避障层。

Blocked units flank: they rotate their heading out of the blockers' influence cone and pass at near full speed (with a paired speed boost while flanking); vehicles that can reverse may flank in reverse. A gap between adjacent blockers is threaded only if it is wider than "own diameter + margin" — otherwise the whole cluster is skirted, never squeezed through. Right against obstacles the rule yields to the avoidance layer.

旋转出速度障碍锥 Rotate DV out of the coneRotate DV out of the cone 不可移动体Immovable body 速度障碍锥 (ORCA 约束区)Velocity-obstacle cone (ORCA constraint region) 原 DV (入锥)Original DV (inside cone) 旋转后 DV (出锥, 满速 ×SpeedMult)Rotated DV (outside, full speed ×SpeedMult) MaxDeflect 封顶MaxDeflect cap 缝宽门 Gap-width gateGap-width gate 窄缝Narrow gap < 2R + MinGapWidth → 绕整簇 ↷< 2R + MinGapWidth → go around cluster ↷ 宽缝Wide gap ≥ 门宽≥ gate width → 钻缝 ↟→ thread the gap ↟ GapCommitBand 平滑钻缝/绕行切换 (防逐帧翻转)GapCommitBand smooths thread/around switch (no flapping)
图 5 · Flank:把 DV 旋出阻挡者的速度障碍锥(ORCA 约束失活→满速通行);缝隙按净宽门决定"钻"还是"绕"。Fig 5 · Flank: rotate DV out of blockers' velocity-obstacle cones (ORCA constraints go inactive → full-speed passage); the gap-width gate decides "thread" vs "go around".

WallSlide 贴墙滑行 WallSlide

带着朝墙分量的移动会被剥掉向内分量,转为沿墙切线滑行;强度从接触带(纯滑行)到避障外缘(不受影响)渐变。不做额外减速——剥掉向内分量本身就是自然的减速,自然的贴墙滑走观感由此而来。

Movement with a component into a wall gets that inward component stripped, turning into a slide along the wall tangent; strength ramps from the contact band (pure slide) to the avoidance rim (untouched). No extra braking — stripping the inward component IS the deceleration, producing the natural wall-slide look.

墙 (障碍平面)Wall (obstacle plane) 椭圆外缘 Outer: 强度 0Outer ellipse edge: strength 0 接触带: 强度 1Contact band: strength 1 入墙分量 (被剥除)Into-wall component (stripped) 切线投影 → 滑行Tangential projection → slide 强度 s =Strength s = 1 @ Dist ≤ R 0 @ Dist ≥ Outer C0 连续插值C0 continuous 不重归一化No re-normalization (去分量=减速)(strip = slow down)
图 6 · WallSlide:入墙分量被剥除、DV 转为沿墙切线;强度从接触带的 1 渐变到椭圆外缘的 0。Fig 6 · WallSlide: the into-wall component is stripped and DV turns along the tangent; strength ramps from 1 at the contact band to 0 at the ellipse rim.

Arbitration 责任仲裁 Arbitration — who yields

谁让、让多少,由一组明确的惯例决定:不可让的一方(站定的攻击者、不可推动物)→ 对方全让;路权档位不同 → 低档位多让(档位从高到低:攻击者 > 远程归位 > 移动中 > 归位中 > 空闲);同档对头 → 各让一半;追尾 → 后车让;轻者让重者(按质量比分配)。攻击者在瞄准/前摇/后摇阶段钉在原地,其他单位绕行。让步比例(YieldBias)、行进侧约定与质量加权都有全局配置。

Who yields and how much follows explicit conventions: a side that cannot yield (a planted attacker, an immovable) forces the other side to fully yield; right-of-way rank asymmetry → the lower rank yields more (ranks high to low: attacker > far-returner > moving > returning > idle); equal head-on → 50/50; rear-ending → the rear yields; the lighter yields to the heavier (by mass ratio). Attackers plant their feet through aim / wind-up / recovery while everyone routes around them. The yield share (YieldBias), traffic-side convention and mass weighting are global knobs.

yield 责任分配 (YieldBias=0.8 示例)yield responsibility split (YieldBias=0.8 example) 0.5 对称位0.5 symmetric split 让步方 yield = 0.8 (机动 ×1.6)Yielder: yield = 0.8 (maneuver ×1.6) 0.2 对称对 yield=0.5 → 双方各半, 同向约定执行Symmetric pair: yield=0.5 → half each, same-side convention ≈不动≈ stationary 路权阶梯 Right-of-way ladderRight-of-way ladder 攻击者*Attacker* 远归位 3Far returner 3 移动 2Moving 2 回归 1Returning 1 空闲 0Idle 0 低档位者承担 YieldBias (让得多) · * 攻击者以 bCanAvoid=false 直接钉地Lower rank takes YieldBias (yields more) · * attackers pin via bCanAvoid=false 质量加权Mass weighting m = 2·M_other ──────── M_self+M_other 轻者 m→2 多让Light: m→2, yields more 重者 m→0 少让Heavy: m→0, yields less 轻Light 重Heavy
图 7 · Arbitration:yield 同时决定"谁让"与"让多少"——不对称对按 0.8/0.2 分担(让步方机动幅度 ×2×yield);路权阶梯与质量比是两条主要修正轴。Fig 7 · Arbitration: yield decides both "who yields" and "by how much" — an asymmetric pair splits 0.8/0.2 (the yielding side maneuvers at ×2×yield magnitude); the right-of-way ladder and the mass ratio are the two main correction axes.

另有两条按需开启的规则:LivingVsDying(默认关)——濒死的身体可以被穿行,倒地不再堵路(与死亡单位的碰撞另有开关);Pressure(默认关)——解算后向人群稀疏的方向再偏一步,缓解极端密集(灵敏度与上限可调)。

Two more rules open on demand: LivingVsDying (default OFF) — dying bodies can be walked through as they fall, so corpses stop clogging lanes (collision with the dying has its own toggle); Pressure (default OFF) — after the solve, velocity nudges one step toward sparser areas to relieve extreme crowding (sensitivity and cap configurable).

③ 避障解算层 Layer 3 — The Avoidance Solve (ORCA)

避障层在近场自动解出"不撞人的最近速度":每个会碰撞的邻居产生一条约束,"让多少"按上面的责任判定分配,最终取距期望速度最近的可行速度。它只管近距离防穿插,不会在远处提前减速(反应距离有封顶倍率可调);被围死时能找回掉速,轻单位顶不动重单位时会放弃推挤、改走人流。求解器可在 ORCA 与斥力场之间切换(AvoidMethod),后者参数更少、观感更松。

The avoidance layer automatically solves for the nearest collision-free speed up close: every colliding neighbor contributes a constraint, "how much to give" follows the responsibility verdicts above, and the solver picks the feasible speed closest to the desired one. It only prevents penetration at short range and never decelerates early at distance (the reaction range has a tunable cap multiplier); boxed-in units recover lost speed, and a light unit that cannot push a heavy one gives up and flows through instead. The solver switches between ORCA and a repulsion field (AvoidMethod) — fewer knobs, a looser feel.

速度空间 Velocity space (v_x, v_y)Velocity space (v_x, v_y) v_x v_y MaxSpeed 速度障碍区 (邻居产生)Velocity obstacle region (from a neighbor) 让行约束线 (按责任分配)ORCA line (split by yield) 可行域 (约束交 ∩ 速度圆)LP feasible region (half-planes ∩ velocity disc) 期望速度 (当前不可行)Desired velocity (infeasible) 取最近可行点Nearest feasible point 避让速度 = 最近可行点v_avoid = nearest feasible point 责任大的一侧:Higher-yield side: 约束更紧, 让得更多tighter constraint, yields more
图 8 · 避障解算:每个会碰撞的邻居划出一条约束线,责任大的一侧让得多;最终取可行域内距期望速度最近的点作为避让速度。Fig 8 · The avoidance solve: each colliding neighbor contributes a constraint line positioned by the responsibility split; the solver picks the feasible point closest to the desired velocity as the avoidance velocity.

CrushRecover 挤压回升CrushRecover

被四面围死时,朝阻挡最小的方向找回掉速——密集包围不会永久锁死单位。

Boxed in on all sides, a unit recovers lost speed toward the least-blocked direction — dense encirclement never permanently locks it.

突破回落 BreakthroughBreakthrough fallback

轻单位顶不动重单位时,放弃推挤、直接"穿流"而过——穿透由碰撞层收拾。

When a light unit cannot push a heavy one, it stops shoving and flows through — the collision layer cleans up the penetration.

ForceField 备选求解器ForceField solver

AvoidMethod 可切换为斥力场模型:邻居按距离产生斥力叠加(Strength / SepSpeedCapFraction / VelocityDamping),同样消费交通层偏置与 yield。

AvoidMethod can switch to a repulsion-field model: neighbors add distance-scaled repulsive forces (Strength / SepSpeedCapFraction / VelocityDamping), consuming the same traffic biases and yields.

④ 碰撞修正层 Layer 4 — Collision Correction (PBD)

碰撞层是最后防线:速度解算与位置推进之后,任何已经发生的穿透都会被当场分开。优先级清晰:墙、地面、天花板的穿透当帧弹回,单位绝不穿墙;单位之间的推挤按质量反比分配(重者少动、不可推动者不动);站定的单位(瞄准中的攻击者、静置单位)不会被推离原地。修正会以符合自身加/减速度节奏的方式回馈到速度,不会瞬移。

The collision layer is the last line of defense: after velocities resolve and positions advance, any penetration that already happened is separated on the spot. Priorities are clear: wall / ground / ceiling penetrations pop back the same frame — units never tunnel through walls; inter-unit pushes split by inverse mass (the heavy barely moves, the immovable not at all); planted units (aiming attackers, idle ones) are not shoved off their spot. Corrections feed back into velocity at the unit's own acceleration / deceleration pace — no teleporting.

Substeps 配置(默认 1)大于 1 时,碰撞改由独立的多子步解算器执行:解算更稳,极端堆叠(万人挤作一团)场景下的表现更好;MassBattle.Physics.DebugResidual 1 可以把收敛过程可视化出来。

With Substeps above 1 (default 1), collision moves to a standalone multi-substep solver: steadier solves and better behavior under extreme stacking (ten-thousand-agent pileups); MassBattle.Physics.DebugResidual 1 visualizes the convergence.

质量反比分离 Inverse-mass splitInverse-mass split 轻 M=1Light M=1 退 80%moves 80% 重 M=4Heavy M=4 退 20%moves 20% 穿透深度 d 按质量反比分配:Penetration depth d split by inverse mass: Δ_轻 = d·M_重/(M_轻+M_重) = 0.8dΔ_light = d·M_heavy/(M_light+M_heavy) = 0.8d bCanAvoid=false → 质量无穷: 只推别人bCanAvoid=false → infinite mass: pushes others only 两阶段优先 Two-phase priorityTwo-phase priority 墙 (硬约束)Wall (hard constraint) 人群推挤 (软)Crowd push (soft) 被压入墙squeezed into the wall PHASE 1 场景弹回PHASE 1 push-out (绝对优先, 当帧)(absolute, same frame) 软约束可为硬约束让位: 单位互叠 ≠ 穿墙Soft yields to hard: agents overlapping ≠ wall penetration
图 9 · PBD 位置修正:左——穿透量按质量反比分配(重者少动、不可推动者不动);右——两阶段优先级:场景硬约束当帧弹回,单位软约束为它让位。Fig 9 · PBD position correction: left — penetration splits by inverse mass (the heavy barely moves, the immovable not at all); right — two-phase priority: scene hard constraints pop back the same frame and agent soft constraints yield to them.
多子步收敛 Multi-substep convergenceMulti-substep convergence 子步 substep 1 → NSubstep 1 → N 总重叠Total overlap 初始穿透initial penetration 收敛中…converging… 总重叠逐步衰减total overlap decays Substeps = 1: 内联单遍 (默认)Substeps=1: inline (default) Substeps > 1: 独立引擎接管Substeps>1: standalone engine DebugResidual 1 观测本曲线DebugResidual 1 plots this curve
图 10 · 多子步收敛:子步越多,穿透修正越平滑,总重叠逐步衰减(曲线为示意)。Fig 10 · Multi-substep convergence: more substeps, smoother correction — total overlap decays step by step (curve illustrative).

四层协作总表 How the Four Layers Cooperate

层Layer职责一句话One-line duty输入 → 输出Input → output作用距离Range改什么Touches
① 期望速度Desired velocity我想怎么走(寻路方向 × 移速链)Where I want to go (path dir × speed chain)目标/路径/行为 → 意图速度Goal/path/behavior → intent velocity全图Global速度Velocity
② 交通偏置Traffic bias按让行文化改写意图(车道/侧让/绕行/贴墙)Rewrite intent per traffic culture (lanes/step/flank/slide)意图速度 → 让行后速度intent → post-yield velocity视野范围内Within vision range速度(意图)Velocity (intent)
③ 避障解算Avoidance solve不撞人的最近可行速度(ORCA)Nearest collision-free feasible speed (ORCA)让行后速度 + 邻居 → 避让速度post-yield velocity + neighbors → avoidance velocity近场Close range速度Velocity
④ 碰撞修正Collision correction穿透必被分开(场景硬约束绝对优先)Penetration always separated (scene hard constraints first)位置(穿透) → 位置修正 + 速度回馈Position (overlap) → positional fix + velocity feedback接触Contact位置(+速度回馈)Position (+ velocity feedback)

配置速查 Configuration Quick Reference

配置Config默认Default含义Meaning
FAvoidance::bUseTrafficRulesfalse交通层总闸;打开后 FTrafficShared 各规则按自身开关生效Traffic master gate; once on, per-rule toggles inside FTrafficShared apply
FAvoidance::DetectRange_Agent—单位检测距离扩展量 = 身体半径 + Clamp(TimeHorizon×速度, Min, Max);同时钳制交通视野Agent detection extension = body radius + Clamp(TimeHorizon×speed, Min, Max); also floors the traffic view
FAvoidance::BrakingRangeMult—求解器反应半径封顶倍率——阻止 ORCA 远距提前减速Solver reaction-radius cap multiplier — stops ORCA from slowing early at range
Arbitration.YieldBias / TrafficSide / CommitBand / MassWeighting0.8 / Right / 0 / 1让步比例 · 行进侧约定 · 判侧滞回带 · 全局质量加权Yield share · traffic-side convention · side-pick hysteresis band · global mass weighting
LaneShift.PerNeighborDeg / MaxDeg / CrossShift— / — / on每对头邻居旋转角 · 总封顶 · 交叉带扩展Per-head-on-neighbor rotation · total cap · crossing-band extension
SideStep.Strength / ClearanceMargin / ClearanceTime1.0 / — / —侧让强度 · 净空余量 · 让出时间折算Step strength · clearance margin · step-time conversion
Flank.PerBlockerAngle / MaxDeflect / MinGapWidth / SpeedMult / BlockerSpeedRatio—每阻挡角 · 总旋封顶 · 缝宽门 · 绕行提速 · 低速同向阻挡阈值Per-blocker angle · rotation cap · gap gate · flank speed multiplier · slow-blocker threshold
Combat.RightOfWay / SkipAvoidanceon / on攻击者路权(钉地)· 瞄准阶段跳过整套避障Attacker right of way (planted) · aim phases skip the whole solver
FPhysics::PositionRelaxation_Agent / VelocityRelaxation_Agent / StaticFriction_*1.0 / — / —位置修正刚度 · 速度回馈系数 · 横/纵向静摩擦预算Position-correction stiffness · velocity-feedback coefficient · lateral/longitudinal static-friction budgets
MassBattle.Physics.Substeps11 = MoveProcessor 内联单遍;>1 启用独立多子步 PBD 引擎1 = inline single pass inside MoveProcessor; >1 arms the standalone multi-substep PBD engine
Move.XY.MoveSpeed / MoveAcceleration / MoveDeceleration / MinInitSpeed—基础移速与趋近节奏;MinInitSpeed 以下求解输出直接归零(防抖动)Base speed and approach pacing; solver output below MinInitSpeed zeroes out (anti-jitter)

深入配置:Move.h · Avoidance.h · Traffic.h(规则参数)与 MassBattleAgentConfigDataAsset(兵种资产)。

Go deeper on configuration: Move.h · Avoidance.h · Traffic.h (rule parameters) and MassBattleAgentConfigDataAsset (the unit asset).

Mass Battle 运动模型 · 依据 2026-10 源码树(MassBattleAgentMoveProcessor / Traffic / PhysicsProcessor) · 插图为示意图,几何关系以源码为准。 Mass Battle Movement Model · verified against the 2026-10 source tree (MassBattleAgentMoveProcessor / Traffic / PhysicsProcessor) · diagrams are schematic; the source code is authoritative on geometry.