ueagentdevkit 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Tools/AssetInspector/godot_pck.py +293 -0
- Tools/Capture/ViewportCapture/Source/ViewportCapture/Private/ViewportFrames.cpp +78 -0
- Tools/Capture/ViewportCapture/Source/ViewportCapture/Public/ViewportFrames.h +12 -0
- Tools/Capture/ViewportCapture/Source/ViewportCapture/ViewportCapture.Build.cs +6 -0
- Tools/Capture/ViewportCapture/ViewportCapture.uplugin +1 -0
- Tools/Capture/session.py +83 -0
- Tools/Hygiene/recovery.py +32 -13
- Tools/TestHost/AgentDevTestHost.uproject +16 -0
- Tools/TestHost/MovementFixture.py +32 -0
- Tools/TestHost/PIEInputSequence.json +42 -0
- Tools/TestHost/PIEMovement.json +9 -0
- Tools/TestHost/Source/AgentDevTestHost/AgentDevTestHost.Build.cs +9 -0
- Tools/TestHost/Source/AgentDevTestHost/DevKitViewport.cpp +30 -0
- Tools/TestHost/Source/AgentDevTestHost/DevKitViewport.h +13 -0
- Tools/TestHost/Source/AgentDevTestHost/Observation.cpp +27 -0
- Tools/TestHost/Source/AgentDevTestHostEditor.Target.cs +12 -0
- Tools/TestHost/UAPSmoke.py +122 -0
- Tools/compare_behavior.py +35 -0
- Tools/connect_editor.py +430 -0
- Tools/environment.py +6 -2
- Tools/make_pie_lab.py +44 -0
- Tools/mcp_readback.py +59 -0
- Tools/media.py +59 -0
- Tools/mux.py +145 -0
- Tools/optional_diagnostics.py +69 -0
- Tools/pie_behavior.py +196 -0
- Tools/provider/capabilities.json +537 -0
- Tools/provider/scripts/connect.py +288 -0
- Tools/provider/scripts/discover.py +257 -0
- Tools/provider/scripts/enable_plugins.py +249 -0
- Tools/provider/scripts/launch_editor.py +257 -0
- Tools/provider/scripts/pinwright_calls.py +100 -0
- Tools/provider/scripts/probe.py +108 -0
- Tools/provider/scripts/register_client.py +366 -0
- Tools/provider/scripts/routing.py +141 -0
- Tools/provider/scripts/run_bridge.py +14 -0
- Tools/record.py +93 -0
- Tools/setup.py +97 -0
- Tools/timeline.py +114 -0
- Tools/uap_lab.py +137 -0
- Tools/umg_readback.py +70 -0
- ueagent.py +27 -16
- ueagentdevkit-0.3.0.data/data/Scripts/Connect-UE.cmd +10 -0
- ueagentdevkit-0.3.0.data/data/Scripts/Connect-UE.ps1 +19 -0
- ueagentdevkit-0.3.0.data/data/Scripts/Install-Shortcut.ps1 +11 -0
- ueagentdevkit-0.3.0.data/data/Scripts/Test-Play.cmd +10 -0
- ueagentdevkit-0.3.0.data/data/share/ueagentdevkit/skills/ue-automation-evidence/SKILL.md +10 -0
- ueagentdevkit-0.3.0.data/data/share/ueagentdevkit/skills/ue-editor-connection/SKILL.md +8 -0
- ueagentdevkit-0.3.0.data/data/share/ueagentdevkit/skills/ue-project-hygiene/SKILL.md +8 -0
- ueagentdevkit-0.3.0.dist-info/METADATA +61 -0
- ueagentdevkit-0.3.0.dist-info/RECORD +66 -0
- ueagentdevkit-0.3.0.dist-info/licenses/LICENSE +21 -0
- ueagentdevkit-0.2.0.dist-info/METADATA +0 -14
- ueagentdevkit-0.2.0.dist-info/RECORD +0 -19
- {ueagentdevkit-0.2.0.data/data/share/ueagentdevkit/association → Tools/provider}/LICENSE +0 -0
- {ueagentdevkit-0.2.0.dist-info/licenses → ueagentdevkit-0.3.0.data/data/share/ueagentdevkit/association}/LICENSE +0 -0
- {ueagentdevkit-0.2.0.data → ueagentdevkit-0.3.0.data}/data/share/ueagentdevkit/association/Repair-UnrealAssociation.ps1 +0 -0
- {ueagentdevkit-0.2.0.data → ueagentdevkit-0.3.0.data}/data/share/ueagentdevkit/association/Start-Doctor.ps1 +0 -0
- {ueagentdevkit-0.2.0.dist-info → ueagentdevkit-0.3.0.dist-info}/WHEEL +0 -0
- {ueagentdevkit-0.2.0.dist-info → ueagentdevkit-0.3.0.dist-info}/entry_points.txt +0 -0
- {ueagentdevkit-0.2.0.dist-info → ueagentdevkit-0.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"""Generic read-only Godot PCK (v2/v3/v4) indexer and selective extractor.
|
|
2
|
+
|
|
3
|
+
Strictly read-only on source .pck files. Enforces path-traversal guards,
|
|
4
|
+
extraction byte budgets, and records SHA-256 digests for every read or
|
|
5
|
+
extracted entry. Contains zero game-specific hardcoding.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
from collections import Counter
|
|
11
|
+
from dataclasses import asdict, dataclass
|
|
12
|
+
import hashlib
|
|
13
|
+
import json
|
|
14
|
+
import os
|
|
15
|
+
from pathlib import Path, PurePosixPath
|
|
16
|
+
import struct
|
|
17
|
+
import sys
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
PCK_MAGIC = b"GDPC"
|
|
22
|
+
FLAG_DIR_ENCRYPTED = 1 << 0
|
|
23
|
+
FLAG_REL_FILEBASE = 1 << 1
|
|
24
|
+
ENTRY_FLAG_ENCRYPTED = 1 << 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class PckEntry:
|
|
29
|
+
path: str
|
|
30
|
+
offset: int
|
|
31
|
+
size: int
|
|
32
|
+
md5: str
|
|
33
|
+
flags: int
|
|
34
|
+
encrypted: bool
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(frozen=True)
|
|
38
|
+
class PckHeader:
|
|
39
|
+
format_version: int
|
|
40
|
+
engine_major: int
|
|
41
|
+
engine_minor: int
|
|
42
|
+
engine_patch: int
|
|
43
|
+
flags: int
|
|
44
|
+
dir_encrypted: bool
|
|
45
|
+
file_base: int
|
|
46
|
+
dir_offset: int
|
|
47
|
+
file_size: int
|
|
48
|
+
file_count: int
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _sanitize_rel_path(logical_path: str) -> PurePosixPath:
|
|
52
|
+
"""Reject absolute paths, drive prefixes, and '..' traversal segments."""
|
|
53
|
+
clean = logical_path
|
|
54
|
+
if clean.startswith("res://"):
|
|
55
|
+
clean = clean[len("res://") :]
|
|
56
|
+
clean = clean.replace("\\", "/").lstrip("/")
|
|
57
|
+
if not clean or ":" in clean.split("/")[0]:
|
|
58
|
+
raise ValueError(f"Unsafe or empty logical path: {logical_path!r}")
|
|
59
|
+
rel = PurePosixPath(clean)
|
|
60
|
+
if rel.is_absolute() or ".." in rel.parts:
|
|
61
|
+
raise ValueError(f"Path traversal rejected: {logical_path!r}")
|
|
62
|
+
return rel
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def inspect_pck(pck_path: Path) -> tuple[PckHeader, list[PckEntry]]:
|
|
66
|
+
"""Read only the header and directory table of a Godot PCK v2/v3/v4 file."""
|
|
67
|
+
pck_path = Path(pck_path).resolve(strict=True)
|
|
68
|
+
file_size = pck_path.stat().st_size
|
|
69
|
+
if file_size < 100:
|
|
70
|
+
raise ValueError(f"File too small to be a valid Godot PCK: {file_size} bytes")
|
|
71
|
+
|
|
72
|
+
with pck_path.open("rb") as stream:
|
|
73
|
+
hdr = stream.read(128)
|
|
74
|
+
if hdr[:4] != PCK_MAGIC:
|
|
75
|
+
raise ValueError(f"Invalid PCK magic: {hdr[:4]!r} (expected {PCK_MAGIC!r})")
|
|
76
|
+
|
|
77
|
+
fmt_ver, maj, min_, patch, flags = struct.unpack("<IIIII", hdr[4:24])
|
|
78
|
+
dir_encrypted = bool(flags & FLAG_DIR_ENCRYPTED)
|
|
79
|
+
if dir_encrypted:
|
|
80
|
+
raise ValueError("PCK directory is encrypted; refusing to decrypt or bypass.")
|
|
81
|
+
|
|
82
|
+
if fmt_ver == 2:
|
|
83
|
+
file_base = struct.unpack("<Q", hdr[24:32])[0]
|
|
84
|
+
dir_offset = 96
|
|
85
|
+
elif fmt_ver >= 3:
|
|
86
|
+
file_base, dir_offset = struct.unpack("<QQ", hdr[24:40])
|
|
87
|
+
if dir_offset == 0 or dir_offset >= file_size:
|
|
88
|
+
dir_offset = 104
|
|
89
|
+
else:
|
|
90
|
+
raise ValueError(f"Unsupported PCK format version: {fmt_ver}")
|
|
91
|
+
|
|
92
|
+
stream.seek(dir_offset)
|
|
93
|
+
raw_count = stream.read(4)
|
|
94
|
+
if len(raw_count) < 4:
|
|
95
|
+
raise ValueError("Unexpected EOF reading PCK file_count")
|
|
96
|
+
file_count = struct.unpack("<I", raw_count)[0]
|
|
97
|
+
|
|
98
|
+
entries: list[PckEntry] = []
|
|
99
|
+
for idx in range(file_count):
|
|
100
|
+
raw_slen = stream.read(4)
|
|
101
|
+
if len(raw_slen) < 4:
|
|
102
|
+
raise ValueError(f"Unexpected EOF at entry {idx}")
|
|
103
|
+
slen = struct.unpack("<I", raw_slen)[0]
|
|
104
|
+
if slen == 0 or slen > 4096:
|
|
105
|
+
raise ValueError(f"Invalid path length {slen} at entry {idx}")
|
|
106
|
+
raw_path = stream.read(slen)
|
|
107
|
+
if len(raw_path) < slen:
|
|
108
|
+
raise ValueError(f"Unexpected EOF reading path at entry {idx}")
|
|
109
|
+
path = raw_path.rstrip(b"\x00").decode("utf-8", errors="replace")
|
|
110
|
+
|
|
111
|
+
meta = stream.read(36)
|
|
112
|
+
if len(meta) < 36:
|
|
113
|
+
raise ValueError(f"Unexpected EOF reading metadata at entry {idx}")
|
|
114
|
+
rel_off, size = struct.unpack("<QQ", meta[:16])
|
|
115
|
+
md5_hex = meta[16:32].hex()
|
|
116
|
+
eflags = struct.unpack("<I", meta[32:36])[0]
|
|
117
|
+
abs_off = (file_base + rel_off) if (flags & FLAG_REL_FILEBASE or fmt_ver >= 2) else rel_off
|
|
118
|
+
if abs_off + size > file_size:
|
|
119
|
+
raise ValueError(f"Entry {path!r} exceeds PCK size ({abs_off}+{size} > {file_size})")
|
|
120
|
+
|
|
121
|
+
entries.append(
|
|
122
|
+
PckEntry(
|
|
123
|
+
path=path,
|
|
124
|
+
offset=abs_off,
|
|
125
|
+
size=size,
|
|
126
|
+
md5=md5_hex,
|
|
127
|
+
flags=eflags,
|
|
128
|
+
encrypted=bool(eflags & ENTRY_FLAG_ENCRYPTED),
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
header = PckHeader(
|
|
133
|
+
format_version=fmt_ver,
|
|
134
|
+
engine_major=maj,
|
|
135
|
+
engine_minor=min_,
|
|
136
|
+
engine_patch=patch,
|
|
137
|
+
flags=flags,
|
|
138
|
+
dir_encrypted=dir_encrypted,
|
|
139
|
+
file_base=file_base,
|
|
140
|
+
dir_offset=dir_offset,
|
|
141
|
+
file_size=file_size,
|
|
142
|
+
file_count=len(entries),
|
|
143
|
+
)
|
|
144
|
+
return header, entries
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def summarize_pck(pck_path: Path) -> dict[str, Any]:
|
|
148
|
+
"""Build a JSON-serializable audit summary without extracting any files."""
|
|
149
|
+
header, entries = inspect_pck(pck_path)
|
|
150
|
+
ext_counts: Counter[str] = Counter()
|
|
151
|
+
ext_bytes: Counter[str] = Counter()
|
|
152
|
+
dir_counts: Counter[str] = Counter()
|
|
153
|
+
dir_bytes: Counter[str] = Counter()
|
|
154
|
+
encrypted_count = 0
|
|
155
|
+
|
|
156
|
+
for e in entries:
|
|
157
|
+
if e.encrypted:
|
|
158
|
+
encrypted_count += 1
|
|
159
|
+
clean = e.path[6:] if e.path.startswith("res://") else e.path
|
|
160
|
+
parts = clean.split("/")
|
|
161
|
+
top = parts[0] if len(parts) > 1 else "<root>"
|
|
162
|
+
ext = os.path.splitext(clean)[1].lower() or "<noext>"
|
|
163
|
+
ext_counts[ext] += 1
|
|
164
|
+
ext_bytes[ext] += e.size
|
|
165
|
+
dir_counts[top] += 1
|
|
166
|
+
dir_bytes[top] += e.size
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
"pck": str(Path(pck_path).resolve()),
|
|
170
|
+
"header": asdict(header),
|
|
171
|
+
"encrypted_entries": encrypted_count,
|
|
172
|
+
"extensions": [
|
|
173
|
+
{"ext": ext, "count": cnt, "bytes": ext_bytes[ext]}
|
|
174
|
+
for ext, cnt in ext_counts.most_common()
|
|
175
|
+
],
|
|
176
|
+
"top_directories": [
|
|
177
|
+
{"dir": d, "count": cnt, "bytes": dir_bytes[d]}
|
|
178
|
+
for d, cnt in dir_counts.most_common()
|
|
179
|
+
],
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def read_entry_bytes(pck_path: Path, logical_path: str, max_bytes: int = 32 * 1024 * 1024) -> tuple[bytes, str]:
|
|
184
|
+
"""Read one unencrypted entry into memory with a size cap and return (bytes, sha256)."""
|
|
185
|
+
_, entries = inspect_pck(pck_path)
|
|
186
|
+
target = logical_path[6:] if logical_path.startswith("res://") else logical_path
|
|
187
|
+
match = next((e for e in entries if e.path == logical_path or e.path == target or e.path == f"res://{target}"), None)
|
|
188
|
+
if match is None:
|
|
189
|
+
raise KeyError(f"Entry not found in PCK: {logical_path!r}")
|
|
190
|
+
if match.encrypted:
|
|
191
|
+
raise ValueError(f"Entry is encrypted: {logical_path!r}")
|
|
192
|
+
if match.size > max_bytes:
|
|
193
|
+
raise ValueError(f"Entry size {match.size} exceeds max_bytes budget {max_bytes}")
|
|
194
|
+
|
|
195
|
+
with Path(pck_path).open("rb") as stream:
|
|
196
|
+
stream.seek(match.offset)
|
|
197
|
+
data = stream.read(match.size)
|
|
198
|
+
return data, hashlib.sha256(data).hexdigest()
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def extract_entries(
|
|
202
|
+
pck_path: Path,
|
|
203
|
+
logical_paths: list[str],
|
|
204
|
+
output_dir: Path,
|
|
205
|
+
max_total_bytes: int = 64 * 1024 * 1024,
|
|
206
|
+
) -> list[dict[str, Any]]:
|
|
207
|
+
"""Selectively extract specific entries under a strict byte budget and path guard."""
|
|
208
|
+
_, entries = inspect_pck(pck_path)
|
|
209
|
+
by_clean = {(e.path[6:] if e.path.startswith("res://") else e.path): e for e in entries}
|
|
210
|
+
|
|
211
|
+
selected: list[tuple[PckEntry, PurePosixPath]] = []
|
|
212
|
+
total_bytes = 0
|
|
213
|
+
for req in logical_paths:
|
|
214
|
+
rel = _sanitize_rel_path(req)
|
|
215
|
+
key = rel.as_posix()
|
|
216
|
+
entry = by_clean.get(key)
|
|
217
|
+
if entry is None:
|
|
218
|
+
raise KeyError(f"Entry not found in PCK: {req!r}")
|
|
219
|
+
if entry.encrypted:
|
|
220
|
+
raise ValueError(f"Refusing to extract encrypted entry: {req!r}")
|
|
221
|
+
total_bytes += entry.size
|
|
222
|
+
if total_bytes > max_total_bytes:
|
|
223
|
+
raise ValueError(f"Total extraction size {total_bytes} exceeds budget {max_total_bytes}")
|
|
224
|
+
selected.append((entry, rel))
|
|
225
|
+
|
|
226
|
+
out_root = Path(output_dir).resolve()
|
|
227
|
+
out_root.mkdir(parents=True, exist_ok=True)
|
|
228
|
+
receipts: list[dict[str, Any]] = []
|
|
229
|
+
|
|
230
|
+
with Path(pck_path).open("rb") as stream:
|
|
231
|
+
for entry, rel in selected:
|
|
232
|
+
dest = (out_root / Path(*rel.parts)).resolve()
|
|
233
|
+
if not dest.is_relative_to(out_root):
|
|
234
|
+
raise ValueError(f"Resolved output escapes output_dir: {dest}")
|
|
235
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
236
|
+
stream.seek(entry.offset)
|
|
237
|
+
data = stream.read(entry.size)
|
|
238
|
+
dest.write_bytes(data)
|
|
239
|
+
receipts.append(
|
|
240
|
+
{
|
|
241
|
+
"logical_path": entry.path,
|
|
242
|
+
"output_path": str(dest),
|
|
243
|
+
"bytes": len(data),
|
|
244
|
+
"sha256": hashlib.sha256(data).hexdigest(),
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
return receipts
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def main(argv: list[str] | None = None) -> int:
|
|
251
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
252
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
253
|
+
|
|
254
|
+
p_sum = sub.add_parser("summary", help="Print JSON summary of a Godot PCK")
|
|
255
|
+
p_sum.add_argument("pck", type=Path)
|
|
256
|
+
|
|
257
|
+
p_ls = sub.add_parser("list", help="List entry paths matching an optional prefix or suffix")
|
|
258
|
+
p_ls.add_argument("pck", type=Path)
|
|
259
|
+
p_ls.add_argument("--prefix", default="")
|
|
260
|
+
p_ls.add_argument("--suffix", default="")
|
|
261
|
+
|
|
262
|
+
p_ext = sub.add_parser("extract", help="Selectively extract entries under a byte budget")
|
|
263
|
+
p_ext.add_argument("pck", type=Path)
|
|
264
|
+
p_ext.add_argument("--out", type=Path, required=True)
|
|
265
|
+
p_ext.add_argument("--max-mib", type=int, default=64)
|
|
266
|
+
p_ext.add_argument("paths", nargs="+")
|
|
267
|
+
|
|
268
|
+
args = parser.parse_args(argv)
|
|
269
|
+
try:
|
|
270
|
+
if args.command == "summary":
|
|
271
|
+
print(json.dumps(summarize_pck(args.pck), ensure_ascii=False, indent=2))
|
|
272
|
+
return 0
|
|
273
|
+
if args.command == "list":
|
|
274
|
+
_, entries = inspect_pck(args.pck)
|
|
275
|
+
rows = [
|
|
276
|
+
{"path": e.path, "size": e.size, "encrypted": e.encrypted}
|
|
277
|
+
for e in entries
|
|
278
|
+
if e.path.startswith(args.prefix) and e.path.endswith(args.suffix)
|
|
279
|
+
]
|
|
280
|
+
print(json.dumps({"count": len(rows), "entries": rows}, ensure_ascii=False, indent=2))
|
|
281
|
+
return 0
|
|
282
|
+
if args.command == "extract":
|
|
283
|
+
receipts = extract_entries(args.pck, args.paths, args.out, args.max_mib * 1024 * 1024)
|
|
284
|
+
print(json.dumps({"extracted": receipts}, ensure_ascii=False, indent=2))
|
|
285
|
+
return 0
|
|
286
|
+
except (OSError, ValueError, KeyError) as exc:
|
|
287
|
+
print(json.dumps({"status": "ERROR", "error": str(exc)}, ensure_ascii=False), file=sys.stderr)
|
|
288
|
+
return 1
|
|
289
|
+
return 1
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
if __name__ == "__main__":
|
|
293
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#include "ViewportFrames.h"
|
|
2
|
+
#include "Algo/AllOf.h"
|
|
3
|
+
#include "Engine/GameViewportClient.h"
|
|
4
|
+
#include "Engine/World.h"
|
|
5
|
+
#include "FrameGrabber.h"
|
|
6
|
+
#include "HAL/FileManager.h"
|
|
7
|
+
#include "Misc/FileHelper.h"
|
|
8
|
+
#include "Misc/Paths.h"
|
|
9
|
+
#include "Modules/ModuleManager.h"
|
|
10
|
+
#include "Widgets/SViewport.h"
|
|
11
|
+
IMPLEMENT_MODULE(FDefaultModuleImpl, ViewportCapture)
|
|
12
|
+
namespace
|
|
13
|
+
{
|
|
14
|
+
struct FStamp : IFramePayload
|
|
15
|
+
{
|
|
16
|
+
double Time;
|
|
17
|
+
uint64 Frame;
|
|
18
|
+
};
|
|
19
|
+
TUniquePtr<FFrameGrabber> Grab;
|
|
20
|
+
TUniquePtr<FArchive> Raw;
|
|
21
|
+
FString GCaptureIndexText, Folder;
|
|
22
|
+
void Drain()
|
|
23
|
+
{
|
|
24
|
+
for (auto &Frame : Grab->GetCapturedFrames())
|
|
25
|
+
{
|
|
26
|
+
auto *Stamp = Frame.GetPayload<FStamp>();
|
|
27
|
+
if (!Stamp || Frame.ColorBuffer.IsEmpty())
|
|
28
|
+
continue;
|
|
29
|
+
Raw->Serialize(Frame.ColorBuffer.GetData(), Frame.ColorBuffer.Num() * sizeof(FColor));
|
|
30
|
+
GCaptureIndexText += FString::Printf(TEXT("%.6f,%llu,%d,%d\n"), Stamp->Time, Stamp->Frame,
|
|
31
|
+
Frame.BufferSize.X, Frame.BufferSize.Y);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} // namespace
|
|
35
|
+
bool UViewportFrames::BeginFrames(UWorld *World, FString Run)
|
|
36
|
+
{
|
|
37
|
+
if (Grab || !World || World->WorldType != EWorldType::PIE ||
|
|
38
|
+
(Run.IsEmpty() || Run.Len() > 32 ||
|
|
39
|
+
!Algo::AllOf(Run, [](TCHAR C) { return C >= TEXT('0') && C <= TEXT('9'); })))
|
|
40
|
+
return false;
|
|
41
|
+
auto *Client = World->GetGameViewport();
|
|
42
|
+
if (!Client || !Client->GetGameViewportWidget().IsValid())
|
|
43
|
+
return false;
|
|
44
|
+
auto View = StaticCastSharedPtr<FSceneViewport>(Client->GetGameViewportWidget()->GetViewportInterface().Pin());
|
|
45
|
+
if (!View.IsValid() || View.Get() != Client->GetGameViewport())
|
|
46
|
+
return false;
|
|
47
|
+
Folder = FPaths::ProjectSavedDir() / TEXT("LiveCapture") / Run;
|
|
48
|
+
IFileManager::Get().MakeDirectory(*Folder, true);
|
|
49
|
+
Raw.Reset(IFileManager::Get().CreateFileWriter(*(Folder / TEXT("video.bgra"))));
|
|
50
|
+
if (!Raw)
|
|
51
|
+
return false;
|
|
52
|
+
GCaptureIndexText = TEXT("time,engine_frame,width,height\n");
|
|
53
|
+
Grab = MakeUnique<FFrameGrabber>(View.ToSharedRef(), View->GetSizeXY());
|
|
54
|
+
Grab->StartCapturingFrames();
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
void UViewportFrames::TakeFrame(double WallTime)
|
|
58
|
+
{
|
|
59
|
+
if (!Grab)
|
|
60
|
+
return;
|
|
61
|
+
Drain();
|
|
62
|
+
auto Stamp = MakeShared<FStamp, ESPMode::ThreadSafe>();
|
|
63
|
+
Stamp->Time = WallTime;
|
|
64
|
+
Stamp->Frame = GFrameCounter;
|
|
65
|
+
Grab->CaptureThisFrame(Stamp);
|
|
66
|
+
}
|
|
67
|
+
void UViewportFrames::FinishFrames()
|
|
68
|
+
{
|
|
69
|
+
if (!Grab)
|
|
70
|
+
return;
|
|
71
|
+
Grab->StopCapturingFrames();
|
|
72
|
+
Grab->Shutdown();
|
|
73
|
+
Drain();
|
|
74
|
+
Grab.Reset();
|
|
75
|
+
Raw.Reset();
|
|
76
|
+
FFileHelper::SaveStringToFile(GCaptureIndexText, *(Folder / TEXT("frames.csv")),
|
|
77
|
+
FFileHelper::EEncodingOptions::ForceUTF8WithoutBOM);
|
|
78
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include "Kismet/BlueprintFunctionLibrary.h"
|
|
3
|
+
#include "ViewportFrames.generated.h"
|
|
4
|
+
UCLASS()
|
|
5
|
+
class UViewportFrames : public UBlueprintFunctionLibrary
|
|
6
|
+
{
|
|
7
|
+
GENERATED_BODY()
|
|
8
|
+
public:
|
|
9
|
+
UFUNCTION(BlueprintCallable, Category = "Test") static bool BeginFrames(UWorld *World, FString Run);
|
|
10
|
+
UFUNCTION(BlueprintCallable, Category = "Test") static void TakeFrame(double WallTime);
|
|
11
|
+
UFUNCTION(BlueprintCallable, Category = "Test") static void FinishFrames();
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
using UnrealBuildTool;
|
|
2
|
+
public class ViewportCapture : ModuleRules {
|
|
3
|
+
public ViewportCapture(ReadOnlyTargetRules Target) : base(Target) {
|
|
4
|
+
PrivateDependencyModuleNames.AddRange(new[]{"Core","CoreUObject","Engine","Slate","SlateCore","MovieSceneCapture","RHI","RenderCore"});
|
|
5
|
+
}
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"FileVersion":3,"Version":1,"VersionName":"1","FriendlyName":"ViewportCapture","Modules":[{"Name":"ViewportCapture","Type":"Editor","LoadingPhase":"Default"}]}
|
Tools/Capture/session.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""PIE viewport and master-submix capture. Load inside the editor's Python VM."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
import unreal
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Capture:
|
|
9
|
+
def __init__(self, world, destination, seconds, capture_id=None):
|
|
10
|
+
self.destination = Path(destination).resolve(strict=True)
|
|
11
|
+
self.world = world
|
|
12
|
+
self.id = capture_id or str(time.time_ns())
|
|
13
|
+
if not unreal.ViewportFrames.begin_frames(world, self.id):
|
|
14
|
+
raise RuntimeError("ViewportCapture requires a live PIE viewport")
|
|
15
|
+
self.started = time.perf_counter()
|
|
16
|
+
self.previous = -1.0
|
|
17
|
+
# Idle submixes may skip render blocks, shortening WAVs across silent passages.
|
|
18
|
+
self.auto_disable = unreal.SystemLibrary.get_console_variable_int_value("au.NeverDisableSubmixes")
|
|
19
|
+
try:
|
|
20
|
+
unreal.SystemLibrary.execute_console_command(world, "au.NeverDisableSubmixes 1")
|
|
21
|
+
unreal.AudioMixerLibrary.start_recording_output(world, seconds)
|
|
22
|
+
except Exception:
|
|
23
|
+
unreal.ViewportFrames.finish_frames()
|
|
24
|
+
self.restore_submix_setting()
|
|
25
|
+
raise
|
|
26
|
+
|
|
27
|
+
def restore_submix_setting(self):
|
|
28
|
+
if unreal.SystemLibrary.get_console_variable_int_value("au.NeverDisableSubmixes") == 1:
|
|
29
|
+
unreal.SystemLibrary.execute_console_command(self.world, f"au.NeverDisableSubmixes {self.auto_disable}")
|
|
30
|
+
|
|
31
|
+
def frame(self):
|
|
32
|
+
elapsed = time.perf_counter() - self.started
|
|
33
|
+
if elapsed - self.previous >= 1 / 30:
|
|
34
|
+
unreal.ViewportFrames.take_frame(elapsed)
|
|
35
|
+
self.previous = elapsed
|
|
36
|
+
|
|
37
|
+
def finish(self):
|
|
38
|
+
try:
|
|
39
|
+
unreal.AudioMixerLibrary.stop_recording_output(
|
|
40
|
+
self.world, unreal.AudioRecordingExportType.WAV_FILE, "game", str(self.destination)
|
|
41
|
+
)
|
|
42
|
+
finally:
|
|
43
|
+
unreal.ViewportFrames.finish_frames()
|
|
44
|
+
self.restore_submix_setting()
|
|
45
|
+
return self.id
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def record_pie(project, destination, seconds, capture_id):
|
|
49
|
+
"""Start a bounded capture in the current PIE world without taking over its lifecycle."""
|
|
50
|
+
import json
|
|
51
|
+
import traceback
|
|
52
|
+
actual = Path(unreal.Paths.convert_relative_path_to_full(unreal.Paths.get_project_file_path()))
|
|
53
|
+
if actual.resolve() != Path(project).resolve():
|
|
54
|
+
raise ValueError("Editor project changed")
|
|
55
|
+
world = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_game_world()
|
|
56
|
+
if not world or "UEDPIE_" not in world.get_path_name():
|
|
57
|
+
raise ValueError("Start PIE before recording")
|
|
58
|
+
capture = Capture(world, destination, seconds + 1, capture_id)
|
|
59
|
+
begin = unreal.GameplayStatics.get_time_seconds(world)
|
|
60
|
+
receipt = Path(destination) / "capture.json"
|
|
61
|
+
|
|
62
|
+
def tick(_delta):
|
|
63
|
+
elapsed = time.perf_counter() - capture.started
|
|
64
|
+
try:
|
|
65
|
+
capture.frame()
|
|
66
|
+
if elapsed < seconds:
|
|
67
|
+
return
|
|
68
|
+
game_seconds = unreal.GameplayStatics.get_time_seconds(world) - begin
|
|
69
|
+
capture.finish()
|
|
70
|
+
result = dict(status="PASS", wall_seconds=elapsed, game_seconds=game_seconds,
|
|
71
|
+
game_seconds_per_second=game_seconds / elapsed)
|
|
72
|
+
except Exception:
|
|
73
|
+
result = dict(status="ERROR", detail=traceback.format_exc())
|
|
74
|
+
try:
|
|
75
|
+
capture.finish()
|
|
76
|
+
except Exception:
|
|
77
|
+
pass
|
|
78
|
+
unreal.unregister_slate_post_tick_callback(handle)
|
|
79
|
+
temp = receipt.with_suffix(".tmp")
|
|
80
|
+
temp.write_text(json.dumps(result), encoding="utf8")
|
|
81
|
+
temp.replace(receipt)
|
|
82
|
+
|
|
83
|
+
handle = unreal.register_slate_post_tick_callback(tick)
|
Tools/Hygiene/recovery.py
CHANGED
|
@@ -35,11 +35,25 @@ def guarded(path):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def checked_run(run):
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
run = guarded(run)
|
|
39
|
+
if run.parent != ART / "Runs" or not re.fullmatch(r"[A-Za-z][A-Za-z0-9_]*-\d+", run.name):
|
|
40
|
+
raise ValueError("Expected an owned recording run")
|
|
41
|
+
meta = json.loads(guarded(run / "lifecycle.json").read_text(encoding="utf8"))
|
|
42
|
+
result = json.loads(guarded(run / "result.json").read_text(encoding="utf8"))
|
|
43
|
+
if "video" in result:
|
|
44
|
+
video = Path(result["video"])
|
|
45
|
+
else:
|
|
46
|
+
# Older recorders identified their output only by its digest.
|
|
47
|
+
candidates = list(run.glob("*.mp4"))
|
|
48
|
+
if len(candidates) != 1:
|
|
49
|
+
raise ValueError("Cannot identify the recording output")
|
|
50
|
+
video = Path(candidates[0].name)
|
|
51
|
+
if (meta["id"] != run.name or meta["kind"] != run.name.split("-")[0]
|
|
52
|
+
or meta["state"] != "PASS" or result["status"] != "PASS"
|
|
53
|
+
or video.name != str(video) or video.suffix.lower() != ".mp4"
|
|
54
|
+
or digest(guarded(run / video)) != result["sha256"]):
|
|
55
|
+
raise ValueError("Active, failed or unverified recording")
|
|
56
|
+
return run
|
|
43
57
|
|
|
44
58
|
|
|
45
59
|
def scratch(run, rel):
|
|
@@ -49,8 +63,8 @@ def scratch(run, rel):
|
|
|
49
63
|
relative = p.relative_to(run)
|
|
50
64
|
if any((a / ".git").exists() for a in p.parents if a.is_relative_to(run)):
|
|
51
65
|
raise ValueError("Nested Git workspace is protected")
|
|
52
|
-
|
|
53
|
-
allowed = relative ==
|
|
66
|
+
raw = Path("copy/Saved/LiveCapture") / run.name.split("-")[1] / "video.bgra"
|
|
67
|
+
allowed = relative == raw or (
|
|
54
68
|
relative.is_relative_to("copy/Intermediate/Build")
|
|
55
69
|
and p.suffix.lower() in {".pch", ".obj"}
|
|
56
70
|
)
|
|
@@ -60,12 +74,17 @@ def scratch(run, rel):
|
|
|
60
74
|
|
|
61
75
|
|
|
62
76
|
def check_git_protection(p):
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
# A tool installation normally owns an artifact directory outside Git.
|
|
78
|
+
probe = subprocess.run(["git", "-C", str(p.parent), "rev-parse", "--show-toplevel"],
|
|
79
|
+
env=dict(os.environ, LC_ALL="C"), capture_output=True)
|
|
80
|
+
if probe.returncode:
|
|
81
|
+
if b"not a git repository" in probe.stderr and not any(
|
|
82
|
+
(folder / ".git").exists() for folder in p.parents):
|
|
83
|
+
return
|
|
84
|
+
raise ValueError("Cannot establish Git ownership of recording scratch")
|
|
85
|
+
root = Path(os.fsdecode(probe.stdout.strip())).resolve()
|
|
86
|
+
if not p.is_relative_to(root):
|
|
87
|
+
raise ValueError("Git working tree identity changed")
|
|
69
88
|
name = p.relative_to(root).as_posix()
|
|
70
89
|
if git(root, "ls-files", "-z", "--", name) or not git(
|
|
71
90
|
root, "check-ignore", "--", name
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"FileVersion": 3,
|
|
3
|
+
"EngineAssociation": "5.8",
|
|
4
|
+
"Plugins": [
|
|
5
|
+
{ "Name": "ModelContextProtocol", "Enabled": true, "TargetAllowList": ["Editor"] },
|
|
6
|
+
{ "Name": "EditorToolset", "Enabled": true, "TargetAllowList": ["Editor"] },
|
|
7
|
+
{ "Name": "AndroidFileServer", "Enabled": false }
|
|
8
|
+
],
|
|
9
|
+
"Modules": [
|
|
10
|
+
{
|
|
11
|
+
"Name": "AgentDevTestHost",
|
|
12
|
+
"Type": "Editor",
|
|
13
|
+
"LoadingPhase": "Default"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Run inside the generated movement lab before PIE. Called by Tools/pie_behavior.py."""
|
|
2
|
+
import unreal
|
|
3
|
+
|
|
4
|
+
directory = "/Game/DevKitMovement"
|
|
5
|
+
assets = unreal.EditorAssetLibrary
|
|
6
|
+
tools = unreal.AssetToolsHelpers.get_asset_tools()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def blueprint(name, parent):
|
|
10
|
+
path = directory + "/" + name
|
|
11
|
+
if assets.does_asset_exist(path):
|
|
12
|
+
return assets.load_asset(path)
|
|
13
|
+
factory = unreal.BlueprintFactory()
|
|
14
|
+
factory.set_editor_property("parent_class", parent)
|
|
15
|
+
return tools.create_asset(name, directory, unreal.Blueprint, factory)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
pawn_bp = blueprint("BP_InputPawn", unreal.DefaultPawn)
|
|
19
|
+
pawn = unreal.get_default_object(pawn_bp.generated_class())
|
|
20
|
+
pawn.modify()
|
|
21
|
+
pawn.set_editor_property("add_default_movement_bindings", bindings_enabled)
|
|
22
|
+
unreal.BlueprintEditorLibrary.compile_blueprint(pawn_bp)
|
|
23
|
+
if not assets.save_loaded_asset(pawn_bp, False):
|
|
24
|
+
raise RuntimeError("Could not save test pawn")
|
|
25
|
+
mode_bp = blueprint("BP_InputMode", unreal.GameModeBase)
|
|
26
|
+
mode = unreal.get_default_object(mode_bp.generated_class())
|
|
27
|
+
mode.modify()
|
|
28
|
+
mode.set_editor_property("default_pawn_class", pawn_bp.generated_class())
|
|
29
|
+
unreal.BlueprintEditorLibrary.compile_blueprint(mode_bp)
|
|
30
|
+
if not assets.save_loaded_asset(mode_bp, False):
|
|
31
|
+
raise RuntimeError("Could not save fixture game mode")
|
|
32
|
+
print(unreal.get_default_object(pawn_bp.generated_class()).get_editor_property("add_default_movement_bindings"))
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"map": "/Engine/Maps/Templates/Template_Default",
|
|
3
|
+
"ready_timeout": 8,
|
|
4
|
+
"duration": 9,
|
|
5
|
+
"capture_interval": 0.5,
|
|
6
|
+
"min_cm": 5,
|
|
7
|
+
"steps": [
|
|
8
|
+
{
|
|
9
|
+
"op": "marker",
|
|
10
|
+
"label": "begin"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"op": "axis",
|
|
14
|
+
"key": "MouseX",
|
|
15
|
+
"value": 0.5
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"op": "down",
|
|
19
|
+
"key": "LeftMouseButton"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"op": "up",
|
|
23
|
+
"key": "LeftMouseButton"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"op": "down",
|
|
27
|
+
"key": "W"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"op": "wait",
|
|
31
|
+
"seconds": 0.7
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"op": "sample",
|
|
35
|
+
"label": "moving"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"op": "up",
|
|
39
|
+
"key": "W"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|