Cleanup some code

This commit is contained in:
Wojtek Figat
2021-06-10 16:59:59 +02:00
parent 90d9f83f8c
commit 14bc9501c7
11 changed files with 114 additions and 439 deletions

View File

@@ -77,15 +77,6 @@ API_ENUM() enum class MaterialBlendMode : byte
Multiply = 3,
};
// Old material blending mode used before introducing MaterialShadingModel
// [Deprecated on 10.09.2018, expires on 10.05.2019]
enum class OldMaterialBlendMode : byte
{
Opaque = 0,
Transparent = 1,
Unlit = 2,
};
/// <summary>
/// Material shading modes. Defines how material inputs and properties are combined to result the final surface color.
/// </summary>
@@ -417,243 +408,6 @@ API_ENUM() enum class MaterialSceneTextures
ShadingModel = 10,
};
/// <summary>
/// Material info structure - version 1
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo1
{
int32 Version;
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo1& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 2
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo2
{
int32 Version;
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo2& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 3
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo3
{
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo3& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 4
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo4
{
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
MaterialPostFxLocation PostFxLocation;
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo4& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& PostFxLocation == other.PostFxLocation
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 5
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo5
{
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
MaterialPostFxLocation PostFxLocation;
float MaskThreshold;
float OpacityThreshold;
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo5& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& PostFxLocation == other.PostFxLocation
&& Math::NearEqual(MaskThreshold, other.MaskThreshold)
&& Math::NearEqual(OpacityThreshold, other.OpacityThreshold)
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 6
/// [Deprecated on 10.09.2018, expires on 10.05.2019]
/// </summary>
struct MaterialInfo6
{
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
MaterialDecalBlendingMode DecalBlendingMode;
MaterialPostFxLocation PostFxLocation;
float MaskThreshold;
float OpacityThreshold;
MaterialInfo6()
{
}
MaterialInfo6(const MaterialInfo5& other)
{
Domain = other.Domain;
BlendMode = other.BlendMode;
Flags = other.Flags;
TransparentLighting = other.TransparentLighting;
DecalBlendingMode = MaterialDecalBlendingMode::Translucent;
PostFxLocation = other.PostFxLocation;
MaskThreshold = other.MaskThreshold;
OpacityThreshold = other.OpacityThreshold;
}
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo6& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& DecalBlendingMode == other.DecalBlendingMode
&& PostFxLocation == other.PostFxLocation
&& Math::NearEqual(MaskThreshold, other.MaskThreshold)
&& Math::NearEqual(OpacityThreshold, other.OpacityThreshold)
&& Flags == other.Flags;
}
};
/// <summary>
/// Material info structure - version 7
/// [Deprecated on 13.09.2018, expires on 13.12.2018]
/// </summary>
struct MaterialInfo7
{
MaterialDomain Domain;
OldMaterialBlendMode BlendMode;
MaterialFlags_Deprecated Flags;
MaterialTransparentLighting_Deprecated TransparentLighting;
MaterialDecalBlendingMode DecalBlendingMode;
MaterialPostFxLocation PostFxLocation;
float MaskThreshold;
float OpacityThreshold;
TessellationMethod TessellationMode;
int32 MaxTessellationFactor;
MaterialInfo7()
{
}
MaterialInfo7(const MaterialInfo6& other)
{
Domain = other.Domain;
BlendMode = other.BlendMode;
Flags = other.Flags;
TransparentLighting = other.TransparentLighting;
DecalBlendingMode = other.DecalBlendingMode;
PostFxLocation = other.PostFxLocation;
MaskThreshold = other.MaskThreshold;
OpacityThreshold = other.OpacityThreshold;
TessellationMode = TessellationMethod::None;
MaxTessellationFactor = 15;
}
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo7& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& TransparentLighting == other.TransparentLighting
&& DecalBlendingMode == other.DecalBlendingMode
&& PostFxLocation == other.PostFxLocation
&& Math::NearEqual(MaskThreshold, other.MaskThreshold)
&& Math::NearEqual(OpacityThreshold, other.OpacityThreshold)
&& Flags == other.Flags
&& TessellationMode == other.TessellationMode
&& MaxTessellationFactor == other.MaxTessellationFactor;
}
};
/// <summary>
/// Material info structure - version 8
/// [Deprecated on 24.07.2019, expires on 10.05.2021]
@@ -676,53 +430,7 @@ struct MaterialInfo8
{
}
MaterialInfo8(const MaterialInfo7& other)
{
Domain = other.Domain;
switch (other.BlendMode)
{
case OldMaterialBlendMode::Opaque:
BlendMode = MaterialBlendMode::Opaque;
ShadingModel = MaterialShadingModel::Lit;
break;
case OldMaterialBlendMode::Transparent:
BlendMode = MaterialBlendMode::Transparent;
ShadingModel = MaterialShadingModel::Lit;
break;
case OldMaterialBlendMode::Unlit:
BlendMode = MaterialBlendMode::Opaque;
ShadingModel = MaterialShadingModel::Unlit;
break;
}
Flags = other.Flags;
TransparentLighting = other.TransparentLighting;
DecalBlendingMode = other.DecalBlendingMode;
PostFxLocation = other.PostFxLocation;
MaskThreshold = other.MaskThreshold;
OpacityThreshold = other.OpacityThreshold;
TessellationMode = other.TessellationMode;
MaxTessellationFactor = other.MaxTessellationFactor;
}
/// <summary>
/// Compare structure with other one
/// </summary>
/// <param name="other">Other structure to compare</param>
/// <returns>True if both structures are equal</returns>
bool operator==(const MaterialInfo8& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& ShadingModel == other.ShadingModel
&& TransparentLighting == other.TransparentLighting
&& DecalBlendingMode == other.DecalBlendingMode
&& PostFxLocation == other.PostFxLocation
&& Math::NearEqual(MaskThreshold, other.MaskThreshold)
&& Math::NearEqual(OpacityThreshold, other.OpacityThreshold)
&& Flags == other.Flags
&& TessellationMode == other.TessellationMode
&& MaxTessellationFactor == other.MaxTessellationFactor;
}
bool operator==(const MaterialInfo8& other) const;
};
/// <summary>
@@ -796,69 +504,8 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(MaterialInfo);
{
}
MaterialInfo(const MaterialInfo8& other)
{
Domain = other.Domain;
BlendMode = other.BlendMode;
ShadingModel = other.ShadingModel;
UsageFlags = MaterialUsageFlags::None;
if (other.Flags & MaterialFlags_Deprecated::UseMask)
UsageFlags |= MaterialUsageFlags::UseMask;
if (other.Flags & MaterialFlags_Deprecated::UseEmissive)
UsageFlags |= MaterialUsageFlags::UseEmissive;
if (other.Flags & MaterialFlags_Deprecated::UsePositionOffset)
UsageFlags |= MaterialUsageFlags::UsePositionOffset;
if (other.Flags & MaterialFlags_Deprecated::UseVertexColor)
UsageFlags |= MaterialUsageFlags::UseVertexColor;
if (other.Flags & MaterialFlags_Deprecated::UseNormal)
UsageFlags |= MaterialUsageFlags::UseNormal;
if (other.Flags & MaterialFlags_Deprecated::UseDisplacement)
UsageFlags |= MaterialUsageFlags::UseDisplacement;
if (other.Flags & MaterialFlags_Deprecated::UseRefraction)
UsageFlags |= MaterialUsageFlags::UseRefraction;
FeaturesFlags = MaterialFeaturesFlags::None;
if (other.Flags & MaterialFlags_Deprecated::Wireframe)
FeaturesFlags |= MaterialFeaturesFlags::Wireframe;
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableDepthTest && BlendMode != MaterialBlendMode::Opaque)
FeaturesFlags |= MaterialFeaturesFlags::DisableDepthTest;
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableFog && BlendMode != MaterialBlendMode::Opaque)
FeaturesFlags |= MaterialFeaturesFlags::DisableFog;
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableReflections && BlendMode != MaterialBlendMode::Opaque)
FeaturesFlags |= MaterialFeaturesFlags::DisableReflections;
if (other.Flags & MaterialFlags_Deprecated::DisableDepthWrite)
FeaturesFlags |= MaterialFeaturesFlags::DisableDepthWrite;
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableDistortion && BlendMode != MaterialBlendMode::Opaque)
FeaturesFlags |= MaterialFeaturesFlags::DisableDistortion;
if (other.Flags & MaterialFlags_Deprecated::InputWorldSpaceNormal)
FeaturesFlags |= MaterialFeaturesFlags::InputWorldSpaceNormal;
if (other.Flags & MaterialFlags_Deprecated::UseDitheredLODTransition)
FeaturesFlags |= MaterialFeaturesFlags::DitheredLODTransition;
if (other.BlendMode != MaterialBlendMode::Opaque && other.TransparentLighting == MaterialTransparentLighting_Deprecated::None)
ShadingModel = MaterialShadingModel::Unlit;
DecalBlendingMode = other.DecalBlendingMode;
PostFxLocation = other.PostFxLocation;
CullMode = other.Flags & MaterialFlags_Deprecated::TwoSided ? ::CullMode::TwoSided : ::CullMode::Normal;
MaskThreshold = other.MaskThreshold;
OpacityThreshold = other.OpacityThreshold;
TessellationMode = other.TessellationMode;
MaxTessellationFactor = other.MaxTessellationFactor;
}
bool operator==(const MaterialInfo& other) const
{
return Domain == other.Domain
&& BlendMode == other.BlendMode
&& ShadingModel == other.ShadingModel
&& UsageFlags == other.UsageFlags
&& FeaturesFlags == other.FeaturesFlags
&& DecalBlendingMode == other.DecalBlendingMode
&& PostFxLocation == other.PostFxLocation
&& CullMode == other.CullMode
&& Math::NearEqual(MaskThreshold, other.MaskThreshold)
&& Math::NearEqual(OpacityThreshold, other.OpacityThreshold)
&& TessellationMode == other.TessellationMode
&& MaxTessellationFactor == other.MaxTessellationFactor;
}
MaterialInfo(const MaterialInfo8& other);
bool operator==(const MaterialInfo& other) const;
};
// The current material info descriptor version used by the material pipeline