Merge branch 'master' into reflection-mapping
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Nz
|
||||
public:
|
||||
using BitField = typename std::conditional<(EnumAsFlags<E>::max > 32), UInt64, UInt32>::type;
|
||||
|
||||
constexpr Flags(BitField value);
|
||||
constexpr Flags(BitField value = 0);
|
||||
constexpr Flags(E enumVal);
|
||||
|
||||
explicit constexpr operator bool() const;
|
||||
@@ -54,13 +54,13 @@ namespace Nz
|
||||
private:
|
||||
BitField m_value;
|
||||
};
|
||||
|
||||
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs);
|
||||
}
|
||||
|
||||
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs);
|
||||
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs);
|
||||
|
||||
#include <Nazara/Core/Flags.inl>
|
||||
|
||||
#endif // NAZARA_FLAGS_HPP
|
||||
|
||||
@@ -13,13 +13,13 @@ namespace Nz
|
||||
* \brief Core class used to combine enumeration values into flags bitfield
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Flags object using a bitfield
|
||||
*
|
||||
* \param value Bitfield to be used
|
||||
/*!
|
||||
* \brief Constructs a Flags object using a bitfield
|
||||
*
|
||||
* \param value Bitfield to be used
|
||||
*
|
||||
* Uses a bitfield to builds the flag value. (e.g. if bit 0 is active, then Enum value 0 will be set as active).
|
||||
*/
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr Flags<E>::Flags(BitField value) :
|
||||
m_value(value)
|
||||
@@ -209,68 +209,67 @@ namespace Nz
|
||||
{
|
||||
return 1U << static_cast<BitField>(enumValue);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Override binary NOT operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with reversed bits.
|
||||
*
|
||||
* \param lhs Enumeration value to reverse.
|
||||
*
|
||||
* Returns a Flags object with all state enabled except for the enum one.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs)
|
||||
{
|
||||
return ~Nz::Flags<E>(lhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Override binary NOT operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with reversed bits.
|
||||
*
|
||||
* \param lhs Enumeration value to reverse.
|
||||
*
|
||||
* Returns a Flags object with all state enabled except for the enum one.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs)
|
||||
{
|
||||
return ~Flags<E>(lhs);
|
||||
}
|
||||
/*!
|
||||
* \brief Override binary OR operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with combined enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to combine.
|
||||
* \param rhs Second enumeration value to combine.
|
||||
*
|
||||
* Returns a Flags object with combined states from the two enumeration values.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs)
|
||||
{
|
||||
return Nz::Flags<E>(lhs) | rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Override binary OR operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with combined enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to combine.
|
||||
* \param rhs Second enumeration value to combine.
|
||||
*
|
||||
* Returns a Flags object with combined states from the two enumeration values.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) | rhs;
|
||||
}
|
||||
/*!
|
||||
* \brief Override binary AND operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with compare enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to compare.
|
||||
* \param rhs Second enumeration value to compare.
|
||||
*
|
||||
* Returns a Flags object with compared states from the two enumeration values.
|
||||
* In this case, only one flag will be enabled if both enumeration values are the same.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs)
|
||||
{
|
||||
return Nz::Flags<E>(lhs) & rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Override binary AND operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with compare enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to compare.
|
||||
* \param rhs Second enumeration value to compare.
|
||||
*
|
||||
* Returns a Flags object with compared states from the two enumeration values.
|
||||
* In this case, only one flag will be enabled if both enumeration values are the same.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) & rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Override binary XOR operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with XORed enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to compare.
|
||||
* \param rhs Second enumeration value to compare.
|
||||
*
|
||||
* Returns a Flags object with XORed states from the two enumeration values.
|
||||
* In this case, two flags will be enabled if both the enumeration values are different.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) ^ rhs;
|
||||
}
|
||||
/*!
|
||||
* \brief Override binary XOR operator on enum to turns into a Flags object.
|
||||
* \return A Flags object with XORed enum states.
|
||||
*
|
||||
* \param lhs First enumeration value to compare.
|
||||
* \param rhs Second enumeration value to compare.
|
||||
*
|
||||
* Returns a Flags object with XORed states from the two enumeration values.
|
||||
* In this case, two flags will be enabled if both the enumeration values are different.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs)
|
||||
{
|
||||
return Nz::Flags<E>(lhs) ^ rhs;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -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 - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace Nz
|
||||
template<typename T, typename... Args>
|
||||
T* PlacementNew(T* ptr, Args&&... args);
|
||||
|
||||
template<typename T>
|
||||
void PlacementDestroy(T* ptr);
|
||||
|
||||
class StackAllocation
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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 - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -64,6 +64,17 @@ namespace Nz
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Calls the object destructor explicitly
|
||||
*
|
||||
* \param ptr Pointer to a previously constructed pointer on raw memory
|
||||
*/
|
||||
template<typename T>
|
||||
void PlacementDestroy(T* ptr)
|
||||
{
|
||||
ptr->~T();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::StackAllocation
|
||||
|
||||
@@ -22,12 +22,14 @@ namespace Nz
|
||||
~MemoryPool() = default;
|
||||
|
||||
void* Allocate(unsigned int size);
|
||||
|
||||
template<typename T> void Delete(T* ptr);
|
||||
|
||||
void Free(void* ptr);
|
||||
|
||||
unsigned int GetBlockSize() const;
|
||||
unsigned int GetFreeBlocks() const;
|
||||
unsigned int GetSize() const;
|
||||
inline unsigned int GetBlockSize() const;
|
||||
inline unsigned int GetFreeBlocks() const;
|
||||
inline unsigned int GetSize() const;
|
||||
|
||||
template<typename T, typename... Args> T* New(Args&&... args);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
@@ -95,9 +96,8 @@ namespace Nz
|
||||
*
|
||||
* \remark If ptr is null, nothing is done
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
inline void MemoryPool::Delete(T* ptr)
|
||||
void MemoryPool::Delete(T* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Nz
|
||||
template<typename T> bool operator<(const T& lhs, const ObjectHandle<T>& rhs);
|
||||
template<typename T> bool operator<(const ObjectHandle<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<=(const ObjectHandle<T>, const ObjectHandle<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectHandle<T>&, const ObjectHandle<T>& rhs);
|
||||
template<typename T> bool operator<=(const T& lhs, const ObjectHandle<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectHandle<T>& lhs, const T& rhs);
|
||||
|
||||
|
||||
@@ -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"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -68,4 +68,4 @@ namespace Nz
|
||||
|
||||
#include <Nazara/Network/AbstractSocket.inl>
|
||||
|
||||
#endif // NAZARA_ABSTRACTSOCKET_HPP
|
||||
#endif // NAZARA_ABSTRACTSOCKET_HPP
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#ifndef NAZARA_ENUMS_NETWORK_HPP
|
||||
#define NAZARA_ENUMS_NETWORK_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum NetCode : UInt16
|
||||
|
||||
21
include/Nazara/Network/NetBuffer.hpp
Normal file
21
include/Nazara/Network/NetBuffer.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_NETBUFFER_HPP
|
||||
#define NAZARA_NETBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NetBuffer
|
||||
{
|
||||
void* data;
|
||||
std::size_t dataLength;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_NETBUFFER_HPP
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Network/NetBuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -49,6 +50,7 @@ namespace Nz
|
||||
bool ReceivePacket(NetPacket* packet);
|
||||
|
||||
bool Send(const void* buffer, std::size_t size, std::size_t* sent);
|
||||
bool SendMultiple(const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent);
|
||||
bool SendPacket(const NetPacket& packet);
|
||||
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Network/NetBuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -29,7 +30,7 @@ namespace Nz
|
||||
inline bool Create(NetProtocol protocol);
|
||||
|
||||
void EnableBroadcasting(bool broadcasting);
|
||||
|
||||
|
||||
inline IpAddress GetBoundAddress() const;
|
||||
inline UInt16 GetBoundPort() const;
|
||||
inline SocketState GetState() const;
|
||||
@@ -42,6 +43,7 @@ namespace Nz
|
||||
bool ReceivePacket(NetPacket* packet, IpAddress* from);
|
||||
|
||||
bool Send(const IpAddress& to, const void* buffer, std::size_t size, std::size_t* sent);
|
||||
bool SendMultiple(const IpAddress& to, const NetBuffer* buffers, std::size_t bufferCount, std::size_t* sent);
|
||||
bool SendPacket(const IpAddress& to, const NetPacket& packet);
|
||||
|
||||
private:
|
||||
@@ -55,4 +57,4 @@ namespace Nz
|
||||
|
||||
#include <Nazara/Network/UdpSocket.inl>
|
||||
|
||||
#endif // NAZARA_UDPSOCKET_HPP
|
||||
#endif // NAZARA_UDPSOCKET_HPP
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Nz
|
||||
static std::array<Vector4f, 2 * 2 * 2 * 2 * 2> s_gradients4;
|
||||
|
||||
private:
|
||||
std::default_random_engine m_randomEngine;
|
||||
std::mt19937 m_randomEngine;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
|
||||
// Nazara version macro
|
||||
#define NAZARA_VERSION_MAJOR 0
|
||||
#define NAZARA_VERSION_MINOR 2
|
||||
#define NAZARA_VERSION_PATCH 1
|
||||
#define NAZARA_VERSION_MINOR 3
|
||||
#define NAZARA_VERSION_PATCH 0
|
||||
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user