diff --git a/Source/Engine/Content/SoftAssetReference.h b/Source/Engine/Content/SoftAssetReference.h index d237b5fd7..0f1be471d 100644 --- a/Source/Engine/Content/SoftAssetReference.h +++ b/Source/Engine/Content/SoftAssetReference.h @@ -89,6 +89,11 @@ public: OnSet(other.GetID()); } + SoftAssetReference(const Guid& id) + { + OnSet(id); + } + SoftAssetReference(SoftAssetReference&& other) { OnSet(other.GetID()); @@ -111,6 +116,10 @@ public: { return GetID() == other.GetID(); } + FORCE_INLINE bool operator==(const Guid& other) const + { + return GetID() == other; + } FORCE_INLINE bool operator!=(T* other) const { return Get() != other; @@ -119,6 +128,10 @@ public: { return GetID() != other.GetID(); } + FORCE_INLINE bool operator!=(const Guid& other) const + { + return GetID() != other; + } SoftAssetReference& operator=(const SoftAssetReference& other) { if (this != &other) diff --git a/Source/Engine/Graphics/PostProcessSettings.cpp b/Source/Engine/Graphics/PostProcessSettings.cpp index 6e2b21045..4de7bdb2e 100644 --- a/Source/Engine/Graphics/PostProcessSettings.cpp +++ b/Source/Engine/Graphics/PostProcessSettings.cpp @@ -207,12 +207,11 @@ void PostFxMaterialsSettings::BlendWith(PostFxMaterialsSettings& other, float we if (isHalf) { int32 indexSrc = 0; - const AssetReference* materialsSrc = other.Materials.Get(); + const SoftAssetReference* materialsSrc = other.Materials.Get(); while (Materials.Count() != POST_PROCESS_SETTINGS_MAX_MATERIALS && indexSrc < other.Materials.Count()) { - MaterialBase* mat = materialsSrc[indexSrc].Get(); - if (mat && !Materials.Contains(mat)) - Materials.Add(mat); + if (!Materials.Contains(materialsSrc[indexSrc].GetID())) + Materials.Add(materialsSrc[indexSrc]); indexSrc++; } } diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index 1d695f353..5d95f7c74 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -1929,8 +1929,8 @@ API_STRUCT() struct FLAXENGINE_API PostFxMaterialsSettings : ISerializable /// /// The post-process materials collection for rendering (fixed capacity). /// - API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle)") - Array, FixedAllocation> Materials; + API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle), Collection(MaxCount=8)") + Array, FixedAllocation> Materials; public: /// diff --git a/Source/Engine/Scripting/ManagedCLR/MUtils.h b/Source/Engine/Scripting/ManagedCLR/MUtils.h index ed1b690c2..46601ede7 100644 --- a/Source/Engine/Scripting/ManagedCLR/MUtils.h +++ b/Source/Engine/Scripting/ManagedCLR/MUtils.h @@ -347,6 +347,31 @@ struct MConverter> } }; +// TODO: use MarshalAs=Guid on SoftAssetReference to pass guid over bindings and not load asset in glue code +template +class SoftAssetReference; +template +struct MConverter> +{ + void ToManagedArray(MArray* result, const Span>& data) + { + if (data.Length() == 0) + return; + MObject** objects = (MObject**)Allocator::Allocate(data.Length() * sizeof(MObject*)); + for (int32 i = 0; i < data.Length(); i++) + objects[i] = data[i].GetManagedInstance(); + MCore::GC::WriteArrayRef(result, Span(objects, data.Length())); + Allocator::Free(objects); + } + + void ToNativeArray(Span>& result, const MArray* data) + { + MObject** dataPtr = MCore::Array::GetAddress(data); + for (int32 i = 0; i < result.Length(); i++) + result.Get()[i] = (T*)ScriptingObject::ToNative(dataPtr[i]); + } +}; + // Converter for Array. template struct MConverter>