@@ -341,19 +341,23 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
341341 }
342342 }
343343
344- if ( shapeFilePath != null && File . Exists ( shapeFilePath + "d" ) )
344+ var shapeDescriptorPath = shapeFilePath + "d" ;
345+ if ( shapeFilePath != null )
345346 {
346- var shape = new ShapeDescriptorFile ( shapeFilePath + "d" ) ;
347- if ( shape . shape . ESD_Bounding_Box != null )
347+ var shape = new ShapeDescriptorFile ( shapeDescriptorPath ) ;
348+ if ( shape != null )
348349 {
349- var min = shape . shape . ESD_Bounding_Box . Min ;
350- var max = shape . shape . ESD_Bounding_Box . Max ;
351- var transform = Matrix . Invert ( worldMatrix . XNAMatrix ) ;
352- // Not sure if this is needed, but it is to correct for center-of-gravity being not the center of the box.
353- //transform.M41 += (max.X + min.X) / 2;
354- //transform.M42 += (max.Y + min.Y) / 2;
355- //transform.M43 += (max.Z + min.Z) / 2;
356- BoundingBoxes . Add ( new BoundingBox ( transform , new Vector3 ( ( max . X - min . X ) / 2 , ( max . Y - min . Y ) / 2 , ( max . Z - min . Z ) / 2 ) , worldMatrix . XNAMatrix . Translation . Y ) ) ;
350+ if ( shape . shape . ESD_Bounding_Box != null )
351+ {
352+ var min = shape . shape . ESD_Bounding_Box . Min ;
353+ var max = shape . shape . ESD_Bounding_Box . Max ;
354+ var transform = Matrix . Invert ( worldMatrix . XNAMatrix ) ;
355+ // Not sure if this is needed, but it is to correct for center-of-gravity being not the center of the box.
356+ //transform.M41 += (max.X + min.X) / 2;
357+ //transform.M42 += (max.Y + min.Y) / 2;
358+ //transform.M43 += (max.Z + min.Z) / 2;
359+ BoundingBoxes . Add ( new BoundingBox ( transform , new Vector3 ( ( max . X - min . X ) / 2 , ( max . Y - min . Y ) / 2 , ( max . Z - min . Z ) / 2 ) , worldMatrix . XNAMatrix . Translation . Y ) ) ;
360+ }
357361 }
358362 }
359363
0 commit comments