Merge branch 'master' into vulkan
This commit is contained in:
commit
a4aad3caac
|
|
@ -111,6 +111,10 @@ Nazara Engine:
|
||||||
- InstancedRenderable::SetMaterial methods are now public.
|
- InstancedRenderable::SetMaterial methods are now public.
|
||||||
- Fixed Model copy constructor not copying materials
|
- Fixed Model copy constructor not copying materials
|
||||||
- ⚠️ Added InstancedRenderable::Clone() method
|
- ⚠️ Added InstancedRenderable::Clone() method
|
||||||
|
- Fixed a lot of classes not having their move constructor/assignation operator marked noexcept
|
||||||
|
- ⚠️ SocketPoller::Wait now returns the number of socket marked as ready, and takes an additional optional parameter allowing to query the last error.
|
||||||
|
- SocketPoller will now silently ignore "interrupt errors"
|
||||||
|
- Added RigidBody2D::ClosestPointQuery
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
|
|
@ -160,6 +164,8 @@ Nazara Development Kit:
|
||||||
- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called.
|
- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called.
|
||||||
- Fixed EntityOwner move assignment which was losing entity ownership
|
- Fixed EntityOwner move assignment which was losing entity ownership
|
||||||
- Add GraphicsComponent:ForEachRenderable method
|
- Add GraphicsComponent:ForEachRenderable method
|
||||||
|
- Fixed GraphicsComponent reflective material count which was not initialized
|
||||||
|
- Added PhysicsComponent2D::ClosestPointQuery
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Ndk
|
||||||
using Factory = std::function<BaseComponent*()>;
|
using Factory = std::function<BaseComponent*()>;
|
||||||
|
|
||||||
BaseComponent(ComponentIndex componentIndex);
|
BaseComponent(ComponentIndex componentIndex);
|
||||||
BaseComponent(BaseComponent&&) = default;
|
BaseComponent(BaseComponent&&) noexcept = default;
|
||||||
virtual ~BaseComponent();
|
virtual ~BaseComponent();
|
||||||
|
|
||||||
virtual std::unique_ptr<BaseComponent> Clone() const = 0;
|
virtual std::unique_ptr<BaseComponent> Clone() const = 0;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Ndk
|
||||||
inline static ComponentIndex GetMaxComponentIndex();
|
inline static ComponentIndex GetMaxComponentIndex();
|
||||||
|
|
||||||
BaseComponent& operator=(const BaseComponent&) = delete;
|
BaseComponent& operator=(const BaseComponent&) = delete;
|
||||||
BaseComponent& operator=(BaseComponent&&) = default;
|
BaseComponent& operator=(BaseComponent&&) noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseComponent(const BaseComponent&) = default;
|
BaseComponent(const BaseComponent&) = default;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Ndk
|
||||||
|
|
||||||
BaseWidget(BaseWidget* parent);
|
BaseWidget(BaseWidget* parent);
|
||||||
BaseWidget(const BaseWidget&) = delete;
|
BaseWidget(const BaseWidget&) = delete;
|
||||||
BaseWidget(BaseWidget&&) = default;
|
BaseWidget(BaseWidget&&) = delete;
|
||||||
virtual ~BaseWidget();
|
virtual ~BaseWidget();
|
||||||
|
|
||||||
template<typename T, typename... Args> T* Add(Args&&... args);
|
template<typename T, typename... Args> T* Add(Args&&... args);
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Ndk
|
||||||
void Show(bool show = true);
|
void Show(bool show = true);
|
||||||
|
|
||||||
BaseWidget& operator=(const BaseWidget&) = delete;
|
BaseWidget& operator=(const BaseWidget&) = delete;
|
||||||
BaseWidget& operator=(BaseWidget&&) = default;
|
BaseWidget& operator=(BaseWidget&&) = delete;
|
||||||
|
|
||||||
struct Padding
|
struct Padding
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Ndk
|
||||||
public:
|
public:
|
||||||
using RenderableList = std::vector<Nz::InstancedRenderableRef>;
|
using RenderableList = std::vector<Nz::InstancedRenderableRef>;
|
||||||
|
|
||||||
GraphicsComponent();
|
inline GraphicsComponent();
|
||||||
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
||||||
~GraphicsComponent() = default;
|
~GraphicsComponent() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
inline GraphicsComponent::GraphicsComponent() :
|
inline GraphicsComponent::GraphicsComponent() :
|
||||||
|
m_reflectiveMaterialCount(0),
|
||||||
m_scissorRect(-1, -1)
|
m_scissorRect(-1, -1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +23,7 @@ namespace Ndk
|
||||||
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
|
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
|
||||||
Component(graphicsComponent),
|
Component(graphicsComponent),
|
||||||
HandledObject(graphicsComponent),
|
HandledObject(graphicsComponent),
|
||||||
|
m_reflectiveMaterialCount(0),
|
||||||
m_boundingVolume(graphicsComponent.m_boundingVolume),
|
m_boundingVolume(graphicsComponent.m_boundingVolume),
|
||||||
m_transformMatrix(graphicsComponent.m_transformMatrix),
|
m_transformMatrix(graphicsComponent.m_transformMatrix),
|
||||||
m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated),
|
m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated),
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ namespace Ndk
|
||||||
void AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
void AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||||
void AddTorque(float torque);
|
void AddTorque(float torque);
|
||||||
|
|
||||||
|
bool ClosestPointQuery(const Nz::Vector2f& position, Nz::Vector2f* closestPoint, float* closestDistance) const;
|
||||||
|
|
||||||
Nz::Rectf GetAABB() const;
|
Nz::Rectf GetAABB() const;
|
||||||
float GetAngularVelocity() const;
|
float GetAngularVelocity() const;
|
||||||
Nz::Vector2f GetCenterOfGravity(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
Nz::Vector2f GetCenterOfGravity(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
|
|
@ -97,6 +98,23 @@ namespace Ndk
|
||||||
m_object->AddTorque(torque);
|
m_object->AddTorque(torque);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Finds the closest point on the entity relative to a position
|
||||||
|
* \return True if such a point exists (will return false if no collider exists)
|
||||||
|
*
|
||||||
|
* \param position The starting point which will be used for the query
|
||||||
|
* \param closestPoint The closest point on entity surface
|
||||||
|
* \param closestDistance The distance between the closest point and the starting point, may be negative if starting point is inside the entity
|
||||||
|
*
|
||||||
|
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||||
|
*/
|
||||||
|
inline bool PhysicsComponent2D::ClosestPointQuery(const Nz::Vector2f& position, Nz::Vector2f* closestPoint, float* closestDistance) const
|
||||||
|
{
|
||||||
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
||||||
|
return m_object->ClosestPointQuery(position, closestPoint, closestDistance);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the AABB of the physics object
|
* \brief Gets the AABB of the physics object
|
||||||
* \return AABB of the object
|
* \return AABB of the object
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ namespace Ndk
|
||||||
public:
|
public:
|
||||||
System();
|
System();
|
||||||
System(const System&) = delete;
|
System(const System&) = delete;
|
||||||
System(System&&) = default;
|
System(System&&) noexcept = default;
|
||||||
virtual ~System();
|
virtual ~System();
|
||||||
|
|
||||||
System& operator=(const System&) = delete;
|
System& operator=(const System&) = delete;
|
||||||
System& operator=(System&&) = default;
|
System& operator=(System&&) noexcept = default;
|
||||||
|
|
||||||
static SystemIndex RegisterSystem();
|
static SystemIndex RegisterSystem();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2017 Samy Bensaid
|
// Copyright (C) 2017 Samy Bensaid
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -266,14 +266,15 @@ namespace Ndk
|
||||||
state.SetGlobal("ResolveError");
|
state.SetGlobal("ResolveError");
|
||||||
|
|
||||||
// Nz::SocketError
|
// Nz::SocketError
|
||||||
static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
|
static_assert(Nz::SocketError_Max + 1 == 16, "Nz::SocketError has been updated but change was not reflected to Lua binding");
|
||||||
state.PushTable(0, 15);
|
state.PushTable(0, 16);
|
||||||
{
|
{
|
||||||
state.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable);
|
state.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable);
|
||||||
state.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed);
|
state.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed);
|
||||||
state.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused);
|
state.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused);
|
||||||
state.PushField("DatagramSize", Nz::SocketError_DatagramSize);
|
state.PushField("DatagramSize", Nz::SocketError_DatagramSize);
|
||||||
state.PushField("Internal", Nz::SocketError_Internal);
|
state.PushField("Internal", Nz::SocketError_Internal);
|
||||||
|
state.PushField("Interrupted", Nz::SocketError_Interrupted);
|
||||||
state.PushField("Packet", Nz::SocketError_Packet);
|
state.PushField("Packet", Nz::SocketError_Packet);
|
||||||
state.PushField("NetworkError", Nz::SocketError_NetworkError);
|
state.PushField("NetworkError", Nz::SocketError_NetworkError);
|
||||||
state.PushField("NoError", Nz::SocketError_NoError);
|
state.PushField("NoError", Nz::SocketError_NoError);
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ NazaraBuild = {}
|
||||||
local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake*", "xcode3", "xcode4"}, " or ")
|
local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake*", "xcode3", "xcode4"}, " or ")
|
||||||
|
|
||||||
function NazaraBuild:AddExecutablePath(path)
|
function NazaraBuild:AddExecutablePath(path)
|
||||||
table.insert(self.ExecutableDir, path)
|
self.ExecutableDir[path] = true
|
||||||
|
|
||||||
self:AddInstallPath(path)
|
self:AddInstallPath(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:AddInstallPath(path)
|
function NazaraBuild:AddInstallPath(path)
|
||||||
table.insert(self.InstallDir, path)
|
self.InstallDir[path] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:FilterLibDirectory(prefix, func)
|
function NazaraBuild:FilterLibDirectory(prefix, func)
|
||||||
|
|
@ -613,9 +614,15 @@ function NazaraBuild:MakeInstallCommands(infoTable)
|
||||||
postbuildmessage("Copying " .. infoTable.Name .. " library and its dependencies to install/executable directories...")
|
postbuildmessage("Copying " .. infoTable.Name .. " library and its dependencies to install/executable directories...")
|
||||||
|
|
||||||
-- Copy built file to install directory
|
-- Copy built file to install directory
|
||||||
for k,installPath in pairs(self.InstallDir) do
|
local installCommands = {}
|
||||||
|
for installPath,_ in pairs(self.InstallDir) do
|
||||||
local destPath = path.translate(path.isabsolute(installPath) and installPath or "../../" .. installPath)
|
local destPath = path.translate(path.isabsolute(installPath) and installPath or "../../" .. installPath)
|
||||||
postbuildcommands({[[xcopy "%{path.translate(cfg.buildtarget.relpath)}" "]] .. destPath .. [[\" /E /Y]]})
|
table.insert(installCommands, [[xcopy "%{path.translate(cfg.buildtarget.relpath)}" "]] .. destPath .. [[\" /E /Y]])
|
||||||
|
end
|
||||||
|
table.sort(installCommands)
|
||||||
|
|
||||||
|
for k,command in pairs(installCommands) do
|
||||||
|
postbuildcommands({command})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Copy additional dependencies to executable directories too
|
-- Copy additional dependencies to executable directories too
|
||||||
|
|
@ -641,10 +648,17 @@ function NazaraBuild:MakeInstallCommands(infoTable)
|
||||||
|
|
||||||
filter("architecture:" .. arch)
|
filter("architecture:" .. arch)
|
||||||
|
|
||||||
for k,execPath in pairs(self.ExecutableDir) do
|
local executableCommands = {}
|
||||||
|
for execPath,_ in pairs(self.ExecutableDir) do
|
||||||
local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]]
|
local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]]
|
||||||
local destPath = path.translate(path.isabsolute(execPath) and execPath or "../../" .. execPath)
|
local destPath = path.translate(path.isabsolute(execPath) and execPath or "../../" .. execPath)
|
||||||
postbuildcommands({[[xcopy "]] .. srcPath .. [[" "]] .. destPath .. [[\" /E /Y]]})
|
table.insert(executableCommands, [[xcopy "]] .. srcPath .. [[" "]] .. destPath .. [[\" /E /Y]])
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(executableCommands)
|
||||||
|
|
||||||
|
for k,command in pairs(executableCommands) do
|
||||||
|
postbuildcommands({command})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
AbstractHash() = default;
|
AbstractHash() = default;
|
||||||
AbstractHash(const AbstractHash&) = delete;
|
AbstractHash(const AbstractHash&) = delete;
|
||||||
AbstractHash(AbstractHash&&) = default;
|
AbstractHash(AbstractHash&&) noexcept = default;
|
||||||
virtual ~AbstractHash();
|
virtual ~AbstractHash();
|
||||||
|
|
||||||
virtual void Append(const UInt8* data, std::size_t len) = 0;
|
virtual void Append(const UInt8* data, std::size_t len) = 0;
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
virtual const char* GetHashName() const = 0;
|
virtual const char* GetHashName() const = 0;
|
||||||
|
|
||||||
AbstractHash& operator=(const AbstractHash&) = delete;
|
AbstractHash& operator=(const AbstractHash&) = delete;
|
||||||
AbstractHash& operator=(AbstractHash&&) = default;
|
AbstractHash& operator=(AbstractHash&&) noexcept = default;
|
||||||
|
|
||||||
static std::unique_ptr<AbstractHash> Get(HashType hash);
|
static std::unique_ptr<AbstractHash> Get(HashType hash);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Nz
|
||||||
inline ByteArray(size_type n, value_type value);
|
inline ByteArray(size_type n, value_type value);
|
||||||
template <class InputIterator> ByteArray(InputIterator first, InputIterator last);
|
template <class InputIterator> ByteArray(InputIterator first, InputIterator last);
|
||||||
ByteArray(const ByteArray& other) = default;
|
ByteArray(const ByteArray& other) = default;
|
||||||
ByteArray(ByteArray&& other) = default;
|
ByteArray(ByteArray&& other) noexcept = default;
|
||||||
~ByteArray() = default;
|
~ByteArray() = default;
|
||||||
|
|
||||||
inline iterator Append(const void* buffer, size_type size);
|
inline iterator Append(const void* buffer, size_type size);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
||||||
ByteStream(void* ptr, Nz::UInt64 size);
|
ByteStream(void* ptr, Nz::UInt64 size);
|
||||||
ByteStream(const void* ptr, Nz::UInt64 size);
|
ByteStream(const void* ptr, Nz::UInt64 size);
|
||||||
ByteStream(const ByteStream&) = delete;
|
ByteStream(const ByteStream&) = delete;
|
||||||
inline ByteStream(ByteStream&& stream);
|
ByteStream(ByteStream&& stream) noexcept = default;
|
||||||
virtual ~ByteStream();
|
virtual ~ByteStream();
|
||||||
|
|
||||||
inline Endianness GetDataEndianness() const;
|
inline Endianness GetDataEndianness() const;
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Nz
|
||||||
ByteStream& operator<<(const T& value);
|
ByteStream& operator<<(const T& value);
|
||||||
|
|
||||||
ByteStream& operator=(const ByteStream&) = delete;
|
ByteStream& operator=(const ByteStream&) = delete;
|
||||||
inline ByteStream& operator=(ByteStream&&);
|
ByteStream& operator=(ByteStream&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void OnEmptyStream();
|
virtual void OnEmptyStream();
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,6 @@ namespace Nz
|
||||||
m_context.stream = stream;
|
m_context.stream = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Constructs a ByteStream object by move semantic
|
|
||||||
*
|
|
||||||
* \param stream ByteStream to move into this
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline ByteStream::ByteStream(ByteStream&& stream) :
|
|
||||||
m_ownedStream(std::move(stream.m_ownedStream)),
|
|
||||||
m_context(stream.m_context)
|
|
||||||
{
|
|
||||||
stream.m_context.stream = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Destructs the object and calls FlushBits
|
* \brief Destructs the object and calls FlushBits
|
||||||
*
|
*
|
||||||
|
|
@ -204,23 +191,6 @@ namespace Nz
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Moves the other byte stream into this
|
|
||||||
* \return A reference to this
|
|
||||||
*
|
|
||||||
* \param stream ByteStream to move in this
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline ByteStream& ByteStream::operator=(ByteStream&& stream)
|
|
||||||
{
|
|
||||||
m_context = stream.m_context;
|
|
||||||
m_ownedStream = std::move(stream.m_ownedStream);
|
|
||||||
|
|
||||||
stream.m_context.stream = nullptr;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
CallOnExit(Func func = nullptr);
|
CallOnExit(Func func = nullptr);
|
||||||
CallOnExit(const CallOnExit&) = delete;
|
CallOnExit(const CallOnExit&) = delete;
|
||||||
CallOnExit(CallOnExit&&) = delete;
|
CallOnExit(CallOnExit&&) noexcept = delete;
|
||||||
~CallOnExit();
|
~CallOnExit();
|
||||||
|
|
||||||
void CallAndReset(Func func = nullptr);
|
void CallAndReset(Func func = nullptr);
|
||||||
void Reset(Func func = nullptr);
|
void Reset(Func func = nullptr);
|
||||||
|
|
||||||
CallOnExit& operator=(const CallOnExit&) = delete;
|
CallOnExit& operator=(const CallOnExit&) = delete;
|
||||||
CallOnExit& operator=(CallOnExit&&) = default;
|
CallOnExit& operator=(CallOnExit&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Func m_func;
|
Func m_func;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
FileLogger(const String& logPath = "NazaraLog.log");
|
FileLogger(const String& logPath = "NazaraLog.log");
|
||||||
FileLogger(const FileLogger&) = default;
|
FileLogger(const FileLogger&) = default;
|
||||||
FileLogger(FileLogger&&) = default;
|
FileLogger(FileLogger&&) noexcept = default;
|
||||||
~FileLogger();
|
~FileLogger();
|
||||||
|
|
||||||
void EnableTimeLogging(bool enable);
|
void EnableTimeLogging(bool enable);
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Nz
|
||||||
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
||||||
|
|
||||||
FileLogger& operator=(const FileLogger&) = default;
|
FileLogger& operator=(const FileLogger&) = default;
|
||||||
FileLogger& operator=(FileLogger&&) = default;
|
FileLogger& operator=(FileLogger&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File m_outputFile;
|
File m_outputFile;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
GuillotineBinPack(unsigned int width, unsigned int height);
|
GuillotineBinPack(unsigned int width, unsigned int height);
|
||||||
GuillotineBinPack(const Vector2ui& size);
|
GuillotineBinPack(const Vector2ui& size);
|
||||||
GuillotineBinPack(const GuillotineBinPack&) = default;
|
GuillotineBinPack(const GuillotineBinPack&) = default;
|
||||||
GuillotineBinPack(GuillotineBinPack&&) = default;
|
GuillotineBinPack(GuillotineBinPack&&) noexcept = default;
|
||||||
~GuillotineBinPack() = default;
|
~GuillotineBinPack() = default;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Nz
|
||||||
void Reset(const Vector2ui& size);
|
void Reset(const Vector2ui& size);
|
||||||
|
|
||||||
GuillotineBinPack& operator=(const GuillotineBinPack&) = default;
|
GuillotineBinPack& operator=(const GuillotineBinPack&) = default;
|
||||||
GuillotineBinPack& operator=(GuillotineBinPack&&) = default;
|
GuillotineBinPack& operator=(GuillotineBinPack&&) noexcept = default;
|
||||||
|
|
||||||
enum FreeRectChoiceHeuristic : int
|
enum FreeRectChoiceHeuristic : int
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#define NAZARA_MEMORYSTREAM_HPP
|
#define NAZARA_MEMORYSTREAM_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Core/MovablePtr.hpp>
|
||||||
#include <Nazara/Core/Stream.hpp>
|
#include <Nazara/Core/Stream.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
@ -20,7 +21,7 @@ namespace Nz
|
||||||
inline MemoryStream();
|
inline MemoryStream();
|
||||||
inline MemoryStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
inline MemoryStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite);
|
||||||
MemoryStream(const MemoryStream&) = default;
|
MemoryStream(const MemoryStream&) = default;
|
||||||
MemoryStream(MemoryStream&&) = default;
|
MemoryStream(MemoryStream&&) noexcept = default;
|
||||||
~MemoryStream() = default;
|
~MemoryStream() = default;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
@ -36,14 +37,14 @@ namespace Nz
|
||||||
bool SetCursorPos(UInt64 offset) override;
|
bool SetCursorPos(UInt64 offset) override;
|
||||||
|
|
||||||
MemoryStream& operator=(const MemoryStream&) = default;
|
MemoryStream& operator=(const MemoryStream&) = default;
|
||||||
MemoryStream& operator=(MemoryStream&&) = default;
|
MemoryStream& operator=(MemoryStream&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FlushStream() override;
|
void FlushStream() override;
|
||||||
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
||||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||||
|
|
||||||
ByteArray* m_buffer;
|
MovablePtr<ByteArray> m_buffer;
|
||||||
UInt64 m_pos;
|
UInt64 m_pos;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
|
#include <Nazara/Core/MovablePtr.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
@ -72,7 +73,7 @@ namespace Nz
|
||||||
|
|
||||||
std::atomic_uint counter;
|
std::atomic_uint counter;
|
||||||
Destructor destructor;
|
Destructor destructor;
|
||||||
void* ptr;
|
MovablePtr<void> ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
ParameterType type;
|
ParameterType type;
|
||||||
|
|
@ -81,6 +82,7 @@ namespace Nz
|
||||||
// We define an empty constructor/destructor, to be able to put classes in the union
|
// We define an empty constructor/destructor, to be able to put classes in the union
|
||||||
Value() {}
|
Value() {}
|
||||||
Value(const Value&) {} // Placeholder
|
Value(const Value&) {} // Placeholder
|
||||||
|
Value(Value&&) noexcept {} // Placeholder
|
||||||
~Value() {}
|
~Value() {}
|
||||||
|
|
||||||
bool boolVal;
|
bool boolVal;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
PrimitiveList() = default;
|
PrimitiveList() = default;
|
||||||
PrimitiveList(const PrimitiveList&) = default;
|
PrimitiveList(const PrimitiveList&) = default;
|
||||||
PrimitiveList(PrimitiveList&&) = default;
|
PrimitiveList(PrimitiveList&&) noexcept = default;
|
||||||
~PrimitiveList() = default;
|
~PrimitiveList() = default;
|
||||||
|
|
||||||
void AddBox(const Vector3f& lengths, const Vector3ui& subdivision = Vector3ui(0U), const Matrix4f& transformMatrix = Matrix4f::Identity());
|
void AddBox(const Vector3f& lengths, const Vector3ui& subdivision = Vector3ui(0U), const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Nz
|
||||||
std::size_t GetSize() const;
|
std::size_t GetSize() const;
|
||||||
|
|
||||||
PrimitiveList& operator=(const PrimitiveList&) = default;
|
PrimitiveList& operator=(const PrimitiveList&) = default;
|
||||||
PrimitiveList& operator=(PrimitiveList&&) = default;
|
PrimitiveList& operator=(PrimitiveList&&) noexcept = default;
|
||||||
|
|
||||||
Primitive& operator()(unsigned int i);
|
Primitive& operator()(unsigned int i);
|
||||||
const Primitive& operator()(unsigned int i) const;
|
const Primitive& operator()(unsigned int i) const;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
RefCounted(bool persistent = true);
|
RefCounted(bool persistent = true);
|
||||||
RefCounted(const RefCounted&) = delete;
|
RefCounted(const RefCounted&) = delete;
|
||||||
RefCounted(RefCounted&&) = default;
|
RefCounted(RefCounted&&) = delete;
|
||||||
virtual ~RefCounted();
|
virtual ~RefCounted();
|
||||||
|
|
||||||
void AddReference() const;
|
void AddReference() const;
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Nz
|
||||||
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
|
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
|
||||||
|
|
||||||
RefCounted& operator=(const RefCounted&) = delete;
|
RefCounted& operator=(const RefCounted&) = delete;
|
||||||
RefCounted& operator=(RefCounted&&) = default;
|
RefCounted& operator=(RefCounted&&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::atomic_bool m_persistent;
|
std::atomic_bool m_persistent;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/Config.hpp>
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Endianness.hpp>
|
#include <Nazara/Core/Endianness.hpp>
|
||||||
|
#include <Nazara/Core/MovablePtr.hpp>
|
||||||
#include <Nazara/Core/TypeTag.hpp>
|
#include <Nazara/Core/TypeTag.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
@ -18,7 +19,7 @@ namespace Nz
|
||||||
|
|
||||||
struct NAZARA_CORE_API SerializationContext
|
struct NAZARA_CORE_API SerializationContext
|
||||||
{
|
{
|
||||||
Stream* stream;
|
MovablePtr<Stream> stream;
|
||||||
Endianness endianness = Endianness_BigEndian; //< Default to Big Endian encoding
|
Endianness endianness = Endianness_BigEndian; //< Default to Big Endian encoding
|
||||||
UInt8 readBitPos = 8; //< 8 means no bit is currently read
|
UInt8 readBitPos = 8; //< 8 means no bit is currently read
|
||||||
UInt8 readByte; //< Undefined value, will be initialized at the first bit read
|
UInt8 readByte; //< Undefined value, will be initialized at the first bit read
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
StdLogger() = default;
|
StdLogger() = default;
|
||||||
StdLogger(const StdLogger&) = default;
|
StdLogger(const StdLogger&) = default;
|
||||||
StdLogger(StdLogger&&) = default;
|
StdLogger(StdLogger&&) noexcept = default;
|
||||||
~StdLogger();
|
~StdLogger();
|
||||||
|
|
||||||
void EnableStdReplication(bool enable) override;
|
void EnableStdReplication(bool enable) override;
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
||||||
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
|
||||||
|
|
||||||
StdLogger& operator=(const StdLogger&) = default;
|
StdLogger& operator=(const StdLogger&) = default;
|
||||||
StdLogger& operator=(StdLogger&&) = default;
|
StdLogger& operator=(StdLogger&&) noexcept = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Stream(const Stream&) = default;
|
Stream(const Stream&) = default;
|
||||||
Stream(Stream&&) = default;
|
Stream(Stream&&) noexcept = default;
|
||||||
virtual ~Stream();
|
virtual ~Stream();
|
||||||
|
|
||||||
virtual bool EndOfStream() const = 0;
|
virtual bool EndOfStream() const = 0;
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Nz
|
||||||
inline std::size_t Write(const void* buffer, std::size_t size);
|
inline std::size_t Write(const void* buffer, std::size_t size);
|
||||||
|
|
||||||
Stream& operator=(const Stream&) = default;
|
Stream& operator=(const Stream&) = default;
|
||||||
Stream& operator=(Stream&&) = default;
|
Stream& operator=(Stream&&) noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline Stream(StreamOptionFlags streamOptions = StreamOption_None, OpenModeFlags openMode = OpenMode_NotOpen);
|
inline Stream(StreamOptionFlags streamOptions = StreamOption_None, OpenModeFlags openMode = OpenMode_NotOpen);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Nz
|
||||||
|
|
||||||
AbstractRenderQueue() = default;
|
AbstractRenderQueue() = default;
|
||||||
AbstractRenderQueue(const AbstractRenderQueue&) = delete;
|
AbstractRenderQueue(const AbstractRenderQueue&) = delete;
|
||||||
AbstractRenderQueue(AbstractRenderQueue&&) = default;
|
AbstractRenderQueue(AbstractRenderQueue&&) noexcept = default;
|
||||||
virtual ~AbstractRenderQueue();
|
virtual ~AbstractRenderQueue();
|
||||||
|
|
||||||
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Nz
|
||||||
virtual void Clear(bool fully = false);
|
virtual void Clear(bool fully = false);
|
||||||
|
|
||||||
AbstractRenderQueue& operator=(const AbstractRenderQueue&) = delete;
|
AbstractRenderQueue& operator=(const AbstractRenderQueue&) = delete;
|
||||||
AbstractRenderQueue& operator=(AbstractRenderQueue&&) = default;
|
AbstractRenderQueue& operator=(AbstractRenderQueue&&) noexcept = default;
|
||||||
|
|
||||||
struct DirectionalLight
|
struct DirectionalLight
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
AbstractRenderTechnique();
|
AbstractRenderTechnique();
|
||||||
AbstractRenderTechnique(const AbstractRenderTechnique&) = delete;
|
AbstractRenderTechnique(const AbstractRenderTechnique&) = delete;
|
||||||
AbstractRenderTechnique(AbstractRenderTechnique&&) = default;
|
AbstractRenderTechnique(AbstractRenderTechnique&&) noexcept = default;
|
||||||
virtual ~AbstractRenderTechnique();
|
virtual ~AbstractRenderTechnique();
|
||||||
|
|
||||||
virtual void Clear(const SceneData& sceneData) const = 0;
|
virtual void Clear(const SceneData& sceneData) const = 0;
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Nz
|
||||||
virtual bool IsInstancingEnabled() const;
|
virtual bool IsInstancingEnabled() const;
|
||||||
|
|
||||||
AbstractRenderTechnique& operator=(const AbstractRenderTechnique&) = delete;
|
AbstractRenderTechnique& operator=(const AbstractRenderTechnique&) = delete;
|
||||||
AbstractRenderTechnique& operator=(AbstractRenderTechnique&&) = default;
|
AbstractRenderTechnique& operator=(AbstractRenderTechnique&&) noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_instancingEnabled;
|
bool m_instancingEnabled;
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,17 @@ namespace Nz
|
||||||
int textureOverlay;
|
int textureOverlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SpriteBatch
|
||||||
|
{
|
||||||
|
std::size_t spriteCount;
|
||||||
|
const Material* material;
|
||||||
|
const Texture* overlayTexture;
|
||||||
|
Recti scissorRect;
|
||||||
|
};
|
||||||
|
|
||||||
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
||||||
mutable std::vector<LightIndex> m_lights;
|
mutable std::vector<LightIndex> m_lights;
|
||||||
mutable std::vector<std::pair<const VertexStruct_XYZ_Color_UV*, std::size_t>> m_spriteChains;
|
mutable std::vector<SpriteBatch> m_spriteBatches;
|
||||||
Buffer m_vertexBuffer;
|
Buffer m_vertexBuffer;
|
||||||
mutable BasicRenderQueue m_renderQueue;
|
mutable BasicRenderQueue m_renderQueue;
|
||||||
TextureRef m_whiteCubemap;
|
TextureRef m_whiteCubemap;
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,13 @@ namespace Nz
|
||||||
using Index = Nz::UInt64;
|
using Index = Nz::UInt64;
|
||||||
|
|
||||||
RenderQueueInternal() = default;
|
RenderQueueInternal() = default;
|
||||||
|
RenderQueueInternal(const RenderQueueInternal&) = default;
|
||||||
|
RenderQueueInternal(RenderQueueInternal&&) = default;
|
||||||
~RenderQueueInternal() = default;
|
~RenderQueueInternal() = default;
|
||||||
|
|
||||||
|
RenderQueueInternal& operator=(const RenderQueueInternal&) = default;
|
||||||
|
RenderQueueInternal& operator=(RenderQueueInternal&&) = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using RenderDataPair = std::pair<Index, std::size_t>;
|
using RenderDataPair = std::pair<Index, std::size_t>;
|
||||||
|
|
||||||
|
|
@ -39,7 +44,7 @@ namespace Nz
|
||||||
|
|
||||||
RenderQueue() = default;
|
RenderQueue() = default;
|
||||||
RenderQueue(const RenderQueue&) = default;
|
RenderQueue(const RenderQueue&) = default;
|
||||||
RenderQueue(RenderQueue&&) = default;
|
RenderQueue(RenderQueue&&) noexcept = default;
|
||||||
~RenderQueue() = default;
|
~RenderQueue() = default;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
@ -55,7 +60,7 @@ namespace Nz
|
||||||
inline size_type size() const;
|
inline size_type size() const;
|
||||||
|
|
||||||
RenderQueue& operator=(const RenderQueue&) = default;
|
RenderQueue& operator=(const RenderQueue&) = default;
|
||||||
RenderQueue& operator=(RenderQueue&&) = default;
|
RenderQueue& operator=(RenderQueue&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RenderData& GetData(std::size_t i) const;
|
const RenderData& GetData(std::size_t i) const;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
Renderable() = default;
|
Renderable() = default;
|
||||||
Renderable(const Renderable& renderable) = default;
|
Renderable(const Renderable& renderable) = default;
|
||||||
Renderable(Renderable&&) = default;
|
Renderable(Renderable&&) noexcept = default;
|
||||||
virtual ~Renderable();
|
virtual ~Renderable();
|
||||||
|
|
||||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const = 0;
|
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const = 0;
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Nz
|
||||||
virtual void UpdateBoundingVolume(const Matrix4f& transformMatrix);
|
virtual void UpdateBoundingVolume(const Matrix4f& transformMatrix);
|
||||||
|
|
||||||
Renderable& operator=(const Renderable& renderable) = default;
|
Renderable& operator=(const Renderable& renderable) = default;
|
||||||
Renderable& operator=(Renderable&& renderable) = default;
|
Renderable& operator=(Renderable&& renderable) noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void MakeBoundingVolume() const = 0;
|
virtual void MakeBoundingVolume() const = 0;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractSocket(const AbstractSocket&) = delete;
|
AbstractSocket(const AbstractSocket&) = delete;
|
||||||
AbstractSocket(AbstractSocket&& abstractSocket);
|
AbstractSocket(AbstractSocket&& abstractSocket) noexcept;
|
||||||
virtual ~AbstractSocket();
|
virtual ~AbstractSocket();
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ namespace Nz
|
||||||
std::vector<ENetPeer> m_peers;
|
std::vector<ENetPeer> m_peers;
|
||||||
std::vector<PendingIncomingPacket> m_pendingIncomingPackets;
|
std::vector<PendingIncomingPacket> m_pendingIncomingPackets;
|
||||||
std::vector<PendingOutgoingPacket> m_pendingOutgoingPackets;
|
std::vector<PendingOutgoingPacket> m_pendingOutgoingPackets;
|
||||||
UInt8* m_receivedData;
|
MovablePtr<UInt8> m_receivedData;
|
||||||
Bitset<UInt64> m_dispatchQueue;
|
Bitset<UInt64> m_dispatchQueue;
|
||||||
MemoryPool m_packetPool;
|
MemoryPool m_packetPool;
|
||||||
IpAddress m_address;
|
IpAddress m_address;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Copyright(c) 2002 - 2016 Lee Salzman
|
Copyright(c) 2002 - 2016 Lee Salzman
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/Bitset.hpp>
|
#include <Nazara/Core/Bitset.hpp>
|
||||||
|
#include <Nazara/Core/MovablePtr.hpp>
|
||||||
#include <Nazara/Network/ENetPacket.hpp>
|
#include <Nazara/Network/ENetPacket.hpp>
|
||||||
#include <Nazara/Network/ENetProtocol.hpp>
|
#include <Nazara/Network/ENetProtocol.hpp>
|
||||||
#include <Nazara/Network/IpAddress.hpp>
|
#include <Nazara/Network/IpAddress.hpp>
|
||||||
|
|
@ -176,8 +177,8 @@ namespace Nz
|
||||||
|
|
||||||
static constexpr std::size_t unsequencedWindow = ENetPeer_ReliableWindowSize / 32;
|
static constexpr std::size_t unsequencedWindow = ENetPeer_ReliableWindowSize / 32;
|
||||||
|
|
||||||
ENetHost* m_host;
|
MovablePtr<ENetHost> m_host;
|
||||||
IpAddress m_address; /**< Internet address of the peer */
|
IpAddress m_address; //< Internet address of the peer
|
||||||
std::array<UInt32, unsequencedWindow> m_unsequencedWindow;
|
std::array<UInt32, unsequencedWindow> m_unsequencedWindow;
|
||||||
std::bernoulli_distribution m_packetLossProbability;
|
std::bernoulli_distribution m_packetLossProbability;
|
||||||
std::list<IncomingCommmand> m_dispatchedCommands;
|
std::list<IncomingCommmand> m_dispatchedCommands;
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ namespace Nz
|
||||||
SocketError_ConnectionRefused, //< The connection attempt was refused
|
SocketError_ConnectionRefused, //< The connection attempt was refused
|
||||||
SocketError_DatagramSize, //< The datagram size is over the system limit
|
SocketError_DatagramSize, //< The datagram size is over the system limit
|
||||||
SocketError_Internal, //< The error is coming from the engine
|
SocketError_Internal, //< The error is coming from the engine
|
||||||
|
SocketError_Interrupted, //< The operation was interrupted by a signal
|
||||||
SocketError_Packet, //< The packet encoding/decoding failed, probably because of corrupted data
|
SocketError_Packet, //< The packet encoding/decoding failed, probably because of corrupted data
|
||||||
SocketError_NetworkError, //< The network system has failed (maybe network is down)
|
SocketError_NetworkError, //< The network system has failed (maybe network is down)
|
||||||
SocketError_NotInitialized, //< Nazara network has not been initialized
|
SocketError_NotInitialized, //< Nazara network has not been initialized
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Nz
|
||||||
inline explicit IpAddress(const char* address);
|
inline explicit IpAddress(const char* address);
|
||||||
inline explicit IpAddress(const String& address);
|
inline explicit IpAddress(const String& address);
|
||||||
IpAddress(const IpAddress&) = default;
|
IpAddress(const IpAddress&) = default;
|
||||||
IpAddress(IpAddress&&) = default;
|
IpAddress(IpAddress&&) noexcept = default;
|
||||||
~IpAddress() = default;
|
~IpAddress() = default;
|
||||||
|
|
||||||
bool BuildFromAddress(const char* address);
|
bool BuildFromAddress(const char* address);
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Nz
|
||||||
inline explicit operator bool() const;
|
inline explicit operator bool() const;
|
||||||
|
|
||||||
IpAddress& operator=(const IpAddress&) = default;
|
IpAddress& operator=(const IpAddress&) = default;
|
||||||
IpAddress& operator=(IpAddress&&) = default;
|
IpAddress& operator=(IpAddress&&) noexcept = default;
|
||||||
|
|
||||||
static String ResolveAddress(const IpAddress& address, String* service = nullptr, ResolveError* error = nullptr);
|
static String ResolveAddress(const IpAddress& address, String* service = nullptr, ResolveError* error = nullptr);
|
||||||
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const String& hostname, const String& protocol = "http", ResolveError* error = nullptr);
|
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const String& hostname, const String& protocol = "http", ResolveError* error = nullptr);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2017 Jérôme Leclercq
|
// Copyright (C) 2017 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Network module"
|
// This file is part of the "Nazara Engine - Network module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
bool RegisterSocket(AbstractSocket& socket, SocketPollEventFlags eventFlags);
|
bool RegisterSocket(AbstractSocket& socket, SocketPollEventFlags eventFlags);
|
||||||
void UnregisterSocket(AbstractSocket& socket);
|
void UnregisterSocket(AbstractSocket& socket);
|
||||||
|
|
||||||
bool Wait(int msTimeout);
|
unsigned int Wait(int msTimeout, SocketError* error = nullptr);
|
||||||
|
|
||||||
SocketPoller& operator=(SocketPoller&&) noexcept = default;
|
SocketPoller& operator=(SocketPoller&&) noexcept = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline TcpClient();
|
inline TcpClient();
|
||||||
TcpClient(TcpClient&& tcpClient) = default;
|
TcpClient(TcpClient&& tcpClient) noexcept = default;
|
||||||
~TcpClient() = default;
|
~TcpClient() = default;
|
||||||
|
|
||||||
SocketState Connect(const IpAddress& remoteAddress);
|
SocketState Connect(const IpAddress& remoteAddress);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
inline UdpSocket();
|
inline UdpSocket();
|
||||||
inline UdpSocket(NetProtocol protocol);
|
inline UdpSocket(NetProtocol protocol);
|
||||||
inline UdpSocket(UdpSocket&& udpSocket);
|
inline UdpSocket(UdpSocket&& udpSocket) noexcept;
|
||||||
~UdpSocket() = default;
|
~UdpSocket() = default;
|
||||||
|
|
||||||
inline SocketState Bind(UInt16 port);
|
inline SocketState Bind(UInt16 port);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Nz
|
||||||
* \param udpSocket UdpSocket to move into this
|
* \param udpSocket UdpSocket to move into this
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) :
|
inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) noexcept :
|
||||||
AbstractSocket(std::move(udpSocket)),
|
AbstractSocket(std::move(udpSocket)),
|
||||||
m_boundAddress(std::move(udpSocket.m_boundAddress))
|
m_boundAddress(std::move(udpSocket.m_boundAddress))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ namespace Nz
|
||||||
void AddImpulse(const Vector2f& impulse, const Vector2f& point, CoordSys coordSys = CoordSys_Global);
|
void AddImpulse(const Vector2f& impulse, const Vector2f& point, CoordSys coordSys = CoordSys_Global);
|
||||||
void AddTorque(float torque);
|
void AddTorque(float torque);
|
||||||
|
|
||||||
|
bool ClosestPointQuery(const Nz::Vector2f& position, Nz::Vector2f* closestPoint = nullptr, float* closestDistance = nullptr) const;
|
||||||
|
|
||||||
void EnableSimulation(bool simulation);
|
void EnableSimulation(bool simulation);
|
||||||
|
|
||||||
Rectf GetAABB() const;
|
Rectf GetAABB() const;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Nz
|
||||||
|
|
||||||
PhysWorld3D();
|
PhysWorld3D();
|
||||||
PhysWorld3D(const PhysWorld3D&) = delete;
|
PhysWorld3D(const PhysWorld3D&) = delete;
|
||||||
PhysWorld3D(PhysWorld3D&&) = default;
|
PhysWorld3D(PhysWorld3D&&) noexcept = default;
|
||||||
~PhysWorld3D();
|
~PhysWorld3D();
|
||||||
|
|
||||||
int CreateMaterial(String name = String());
|
int CreateMaterial(String name = String());
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Nz
|
||||||
void Step(float timestep);
|
void Step(float timestep);
|
||||||
|
|
||||||
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
|
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
|
||||||
PhysWorld3D& operator=(PhysWorld3D&&) = default;
|
PhysWorld3D& operator=(PhysWorld3D&&) noexcept = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Callback
|
struct Callback
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
CursorController() = default;
|
CursorController() = default;
|
||||||
CursorController(const CursorController&) = delete;
|
CursorController(const CursorController&) = delete;
|
||||||
CursorController(CursorController&&) = default;
|
CursorController(CursorController&&) noexcept = default;
|
||||||
~CursorController() = default;
|
~CursorController() = default;
|
||||||
|
|
||||||
inline void UpdateCursor(const CursorRef& cursor);
|
inline void UpdateCursor(const CursorRef& cursor);
|
||||||
|
|
||||||
CursorController& operator=(const CursorController&) = delete;
|
CursorController& operator=(const CursorController&) = delete;
|
||||||
CursorController& operator=(CursorController&&) = default;
|
CursorController& operator=(CursorController&&) noexcept = default;
|
||||||
|
|
||||||
NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const CursorRef& /*cursor*/);
|
NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const CursorRef& /*cursor*/);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
EventHandler() = default;
|
EventHandler() = default;
|
||||||
explicit EventHandler(const EventHandler&);
|
explicit EventHandler(const EventHandler&);
|
||||||
EventHandler(EventHandler&&) = default;
|
EventHandler(EventHandler&&) noexcept = default;
|
||||||
~EventHandler() = default;
|
~EventHandler() = default;
|
||||||
|
|
||||||
inline void Dispatch(const WindowEvent& event);
|
inline void Dispatch(const WindowEvent& event);
|
||||||
|
|
||||||
EventHandler& operator=(const EventHandler&) = delete;
|
EventHandler& operator=(const EventHandler&) = delete;
|
||||||
EventHandler& operator=(EventHandler&&) = default;
|
EventHandler& operator=(EventHandler&&) noexcept = default;
|
||||||
|
|
||||||
NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/);
|
NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/);
|
||||||
NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/);
|
NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Nz
|
||||||
Buffer(BufferType type);
|
Buffer(BufferType type);
|
||||||
Buffer(BufferType type, UInt32 size, DataStorage storage = DataStorage_Software, BufferUsageFlags usage = 0);
|
Buffer(BufferType type, UInt32 size, DataStorage storage = DataStorage_Software, BufferUsageFlags usage = 0);
|
||||||
Buffer(const Buffer&) = delete;
|
Buffer(const Buffer&) = delete;
|
||||||
Buffer(Buffer&&) = default;
|
Buffer(Buffer&&) = delete;
|
||||||
~Buffer();
|
~Buffer();
|
||||||
|
|
||||||
bool CopyContent(const BufferRef& buffer);
|
bool CopyContent(const BufferRef& buffer);
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Nz
|
||||||
void Unmap() const;
|
void Unmap() const;
|
||||||
|
|
||||||
Buffer& operator=(const Buffer&) = delete;
|
Buffer& operator=(const Buffer&) = delete;
|
||||||
Buffer& operator=(Buffer&&) = default;
|
Buffer& operator=(Buffer&&) = delete;
|
||||||
|
|
||||||
static bool IsStorageSupported(DataStorage storage);
|
static bool IsStorageSupported(DataStorage storage);
|
||||||
template<typename... Args> static BufferRef New(Args&&... args);
|
template<typename... Args> static BufferRef New(Args&&... args);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
Mesh::Mesh() :
|
Mesh::Mesh() :
|
||||||
m_materialData(1),
|
m_materialData(1),
|
||||||
m_aabbUpdated(false)
|
m_aabbUpdated(false),
|
||||||
|
m_isValid(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||||
|
|
||||||
if (!sinCosPtr)
|
if (!sinCosPtr)
|
||||||
|
|
@ -104,6 +106,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||||
|
|
||||||
if (!sinCosPtr)
|
if (!sinCosPtr)
|
||||||
|
|
@ -174,6 +178,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
float defaultRotation = 0.f;
|
float defaultRotation = 0.f;
|
||||||
|
|
||||||
if (!anglePtr)
|
if (!anglePtr)
|
||||||
|
|
@ -242,6 +248,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
float defaultRotation = 0.f;
|
float defaultRotation = 0.f;
|
||||||
|
|
||||||
if (!anglePtr)
|
if (!anglePtr)
|
||||||
|
|
@ -312,6 +320,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||||
|
|
||||||
if (!sinCosPtr)
|
if (!sinCosPtr)
|
||||||
|
|
@ -380,6 +390,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1
|
||||||
|
|
||||||
if (!sinCosPtr)
|
if (!sinCosPtr)
|
||||||
|
|
@ -450,6 +462,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
float defaultRotation = 0.f;
|
float defaultRotation = 0.f;
|
||||||
|
|
||||||
if (!anglePtr)
|
if (!anglePtr)
|
||||||
|
|
@ -518,6 +532,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
RegisterLayer(renderOrder);
|
||||||
|
|
||||||
float defaultRotation = 0.f;
|
float defaultRotation = 0.f;
|
||||||
|
|
||||||
if (!anglePtr)
|
if (!anglePtr)
|
||||||
|
|
|
||||||
|
|
@ -618,61 +618,51 @@ namespace Nz
|
||||||
const RenderTarget* renderTarget = sceneData.viewer->GetTarget();
|
const RenderTarget* renderTarget = sceneData.viewer->GetTarget();
|
||||||
Recti fullscreenScissorRect = Recti(Vector2i(renderTarget->GetSize()));
|
Recti fullscreenScissorRect = Recti(Vector2i(renderTarget->GetSize()));
|
||||||
|
|
||||||
Renderer::SetIndexBuffer(&s_quadIndexBuffer);
|
|
||||||
Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity());
|
|
||||||
Renderer::SetVertexBuffer(&m_spriteBuffer);
|
|
||||||
|
|
||||||
const unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay);
|
const unsigned int overlayTextureUnit = Material::GetTextureUnit(TextureMap_Overlay);
|
||||||
const std::size_t maxSpriteCount = std::min<std::size_t>(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4);
|
const std::size_t maxSpriteCount = std::min<std::size_t>(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4);
|
||||||
|
|
||||||
m_spriteChains.clear();
|
m_spriteBatches.clear();
|
||||||
|
|
||||||
auto Commit = [&]()
|
|
||||||
{
|
{
|
||||||
std::size_t spriteChainCount = m_spriteChains.size();
|
BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite);
|
||||||
if (spriteChainCount > 0)
|
VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
|
||||||
|
|
||||||
|
std::size_t remainingSprite = maxSpriteCount;
|
||||||
|
|
||||||
|
const Material* lastMaterial = nullptr;
|
||||||
|
const Texture* lastOverlay = nullptr;
|
||||||
|
Recti lastScissorRect = Recti(-1, -1);
|
||||||
|
|
||||||
|
for (const BasicRenderQueue::SpriteChain& basicSprites : spriteList)
|
||||||
{
|
{
|
||||||
std::size_t spriteChain = 0; // Which chain of sprites are we treating
|
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : m_whiteTexture.Get();
|
||||||
std::size_t spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain
|
const Nz::Recti& scissorRect = (basicSprites.scissorRect.width > 0) ? basicSprites.scissorRect : fullscreenScissorRect;
|
||||||
|
if (basicSprites.material != lastMaterial || overlayTexture != lastOverlay || (basicSprites.material->IsScissorTestEnabled() && scissorRect != lastScissorRect))
|
||||||
do
|
|
||||||
{
|
{
|
||||||
// We open the buffer in writing mode
|
m_spriteBatches.emplace_back();
|
||||||
BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite);
|
SpriteBatch& newBatch = m_spriteBatches.back();
|
||||||
VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
|
newBatch.material = basicSprites.material;
|
||||||
|
newBatch.overlayTexture = overlayTexture;
|
||||||
|
newBatch.scissorRect = scissorRect;
|
||||||
|
newBatch.spriteCount = 0;
|
||||||
|
|
||||||
std::size_t spriteCount = 0;
|
lastMaterial = basicSprites.material;
|
||||||
|
lastOverlay = overlayTexture;
|
||||||
do
|
lastScissorRect = scissorRect;
|
||||||
{
|
|
||||||
const VertexStruct_XYZ_Color_UV* currentChain = m_spriteChains[spriteChain].first;
|
|
||||||
std::size_t currentChainSpriteCount = m_spriteChains[spriteChain].second;
|
|
||||||
std::size_t count = std::min(maxSpriteCount - spriteCount, currentChainSpriteCount - spriteChainOffset);
|
|
||||||
|
|
||||||
std::memcpy(vertices, currentChain + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV));
|
|
||||||
vertices += count * 4;
|
|
||||||
|
|
||||||
spriteCount += count;
|
|
||||||
spriteChainOffset += count;
|
|
||||||
|
|
||||||
// Have we treated the entire chain ?
|
|
||||||
if (spriteChainOffset == currentChainSpriteCount)
|
|
||||||
{
|
|
||||||
spriteChain++;
|
|
||||||
spriteChainOffset = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount);
|
|
||||||
|
|
||||||
vertexMapper.Unmap();
|
|
||||||
|
|
||||||
Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6);
|
|
||||||
}
|
}
|
||||||
while (spriteChain < spriteChainCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_spriteChains.clear();
|
SpriteBatch& currentBatch = m_spriteBatches.back();
|
||||||
};
|
|
||||||
|
std::size_t spriteCount = std::min(remainingSprite, basicSprites.spriteCount);
|
||||||
|
std::memcpy(vertices, basicSprites.vertices, spriteCount * 4 * sizeof(VertexStruct_XYZ_Color_UV));
|
||||||
|
vertices += spriteCount * 4;
|
||||||
|
|
||||||
|
currentBatch.spriteCount += spriteCount;
|
||||||
|
|
||||||
|
remainingSprite -= spriteCount;
|
||||||
|
if (remainingSprite == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Material* lastMaterial = nullptr;
|
const Material* lastMaterial = nullptr;
|
||||||
const MaterialPipeline* lastPipeline = nullptr;
|
const MaterialPipeline* lastPipeline = nullptr;
|
||||||
|
|
@ -683,66 +673,63 @@ namespace Nz
|
||||||
|
|
||||||
const MaterialPipeline::Instance* pipelineInstance = nullptr;
|
const MaterialPipeline::Instance* pipelineInstance = nullptr;
|
||||||
|
|
||||||
for (const BasicRenderQueue::SpriteChain& basicSprites : spriteList)
|
Renderer::SetIndexBuffer(&s_quadIndexBuffer);
|
||||||
|
Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity());
|
||||||
|
Renderer::SetVertexBuffer(&m_spriteBuffer);
|
||||||
|
|
||||||
|
unsigned int firstIndex = 0;
|
||||||
|
for (const auto& batch : m_spriteBatches)
|
||||||
{
|
{
|
||||||
const Nz::Recti& scissorRect = (basicSprites.scissorRect.width > 0) ? basicSprites.scissorRect : fullscreenScissorRect;
|
const MaterialPipeline* pipeline = batch.material->GetPipeline();
|
||||||
|
if (pipeline != lastPipeline)
|
||||||
if (basicSprites.material != lastMaterial || basicSprites.overlay != lastOverlay || (basicSprites.material->IsScissorTestEnabled() && scissorRect != lastScissorRect))
|
|
||||||
{
|
{
|
||||||
Commit();
|
pipelineInstance = &batch.material->GetPipeline()->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor);
|
||||||
|
|
||||||
const MaterialPipeline* pipeline = basicSprites.material->GetPipeline();
|
const Shader* shader = pipelineInstance->uberInstance->GetShader();
|
||||||
if (lastPipeline != pipeline)
|
if (shader != lastShader)
|
||||||
{
|
{
|
||||||
pipelineInstance = &basicSprites.material->GetPipeline()->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor);
|
// Index of uniforms in the shader
|
||||||
|
shaderUniforms = GetShaderUniforms(shader);
|
||||||
|
|
||||||
const Shader* shader = pipelineInstance->uberInstance->GetShader();
|
// Ambient color of the scene
|
||||||
if (shader != lastShader)
|
shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
|
||||||
{
|
// Position of the camera
|
||||||
// Index of uniforms in the shader
|
shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
|
||||||
shaderUniforms = GetShaderUniforms(shader);
|
|
||||||
|
|
||||||
// Ambient color of the scene
|
// Overlay texture unit
|
||||||
shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
|
shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit);
|
||||||
// Position of the camera
|
|
||||||
shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
|
|
||||||
|
|
||||||
// Overlay texture unit
|
lastShader = shader;
|
||||||
shader->SendInteger(shaderUniforms->textureOverlay, overlayTextureUnit);
|
|
||||||
|
|
||||||
lastShader = shader;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastPipeline = pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMaterial != basicSprites.material)
|
lastPipeline = pipeline;
|
||||||
{
|
|
||||||
basicSprites.material->Apply(*pipelineInstance);
|
|
||||||
|
|
||||||
Renderer::SetTextureSampler(overlayTextureUnit, basicSprites.material->GetDiffuseSampler());
|
|
||||||
|
|
||||||
lastMaterial = basicSprites.material;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : m_whiteTexture.Get();
|
|
||||||
if (overlayTexture != lastOverlay)
|
|
||||||
{
|
|
||||||
Renderer::SetTexture(overlayTextureUnit, overlayTexture);
|
|
||||||
lastOverlay = overlayTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (basicSprites.material->IsScissorTestEnabled() && scissorRect != lastScissorRect)
|
|
||||||
{
|
|
||||||
Renderer::SetScissorRect(scissorRect);
|
|
||||||
lastScissorRect = scissorRect;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_spriteChains.emplace_back(basicSprites.vertices, basicSprites.spriteCount);
|
if (batch.material != lastMaterial)
|
||||||
}
|
{
|
||||||
|
batch.material->Apply(*pipelineInstance);
|
||||||
|
|
||||||
Commit();
|
Renderer::SetTextureSampler(overlayTextureUnit, batch.material->GetDiffuseSampler());
|
||||||
|
|
||||||
|
lastMaterial = batch.material;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (batch.overlayTexture != lastOverlay)
|
||||||
|
{
|
||||||
|
Renderer::SetTexture(overlayTextureUnit, batch.overlayTexture);
|
||||||
|
lastOverlay = batch.overlayTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (batch.material->IsScissorTestEnabled() && batch.scissorRect != lastScissorRect)
|
||||||
|
{
|
||||||
|
Renderer::SetScissorRect(batch.scissorRect);
|
||||||
|
lastScissorRect = batch.scissorRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int indexCount = batch.spriteCount * 6;
|
||||||
|
Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, firstIndex, indexCount);
|
||||||
|
firstIndex += indexCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ForwardRenderTechnique::ShaderUniforms* ForwardRenderTechnique::GetShaderUniforms(const Shader* shader) const
|
const ForwardRenderTechnique::ShaderUniforms* ForwardRenderTechnique::GetShaderUniforms(const Shader* shader) const
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2017 Jérôme Leclercq
|
// Copyright (C) 2017 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Utility module"
|
// This file is part of the "Nazara Engine - Utility module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Nz
|
||||||
* \param abstractSocket AbstractSocket to move into this
|
* \param abstractSocket AbstractSocket to move into this
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) :
|
AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) noexcept :
|
||||||
m_protocol(abstractSocket.m_protocol),
|
m_protocol(abstractSocket.m_protocol),
|
||||||
m_lastError(abstractSocket.m_lastError),
|
m_lastError(abstractSocket.m_lastError),
|
||||||
m_handle(abstractSocket.m_handle),
|
m_handle(abstractSocket.m_handle),
|
||||||
|
|
|
||||||
|
|
@ -84,35 +84,35 @@ namespace Nz
|
||||||
*
|
*
|
||||||
* \param resolveError Error enumeration
|
* \param resolveError Error enumeration
|
||||||
*/
|
*/
|
||||||
const char* ErrorToString(Nz::ResolveError resolveError)
|
const char* ErrorToString(ResolveError resolveError)
|
||||||
{
|
{
|
||||||
switch (resolveError)
|
switch (resolveError)
|
||||||
{
|
{
|
||||||
case Nz::ResolveError_NoError:
|
case ResolveError_NoError:
|
||||||
return "No error";
|
return "No error";
|
||||||
|
|
||||||
case Nz::ResolveError_Internal:
|
case ResolveError_Internal:
|
||||||
return "An internal error occurred";
|
return "An internal error occurred";
|
||||||
|
|
||||||
case Nz::ResolveError_ResourceError:
|
case ResolveError_ResourceError:
|
||||||
return "The operating system lacks the resources to proceed";
|
return "The operating system lacks the resources to proceed";
|
||||||
|
|
||||||
case Nz::ResolveError_NonRecoverable:
|
case ResolveError_NonRecoverable:
|
||||||
return "A nonrecoverable error occurred";
|
return "A nonrecoverable error occurred";
|
||||||
|
|
||||||
case Nz::ResolveError_NotFound:
|
case ResolveError_NotFound:
|
||||||
return "No such host is known";
|
return "No such host is known";
|
||||||
|
|
||||||
case Nz::ResolveError_NotInitialized:
|
case ResolveError_NotInitialized:
|
||||||
return "Nazara Network has not been initialized";
|
return "Nazara Network has not been initialized";
|
||||||
|
|
||||||
case Nz::ResolveError_ProtocolNotSupported:
|
case ResolveError_ProtocolNotSupported:
|
||||||
return "A specified protocol is not supported by the server";
|
return "A specified protocol is not supported by the server";
|
||||||
|
|
||||||
case Nz::ResolveError_TemporaryFailure:
|
case ResolveError_TemporaryFailure:
|
||||||
return "A temporary failure occurred, try again";
|
return "A temporary failure occurred, try again";
|
||||||
|
|
||||||
case Nz::ResolveError_Unknown:
|
case ResolveError_Unknown:
|
||||||
return "An unknown error occurred";
|
return "An unknown error occurred";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -127,53 +127,56 @@ namespace Nz
|
||||||
*
|
*
|
||||||
* \param socketError Error enumeration
|
* \param socketError Error enumeration
|
||||||
*/
|
*/
|
||||||
const char* ErrorToString(Nz::SocketError socketError)
|
const char* ErrorToString(SocketError socketError)
|
||||||
{
|
{
|
||||||
switch (socketError)
|
switch (socketError)
|
||||||
{
|
{
|
||||||
case Nz::SocketError_NoError:
|
case SocketError_NoError:
|
||||||
return "No error";
|
return "No error";
|
||||||
|
|
||||||
case Nz::SocketError_AddressNotAvailable:
|
case SocketError_AddressNotAvailable:
|
||||||
return "The address is already in use";
|
return "The address is already in use";
|
||||||
|
|
||||||
case Nz::SocketError_ConnectionClosed:
|
case SocketError_ConnectionClosed:
|
||||||
return "The connection has been closed";
|
return "The connection has been closed";
|
||||||
|
|
||||||
case Nz::SocketError_ConnectionRefused:
|
case SocketError_ConnectionRefused:
|
||||||
return "The connection attempt was refused";
|
return "The connection attempt was refused";
|
||||||
|
|
||||||
case Nz::SocketError_DatagramSize:
|
case SocketError_DatagramSize:
|
||||||
return "The datagram size is over the system limit";
|
return "The datagram size is over the system limit";
|
||||||
|
|
||||||
case Nz::SocketError_Internal:
|
case SocketError_Internal:
|
||||||
return "An internal error occurred";
|
return "An internal error occurred";
|
||||||
|
|
||||||
case Nz::SocketError_Packet:
|
case SocketError_Interrupted:
|
||||||
|
return "The operation was interrupted by a signal";
|
||||||
|
|
||||||
|
case SocketError_Packet:
|
||||||
return "Packet encoding or decoding failed";
|
return "Packet encoding or decoding failed";
|
||||||
|
|
||||||
case Nz::SocketError_NetworkError:
|
case SocketError_NetworkError:
|
||||||
return "Networking subsystem failed";
|
return "Networking subsystem failed";
|
||||||
|
|
||||||
case Nz::SocketError_NotInitialized:
|
case SocketError_NotInitialized:
|
||||||
return "Network module has not been initialized";
|
return "Network module has not been initialized";
|
||||||
|
|
||||||
case Nz::SocketError_NotSupported:
|
case SocketError_NotSupported:
|
||||||
return "This operation is not supported";
|
return "This operation is not supported";
|
||||||
|
|
||||||
case Nz::SocketError_ResolveError:
|
case SocketError_ResolveError:
|
||||||
return "The hostname couldn't be resolved";
|
return "The hostname couldn't be resolved";
|
||||||
|
|
||||||
case Nz::SocketError_ResourceError:
|
case SocketError_ResourceError:
|
||||||
return "The operating system lacks the resources to proceed";
|
return "The operating system lacks the resources to proceed";
|
||||||
|
|
||||||
case Nz::SocketError_TimedOut:
|
case SocketError_TimedOut:
|
||||||
return "The operation timed out";
|
return "The operation timed out";
|
||||||
|
|
||||||
case Nz::SocketError_Unknown:
|
case SocketError_Unknown:
|
||||||
return "An unknown error occurred";
|
return "An unknown error occurred";
|
||||||
|
|
||||||
case Nz::SocketError_UnreachableHost:
|
case SocketError_UnreachableHost:
|
||||||
return "The host is not reachable";
|
return "The host is not reachable";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ namespace Nz
|
||||||
if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime))
|
if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ENetProtocolHeader* header = reinterpret_cast<ENetProtocolHeader*>(m_receivedData);
|
ENetProtocolHeader* header = reinterpret_cast<ENetProtocolHeader*>(m_receivedData.Get());
|
||||||
|
|
||||||
UInt16 peerID = NetToHost(header->peerID);
|
UInt16 peerID = NetToHost(header->peerID);
|
||||||
UInt8 sessionID = (peerID & ENetProtocolHeaderSessionMask) >> ENetProtocolHeaderSessionShift;
|
UInt8 sessionID = (peerID & ENetProtocolHeaderSessionMask) >> ENetProtocolHeaderSessionShift;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ namespace Nz
|
||||||
NazaraWarning("An error occured while removing socket from epoll structure (errno " + String::Number(errno) + ": " + Error::GetLastSystemError() + ')');
|
NazaraWarning("An error occured while removing socket from epoll structure (errno " + String::Number(errno) + ": " + Error::GetLastSystemError() + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
unsigned int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
||||||
{
|
{
|
||||||
int activeSockets;
|
int activeSockets;
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Nz
|
||||||
if (activeSockets == -1)
|
if (activeSockets == -1)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketImpl::TranslateErrnoToResolveError(errno);
|
*error = SocketImpl::TranslateErrnoToSocketError(errno);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Nz
|
||||||
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
||||||
void UnregisterSocket(SocketHandle socket);
|
void UnregisterSocket(SocketHandle socket);
|
||||||
|
|
||||||
int Wait(int msTimeout, SocketError* error);
|
unsigned int Wait(int msTimeout, SocketError* error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<SocketHandle> m_readyToReadSockets;
|
std::unordered_set<SocketHandle> m_readyToReadSockets;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Nz
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
return newClient;
|
return newClient;
|
||||||
|
|
@ -58,7 +58,7 @@ namespace Nz
|
||||||
if (bind(handle, reinterpret_cast<const sockaddr*>(&nameBuffer), bufferLength) == SOCKET_ERROR)
|
if (bind(handle, reinterpret_cast<const sockaddr*>(&nameBuffer), bufferLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ namespace Nz
|
||||||
|
|
||||||
SocketHandle handle = socket(TranslateNetProtocolToAF(protocol), TranslateSocketTypeToSock(type), 0);
|
SocketHandle handle = socket(TranslateNetProtocolToAF(protocol), TranslateSocketTypeToSock(type), 0);
|
||||||
if (handle == InvalidHandle && error != nullptr)
|
if (handle == InvalidHandle && error != nullptr)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ namespace Nz
|
||||||
if (errorCode == EADDRNOTAVAIL)
|
if (errorCode == EADDRNOTAVAIL)
|
||||||
*error = SocketError_ConnectionRefused; //< ConnectionRefused seems more legit than AddressNotAvailable in connect case
|
*error = SocketError_ConnectionRefused; //< ConnectionRefused seems more legit than AddressNotAvailable in connect case
|
||||||
else
|
else
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Nz
|
||||||
if (code)
|
if (code)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(code);
|
*error = TranslateErrnoToSocketError(code);
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Nz
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Nz
|
||||||
if (code < 0)
|
if (code < 0)
|
||||||
return SocketError_Internal;
|
return SocketError_Internal;
|
||||||
|
|
||||||
return TranslateErrnoToResolveError(code);
|
return TranslateErrnoToSocketError(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketImpl::GetLastErrorCode()
|
int SocketImpl::GetLastErrorCode()
|
||||||
|
|
@ -218,7 +218,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, SOL_SOCKET, SO_ERROR, &code, &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, SOL_SOCKET, SO_ERROR, &code, &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +240,7 @@ namespace Nz
|
||||||
if (bind(handle, reinterpret_cast<const sockaddr*>(&nameBuffer), bufferLength) == SOCKET_ERROR)
|
if (bind(handle, reinterpret_cast<const sockaddr*>(&nameBuffer), bufferLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ namespace Nz
|
||||||
if (listen(handle, queueSize) == SOCKET_ERROR)
|
if (listen(handle, queueSize) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return SocketState_NotConnected;
|
return SocketState_NotConnected;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +267,7 @@ namespace Nz
|
||||||
if (ioctl(handle, FIONREAD, &availableBytes) == SOCKET_ERROR)
|
if (ioctl(handle, FIONREAD, &availableBytes) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +286,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, SOL_SOCKET, SO_BROADCAST, &code, &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, SOL_SOCKET, SO_BROADCAST, &code, &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +305,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &code, &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &code, &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -324,7 +324,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, IPPROTO_IP, IP_MTU, &code, &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, IPPROTO_IP, IP_MTU, &code, &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +343,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, IPPROTO_TCP, TCP_NODELAY, &code, &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, IPPROTO_TCP, TCP_NODELAY, &code, &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -362,7 +362,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&code), &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&code), &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ namespace Nz
|
||||||
if (getpeername(handle, reinterpret_cast<sockaddr*>(nameBuffer.data()), &bufferLength) == SOCKET_ERROR)
|
if (getpeername(handle, reinterpret_cast<sockaddr*>(nameBuffer.data()), &bufferLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return IpAddress();
|
return IpAddress();
|
||||||
}
|
}
|
||||||
|
|
@ -404,7 +404,7 @@ namespace Nz
|
||||||
if (getsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&code), &codeLength) == SOCKET_ERROR)
|
if (getsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&code), &codeLength) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -432,7 +432,7 @@ namespace Nz
|
||||||
if (errorCode == EINVAL)
|
if (errorCode == EINVAL)
|
||||||
*error = SocketError_NoError;
|
*error = SocketError_NoError;
|
||||||
else
|
else
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return IpAddress();
|
return IpAddress();
|
||||||
|
|
@ -444,7 +444,7 @@ namespace Nz
|
||||||
return IpAddressImpl::FromSockAddr(reinterpret_cast<sockaddr*>(nameBuffer.data()));
|
return IpAddressImpl::FromSockAddr(reinterpret_cast<sockaddr*>(nameBuffer.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error)
|
unsigned int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error)
|
||||||
{
|
{
|
||||||
NazaraAssert(fdarray && nfds > 0, "Invalid fdarray");
|
NazaraAssert(fdarray && nfds > 0, "Invalid fdarray");
|
||||||
|
|
||||||
|
|
@ -454,12 +454,12 @@ namespace Nz
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return static_cast<unsigned int>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SocketImpl::Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error)
|
bool SocketImpl::Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error)
|
||||||
|
|
@ -486,7 +486,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -541,7 +541,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +618,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -677,7 +677,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -730,7 +730,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -770,7 +770,7 @@ namespace Nz
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(errorCode);
|
*error = TranslateErrnoToSocketError(errorCode);
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -794,7 +794,7 @@ namespace Nz
|
||||||
if (ioctl(handle, FIONBIO, &block) == SOCKET_ERROR)
|
if (ioctl(handle, FIONBIO, &block) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -813,7 +813,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
if (setsockopt(handle, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -832,7 +832,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
if (setsockopt(handle, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -854,7 +854,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &keepAlive , sizeof(keepAlive)) == SOCKET_ERROR)
|
if (setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &keepAlive , sizeof(keepAlive)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -862,7 +862,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &keepIdle, sizeof(keepIdle)) == SOCKET_ERROR)
|
if (setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &keepIdle, sizeof(keepIdle)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -870,7 +870,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &keepInterval, sizeof(keepInterval)) == SOCKET_ERROR)
|
if (setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &keepInterval, sizeof(keepInterval)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -889,7 +889,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)) == SOCKET_ERROR)
|
if (setsockopt(handle, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -908,7 +908,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -927,7 +927,7 @@ namespace Nz
|
||||||
if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<const char*>(&option), sizeof(option)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
return false; //< Error
|
return false; //< Error
|
||||||
}
|
}
|
||||||
|
|
@ -938,7 +938,7 @@ namespace Nz
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketError SocketImpl::TranslateErrnoToResolveError(int error)
|
SocketError SocketImpl::TranslateErrnoToSocketError(int error)
|
||||||
{
|
{
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
|
|
@ -974,6 +974,9 @@ namespace Nz
|
||||||
case ECONNREFUSED:
|
case ECONNREFUSED:
|
||||||
return SocketError_ConnectionRefused;
|
return SocketError_ConnectionRefused;
|
||||||
|
|
||||||
|
case EINTR:
|
||||||
|
return SocketError_Interrupted;
|
||||||
|
|
||||||
case EMSGSIZE:
|
case EMSGSIZE:
|
||||||
return SocketError_DatagramSize;
|
return SocketError_DatagramSize;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Nz
|
||||||
static std::size_t QueryReceiveBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
static std::size_t QueryReceiveBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
||||||
static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
||||||
|
|
||||||
static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error);
|
static unsigned int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error);
|
||||||
|
|
||||||
static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error);
|
static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error);
|
||||||
static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error);
|
static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error);
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Nz
|
||||||
static bool SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr);
|
static bool SetReceiveBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr);
|
||||||
static bool SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr);
|
static bool SetSendBufferSize(SocketHandle handle, std::size_t size, SocketError* error = nullptr);
|
||||||
|
|
||||||
static SocketError TranslateErrnoToResolveError(int error);
|
static SocketError TranslateErrnoToSocketError(int error);
|
||||||
static int TranslateNetProtocolToAF(NetProtocol protocol);
|
static int TranslateNetProtocolToAF(NetProtocol protocol);
|
||||||
static int TranslateSocketTypeToSock(SocketType type);
|
static int TranslateSocketTypeToSock(SocketType type);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,9 @@ namespace Nz
|
||||||
m_readyToWriteSockets.erase(socket);
|
m_readyToWriteSockets.erase(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
unsigned int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
||||||
{
|
{
|
||||||
int activeSockets;
|
unsigned int activeSockets;
|
||||||
|
|
||||||
// Reset status of sockets
|
// Reset status of sockets
|
||||||
activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast<int>(msTimeout), error);
|
activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast<int>(msTimeout), error);
|
||||||
|
|
@ -87,7 +87,7 @@ namespace Nz
|
||||||
m_readyToWriteSockets.clear();
|
m_readyToWriteSockets.clear();
|
||||||
if (activeSockets > 0U)
|
if (activeSockets > 0U)
|
||||||
{
|
{
|
||||||
int socketRemaining = activeSockets;
|
unsigned int socketRemaining = activeSockets;
|
||||||
for (PollSocket& entry : m_sockets)
|
for (PollSocket& entry : m_sockets)
|
||||||
{
|
{
|
||||||
if (!entry.revents)
|
if (!entry.revents)
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraWarning("Socket " + String::Number(entry.fd) + " was returned by WSAPoll without POLLRDNORM nor POLLWRNORM events (events: 0x" + String::Number(entry.revents, 16) + ')');
|
NazaraWarning("Socket " + String::Number(entry.fd) + " was returned by poll without POLLRDNORM nor POLLWRNORM events (events: 0x" + String::Number(entry.revents, 16) + ')');
|
||||||
activeSockets--;
|
activeSockets--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,14 @@ namespace Nz
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
bool IsReady(SocketHandle socket) const;
|
bool IsReadyToRead(SocketHandle socket) const;
|
||||||
|
bool IsReadyToWrite(SocketHandle socket) const;
|
||||||
bool IsRegistered(SocketHandle socket) const;
|
bool IsRegistered(SocketHandle socket) const;
|
||||||
|
|
||||||
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
||||||
void UnregisterSocket(SocketHandle socket);
|
void UnregisterSocket(SocketHandle socket);
|
||||||
|
|
||||||
int Wait(int msTimeout, SocketError* error);
|
unsigned int Wait(int msTimeout, SocketError* error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<SocketHandle> m_readyToReadSockets;
|
std::unordered_set<SocketHandle> m_readyToReadSockets;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Network/SocketPoller.hpp>
|
#include <Nazara/Network/SocketPoller.hpp>
|
||||||
|
#include <Nazara/Network/Algorithm.hpp>
|
||||||
|
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
#include <Nazara/Network/Win32/SocketPollerImpl.hpp>
|
#include <Nazara/Network/Win32/SocketPollerImpl.hpp>
|
||||||
|
|
@ -170,24 +171,33 @@ namespace Nz
|
||||||
* Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready.
|
* Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready.
|
||||||
* To query the ready state of the registered socket, use the IsReadyToRead or IsReadyToWrite functions.
|
* To query the ready state of the registered socket, use the IsReadyToRead or IsReadyToWrite functions.
|
||||||
*
|
*
|
||||||
|
* If error is a valid pointer, it will be used to report the last error occurred (if no error occurred, a value of NoError will be reported)
|
||||||
|
*
|
||||||
* \param msTimeout Maximum time to wait in milliseconds, 0 will returns immediately and -1 will block indefinitely
|
* \param msTimeout Maximum time to wait in milliseconds, 0 will returns immediately and -1 will block indefinitely
|
||||||
|
* \param error If valid, this will be used to report the error status from the poller (if no error occurred, a value of NoError will be reported).
|
||||||
*
|
*
|
||||||
* \return True if at least one socket registered to the poller is ready.
|
* \return The number of socket reported ready (may be zero if no socket is ready or if an error occurred)
|
||||||
*
|
*
|
||||||
* \remark It is an error to try to unregister a non-registered socket from a SocketPoller.
|
* \remark In case of error, a NazaraError is triggered (except for interrupted errors)
|
||||||
*
|
*
|
||||||
* \see IsReady
|
* \see IsReady
|
||||||
* \see RegisterSocket
|
* \see RegisterSocket
|
||||||
*/
|
*/
|
||||||
bool SocketPoller::Wait(int msTimeout)
|
unsigned int SocketPoller::Wait(int msTimeout, SocketError* error)
|
||||||
{
|
{
|
||||||
SocketError error;
|
SocketError waitError;
|
||||||
|
|
||||||
int readySockets = m_impl->Wait(msTimeout, &error);
|
unsigned int readySockets = m_impl->Wait(msTimeout, &waitError);
|
||||||
if (error != SocketError_NoError)
|
|
||||||
|
if (error)
|
||||||
|
*error = waitError;
|
||||||
|
|
||||||
|
if (waitError != SocketError_NoError)
|
||||||
{
|
{
|
||||||
NazaraError("SocketPoller encountered an error (code: 0x" + String::Number(error, 16) + ')');
|
if (waitError != SocketError_Interrupted) //< Do not log interrupted error
|
||||||
return false;
|
NazaraError("SocketPoller encountered an error (code: 0x" + String::Number(waitError, 16) + "): " + ErrorToString(waitError));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return readySockets > 0;
|
return readySockets > 0;
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@ namespace Nz
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error)
|
unsigned int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error)
|
||||||
{
|
{
|
||||||
NazaraAssert(fdarray && nfds > 0, "Invalid fdarray");
|
NazaraAssert(fdarray && nfds > 0, "Invalid fdarray");
|
||||||
|
|
||||||
|
|
@ -484,10 +484,12 @@ namespace Nz
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(result >= 0);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketError_NoError;
|
*error = SocketError_NoError;
|
||||||
|
|
||||||
return result;
|
return static_cast<unsigned int>(result);
|
||||||
#else
|
#else
|
||||||
NazaraUnused(fdarray);
|
NazaraUnused(fdarray);
|
||||||
NazaraUnused(nfds);
|
NazaraUnused(nfds);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Nz
|
||||||
static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr);
|
static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr);
|
||||||
static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
static std::size_t QuerySendBufferSize(SocketHandle handle, SocketError* error = nullptr);
|
||||||
|
|
||||||
static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error);
|
static unsigned int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error);
|
||||||
|
|
||||||
static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error);
|
static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error);
|
||||||
static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error);
|
static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error);
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,9 @@ namespace Nz
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
unsigned int SocketPollerImpl::Wait(int msTimeout, SocketError* error)
|
||||||
{
|
{
|
||||||
int activeSockets;
|
unsigned int activeSockets;
|
||||||
|
|
||||||
#if NAZARA_NETWORK_POLL_SUPPORT
|
#if NAZARA_NETWORK_POLL_SUPPORT
|
||||||
activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast<int>(msTimeout), error);
|
activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast<int>(msTimeout), error);
|
||||||
|
|
@ -187,8 +187,8 @@ namespace Nz
|
||||||
tv.tv_sec = static_cast<long>(msTimeout / 1000ULL);
|
tv.tv_sec = static_cast<long>(msTimeout / 1000ULL);
|
||||||
tv.tv_usec = static_cast<long>((msTimeout % 1000ULL) * 1000ULL);
|
tv.tv_usec = static_cast<long>((msTimeout % 1000ULL) * 1000ULL);
|
||||||
|
|
||||||
activeSockets = ::select(0xDEADBEEF, readSet, writeSet, nullptr, (msTimeout >= 0) ? &tv : nullptr); //< The first argument is ignored on Windows
|
int selectValue = ::select(0xDEADBEEF, readSet, writeSet, nullptr, (msTimeout >= 0) ? &tv : nullptr); //< The first argument is ignored on Windows
|
||||||
if (activeSockets == SOCKET_ERROR)
|
if (selectValue == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketImpl::TranslateWSAErrorToSocketError(WSAGetLastError());
|
*error = SocketImpl::TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||||
|
|
@ -196,6 +196,9 @@ namespace Nz
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(selectValue >= 0);
|
||||||
|
activeSockets = static_cast<unsigned int>(selectValue);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketError_NoError;
|
*error = SocketError_NoError;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Nz
|
||||||
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
bool RegisterSocket(SocketHandle socket, SocketPollEventFlags eventFlags);
|
||||||
void UnregisterSocket(SocketHandle socket);
|
void UnregisterSocket(SocketHandle socket);
|
||||||
|
|
||||||
int Wait(int msTimeout, SocketError* error);
|
unsigned int Wait(int msTimeout, SocketError* error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if NAZARA_NETWORK_POLL_SUPPORT
|
#if NAZARA_NETWORK_POLL_SUPPORT
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <chipmunk/chipmunk.h>
|
#include <chipmunk/chipmunk.h>
|
||||||
#include <chipmunk/chipmunk_private.h>
|
#include <chipmunk/chipmunk_private.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
#include <Nazara/Physics3D/Debug.hpp>
|
#include <Nazara/Physics3D/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
@ -127,6 +128,37 @@ namespace Nz
|
||||||
cpBodySetTorque(m_handle, cpBodyGetTorque(m_handle) + ToRadians(torque));
|
cpBodySetTorque(m_handle, cpBodyGetTorque(m_handle) + ToRadians(torque));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RigidBody2D::ClosestPointQuery(const Nz::Vector2f& position, Nz::Vector2f* closestPoint, float* closestDistance) const
|
||||||
|
{
|
||||||
|
cpVect pos = cpv(cpFloat(position.x), cpFloat(position.y));
|
||||||
|
|
||||||
|
float minDistance = std::numeric_limits<float>::infinity();
|
||||||
|
Nz::Vector2f closest;
|
||||||
|
for (cpShape* shape : m_shapes)
|
||||||
|
{
|
||||||
|
cpPointQueryInfo result;
|
||||||
|
cpShapePointQuery(shape, pos, &result);
|
||||||
|
|
||||||
|
float resultDistance = float(result.distance);
|
||||||
|
if (resultDistance < minDistance)
|
||||||
|
{
|
||||||
|
closest.Set(float(result.point.x), float(result.point.y));
|
||||||
|
minDistance = resultDistance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::isinf(minDistance))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (closestPoint)
|
||||||
|
*closestPoint = closest;
|
||||||
|
|
||||||
|
if (minDistance)
|
||||||
|
*closestDistance = minDistance;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void RigidBody2D::EnableSimulation(bool simulation)
|
void RigidBody2D::EnableSimulation(bool simulation)
|
||||||
{
|
{
|
||||||
if (m_isRegistered != simulation)
|
if (m_isRegistered != simulation)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue