diff --git a/src/PhoenixSim/LDS/Json/JsonCatalogBuilderBase.h b/src/PhoenixSim/LDS/Json/JsonCatalogBuilderBase.h index c80c655..1fbc1e0 100644 --- a/src/PhoenixSim/LDS/Json/JsonCatalogBuilderBase.h +++ b/src/PhoenixSim/LDS/Json/JsonCatalogBuilderBase.h @@ -41,7 +41,7 @@ namespace Phoenix::LDS::Json protected: - static bool GetValueFromJson( + bool GetValueFromJson( const json& json, ELDSValueType type, LDSValue& outValue) @@ -129,7 +129,6 @@ namespace Phoenix::LDS::Json } break; case ELDSValueType::Text: - case ELDSValueType::Asset: case ELDSValueType::Enum: case ELDSValueType::EnumFlags: if (json.is_string()) @@ -138,6 +137,16 @@ namespace Phoenix::LDS::Json return true; } break; + case ELDSValueType::Asset: + if (json.is_string()) + { + // Store the full asset path string in the catalog's asset table + // The handle (index into AssetStrings) is stored in UInt32 + const PHXString& assetPath = json.get(); + outValue.UInt32 = Catalog->AddAssetString(assetPath); + return true; + } + break; case ELDSValueType::Unknown: case ELDSValueType::Array: case ELDSValueType::Object: diff --git a/src/PhoenixSim/LDS/Json/JsonCatalogTypeBuilder.inl b/src/PhoenixSim/LDS/Json/JsonCatalogTypeBuilder.inl index a1f0ad0..347c02d 100644 --- a/src/PhoenixSim/LDS/Json/JsonCatalogTypeBuilder.inl +++ b/src/PhoenixSim/LDS/Json/JsonCatalogTypeBuilder.inl @@ -129,7 +129,10 @@ namespace Phoenix::LDS::Json if (typeStr.starts_with("Asset")) { - // TODO (jfarris): implement assets? + // Record the type + PHXString typePropertyPath = propertyPath + "/type"; + this->Catalog->EmplaceTypeRecord(rootTypeId, typePropertyPath, LDSTypedValue(ELDSValueType::Asset)); + return ProcessValueProperty(rootTypeId, jsonObject, ELDSValueType::Asset, propertyPath); } diff --git a/src/PhoenixSim/LDS/LDSCatalog.h b/src/PhoenixSim/LDS/LDSCatalog.h index e421c7f..8da2dc0 100644 --- a/src/PhoenixSim/LDS/LDSCatalog.h +++ b/src/PhoenixSim/LDS/LDSCatalog.h @@ -289,8 +289,26 @@ namespace Phoenix::LDS return {}; } + uint32 AddAssetString(const PHXString& assetPath) + { + uint32 handle = static_cast(AssetStrings.size()); + AssetStrings.push_back(assetPath); + return handle; + } + + const PHXString& GetAssetString(uint32 handle) const + { + static const PHXString EmptyString; + if (handle >= AssetStrings.size()) + { + return EmptyString; + } + return AssetStrings[handle]; + } + TObjectStore Objects; TTypeStore Types; + TArray AssetStrings; }; template diff --git a/src/PhoenixSim/LDS/LDSCatalogQueryContext.h b/src/PhoenixSim/LDS/LDSCatalogQueryContext.h index cfb57c9..b955509 100644 --- a/src/PhoenixSim/LDS/LDSCatalogQueryContext.h +++ b/src/PhoenixSim/LDS/LDSCatalogQueryContext.h @@ -57,6 +57,16 @@ namespace Phoenix::LDS return false; } + const PHXString& GetAssetString(uint32 handle) const override + { + if (!Catalog) + { + static const PHXString EmptyString; + return EmptyString; + } + return Catalog->GetAssetString(handle); + } + private: const TCatalog* Catalog; ELDSCatalogRecordStore Mode = ELDSCatalogRecordStore::Object; diff --git a/src/PhoenixSim/LDS/LDSFeatureQueryContext.cpp b/src/PhoenixSim/LDS/LDSFeatureQueryContext.cpp index b134eaa..0dccb80 100644 --- a/src/PhoenixSim/LDS/LDSFeatureQueryContext.cpp +++ b/src/PhoenixSim/LDS/LDSFeatureQueryContext.cpp @@ -5,6 +5,7 @@ #include "PhoenixSim/Worlds.h" using namespace Phoenix::LDS; +using Phoenix::PHXString; LDSFeatureQueryContext LDSFeatureQueryContext::Create(SessionConstRef session, WorldConstPtr world) { @@ -260,3 +261,46 @@ bool LDSFeatureQueryContext::TypeExists(const FName& typeId) const return false; } +const PHXString& LDSFeatureQueryContext::GetAssetString(uint32 handle) const +{ + static const PHXString EmptyString; + + if (WorldDynamicCatalog && HasNoneFlags(FeatureQueryFlags, ELDSFeatureRecordQueryFlags::SessionOnly, ELDSFeatureRecordQueryFlags::StaticOnly)) + { + const PHXString& str = WorldDynamicCatalog->GetAssetString(handle); + if (!str.empty()) + { + return str; + } + } + + if (WorldStaticCatalog && HasNoneFlags(FeatureQueryFlags, ELDSFeatureRecordQueryFlags::SessionOnly, ELDSFeatureRecordQueryFlags::DynamicOnly)) + { + const PHXString& str = WorldStaticCatalog->GetAssetString(handle); + if (!str.empty()) + { + return str; + } + } + + if (SessionDynamicCatalog && HasNoneFlags(FeatureQueryFlags, ELDSFeatureRecordQueryFlags::WorldOnly, ELDSFeatureRecordQueryFlags::StaticOnly)) + { + const PHXString& str = SessionDynamicCatalog->GetAssetString(handle); + if (!str.empty()) + { + return str; + } + } + + if (SessionStaticCatalog && HasNoneFlags(FeatureQueryFlags, ELDSFeatureRecordQueryFlags::WorldOnly, ELDSFeatureRecordQueryFlags::DynamicOnly)) + { + const PHXString& str = SessionStaticCatalog->GetAssetString(handle); + if (!str.empty()) + { + return str; + } + } + + return EmptyString; +} + diff --git a/src/PhoenixSim/LDS/LDSFeatureQueryContext.h b/src/PhoenixSim/LDS/LDSFeatureQueryContext.h index 12672cb..a9ab502 100644 --- a/src/PhoenixSim/LDS/LDSFeatureQueryContext.h +++ b/src/PhoenixSim/LDS/LDSFeatureQueryContext.h @@ -31,6 +31,8 @@ namespace Phoenix::LDS bool TypeExists(const FName& typeId) const; + const PHXString& GetAssetString(uint32 handle) const override; + private: TSharedPtr SessionStaticCatalog = nullptr; diff --git a/src/PhoenixSim/LDS/LDSQueryContext.h b/src/PhoenixSim/LDS/LDSQueryContext.h index def4c00..2b5d48f 100644 --- a/src/PhoenixSim/LDS/LDSQueryContext.h +++ b/src/PhoenixSim/LDS/LDSQueryContext.h @@ -32,6 +32,12 @@ namespace Phoenix::LDS virtual bool Exists(const FName& objectId) const = 0; + virtual const PHXString& GetAssetString(uint32 handle) const + { + static const PHXString EmptyString; + return EmptyString; + } + virtual bool RecordExists( const LDSRecordPath& path, ELDSRecordQueryFlags flags = ELDSRecordQueryFlags::None) const;