Skip to content

Commit a519452

Browse files
committed
Warning message should only show when we know the shape file location
1 parent 9b0ec01 commit a519452

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Source/RunActivity/Viewer3D/Shapes.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,23 @@ public class PoseableShape : StaticShape
277277
public PoseableShape(Viewer viewer, string path, WorldPosition initialPosition, ShapeFlags flags)
278278
: base(viewer, path, initialPosition, flags)
279279
{
280-
// In some cases, a corrupt shape file can prevent matrices from loading
281280
if (SharedShape.Matrices.Length > 0)
282281
{
283282
XNAMatrices = new Matrix[SharedShape.Matrices.Length];
284283
for (int iMatrix = 0; iMatrix < SharedShape.Matrices.Length; ++iMatrix)
285284
XNAMatrices[iMatrix] = SharedShape.Matrices[iMatrix];
286285
}
287-
else
286+
else // If the shape file is missing or fails to load, we need some default data to prevent crashes
288287
{
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
288+
if (path != null && path != "Empty")
289+
{
290+
string location = path;
291+
if (path != null && path.Contains('\0'))
292+
location = path.Split('\0')[0];
293+
294+
Trace.TraceWarning("Couldn't load shape {0} file may be corrupt", location);
295+
}
296+
// The 0th matrix should always be the identity matrix
291297
XNAMatrices = new Matrix[1];
292298
XNAMatrices[0] = Matrix.Identity;
293299
}

0 commit comments

Comments
 (0)