MassBattleRagdollTable.h
Source/MassBattle/Public/Ragdoll/MassBattleRagdollTable.h
概述Overview
一个单位的烘焙布娃娃表:刚体表、关节表、逐骨的刚体归属,以及供查询期一次性摆姿使用的逐帧姿态镜像。这些表由烘焙从源网格的物理资产产出,供 GPU 布娃娃与骨骼查询消费;它们是烘焙产物,每次 Generate 都会重写,详情面板里只供查看,不能手改。作者可调的部分都在别处:Agent 配置 Bone Shared → Ragdoll 块里的三个参数(寿命、刚体阻尼、初速),以及 notify 表里决定何时启动的一行 Ragdoll 动作——后者只在实体处于死亡过程中生效。
A unit's baked ragdoll tables: the body table, the joint table, per-bone body ownership, and a per-frame pose mirror used for query-time one-shot posing. The bake produces them from the source mesh's physics asset, and the GPU ragdoll pass and bone queries consume them; they are bake output, rewritten on every Generate and read-only in the Details panel. Everything an author can tune lives elsewhere: the three parameters in the Agent config's Bone Shared → Ragdoll block (lifetime, body damping, launch speed), and the Ragdoll action row in the notify table that decides when the ragdoll starts — the latter only takes effect while the agent is dying.
FRagdollBodyDef USTRUCT
一个刚体(一组骨骼的代理形状)。每个刚体记录它属于哪根骨、形状种类与尺寸、质量与惯量,以及它与其它刚体的禁碰关系与模拟/碰撞开关。
One rigid body — a proxy shape for a group of bones. Each body records the bone it belongs to, its shape kind and size, its mass and inertia, plus the collision-exclusion relation with other bodies and its simulation/collision switches.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
BoneShapeMaskFlags | FVector4f | — | 刚体身份与过滤:所属骨下标、形状种类、与其它刚体的禁碰掩码,以及是否参与模拟、是否参与碰撞。由烘焙写入。Body identity and filtering: the owning bone index, the shape kind, the exclusion mask against other bodies, and whether it simulates and collides. Written by the bake. |
ShapeCenterRadius | FVector4f | — | 形状在骨骼空间里的中心,以及代理半径。由烘焙写入。Shape centre in bone space, plus the proxy radius. Written by the bake. |
HalfLengthExtentX | FVector4f | — | 胶囊线段半长;盒沿三轴的全尺寸。由烘焙写入。Capsule segment half length; the box's full size along each axis. Written by the bake. |
ShapeRot | FVector4f | — | 形状在骨骼空间里的旋转四元数。由烘焙写入。The shape's rotation quaternion in bone space. Written by the bake. |
MassInvMass | FVector4f | — | 质量(kg)与其倒数。由烘焙写入。Mass in kg and its reciprocal. Written by the bake. |
InvInertiaRow0 | FVector4f | — | 逆惯量张量第一行,骨骼轴、绕骨原点。由烘焙写入。First row of the inverse inertia tensor, in bone axes about the bone origin. Written by the bake. |
InvInertiaRow1 | FVector4f | — | 逆惯量张量第二行。由烘焙写入。Second row of the inverse inertia tensor. Written by the bake. |
InvInertiaRow2 | FVector4f | — | 逆惯量张量第三行。由烘焙写入。Third row of the inverse inertia tensor. Written by the bake. |
Pad | FVector4f | — | 未使用的填充。Unused padding. |
FRagdollJointDef USTRUCT
两个刚体之间的关节。ConstraintBone1 是子体、ConstraintBone2 是父体;两个锚点与两个坐标系都写在各自刚体的骨骼空间里,旋转限位用弧度。
A joint between two bodies. ConstraintBone1 is the child and ConstraintBone2 the parent; both anchors and both frames are written in their own body's bone space, and rotation limits are in radians.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
ChildParent | FVector4f | — | 子刚体索引与父刚体索引。由烘焙写入。Child body index and parent body index. Written by the bake. |
Pos1 | FVector4f | — | 关节锚点,位于子刚体的骨骼空间。由烘焙写入。Joint anchor in the child body's bone space. Written by the bake. |
Frame1 | FVector4f | — | 关节坐标系,位于子刚体的骨骼空间。由烘焙写入。Joint frame in the child body's bone space. Written by the bake. |
Pos2 | FVector4f | — | 关节锚点,位于父刚体的骨骼空间。由烘焙写入。Joint anchor in the parent body's bone space. Written by the bake. |
Frame2 | FVector4f | — | 关节坐标系,位于父刚体的骨骼空间。由烘焙写入。Joint frame in the parent body's bone space. Written by the bake. |
Limits | FVector4f | — | 摆动1、摆动2 与扭转三个限位(弧度),以及三种运动模式——每轴可为自由、受限或锁定。由烘焙写入。The swing-1, swing-2 and twist limits in radians, plus the three motion modes — each axis is free, limited or locked. Written by the bake. |
FRagdollBakeData USTRUCT
单个单位的整份布娃娃烘焙——刚体、关节与逐骨归属。所有刚体索引都是裁剪后的下标(最多 32 个刚体),BoneOwner 绝不留空:查不到归属的骨骼折到 0 号刚体。
One unit's whole ragdoll bake — bodies, joints and per-bone ownership. Every body index is post-cap (at most 32 bodies), and BoneOwner never holds an unset entry: an unknown bone is folded onto body 0.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Bodies | TArray<FRagdollBodyDef> | 空empty | 烘出的刚体。源物理资产超过 32 个刚体时,烘出的列表按质量从大到小排列。Baked bodies. When the source physics asset has more than 32, the baked list is mass-descending. |
Joints | TArray<FRagdollJointDef> | 空empty | 存活刚体之间的关节。Joints between the surviving bodies. |
BoneOwner | TArray<uint32> | 空empty | 逐骨所属的刚体索引,按网格参考骨架的顺序;查不到归属的骨折到 0 号刚体。Owning body index per bone in mesh reference-skeleton order; unknown bones are folded onto body 0. |
bBaked | bool | false | 只有物理资产至少提供了一个刚体时才为 true。为 false 表示这个单位没有可用的布娃娃。True only when a physics asset supplied at least one body. False means this unit has no usable ragdoll. |
FRagdollPoseTable USTRUCT
烘焙出的逐帧分量空间骨骼姿势的 CPU 镜像,源网格物理资产里每根拥有刚体的骨占一个槽。它只为查询期的一次性摆姿存在:运行时不做逐帧更新,GPU 仍消费骨骼纹理。查询接口(MassBattleBoneQuery.h)就是它的消费方。
A CPU mirror of the baked per-frame component-space bone pose, one slot per bone that owns a body in the source mesh's physics asset. It exists for query-time one-shot posing only: the runtime never updates it per frame, and the GPU keeps consuming the bone textures. The query interface (MassBattleBoneQuery.h) is its consumer.
成员变量Members
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
BoneIndices | TArray<int32> | 空empty | 物理资产刚体骨的网格参考骨架下标,升序且唯一。按骨骼下标查槽依赖这个顺序。Mesh reference-skeleton indices of the physics-asset body bones, ascending and unique. Looking a slot up by bone index relies on that order. |
BoneNames | TArray<FName> | 空empty | 与 BoneIndices 平行的骨骼名,让查询结果无需加载骨架就能说出骨名。Bone names parallel to BoneIndices, so a query result can name the bone without loading a skeleton. |
PosScale | TArray<FVector4f> | 空empty | 逐帧、逐骨的姿势位置与统一缩放。体量数据,详情面板不显示——一个单位有数万条,为它们建树会让编辑器卡死。Per-frame, per-bone pose position and uniform scale. Bulk data deliberately kept out of the Details panel: one unit holds tens of thousands of entries and a tree over them would freeze the editor. |
Rotations | TArray<FVector4f> | 空empty | 与 PosScale 同下标的逐帧、逐骨旋转。同样不进详情面板。Per-frame, per-bone rotations indexed like PosScale. Also kept out of the Details panel. |
NumFrames | int32 | 0 | 烘焙帧数;0 表示这张表从未被填过。Number of baked frames; 0 means the table was never filled. |
方法Methods
本表覆盖的骨骼槽数,即 BoneIndices 的长度。
Number of bone slots this table covers — the length of BoneIndices.
Input
无参数。
No parameters.
Output
返回骨骼槽数;无副作用。
Returns the bone-slot count; no side effects.
只有可以直接索引的表才为真:帧与骨都存在,且两个姿势数组恰好每个(帧, 骨)对有一条。用它决定是否还能查这张表。
True only for a table a consumer may index: frames and bones exist, and both pose arrays hold exactly one entry per (frame, bone) pair. Use it to decide whether this table is still queryable.
Input
无参数。
No parameters.
Output
返回是否可索引;无副作用。
Returns whether the table is indexable; no side effects.
按网格骨骼下标找本表的槽号(在升序的 BoneIndices 上查找)。
Finds this table's slot for a mesh bone index (looks it up in the ascending BoneIndices).
Input
| 参数Param | 类型Type | 说明Description |
|---|---|---|
BoneIndex | const int32 | 网格参考骨架里的骨骼下标。Bone index in the mesh reference skeleton. |
Output
返回槽号;本表没有这根骨的姿势时返回 INDEX_NONE。无副作用。
Returns the slot, or INDEX_NONE when this table has no pose for that bone. No side effects.
清空这张表:下标、骨名、两个姿势数组与帧数都归零。下一次烘焙重新填入。
Empties the table: indices, bone names, both pose arrays and the frame count all reset. The next bake refills them.
Input
无参数。
No parameters.
Output
无返回值。副作用:整张表清空。
No return value. Side effect: the whole table is cleared.