mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-07-31 07:48:52 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
namespace MathTests;
|
|
|
|
public partial class BBoxTest
|
|
{
|
|
[TestMethod]
|
|
public void TraceBBox()
|
|
{
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( -100, 0, 0 ), new Vector3( 1, 0, 0 ) );
|
|
Assert.IsTrue( bbox.Trace( ray, 100, out var dist ) );
|
|
Assert.AreEqual( 95.0f, dist );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 100, 0, 0 ), new Vector3( -1, 0, 0 ) );
|
|
Assert.IsTrue( bbox.Trace( ray, 100, out var dist ) );
|
|
Assert.AreEqual( 95.0f, dist );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 0, 100, 0 ), new Vector3( 0, -1, 0 ) );
|
|
Assert.IsTrue( bbox.Trace( ray, 100, out var dist ) );
|
|
Assert.AreEqual( 95.0f, dist );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 0, -100, 0 ), new Vector3( 0, 1, 0 ) );
|
|
Assert.IsTrue( bbox.Trace( ray, 100, out var dist ) );
|
|
Assert.AreEqual( 95.0f, dist );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 0, -100, 0 ), new Vector3( 0, 1, 0 ) );
|
|
Assert.IsFalse( bbox.Trace( ray, 90, out var dist ) );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 100, 0, 0 ), new Vector3( -1, 0, 0 ) );
|
|
Assert.IsFalse( bbox.Trace( ray, 90, out var dist ) );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 100, 0, 0 ), new Vector3( -1, 0, 0 ) );
|
|
Assert.IsTrue( bbox.Trace( ray, 100000, out var dist ) );
|
|
}
|
|
|
|
{
|
|
var bbox = BBox.FromPositionAndSize( 0, 10 );
|
|
var ray = new Ray( new Vector3( 6, 0, 0 ), new Vector3( 1, 0, 0 ) );
|
|
Assert.IsFalse( bbox.Trace( ray, 100000, out var dist ) );
|
|
}
|
|
}
|
|
|
|
}
|