Mass Battle Frameworkv1.20.0

MassBattleSpritePrepState.h

UCLASS ×2 enum class ×1

Source/MassBattleEditor/Public/SpritePrep/MassBattleSpritePrepState.h

概述Overview

Sprite Prep 的状态对象:承载布局参数(格子、列数、纹理、渲染输入)、逐桶的 sprite 动画变体,以及所绑定的 ATA。它不含控件,也不执行烘焙;面板读取并编辑它、显示它的日志,New / Save / Apply 的模型动作则直接复用它的成员函数。图集纹理由 Creator 的 Generate 产出并回写 ATA。

The Sprite Prep's state object: it holds the layout parameters (cell, columns, texture, render inputs), the per-bucket sprite animation variants and the bound ATA. It owns no widgets and performs no bake; the panel reads and edits it and displays its log, while the model actions of New / Save / Apply reuse its member functions directly. The atlas texture is produced by the creator's Generate and written back to the ATA.

参数挂在详情视图里(参数多则用详情视图的规则);该视图过滤掉动画变体列表、Creator 链接、日志与 ATA 成员——动画变体由面板自己的卡片 UI 管理,可编辑的 ATA 行是面板顶部 Prep Asset 模块里的桥接对象。本对象只在编辑器里存在,不参与运行时:图集最终由 Creator 的 Generate 装配成运行资产。

The parameters live in a details view (the many-parameter rule); that view filters out the animation-variant list, the creator link, the log and the ATA member — the variants are managed by the panel's own card UI, and the editable ATA row is the bridge object in the panel's top Prep Asset module. The object exists in the editor only and takes no part at runtime: the atlas is eventually assembled into runtime assets by the creator's Generate.

继承Inheritance

UObject → UMassBattleSpritePrepState

ESpriteAnimBucketEd enum class

动画桶选择器,共八个值;顺序与 FAnimData 的 Anim0..Anim7 相同,所以下标本身就是运行时槽。Idle 与 Move 作循环底轨,其余桶按一次性蒙太奇使用。枚举值按声明顺序从 0 递增。

The animation bucket selector — eight values in the same order as FAnimData's Anim0..Anim7, so an index here IS the runtime slot. Idle and Move act as looping base tracks; the remaining buckets are used as one-shot montages. Values increment from 0 in declaration order.

值Value序号Index说明Description
Idle0待机,循环播放。Idle, played as a loop.
Move1移动,循环播放。Move, played as a loop.
Fall2坠落,一次性。Fall, one-shot.
Appear3出现,一次性。Appear, one-shot.
Attack4攻击,一次性。Attack, one-shot.
Hit5受击,一次性。Hit, one-shot.
Death6死亡,一次性。Death, one-shot.
Other7其它/额外蒙太奇,一次性。Other/extra montages, one-shot.

UMassBattleSpritePrepAssetFields UCLASS

UObject → UMassBattleSpritePrepAssetFields

"Prep Asset" 模块的 DetailsView 桥接对象——assembly 面板 Agent Template 字段对象的镜像。DetailsView 只能编辑反射属性,所以所绑定的 ATA 需要一个属性落脚;面板每 Tick 让本对象与 UMassBattleSpritePrepState::Asset 保持一致,并把这里的选择当作「绑定并载入」。载入、保存、撤销等行为仍归状态对象。

The DetailsView bridge for the "Prep Asset" module — the mirror of the assembly panel's Agent Template fields object. A DetailsView can only edit reflected properties, so the bound ATA needs a property to live on; the panel keeps this object equal to UMassBattleSpritePrepState::Asset every Tick and treats a pick here as "bind and load". Load, save and undo stay with the state object.

成员变量Members

名称Name类型Type默认值Default说明Description
Asset TObjectPtr<UMassBattleATADataAsset> nullptr 标准资产卡片行,由属性自身的类限定为 ATA。选择已存在的 ATA 会把它载入本面板,替换当前内容;New 仍新建资产,Save 写回所绑定的那个。Standard asset-card row restricted to ATAs by the property's own class. Picking an existing ATA loads its tracks and layout parameters into the panel, replacing what is shown; New still creates a fresh asset and Save writes back to the bound one.

成员变量Members

输出Output

名称Name类型Type默认值Default说明Description
Asset TObjectPtr<UMassBattleATADataAsset> nullptr 所绑定 ATA 的镜像:New / Save / Clear 与选择资产都落到这里。成员本身是 VisibleAnywhere,可编辑的选择行是面板 Prep Asset 模块里的桥接对象;输出名与路径不在本对象里——它们归 Creator 的 0.RenderProfile 类别。The mirror of the bound ATA: New / Save / Clear and an asset pick all land here. The member itself is VisibleAnywhere, and the editable picker row is the bridge object in the panel's Prep Asset module; the output name and path are not on this object — they live in the creator's 0.RenderProfile category.

格子尺寸Cell Size

名称Name类型Type默认值Default说明Description
bAutoCellSize bool true 开启时格子 = 全部帧的最大宽高,再按尺寸上限与纹素预算压低;关闭时使用手动宽高。帧大于格子时重采样缩小放进格内,绝不拒绝。On: cell = the largest frame width/height across all frames, then cut down to whatever the size cap and the texel budget allow; off: use the manual sizes. A frame larger than its cell is resampled down into it, never refused.
ManualCellWidth int32 128 手动格子宽(像素),仅自动格子关闭时生效;源码下限 1。Manual cell width in pixels, used only when auto cell size is off; source minimum 1.
ManualCellHeight int32 128 手动格子高(像素),仅自动格子关闭时生效;源码下限 1。Manual cell height in pixels, used only when auto cell size is off; source minimum 1.

列数Columns

名称Name类型Type默认值Default说明Description
bAutoColumns bool true 开启时列数 = ⌈√总帧数⌉;关闭时使用手动列数。行数始终由帧总数与列数推出。On: columns = ⌈√(total frames)⌉; off: use the manual count. Rows are always derived from the frame total and the column count.
ManualColumns int32 8 手动列数,仅自动列数关闭时生效;源码下限 1。Manual column count, used only when auto columns is off; source minimum 1.

纹理设置Texture Settings

名称Name类型Type默认值Default说明Description
bPowerOfTwo bool true 把格子宽高、列数、行数依次向上取到 2 的幂,图集宽高因此也是 2 的幂;可能留下空格子。Snaps cell width/height, then columns, then rows up to powers of two, making the atlas width/height powers of two as well; unused cells may remain.
bSRGB bool true 把图集标记为 sRGB 颜色数据。Marks the atlas as sRGB color data.
bNearestFilter bool true 点采样,帧像素锐利无插值;关闭则使用默认过滤。Point filtering for crisp frame pixels without interpolation; off uses default filtering.
MaxAtlasSize int32 4096 图集宽和高的硬上限(像素),源码范围 256–16384。布局会把格子压到该上限按网格摊分后的大小;只有格子缩到 1 像素仍超出上限的网格才会被拒绝,不裁剪。Hard cap on atlas width/height in pixels, source range 256–16384. The layout cuts the cell down to this cap divided over the grid; only a grid that would still exceed the cap at a 1-pixel cell is refused — nothing is cropped.
AtlasTexelBudget int32 16777216 整张图集的纹素预算(宽 × 高),源码下限 65536;默认值就是一张 4096×4096。格子会被压小、帧随之重采样,直到网格装得下;只有每格 1×1 仍装不进预算的网格才会被拒绝。Texel budget for the whole atlas (width × height), source minimum 65536; the default is one 4096×4096 sheet. The cell shrinks and frames are resampled down until the grid fits; only a grid whose cells cannot fit the budget even at 1×1 is refused.

渲染Render

名称Name类型Type默认值Default说明Description
MasterMaterial TObjectPtr<UMaterialInterface> nullptr 逐版本 sprite MI 的母材质;必须暴露 MB_AtlasTexture / MB_AtlasCols / MB_AtlasRows 与 MB_SpriteMode 开关。Master material the per-version sprite MIs parent to; it must expose MB_AtlasTexture / MB_AtlasCols / MB_AtlasRows and the MB_SpriteMode switch.
QuadMesh TObjectPtr<UStaticMesh> nullptr sprite renderer 绘制的四边形。The quad a sprite renderer draws.
PlaybackFPS double 12.0 图集播放帧率,源码范围 1–120;烘焙的 FAnimData 写入 PlayLength = 帧数 / FPS。Atlas playback FPS, source range 1–120; the baked FAnimData writes PlayLength = frame count / FPS.

Sprite 源Sprite Source

名称Name类型Type默认值Default说明Description
SpriteAnims FSpriteAnimsEd 空Empty 逐桶的 sprite 动画变体(下标 = 运行时槽)。八个固定桶,每桶最多八个变体;桶的位置就是运行时桶,变体下标就是槽号,因此填不出非法的轨道。面板用自有卡片 UI 编辑它,详情视图过滤掉这一行。Per-bucket sprite animation variants (index = runtime slot). Eight fixed buckets, each holding up to eight variants; the bucket position IS the runtime bucket and the variant index IS the slot, so an impossible track cannot be authored. The panel edits it through its own card UI, and the details view filters this row out.

Creator 链接与日志Creator Link and Log

名称Name类型Type默认值Default说明Description
CreatorState TObjectPtr<UMassBattleAgentCreatorState> nullptr 指向 Creator 状态的链接,放在被持根的状态对象里让 GC 可见(Slate 成员反射不可见);Creator 面板已关时为空。Creator-side link kept inside the rooted state so GC sees it (Slate members are invisible to reflection). Null when the creator panel is gone.
Log TArray<FString> 空Empty 本状态的日志行;详情视图过滤掉它,由面板显示。The state's log lines; the details view filters it out and the panel displays it.

设置如何影响图集How Settings Shape the Atlas

格子尺寸决定每帧能占的像素范围。自动格子取全部帧的最大宽高,再按尺寸上限与纹素预算压低;手动格子更紧凑。帧大于格子时会等比缩小放进格内,绝不拒绝、绝不裁切或拉伸;小帧则放大贴合。每帧在自己的格子里居中,未被覆盖的像素保持透明。

Cell size decides how many pixels each frame may occupy. Auto cell size takes the largest frame width/height and then cuts it down to what the size cap and the texel budget allow; a manual cell is tighter. A frame larger than its cell is downscaled to fit — never refused, clipped or stretched — while a smaller frame is upscaled. Each frame is centred in its cell and uncovered pixels stay transparent.

列数与行数决定格子的排列:列数由自动公式或手动值给出,行数 = ⌈总帧数 / 列数⌉,所以最后一行可以不满。开启 Power of Two 时,格子宽高、列数、行数都会先向上取 2 的幂,图集宽高随之为 2 的幂;未被使用的格子保持透明。关闭时不做向上取整,图集宽高就是列数 × 格子宽与行数 × 格子高,通常不是 2 的幂。

Columns and rows decide the cell arrangement: columns come from the auto formula or a manual value, and rows = ⌈total frames / columns⌉, so the last row may be partial. With Power of Two on, cell width/height, columns and rows are each snapped up to a power of two first, which makes the atlas width/height powers of two as well; unused cells stay transparent. With it off, no rounding up is applied: the atlas width/height are columns × cell width and rows × cell height, usually not powers of two.

尺寸上限与纹素预算一起压低格子,而不是否决整次烘焙:逐轴格子取「请求尺寸」与「MaxAtlasSize 按该轴格数摊分」的较小值;若宽 × 高仍超过 AtlasTexelBudget / 格数,两轴再按同一倍率缩小(保持比例),帧随后重采样进这个更小的格子。只有缩小之后仍装不下的两种网格才会让布局失败:格子到 1 像素仍超出 MaxAtlasSize 的网格,以及每格 1×1 都装不进预算的网格。

The size cap and the texel budget cut the cell down together rather than vetoing the bake: per axis, the cell is the smaller of the requested size and MaxAtlasSize divided by that axis' grid extent; if width × height still exceeds AtlasTexelBudget / cells, both axes shrink by one common factor (aspect preserved), and the frames are then resampled into that smaller cell. Only two grids fail the layout after that downscale: one that would still exceed MaxAtlasSize at a 1-pixel cell, and one whose cells cannot fit the budget even at 1×1.

sRGB 与 Nearest Filter 只影响生成纹理的采样与压缩方式,不改变像素布局:sRGB 决定按颜色数据还是掩码数据压缩,Nearest Filter 决定点采样还是默认过滤。图集始终不生成 mipmap。输出名称与路径由调用方(Creator)解析后传给烘焙,决定资产落在哪里;同一标识重烘是原位更新,已有引用不断开。

sRGB and Nearest Filter affect only how the generated texture is sampled and compressed, not the pixel layout: sRGB selects color-data versus mask-data compression, and Nearest Filter selects point sampling or default filtering. The atlas never generates mipmaps. The output name and path are resolved by the caller (the creator) and passed into the bake; re-baking under the same identity updates the asset in place, so existing references are not broken.

管线角色Pipeline Role

本对象由 SMassBattleSpritePrepPanel 在构造时创建,生命周期与窗口一致;参数在详情视图里编辑,输出标识(图集名与目录)归 Agent Creator 的 0.RenderProfile 类别——New / Save 需要的词干与路径由调用方解析后传入(选中的版本行 → Creator 的 AssetName / GeneratePath → 绑定 ATA 的名字 / 目录 → 默认值),本状态既不保存也不回写它们。点击 Apply to Creator 时,面板只把所绑定的 ATA 交给 Creator 状态,不写任何名字或路径。关闭窗口后本对象不保留,下次打开会重新创建。

This object is created by SMassBattleSpritePrepPanel at construction and lives as long as the window; its parameters are edited in a details view, while the output identity (atlas name + folder) belongs to the Agent Creator's 0.RenderProfile category — the stem and path New / Save need are resolved by the caller and passed in (selected version row → creator's AssetName / GeneratePath → bound ATA's name / folder → defaults), and this state neither stores nor writes them. On Apply to Creator the panel hands over the bound ATA only and writes no name or path. The object is not retained after the window closes; reopening creates a new one.

补充说明Notes

① SpriteAnims 是八个固定桶,每桶最多八个变体:桶的位置就是运行时桶,变体下标就是槽号,填不出非法轨道。② 载入 ATA 是整份替换作者桶,绝不与现有内容合并。③ 保存把八个桶拍平成 ATA 的轨道数组(桶下标 → Bucket,变体下标 → SlotIndex),写入布局参数并重算布局;空变体不产出轨道。④ 未绑定资产时 Save 先新建一个全新、自动加后缀的 ATA_<AtlasStem>,绝不接管已存在的资产——输出标识归调用方(Agent Creator),本状态只借用。⑤ 详情视图过滤掉 SpriteAnims、CreatorState、Log 与 Asset:它们由面板自己的 UI 承载。⑥ Apply 只把所绑定的 ATA 交给 Creator 状态并在那边写一条摘要日志,绝不回写名字或路径。

① SpriteAnims is eight fixed buckets, each holding up to eight variants: the bucket position IS the runtime bucket and the variant index IS the slot, so an impossible track cannot be authored. ② Loading an ATA REPLACES the authored buckets outright — it never merges into them. ③ Save flattens the eight buckets into the ATA's track array (bucket index → Bucket, variant index → SlotIndex), writes the layout parameters and re-applies the layout; an empty variant emits no track. ④ With nothing bound, Save first creates a fresh, auto-suffixed ATA_<AtlasStem> and never takes over an existing asset — the output identity belongs to the caller (the Agent Creator), and this state only borrows it. ⑤ The details view filters out SpriteAnims, CreatorState, Log and Asset; the panel's own UI carries them. ⑥ Apply only hands the bound ATA to the creator state and logs an applied summary there; it never writes a name or path back.