iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
582 stars 210 forks source link

Disappearing graphics as you zoom in #6010

Open simnorm opened 9 months ago

simnorm commented 9 months ago

Describe the bug Linear elements disappear as you zoom in closer in this imodel. Please reach out to get an invitation to the project.

To Reproduce Open this imodel Notice as you zoom in that some linear geometry disappears

Screenshots Initial state, linear element is visible image Zoom in twice using mousewheel and the linear element is no longer visible image

Additional context Add any other context about the problem here.

pmconne commented 9 months ago

Please supply the .bim file. After 10 minutes of blank white screens, spinners, etc I finally can see a 3d view in ProjectWise, with no useful debugging tools.

simnorm commented 9 months ago

I have invited you to the project while I try to figure out a way to get the bim file from infrastructurecloud. I don't see a way exposed to do that

simnorm commented 9 months ago

download link to bim file

pmconne commented 9 months ago

Root tile for model 0x20000000018 produces content, but its child tile produces no content. Probably has something to do with the geometry in the model lying in a single plane - the low and high Z values of the tile range are identical. Enormous translation in X and Y (4000km from origin) may also contribute to floating point fuzz causing us to decide the geometry doesn't intersect the tile volume.

I thought we expanded the tile volumes slightly, specifically to avoid this kind of problem. We certainly impose a minimum low-high delta on project extents (0.0005m), and the tile volumes are supposed to be based on the project extents.

Need to debug the tile generation code for the child tile. I suspect the newish logic that computes the tile tree volume by preserving the shape of the model's extents but with the diagonal distance of the project extents is not accounting for extremely close low-high values in the former.

pmconne commented 9 months ago

The lines in the "Default" model have a custom line style. We don't stroke the style when zoomed all the way out. When you zoom in, we attempt to stroke the style and produce no graphics from it.

The Ids of the two vanishing elements are 0x20000000116 and 0x20000000117.

If at all possible, please supply the DGN file from which the Default model originated.

simnorm commented 9 months ago

Link to the dgn files The disappearing lines are in "143402005-FM1977-TRF-STRIPING.dgn" thanks

(fixed the download link)

pmconne commented 9 months ago

Link to the dgn files

That's a link to a .bim file.

pmconne commented 9 months ago

Here are the DGN files.

pmconne commented 9 months ago

@bbastings for the lowest-resolution tile, my GraphicBuilder's _WantStrokeLineStyle returns false, and we just output the unstyled curve vector. For the next-higher-resolution tile, _WantStrokeLineStyle returns true. We invoke NullContext::_DrawStyledCurveVector. As far as I can tell, it outputs no geometry to my GraphicBuilder.

As far as I can tell from looking at it in MicroStation, the line style is pretty simple - it just makes the curves a specific width in world units.

Any suggestions?

bbastings commented 9 months ago

Surprisingly, this is not just a continuous style with width, it's drawing symbols. The symbols are being excluded in z range.

TileContext:
-       m_range
-       low {x=712609.43252710858 y=4216966.8690504190 z=-1.5485450325739357e-05 }
-       high    {x=713015.63774212461 y=4217100.3169883303 z=1.5485450325739357e-05 }   

Symbol:
-       range
+       low {x=712610.67174229992 y=4216976.7053834554 z=0.0038100076200152403 }
+       high    {x=712611.28192926373 y=4216976.8105593603 z=0.0038100076200152403 }

The original dgn models were 2d, so MicroStation was likely flattening to z=0.

I naively tried padding GeometryLoader.GetDgnRange just to see if anything would draw...that gets past the symbol range check, but didn't affect the lack of display...

bbastings commented 9 months ago

This is a connector issue and not a display issue. These "2d" line styles aren't drawing their symbols at z=0 and the double yellow centerline even has 3d symbol geometry. This would display correctly if the geometric element's bounding box was being correctly expanded for the symbols, but it's unfortunately computing a value that is too small. I'm attempting to fix the width calculation but I am not having much luck understanding this ridiculous code.