Add more assertions to tests build
This commit is contained in:
@@ -1012,7 +1012,7 @@ Asset::LoadResult Model::load()
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILD_DEBUG || BUILD_DEVELOPMENT
|
||||
#if !BUILD_RELEASE
|
||||
// Validate LODs
|
||||
for (int32 lodIndex = 1; lodIndex < LODs.Count(); lodIndex++)
|
||||
{
|
||||
|
||||
@@ -304,7 +304,7 @@ bool Content::GetAssetInfo(const StringView& path, AssetInfo& info)
|
||||
auto storage = ContentStorageManager::GetStorage(path);
|
||||
if (storage)
|
||||
{
|
||||
#if BUILD_DEBUG
|
||||
#if BUILD_DEBUG || FLAX_TESTS
|
||||
ASSERT(storage->GetPath() == path);
|
||||
#endif
|
||||
|
||||
@@ -904,7 +904,7 @@ bool Content::IsAssetTypeIdInvalid(const ScriptingTypeHandle& type, const Script
|
||||
if (!type || !assetType)
|
||||
return false;
|
||||
|
||||
#if BUILD_DEBUG
|
||||
#if BUILD_DEBUG || FLAX_TESTS
|
||||
// Peek types for debugging
|
||||
const auto& typeObj = type.GetType();
|
||||
const auto& assetTypeObj = assetType.GetType();
|
||||
|
||||
@@ -189,26 +189,26 @@ Actor* PrefabManager::SpawnPrefab(Prefab* prefab, Actor* parent, Dictionary<Guid
|
||||
// Check for missing parent (eg. parent object has been deleted)
|
||||
if (obj->GetParent() == nullptr)
|
||||
{
|
||||
sceneObjects->At(i) = nullptr;
|
||||
LOG(Warning, "Scene object {0} {1} has missing parent object after load. Removing it.", obj->GetID(), obj->ToString());
|
||||
sceneObjects->At(i) = nullptr;
|
||||
obj->DeleteObject();
|
||||
continue;
|
||||
}
|
||||
|
||||
#if USE_EDITOR && !BUILD_RELEASE
|
||||
#if (USE_EDITOR && !BUILD_RELEASE) || FLAX_TESTS
|
||||
// Check for not being added to the parent (eg. invalid setup events fault on registration)
|
||||
auto actor = dynamic_cast<Actor*>(obj);
|
||||
auto script = dynamic_cast<Script*>(obj);
|
||||
if (obj->GetParent() == obj || (actor && !actor->GetParent()->Children.Contains(actor)) || (script && !script->GetParent()->Scripts.Contains(script)))
|
||||
{
|
||||
sceneObjects->At(i) = nullptr;
|
||||
LOG(Warning, "Scene object {0} {1} has invalid parent object linkage after load. Removing it.", obj->GetID(), obj->ToString());
|
||||
sceneObjects->At(i) = nullptr;
|
||||
obj->DeleteObject();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_EDITOR && BUILD_DEBUG
|
||||
#if (USE_EDITOR && BUILD_DEBUG) || FLAX_TESTS
|
||||
// Check for being added to parent not from spawned prefab (eg. invalid parentId linkage fault)
|
||||
bool hasParentInInstance = false;
|
||||
for (int32 j = 0; j < sceneObjects->Count(); j++)
|
||||
@@ -221,11 +221,22 @@ Actor* PrefabManager::SpawnPrefab(Prefab* prefab, Actor* parent, Dictionary<Guid
|
||||
}
|
||||
if (!hasParentInInstance)
|
||||
{
|
||||
sceneObjects->At(i) = nullptr;
|
||||
LOG(Warning, "Scene object {0} {1} has invalid parent object after load. Removing it.", obj->GetID(), obj->ToString());
|
||||
sceneObjects->At(i) = nullptr;
|
||||
obj->DeleteObject();
|
||||
continue;
|
||||
}
|
||||
|
||||
#if FLAX_TESTS
|
||||
// Perform extensive validation of the prefab instance structure
|
||||
if (actor && actor->HasActorInHierarchy(actor))
|
||||
{
|
||||
LOG(Warning, "Scene object {0} {1} has invalid hierarchy after load. Removing it.", obj->GetID(), obj->ToString());
|
||||
sceneObjects->At(i) = nullptr;
|
||||
obj->DeleteObject();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user