File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Source/RunActivity/Viewer3D Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -277,9 +277,20 @@ public class PoseableShape : StaticShape
277
277
public PoseableShape ( Viewer viewer , string path , WorldPosition initialPosition , ShapeFlags flags )
278
278
: base ( viewer , path , initialPosition , flags )
279
279
{
280
- XNAMatrices = new Matrix [ SharedShape . Matrices . Length ] ;
281
- for ( int iMatrix = 0 ; iMatrix < SharedShape . Matrices . Length ; ++ iMatrix )
282
- XNAMatrices [ iMatrix ] = SharedShape . Matrices [ iMatrix ] ;
280
+ // In some cases, a corrupt shape file can prevent matrices from loading
281
+ if ( SharedShape . Matrices . Length > 0 )
282
+ {
283
+ XNAMatrices = new Matrix [ SharedShape . Matrices . Length ] ;
284
+ for ( int iMatrix = 0 ; iMatrix < SharedShape . Matrices . Length ; ++ iMatrix )
285
+ XNAMatrices [ iMatrix ] = SharedShape . Matrices [ iMatrix ] ;
286
+ }
287
+ else
288
+ {
289
+ Trace . TraceWarning ( "Could not determine matrices for shape file {0} file may be corrupt" , SharedShape . FilePath ) ;
290
+ // The 0th matrix should always be the identity matrix, add this to avoid crashes elsewhere
291
+ XNAMatrices = new Matrix [ 1 ] ;
292
+ XNAMatrices [ 0 ] = Matrix . Identity ;
293
+ }
283
294
284
295
if ( SharedShape . LodControls . Length > 0 && SharedShape . LodControls [ 0 ] . DistanceLevels . Length > 0 && SharedShape . LodControls [ 0 ] . DistanceLevels [ 0 ] . SubObjects . Length > 0 && SharedShape . LodControls [ 0 ] . DistanceLevels [ 0 ] . SubObjects [ 0 ] . ShapePrimitives . Length > 0 )
285
296
Hierarchy = SharedShape . LodControls [ 0 ] . DistanceLevels [ 0 ] . SubObjects [ 0 ] . ShapePrimitives [ 0 ] . Hierarchy ;
You can’t perform that action at this time.
0 commit comments