Fix opening projects with PostFx material assigned in Graphics Settings
#1993
This commit is contained in:
@@ -89,6 +89,11 @@ public:
|
|||||||
OnSet(other.GetID());
|
OnSet(other.GetID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoftAssetReference(const Guid& id)
|
||||||
|
{
|
||||||
|
OnSet(id);
|
||||||
|
}
|
||||||
|
|
||||||
SoftAssetReference(SoftAssetReference&& other)
|
SoftAssetReference(SoftAssetReference&& other)
|
||||||
{
|
{
|
||||||
OnSet(other.GetID());
|
OnSet(other.GetID());
|
||||||
@@ -111,6 +116,10 @@ public:
|
|||||||
{
|
{
|
||||||
return GetID() == other.GetID();
|
return GetID() == other.GetID();
|
||||||
}
|
}
|
||||||
|
FORCE_INLINE bool operator==(const Guid& other) const
|
||||||
|
{
|
||||||
|
return GetID() == other;
|
||||||
|
}
|
||||||
FORCE_INLINE bool operator!=(T* other) const
|
FORCE_INLINE bool operator!=(T* other) const
|
||||||
{
|
{
|
||||||
return Get() != other;
|
return Get() != other;
|
||||||
@@ -119,6 +128,10 @@ public:
|
|||||||
{
|
{
|
||||||
return GetID() != other.GetID();
|
return GetID() != other.GetID();
|
||||||
}
|
}
|
||||||
|
FORCE_INLINE bool operator!=(const Guid& other) const
|
||||||
|
{
|
||||||
|
return GetID() != other;
|
||||||
|
}
|
||||||
SoftAssetReference& operator=(const SoftAssetReference& other)
|
SoftAssetReference& operator=(const SoftAssetReference& other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
|
|||||||
@@ -207,12 +207,11 @@ void PostFxMaterialsSettings::BlendWith(PostFxMaterialsSettings& other, float we
|
|||||||
if (isHalf)
|
if (isHalf)
|
||||||
{
|
{
|
||||||
int32 indexSrc = 0;
|
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())
|
while (Materials.Count() != POST_PROCESS_SETTINGS_MAX_MATERIALS && indexSrc < other.Materials.Count())
|
||||||
{
|
{
|
||||||
MaterialBase* mat = materialsSrc[indexSrc].Get();
|
if (!Materials.Contains(materialsSrc[indexSrc].GetID()))
|
||||||
if (mat && !Materials.Contains(mat))
|
Materials.Add(materialsSrc[indexSrc]);
|
||||||
Materials.Add(mat);
|
|
||||||
indexSrc++;
|
indexSrc++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1929,8 +1929,8 @@ API_STRUCT() struct FLAXENGINE_API PostFxMaterialsSettings : ISerializable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The post-process materials collection for rendering (fixed capacity).
|
/// The post-process materials collection for rendering (fixed capacity).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle)")
|
API_FIELD(Attributes="EditorDisplay(null, EditorDisplayAttribute.InlineStyle), Collection(MaxCount=8)")
|
||||||
Array<AssetReference<MaterialBase>, FixedAllocation<POST_PROCESS_SETTINGS_MAX_MATERIALS>> Materials;
|
Array<SoftAssetReference<MaterialBase>, FixedAllocation<POST_PROCESS_SETTINGS_MAX_MATERIALS>> Materials;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <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.
|
// Converter for Array.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct MConverter<Array<T>>
|
struct MConverter<Array<T>>
|
||||||
|
|||||||
Reference in New Issue
Block a user