Fix opening projects with PostFx material assigned in Graphics Settings
#1993
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -207,12 +207,11 @@ void PostFxMaterialsSettings::BlendWith(PostFxMaterialsSettings& other, float we
|
||||
if (isHalf)
|
||||
{
|
||||
int32 indexSrc = 0;
|
||||
const AssetReference<MaterialBase>* materialsSrc = other.Materials.Get();
|
||||
const SoftAssetReference<MaterialBase>* 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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1929,8 +1929,8 @@ API_STRUCT() struct FLAXENGINE_API PostFxMaterialsSettings : ISerializable
|
||||
/// <summary>
|
||||
/// The post-process materials collection for rendering (fixed capacity).
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle)")
|
||||
Array<AssetReference<MaterialBase>, FixedAllocation<POST_PROCESS_SETTINGS_MAX_MATERIALS>> Materials;
|
||||
API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle), Collection(MaxCount=8)")
|
||||
Array<SoftAssetReference<MaterialBase>, FixedAllocation<POST_PROCESS_SETTINGS_MAX_MATERIALS>> Materials;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
|
||||
@@ -347,6 +347,31 @@ struct MConverter<AssetReference<T>>
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: use MarshalAs=Guid on SoftAssetReference to pass guid over bindings and not load asset in glue code
|
||||
template<typename T>
|
||||
class SoftAssetReference;
|
||||
template<typename T>
|
||||
struct MConverter<SoftAssetReference<T>>
|
||||
{
|
||||
void ToManagedArray(MArray* result, const Span<SoftAssetReference<T>>& 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<MObject*>(objects, data.Length()));
|
||||
Allocator::Free(objects);
|
||||
}
|
||||
|
||||
void ToNativeArray(Span<SoftAssetReference<T>>& result, const MArray* data)
|
||||
{
|
||||
MObject** dataPtr = MCore::Array::GetAddress<MObject*>(data);
|
||||
for (int32 i = 0; i < result.Length(); i++)
|
||||
result.Get()[i] = (T*)ScriptingObject::ToNative(dataPtr[i]);
|
||||
}
|
||||
};
|
||||
|
||||
// Converter for Array.
|
||||
template<typename T>
|
||||
struct MConverter<Array<T>>
|
||||
|
||||
Reference in New Issue
Block a user