Repository navigation
Commit 63b81b4
viewer: sparse tiled room map for daylight; rooms built from settled geometry (#1245)
* Daylight rooms: a sparse tiled room map, per level and per building
The room-id map was one texture with every level stacked along Y at 10 cm cells,
levels found by height across the whole site and capped at 8. A 40-storey tower
lit floors 8-39 with whichever room was rasterized last, a campus fell to ~80 cm
cells and still mixed its buildings' floors, a datacenter took 48 MB at 20 cm.
Each level now keeps its own map of 10 cm cells cut into 1.6 m tiles: a tile inside
one room (or outside all of them) is one value, only tiles a room edge crosses keep
their cells, packed into a shared two-byte atlas. A point finds its buildings in a
coarse directory and its level by a binary search over that building's live floor
heights, which stay sorted when levels explode apart. Zone holes are rasterized.
"Open to the sky" and the meters read the real presentation per level (shown, not
shadow-only; focused when the level over it is hidden), not an index order. Texture
sizes come from the device. The lighting and the exterior mask share one lookup.
CPU bench, every room on every floor: tower 96/480 -> 480/480 rooms right, campus
708/1770 -> 1770/1770 at 10 cm (35 -> 17 MB), datacenter 48 MB at 20 cm -> 14 MB at
10 cm, street block 21 MB -> 0.4 MB; houses resolve the same rooms (differences only
inside the 2-cell edge band). Rebuilds 2-90x faster. Main-pass GPU time within
run-to-run noise on houses, tower and datacenter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Daylight rooms: build tile rows, cluster rooms, index rays; smallest room wins
Review and browser findings on the tiled room map:
- Build by rows of tiles (with a 3-cell margin) and group each level's rooms
into clusters with their own rects: no dense per-level grid, so a level with
rooms kilometres apart neither runs out of memory nor pays for the ground
between them. Tile rects are computed in whole tiles (a rounded origin could
start a level at tile -1 and crash the directory).
- Doorway and cover rays test only the meshes near them (a 2 m grid of mesh
bounds) instead of every wall and slab: room builds drop from 37 s to 0.6 s on
a 2,560-wall datacenter and from 6.7 s to 1.2 s on a 40-storey tower.
- Where zones overlap, the smallest room wins (largest rasterized first): an
automatic floor-wide room or a unit around its rooms no longer swallows them.
- A level opens from above only when every level over it in its building is
hidden; the index texture is as wide as the device allows; room ids are
capped at 65,535 with a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Daylight rooms: build from settled geometry; mesh bounds from current vertices
On a large scene the rooms were built while walls and windows were still being
built, and never again: walls and openings finish without a geometry revision.
Rays then passed through unbuilt walls, so doorways read as whole walls and an
L of exterior wall became one diagonal opening across a corner room, pouring
outdoor light in (the bright wedges); most windows had no portal yet.
- Rooms wait for the scene to settle (no dirty nodes) and build again each time
it does after walls, slabs, openings or zones changed (not furniture).
- A scene still loading after 10 s builds anyway, then again every 10 s while
its dirty count keeps falling, so the rooms catch up with the geometry.
- The ray index takes each mesh's bounds from its current vertices: a cached
bounding box can predate a wall rebuilt in place, filing it where no ray
looks.
Campus: corner room 8-1 goes from one 17.6 m diagonal exterior opening and no
windows to its four windows and two 1.2 m doorways; interior rooms from four
12 m "openings" to their four 1.2 m doorways.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Daylight rooms: overlapping clusters keep searching; no rebuild while levels move
Bugbot review on #1245:
- A level's cluster rects can overlap (a C-shaped wing's rect covers a courtyard
pavilion in its own cluster). The lookup stopped at the first rect holding the
point, empty there, so the pavilion got no room light. It now keeps going
until a cluster has a room at the point (CPU and shader).
- Cover and doorway rays are cast at stacked floor heights against meshes where
they are; a rebuild while levels are exploded (or still moving) read doorways
as open and covers at exploded heights. Rebuilds wait until levels are
stacked and still.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 55f7d51 commit 63b81b4
6 files changed
Lines changed: 1378 additions & 421 deletions
File tree
- packages/viewer/src
- components/viewer
- lib/daylight
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
50 | 64 | | |
51 | 65 | | |
52 | | - | |
| 66 | + | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
| |||
65 | 79 | | |
66 | 80 | | |
67 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
68 | 99 | | |
69 | 100 | | |
70 | 101 | | |
| |||
73 | 104 | | |
74 | 105 | | |
75 | 106 | | |
76 | | - | |
| 107 | + | |
77 | 108 | | |
78 | 109 | | |
79 | 110 | | |
| |||
84 | 115 | | |
85 | 116 | | |
86 | 117 | | |
87 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
88 | 124 | | |
89 | 125 | | |
90 | 126 | | |
91 | 127 | | |
92 | 128 | | |
93 | 129 | | |
| 130 | + | |
94 | 131 | | |
95 | 132 | | |
96 | 133 | | |
97 | | - | |
| 134 | + | |
98 | 135 | | |
99 | 136 | | |
100 | 137 | | |
| |||
104 | 141 | | |
105 | 142 | | |
106 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
107 | 150 | | |
108 | 151 | | |
109 | 152 | | |
110 | 153 | | |
111 | 154 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
115 | 159 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 160 | + | |
| 161 | + | |
120 | 162 | | |
121 | | - | |
122 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
123 | 169 | | |
124 | 170 | | |
125 | 171 | | |
| |||
227 | 273 | | |
228 | 274 | | |
229 | 275 | | |
230 | | - | |
231 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
232 | 281 | | |
233 | | - | |
| 282 | + | |
234 | 283 | | |
235 | 284 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 285 | + | |
| 286 | + | |
241 | 287 | | |
242 | 288 | | |
243 | 289 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
247 | 301 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
0 commit comments