diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h
index 0bd22067c..44f644d42 100644
--- a/Source/Engine/Graphics/Enums.h
+++ b/Source/Engine/Graphics/Enums.h
@@ -431,6 +431,9 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(BlendingMode);
///
API_ENUM() enum class ColorWrite
{
+ // No color writing.
+ None = 0,
+
// Allow data to be stored in the red component.
Red = 1,
// Allow data to be stored in the green component.
diff --git a/Source/Engine/Graphics/Graphics.Build.cs b/Source/Engine/Graphics/Graphics.Build.cs
index bcc1d2c98..c64dd5478 100644
--- a/Source/Engine/Graphics/Graphics.Build.cs
+++ b/Source/Engine/Graphics/Graphics.Build.cs
@@ -58,8 +58,8 @@ public class Graphics : EngineModule
case TargetPlatform.UWP:
options.PrivateDependencies.Add("GraphicsDeviceDX11");
break;
- case TargetPlatform.XboxOne:
- case TargetPlatform.XboxScarlett:
+ case TargetPlatform.XboxOne:
+ case TargetPlatform.XboxScarlett:
options.PrivateDependencies.Add("GraphicsDeviceDX12");
break;
case TargetPlatform.Linux:
diff --git a/Source/Engine/Input/Input.cpp b/Source/Engine/Input/Input.cpp
index 788ea6f2e..10888bb99 100644
--- a/Source/Engine/Input/Input.cpp
+++ b/Source/Engine/Input/Input.cpp
@@ -15,6 +15,7 @@
#include "Engine/Scripting/ScriptingType.h"
#include "Engine/Scripting/BinaryModule.h"
#include "Engine/Profiler/ProfilerCPU.h"
+#include "Engine/Serialization/JsonTools.h"
struct AxisEvaluation
{
@@ -105,6 +106,69 @@ void InputSettings::Apply()
Input::AxisMappings = AxisMappings;
}
+void InputSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
+{
+ const auto actionMappings = stream.FindMember("ActionMappings");
+ if (actionMappings != stream.MemberEnd())
+ {
+ auto& actionMappingsArray = actionMappings->value;
+ if (actionMappingsArray.IsArray())
+ {
+ ActionMappings.Resize(actionMappingsArray.Size(), false);
+ for (uint32 i = 0; i < actionMappingsArray.Size(); i++)
+ {
+ auto& v = actionMappingsArray[i];
+ if (!v.IsObject())
+ continue;
+
+ ActionConfig& config = ActionMappings[i];
+ config.Name = JsonTools::GetString(v, "Name");
+ config.Mode = JsonTools::GetEnum(v, "Mode", InputActionMode::Pressing);
+ config.Key = JsonTools::GetEnum(v, "Key", KeyboardKeys::None);
+ config.MouseButton = JsonTools::GetEnum(v, "MouseButton", MouseButton::None);
+ config.GamepadButton = JsonTools::GetEnum(v, "GamepadButton", GamepadButton::None);
+ config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
+ }
+ }
+ else
+ {
+ ActionMappings.Resize(0, false);
+ }
+ }
+
+ const auto axisMappings = stream.FindMember("AxisMappings");
+ if (axisMappings != stream.MemberEnd())
+ {
+ auto& axisMappingsArray = axisMappings->value;
+ if (axisMappingsArray.IsArray())
+ {
+ AxisMappings.Resize(axisMappingsArray.Size(), false);
+ for (uint32 i = 0; i < axisMappingsArray.Size(); i++)
+ {
+ auto& v = axisMappingsArray[i];
+ if (!v.IsObject())
+ continue;
+
+ AxisConfig& config = AxisMappings[i];
+ config.Name = JsonTools::GetString(v, "Name");
+ config.Axis = JsonTools::GetEnum(v, "Axis", InputAxisType::MouseX);
+ config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
+ config.PositiveButton = JsonTools::GetEnum(v, "PositiveButton", KeyboardKeys::None);
+ config.NegativeButton = JsonTools::GetEnum(v, "NegativeButton", KeyboardKeys::None);
+ config.DeadZone = JsonTools::GetFloat(v, "DeadZone", 0.1f);
+ config.Sensitivity = JsonTools::GetFloat(v, "Sensitivity", 0.4f);
+ config.Gravity = JsonTools::GetFloat(v, "Gravity", 1.0f);
+ config.Scale = JsonTools::GetFloat(v, "Scale", 1.0f);
+ config.Snap = JsonTools::GetBool(v, "Snap", false);
+ }
+ }
+ else
+ {
+ AxisMappings.Resize(0, false);
+ }
+ }
+}
+
void Mouse::OnMouseMoved(const Vector2& newPosition)
{
_prevState.MousePosition = newPosition;
diff --git a/Source/Engine/Input/InputSettings.h b/Source/Engine/Input/InputSettings.h
index fd594f3ee..1a28dfee9 100644
--- a/Source/Engine/Input/InputSettings.h
+++ b/Source/Engine/Input/InputSettings.h
@@ -3,7 +3,6 @@
#pragma once
#include "Engine/Core/Config/Settings.h"
-#include "Engine/Serialization/JsonTools.h"
#include "VirtualInput.h"
#include "Engine/Core/Collections/Array.h"
@@ -34,59 +33,5 @@ public:
// [SettingsBase]
void Apply() override;
-
- void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
- {
- const auto actionMappings = stream.FindMember("ActionMappings");
- if (actionMappings != stream.MemberEnd())
- {
- auto& actionMappingsArray = actionMappings->value;
- ASSERT(actionMappingsArray.IsArray());
- ActionMappings.Resize(actionMappingsArray.Size(), false);
-
- for (uint32 i = 0; i < actionMappingsArray.Size(); i++)
- {
- auto& v = actionMappingsArray[i];
- if (!v.IsObject())
- continue;
-
- ActionConfig& config = ActionMappings[i];
-
- config.Name = JsonTools::GetString(v, "Name");
- config.Mode = JsonTools::GetEnum(v, "Mode", InputActionMode::Pressing);
- config.Key = JsonTools::GetEnum(v, "Key", KeyboardKeys::None);
- config.MouseButton = JsonTools::GetEnum(v, "MouseButton", MouseButton::None);
- config.GamepadButton = JsonTools::GetEnum(v, "GamepadButton", GamepadButton::None);
- config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
- }
- }
-
- const auto axisMappings = stream.FindMember("AxisMappings");
- if (axisMappings != stream.MemberEnd())
- {
- auto& axisMappingsArray = axisMappings->value;
- ASSERT(axisMappingsArray.IsArray());
- AxisMappings.Resize(axisMappingsArray.Size(), false);
-
- for (uint32 i = 0; i < axisMappingsArray.Size(); i++)
- {
- auto& v = axisMappingsArray[i];
- if (!v.IsObject())
- continue;
-
- AxisConfig& config = AxisMappings[i];
-
- config.Name = JsonTools::GetString(v, "Name");
- config.Axis = JsonTools::GetEnum(v, "Axis", InputAxisType::MouseX);
- config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
- config.PositiveButton = JsonTools::GetEnum(v, "PositiveButton", KeyboardKeys::None);
- config.NegativeButton = JsonTools::GetEnum(v, "NegativeButton", KeyboardKeys::None);
- config.DeadZone = JsonTools::GetFloat(v, "DeadZone", 0.1f);
- config.Sensitivity = JsonTools::GetFloat(v, "Sensitivity", 0.4f);
- config.Gravity = JsonTools::GetFloat(v, "Gravity", 1.0f);
- config.Scale = JsonTools::GetFloat(v, "Scale", 1.0f);
- config.Snap = JsonTools::GetBool(v, "Snap", false);
- }
- }
- }
+ void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override;
};
diff --git a/Source/Engine/Level/Actors/StaticModel.cpp b/Source/Engine/Level/Actors/StaticModel.cpp
index 71996575e..7efd0ef32 100644
--- a/Source/Engine/Level/Actors/StaticModel.cpp
+++ b/Source/Engine/Level/Actors/StaticModel.cpp
@@ -238,6 +238,7 @@ void StaticModel::Draw(RenderContext& renderContext)
SAFE_DELETE_GPU_RESOURCE(vertexColorsBuffer);
}
}
+ _vertexColorsDirty = false;
}
#if USE_EDITOR
diff --git a/Source/Engine/Networking/Drivers/ENetDriver.cpp b/Source/Engine/Networking/Drivers/ENetDriver.cpp
index 5850fc499..5079ef218 100644
--- a/Source/Engine/Networking/Drivers/ENetDriver.cpp
+++ b/Source/Engine/Networking/Drivers/ENetDriver.cpp
@@ -55,7 +55,7 @@ ENetDriver::ENetDriver(const SpawnParams& params)
{
}
-void ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config)
+bool ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config)
{
_networkHost = host;
_config = config;
@@ -64,9 +64,11 @@ void ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config)
if (enet_initialize() != 0)
{
LOG(Error, "Failed to initialize ENet driver!");
+ return true;
}
- LOG(Info, "Initialized ENet driver!");
+ LOG(Info, "Initialized ENet driver");
+ return false;
}
void ENetDriver::Dispose()
diff --git a/Source/Engine/Networking/Drivers/ENetDriver.h b/Source/Engine/Networking/Drivers/ENetDriver.h
index e951b6fb2..b9f4b5545 100644
--- a/Source/Engine/Networking/Drivers/ENetDriver.h
+++ b/Source/Engine/Networking/Drivers/ENetDriver.h
@@ -19,7 +19,8 @@ DECLARE_SCRIPTING_TYPE(ENetDriver);
public:
// [INetworkDriver]
- void Initialize(NetworkPeer* host, const NetworkConfig& config) override;
+ String DriverName() override { return String("ENetDriver"); }
+ bool Initialize(NetworkPeer* host, const NetworkConfig& config) override;
void Dispose() override;
bool Listen() override;
bool Connect() override;
diff --git a/Source/Engine/Networking/INetworkDriver.h b/Source/Engine/Networking/INetworkDriver.h
index 2908f0d5f..7443210ea 100644
--- a/Source/Engine/Networking/INetworkDriver.h
+++ b/Source/Engine/Networking/INetworkDriver.h
@@ -3,6 +3,7 @@
#pragma once
#include "Types.h"
+#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/ScriptingType.h"
///
@@ -18,12 +19,21 @@ public:
///
virtual ~INetworkDriver() = default;
+ ///
+ /// Return name of this network driver implementation.
+ ///
+ API_FUNCTION() virtual String DriverName()
+ {
+ return String("Unknown");
+ }
+
///
/// Initializes the instance of this network driver using given configuration.
///
/// The peer that this driver has been assigned to.
/// The network config to use to configure this driver.
- API_FUNCTION() virtual void Initialize(NetworkPeer* host, const NetworkConfig& config) = 0;
+ /// True if failed to initialize network driver, false otherwise.
+ API_FUNCTION() virtual bool Initialize(NetworkPeer* host, const NetworkConfig& config) = 0;
///
/// Disposes this driver making it no longer usable.
diff --git a/Source/Engine/Networking/NetworkConfig.h b/Source/Engine/Networking/NetworkConfig.h
index 8814759db..6497043ab 100644
--- a/Source/Engine/Networking/NetworkConfig.h
+++ b/Source/Engine/Networking/NetworkConfig.h
@@ -4,10 +4,12 @@
#include "Engine/Platform/Network.h"
+class ScriptingObject;
+
///
/// Network driver implementations enum.
///
-API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkDriverType
+API_ENUM(Namespace="FlaxEngine.Networking") enum class DEPRECATED NetworkDriverType
{
///
/// Invalid network driver implementation.
@@ -26,16 +28,21 @@ API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkDriverType
API_STRUCT(Namespace="FlaxEngine.Networking") struct FLAXENGINE_API NetworkConfig
{
DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkConfig);
-public:
+
///
/// The network driver that will be used to create the peer.
/// To allow two peers to connect, they must use the same host.
///
API_FIELD()
- NetworkDriverType NetworkDriverType = NetworkDriverType::ENet;
- // TODO: Expose INetworkDriver as a ref not enum, when C++/C# interfaces are done.
+ DEPRECATED NetworkDriverType NetworkDriverType = NetworkDriverType::ENet;
+
+ ///
+ /// The network driver instance (implements INetworkDriver) that will be used to create and manage the peer, send and receive messages.
+ ///
+ /// Object is managed by the created network peer (will be deleted on peer shutdown).
+ API_FIELD()
+ ScriptingObject* NetworkDriver;
-public:
///
/// The upper limit on how many peers can join when we're listening.
///
@@ -48,21 +55,21 @@ public:
/// Set it to "any" when you want to listen at all available addresses.
/// Only IPv4 is supported.
API_FIELD()
- String Address = String("127.0.0.1");
+ String Address = String(TEXT("127.0.0.1"));
///
/// The port to connect to or listen at.
///
API_FIELD()
uint16 Port = 7777;
-
+
///
/// The size of a message buffer in bytes.
/// Should be lower than the MTU (maximal transmission unit) - typically 1500 bytes.
///
API_FIELD()
uint16 MessageSize = 1500;
-
+
///
/// The amount of pooled messages that can be used at once (receiving and sending!).
///
diff --git a/Source/Engine/Networking/NetworkPeer.cpp b/Source/Engine/Networking/NetworkPeer.cpp
index 52bc72776..9fd6317a6 100644
--- a/Source/Engine/Networking/NetworkPeer.cpp
+++ b/Source/Engine/Networking/NetworkPeer.cpp
@@ -2,9 +2,7 @@
#include "NetworkPeer.h"
#include "NetworkEvent.h"
-
#include "Drivers/ENetDriver.h"
-
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Math.h"
#include "Engine/Platform/CPUInfo.h"
@@ -15,15 +13,43 @@ namespace
uint32 LastHostId = 0;
}
-void NetworkPeer::Initialize(const NetworkConfig& config)
+bool NetworkPeer::Initialize(const NetworkConfig& config)
{
- Config = config;
+ if (NetworkDriver)
+ return true;
- ASSERT(NetworkDriver == nullptr);
- ASSERT(Config.NetworkDriverType != NetworkDriverType::Undefined);
- ASSERT(Config.ConnectionsLimit > 0);
- ASSERT(Config.MessageSize > 32); // TODO: Adjust this, not sure what the lowest limit should be.
- ASSERT(Config.MessagePoolSize > 128);
+ Config = config;
+ PRAGMA_DISABLE_DEPRECATION_WARNINGS
+ if (Config.NetworkDriver == nullptr && Config.NetworkDriverType == NetworkDriverType::ENet)
+ Config.NetworkDriver = New();
+ PRAGMA_ENABLE_DEPRECATION_WARNINGS
+
+ if (Config.NetworkDriver == nullptr)
+ {
+ LOG(Error, "Missing NetworkDriver");
+ return true;
+ }
+ if (Config.ConnectionsLimit <= 0)
+ {
+ LOG(Error, "Invalid ConnectionsLimit");
+ return true;
+ }
+ if (Config.MessageSize <= 32) // TODO: Adjust this, not sure what the lowest limit should be.
+ {
+ LOG(Error, "Invalid MessageSize");
+ return true;
+ }
+ if (Config.MessagePoolSize <= 128)
+ {
+ LOG(Error, "Invalid MessagePoolSize");
+ return true;
+ }
+ NetworkDriver = ToInterface(Config.NetworkDriver);
+ if (!NetworkDriver)
+ {
+ LOG(Error, "NetworkDriver doesn't implement INetworkDriver interface");
+ return true;
+ }
// TODO: Dynamic message pool allocation
// Setup messages
@@ -35,10 +61,14 @@ void NetworkPeer::Initialize(const NetworkConfig& config)
MessagePool.Push(messageId);
// Setup network driver
- NetworkDriver = New();
- NetworkDriver->Initialize(this, Config);
+ if (NetworkDriver->Initialize(this, Config))
+ {
+ LOG(Error, "Failed to initialize NetworkDriver");
+ return true;
+ }
- LOG(Info, "NetworkManager initialized using driver = {0}", static_cast(Config.NetworkDriverType));
+ LOG(Info, "NetworkManager initialized using driver = {0}", NetworkDriver->DriverName());
+ return false;
}
void NetworkPeer::Shutdown()
@@ -53,7 +83,7 @@ void NetworkPeer::Shutdown()
void NetworkPeer::CreateMessageBuffers()
{
ASSERT(MessageBuffer == nullptr);
-
+
const uint32 pageSize = Platform::GetCPUInfo().PageSize;
// Calculate total size in bytes
@@ -69,7 +99,7 @@ void NetworkPeer::CreateMessageBuffers()
void NetworkPeer::DisposeMessageBuffers()
{
ASSERT(MessageBuffer != nullptr);
-
+
Platform::FreePages(MessageBuffer);
MessageBuffer = nullptr;
}
@@ -117,7 +147,7 @@ void NetworkPeer::RecycleMessage(const NetworkMessage& message)
#ifdef BUILD_DEBUG
ASSERT(MessagePool.Contains(message.MessageId) == false);
#endif
-
+
// Return the message id
MessagePool.Push(message.MessageId);
}
@@ -136,7 +166,7 @@ void NetworkPeer::AbortSendMessage(const NetworkMessage& message)
bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const NetworkMessage& message)
{
ASSERT(message.IsValid());
-
+
NetworkDriver->SendMessage(channelType, message);
RecycleMessage(message);
@@ -146,7 +176,7 @@ bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const Net
bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const NetworkMessage& message, const NetworkConnection& target)
{
ASSERT(message.IsValid());
-
+
NetworkDriver->SendMessage(channelType, message, target);
RecycleMessage(message);
@@ -156,7 +186,7 @@ bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const Net
bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const NetworkMessage& message, const Array& targets)
{
ASSERT(message.IsValid());
-
+
NetworkDriver->SendMessage(channelType, message, targets);
RecycleMessage(message);
@@ -166,18 +196,28 @@ bool NetworkPeer::EndSendMessage(const NetworkChannelType channelType, const Net
NetworkPeer* NetworkPeer::CreatePeer(const NetworkConfig& config)
{
// Validate the address for listen/connect
- NetworkEndPoint endPoint = {};
- const bool isValidEndPoint = NetworkBase::CreateEndPoint(config.Address, String("7777"), NetworkIPVersion::IPv4, endPoint, false);
- ASSERT(config.Address == String("any") || isValidEndPoint);
-
+ if (config.Address != TEXT("any"))
+ {
+ NetworkEndPoint endPoint;
+ if (Network::CreateEndPoint(config.Address, String::Empty, NetworkIPVersion::IPv4, endPoint, false))
+ {
+ LOG(Error, "Invalid end point.");
+ return nullptr;
+ }
+ }
+
// Alloc new host
- Peers.Add(New());
- NetworkPeer* host = Peers.Last();
+ NetworkPeer* host = New();
host->HostId = LastHostId++;
// Initialize the host
- host->Initialize(config);
-
+ if (host->Initialize(config))
+ {
+ Delete(host);
+ return nullptr;
+ }
+
+ Peers.Add(host);
return host;
}
@@ -187,6 +227,6 @@ void NetworkPeer::ShutdownPeer(NetworkPeer* peer)
peer->Shutdown();
peer->HostId = -1;
Peers.Remove(peer);
-
+
Delete(peer);
}
diff --git a/Source/Engine/Networking/NetworkPeer.h b/Source/Engine/Networking/NetworkPeer.h
index ba0347ffd..865a8f3ec 100644
--- a/Source/Engine/Networking/NetworkPeer.h
+++ b/Source/Engine/Networking/NetworkPeer.h
@@ -2,12 +2,11 @@
#pragma once
-#include "Engine/Scripting/ScriptingType.h"
-#include "Engine/Scripting/ScriptingObjectReference.h"
#include "Types.h"
#include "NetworkConfig.h"
-
#include "Engine/Core/Collections/Array.h"
+#include "Engine/Scripting/ScriptingType.h"
+#include "Engine/Scripting/ScriptingObjectReference.h"
///
/// Low-level network peer class. Provides server-client communication functions, message processing and sending.
@@ -17,6 +16,7 @@ API_CLASS(sealed, NoSpawn, Namespace = "FlaxEngine.Networking") class FLAXENGINE
DECLARE_SCRIPTING_TYPE_NO_SPAWN(NetworkPeer);
friend class NetworkManager;
public:
+
int HostId = -1;
NetworkConfig Config;
INetworkDriver* NetworkDriver = nullptr;
@@ -25,22 +25,17 @@ public:
Array MessagePool;
public:
+
///
/// Initializes a new instance of the class.
///
- NetworkPeer() : PersistentScriptingObject(SpawnParams(Guid::New(), TypeInitializer))
+ NetworkPeer()
+ : PersistentScriptingObject(SpawnParams(Guid::New(), TypeInitializer))
{
}
-
-private:
- void Initialize(const NetworkConfig& config);
- void Shutdown();
-
-private:
- void CreateMessageBuffers();
- void DisposeMessageBuffers();
public:
+
///
/// Starts listening for incoming connections.
/// Once this is called, this peer becomes a server.
@@ -151,13 +146,12 @@ public:
API_FUNCTION()
bool EndSendMessage(NetworkChannelType channelType, const NetworkMessage& message, const Array& targets);
-public:
///
/// Creates new peer using given configuration.
///
/// The configuration to create and setup new peer.
/// The peer.
- /// Peer should be destroyed using once it is no longer in use.
+ /// Peer should be destroyed using once it is no longer in use. Returns null if failed to create a peer (eg. config is invalid).
API_FUNCTION()
static NetworkPeer* CreatePeer(const NetworkConfig& config);
@@ -167,8 +161,9 @@ public:
/// The peer to destroy.
API_FUNCTION()
static void ShutdownPeer(NetworkPeer* peer);
-
+
public:
+
bool IsValid() const
{
return NetworkDriver != nullptr && HostId >= 0;
@@ -181,6 +176,7 @@ public:
}
public:
+
FORCE_INLINE bool operator==(const NetworkPeer& other) const
{
return HostId == other.HostId;
@@ -190,5 +186,11 @@ public:
{
return HostId != other.HostId;
}
-};
+private:
+
+ bool Initialize(const NetworkConfig& config);
+ void Shutdown();
+ void CreateMessageBuffers();
+ void DisposeMessageBuffers();
+};
diff --git a/Source/Engine/Platform/ConditionVariable.h b/Source/Engine/Platform/ConditionVariable.h
index 90cf375e6..3d9989b18 100644
--- a/Source/Engine/Platform/ConditionVariable.h
+++ b/Source/Engine/Platform/ConditionVariable.h
@@ -2,19 +2,9 @@
#pragma once
-#if PLATFORM_WINDOWS
+#if PLATFORM_WINDOWS || PLATFORM_UWP || PLATFORM_XBOX_ONE || PLATFORM_XBOX_SCARLETT
#include "Win32/Win32ConditionVariable.h"
-#elif PLATFORM_UWP
-#include "Win32/Win32ConditionVariable.h"
-#elif PLATFORM_LINUX
-#include "Unix/UnixConditionVariable.h"
-#elif PLATFORM_PS4
-#include "Unix/UnixConditionVariable.h"
-#elif PLATFORM_XBOX_ONE
-#include "Win32/Win32ConditionVariable.h"
-#elif PLATFORM_XBOX_SCARLETT
-#include "Win32/Win32ConditionVariable.h"
-#elif PLATFORM_ANDROID
+#elif PLATFORM_LINUX || PLATFORM_ANDROID || PLATFORM_PS4 || PLATFORM_PS5
#include "Unix/UnixConditionVariable.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchConditionVariable.h"
diff --git a/Source/Engine/Platform/Unix/UnixPlatform.cpp b/Source/Engine/Platform/Unix/UnixPlatform.cpp
index 42b788649..be1d76d40 100644
--- a/Source/Engine/Platform/Unix/UnixPlatform.cpp
+++ b/Source/Engine/Platform/Unix/UnixPlatform.cpp
@@ -22,7 +22,6 @@ void* UnixPlatform::Allocate(uint64 size, uint64 alignment)
{
uint32_t pad = sizeof(offset_t) + (alignment - 1);
void* p = malloc(size + pad);
-
if (p)
{
// Add the offset size to malloc's pointer
@@ -31,8 +30,10 @@ void* UnixPlatform::Allocate(uint64 size, uint64 alignment)
// Calculate the offset and store it behind aligned pointer
*((offset_t*)ptr - 1) = (offset_t)((uintptr_t)ptr - (uintptr_t)p);
}
+#if COMPILE_WITH_PROFILER
+ OnMemoryAlloc(ptr, size);
+#endif
}
-
return ptr;
}
@@ -40,11 +41,14 @@ void UnixPlatform::Free(void* ptr)
{
if (ptr)
{
+#if COMPILE_WITH_PROFILER
+ OnMemoryFree(ptr);
+#endif
// Walk backwards from the passed-in pointer to get the pointer offset
offset_t offset = *((offset_t*)ptr - 1);
// Get original pointer
- void* p = (void *)((uint8_t *)ptr - offset);
+ void* p = (void*)((uint8_t*)ptr - offset);
// Free memory
free(p);
diff --git a/Source/Engine/Platform/Window.h b/Source/Engine/Platform/Window.h
index 0a68ea9c7..ea2bb6e8e 100644
--- a/Source/Engine/Platform/Window.h
+++ b/Source/Engine/Platform/Window.h
@@ -18,6 +18,8 @@
#include "Android/AndroidWindow.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchWindow.h"
+#elif PLATFORM_PS5
+#include "Platforms/PS5/Engine/Platform/PS5Window.h"
#else
#error Missing Window implementation!
#endif
diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp
index 65c38003c..96b2284dd 100644
--- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp
+++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp
@@ -96,7 +96,7 @@ bool FeatureData::Init()
if (c == '@')
break;
}
- const Char* end = &contents[i];
+ const Char* end = contents.Get() + i;
// Set input
Inputs[inIndex].Set(start, (int32)(end - start));
diff --git a/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h b/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h
index bdd6cc7ba..3b7a8f37e 100644
--- a/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h
+++ b/Source/ThirdParty/PhysX/foundation/PxPreprocessor.h
@@ -102,6 +102,9 @@ Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSyst
#define PX_IOS 1
#elif defined(__APPLE__)
#define PX_OSX 1
+#elif defined(__PROSPERO__)
+#define PX_PS4 1
+#define PX_PS5 1
#elif defined(__ORBIS__)
#define PX_PS4 1
#elif defined(__NX__)
diff --git a/Source/ThirdParty/enet/enet.h b/Source/ThirdParty/enet/enet.h
index 73aa72cf0..2357e8488 100644
--- a/Source/ThirdParty/enet/enet.h
+++ b/Source/ThirdParty/enet/enet.h
@@ -140,7 +140,7 @@
#else
#include
#include
- #if PLATFORM_PS4
+ #if PLATFORM_PS4 || PLATFORM_PS5
#define ENET_IPV6 0
#include
in_addr in4addr_any = { 0 };
diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
index 4937e6d6d..6073318a1 100644
--- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
+++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs
@@ -185,7 +185,7 @@ namespace Flax.Build.Bindings
// ScriptingObjectReference or AssetReference or WeakAssetReference or SoftObjectReference
if ((typeInfo.Type == "ScriptingObjectReference" || typeInfo.Type == "AssetReference" || typeInfo.Type == "WeakAssetReference" || typeInfo.Type == "SoftObjectReference") && typeInfo.GenericArgs != null)
- return typeInfo.GenericArgs[0].Type.Replace("::", ".");
+ return GenerateCSharpNativeToManaged(buildData, typeInfo.GenericArgs[0], caller);
// Array or Span
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span") && typeInfo.GenericArgs != null)
diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs
index 29415bb45..0e1e2a818 100644
--- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs
+++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs
@@ -1291,7 +1291,7 @@ namespace Flax.Build.Bindings
var baseType = classInfo?.BaseType ?? structureInfo?.BaseType;
if (classInfo != null && classInfo.IsBaseTypeHidden)
baseType = null;
- if (baseType != null && (baseType.Name == "PersistentScriptingObject" || baseType.Name == "ScriptingObject"))
+ if (baseType != null && (baseType.Name == "PersistentScriptingObject" || baseType.Name == "ScriptingObject" || baseType.Name == "ManagedScriptingObject"))
baseType = null;
CppAutoSerializeFields.Clear();
CppAutoSerializeProperties.Clear();
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs
index 4267141fd..f3aa8ac9e 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs
@@ -31,6 +31,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.UWP,
TargetPlatform.XboxOne,
TargetPlatform.PS4,
+ TargetPlatform.PS5,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
@@ -152,6 +153,12 @@ namespace Flax.Deps.Dependencies
suppressBitsPostfix = true;
binariesPrefix = "lib";
break;
+ case TargetPlatform.PS5:
+ binariesSubDir = "ps5";
+ buildPlatform = "PROSPERO";
+ suppressBitsPostfix = true;
+ binariesPrefix = "lib";
+ break;
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett:
binariesSubDir = "win.x86_64.vc142.md";
@@ -209,8 +216,9 @@ namespace Flax.Deps.Dependencies
switch (targetPlatform)
{
case TargetPlatform.PS4:
+ case TargetPlatform.PS5:
// Hack: PS4 uses .o extension for compiler output files but CMake uses .obj even if CMAKE_CXX_OUTPUT_EXTENSION/CMAKE_C_OUTPUT_EXTENSION are specified
- Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\ps4"), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o");
+ Utilities.ReplaceInFiles(Path.Combine(root, "physx\\compiler\\" + binariesSubDir), "*.vcxproj", SearchOption.AllDirectories, ".obj", ".o");
break;
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett:
@@ -320,7 +328,7 @@ namespace Flax.Deps.Dependencies
}
// Get the source
- CloneGitRepoSingleBranch(root, "https://github.com/NVIDIAGameWorks/PhysX.git", "4.1");
+ CloneGitRepoSingleBranch(root, "https://github.com/FlaxEngine/PhysX.git", "flax-master");
foreach (var platform in options.Platforms)
{
@@ -347,6 +355,12 @@ namespace Flax.Deps.Dependencies
Build(options, "ps4", platform, TargetArchitecture.x64);
break;
}
+ case TargetPlatform.PS5:
+ {
+ Utilities.DirectoryCopy(Path.Combine(GetBinariesFolder(options, platform), "Data", "PhysX"), root, true, true);
+ Build(options, "ps5", platform, TargetArchitecture.x64);
+ break;
+ }
case TargetPlatform.XboxScarlett:
{
Build(options, "vc16win64", platform, TargetArchitecture.x64);
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs
index 03ec4f711..b198dbf29 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/freetype.cs
@@ -29,6 +29,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.UWP,
TargetPlatform.XboxOne,
TargetPlatform.PS4,
+ TargetPlatform.PS5,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
@@ -163,6 +164,21 @@ namespace Flax.Deps.Dependencies
break;
}
+ case TargetPlatform.PS5:
+ {
+ // Get the build data files
+ Utilities.DirectoryCopy(
+ Path.Combine(GetBinariesFolder(options, platform), "Data", "freetype"),
+ Path.Combine(root, "builds", "PS5"), false, true);
+
+ // Build for PS5
+ var solutionPath = Path.Combine(root, "builds", "PS5", "freetype.sln");
+ Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO");
+ var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
+ Utilities.FileCopy(Path.Combine(root, "lib", "PS5", libraryFileName), Path.Combine(depsFolder, libraryFileName));
+
+ break;
+ }
case TargetPlatform.XboxOne:
{
// Fix the MSVC project settings for Xbox One
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs b/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs
index d0e81ae57..6056cad48 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/ogg.cs
@@ -28,6 +28,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.UWP,
TargetPlatform.XboxOne,
TargetPlatform.PS4,
+ TargetPlatform.PS5,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
@@ -143,6 +144,21 @@ namespace Flax.Deps.Dependencies
break;
}
+ case TargetPlatform.PS5:
+ {
+ // Get the build data files
+ Utilities.DirectoryCopy(
+ Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg"),
+ Path.Combine(root, "PS5"), true, true);
+
+ // Build for PS5
+ var solutionPath = Path.Combine(root, "PS5", "libogg_static.sln");
+ Deploy.VCEnvironment.BuildSolution(solutionPath, "Release", "PROSPERO");
+ var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
+ Utilities.FileCopy(Path.Combine(root, "PS5", "lib", libraryFileName), Path.Combine(depsFolder, libraryFileName));
+
+ break;
+ }
case TargetPlatform.XboxOne:
{
// Fix the MSVC project settings for Xbox Scarlett
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs
index 7d49a8d8e..510feacb9 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/vorbis.cs
@@ -29,6 +29,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.UWP,
TargetPlatform.XboxOne,
TargetPlatform.PS4,
+ TargetPlatform.PS5,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
@@ -186,6 +187,24 @@ namespace Flax.Deps.Dependencies
Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"),
Path.Combine(root, "libogg", "include", "ogg", "config_types.h"));
break;
+ case TargetPlatform.PS5:
+ buildDir = Path.Combine(rootMsvcLib, "PS5");
+ binariesToCopy = new[]
+ {
+ new Binary("libvorbis.a", "libvorbis"),
+ };
+ vcxprojPaths = new[]
+ {
+ Path.Combine(buildDir, "libvorbis", "libvorbis_static.vcxproj"),
+ };
+ buildPlatform = "PROSPERO";
+ Utilities.DirectoryCopy(
+ Path.Combine(GetBinariesFolder(options, platform), "Data", "vorbis"),
+ buildDir, true, true);
+ Utilities.FileCopy(
+ Path.Combine(GetBinariesFolder(options, platform), "Data", "ogg", "ogg", "config_types.h"),
+ Path.Combine(root, "libogg", "include", "ogg", "config_types.h"));
+ break;
case TargetPlatform.XboxOne:
buildDir = Path.Combine(rootMsvcLib, "win32", "VS2010");
binariesToCopy = binariesToCopyWindows;
@@ -279,6 +298,11 @@ namespace Flax.Deps.Dependencies
BuildMsbuild(options, TargetPlatform.PS4, TargetArchitecture.x64);
break;
}
+ case TargetPlatform.PS5:
+ {
+ BuildMsbuild(options, TargetPlatform.PS5, TargetArchitecture.x64);
+ break;
+ }
case TargetPlatform.XboxScarlett:
{
BuildMsbuild(options, TargetPlatform.XboxScarlett, TargetArchitecture.x64);
diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
index 758e2dfb1..2ea075e1d 100644
--- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
+++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
@@ -96,8 +96,12 @@ namespace Flax.Build.Platforms
var exeExtension = Platform.BuildPlatform.ExecutableFileExtension;
ToolsetRoot = toolchainSubDir == null ? Path.Combine(toolchainRoots, ArchitectureName) : Path.Combine(toolchainRoots, toolchainSubDir);
ClangPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "clang++"))) + exeExtension;
+ if (!File.Exists(ClangPath))
+ ClangPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "clang"))) + exeExtension;
if (!File.Exists(ClangPath))
ClangPath = Path.Combine(ToolsetRoot, "bin/clang++") + exeExtension;
+ if (!File.Exists(ClangPath))
+ ClangPath = Path.Combine(ToolsetRoot, "bin/clang") + exeExtension;
ArPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "ar"))) + exeExtension;
LlvmArPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}", "llvm-ar"))) + exeExtension;
RanlibPath = Path.Combine(Path.Combine(ToolsetRoot, string.Format("bin/{0}-{1}", ArchitectureName, "ranlib"))) + exeExtension;