Merge branch 'development' into LYN-4501
Signed-off-by: John Jones-Steele <jjjoness@amazon.com>
This commit is contained in:
@@ -3252,6 +3252,7 @@ LUA_API const Node* lua_getDummyNode()
|
||||
else if (Internal::LuaScriptNumber<short>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<AZ::s64>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<long>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<AZ::s8>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<unsigned char>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<unsigned short>::FromStack(param, result)) return result;
|
||||
else if (Internal::LuaScriptNumber<unsigned int>::FromStack(param, result)) return result;
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace AzPhysics
|
||||
->Property("Distance", BehaviorValueProperty(&RayCastRequest::m_distance))
|
||||
->Property("Start", BehaviorValueProperty(&RayCastRequest::m_start))
|
||||
->Property("Direction", BehaviorValueProperty(&RayCastRequest::m_direction))
|
||||
->Property("ReportMultipleHits", BehaviorValueProperty(&RayCastRequest::m_reportMultipleHits))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -153,6 +154,45 @@ namespace AzPhysics
|
||||
->Field("ReportMultipleHits", &ShapeCastRequest::m_reportMultipleHits)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto* behaviorContext = azdynamic_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<ShapeCastRequest>("ShapeCastRequest")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Script::Attributes::Category, "PhysX")
|
||||
->Property("Distance", BehaviorValueProperty(&ShapeCastRequest::m_distance))
|
||||
->Property("Start", BehaviorValueProperty(&ShapeCastRequest::m_start))
|
||||
->Property("Direction", BehaviorValueProperty(&ShapeCastRequest::m_direction))
|
||||
;
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateSphereCastRequest",
|
||||
[](float radius, const AZ::Transform& startPose, const AZ::Vector3& direction, float distance,
|
||||
SceneQuery::QueryType queryType, CollisionGroup collisionGroup)
|
||||
{
|
||||
return ShapeCastRequestHelpers::CreateSphereCastRequest(
|
||||
radius, startPose, direction, distance, queryType, collisionGroup, nullptr);
|
||||
});
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateBoxCastRequest",
|
||||
[](const AZ::Vector3& boxDimensions, const AZ::Transform& startPose, const AZ::Vector3& direction, float distance,
|
||||
SceneQuery::QueryType queryType, CollisionGroup collisionGroup)
|
||||
{
|
||||
return ShapeCastRequestHelpers::CreateBoxCastRequest(
|
||||
boxDimensions, startPose, direction, distance, queryType, collisionGroup, nullptr);
|
||||
});
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateCapsuleCastRequest",
|
||||
[](float capsuleRadius, float capsuleHeight, const AZ::Transform& startPose, const AZ::Vector3& direction, float distance,
|
||||
SceneQuery::QueryType queryType, CollisionGroup collisionGroup)
|
||||
{
|
||||
return ShapeCastRequestHelpers::CreateCapsuleCastRequest(
|
||||
capsuleRadius, capsuleHeight, startPose, direction, distance, queryType, collisionGroup, nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace ShapeCastRequestHelpers
|
||||
@@ -219,6 +259,40 @@ namespace AzPhysics
|
||||
->Field("ShapeConfiguration", &OverlapRequest::m_shapeConfiguration)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto* behaviorContext = azdynamic_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<OverlapRequest>("OverlapRequest")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Script::Attributes::Category, "PhysX")
|
||||
->Property("Pose", BehaviorValueProperty(&OverlapRequest::m_pose))
|
||||
;
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateSphereOverlapRequest",
|
||||
[](float radius, const AZ::Transform& pose)
|
||||
{
|
||||
return OverlapRequestHelpers::CreateSphereOverlapRequest(
|
||||
radius, pose, nullptr);
|
||||
});
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateBoxOverlapRequest",
|
||||
[](const AZ::Vector3& boxDimensions, const AZ::Transform& pose)
|
||||
{
|
||||
return OverlapRequestHelpers::CreateBoxOverlapRequest(
|
||||
boxDimensions, pose, nullptr);
|
||||
});
|
||||
|
||||
behaviorContext->Method(
|
||||
"CreateCapsuleOverlapRequest",
|
||||
[](float height, float radius, const AZ::Transform& pose)
|
||||
{
|
||||
return OverlapRequestHelpers::CreateCapsuleOverlapRequest(
|
||||
height, radius, pose, nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace OverlapRequestHelpers
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace AzPhysics
|
||||
->Attribute(AZ::Script::Attributes::Category, "Physics")
|
||||
->Method("GetOnGravityChangeEvent", getOnGravityChange)
|
||||
->Attribute(AZ::Script::Attributes::AzEventDescription, gravityChangedEventDescription)
|
||||
->Method("QueryScene", &Scene::QueryScene)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace AzPhysics
|
||||
{"Tick time"} // Parameters
|
||||
};
|
||||
|
||||
behaviorContext->Class<SystemInterface>("System Interface")
|
||||
behaviorContext->Class<SystemInterface>("PhysicsSystemInterface")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Script::Attributes::Category, "PhysX")
|
||||
@@ -49,7 +49,21 @@ namespace AzPhysics
|
||||
->Attribute(AZ::Script::Attributes::AzEventDescription, presimulateEventDescription)
|
||||
->Method("GetOnPostsimulateEvent", getOnPostsimulateEvent)
|
||||
->Attribute(AZ::Script::Attributes::AzEventDescription, postsimulateEventDescription)
|
||||
;
|
||||
->Method("GetSceneHandle", &SystemInterface::GetSceneHandle)
|
||||
->Method("GetScene", &SystemInterface::GetScene);
|
||||
|
||||
behaviorContext->Method(
|
||||
"GetPhysicsSystem",
|
||||
[]()
|
||||
{
|
||||
return AZ::Interface<AzPhysics::SystemInterface>::Get();
|
||||
});
|
||||
|
||||
behaviorContext
|
||||
->Constant("DefaultPhysicsSceneName", BehaviorConstant(DefaultPhysicsSceneName))
|
||||
->Constant("DefaultPhysicsSceneId", BehaviorConstant(DefaultPhysicsSceneId))
|
||||
->Constant("EditorPhysicsSceneName", BehaviorConstant(EditorPhysicsSceneName))
|
||||
->Constant("EditorPhysicsSceneId", BehaviorConstant(EditorPhysicsSceneId));
|
||||
}
|
||||
}
|
||||
} // namespace AzPhysics
|
||||
|
||||
@@ -491,6 +491,10 @@ namespace PhysX
|
||||
{
|
||||
m_physicsSystemConfigChanged.Disconnect();
|
||||
|
||||
s_overlapBuffer.swap({});
|
||||
s_rayCastBuffer.swap({});
|
||||
s_sweepBuffer.swap({});
|
||||
|
||||
for (auto& simulatedBody : m_simulatedBodies)
|
||||
{
|
||||
if (simulatedBody.second != nullptr)
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace PhysX
|
||||
AZStd::unique_ptr<AZ::ScriptContext> m_scriptContext;
|
||||
};
|
||||
|
||||
TEST_F(PhysXScriptTest, ScriptedRaycast_RaycastNotIntersectingBox_ReturnsNoHits)
|
||||
TEST_F(PhysXScriptTest, SimulatedBodyRaycast_RaycastNotIntersectingBox_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
@@ -109,7 +109,7 @@ namespace PhysX
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, ScriptedRaycast_RaycastIntersectingBox_ReturnsHitOnBox)
|
||||
TEST_F(PhysXScriptTest, SimulatedBodyRaycast_RaycastIntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
@@ -131,7 +131,7 @@ namespace PhysX
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, ScriptedRaycast_RaycastNotInteractingCollisionFilters_ReturnsNoHit)
|
||||
TEST_F(PhysXScriptTest, SimulatedBodyRaycast_RaycastNonInteractingCollisionFilters_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
@@ -153,4 +153,385 @@ namespace PhysX
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SceneRayCast_RaycastNotIntersectingBox_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
request = RayCastRequest()
|
||||
request.Start = Vector3(5.0, 0.0, 5.0)
|
||||
request.Direction = Vector3(0.0, 0.0, -1.0)
|
||||
request.Distance = 10.0
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 0)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SceneRayCast_RaycastIntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
request = RayCastRequest()
|
||||
request.Start = Vector3(0.0, 0.0, 5.0)
|
||||
request.Direction = Vector3(0.0, 0.0, -1.0)
|
||||
request.Distance = 10.0
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SceneRayCast_MultipleHitRaycastIntersectingBoxes_ReturnsMultipleHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box1",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box1")
|
||||
});
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box2",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateAxisZ(-5.0f), "Box2")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
box1Id = GetTestEntityId("Box1")
|
||||
box2Id = GetTestEntityId("Box2")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
request = RayCastRequest()
|
||||
request.Start = Vector3(0.0, 0.0, 5.0)
|
||||
request.Direction = Vector3(0.0, 0.0, -1.0)
|
||||
request.Distance = 10.0
|
||||
request.ReportMultipleHits = true
|
||||
hits = scene:QueryScene(request)
|
||||
numHits = hits.HitArray:Size()
|
||||
box1Hit = false
|
||||
box2Hit = false
|
||||
for hitIndex = 1, numHits do
|
||||
box1Hit = box1Hit or hits.HitArray[hitIndex].EntityId == box1Id
|
||||
box2Hit = box2Hit or hits.HitArray[hitIndex].EntityId == box2Id
|
||||
end
|
||||
ExpectTrue(box1Hit)
|
||||
ExpectTrue(box2Hit)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SceneRaycast_RaycastNonInteractingCollisionFilters_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
request = RayCastRequest()
|
||||
request.Start = Vector3(0.0, 0.0, 5.0)
|
||||
request.Direction = Vector3(0.0, 0.0, -1.0)
|
||||
request.Distance = 10.0
|
||||
request.Collision = CollisionGroup("None")
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 0)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, BoxCast_NotIntersectingBox_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
boxDimensions = Vector3(1.0, 1.0, 1.0)
|
||||
startPose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
direction = Vector3(-1.0, 0.0, 0.0)
|
||||
distance = 10.0
|
||||
queryType = 0
|
||||
collisionGroup = CollisionGroup("All")
|
||||
request = CreateBoxCastRequest(boxDimensions, startPose, direction, distance, queryType, collisionGroup)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 0)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, BoxCast_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
boxDimensions = Vector3(1.0, 1.0, 1.0)
|
||||
startPose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
direction = Vector3(0.0, 0.0, -1.0)
|
||||
distance = 10.0
|
||||
queryType = 0
|
||||
collisionGroup = CollisionGroup("All")
|
||||
request = CreateBoxCastRequest(boxDimensions, startPose, direction, distance, queryType, collisionGroup)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, BoxCast_NonInteractingCollisionFilters_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
boxDimensions = Vector3(1.0, 1.0, 1.0)
|
||||
startPose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
direction = Vector3(0.0, 0.0, -1.0)
|
||||
distance = 10.0
|
||||
queryType = 0
|
||||
collisionGroup = CollisionGroup("None")
|
||||
request = CreateBoxCastRequest(boxDimensions, startPose, direction, distance, queryType, collisionGroup)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 0)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SphereCast_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
radius = 2.0
|
||||
startPose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
direction = Vector3(0.0, 0.0, -1.0)
|
||||
distance = 10.0
|
||||
queryType = 0
|
||||
collisionGroup = CollisionGroup("All")
|
||||
request = CreateSphereCastRequest(radius, startPose, direction, distance, queryType, collisionGroup)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, CapsuleCast_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
radius = 0.5
|
||||
height = 2.0
|
||||
startPose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
direction = Vector3(0.0, 0.0, -1.0)
|
||||
distance = 10.0
|
||||
queryType = 0
|
||||
collisionGroup = CollisionGroup("All")
|
||||
request = CreateCapsuleCastRequest(radius, height, startPose, direction, distance, queryType, collisionGroup)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, BoxOverlap_NotIntersectingBox_ReturnsNoHits)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
boxDimensions = Vector3(1.0, 1.0, 1.0)
|
||||
pose = Transform.CreateTranslation(Vector3(0.0, 0.0, 5.0))
|
||||
request = CreateBoxOverlapRequest(boxDimensions, pose)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 0)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, BoxOverlap_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
boxDimensions = Vector3(1.0, 1.0, 1.0)
|
||||
pose = Transform.CreateTranslation(Vector3(0.0, 0.0, 0.0))
|
||||
request = CreateBoxOverlapRequest(boxDimensions, pose)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, SphereOverlap_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
radius = 0.5
|
||||
pose = Transform.CreateTranslation(Vector3(0.0, 0.0, 0.0))
|
||||
request = CreateSphereOverlapRequest(radius, pose)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
|
||||
TEST_F(PhysXScriptTest, CapsuleOverlap_IntersectingBox_ReturnsHitOnBox)
|
||||
{
|
||||
s_testEntities.insert(
|
||||
{
|
||||
"Box",
|
||||
TestUtils::AddStaticUnitTestObject<BoxColliderComponent>(GetDefaultSceneHandle(), AZ::Vector3::CreateZero(), "Box")
|
||||
});
|
||||
|
||||
const char luaCode[] =
|
||||
R"(
|
||||
boxId = GetTestEntityId("Box")
|
||||
physicsSystem = GetPhysicsSystem()
|
||||
sceneHandle = physicsSystem:GetSceneHandle(DefaultPhysicsSceneName)
|
||||
scene = physicsSystem:GetScene(sceneHandle)
|
||||
|
||||
height = 2.0
|
||||
radius = 0.5
|
||||
pose = Transform.CreateTranslation(Vector3(0.0, 0.0, 0.0))
|
||||
request = CreateCapsuleOverlapRequest(height, radius, pose)
|
||||
|
||||
hits = scene:QueryScene(request)
|
||||
ExpectTrue(hits.HitArray:Size() == 1)
|
||||
hit = hits.HitArray[1] -- lua uses 1-indexing
|
||||
ExpectTrue(hit.EntityId == boxId)
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(GetScriptContext()->Execute(luaCode));
|
||||
}
|
||||
} // namespace PhysX
|
||||
|
||||
Reference in New Issue
Block a user