Merge branch 'master' into vulkan
Former-commit-id: 783e31e1f02fea8f9cd5080dc5295eead00ba1ce [formerly 7bf4eb3cc900923a8b3483b45e73333954a9c143] [formerly bd47f3386b2ccaa49ab5a45d874ebcdd653df81f [formerly 60494c4bdb49e4c3cfbdd97f048ee9e5b7b3a81d]] Former-commit-id: eea148c75240307741b212eff37937ae325d323d [formerly df04c665b6bddd805665558928d8b16938c719fc] Former-commit-id: f69cd1b0f1762bb2c4a289e553207adbd622ac5a
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T> void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
||||
template<typename T> void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount);
|
||||
}
|
||||
|
||||
#include <Nazara/Audio/Algorithm.inl>
|
||||
|
||||
@@ -19,16 +19,16 @@ namespace Nz
|
||||
* \remark The input buffer may be the same as the output one
|
||||
*/
|
||||
template<typename T>
|
||||
void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
|
||||
void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount)
|
||||
{
|
||||
// To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
|
||||
for (unsigned int i = 0; i < frameCount; ++i)
|
||||
for (UInt64 i = 0; i < frameCount; ++i)
|
||||
{
|
||||
Biggest acc = Biggest(0);
|
||||
for (unsigned int j = 0; j < channelCount; ++j)
|
||||
for (UInt32 j = 0; j < channelCount; ++j)
|
||||
acc += input[i * channelCount + j];
|
||||
|
||||
output[i] = static_cast<T>(acc / channelCount);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Nz
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
UInt32 GetPlayingOffset() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt64 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
SoundStatus GetStatus() const;
|
||||
|
||||
|
||||
@@ -50,18 +50,18 @@ namespace Nz
|
||||
|
||||
public:
|
||||
SoundBuffer() = default;
|
||||
SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples);
|
||||
SoundBuffer(const SoundBuffer&) = delete;
|
||||
SoundBuffer(SoundBuffer&&) = delete;
|
||||
~SoundBuffer();
|
||||
|
||||
bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples);
|
||||
bool Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples);
|
||||
void Destroy();
|
||||
|
||||
UInt32 GetDuration() const;
|
||||
AudioFormat GetFormat() const;
|
||||
const Int16* GetSamples() const;
|
||||
UInt32 GetSampleCount() const;
|
||||
UInt64 GetSampleCount() const;
|
||||
UInt32 GetSampleRate() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace Nz
|
||||
|
||||
virtual UInt32 GetDuration() const = 0;
|
||||
virtual AudioFormat GetFormat() const = 0;
|
||||
virtual UInt32 GetSampleCount() const = 0;
|
||||
virtual UInt64 GetSampleCount() const = 0;
|
||||
virtual UInt32 GetSampleRate() const = 0;
|
||||
|
||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||
virtual void Seek(UInt32 offset) = 0;
|
||||
virtual UInt64 Read(void* buffer, UInt64 sampleCount) = 0;
|
||||
virtual void Seek(UInt64 offset) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Nz
|
||||
if (sizeof(T) <= sizeof(Block))
|
||||
{
|
||||
m_bitCount = std::numeric_limits<T>::digits;
|
||||
m_blocks.push_back(value);
|
||||
m_blocks.push_back(static_cast<Block>(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace Nz
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
InstanceData(const Matrix4f& referenceMatrix) :
|
||||
transformMatrix(&referenceMatrix),
|
||||
InstanceData(const Matrix4f& transformationMatrix) :
|
||||
localMatrix(transformationMatrix),
|
||||
flags(0)
|
||||
{
|
||||
}
|
||||
@@ -67,6 +67,7 @@ namespace Nz
|
||||
data = std::move(instanceData.data);
|
||||
flags = instanceData.flags;
|
||||
renderOrder = instanceData.renderOrder;
|
||||
localMatrix = instanceData.localMatrix;
|
||||
transformMatrix = instanceData.transformMatrix;
|
||||
volume = instanceData.volume;
|
||||
|
||||
@@ -75,7 +76,8 @@ namespace Nz
|
||||
|
||||
std::vector<UInt8> data;
|
||||
BoundingVolumef volume;
|
||||
const Matrix4f* transformMatrix;
|
||||
Matrix4f localMatrix;
|
||||
mutable Matrix4f transformMatrix;
|
||||
UInt32 flags;
|
||||
int renderOrder;
|
||||
};
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace Nz
|
||||
MaterialPipelineRef MaterialPipeline::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<MaterialPipeline> object(new MaterialPipeline(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ namespace Nz
|
||||
*/
|
||||
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
|
||||
{
|
||||
InstanceData instanceData(transformMatrix);
|
||||
InstanceData instanceData(Nz::Matrix4f::Identity());
|
||||
instanceData.renderOrder = renderOrder;
|
||||
instanceData.transformMatrix = transformMatrix;
|
||||
return AddToRenderQueue(renderQueue, instanceData);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,17 @@ namespace Nz
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
|
||||
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;
|
||||
|
||||
inline void SetColor(const Color& color);
|
||||
inline void SetCornerColor(RectCorner corner, const Color& color);
|
||||
inline void SetDefaultMaterial();
|
||||
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
|
||||
inline void SetOrigin(const Vector3f& origin);
|
||||
inline void SetSize(const Vector2f& size);
|
||||
inline void SetSize(float sizeX, float sizeY);
|
||||
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
|
||||
@@ -63,10 +67,12 @@ namespace Nz
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::array<Color, 4> m_cornerColor;
|
||||
Color m_color;
|
||||
MaterialRef m_material;
|
||||
Rectf m_textureCoords;
|
||||
Vector2f m_size;
|
||||
Vector3f m_origin;
|
||||
|
||||
static SpriteLibrary::LibraryMap s_library;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,12 @@ namespace Nz
|
||||
inline Sprite::Sprite() :
|
||||
m_color(Color::White),
|
||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
||||
m_size(64.f, 64.f)
|
||||
m_size(64.f, 64.f),
|
||||
m_origin(Nz::Vector3f::Zero())
|
||||
{
|
||||
for (Color& color : m_cornerColor)
|
||||
color = Color::White;
|
||||
|
||||
SetDefaultMaterial();
|
||||
}
|
||||
|
||||
@@ -25,11 +29,8 @@ namespace Nz
|
||||
*
|
||||
* \param material Reference to a material
|
||||
*/
|
||||
|
||||
inline Sprite::Sprite(MaterialRef material) :
|
||||
m_color(Color::White),
|
||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
||||
m_size(64.f, 64.f)
|
||||
Sprite()
|
||||
{
|
||||
SetMaterial(std::move(material), true);
|
||||
}
|
||||
@@ -41,9 +42,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
inline Sprite::Sprite(Texture* texture) :
|
||||
m_color(Color::White),
|
||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
||||
m_size(64.f, 64.f)
|
||||
Sprite()
|
||||
{
|
||||
SetTexture(texture, true);
|
||||
}
|
||||
@@ -59,30 +58,63 @@ namespace Nz
|
||||
m_color(sprite.m_color),
|
||||
m_material(sprite.m_material),
|
||||
m_textureCoords(sprite.m_textureCoords),
|
||||
m_size(sprite.m_size)
|
||||
m_size(sprite.m_size),
|
||||
m_origin(sprite.m_origin)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the color of the sprite
|
||||
*
|
||||
* This is the global color of the sprite, independent from corner colors
|
||||
*
|
||||
* \return Current color
|
||||
*
|
||||
* \see GetCornerColor
|
||||
* \see SetColor
|
||||
*/
|
||||
|
||||
inline const Color& Sprite::GetColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the color setup on a corner of the sprite
|
||||
*
|
||||
* \return Current color
|
||||
*
|
||||
* \param corner Corner of the sprite to query
|
||||
*
|
||||
* \see SetCornerColor
|
||||
*/
|
||||
inline const Color& Sprite::GetCornerColor(RectCorner corner) const
|
||||
{
|
||||
NazaraAssert(static_cast<std::size_t>(corner) < m_cornerColor.size(), "Invalid corner");
|
||||
|
||||
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
|
||||
*
|
||||
* \return Current material
|
||||
*
|
||||
* \see SetOrigin
|
||||
*/
|
||||
inline const Vector3f& Sprite::GetOrigin() const
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the size of the sprite
|
||||
* \return Current size
|
||||
@@ -97,18 +129,21 @@ namespace Nz
|
||||
* \brief Gets the texture coordinates of the sprite
|
||||
* \return Current texture coordinates
|
||||
*/
|
||||
|
||||
inline const Rectf& Sprite::GetTextureCoords() const
|
||||
{
|
||||
return m_textureCoords;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the color of the billboard
|
||||
* \brief Sets the global color of the sprite
|
||||
*
|
||||
* \param color Color for the billboard
|
||||
* This is independent from the corner color of the sprite
|
||||
*
|
||||
* \param color Color for the sprite
|
||||
*
|
||||
* \see GetColor
|
||||
* \see SetCornerColor
|
||||
*/
|
||||
|
||||
inline void Sprite::SetColor(const Color& color)
|
||||
{
|
||||
m_color = color;
|
||||
@@ -116,6 +151,26 @@ namespace Nz
|
||||
InvalidateVertices();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets a color for a corner of the sprite
|
||||
*
|
||||
* This is independent from the sprite global color, which gets multiplied by the corner color when rendering the sprite.
|
||||
*
|
||||
* \param corner Corner of the sprite to set
|
||||
* \param color Color for the sprite
|
||||
*
|
||||
* \see GetCornerColor
|
||||
* \see SetColor
|
||||
*/
|
||||
inline void Sprite::SetCornerColor(RectCorner corner, const Color& color)
|
||||
{
|
||||
NazaraAssert(static_cast<std::size_t>(corner) < m_cornerColor.size(), "Invalid corner");
|
||||
|
||||
m_cornerColor[corner] = color;
|
||||
|
||||
InvalidateVertices();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the default material of the sprite (just default material)
|
||||
*/
|
||||
@@ -146,6 +201,24 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the origin of the sprite
|
||||
*
|
||||
* The origin is the center of translation/rotation/scaling of the sprite.
|
||||
*
|
||||
* \param origin New origin for the sprite
|
||||
*
|
||||
* \see GetOrigin
|
||||
*/
|
||||
inline void Sprite::SetOrigin(const Vector3f& origin)
|
||||
{
|
||||
m_origin = origin;
|
||||
|
||||
// On invalide la bounding box
|
||||
InvalidateBoundingVolume();
|
||||
InvalidateVertices();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the size of the sprite
|
||||
*
|
||||
@@ -240,6 +313,7 @@ namespace Nz
|
||||
|
||||
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;
|
||||
|
||||
@@ -277,3 +351,4 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include "Sprite.hpp"
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Nz
|
||||
public:
|
||||
LuaInstance();
|
||||
LuaInstance(const LuaInstance&) = delete;
|
||||
LuaInstance(LuaInstance&&) = delete; ///TODO
|
||||
inline LuaInstance(LuaInstance&& instance) noexcept;
|
||||
~LuaInstance();
|
||||
|
||||
void ArgCheck(bool condition, unsigned int argNum, const char* error);
|
||||
@@ -92,16 +92,16 @@ namespace Nz
|
||||
LuaType GetField(const String& fieldName, int tableIndex = -1) const;
|
||||
LuaType GetGlobal(const char* name) const;
|
||||
LuaType GetGlobal(const String& name) const;
|
||||
lua_State* GetInternalState() const;
|
||||
String GetLastError() const;
|
||||
UInt32 GetMemoryLimit() const;
|
||||
UInt32 GetMemoryUsage() const;
|
||||
inline lua_State* GetInternalState() const;
|
||||
inline String GetLastError() const;
|
||||
inline std::size_t GetMemoryLimit() const;
|
||||
inline std::size_t GetMemoryUsage() const;
|
||||
LuaType GetMetatable(const char* tname) const;
|
||||
LuaType GetMetatable(const String& tname) const;
|
||||
bool GetMetatable(int index) const;
|
||||
unsigned int GetStackTop() const;
|
||||
LuaType GetTable(int index = -2) const;
|
||||
UInt32 GetTimeLimit() const;
|
||||
inline UInt32 GetTimeLimit() const;
|
||||
LuaType GetType(int index) const;
|
||||
const char* GetTypeName(LuaType type) const;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Nz
|
||||
void PushString(const char* str) const;
|
||||
void PushString(const char* str, std::size_t size) const;
|
||||
void PushString(const String& str) const;
|
||||
void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const;
|
||||
void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const;
|
||||
void* PushUserdata(std::size_t size) const;
|
||||
void PushValue(int index) const;
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Nz
|
||||
void* ToUserdata(int index, const String& tname) const;
|
||||
|
||||
LuaInstance& operator=(const LuaInstance&) = delete;
|
||||
LuaInstance& operator=(LuaInstance&&) = delete; ///TODO
|
||||
inline LuaInstance& operator=(LuaInstance&& instance) noexcept;
|
||||
|
||||
static int GetIndexOfUpValue(int upValue);
|
||||
static LuaInstance* GetInstance(lua_State* state);
|
||||
|
||||
@@ -13,6 +13,58 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept :
|
||||
m_memoryLimit(instance.m_memoryLimit),
|
||||
m_memoryUsage(instance.m_memoryUsage),
|
||||
m_timeLimit(m_timeLimit),
|
||||
m_clock(std::move(m_clock)),
|
||||
m_lastError(std::move(m_lastError)),
|
||||
m_state(m_state),
|
||||
m_level(m_level)
|
||||
{
|
||||
instance.m_state = nullptr;
|
||||
}
|
||||
|
||||
inline lua_State* LuaInstance::GetInternalState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
inline String LuaInstance::GetLastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
inline std::size_t LuaInstance::GetMemoryLimit() const
|
||||
{
|
||||
return m_memoryLimit;
|
||||
}
|
||||
|
||||
inline std::size_t LuaInstance::GetMemoryUsage() const
|
||||
{
|
||||
return m_memoryUsage;
|
||||
}
|
||||
|
||||
inline UInt32 LuaInstance::GetTimeLimit() const
|
||||
{
|
||||
return m_timeLimit;
|
||||
}
|
||||
|
||||
inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept
|
||||
{
|
||||
m_clock = std::move(m_clock);
|
||||
m_lastError = std::move(m_lastError);
|
||||
m_level = m_level;
|
||||
m_memoryLimit = instance.m_memoryLimit;
|
||||
m_memoryUsage = instance.m_memoryUsage;
|
||||
m_state = m_state;
|
||||
m_timeLimit = m_timeLimit;
|
||||
|
||||
instance.m_state = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Functions args
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag<bool>)
|
||||
{
|
||||
|
||||
@@ -45,20 +45,21 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
// Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça
|
||||
// The parentheses are needed for GCC
|
||||
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2(T number)
|
||||
{
|
||||
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
|
||||
|
||||
// L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits
|
||||
// ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting
|
||||
// Masking and shifting bits to the right (to bring it back to 32 bits)
|
||||
|
||||
// Call of the function with 32 bits number, if the result is non-null we have our answer
|
||||
for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32))
|
||||
{
|
||||
// Le masque 32 bits sur la partie du nombre qu'on traite actuellement
|
||||
// The 32 bits mask on the part we are treating
|
||||
T mask = T(std::numeric_limits<UInt32>::max()) << i*8;
|
||||
T val = (number & mask) >> i*8; // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits)
|
||||
T val = (number & mask) >> i*8; // Masking and shifting bits to the right (to bring it back to 32 bits)
|
||||
|
||||
// Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse
|
||||
// Call of the function with 32 bits number, if the result is non-null we have our answer
|
||||
unsigned int log2 = IntegralLog2<UInt32>(val);
|
||||
if (log2)
|
||||
return log2 + i*8;
|
||||
@@ -75,20 +76,20 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
// Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça
|
||||
// The parentheses are needed for GCC
|
||||
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2Pot(T number)
|
||||
{
|
||||
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
|
||||
|
||||
// L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits
|
||||
// ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting
|
||||
// The algorithm for logarithm in base 2 only works with numbers greather than 32 bits
|
||||
// This code subdivides the biggest number into 32 bits ones
|
||||
for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32))
|
||||
{
|
||||
// Le masque 32 bits sur la partie du nombre qu'on traite actuellement
|
||||
// The 32 bits mask on the part we are treating
|
||||
T mask = T(std::numeric_limits<UInt32>::max()) << i*8;
|
||||
UInt32 val = UInt32((number & mask) >> i*8); // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits)
|
||||
UInt32 val = UInt32((number & mask) >> i*8); // Masking and shifting bits to the right (to bring it back to 32 bits)
|
||||
|
||||
// Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse
|
||||
// Call of the function with 32 bits number, if the result is non-null we have our answer
|
||||
unsigned int log2 = IntegralLog2Pot<UInt32>(val);
|
||||
if (log2 || val == 1)
|
||||
return log2 + i*8;
|
||||
@@ -99,7 +100,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Approaches the objective, beginning with value and with increment
|
||||
* \return The nearest value of the objective you can get with the value and the increment for one step
|
||||
*
|
||||
@@ -121,7 +122,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Clamps value between min and max and returns the expected value
|
||||
* \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval
|
||||
*
|
||||
@@ -137,7 +138,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets number of bits set in the number
|
||||
* \return The number of bits set to 1
|
||||
*
|
||||
@@ -160,7 +161,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Converts degree to radian
|
||||
* \return The representation in radian of the angle in degree (0..2*pi)
|
||||
*
|
||||
@@ -174,7 +175,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||
* \return Express the degrees
|
||||
*
|
||||
@@ -192,7 +193,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||
* \return Express the radians
|
||||
*
|
||||
@@ -210,7 +211,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the nearest power of two for the number
|
||||
* \return First power of two containing the number
|
||||
*
|
||||
@@ -229,7 +230,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -257,7 +258,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -279,7 +280,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -295,7 +296,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -312,7 +313,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -328,7 +329,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits
|
||||
*
|
||||
@@ -345,7 +346,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits + 1 for the dot
|
||||
*
|
||||
@@ -360,7 +361,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits + 1 for the dot
|
||||
*
|
||||
@@ -375,7 +376,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the number of digits to represent the number in base 10
|
||||
* \return Number of digits + 1 for the dot
|
||||
*
|
||||
@@ -390,7 +391,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the log in base 2 of integral number
|
||||
* \return Log of the number (floor)
|
||||
*
|
||||
@@ -408,7 +409,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the log in base 2 of integral number, only works for power of two !
|
||||
* \return Log of the number
|
||||
*
|
||||
@@ -426,7 +427,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the power of integrals
|
||||
* \return base^exponent for integral
|
||||
*
|
||||
@@ -445,7 +446,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Interpolates the value to other one with a factor of interpolation
|
||||
* \return A new value which is the interpolation of two values
|
||||
*
|
||||
@@ -466,7 +467,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Multiplies X and Y, then add Z
|
||||
* \return The result of X * Y + Z
|
||||
*
|
||||
@@ -508,7 +509,7 @@ namespace Nz
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Normalizes the angle
|
||||
* \return Normalized value between 0..2*(pi if radian or 180 if degrees)
|
||||
*
|
||||
@@ -534,7 +535,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Checks whether two numbers are equal
|
||||
* \return true if they are equal within a certain epsilon
|
||||
*
|
||||
@@ -550,7 +551,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Checks whether two numbers are equal
|
||||
* \return true if they are equal within the max difference
|
||||
*
|
||||
@@ -571,7 +572,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Converts the number to String
|
||||
* \return String representation of the number
|
||||
*
|
||||
@@ -623,7 +624,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Converts radian to degree
|
||||
* \return The representation in degree of the angle in radian (0..360)
|
||||
*
|
||||
@@ -637,7 +638,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Converts the string to number
|
||||
* \return Number which is represented by the string
|
||||
*
|
||||
@@ -699,7 +700,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||
* \return Express in degrees
|
||||
*
|
||||
@@ -717,7 +718,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \brief Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||
* \return Express in radians
|
||||
*
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace Nz
|
||||
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
CompoundGeom(PhysGeom** geoms, unsigned int geomCount);
|
||||
CompoundGeom(PhysGeom** geoms, std::size_t geomCount);
|
||||
|
||||
const std::vector<PhysGeomRef>& GetGeoms() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
@@ -20,16 +20,15 @@
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Sequence.hpp>
|
||||
#include <limits>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
|
||||
{
|
||||
// La frame de fin à charger
|
||||
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
|
||||
UInt32 endFrame = 0xFFFFFFFF;
|
||||
// La frame de début à charger
|
||||
unsigned int startFrame = 0;
|
||||
UInt32 startFrame = 0;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
@@ -57,27 +56,27 @@ namespace Nz
|
||||
~Animation();
|
||||
|
||||
bool AddSequence(const Sequence& sequence);
|
||||
void AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const;
|
||||
void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const;
|
||||
|
||||
bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount);
|
||||
bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount);
|
||||
void Destroy();
|
||||
|
||||
void EnableLoopPointInterpolation(bool loopPointInterpolation);
|
||||
|
||||
unsigned int GetFrameCount() const;
|
||||
unsigned int GetJointCount() const;
|
||||
UInt32 GetFrameCount() const;
|
||||
UInt32 GetJointCount() const;
|
||||
Sequence* GetSequence(const String& sequenceName);
|
||||
Sequence* GetSequence(unsigned int index);
|
||||
Sequence* GetSequence(UInt32 index);
|
||||
const Sequence* GetSequence(const String& sequenceName) const;
|
||||
const Sequence* GetSequence(unsigned int index) const;
|
||||
unsigned int GetSequenceCount() const;
|
||||
int GetSequenceIndex(const String& sequenceName) const;
|
||||
SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
|
||||
const SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
|
||||
const Sequence* GetSequence(UInt32 index) const;
|
||||
UInt32 GetSequenceCount() const;
|
||||
UInt32 GetSequenceIndex(const String& sequenceName) const;
|
||||
SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0);
|
||||
const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const;
|
||||
AnimationType GetType() const;
|
||||
|
||||
bool HasSequence(const String& sequenceName) const;
|
||||
bool HasSequence(unsigned int index = 0) const;
|
||||
bool HasSequence(UInt32 index = 0) const;
|
||||
|
||||
bool IsLoopPointInterpolationEnabled() const;
|
||||
bool IsValid() const;
|
||||
@@ -87,7 +86,7 @@ namespace Nz
|
||||
bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams());
|
||||
|
||||
void RemoveSequence(const String& sequenceName);
|
||||
void RemoveSequence(unsigned int index);
|
||||
void RemoveSequence(UInt32 index);
|
||||
|
||||
template<typename... Args> static AnimationRef New(Args&&... args);
|
||||
|
||||
|
||||
48
include/Nazara/Utility/EventHandler.hpp
Normal file
48
include/Nazara/Utility/EventHandler.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_EVENTHANDLER_HPP
|
||||
#define NAZARA_EVENTHANDLER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
EventHandler() = default;
|
||||
explicit EventHandler(const EventHandler&);
|
||||
EventHandler(EventHandler&&) = default;
|
||||
~EventHandler() = default;
|
||||
|
||||
inline void Dispatch(const WindowEvent& event);
|
||||
|
||||
NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/);
|
||||
NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/);
|
||||
NazaraSignal(OnKeyReleased, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonDoubleClicked, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonPressed, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseButtonReleased, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/);
|
||||
NazaraSignal(OnMouseEntered, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnMouseLeft, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnMouseMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseMoveEvent& /*event*/);
|
||||
NazaraSignal(OnMouseWheelMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseWheelEvent& /*event*/);
|
||||
NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/);
|
||||
NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/);
|
||||
NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/);
|
||||
NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/EventHandler.inl>
|
||||
|
||||
#endif // NAZARA_EVENTHANDLER_HPP
|
||||
84
include/Nazara/Utility/EventHandler.inl
Normal file
84
include/Nazara/Utility/EventHandler.inl
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline EventHandler::EventHandler(const EventHandler&)
|
||||
{
|
||||
}
|
||||
|
||||
inline void EventHandler::Dispatch(const WindowEvent& event)
|
||||
{
|
||||
OnEvent(this, event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case WindowEventType_GainedFocus:
|
||||
OnGainedFocus(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_KeyPressed:
|
||||
OnKeyPressed(this, event.key);
|
||||
break;
|
||||
|
||||
case WindowEventType_KeyReleased:
|
||||
OnKeyReleased(this, event.key);
|
||||
break;
|
||||
|
||||
case WindowEventType_LostFocus:
|
||||
OnLostFocus(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonDoubleClicked:
|
||||
OnMouseButtonDoubleClicked(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonPressed:
|
||||
OnMouseButtonPressed(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseButtonReleased:
|
||||
OnMouseButtonReleased(this, event.mouseButton);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseEntered:
|
||||
OnMouseEntered(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseLeft:
|
||||
OnMouseLeft(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseMoved:
|
||||
OnMouseMoved(this, event.mouseMove);
|
||||
break;
|
||||
|
||||
case WindowEventType_MouseWheelMoved:
|
||||
OnMouseWheelMoved(this, event.mouseWheel);
|
||||
break;
|
||||
|
||||
case WindowEventType_Moved:
|
||||
OnMoved(this, event.position);
|
||||
break;
|
||||
|
||||
case WindowEventType_Quit:
|
||||
OnQuit(this);
|
||||
break;
|
||||
|
||||
case WindowEventType_Resized:
|
||||
OnResized(this, event.size);
|
||||
break;
|
||||
|
||||
case WindowEventType_TextEntered:
|
||||
OnTextEntered(this, event.text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -34,12 +34,12 @@ namespace Nz
|
||||
|
||||
struct Joint
|
||||
{
|
||||
Int32 parent;
|
||||
Quaternionf bindOrient;
|
||||
String name;
|
||||
Vector3f bindPos;
|
||||
int parent;
|
||||
unsigned int flags;
|
||||
unsigned int index;
|
||||
UInt32 flags;
|
||||
UInt32 index;
|
||||
};
|
||||
|
||||
MD5AnimParser(Stream& stream);
|
||||
@@ -47,12 +47,12 @@ namespace Nz
|
||||
|
||||
Ternary Check();
|
||||
|
||||
std::size_t GetAnimatedComponentCount() const;
|
||||
UInt32 GetAnimatedComponentCount() const;
|
||||
const Frame* GetFrames() const;
|
||||
std::size_t GetFrameCount() const;
|
||||
std::size_t GetFrameRate() const;
|
||||
UInt32 GetFrameCount() const;
|
||||
UInt32 GetFrameRate() const;
|
||||
const Joint* GetJoints() const;
|
||||
std::size_t GetJointCount() const;
|
||||
UInt32 GetJointCount() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace Nz
|
||||
public:
|
||||
struct Joint
|
||||
{
|
||||
Int32 parent;
|
||||
Quaternionf bindOrient;
|
||||
String name;
|
||||
Vector3f bindPos;
|
||||
int parent;
|
||||
};
|
||||
|
||||
typedef Vector3ui Triangle;
|
||||
@@ -58,9 +58,9 @@ namespace Nz
|
||||
Ternary Check();
|
||||
|
||||
const Joint* GetJoints() const;
|
||||
std::size_t GetJointCount() const;
|
||||
UInt32 GetJointCount() const;
|
||||
const Mesh* GetMeshes() const;
|
||||
std::size_t GetMeshCount() const;
|
||||
UInt32 GetMeshCount() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
|
||||
@@ -31,43 +31,43 @@ namespace Nz
|
||||
|
||||
inline String* GetMaterials();
|
||||
inline const String* GetMaterials() const;
|
||||
inline unsigned int GetMaterialCount() const;
|
||||
inline UInt32 GetMaterialCount() const;
|
||||
inline Mesh* GetMeshes();
|
||||
inline const Mesh* GetMeshes() const;
|
||||
inline unsigned int GetMeshCount() const;
|
||||
inline UInt32 GetMeshCount() const;
|
||||
inline const String& GetMtlLib() const;
|
||||
inline Vector3f* GetNormals();
|
||||
inline const Vector3f* GetNormals() const;
|
||||
inline unsigned int GetNormalCount() const;
|
||||
inline UInt32 GetNormalCount() const;
|
||||
inline Vector4f* GetPositions();
|
||||
inline const Vector4f* GetPositions() const;
|
||||
inline unsigned int GetPositionCount() const;
|
||||
inline UInt32 GetPositionCount() const;
|
||||
inline Vector3f* GetTexCoords();
|
||||
inline const Vector3f* GetTexCoords() const;
|
||||
inline unsigned int GetTexCoordCount() const;
|
||||
inline UInt32 GetTexCoordCount() const;
|
||||
|
||||
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
|
||||
bool Parse(Stream& stream, UInt32 reservedVertexCount = 100);
|
||||
|
||||
bool Save(Stream& stream) const;
|
||||
|
||||
inline String* SetMaterialCount(std::size_t materialCount);
|
||||
inline Mesh* SetMeshCount(std::size_t meshCount);
|
||||
inline String* SetMaterialCount(UInt32 materialCount);
|
||||
inline Mesh* SetMeshCount(UInt32 meshCount);
|
||||
inline void SetMtlLib(const String& mtlLib);
|
||||
inline Vector3f* SetNormalCount(std::size_t normalCount);
|
||||
inline Vector4f* SetPositionCount(std::size_t positionCount);
|
||||
inline Vector3f* SetTexCoordCount(std::size_t texCoordCount);
|
||||
inline Vector3f* SetNormalCount(UInt32 normalCount);
|
||||
inline Vector4f* SetPositionCount(UInt32 positionCount);
|
||||
inline Vector3f* SetTexCoordCount(UInt32 texCoordCount);
|
||||
|
||||
struct Face
|
||||
{
|
||||
std::size_t firstVertex;
|
||||
std::size_t vertexCount;
|
||||
UInt32 firstVertex;
|
||||
UInt32 vertexCount;
|
||||
};
|
||||
|
||||
struct FaceVertex
|
||||
{
|
||||
std::size_t normal;
|
||||
std::size_t position;
|
||||
std::size_t texCoord;
|
||||
UInt32 normal;
|
||||
UInt32 position;
|
||||
UInt32 texCoord;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
@@ -75,7 +75,7 @@ namespace Nz
|
||||
std::vector<Face> faces;
|
||||
std::vector<FaceVertex> vertices;
|
||||
String name;
|
||||
std::size_t material;
|
||||
UInt32 material;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Nz
|
||||
return m_materials.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetMaterialCount() const
|
||||
inline UInt32 OBJParser::GetMaterialCount() const
|
||||
{
|
||||
return m_materials.size();
|
||||
return static_cast<UInt32>(m_materials.size());
|
||||
}
|
||||
|
||||
inline OBJParser::Mesh* OBJParser::GetMeshes()
|
||||
@@ -42,9 +42,9 @@ namespace Nz
|
||||
return m_meshes.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetMeshCount() const
|
||||
inline UInt32 OBJParser::GetMeshCount() const
|
||||
{
|
||||
return m_meshes.size();
|
||||
return static_cast<UInt32>(m_meshes.size());
|
||||
}
|
||||
|
||||
inline const String& OBJParser::GetMtlLib() const
|
||||
@@ -62,9 +62,9 @@ namespace Nz
|
||||
return m_normals.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetNormalCount() const
|
||||
inline UInt32 OBJParser::GetNormalCount() const
|
||||
{
|
||||
return m_normals.size();
|
||||
return static_cast<UInt32>(m_normals.size());
|
||||
}
|
||||
|
||||
inline Vector4f* OBJParser::GetPositions()
|
||||
@@ -77,9 +77,9 @@ namespace Nz
|
||||
return m_positions.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetPositionCount() const
|
||||
inline UInt32 OBJParser::GetPositionCount() const
|
||||
{
|
||||
return m_positions.size();
|
||||
return static_cast<UInt32>(m_positions.size());
|
||||
}
|
||||
|
||||
inline Vector3f* OBJParser::GetTexCoords()
|
||||
@@ -92,18 +92,18 @@ namespace Nz
|
||||
return m_texCoords.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetTexCoordCount() const
|
||||
inline UInt32 OBJParser::GetTexCoordCount() const
|
||||
{
|
||||
return m_texCoords.size();
|
||||
return static_cast<UInt32>(m_texCoords.size());
|
||||
}
|
||||
|
||||
inline String* OBJParser::SetMaterialCount(std::size_t materialCount)
|
||||
inline String* OBJParser::SetMaterialCount(UInt32 materialCount)
|
||||
{
|
||||
m_materials.resize(materialCount);
|
||||
return m_materials.data();
|
||||
}
|
||||
|
||||
inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount)
|
||||
inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount)
|
||||
{
|
||||
m_meshes.resize(meshCount);
|
||||
return m_meshes.data();
|
||||
@@ -114,19 +114,19 @@ namespace Nz
|
||||
m_mtlLib = mtlLib;
|
||||
}
|
||||
|
||||
inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount)
|
||||
inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount)
|
||||
{
|
||||
m_normals.resize(normalCount);
|
||||
return m_normals.data();
|
||||
}
|
||||
|
||||
inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount)
|
||||
inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount)
|
||||
{
|
||||
m_positions.resize(positionCount);
|
||||
return m_positions.data();
|
||||
}
|
||||
|
||||
inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount)
|
||||
inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount)
|
||||
{
|
||||
m_texCoords.resize(texCoordCount);
|
||||
return m_texCoords.data();
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Nz
|
||||
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
|
||||
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
|
||||
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
bool CreateSkeletal(UInt32 jointCount);
|
||||
bool CreateStatic();
|
||||
void Destroy();
|
||||
|
||||
@@ -95,23 +95,23 @@ namespace Nz
|
||||
const Boxf& GetAABB() const;
|
||||
String GetAnimation() const;
|
||||
AnimationType GetAnimationType() const;
|
||||
unsigned int GetJointCount() const;
|
||||
ParameterList& GetMaterialData(unsigned int index);
|
||||
const ParameterList& GetMaterialData(unsigned int index) const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
UInt32 GetJointCount() const;
|
||||
ParameterList& GetMaterialData(UInt32 index);
|
||||
const ParameterList& GetMaterialData(UInt32 index) const;
|
||||
UInt32 GetMaterialCount() const;
|
||||
Skeleton* GetSkeleton();
|
||||
const Skeleton* GetSkeleton() const;
|
||||
SubMesh* GetSubMesh(const String& identifier);
|
||||
SubMesh* GetSubMesh(unsigned int index);
|
||||
SubMesh* GetSubMesh(UInt32 index);
|
||||
const SubMesh* GetSubMesh(const String& identifier) const;
|
||||
const SubMesh* GetSubMesh(unsigned int index) const;
|
||||
unsigned int GetSubMeshCount() const;
|
||||
int GetSubMeshIndex(const String& identifier) const;
|
||||
unsigned int GetTriangleCount() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
const SubMesh* GetSubMesh(UInt32 index) const;
|
||||
UInt32 GetSubMeshCount() const;
|
||||
UInt32 GetSubMeshIndex(const String& identifier) const;
|
||||
UInt32 GetTriangleCount() const;
|
||||
UInt32 GetVertexCount() const;
|
||||
|
||||
bool HasSubMesh(const String& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
bool HasSubMesh(UInt32 index = 0) const;
|
||||
|
||||
void InvalidateAABB() const;
|
||||
|
||||
@@ -125,14 +125,14 @@ namespace Nz
|
||||
void Recenter();
|
||||
|
||||
void RemoveSubMesh(const String& identifier);
|
||||
void RemoveSubMesh(unsigned int index);
|
||||
void RemoveSubMesh(UInt32 index);
|
||||
|
||||
bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams());
|
||||
bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams());
|
||||
|
||||
void SetAnimation(const String& animationPath);
|
||||
void SetMaterialCount(unsigned int matCount);
|
||||
void SetMaterialData(unsigned int matIndex, ParameterList data);
|
||||
void SetMaterialCount(UInt32 matCount);
|
||||
void SetMaterialData(UInt32 matIndex, ParameterList data);
|
||||
|
||||
void Transform(const Matrix4f& matrix);
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace Nz
|
||||
struct Sequence
|
||||
{
|
||||
String name;
|
||||
unsigned int firstFrame;
|
||||
unsigned int frameCount;
|
||||
unsigned int frameRate;
|
||||
UInt32 firstFrame;
|
||||
UInt32 frameCount;
|
||||
UInt32 frameRate;
|
||||
};
|
||||
|
||||
struct SequenceJoint
|
||||
|
||||
@@ -37,21 +37,21 @@ namespace Nz
|
||||
Skeleton(const Skeleton& skeleton);
|
||||
~Skeleton();
|
||||
|
||||
bool Create(unsigned int jointCount);
|
||||
bool Create(UInt32 jointCount);
|
||||
void Destroy();
|
||||
|
||||
const Boxf& GetAABB() const;
|
||||
Joint* GetJoint(const String& jointName);
|
||||
Joint* GetJoint(unsigned int index);
|
||||
Joint* GetJoint(UInt32 index);
|
||||
const Joint* GetJoint(const String& jointName) const;
|
||||
const Joint* GetJoint(unsigned int index) const;
|
||||
const Joint* GetJoint(UInt32 index) const;
|
||||
Joint* GetJoints();
|
||||
const Joint* GetJoints() const;
|
||||
unsigned int GetJointCount() const;
|
||||
UInt32 GetJointCount() const;
|
||||
int GetJointIndex(const String& jointName) const;
|
||||
|
||||
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation);
|
||||
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount);
|
||||
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount);
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ namespace Nz
|
||||
virtual const Boxf& GetAABB() const = 0;
|
||||
virtual AnimationType GetAnimationType() const = 0;
|
||||
virtual const IndexBuffer* GetIndexBuffer() const = 0;
|
||||
unsigned int GetMaterialIndex() const;
|
||||
UInt32 GetMaterialIndex() const;
|
||||
const Mesh* GetParent() const;
|
||||
PrimitiveMode GetPrimitiveMode() const;
|
||||
unsigned int GetTriangleCount() const;
|
||||
virtual unsigned int GetVertexCount() const = 0;
|
||||
UInt32 GetTriangleCount() const;
|
||||
virtual UInt32 GetVertexCount() const = 0;
|
||||
|
||||
virtual bool IsAnimated() const = 0;
|
||||
|
||||
void SetMaterialIndex(unsigned int matIndex);
|
||||
void SetMaterialIndex(UInt32 matIndex);
|
||||
void SetPrimitiveMode(PrimitiveMode mode);
|
||||
|
||||
// Signals:
|
||||
@@ -56,7 +56,7 @@ namespace Nz
|
||||
protected:
|
||||
PrimitiveMode m_primitiveMode;
|
||||
const Mesh* m_parent;
|
||||
unsigned int m_matIndex;
|
||||
UInt32 m_matIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Nz
|
||||
{
|
||||
NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled");
|
||||
return SparsePtr<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
#include <queue>
|
||||
@@ -52,9 +52,15 @@ namespace Nz
|
||||
|
||||
void Destroy();
|
||||
|
||||
inline void EnableCloseOnQuit(bool closeOnQuit);
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
inline void EnableEventPolling(bool enable);
|
||||
|
||||
void EnableKeyRepeat(bool enable);
|
||||
void EnableSmoothScrolling(bool enable);
|
||||
|
||||
EventHandler& GetEventHandler();
|
||||
WindowHandle GetHandle() const;
|
||||
unsigned int GetHeight() const;
|
||||
Vector2i GetPosition() const;
|
||||
@@ -71,8 +77,11 @@ namespace Nz
|
||||
inline bool IsValid() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
bool PollEvent(WindowEvent* event);
|
||||
|
||||
void ProcessEvents(bool block = false);
|
||||
|
||||
void SetCursor(WindowCursor cursor);
|
||||
void SetCursor(const Cursor& cursor);
|
||||
void SetEventListener(bool listener);
|
||||
@@ -90,6 +99,7 @@ namespace Nz
|
||||
void SetTitle(const String& title);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
bool WaitEvent(WindowEvent* event);
|
||||
|
||||
Window& operator=(const Window&) = delete;
|
||||
@@ -114,10 +124,12 @@ namespace Nz
|
||||
ConditionVariable m_eventCondition;
|
||||
Mutex m_eventMutex;
|
||||
Mutex m_eventConditionMutex;
|
||||
bool m_eventListener;
|
||||
bool m_waitForEvent;
|
||||
#endif
|
||||
EventHandler m_eventHandler;
|
||||
bool m_closed;
|
||||
bool m_closeOnQuit;
|
||||
bool m_eventPolling;
|
||||
bool m_ownsWindow;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,39 +11,25 @@ namespace Nz
|
||||
/*!
|
||||
* \class Nz::Window
|
||||
*/
|
||||
|
||||
inline Window::Window() :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_waitForEvent(false),
|
||||
#endif
|
||||
m_closeOnQuit(true),
|
||||
m_eventPolling(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline Window::Window(VideoMode mode, const String& title, UInt32 style) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(handle);
|
||||
@@ -59,10 +45,11 @@ namespace Nz
|
||||
m_eventCondition(std::move(window.m_eventCondition)),
|
||||
m_eventMutex(std::move(window.m_eventMutex)),
|
||||
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
||||
m_eventListener(window.m_eventListener),
|
||||
m_waitForEvent(window.m_waitForEvent),
|
||||
#endif
|
||||
m_closed(window.m_closed),
|
||||
m_closeOnQuit(window.m_closeOnQuit),
|
||||
m_eventPolling(window.m_eventPolling),
|
||||
m_ownsWindow(window.m_ownsWindow)
|
||||
{
|
||||
window.m_impl = nullptr;
|
||||
@@ -78,6 +65,26 @@ namespace Nz
|
||||
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
||||
}
|
||||
|
||||
inline void Window::EnableCloseOnQuit(bool closeOnQuit)
|
||||
{
|
||||
m_closeOnQuit = closeOnQuit;
|
||||
}
|
||||
|
||||
inline void Window::EnableEventPolling(bool enable)
|
||||
{
|
||||
m_eventPolling = enable;
|
||||
if (!m_eventPolling)
|
||||
{
|
||||
while (!m_events.empty())
|
||||
m_events.pop();
|
||||
}
|
||||
}
|
||||
|
||||
inline EventHandler& Nz::Window::GetEventHandler()
|
||||
{
|
||||
return m_eventHandler;
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen(bool checkClosed)
|
||||
{
|
||||
if (!m_impl)
|
||||
@@ -108,10 +115,17 @@ namespace Nz
|
||||
m_eventMutex.Lock();
|
||||
#endif
|
||||
|
||||
m_events.push(event);
|
||||
if (m_eventPolling)
|
||||
m_events.push(event);
|
||||
|
||||
m_eventHandler.Dispatch(event);
|
||||
|
||||
if (event.type == WindowEventType_Resized)
|
||||
OnWindowResized();
|
||||
|
||||
if (event.type == WindowEventType_Quit && m_closeOnQuit)
|
||||
Close();
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_eventMutex.Unlock();
|
||||
|
||||
@@ -132,10 +146,12 @@ namespace Nz
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_closed = window.m_closed;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
m_closed = window.m_closed;
|
||||
m_closeOnQuit = window.m_closeOnQuit;
|
||||
m_eventPolling = window.m_eventPolling;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
|
||||
window.m_impl = nullptr;
|
||||
|
||||
@@ -143,7 +159,6 @@ namespace Nz
|
||||
m_eventCondition = std::move(window.m_eventCondition);
|
||||
m_eventMutex = std::move(window.m_eventMutex);
|
||||
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
|
||||
m_eventListener = window.m_eventListener;
|
||||
m_waitForEvent = window.m_waitForEvent;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user