mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -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
31 lines
769 B
C#
31 lines
769 B
C#
|
|
namespace PhysicsTests;
|
|
|
|
[TestClass]
|
|
public class QueryTest
|
|
{
|
|
/// <summary>
|
|
/// Does sphere overlap test work against meshes?
|
|
/// </summary>
|
|
[TestMethod]
|
|
public void QueryMesh()
|
|
{
|
|
var scene = new Scene();
|
|
using var sceneScope = scene.Push();
|
|
|
|
var world = scene.PhysicsWorld;
|
|
var body = new PhysicsBody( world );
|
|
var vertices = new[] { new Vector3( 0, 0, 0 ), new Vector3( 100, 0, 0 ), new Vector3( 100, 100, 0 ) };
|
|
var indices = new[] { 0, 1, 2 };
|
|
body.AddMeshShape( vertices, indices );
|
|
|
|
var go = scene.CreateObject();
|
|
body.GameObject = go;
|
|
|
|
var gameObjects = scene.FindInPhysics( new Sphere( 0, 200 ) ).ToList();
|
|
|
|
Assert.IsTrue( gameObjects != null && gameObjects.Count == 1 );
|
|
Assert.IsTrue( gameObjects.FirstOrDefault() == go );
|
|
}
|
|
}
|