@@ -20,18 +20,16 @@ public class BSPMap
20
20
public string mapName { get ; private set ; }
21
21
public string mapDir { get ; private set ; }
22
22
public static bool combineMeshesWithSameTexture ;
23
- public static bool excludeModels ;
24
- public static bool excludeMapFaces ;
23
+ private static float modelLoadPercent = 1 ;
24
+ public static float ModelLoadPercent { get { return Mathf . Clamp01 ( modelLoadPercent ) ; } set { modelLoadPercent = value ; } }
25
+ private static float faceLoadPercent = 1 ;
26
+ public static float FaceLoadPercent { get { return Mathf . Clamp01 ( faceLoadPercent ) ; } set { faceLoadPercent = value ; } }
25
27
public static bool applyLightmaps ;
26
28
public static string vpkLoc ;
27
29
public GameObject gameObject { get ; private set ; }
28
30
29
- //private Material noTexture;
30
- //private Dictionary<SourceTexture, Material> materialsCreated = new Dictionary<SourceTexture, Material>();
31
-
32
31
private List < FaceMesh > allFaces = new List < FaceMesh > ( ) ;
33
32
private StaticPropData [ ] staticProps ;
34
- //private SourceModel[] staticProps;
35
33
public Dictionary < int , SourceLightmap > lightmaps ; //Maps from face lightofs to lightmap
36
34
#endregion
37
35
@@ -109,7 +107,7 @@ public List<string> GetDependencies(CancellationToken cancelToken)
109
107
// added by other dependencies, those archives will not be added. That would require us to read the materials and models to get what textures they use.
110
108
111
109
#region Map face textures dependencies
112
- if ( ! excludeMapFaces )
110
+ if ( FaceLoadPercent > 0 )
113
111
{
114
112
foreach ( dface_t face in bspParser . faces )
115
113
{
@@ -135,7 +133,7 @@ public List<string> GetDependencies(CancellationToken cancelToken)
135
133
#endregion
136
134
137
135
#region Model dependencies
138
- if ( ! excludeModels )
136
+ if ( ModelLoadPercent > 0 )
139
137
{
140
138
for ( int i = 0 ; i < bspParser . staticProps . staticPropInfo . Length ; i ++ )
141
139
{
@@ -185,20 +183,19 @@ public void ParseFile(CancellationToken cancelToken, Action<float, string> onPro
185
183
//if (!cancelToken.IsCancellationRequested)
186
184
// lightmaps = bspParser.GetLightmaps(cancelToken);
187
185
188
- int facesCount = excludeMapFaces ? 0 : bspParser . faces . Length ;
189
- int propsCount = excludeModels ? 0 : bspParser . staticProps . staticPropInfo . Length ;
186
+ int facesCount = Mathf . RoundToInt ( bspParser . faces . Length * FaceLoadPercent ) ;
187
+ int propsCount = Mathf . RoundToInt ( bspParser . staticProps . staticPropInfo . Length * ModelLoadPercent ) ;
190
188
totalItemsToLoad = facesCount + propsCount ;
191
189
192
190
bool validVPK = vpkParser . IsValid ( ) ;
193
191
194
192
currentMessage = "Parsing Faces" ;
195
193
onProgressChanged ? . Invoke ( PercentLoaded , currentMessage ) ;
196
- if ( ! excludeMapFaces )
197
- ReadFaces ( bspParser , validVPK ? vpkParser : null , cancelToken , onProgressChanged ) ;
194
+ ReadFaces ( bspParser , validVPK ? vpkParser : null , cancelToken , onProgressChanged ) ;
198
195
199
196
currentMessage = "Loading Static Props" ;
200
197
onProgressChanged ? . Invoke ( PercentLoaded , currentMessage ) ;
201
- if ( validVPK && ! excludeModels )
198
+ if ( validVPK )
202
199
ReadStaticProps ( bspParser , vpkParser , cancelToken , onProgressChanged ) ;
203
200
}
204
201
@@ -234,7 +231,7 @@ private bool IsUndesiredTexture(string textureLocation, texflags tf)
234
231
}
235
232
private void ReadFaces ( BSPParser bspParser , VPKParser vpkParser , CancellationToken cancelToken , Action < float , string > onProgressChanged = null )
236
233
{
237
- for ( int i = 0 ; i < bspParser . faces . Length ; i ++ )
234
+ for ( int i = 0 ; i < Mathf . RoundToInt ( bspParser . faces . Length * FaceLoadPercent ) ; i ++ )
238
235
{
239
236
if ( cancelToken . IsCancellationRequested )
240
237
return ;
@@ -497,8 +494,9 @@ private void AddFaceMesh(FaceMesh faceMesh, bool combine)
497
494
498
495
private void ReadStaticProps ( BSPParser bspParser , VPKParser vpkParser , CancellationToken cancelToken , Action < float , string > onProgressChanged = null )
499
496
{
500
- staticProps = new StaticPropData [ bspParser . staticProps . staticPropInfo . Length ] ;
501
- for ( int i = 0 ; i < bspParser . staticProps . staticPropInfo . Length ; i ++ )
497
+ int staticPropCount = Mathf . RoundToInt ( bspParser . staticProps . staticPropInfo . Length * ModelLoadPercent ) ;
498
+ staticProps = new StaticPropData [ staticPropCount ] ;
499
+ for ( int i = 0 ; i < staticPropCount ; i ++ )
502
500
{
503
501
if ( cancelToken . IsCancellationRequested )
504
502
return ;
0 commit comments