| … | … | @@ -331,3 +331,36 @@ func _run() -> void: |
| 331 | 331 | ids.append(String(r["id"])) |
| 332 | 332 | _ok("S9 strands tabled: no Strands / Spread / Twist row in the Shape panel", not ids.has("p.strands") |
| 333 | 333 | and not ids.has("p.spread") and not ids.has("p.twist") and ids.has("p.radius"), ids) |
| 334 | _cache_checks() |
| 335 | |
| 336 | |
| 337 | ## THE PIECES CACHE (#127): world_pieces answers from a content-keyed cache. Each input it |
| 338 | ## reads changes ALONE here, with the params left as they were (the case a key that missed |
| 339 | ## an input would get wrong: a dropped curve went undetected by every cable gate), and the |
| 340 | ## answer must equal a fresh, uncached _world_pieces of that input — and differ from before. |
| 341 | ## C1 the same input twice: the SAME array (the cache is live, so C2–C4 test it) |
| 342 | ## C2 the path curve's points moved |
| 343 | ## C3 the path curve closed |
| 344 | ## C4 the profile curve's points moved, and the profile curve closed / opened |
| 345 | func _cache_checks() -> void: |
| 346 | var a := _curve([Vector3(0, 0.5, 0), Vector3(5, 0.5, 2), Vector3(10, 0.5, 0)]) |
| 347 | var p: Dictionary = gen.resolve({"radius": 0.1}) |
| 348 | var first: Array = gen.world_pieces(a, p) |
| 349 | _ok("C1 cache: the same input twice -> the same pieces array", is_same(first, gen.world_pieces(a, p))) |
| 350 | var b := _curve([Vector3(0, 0.5, 0), Vector3(5, 1.5, 2), Vector3(10, 0.5, 0)]) |
| 351 | var pb: Array = gen.world_pieces(b, p) |
| 352 | _ok("C2 path points moved: = uncached, != before", pb == gen._world_pieces(b, p) and pb != first, pb.size()) |
| 353 | # The SAME points, only `closed` flipped (_curve(..., true) re-derives the handles, so |
| 354 | # the points would differ too and hide a key that dropped `closed`). |
| 355 | var c := {"points": a["points"], "closed": true} |
| 356 | var pc: Array = gen.world_pieces(c, p) |
| 357 | _ok("C3 path closed: = uncached, != before", pc == gen._world_pieces(c, p) and pc != first, pc.size()) |
| 358 | var pcust: Dictionary = gen.resolve({"radius": 0.1, "profile": "custom"}) |
| 359 | var sq := _curve([Vector3(100, 0, 0), Vector3(101, 0, 0), Vector3(101, 1, 0), Vector3(100, 1, 0)], true) |
| 360 | var kite := _curve([Vector3(100, 0, 0), Vector3(101, 0, 0), Vector3(102, 2, 0), Vector3(100, 1, 0)], true) |
| 361 | var sq_open := _curve([Vector3(100, 0, 0), Vector3(101, 0, 0), Vector3(101, 1, 0), Vector3(100, 1, 0)], false) |
| 362 | var ps: Array = gen.world_pieces(a, pcust, sq) |
| 363 | var pk: Array = gen.world_pieces(a, pcust, kite) |
| 364 | var po: Array = gen.world_pieces(a, pcust, sq_open) |
| 365 | _ok("C4 profile points moved: = uncached, != before", pk == gen._world_pieces(a, pcust, kite) and pk != ps) |
| 366 | _ok("C4 profile opened (folds round): = uncached, != before", po == gen._world_pieces(a, pcust, sq_open) and po != ps) |