Initial improvements to fix viewport icon selection and draw order (#6284)

* wip fixes for entity viewport icons displaying in the correct order and handling selection correctly

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add additional comment about z value

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* move manual sorting and some small tidy-up

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update comment

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* updates following initial round of PR feedback

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* additional changes to support tests for entity icon intersection

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* add support to enable/disable icons separately from helpers

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* final tests added and small tidy-up to display EntityId correctly

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update some manipulator test framework calls after utility functions were moved

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* fix for implicit cast

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* move icon scale values to AZ_CVARS

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* fix failing tests caught in AR and update some naming conventions for tests

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update naming convention for members of ProjectedViewportRay

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update other references to ProjectedViewportRay

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update more references to ProjectedViewportRay change

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>

* update menus for python tests

Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
Tom Hulton-Harrop
2021-12-16 09:35:23 +00:00
committed by GitHub
parent df8326a1b0
commit d065eb9498
56 changed files with 783 additions and 449 deletions
@@ -8,9 +8,9 @@
#include <Tests/FocusMode/EditorFocusModeFixture.h>
namespace AzToolsFramework
namespace UnitTest
{
TEST_F(EditorFocusModeFixture, ContainerEntityTests_Register)
TEST_F(EditorFocusModeFixture, ContainerEntityRegister)
{
// Registering an entity is successful.
auto outcome = m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]);
@@ -20,7 +20,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_RegisterTwice)
TEST_F(EditorFocusModeFixture, ContainerEntityRegisterTwice)
{
// Registering an entity twice fails.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]);
@@ -31,7 +31,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_Unregister)
TEST_F(EditorFocusModeFixture, ContainerEntityUnregister)
{
// Unregistering a container entity is successful.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]);
@@ -39,21 +39,21 @@ namespace AzToolsFramework
EXPECT_TRUE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_UnregisterRegularEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityUnregisterRegularEntity)
{
// Unregistering an entity that was not previously registered fails.
auto outcome = m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]);
EXPECT_FALSE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_UnregisterTwice)
TEST_F(EditorFocusModeFixture, ContainerEntityUnregisterTwice)
{
// Unregistering a container entity twice fails.
auto outcome = m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]);
EXPECT_FALSE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnRegularEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnRegularEntity)
{
// If a regular entity is passed, IsContainer returns false.
// Note that we use a different entity than the tests above to validate a completely new EntityId.
@@ -61,7 +61,7 @@ namespace AzToolsFramework
EXPECT_FALSE(isContainer);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnRegisteredContainer)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnRegisteredContainer)
{
// If a container entity is passed, IsContainer returns true.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
@@ -72,7 +72,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnUnRegisteredContainer)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnUnRegisteredContainer)
{
// If an entity that was previously a container but was then unregistered is passed, IsContainer returns false.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
@@ -82,14 +82,14 @@ namespace AzToolsFramework
EXPECT_FALSE(isContainer);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpenOnRegularEntity)
TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpenOnRegularEntity)
{
// Setting a regular entity to open should return a failure.
auto outcome = m_containerEntityInterface->SetContainerOpen(m_entityMap[StreetEntityName], true);
EXPECT_FALSE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpen)
TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpen)
{
// Set a container entity to open, and verify the operation was successful.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]);
@@ -100,7 +100,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpenTwice)
TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpenTwice)
{
// Set a container entity to open twice, and verify that does not cause a failure (as intended).
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]);
@@ -112,7 +112,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerClosed)
TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerClosed)
{
// Set a container entity to closed, and verify the operation was successful.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]);
@@ -122,16 +122,16 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnRegularEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnRegularEntity)
{
// Query open state on a regular entity, and verify it returns true.
// Open containers behave exactly as regular entities, so this is the expected return value.
bool isOpen = m_containerEntityInterface->IsContainerOpen(m_entityMap[CityEntityName]);
EXPECT_TRUE(isOpen);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnDefaultContainerEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnDefaultContainerEntity)
{
// Query open state on a newly registered container entity, and verify it returns false.
// Containers are registered closed by default.
@@ -142,8 +142,8 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnOpenContainerEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnOpenContainerEntity)
{
// Query open state on a container entity that was opened, and verify it returns true.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CityEntityName]);
@@ -154,8 +154,8 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnClosedContainerEntity)
TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnClosedContainerEntity)
{
// Query open state on a container entity that was opened and then closed, and verify it returns false.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CityEntityName]);
@@ -167,8 +167,8 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_ContainerOpenStateIsPreserved)
TEST_F(EditorFocusModeFixture, ContainerEntityContainerOpenStateIsPreserved)
{
// Register an entity as container, open it, then unregister it.
// When the entity is registered again, the open state should be preserved.
@@ -184,15 +184,15 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearSucceeds)
TEST_F(EditorFocusModeFixture, ContainerEntityClearSucceeds)
{
// The Clear function works if no container is registered.
auto outcome = m_containerEntityInterface->Clear(m_editorEntityContextId);
EXPECT_TRUE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearFailsIfContainersAreStillRegistered)
TEST_F(EditorFocusModeFixture, ContainerEntityClearFailsIfContainersAreStillRegistered)
{
// The Clear function fails if a container is registered.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[Passenger1EntityName]);
@@ -202,8 +202,8 @@ namespace AzToolsFramework
// Restore default state for other tests.
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[Passenger1EntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearSucceedsIfContainersAreUnregistered)
TEST_F(EditorFocusModeFixture, ContainerEntityClearSucceedsIfContainersAreUnregistered)
{
// The Clear function fails if a container is registered.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[Passenger1EntityName]);
@@ -212,7 +212,7 @@ namespace AzToolsFramework
EXPECT_TRUE(outcome.IsSuccess());
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearDeletesPreservedOpenStates)
TEST_F(EditorFocusModeFixture, ContainerEntityClearDeletesPreservedOpenStates)
{
// Register an entity as container, open it, unregister it, then call clear.
// When the entity is registered again, the open state should not be preserved.
@@ -230,14 +230,14 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[Passenger1EntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithNoContainers)
TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithNoContainers)
{
// When no containers are in the way, the function will just return the entityId that was passed to it.
AZ::EntityId selectedEntityId = m_containerEntityInterface->FindHighestSelectableEntity(m_entityMap[Passenger2EntityName]);
EXPECT_EQ(selectedEntityId, m_entityMap[Passenger2EntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithClosedContainer)
TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithClosedContainer)
{
// If a closed container is an ancestor of the queried entity, the closed container is selected.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]); // Containers are closed by default
@@ -248,7 +248,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithOpenContainer)
TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithOpenContainer)
{
// If an open container is an ancestor of the queried entity, it is ignored.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
@@ -261,7 +261,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithMultipleClosedContainers)
TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithMultipleClosedContainers)
{
// If multiple closed containers are ancestors of the queried entity, the highest closed container is selected.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]);
@@ -275,7 +275,7 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
}
TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithMultipleContainers)
TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithMultipleContainers)
{
// If multiple containers are ancestors of the queried entity, the highest closed container is selected.
m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]);
@@ -289,5 +289,4 @@ namespace AzToolsFramework
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]);
m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]);
}
}
} // namespace UnitTest