//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// using System.Runtime.InteropServices; namespace BansheeEngine { /** @addtogroup Physics * @{ */ /// /// Hit information from a physics query. /// public struct PhysicsQueryHit { /// /// Position of the hit in world space. /// public Vector3 point; /// /// Normal to the surface that was hit. /// public Vector3 normal; /// /// UV coordinates of the triangle that was hit (only applicable when triangle meshes are hit). /// public Vector2 uv; /// /// Distance from the query origin to the hit position. /// public float distance; /// /// Index of the triangle that was hit (only applicable when triangle meshes are hit). /// public int triangleIdx; /// /// Collider that was hit. /// public Collider collider; } /// /// Information about a single contact point during physics collision. /// [StructLayout(LayoutKind.Sequential)] public struct ContactPoint // Note: Must match C++ ContactPoint struct { /// /// Contact point in world space. /// public Vector3 position; /// /// Normal pointing from the second shape to the first shape. /// public Vector3 normal; /// /// Impulse applied to the objects to keep them from penetrating. Divide by simulation step to get the force. /// public float impulse; /// /// Determines how far are the objects. Negative value denotes penetration. /// public float separation; } /// /// Information about a collision between two physics objects. /// public struct CollisionData { internal CollisionData(ScriptCollisionData data) { if (data.colliderA != null) colliderA = data.colliderA.Component; else colliderA = null; if (data.colliderB != null) colliderB = data.colliderB.Component; else colliderB = null; contactPoints = data.contactPoints; } /// /// First of the colliders involved in the collision. /// public Collider colliderA; /// /// Second of the colliders involved in the collision. /// public Collider colliderB; /// /// Information about all the contact points for the hit. /// public ContactPoint[] contactPoints; } /// /// Interop class used for passing PhysicsQueryHit data from native to managed code. . /// [StructLayout(LayoutKind.Sequential)] internal struct ScriptPhysicsQueryHit // Note: Must match C++ struct ScriptPhysicsQueryHit { public Vector3 point; public Vector3 normal; public Vector2 uv; public float distance; public int triangleIdx; public NativeCollider collider; } /// /// Interop class used for passing CollisionData data from native to managed code. . /// [StructLayout(LayoutKind.Sequential)] internal struct ScriptCollisionData // Note: Must match C++ CollisionData struct { public NativeCollider colliderA; public NativeCollider colliderB; public ContactPoint[] contactPoints; } /// /// Determines which collision events will be reported by physics objects. /// public enum CollisionReportMode { /// /// No collision events will be triggered. /// None, /// /// Collision events will be triggered when object enters and/or leaves collision. /// Report, /// /// Collision events will be triggered when object enters and/or leaves collision, but also every frame the object /// remains in collision. /// ReportPersistent, } /** @} */ }