🐛 Count a copy bool that mirrors apart from its main as moved

A bool keeps its corners in one order whatever its flips. Sync places
the shapes of a copy shape that authors its geometry like it only when
its geometry differs from its main's, so a flipped bool in a copy
looked like its main, and sync gave its shapes their main's unflipped
geometry.

A group or bool also differs from its main when it mirrors differently,
read from its transform.

Test: syncing-the-shapes-of-a-flipped-copy-bool-keeps-them-flipped.

Benchmark (alone, shared with the next commit):

|                             :world | :baseline |   :now |   :mean | :ratio |
|------------------------------------+-----------+--------+---------+--------|
|  deepest-edit-through-three-levels |    35.215 | 20.498 |  21.134 |   0.58 |
| edit-through-a-chain-of-dependents |    68.931 | 40.257 |  42.557 |   0.58 |
|         library-update-into-copies |    83.083 | 51.433 |  52.577 |   0.62 |
|        main-edit-among-many-shapes |     4.837 |  2.145 |   2.365 |   0.44 |
|           main-edit-into-10-copies |      1.79 |  1.012 |   1.093 |   0.57 |
|          main-edit-into-100-copies |    15.415 | 10.535 |  10.754 |   0.68 |
|         main-edit-into-1000-copies |   153.086 |  99.04 | 105.491 |   0.65 |
|         variant-switch-into-copies |    32.052 | 22.662 |  23.464 |   0.71 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-13 02:05:21 +01:00
parent c1778338e4
commit fb24f8c19e
2 changed files with 12 additions and 1 deletions

View File

@ -550,11 +550,17 @@
(gpt/point (-> root-inst :selrect :x) (-> root-inst :selrect :y)))]
(gsh/move shape delta)))
(declare flips)
(defn- close-geometry?
"Whether `shape` and `other` have the same geometry: a bool keeps its
corners in one order whatever its flips, so they count too."
[shape other]
(and (gsh/close-attrs? :selrect (:selrect shape) (:selrect other))
(gsh/close-attrs? :points (:points shape) (:points other))
(mth/close? (:content-scale shape 1) (:content-scale other 1))))
(mth/close? (:content-scale shape 1) (:content-scale other 1))
(or (not (#{:group :bool} (:type shape)))
(= (flips shape) (flips other)))))
(defn- authored-constraints
"The constraints that the copy shapes `ids` author, by the id of the main

View File

@ -2519,6 +2519,11 @@
:layout-copies false :layout-children false}]
:ops [[:structure 1 1 1] [:remove-child 1]]}))))
(t/deftest syncing-the-shapes-of-a-flipped-copy-bool-keeps-them-flipped
(t/is (map? (cg/run {:world [1 0 {:variants false :rich-variants false :text false :layout :grid
:layout-copies false :layout-children false}]
:ops [[:structure 0 4] [:transform 0 4 0 2]]}))))
(t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place
(t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid
:layout-copies true :layout-children true}]