Merge remote-tracking branch 'origin/master' into 1.8
# Conflicts: # Source/Editor/Utilities/EditorUtilities.cpp # Source/Editor/Utilities/EditorUtilities.h
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
|
||||
#include "Engine/Debug/Exceptions/ArgumentNullException.h"
|
||||
#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
@@ -81,33 +82,10 @@ bool GPUBufferDescription::Equals(const GPUBufferDescription& other) const
|
||||
|
||||
String GPUBufferDescription::ToString() const
|
||||
{
|
||||
// TODO: add tool to Format to string
|
||||
|
||||
String flags;
|
||||
if (Flags == GPUBufferFlags::None)
|
||||
{
|
||||
flags = TEXT("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: create tool to auto convert flag enums to string
|
||||
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if (EnumHasAnyFlags(Flags, GPUBufferFlags::value)) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
CONVERT_FLAGS_FLAGS_2_STR(ShaderResource);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(VertexBuffer);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(IndexBuffer);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(UnorderedAccess);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(Append);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(Counter);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(Argument);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(Structured);
|
||||
#undef CONVERT_FLAGS_FLAGS_2_STR
|
||||
}
|
||||
|
||||
return String::Format(TEXT("Size: {0}, Stride: {1}, Flags: {2}, Format: {3}, Usage: {4}"),
|
||||
Size,
|
||||
Stride,
|
||||
flags,
|
||||
ScriptingEnum::ToStringFlags(Flags),
|
||||
ScriptingEnum::ToString(Format),
|
||||
(int32)Usage);
|
||||
}
|
||||
@@ -212,7 +190,7 @@ GPUBuffer* GPUBuffer::ToStagingUpload() const
|
||||
|
||||
bool GPUBuffer::Resize(uint32 newSize)
|
||||
{
|
||||
// Validate input
|
||||
PROFILE_CPU();
|
||||
if (!IsAllocated())
|
||||
{
|
||||
Log::InvalidOperationException(TEXT("Buffer.Resize"));
|
||||
@@ -236,12 +214,12 @@ bool GPUBuffer::DownloadData(BytesContainer& result)
|
||||
LOG(Warning, "Cannot download GPU buffer data from an empty buffer.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_desc.Usage == GPUResourceUsage::StagingReadback || _desc.Usage == GPUResourceUsage::Dynamic)
|
||||
{
|
||||
// Use faster path for staging resources
|
||||
return GetData(result);
|
||||
}
|
||||
PROFILE_CPU();
|
||||
|
||||
// Ensure not running on main thread
|
||||
if (IsInMainThread())
|
||||
@@ -358,6 +336,7 @@ Task* GPUBuffer::DownloadDataAsync(BytesContainer& result)
|
||||
|
||||
bool GPUBuffer::GetData(BytesContainer& output)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
void* mapped = Map(GPUResourceMapMode::Read);
|
||||
if (!mapped)
|
||||
return true;
|
||||
@@ -368,6 +347,7 @@ bool GPUBuffer::GetData(BytesContainer& output)
|
||||
|
||||
void GPUBuffer::SetData(const void* data, uint32 size)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
if (size == 0 || data == nullptr)
|
||||
{
|
||||
Log::ArgumentNullException(TEXT("Buffer.SetData"));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Engine/Core/Config/GraphicsSettings.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
#include "Engine/Render2D/Font.h"
|
||||
|
||||
bool Graphics::UseVSync = false;
|
||||
Quality Graphics::AAQuality = Quality::Medium;
|
||||
@@ -69,6 +70,9 @@ void GraphicsSettings::Apply()
|
||||
Graphics::GIQuality = GIQuality;
|
||||
Graphics::PostProcessSettings = ::PostProcessSettings();
|
||||
Graphics::PostProcessSettings.BlendWith(PostProcessSettings, 1.0f);
|
||||
#if !USE_EDITOR // OptionsModule handles fallback fonts in Editor
|
||||
Font::FallbackFonts = FallbackFonts;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Graphics::DisposeDevice()
|
||||
|
||||
@@ -911,10 +911,10 @@ bool ModelData::Pack2AnimationHeader(WriteStream* stream, int32 animIndex) const
|
||||
}
|
||||
|
||||
// Info
|
||||
stream->WriteInt32(100); // Header version (for fast version upgrades without serialization format change)
|
||||
stream->WriteInt32(103); // Header version (for fast version upgrades without serialization format change)
|
||||
stream->WriteDouble(anim.Duration);
|
||||
stream->WriteDouble(anim.FramesPerSecond);
|
||||
stream->WriteBool(anim.EnableRootMotion);
|
||||
stream->WriteByte((byte)anim.RootMotionFlags);
|
||||
stream->WriteString(anim.RootNodeName, 13);
|
||||
|
||||
// Animation channels
|
||||
@@ -928,6 +928,12 @@ bool ModelData::Pack2AnimationHeader(WriteStream* stream, int32 animIndex) const
|
||||
Serialization::Serialize(*stream, channel.Scale);
|
||||
}
|
||||
|
||||
// Animation events
|
||||
stream->WriteInt32(0);
|
||||
|
||||
// Nested animations
|
||||
stream->WriteInt32(0);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
FORCE_INLINE SkeletonNode& RootNode()
|
||||
{
|
||||
ASSERT(Nodes.HasItems());
|
||||
return Nodes[0];
|
||||
return Nodes.Get()[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,52 +100,24 @@ public:
|
||||
FORCE_INLINE const SkeletonNode& RootNode() const
|
||||
{
|
||||
ASSERT(Nodes.HasItems());
|
||||
return Nodes[0];
|
||||
return Nodes.Get()[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the contents of object with the other object without copy operation. Performs fast internal data exchange.
|
||||
/// </summary>
|
||||
void Swap(SkeletonData& other)
|
||||
{
|
||||
Nodes.Swap(other.Nodes);
|
||||
Bones.Swap(other.Bones);
|
||||
}
|
||||
void Swap(SkeletonData& other);
|
||||
|
||||
int32 FindNode(const StringView& name) const
|
||||
{
|
||||
for (int32 i = 0; i < Nodes.Count(); i++)
|
||||
{
|
||||
if (Nodes[i].Name == name)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Transform GetNodeTransform(int32 nodeIndex) const;
|
||||
void SetNodeTransform(int32 nodeIndex, const Transform& value);
|
||||
|
||||
int32 FindBone(int32 nodeIndex) const
|
||||
{
|
||||
for (int32 i = 0; i < Bones.Count(); i++)
|
||||
{
|
||||
if (Bones[i].NodeIndex == nodeIndex)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int32 FindNode(const StringView& name) const;
|
||||
int32 FindBone(int32 nodeIndex) const;
|
||||
|
||||
uint64 GetMemoryUsage() const
|
||||
{
|
||||
uint64 result = Nodes.Capacity() * sizeof(SkeletonNode) + Bones.Capacity() * sizeof(SkeletonBone);
|
||||
for (const auto& e : Nodes)
|
||||
result += (e.Name.Length() + 1) * sizeof(Char);
|
||||
return result;
|
||||
}
|
||||
uint64 GetMemoryUsage() const;
|
||||
|
||||
/// <summary>
|
||||
/// Releases data.
|
||||
/// </summary>
|
||||
void Dispose()
|
||||
{
|
||||
Nodes.Resize(0);
|
||||
Bones.Resize(0);
|
||||
}
|
||||
void Dispose();
|
||||
};
|
||||
|
||||
@@ -18,6 +18,69 @@
|
||||
#include "Engine/Threading/Task.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
|
||||
void SkeletonData::Swap(SkeletonData& other)
|
||||
{
|
||||
Nodes.Swap(other.Nodes);
|
||||
Bones.Swap(other.Bones);
|
||||
}
|
||||
|
||||
Transform SkeletonData::GetNodeTransform(int32 nodeIndex) const
|
||||
{
|
||||
const int32 parentIndex = Nodes[nodeIndex].ParentIndex;
|
||||
if (parentIndex == -1)
|
||||
{
|
||||
return Nodes[nodeIndex].LocalTransform;
|
||||
}
|
||||
const Transform parentTransform = GetNodeTransform(parentIndex);
|
||||
return parentTransform.LocalToWorld(Nodes[nodeIndex].LocalTransform);
|
||||
}
|
||||
|
||||
void SkeletonData::SetNodeTransform(int32 nodeIndex, const Transform& value)
|
||||
{
|
||||
const int32 parentIndex = Nodes[nodeIndex].ParentIndex;
|
||||
if (parentIndex == -1)
|
||||
{
|
||||
Nodes[nodeIndex].LocalTransform = value;
|
||||
return;
|
||||
}
|
||||
const Transform parentTransform = GetNodeTransform(parentIndex);
|
||||
parentTransform.WorldToLocal(value, Nodes[nodeIndex].LocalTransform);
|
||||
}
|
||||
|
||||
int32 SkeletonData::FindNode(const StringView& name) const
|
||||
{
|
||||
for (int32 i = 0; i < Nodes.Count(); i++)
|
||||
{
|
||||
if (Nodes[i].Name == name)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32 SkeletonData::FindBone(int32 nodeIndex) const
|
||||
{
|
||||
for (int32 i = 0; i < Bones.Count(); i++)
|
||||
{
|
||||
if (Bones[i].NodeIndex == nodeIndex)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint64 SkeletonData::GetMemoryUsage() const
|
||||
{
|
||||
uint64 result = Nodes.Capacity() * sizeof(SkeletonNode) + Bones.Capacity() * sizeof(SkeletonBone);
|
||||
for (const auto& e : Nodes)
|
||||
result += (e.Name.Length() + 1) * sizeof(Char);
|
||||
return result;
|
||||
}
|
||||
|
||||
void SkeletonData::Dispose()
|
||||
{
|
||||
Nodes.Resize(0);
|
||||
Bones.Resize(0);
|
||||
}
|
||||
|
||||
void SkinnedMesh::Init(SkinnedModel* model, int32 lodIndex, int32 index, int32 materialSlotIndex, const BoundingBox& box, const BoundingSphere& sphere)
|
||||
{
|
||||
_model = model;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace FlaxEngine
|
||||
Matrix.Invert(ref View, out IV);
|
||||
Matrix.Invert(ref Projection, out IP);
|
||||
Matrix.Multiply(ref View, ref Projection, out var viewProjection);
|
||||
Frustum = new BoundingFrustum(viewProjection);
|
||||
Frustum = new BoundingFrustum(ref viewProjection);
|
||||
Matrix.Invert(ref viewProjection, out IVP);
|
||||
CullingFrustum = Frustum;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Engine/Graphics/GPULimits.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
|
||||
namespace
|
||||
@@ -158,29 +159,6 @@ bool GPUTextureDescription::Equals(const GPUTextureDescription& other) const
|
||||
|
||||
String GPUTextureDescription::ToString() const
|
||||
{
|
||||
// TODO: add tool to Format to string
|
||||
|
||||
String flags;
|
||||
if (Flags == GPUTextureFlags::None)
|
||||
{
|
||||
flags = TEXT("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: create tool to auto convert flag enums to string
|
||||
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if (EnumHasAnyFlags(Flags, GPUTextureFlags::value)) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
CONVERT_FLAGS_FLAGS_2_STR(ShaderResource);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(RenderTarget);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(UnorderedAccess);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(DepthStencil);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(PerMipViews);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(PerSliceViews);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(ReadOnlyDepthView);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(BackBuffer);
|
||||
#undef CONVERT_FLAGS_FLAGS_2_STR
|
||||
}
|
||||
|
||||
return String::Format(TEXT("Size: {0}x{1}x{2}[{3}], Type: {4}, Mips: {5}, Format: {6}, MSAA: {7}, Flags: {8}, Usage: {9}"),
|
||||
Width,
|
||||
Height,
|
||||
@@ -190,7 +168,7 @@ String GPUTextureDescription::ToString() const
|
||||
MipLevels,
|
||||
ScriptingEnum::ToString(Format),
|
||||
::ToString(MultiSampleLevel),
|
||||
flags,
|
||||
ScriptingEnum::ToStringFlags(Flags),
|
||||
(int32)Usage);
|
||||
}
|
||||
|
||||
@@ -545,7 +523,7 @@ GPUTexture* GPUTexture::ToStagingUpload() const
|
||||
|
||||
bool GPUTexture::Resize(int32 width, int32 height, int32 depth, PixelFormat format)
|
||||
{
|
||||
// Validate texture is created
|
||||
PROFILE_CPU();
|
||||
if (!IsAllocated())
|
||||
{
|
||||
LOG(Warning, "Cannot resize not created textures.");
|
||||
@@ -609,6 +587,7 @@ GPUTask* GPUTexture::UploadMipMapAsync(const BytesContainer& data, int32 mipInde
|
||||
|
||||
GPUTask* GPUTexture::UploadMipMapAsync(const BytesContainer& data, int32 mipIndex, int32 rowPitch, int32 slicePitch, bool copyData)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
ASSERT(IsAllocated());
|
||||
ASSERT(mipIndex < MipLevels() && data.IsValid());
|
||||
ASSERT(data.Length() >= slicePitch);
|
||||
@@ -700,6 +679,7 @@ bool GPUTexture::DownloadData(TextureData& result)
|
||||
{
|
||||
MISSING_CODE("support volume texture data downloading.");
|
||||
}
|
||||
PROFILE_CPU();
|
||||
|
||||
// Use faster path for staging resources
|
||||
if (IsStaging())
|
||||
@@ -781,6 +761,7 @@ Task* GPUTexture::DownloadDataAsync(TextureData& result)
|
||||
{
|
||||
MISSING_CODE("support volume texture data downloading.");
|
||||
}
|
||||
PROFILE_CPU();
|
||||
|
||||
// Use faster path for staging resources
|
||||
if (IsStaging())
|
||||
|
||||
Reference in New Issue
Block a user