Merge branch 'master' into vulkan
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
@@ -37,7 +38,7 @@ namespace Nz
|
||||
public:
|
||||
Music() = default;
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) = delete; ///TODO
|
||||
Music(Music&&) = delete;
|
||||
~Music();
|
||||
|
||||
bool Create(SoundStream* soundStream);
|
||||
@@ -66,10 +67,10 @@ namespace Nz
|
||||
void Stop() override;
|
||||
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) = delete; ///TODO
|
||||
Music& operator=(Music&&) = delete;
|
||||
|
||||
private:
|
||||
MusicImpl* m_impl = nullptr;
|
||||
MovablePtr<MusicImpl> m_impl = nullptr;
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
@@ -18,7 +19,6 @@
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace Nz
|
||||
template<typename... Args> static SoundBufferRef New(Args&&... args);
|
||||
|
||||
SoundBuffer& operator=(const SoundBuffer&) = delete;
|
||||
SoundBuffer& operator=(SoundBuffer&&) = delete; ///TODO
|
||||
SoundBuffer& operator=(SoundBuffer&&) = delete;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/);
|
||||
@@ -86,7 +86,7 @@ namespace Nz
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
SoundBufferImpl* m_impl = nullptr;
|
||||
MovablePtr<SoundBufferImpl> m_impl = nullptr;
|
||||
|
||||
static SoundBufferLibrary::LibraryMap s_library;
|
||||
static SoundBufferLoader::LoaderList s_loaders;
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace Nz
|
||||
virtual void Stop() = 0;
|
||||
|
||||
SoundEmitter& operator=(const SoundEmitter&) = delete; ///TODO
|
||||
SoundEmitter& operator=(SoundEmitter&&) = delete; ///TODO
|
||||
SoundEmitter& operator=(SoundEmitter&&) = delete;
|
||||
|
||||
protected:
|
||||
SoundEmitter();
|
||||
SoundEmitter(const SoundEmitter& emitter);
|
||||
SoundEmitter(SoundEmitter&&) = delete; ///TODO
|
||||
SoundEmitter(SoundEmitter&&) = delete;
|
||||
|
||||
SoundStatus GetInternalStatus() const;
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_ABSTRACTLOGGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -130,8 +130,6 @@ namespace Nz
|
||||
* \brief Returns the number of elements in a C-array
|
||||
* \return The number of elements
|
||||
*
|
||||
* \param name C-array
|
||||
*
|
||||
* \see CountOf
|
||||
*/
|
||||
template<typename T, std::size_t N>
|
||||
@@ -308,7 +306,7 @@ namespace Nz
|
||||
return false;
|
||||
|
||||
string->resize(size);
|
||||
return context.stream->Read(&string[0], size) == size;
|
||||
return context.stream->Read(&(*string)[0], size) == size;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Nz
|
||||
void ShiftLeft(std::size_t pos);
|
||||
void ShiftRight(std::size_t pos);
|
||||
|
||||
void Swap(Bitset& bitset);
|
||||
void Swap(Bitset& bitset) noexcept;
|
||||
|
||||
bool Test(std::size_t bit) const;
|
||||
bool TestAll() const;
|
||||
@@ -90,8 +90,8 @@ namespace Nz
|
||||
void UnboundedSet(std::size_t bit, bool val = true);
|
||||
bool UnboundedTest(std::size_t bit) const;
|
||||
|
||||
Bit operator[](int index);
|
||||
bool operator[](int index) const;
|
||||
Bit operator[](std::size_t index);
|
||||
bool operator[](std::size_t index) const;
|
||||
|
||||
Bitset operator~() const;
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Nz
|
||||
namespace std
|
||||
{
|
||||
template<typename Block, class Allocator>
|
||||
void swap(Nz::Bitset<Block, Allocator>& lhs, Nz::Bitset<Block, Allocator>& rhs);
|
||||
void swap(Nz::Bitset<Block, Allocator>& lhs, Nz::Bitset<Block, Allocator>& rhs) noexcept;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Bitset.inl>
|
||||
|
||||
@@ -776,7 +776,7 @@ namespace Nz
|
||||
* \param bitset Other bitset to swap
|
||||
*/
|
||||
template<typename Block, class Allocator>
|
||||
void Bitset<Block, Allocator>::Swap(Bitset& bitset)
|
||||
void Bitset<Block, Allocator>::Swap(Bitset& bitset) noexcept
|
||||
{
|
||||
std::swap(m_bitCount, bitset.m_bitCount);
|
||||
std::swap(m_blocks, bitset.m_blocks);
|
||||
@@ -815,7 +815,7 @@ namespace Nz
|
||||
for (std::size_t i = 0; i < m_blocks.size(); ++i)
|
||||
{
|
||||
Block mask = (i == m_blocks.size() - 1) ? lastBlockMask : fullBitMask;
|
||||
if (m_blocks[i] == mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask
|
||||
if (m_blocks[i] != mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -958,7 +958,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
typename Bitset<Block, Allocator>::Bit Bitset<Block, Allocator>::operator[](int index)
|
||||
typename Bitset<Block, Allocator>::Bit Bitset<Block, Allocator>::operator[](std::size_t index)
|
||||
{
|
||||
return Bit(m_blocks[GetBlockIndex(index)], Block(1U) << GetBitIndex(index));
|
||||
}
|
||||
@@ -969,7 +969,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
bool Bitset<Block, Allocator>::operator[](int index) const
|
||||
bool Bitset<Block, Allocator>::operator[](std::size_t index) const
|
||||
{
|
||||
return Test(index);
|
||||
}
|
||||
@@ -1645,7 +1645,7 @@ namespace std
|
||||
*/
|
||||
|
||||
template<typename Block, class Allocator>
|
||||
void swap(Nz::Bitset<Block, Allocator>& lhs, Nz::Bitset<Block, Allocator>& rhs)
|
||||
void swap(Nz::Bitset<Block, Allocator>& lhs, Nz::Bitset<Block, Allocator>& rhs) noexcept
|
||||
{
|
||||
lhs.Swap(rhs);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <cstdio>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -422,7 +421,6 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Resizes the string
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param newSize Target size
|
||||
*/
|
||||
@@ -434,7 +432,6 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Resizes the string
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param newSize Target size
|
||||
* \param byte Byte to add if newSize is greather than actual size
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
#define NAZARA_BYTESTREAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/SerializationContext.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ByteArray;
|
||||
class Stream;
|
||||
|
||||
class NAZARA_CORE_API ByteStream
|
||||
{
|
||||
public:
|
||||
@@ -40,7 +41,7 @@ namespace Nz
|
||||
void SetStream(void* ptr, Nz::UInt64 size);
|
||||
void SetStream(const void* ptr, Nz::UInt64 size);
|
||||
|
||||
inline void Write(const void* data, std::size_t size);
|
||||
inline std::size_t Write(const void* data, std::size_t size);
|
||||
|
||||
template<typename T>
|
||||
ByteStream& operator>>(T& value);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Nz
|
||||
* \brief Reads data
|
||||
* \return Number of data read
|
||||
*
|
||||
* \param buffer Preallocated buffer to contain information read
|
||||
* \param ptr Preallocated buffer to contain information read
|
||||
* \param size Size of the read and thus of the buffer
|
||||
*/
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Sets the stream endianness
|
||||
*
|
||||
* \param Type of the endianness
|
||||
* \param endiannes Type of the endianness
|
||||
*/
|
||||
|
||||
inline void ByteStream::SetDataEndianness(Endianness endiannes)
|
||||
@@ -154,13 +154,13 @@ namespace Nz
|
||||
* \remark Produces a NazaraAssert if buffer is nullptr
|
||||
*/
|
||||
|
||||
inline void ByteStream::Write(const void* data, std::size_t size)
|
||||
inline std::size_t ByteStream::Write(const void* data, std::size_t size)
|
||||
{
|
||||
if (!m_context.stream)
|
||||
OnEmptyStream();
|
||||
|
||||
FlushBits();
|
||||
m_context.stream->Write(data, size);
|
||||
return m_context.stream->Write(data, size);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Nz
|
||||
inline explicit Color(UInt8 lightness);
|
||||
inline Color(UInt8 color[3], UInt8 alpha = 255);
|
||||
inline Color(const Color& color) = default;
|
||||
inline Color(Color&& color) = default;
|
||||
inline ~Color() = default;
|
||||
|
||||
inline bool IsOpaque() const;
|
||||
@@ -32,6 +33,9 @@ namespace Nz
|
||||
inline Color operator+(const Color& angles) const;
|
||||
inline Color operator*(const Color& angles) const;
|
||||
|
||||
inline Color& operator=(const Color& other) = default;
|
||||
inline Color& operator=(Color&& other) = default;
|
||||
|
||||
inline Color operator+=(const Color& angles);
|
||||
inline Color operator*=(const Color& angles);
|
||||
|
||||
@@ -40,13 +44,13 @@ namespace Nz
|
||||
|
||||
static inline Color FromCMY(float cyan, float magenta, float yellow);
|
||||
static inline Color FromCMYK(float cyan, float magenta, float yellow, float black);
|
||||
static inline Color FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness);
|
||||
static inline Color FromHSL(float hue, float saturation, float lightness);
|
||||
static inline Color FromHSV(float hue, float saturation, float value);
|
||||
static inline Color FromXYZ(const Vector3f& vec);
|
||||
static inline Color FromXYZ(float x, float y, float z);
|
||||
static inline void ToCMY(const Color& color, float* cyan, float* magenta, float* yellow);
|
||||
static inline void ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black);
|
||||
static inline void ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness);
|
||||
static inline void ToHSL(const Color& color, float* hue, float* saturation, float* lightness);
|
||||
static inline void ToHSV(const Color& color, float* hue, float* saturation, float* value);
|
||||
static inline void ToXYZ(const Color& color, Vector3f* vec);
|
||||
static inline void ToXYZ(const Color& color, float* x, float* y, float* z);
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
// 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/Algorithm.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -222,35 +219,29 @@ namespace Nz
|
||||
* \brief Converts HSL representation to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param lightness Lightness component
|
||||
* \param hue Hue component in [0, 360]
|
||||
* \param saturation Saturation component [0, 1]
|
||||
* \param lightness Lightness component [0, 1]
|
||||
*/
|
||||
|
||||
inline Color Color::FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness)
|
||||
inline Color Color::FromHSL(float hue, float saturation, float lightness)
|
||||
{
|
||||
if (saturation == 0)
|
||||
if (NumberEquals(saturation, 0.f))
|
||||
{
|
||||
// RGB results from 0 to 255
|
||||
return Color(lightness * 255,
|
||||
lightness * 255,
|
||||
lightness * 255);
|
||||
return Color(static_cast<UInt8>(lightness * 255.f));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Norme Windows
|
||||
float l = lightness/240.f;
|
||||
float h = hue/240.f;
|
||||
float s = saturation/240.f;
|
||||
|
||||
float v2;
|
||||
if (l < 0.5f)
|
||||
v2 = l * (1.f + s);
|
||||
if (lightness < 0.5f)
|
||||
v2 = lightness * (1.f + saturation);
|
||||
else
|
||||
v2 = (l + s) - (s*l);
|
||||
v2 = (lightness + saturation) - (saturation * lightness);
|
||||
|
||||
float v1 = 2.f * l - v2;
|
||||
float v1 = 2.f * lightness - v2;
|
||||
|
||||
float h = hue / 360.f;
|
||||
return Color(static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h + (1.f/3.f))),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h)),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h - (1.f/3.f))));
|
||||
@@ -261,9 +252,9 @@ namespace Nz
|
||||
* \brief Converts HSV representation to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param value Value component
|
||||
* \param hue Hue component in [0, 360]
|
||||
* \param saturation Saturation component in [0, 1]
|
||||
* \param value Value component in [0, 1]
|
||||
*/
|
||||
|
||||
inline Color Color::FromHSV(float hue, float saturation, float value)
|
||||
@@ -272,16 +263,15 @@ namespace Nz
|
||||
return Color(static_cast<UInt8>(value * 255.f));
|
||||
else
|
||||
{
|
||||
float h = hue/360.f * 6.f;
|
||||
float s = saturation/360.f;
|
||||
float h = (hue / 360.f) * 6.f;
|
||||
|
||||
if (NumberEquals(h, 6.f))
|
||||
h = 0; // hue must be < 1
|
||||
if (NumberEquals(h , 6.f))
|
||||
h = 0.f; // hue must be < 1
|
||||
|
||||
int i = static_cast<unsigned int>(h);
|
||||
float v1 = value * (1.f - s);
|
||||
float v2 = value * (1.f - s * (h - i));
|
||||
float v3 = value * (1.f - s * (1.f - (h - i)));
|
||||
int i = static_cast<int>(h);
|
||||
float v1 = value * (1.f - saturation);
|
||||
float v2 = value * (1.f - saturation * (h - i));
|
||||
float v3 = value * (1.f - saturation * (1.f - (h - i)));
|
||||
|
||||
float r, g, b;
|
||||
switch (i)
|
||||
@@ -324,7 +314,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
// RGB results from 0 to 255
|
||||
return Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
|
||||
return Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +331,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Converts XYZ representation to RGB
|
||||
* \brief Converts XYZ representation (D65/2°) to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param x X component
|
||||
@@ -365,12 +355,12 @@ namespace Nz
|
||||
r *= 12.92f;
|
||||
|
||||
if (g > 0.0031308f)
|
||||
g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
g = 1.055f * (std::pow(g, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
g *= 12.92f;
|
||||
|
||||
if (b > 0.0031308f)
|
||||
b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
b = 1.055f * (std::pow(b, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
b *= 12.92f;
|
||||
|
||||
@@ -430,12 +420,12 @@ namespace Nz
|
||||
* \brief Converts RGB representation to HSL
|
||||
*
|
||||
* \param color Color to transform
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param lightness Lightness component
|
||||
* \param hue Hue component [0, 360]
|
||||
* \param saturation Saturation component in [0, 1]
|
||||
* \param lightness Lightness component in [0, 1]
|
||||
*/
|
||||
|
||||
inline void Color::ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness)
|
||||
inline void Color::ToHSL(const Color& color, float* hue, float* saturation, float* lightness)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
@@ -446,42 +436,41 @@ namespace Nz
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
float l = (max + min)/2.f;
|
||||
float l = (max + min) / 2.f;
|
||||
*lightness = l;
|
||||
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSL results from 0 to 1
|
||||
*saturation = 0;
|
||||
*hue = 0.f;
|
||||
*saturation = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
if (l < 0.5f)
|
||||
*saturation = static_cast<UInt8>(deltaMax/(max+min)*240.f);
|
||||
if (l <= 0.5f)
|
||||
*saturation = deltaMax / (max + min);
|
||||
else
|
||||
*saturation = static_cast<UInt8>(deltaMax/(2.f-max-min)*240.f);
|
||||
*saturation = (deltaMax / (2.f - max - min));
|
||||
|
||||
*lightness = static_cast<UInt8>(l*240.f);
|
||||
|
||||
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaR = ((max - r) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
|
||||
float h;
|
||||
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
h = (1.f / 3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
h = (2.f / 3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = static_cast<UInt8>(h*240.f);
|
||||
*hue = h * 360.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,33 +499,33 @@ namespace Nz
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSV results from 0 to 1
|
||||
*saturation = 0;
|
||||
*hue = 0.f;
|
||||
*saturation = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
*saturation = deltaMax/max*360.f;
|
||||
*saturation = deltaMax / max;
|
||||
|
||||
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaR = ((max - r) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
|
||||
float h;
|
||||
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
h = (1.f / 3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
h = (2.f / 3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = h*360.f;
|
||||
*hue = h * 360.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_CONDITIONVARIABLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Nz
|
||||
public:
|
||||
ConditionVariable();
|
||||
ConditionVariable(const ConditionVariable&) = delete;
|
||||
inline ConditionVariable(ConditionVariable&& condition) noexcept;
|
||||
ConditionVariable(ConditionVariable&& condition) noexcept = default;
|
||||
~ConditionVariable();
|
||||
|
||||
void Signal();
|
||||
@@ -29,10 +30,10 @@ namespace Nz
|
||||
bool Wait(Mutex* mutex, UInt32 timeout);
|
||||
|
||||
ConditionVariable& operator=(const ConditionVariable&) = delete;
|
||||
ConditionVariable& operator=(ConditionVariable&& condition) noexcept;
|
||||
ConditionVariable& operator=(ConditionVariable&& condition) noexcept = default;
|
||||
|
||||
private:
|
||||
ConditionVariableImpl* m_impl;
|
||||
MovablePtr<ConditionVariableImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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/ConditionVariable.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -11,15 +9,6 @@ namespace Nz
|
||||
/*!
|
||||
* \class Nz::ConditionVariable
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a ConditionVariable object by moving another one
|
||||
*/
|
||||
inline ConditionVariable::ConditionVariable(ConditionVariable&& condition) noexcept :
|
||||
m_impl(condition.m_impl)
|
||||
{
|
||||
condition.m_impl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_CORE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_DIRECTORY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
@@ -35,7 +36,7 @@ namespace Nz
|
||||
Directory();
|
||||
Directory(const String& dirPath);
|
||||
Directory(const Directory&) = delete;
|
||||
Directory(Directory&&) = delete; ///TODO
|
||||
Directory(Directory&&) noexcept = default;
|
||||
~Directory();
|
||||
|
||||
void Close();
|
||||
@@ -67,14 +68,14 @@ namespace Nz
|
||||
static bool SetCurrent(const String& dirPath);
|
||||
|
||||
Directory& operator=(const Directory&) = delete;
|
||||
Directory& operator=(Directory&&) = delete; ///TODO
|
||||
Directory& operator=(Directory&&) noexcept = delete;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
String m_dirPath;
|
||||
String m_pattern;
|
||||
DirectoryImpl* m_impl;
|
||||
MovablePtr<DirectoryImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_DYNLIB_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
@@ -28,7 +29,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
using DynLibFunc = int (*)(); // "Generic" type of poiter to function
|
||||
using DynLibFunc = int (*)(); // "Generic" type of pointer to function
|
||||
|
||||
class DynLibImpl;
|
||||
|
||||
@@ -37,7 +38,7 @@ namespace Nz
|
||||
public:
|
||||
DynLib();
|
||||
DynLib(const DynLib&) = delete;
|
||||
DynLib(DynLib&& lib);
|
||||
DynLib(DynLib&&) noexcept = default;
|
||||
~DynLib();
|
||||
|
||||
String GetLastError() const;
|
||||
@@ -49,13 +50,13 @@ namespace Nz
|
||||
void Unload();
|
||||
|
||||
DynLib& operator=(const DynLib&) = delete;
|
||||
DynLib& operator=(DynLib&& lib);
|
||||
DynLib& operator=(DynLib&& lib) noexcept = default;
|
||||
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
mutable String m_lastError;
|
||||
DynLibImpl* m_impl;
|
||||
MovablePtr<DynLibImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +94,7 @@ namespace Nz
|
||||
template<>
|
||||
struct EnumAsFlags<OpenMode>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
static constexpr int max = OpenMode_Max;
|
||||
static constexpr OpenMode max = OpenMode_Max;
|
||||
};
|
||||
|
||||
using OpenModeFlags = Flags<OpenMode>;
|
||||
@@ -198,8 +197,7 @@ namespace Nz
|
||||
template<>
|
||||
struct EnumAsFlags<StreamOption>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
static constexpr int max = StreamOption_Max;
|
||||
static constexpr StreamOption max = StreamOption_Max;
|
||||
};
|
||||
|
||||
using StreamOptionFlags = Flags<StreamOption>;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_ERRORFLAGS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Nz
|
||||
File(const String& filePath);
|
||||
File(const String& filePath, OpenModeFlags openMode);
|
||||
File(const File&) = delete;
|
||||
File(File&& file) noexcept;
|
||||
File(File&& file) noexcept = default;
|
||||
~File();
|
||||
|
||||
bool Copy(const String& newFilePath);
|
||||
@@ -69,7 +69,7 @@ namespace Nz
|
||||
|
||||
File& operator=(const String& filePath);
|
||||
File& operator=(const File&) = delete;
|
||||
File& operator=(File&& file) noexcept;
|
||||
File& operator=(File&& file) noexcept = default;
|
||||
|
||||
static String AbsolutePath(const String& filePath);
|
||||
static inline ByteArray ComputeHash(HashType hash, const String& filePath);
|
||||
@@ -95,7 +95,7 @@ namespace Nz
|
||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||
|
||||
String m_filePath;
|
||||
FileImpl* m_impl;
|
||||
MovablePtr<FileImpl> m_impl;
|
||||
};
|
||||
|
||||
NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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/AbstractHash.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
|
||||
@@ -16,24 +16,42 @@ namespace Nz
|
||||
template<typename E>
|
||||
struct EnumAsFlags
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
static constexpr int max = 0;
|
||||
};
|
||||
|
||||
// From: https://stackoverflow.com/questions/11927032/sfinae-check-for-static-member-using-decltype
|
||||
template <typename T>
|
||||
class IsEnumFlag
|
||||
{
|
||||
template<typename U, typename = typename std::enable_if<!std::is_member_pointer<decltype(&EnumAsFlags<U>::max)>::value>::type>
|
||||
static std::true_type check(int);
|
||||
|
||||
template <typename> static std::false_type check(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(check<T>(0))::value;
|
||||
};
|
||||
|
||||
template<typename E>
|
||||
class Flags
|
||||
{
|
||||
static_assert(std::is_enum<E>::value, "Type must be an enumeration");
|
||||
static_assert(EnumAsFlags<E>::value, "Enum has not been enabled as flags by an EnumAsFlags specialization");
|
||||
static_assert(IsEnumFlag<E>::value, "Enum has not been enabled as flags by an EnumAsFlags specialization");
|
||||
|
||||
static constexpr std::size_t MaxValue = static_cast<std::size_t>(EnumAsFlags<E>::max);
|
||||
|
||||
using BitField16 = std::conditional_t<(MaxValue > 8), UInt16, UInt8>;
|
||||
using BitField32 = std::conditional_t<(MaxValue > 16), UInt32, BitField16>;
|
||||
|
||||
public:
|
||||
using BitField = typename std::conditional<(EnumAsFlags<E>::max > 32), UInt64, UInt32>::type;
|
||||
using BitField = std::conditional_t<(MaxValue > 32), UInt64, BitField32>;
|
||||
|
||||
constexpr Flags(BitField value = 0);
|
||||
constexpr Flags(E enumVal);
|
||||
|
||||
constexpr bool Test(const Flags& flags) const;
|
||||
|
||||
explicit constexpr operator bool() const;
|
||||
explicit constexpr operator BitField() const;
|
||||
template<typename T, typename = std::enable_if_t<std::is_integral<T>::value && sizeof(T) >= sizeof(BitField)>> explicit constexpr operator T() const;
|
||||
|
||||
constexpr Flags operator~() const;
|
||||
constexpr Flags operator&(const Flags& rhs) const;
|
||||
@@ -49,7 +67,7 @@ namespace Nz
|
||||
|
||||
static constexpr BitField GetFlagValue(E enumValue);
|
||||
|
||||
static constexpr BitField ValueMask = ((BitField(1) << (EnumAsFlags<E>::max + 1)) - 1);
|
||||
static constexpr BitField ValueMask = ((BitField(1) << (MaxValue + 1)) - 1);
|
||||
|
||||
private:
|
||||
BitField m_value;
|
||||
@@ -58,10 +76,10 @@ namespace Nz
|
||||
// Little hack to have them in both Nz and global scope
|
||||
namespace FlagsOperators
|
||||
{
|
||||
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<IsEnumFlag<E>::value, Flags<E>> operator~(E lhs);
|
||||
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator|(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator&(E lhs, E rhs);
|
||||
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator^(E lhs, E rhs);
|
||||
}
|
||||
|
||||
using namespace FlagsOperators;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Constructs a Flags object using an Enum value
|
||||
*
|
||||
* \param value enumVal
|
||||
* \param enumVal enumVal
|
||||
*
|
||||
* Setup a Flags object with only one flag active (corresponding to the enum value passed as argument).
|
||||
*/
|
||||
@@ -40,7 +40,17 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tests a Flags
|
||||
* \brief Tests if all flags from a Flags object are enabled
|
||||
* \return True if all tested flags are enabled.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr bool Flags<E>::Test(const Flags& flags) const
|
||||
{
|
||||
return (m_value & flags.m_value) == flags.m_value;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tests any flag
|
||||
* \return True if any flag is enabled.
|
||||
*
|
||||
* This will convert to a boolean value allowing to check if any flag is set.
|
||||
@@ -52,13 +62,14 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Converts to a bitfield
|
||||
* \return Enabled flags as a bitfield.
|
||||
* \brief Converts to an integer
|
||||
* \return Enabled flags as a integer
|
||||
*
|
||||
* This will convert to a bitfield value.
|
||||
* This will only works if the integer type is large enough to store all flags states
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr Flags<E>::operator BitField() const
|
||||
template<typename T, typename>
|
||||
constexpr Flags<E>::operator T() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
@@ -222,7 +233,7 @@ namespace Nz
|
||||
* 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)
|
||||
constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator~(E lhs)
|
||||
{
|
||||
return ~Flags<E>(lhs);
|
||||
}
|
||||
@@ -237,7 +248,7 @@ namespace Nz
|
||||
* 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)
|
||||
constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator|(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) | rhs;
|
||||
}
|
||||
@@ -253,7 +264,7 @@ namespace Nz
|
||||
* 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)
|
||||
constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator&(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) & rhs;
|
||||
}
|
||||
@@ -269,7 +280,7 @@ namespace Nz
|
||||
* 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)
|
||||
constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator^(E lhs, E rhs)
|
||||
{
|
||||
return Flags<E>(lhs) ^ rhs;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#define NAZARA_GUILLOTINEBINPACK_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -8,11 +8,8 @@
|
||||
#define NAZARA_LOG_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <memory>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
@@ -30,6 +27,8 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractLogger;
|
||||
|
||||
class NAZARA_CORE_API Log
|
||||
{
|
||||
friend class Core;
|
||||
|
||||
@@ -23,12 +23,15 @@
|
||||
#endif
|
||||
|
||||
#ifdef NAZARA_ALLOCA_SUPPORT
|
||||
#define NazaraStackAllocation(size) Nz::StackAllocation(NAZARA_ALLOCA(size))
|
||||
#define NazaraStackAllocation(T, size) Nz::StackArray<T>(static_cast<T*>(NAZARA_ALLOCA((size) * sizeof(T))), size)
|
||||
#define NazaraStackAllocationNoInit(T, size) Nz::StackArray<T>(static_cast<T*>(NAZARA_ALLOCA((size) * sizeof(T))), size, Nz::NoInitTag())
|
||||
#else
|
||||
#define NazaraStackAllocation(size) Nz::StackAllocation(Nz::OperatorNew(size))
|
||||
#define NazaraStackAllocation(T, size) Nz::StackArray<T>(static_cast<T*>(Nz::OperatorNew((size) * sizeof(T))), size)
|
||||
#define NazaraStackAllocationNoInit(T, size) Nz::StackArray<T>(static_cast<T*>(Nz::OperatorNew((size) * sizeof(T))), size, Nz::NoInitTag())
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -41,19 +44,70 @@ namespace Nz
|
||||
template<typename T>
|
||||
void PlacementDestroy(T* ptr);
|
||||
|
||||
class StackAllocation
|
||||
struct NoInitTag {};
|
||||
|
||||
template<typename T>
|
||||
class StackArray
|
||||
{
|
||||
public:
|
||||
explicit StackAllocation(void* stackMemory);
|
||||
~StackAllocation();
|
||||
using value_type = T;
|
||||
using const_iterator = const value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using const_reference = const value_type&;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using iterator = value_type*;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type&;
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using size_type = std::size_t;
|
||||
|
||||
void* GetPtr();
|
||||
StackArray(T* stackMemory, std::size_t size);
|
||||
StackArray(T* stackMemory, std::size_t size, NoInitTag);
|
||||
~StackArray();
|
||||
|
||||
operator void*();
|
||||
reference back();
|
||||
const_reference back() const;
|
||||
|
||||
iterator begin() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
T* data() noexcept;
|
||||
const T* data() const noexcept;
|
||||
|
||||
bool empty() const noexcept;
|
||||
|
||||
iterator end() noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
|
||||
void fill(const T& value);
|
||||
|
||||
reference front() noexcept;
|
||||
const_reference front() const noexcept;
|
||||
|
||||
size_type max_size() const noexcept;
|
||||
|
||||
reverse_iterator rbegin() noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
|
||||
reverse_iterator rend() noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
|
||||
size_type size() const noexcept;
|
||||
|
||||
reference operator[](size_type pos);
|
||||
const_reference operator[](size_type pos) const;
|
||||
|
||||
private:
|
||||
void* m_ptr;
|
||||
std::size_t m_size;
|
||||
T* m_ptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.inl>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
@@ -77,48 +79,184 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::StackAllocation
|
||||
* \brief Core class that represents a stack allocation
|
||||
* \class Nz::StackArray
|
||||
* \brief Core class that represents a stack-allocated (if alloca is present) array
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
StackArray<T>::StackArray(T* stackMemory, std::size_t size) :
|
||||
m_size(size),
|
||||
m_ptr(stackMemory)
|
||||
{
|
||||
for (std::size_t i = 0; i < m_size; ++i)
|
||||
PlacementNew(&m_ptr[i]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a StackAllocation object with a pointer to a memory allocated with NAZARA_ALLOCA or OperatorNew is alloca is not supported
|
||||
*
|
||||
* \param ptr Pointer to raw memory
|
||||
*/
|
||||
inline StackAllocation::StackAllocation(void* stackMemory) :
|
||||
template<typename T>
|
||||
StackArray<T>::StackArray(T* stackMemory, std::size_t size, NoInitTag) :
|
||||
m_size(size),
|
||||
m_ptr(stackMemory)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Destructs the object and release memory if necessary
|
||||
*/
|
||||
inline StackAllocation::~StackAllocation()
|
||||
template<typename T>
|
||||
StackArray<T>::~StackArray()
|
||||
{
|
||||
for (std::size_t i = 0; i < m_size; ++i)
|
||||
m_ptr[i].~T();
|
||||
|
||||
#ifndef NAZARA_ALLOCA_SUPPORT
|
||||
OperatorDelete(m_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Access the internal pointer
|
||||
* \return internal memory pointer
|
||||
*/
|
||||
inline void* StackAllocation::GetPtr()
|
||||
template<typename T>
|
||||
typename StackArray<T>::reference StackArray<T>::back()
|
||||
{
|
||||
assert(m_size != 0);
|
||||
return m_ptr[m_size - 1];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reference StackArray<T>::back() const
|
||||
{
|
||||
assert(m_size != 0);
|
||||
return m_ptr[m_size - 1];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::iterator StackArray<T>::begin() noexcept
|
||||
{
|
||||
return iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_iterator StackArray<T>::begin() const noexcept
|
||||
{
|
||||
return const_iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_iterator StackArray<T>::cbegin() const noexcept
|
||||
{
|
||||
return const_iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_iterator StackArray<T>::cend() const noexcept
|
||||
{
|
||||
return const_iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reverse_iterator StackArray<T>::crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reverse_iterator StackArray<T>::crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* StackArray<T>::data() noexcept
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Access the internal pointer
|
||||
* \return internal memory pointer
|
||||
*/
|
||||
inline StackAllocation::operator void*()
|
||||
template<typename T>
|
||||
const T* StackArray<T>::data() const noexcept
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool StackArray<T>::empty() const noexcept
|
||||
{
|
||||
return m_size == 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::iterator StackArray<T>::end() noexcept
|
||||
{
|
||||
return iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_iterator StackArray<T>::end() const noexcept
|
||||
{
|
||||
return const_iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void StackArray<T>::fill(const T& value)
|
||||
{
|
||||
std::fill(begin(), end(), value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::reference StackArray<T>::front() noexcept
|
||||
{
|
||||
return m_ptr[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reference StackArray<T>::front() const noexcept
|
||||
{
|
||||
return m_ptr[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::size_type StackArray<T>::max_size() const noexcept
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::reverse_iterator StackArray<T>::rbegin() noexcept
|
||||
{
|
||||
return reverse_iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reverse_iterator StackArray<T>::rbegin() const noexcept
|
||||
{
|
||||
return reverse_iterator(&m_ptr[m_size]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::reverse_iterator StackArray<T>::rend() noexcept
|
||||
{
|
||||
return reverse_iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reverse_iterator StackArray<T>::rend() const noexcept
|
||||
{
|
||||
return reverse_iterator(&m_ptr[0]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::size_type StackArray<T>::size() const noexcept
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::reference StackArray<T>::operator[](size_type pos)
|
||||
{
|
||||
assert(pos < m_size);
|
||||
return m_ptr[pos];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename StackArray<T>::const_reference StackArray<T>::operator[](size_type pos) const
|
||||
{
|
||||
assert(pos < m_size);
|
||||
return m_ptr[pos];
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#define NAZARA_MEMORYMANAGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
38
include/Nazara/Core/MovablePtr.hpp
Normal file
38
include/Nazara/Core/MovablePtr.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MOVABLE_PTR_HPP
|
||||
#define NAZARA_MOVABLE_PTR_HPP
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T>
|
||||
class MovablePtr
|
||||
{
|
||||
public:
|
||||
MovablePtr(T* value = nullptr);
|
||||
MovablePtr(const MovablePtr&) = default;
|
||||
MovablePtr(MovablePtr&& ptr) noexcept;
|
||||
~MovablePtr() = default;
|
||||
|
||||
T* Get() const;
|
||||
|
||||
T* operator->() const;
|
||||
|
||||
operator T*() const;
|
||||
|
||||
MovablePtr& operator=(T* value);
|
||||
MovablePtr& operator=(const MovablePtr&) = default;
|
||||
MovablePtr& operator=(MovablePtr&& ptr) noexcept;
|
||||
|
||||
private:
|
||||
T* m_value;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MovablePtr.inl>
|
||||
|
||||
#endif // NAZARA_MOVABLE_PTR_HPP
|
||||
61
include/Nazara/Core/MovablePtr.inl
Normal file
61
include/Nazara/Core/MovablePtr.inl
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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
|
||||
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::MovablePtr
|
||||
* \brief Wraps a raw (non-proprietary) to allows it to be moved implicitly
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
MovablePtr<T>::MovablePtr(T* value) :
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MovablePtr<T>::MovablePtr(MovablePtr&& ptr) noexcept :
|
||||
m_value(ptr.m_value)
|
||||
{
|
||||
ptr.m_value = nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T* MovablePtr<T>::Get() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* MovablePtr<T>::operator->() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MovablePtr<T>::operator T*() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline MovablePtr<T>& MovablePtr<T>::operator=(T* value)
|
||||
{
|
||||
m_value = value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
MovablePtr<T>& MovablePtr<T>::operator=(MovablePtr&& ptr) noexcept
|
||||
{
|
||||
std::swap(m_value, ptr.m_value);
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_MUTEX_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Nz
|
||||
public:
|
||||
Mutex();
|
||||
Mutex(const Mutex&) = delete;
|
||||
inline Mutex(Mutex&& mutex) noexcept;
|
||||
Mutex(Mutex&&) noexcept = default;
|
||||
~Mutex();
|
||||
|
||||
void Lock();
|
||||
@@ -28,10 +29,10 @@ namespace Nz
|
||||
void Unlock();
|
||||
|
||||
Mutex& operator=(const Mutex&) = delete;
|
||||
Mutex& operator=(Mutex&& mutex) noexcept;
|
||||
Mutex& operator=(Mutex&&) noexcept = default;
|
||||
|
||||
private:
|
||||
MutexImpl* m_impl;
|
||||
MovablePtr<MutexImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,6 @@ namespace Nz
|
||||
* \ingroup core
|
||||
* \class Nz::Mutex
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Mutex object by moving another one
|
||||
*/
|
||||
inline Mutex::Mutex(Mutex&& mutex) noexcept :
|
||||
m_impl(mutex.m_impl)
|
||||
{
|
||||
mutex.m_impl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -484,16 +484,17 @@ namespace Nz
|
||||
|
||||
namespace std
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Gives a hash representation of the object, specialisation of std
|
||||
* \return Hash of the ObjectRef
|
||||
*
|
||||
* \param object Object to hash
|
||||
*/
|
||||
template<typename T>
|
||||
struct hash<Nz::ObjectRef<T>>
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Gives a hash representation of the object, specialisation of std
|
||||
* \return Hash of the ObjectRef
|
||||
*
|
||||
* \param object Object to hash
|
||||
*/
|
||||
|
||||
size_t operator()(const Nz::ObjectRef<T>& object) const
|
||||
{
|
||||
hash<T*> h;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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/ParameterList.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace Nz
|
||||
*
|
||||
* \param size (Width, Depth)
|
||||
* \param subdivision Number of subdivision for the axis
|
||||
* \param planeInfo Information for the plane
|
||||
* \param plane Information for the plane
|
||||
* \param uvCoords Coordinates for texture
|
||||
*/
|
||||
inline Primitive Primitive::Plane(const Vector2f& size, const Vector2ui& subdivision, const Planef& plane, const Rectf& uvCoords)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED
|
||||
#include <Nazara/Core/ThreadSafety.hpp>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Nz
|
||||
public:
|
||||
Resource() = default;
|
||||
Resource(const Resource&) = default;
|
||||
Resource(Resource&&) = default;
|
||||
Resource(Resource&&) noexcept = default;
|
||||
virtual ~Resource();
|
||||
|
||||
const String& GetFilePath() const;
|
||||
@@ -25,7 +25,7 @@ namespace Nz
|
||||
void SetFilePath(const String& filePath);
|
||||
|
||||
Resource& operator=(const Resource&) = default;
|
||||
Resource& operator=(Resource&&) = default;
|
||||
Resource& operator=(Resource&&) noexcept = default;
|
||||
|
||||
private:
|
||||
String m_filePath;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_SEMAPHORE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace Nz
|
||||
public:
|
||||
Semaphore(unsigned int count);
|
||||
Semaphore(const Semaphore&) = delete;
|
||||
Semaphore(Semaphore&&) = delete; ///TODO
|
||||
Semaphore(Semaphore&&) noexcept = default;
|
||||
~Semaphore();
|
||||
|
||||
unsigned int GetCount() const;
|
||||
@@ -29,10 +30,10 @@ namespace Nz
|
||||
bool Wait(UInt32 timeout);
|
||||
|
||||
Semaphore& operator=(const Semaphore&) = delete;
|
||||
Semaphore& operator=(Semaphore&&) = delete; ///TODO
|
||||
Semaphore& operator=(Semaphore&&) noexcept = default;
|
||||
|
||||
private:
|
||||
SemaphoreImpl* m_impl;
|
||||
MovablePtr<SemaphoreImpl> m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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/SerializationContext.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Nz
|
||||
SparsePtr();
|
||||
SparsePtr(T* ptr);
|
||||
SparsePtr(VoidPtr ptr, int stride);
|
||||
SparsePtr(VoidPtr ptr, std::size_t stride);
|
||||
template<typename U> SparsePtr(const SparsePtr<U>& ptr);
|
||||
SparsePtr(const SparsePtr& ptr) = default;
|
||||
~SparsePtr() = default;
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// 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/SparsePtr.hpp>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -48,6 +51,22 @@ namespace Nz
|
||||
Reset(ptr, stride);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a SparsePtr object with a pointer and a step
|
||||
*
|
||||
* \param ptr Pointer to data
|
||||
* \param stride Step between two elements
|
||||
*
|
||||
* \remark This constructor only exists because std::size_t is a frequent type for constructing this object, but stride may not be higher than int max
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T>::SparsePtr(VoidPtr ptr, std::size_t stride)
|
||||
{
|
||||
assert(stride <= std::numeric_limits<int>::max());
|
||||
Reset(ptr, static_cast<int>(stride));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a SparsePtr object from another type of SparsePtr
|
||||
*
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include "Stream.hpp"
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/SerializationContext.hpp>
|
||||
#include <atomic>
|
||||
#include <cstdarg>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
@@ -19,6 +17,8 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct SerializationContext;
|
||||
|
||||
class NAZARA_CORE_API String
|
||||
{
|
||||
public:
|
||||
@@ -41,7 +41,7 @@ namespace Nz
|
||||
String(const char* string, std::size_t length);
|
||||
String(const std::string& string);
|
||||
String(const String& string) = default;
|
||||
String(String&& string) noexcept = default;
|
||||
inline String(String&& string) noexcept;
|
||||
~String() = default;
|
||||
|
||||
String& Append(char character);
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Constructs a String object with a shared string by move semantic
|
||||
*
|
||||
* \param sharedString Shared string to move into this
|
||||
*/
|
||||
inline Nz::String::String(String&& string) noexcept :
|
||||
m_sharedString(std::move(string.m_sharedString))
|
||||
{
|
||||
string.m_sharedString = GetEmptyString();
|
||||
}
|
||||
|
||||
inline String::String(std::shared_ptr<SharedString>&& sharedString) :
|
||||
m_sharedString(std::move(sharedString))
|
||||
@@ -121,7 +120,7 @@ namespace std
|
||||
const char* ptr = str.GetConstBuffer();
|
||||
|
||||
do
|
||||
h = ((h << 5) + h) + *ptr;
|
||||
h = ((h << 5) + h) + static_cast<size_t>(*ptr);
|
||||
while (*++ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace Nz
|
||||
class NAZARA_CORE_API StringStream
|
||||
{
|
||||
public:
|
||||
StringStream();
|
||||
StringStream(const String& str);
|
||||
StringStream() = default;
|
||||
StringStream(String str);
|
||||
StringStream(const StringStream&) = default;
|
||||
StringStream(StringStream&&) noexcept = default;
|
||||
|
||||
@@ -53,8 +53,7 @@ namespace Nz
|
||||
operator String() const;
|
||||
|
||||
private:
|
||||
std::vector<String> m_strings;
|
||||
std::size_t m_bufferSize;
|
||||
String m_result;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class String;
|
||||
class ThreadImpl;
|
||||
|
||||
class NAZARA_CORE_API Thread
|
||||
@@ -25,7 +27,7 @@ namespace Nz
|
||||
template<typename F, typename... Args> Thread(F function, Args&&... args);
|
||||
template<typename C> Thread(void (C::*function)(), C* object);
|
||||
Thread(const Thread&) = delete;
|
||||
Thread(Thread&& other) noexcept;
|
||||
Thread(Thread&& other) noexcept = default;
|
||||
~Thread();
|
||||
|
||||
void Detach();
|
||||
@@ -35,7 +37,7 @@ namespace Nz
|
||||
void SetName(const String& name);
|
||||
|
||||
Thread& operator=(const Thread&) = delete;
|
||||
Thread& operator=(Thread&& thread);
|
||||
Thread& operator=(Thread&& thread) noexcept = default;
|
||||
|
||||
static unsigned int HardwareConcurrency();
|
||||
static void SetCurrentThreadName(const String& name);
|
||||
@@ -44,7 +46,7 @@ namespace Nz
|
||||
private:
|
||||
void CreateImpl(Functor* functor);
|
||||
|
||||
ThreadImpl* m_impl;
|
||||
MovablePtr<ThreadImpl> m_impl;
|
||||
};
|
||||
|
||||
class NAZARA_CORE_API Thread::Id
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
@@ -23,6 +21,7 @@ namespace Nz
|
||||
class Material;
|
||||
class Texture;
|
||||
struct MeshData;
|
||||
struct VertexStruct_XYZ_Color_UV;
|
||||
|
||||
class NAZARA_GRAPHICS_API AbstractRenderQueue
|
||||
{
|
||||
|
||||
@@ -8,16 +8,13 @@
|
||||
#define NAZARA_ABSTRACTRENDERTECHNIQUE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/SceneData.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
class Background;
|
||||
class AbstractRenderQueue;
|
||||
struct SceneData;
|
||||
|
||||
class NAZARA_GRAPHICS_API AbstractRenderTechnique
|
||||
|
||||
@@ -32,17 +32,18 @@ namespace Nz
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
|
||||
inline const Color& GetColor() const;
|
||||
inline const MaterialRef& GetMaterial() const;
|
||||
inline float GetRotation() const;
|
||||
inline const Vector2f& GetSize() const;
|
||||
|
||||
inline void SetColor(const Color& color);
|
||||
inline void SetDefaultMaterial();
|
||||
inline void SetMaterial(MaterialRef material, bool resizeBillboard = true);
|
||||
inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeBillboard = true);
|
||||
inline void SetRotation(float rotation);
|
||||
inline void SetSize(const Vector2f& size);
|
||||
inline void SetSize(float sizeX, float sizeY);
|
||||
inline void SetTexture(TextureRef texture, bool resizeBillboard = true);
|
||||
inline void SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeBillboard = true);
|
||||
|
||||
inline Billboard& operator=(const Billboard& billboard);
|
||||
Billboard& operator=(Billboard&&) = delete;
|
||||
@@ -53,7 +54,6 @@ namespace Nz
|
||||
void MakeBoundingVolume() const override;
|
||||
|
||||
Color m_color;
|
||||
MaterialRef m_material;
|
||||
Vector2f m_sinCos;
|
||||
Vector2f m_size;
|
||||
float m_rotation;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/Billboard.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
@@ -13,6 +14,8 @@ namespace Nz
|
||||
|
||||
inline Billboard::Billboard()
|
||||
{
|
||||
ResetMaterials(1);
|
||||
|
||||
SetColor(Color::White);
|
||||
SetDefaultMaterial();
|
||||
SetRotation(0.f);
|
||||
@@ -27,6 +30,8 @@ namespace Nz
|
||||
|
||||
inline Billboard::Billboard(MaterialRef material)
|
||||
{
|
||||
ResetMaterials(1);
|
||||
|
||||
SetColor(Color::White);
|
||||
SetMaterial(std::move(material), true);
|
||||
SetRotation(0.f);
|
||||
@@ -41,6 +46,8 @@ namespace Nz
|
||||
|
||||
inline Billboard::Billboard(Texture* texture)
|
||||
{
|
||||
ResetMaterials(1);
|
||||
|
||||
SetColor(Color::White);
|
||||
SetRotation(0.f);
|
||||
SetSize(64.f, 64.f);
|
||||
@@ -56,7 +63,6 @@ namespace Nz
|
||||
inline Billboard::Billboard(const Billboard& billboard) :
|
||||
InstancedRenderable(billboard),
|
||||
m_color(billboard.m_color),
|
||||
m_material(billboard.m_material),
|
||||
m_sinCos(billboard.m_sinCos),
|
||||
m_size(billboard.m_size),
|
||||
m_rotation(billboard.m_rotation)
|
||||
@@ -73,16 +79,6 @@ namespace Nz
|
||||
return m_color;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material of the billboard
|
||||
* \return Current material
|
||||
*/
|
||||
|
||||
inline const MaterialRef& Billboard::GetMaterial() const
|
||||
{
|
||||
return m_material;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the rotation of the billboard
|
||||
* \return Current rotation
|
||||
@@ -132,15 +128,30 @@ namespace Nz
|
||||
* \param material Material for the billboard
|
||||
* \param resizeBillboard Should billboard be resized to the material size (diffuse map)
|
||||
*/
|
||||
|
||||
inline void Billboard::SetMaterial(MaterialRef material, bool resizeBillboard)
|
||||
{
|
||||
m_material = std::move(material);
|
||||
if (m_material && resizeBillboard)
|
||||
SetMaterial(GetSkin(), std::move(material), resizeBillboard);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material of the billboard
|
||||
*
|
||||
* \param skinIndex Skin index to change
|
||||
* \param material Material for the billboard
|
||||
* \param resizeBillboard Should billboard be resized to the material size (diffuse map)
|
||||
*/
|
||||
inline void Billboard::SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeBillboard)
|
||||
{
|
||||
InstancedRenderable::SetMaterial(skinIndex, 0, std::move(material));
|
||||
|
||||
if (resizeBillboard)
|
||||
{
|
||||
Texture* diffuseMap = m_material->GetDiffuseMap();
|
||||
if (diffuseMap && diffuseMap->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(diffuseMap->GetSize())));
|
||||
if (const MaterialRef& newMat = GetMaterial())
|
||||
{
|
||||
const TextureRef& diffuseMap = newMat->GetDiffuseMap();
|
||||
if (diffuseMap && diffuseMap->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(diffuseMap->GetSize())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,18 +199,36 @@ namespace Nz
|
||||
* \param texture Texture for the billboard
|
||||
* \param resizeBillboard Should billboard be resized to the texture size
|
||||
*/
|
||||
|
||||
inline void Billboard::SetTexture(TextureRef texture, bool resizeBillboard)
|
||||
{
|
||||
if (!m_material)
|
||||
SetDefaultMaterial();
|
||||
else if (m_material->GetReferenceCount() > 1)
|
||||
m_material = Material::New(*m_material); // Copie
|
||||
SetTexture(GetSkin(), std::move(texture), resizeBillboard);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the texture of the billboard for a specific index
|
||||
*
|
||||
* This function changes the diffuse map of the material associated with the specified skin index
|
||||
*
|
||||
* \param skinIndex Skin index to change
|
||||
* \param texture Texture for the billboard
|
||||
* \param resizeBillboard Should billboard be resized to the texture size
|
||||
*/
|
||||
inline void Billboard::SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeBillboard)
|
||||
{
|
||||
if (resizeBillboard && texture && texture->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(texture->GetSize())));
|
||||
|
||||
m_material->SetDiffuseMap(std::move(texture));
|
||||
const MaterialRef& material = GetMaterial(skinIndex);
|
||||
|
||||
if (material->GetReferenceCount() > 1)
|
||||
{
|
||||
MaterialRef newMat = Material::New(*material); // Copy
|
||||
newMat->SetDiffuseMap(std::move(texture));
|
||||
|
||||
SetMaterial(skinIndex, std::move(newMat));
|
||||
}
|
||||
else
|
||||
material->SetDiffuseMap(std::move(texture));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -214,7 +243,6 @@ namespace Nz
|
||||
InstancedRenderable::operator=(billboard);
|
||||
|
||||
m_color = billboard.m_color;
|
||||
m_material = billboard.m_material;
|
||||
m_size = billboard.m_size;
|
||||
|
||||
InvalidateBoundingVolume();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <type_traits>
|
||||
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
|
||||
|
||||
// We fore the value of MANAGE_MEMORY in debug
|
||||
// We force the value of MANAGE_MEMORY in debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY
|
||||
#undef NAZARA_GRAPHICS_MANAGE_MEMORY
|
||||
#define NAZARA_GRAPHICS_MANAGE_MEMORY 0
|
||||
|
||||
@@ -9,18 +9,14 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/SceneData.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
class DeferredRenderTechnique;
|
||||
class DeferredRenderQueue;
|
||||
class RenderBuffer;
|
||||
struct SceneData;
|
||||
class RenderTexture;
|
||||
class Scene;
|
||||
class Texture;
|
||||
|
||||
class NAZARA_GRAPHICS_API DeferredRenderPass
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
@@ -17,7 +16,6 @@
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -9,21 +9,18 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class DeferredRenderPass;
|
||||
|
||||
class NAZARA_GRAPHICS_API DeferredRenderTechnique : public AbstractRenderTechnique
|
||||
{
|
||||
friend class Graphics;
|
||||
|
||||
@@ -8,15 +8,9 @@
|
||||
#define NAZARA_DEPTHRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
|
||||
@@ -122,6 +122,15 @@ namespace Nz
|
||||
RenderTechniqueType_Max = RenderTechniqueType_User
|
||||
};
|
||||
|
||||
enum ReflectionMode
|
||||
{
|
||||
ReflectionMode_RealTime,
|
||||
ReflectionMode_Probe,
|
||||
ReflectionMode_Skybox,
|
||||
|
||||
ReflectionMode_Max = ReflectionMode_Skybox
|
||||
};
|
||||
|
||||
enum SceneNodeType
|
||||
{
|
||||
SceneNodeType_Light, // Light
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace Nz
|
||||
|
||||
// Other uniforms
|
||||
int eyePosition;
|
||||
int reflectionMap;
|
||||
int sceneAmbient;
|
||||
int textureOverlay;
|
||||
};
|
||||
@@ -91,6 +92,8 @@ namespace Nz
|
||||
unsigned int m_maxLightPassPerObject;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static Texture s_dummyReflection;
|
||||
static TextureSampler s_reflectionSampler;
|
||||
static TextureSampler s_shadowSampler;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
static VertexDeclaration s_billboardInstanceDeclaration;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_GRAPHICS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#ifndef NAZARA_INSTANCEDRENDERABLE_HPP
|
||||
#define NAZARA_INSTANCEDRENDERABLE_HPP
|
||||
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
@@ -44,7 +44,18 @@ namespace Nz
|
||||
inline void EnsureBoundingVolumeUpdated() const;
|
||||
|
||||
virtual const BoundingVolumef& GetBoundingVolume() const;
|
||||
|
||||
inline const MaterialRef& GetMaterial(std::size_t matIndex = 0) const;
|
||||
inline const MaterialRef& GetMaterial(std::size_t skinIndex, std::size_t matIndex) const;
|
||||
inline std::size_t GetMaterialCount() const;
|
||||
inline std::size_t GetSkin() const;
|
||||
inline std::size_t GetSkinCount() const;
|
||||
|
||||
virtual void InvalidateData(InstanceData* instanceData, UInt32 flags) const;
|
||||
|
||||
inline void SetSkin(std::size_t skinIndex);
|
||||
inline void SetSkinCount(std::size_t skinCount);
|
||||
|
||||
virtual void UpdateBoundingVolume(InstanceData* instanceData) const;
|
||||
virtual void UpdateData(InstanceData* instanceData) const;
|
||||
|
||||
@@ -54,7 +65,10 @@ namespace Nz
|
||||
// Signals:
|
||||
NazaraSignal(OnInstancedRenderableInvalidateBoundingVolume, const InstancedRenderable* /*instancedRenderable*/);
|
||||
NazaraSignal(OnInstancedRenderableInvalidateData, const InstancedRenderable* /*instancedRenderable*/, UInt32 /*flags*/);
|
||||
NazaraSignal(OnInstancedRenderableInvalidateMaterial, const InstancedRenderable* /*instancedRenderable*/, std::size_t /*skinIndex*/, std::size_t /*matIndex*/, const MaterialRef& /*newMat*/);
|
||||
NazaraSignal(OnInstancedRenderableRelease, const InstancedRenderable* /*instancedRenderable*/);
|
||||
NazaraSignal(OnInstancedRenderableResetMaterials, const InstancedRenderable* /*instancedRenderable*/, std::size_t /*newMaterialCount*/);
|
||||
NazaraSignal(OnInstancedRenderableSkinChange, const InstancedRenderable* /*instancedRenderable*/, std::size_t /*newSkinIndex*/);
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
@@ -89,14 +103,23 @@ namespace Nz
|
||||
protected:
|
||||
inline void InvalidateBoundingVolume();
|
||||
inline void InvalidateInstanceData(UInt32 flags);
|
||||
|
||||
|
||||
virtual void MakeBoundingVolume() const = 0;
|
||||
|
||||
inline void ResetMaterials(std::size_t matCount, std::size_t skinCount = 1);
|
||||
|
||||
inline void SetMaterial(std::size_t matIndex, MaterialRef material);
|
||||
inline void SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material);
|
||||
|
||||
mutable BoundingVolumef m_boundingVolume;
|
||||
|
||||
private:
|
||||
inline void UpdateBoundingVolume() const;
|
||||
|
||||
|
||||
std::size_t m_matCount;
|
||||
std::size_t m_skin;
|
||||
std::size_t m_skinCount;
|
||||
std::vector<MaterialRef> m_materials;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
|
||||
static InstancedRenderableLibrary::LibraryMap s_library;
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
@@ -20,6 +23,10 @@ namespace Nz
|
||||
inline InstancedRenderable::InstancedRenderable(const InstancedRenderable& renderable) :
|
||||
RefCounted(),
|
||||
m_boundingVolume(renderable.m_boundingVolume),
|
||||
m_matCount(renderable.m_matCount),
|
||||
m_skin(renderable.m_skin),
|
||||
m_skinCount(renderable.m_skinCount),
|
||||
m_materials(renderable.m_materials),
|
||||
m_boundingVolumeUpdated(renderable.m_boundingVolumeUpdated)
|
||||
{
|
||||
}
|
||||
@@ -34,6 +41,116 @@ namespace Nz
|
||||
UpdateBoundingVolume();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets one of the material used by the object.
|
||||
* \return A reference to the material.
|
||||
*
|
||||
* This function returns the active material at the specified index, depending on the current active skin.
|
||||
*
|
||||
* \param matIndex Material index to query
|
||||
*
|
||||
* \see GetSkin, GetMaterialCount, SetSkin
|
||||
*/
|
||||
inline const MaterialRef& InstancedRenderable::GetMaterial(std::size_t matIndex) const
|
||||
{
|
||||
return GetMaterial(m_skin, matIndex);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets one of the material used by the object, independently from the active skin.
|
||||
* \return A reference to the material.
|
||||
*
|
||||
* This function returns the active material at the specified index and the specified skin index.
|
||||
* This function is the only way to query a material independently from the active skin.
|
||||
*
|
||||
* \param skinIndex Skin index to query
|
||||
* \param matIndex Material index to query
|
||||
*
|
||||
* \see GetSkinCount, GetMaterialCount, SetSkin
|
||||
*/
|
||||
inline const MaterialRef& InstancedRenderable::GetMaterial(std::size_t skinIndex, std::size_t matIndex) const
|
||||
{
|
||||
NazaraAssert(skinIndex < m_skinCount, "Skin index out of bounds");
|
||||
NazaraAssert(matIndex < m_materials.size(), "Material index out of bounds");
|
||||
|
||||
return m_materials[m_matCount * skinIndex + matIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the number of material per skin.
|
||||
* \return The current material count per skin
|
||||
*
|
||||
* This function returns how many different materials entries exists per skin
|
||||
* and is independent from the number of skin.
|
||||
*/
|
||||
inline std::size_t InstancedRenderable::GetMaterialCount() const
|
||||
{
|
||||
return m_matCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the current active skin index
|
||||
* \return Current skin index
|
||||
*
|
||||
* \see SetSkin
|
||||
*/
|
||||
inline std::size_t InstancedRenderable::GetSkin() const
|
||||
{
|
||||
return m_skin;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the number of skins this object has
|
||||
* \return Skin count
|
||||
*
|
||||
* \see GetSkin, SetSkinCount
|
||||
*/
|
||||
inline std::size_t InstancedRenderable::GetSkinCount() const
|
||||
{
|
||||
return m_skinCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes the active skin
|
||||
*
|
||||
* Each InstancedRenderable has the possibility to have multiples skins, which are sets of materials.
|
||||
* Using this function allows you to have an object reference multiple materials, while using only some of thems (depending on the type of the object, see GetMaterialCount).
|
||||
*
|
||||
* \param skinIndex Skin index to change to
|
||||
*
|
||||
* \see SetSkinCount
|
||||
*/
|
||||
inline void InstancedRenderable::SetSkin(std::size_t skinIndex)
|
||||
{
|
||||
NazaraAssert(skinIndex < m_skinCount, "Skin index out of bounds");
|
||||
|
||||
if (m_skin != skinIndex)
|
||||
{
|
||||
OnInstancedRenderableSkinChange(this, skinIndex);
|
||||
|
||||
m_skin = skinIndex;
|
||||
|
||||
// Force render queue invalidation
|
||||
InvalidateInstanceData(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes the maximum skin count of the object
|
||||
*
|
||||
* This functions allows the object to store up to skinCount skins, which can then be switched to using SetSkin.
|
||||
* Please note that the possibly new skins will be set to the default material, which should not be changed.
|
||||
*
|
||||
* \param skinCount Skin index to change to
|
||||
*
|
||||
* \see SetSkin
|
||||
*/
|
||||
inline void InstancedRenderable::SetSkinCount(std::size_t skinCount)
|
||||
{
|
||||
m_materials.resize(m_matCount * skinCount, Material::GetDefault());
|
||||
m_skinCount = skinCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the bounding volume
|
||||
*/
|
||||
@@ -56,6 +173,79 @@ namespace Nz
|
||||
OnInstancedRenderableInvalidateData(this, flags);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets the materials, material count and skin count
|
||||
*
|
||||
* This function clears the materials in use by the InstancedRenderable and resets its material count per skin along with its skin count.
|
||||
* This is the only way of setting the material count per skin and should be called at least by the constructor of the derived class.
|
||||
* Please note that all materials will be set to the default material, which should not be changed.
|
||||
*
|
||||
* This function also resets the current skin to the first one.
|
||||
*
|
||||
* \param matCount The new material count per skin value, must be at least 1
|
||||
* \param skinCount The new skin count value
|
||||
*
|
||||
* \see GetMaterial, GetMaterialCount, GetSkinCount, SetSkinCount
|
||||
*/
|
||||
inline void InstancedRenderable::ResetMaterials(std::size_t matCount, std::size_t skinCount)
|
||||
{
|
||||
NazaraAssert(skinCount != 0, "Invalid skin count (cannot be zero)");
|
||||
|
||||
OnInstancedRenderableResetMaterials(this, matCount);
|
||||
|
||||
m_materials.clear();
|
||||
m_materials.resize(matCount * skinCount, Material::GetDefault());
|
||||
|
||||
m_matCount = matCount;
|
||||
m_skinCount = skinCount;
|
||||
m_skin = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes the material used at the specified index by another one
|
||||
*
|
||||
* This function changes the active material at the specified index, depending on the current active skin, to the one passed as parameter.
|
||||
*
|
||||
* \param matIndex Material index
|
||||
* \param material New material, cannot be null
|
||||
*
|
||||
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
|
||||
*
|
||||
* \see SetMaterial
|
||||
*/
|
||||
inline void InstancedRenderable::SetMaterial(std::size_t matIndex, MaterialRef material)
|
||||
{
|
||||
SetMaterial(m_skin, matIndex, std::move(material));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes the material used at the specified index by another one, independently from the active skin.
|
||||
*
|
||||
* This function changes the active material at the specified index and for the specified skin index, to the one passed as parameter.
|
||||
*
|
||||
* \param skinIndex Skin index
|
||||
* \param matIndex Material index
|
||||
* \param material New material, cannot be null
|
||||
*
|
||||
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
|
||||
*
|
||||
* \see SetMaterial
|
||||
*/
|
||||
inline void InstancedRenderable::SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
|
||||
{
|
||||
NazaraAssert(skinIndex < m_skinCount, "Skin index out of bounds");
|
||||
NazaraAssert(matIndex < m_materials.size(), "Material index out of bounds");
|
||||
NazaraAssert(material.IsValid(), "Material must be valid");
|
||||
|
||||
MaterialRef& matEntry = m_materials[m_matCount * skinIndex + matIndex];
|
||||
if (matEntry != material)
|
||||
{
|
||||
OnInstancedRenderableInvalidateMaterial(this, skinIndex, matIndex, material);
|
||||
|
||||
matEntry = std::move(material);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the current instanced renderable with the content of the other one
|
||||
* \return A reference to this
|
||||
@@ -67,6 +257,10 @@ namespace Nz
|
||||
{
|
||||
m_boundingVolume = renderable.m_boundingVolume;
|
||||
m_boundingVolumeUpdated = renderable.m_boundingVolumeUpdated;
|
||||
m_matCount = renderable.m_matCount;
|
||||
m_materials = renderable.m_materials;
|
||||
m_skin = renderable.m_skin;
|
||||
m_skinCount = renderable.m_skinCount;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -82,3 +276,5 @@ namespace Nz
|
||||
m_boundingVolumeUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
@@ -11,14 +11,10 @@
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/Renderable.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Light;
|
||||
struct LightUniforms;
|
||||
|
||||
class NAZARA_GRAPHICS_API Light : public Renderable
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -265,7 +265,8 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Sets the inner angle in spot light
|
||||
* \return innerAngle Inner angle
|
||||
*
|
||||
* \param innerAngle Inner angle
|
||||
*/
|
||||
|
||||
inline void Light::SetInnerAngle(float innerAngle)
|
||||
@@ -289,7 +290,8 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Sets the outer angle in spot light
|
||||
* \return outerAngle Outer angle
|
||||
*
|
||||
* \param outerAngle Outer angle
|
||||
*
|
||||
* \remark Invalidates the bounding volume
|
||||
*/
|
||||
@@ -305,7 +307,8 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Sets the radius of the light
|
||||
* \return radius Light radius
|
||||
*
|
||||
* \param radius Light radius
|
||||
*
|
||||
* \remark Invalidates the bounding volume
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <Nazara/Utility/MaterialData.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -79,6 +78,7 @@ namespace Nz
|
||||
inline void EnableDepthSorting(bool depthSorting);
|
||||
inline void EnableDepthWrite(bool depthWrite);
|
||||
inline void EnableFaceCulling(bool faceCulling);
|
||||
inline void EnableReflectionMapping(bool reflection);
|
||||
inline void EnableScissorTest(bool scissorTest);
|
||||
inline void EnableShadowCasting(bool castShadows);
|
||||
inline void EnableShadowReceive(bool receiveShadows);
|
||||
@@ -105,6 +105,7 @@ namespace Nz
|
||||
inline const MaterialPipeline* GetPipeline() const;
|
||||
inline const MaterialPipelineInfo& GetPipelineInfo() const;
|
||||
inline float GetPointSize() const;
|
||||
inline ReflectionMode GetReflectionMode() const;
|
||||
inline const UberShader* GetShader() const;
|
||||
inline float GetShininess() const;
|
||||
inline Color GetSpecularColor() const;
|
||||
@@ -128,6 +129,7 @@ namespace Nz
|
||||
inline bool IsDepthSortingEnabled() const;
|
||||
inline bool IsDepthWriteEnabled() const;
|
||||
inline bool IsFaceCullingEnabled() const;
|
||||
inline bool IsReflectionMappingEnabled() const;
|
||||
inline bool IsScissorTestEnabled() const;
|
||||
inline bool IsStencilTestEnabled() const;
|
||||
inline bool IsShadowCastingEnabled() const;
|
||||
@@ -162,6 +164,7 @@ namespace Nz
|
||||
inline bool SetNormalMap(const String& textureName);
|
||||
inline void SetNormalMap(TextureRef textureName);
|
||||
inline void SetPointSize(float pointSize);
|
||||
inline void SetReflectionMode(ReflectionMode reflectionMode);
|
||||
inline void SetShader(UberShaderConstRef uberShader);
|
||||
inline bool SetShader(const String& uberShaderName);
|
||||
inline void SetShininess(float shininess);
|
||||
@@ -178,6 +181,7 @@ namespace Nz
|
||||
template<typename... Args> static MaterialRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnMaterialReflectionModeChange, const Material* /*material*/, ReflectionMode /*newReflectionMode*/);
|
||||
NazaraSignal(OnMaterialRelease, const Material* /*material*/);
|
||||
NazaraSignal(OnMaterialReset, const Material* /*material*/);
|
||||
|
||||
@@ -195,6 +199,7 @@ namespace Nz
|
||||
MaterialRef m_depthMaterial; //< Materialception
|
||||
mutable const MaterialPipeline* m_pipeline;
|
||||
MaterialPipelineInfo m_pipelineInfo;
|
||||
ReflectionMode m_reflectionMode;
|
||||
TextureSampler m_diffuseSampler;
|
||||
TextureSampler m_specularSampler;
|
||||
TextureRef m_alphaMap;
|
||||
@@ -207,6 +212,7 @@ namespace Nz
|
||||
bool m_shadowCastingEnabled;
|
||||
float m_alphaThreshold;
|
||||
float m_shininess;
|
||||
unsigned int m_reflectionSize;
|
||||
|
||||
static std::array<int, TextureMap_Max + 1> s_textureUnits;
|
||||
static MaterialLibrary::LibraryMap s_library;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Enable/Disable alpha test for this material
|
||||
*
|
||||
* When enabled, all objects using this material will be rendered using alpha testing,
|
||||
* When enabled, all objects using this material will be rendered using alpha testing,
|
||||
* rejecting pixels if their alpha component is under a defined threshold.
|
||||
* This allows some kind of transparency with a much cheaper cost as it doesn't prevent any optimization (as deferred rendering or batching).
|
||||
*
|
||||
@@ -252,7 +252,7 @@ namespace Nz
|
||||
* When enabled, and if depth buffer is enabled and present, all fragments generated with this material will write
|
||||
* to the depth buffer if they pass depth test.
|
||||
*
|
||||
* This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but
|
||||
* This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but
|
||||
* not depth writing (which could make other translucent fragments to fail depth test)
|
||||
*
|
||||
* \param depthBuffer Defines if this material will use depth write
|
||||
@@ -291,6 +291,31 @@ namespace Nz
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable reflection mapping for this material
|
||||
*
|
||||
* When enabled, the material will render reflections from the object environment according to the reflection mode.
|
||||
* Whether or not this is expensive depends of the reflection mode and size.
|
||||
*
|
||||
* Please note this is only a hint for the render technique, and reflections can be forcefully enabled or disabled depending on the material shader.
|
||||
*
|
||||
* Use SetReflectionMode and SetReflectionSize to control reflection quality.
|
||||
*
|
||||
* \param reflection Defines if this material should use reflection mapping
|
||||
*
|
||||
* \remark May invalidates the pipeline
|
||||
*
|
||||
* \see IsReflectionMappingEnabled
|
||||
* \see SetReflectionMode
|
||||
* \see SetReflectionSize
|
||||
*/
|
||||
inline void Material::EnableReflectionMapping(bool reflection)
|
||||
{
|
||||
m_pipelineInfo.reflectionMapping = reflection;
|
||||
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable scissor test for this material
|
||||
*
|
||||
@@ -593,6 +618,18 @@ namespace Nz
|
||||
return m_pipelineInfo.pointSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the reflection mode of the material
|
||||
*
|
||||
* \return Current reflection mode
|
||||
*
|
||||
* \see SetReflectionMode
|
||||
*/
|
||||
inline ReflectionMode Material::GetReflectionMode() const
|
||||
{
|
||||
return m_reflectionMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the über-shader used by this material
|
||||
* \return Constant pointer to the über-shader used
|
||||
@@ -782,6 +819,17 @@ namespace Nz
|
||||
return m_pipelineInfo.faceCulling;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has reflection mapping enabled
|
||||
* \return true If it is the case
|
||||
*
|
||||
* \see EnableReflectionMapping
|
||||
*/
|
||||
inline bool Material::IsReflectionMappingEnabled() const
|
||||
{
|
||||
return m_pipelineInfo.reflectionMapping;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has scissor test enabled
|
||||
* \return true If it is the case
|
||||
@@ -1207,6 +1255,34 @@ namespace Nz
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes reflection mode of the material
|
||||
*
|
||||
* When reflections are enabled, the material will render reflections from the object environment according to the reflection mode.
|
||||
* This function does change the reflection mode used by the material.
|
||||
*
|
||||
* Skyboxes reflections are the cheapest but are static and thus can't reflect other objects.
|
||||
* Probes reflections are cheap, depending on probes reflection mode, but require regular probe finding from objects using it.
|
||||
* Real-time reflections are expensive but provide the most accurate reflection map (and can reflect other objects around).
|
||||
*
|
||||
* \param reflectionMode The new reflection mode this material should use
|
||||
*
|
||||
* \remark May invalidates the pipeline
|
||||
*
|
||||
* \see EnableReflectionMapping
|
||||
* \see IsReflectionMappingEnabled
|
||||
* \see SetReflectionSize
|
||||
*/
|
||||
inline void Material::SetReflectionMode(ReflectionMode reflectionMode)
|
||||
{
|
||||
if (m_reflectionMode != reflectionMode)
|
||||
{
|
||||
OnMaterialReflectionModeChange(this, reflectionMode);
|
||||
|
||||
m_reflectionMode = reflectionMode;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the shader with a constant reference to a ubershader
|
||||
*
|
||||
@@ -1389,4 +1465,3 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
#include "Material.hpp"
|
||||
|
||||
@@ -10,25 +10,24 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct MaterialPipelineInfo : RenderStates
|
||||
{
|
||||
bool alphaTest = false;
|
||||
bool depthSorting = false;
|
||||
bool hasAlphaMap = false;
|
||||
bool hasDiffuseMap = false;
|
||||
bool hasEmissiveMap = false;
|
||||
bool hasHeightMap = false;
|
||||
bool hasNormalMap = false;
|
||||
bool hasSpecularMap = false;
|
||||
bool shadowReceive = true;
|
||||
bool alphaTest = false;
|
||||
bool depthSorting = false;
|
||||
bool hasAlphaMap = false;
|
||||
bool hasDiffuseMap = false;
|
||||
bool hasEmissiveMap = false;
|
||||
bool hasHeightMap = false;
|
||||
bool hasNormalMap = false;
|
||||
bool hasSpecularMap = false;
|
||||
bool reflectionMapping = false;
|
||||
bool shadowReceive = true;
|
||||
|
||||
UberShaderConstRef uberShader;
|
||||
};
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
#include <functional>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
@@ -72,6 +71,7 @@ namespace Nz
|
||||
NazaraPipelineBoolMember(hasHeightMap);
|
||||
NazaraPipelineBoolMember(hasNormalMap);
|
||||
NazaraPipelineBoolMember(hasSpecularMap);
|
||||
NazaraPipelineBoolMember(reflectionMapping);
|
||||
NazaraPipelineBoolMember(shadowReceive);
|
||||
|
||||
NazaraPipelineMember(uberShader);
|
||||
@@ -127,6 +127,7 @@ namespace std
|
||||
NazaraPipelineBoolMember(hasHeightMap);
|
||||
NazaraPipelineBoolMember(hasNormalMap);
|
||||
NazaraPipelineBoolMember(hasSpecularMap);
|
||||
NazaraPipelineBoolMember(reflectionMapping);
|
||||
NazaraPipelineBoolMember(shadowReceive);
|
||||
|
||||
NazaraPipelineMember(uberShader);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Nz
|
||||
friend ModelLoader;
|
||||
|
||||
public:
|
||||
Model();
|
||||
inline Model();
|
||||
Model(const Model& model) = default;
|
||||
Model(Model&& model) = default;
|
||||
virtual ~Model();
|
||||
@@ -47,13 +47,9 @@ namespace Nz
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0);
|
||||
|
||||
Material* GetMaterial(const String& subMeshName) const;
|
||||
Material* GetMaterial(unsigned int matIndex) const;
|
||||
Material* GetMaterial(unsigned int skinIndex, const String& subMeshName) const;
|
||||
Material* GetMaterial(unsigned int skinIndex, unsigned int matIndex) const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
unsigned int GetSkin() const;
|
||||
unsigned int GetSkinCount() const;
|
||||
using InstancedRenderable::GetMaterial;
|
||||
const MaterialRef& GetMaterial(const String& subMeshName) const;
|
||||
const MaterialRef& GetMaterial(std::size_t skinIndex, const String& subMeshName) const;
|
||||
Mesh* GetMesh() const;
|
||||
|
||||
virtual bool IsAnimated() const;
|
||||
@@ -62,15 +58,11 @@ namespace Nz
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params = ModelParameters());
|
||||
bool LoadFromStream(Stream& stream, const ModelParameters& params = ModelParameters());
|
||||
|
||||
void Reset();
|
||||
using InstancedRenderable::SetMaterial;
|
||||
bool SetMaterial(const String& subMeshName, MaterialRef material);
|
||||
bool SetMaterial(std::size_t skinIndex, const String& subMeshName, MaterialRef material);
|
||||
|
||||
bool SetMaterial(const String& subMeshName, Material* material);
|
||||
void SetMaterial(unsigned int matIndex, Material* material);
|
||||
bool SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material);
|
||||
void SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material);
|
||||
virtual void SetMesh(Mesh* mesh);
|
||||
void SetSkin(unsigned int skin);
|
||||
void SetSkinCount(unsigned int skinCount);
|
||||
|
||||
Model& operator=(const Model& node) = default;
|
||||
Model& operator=(Model&& node) = default;
|
||||
@@ -80,11 +72,7 @@ namespace Nz
|
||||
protected:
|
||||
void MakeBoundingVolume() const override;
|
||||
|
||||
std::vector<MaterialRef> m_materials;
|
||||
MeshRef m_mesh;
|
||||
unsigned int m_matCount;
|
||||
unsigned int m_skin;
|
||||
unsigned int m_skinCount;
|
||||
|
||||
static ModelLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a Model object by default
|
||||
*/
|
||||
Model::Model()
|
||||
{
|
||||
ResetMaterials(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds this model to a render queue, using user-specified transform matrix and render order
|
||||
*
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ParticleFunctionController.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ParticleFunctionGenerator.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ParticleFunctionRenderer.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||
#include <Nazara/Graphics/Renderable.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
#include <Nazara/Utility/Algorithm.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Nz
|
||||
std::size_t offset;
|
||||
m_declaration->GetComponent(component, &enabled, &type, &offset);
|
||||
|
||||
if (enabled)
|
||||
if (enabled && GetComponentTypeOf<T>() == type)
|
||||
{
|
||||
///TODO: Check the ratio between the type of the attribute and the template type ?
|
||||
return SparsePtr<T>(m_ptr + offset, m_declaration->GetStride());
|
||||
@@ -57,7 +58,7 @@ namespace Nz
|
||||
std::size_t offset;
|
||||
m_declaration->GetComponent(component, &enabled, &type, &offset);
|
||||
|
||||
if (enabled)
|
||||
if (enabled && GetComponentTypeOf<T>() == type)
|
||||
{
|
||||
///TODO: Check the ratio between the type of the attribute and the template type ?
|
||||
return SparsePtr<const T>(m_ptr + offset, m_declaration->GetStride());
|
||||
|
||||
@@ -13,12 +13,14 @@ namespace Nz
|
||||
{
|
||||
class AbstractBackground;
|
||||
class AbstractViewer;
|
||||
class Texture;
|
||||
|
||||
struct SceneData
|
||||
{
|
||||
Color ambientColor;
|
||||
const AbstractBackground* background;
|
||||
const AbstractViewer* viewer;
|
||||
Texture* globalReflectionTexture;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <vector>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -61,8 +59,6 @@ namespace Nz
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const SkeletalModelParameters& params = SkeletalModelParameters());
|
||||
bool LoadFromStream(Stream& stream, const SkeletalModelParameters& params = SkeletalModelParameters());
|
||||
|
||||
void Reset();
|
||||
|
||||
bool SetAnimation(Animation* animation);
|
||||
void SetMesh(Mesh* mesh) override;
|
||||
bool SetSequence(const String& sequenceName);
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
class SkyboxBackground;
|
||||
|
||||
using SkyboxBackgroundConstRef = ObjectRef<const SkyboxBackground>;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
@@ -38,7 +37,6 @@ namespace Nz
|
||||
|
||||
inline const Color& GetColor() const;
|
||||
inline const Color& GetCornerColor(RectCorner corner) const;
|
||||
inline const MaterialRef& GetMaterial() const;
|
||||
inline const Vector3f& GetOrigin() const;
|
||||
inline const Vector2f& GetSize() const;
|
||||
inline const Rectf& GetTextureCoords() const;
|
||||
@@ -48,11 +46,15 @@ namespace Nz
|
||||
inline void SetDefaultMaterial();
|
||||
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
|
||||
bool SetMaterial(String materialName, bool resizeSprite = true);
|
||||
inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeSprite = true);
|
||||
bool SetMaterial(std::size_t skinIndex, String materialName, bool resizeSprite = true);
|
||||
inline void SetOrigin(const Vector3f& origin);
|
||||
inline void SetSize(const Vector2f& size);
|
||||
inline void SetSize(float sizeX, float sizeY);
|
||||
bool SetTexture(String textureName, bool resizeSprite = true);
|
||||
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
|
||||
bool SetTexture(std::size_t skinIndex, String textureName, bool resizeSprite = true);
|
||||
inline void SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeSprite = true);
|
||||
inline void SetTextureCoords(const Rectf& coords);
|
||||
inline void SetTextureRect(const Rectui& rect);
|
||||
|
||||
@@ -71,7 +73,6 @@ namespace Nz
|
||||
|
||||
std::array<Color, 4> m_cornerColor;
|
||||
Color m_color;
|
||||
MaterialRef m_material;
|
||||
Rectf m_textureCoords;
|
||||
Vector2f m_size;
|
||||
Vector3f m_origin;
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -18,6 +19,8 @@ namespace Nz
|
||||
m_size(64.f, 64.f),
|
||||
m_origin(Nz::Vector3f::Zero())
|
||||
{
|
||||
ResetMaterials(1);
|
||||
|
||||
for (Color& color : m_cornerColor)
|
||||
color = Color::White;
|
||||
|
||||
@@ -56,7 +59,6 @@ namespace Nz
|
||||
inline Sprite::Sprite(const Sprite& sprite) :
|
||||
InstancedRenderable(sprite),
|
||||
m_color(sprite.m_color),
|
||||
m_material(sprite.m_material),
|
||||
m_textureCoords(sprite.m_textureCoords),
|
||||
m_size(sprite.m_size),
|
||||
m_origin(sprite.m_origin)
|
||||
@@ -94,15 +96,6 @@ namespace Nz
|
||||
return m_cornerColor[corner];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material of the sprite
|
||||
* \return Current material
|
||||
*/
|
||||
inline const MaterialRef& Sprite::GetMaterial() const
|
||||
{
|
||||
return m_material;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the origin of the sprite
|
||||
*
|
||||
@@ -187,16 +180,32 @@ namespace Nz
|
||||
* \brief Changes the material of the sprite
|
||||
*
|
||||
* \param material Material for the sprite
|
||||
* \param resizeSprite Should the sprite be resized to the texture size?
|
||||
* \param resizeSprite Should billboard be resized to the material size (diffuse map)
|
||||
*/
|
||||
inline void Sprite::SetMaterial(MaterialRef material, bool resizeSprite)
|
||||
{
|
||||
m_material = std::move(material);
|
||||
if (m_material && resizeSprite)
|
||||
SetMaterial(GetSkin(), std::move(material), resizeSprite);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material of the sprite
|
||||
*
|
||||
* \param skinIndex Skin index to change
|
||||
* \param material Material for the sprite
|
||||
* \param resizeBillboard Should billboard be resized to the material size (diffuse map)
|
||||
*/
|
||||
inline void Sprite::SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeSprite)
|
||||
{
|
||||
InstancedRenderable::SetMaterial(skinIndex, 0, std::move(material));
|
||||
|
||||
if (resizeSprite)
|
||||
{
|
||||
Texture* diffuseMap = m_material->GetDiffuseMap();
|
||||
if (diffuseMap && diffuseMap->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(diffuseMap->GetSize())));
|
||||
if (const MaterialRef& newMat = GetMaterial())
|
||||
{
|
||||
const TextureRef& diffuseMap = newMat->GetDiffuseMap();
|
||||
if (diffuseMap && diffuseMap->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(diffuseMap->GetSize())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,9 +255,9 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the texture of the sprite
|
||||
* \brief Sets the texture of the sprite for the current skin
|
||||
*
|
||||
* Assign a texture to the sprite material
|
||||
* This function changes the diffuse map of the material associated with the current skin
|
||||
*
|
||||
* \param texture Texture for the sprite
|
||||
* \param resizeSprite Should the sprite be resized to the texture size?
|
||||
@@ -257,15 +266,37 @@ namespace Nz
|
||||
*/
|
||||
inline void Sprite::SetTexture(TextureRef texture, bool resizeSprite)
|
||||
{
|
||||
if (!m_material)
|
||||
SetDefaultMaterial();
|
||||
else if (m_material->GetReferenceCount() > 1)
|
||||
m_material = Material::New(*m_material); // Copy the material
|
||||
SetTexture(GetSkin(), std::move(texture), resizeSprite);
|
||||
}
|
||||
|
||||
if (resizeSprite && texture && texture->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(texture->GetSize())));
|
||||
/*!
|
||||
* \brief Sets the texture of the sprite for a specific skin
|
||||
*
|
||||
* This function changes the diffuse map of the material associated with the specified skin
|
||||
*
|
||||
* \param skinIndex Skin index to change
|
||||
* \param texture Texture for the sprite
|
||||
* \param resizeSprite Should the sprite be resized to the texture size?
|
||||
*
|
||||
* \remark The sprite material gets copied to prevent accidentally changing other drawable materials
|
||||
*/
|
||||
inline void Sprite::SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeSprite)
|
||||
{
|
||||
const MaterialRef& material = GetMaterial(skinIndex);
|
||||
|
||||
m_material->SetDiffuseMap(std::move(texture));
|
||||
if (material->GetReferenceCount() > 1)
|
||||
{
|
||||
MaterialRef newMat = Material::New(*material); // Copy
|
||||
newMat->SetDiffuseMap(std::move(texture));
|
||||
|
||||
SetMaterial(skinIndex, std::move(newMat), resizeSprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
material->SetDiffuseMap(std::move(texture));
|
||||
if (resizeSprite && texture && texture->IsValid())
|
||||
SetSize(Vector2f(Vector2ui(texture->GetSize())));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -277,6 +308,7 @@ namespace Nz
|
||||
inline void Sprite::SetTextureCoords(const Rectf& coords)
|
||||
{
|
||||
m_textureCoords = coords;
|
||||
|
||||
InvalidateVertices();
|
||||
}
|
||||
|
||||
@@ -291,10 +323,10 @@ namespace Nz
|
||||
|
||||
inline void Sprite::SetTextureRect(const Rectui& rect)
|
||||
{
|
||||
NazaraAssert(m_material, "Sprite has no material");
|
||||
NazaraAssert(m_material->HasDiffuseMap(), "Sprite material has no diffuse map");
|
||||
const MaterialRef& material = GetMaterial();
|
||||
NazaraAssert(material->HasDiffuseMap(), "Sprite material has no diffuse map");
|
||||
|
||||
Texture* diffuseMap = m_material->GetDiffuseMap();
|
||||
Texture* diffuseMap = material->GetDiffuseMap();
|
||||
|
||||
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||
@@ -314,7 +346,6 @@ namespace Nz
|
||||
InstancedRenderable::operator=(sprite);
|
||||
|
||||
m_color = sprite.m_color;
|
||||
m_material = sprite.m_material;
|
||||
m_origin = sprite.m_origin;
|
||||
m_textureCoords = sprite.m_textureCoords;
|
||||
m_size = sprite.m_size;
|
||||
@@ -352,5 +383,4 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include "Sprite.hpp"
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
@@ -11,13 +11,11 @@
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractTextDrawer;
|
||||
class TextSprite;
|
||||
|
||||
using TextSpriteConstRef = ObjectRef<const TextSprite>;
|
||||
@@ -37,12 +35,12 @@ namespace Nz
|
||||
inline void Clear();
|
||||
|
||||
inline const Color& GetColor() const;
|
||||
inline const MaterialRef& GetMaterial() const;
|
||||
inline float GetScale() const;
|
||||
|
||||
inline void SetColor(const Color& color);
|
||||
inline void SetDefaultMaterial();
|
||||
inline void SetMaterial(MaterialRef material);
|
||||
inline void SetMaterial(std::size_t skinIndex, MaterialRef material);
|
||||
inline void SetScale(float scale);
|
||||
|
||||
void Update(const AbstractTextDrawer& drawer);
|
||||
@@ -76,7 +74,6 @@ namespace Nz
|
||||
mutable std::unordered_map<Texture*, RenderIndices> m_renderInfos;
|
||||
mutable std::vector<VertexStruct_XY_Color_UV> m_localVertices;
|
||||
Color m_color;
|
||||
MaterialRef m_material;
|
||||
Recti m_localBounds;
|
||||
float m_scale;
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -15,6 +16,8 @@ namespace Nz
|
||||
m_color(Color::White),
|
||||
m_scale(1.f)
|
||||
{
|
||||
ResetMaterials(1U);
|
||||
|
||||
SetDefaultMaterial();
|
||||
}
|
||||
|
||||
@@ -41,7 +44,6 @@ namespace Nz
|
||||
m_renderInfos(sprite.m_renderInfos),
|
||||
m_localVertices(sprite.m_localVertices),
|
||||
m_color(sprite.m_color),
|
||||
m_material(sprite.m_material),
|
||||
m_localBounds(sprite.m_localBounds),
|
||||
m_scale(sprite.m_scale)
|
||||
{
|
||||
@@ -78,16 +80,6 @@ namespace Nz
|
||||
return m_color;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material of the text sprite
|
||||
* \return Current material
|
||||
*/
|
||||
|
||||
inline const MaterialRef& TextSprite::GetMaterial() const
|
||||
{
|
||||
return m_material;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the current scale of the text sprite
|
||||
* \return Current scale
|
||||
@@ -136,7 +128,12 @@ namespace Nz
|
||||
|
||||
inline void TextSprite::SetMaterial(MaterialRef material)
|
||||
{
|
||||
m_material = std::move(material);
|
||||
InstancedRenderable::SetMaterial(0, std::move(material));
|
||||
}
|
||||
|
||||
inline void TextSprite::SetMaterial(std::size_t skinIndex, MaterialRef material)
|
||||
{
|
||||
InstancedRenderable::SetMaterial(skinIndex, 0, std::move(material));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -167,7 +164,6 @@ namespace Nz
|
||||
m_atlases.clear();
|
||||
|
||||
m_color = text.m_color;
|
||||
m_material = text.m_material;
|
||||
m_renderInfos = text.m_renderInfos;
|
||||
m_localBounds = text.m_localBounds;
|
||||
m_localVertices = text.m_localVertices;
|
||||
@@ -216,4 +212,4 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <array>
|
||||
#include <set>
|
||||
|
||||
namespace Nz
|
||||
@@ -50,8 +48,6 @@ namespace Nz
|
||||
inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||
inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||
|
||||
inline const MaterialRef& GetMaterial(std::size_t index) const;
|
||||
inline std::size_t GetMaterialCount() const;
|
||||
inline const Vector2ui& GetMapSize() const;
|
||||
inline Vector2f GetSize() const;
|
||||
inline const Tile& GetTile(const Vector2ui& tilePos) const;
|
||||
@@ -59,7 +55,7 @@ namespace Nz
|
||||
|
||||
inline bool IsIsometricModeEnabled() const;
|
||||
|
||||
inline void SetMaterial(std::size_t index, MaterialRef material);
|
||||
using InstancedRenderable::SetMaterial;
|
||||
|
||||
inline TileMap& operator=(const TileMap& TileMap);
|
||||
TileMap& operator=(TileMap&& TileMap) = delete;
|
||||
@@ -83,7 +79,6 @@ namespace Nz
|
||||
|
||||
struct Layer
|
||||
{
|
||||
MaterialRef material;
|
||||
std::set<std::size_t> tiles;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/TileMap.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
@@ -32,8 +31,7 @@ namespace Nz
|
||||
NazaraAssert(m_tileSize.x > 0 && m_tileSize.y > 0, "Invalid tile size");
|
||||
NazaraAssert(m_layers.size() != 0U, "Invalid material count");
|
||||
|
||||
for (Layer& layer : m_layers)
|
||||
layer.material = Material::GetDefault();
|
||||
ResetMaterials(materialCount);
|
||||
|
||||
InvalidateBoundingVolume();
|
||||
}
|
||||
@@ -183,9 +181,11 @@ namespace Nz
|
||||
inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex)
|
||||
{
|
||||
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||
NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map");
|
||||
|
||||
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||
const MaterialRef& material = GetMaterial(materialIndex);
|
||||
NazaraAssert(material->HasDiffuseMap(), "Material has no diffuse map");
|
||||
|
||||
Texture* diffuseMap = material->GetDiffuseMap();
|
||||
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Nz
|
||||
{
|
||||
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||
|
||||
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||
Texture* diffuseMap = GetMaterial(materialIndex)->GetDiffuseMap();
|
||||
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||
|
||||
@@ -321,9 +321,11 @@ namespace Nz
|
||||
inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex)
|
||||
{
|
||||
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||
NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map");
|
||||
|
||||
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||
const MaterialRef& material = GetMaterial(materialIndex);
|
||||
NazaraAssert(material->HasDiffuseMap(), "Material has no diffuse map");
|
||||
|
||||
Texture* diffuseMap = material->GetDiffuseMap();
|
||||
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||
|
||||
@@ -331,29 +333,6 @@ namespace Nz
|
||||
EnableTiles(tilesPos, tileCount, unnormalizedCoords, color, materialIndex);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material at position index used by the TileMap
|
||||
*
|
||||
* \param index Index of the material to query
|
||||
*
|
||||
* \return Material at index
|
||||
*/
|
||||
inline const MaterialRef& TileMap::GetMaterial(std::size_t index) const
|
||||
{
|
||||
NazaraAssert(index < m_layers.size(), "Material out of bounds");
|
||||
|
||||
return m_layers[index].material;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the maximum material count this TileMap can use
|
||||
* \return Material count
|
||||
*/
|
||||
inline std::size_t TileMap::GetMaterialCount() const
|
||||
{
|
||||
return m_layers.size();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the tilemap size (i.e. number of tiles in each dimension)
|
||||
* \return Number of tiles in each dimension
|
||||
@@ -415,19 +394,6 @@ namespace Nz
|
||||
return m_isometricModeEnabled;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets a material of the TileMap
|
||||
*
|
||||
* \param index Index of the material to change
|
||||
* \param material Material for the TileMap
|
||||
*/
|
||||
inline void TileMap::SetMaterial(std::size_t index, MaterialRef material)
|
||||
{
|
||||
NazaraAssert(index < m_layers.size(), "Material out of bounds");
|
||||
|
||||
m_layers[index].material = std::move(material);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the current TileMap with the content of the other one
|
||||
* \return A reference to this
|
||||
|
||||
@@ -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 - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_LUA_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Lua/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Lua/LuaCoroutine.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline LuaCoroutine::LuaCoroutine(LuaCoroutine&& instance) :
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#define NAZARA_LUAINSTANCE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Lua/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#define NAZARA_LUASTATE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Lua/Config.hpp>
|
||||
#include <Nazara/Lua/Enums.hpp>
|
||||
@@ -25,6 +23,7 @@ namespace Nz
|
||||
class LuaCoroutine;
|
||||
class LuaInstance;
|
||||
class LuaState;
|
||||
class Stream;
|
||||
|
||||
using LuaCFunction = int (*)(lua_State* internalState);
|
||||
using LuaFunction = std::function<int(LuaState& state)>;
|
||||
@@ -33,7 +32,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
LuaState(const LuaState&) = default;
|
||||
LuaState(LuaState&& instance) noexcept;
|
||||
inline LuaState(LuaState&& instance) noexcept;
|
||||
~LuaState() = default;
|
||||
|
||||
void ArgCheck(bool condition, unsigned int argNum, const char* error) const;
|
||||
@@ -174,7 +173,7 @@ namespace Nz
|
||||
void* ToUserdata(int index, const String& tname) const;
|
||||
|
||||
LuaState& operator=(const LuaState&) = default;
|
||||
LuaState& operator=(LuaState&& instance) noexcept;
|
||||
inline LuaState& operator=(LuaState&& instance) noexcept;
|
||||
|
||||
static int GetIndexOfUpValue(int upValue);
|
||||
static LuaInstance& GetInstance(lua_State* internalState);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
@@ -20,6 +19,13 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline LuaState::LuaState(LuaState&& state) noexcept :
|
||||
m_lastError(state.m_lastError),
|
||||
m_state(state.m_state)
|
||||
{
|
||||
state.m_state = nullptr;
|
||||
}
|
||||
|
||||
inline lua_State* LuaState::GetInternalState() const
|
||||
{
|
||||
return m_state;
|
||||
@@ -64,21 +70,21 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !IsEnumFlag<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), TypeTag<UnderlyingT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !IsEnumFlag<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
return LuaImplQueryArg(instance, index, reinterpret_cast<UnderlyingT*>(arg), static_cast<UnderlyingT>(defValue), TypeTag<UnderlyingT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && IsEnumFlag<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
|
||||
@@ -90,7 +96,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && IsEnumFlag<T>::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag<T>)
|
||||
{
|
||||
using UnderlyingT = std::underlying_type_t<T>;
|
||||
|
||||
@@ -180,14 +186,14 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && !EnumAsFlags<T>::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && !IsEnumFlag<T>::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag<T>)
|
||||
{
|
||||
using EnumT = typename std::underlying_type<T>::type;
|
||||
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_enum<T>::value && EnumAsFlags<T>::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag<T>)
|
||||
std::enable_if_t<std::is_enum<T>::value && IsEnumFlag<T>::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag<T>)
|
||||
{
|
||||
Flags<T> flags(val);
|
||||
return LuaImplReplyVal(instance, flags, TypeTag<decltype(flags)>());
|
||||
@@ -196,7 +202,7 @@ namespace Nz
|
||||
template<typename E>
|
||||
int LuaImplReplyVal(const LuaState& instance, Flags<E> val, TypeTag<Flags<E>>)
|
||||
{
|
||||
instance.PushInteger(UInt32(val));
|
||||
instance.PushInteger(typename Flags<E>::BitField(val));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -770,6 +776,16 @@ namespace Nz
|
||||
SetMetatable(tname);
|
||||
}
|
||||
|
||||
inline LuaState& LuaState::operator=(LuaState&& state) noexcept
|
||||
{
|
||||
m_lastError = std::move(state.m_lastError);
|
||||
m_state = state.m_state;
|
||||
|
||||
state.m_state = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_signed<T>::value, T> LuaState::CheckBounds(int index, long long value) const
|
||||
{
|
||||
|
||||
@@ -552,11 +552,11 @@ namespace Nz
|
||||
#endif
|
||||
const T twoLimit = limit * T(2);
|
||||
|
||||
angle = std::fmod(angle + limit, twoLimit);
|
||||
angle = std::fmod(angle, twoLimit);
|
||||
if (angle < T(0))
|
||||
angle += twoLimit;
|
||||
|
||||
return angle - limit;
|
||||
return angle;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -541,7 +541,7 @@ namespace Nz
|
||||
return Infinite();
|
||||
|
||||
case Extend_Null:
|
||||
return from.obb * interpolation;
|
||||
return to.obb * interpolation;
|
||||
}
|
||||
|
||||
// If we arrive here, the extend is invalid
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Makes the euler angle (0, 0, 0)
|
||||
* \return A reference to this euler angle with components (0, 0, 0)
|
||||
*
|
||||
* \see Zero
|
||||
*/
|
||||
@@ -276,7 +275,7 @@ namespace Nz
|
||||
* \brief Substracts the components of other euler angle to this euler angle
|
||||
* \return A reference to this euler angle where components are the difference of this euler angle and the other one
|
||||
*
|
||||
* \param angle The other euler angle to substract components with
|
||||
* \param angles The other euler angle to substract components with
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -664,9 +664,9 @@ namespace Nz
|
||||
template<typename T>
|
||||
Vector3<T> Matrix4<T>::GetSquaredScale() const
|
||||
{
|
||||
return Vector3<T>(m11*m11 + m21*m21 + m31*m31,
|
||||
m12*m12 + m22*m22 + m32*m32,
|
||||
m13*m13 + m23*m23 + m33*m33);
|
||||
return Vector3<T>(m11 * m11 + m12 * m12 + m13 * m13,
|
||||
m21 * m21 + m22 * m22 + m23 * m23,
|
||||
m31 * m31 + m32 * m32 + m33 * m33);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1153,36 +1153,32 @@ namespace Nz
|
||||
*
|
||||
* \param rotation Quaternion representing a rotation of space
|
||||
*
|
||||
* \remark 3rd column and row are unchanged
|
||||
* \remark 3rd column and row are unchanged. Scale is removed.
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Matrix4<T>& Matrix4<T>::SetRotation(const Quaternion<T>& rotation)
|
||||
{
|
||||
T tx = rotation.x + rotation.x;
|
||||
T ty = rotation.y + rotation.y;
|
||||
T tz = rotation.z + rotation.z;
|
||||
T twx = tx * rotation.w;
|
||||
T twy = ty * rotation.w;
|
||||
T twz = tz * rotation.w;
|
||||
T txx = tx * rotation.x;
|
||||
T txy = ty * rotation.x;
|
||||
T txz = tz * rotation.x;
|
||||
T tyy = ty * rotation.y;
|
||||
T tyz = tz * rotation.y;
|
||||
T tzz = tz * rotation.z;
|
||||
T qw = rotation.w;
|
||||
T qx = rotation.x;
|
||||
T qy = rotation.y;
|
||||
T qz = rotation.z;
|
||||
|
||||
m11 = F(1.0) - (tyy + tzz);
|
||||
m12 = txy + twz;
|
||||
m13 = txz - twy;
|
||||
T qx2 = qx * qx;
|
||||
T qy2 = qy * qy;
|
||||
T qz2 = qz * qz;
|
||||
|
||||
m21 = txy - twz;
|
||||
m22 = F(1.0) - (txx + tzz);
|
||||
m23 = tyz + twx;
|
||||
m11 = F(1.0) - F(2.0) * qy2 - F(2.0) * qz2;
|
||||
m21 = F(2.0) * qx * qy - F(2.0) * qz * qw;
|
||||
m31 = F(2.0) * qx * qz + F(2.0) * qy * qw;
|
||||
|
||||
m31 = txz + twy;
|
||||
m32 = tyz - twx;
|
||||
m33 = F(1.0) - (txx + tyy);
|
||||
m12 = F(2.0) * qx * qy + F(2.0) * qz * qw;
|
||||
m22 = F(1.0) - F(2.0) * qx2 - F(2.0) * qz2;
|
||||
m32 = F(2.0) * qy * qz - F(2.0) * qx * qw;
|
||||
|
||||
m13 = F(2.0) * qx * qz - F(2.0) * qy * qw;
|
||||
m23 = F(2.0) * qy * qz + F(2.0) * qx * qw;
|
||||
m33 = F(1.0) - F(2.0) * qx2 - F(2.0) * qy2;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user