@@ -151,6 +151,8 @@ public DynamicTrackViewer(Viewer viewer, WorldPosition position, WorldPosition e
151151 /// </summary>
152152 public void PrepareFrame ( RenderFrame frame , ElapsedTime elapsedTime )
153153 {
154+ var lodBias = ( ( float ) Viewer . Settings . LODBias / 100 + 1 ) ;
155+
154156 // Offset relative to the camera-tile origin
155157 int dTileX = worldPosition . TileX - Viewer . Camera . TileX ;
156158 int dTileZ = worldPosition . TileZ - Viewer . Camera . TileZ ;
@@ -166,15 +168,16 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
166168 if ( ! Viewer . Camera . InFov ( Primitive . MSTSLODCenter , Primitive . ObjectRadius ) ) return ;
167169
168170 // Scan LODs in forward order, and find first LOD in-range
171+ // lodIndex marks first in-range LOD
169172 LOD lod ;
170173 int lodIndex ;
171174 for ( lodIndex = 0 ; lodIndex < Primitive . TrProfile . LODs . Count ; lodIndex ++ )
172175 {
173176 lod = ( LOD ) Primitive . TrProfile . LODs [ lodIndex ] ;
174- if ( Viewer . Camera . InRange ( Primitive . MSTSLODCenter , 0 , lod . CutoffRadius ) ) break ;
177+ if ( Viewer . Camera . InRange ( Primitive . MSTSLODCenter , 0 , lod . CutoffRadius * lodBias ) ) break ;
175178 }
179+ // Ignore any mesh too far away for the furthest LOD
176180 if ( lodIndex == Primitive . TrProfile . LODs . Count ) return ;
177- // lodIndex marks first in-range LOD
178181
179182 // Initialize xnaXfmWrtCamTile to object-tile to camera-tile translation:
180183 Matrix xnaXfmWrtCamTile = Matrix . CreateTranslation ( tileOffsetWrtCamera ) ;
@@ -199,7 +202,7 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
199202 lod = ( LOD ) Primitive . TrProfile . LODs [ lodIndex ] ;
200203 for ( int j = lod . PrimIndexStart ; j < lod . PrimIndexStop ; j ++ )
201204 {
202- frame . AddPrimitive ( Primitive . ShapePrimitives [ j ] . Material , Primitive . ShapePrimitives [ j ] , RenderPrimitiveGroup . World , ref xnaXfmWrtCamTile , ShapeFlags . AutoZBias ) ;
205+ frame . AddPrimitive ( Primitive . ShapePrimitives [ j ] . Material , Primitive . ShapePrimitives [ j ] , RenderPrimitiveGroup . World , ref xnaXfmWrtCamTile , ShapeFlags . None ) ;
203206 }
204207 lodIndex ++ ;
205208 }
0 commit comments