diff --git a/Source/Engine/Physics/Physics.h b/Source/Engine/Physics/Physics.h index 2fc116020..c2a52cb05 100644 --- a/Source/Engine/Physics/Physics.h +++ b/Source/Engine/Physics/Physics.h @@ -471,4 +471,225 @@ public: /// If set to true triggers will be hit, otherwise will skip them. /// True if convex mesh overlaps any matching object, otherwise false. API_FUNCTION() static bool OverlapConvex(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Out) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true); + +private: + /// + /// Performs a line between two points in the scene, returns all hitpoints infos. + /// + /// The origin of the ray. + /// The end position of the line. + /// The result hits. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if ray hits an matching object, otherwise false. + API_FUNCTION(Public, Name = LineCastAll) static bool LineCastAllDynamic(const Vector3& start, const Vector3& end, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return LineCastAll(start, end, results, layerMask, hitTriggers); + } + + /// + /// Performs a raycast against objects in the scene, returns results in a RayCastHit structure. + /// + /// The origin of the ray. + /// The normalized direction of the ray. + /// The result hits. Valid only when method returns true. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if ray hits an matching object, otherwise false. + API_FUNCTION(Public, Name = RayCastAll) static bool RayCastAllDynamic(const Vector3& origin, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return RayCastAll(origin, direction, results, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a box geometry. + /// + /// The box center. + /// The half size of the box in each direction. + /// The normalized direction in which cast a box. + /// The result hits. Valid only when method returns true. + /// The box rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box hits an matching object, otherwise false. + API_FUNCTION(Public, Name = BoxCastAll) static bool BoxCastAllDynamic(const Vector3& center, const Vector3& halfExtents, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return BoxCastAll(center, halfExtents, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a sphere geometry. + /// + /// The sphere center. + /// The radius of the sphere. + /// The normalized direction in which cast a sphere. + /// The result hits. Valid only when method returns true. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere hits an matching object, otherwise false. + API_FUNCTION(Public, Name = SphereCastAll) static bool SphereCastAllDynamic(const Vector3& center, float radius, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return SphereCastAll(center, radius, direction, results, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a capsule geometry. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The normalized direction in which cast a capsule. + /// The result hits. Valid only when method returns true. + /// The capsule rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule hits an matching object, otherwise false. + API_FUNCTION(Public, Name = CapsuleCastAll) static bool CapsuleCastAllDynamic(const Vector3& center, float radius, float height, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return CapsuleCastAll(center, radius, height, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The normalized direction in which cast a convex mesh. + /// The result hits. Valid only when method returns true. + /// The convex mesh rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh hits an matching object, otherwise false. + API_FUNCTION(Public, Name = ConvexCastAll) static bool ConvexCastAllDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return ConvexCastAll(center, convexMesh, scale, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given box. + /// + /// The box center. + /// The half size of the box in each direction. + /// The box rotation. + /// The result colliders that overlap with the given box. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapBox) static bool OverlapBoxDynamic(const Vector3& center, const Vector3& halfExtents, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapBox(center, halfExtents, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given sphere. + /// + /// The sphere center. + /// The radius of the sphere. + /// The result colliders that overlap with the given sphere. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapSphere) static bool OverlapSphereDynamic(const Vector3& center, float radius, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapSphere(center, radius, results, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given capsule. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The result colliders that overlap with the given capsule. Valid only when method returns true. + /// The capsule rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapCapsule) static bool OverlapCapsuleDynamic(const Vector3& center, float radius, float height, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapCapsule(center, radius, height, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The result colliders that overlap with the given convex mesh. Valid only when method returns true. + /// The convex mesh rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapConvex) static bool OverlapConvexDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapConvex(center, convexMesh, scale, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given box. + /// + /// The box center. + /// The half size of the box in each direction. + /// The box rotation. + /// The result colliders that overlap with the given box. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapBox) static bool OverlapBoxDynamic(const Vector3& center, const Vector3& halfExtents, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapBox(center, halfExtents, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given sphere. + /// + /// The sphere center. + /// The radius of the sphere. + /// The result colliders that overlap with the given sphere. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapSphere) static bool OverlapSphereDynamic(const Vector3& center, float radius, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapSphere(center, radius, results, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given capsule. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The result colliders that overlap with the given capsule. Valid only when method returns true. + /// The capsule rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapCapsule) static bool OverlapCapsuleDynamic(const Vector3& center, float radius, float height, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapCapsule(center, radius, height, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The result colliders that overlap with the given convex mesh. Valid only when method returns true. + /// The convex mesh rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapConvex) static bool OverlapConvexDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapConvex(center, convexMesh, scale, results, rotation, layerMask, hitTriggers); + } }; diff --git a/Source/Engine/Physics/PhysicsScene.h b/Source/Engine/Physics/PhysicsScene.h index 602e6f713..46fef88b3 100644 --- a/Source/Engine/Physics/PhysicsScene.h +++ b/Source/Engine/Physics/PhysicsScene.h @@ -509,4 +509,225 @@ public: /// If set to true triggers will be hit, otherwise will skip them. /// True if convex mesh overlaps any matching object, otherwise false. API_FUNCTION() bool OverlapConvex(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Out) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true); + +private: + /// + /// Performs a line between two points in the scene, returns all hitpoints infos. + /// + /// The origin of the ray. + /// The normalized direction of the ray. + /// The result hits. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if ray hits an matching object, otherwise false. + API_FUNCTION(Public, Name = LineCastAll) bool LineCastAllDynamic(const Vector3& start, const Vector3& end, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return LineCastAll(start, end, results, layerMask, hitTriggers); + } + + /// + /// Performs a raycast against objects in the scene, returns results in a RayCastHit structure. + /// + /// The origin of the ray. + /// The normalized direction of the ray. + /// The result hits. Valid only when method returns true. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if ray hits an matching object, otherwise false. + API_FUNCTION(Public, Name = RayCastAll) bool RayCastAllDynamic(const Vector3& origin, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return RayCastAll(origin, direction, results, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a box geometry. + /// + /// The box center. + /// The half size of the box in each direction. + /// The normalized direction in which cast a box. + /// The result hits. Valid only when method returns true. + /// The box rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box hits an matching object, otherwise false. + API_FUNCTION(Public, Name = BoxCastAll) bool BoxCastAllDynamic(const Vector3& center, const Vector3& halfExtents, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return BoxCastAll(center, halfExtents, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a sphere geometry. + /// + /// The sphere center. + /// The radius of the sphere. + /// The normalized direction in which cast a sphere. + /// The result hits. Valid only when method returns true. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere hits an matching object, otherwise false. + API_FUNCTION(Public, Name = SphereCastAll) bool SphereCastAllDynamic(const Vector3& center, float radius, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return SphereCastAll(center, radius, direction, results, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a capsule geometry. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The normalized direction in which cast a capsule. + /// The result hits. Valid only when method returns true. + /// The capsule rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule hits an matching object, otherwise false. + API_FUNCTION(Public, Name = CapsuleCastAll) bool CapsuleCastAllDynamic(const Vector3& center, float radius, float height, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return CapsuleCastAll(center, radius, height, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Performs a sweep test against objects in the scene using a convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The normalized direction in which cast a convex mesh. + /// The result hits. Valid only when method returns true. + /// The convex mesh rotation. + /// The maximum distance the ray should check for collisions. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh hits an matching object, otherwise false. + API_FUNCTION(Public, Name = ConvexCastAll) bool ConvexCastAllDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, const Vector3& direction, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, float maxDistance = MAX_float, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return ConvexCastAll(center, convexMesh, scale, direction, results, rotation, maxDistance, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given box. + /// + /// The box center. + /// The half size of the box in each direction. + /// The box rotation. + /// The result colliders that overlap with the given box. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapBox) bool OverlapBoxDynamic(const Vector3& center, const Vector3& halfExtents, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapBox(center, halfExtents, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given sphere. + /// + /// The sphere center. + /// The radius of the sphere. + /// The result colliders that overlap with the given sphere. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapSphere) bool OverlapSphereDynamic(const Vector3& center, float radius, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapSphere(center, radius, results, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given capsule. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The result colliders that overlap with the given capsule. Valid only when method returns true. + /// The capsule rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapCapsule) bool OverlapCapsuleDynamic(const Vector3& center, float radius, float height, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapCapsule(center, radius, height, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The result colliders that overlap with the given convex mesh. Valid only when method returns true. + /// The convex mesh rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapConvex) bool OverlapConvexDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapConvex(center, convexMesh, scale, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given box. + /// + /// The box center. + /// The half size of the box in each direction. + /// The box rotation. + /// The result colliders that overlap with the given box. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if box overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapBox) bool OverlapBoxDynamic(const Vector3& center, const Vector3& halfExtents, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapBox(center, halfExtents, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given sphere. + /// + /// The sphere center. + /// The radius of the sphere. + /// The result colliders that overlap with the given sphere. Valid only when method returns true. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if sphere overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapSphere) bool OverlapSphereDynamic(const Vector3& center, float radius, API_PARAM(Ref, DynamicArray) Array& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapSphere(center, radius, results, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given capsule. + /// + /// The capsule center. + /// The radius of the capsule. + /// The height of the capsule, excluding the top and bottom spheres. + /// The result colliders that overlap with the given capsule. Valid only when method returns true. + /// The capsule rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if capsule overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapCapsule) bool OverlapCapsuleDynamic(const Vector3& center, float radius, float height, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapCapsule(center, radius, height, results, rotation, layerMask, hitTriggers); + } + + /// + /// Finds all colliders touching or inside of the given convex mesh. + /// + /// The convex mesh center. + /// Collision data of the convex mesh. + /// The scale of the convex mesh. + /// The result colliders that overlap with the given convex mesh. Valid only when method returns true. + /// The convex mesh rotation. + /// The layer mask used to filter the results. + /// If set to true triggers will be hit, otherwise will skip them. + /// True if convex mesh overlaps any matching object, otherwise false. + API_FUNCTION(Public, Name = OverlapConvex) bool OverlapConvexDynamic(const Vector3& center, const CollisionData* convexMesh, const Vector3& scale, API_PARAM(Ref, DynamicArray) Array& results, const Quaternion& rotation = Quaternion::Identity, uint32 layerMask = MAX_uint32, bool hitTriggers = true) + { + return OverlapConvex(center, convexMesh, scale, results, rotation, layerMask, hitTriggers); + } };