mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-17 02:39:41 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
31 lines
760 B
C#
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 );
|
|
}
|
|
}
|