add LineCastAll

This commit is contained in:
Ruan Lucas
2023-06-03 13:52:50 -04:00
parent eda4def35b
commit e32f4d5f8c
3 changed files with 34 additions and 0 deletions

View File

@@ -228,6 +228,11 @@ bool Physics::LineCast(const Vector3& start, const Vector3& end, API_PARAM(Out)R
return DefaultScene->LineCast(start, end, hitInfo, layerMask, hitTriggers);
}
bool Physics::LineCastAll(const Vector3& start, const Vector3& end, API_PARAM(Out)Array<RayCastHit, HeapAllocation>& results, uint32 layerMask, bool hitTriggers)
{
return DefaultScene->LineCastAll(start, end, results, layerMask, hitTriggers);
}
bool Physics::RayCast(const Vector3& origin, const Vector3& direction, const float maxDistance, uint32 layerMask, bool hitTriggers)
{
return DefaultScene->RayCast(origin, direction, maxDistance, layerMask, hitTriggers);
@@ -474,6 +479,13 @@ bool PhysicsScene::LineCast(const Vector3& start, const Vector3& end, API_PARAM(
return PhysicsBackend::RayCast(_scene, start, directionToEnd, hitInfo, distanceToEnd, layerMask, hitTriggers);
}
bool PhysicsScene::LineCastAll(const Vector3& start, const Vector3& end, API_PARAM(Out)Array<RayCastHit, HeapAllocation>& results, uint32 layerMask, bool hitTriggers)
{
float distanceToEnd = Vector3::Distance(start, end);
Vector3 directionToEnd = (end - start).GetNormalized();
return PhysicsBackend::RayCastAll(_scene, start, directionToEnd, results, distanceToEnd, layerMask, hitTriggers);
}
bool PhysicsScene::RayCast(const Vector3& origin, const Vector3& direction, const float maxDistance, uint32 layerMask, bool hitTriggers)
{
return PhysicsBackend::RayCast(_scene, origin, direction, maxDistance, layerMask, hitTriggers);

View File

@@ -116,6 +116,17 @@ public:
/// <returns>True if ray hits an matching object, otherwise false.</returns>
API_FUNCTION() static bool LineCast(const Vector3& start, const Vector3& end, API_PARAM(Out) RayCastHit& hitInfo, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
// <summary>
/// Performs a line between two points in the scene, returns all hitpoints infos.
/// </summary>
/// <param name="start">The origin of the ray.</param>
/// <param name="end">The normalized direction of the ray.</param>
/// <param name="results">The result hits. Valid only when method returns true.</param>
/// <param name="layerMask">The layer mask used to filter the results.</param>
/// <param name="hitTriggers">If set to <c>true</c> triggers will be hit, otherwise will skip them.</param>
/// <returns>True if ray hits an matching object, otherwise false.</returns>
API_FUNCTION() static bool LineCastAll(const Vector3& start, const Vector3& end, API_PARAM(Out) Array<RayCastHit, HeapAllocation>& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
/// <summary>
/// Performs a raycast against objects in the scene.
/// </summary>

View File

@@ -148,6 +148,17 @@ public:
/// <returns>True if ray hits an matching object, otherwise false.</returns>
API_FUNCTION() bool LineCast(const Vector3& start, const Vector3& end, API_PARAM(Out) RayCastHit& hitInfo, uint32 layerMask = MAX_uint32, bool hitOnTriggers = true);
// <summary>
/// Performs a line between two points in the scene, returns all hitpoints infos.
/// </summary>
/// <param name="start">The origin of the ray.</param>
/// <param name="end">The normalized direction of the ray.</param>
/// <param name="results">The result hits. Valid only when method returns true.</param>
/// <param name="layerMask">The layer mask used to filter the results.</param>
/// <param name="hitTriggers">If set to <c>true</c> triggers will be hit, otherwise will skip them.</param>
/// <returns>True if ray hits an matching object, otherwise false.</returns>
API_FUNCTION() bool LineCastAll(const Vector3& start, const Vector3& end, API_PARAM(Out) Array<RayCastHit, HeapAllocation>& results, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
/// <summary>
/// Performs a raycast against objects in the scene.
/// </summary>