add simple linecast to physics
This commit is contained in:
@@ -218,6 +218,11 @@ void Physics::FlushRequests()
|
||||
PhysicsBackend::FlushRequests();
|
||||
}
|
||||
|
||||
bool Physics::LineCast(const Vector3& start, const Vector3& end, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
return DefaultScene->LineCast(start, end, 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);
|
||||
@@ -450,6 +455,13 @@ void PhysicsScene::CollectResults()
|
||||
_isDuringSimulation = false;
|
||||
}
|
||||
|
||||
bool PhysicsScene::LineCast(const Vector3& start, const Vector3& end, uint32 layerMask, bool hitTriggers)
|
||||
{
|
||||
float distanceToEnd = Vector3::Distance(start, end);
|
||||
Vector3 directionToEnd = (end - start).GetNormalized();
|
||||
return PhysicsBackend::RayCast(_scene, start, directionToEnd, 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);
|
||||
|
||||
@@ -95,6 +95,16 @@ public:
|
||||
API_FUNCTION() static void FlushRequests();
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Performs a line between two points in the scene.
|
||||
/// </summary>
|
||||
/// <param name="start">The start position of the line.</param>
|
||||
/// <param name="end">The end position of the line.</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 LineCast(const Vector3& start, const Vector3& end, uint32 layerMask = MAX_uint32, bool hitTriggers = true);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a raycast against objects in the scene.
|
||||
/// </summary>
|
||||
|
||||
@@ -126,6 +126,16 @@ public:
|
||||
API_FUNCTION() void CollectResults();
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Performs a line between two points in the scene.
|
||||
/// </summary>
|
||||
/// <param name="start">The start position of the line.</param>
|
||||
/// <param name="end">The end position of the line.</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 LineCast(const Vector3& start, const Vector3& end, uint32 layerMask = MAX_uint32, bool hitOnTriggers = true);
|
||||
/// <summary>
|
||||
/// Performs a raycast against objects in the scene.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user