Repository navigation
The exact CSG writes a neighbour's face as the last update built it when nothing that can reach the face changed (#281) - #362
Merged
Conversation
…hen nothing that can reach the face changed (#281)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #281 (exact speed-ups, item 1: replay faces the edit cannot reach).
When a brush moves, every brush touching it is built again, all its faces, although most of them are nowhere near the moved brush. On bm_c0a0a those neighbours took 85-90% of
ExactCSGJob's time in a drag, and the longest of them set its wall time, not the moved brush.What a face is built from
ExactFaceBuilder.BuildFacereads, for one face: the face's own brush (its exact planes and the face polygon made from them), the brush's routing table, and every touching brush that can reach the face: its planes, the three categories it gives the face's parts, whether it routes and its lookup, in touching order. A touching brush can reach the face unless its bounds miss the face's or one of its planes has every corner of the face strictly outside. One that can't makes no region of the face and has no interval on any line through it, so it adds nothing, and a lookup to it routes as Outside. Having no region is not enough: a brush without a lookup still puts points on the face's lines.Changes
ExactBrush.generation: a brush built again keeps its generation when its planes and corner count are the same (everything the CSG reads of it is made from them), otherwise it takes a new one from the tree's counter (ExactBrushes.SetGeneration, inExactInputJob,ExactBoundsJobandExactMergedRebuildJob).ExactFaceCache, by node order: per brush, its generation, its routing table, and per face what it wrote, what it counted and its key: the generation, categories, routing and lookup of each brush that can reach it.ExactCSGJobwrites a face from the cache when the brush, its routing table and the face's key are the same, and builds it otherwise. A face routed through the tables of brushes it gives way to (a coplanar tie) is always built. Faces are built into a list first and then written value by value as before, so the streamGenerateSurfaceTrianglesJobreads is unchanged. Nothing is replayed while the exact output is captured for tests.CompactHierarchyManager.BuildEveryFaceturns replay off;VerifyReplayedFacesbuilds every replayed face as well and countsExactCSGStat.ReplayMismatch, a failure, where the two differ.ContentsTreeHarness.Build(scene, captureExact: false)runs the CSG as outside tests.Timing
Two drags of each brush on bm_c0a0a, median per frame, main / this branch:
ExactCSGJobover the worker threads: large brush 11.3-11.4 / 7.6-7.8 ms, median brush 2.35-2.46 / 2.19-2.22 ms.UpdateTreeMeshes: large brush 13.4-13.5 / 12.9-13.1 ms; median brush within noise (10.8-11.1 / 10.6-10.9 ms).Memory: the cache holds 9.8 MB on bm_c0a0a (5,755 brushes, 34,378 faces).
Tests
ExactFaceReplayTests(12): two trees with the same scene and the same edits, one replaying with every replayed face verified, one building every face; the triangles must be the same. Moves (including through a neighbour and back), operation changes (Additive, Subtractive, Intersecting, in and out of a composite), contents changes, reordering, removing and adding, and random edits; faces must have been replayed.Each fails when the key leaves out the touching brushes' generations, when no brush is taken to reach a face, when the routing tables are not compared, when a brush keeps its generation with other planes, when faces with ties are replayed, or when the categories are left out of the key.
Dragging both brushes on bm_c0a0a with
VerifyReplayedFaceson: no mismatches.Full EditMode suite: 3193 passed, 2 failed, 5 skipped. The two failures are
ChiselSubtractiveWorkflowTests.APillarInARoom_ShadowsTheFloorFromALamp, which fail the same way on main in the project this ran in.