Przeglądaj źródła

Added interface for global scene queries

BearishSun 9 lat temu
rodzic
commit
8bff473d2f

+ 2 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -568,6 +568,8 @@ namespace BansheeEngine
 			MemStack::endThread();
 		}
 	};
+
+	#define BS_ALL_LAYERS 0xFFFFFFFFFFFFFFFF
 }
 
 #include "BsCommonTypes.h"

+ 361 - 0
BansheeCore/Include/BsPhysics.h

@@ -5,6 +5,7 @@
 #include "BsCorePrerequisites.h"
 #include "BsModule.h"
 #include "BsVector3.h"
+#include "BsVector2.h"
 #include "BsQuaternion.h"
 
 namespace BansheeEngine
@@ -40,6 +41,17 @@ namespace BansheeEngine
 	typedef Flags<PhysicsFlag> PhysicsFlags;
 	BS_FLAGS_OPERATORS(PhysicsFlag)
 
+	/** Hit information from a physics query. */
+	struct PhysicsQueryHit
+	{
+		Vector3 point; /**< Position of the hit in world space. */
+		Vector3 normal; /**< Normal to the surface that was hit. */
+		Vector2 uv; /**< UV coordinates of the triangle that was hit (only applicable when triangle meshes are hit). */
+		float distance; /**< Distance from the query origin to the hit position. */
+		UINT32 triangleIdx; /**< Index of the triangle that was hit (only applicable when triangle meshes are hit). */
+		HCollider collider; /**< Collider that was hit. */
+	};
+
 	class BS_CORE_EXPORT Physics : public Module<Physics>
 	{
 	public:
@@ -48,6 +60,10 @@ namespace BansheeEngine
 
 		virtual void update() = 0;
 
+		/******************************************************************************************************************/
+		/************************************************* CREATION *******************************************************/
+		/******************************************************************************************************************/
+
 		virtual SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) = 0;
 		virtual SPtr<PhysicsMesh> createMesh(const MeshDataPtr& meshData, PhysicsMeshType type) = 0;
 		virtual SPtr<Rigidbody> createRigidbody(const HSceneObject& linkedSO) = 0;
@@ -71,6 +87,351 @@ namespace BansheeEngine
 		/** @copydoc CharacterController::create */
 		virtual SPtr<CharacterController> createCharacterController(const CHAR_CONTROLLER_DESC& desc) = 0;
 
+		/******************************************************************************************************************/
+		/************************************************* QUERIES ********************************************************/
+		/******************************************************************************************************************/
+
+		/**
+		 * Casts a ray into the scene and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	ray		Ray to cast into the scene.
+		 * @param[out]	hit		Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer	Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max		Maximum distance at which to perform the query. Hits past this distance will not be
+		 *						detected.
+		 * @return				True if something was hit, false otherwise.
+		 */
+		virtual bool rayCast(const Ray& ray, PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Casts a ray into the scene and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	origin		Origin of the ray to cast into the scene.
+		 * @param[in]	direction	Direction of the ray to cast into the scene.
+		 * @param[out]	hit			Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool rayCast(const Vector3& origin, const Vector3& direction, PhysicsQueryHit& hit, 
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a box and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	box			Box to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the box.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[out]	hit			Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool boxCast(const AABox& box, const Quaternion& rotation, const Vector3& direction, PhysicsQueryHit& hit,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a sphere and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	sphere		Sphere to sweep through the scene.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[out]	hit			Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool sphereCast(const Sphere& sphere, const Vector3& direction, PhysicsQueryHit& hit,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a capsule and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	capsule		Capsule to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the capsule.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[out]	hit			Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool capsuleCast(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction, 
+			PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a convex mesh and returns the closest found hit, if any.
+		 * 
+		 * @param[in]	mesh		Mesh to sweep through the scene. Must be convex.
+		 * @param[in]	position	Starting position of the mesh.
+		 * @param[in]	rotation	Orientation of the mesh.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[out]	hit			Information recorded about a hit. Only valid if method returns true.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool convexCast(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			const Vector3& direction, PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Casts a ray into the scene and returns all found hits.
+		 * 
+		 * @param[in]	ray		Ray to cast into the scene.
+		 * @param[in]	layer	Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max		Maximum distance at which to perform the query. Hits past this distance will not be
+		 *						detected.
+		 * @return				List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> rayCastAll(const Ray& ray, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Casts a ray into the scene and returns all found hits.
+		 * 
+		 * @param[in]	origin		Origin of the ray to cast into the scene.
+		 * @param[in]	direction	Direction of the ray to cast into the scene.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> rayCastAll(const Vector3& origin, const Vector3& direction, 
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a box and returns all found hits.
+		 * 
+		 * @param[in]	box			Box to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the box.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> boxCastAll(const AABox& box, const Quaternion& rotation, 
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a sphere and returns all found hits.
+		 * 
+		 * @param[in]	sphere		Sphere to sweep through the scene.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> sphereCastAll(const Sphere& sphere, const Vector3& direction, 
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a capsule and returns all found hits.
+		 * 
+		 * @param[in]	capsule		Capsule to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the capsule.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> capsuleCastAll(const Capsule& capsule, const Quaternion& rotation, 
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a convex mesh and returns all found hits.
+		 * 
+		 * @param[in]	mesh		Mesh to sweep through the scene. Must be convex.
+		 * @param[in]	position	Starting position of the mesh.
+		 * @param[in]	rotation	Orientation of the mesh.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					List of all detected hits.
+		 */
+		virtual Vector<PhysicsQueryHit> convexCastAll(const HPhysicsMesh& mesh, const Vector3& position, 
+			const Quaternion& rotation, const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Casts a ray into the scene and checks if it has hit anything. This can be significantly more efficient than other
+		 * types of cast* calls.
+		 * 
+		 * @param[in]	ray		Ray to cast into the scene.
+		 * @param[in]	layer	Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max		Maximum distance at which to perform the query. Hits past this distance will not be
+		 *						detected.
+		 * @return				True if something was hit, false otherwise.
+		 */
+		virtual bool rayCastAny(const Ray& ray, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Casts a ray into the scene and checks if it has hit anything. This can be significantly more efficient than other
+		 * types of cast* calls.
+		 * 
+		 * @param[in]	origin		Origin of the ray to cast into the scene.
+		 * @param[in]	direction	Direction of the ray to cast into the scene.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool rayCastAny(const Vector3& origin, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a box and checks if it has hit anything. This can be significantly more
+		 * efficient than other types of cast* calls.
+		 * 
+		 * @param[in]	box			Box to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the box.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool boxCastAny(const AABox& box, const Quaternion& rotation, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a sphere and checks if it has hit anything. This can be significantly more
+		 * efficient than other types of cast* calls.
+		 * 
+		 * @param[in]	sphere		Sphere to sweep through the scene.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool sphereCastAny(const Sphere& sphere, const Vector3& direction, 
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a capsule and checks if it has hit anything. This can be significantly more
+		 * efficient than other types of cast* calls.
+		 * 
+		 * @param[in]	capsule		Capsule to sweep through the scene.
+		 * @param[in]	rotation	Orientation of the capsule.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool capsuleCastAny(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Performs a sweep into the scene using a convex mesh and checks if it has hit anything. This can be significantly
+		 * more efficient than other types of cast* calls.
+		 * 
+		 * @param[in]	mesh		Mesh to sweep through the scene. Must be convex.
+		 * @param[in]	position	Starting position of the mesh.
+		 * @param[in]	rotation	Orientation of the mesh.
+		 * @param[in]	direction	Direction towards which to perform the sweep.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @param[in]	max			Maximum distance at which to perform the query. Hits past this distance will not be
+		 *							detected.
+		 * @return					True if something was hit, false otherwise.
+		 */
+		virtual bool convexCastAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) = 0;
+
+		/**
+		 * Returns a list of all colliders in the scene that overlap the provided box.
+		 * 
+		 * @param[in]	box			Box to check for overlap.
+		 * @param[in]	rotation	Orientation of the box.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					List of all colliders that overlap the box.
+		 */
+		virtual Vector<HCollider> boxOverlap(const AABox& box, const Quaternion& rotation, 
+			UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Returns a list of all colliders in the scene that overlap the provided sphere.
+		 * 
+		 * @param[in]	Sphere		Sphere to check for overlap.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					List of all colliders that overlap the sphere.
+		 */
+		virtual Vector<HCollider> sphereOverlap(const Sphere& sphere, UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Returns a list of all colliders in the scene that overlap the provided capsule.
+		 * 
+		 * @param[in]	capsule		Capsule to check for overlap.
+		 * @param[in]	rotation	Orientation of the capsule.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					List of all colliders that overlap the capsule.
+		 */
+		virtual Vector<HCollider> capsuleOverlap(const Capsule& capsule, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Returns a list of all colliders in the scene that overlap the provided convex mesh.
+		 * 
+		 * @param[in]	mesh		Mesh to check for overlap. Must be convex.
+		 * @param[in]	position	Position of the mesh.
+		 * @param[in]	rotation	Orientation of the mesh.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					List of all colliders that overlap the mesh.
+		 */
+		virtual Vector<HCollider> convexOverlap(const HPhysicsMesh& mesh, const Vector3& position, 
+			const Quaternion& rotation, UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Checks if the provided box overlaps any other collider in the scene.
+		 * 
+		 * @param[in]	box			Box to check for overlap.
+		 * @param[in]	rotation	Orientation of the box.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					True if there is overlap with another object, false otherwise.
+		 */
+		virtual bool boxOverlapAny(const AABox& box, const Quaternion& rotation, UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Checks if the provided sphere overlaps any other collider in the scene.
+		 * 
+		 * @param[in]	sphere		Sphere to check for overlap.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					True if there is overlap with another object, false otherwise.
+		 */
+		virtual bool sphereOverlapAny(const Sphere& sphere, UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Checks if the provided capsule overlaps any other collider in the scene.
+		 * 
+		 * @param[in]	capsule		Capsule to check for overlap.
+		 * @param[in]	rotation	Orientation of the capsule.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					True if there is overlap with another object, false otherwise.
+		 */
+		virtual bool capsuleOverlapAny(const Capsule& capsule, const Quaternion& rotation, 
+			UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/**
+		 * Checks if the provided convex mesh overlaps any other collider in the scene.
+		 * 
+		 * @param[in]	mesh		Mesh to check for overlap. Must be convex.
+		 * @param[in]	position	Position of the mesh.
+		 * @param[in]	rotation	Orientation of the mesh.
+		 * @param[in]	layer		Layers to consider for the query. This allows you to ignore certain groups of objects.
+		 * @return					True if there is overlap with another object, false otherwise.
+		 */
+		virtual bool convexOverlapAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) = 0;
+
+		/******************************************************************************************************************/
+		/************************************************* OPTIONS ********************************************************/
+		/******************************************************************************************************************/
+
 		virtual bool hasFlag(PhysicsFlags flag) const { return mFlags & flag; }
 		virtual void setFlag(PhysicsFlags flag, bool enabled) { if (enabled) mFlags |= flag; else mFlags &= ~flag; }
 

+ 2 - 0
BansheeCore/Source/BsCCharacterController.cpp

@@ -25,6 +25,8 @@ namespace BansheeEngine
 
 		output = mInternal->move(displacement);
 		updatePositionFromController();
+
+		return output;
 	}
 
 	Vector3 CCharacterController::getFootPosition() const

+ 98 - 0
BansheePhysX/Include/BsPhysX.h

@@ -69,6 +69,104 @@ namespace BansheeEngine
 		/** @copydoc Physics::createCharacterController*/
 		SPtr<CharacterController> createCharacterController(const CHAR_CONTROLLER_DESC& desc) override;
 
+		/** @copydoc Physics::rayCast(const Ray&, PhysicsQueryHit&, UINT64, float) */
+		bool rayCast(const Ray& ray, PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::rayCast(const Vector3&, const Vector3&, UINT64, float) */
+		bool rayCast(const Vector3& origin, const Vector3& direction, PhysicsQueryHit& hit,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::boxCast */
+		bool boxCast(const AABox& box, const Quaternion& rotation, const Vector3& direction, PhysicsQueryHit& hit,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::sphereCast */
+		bool sphereCast(const Sphere& sphere, const Vector3& direction, PhysicsQueryHit& hit,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::capsuleCast */
+		bool capsuleCast(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction,
+			PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::convexCast */
+		bool convexCast(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			const Vector3& direction, PhysicsQueryHit& hit, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::rayCastAll(const Ray&, UINT64, float) */
+		Vector<PhysicsQueryHit> rayCastAll(const Ray& ray, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::rayCastAll(const Vector3&, const Vector3&, UINT64, float) */
+		Vector<PhysicsQueryHit> rayCastAll(const Vector3& origin, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::boxCastAll */
+		Vector<PhysicsQueryHit> boxCastAll(const AABox& box, const Quaternion& rotation,
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::sphereCastAll */
+		Vector<PhysicsQueryHit> sphereCastAll(const Sphere& sphere, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::capsuleCastAll */
+		Vector<PhysicsQueryHit> capsuleCastAll(const Capsule& capsule, const Quaternion& rotation,
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::convexCastAll */
+		Vector<PhysicsQueryHit> convexCastAll(const HPhysicsMesh& mesh, const Vector3& position,
+			const Quaternion& rotation, const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::rayCastAny(const Ray&, UINT64, float) */
+		bool rayCastAny(const Ray& ray, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::rayCastAny(const Vector3&, const Vector3&, UINT64, float) */
+		bool rayCastAny(const Vector3& origin, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::boxCastAny */
+		bool boxCastAny(const AABox& box, const Quaternion& rotation, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::sphereCastAny */
+		bool sphereCastAny(const Sphere& sphere, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::capsuleCastAny */
+		bool capsuleCastAny(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction,
+			UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::convexCastAny */
+		bool convexCastAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			const Vector3& direction, UINT64 layer = BS_ALL_LAYERS, float max = FLT_MAX) override;
+
+		/** @copydoc Physics::boxOverlap */
+		Vector<HCollider> boxOverlap(const AABox& box, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::sphereOverlap */
+		Vector<HCollider> sphereOverlap(const Sphere& sphere, UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::capsuleOverlap */
+		Vector<HCollider> capsuleOverlap(const Capsule& capsule, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::convexOverlap */
+		Vector<HCollider> convexOverlap(const HPhysicsMesh& mesh, const Vector3& position,
+			const Quaternion& rotation, UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::boxOverlapAny */
+		bool boxOverlapAny(const AABox& box, const Quaternion& rotation, UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::sphereOverlapAny */
+		bool sphereOverlapAny(const Sphere& sphere, UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::capsuleOverlapAny */
+		bool capsuleOverlapAny(const Capsule& capsule, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) override;
+
+		/** @copydoc Physics::convexOverlapAny */
+		bool convexOverlapAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+			UINT64 layer = BS_ALL_LAYERS) override;
+
 		void setFlag(PhysicsFlags flags, bool enabled) override;
 
 		Vector3 getGravity() const override;

+ 8 - 0
BansheePhysX/Source/BsFPhysXCollider.cpp

@@ -12,6 +12,13 @@ namespace BansheeEngine
 	FPhysXCollider::FPhysXCollider(PxShape* shape)
 		:mShape(shape), mStaticBody(nullptr), mIsTrigger(false), mIsStatic(true)
 	{
+		UINT64 layer = 1;
+
+		PxFilterData data;
+		memcpy(&data.word0, &layer, sizeof(layer));
+		mShape->setSimulationFilterData(data);
+		mShape->setQueryFilterData(data);
+
 		mStaticBody = gPhysX().getPhysX()->createRigidStatic(PxTransform());
 		mStaticBody->attachShape(*mShape);
 
@@ -137,5 +144,6 @@ namespace BansheeEngine
 		PxFilterData data;
 		memcpy(&data.word0, &layer, sizeof(layer));
 		mShape->setSimulationFilterData(data);
+		mShape->setQueryFilterData(data);
 	}
 }

+ 175 - 0
BansheePhysX/Source/BsPhysX.cpp

@@ -583,6 +583,181 @@ namespace BansheeEngine
 		return bs_shared_ptr_new<PhysXCharacterController>(mCharManager, desc);
 	}
 
+	bool PhysX::rayCast(const Ray& ray, PhysicsQueryHit& hit, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::rayCast(const Vector3& origin, const Vector3& direction, PhysicsQueryHit& hit, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::boxCast(const AABox& box, const Quaternion& rotation, const Vector3& direction, PhysicsQueryHit& hit,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::sphereCast(const Sphere& sphere, const Vector3& direction, PhysicsQueryHit& hit,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::capsuleCast(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction,
+		PhysicsQueryHit& hit, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::convexCast(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+		const Vector3& direction, PhysicsQueryHit& hit, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	Vector<PhysicsQueryHit> PhysX::rayCastAll(const Ray& ray, UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	Vector<PhysicsQueryHit> PhysX::rayCastAll(const Vector3& origin, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	Vector<PhysicsQueryHit> PhysX::boxCastAll(const AABox& box, const Quaternion& rotation,
+		const Vector3& direction, UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	Vector<PhysicsQueryHit> PhysX::sphereCastAll(const Sphere& sphere, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	Vector<PhysicsQueryHit> PhysX::capsuleCastAll(const Capsule& capsule, const Quaternion& rotation,
+		const Vector3& direction, UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	Vector<PhysicsQueryHit> PhysX::convexCastAll(const HPhysicsMesh& mesh, const Vector3& position,
+		const Quaternion& rotation, const Vector3& direction, UINT64 layer, float max)
+	{
+		// TODO
+		return Vector<PhysicsQueryHit>();
+	}
+
+	bool PhysX::rayCastAny(const Ray& ray, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::rayCastAny(const Vector3& origin, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::boxCastAny(const AABox& box, const Quaternion& rotation, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::sphereCastAny(const Sphere& sphere, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::capsuleCastAny(const Capsule& capsule, const Quaternion& rotation, const Vector3& direction,
+		UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::convexCastAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+		const Vector3& direction, UINT64 layer, float max)
+	{
+		// TODO
+		return false;
+	}
+
+	Vector<HCollider> PhysX::boxOverlap(const AABox& box, const Quaternion& rotation,
+		UINT64 layer)
+	{
+		// TODO
+		return Vector<HCollider>();
+	}
+
+	Vector<HCollider> PhysX::sphereOverlap(const Sphere& sphere, UINT64 layer)
+	{
+		// TODO
+		return Vector<HCollider>();
+	}
+
+	Vector<HCollider> PhysX::capsuleOverlap(const Capsule& capsule, const Quaternion& rotation,
+		UINT64 layer)
+	{
+		// TODO
+		return Vector<HCollider>();
+	}
+
+	Vector<HCollider> PhysX::convexOverlap(const HPhysicsMesh& mesh, const Vector3& position,
+		const Quaternion& rotation, UINT64 layer)
+	{
+		// TODO
+		return Vector<HCollider>();
+	}
+
+	bool PhysX::boxOverlapAny(const AABox& box, const Quaternion& rotation, UINT64 layer)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::sphereOverlapAny(const Sphere& sphere, UINT64 layer)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::capsuleOverlapAny(const Capsule& capsule, const Quaternion& rotation,
+		UINT64 layer)
+	{
+		// TODO
+		return false;
+	}
+
+	bool PhysX::convexOverlapAny(const HPhysicsMesh& mesh, const Vector3& position, const Quaternion& rotation,
+		UINT64 layer)
+	{
+		// TODO
+		return false;
+	}
+
 	void PhysX::setFlag(PhysicsFlags flag, bool enabled)
 	{
 		Physics::setFlag(flag, enabled);

+ 1 - 0
BansheeUtility/Include/BsFwdDeclUtil.h

@@ -41,6 +41,7 @@ namespace BansheeEngine
 	class Quaternion;
 	class Radian;
 	class Ray;
+	class Capsule;
 	class Sphere;
 	class Vector2;
 	class Vector3;