From 14bc9501c7b7170d583074d9f4d83020759eb374 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 10 Jun 2021 16:59:59 +0200 Subject: [PATCH] Cleanup some code --- Source/Engine/Core/Math/BoundingFrustum.h | 2 +- Source/Engine/Core/Math/CollisionsHelper.cpp | 42 +- Source/Engine/Core/Math/CollisionsHelper.h | 2 - Source/Engine/Graphics/GPUDevice.cpp | 9 + Source/Engine/Graphics/GPUResource.h | 9 +- Source/Engine/Graphics/GPUResourceState.h | 19 - .../Engine/Graphics/Materials/MaterialInfo.h | 359 +----------------- .../Graphics/Materials/MaterialParams.cpp | 79 ++++ .../Graphics/Materials/MaterialParams.h | 8 - .../Handlers/ModelsStreamingHandler.cpp | 2 +- Source/Engine/Streaming/StreamableResource.h | 22 +- 11 files changed, 114 insertions(+), 439 deletions(-) diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index 9052521fc..6056fd82e 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -248,7 +248,7 @@ public: /// True if the current BoundingFrustum intersects a BoundingBox, otherwise false. FORCE_INLINE bool Intersects(const BoundingBox& box) const { - return CollisionsHelper::FrustumIntersectsBox(*this, box); + return CollisionsHelper::FrustumContainsBox(*this, box) != ContainmentType::Disjoint; } private: diff --git a/Source/Engine/Core/Math/CollisionsHelper.cpp b/Source/Engine/Core/Math/CollisionsHelper.cpp index d485e5fba..00ff0ea9b 100644 --- a/Source/Engine/Core/Math/CollisionsHelper.cpp +++ b/Source/Engine/Core/Math/CollisionsHelper.cpp @@ -1301,43 +1301,33 @@ bool CollisionsHelper::FrustumIntersectsBox(const BoundingFrustum& frustum, cons ContainmentType CollisionsHelper::FrustumContainsBox(const BoundingFrustum& frustum, const BoundingBox& box) { - Vector3 p, n; - Plane plane; auto result = ContainmentType::Contains; - for (int32 i = 0; i < 6; i++) { - plane = frustum.GetPlane(i); - GetBoxToPlanePVertexNVertex(box, plane.Normal, p, n); - + Plane plane = frustum.GetPlane(i); + Vector3 p = box.Minimum; + if (plane.Normal.X >= 0) + p.X = box.Maximum.X; + if (plane.Normal.Y >= 0) + p.Y = box.Maximum.Y; + if (plane.Normal.Z >= 0) + p.Z = box.Maximum.Z; if (PlaneIntersectsPoint(plane, p) == PlaneIntersectionType::Back) return ContainmentType::Disjoint; - if (PlaneIntersectsPoint(plane, n) == PlaneIntersectionType::Back) + p = box.Maximum; + if (plane.Normal.X >= 0) + p.X = box.Minimum.X; + if (plane.Normal.Y >= 0) + p.Y = box.Minimum.Y; + if (plane.Normal.Z >= 0) + p.Z = box.Minimum.Z; + if (PlaneIntersectsPoint(plane, p) == PlaneIntersectionType::Back) result = ContainmentType::Intersects; } return result; } -void CollisionsHelper::GetBoxToPlanePVertexNVertex(const BoundingBox& box, const Vector3& planeNormal, Vector3& p, Vector3& n) -{ - p = box.Minimum; - if (planeNormal.X >= 0) - p.X = box.Maximum.X; - if (planeNormal.Y >= 0) - p.Y = box.Maximum.Y; - if (planeNormal.Z >= 0) - p.Z = box.Maximum.Z; - - n = box.Maximum; - if (planeNormal.X >= 0) - n.X = box.Minimum.X; - if (planeNormal.Y >= 0) - n.Y = box.Minimum.Y; - if (planeNormal.Z >= 0) - n.Z = box.Minimum.Z; -} - bool CollisionsHelper::LineIntersectsLine(const Vector2& l1p1, const Vector2& l1p2, const Vector2& l2p1, const Vector2& l2p2) { float q = (l1p1.Y - l2p1.Y) * (l2p2.X - l2p1.X) - (l1p1.X - l2p1.X) * (l2p2.Y - l2p1.Y); diff --git a/Source/Engine/Core/Math/CollisionsHelper.h b/Source/Engine/Core/Math/CollisionsHelper.h index 692b86dbe..9ef940c3e 100644 --- a/Source/Engine/Core/Math/CollisionsHelper.h +++ b/Source/Engine/Core/Math/CollisionsHelper.h @@ -550,8 +550,6 @@ public: static ContainmentType FrustumContainsBox(const BoundingFrustum& frustum, const BoundingBox& box); - static void GetBoxToPlanePVertexNVertex(const BoundingBox& box, const Vector3& planeNormal, Vector3& p, Vector3& n); - /// /// Determines whether a line intersects with the other line. /// diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index f6be31923..cdf1da0d3 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -175,6 +175,15 @@ void GPUResource::OnReleaseGPU() { } +String GPUResource::ToString() const +{ +#if GPU_ENABLE_RESOURCE_NAMING + return GetName(); +#else + return TEXT("GPU Resource"); +#endif +} + void GPUResource::OnDeleteObject() { ReleaseGPU(); diff --git a/Source/Engine/Graphics/GPUResource.h b/Source/Engine/Graphics/GPUResource.h index 8f014d318..92fa9c769 100644 --- a/Source/Engine/Graphics/GPUResource.h +++ b/Source/Engine/Graphics/GPUResource.h @@ -126,14 +126,7 @@ protected: public: // [PersistentScriptingObject] - String ToString() const override - { -#if GPU_ENABLE_RESOURCE_NAMING - return GetName(); -#else - return TEXT("GPU Resource"); -#endif - } + String ToString() const override; void OnDeleteObject() override; }; diff --git a/Source/Engine/Graphics/GPUResourceState.h b/Source/Engine/Graphics/GPUResourceState.h index c5083b952..5ea11c3c3 100644 --- a/Source/Engine/Graphics/GPUResourceState.h +++ b/Source/Engine/Graphics/GPUResourceState.h @@ -45,12 +45,8 @@ public: void Initialize(uint32 subresourceCount, StateType initialState, bool usePerSubresourceTracking) { ASSERT(_subresourceState.IsEmpty() && subresourceCount > 0); - - // Initialize state _allSubresourcesSame = true; _resourceState = initialState; - - // Allocate space for per-subresource state tracking if (usePerSubresourceTracking && subresourceCount > 1) _subresourceState.Resize(subresourceCount, false); #if BUILD_DEBUG @@ -82,29 +78,19 @@ public: bool CheckResourceState(StateType state) const { if (_allSubresourcesSame) - { return state == _resourceState; - } - - // Check all subresources for (int32 i = 0; i < _subresourceState.Count(); i++) { if (_subresourceState[i] != state) - { return false; - } } - return true; } StateType GetSubresourceState(uint32 subresourceIndex) const { if (_allSubresourcesSame) - { return _resourceState; - } - ASSERT(subresourceIndex >= 0 && subresourceIndex < static_cast(_subresourceState.Count())); return _subresourceState[subresourceIndex]; } @@ -113,12 +99,9 @@ public: { _allSubresourcesSame = 1; _resourceState = state; - #if BUILD_DEBUG for (int32 i = 0; i < _subresourceState.Count(); i++) - { _subresourceState[i] = InvalidState; - } #endif } @@ -137,9 +120,7 @@ public: if (_allSubresourcesSame) { for (int32 i = 0; i < _subresourceState.Count(); i++) - { _subresourceState[i] = _resourceState; - } _allSubresourcesSame = 0; #if BUILD_DEBUG _resourceState = InvalidState; diff --git a/Source/Engine/Graphics/Materials/MaterialInfo.h b/Source/Engine/Graphics/Materials/MaterialInfo.h index 7edf7da54..f3fc4fa67 100644 --- a/Source/Engine/Graphics/Materials/MaterialInfo.h +++ b/Source/Engine/Graphics/Materials/MaterialInfo.h @@ -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, -}; - /// /// Material shading modes. Defines how material inputs and properties are combined to result the final surface color. /// @@ -417,243 +408,6 @@ API_ENUM() enum class MaterialSceneTextures ShadingModel = 10, }; -/// -/// Material info structure - version 1 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -struct MaterialInfo1 -{ - int32 Version; - MaterialDomain Domain; - OldMaterialBlendMode BlendMode; - MaterialFlags_Deprecated Flags; - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - bool operator==(const MaterialInfo1& other) const - { - return Domain == other.Domain - && BlendMode == other.BlendMode - && Flags == other.Flags; - } -}; - -/// -/// Material info structure - version 2 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -struct MaterialInfo2 -{ - int32 Version; - MaterialDomain Domain; - OldMaterialBlendMode BlendMode; - MaterialFlags_Deprecated Flags; - MaterialTransparentLighting_Deprecated TransparentLighting; - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - bool operator==(const MaterialInfo2& other) const - { - return Domain == other.Domain - && BlendMode == other.BlendMode - && TransparentLighting == other.TransparentLighting - && Flags == other.Flags; - } -}; - -/// -/// Material info structure - version 3 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -struct MaterialInfo3 -{ - MaterialDomain Domain; - OldMaterialBlendMode BlendMode; - MaterialFlags_Deprecated Flags; - MaterialTransparentLighting_Deprecated TransparentLighting; - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - bool operator==(const MaterialInfo3& other) const - { - return Domain == other.Domain - && BlendMode == other.BlendMode - && TransparentLighting == other.TransparentLighting - && Flags == other.Flags; - } -}; - -/// -/// Material info structure - version 4 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -struct MaterialInfo4 -{ - MaterialDomain Domain; - OldMaterialBlendMode BlendMode; - MaterialFlags_Deprecated Flags; - MaterialTransparentLighting_Deprecated TransparentLighting; - MaterialPostFxLocation PostFxLocation; - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - bool operator==(const MaterialInfo4& other) const - { - return Domain == other.Domain - && BlendMode == other.BlendMode - && TransparentLighting == other.TransparentLighting - && PostFxLocation == other.PostFxLocation - && Flags == other.Flags; - } -}; - -/// -/// Material info structure - version 5 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -struct MaterialInfo5 -{ - MaterialDomain Domain; - OldMaterialBlendMode BlendMode; - MaterialFlags_Deprecated Flags; - MaterialTransparentLighting_Deprecated TransparentLighting; - MaterialPostFxLocation PostFxLocation; - float MaskThreshold; - float OpacityThreshold; - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - 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; - } -}; - -/// -/// Material info structure - version 6 -/// [Deprecated on 10.09.2018, expires on 10.05.2019] -/// -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; - } - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - 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; - } -}; - -/// -/// Material info structure - version 7 -/// [Deprecated on 13.09.2018, expires on 13.12.2018] -/// -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; - } - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - 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; - } -}; - /// /// 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; - } - - /// - /// Compare structure with other one - /// - /// Other structure to compare - /// True if both structures are equal - 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; }; /// @@ -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 diff --git a/Source/Engine/Graphics/Materials/MaterialParams.cpp b/Source/Engine/Graphics/Materials/MaterialParams.cpp index b5ff66c3b..01483558d 100644 --- a/Source/Engine/Graphics/Materials/MaterialParams.cpp +++ b/Source/Engine/Graphics/Materials/MaterialParams.cpp @@ -12,6 +12,85 @@ #include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPULimits.h" +bool MaterialInfo8::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; +} + +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 MaterialInfo::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; +} + const Char* ToString(MaterialParameterType value) { const Char* result; diff --git a/Source/Engine/Graphics/Materials/MaterialParams.h b/Source/Engine/Graphics/Materials/MaterialParams.h index d4fef1966..63ee16677 100644 --- a/Source/Engine/Graphics/Materials/MaterialParams.h +++ b/Source/Engine/Graphics/Materials/MaterialParams.h @@ -214,7 +214,6 @@ public: /// /// Gets the parameter ID (not the parameter instance Id but the original parameter ID). /// - /// The ID. API_PROPERTY() FORCE_INLINE Guid GetParameterID() const { return _paramId; @@ -223,7 +222,6 @@ public: /// /// Gets the parameter type. /// - /// The type. API_PROPERTY() FORCE_INLINE MaterialParameterType GetParameterType() const { return _type; @@ -232,7 +230,6 @@ public: /// /// Gets the parameter name. /// - /// The name. API_PROPERTY() FORCE_INLINE const String& GetName() const { return _name; @@ -241,7 +238,6 @@ public: /// /// Returns true is parameter is public visible. /// - /// True if parameter has public access, otherwise false. API_PROPERTY() FORCE_INLINE bool IsPublic() const { return _isPublic; @@ -250,7 +246,6 @@ public: /// /// Returns true is parameter is overriding the value. /// - /// True if parameter is overriding the value, otherwise false. API_PROPERTY() FORCE_INLINE bool IsOverride() const { return _override; @@ -259,7 +254,6 @@ public: /// /// Sets the value override mode. /// - /// The value. API_PROPERTY() void SetIsOverride(bool value) { _override = value; @@ -268,7 +262,6 @@ public: /// /// Gets the parameter resource graphics pipeline binding register index. /// - /// The binding register. FORCE_INLINE byte GetRegister() const { return _registerIndex; @@ -277,7 +270,6 @@ public: /// /// Gets the parameter binding offset since the start of the constant buffer. /// - /// The binding data offset (in bytes). FORCE_INLINE uint16 GetBindOffset() const { return _offset; diff --git a/Source/Engine/Streaming/Handlers/ModelsStreamingHandler.cpp b/Source/Engine/Streaming/Handlers/ModelsStreamingHandler.cpp index 32626e071..8c99f5155 100644 --- a/Source/Engine/Streaming/Handlers/ModelsStreamingHandler.cpp +++ b/Source/Engine/Streaming/Handlers/ModelsStreamingHandler.cpp @@ -21,7 +21,7 @@ int32 ModelsStreamingHandler::CalculateResidency(StreamableResource* resource, S if (quality < ZeroTolerance) return 0; - int32 lods = Math::CeilToInt(quality * lodCount); + int32 lods = Math::CeilToInt(quality * (StreamingQuality)lodCount); ASSERT(model.IsValidLODIndex(lods - 1)); return lods; diff --git a/Source/Engine/Streaming/StreamableResource.h b/Source/Engine/Streaming/StreamableResource.h index fab245791..257b02c57 100644 --- a/Source/Engine/Streaming/StreamableResource.h +++ b/Source/Engine/Streaming/StreamableResource.h @@ -108,27 +108,13 @@ public: public: - // Streaming Manager cached variables struct StreamingCache { - /// - /// The minimum usage distance since last update (eg. mesh draw distance from camera). - /// Used to calculate resource quality. - /// - //float MinDstSinceLastUpdate; - - DateTime LastUpdate; - int32 TargetResidency; - DateTime TargetResidencyChange; + //float MinDstSinceLastUpdate = MAX_float; + DateTime LastUpdate = 0; + int32 TargetResidency = 0; + DateTime TargetResidencyChange = 0; SamplesBuffer QualitySamples; - - StreamingCache() - //: MinDstSinceLastUpdate(MAX_float) - : LastUpdate(0) - , TargetResidency(0) - , TargetResidencyChange(0) - { - } }; StreamingCache Streaming;