Files
sbox-public/engine/Sandbox.Test/Physics/Query.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

31 lines
760 B
C#

namespace Physics;
[TestClass]
public class Query
{
/// <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 );
}
}