forked from 1b-agent/opencadstudio-upstream
Every further reference to an already expanded block (a translated copy of the same definition, at the top level or nested) was materialised as a full copy of every wire, although the GPU already draws those copies from one shared source with a per-copy offset. Such a copy is now a single stub wire holding the shared prototype and its offset (stubs nest inside prototypes, so nested repeats collapse too). - The block renderer expands stubs into instance references while it groups by source, so drawing is unchanged. - Interaction queries expand only the stubs near the query, so snapping, picking, window and crossing selection see each copy's geometry. - Plot, boundary detection, viewport projection and entity_wires() get fully expanded wires; count and reference-edit recolouring expand the set while they are active. - OCS_NO_BLOCK_STUBS turns it off. A drawing with 480 references to a block of 100 nested 50-line blocks (2.4M lines) now opens with 11k wires instead of 2.4M: peak memory 5.4 GB -> 0.37 GB, wire assembly 2.4 s -> 36 ms, interaction index 3.7 s -> 23 ms. The viewport, a plotted PDF, snaps and selections are identical with and without stubs, and on five real drawings the view renders the same. Refs #1698, #1542 Co-Authored-By: Claude Opus 5.5 <[email protected]>