Animation.h
Source/MassBattle/Public/Fragments/Animation.h
概述Overview
动画系统的 fragment 集合:共享配置 FAnimShared(Idle↔Move 融合、移动曲线、Jump State Machine 与动画槽表)、运行时状态 FAnimating(逐 agent 的动画状态机、选中的片段槽、跳跃/蒙太奇状态与渲染材质通道),以及承载数据的结构体。作者面只有一个:FAnimsData::Entries 的扁平动画槽表——每行自带所属相位、桶内槽号与片段;烘焙出的表(片段池、通知、同步标记、socket 轨迹、逐集合相位表)都藏在同一结构体里,不出现在 Details 面板中。跳跃时序住在三个相位引用上(FMassBattleJumpAnim),不再是一组浮在上方的散装浮点。
Animation fragment collection: shared config FAnimShared (Idle↔Move blending, the locomotion curve, the Jump State Machine and the animation slot table), runtime state FAnimating (per-agent animation machine, selected clip slots, jump / montage state and material FX channels), plus the structs that carry the data. There is exactly one author face: the flat slot table FAnimsData::Entries — each row carries its phase, its slot inside that phase and its clip. The bake-built tables (clip pool, notify events, sync markers, socket tracks, per-set phase table) live inside the same struct and never appear in the Details panel. Jump timings live on the three phase references (FMassBattleJumpAnim) instead of a set of loose floats above them.
FPerLevelAnimState USTRUCT
某一 LOD 层级的隔离混合状态。五个槽位分工固定:0/1 是移动混合空间(待机 / 移动),2/3 是覆盖层(旧覆盖 / 当前覆盖,含蒙太奇),4 是叠加层——受击反应叠加在已完成的基底+覆盖姿势之上,受击播放期间底下的状态照常推进。只有骨骼 CS 档拥有槽 4。两层不共用槽位,状态切换因此不必搬动任何一组槽。Lerp0 混合 0↔1,Lerp1 混合基底对与覆盖对,Lerp2 混合 2↔3,Lerp3 引入叠加轨。
Isolated blend state for one LOD tier. Slot roles are fixed: 0/1 are the locomotion blend space (idle / move), 2/3 the overlay layer (outgoing / current, montages included), and 4 the additive layer — a hit reaction composed on top of the finished base+overlay pose, so the state underneath keeps advancing while the hit plays. Only the BoneCS tier has slot 4. No slot is shared between layers, so a state change never has to move a set of slots around. Lerp0 blends 0↔1, Lerp1 blends the base pair with the overlay pair, Lerp2 blends 2↔3, and Lerp3 fades the additive track in.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Index0 … Index4 | uint8 | 255 (invalid) | 各槽当前使用的片段下标;255 表示该槽为空。Clip index used by each slot; 255 means the slot is empty. |
PlayRate0 … PlayRate4 | float | 1.0f | 各槽播放速率。Play rate of each slot. |
CurrentFrame0 … CurrentFrame4 | float | 0.0f | 各槽当前帧(浮点,可插值)。Current frame of each slot (float, interpolatable). |
StartFrame0 … StartFrame4 | uint16 | 0 | 各槽播放区间的起始帧。First frame of each slot's played range. |
EndFrame0 … EndFrame4 | uint16 | 0 | 各槽播放区间的结束帧。Last frame of each slot's played range. |
bLoop0 … bLoop4 | bool | false | 各槽是否循环。Whether each slot loops. |
Lerp0 / Lerp1 / Lerp2 / Lerp3 | uint8 | 0 | 混合权重,0-255 表示 0.0-1.0。Lerp2 是覆盖交叉淡化(2→3):新覆盖开始置 0,推进到 255 后把槽 3 抄到槽 2 并归零,不是常驻目标值。Blend weights; 0-255 represents 0.0-1.0. Lerp2 is the overlay crossfade (2→3): it is set to 0 when a new overlay starts and, at 255, slot 3 is copied onto slot 2 and the value returns to 0 — never a standing target. |
FAnimData USTRUCT
八个具名槽的片段元组,遗留表示。每槽是一个 FVector4f:(AnimIndex, PlayLength, StartFrame, EndFrame),X = -1 表示该槽空。新的作者面是 FAnimsData::Entries;这个结构体仍参与序列化,并作为直接填充之前保存的资产的回退来源。提供 operator== 按槽逐项比较。
Eight named clip tuples — the legacy representation. Each slot is an FVector4f: (AnimIndex, PlayLength, StartFrame, EndFrame); X = -1 marks an empty slot. The current author face is FAnimsData::Entries; this struct is still serialized and serves as the fallback for assets saved before the direct fill. Provides operator== comparing slot by slot.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Anim0 … Anim7 | FVector4f | (-1, 0, 0, 0) | 八个槽,格式 (片段下标, 时长, 起始帧, 结束帧);X=-1 表示空。Eight slots as (clip index, length, start frame, end frame); X=-1 means empty. |
方法Methods
逐槽比较两个 FAnimData,全部相等才为真。
Compares two FAnimData slot by slot; true only when all slots match.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Other | const FAnimData& | 待比较对象。The object to compare against. |
Output
返回是否全部槽位相等。无副作用。
Returns whether all slots are equal. No side effects.
FAnimsData USTRUCT
动画载荷。作者编辑 Entries——全部相位合计 64 条扁平槽,每条自带所属相位、桶内槽号与片段;每条目的 PlayLength 就是运行时采用的播放速度。烘焙在同一结构体里写入片段池与各张冷表,它们都是隐藏成员,Details 面板看不到。八个遗留桶成员仍参与序列化,但已从作者面退役。
The animation payload. Authors edit Entries — 64 flat slots in total across every phase, each carrying its phase, its slot inside that phase and its clip; each entry's PlayLength is the playback speed the runtime uses. The bake writes the clip pool and the cold tables into the same struct as hidden members, invisible in the Details panel. The eight legacy bucket members are still serialized but retired from the author face.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Entries | FMassBattleAnimSlotEntry[64] | — | 作者面:全部桶合计 64 条扁平动画槽,每条带相位、槽号与片段。AnimIndex = -1 表示空行。运行时读取的就是这张表里的播放数字。The author face: 64 flat animation slots in total across all buckets, each tagged with its phase, slot and clip. AnimIndex = -1 marks an empty row. The runtime reads its play numbers from this table. |
Tables | FMassBattleAnimTables | — | 烘焙出的布局表(去重片段池 + 组合→映射行→相位/槽→池条目)。隐藏;从未烘焙时为空(NumMaps = 0)。The baked layout table (deduped clip pool + combination → map row → phase/slot → pool entry). Hidden; empty when never baked (NumMaps = 0). |
Notifies | TArray<FMassBattleClipNotifyEvents> | — | 逐片段的已烘通知事件表,与片段池一一对应。隐藏;供 notify 反应表按名字触发。Per-clip harvested notify events, one entry per clip-pool row. Hidden; drives the notify reaction table by name. |
SyncMarkers | TArray<FMassBattleClipSyncMarkers> | — | 逐片段的作者同步标记(与片段池同序)。隐藏;用于把动作对齐到脚步等关键时刻。Per-clip authored sync markers, in clip-pool order. Hidden; used to align actions to key moments such as footfalls. |
SocketTracks | TArray<FMassBattleClipSocketTracks> | — | 逐片段、逐 socket 的已烘轨迹(与片段池同序)。隐藏;出生时读取一次。Per-clip, per-socket baked trajectories, in clip-pool order. Hidden; read once at spawn. |
SetPhaseRanges | TArray<FMassBattleAnimSetPhaseRange> | — | 逐(集合, 相位)的片段段表,索引为 SetIndex * 相位总数 + 相位。隐藏;让逐 agent 的集合下标解析出片段,而不必走已烘的槽位地址。One clip range per (set, phase), indexed SetIndex * phase count + phase. Hidden; lets a per-agent set index resolve a clip instead of the baked slot address. |
SetPhaseClipPool | TArray<uint16> | — | 平铺的逐集合、逐相位片段下标,顺序由 SetPhaseRanges 决定,每个值指向片段池。隐藏。Flat per-set, per-phase clip indices ordered by SetPhaseRanges, each pointing into the clip pool. Hidden. |
IdleAnimData … OtherAnimData | FAnimData | — | 八个遗留桶(待机/移动/下落/出生/攻击/受击/死亡/其它)。仅参与序列化,面板不显示、不供作者编辑;权威表是 Entries。The eight legacy buckets (idle/move/fall/appear/attack/hit/death/other). Serialization only — not shown or authored; Entries is the authoritative table. |
方法Methods
比较作者表、烘焙布局、通知表、同步标记表、socket 表与逐集合相位表,以及遗留桶。任一成员不同即不相等——这是共享片段去重的判据。
Compares the author table, the baked layout, the notify table, the sync-marker table, the socket table and the per-set phase table, plus the legacy buckets. Any differing member makes the values unequal — this is what shared-fragment deduplication compares.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Other | const FAnimsData& | 待比较对象。The object to compare against. |
Output
返回是否全部成员相等。无副作用。
Returns whether every member is equal. No side effects.
FMassBattleAnimSlotEntry USTRUCT
FAnimsData::Entries 的一行:属于哪个相位、桶内槽号,以及该槽代表的片段。大多数字段由烘焙按 ATT 行写入(只读);作者通常只调 PlayLength,要换片段归属则在 Mesh Prep 改并重烘。
One row of FAnimsData::Entries: which phase it belongs to, its slot inside that phase, and the clip it stands for. Most fields are written by the bake from the ATT row (read-only); an author usually only tunes PlayLength, and changes clip membership in Mesh Prep and re-bakes.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Bucket | EMassBattleAnimBucket | Idle | 本槽所属的遗留桶(只读,由烘焙写入)。桶已从作者概念退役,只用于把一项旧地址映射到相位。The legacy bucket this slot belongs to (read-only, written by the bake). Buckets are retired as an authoring concept and only map an old address onto a phase. |
Phase | EMassBattleAnimPhase | Locomotion_Idle | 本片段所属相位(只读,由烘焙写入)。运行时按相位解析片段。The phase this clip belongs to (read-only, written by the bake). The runtime resolves clips by phase. |
Slot | uint8 | 0 | 桶内槽号(只读,由烘焙写入):片段在 ATT 行本相位段内的位置。Slot inside the bucket (read-only, written by the bake): the clip's position inside its phase band on the ATT row. |
AnimIndex | int32 | -1 | ATT 原始 AnimSequences 数组的下标(只读);-1 表示空行。运行时用它做变更检测。Index into the ATT's raw AnimSequences array (read-only); -1 marks an empty row. The runtime uses it for change detection. |
PlayLength | float | 0.f | 片段时长(秒)——运行时采用的播放速度。这一项作者可编辑。Clip length in seconds — the playback speed the runtime uses. This is the field an author edits. |
StartFrame | int32 | 0 | 播放区间起始帧(只读,由烘焙写入;sprite 片段取 sprite 区间)。First frame of the played range (read-only, written by the bake; sprite clips use the sprite range). |
EndFrame | int32 | 0 | 播放区间结束帧(只读)。Last frame of the played range (read-only). |
方法Methods
该行是否不代表任何片段(AnimIndex < 0)。
Whether this row stands for no clip (AnimIndex < 0).
Input
无参数。
No parameters.
Output
空行返回 true。无副作用。
True for an empty row. No side effects.
逐字段比较两行,供共享片段去重使用。
Field-by-field comparison of two rows, used for shared-fragment deduplication.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Other | const FMassBattleAnimSlotEntry& | 待比较行。The row to compare against. |
Output
全部字段相等时返回 true。
True when every field matches.
烘焙表Baked Tables
下面这些结构体是烘焙产物,住在 FAnimsData 的隐藏成员里。它们随资产序列化保存,但不出现在 Details 面板、也不暴露给蓝图:作者不需要填它们,只会在烘焙报告里看到同名概念(例如某条片段携带几条通知)。重新烘焙会整表重建。
The structs below are bake output, held by the hidden members of FAnimsData. They serialize with the asset but never appear in the Details panel or in Blueprints: an author never fills them and only meets the same concepts in bake reports (for example, how many notifies a clip carries). A re-bake rebuilds them wholesale.
| 结构体Struct | 承载什么Carries | 用途Use |
|---|---|---|
FMassBattleAnimTables | 布局载荷:去重片段池、组合→映射行→相位/槽→池条目的查找表,以及每张映射的槽表与组合表。The layout payload: the deduped clip pool, the combination → map row → phase/slot → pool-entry lookup, and each map's slot and combination tables. | 由 FAnimsData::Tables 承载;映射数为 0 表示从未构建,读取方此时回落到扁平作者表。Held by FAnimsData::Tables; zero maps means it was never built and readers fall back to the flat author table. |
FMassBattleAnimClipEntry | 片段池的一条:原始片段下标、时长、帧区间。One clip-pool row: raw clip index, length and frame band. | 去重后的片段池;多个集合引用同一片段时共用这一条与它唯一的帧区间。The deduped clip pool; sets referencing one clip share this row and its single frame band. |
FMassBattleAnimNotifyEvent | 一条通知:名字与片段内归一化时间。One notify: name and its normalized time inside the clip. | 片段通知按名字驱动作者的 notify 反应表;每条片段最多 4 条,超出时烘焙失败并点名,绝不截断。Clip notifies drive the authored notify reaction table by name; at most 4 per clip, and a bake that harvests more fails and names the clip instead of truncating. |
FMassBattleAnimSyncMarker | 一条同步标记:名字与归一化时间。One sync marker: name and normalized time. | 作者在 Persona 同步轨道上画的标记,用于把动作对齐到脚步等关键时刻;每条片段最多 16 条,超出时烘焙失败。A marker drawn on the clip's sync track in Persona, used to align actions to key moments such as footfalls; at most 16 per clip, and a bake that harvests more fails. |
FMassBattleClipSocketTrack | 一个 socket 在一条片段上的逐帧轨迹,连同其骨骼绑定。One socket's per-frame trajectory over one clip, plus its bone binding. | 出生时读取,用来摆放跟随 socket 的挂件;网格没有 socket 时为空,这是正常的关闭状态。Read at spawn to place socket-following attachments; empty when the mesh has no sockets, which is a normal off state. |
FMassBattleAnimSetPhaseRange | (集合, 相位) 在平铺片段清单里的起点与数量。The start and count of one (set, phase) inside the flat clip list. | 逐 agent 的集合下标据此解析片段;集合列表里没有槽号。A per-agent set index resolves clips through this; a set list carries no slot numbers. |
FMassBattleLocoSample USTRUCT
移动曲线上的一个采样点:播放三类片段中的哪一类,锚在哪个移动速度上,以及对该片段自然速率的倍数。相邻两点构成一段:两点同类时该类片段贯穿整段、只插值速率;不同类时整段交叉淡化,所以段的宽度就是切换时长。
One sample on the locomotion curve: which of the three clip kinds it plays, the movement speed it is anchored at, and a multiplier on that clip's natural rate. Adjacent samples form one band — two samples of the same kind hold that kind's clip across the band and interpolate only the rate; two different kinds cross-fade, so the band width is the switch duration.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Speed | float | 0.f | 本采样点锚定的有符号移动速度(cm/s),负值表示向后移动。采样点按升序排列;烘焙发布前会排序。Signed movement speed this sample is anchored at (cm/s); negative means travelling backwards. Samples ascend, and the bake sorts them before publishing. |
PlayRate | float | 1.f | 片段自然播放速率的倍数(1 = 烘焙时长);负值让片段倒放——倒退移动就用负速度键配负速率作者化。Multiplier on the clip's natural play rate (1 = baked length); a negative value plays it backwards — reverse travel is authored as a negative-speed key with a negative rate. |
Kind | EMassBattleLocoKind | Idle | 本关键帧属于三类片段中的哪一类(Idle / Walk / Run)。一类只有一条片段:同一类在多个速度上出现,就是保持该片段、只变速率。Which of the three kinds (Idle / Walk / Run) this key belongs to. One kind is one clip: placing the same kind at several speeds holds that clip and varies only its rate. |
FMassBattleLocoClip USTRUCT
某一类移动片段播放的片段引用:相位,加上该相位段内的槽号。Slot = 255 表示"该 agent 出生时在这个相位里抽到的槽"——这是保住逐 agent 变体的唯一写法,写死槽号会把它抹掉。
The clip reference one locomotion kind plays: a phase plus the slot inside that phase's band. Slot = 255 means "the slot this agent drew at spawn for that phase" — the only way to keep the per-agent variant, since a pinned slot erases it.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Phase | EMassBattleAnimPhase | Locomotion_Idle | 本类片段取自哪个相位。The phase this kind's clip comes from. |
Slot | uint8 | 255 | 相位段内的槽号(0-255);255 = 出生时抽到的槽。Slot inside the phase's band (0-255); 255 = the slot drawn at spawn. |
FMassBattleLocoBlendSpace1D USTRUCT
移动的 1D 混合空间:两个随机起始时间偏移、三个逐类片段引用与速度键。角速度贡献住在上一层的 FMassBattleLocomotion,因为它服务所有混合空间,不只这一个。
The locomotion 1D blend space: two random start-time offsets, the three per-kind clip refs and the speed keys. The angular contribution lives one level up on FMassBattleLocomotion because it feeds every blend space, not just this one.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
IdleRandomTimeOffset | FVector2f | (0, 0) | 待机动画起始时间的随机偏移范围(秒;最小值, 最大值)。让同批单位不同步。Random offset range for the idle animation's start time (seconds; min, max), so a group does not move in lockstep. |
MoveRandomTimeOffset | FVector2f | (0, 0) | 移动动画起始时间的随机偏移范围(秒;最小值, 最大值)。Random offset range for the move animation's start time (seconds; min, max). |
IdleClip / WalkClip / RunClip | FMassBattleLocoClip | — | 三个作者化的片段引用,每类一条。该类每个采样点都播这条引用,所以"在某段速度上保持同一片段"只需把同一类摆在两个速度上。The three authored clip refs, one per kind. Every sample of a kind plays its ref, so "hold one clip across a speed band" only needs the same kind at two speeds. |
Samples | TArray<FMassBattleLocoSample> | — | 速度 →(类别, 速率)的采样点,按 Speed 升序,最多 16 个。留空表示还没有作者化移动曲线,求值回落到旧的两点对(待机对行走)。Speed → (kind, rate) samples, ascending by Speed, at most 16. Empty means no curve has been authored yet and evaluation falls back to the legacy two-point pair (idle against walk). |
FMassBattleLocomotion USTRUCT
locomotion 中不属于混合空间载荷的部分:所有混合空间共用的角速度贡献,以及 1D 混合空间本身。FAnimShared 只持有其中一个。
The part of locomotion that is not the blend-space payload: the angular contribution every blend space shares, plus the 1D blend space itself. FAnimShared holds exactly one of these.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
AngularSpeedBlendMultiplier | float | 0.f | 角速度对移动混合的贡献权重(最小值 0)。转向越快,该权重越能把移动动画推向移动端。How much angular speed contributes to locomotion blending (minimum 0). The faster the turn, the more this weight pushes the locomotion animation toward its moving end. |
BlendSpace1D | FMassBattleLocoBlendSpace1D | — | 1D 混合空间:速度键与三个逐类片段引用。The 1D blend space: speed keys plus the three per-kind clip refs. |
FMassBattleJumpClipBase USTRUCT
一个跳跃相位的片段引用。bEnabled = false 表示该相位没有片段,运行时覆盖轨保持为空;从未作者化过跳跃片段的配置就是这个行为。
The clip reference of one jump phase. bEnabled = false means the phase has no clip and the runtime overlay stays empty — exactly how a config that never authored jump clips behaves.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Phase | EMassBattleAnimPhase | Jump_FallingLoop | 片段所在的相位(由烘焙写入)。三个引用分别携带 Jump_JumpStart / Jump_FallingLoop / Jump_Land。The phase the clip lives in (written by the bake). The three refs carry Jump_JumpStart / Jump_FallingLoop / Jump_Land. |
Slot | uint8 | 255 | 相位段内的槽号;255 = 相位开始时随机抽一个变体,而不是钉死某个槽。Slot inside the phase band; 255 = draw a random variant when the phase starts instead of pinning one slot. |
bEnabled | bool | false | false = 该相位不播片段,覆盖轨保持为空。False = the phase plays no clip and the overlay stays empty. |
FMassBattleJumpClip USTRUCT
拥有长度的跳跃相位引用——JumpStart 与 Land 的时序就是它们持续多久。坠落相位度量的是启动前的等待,用的是 FMassBattleFallingClip。
A jump phase ref that owns a length — JumpStart and Land are the phases whose timing is how long they run. The falling phase measures a start delay instead and uses FMassBattleFallingClip.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Duration | float | 0.1f | 本相位一旦开始持续多久(秒),面板显示名 Duration。只有拥有长度的相位把它放在这里。How long this phase runs once it starts (seconds), shown as Duration. Only the phases that own a length carry it here. |
FMassBattleFallingClip USTRUCT
坠落相位的引用:无时序的片段载荷,加上一个在那里含义不同的时序值——本相位在坠落片段启动前等多久。它是动画滞回,不是相位长度:物理在离地瞬间就进入坠落,本项只避免台阶与斜坡上的动画抖动。
The falling phase's ref: the timing-free clip payload plus the one timing value that means something else there — how long the phase waits before the falling clip starts. It is animation hysteresis, not a phase length: physics enters falling instantly on takeoff, and this only avoids flicker on bumps and slopes.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Delay | float | 0.1f | 片段启动前必须在空中持续的秒数(面板显示名 Delay)。Seconds the agent must remain airborne before this phase's clip starts (shown as Delay). |
FMassBattleJumpAnim USTRUCT
所有跳跃作者参数集中在一块,Details 面板只有一行 Jump State Machine。每个相位的引用自带时序——JumpStart 与 Land 上是 Duration,FallingLoop 上是启动延迟 Delay——因此引用上方不再有待着的浮点。JumpStart 与 Land 默认关闭,那两个相位的覆盖轨保持为空;FallingLoop 携带 Jump_FallingLoop(遗留 Fall 桶映射到的相位),从未作者化跳跃片段的配置因此保持当前的坠落动画。
Every jump-authoring parameter in one block, shown as the single Jump State Machine row. Each phase's ref carries its own timing — a Duration on JumpStart and Land, a start Delay on FallingLoop — so nothing sits loose above the refs. JumpStart and Land default to disabled, which leaves their overlay empty; FallingLoop carries Jump_FallingLoop (the phase the legacy Fall bucket maps to), so a config that never authored jump clips keeps its current falling animation.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
JumpStart | FMassBattleJumpClip | bEnabled = false | 起跳相位显示的片段与它持续多久。关闭时该相位的覆盖轨保持为空。The clip shown during the JumpStart phase and how long it runs. Disabled leaves the overlay empty for this phase. |
FallingLoop | FMassBattleFallingClip | bEnabled = false | 下落循环相位显示的片段与启动前的等待。它携带 Jump_FallingLoop,未作者化跳跃的配置因此保持原有坠落表现。The clip shown during the FallingLoop phase and the wait before it starts. It carries Jump_FallingLoop, so a config with no authored jump keeps its existing falling behaviour. |
Land | FMassBattleJumpClip | Duration = 0.15f, bEnabled = false | 落地相位显示的片段与它持续多久(面板显示名 Landing)。关闭时覆盖轨保持为空。The clip shown during the Land phase and how long it runs (shown as Landing). Disabled leaves the overlay empty for this phase. |
FAnimating USTRUCT
动画运行时状态 fragment,每个 agent 一份。承载逐级混合状态、动画状态机、选中的片段槽(含该 agent 出生时抽到的移动集合与跳跃集合)、跳跃机与蒙太奇机状态,以及渲染材质通道。在 AgentConfig 中默认为隐藏的运行时片段,把 bHideRuntimeFragments 设为 false 即可在 Details 中查看,不应编辑。
The animation runtime state fragment, one per agent. It holds the per-level blend state, the animation state machine, the selected clip slots (including the locomotion set and jump set this agent drew at spawn), the jump and montage machine state, and the render material channels. In the AgentConfig it is a runtime fragment hidden by default; set bHideRuntimeFragments to false to inspect it, never to edit.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Level1State / Level2State / Level3State / AnimBlendResult | FPerLevelAnimState | — | 三级 LOD 的独立混合状态与最终混合结果。Per-LOD blend state and the final blend result. |
AnimState / PreviousAnimState | EAnimState | Dirty | 当前与上一帧的动画状态(遗留状态机,由蒙太奇机与跳跃机派生)。Current and previous animation state (the legacy machine, derived from the montage and jump machines). |
CurrentAnimBlendLevel | uint8 | 1 | 当前激活的最高混合层级:1 = sprite 单轨,2 = VatVert 两轨,3 = BoneCS 五轨。Highest blend tier active: 1 = sprite single track, 2 = VatVert two tracks, 3 = BoneCS five tracks. |
SampleRate | int32 | 30 | 动画数据的帧采样率(每秒帧数)。Frame sample rate of the animation data (frames per second). |
IdleRandomStartFrame / MoveRandomStartFrame | float | 0.0f | 该 agent 的待机 / 移动动画随机起始帧。This agent's random start frame for the idle / move animation. |
SelectedIdleAnimIndex … SelectedDeathAnimIndex | uint8 | 255 | 各相位选中的槽下标(255 = 无):Idle / Move / Run / Fall / Appear / Attack / Hit / Death。Selected slot per phase (255 = none): Idle / Move / Run / Fall / Appear / Attack / Hit / Death. |
SelectedJumpStartAnimIndex / SelectedJumpLandAnimIndex | uint8 | 255 | JumpStart 与 Land 相位使用的片段槽;跳跃片段作者化之前两者都保持 255。FallingLoop 继续使用 SelectedFallAnimIndex。Clip slots used by the JumpStart and Land phases; both stay 255 until jump clips are authored. FallingLoop keeps using SelectedFallAnimIndex. |
SelectedMontageAnimIndex | uint8 | 255 | 蒙太奇槽:Montage_Generic 相位段内的 0 基槽号(0-31);255 = 无蒙太奇。它不是 ATT 片段下标,也不是烘焙片段下标。Montage slot: the 0-based slot inside the Montage_Generic phase band (0-31); 255 = no montage. It is neither an ATT clip index nor the baked clip index. |
LocoSetIndex / JumpSetIndex | uint8 | 255 | 该 agent 的移动相位 / 跳跃相位在哪个作者化动画集合里解析。255 = 载荷不携带集合表,走原来的槽位地址。两者是各自独立的一次出生抽签,所以移动集合不动也能换跳跃集合。Which authored animation set this agent's locomotion / jump phases resolve in. 255 = the payload has no set table and the old slot address runs. They are two independent spawn draws, so the jump set can change without moving the locomotion one. |
JumpState | EJumpState | Grounded | 跳跃机相位:Grounded / JumpStart / FallingLoop / Land。Jump machine phase: Grounded / JumpStart / FallingLoop / Land. |
LandTimer / JumpStartTimer | float | 0.0f | 在 Land / JumpStart 相位里经过的时间(仅在对应相位递增)。Time spent in the Land / JumpStart phase (advances only while that phase is active). |
MontageState | EMontageState | None | 蒙太奇机种类:None / Appear / Attack / Hit / Death / Generic。它拥有"正在播蒙太奇"这件事,遗留的 AnimState 由它派生。Montage machine kind: None / Appear / Attack / Hit / Death / Generic. It owns "a montage is playing", and the legacy AnimState is derived from it. |
MontagePlayRate | float | 1.f | 蒙太奇播放速率乘数。Montage play rate multiplier. |
bMontageLooping | uint8 : 1 | 0 | 蒙太奇是否循环。Whether the montage loops. |
Team | uint8 | 0 | 队伍 ID,通常用于材质着色。Team id, usually used for material tinting. |
HitGlow / Dissolve | uint8 | 0 | 受击辉光强度(0-255)与消融进度(0 = 实体,255 = 完全消融)。Hit glow intensity (0-255) and dissolve progress (0 = solid, 255 = fully dissolved). |
IceFx / FireFx / PoisonFx | uint8 | 0 | 冰冻 / 火焰 / 中毒效果强度(0-255)。Ice / fire / poison effect intensity (0-255). |
IceFxInterped / FireFxInterped / PoisonFxInterped | uint8 | 0 | 插值后的对应效果强度(0-255)。Interpolated intensity of the same effects (0-255). |
两个同帧触发位也在这里:bMontageRestart 是一次新的 Play Montage 请求——即便槽位已经持有同一片段,也强制从起始帧重新播;它由渲染侧在消费它的那一帧清除。bUpdateAnimState 表示本帧要更新动画状态。两者都不参与同步,真正传递的是它们产生的层级状态。
Two same-frame trigger bits live here too: bMontageRestart is a new Play Montage request — it forces a restart from the start frame even when the slot already holds the same clip, and is cleared on the frame it is consumed. bUpdateAnimState asks for an animation-state update this frame. Neither is synced; what travels is the level state they produce.
AnimationHelpers Helpers
动画数据辅助命名空间。常量是墙不是建议:超过任一上限的烘焙会失败并点名,绝不截断。解析函数是运行时与烘焙共用的唯一取片段入口——<(相位, 槽)> 如何变成一个片段只有一处定义,读片段与读通知因此不可能落到两条不同的片段上。
The animation helper namespace. The constants are walls, not hints: a bake that exceeds any of them fails and names the cause instead of truncating. The resolvers are the one clip lookup shared by the runtime and the bake — how a (phase, slot) becomes a clip is defined in exactly one place, so reading a clip and reading its notifies can never land on two different clips.
常量Constants
| 名称Name | 值Value | 说明Description |
|---|---|---|
INVALID_ANIM_INDEX | 255 | "没有片段 / 没有槽"哨兵;读取方必须把它读作空,不能当成第 255 个槽。The "no clip / no slot" sentinel; readers must treat it as empty, never as slot 255. |
InvalidSetIndex | 255 | 逐 agent 集合下标的"无集合"哨兵;集合解析器一律拒绝它。The "no set" sentinel of a per-agent set index; the set resolver refuses it. |
SlotsPerBucket | 8 | 每个遗留桶的槽数。Slots per legacy bucket. |
SlotsPerPhase | 32 | 每个相位的槽段宽度;相位在已烘表里占一段连续槽。Width of one phase's slot band; a phase owns a contiguous band in the baked table. |
MaxAnimSlots | 64 | 扁平作者表的槽位总数(所有相位合计),即 Entries 的容量。Total author-table slots across all phases — the capacity of Entries. |
MaxLocoSamples | 16 | 移动曲线的采样点上限。Maximum locomotion curve samples. |
MaxNotifyEventsPerClip | 4 | 一条片段最多携带的通知事件数;超出时烘焙失败。Maximum notify events one clip may carry; a bake that harvests more fails. |
MaxSyncMarkersPerClip | 16 | 一条片段最多携带的同步标记数;超出时烘焙失败。Maximum sync markers one clip may carry; a bake that harvests more fails. |
MaxMaps | 8 | 一份配置最多携带的已烘映射数(每个命名动画集合一张)。Maximum baked maps one config may carry (one per named animation set). |
方法Methods
所有动画读取方共用的取片段入口。按组合行、相位与槽号解析出一条片段的四元组 (AnimIndex, PlayLength, StartFrame, EndFrame);该处没有片段时返回 (-1, 0, 0, 0)。旧配置没有烘焙载荷时,它先读扁平作者表,再回落到八个遗留桶。
The clip lookup shared by every animation reader. Resolves a clip's four-tuple (AnimIndex, PlayLength, StartFrame, EndFrame) from a combination row, a phase and a slot; returns (-1, 0, 0, 0) when no clip lives there. For an old config with no baked payload it reads the flat author table first and falls back to the eight legacy buckets.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
CombinationIndex | uint8 | 风格组合行(0 = 默认)。Style combination row (0 = the default). |
Phase | EMassBattleAnimPhase | 片段所属相位。The phase the clip belongs to. |
Slot | uint8 | 相位段内槽号;255 读作"无片段"。Slot inside the phase band; 255 reads as "no clip". |
Output
返回片段四元组,无片段时为 (-1, 0, 0, 0)。无副作用。
Returns the four-tuple, or (-1, 0, 0, 0) when there is none. No side effects.
从本相位段里实际有片段的槽中均匀抽一个下标,并跟随该 agent 的组合行。抽取只消耗一次随机流,所以无论候选多少,随机游标的消耗次数都不变——这是跨端一致的前提。没有候选时返回 -1。
Uniformly picks one slot among the slots this phase band actually holds, following the agent's combination row. The draw consumes exactly one stream value regardless of how many candidates exist — that is what keeps peers identical. Returns -1 when there are no candidates.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
CombinationIndex | uint8 | 风格组合行。Style combination row. |
Phase | EMassBattleAnimPhase | 要抽取的相位。The phase to draw from. |
Stream | FRandomStream& | 该 agent 的确定性随机流(会被推进一次)。The agent's deterministic stream (advanced once). |
Output
返回选中的槽下标;无候选时返回 -1。副作用:消费一次随机数。
Returns the picked slot index, or -1 with no candidates. Side effect: consumes one random draw.
回答"这个移动速度上有哪两条片段在承担权重":选出夹住速度的两个采样点、它们之间的权重、两条片段各自的绝对播放速率,以及主导的那一条。曲线为空时回落到旧的两点对(待机对行走),两端速率恰为 1。
Answers "which two clips carry weight at this speed": it picks the two samples bracketing the speed, the weight between them, each clip's absolute play rate, and which one dominates. With an empty curve it falls back to the legacy two-point pair (idle against walk), both rates exactly 1.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置(含移动曲线)。The animation config (including its locomotion curve). |
CombinationRow | uint8 | 风格组合行。Style combination row. |
Animating | const FAnimating& | 该 agent 的运行时状态(出生抽到的槽与集合)。The agent's runtime state (spawn-drawn slots and set). |
Velocity | float | 当前移动速度(cm/s,有符号)。Current movement speed (cm/s, signed). |
Out | FMassBattleLocoEvaluation& | 接收结果的求值结构。Evaluation struct that receives the result. |
Output
无返回值;写入 Out(两条片段及其相位/槽/速率、权重、主导项、是否同一片段)。无其它副作用。
No return value; fills Out (both clips with their phase/slot/rate, the weight, the dominant pick, and whether both are the same clip). No other side effects.
把某一类移动片段完整解析出来:片段四元组、读取所用的相位与槽号,以及拥有该片段冷表行的池条目。载荷携带逐集合表、且该 agent 出生时抽到了集合下标时,该类在自己的相位里解析为该集合的第一条作者化片段;否则沿用集合表之前的槽位地址。
Resolves one locomotion kind end to end: the clip four-tuple, the phase and slot it was read through, and the pool entry that owns the clip's cold rows. When the payload carries the per-set table and this agent drew a set index at spawn, the kind resolves in its own phase as that set's first authored clip; otherwise the pre-set slot address runs.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
Kind | EMassBattleLocoKind | 三类移动片段之一。One of the three locomotion kinds. |
Animating | const FAnimating& | 该 agent 的运行时状态。The agent's runtime state. |
CombinationRow | uint8 | 风格组合行。Style combination row. |
OutClip / OutPhase / OutSlot / OutEntry | FVector4f& / EMassBattleAnimPhase& / uint8& / const FMassBattleAnimClipEntry*& | 接收片段、相位、槽号与池条目。Receive the clip, phase, slot and pool entry. |
Output
解析到片段时返回 true(集合路径以集合解析的返回值为准)。无其它副作用。
True when a clip was resolved (the set path returns the set resolver's verdict). No other side effects.
解析某个跳跃相位的片段与它的池条目。跳跃机寻址与移动相位相同的逐 agent 集合;集合路径还要求状态机真的选过这个相位——片段被关闭或该集合没有提供时,这个相位必须继续什么都不画。
Resolves one jump phase's clip and its pool entry. The jump machine addresses the same per-agent set as the locomotion phases; the set path also requires the machine to have actually selected this phase — a disabled clip, or a set that supplies nothing, must keep drawing nothing.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
Phase | EMassBattleAnimPhase | 三个跳跃相位之一。One of the three jump phases. |
Animating | const FAnimating& | 该 agent 的运行时状态。The agent's runtime state. |
CombinationRow | uint8 | 风格组合行。Style combination row. |
OutClip / OutEntry | FVector4f& / const FMassBattleAnimClipEntry*& | 接收片段与池条目。Receive the clip and pool entry. |
Output
解析到片段时返回 true。无其它副作用。
True when a clip was resolved. No other side effects.
按原始片段下标找到该片段的已烘同步标记(按片段内时间升序)。片段池已去重,一个片段下标至多对应一条。只在轨道换片段时调用——它不是逐帧接口。返回空指针表示没有标记表或没有该片段;空数组是真实答案,表示该片段没有同步标记。
Finds a clip's baked sync markers by its raw clip index (ascending by time inside the clip). The clip pool is deduped, so one clip index identifies at most one row. Call it only when a track changes clip — it is not a per-frame API. A null pointer means no marker table or no such clip; an empty array is a real answer meaning the clip has no sync marker.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
AnimIndex | uint8 | 原始片段下标。Raw clip index. |
Output
返回标记数组指针,或 nullptr。无副作用。
Returns a pointer to the marker array, or nullptr. No side effects.
取某条片段上某个 socket 在某归一化时间的组件空间变换。第一个版本吸附到某一已烘帧,第二个版本在夹住该时间的两帧之间插值(旋转用 slerp)。输入全部来自同步状态或烘焙产物,所以各端落在同一帧、同一帧间比例。
Returns a socket's component-space transform at a normalized time on one clip. The first variant snaps to one baked frame; the second interpolates between the two frames bracketing that time (rotation slerped). Every input is synced state or bake output, so all peers land on the same frame and the same fraction between frames.
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
Animation | const FAnimShared& | 动画配置。The animation config. |
Entry | const FMassBattleAnimClipEntry* | 解析器交出的片段池条目。The clip-pool entry a resolver handed back. |
SocketName | FName | 烘焙在源网格上发现的 socket 名。A socket name the bake discovered on the source mesh. |
NormalizedTime | float | 片段内归一化时间 0-1(越界会钳制)。Normalized time inside the clip, 0-1 (clamped). |
OutFrame | FTransform3f& | 插值版本接收结果。The interpolating variant receives the result here. |
Output
第一个版本返回帧指针(未命中为 nullptr);第二个版本返回是否命中。无其它副作用。
The first variant returns a frame pointer (nullptr on a miss); the second returns whether it hit. No other side effects.
其他辅助Other helpers
| 函数Function | 用途Purpose |
|---|---|
GetClipAndEntry | 完整解析:片段四元组 + 拥有其冷表行的池条目;通知与 socket 查找从该条目出发,不重新推导地址。Full resolution: the four-tuple plus the pool entry owning its cold rows; notify and socket lookups start from that entry instead of re-deriving the address. |
GetDataFromIndex | 按槽号(0-7)取 FAnimData 的一个元组;越界返回 (-1, 0, 0, 0)。Reads one slot (0-7) of FAnimData; out of range returns (-1, 0, 0, 0). |
GetClipNotifies | 取解析器刚交出的那条片段的已烘通知事件;空数组表示该片段没有通知。Returns the baked notify events of the clip a resolver just handed back; an empty array means the clip carries none. |
GetSetPhaseClipCount | 某个集合为某个相位提供几条片段(载荷没有集合表时为 0)。How many clips a set supplies for one phase (0 when the payload has no set table). |
JumpPhaseHasClip | 该 agent 的某个跳跃相位是否解析得出片段;不消耗随机流。Whether one of the agent's jump phases resolves a clip at all; consumes no random draw. |
SelectedSlotForPhase | 该 agent 出生时为某个相位抽到的槽——片段引用里 Slot = 255 解析出的就是它。The slot this agent drew at spawn for one phase — what a clip ref's Slot = 255 resolves to. |
CalculatePlayRate | 让一段帧区间恰好用目标时长播完的绝对速率。The absolute rate that makes a frame band play in exactly the target duration. |
逐 agent 动画集合与同步标记 Per-Agent Sets &Sync Markers
一次烘焙可以把片段组织成多个命名集合,每个集合按选择器服务一组风格组合;逐 agent 在出生时从实体自己的种子流里各抽一次移动集合下标与跳跃集合下标,所以同一原型的不同单位可以播不同的一套片段,而各端无需额外通信就一致。集合下标是同步的出生状态,记录在 FAnimating::LocoSetIndex / JumpSetIndex;载荷不带集合表时(旧烘焙)两个下标保持 255,运行时走原来的槽位地址。
One bake can organize clips into several named sets, each serving a group of style combinations through its selector; every agent draws a locomotion set index and a jump set index at spawn from its own seeded stream, so units of one archetype can play different clip sets and all peers agree without extra traffic. The set indices are synced spawn state, recorded in FAnimating::LocoSetIndex / JumpSetIndex. A payload without a set table (an old bake) keeps both at 255 and the runtime uses the original slot address.
同步标记是作者在动画片段的同步轨道上画的名字与时间点,由烘焙按片段内归一化时间采集(最多 16 条)。它们的用途是让逻辑对齐到动作的关键瞬间——脚步落地、挥击命中之类的时刻——而不是靠帧号猜测。标记随片段池走,因此换片段时会拿到新片段自己的标记表;查询只在换片段时发生,不是每帧开销。
Sync markers are names and time points an author draws on a clip's sync track; the bake harvests them as normalized times inside the clip (at most 16). Their purpose is to align logic to key instants of the motion — a footfall, the moment of a swing — instead of guessing from frame numbers. They travel with the clip pool, so a clip change brings that clip's own marker table; the lookup happens only on a clip change, not every frame.
| 项目Item | 说明Description |
|---|---|
| 集合选择器Set selector | * = 基底集合:把它声明的每个桶(对作者即相位)供给每个组合(可选);名字 / #N / 名字* = 组合专属:声明非空的桶整体替换基底,其余仍由基底供给。两种规则可并存。* = a base set that supplies every bucket it declares (a phase, for an author) to every combination (optional); name / #N / name* = combination-specific, replacing the base wholesale for every bucket it declares non-empty while the base supplies the rest. Both rules may coexist. |
| 共享冲突Conflicts | 两个集合点名同一组合且声明同一个桶时,烘焙拒绝——谁赢没有定义。Two sets naming one combination and declaring the same bucket are refused at bake — which one wins would be undefined. |
| 集合上限Set limit | 一份配置最多携带 8 张已烘映射(每个命名集合一张);超出时烘焙失败。A config carries at most 8 baked maps (one per named set); a bake that exceeds this fails. |
| 通知事件Notify events | 片段通知按名字驱动作者的 notify 反应表,每条片段最多 4 条;它与同步标记是两套数据:通知触发逻辑,标记用于对齐。Clip notifies drive the authored notify reaction table by name, at most 4 per clip; they are separate data from sync markers: notifies trigger logic, markers align it. |
管线角色Pipeline Role
制作期:动画片段在 Mesh Prep 里登记到 ATT 的片段表(逐行选相位、可选自定义帧区间);移动曲线与跳跃片段也在那张表上按资产配置。Agent Creator 烘焙时把片段池、帧区间、通知、同步标记与 socket 轨迹写进 AgentConfig 的 AnimShared.AnimData,并把移动与跳跃作者块发布进去。任一容量上限被突破时烘焙失败并点名,绝不截断。
运行期:每个 agent 的 FAnimating 记录它出生时抽到的槽与集合下标;AnimationHelpers::GetClip 是"这个 agent 在播哪条片段"的唯一答案,渲染播放与逻辑调度(攻击时长、受击/死亡长度、出生起始帧)都从它取数。相同取值的配置在运行时合并成一份共享实例,所以同原型的成千上万单位只占一份动画配置。
Authoring: animation clips are registered on the ATT's clip table in Mesh Prep (choose a phase per row, optionally a custom frame range); the locomotion curve and jump clips are authored on that same asset. The Agent Creator bakes the clip pool, frame bands, notifies, sync markers and socket tracks into the AgentConfig's AnimShared.AnimData, and publishes the locomotion and jump authoring blocks into it. A bake that exceeds any capacity wall fails and names the cause; it never truncates.
Runtime: each agent's FAnimating records the slots and set indices it drew at spawn; AnimationHelpers::GetClip is the single answer to "which clip is this agent playing", and both rendering and logic scheduling (attack duration, hit/death length, spawn start frames) read from it. Configs with identical values collapse into one shared runtime instance, so tens of thousands of units of one archetype carry one animation config.
补充说明Notes
① 一个作者面:要改片段归属,改 ATT 上的相位并在 Mesh Prep 重烘;要改播放速度,改 Entries[i].PlayLength。烘焙出的表不是编辑入口——它们是产物,重烘会整表重建。
② 空表示"没作者化过":空的移动采样表回落到旧两点对;空的跳跃相位覆盖轨保持为空;空的键表/片段项让烘焙保留配置里已有的值,而不是清空它。
③ 容量是墙:64 条动画槽、每相位 32 个槽、每片段 4 条通知、16 条同步标记、16 个移动采样点、8 个集合。突破上限的烘焙会失败并点名具体片段或相位。
④ 旧数据自动迁移:八个遗留桶、旧的分段移动字段与散装跳跃时序都仍参与序列化;加载时迁移进当前的扁平表、移动块与相位引用,作者无需手工转换。面板里不再有单独的跳跃时序行——Duration / Delay 随各自相位引用一起显示,散装的那三个浮点仅用于序列化。
⑤ 确定性:槽与集合的抽取都来自该 agent 播种的随机流,且每次抽取只消耗一个随机值;同输入同 tick,各端解出同一片段。
① One author face: to change which clip a slot plays, change its phase on the ATT and re-bake in Mesh Prep; to change playback speed, edit Entries[i].PlayLength. The baked tables are not an editing surface — they are output and a re-bake rebuilds them wholesale.
② Empty means "not authored": an empty locomotion sample list falls back to the legacy two-point pair; an empty jump phase leaves its overlay empty; an empty key list or clip entry makes the bake keep the config's existing value instead of clearing it.
③ Capacity is a wall: 64 animation slots, 32 slots per phase, 4 notifies and 16 sync markers per clip, 16 locomotion samples, 8 sets. A bake that exceeds a wall fails and names the clip or phase.
④ Old data migrates automatically: the eight legacy buckets, the old split locomotion fields and the loose jump timings are all still serialized; loading migrates them into the current flat table, locomotion block and phase refs, with no manual conversion. There is no separate jump-timing row any more — Duration / Delay are shown on their own phase refs, and the three loose floats are serialization only.
⑤ Determinism: slot and set draws both come from the agent's seeded stream and each draw consumes exactly one random value; the same inputs on the same tick resolve the same clip on every peer.