1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Ported from UnityPy 1.25.2 (MIT): UnityPy/helpers/MeshHelper.py's MeshHandler, UnityPy/helpers/PackedBitVector.py and UnityPyBoost/Mesh.cpp's unpack_vertexdata, the vertex-data unpack sprites and meshes share. See THIRD_PARTY_LICENSES.
//! A Mesh's or a sprite's vertex arrays, index buffer and triangles, as
//! UnityPy 1.25.2's `MeshHandler` gives them (`docs/plans/extract.md` E16;
//! `PARITY.md` section 15.3's rows marked P1b): the same values, the same
//! types (`float` as `f64`, `int`), and the same exceptions where it
//! raises.
//!
//! - [`Source`]: what the handler reads, a Mesh object's value or a
//! Sprite's render data, from the core's typetree read, viewed as
//! UnityPy's object mode builds it ([`unityrs_core::objmode`]).
//! - [`MeshHandler::process`]: the channels and streams by version, a
//! Mesh's `m_StreamData` through [`Resources`], the index size and
//! buffer, and each channel's data, through the three `VertexFormat`
//! tables ([`get_channel_dtype`]) and UnityPyBoost's strided gather
//! ([`unpack_vertexdata`]), into a [`Processed`].
//! A Mesh's `CompressedMesh` is unpacked (`PackedBitVector`'s
//! `unpack_ints` and `unpack_floats`, then `decompress_compressed_mesh`)
//! with UnityPy's two Tier C errors there corrected (`compressed`'s
//! module docs).
//! - [`Processed::get_triangles`]: each submesh's triangles, for triangle
//! lists, strips and quads, with UnityPy's errors for the rest.
//!
//! **What is not here** (`docs/plans/extract.md` E16). A Mesh's own vertex
//! arrays and a sprite's own `vertices`, which no version's typetree holds
//! beside `m_VertexData`, are P4's (docs/plans/static3d.md, decision 2); below Unity 4, `get_channels`'
//! fixed layout is P4. Each is [`MeshError::Unsupported`], returned where
//! UnityPy would begin it, so every failure before it is UnityPy's.
//!
//! **Divergences** (`PARITY.md` sections 15.3, 19.1 and 19.3): a compressed
//! mesh's third and later UV channels read from where the ones before end,
//! a skin's fourth weight in 31sts, and a Mesh's `UNorm`, `SNorm` and byte
//! colour channels normalised to `float`s (its blend indices, and a
//! Sprite's channels, kept as UnityPy's integers), where UnityPy errs
//! (Tier C); a
//! packed item wider than 32 bits is [`MeshError::Malformed`]; an array or a
//! loop past the caller's meter is [`MeshError::Charge`]; a gather whose
//! 32-bit offsets wrap past UnityPyBoost's check, where UnityPy reads or
//! writes out of bounds, is [`MeshError::WrappedAccess`]; a field of a type
//! or range no version's typetree gives it, or a class node of another
//! type, is [`MeshError::Malformed`]; and the core's resource read reports
//! its own errors ([`MeshError::Resource`]). The handler changes nothing it
//! reads: UnityPy's `process` sets a streamed Mesh's `m_DataSize` and leaves
//! its results on the handler for a second call to read, and its
//! `get_triangles` rewrites a strip's `indexCount`, which
//! [`SubMeshTriangles::index_count`] returns instead; so each call here
//! gives the first's answer.
//!
//! **No panics, bounded work** (`docs/plans/core.md` section 3.15): indexing,
//! `unwrap` and the like are denied outside tests; offsets are computed as
//! UnityPyBoost computes them, in wrapping `u32`s, and checked. Every array
//! sized by the input (the values, the index buffer, the triangles, the
//! derived streams) is charged to the caller's meter, at its element count,
//! before it is allocated, and a message echoes at most 64 bytes of a type
//! name. Every loop's work is counted on the meter before the loop runs, and
//! after the charge that loop's output needs, so a refused charge counts no
//! work: a unit per byte or element of output, per channel (those skipped
//! included), per submesh, and for every name a scan of a class's fields may
//! compare, counted before it, so the work is in proportion to the input or
//! the output.
//! `tests/oracle.rs` replays what the oracle recorded
//! (`tools/fixtures/meshdecode.py`); `tests/limits.rs` runs each recorded
//! case under smaller meters and work bounds, and with its bytes changed;
//! `tests/charges.rs` counts the allocations each case makes against its
//! charges; and `tests/work.rs` measures the work against the channels,
//! submeshes and fields read.
// No panics on a mesh's contents (plan section 3.15). Tests may opt out.
pub use ;
pub use ;
pub use ;
pub use ProcessedOwned;
pub use ;
pub use ;
pub use Version;
/// Asserts at compile time that `T` is `Send + Sync` (plan section 3.16).
pub const Sized>