forked from bepu/bepuphysics1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhysicsChecker.cs
42 lines (37 loc) · 1.37 KB
/
PhysicsChecker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Diagnostics;
using BEPUphysics.CollisionTests;
using BEPUutilities;
namespace BEPUphysics
{
/// <summary>
/// Contains conditional extensions to check for bad values in various structures.
/// </summary>
public static class PhysicsChecker
{
/// <summary>
/// Checks the contact to see if it contains NaNs or infinities. If it is, an exception is thrown.
/// This is only run when the CHECKMATH symbol is defined.
/// </summary>
[Conditional("CHECKMATH")]
public static void Validate(this Contact contact)
{
contact.Normal.Validate();
if (contact.Normal.LengthSquared() < 0.9f)
throw new ArithmeticException("Invalid contact normal.");
contact.Position.Validate();
contact.PenetrationDepth.Validate();
}
/// <summary>
/// Checks the contact to see if it contains NaNs or infinities. If it is, an exception is thrown.
/// This is only run when the CHECKMATH symbol is defined.
/// </summary>
[Conditional("CHECKMATH")]
public static void Validate(this ContactData contact)
{
contact.Normal.Validate();
contact.Position.Validate();
contact.PenetrationDepth.Validate();
}
}
}