Merge remote-tracking branch 'origin/master' into Font-Update
Former-commit-id: ae0244334123a3442c7675df80b1a501a6837257
This commit is contained in:
@@ -26,7 +26,7 @@ using NzMusicLoader = NzResourceLoader<NzMusic, NzMusicParams>;
|
||||
|
||||
struct NzMusicImpl;
|
||||
|
||||
class NAZARA_API NzMusic : public NzSoundEmitter
|
||||
class NAZARA_API NzMusic : public NzSoundEmitter, NzNonCopyable
|
||||
{
|
||||
friend NzMusicLoader;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
@@ -235,7 +236,7 @@ inline void NzColor::ToCMYK(const NzColor& color, float* cyan, float* magenta, f
|
||||
float c, m, y;
|
||||
ToCMY(color, &c, &m, &y);
|
||||
|
||||
float k = std::min(std::min(std::min(1.f, c), m), y);
|
||||
float k = std::min({1.f, c, m, y});
|
||||
|
||||
if (NzNumberEquals(k, 1.f))
|
||||
{
|
||||
@@ -260,8 +261,8 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
|
||||
float g = color.g / 255.f;
|
||||
float b = color.b / 255.f;
|
||||
|
||||
float min = std::min(std::min(r, g), b); // Min. value of RGB
|
||||
float max = std::max(std::max(r, g), b); // Max. value of RGB
|
||||
float min = std::min({r, g, b}); // Min. value of RGB
|
||||
float max = std::max({r, g, b}); // Max. value of RGB
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
|
||||
@@ -21,32 +21,34 @@ class NzSparsePtr
|
||||
|
||||
NzSparsePtr();
|
||||
NzSparsePtr(T* ptr);
|
||||
NzSparsePtr(VoidPtr ptr, unsigned int stride);
|
||||
NzSparsePtr(VoidPtr ptr, int stride);
|
||||
template<typename U> NzSparsePtr(const NzSparsePtr<U>& ptr);
|
||||
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
||||
~NzSparsePtr() = default;
|
||||
|
||||
VoidPtr GetPtr() const;
|
||||
unsigned int GetStride() const;
|
||||
int GetStride() const;
|
||||
|
||||
void Reset();
|
||||
void Reset(T* ptr);
|
||||
void Reset(VoidPtr ptr, unsigned int stride);
|
||||
void Reset(VoidPtr ptr, int stride);
|
||||
void Reset(const NzSparsePtr& ptr);
|
||||
template<typename U> void Reset(const NzSparsePtr<U>& ptr);
|
||||
|
||||
void SetPtr(VoidPtr ptr);
|
||||
void SetStride(unsigned int stride);
|
||||
void SetStride(int stride);
|
||||
|
||||
operator bool() const;
|
||||
operator T*() const;
|
||||
T& operator*() const;
|
||||
T& operator->() const;
|
||||
T& operator[](unsigned int index) const;
|
||||
T& operator[](int index) const;
|
||||
|
||||
NzSparsePtr operator+(unsigned int count) const;
|
||||
NzSparsePtr operator-(unsigned int count) const;
|
||||
NzSparsePtr operator+(int count) const;
|
||||
NzSparsePtr operator-(int count) const;
|
||||
|
||||
NzSparsePtr& operator+=(unsigned int count);
|
||||
NzSparsePtr& operator-=(unsigned int count);
|
||||
NzSparsePtr& operator+=(int count);
|
||||
NzSparsePtr& operator-=(int count);
|
||||
|
||||
NzSparsePtr& operator++();
|
||||
NzSparsePtr operator++(int);
|
||||
@@ -65,7 +67,7 @@ class NzSparsePtr
|
||||
|
||||
private:
|
||||
BytePtr m_ptr;
|
||||
unsigned int m_stride;
|
||||
int m_stride;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/SparsePtr.inl>
|
||||
|
||||
@@ -17,11 +17,18 @@ NzSparsePtr<T>::NzSparsePtr(T* ptr)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, unsigned int stride)
|
||||
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, int stride)
|
||||
{
|
||||
Reset(ptr, stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzSparsePtr<T>::NzSparsePtr(const NzSparsePtr<U>& ptr)
|
||||
{
|
||||
Reset(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
|
||||
{
|
||||
@@ -29,7 +36,7 @@ typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
unsigned int NzSparsePtr<T>::GetStride() const
|
||||
int NzSparsePtr<T>::GetStride() const
|
||||
{
|
||||
return m_stride;
|
||||
}
|
||||
@@ -49,7 +56,7 @@ void NzSparsePtr<T>::Reset(T* ptr)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(VoidPtr ptr, unsigned int stride)
|
||||
void NzSparsePtr<T>::Reset(VoidPtr ptr, int stride)
|
||||
{
|
||||
SetPtr(ptr);
|
||||
SetStride(stride);
|
||||
@@ -62,6 +69,16 @@ void NzSparsePtr<T>::Reset(const NzSparsePtr& ptr)
|
||||
SetStride(ptr.GetStride());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
void NzSparsePtr<T>::Reset(const NzSparsePtr<U>& ptr)
|
||||
{
|
||||
static_assert(std::is_convertible<U*, T*>::value, "Source type pointer cannot be implicitely converted to target type pointer");
|
||||
|
||||
SetPtr(static_cast<T*>(ptr.GetPtr()));
|
||||
SetStride(ptr.GetStride());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||
{
|
||||
@@ -69,7 +86,7 @@ void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetStride(unsigned int stride)
|
||||
void NzSparsePtr<T>::SetStride(int stride)
|
||||
{
|
||||
m_stride = stride;
|
||||
}
|
||||
@@ -99,34 +116,36 @@ T& NzSparsePtr<T>::operator->() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzSparsePtr<T>::operator[](unsigned int index) const
|
||||
T& NzSparsePtr<T>::operator[](int index) const
|
||||
{
|
||||
return *reinterpret_cast<T*>(m_ptr + index*m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator+(unsigned int count) const
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator+(int count) const
|
||||
{
|
||||
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
|
||||
NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
|
||||
{
|
||||
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(unsigned int count)
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(int count)
|
||||
{
|
||||
m_ptr += count*m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(unsigned int count)
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(int count)
|
||||
{
|
||||
m_ptr -= count*m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -134,6 +153,7 @@ template<typename T>
|
||||
NzSparsePtr<T>& NzSparsePtr<T>::operator++()
|
||||
{
|
||||
m_ptr += m_stride;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
88
include/Nazara/Graphics/SkeletalModel.hpp
Normal file
88
include/Nazara/Graphics/SkeletalModel.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (C) 2014 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SKELETALMODEL_HPP
|
||||
#define NAZARA_SKELETALMODEL_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#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>
|
||||
|
||||
struct NAZARA_API NzSkeletalModelParameters : public NzModelParameters
|
||||
{
|
||||
bool loadAnimation = true;
|
||||
NzAnimationParams animation;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzSkeletalModel;
|
||||
|
||||
using NzSkeletalModelLoader = NzResourceLoader<NzSkeletalModel, NzSkeletalModelParameters>;
|
||||
|
||||
class NAZARA_API NzSkeletalModel : public NzModel, NzUpdatable
|
||||
{
|
||||
friend NzSkeletalModelLoader;
|
||||
//friend class NzScene;
|
||||
|
||||
public:
|
||||
NzSkeletalModel();
|
||||
NzSkeletalModel(const NzSkeletalModel& model);
|
||||
NzSkeletalModel(NzSkeletalModel&& model);
|
||||
~NzSkeletalModel();
|
||||
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||
void AdvanceAnimation(float elapsedTime);
|
||||
|
||||
void EnableAnimation(bool animation);
|
||||
|
||||
NzAnimation* GetAnimation() const;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
|
||||
bool IsAnimated() const;
|
||||
bool IsAnimationEnabled() const;
|
||||
bool IsDrawable() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzSkeletalModelParameters& params = NzSkeletalModelParameters());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzSkeletalModelParameters& params = NzSkeletalModelParameters());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzSkeletalModelParameters& params = NzSkeletalModelParameters());
|
||||
|
||||
void Reset();
|
||||
|
||||
bool SetAnimation(NzAnimation* animation);
|
||||
void SetMesh(NzMesh* mesh) override;
|
||||
bool SetSequence(const NzString& sequenceName);
|
||||
void SetSequence(unsigned int sequenceIndex);
|
||||
|
||||
NzSkeletalModel& operator=(const NzSkeletalModel& node);
|
||||
NzSkeletalModel& operator=(NzSkeletalModel&& node);
|
||||
|
||||
private:
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void Update() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
|
||||
NzAnimationRef m_animation;
|
||||
NzSkeleton m_skeleton;
|
||||
const NzSequence* m_currentSequence;
|
||||
bool m_animationEnabled;
|
||||
float m_interpolation;
|
||||
unsigned int m_currentFrame;
|
||||
unsigned int m_nextFrame;
|
||||
|
||||
static NzSkeletalModelLoader::LoaderList s_loaders;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SKELETALMODEL_HPP
|
||||
@@ -32,6 +32,7 @@ class NAZARA_API NzSprite : public NzSceneNode
|
||||
|
||||
void SetMaterial(NzMaterial* material, bool resizeSprite = true);
|
||||
void SetSize(const NzVector2f& size);
|
||||
void SetSize(float sizeX, float sizeY);
|
||||
void SetTexture(NzTexture* texture, bool resizeSprite = true);
|
||||
void SetTextureCoords(const NzRectf& coords);
|
||||
void SetTextureRect(const NzRectui& rect);
|
||||
|
||||
@@ -20,6 +20,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||
{
|
||||
public:
|
||||
NzView();
|
||||
NzView(const NzVector2f& size);
|
||||
~NzView();
|
||||
|
||||
void EnsureFrustumUpdate() const;
|
||||
@@ -32,6 +33,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||
NzVector3f GetForward() const;
|
||||
const NzFrustumf& GetFrustum() const;
|
||||
const NzMatrix4f& GetProjectionMatrix() const;
|
||||
const NzVector2f& GetSize() const;
|
||||
const NzRenderTarget* GetTarget() const;
|
||||
const NzRectf& GetTargetRegion() const;
|
||||
const NzMatrix4f& GetViewMatrix() const;
|
||||
@@ -39,6 +41,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||
float GetZFar() const;
|
||||
float GetZNear() const;
|
||||
|
||||
void SetSize(const NzVector2f& size);
|
||||
void SetTarget(const NzRenderTarget* renderTarget);
|
||||
void SetTarget(const NzRenderTarget& renderTarget);
|
||||
void SetTargetRegion(const NzRectf& region);
|
||||
@@ -63,6 +66,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||
mutable NzMatrix4f m_viewMatrix;
|
||||
NzRectf m_targetRegion;
|
||||
mutable NzRecti m_viewport;
|
||||
NzVector2f m_size;
|
||||
const NzRenderTarget* m_target;
|
||||
mutable bool m_frustumUpdated;
|
||||
mutable bool m_projectionMatrixUpdated;
|
||||
|
||||
@@ -562,9 +562,9 @@ template<typename T>
|
||||
bool NzMatrix4<T>::IsIdentity() const
|
||||
{
|
||||
return (NzNumberEquals(m11, F(1.0)) && NzNumberEquals(m12, F(0.0)) && NzNumberEquals(m13, F(0.0)) && NzNumberEquals(m14, F(0.0)) &&
|
||||
NzNumberEquals(m11, F(0.0)) && NzNumberEquals(m12, F(1.0)) && NzNumberEquals(m13, F(0.0)) && NzNumberEquals(m14, F(0.0)) &&
|
||||
NzNumberEquals(m11, F(0.0)) && NzNumberEquals(m12, F(0.0)) && NzNumberEquals(m13, F(1.0)) && NzNumberEquals(m14, F(0.0)) &&
|
||||
NzNumberEquals(m11, F(0.0)) && NzNumberEquals(m12, F(0.0)) && NzNumberEquals(m13, F(0.0)) && NzNumberEquals(m14, F(1.0)));
|
||||
NzNumberEquals(m21, F(0.0)) && NzNumberEquals(m22, F(1.0)) && NzNumberEquals(m23, F(0.0)) && NzNumberEquals(m24, F(0.0)) &&
|
||||
NzNumberEquals(m31, F(0.0)) && NzNumberEquals(m32, F(0.0)) && NzNumberEquals(m33, F(1.0)) && NzNumberEquals(m34, F(0.0)) &&
|
||||
NzNumberEquals(m41, F(0.0)) && NzNumberEquals(m42, F(0.0)) && NzNumberEquals(m43, F(0.0)) && NzNumberEquals(m44, F(1.0)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -61,7 +61,7 @@ class NAZARA_API NzRenderTarget
|
||||
|
||||
private:
|
||||
mutable std::unordered_map<Listener*, void*> m_listeners;
|
||||
bool m_listenersLocked;
|
||||
bool m_listenersLocked;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
|
||||
@@ -32,6 +32,7 @@ NAZARA_API void NzComputePlaneIndexVertexCount(const NzVector2ui& subdivision, u
|
||||
NAZARA_API void NzComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
template<typename T> NzBoxf NzComputeVerticesAABB(const T* vertices, unsigned int vertexCount);
|
||||
|
||||
///TODO: Remplacer le pointeur vertices par une structure composée de plusieurs SparsePtr
|
||||
NAZARA_API void NzGenerateBox(const NzVector3f& lengths, const NzVector3ui& subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzMeshVertex* vertices, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateCone(float length, float radius, unsigned int subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzMeshVertex* vertices, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzMeshVertex* vertices, NzIndexIterator indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
|
||||
@@ -50,13 +50,13 @@ class NAZARA_API NzNode
|
||||
NzNode& Interpolate(const NzNode& nodeA, const NzNode& nodeB, float interpolation, nzCoordSys coordSys = nzCoordSys_Global);
|
||||
|
||||
NzNode& Move(const NzVector3f& movement, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
NzNode& Move(float movementX, float movementY, float movementZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
NzNode& Move(float movementX, float movementY, float movementZ = 0.f, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
|
||||
NzNode& Rotate(const NzQuaternionf& rotation, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
|
||||
NzNode& Scale(const NzVector3f& scale);
|
||||
NzNode& Scale(float scale);
|
||||
NzNode& Scale(float scaleX, float scaleY, float scaleZ);
|
||||
NzNode& Scale(float scaleX, float scaleY, float scaleZ = 1.f);
|
||||
|
||||
void SetInheritRotation(bool inheritRotation);
|
||||
void SetInheritScale(bool inheritScale);
|
||||
@@ -64,18 +64,18 @@ class NAZARA_API NzNode
|
||||
void SetInitialRotation(const NzQuaternionf& quat);
|
||||
void SetInitialScale(const NzVector3f& scale);
|
||||
void SetInitialScale(float scale);
|
||||
void SetInitialScale(float scaleX, float scaleY, float scaleZ);
|
||||
void SetInitialScale(float scaleX, float scaleY, float scaleZ = 1.f);
|
||||
void SetInitialPosition(const NzVector3f& translation);
|
||||
void SetInitialPosition(float translationX, float translationXY, float translationZ);
|
||||
void SetInitialPosition(float translationX, float translationXY, float translationZ = 0.f);
|
||||
void SetName(const NzString& name);
|
||||
void SetParent(const NzNode* node = nullptr, bool keepDerived = false);
|
||||
void SetParent(const NzNode& node, bool keepDerived = false);
|
||||
void SetPosition(const NzVector3f& translation, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetPosition(float translationX, float translationXY, float translationZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetPosition(float translationX, float translationY, float translationZ = 0.f, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetRotation(const NzQuaternionf& quat, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(const NzVector3f& scale, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(float scale, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(float scaleX, float scaleY, float scaleZ, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetScale(float scaleX, float scaleY, float scaleZ = 1.f, nzCoordSys coordSys = nzCoordSys_Local);
|
||||
void SetTransformMatrix(const NzMatrix4f& matrix);
|
||||
|
||||
// Local -> global
|
||||
|
||||
Reference in New Issue
Block a user