Prefabs | Introduce sanitation of prefab doms on loading (#1929)

* Update PrefabLoader to sanitize ingested prefabs and have core systems operate with default values

Signed-off-by: sconel <sconel@amazon.com>
Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Remove IsExplicitDefault implementation to avoid confusion (since the function isn't virtual).
Avoid copying PrefabDoms over in SanitizeLoadTemplate.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Address naming and commenting concerns from PR reviews.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Fix to error detection code

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Add support for all uuid formats for zero check.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

Co-authored-by: sconel <sconel@amazon.com>
This commit is contained in:
Danilo Aimini
2021-07-09 16:22:38 -07:00
committed by GitHub
parent b8f857a270
commit 1d022907dc
11 changed files with 200 additions and 91 deletions
@@ -428,8 +428,7 @@ namespace UnitTest
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*newInstance, updatedDom));
newTemplateDom.CopyFrom(updatedDom, newTemplateDom.GetAllocator());
// Validate that the prefabTestComponent in the Template's DOM doesn't have a BoolProperty.
// Even though we changed the property to false, it won't be serialized out because it's a default value.
// Validate that the value of the BoolProperty of the prefabTestComponent in the Template's DOM has changed.
entityComponents = PrefabTestDomUtils::GetPrefabDomComponents(newTemplateDom, newTemplateEntityAliases.front());
ASSERT_TRUE(entityComponents != nullptr && entityComponents->IsObject());
EXPECT_EQ(entityComponents->MemberCount(), 2);
@@ -440,7 +439,7 @@ namespace UnitTest
PrefabDomValueConstReference wheelEntityComponentBoolPropertyValue =
PrefabDomUtils::FindPrefabDomValue(wheelEntityComponentValue->get(), PrefabTestDomUtils::BoolPropertyName);
ASSERT_FALSE(wheelEntityComponentBoolPropertyValue.has_value());
ASSERT_TRUE(wheelEntityComponentBoolPropertyValue.has_value() && wheelEntityComponentBoolPropertyValue->get() == false);
// Update Template's Instances and validate if all Instances have no BoolProperty under their prefabTestComponents in entities.
m_instanceUpdateExecutorInterface->AddTemplateInstancesToQueue(newTemplateId);