Move collider shape raycasting utilities to the PhysicsColliderActor class

This commit is contained in:
Wojtek Figat
2024-02-16 17:19:51 +01:00
parent 42b4443e14
commit 85f2910718
6 changed files with 55 additions and 70 deletions

View File

@@ -84,40 +84,6 @@ public:
JsonAssetReference<PhysicalMaterial> Material;
public:
/// <summary>
/// Performs a raycast against this collider shape.
/// </summary>
/// <param name="origin">The origin of the ray.</param>
/// <param name="direction">The normalized direction of the ray.</param>
/// <param name="resultHitDistance">The raycast result hit position distance from the ray origin. Valid only if raycast hits anything.</param>
/// <param name="maxDistance">The maximum distance the ray should check for collisions.</param>
/// <returns>True if ray hits an object, otherwise false.</returns>
API_FUNCTION() bool RayCast(const Vector3& origin, const Vector3& direction, API_PARAM(Out) float& resultHitDistance, float maxDistance = MAX_float) const;
/// <summary>
/// Performs a raycast against this collider, returns results in a RaycastHit structure.
/// </summary>
/// <param name="origin">The origin of the ray.</param>
/// <param name="direction">The normalized direction of the ray.</param>
/// <param name="hitInfo">The result hit information. Valid only when method returns true.</param>
/// <param name="maxDistance">The maximum distance the ray should check for collisions.</param>
/// <returns>True if ray hits an object, otherwise false.</returns>
API_FUNCTION() bool RayCast(const Vector3& origin, const Vector3& direction, API_PARAM(Out) RayCastHit& hitInfo, float maxDistance = MAX_float) const;
/// <summary>
/// Gets a point on the collider that is closest to a given location. Can be used to find a hit location or position to apply explosion force or any other special effects.
/// </summary>
/// <param name="point">The position to find the closest point to it.</param>
/// <param name="result">The result point on the collider that is closest to the specified location.</param>
API_FUNCTION() void ClosestPoint(const Vector3& point, API_PARAM(Out) Vector3& result) const;
/// <summary>
/// Checks if a point is inside the collider.
/// </summary>
/// <param name="point">The point to check if is contained by the collider shape (in world-space).</param>
/// <returns>True if collider shape contains a given point, otherwise false.</returns>
API_FUNCTION() bool ContainsPoint(const Vector3& point) const;
/// <summary>
/// Computes minimum translational distance between two geometry objects.
/// Translating the first collider by direction * distance will separate the colliders apart if the function returned true. Otherwise, direction and distance are not defined.
@@ -198,6 +164,10 @@ private:
public:
// [PhysicsColliderActor]
RigidBody* GetAttachedRigidBody() const override;
bool RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance = MAX_float) const final;
bool RayCast(const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, float maxDistance = MAX_float) const final;
void ClosestPoint(const Vector3& point, Vector3& result) const final;
bool ContainsPoint(const Vector3& point) const final;
protected:
// [PhysicsColliderActor]