Merge pull request #4694 from aws-lumberyard-dev/shape-collider-compatibility

mark not yet supported shapes incompatible with shape collider compon…
This commit is contained in:
greerdv
2021-10-18 13:25:52 +01:00
committed by GitHub
3 changed files with 9 additions and 29 deletions
@@ -121,8 +121,14 @@ namespace PhysX
void EditorShapeColliderComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("LegacyCryPhysicsService", 0xbb370351));
incompatible.push_back(AZ_CRC("PhysXShapeColliderService", 0x98a7e779));
incompatible.push_back(AZ_CRC_CE("LegacyCryPhysicsService"));
incompatible.push_back(AZ_CRC_CE("PhysXShapeColliderService"));
incompatible.push_back(AZ_CRC_CE("AxisAlignedBoxShapeService"));
incompatible.push_back(AZ_CRC_CE("CompoundShapeService"));
incompatible.push_back(AZ_CRC_CE("DiskShapeService"));
incompatible.push_back(AZ_CRC_CE("QuadShapeService"));
incompatible.push_back(AZ_CRC_CE("TubeShapeService"));
incompatible.push_back(AZ_CRC_CE("ReferenceShapeService"));
}
const AZStd::vector<AZ::Vector3>& EditorShapeColliderComponent::GetSamplePoints() const
@@ -338,33 +338,6 @@ namespace PhysXEditorTests
ValidateInvalidEditorShapeColliderComponentParams(0.f, -1.f);
}
TEST_F(PhysXEditorFixture, EditorShapeColliderComponent_ShapeColliderWithUnsupportedShape_HandledGracefully)
{
UnitTest::ErrorHandler unsupportedShapeWarningHandler("Unsupported shape");
UnitTest::ErrorHandler rigidBodyWarningHandler("No Collider or Shape information found when creating Rigid body");
// create an editor entity with a shape collider component and a cylinder shape component
// the cylinder shape is not currently supported by the shape collider component
EntityPtr editorEntity = CreateInactiveEditorEntity("ShapeColliderComponentEditorEntity");
editorEntity->CreateComponent<PhysX::EditorShapeColliderComponent>();
editorEntity->CreateComponent(LmbrCentral::EditorCompoundShapeComponentTypeId);
editorEntity->Activate();
EXPECT_EQ(unsupportedShapeWarningHandler.GetExpectedWarningCount(), 1);
EXPECT_EQ(rigidBodyWarningHandler.GetExpectedWarningCount(), 1);
EntityPtr gameEntity = CreateActiveGameEntityFromEditorEntity(editorEntity.get());
// since there was no editor rigid body component, the runtime entity should have a static rigid body
const auto* staticBody = azdynamic_cast<PhysX::StaticRigidBody*>(gameEntity->FindComponent<PhysX::StaticRigidBodyComponent>()->GetSimulatedBody());
const auto* pxRigidStatic = static_cast<const physx::PxRigidStatic*>(staticBody->GetNativePointer());
PHYSX_SCENE_READ_LOCK(pxRigidStatic->getScene());
// there should be no shapes on the rigid body because the cylinder is not supported
EXPECT_EQ(pxRigidStatic->getNbShapes(), 0);
}
TEST_F(PhysXEditorFixture, EditorShapeColliderComponent_ShapeColliderWithBoxAndRigidBody_CorrectRuntimeComponents)
{
// create an editor entity with a shape collider component and a box shape component
@@ -50,6 +50,7 @@ namespace Vegetation
void ReferenceShapeComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services)
{
services.push_back(AZ_CRC("ShapeService", 0xe86aa5fe));
services.push_back(AZ_CRC_CE("ReferenceShapeService"));
}
void ReferenceShapeComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services)