Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan

Former-commit-id: 2d7b8f2258dcb13272482a886aa88e780bffd307 [formerly ffaa87cb5564013addc8749dff6589f732ffe599] [formerly 6792cc9d7a87711eab92875da19bc4200e4463d6 [formerly 0a51ed831d274b1e325cc2efc57016094a7aee83]]
Former-commit-id: b16416186770928262bc982969e9dbf10308d121 [formerly 92dc66185439cf46dcd3fb4672061d75d003d508]
Former-commit-id: 34072644c9bf88918998070201d9b131ea5b3731
This commit is contained in:
Lynix
2016-08-08 08:54:09 +02:00
141 changed files with 4226 additions and 2233 deletions

View File

@@ -78,7 +78,7 @@ namespace Nz
* \param v Object to hash
*
* \remark a HashAppend specialization for type T is required
*
*
* \see ComputeHash
*/
template<typename T>
@@ -124,6 +124,7 @@ namespace Nz
template<typename T, std::size_t N>
constexpr std::size_t CountOf(T(&name)[N]) noexcept
{
NazaraUnused(name);
return N;
}

View File

@@ -23,10 +23,10 @@ namespace Nz
/*!
* \brief Constructs a ByteArray object with a raw memory and a size
*
* \param ptr Pointer to raw memory
* \param buffer Pointer to raw memory
* \param n Size that can be accessed
*
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
*/
inline ByteArray::ByteArray(const void* buffer, size_type n) :
@@ -62,10 +62,10 @@ namespace Nz
/*!
* \brief Appends the content of raw memory
*
* \param ptr Constant pointer to raw memory
* \param buffer Constant pointer to raw memory
* \param n Size that can be read
*
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
*
* \see Insert
*/
@@ -298,11 +298,11 @@ namespace Nz
}
/*!
* \brief Inserts n times the same value at the iterator position
* \brief Inserts n times the same byte at the iterator position
*
* \param pos Iterator to the position
* \param n Number of repetitions
* \param value Value to repeat
* \param byte Value to repeat
*/
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte)
@@ -359,10 +359,10 @@ namespace Nz
/*!
* \brief Prepends the content of raw memory
*
* \param ptr Constant pointer to raw memory
* \param buffer Constant pointer to raw memory
* \param n Size that can be read
*
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
*
* \see Insert
*/
@@ -682,8 +682,7 @@ namespace Nz
* \brief Checks whether the first byte array is equal to the second byte array
* \return true if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator==(const ByteArray& rhs) const
@@ -695,8 +694,7 @@ namespace Nz
* \brief Checks whether the first byte array is equal to the second byte array
* \return false if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator!=(const ByteArray& rhs) const
@@ -708,8 +706,7 @@ namespace Nz
* \brief Checks whether the first byte array is less than the second byte array
* \return true if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator<(const ByteArray& rhs) const
@@ -721,8 +718,7 @@ namespace Nz
* \brief Checks whether the first byte array is less or equal than the second byte array
* \return true if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator<=(const ByteArray& rhs) const
@@ -731,11 +727,10 @@ namespace Nz
}
/*!
* \brief Checks whether the first byte array is greather than the second byte array
* \brief Checks whether the first byte array is greater than the second byte array
* \return true if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator>(const ByteArray& rhs) const
@@ -744,11 +739,10 @@ namespace Nz
}
/*!
* \brief Checks whether the first byte array is greather or equal than the second byte array
* \brief Checks whether the first byte array is greater or equal than the second byte array
* \return true if it is the case
*
* \param first ByteArray to compare in left hand side
* \param second ByteArray to compare in right hand side
* \param rhs ByteArray to compare with
*/
inline bool ByteArray::operator>=(const ByteArray& rhs) const

View File

@@ -291,15 +291,16 @@ namespace Nz
template<typename T>
std::ostream& operator<<(std::ostream& out, const ObjectHandle<T>& handle)
{
return handle.ToString();
out << handle.ToString();
return out;
}
/*!
* \brief Checks whether the first object handle is equal to the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator==(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -311,8 +312,8 @@ namespace Nz
* \brief Checks whether the object is equal to the second object handle
* \return true if it is the case
*
* \param first Object to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs Object to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator==(const T& lhs, const ObjectHandle<T>& rhs)
@@ -324,8 +325,8 @@ namespace Nz
* \brief Checks whether the object handle is equal to the second object
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second Object to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs Object to compare in right hand side
*/
template<typename T>
bool operator==(const ObjectHandle<T>& lhs, const T& rhs)
@@ -337,8 +338,8 @@ namespace Nz
* \brief Checks whether the first object handle is equal to the second object handle
* \return false if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator!=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -350,8 +351,8 @@ namespace Nz
* \brief Checks whether the object is equal to the second object handle
* \return false if it is the case
*
* \param first Object to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs Object to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator!=(const T& lhs, const ObjectHandle<T>& rhs)
@@ -363,8 +364,8 @@ namespace Nz
* \brief Checks whether the object handle is equal to the second object
* \return false if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second Object to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs Object to compare in right hand side
*/
template<typename T>
bool operator!=(const ObjectHandle<T>& lhs, const T& rhs)
@@ -376,8 +377,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -389,8 +390,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<(const T& lhs, const ObjectHandle<T>& rhs)
@@ -402,8 +403,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<(const ObjectHandle<T>& lhs, const T& rhs)
@@ -415,8 +416,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -428,8 +429,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<=(const T& lhs, const ObjectHandle<T>& rhs)
@@ -441,8 +442,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator<=(const ObjectHandle<T>& lhs, const T& rhs)
@@ -454,8 +455,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -467,8 +468,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>(const T& lhs, const ObjectHandle<T>& rhs)
@@ -480,8 +481,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>(const ObjectHandle<T>& lhs, const T& rhs)
@@ -493,8 +494,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
@@ -506,8 +507,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>=(const T& lhs, const ObjectHandle<T>& rhs)
@@ -519,8 +520,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectHandle to compare in left hand side
* \param second ObjectHandle to compare in right hand side
* \param lhs ObjectHandle to compare in left hand side
* \param rhs ObjectHandle to compare in right hand side
*/
template<typename T>
bool operator>=(const ObjectHandle<T>& lhs, const T& rhs)

View File

@@ -184,7 +184,7 @@ namespace Nz
{
return m_object;
}
/*!
* \brief Assigns the object into this
* \return A reference to this
@@ -251,8 +251,8 @@ namespace Nz
* \brief Checks whether the first object handle is equal to the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -264,8 +264,8 @@ namespace Nz
* \brief Checks whether the object is equal to the second object handle
* \return true if it is the case
*
* \param first Object to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs Object to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator==(const T& lhs, const ObjectRef<T>& rhs)
@@ -277,8 +277,8 @@ namespace Nz
* \brief Checks whether the object handle is equal to the second object
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second Object to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs Object to compare in right hand side
*/
template<typename T>
bool operator==(const ObjectRef<T>& lhs, const T& rhs)
@@ -290,8 +290,8 @@ namespace Nz
* \brief Checks whether the first object handle is equal to the second object handle
* \return false if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -303,8 +303,8 @@ namespace Nz
* \brief Checks whether the object is equal to the second object handle
* \return false if it is the case
*
* \param first Object to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs Object to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator!=(const T& lhs, const ObjectRef<T>& rhs)
@@ -316,8 +316,8 @@ namespace Nz
* \brief Checks whether the object handle is equal to the second object
* \return false if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second Object to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs Object to compare in right hand side
*/
template<typename T>
bool operator!=(const ObjectRef<T>& lhs, const T& rhs)
@@ -329,8 +329,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -342,8 +342,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<(const T& lhs, const ObjectRef<T>& rhs)
@@ -355,8 +355,8 @@ namespace Nz
* \brief Checks whether the first object handle is less than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<(const ObjectRef<T>& lhs, const T& rhs)
@@ -368,8 +368,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -381,8 +381,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<=(const T& lhs, const ObjectRef<T>& rhs)
@@ -394,8 +394,8 @@ namespace Nz
* \brief Checks whether the first object handle is less or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator<=(const ObjectRef<T>& lhs, const T& rhs)
@@ -407,8 +407,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -420,8 +420,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>(const T& lhs, const ObjectRef<T>& rhs)
@@ -433,8 +433,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>(const ObjectRef<T>& lhs, const T& rhs)
@@ -446,8 +446,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
@@ -459,8 +459,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>=(const T& lhs, const ObjectRef<T>& rhs)
@@ -472,8 +472,8 @@ namespace Nz
* \brief Checks whether the first object handle is greather or equal than the second object handle
* \return true if it is the case
*
* \param first ObjectRef to compare in left hand side
* \param second ObjectRef to compare in right hand side
* \param lhs ObjectRef to compare in left hand side
* \param rhs ObjectRef to compare in right hand side
*/
template<typename T>
bool operator>=(const ObjectRef<T>& lhs, const T& rhs)

View File

@@ -48,7 +48,7 @@ namespace Nz
* \remark The previous file content will be discarded, to prevent this behavior you should use SaveToStream
* \remark The file extension will be used as format for the saver ("image.png" => "png", to write a specified format to a user-specified extension you should use SaveToStream
*
* \seealso SaveToStream
* \see SaveToStream
*/
template<typename Type, typename Parameters>
bool ResourceSaver<Type, Parameters>::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters)
@@ -114,7 +114,7 @@ namespace Nz
* \param format Data format to save the resource to
* \param parameters Parameters for the saving
*
* \seealso SaveToFile
* \see SaveToFile
*/
template<typename Type, typename Parameters>
bool ResourceSaver<Type, Parameters>::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters)

View File

@@ -45,7 +45,7 @@ namespace Nz
*/
inline String::SharedString::SharedString(std::size_t strSize) :
capacity(strSize),
capacity(strSize),
size(strSize),
string(new char[strSize + 1])
{
@@ -84,16 +84,15 @@ namespace Nz
namespace std
{
/*!
* \brief Specialisation of std to hash
* \return Result of the hash
*
* \param str String to hash
*/
template<>
struct hash<Nz::String>
{
/*!
* \brief Specialisation of std to hash
* \return Result of the hash
*
* \param str String to hash
*/
size_t operator()(const Nz::String& str) const
{
// Algorithme DJB2

View File

@@ -1,4 +1,4 @@
// This file was automatically generated on 12 Jul 2016 at 17:44:43
// This file was automatically generated on 20 Jul 2016 at 13:49:17
/*
Nazara Engine - Graphics module
@@ -63,11 +63,12 @@
#include <Nazara/Graphics/ParticleDeclaration.hpp>
#include <Nazara/Graphics/ParticleEmitter.hpp>
#include <Nazara/Graphics/ParticleGenerator.hpp>
#include <Nazara/Graphics/ParticleGroup.hpp>
#include <Nazara/Graphics/ParticleMapper.hpp>
#include <Nazara/Graphics/ParticleRenderer.hpp>
#include <Nazara/Graphics/ParticleStruct.hpp>
#include <Nazara/Graphics/ParticleSystem.hpp>
#include <Nazara/Graphics/Renderable.hpp>
#include <Nazara/Graphics/MaterialPipeline.hpp>
#include <Nazara/Graphics/RenderTechniques.hpp>
#include <Nazara/Graphics/SceneData.hpp>
#include <Nazara/Graphics/SkeletalModel.hpp>

View File

@@ -38,7 +38,6 @@ namespace Nz
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
// mais je n'ai pas d'autre solution tout aussi performante pour le moment...
virtual void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0;
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;

View File

@@ -121,8 +121,7 @@ namespace Nz
inline void Billboard::SetDefaultMaterial()
{
MaterialRef material = Material::New();
material->Enable(RendererParameter_FaceCulling, true);
material->EnableLighting(false);
material->EnableFaceCulling(true);
SetMaterial(std::move(material));
}

View File

@@ -9,7 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
#include <Nazara/Graphics/Material.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Matrix4.hpp>
@@ -21,15 +21,12 @@
namespace Nz
{
class ForwardRenderQueue;
class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue
{
public:
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
~DeferredRenderQueue() = default;
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
@@ -44,11 +41,6 @@ namespace Nz
void Clear(bool fully = false) override;
struct MeshDataComparator
{
bool operator()(const MeshData& data1, const MeshData& data2) const;
};
struct MeshInstanceEntry
{
NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot);
@@ -57,12 +49,7 @@ namespace Nz
std::vector<Matrix4f> instances;
};
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
struct BatchedModelMaterialComparator
{
bool operator()(const Material* mat1, const Material* mat2) const;
};
typedef std::map<MeshData, MeshInstanceEntry, ForwardRenderQueue::MeshDataComparator> MeshInstanceContainer;
struct BatchedModelEntry
{
@@ -70,14 +57,21 @@ namespace Nz
MeshInstanceContainer meshMap;
bool enabled = false;
bool instancingEnabled = false;
};
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
typedef std::map<const Material*, BatchedModelEntry, ForwardRenderQueue::MaterialComparator> MeshMaterialBatches;
struct BatchedMaterialEntry
{
std::size_t maxInstanceCount = 0;
MeshMaterialBatches materialMap;
};
typedef std::map<const MaterialPipeline*, BatchedMaterialEntry, ForwardRenderQueue::MaterialPipelineComparator> MeshPipelineBatches;
struct Layer
{
ModelBatches opaqueModels;
MeshPipelineBatches opaqueModels;
unsigned int clearCount = 0;
};

View File

@@ -26,7 +26,6 @@ namespace Nz
DepthRenderQueue();
~DepthRenderQueue() = default;
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;

View File

@@ -18,7 +18,7 @@ namespace Nz
{
NazaraAssert(material, "Invalid material");
return material->HasDepthMaterial() || (material->IsEnabled(RendererParameter_DepthBuffer) && material->IsEnabled(RendererParameter_DepthWrite) && material->IsShadowCastingEnabled());
return material->HasDepthMaterial() || (material->IsDepthBufferEnabled() && material->IsDepthWriteEnabled() && material->IsShadowCastingEnabled());
}
}

View File

@@ -63,6 +63,7 @@ namespace Nz
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
Buffer m_vertexBuffer;
mutable DepthRenderQueue m_renderQueue;
Texture m_whiteTexture;
VertexBuffer m_billboardPointBuffer;
VertexBuffer m_spriteBuffer;

View File

@@ -31,7 +31,6 @@ namespace Nz
ForwardRenderQueue() = default;
~ForwardRenderQueue() = default;
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
@@ -48,6 +47,16 @@ namespace Nz
void Sort(const AbstractViewer* viewer);
struct MaterialComparator
{
bool operator()(const Material* mat1, const Material* mat2) const;
};
struct MaterialPipelineComparator
{
bool operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const;
};
/// Billboards
struct BillboardData
{
@@ -57,11 +66,6 @@ namespace Nz
Vector2f sinCos;
};
struct BatchedBillboardComparator
{
bool operator()(const Material* mat1, const Material* mat2) const;
};
struct BatchedBillboardEntry
{
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
@@ -69,7 +73,15 @@ namespace Nz
std::vector<BillboardData> billboards;
};
typedef std::map<const Material*, BatchedBillboardEntry, BatchedBillboardComparator> BatchedBillboardContainer;
typedef std::map<const Material*, BatchedBillboardEntry, MaterialComparator> BatchedBillboardContainer;
struct BatchedBillboardPipelineEntry
{
BatchedBillboardContainer materialMap;
bool enabled = false;
};
typedef std::map<const MaterialPipeline*, BatchedBillboardPipelineEntry, MaterialPipelineComparator> BillboardPipelineBatches;
/// Sprites
struct SpriteChain_XYZ_Color_UV
@@ -85,22 +97,25 @@ namespace Nz
std::vector<SpriteChain_XYZ_Color_UV> spriteChains;
};
struct BatchedSpriteMaterialComparator
{
bool operator()(const Material* mat1, const Material* mat2);
};
typedef std::map<const Texture*, BatchedSpriteEntry> BasicSpriteOverlayContainer;
typedef std::map<const Texture*, BatchedSpriteEntry> SpriteOverlayBatches;
struct BatchedBasicSpriteEntry
{
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
BasicSpriteOverlayContainer overlayMap;
SpriteOverlayBatches overlayMap;
bool enabled = false;
};
typedef std::map<const Material*, BatchedBasicSpriteEntry> BasicSpriteBatches;
typedef std::map<const Material*, BatchedBasicSpriteEntry, MaterialComparator> SpriteMaterialBatches;
struct BatchedSpritePipelineEntry
{
SpriteMaterialBatches materialMap;
bool enabled = false;
};
typedef std::map<const MaterialPipeline*, BatchedSpritePipelineEntry, MaterialPipelineComparator> SpritePipelineBatches;
/// Meshes
struct MeshDataComparator
@@ -119,21 +134,23 @@ namespace Nz
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
struct BatchedModelMaterialComparator
{
bool operator()(const Material* mat1, const Material* mat2) const;
};
struct BatchedModelEntry
{
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
MeshInstanceContainer meshMap;
bool enabled = false;
bool instancingEnabled = false;
};
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
typedef std::map<const Material*, BatchedModelEntry, MaterialComparator> MeshMaterialBatches;
struct BatchedMaterialEntry
{
std::size_t maxInstanceCount = 0;
MeshMaterialBatches materialMap;
};
typedef std::map<const MaterialPipeline*, BatchedMaterialEntry, MaterialPipelineComparator> MeshPipelineBatches;
struct TransparentModelData
{
@@ -147,9 +164,9 @@ namespace Nz
struct Layer
{
BatchedBillboardContainer billboards;
BasicSpriteBatches basicSprites;
ModelBatches opaqueModels;
BillboardPipelineBatches billboards;
SpritePipelineBatches basicSprites;
MeshPipelineBatches opaqueModels;
TransparentModelContainer transparentModels;
std::vector<TransparentModelData> transparentModelData;
std::vector<const Drawable*> otherDrawables;

View File

@@ -84,6 +84,7 @@ namespace Nz
mutable std::vector<LightIndex> m_lights;
Buffer m_vertexBuffer;
mutable ForwardRenderQueue m_renderQueue;
Texture m_whiteTexture;
VertexBuffer m_billboardPointBuffer;
VertexBuffer m_spriteBuffer;
unsigned int m_maxLightPassPerObject;

View File

@@ -54,7 +54,7 @@ namespace Nz
struct InstanceData
{
InstanceData(Matrix4f& referenceMatrix) :
InstanceData(const Matrix4f& referenceMatrix) :
transformMatrix(&referenceMatrix),
flags(0)
{
@@ -75,7 +75,7 @@ namespace Nz
std::vector<UInt8> data;
BoundingVolumef volume;
Matrix4f* transformMatrix;
const Matrix4f* transformMatrix;
UInt32 flags;
int renderOrder;
};

View File

@@ -20,7 +20,7 @@
#include <Nazara/Core/String.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Graphics/MaterialPipeline.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Renderer/TextureSampler.hpp>
#include <Nazara/Renderer/UberShader.hpp>
@@ -58,20 +58,33 @@ namespace Nz
public:
inline Material();
inline Material(const MaterialPipeline* pipeline);
inline Material(const MaterialPipelineInfo& pipelineInfo);
inline Material(const String& pipelineName);
inline Material(const Material& material);
inline ~Material();
const Shader* Apply(UInt32 shaderFlags = 0, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const;
void Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const;
void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams());
inline void Enable(RendererParameter renderParameter, bool enable);
inline void Configure(const MaterialPipeline* pipeline);
inline void Configure(const MaterialPipelineInfo& pipelineInfo);
inline bool Configure(const String& pipelineName);
inline void EnableAlphaTest(bool alphaTest);
inline void EnableBlending(bool blending);
inline void EnableColorWrite(bool colorWrite);
inline void EnableDepthBuffer(bool depthBuffer);
inline void EnableDepthSorting(bool depthSorting);
inline void EnableLighting(bool lighting);
inline void EnableDepthWrite(bool depthWrite);
inline void EnableFaceCulling(bool faceCulling);
inline void EnableScissorTest(bool scissorTest);
inline void EnableShadowCasting(bool castShadows);
inline void EnableShadowReceive(bool receiveShadows);
inline void EnableTransform(bool transform);
inline void EnableStencilTest(bool stencilTest);
inline void EnsurePipelineUpdate() const;
inline const TextureRef& GetAlphaMap() const;
inline float GetAlphaThreshold() const;
@@ -87,10 +100,12 @@ namespace Nz
inline FaceSide GetFaceCulling() const;
inline FaceFilling GetFaceFilling() const;
inline const TextureRef& GetHeightMap() const;
inline float GetLineWidth() const;
inline const TextureRef& GetNormalMap() const;
inline const RenderStates& GetRenderStates() const;
inline const MaterialPipeline* GetPipeline() const;
inline const MaterialPipelineInfo& GetPipelineInfo() const;
inline float GetPointSize() const;
inline const UberShader* GetShader() const;
inline const UberShaderInstance* GetShaderInstance(UInt32 flags = ShaderFlags_None) const;
inline float GetShininess() const;
inline Color GetSpecularColor() const;
inline const TextureRef& GetSpecularMap() const;
@@ -107,12 +122,16 @@ namespace Nz
inline bool HasSpecularMap() const;
inline bool IsAlphaTestEnabled() const;
inline bool IsBlendingEnabled() const;
inline bool IsColorWriteEnabled() const;
inline bool IsDepthBufferEnabled() const;
inline bool IsDepthSortingEnabled() const;
inline bool IsEnabled(RendererParameter renderParameter) const;
inline bool IsLightingEnabled() const;
inline bool IsDepthWriteEnabled() const;
inline bool IsFaceCullingEnabled() const;
inline bool IsScissorTestEnabled() const;
inline bool IsStencilTestEnabled() const;
inline bool IsShadowCastingEnabled() const;
inline bool IsShadowReceiveEnabled() const;
inline bool IsTransformEnabled() const;
inline bool LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams());
inline bool LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams());
@@ -139,9 +158,10 @@ namespace Nz
inline void SetFaceFilling(FaceFilling filling);
inline bool SetHeightMap(const String& textureName);
inline void SetHeightMap(TextureRef textureName);
inline void SetLineWidth(float lineWidth);
inline bool SetNormalMap(const String& textureName);
inline void SetNormalMap(TextureRef textureName);
inline void SetRenderStates(const RenderStates& states);
inline void SetPointSize(float pointSize);
inline void SetShader(UberShaderConstRef uberShader);
inline bool SetShader(const String& uberShaderName);
inline void SetShininess(float shininess);
@@ -161,16 +181,9 @@ namespace Nz
NazaraSignal(OnMaterialReset, const Material* /*material*/);
private:
struct ShaderInstance
{
const Shader* shader;
UberShaderInstance* uberInstance = nullptr;
int uniforms[MaterialUniform_Max + 1];
};
void Copy(const Material& material);
void GenerateShader(UInt32 flags) const;
inline void InvalidateShaders();
inline void InvalidatePipeline();
inline void UpdatePipeline() const;
static bool Initialize();
static void Uninitialize();
@@ -179,7 +192,8 @@ namespace Nz
Color m_diffuseColor;
Color m_specularColor;
MaterialRef m_depthMaterial; //< Materialception
RenderStates m_states;
mutable const MaterialPipeline* m_pipeline;
MaterialPipelineInfo m_pipelineInfo;
TextureSampler m_diffuseSampler;
TextureSampler m_specularSampler;
TextureRef m_alphaMap;
@@ -188,14 +202,8 @@ namespace Nz
TextureRef m_heightMap;
TextureRef m_normalMap;
TextureRef m_specularMap;
UberShaderConstRef m_uberShader;
mutable ShaderInstance m_shaders[ShaderFlags_Max + 1];
bool m_alphaTestEnabled;
bool m_depthSortingEnabled;
bool m_lightingEnabled;
mutable bool m_pipelineUpdated;
bool m_shadowCastingEnabled;
bool m_shadowReceiveEnabled;
bool m_transformEnabled;
float m_alphaThreshold;
float m_shininess;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,95 @@
// Copyright (C) 2016 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_MATERIALPIPELINE_HPP
#define NAZARA_MATERIALPIPELINE_HPP
#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;
UberShaderConstRef uberShader;
};
inline bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs);
inline bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs);
class MaterialPipeline;
using MaterialPipelineConstRef = ObjectRef<const MaterialPipeline>;
using MaterialPipelineLibrary = ObjectLibrary<MaterialPipeline>;
using MaterialPipelineRef = ObjectRef<MaterialPipeline>;
class NAZARA_GRAPHICS_API MaterialPipeline : public RefCounted
{
friend class Graphics;
friend MaterialPipelineLibrary;
public:
struct Instance;
MaterialPipeline(const MaterialPipeline&) = delete;
MaterialPipeline(MaterialPipeline&&) = delete;
~MaterialPipeline() = default;
inline const Instance& Apply(UInt32 flags = ShaderFlags_None) const;
MaterialPipeline& operator=(const MaterialPipeline&) = delete;
MaterialPipeline& operator=(MaterialPipeline&&) = delete;
inline const MaterialPipelineInfo& GetInfo() const;
inline const Instance& GetInstance(UInt32 flags = ShaderFlags_None) const;
static MaterialPipelineRef GetPipeline(const MaterialPipelineInfo& pipelineInfo);
struct Instance
{
RenderPipeline renderPipeline;
UberShaderInstance* uberInstance = nullptr;
std::array<int, MaterialUniform_Max + 1> uniforms;
};
private:
inline MaterialPipeline(const MaterialPipelineInfo& pipelineInfo);
void GenerateRenderPipeline(UInt32 flags) const;
static bool Initialize();
template<typename... Args> static MaterialPipelineRef New(Args&&... args);
static void Uninitialize();
MaterialPipelineInfo m_pipelineInfo;
mutable std::array<Instance, ShaderFlags_Max + 1> m_instances;
using PipelineCache = std::unordered_map<MaterialPipelineInfo, MaterialPipelineRef>;
static PipelineCache s_pipelineCache;
static MaterialPipelineLibrary::LibraryMap s_library;
};
}
#include <Nazara/Graphics/MaterialPipeline.inl>
#endif // NAZARA_MATERIALPIPELINE_HPP

View File

@@ -0,0 +1,143 @@
// Copyright (C) 2016 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/Graphics/MaterialPipeline.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Renderer/Renderer.hpp>
#include <functional>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline MaterialPipeline::MaterialPipeline(const MaterialPipelineInfo& pipelineInfo) :
m_pipelineInfo(pipelineInfo)
{
}
/*!
* \brief Enable pipeline states for rendering
*
* \param flags Shader flags
*/
inline const MaterialPipeline::Instance& MaterialPipeline::Apply(UInt32 flags) const
{
const Instance& instance = GetInstance(flags);
instance.uberInstance->Activate();
Renderer::SetRenderStates(m_pipelineInfo);
return instance;
}
/*!
* \brief Retrieve a MaterialPipelineInfo object describing this pipeline
*
* \return Pipeline informations
*/
const MaterialPipelineInfo& MaterialPipeline::GetInfo() const
{
return m_pipelineInfo;
}
/*!
* \brief Retrieve (and generate if required) a pipeline instance using shader flags without applying it
*
* \param flags Shader flags
*
* \return Pipeline instance
*/
inline const MaterialPipeline::Instance& MaterialPipeline::GetInstance(UInt32 flags) const
{
const Instance& instance = m_instances[flags];
if (!instance.uberInstance)
GenerateRenderPipeline(flags);
return instance;
}
bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs)
{
if (!operator==(static_cast<const RenderStates&>(lhs), static_cast<const RenderStates&>(rhs)))
return false;
#define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false
#define NazaraPipelineBoolMember NazaraPipelineMember
NazaraPipelineBoolMember(alphaTest);
NazaraPipelineBoolMember(depthSorting);
NazaraPipelineBoolMember(hasAlphaMap);
NazaraPipelineBoolMember(hasDiffuseMap);
NazaraPipelineBoolMember(hasEmissiveMap);
NazaraPipelineBoolMember(hasHeightMap);
NazaraPipelineBoolMember(hasNormalMap);
NazaraPipelineBoolMember(hasSpecularMap);
NazaraPipelineBoolMember(shadowReceive);
NazaraPipelineMember(uberShader);
#undef NazaraPipelineMember
#undef NazaraPipelineBoolMember
return true;
}
bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs)
{
return !operator==(lhs, rhs);
}
/*!
* \brief Creates a new MaterialPipeline from the arguments
* \return A reference to the newly created material pipeline
*
* \param args Arguments for the material pipeline
*/
template<typename... Args>
MaterialPipelineRef MaterialPipeline::New(Args&&... args)
{
std::unique_ptr<MaterialPipeline> object(new MaterialPipeline(std::forward<Args>(args)...));
return object.release();
}
}
namespace std
{
template<>
struct hash<Nz::MaterialPipelineInfo>
{
size_t operator()(const Nz::MaterialPipelineInfo& pipelineInfo) const
{
hash<Nz::RenderStates> parentHash;
std::size_t seed = parentHash(pipelineInfo);
Nz::UInt16 parameterHash = 0;
Nz::UInt16 parameterIndex = 0;
#define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
#define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
NazaraPipelineBoolMember(alphaTest);
NazaraPipelineBoolMember(depthSorting);
NazaraPipelineBoolMember(hasAlphaMap);
NazaraPipelineBoolMember(hasDiffuseMap);
NazaraPipelineBoolMember(hasEmissiveMap);
NazaraPipelineBoolMember(hasHeightMap);
NazaraPipelineBoolMember(hasNormalMap);
NazaraPipelineBoolMember(hasSpecularMap);
NazaraPipelineBoolMember(shadowReceive);
NazaraPipelineMember(uberShader);
#undef NazaraPipelineMember
#undef NazaraPipelineBoolMember
Nz::HashCombine(seed, parameterHash);
return seed;
}
};
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -45,6 +45,7 @@ namespace Nz
virtual ~Model();
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;

View File

@@ -7,6 +7,22 @@
namespace Nz
{
/*!
* \brief Adds this model to a render queue, using user-specified transform matrix and render order
*
* This can be useful when drawing particles
*
* \param renderQueue Queue to be added
* \param transformMatrix Transform matrix to be used for rendering the model
* \param renderOrder Specify the renderqueue layer to be used
*/
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
{
InstanceData instanceData(transformMatrix);
instanceData.renderOrder = renderOrder;
return AddToRenderQueue(renderQueue, instanceData);
}
/*!
* \brief Creates a new Model from the arguments
* \return A reference to the newly created model

View File

@@ -18,7 +18,7 @@ namespace Nz
{
class ParticleController;
class ParticleMapper;
class ParticleSystem;
class ParticleGroup;
using ParticleControllerConstRef = ObjectRef<const ParticleController>;
using ParticleControllerLibrary = ObjectLibrary<ParticleController>;
@@ -34,7 +34,7 @@ namespace Nz
ParticleController(const ParticleController& controller);
virtual ~ParticleController();
virtual void Apply(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
virtual void Apply(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
// Signals:
NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/);

View File

@@ -15,6 +15,7 @@
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <array>
namespace Nz
{
@@ -46,6 +47,7 @@ namespace Nz
static ParticleDeclaration* Get(ParticleLayout layout);
static bool IsTypeSupported(ComponentType type);
template<typename... Args> static ParticleDeclarationRef New(Args&&... args);
// Signals:
NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/);
@@ -68,12 +70,14 @@ namespace Nz
*/
};
Component m_components[ParticleComponent_Max + 1];
std::array<Component, ParticleComponent_Max + 1> m_components;
unsigned int m_stride;
static ParticleDeclaration s_declarations[ParticleLayout_Max + 1];
static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations;
static ParticleDeclarationLibrary::LibraryMap s_library;
};
}
#include <Nazara/Graphics/ParticleDeclaration.inl>
#endif // NAZARA_PARTICLEDECLARATION_HPP

View File

@@ -0,0 +1,18 @@
// Copyright (C) 2016 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 <memory>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
template<typename... Args>
ParticleDeclarationRef ParticleDeclaration::New(Args&&... args)
{
std::unique_ptr<ParticleDeclaration> object(new ParticleDeclaration(std::forward<Args>(args)...));
return object.release();
}
}
#include <Nazara/Utility/DebugOff.hpp>

View File

@@ -8,23 +8,23 @@
#define NAZARA_PARTICLEEMITTER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Utility/Node.hpp>
namespace Nz
{
class ParticleMapper;
class ParticleSystem;
class ParticleGroup;
class NAZARA_GRAPHICS_API ParticleEmitter : public Node
class NAZARA_GRAPHICS_API ParticleEmitter
{
public:
ParticleEmitter();
ParticleEmitter(const ParticleEmitter& emitter) = default;
ParticleEmitter(ParticleEmitter&& emitter) = default;
ParticleEmitter(const ParticleEmitter& emitter);
ParticleEmitter(ParticleEmitter&& emitter);
virtual ~ParticleEmitter();
virtual void Emit(ParticleSystem& system, float elapsedTime) const;
virtual void Emit(ParticleGroup& system, float elapsedTime) const;
void EnableLagCompensation(bool enable);
@@ -37,7 +37,11 @@ namespace Nz
void SetEmissionRate(float rate);
ParticleEmitter& operator=(const ParticleEmitter& emitter) = default;
ParticleEmitter& operator=(ParticleEmitter&& emitter) = default;
ParticleEmitter& operator=(ParticleEmitter&& emitter);
// Signals:
NazaraSignal(OnParticleEmitterMove, ParticleEmitter* /*oldParticleEmitter*/, ParticleEmitter* /*newParticleEmitter*/);
NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/);
private:
virtual void SetupParticles(ParticleMapper& mapper, unsigned int count) const = 0;

View File

@@ -18,7 +18,7 @@ namespace Nz
{
class ParticleGenerator;
class ParticleMapper;
class ParticleSystem;
class ParticleGroup;
using ParticleGeneratorConstRef = ObjectRef<const ParticleGenerator>;
using ParticleGeneratorLibrary = ObjectLibrary<ParticleGenerator>;
@@ -34,7 +34,7 @@ namespace Nz
ParticleGenerator(const ParticleGenerator& generator);
virtual ~ParticleGenerator();
virtual void Generate(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
virtual void Generate(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
// Signals:
NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/);

View File

@@ -4,10 +4,11 @@
#pragma once
#ifndef NAZARA_PARTICLESYSTEM_HPP
#define NAZARA_PARTICLESYSTEM_HPP
#ifndef NAZARA_PARTICLEGROUP_HPP
#define NAZARA_PARTICLEGROUP_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/signal.hpp>
#include <Nazara/Graphics/ParticleController.hpp>
#include <Nazara/Graphics/ParticleDeclaration.hpp>
#include <Nazara/Graphics/ParticleEmitter.hpp>
@@ -22,13 +23,13 @@
namespace Nz
{
class NAZARA_GRAPHICS_API ParticleSystem : public Renderable
class NAZARA_GRAPHICS_API ParticleGroup : public Renderable
{
public:
ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout);
ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
ParticleSystem(const ParticleSystem& emitter);
~ParticleSystem();
ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout);
ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
ParticleGroup(const ParticleGroup& emitter);
~ParticleGroup();
void AddController(ParticleControllerRef controller);
void AddEmitter(ParticleEmitter* emitter);
@@ -40,19 +41,14 @@ namespace Nz
void* CreateParticle();
void* CreateParticles(unsigned int count);
void EnableFixedStep(bool fixedStep);
void* GenerateParticle();
void* GenerateParticles(unsigned int count);
const ParticleDeclarationConstRef& GetDeclaration() const;
float GetFixedStepSize() const;
unsigned int GetMaxParticleCount() const;
unsigned int GetParticleCount() const;
unsigned int GetParticleSize() const;
bool IsFixedStepEnabled() const;
void KillParticle(unsigned int index);
void KillParticles();
@@ -60,33 +56,42 @@ namespace Nz
void RemoveEmitter(ParticleEmitter* emitter);
void RemoveGenerator(ParticleGenerator* generator);
void SetFixedStepSize(float stepSize);
void SetRenderer(ParticleRenderer* renderer);
void Update(float elapsedTime);
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
ParticleSystem& operator=(const ParticleSystem& emitter);
ParticleGroup& operator=(const ParticleGroup& emitter);
// Signals:
NazaraSignal(OnParticleGroupRelease, const ParticleGroup* /*particleGroup*/);
private:
void MakeBoundingVolume() const override;
void OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter);
void OnEmitterRelease(const ParticleEmitter* emitter);
void ResizeBuffer();
struct EmitterEntry
{
NazaraSlot(ParticleEmitter, OnParticleEmitterMove, moveSlot);
NazaraSlot(ParticleEmitter, OnParticleEmitterRelease, releaseSlot);
ParticleEmitter* emitter;
};
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
mutable std::vector<UInt8> m_buffer;
std::vector<ParticleControllerRef> m_controllers;
std::vector<ParticleEmitter*> m_emitters;
std::vector<EmitterEntry> m_emitters;
std::vector<ParticleGeneratorRef> m_generators;
ParticleDeclarationConstRef m_declaration;
ParticleRendererRef m_renderer;
bool m_fixedStepEnabled;
bool m_processing;
float m_stepAccumulator;
float m_stepSize;
unsigned int m_maxParticleCount;
unsigned int m_particleCount;
unsigned int m_particleSize;
};
}
#endif // NAZARA_PARTICLESYSTEM_HPP
#endif // NAZARA_PARTICLEGROUP_HPP

View File

@@ -19,7 +19,7 @@ namespace Nz
class AbstractRenderQueue;
class ParticleMapper;
class ParticleRenderer;
class ParticleSystem;
class ParticleGroup;
using ParticleRendererConstRef = ObjectRef<const ParticleRenderer>;
using ParticleRendererLibrary = ObjectLibrary<ParticleRenderer>;
@@ -35,7 +35,7 @@ namespace Nz
ParticleRenderer(const ParticleRenderer& renderer);
virtual ~ParticleRenderer();
virtual void Render(const ParticleSystem& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0;
virtual void Render(const ParticleGroup& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0;
// Signals:
NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/);

View File

@@ -35,8 +35,8 @@ namespace Nz
struct ParticleStruct_Sprite
{
Color color;
Vector2f position;
Vector2f velocity;
Vector3f position;
Vector3f velocity;
UInt32 life;
float rotation;
};

View File

@@ -24,9 +24,7 @@ namespace Nz
}
/*!
* \brief Updates the bounding volume by a matrix
*
* \param transformMatrix Matrix transformation for our bounding volume
* \brief Updates the bounding volume
*/
inline void Renderable::UpdateBoundingVolume() const

View File

@@ -123,8 +123,7 @@ namespace Nz
inline void Sprite::SetDefaultMaterial()
{
MaterialRef material = Material::New();
material->Enable(RendererParameter_FaceCulling, false);
material->EnableLighting(false);
material->EnableFaceCulling(false);
SetMaterial(std::move(material));
}

View File

@@ -119,10 +119,9 @@ namespace Nz
inline void TextSprite::SetDefaultMaterial()
{
MaterialRef material = Material::New();
material->Enable(RendererParameter_Blend, true);
material->Enable(RendererParameter_DepthWrite, false);
material->Enable(RendererParameter_FaceCulling, false);
material->EnableLighting(false);
material->EnableBlending(true);
material->EnableDepthWrite(false);
material->EnableFaceCulling(false);
material->SetDstBlend(BlendFunc_InvSrcAlpha);
material->SetSrcBlend(BlendFunc_SrcAlpha);

View File

@@ -0,0 +1,97 @@
// Copyright (C) 2016 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_TILEMAP_HPP
#define NAZARA_TILEMAP_HPP
#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
{
class TileMap;
using TileMapConstRef = ObjectRef<const TileMap>;
using TileMapLibrary = ObjectLibrary<TileMap>;
using TileMapRef = ObjectRef<TileMap>;
class NAZARA_GRAPHICS_API TileMap : public InstancedRenderable
{
friend TileMapLibrary;
friend class Graphics;
public:
struct Tile;
inline TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount = 1);
TileMap(const TileMap& TileMap) = default;
TileMap(TileMap&&) = delete;
~TileMap() = default;
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
inline void DisableTile(const Vector2ui& tilePos);
inline void DisableTiles();
inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount);
inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
inline void EnableTiles(const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
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;
inline const Vector2f& GetTileSize() const;
inline void SetMaterial(std::size_t index, MaterialRef material);
inline TileMap& operator=(const TileMap& TileMap);
TileMap& operator=(TileMap&& TileMap) = delete;
template<typename... Args> static TileMapRef New(Args&&... args);
struct Tile
{
std::size_t layerIndex = 0U;
Color color = Color::White;
Rectf textureCoords = Rectf::Zero();
bool enabled = false;
};
private:
void MakeBoundingVolume() const override;
void UpdateData(InstanceData* instanceData) const override;
static bool Initialize();
static void Uninitialize();
struct Layer
{
MaterialRef material;
std::set<std::size_t> tiles;
};
std::vector<Tile> m_tiles;
std::vector<Layer> m_layers;
Vector2ui m_mapSize;
Vector2f m_tileSize;
static TileMapLibrary::LibraryMap s_library;
};
}
#include <Nazara/Graphics/TileMap.inl>
#endif // NAZARA_TILEMAP_HPP

View File

@@ -0,0 +1,441 @@
// Copyright (C) 2015 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/Graphics/TileMap.hpp>
#include <Nazara/Core/Error.hpp>
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \brief Constructs a TileMap object, containing mapSize tileSize-sized tiles
*
* \param mapSize Number of tiles in each dimension, must be
* \param tileSize Size of each tile of the TileMap
* \param materialCount The maximum number of differents Material this TileMap will use
*
* \remark When constructed, a TileMap has no tile active and will not be rendered
* To use it, you have to enable some tiles.
*
* \remark The default material is used for every material requested
*/
inline TileMap::TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount) :
m_tiles(mapSize.x * mapSize.y),
m_layers(materialCount),
m_mapSize(mapSize),
m_tileSize(tileSize)
{
NazaraAssert(m_tiles.size() != 0U, "Invalid map size");
NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size");
NazaraAssert(m_layers.size() != 0U, "Invalid material count");
for (Layer& layer : m_layers)
layer.material = Material::GetDefault();
InvalidateBoundingVolume();
}
/*!
* \brief Disable the tile at position tilePos, disabling rendering at this location
*
* \param tilePos Position of the tile to disable
*
* \see DisableTiles
*/
inline void TileMap::DisableTile(const Vector2ui& tilePos)
{
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x;
Tile& tile = m_tiles[tileIndex];
tile.enabled = false;
m_layers[tile.layerIndex].tiles.erase(tileIndex);
InvalidateInstanceData(1U << tile.layerIndex);
}
/*!
* \brief Disable all tiles
*/
inline void TileMap::DisableTiles()
{
for (Tile& tile : m_tiles)
tile.enabled = false;
for (Layer& layer : m_layers)
layer.tiles.clear();
InvalidateInstanceData(0xFFFFFFFF);
}
/*!
* \brief Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations
*
* This is equivalent to calling tileCount times DisableTile with the positions contained at tilesPos
*
* \param tilesPos Pointer to a valid array of at least tileCount positions
* \param tileCount Number of tiles to disable
*
* \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used
*
* \see DisableTile
*/
inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount)
{
NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount");
UInt32 invalidatedLayers = 0;
for (std::size_t i = 0; i < tileCount; ++i)
{
NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds");
std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x;
Tile& tile = m_tiles[tileIndex];
tile.enabled = false;
m_layers[tile.layerIndex].tiles.erase(tileIndex);
invalidatedLayers |= 1U << tile.layerIndex;
tilesPos++;
}
if (tileCount > 0)
InvalidateInstanceData(invalidatedLayers);
}
/*!
* \brief Enable and sets the tile at position tilePos
*
* Setup the tile at position tilePos using color, normalized coordinates coords and materialIndex
*
* \param tilePos Position of the tile to enable
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \see EnableTiles
*/
inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
UInt32 invalidatedLayers = 1U << materialIndex;
std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x;
Tile& tile = m_tiles[tilePos.y * m_mapSize.x + tilePos.x];
if (!tile.enabled)
m_layers[materialIndex].tiles.insert(tileIndex);
else if (materialIndex != tile.layerIndex)
{
m_layers[materialIndex].tiles.erase(tileIndex);
m_layers[tile.layerIndex].tiles.insert(tileIndex);
invalidatedLayers |= 1U << tile.layerIndex;
}
tile.enabled = true;
tile.color = color;
tile.textureCoords = coords;
tile.layerIndex = materialIndex;
InvalidateInstanceData(invalidatedLayers);
}
/*!
* \brief Enable and sets the tile at position tilePos
*
* Setup the tile at position tilePos using color, unnormalized coordinates rect and materialIndex
*
* \param tilePos Position of the tile to enable
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
*
* \see EnableTiles
*/
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();
float invWidth = 1.f / diffuseMap->GetWidth();
float invHeight = 1.f / diffuseMap->GetHeight();
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
EnableTile(tilePos, unnormalizedCoords, color, materialIndex);
}
/*!
* \brief Enable and sets all the tiles
*
* Setup all tiles using color, normalized coordinates coords and materialIndex
*
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
*
* \see EnableTile
*/
inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
for (Layer& layer : m_layers)
layer.tiles.clear();
std::size_t tileIndex = 0;
for (Tile& tile : m_tiles)
{
tile.enabled = true;
tile.color = color;
tile.textureCoords = coords;
tile.layerIndex = materialIndex;
m_layers[materialIndex].tiles.insert(tileIndex++);
}
InvalidateInstanceData(0xFFFFFFFF);
}
/*!
* \brief Enable and sets all the tiles
*
* Setup all tiles using color, unnormalized coordinates coords and materialIndex
*
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
*
* \see EnableTile
*/
inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
float invWidth = 1.f / diffuseMap->GetWidth();
float invHeight = 1.f / diffuseMap->GetHeight();
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
EnableTiles(unnormalizedCoords, color, materialIndex);
}
/*!
* \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations
*
* Setup all tiles using color, normalized coordinates coords and materialIndex
*
* \param tilesPos Pointer to a valid array of at least tileCount positions
* \param tileCount Number of tiles to enable
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \see EnableTile
*/
inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount");
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
UInt32 invalidatedLayers = 1U << materialIndex;
for (std::size_t i = 0; i < tileCount; ++i)
{
NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds");
std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x;
Tile& tile = m_tiles[tileIndex];
if (!tile.enabled)
m_layers[materialIndex].tiles.insert(tileIndex);
else if (materialIndex != tile.layerIndex)
{
m_layers[materialIndex].tiles.erase(tileIndex);
m_layers[tile.layerIndex].tiles.insert(tileIndex);
invalidatedLayers |= 1U << tile.layerIndex;
}
tile.enabled = true;
tile.color = color;
tile.textureCoords = coords;
tile.layerIndex = materialIndex;
tilesPos++;
}
if (tileCount > 0)
InvalidateInstanceData(invalidatedLayers);
}
/*!
* \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations
*
* Setup all tiles using color, unnormalized coordinates coords and materialIndex
*
* \param tilesPos Pointer to a valid array of at least tileCount positions
* \param tileCount Number of tiles to enable
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
* \param color The multiplicative color applied to the tile
* \param materialIndex The material which will be used for rendering this tile
*
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
*
* \see EnableTile
*/
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();
float invWidth = 1.f / diffuseMap->GetWidth();
float invHeight = 1.f / diffuseMap->GetHeight();
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
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
*
* \see GetSize
* \see GetTileSize
*/
inline const Vector2ui& TileMap::GetMapSize() const
{
return m_mapSize;
}
/*!
* \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize())
* \return Maximum size in units occupied by this tilemap
*
* \see GetMapSize
* \see GetTileSize
*/
inline Vector2f TileMap::GetSize() const
{
return Vector2f(m_mapSize) * m_tileSize;
}
/*!
* \brief Returns informations about a particular tile
*
* \param tilePos Position of the tile to get (enabled or not)
*
* \return Maximum size in units occupied by this tilemap
*/
inline const TileMap::Tile& TileMap::GetTile(const Vector2ui& tilePos) const
{
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
return m_tiles[tilePos.y * m_mapSize.x + tilePos.x];
}
/*!
* \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension)
* \return Tile size in each dimension
*
* \see GetMapSize
* \see GetSize
*/
inline const Vector2f& TileMap::GetTileSize() const
{
return m_tileSize;
}
/*!
* \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
*
* \param TileMap The other TileMap
*/
inline TileMap& TileMap::operator=(const TileMap& TileMap)
{
InstancedRenderable::operator=(TileMap);
m_layers = TileMap.m_layers;
m_mapSize = TileMap.m_mapSize;
m_tiles = TileMap.m_tiles;
m_tileSize = TileMap.m_tileSize;
// We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated
InvalidateBoundingVolume();
InvalidateInstanceData(0xFFFFFFFF);
return *this;
}
/*!
* \brief Creates a new TileMap from the arguments
* \return A reference to the newly created TileMap
*
* \param args Arguments for the TileMap
*/
template<typename... Args>
TileMapRef TileMap::New(Args&&... args)
{
std::unique_ptr<TileMap> object(new TileMap(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -105,7 +105,7 @@ namespace Nz
*
* \param value Initial value
* \param objective Target value
* \parma increment One step value
* \param increment One step value
*/
template<typename T>
@@ -412,7 +412,7 @@ namespace Nz
* \brief Gets the log in base 2 of integral number, only works for power of two !
* \return Log of the number
*
* \param number To get log in base 2
* \param pot To get log in base 2
*
* \remark Only works for power of two
* \remark If number is 0, 0 is returned
@@ -431,7 +431,7 @@ namespace Nz
* \return base^exponent for integral
*
* \param base Base of the exponentation
* \parma exponent Power for the base
* \param exponent Power for the base
*/
//TODO: Mark as constexpr when supported by all major compilers

View File

@@ -53,6 +53,7 @@ namespace Nz
void Update(const Vector3<T>& translation);
BoundingVolume operator*(T scalar) const;
BoundingVolume& operator=(const BoundingVolume& other) = default;
BoundingVolume& operator*=(T scalar);

View File

@@ -79,6 +79,7 @@ namespace Nz
Box operator*(T scalar) const;
Box operator*(const Vector3<T>& vec) const;
Box& operator=(const Box& other) = default;
Box& operator*=(T scalar);
Box& operator*=(const Vector3<T>& vec);

View File

@@ -787,7 +787,7 @@ namespace Nz
* \brief Multiplies the lengths with the scalar
* \return A box where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
*
* \param scale The scalar to multiply width, height and depth with
* \param scalar The scalar to multiply width, height and depth with
*/
template<typename T>

View File

@@ -47,6 +47,7 @@ namespace Nz
EulerAngles operator-(const EulerAngles& angles) const;
/*EulerAngles operator*(const EulerAngles& angles) const;
EulerAngles operator/(const EulerAngles& angles) const;*/
EulerAngles& operator=(const EulerAngles& other) = default;
EulerAngles& operator+=(const EulerAngles& angles);
EulerAngles& operator-=(const EulerAngles& angles);

View File

@@ -50,6 +50,8 @@ namespace Nz
IntersectionSide Intersect(const Sphere<T>& sphere) const;
IntersectionSide Intersect(const Vector3<T>* points, unsigned int pointCount) const;
Frustum& operator=(const Frustum& other) = default;
Frustum& Set(const Frustum& frustum);
template<typename U> Frustum& Set(const Frustum<U>& frustum);

View File

@@ -750,7 +750,7 @@ namespace Nz
* \brief Inverts this matrix
* \return A reference to this matrix inverted
*
* \param bool Optional argument to know if matrix has been successfully inverted
* \param succeeded Optional argument to know if matrix has been successfully inverted
*
* \see InverseAffine
*/
@@ -769,7 +769,7 @@ namespace Nz
* \brief Inverts this matrix
* \return A reference to this matrix inverted
*
* \param bool Optional argument to know if matrix has been successfully inverted
* \param succeeded Optional argument to know if matrix has been successfully inverted
*
* \see Inverse
*/
@@ -1487,7 +1487,7 @@ namespace Nz
* \brief Compares the matrix to other one
* \return true if the matrices are the same
*
* \param matrix Other matrix to compare with
* \param mat Other matrix to compare with
*/
template<typename T>
@@ -1504,7 +1504,7 @@ namespace Nz
* \brief Compares the matrix to other one
* \return false if the matrices are the same
*
* \param matrix Other matrix to compare with
* \param mat Other matrix to compare with
*/
template<typename T>

View File

@@ -52,6 +52,7 @@ namespace Nz
Vector3<T> operator()(unsigned int i) const;
OrientedBox operator*(T scalar) const;
OrientedBox& operator=(const OrientedBox& other) = default;
OrientedBox& operator*=(T scalar);

View File

@@ -340,7 +340,7 @@ namespace Nz
* \brief Multiplies the lengths with the scalar
* \return A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
*
* \param scale The scalar to multiply width, height and depth with
* \param scalar The scalar to multiply width, height and depth with
*/
template<typename T>

View File

@@ -45,6 +45,8 @@ namespace Nz
String ToString() const;
Plane& operator=(const Plane& other) = default;
bool operator==(const Plane& plane) const;
bool operator!=(const Plane& plane) const;

View File

@@ -61,6 +61,7 @@ namespace Nz
String ToString() const;
Vector3<T> operator*(T lambda) const;
Ray& operator=(const Ray& other) = default;
bool operator==(const Ray& ray) const;
bool operator!=(const Ray& ray) const;

View File

@@ -71,6 +71,7 @@ namespace Nz
Rect operator*(const Vector2<T>& vec) const;
Rect operator/(T scalar) const;
Rect operator/(const Vector2<T>& vec) const;
Rect& operator=(const Rect& other) = default;
Rect& operator*=(T scalar);
Rect& operator*=(const Vector2<T>& vec);

View File

@@ -629,7 +629,7 @@ namespace Nz
* \brief Multiplies the lengths with the scalar
* \return A rectangle where the position is the same and width and height are the product of the old width and height and the scalar
*
* \param scale The scalar to multiply width and height with
* \param scalar The scalar to multiply width and height with
*/
template<typename T>
@@ -655,13 +655,13 @@ namespace Nz
* \brief Divides the lengths with the scalar
* \return A rectangle where the position is the same and width and height are the quotient of the old width and height and the scalar
*
* \param scale The scalar to divide width and height with
* \param scalar The scalar to divide width and height with
*/
template<typename T>
Rect<T> Rect<T>::operator/(T scalar) const
{
return Rect(x, y, width/scalar, height/scalar);
return Rect(x, y, width / scalar, height / scalar);
}
/*!
@@ -745,7 +745,7 @@ namespace Nz
* \brief Compares the rectangle to other one
* \return true if the rectangles are the same
*
* \param rec Other rectangle to compare with
* \param rect Other rectangle to compare with
*/
template<typename T>
@@ -759,7 +759,7 @@ namespace Nz
* \brief Compares the rectangle to other one
* \return false if the rectangles are the same
*
* \param rec Other rectangle to compare with
* \param rect Other rectangle to compare with
*/
template<typename T>

View File

@@ -67,6 +67,7 @@ namespace Nz
T operator[](unsigned int i) const;
Sphere operator*(T scalar) const;
Sphere& operator=(const Sphere& other) = default;
Sphere& operator*=(T scalar);

View File

@@ -76,6 +76,7 @@ namespace Nz
Vector2 operator*(T scale) const;
Vector2 operator/(const Vector2& vec) const;
Vector2 operator/(T scale) const;
Vector2& operator=(const Vector2& other) = default;
Vector2& operator+=(const Vector2& vec);
Vector2& operator-=(const Vector2& vec);

View File

@@ -87,6 +87,7 @@ namespace Nz
Vector3 operator*(T scale) const;
Vector3 operator/(const Vector3& vec) const;
Vector3 operator/(T scale) const;
Vector3& operator=(const Vector3& vec) = default;
Vector3& operator+=(const Vector3& vec);
Vector3& operator-=(const Vector3& vec);

View File

@@ -74,6 +74,7 @@ namespace Nz
Vector4 operator*(T scale) const;
Vector4 operator/(const Vector4& vec) const;
Vector4 operator/(T scale) const;
Vector4& operator=(const Vector4& other) = default;
Vector4& operator+=(const Vector4& vec);
Vector4& operator-=(const Vector4& vec);

View File

@@ -0,0 +1,42 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERPIPELINE_HPP
#define NAZARA_RENDERPIPELINE_HPP
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Renderer/Shader.hpp>
namespace Nz
{
struct RenderPipelineInfo : RenderStates
{
ShaderConstRef shader;
};
class RenderPipeline
{
public:
inline RenderPipeline();
inline ~RenderPipeline();
inline bool Create(const RenderPipelineInfo& pipelineInfo);
inline void Destroy();
inline const RenderPipelineInfo& GetInfo() const;
inline bool IsValid() const;
private:
RenderPipelineInfo m_pipelineInfo;
bool m_valid;
};
}
#include <Nazara/Renderer/RenderPipeline.inl>
#endif // NAZARA_RENDERPIPELINE_HPP

View File

@@ -0,0 +1,48 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
inline RenderPipeline::RenderPipeline() :
m_valid(false)
{
}
inline RenderPipeline::~RenderPipeline()
{
}
inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo)
{
NazaraAssert(pipelineInfo.shader, "Invalid shader");
m_pipelineInfo = pipelineInfo;
m_valid = true;
return true;
}
inline void RenderPipeline::Destroy()
{
m_valid = false;
}
inline const RenderPipelineInfo& RenderPipeline::GetInfo() const
{
NazaraAssert(m_valid, "Invalid pipeline info");
return m_pipelineInfo;
}
inline bool RenderPipeline::IsValid() const
{
return m_valid;
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -7,39 +7,74 @@
#ifndef NAZARA_RENDERSTATES_HPP
#define NAZARA_RENDERSTATES_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Enums.hpp>
namespace Nz
{
struct RenderStates
{
RenderStates();
RenderStates(const RenderStates& states);
~RenderStates() = default;
BlendFunc dstBlend = BlendFunc_Zero;
BlendFunc srcBlend = BlendFunc_One;
FaceFilling faceFilling = FaceFilling_Fill;
FaceSide cullingSide = FaceSide_Back;
RendererComparison depthFunc = RendererComparison_Less;
RenderStates& operator=(const RenderStates& states);
struct Face
struct
{
RendererComparison stencilCompare;
StencilOperation stencilFail;
StencilOperation stencilPass;
StencilOperation stencilZFail;
UInt32 stencilMask;
unsigned int stencilReference;
};
RendererComparison back = RendererComparison_Always;
RendererComparison front = RendererComparison_Always;
} stencilCompare;
Face backFace;
Face frontFace;
BlendFunc dstBlend;
BlendFunc srcBlend;
FaceFilling faceFilling;
FaceSide faceCulling;
RendererComparison depthFunc;
bool parameters[RendererParameter_Max+1];
float lineWidth;
float pointSize;
struct
{
UInt32 back = 0xFFFFFFFF;
UInt32 front = 0xFFFFFFFF;
} stencilCompareMask;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilDepthFail;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilFail;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilPass;
struct
{
UInt32 back = 0U;
UInt32 front = 0U;
} stencilReference;
struct
{
UInt32 back = 0xFFFFFFFF;
UInt32 front = 0xFFFFFFFF;
} stencilWriteMask;
bool blending = false;
bool colorWrite = true;
bool depthBuffer = false;
bool depthWrite = true;
bool faceCulling = false;
bool scissorTest = false;
bool stencilTest = false;
float lineWidth = 1.f;
float pointSize = 1.f;
};
inline bool operator==(const RenderStates& lhs, const RenderStates& rhs);
}
#include <Nazara/Renderer/RenderStates.inl>

View File

@@ -2,52 +2,144 @@
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <cstring>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Math/Algorithm.hpp>
#include <functional>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
inline RenderStates::RenderStates() :
dstBlend(BlendFunc_Zero),
srcBlend(BlendFunc_One),
faceFilling(FaceFilling_Fill),
faceCulling(FaceSide_Back),
depthFunc(RendererComparison_Less),
lineWidth(1.f),
pointSize(1.f)
bool operator==(const RenderStates& lhs, const RenderStates& rhs)
{
parameters[RendererParameter_Blend] = false;
parameters[RendererParameter_ColorWrite] = true;
parameters[RendererParameter_DepthBuffer] = false;
parameters[RendererParameter_DepthWrite] = true;
parameters[RendererParameter_FaceCulling] = false;
parameters[RendererParameter_ScissorTest] = false;
parameters[RendererParameter_StencilTest] = false;
#define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false
#define NazaraRenderStateBoolMember NazaraRenderStateMember
#define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false
for (unsigned int i = 0; i < 2; ++i)
NazaraRenderStateBoolMember(blending);
NazaraRenderStateBoolMember(colorWrite);
NazaraRenderStateBoolMember(depthBuffer);
NazaraRenderStateBoolMember(faceCulling);
NazaraRenderStateBoolMember(scissorTest);
NazaraRenderStateBoolMember(stencilTest);
if (lhs.depthBuffer)
NazaraRenderStateBoolMember(depthWrite);
NazaraRenderStateMember(faceFilling);
if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending
{
Face& face = (i == 0) ? backFace : frontFace;
face.stencilCompare = RendererComparison_Always;
face.stencilFail = StencilOperation_Keep;
face.stencilMask = 0xFFFFFFFF;
face.stencilPass = StencilOperation_Keep;
face.stencilReference = 0;
face.stencilZFail = StencilOperation_Keep;
NazaraRenderStateMember(dstBlend);
NazaraRenderStateMember(srcBlend);
}
}
inline RenderStates::RenderStates(const RenderStates& states)
{
std::memcpy(this, &states, sizeof(RenderStates));
}
if (lhs.depthBuffer)
NazaraRenderStateMember(depthFunc);
inline RenderStates& RenderStates::operator=(const RenderStates& states)
{
std::memcpy(this, &states, sizeof(RenderStates));
if (lhs.faceCulling)
NazaraRenderStateMember(cullingSide);
return *this;
if (lhs.stencilTest)
{
NazaraRenderStateMember(stencilCompare.back);
NazaraRenderStateMember(stencilCompare.front);
NazaraRenderStateMember(stencilCompareMask.back);
NazaraRenderStateMember(stencilCompareMask.front);
NazaraRenderStateMember(stencilDepthFail.back);
NazaraRenderStateMember(stencilDepthFail.front);
NazaraRenderStateMember(stencilFail.back);
NazaraRenderStateMember(stencilFail.front);
NazaraRenderStateMember(stencilPass.back);
NazaraRenderStateMember(stencilPass.front);
NazaraRenderStateMember(stencilReference.back);
NazaraRenderStateMember(stencilReference.front);
NazaraRenderStateMember(stencilWriteMask.back);
NazaraRenderStateMember(stencilWriteMask.front);
}
NazaraRenderStateFloatMember(lineWidth, 0.001f);
NazaraRenderStateFloatMember(pointSize, 0.001f);
#undef NazaraRenderStateMember
#undef NazaraRenderStateBoolMember
#undef NazaraRenderStateFloatMember
return true;
}
}
namespace std
{
template<>
struct hash<Nz::RenderStates>
{
size_t operator()(const Nz::RenderStates& pipelineInfo) const
{
std::size_t seed = 0;
Nz::UInt8 parameterHash = 0;
Nz::UInt8 parameterIndex = 0;
#define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
#define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff)
NazaraRenderStateBoolMember(blending);
NazaraRenderStateBoolMember(colorWrite);
NazaraRenderStateBoolMember(depthBuffer);
NazaraRenderStateBoolMember(faceCulling);
NazaraRenderStateBoolMember(scissorTest);
NazaraRenderStateBoolMember(stencilTest);
NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite);
NazaraRenderStateMember(faceFilling);
if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending
{
NazaraRenderStateMember(dstBlend);
NazaraRenderStateMember(srcBlend);
}
if (pipelineInfo.depthBuffer)
NazaraRenderStateMember(depthFunc);
if (pipelineInfo.faceCulling)
NazaraRenderStateMember(cullingSide);
if (pipelineInfo.stencilTest)
{
NazaraRenderStateMember(stencilCompare.back);
NazaraRenderStateMember(stencilCompare.front);
NazaraRenderStateMember(stencilCompareMask.back);
NazaraRenderStateMember(stencilCompareMask.front);
NazaraRenderStateMember(stencilDepthFail.back);
NazaraRenderStateMember(stencilDepthFail.front);
NazaraRenderStateMember(stencilFail.back);
NazaraRenderStateMember(stencilFail.front);
NazaraRenderStateMember(stencilPass.back);
NazaraRenderStateMember(stencilPass.front);
NazaraRenderStateMember(stencilReference.back);
NazaraRenderStateMember(stencilReference.front);
NazaraRenderStateMember(stencilWriteMask.back);
NazaraRenderStateMember(stencilWriteMask.front);
}
NazaraRenderStateFloatMember(lineWidth, 0.001f);
NazaraRenderStateFloatMember(pointSize, 0.001f);
#undef NazaraRenderStateMember
#undef NazaraRenderStateBoolMember
#undef NazaraRenderStateBoolMemberDep
#undef NazaraRenderStateFloatMember
Nz::HashCombine(seed, parameterHash);
return seed;
}
};
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -86,7 +86,7 @@ namespace Nz
inline void Error(const String& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void UnrecognizedLine(bool error = false);
inline bool UnrecognizedLine(bool error = false);
std::vector<Mesh> m_meshes;
std::vector<String> m_materials;
@@ -99,6 +99,7 @@ namespace Nz
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_errorCount;
};
}

View File

@@ -168,7 +168,7 @@ namespace Nz
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
}
inline void OBJParser::UnrecognizedLine(bool error)
inline bool OBJParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
@@ -176,6 +176,16 @@ namespace Nz
Error(message);
else
Warning(message);
m_errorCount++;
if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50)
{
NazaraError("Aborting parsing because of error percentage");
return false; //< Abort parsing if error percentage is too high
}
return true;
}
}

View File

@@ -23,7 +23,6 @@ namespace Nz
static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail";
static constexpr const char* Blending = "MatBlending";
static constexpr const char* CullingSide = "MatCullingSide";
static constexpr const char* CustomDefined = "MatCustomDefined";
static constexpr const char* ColorWrite = "MatColorWrite";
static constexpr const char* DepthBuffer = "MatDepthBuffer";
static constexpr const char* DepthFunc = "MatDepthfunc";

View File

@@ -14,6 +14,7 @@
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <array>
namespace Nz
{
@@ -69,14 +70,14 @@ namespace Nz
*/
};
Component m_components[VertexComponent_Max+1];
std::array<Component, VertexComponent_Max + 1> m_components;
std::size_t m_stride;
static VertexDeclaration s_declarations[VertexLayout_Max+1];
static std::array<VertexDeclaration, VertexLayout_Max + 1> s_declarations;
static VertexDeclarationLibrary::LibraryMap s_library;
};
}
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <Nazara/Utility/VertexDeclaration.inl>
#endif // NAZARA_VERTEXDECLARATION_HPP