Files
sbox-public/engine/Tests/Sandbox.Test.Integration/Physics/Query.cs
Garry Newman d95169d8fa Unit Test Cleanup (#5064)
* 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
2026-06-12 13:23:50 +01:00

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 );
}
}