@@ -101,7 +101,10 @@ public void Mark(SharedShape shape)
101
101
public void Sweep ( )
102
102
{
103
103
foreach ( var path in ShapeMarks . Where ( kvp => ! kvp . Value ) . Select ( kvp => kvp . Key ) )
104
+ {
105
+ Shapes [ path ] . Dispose ( ) ;
104
106
Shapes . Remove ( path ) ;
107
+ }
105
108
}
106
109
107
110
[ CallOnThread ( "Updater" ) ]
@@ -1343,7 +1346,7 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
1343
1346
}
1344
1347
}
1345
1348
1346
- public class ShapePrimitive : RenderPrimitive
1349
+ public class ShapePrimitive : RenderPrimitive , IDisposable
1347
1350
{
1348
1351
public Material Material { get ; protected set ; }
1349
1352
public int [ ] Hierarchy { get ; protected set ; } // the hierarchy from the sub_object
@@ -1394,6 +1397,13 @@ public virtual void Mark()
1394
1397
{
1395
1398
Material . Mark ( ) ;
1396
1399
}
1400
+
1401
+ public void Dispose ( )
1402
+ {
1403
+ VertexBuffer . Dispose ( ) ;
1404
+ IndexBuffer . Dispose ( ) ;
1405
+ PrimitiveCount = 0 ;
1406
+ }
1397
1407
}
1398
1408
1399
1409
/// <summary>
@@ -1535,7 +1545,7 @@ public virtual void Mark()
1535
1545
}
1536
1546
#endif
1537
1547
1538
- public class SharedShape
1548
+ public class SharedShape : IDisposable
1539
1549
{
1540
1550
static List < string > ShapeWarnings = new List < string > ( ) ;
1541
1551
@@ -1668,7 +1678,7 @@ void LoadContent()
1668
1678
}
1669
1679
}
1670
1680
1671
- public class LodControl
1681
+ public class LodControl : IDisposable
1672
1682
{
1673
1683
public DistanceLevel [ ] DistanceLevels ;
1674
1684
@@ -1687,11 +1697,21 @@ public LodControl(lod_control MSTSlod_control, Helpers.TextureFlags textureFlags
1687
1697
internal void Mark ( )
1688
1698
{
1689
1699
foreach ( var dl in DistanceLevels )
1700
+ {
1690
1701
dl . Mark ( ) ;
1702
+ }
1703
+ }
1704
+
1705
+ public void Dispose ( )
1706
+ {
1707
+ foreach ( var dl in DistanceLevels )
1708
+ {
1709
+ dl . Dispose ( ) ;
1710
+ }
1691
1711
}
1692
1712
}
1693
1713
1694
- public class DistanceLevel
1714
+ public class DistanceLevel : IDisposable
1695
1715
{
1696
1716
public float ViewingDistance ;
1697
1717
public float ViewSphereRadius ;
@@ -1726,11 +1746,21 @@ public DistanceLevel(distance_level MSTSdistance_level, Helpers.TextureFlags tex
1726
1746
internal void Mark ( )
1727
1747
{
1728
1748
foreach ( var so in SubObjects )
1749
+ {
1729
1750
so . Mark ( ) ;
1751
+ }
1752
+ }
1753
+
1754
+ public void Dispose ( )
1755
+ {
1756
+ foreach ( var so in SubObjects )
1757
+ {
1758
+ so . Dispose ( ) ;
1759
+ }
1730
1760
}
1731
1761
}
1732
1762
1733
- public class SubObject
1763
+ public class SubObject : IDisposable
1734
1764
{
1735
1765
static readonly SceneryMaterialOptions [ ] UVTextureAddressModeMap = new [ ] {
1736
1766
SceneryMaterialOptions . TextureAddressModeWrap ,
@@ -1951,7 +1981,17 @@ public SubObject(sub_object sub_object, ref int totalPrimitiveIndex, int[] hiera
1951
1981
internal void Mark ( )
1952
1982
{
1953
1983
foreach ( var prim in ShapePrimitives )
1984
+ {
1954
1985
prim . Mark ( ) ;
1986
+ }
1987
+ }
1988
+
1989
+ public void Dispose ( )
1990
+ {
1991
+ foreach ( var prim in ShapePrimitives )
1992
+ {
1993
+ prim . Dispose ( ) ;
1994
+ }
1955
1995
}
1956
1996
}
1957
1997
@@ -2180,7 +2220,17 @@ internal void Mark()
2180
2220
{
2181
2221
Viewer . ShapeManager . Mark ( this ) ;
2182
2222
foreach ( var lod in LodControls )
2223
+ {
2183
2224
lod . Mark ( ) ;
2225
+ }
2226
+ }
2227
+
2228
+ public void Dispose ( )
2229
+ {
2230
+ foreach ( var lod in LodControls )
2231
+ {
2232
+ lod . Dispose ( ) ;
2233
+ }
2184
2234
}
2185
2235
}
2186
2236
0 commit comments