Merge branch 'master' into vulkan
This commit is contained in:
@@ -22,8 +22,8 @@ namespace Nz
|
||||
void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount)
|
||||
{
|
||||
// To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings
|
||||
typedef typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||
using BiggestInt = typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type;
|
||||
using Biggest = typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type;
|
||||
|
||||
for (UInt64 i = 0; i < frameCount; ++i)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
public:
|
||||
Music() = default;
|
||||
Music(const Music&) = delete;
|
||||
Music(Music&&) = delete;
|
||||
Music(Music&&) noexcept = default;
|
||||
~Music();
|
||||
|
||||
bool Create(SoundStream* soundStream);
|
||||
@@ -67,10 +67,10 @@ namespace Nz
|
||||
void Stop() override;
|
||||
|
||||
Music& operator=(const Music&) = delete;
|
||||
Music& operator=(Music&&) = delete;
|
||||
Music& operator=(Music&&) noexcept = default;
|
||||
|
||||
private:
|
||||
MovablePtr<MusicImpl> m_impl = nullptr;
|
||||
MovablePtr<MusicImpl> m_impl;
|
||||
|
||||
bool FillAndQueueBuffer(unsigned int buffer);
|
||||
void MusicThread();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Nz
|
||||
Sound() = default;
|
||||
Sound(const SoundBuffer* soundBuffer);
|
||||
Sound(const Sound& sound);
|
||||
Sound(Sound&&) = default;
|
||||
Sound(Sound&&) noexcept = default;
|
||||
~Sound();
|
||||
|
||||
void EnableLooping(bool loop) override;
|
||||
@@ -47,7 +47,7 @@ namespace Nz
|
||||
void Stop() override;
|
||||
|
||||
Sound& operator=(const Sound&) = delete; ///TODO?
|
||||
Sound& operator=(Sound&&) = default;
|
||||
Sound& operator=(Sound&&) noexcept = default;
|
||||
|
||||
private:
|
||||
SoundBufferConstRef m_buffer;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/Enums.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <limits>
|
||||
|
||||
///TODO: Inherit SoundEmitter from Node
|
||||
|
||||
@@ -19,6 +20,7 @@ namespace Nz
|
||||
class NAZARA_AUDIO_API SoundEmitter
|
||||
{
|
||||
public:
|
||||
SoundEmitter(SoundEmitter&& emitter) noexcept;
|
||||
virtual ~SoundEmitter();
|
||||
|
||||
virtual void EnableLooping(bool loop) = 0;
|
||||
@@ -51,16 +53,17 @@ namespace Nz
|
||||
|
||||
virtual void Stop() = 0;
|
||||
|
||||
SoundEmitter& operator=(const SoundEmitter&) = delete; ///TODO
|
||||
SoundEmitter& operator=(SoundEmitter&&) = delete;
|
||||
SoundEmitter& operator=(const SoundEmitter&) = delete;
|
||||
SoundEmitter& operator=(SoundEmitter&&) noexcept;
|
||||
|
||||
protected:
|
||||
SoundEmitter();
|
||||
SoundEmitter(const SoundEmitter& emitter);
|
||||
SoundEmitter(SoundEmitter&&) = delete;
|
||||
|
||||
SoundStatus GetInternalStatus() const;
|
||||
|
||||
static constexpr unsigned int InvalidSource = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
unsigned int m_source;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/TaskScheduler.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/SerializationContext.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
@@ -37,19 +38,22 @@ namespace Nz
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct TypeTag {};
|
||||
bool Serialize(SerializationContext& context, T&& value);
|
||||
|
||||
inline bool Serialize(SerializationContext& context, bool value);
|
||||
inline bool Serialize(SerializationContext& context, const std::string& value);
|
||||
inline bool Serialize(SerializationContext& context, bool value, TypeTag<bool>);
|
||||
inline bool Serialize(SerializationContext& context, const std::string& value, TypeTag<std::string>);
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value);
|
||||
|
||||
inline bool Unserialize(SerializationContext& context, bool* value);
|
||||
inline bool Unserialize(SerializationContext& context, std::string* value);
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value, TypeTag<T>);
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(SerializationContext& context, T* value);
|
||||
bool Unserialize(SerializationContext& context, T* value);
|
||||
|
||||
inline bool Unserialize(SerializationContext& context, bool* value, TypeTag<bool>);
|
||||
inline bool Unserialize(SerializationContext& context, std::string* value, TypeTag<std::string>);
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(SerializationContext& context, T* value, TypeTag<T>);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/Algorithm.inl>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <climits>
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -194,10 +195,17 @@ namespace Nz
|
||||
return reversed;
|
||||
}
|
||||
|
||||
template<typename T> struct PointedType<T*> {typedef T type;};
|
||||
template<typename T> struct PointedType<T* const> {typedef T type;};
|
||||
template<typename T> struct PointedType<T* volatile> {typedef T type;};
|
||||
template<typename T> struct PointedType<T* const volatile> {typedef T type;};
|
||||
template<typename T> struct PointedType<T*> { using type = T; };
|
||||
template<typename T> struct PointedType<T* const> { using type = T; };
|
||||
template<typename T> struct PointedType<T* volatile> { using type = T; };
|
||||
template<typename T> struct PointedType<T* const volatile> { using type = T; };
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, T&& value)
|
||||
{
|
||||
return Serialize(context, std::forward<T>(value), TypeTag<std::decay_t<T>>());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
@@ -209,7 +217,7 @@ namespace Nz
|
||||
*
|
||||
* \see Serialize, Unserialize
|
||||
*/
|
||||
inline bool Serialize(SerializationContext& context, bool value)
|
||||
inline bool Serialize(SerializationContext& context, bool value, TypeTag<bool>)
|
||||
{
|
||||
if (context.currentBitPos == 8)
|
||||
{
|
||||
@@ -221,7 +229,7 @@ namespace Nz
|
||||
context.currentByte |= 1 << context.currentBitPos;
|
||||
|
||||
if (++context.currentBitPos >= 8)
|
||||
return Serialize<UInt8>(context, context.currentByte);
|
||||
return Serialize(context, context.currentByte, TypeTag<UInt8>());
|
||||
else
|
||||
return true;
|
||||
}
|
||||
@@ -234,9 +242,9 @@ namespace Nz
|
||||
* \param context Context for the serialization
|
||||
* \param value String to serialize
|
||||
*/
|
||||
bool Serialize(SerializationContext& context, const std::string& value)
|
||||
bool Serialize(SerializationContext& context, const std::string& value, TypeTag<std::string>)
|
||||
{
|
||||
if (!Serialize(context, UInt32(value.size())))
|
||||
if (!Serialize(context, UInt32(value.size()), TypeTag<UInt32>()))
|
||||
return false;
|
||||
|
||||
return context.stream->Write(value.data(), value.size()) == value.size();
|
||||
@@ -253,7 +261,7 @@ namespace Nz
|
||||
* \see Serialize, Unserialize
|
||||
*/
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value)
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Serialize(SerializationContext& context, T value, TypeTag<T>)
|
||||
{
|
||||
// Flush bits in case a writing is in progress
|
||||
context.FlushBits();
|
||||
@@ -264,6 +272,13 @@ namespace Nz
|
||||
return context.stream->Write(&value, sizeof(T)) == sizeof(T);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, T* value)
|
||||
{
|
||||
return Unserialize(context, value, TypeTag<T>());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Unserializes a boolean
|
||||
@@ -274,11 +289,11 @@ namespace Nz
|
||||
*
|
||||
* \see Serialize, Unserialize
|
||||
*/
|
||||
inline bool Unserialize(SerializationContext& context, bool* value)
|
||||
inline bool Unserialize(SerializationContext& context, bool* value, TypeTag<bool>)
|
||||
{
|
||||
if (context.currentBitPos == 8)
|
||||
{
|
||||
if (!Unserialize(context, &context.currentByte))
|
||||
if (!Unserialize(context, &context.currentByte, TypeTag<UInt8>()))
|
||||
return false;
|
||||
|
||||
context.currentBitPos = 0;
|
||||
@@ -299,10 +314,10 @@ namespace Nz
|
||||
* \param context Context of unserialization
|
||||
* \param string std::string to unserialize
|
||||
*/
|
||||
bool Unserialize(SerializationContext& context, std::string* string)
|
||||
bool Unserialize(SerializationContext& context, std::string* string, TypeTag<std::string>)
|
||||
{
|
||||
UInt32 size;
|
||||
if (!Unserialize(context, &size))
|
||||
if (!Unserialize(context, &size, TypeTag<UInt32>()))
|
||||
return false;
|
||||
|
||||
string->resize(size);
|
||||
@@ -322,7 +337,7 @@ namespace Nz
|
||||
* \see Serialize, Unserialize
|
||||
*/
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(SerializationContext& context, T* value)
|
||||
std::enable_if_t<std::is_arithmetic<T>::value, bool> Unserialize(SerializationContext& context, T* value, TypeTag<T>)
|
||||
{
|
||||
NazaraAssert(value, "Invalid data pointer");
|
||||
|
||||
|
||||
@@ -51,9 +51,6 @@ namespace Nz
|
||||
std::size_t GetCapacity() const;
|
||||
std::size_t GetSize() const;
|
||||
|
||||
PointerSequence Read(const void* ptr, std::size_t bitCount);
|
||||
PointerSequence Read(const PointerSequence& sequence, std::size_t bitCount);
|
||||
|
||||
void PerformsAND(const Bitset& a, const Bitset& b);
|
||||
void PerformsNOT(const Bitset& a);
|
||||
void PerformsOR(const Bitset& a, const Bitset& b);
|
||||
@@ -90,6 +87,9 @@ namespace Nz
|
||||
void UnboundedSet(std::size_t bit, bool val = true);
|
||||
bool UnboundedTest(std::size_t bit) const;
|
||||
|
||||
PointerSequence Write(const void* ptr, std::size_t bitCount);
|
||||
PointerSequence Write(const PointerSequence& sequence, std::size_t bitCount);
|
||||
|
||||
Bit operator[](std::size_t index);
|
||||
bool operator[](std::size_t index) const;
|
||||
|
||||
|
||||
@@ -328,9 +328,9 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Read a byte sequence into a bitset
|
||||
* \brief Writes a byte sequence into a bitset
|
||||
*
|
||||
* This function extends the bitset with bits read from a byte sequence
|
||||
* This function extends the bitset with bits read from a byte sequence.
|
||||
*
|
||||
* \param ptr A pointer to the start of the byte sequence
|
||||
* \param bitCount Number of bits to read from the byte sequence
|
||||
@@ -341,17 +341,18 @@ namespace Nz
|
||||
*
|
||||
* \see AppendBits
|
||||
* \see Read
|
||||
* \see Write
|
||||
*/
|
||||
template<typename Block, class Allocator>
|
||||
typename Bitset<Block, Allocator>::PointerSequence Bitset<Block, Allocator>::Read(const void* ptr, std::size_t bitCount)
|
||||
typename Bitset<Block, Allocator>::PointerSequence Bitset<Block, Allocator>::Write(const void* ptr, std::size_t bitCount)
|
||||
{
|
||||
return Read(PointerSequence(ptr, 0U), bitCount);
|
||||
return Write(PointerSequence(ptr, 0U), bitCount);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Read a byte sequence into a bitset
|
||||
* \brief Writes a byte sequence into a bitset
|
||||
*
|
||||
* This function extends the bitset with bits read from a pointer sequence (made of a pointer and a bit index)
|
||||
* This function extends the bitset with bits read from a pointer sequence (made of a pointer and a bit index).
|
||||
*
|
||||
* \param sequence A pointer sequence to the start of the byte sequence
|
||||
* \param bitCount Number of bits to read from the byte sequence
|
||||
@@ -362,9 +363,10 @@ namespace Nz
|
||||
*
|
||||
* \see AppendBits
|
||||
* \see Read
|
||||
* \see Write
|
||||
*/
|
||||
template<typename Block, class Allocator>
|
||||
typename Bitset<Block, Allocator>::PointerSequence Bitset<Block, Allocator>::Read(const PointerSequence& sequence, std::size_t bitCount)
|
||||
typename Bitset<Block, Allocator>::PointerSequence Bitset<Block, Allocator>::Write(const PointerSequence& sequence, std::size_t bitCount)
|
||||
{
|
||||
NazaraAssert(sequence.first, "Invalid pointer sequence");
|
||||
NazaraAssert(sequence.second < 8, "Invalid next bit index (must be < 8)");
|
||||
@@ -1161,9 +1163,9 @@ namespace Nz
|
||||
Bitset bitset;
|
||||
|
||||
if (sequence)
|
||||
*sequence = bitset.Read(ptr, bitCount);
|
||||
*sequence = bitset.Write(ptr, bitCount);
|
||||
else
|
||||
bitset.Read(ptr, bitCount);
|
||||
bitset.Write(ptr, bitCount);
|
||||
|
||||
return bitset;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Nz
|
||||
{
|
||||
m_context.currentBitPos = 8; //< To prevent Serialize to flush bits itself
|
||||
|
||||
if (!Serialize<UInt8>(m_context, m_context.currentByte))
|
||||
if (!Serialize(m_context, m_context.currentByte))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ namespace Nz
|
||||
static float Hue2RGB(float v1, float v2, float vH);
|
||||
};
|
||||
|
||||
inline bool Serialize(SerializationContext& context, const Color& color);
|
||||
inline bool Unserialize(SerializationContext& context, Color* color);
|
||||
inline bool Serialize(SerializationContext& context, const Color& color, TypeTag<Color>);
|
||||
inline bool Unserialize(SerializationContext& context, Color* color, TypeTag<Color>);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Nz::Color& color);
|
||||
|
||||
@@ -617,7 +617,7 @@ namespace Nz
|
||||
* \param context Serialization context
|
||||
* \param color Input color
|
||||
*/
|
||||
inline bool Serialize(SerializationContext& context, const Color& color)
|
||||
inline bool Serialize(SerializationContext& context, const Color& color, TypeTag<Color>)
|
||||
{
|
||||
if (!Serialize(context, color.r))
|
||||
return false;
|
||||
@@ -641,7 +641,7 @@ namespace Nz
|
||||
* \param context Serialization context
|
||||
* \param color Output color
|
||||
*/
|
||||
inline bool Unserialize(SerializationContext& context, Color* color)
|
||||
inline bool Unserialize(SerializationContext& context, Color* color, TypeTag<Color>)
|
||||
{
|
||||
if (!Unserialize(context, &color->r))
|
||||
return false;
|
||||
|
||||
@@ -23,16 +23,16 @@ namespace Nz
|
||||
public:
|
||||
HandledObject() = default;
|
||||
HandledObject(const HandledObject& object);
|
||||
HandledObject(HandledObject&& object);
|
||||
HandledObject(HandledObject&& object) noexcept;
|
||||
~HandledObject();
|
||||
|
||||
ObjectHandle<T> CreateHandle();
|
||||
|
||||
HandledObject& operator=(const HandledObject& object);
|
||||
HandledObject& operator=(HandledObject&& object);
|
||||
HandledObject& operator=(HandledObject&& object) noexcept;
|
||||
|
||||
protected:
|
||||
void UnregisterAllHandles();
|
||||
void UnregisterAllHandles() noexcept;
|
||||
|
||||
private:
|
||||
void RegisterHandle(ObjectHandle<T>* handle);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Nz
|
||||
* \param object HandledObject to move into this
|
||||
*/
|
||||
template<typename T>
|
||||
HandledObject<T>::HandledObject(HandledObject&& object) :
|
||||
HandledObject<T>::HandledObject(HandledObject&& object) noexcept :
|
||||
m_handles(std::move(object.m_handles))
|
||||
{
|
||||
for (ObjectHandle<T>* handle : m_handles)
|
||||
@@ -84,8 +84,10 @@ namespace Nz
|
||||
* \param object HandledObject to move in this
|
||||
*/
|
||||
template<typename T>
|
||||
HandledObject<T>& HandledObject<T>::operator=(HandledObject&& object)
|
||||
HandledObject<T>& HandledObject<T>::operator=(HandledObject&& object) noexcept
|
||||
{
|
||||
UnregisterAllHandles();
|
||||
|
||||
m_handles = std::move(object.m_handles);
|
||||
for (ObjectHandle<T>* handle : m_handles)
|
||||
handle->OnObjectMoved(static_cast<T*>(this));
|
||||
@@ -110,7 +112,7 @@ namespace Nz
|
||||
* \brief Unregisters all handles
|
||||
*/
|
||||
template<typename T>
|
||||
void HandledObject<T>::UnregisterAllHandles()
|
||||
void HandledObject<T>::UnregisterAllHandles() noexcept
|
||||
{
|
||||
// Tell every handle we got destroyed, to null them
|
||||
for (ObjectHandle<T>* handle : m_handles)
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace Nz
|
||||
static const ObjectHandle InvalidHandle;
|
||||
|
||||
protected:
|
||||
void OnObjectDestroyed();
|
||||
void OnObjectMoved(T* newObject);
|
||||
void OnObjectDestroyed() noexcept;
|
||||
void OnObjectMoved(T* newObject) noexcept;
|
||||
|
||||
T* m_object;
|
||||
};
|
||||
@@ -81,8 +81,8 @@ namespace Nz
|
||||
template<typename T> bool operator>=(const T& lhs, const ObjectHandle<T>& rhs);
|
||||
template<typename T> bool operator>=(const ObjectHandle<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> struct PointedType<ObjectHandle<T>> { typedef T type; };
|
||||
template<typename T> struct PointedType<const ObjectHandle<T>> { typedef T type; };
|
||||
template<typename T> struct PointedType<ObjectHandle<T>> { using type = T; };
|
||||
template<typename T> struct PointedType<const ObjectHandle<T>> { using type = T; };
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace Nz
|
||||
* \brief Action to do on object destruction
|
||||
*/
|
||||
template<typename T>
|
||||
void ObjectHandle<T>::OnObjectDestroyed()
|
||||
void ObjectHandle<T>::OnObjectDestroyed() noexcept
|
||||
{
|
||||
// Shortcut
|
||||
m_object = nullptr;
|
||||
@@ -278,7 +278,7 @@ namespace Nz
|
||||
* \brief Action to do on object move
|
||||
*/
|
||||
template<typename T>
|
||||
void ObjectHandle<T>::OnObjectMoved(T* newObject)
|
||||
void ObjectHandle<T>::OnObjectMoved(T* newObject) noexcept
|
||||
{
|
||||
// The object has been moved, update our pointer
|
||||
m_object = newObject;
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace Nz
|
||||
template<typename T> bool operator>=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
|
||||
template<typename T> struct PointedType<ObjectRef<T>> { typedef T type; };
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> { typedef T type; };
|
||||
template<typename T> struct PointedType<ObjectRef<T>> { using type = T; };
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> { using type = T; };
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ObjectRef.inl>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
#include <cstdarg>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
@@ -188,10 +189,10 @@ namespace Nz
|
||||
//char* rend();
|
||||
//const char* rend() const;
|
||||
|
||||
typedef const char& const_reference;
|
||||
typedef char* iterator;
|
||||
//typedef char* reverse_iterator;
|
||||
typedef char value_type;
|
||||
using const_reference = const char&;
|
||||
using iterator = char*;
|
||||
//using reverse_iterator = char*;
|
||||
using value_type = char;
|
||||
// Méthodes STD
|
||||
|
||||
char& operator[](std::size_t pos);
|
||||
@@ -328,8 +329,8 @@ namespace Nz
|
||||
class AbstractHash;
|
||||
|
||||
inline bool HashAppend(AbstractHash* hash, const String& string);
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, const String& string);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, String* string);
|
||||
NAZARA_CORE_API bool Serialize(SerializationContext& context, const String& string, TypeTag<String>);
|
||||
NAZARA_CORE_API bool Unserialize(SerializationContext& context, String* string, TypeTag<String>);
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
16
include/Nazara/Core/TypeTag.hpp
Normal file
16
include/Nazara/Core/TypeTag.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TYPETAG_HPP
|
||||
#define NAZARA_TYPETAG_HPP
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename T>
|
||||
struct TypeTag {};
|
||||
}
|
||||
|
||||
#endif // NAZARA_TYPETAG_HPP
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Billboard.hpp>
|
||||
#include <Nazara/Graphics/ColorBackground.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
@@ -45,14 +46,13 @@
|
||||
#include <Nazara/Graphics/DeferredFXAAPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredGeometryPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredPhongLightingPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredProxyRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/Drawable.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
||||
@@ -73,6 +73,7 @@
|
||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||
#include <Nazara/Graphics/ParticleStruct.hpp>
|
||||
#include <Nazara/Graphics/Renderable.hpp>
|
||||
#include <Nazara/Graphics/RenderQueue.hpp>
|
||||
#include <Nazara/Graphics/RenderTechniques.hpp>
|
||||
#include <Nazara/Graphics/SceneData.hpp>
|
||||
#include <Nazara/Graphics/SkeletalModel.hpp>
|
||||
|
||||
@@ -37,20 +37,20 @@ 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 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;
|
||||
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 float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> 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 float> 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 float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, 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, std::size_t billboardCount, const Recti& scissorRect, 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, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddDrawable(int renderOrder, const Drawable* drawable) = 0;
|
||||
virtual void AddDirectionalLight(const DirectionalLight& light);
|
||||
virtual void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) = 0;
|
||||
virtual void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix, const Recti& scissorRect) = 0;
|
||||
virtual void AddPointLight(const PointLight& light);
|
||||
virtual void AddSpotLight(const SpotLight& light);
|
||||
virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) = 0;
|
||||
virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Recti& scissorRect, const Texture* overlay = nullptr) = 0;
|
||||
|
||||
virtual void Clear(bool fully = false);
|
||||
|
||||
|
||||
142
include/Nazara/Graphics/BasicRenderQueue.hpp
Normal file
142
include/Nazara/Graphics/BasicRenderQueue.hpp
Normal file
@@ -0,0 +1,142 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BASICRENDERQUEUE_HPP
|
||||
#define NAZARA_BASICRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/RenderQueue.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Plane.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
|
||||
class NAZARA_GRAPHICS_API BasicRenderQueue : public AbstractRenderQueue
|
||||
{
|
||||
friend class ForwardRenderTechnique;
|
||||
|
||||
public:
|
||||
struct BillboardData;
|
||||
|
||||
BasicRenderQueue() = default;
|
||||
~BasicRenderQueue() = default;
|
||||
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, 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, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix, const Recti& scissorRect) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Recti& scissorRect, const Texture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully = false) override;
|
||||
|
||||
inline const BillboardData* GetBillboardData(std::size_t billboardIndex) const;
|
||||
|
||||
void Sort(const AbstractViewer* viewer);
|
||||
|
||||
struct BillboardData
|
||||
{
|
||||
Color color;
|
||||
Vector3f center;
|
||||
Vector2f size;
|
||||
Vector2f sinCos;
|
||||
};
|
||||
|
||||
struct Billboard
|
||||
{
|
||||
int layerIndex;
|
||||
MovablePtr<const Nz::Material> material;
|
||||
Nz::Recti scissorRect;
|
||||
BillboardData data;
|
||||
};
|
||||
|
||||
struct BillboardChain
|
||||
{
|
||||
int layerIndex;
|
||||
MovablePtr<const Nz::Material> material;
|
||||
Nz::Recti scissorRect;
|
||||
std::size_t billboardCount;
|
||||
std::size_t billboardIndex;
|
||||
};
|
||||
|
||||
RenderQueue<BillboardChain> billboards;
|
||||
RenderQueue<Billboard> depthSortedBillboards;
|
||||
|
||||
struct CustomDrawable
|
||||
{
|
||||
int layerIndex;
|
||||
MovablePtr<const Drawable> drawable;
|
||||
};
|
||||
|
||||
RenderQueue<CustomDrawable> customDrawables;
|
||||
|
||||
struct Model
|
||||
{
|
||||
int layerIndex;
|
||||
MeshData meshData;
|
||||
MovablePtr<const Nz::Material> material;
|
||||
Nz::Matrix4f matrix;
|
||||
Nz::Recti scissorRect;
|
||||
Nz::Spheref obbSphere;
|
||||
};
|
||||
|
||||
RenderQueue<Model> models;
|
||||
RenderQueue<Model> depthSortedModels;
|
||||
|
||||
struct SpriteChain
|
||||
{
|
||||
int layerIndex;
|
||||
std::size_t spriteCount;
|
||||
MovablePtr<const Material> material;
|
||||
MovablePtr<const Texture> overlay;
|
||||
MovablePtr<const VertexStruct_XYZ_Color_UV> vertices;
|
||||
Nz::Recti scissorRect;
|
||||
};
|
||||
|
||||
RenderQueue<SpriteChain> basicSprites;
|
||||
RenderQueue<SpriteChain> depthSortedSprites;
|
||||
|
||||
private:
|
||||
inline Color ComputeColor(float alpha);
|
||||
inline Vector2f ComputeSinCos(float angle);
|
||||
inline Vector2f ComputeSize(float size);
|
||||
|
||||
inline void RegisterLayer(int layerIndex);
|
||||
|
||||
std::unordered_map<const MaterialPipeline*, std::size_t> m_pipelineCache;
|
||||
std::unordered_map<const Material*, std::size_t> m_materialCache;
|
||||
std::unordered_map<const Texture*, std::size_t> m_overlayCache;
|
||||
std::unordered_map<const UberShader*, std::size_t> m_shaderCache;
|
||||
std::unordered_map<const Texture*, std::size_t> m_textureCache;
|
||||
std::unordered_map<const VertexBuffer*, std::size_t> m_vertexBufferCache;
|
||||
std::unordered_map<int, std::size_t> m_layerCache;
|
||||
|
||||
std::vector<BillboardData> m_billboards;
|
||||
std::vector<int> m_renderLayers;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/BasicRenderQueue.inl>
|
||||
|
||||
#endif // NAZARA_BASICRENDERQUEUE_HPP
|
||||
38
include/Nazara/Graphics/BasicRenderQueue.inl
Normal file
38
include/Nazara/Graphics/BasicRenderQueue.inl
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const BasicRenderQueue::BillboardData* BasicRenderQueue::GetBillboardData(std::size_t billboardIndex) const
|
||||
{
|
||||
assert(billboardIndex < m_billboards.size());
|
||||
return &m_billboards[billboardIndex];
|
||||
}
|
||||
|
||||
inline Color BasicRenderQueue::ComputeColor(float alpha)
|
||||
{
|
||||
return Color(255, 255, 255, static_cast<UInt8>(255.f * alpha));
|
||||
}
|
||||
|
||||
inline Vector2f BasicRenderQueue::ComputeSinCos(float angle)
|
||||
{
|
||||
float radians = ToRadians(angle);
|
||||
return { std::sin(radians), std::cos(radians) };
|
||||
}
|
||||
|
||||
inline Vector2f BasicRenderQueue::ComputeSize(float size)
|
||||
{
|
||||
return Vector2f(size, size);
|
||||
}
|
||||
|
||||
inline void BasicRenderQueue::RegisterLayer(int layerIndex)
|
||||
{
|
||||
auto it = std::lower_bound(m_renderLayers.begin(), m_renderLayers.end(), layerIndex);
|
||||
if (it == m_renderLayers.end() || *it != layerIndex)
|
||||
m_renderLayers.insert(it, layerIndex);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
Billboard(Billboard&&) = delete;
|
||||
~Billboard() = default;
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
|
||||
inline const Color& GetColor() const;
|
||||
inline float GetRotation() const;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_DEFERREDGEOMETRYPASS_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
@@ -17,6 +18,8 @@ namespace Nz
|
||||
{
|
||||
class NAZARA_GRAPHICS_API DeferredGeometryPass : public DeferredRenderPass
|
||||
{
|
||||
friend class DeferredRenderTechnique;
|
||||
|
||||
public:
|
||||
DeferredGeometryPass();
|
||||
virtual ~DeferredGeometryPass();
|
||||
@@ -27,9 +30,17 @@ namespace Nz
|
||||
protected:
|
||||
struct ShaderUniforms;
|
||||
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Billboard>& billboards) const;
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::BillboardChain>& billboards) const;
|
||||
void DrawModels(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Model>& models) const;
|
||||
void DrawSprites(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::SpriteChain>& sprites) const;
|
||||
|
||||
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
|
||||
void OnShaderInvalidated(const Shader* shader) const;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
struct ShaderUniforms
|
||||
{
|
||||
NazaraSlot(Shader, OnShaderUniformInvalidated, shaderUniformInvalidatedSlot);
|
||||
@@ -41,8 +52,18 @@ namespace Nz
|
||||
};
|
||||
|
||||
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
||||
mutable std::vector<std::pair<const VertexStruct_XYZ_Color_UV*, std::size_t>> m_spriteChains;
|
||||
Buffer m_vertexBuffer;
|
||||
RenderStates m_clearStates;
|
||||
ShaderRef m_clearShader;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
static VertexDeclaration s_billboardInstanceDeclaration;
|
||||
static VertexDeclaration s_billboardVertexDeclaration;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
58
include/Nazara/Graphics/DeferredProxyRenderQueue.hpp
Normal file
58
include/Nazara/Graphics/DeferredProxyRenderQueue.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
#define NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class BasicRenderQueue;
|
||||
|
||||
class NAZARA_GRAPHICS_API DeferredProxyRenderQueue final : public AbstractRenderQueue
|
||||
{
|
||||
public:
|
||||
struct BillboardData;
|
||||
|
||||
inline DeferredProxyRenderQueue(BasicRenderQueue* deferredQueue, BasicRenderQueue* forwardQueue);
|
||||
~DeferredProxyRenderQueue() = default;
|
||||
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, 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, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t billboardCount, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix, const Recti& scissorRect) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Recti& scissorRect, const Texture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully = false) override;
|
||||
|
||||
inline BasicRenderQueue* GetDeferredRenderQueue();
|
||||
inline BasicRenderQueue* GetForwardRenderQueue();
|
||||
|
||||
private:
|
||||
BasicRenderQueue * m_deferredRenderQueue;
|
||||
BasicRenderQueue* m_forwardRenderQueue;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DeferredProxyRenderQueue.inl>
|
||||
|
||||
#endif // NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
30
include/Nazara/Graphics/DeferredProxyRenderQueue.inl
Normal file
30
include/Nazara/Graphics/DeferredProxyRenderQueue.inl
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/DeferredProxyRenderQueue.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a DeferredProxyRenderQueue using a deferred and a forward queues
|
||||
*
|
||||
* \param deferredQueue Deferred queue which will be used for non-blended objects
|
||||
* \param forwardQueue Forward queue which will be used for blended objects
|
||||
*/
|
||||
inline DeferredProxyRenderQueue::DeferredProxyRenderQueue(BasicRenderQueue* deferredQueue, BasicRenderQueue* forwardQueue) :
|
||||
m_deferredRenderQueue(deferredQueue),
|
||||
m_forwardRenderQueue(forwardQueue)
|
||||
{
|
||||
}
|
||||
|
||||
inline BasicRenderQueue* DeferredProxyRenderQueue::GetDeferredRenderQueue()
|
||||
{
|
||||
return m_deferredRenderQueue;
|
||||
}
|
||||
|
||||
inline BasicRenderQueue* DeferredProxyRenderQueue::GetForwardRenderQueue()
|
||||
{
|
||||
return m_forwardRenderQueue;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@
|
||||
namespace Nz
|
||||
{
|
||||
class DeferredRenderTechnique;
|
||||
class DeferredRenderQueue;
|
||||
struct SceneData;
|
||||
class DeferredProxyRenderQueue;
|
||||
class RenderTexture;
|
||||
class Texture;
|
||||
struct SceneData;
|
||||
|
||||
class NAZARA_GRAPHICS_API DeferredRenderPass
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace Nz
|
||||
protected:
|
||||
Vector2ui m_dimensions;
|
||||
DeferredRenderTechnique* m_deferredTechnique;
|
||||
DeferredRenderQueue* m_renderQueue;
|
||||
DeferredProxyRenderQueue* m_renderQueue;
|
||||
RenderTexture* m_GBufferRTT;
|
||||
RenderTexture* m_workRTT;
|
||||
Texture* m_depthStencilTexture;
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
#define NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue
|
||||
{
|
||||
public:
|
||||
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
|
||||
~DeferredRenderQueue() = default;
|
||||
|
||||
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;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> 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 float> 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 float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully = false) override;
|
||||
|
||||
struct MeshInstanceEntry
|
||||
{
|
||||
NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot);
|
||||
NazaraSlot(VertexBuffer, OnVertexBufferRelease, vertexBufferReleaseSlot);
|
||||
|
||||
std::vector<Matrix4f> instances;
|
||||
};
|
||||
|
||||
typedef std::map<MeshData, MeshInstanceEntry, ForwardRenderQueue::MeshDataComparator> MeshInstanceContainer;
|
||||
|
||||
struct BatchedModelEntry
|
||||
{
|
||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||
|
||||
MeshInstanceContainer meshMap;
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
MeshPipelineBatches opaqueModels;
|
||||
unsigned int clearCount = 0;
|
||||
};
|
||||
|
||||
std::map<int, Layer> layers;
|
||||
|
||||
private:
|
||||
Layer& GetLayer(unsigned int i); ///TODO: Inline
|
||||
|
||||
ForwardRenderQueue* m_forwardQueue;
|
||||
|
||||
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
||||
void OnMaterialInvalidation(const Material* material);
|
||||
void OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_DEFERREDRENDERQUEUE_HPP
|
||||
0
include/Nazara/Graphics/DeferredRenderQueue.inl
Normal file
0
include/Nazara/Graphics/DeferredRenderQueue.inl
Normal file
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/DeferredProxyRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
@@ -64,8 +64,9 @@ namespace Nz
|
||||
};
|
||||
|
||||
std::map<RenderPassType, std::map<int, std::unique_ptr<DeferredRenderPass>>, RenderPassComparator> m_passes;
|
||||
ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue
|
||||
DeferredRenderQueue m_renderQueue;
|
||||
BasicRenderQueue m_deferredRenderQueue; // Must be initialized before the ProxyRenderQueue
|
||||
ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the ProxyRenderQueue
|
||||
DeferredProxyRenderQueue m_renderQueue;
|
||||
mutable TextureRef m_depthStencilTexture;
|
||||
mutable RenderTexture m_GBufferRTT;
|
||||
mutable RenderTexture m_workRTT;
|
||||
|
||||
@@ -8,33 +8,33 @@
|
||||
#define NAZARA_DEPTHRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_GRAPHICS_API DepthRenderQueue : public ForwardRenderQueue
|
||||
class NAZARA_GRAPHICS_API DepthRenderQueue : public BasicRenderQueue
|
||||
{
|
||||
public:
|
||||
DepthRenderQueue();
|
||||
~DepthRenderQueue() = default;
|
||||
|
||||
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;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> 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 float> 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 float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, 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, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, std::size_t count, const Recti& scissorRect, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddDirectionalLight(const DirectionalLight& light) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix, const Recti& scissorRect) override;
|
||||
void AddPointLight(const PointLight& light) override;
|
||||
void AddSpotLight(const SpotLight& light) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Recti& scissorRect, const Texture* overlay = nullptr) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
inline bool IsMaterialSuitable(const Material* material) const;
|
||||
|
||||
MaterialRef m_baseMaterial;
|
||||
|
||||
@@ -35,9 +35,12 @@ namespace Nz
|
||||
private:
|
||||
struct ShaderUniforms;
|
||||
|
||||
void DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Billboard>& billboards) const;
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::BillboardChain>& billboards) const;
|
||||
void DrawCustomDrawables(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::CustomDrawable>& customDrawables) const;
|
||||
void DrawModels(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Model>& models) const;
|
||||
void DrawSprites(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::SpriteChain>& sprites) const;
|
||||
|
||||
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
|
||||
void OnShaderInvalidated(const Shader* shader) const;
|
||||
|
||||
@@ -59,11 +62,14 @@ namespace Nz
|
||||
};
|
||||
|
||||
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
||||
mutable std::vector<std::pair<const VertexStruct_XYZ_Color_UV*, std::size_t>> m_spriteChains;
|
||||
Buffer m_vertexBuffer;
|
||||
mutable DepthRenderQueue m_renderQueue;
|
||||
Texture m_whiteTexture;
|
||||
RenderStates m_clearStates;
|
||||
ShaderRef m_clearShader;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
mutable DepthRenderQueue m_renderQueue;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_FORWARDRENDERQUEUE_HPP
|
||||
#define NAZARA_FORWARDRENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Plane.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
|
||||
class NAZARA_GRAPHICS_API ForwardRenderQueue : public AbstractRenderQueue
|
||||
{
|
||||
friend class ForwardRenderTechnique;
|
||||
|
||||
public:
|
||||
ForwardRenderQueue() = default;
|
||||
~ForwardRenderQueue() = default;
|
||||
|
||||
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;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> 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 float> 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 float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) override;
|
||||
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully = false) override;
|
||||
|
||||
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
|
||||
{
|
||||
Color color;
|
||||
Vector3f center;
|
||||
Vector2f size;
|
||||
Vector2f sinCos;
|
||||
};
|
||||
|
||||
struct BatchedBillboardEntry
|
||||
{
|
||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||
|
||||
std::vector<BillboardData> billboards;
|
||||
};
|
||||
|
||||
using BatchedBillboardContainer = std::map<const Material*, BatchedBillboardEntry, MaterialComparator>;
|
||||
|
||||
struct BatchedBillboardPipelineEntry
|
||||
{
|
||||
BatchedBillboardContainer materialMap;
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
using BillboardPipelineBatches = std::map<const MaterialPipeline*, BatchedBillboardPipelineEntry, MaterialPipelineComparator>;
|
||||
|
||||
/// Sprites
|
||||
struct SpriteChain_XYZ_Color_UV
|
||||
{
|
||||
const VertexStruct_XYZ_Color_UV* vertices;
|
||||
std::size_t spriteCount;
|
||||
};
|
||||
|
||||
struct BatchedSpriteEntry
|
||||
{
|
||||
NazaraSlot(Texture, OnTextureRelease, textureReleaseSlot);
|
||||
|
||||
std::vector<SpriteChain_XYZ_Color_UV> spriteChains;
|
||||
};
|
||||
|
||||
using SpriteOverlayBatches = std::map<const Texture*, BatchedSpriteEntry>;
|
||||
|
||||
struct BatchedBasicSpriteEntry
|
||||
{
|
||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||
|
||||
SpriteOverlayBatches overlayMap;
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
using SpriteMaterialBatches = std::map<const Material*, BatchedBasicSpriteEntry, MaterialComparator>;
|
||||
|
||||
struct BatchedSpritePipelineEntry
|
||||
{
|
||||
SpriteMaterialBatches materialMap;
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
using SpritePipelineBatches = std::map<const MaterialPipeline*, BatchedSpritePipelineEntry, MaterialPipelineComparator>;
|
||||
|
||||
/// Meshes
|
||||
struct MeshDataComparator
|
||||
{
|
||||
bool operator()(const MeshData& data1, const MeshData& data2) const;
|
||||
};
|
||||
|
||||
struct MeshInstanceEntry
|
||||
{
|
||||
NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot);
|
||||
NazaraSlot(VertexBuffer, OnVertexBufferRelease, vertexBufferReleaseSlot);
|
||||
|
||||
std::vector<Matrix4f> instances;
|
||||
Spheref squaredBoundingSphere;
|
||||
};
|
||||
|
||||
using MeshInstanceContainer = std::map<MeshData, MeshInstanceEntry, MeshDataComparator>;
|
||||
|
||||
struct BatchedModelEntry
|
||||
{
|
||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||
|
||||
MeshInstanceContainer meshMap;
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
using MeshMaterialBatches = std::map<const Material*, BatchedModelEntry, MaterialComparator>;
|
||||
|
||||
struct BatchedMaterialEntry
|
||||
{
|
||||
std::size_t maxInstanceCount = 0;
|
||||
MeshMaterialBatches materialMap;
|
||||
};
|
||||
|
||||
using MeshPipelineBatches = std::map<const MaterialPipeline*, BatchedMaterialEntry, MaterialPipelineComparator>;
|
||||
|
||||
struct UnbatchedModelData
|
||||
{
|
||||
Matrix4f transformMatrix;
|
||||
MeshData meshData;
|
||||
Spheref obbSphere;
|
||||
const Material* material;
|
||||
};
|
||||
|
||||
struct UnbatchedSpriteData
|
||||
{
|
||||
std::size_t spriteCount;
|
||||
const Material* material;
|
||||
const Texture* overlay;
|
||||
const VertexStruct_XYZ_Color_UV* vertices;
|
||||
};
|
||||
|
||||
struct Layer
|
||||
{
|
||||
BillboardPipelineBatches billboards;
|
||||
SpritePipelineBatches opaqueSprites;
|
||||
MeshPipelineBatches opaqueModels;
|
||||
std::vector<std::size_t> depthSortedMeshes;
|
||||
std::vector<std::size_t> depthSortedSprites;
|
||||
std::vector<UnbatchedModelData> depthSortedMeshData;
|
||||
std::vector<UnbatchedSpriteData> depthSortedSpriteData;
|
||||
std::vector<const Drawable*> otherDrawables;
|
||||
unsigned int clearCount = 0;
|
||||
};
|
||||
|
||||
std::map<int, Layer> layers;
|
||||
|
||||
private:
|
||||
BillboardData* GetBillboardData(int renderOrder, const Material* material, unsigned int count);
|
||||
Layer& GetLayer(int i); ///TODO: Inline
|
||||
|
||||
void SortBillboards(Layer& layer, const Planef& nearPlane);
|
||||
void SortForOrthographic(const AbstractViewer* viewer);
|
||||
void SortForPerspective(const AbstractViewer* viewer);
|
||||
|
||||
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
||||
void OnMaterialInvalidation(const Material* material);
|
||||
void OnTextureInvalidation(const Texture* texture);
|
||||
void OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_FORWARDRENDERQUEUE_HPP
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/BasicRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
@@ -40,11 +40,12 @@ namespace Nz
|
||||
struct ShaderUniforms;
|
||||
|
||||
void ChooseLights(const Spheref& object, bool includeDirectionalLights = true) const;
|
||||
void DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawOrderedSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Billboard>& billboards) const;
|
||||
void DrawBillboards(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::BillboardChain>& billboards) const;
|
||||
void DrawCustomDrawables(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::CustomDrawable>& customDrawables) const;
|
||||
void DrawModels(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::Model>& models) const;
|
||||
void DrawSprites(const SceneData& sceneData, const BasicRenderQueue& renderQueue, const RenderQueue<BasicRenderQueue::SpriteChain>& sprites) const;
|
||||
|
||||
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
|
||||
void OnShaderInvalidated(const Shader* shader) const;
|
||||
void SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int lightIndex, unsigned int uniformOffset) const;
|
||||
@@ -84,15 +85,16 @@ namespace Nz
|
||||
|
||||
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
||||
mutable std::vector<LightIndex> m_lights;
|
||||
mutable std::vector<std::pair<const VertexStruct_XYZ_Color_UV*, std::size_t>> m_spriteChains;
|
||||
Buffer m_vertexBuffer;
|
||||
mutable ForwardRenderQueue m_renderQueue;
|
||||
Texture m_whiteTexture;
|
||||
mutable BasicRenderQueue m_renderQueue;
|
||||
TextureRef m_whiteCubemap;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
unsigned int m_maxLightPassPerObject;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static Texture s_dummyReflection;
|
||||
static TextureSampler s_reflectionSampler;
|
||||
static TextureSampler s_shadowSampler;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Nz
|
||||
InstancedRenderable(InstancedRenderable&& renderable) = delete;
|
||||
virtual ~InstancedRenderable();
|
||||
|
||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const = 0;
|
||||
virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const = 0;
|
||||
|
||||
virtual bool Cull(const Frustumf& frustum, const InstanceData& instanceData) const;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
@@ -44,8 +45,8 @@ namespace Nz
|
||||
Model(Model&& model) = default;
|
||||
virtual ~Model();
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0);
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, int renderOrder = 0, const Recti& scissorRect = Recti(-1, -1, -1, -1)) const;
|
||||
|
||||
using InstancedRenderable::GetMaterial;
|
||||
const MaterialRef& GetMaterial(const String& subMeshName) const;
|
||||
|
||||
@@ -22,14 +22,15 @@ namespace Nz
|
||||
*
|
||||
* \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
|
||||
* \param renderOrder Specify the render queue layer to be used
|
||||
* \param scissorRect The Scissor rect to uses for rendering
|
||||
*/
|
||||
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
|
||||
{
|
||||
void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, int renderOrder, const Recti& scissorRect) const
|
||||
{
|
||||
InstanceData instanceData(Nz::Matrix4f::Identity());
|
||||
instanceData.renderOrder = renderOrder;
|
||||
instanceData.transformMatrix = transformMatrix;
|
||||
return AddToRenderQueue(renderQueue, instanceData);
|
||||
return AddToRenderQueue(renderQueue, instanceData, scissorRect);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
96
include/Nazara/Graphics/RenderQueue.hpp
Normal file
96
include/Nazara/Graphics/RenderQueue.hpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERQUEUE_HPP
|
||||
#define NAZARA_RENDERQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RenderQueueInternal
|
||||
{
|
||||
public:
|
||||
using Index = Nz::UInt64;
|
||||
|
||||
RenderQueueInternal() = default;
|
||||
~RenderQueueInternal() = default;
|
||||
|
||||
protected:
|
||||
using RenderDataPair = std::pair<Index, std::size_t>;
|
||||
|
||||
void Sort();
|
||||
|
||||
std::vector<RenderDataPair> m_orderedRenderQueue;
|
||||
};
|
||||
|
||||
template<typename RenderData>
|
||||
class RenderQueue : public RenderQueueInternal
|
||||
{
|
||||
public:
|
||||
class const_iterator;
|
||||
friend const_iterator;
|
||||
using size_type = std::size_t;
|
||||
|
||||
RenderQueue() = default;
|
||||
RenderQueue(const RenderQueue&) = default;
|
||||
RenderQueue(RenderQueue&&) = default;
|
||||
~RenderQueue() = default;
|
||||
|
||||
void Clear();
|
||||
|
||||
void Insert(RenderData&& data);
|
||||
|
||||
template<typename IndexFunc> void Sort(IndexFunc&& func);
|
||||
|
||||
// STL API
|
||||
inline const_iterator begin() const;
|
||||
inline bool empty() const;
|
||||
inline const_iterator end() const;
|
||||
inline size_type size() const;
|
||||
|
||||
RenderQueue& operator=(const RenderQueue&) = default;
|
||||
RenderQueue& operator=(RenderQueue&&) = default;
|
||||
|
||||
private:
|
||||
const RenderData& GetData(std::size_t i) const;
|
||||
|
||||
std::vector<RenderData> m_data;
|
||||
};
|
||||
|
||||
template<typename RenderData>
|
||||
class RenderQueue<RenderData>::const_iterator : public std::iterator<std::forward_iterator_tag, const RenderData>
|
||||
{
|
||||
friend RenderQueue;
|
||||
|
||||
public:
|
||||
const_iterator(const const_iterator& it);
|
||||
|
||||
const RenderData& operator*() const;
|
||||
|
||||
const_iterator& operator=(const const_iterator& it);
|
||||
const_iterator& operator++();
|
||||
const_iterator operator++(int);
|
||||
|
||||
bool operator==(const const_iterator& rhs) const;
|
||||
bool operator!=(const const_iterator& rhs) const;
|
||||
|
||||
void swap(const_iterator& rhs);
|
||||
|
||||
private:
|
||||
const_iterator(const RenderQueue* queue, std::size_t nextId);
|
||||
|
||||
std::size_t m_nextDataId;
|
||||
const RenderQueue* m_queue;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/RenderQueue.inl>
|
||||
|
||||
#endif // NAZARA_RENDERQUEUE_HPP
|
||||
136
include/Nazara/Graphics/RenderQueue.inl
Normal file
136
include/Nazara/Graphics/RenderQueue.inl
Normal file
@@ -0,0 +1,136 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/RenderQueue.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename RenderData>
|
||||
void RenderQueue<RenderData>::Clear()
|
||||
{
|
||||
m_orderedRenderQueue.clear();
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
void RenderQueue<RenderData>::Insert(RenderData&& data)
|
||||
{
|
||||
m_data.emplace_back(std::move(data));
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
template<typename IndexFunc>
|
||||
void RenderQueue<RenderData>::Sort(IndexFunc&& func)
|
||||
{
|
||||
m_orderedRenderQueue.clear();
|
||||
m_orderedRenderQueue.reserve(m_data.size());
|
||||
|
||||
std::size_t dataIndex = 0;
|
||||
for (const RenderData& renderData : m_data)
|
||||
m_orderedRenderQueue.emplace_back(func(renderData), dataIndex++);
|
||||
|
||||
RenderQueueInternal::Sort();
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::const_iterator RenderQueue<RenderData>::begin() const
|
||||
{
|
||||
return const_iterator(this, 0);
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
bool RenderQueue<RenderData>::empty() const
|
||||
{
|
||||
return m_orderedRenderQueue.empty();
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::const_iterator RenderQueue<RenderData>::end() const
|
||||
{
|
||||
return const_iterator(this, m_orderedRenderQueue.size());
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::size_type RenderQueue<RenderData>::size() const
|
||||
{
|
||||
return m_orderedRenderQueue.size();
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
const RenderData& RenderQueue<RenderData>::GetData(std::size_t i) const
|
||||
{
|
||||
NazaraAssert(i < m_orderedRenderQueue.size(), "Cannot dereference post-end iterator");
|
||||
|
||||
return m_data[m_orderedRenderQueue[i].second];
|
||||
}
|
||||
|
||||
|
||||
template<typename RenderData>
|
||||
RenderQueue<RenderData>::const_iterator::const_iterator(const RenderQueue* queue, std::size_t nextId) :
|
||||
m_nextDataId(nextId),
|
||||
m_queue(queue)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
RenderQueue<RenderData>::const_iterator::const_iterator(const const_iterator& it) :
|
||||
m_nextDataId(it.m_nextDataId),
|
||||
m_queue(it.m_queue)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
const RenderData& RenderQueue<RenderData>::const_iterator::operator*() const
|
||||
{
|
||||
return m_queue->GetData(m_nextDataId);
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::const_iterator& RenderQueue<RenderData>::const_iterator::operator=(const const_iterator& it)
|
||||
{
|
||||
m_nextDataId = it.m_nextDataId;
|
||||
m_queue = it.m_queue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::const_iterator& RenderQueue<RenderData>::const_iterator::operator++()
|
||||
{
|
||||
++m_nextDataId;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
typename RenderQueue<RenderData>::const_iterator RenderQueue<RenderData>::const_iterator::operator++(int)
|
||||
{
|
||||
return iterator(m_queue, m_nextDataId++);
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
bool RenderQueue<RenderData>::const_iterator::operator==(const typename RenderQueue<RenderData>::const_iterator& rhs) const
|
||||
{
|
||||
NazaraAssert(m_queue == rhs.m_queue, "Cannot compare iterator coming from different queues");
|
||||
|
||||
return m_nextDataId == rhs.m_nextDataId;
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
bool RenderQueue<RenderData>::const_iterator::operator!=(const typename RenderQueue<RenderData>::const_iterator& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
template<typename RenderData>
|
||||
void RenderQueue<RenderData>::const_iterator::swap(typename RenderQueue<RenderData>::const_iterator& rhs)
|
||||
{
|
||||
NazaraAssert(m_queue == rhs.m_queue, "Cannot swap iterator coming from different queues");
|
||||
|
||||
using std::swap;
|
||||
|
||||
swap(m_nextDataId, rhs.m_nextDataId);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
SkeletalModel(SkeletalModel&& model) = default;
|
||||
~SkeletalModel() = default;
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
void AdvanceAnimation(float elapsedTime);
|
||||
|
||||
SkeletalModel* Clone() const;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Nz
|
||||
Sprite(Sprite&&) = delete;
|
||||
~Sprite() = default;
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
|
||||
inline const Color& GetColor() const;
|
||||
inline const Color& GetCornerColor(RectCorner corner) const;
|
||||
|
||||
@@ -172,6 +172,7 @@ namespace Nz
|
||||
{
|
||||
MaterialRef material = Material::New();
|
||||
material->EnableFaceCulling(false);
|
||||
material->EnableScissorTest(true);
|
||||
|
||||
SetMaterial(std::move(material));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Nz
|
||||
inline TextSprite(const TextSprite& sprite);
|
||||
~TextSprite() = default;
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
|
||||
inline void Clear();
|
||||
|
||||
|
||||
@@ -110,14 +110,7 @@ namespace Nz
|
||||
|
||||
inline void TextSprite::SetDefaultMaterial()
|
||||
{
|
||||
MaterialRef material = Material::New();
|
||||
material->EnableBlending(true);
|
||||
material->EnableDepthWrite(false);
|
||||
material->EnableFaceCulling(false);
|
||||
material->SetDstBlend(BlendFunc_InvSrcAlpha);
|
||||
material->SetSrcBlend(BlendFunc_SrcAlpha);
|
||||
|
||||
SetMaterial(material);
|
||||
SetMaterial(Material::New("Translucent2D"));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Nz
|
||||
TileMap(TileMap&&) = delete;
|
||||
~TileMap() = default;
|
||||
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
|
||||
|
||||
inline void DisableTile(const Vector2ui& tilePos);
|
||||
inline void DisableTiles();
|
||||
|
||||
@@ -69,11 +69,11 @@ namespace Nz
|
||||
OrientedBox<T> obb;
|
||||
};
|
||||
|
||||
typedef BoundingVolume<double> BoundingVolumed;
|
||||
typedef BoundingVolume<float> BoundingVolumef;
|
||||
using BoundingVolumed = BoundingVolume<double>;
|
||||
using BoundingVolumef = BoundingVolume<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume, TypeTag<BoundingVolume<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume, TypeTag<BoundingVolume<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace Nz
|
||||
* \remark Does not save OBB corners
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume)
|
||||
bool Serialize(SerializationContext& context, const BoundingVolume<T>& boundingVolume, TypeTag<BoundingVolume<T>>)
|
||||
{
|
||||
if (!Serialize(context, static_cast<UInt8>(boundingVolume.extend)))
|
||||
return false;
|
||||
@@ -627,7 +627,7 @@ namespace Nz
|
||||
* \remark The resulting oriented box corners will *not* be updated, a call to Update is required
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume)
|
||||
bool Unserialize(SerializationContext& context, BoundingVolume<T>* boundingVolume, TypeTag<BoundingVolume<T>>)
|
||||
{
|
||||
UInt8 extend;
|
||||
if (!Unserialize(context, &extend))
|
||||
|
||||
@@ -93,15 +93,15 @@ namespace Nz
|
||||
T x, y, z, width, height, depth;
|
||||
};
|
||||
|
||||
typedef Box<double> Boxd;
|
||||
typedef Box<float> Boxf;
|
||||
typedef Box<int> Boxi;
|
||||
typedef Box<unsigned int> Boxui;
|
||||
typedef Box<Int32> Boxi32;
|
||||
typedef Box<UInt32> Boxui32;
|
||||
using Boxd = Box<double>;
|
||||
using Boxf = Box<float>;
|
||||
using Boxi = Box<int>;
|
||||
using Boxui = Box<unsigned int>;
|
||||
using Boxi32 = Box<Int32>;
|
||||
using Boxui32 = Box<UInt32>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Box<T>& box);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Box<T>* box);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Box<T>& box, TypeTag<Box<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Box<T>* box, TypeTag<Box<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -912,7 +912,7 @@ namespace Nz
|
||||
* \param box Input Box
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Box<T>& box)
|
||||
bool Serialize(SerializationContext& context, const Box<T>& box, TypeTag<Box<T>>)
|
||||
{
|
||||
if (!Serialize(context, box.x))
|
||||
return false;
|
||||
@@ -943,7 +943,7 @@ namespace Nz
|
||||
* \param box Output Box
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Box<T>* box)
|
||||
bool Unserialize(SerializationContext& context, Box<T>* box, TypeTag<Box<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &box->x))
|
||||
return false;
|
||||
|
||||
@@ -62,11 +62,11 @@ namespace Nz
|
||||
T pitch, yaw, roll;
|
||||
};
|
||||
|
||||
typedef EulerAngles<double> EulerAnglesd;
|
||||
typedef EulerAngles<float> EulerAnglesf;
|
||||
using EulerAnglesd = EulerAngles<double>;
|
||||
using EulerAnglesf = EulerAngles<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const EulerAngles<T>& eulerAngles);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, EulerAngles<T>* eulerAngles);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const EulerAngles<T>& eulerAngles, TypeTag<EulerAngles<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, EulerAngles<T>* eulerAngles, TypeTag<EulerAngles<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::EulerAngles<T>& angles);
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace Nz
|
||||
* \param angles Input euler angles
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const EulerAngles<T>& angles)
|
||||
bool Serialize(SerializationContext& context, const EulerAngles<T>& angles, TypeTag<EulerAngles<T>>)
|
||||
{
|
||||
if (!Serialize(context, angles.pitch))
|
||||
return false;
|
||||
@@ -362,7 +362,7 @@ namespace Nz
|
||||
* \param angles Output euler angles
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, EulerAngles<T>* angles)
|
||||
bool Unserialize(SerializationContext& context, EulerAngles<T>* angles, TypeTag<EulerAngles<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &angles->pitch))
|
||||
return false;
|
||||
|
||||
@@ -58,17 +58,18 @@ namespace Nz
|
||||
String ToString() const;
|
||||
|
||||
template<typename U>
|
||||
friend bool Serialize(SerializationContext& context, const Frustum<U>& frustum);
|
||||
friend bool Serialize(SerializationContext& context, const Frustum<U>& frustum, TypeTag<Frustum<U>>);
|
||||
|
||||
template<typename U>
|
||||
friend bool Unserialize(SerializationContext& context, Frustum<U>* frustum);
|
||||
friend bool Unserialize(SerializationContext& context, Frustum<U>* frustum, TypeTag<Frustum<U>>);
|
||||
|
||||
private:
|
||||
Vector3<T> m_corners[BoxCorner_Max+1];
|
||||
Plane<T> m_planes[FrustumPlane_Max+1];
|
||||
};
|
||||
|
||||
typedef Frustum<double> Frustumd;
|
||||
typedef Frustum<float> Frustumf;
|
||||
using Frustumd = Frustum<double>;
|
||||
using Frustumf = Frustum<float>;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -684,7 +684,7 @@ namespace Nz
|
||||
* \param matrix Input frustum
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Frustum<T>& frustum)
|
||||
bool Serialize(SerializationContext& context, const Frustum<T>& frustum, TypeTag<Frustum<T>>)
|
||||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
@@ -709,7 +709,7 @@ namespace Nz
|
||||
* \param matrix Output frustum
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Frustum<T>* frustum)
|
||||
bool Unserialize(SerializationContext& context, Frustum<T>* frustum, TypeTag<Frustum<T>>)
|
||||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
|
||||
@@ -138,11 +138,11 @@ namespace Nz
|
||||
m41, m42, m43, m44;
|
||||
};
|
||||
|
||||
typedef Matrix4<double> Matrix4d;
|
||||
typedef Matrix4<float> Matrix4f;
|
||||
using Matrix4d = Matrix4<double>;
|
||||
using Matrix4f = Matrix4<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Matrix4<T>& matrix);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Matrix4<T>* matrix);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Matrix4<T>& matrix, TypeTag<Matrix4<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Matrix4<T>* matrix, TypeTag<Matrix4<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Matrix4<T>& matrix);
|
||||
|
||||
@@ -242,8 +242,8 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
const T* ptr = (&m11) + column*4;
|
||||
return Vector4<T>(ptr);
|
||||
const T* ptr = &m11 + column * 4;
|
||||
return Vector4<T>(ptr[0], ptr[1], ptr[2], ptr[3]);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1767,7 +1767,7 @@ namespace Nz
|
||||
* \param matrix Input matrix
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Matrix4<T>& matrix)
|
||||
bool Serialize(SerializationContext& context, const Matrix4<T>& matrix, TypeTag<Matrix4<T>>)
|
||||
{
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
@@ -1786,7 +1786,7 @@ namespace Nz
|
||||
* \param matrix Output matrix
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Matrix4<T>* matrix)
|
||||
bool Unserialize(SerializationContext& context, Matrix4<T>* matrix, TypeTag<Matrix4<T>>)
|
||||
{
|
||||
T* head = matrix->operator T*();
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
|
||||
@@ -68,11 +68,11 @@ namespace Nz
|
||||
Vector3<T> m_corners[BoxCorner_Max+1]; // Ne peuvent pas être modifiés directement
|
||||
};
|
||||
|
||||
typedef OrientedBox<double> OrientedBoxd;
|
||||
typedef OrientedBox<float> OrientedBoxf;
|
||||
using OrientedBoxd = OrientedBox<double>;
|
||||
using OrientedBoxf = OrientedBox<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const OrientedBox<T>& obb);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, OrientedBox<T>* obb);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const OrientedBox<T>& obb, TypeTag<OrientedBox<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, OrientedBox<T>* obb, TypeTag<OrientedBox<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace Nz
|
||||
* \remark Does not save OBB corners
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const OrientedBox<T>& obb)
|
||||
bool Serialize(SerializationContext& context, const OrientedBox<T>& obb, TypeTag<OrientedBox<T>>)
|
||||
{
|
||||
if (!Serialize(context, obb.localBox))
|
||||
return false;
|
||||
@@ -460,7 +460,7 @@ namespace Nz
|
||||
* \remark The resulting oriented box corners will *not* be updated, a call to Update is required
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, OrientedBox<T>* obb)
|
||||
bool Unserialize(SerializationContext& context, OrientedBox<T>* obb, TypeTag<OrientedBox<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &obb->localBox))
|
||||
return false;
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace Nz
|
||||
T distance;
|
||||
};
|
||||
|
||||
typedef Plane<double> Planed;
|
||||
typedef Plane<float> Planef;
|
||||
using Planed = Plane<double>;
|
||||
using Planef = Plane<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Plane<T>& plane);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Plane<T>* plane);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Plane<T>& plane, TypeTag<Plane<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Plane<T>* plane, TypeTag<Plane<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace Nz
|
||||
* \param plane Input Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Plane<T>& plane)
|
||||
bool Serialize(SerializationContext& context, const Plane<T>& plane, TypeTag<Plane<T>>)
|
||||
{
|
||||
if (!Serialize(context, plane.normal))
|
||||
return false;
|
||||
@@ -453,7 +453,7 @@ namespace Nz
|
||||
* \param plane Output Plane
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Plane<T>* plane)
|
||||
bool Unserialize(SerializationContext& context, Plane<T>* plane, TypeTag<Plane<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &plane->normal))
|
||||
return false;
|
||||
|
||||
@@ -88,11 +88,11 @@ namespace Nz
|
||||
T w, x, y, z;
|
||||
};
|
||||
|
||||
typedef Quaternion<double> Quaterniond;
|
||||
typedef Quaternion<float> Quaternionf;
|
||||
using Quaterniond = Quaternion<double>;
|
||||
using Quaternionf = Quaternion<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Quaternion<T>& quat);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Quaternion<T>* quat);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Quaternion<T>& quat, TypeTag<Quaternion<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Quaternion<T>* quat, TypeTag<Quaternion<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Quaternion<T>& quat);
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace Nz
|
||||
T norm = SquaredMagnitude();
|
||||
if (norm > F(0.0))
|
||||
{
|
||||
T invNorm = F(1.0) / norm;
|
||||
T invNorm = F(1.0) / std::sqrt(norm);
|
||||
|
||||
w *= invNorm;
|
||||
x *= -invNorm;
|
||||
@@ -826,7 +826,7 @@ namespace Nz
|
||||
* \param quat Input Quaternion
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Quaternion<T>& quat)
|
||||
bool Serialize(SerializationContext& context, const Quaternion<T>& quat, TypeTag<Quaternion<T>>)
|
||||
{
|
||||
if (!Serialize(context, quat.x))
|
||||
return false;
|
||||
@@ -851,7 +851,7 @@ namespace Nz
|
||||
* \param quat Output Quaternion
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Quaternion<T>* quat)
|
||||
bool Unserialize(SerializationContext& context, Quaternion<T>* quat, TypeTag<Quaternion<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &quat->x))
|
||||
return false;
|
||||
|
||||
@@ -74,11 +74,11 @@ namespace Nz
|
||||
Vector3<T> direction, origin;
|
||||
};
|
||||
|
||||
typedef Ray<double> Rayd;
|
||||
typedef Ray<float> Rayf;
|
||||
using Rayd = Ray<double>;
|
||||
using Rayf = Ray<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Ray<T>& ray);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Ray<T>* ray);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Ray<T>& ray, TypeTag<Ray<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Ray<T>* ray, TypeTag<Ray<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Ray<T>& vec);
|
||||
|
||||
@@ -772,7 +772,7 @@ namespace Nz
|
||||
* \param ray Input Ray
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Ray<T>& ray)
|
||||
bool Serialize(SerializationContext& context, const Ray<T>& ray, TypeTag<Ray<T>>)
|
||||
{
|
||||
if (!Serialize(context, ray.origin))
|
||||
return false;
|
||||
@@ -791,7 +791,7 @@ namespace Nz
|
||||
* \param ray Output Ray
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Ray<T>* ray)
|
||||
bool Unserialize(SerializationContext& context, Ray<T>* ray, TypeTag<Ray<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &ray->origin))
|
||||
return false;
|
||||
|
||||
@@ -87,15 +87,15 @@ namespace Nz
|
||||
T x, y, width, height;
|
||||
};
|
||||
|
||||
typedef Rect<double> Rectd;
|
||||
typedef Rect<float> Rectf;
|
||||
typedef Rect<int> Recti;
|
||||
typedef Rect<unsigned int> Rectui;
|
||||
typedef Rect<Int32> Recti32;
|
||||
typedef Rect<UInt32> Rectui32;
|
||||
using Rectd = Rect<double>;
|
||||
using Rectf = Rect<float>;
|
||||
using Recti = Rect<int>;
|
||||
using Rectui = Rect<unsigned int>;
|
||||
using Recti32 = Rect<Int32>;
|
||||
using Rectui32 = Rect<UInt32>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Rect<T>& rect);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Rect<T>* rect);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Rect<T>& rect, TypeTag<Rect<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Rect<T>* rect, TypeTag<Rect<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -808,7 +808,7 @@ namespace Nz
|
||||
* \param rect Input Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Rect<T>& rect)
|
||||
bool Serialize(SerializationContext& context, const Rect<T>& rect, TypeTag<Rect<T>>)
|
||||
{
|
||||
if (!Serialize(context, rect.x))
|
||||
return false;
|
||||
@@ -833,7 +833,7 @@ namespace Nz
|
||||
* \param rect Output Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Rect<T>* rect)
|
||||
bool Unserialize(SerializationContext& context, Rect<T>* rect, TypeTag<Rect<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &rect->x))
|
||||
return false;
|
||||
|
||||
@@ -78,11 +78,11 @@ namespace Nz
|
||||
T x, y, z, radius;
|
||||
};
|
||||
|
||||
typedef Sphere<double> Sphered;
|
||||
typedef Sphere<float> Spheref;
|
||||
using Sphered = Sphere<double>;
|
||||
using Spheref = Sphere<float>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Sphere<T>& sphere);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Sphere<T>* sphere);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Sphere<T>& sphere, TypeTag<Sphere<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Sphere<T>* sphere, TypeTag<Sphere<T>>);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -623,7 +623,7 @@ namespace Nz
|
||||
* \param sphere Input Sphere
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Sphere<T>& sphere)
|
||||
bool Serialize(SerializationContext& context, const Sphere<T>& sphere, TypeTag<Sphere<T>>)
|
||||
{
|
||||
if (!Serialize(context, sphere.x))
|
||||
return false;
|
||||
@@ -648,7 +648,7 @@ namespace Nz
|
||||
* \param sphere Output Sphere
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Sphere<T>* sphere)
|
||||
bool Unserialize(SerializationContext& context, Sphere<T>* sphere, TypeTag<Sphere<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &sphere->x))
|
||||
return false;
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Nz
|
||||
Vector2() = default;
|
||||
Vector2(T X, T Y);
|
||||
explicit Vector2(T scale);
|
||||
explicit Vector2(const T vec[2]);
|
||||
template<typename U> explicit Vector2(const Vector2<U>& vec);
|
||||
Vector2(const Vector2& vec) = default;
|
||||
explicit Vector2(const Vector3<T>& vec);
|
||||
@@ -104,15 +103,15 @@ namespace Nz
|
||||
T x, y;
|
||||
};
|
||||
|
||||
typedef Vector2<double> Vector2d;
|
||||
typedef Vector2<float> Vector2f;
|
||||
typedef Vector2<int> Vector2i;
|
||||
typedef Vector2<unsigned int> Vector2ui;
|
||||
typedef Vector2<Int32> Vector2i32;
|
||||
typedef Vector2<UInt32> Vector2ui32;
|
||||
using Vector2d = Vector2<double>;
|
||||
using Vector2f = Vector2<float>;
|
||||
using Vector2i = Vector2<int>;
|
||||
using Vector2ui = Vector2<unsigned int>;
|
||||
using Vector2i32 = Vector2<Int32>;
|
||||
using Vector2ui32 = Vector2<UInt32>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector2<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector2<T>* vector);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector2<T>& vector, TypeTag<Vector2<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector2<T>* vector, TypeTag<Vector2<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector2<T>& vec);
|
||||
|
||||
@@ -45,18 +45,6 @@ namespace Nz
|
||||
Set(scale);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector2 object from an array of two elements
|
||||
*
|
||||
* \param vec[2] vec[0] is X component and vec[1] is Y component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector2<T>::Vector2(const T vec[2])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector2 object from another type of Vector2
|
||||
*
|
||||
@@ -973,7 +961,7 @@ namespace Nz
|
||||
* \param vector Input Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector2<T>& vector)
|
||||
bool Serialize(SerializationContext& context, const Vector2<T>& vector, TypeTag<Vector2<T>>)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
@@ -992,7 +980,7 @@ namespace Nz
|
||||
* \param vector Output Vector2
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector2<T>* vector)
|
||||
bool Unserialize(SerializationContext& context, Vector2<T>* vector, TypeTag<Vector2<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Nz
|
||||
Vector3(T X, T Y, T Z);
|
||||
Vector3(T X, const Vector2<T>& vec);
|
||||
explicit Vector3(T scale);
|
||||
explicit Vector3(const T vec[3]);
|
||||
Vector3(const Vector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> explicit Vector3(const Vector3<U>& vec);
|
||||
Vector3(const Vector3& vec) = default;
|
||||
@@ -126,15 +125,15 @@ namespace Nz
|
||||
T x, y, z;
|
||||
};
|
||||
|
||||
typedef Vector3<double> Vector3d;
|
||||
typedef Vector3<float> Vector3f;
|
||||
typedef Vector3<int> Vector3i;
|
||||
typedef Vector3<unsigned int> Vector3ui;
|
||||
typedef Vector3<Int32> Vector3i32;
|
||||
typedef Vector3<UInt32> Vector3ui32;
|
||||
using Vector3d = Vector3<double>;
|
||||
using Vector3f = Vector3<float>;
|
||||
using Vector3i = Vector3<int>;
|
||||
using Vector3ui = Vector3<unsigned int>;
|
||||
using Vector3i32 = Vector3<Int32>;
|
||||
using Vector3ui32 = Vector3<UInt32>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector3<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector3<T>* vector);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector3<T>& vector, TypeTag<Vector3<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector3<T>* vector, TypeTag<Vector3<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector3<T>& vec);
|
||||
|
||||
@@ -58,17 +58,6 @@ namespace Nz
|
||||
Set(scale);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector3 object from an array of three elements
|
||||
*
|
||||
* \param vec[3] vec[0] is X component, vec[1] is Y component and vec[2] is Z component
|
||||
*/
|
||||
template<typename T>
|
||||
Vector3<T>::Vector3(const T vec[3])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector3 object from a Vector2<T> and a component
|
||||
*
|
||||
@@ -522,7 +511,9 @@ namespace Nz
|
||||
template<typename T>
|
||||
Vector3<T>& Vector3<T>::Set(const T vec[3])
|
||||
{
|
||||
std::memcpy(&x, vec, 3*sizeof(T));
|
||||
x = vec[0];
|
||||
y = vec[1];
|
||||
z = vec[2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1257,7 +1248,7 @@ namespace Nz
|
||||
* \param vector Input Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector3<T>& vector)
|
||||
bool Serialize(SerializationContext& context, const Vector3<T>& vector, TypeTag<Vector3<T>>)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
@@ -1279,7 +1270,7 @@ namespace Nz
|
||||
* \param vector Output Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector3<T>* vector)
|
||||
bool Unserialize(SerializationContext& context, Vector3<T>* vector, TypeTag<Vector3<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Nz
|
||||
Vector4(T X, const Vector2<T>& vec, T W);
|
||||
Vector4(T X, const Vector3<T>& vec);
|
||||
explicit Vector4(T scale);
|
||||
explicit Vector4(const T vec[4]);
|
||||
Vector4(const Vector2<T>& vec, T Z = 0.0, T W = 1.0);
|
||||
Vector4(const Vector3<T>& vec, T W = 1.0);
|
||||
template<typename U> explicit Vector4(const Vector4<U>& vec);
|
||||
@@ -102,15 +101,15 @@ namespace Nz
|
||||
T x, y, z, w;
|
||||
};
|
||||
|
||||
typedef Vector4<double> Vector4d;
|
||||
typedef Vector4<float> Vector4f;
|
||||
typedef Vector4<int> Vector4i;
|
||||
typedef Vector4<unsigned int> Vector4ui;
|
||||
typedef Vector4<Int32> Vector4i32;
|
||||
typedef Vector4<UInt32> Vector4ui32;
|
||||
using Vector4d = Vector4<double>;
|
||||
using Vector4f = Vector4<float>;
|
||||
using Vector4i = Vector4<int>;
|
||||
using Vector4ui = Vector4<unsigned int>;
|
||||
using Vector4i32 = Vector4<Int32>;
|
||||
using Vector4ui32 = Vector4<UInt32>;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector4<T>& vector);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector4<T>* vector);
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Vector4<T>& vector, TypeTag<Vector4<T>>);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Vector4<T>* vector, TypeTag<Vector4<T>>);
|
||||
}
|
||||
|
||||
template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector4<T>& vec);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Nz
|
||||
{
|
||||
|
||||
/*!
|
||||
* \ingroup math
|
||||
* \ingroup math
|
||||
* \class Nz::Vector4
|
||||
* \brief Math class that represents an element of the three dimensional vector space with the notion of projectivity. When the fourth component is 1, it describes an 'usual' point and when it is 0, it represents the point at infinity
|
||||
*/
|
||||
@@ -90,18 +90,6 @@ namespace Nz
|
||||
Set(scale);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector4 object from an array of four elements
|
||||
*
|
||||
* \param vec[4] vec[0] is X component, vec[1] is Y component, vec[2] is Z component and vec[3] is W component
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
Vector4<T>::Vector4(const T vec[4])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Vector4 object from a Vector2<T> and two components
|
||||
*
|
||||
@@ -1023,7 +1011,7 @@ namespace Nz
|
||||
* \param vector Input Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Vector4<T>& vector)
|
||||
bool Serialize(SerializationContext& context, const Vector4<T>& vector, TypeTag<Vector4<T>>)
|
||||
{
|
||||
if (!Serialize(context, vector.x))
|
||||
return false;
|
||||
@@ -1048,7 +1036,7 @@ namespace Nz
|
||||
* \param vector Output Vector3
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Vector4<T>* vector)
|
||||
bool Unserialize(SerializationContext& context, Vector4<T>* vector, TypeTag<Vector4<T>>)
|
||||
{
|
||||
if (!Unserialize(context, &vector->x))
|
||||
return false;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
ENetCompressor() = default;
|
||||
~ENetCompressor();
|
||||
virtual ~ENetCompressor();
|
||||
|
||||
virtual std::size_t Compress(const ENetPeer* peer, const NetBuffer* buffers, std::size_t bufferCount, std::size_t totalInputSize, UInt8* output, std::size_t maxOutputSize) = 0;
|
||||
virtual std::size_t Decompress(const ENetPeer* peer, const UInt8* input, std::size_t inputSize, UInt8* output, std::size_t maxOutputSize) = 0;
|
||||
|
||||
@@ -156,6 +156,7 @@ namespace Nz
|
||||
UInt64 m_totalReceivedData;
|
||||
bool m_allowsIncomingConnections;
|
||||
bool m_continueSending;
|
||||
bool m_isUsingDualStack;
|
||||
bool m_isSimulationEnabled;
|
||||
bool m_recalculateBandwidthLimits;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Nz
|
||||
{
|
||||
inline ENetHost::ENetHost() :
|
||||
m_packetPool(sizeof(ENetPacket)),
|
||||
m_isUsingDualStack(false),
|
||||
m_isSimulationEnabled(false)
|
||||
{
|
||||
}
|
||||
@@ -20,21 +21,22 @@ namespace Nz
|
||||
|
||||
inline bool ENetHost::Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount)
|
||||
{
|
||||
NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO
|
||||
NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol");
|
||||
|
||||
IpAddress any;
|
||||
switch (protocol)
|
||||
{
|
||||
case NetProtocol_Any:
|
||||
case NetProtocol_Unknown:
|
||||
NazaraInternalError("Invalid protocol Any at this point");
|
||||
NazaraInternalError("Invalid protocol");
|
||||
return false;
|
||||
|
||||
case NetProtocol_IPv4:
|
||||
any = IpAddress::AnyIpV4;
|
||||
break;
|
||||
|
||||
case NetProtocol_Any:
|
||||
m_isUsingDualStack = true;
|
||||
// fallthrough
|
||||
case NetProtocol_IPv6:
|
||||
any = IpAddress::AnyIpV6;
|
||||
break;
|
||||
|
||||
@@ -51,15 +51,15 @@ namespace Nz
|
||||
IpAddress any;
|
||||
switch (m_protocol)
|
||||
{
|
||||
case NetProtocol_Any:
|
||||
case NetProtocol_Unknown:
|
||||
NazaraInternalError("Invalid protocol Any at this point");
|
||||
NazaraInternalError("Invalid protocol");
|
||||
return SocketState_NotConnected;
|
||||
|
||||
case NetProtocol_IPv4:
|
||||
any = IpAddress::AnyIpV4;
|
||||
break;
|
||||
|
||||
case NetProtocol_Any:
|
||||
case NetProtocol_IPv6:
|
||||
any = IpAddress::AnyIpV6;
|
||||
break;
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace Nz
|
||||
virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
|
||||
virtual float ComputeVolume() const;
|
||||
|
||||
virtual void ForEachPolygon(const std::function<void(const float* vertices, std::size_t vertexCount)>& callback) const;
|
||||
|
||||
NewtonCollision* GetHandle(PhysWorld3D* world) const;
|
||||
virtual ColliderType3D GetType() const = 0;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_PHYSWORLD_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
@@ -26,22 +27,22 @@ namespace Nz
|
||||
class NAZARA_PHYSICS3D_API PhysWorld3D
|
||||
{
|
||||
public:
|
||||
using BodyIterator = std::function<bool(const RigidBody3D& body)>;
|
||||
using BodyIterator = std::function<bool(RigidBody3D& body)>;
|
||||
using AABBOverlapCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||
using CollisionCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||
|
||||
PhysWorld3D();
|
||||
PhysWorld3D(const PhysWorld3D&) = delete;
|
||||
PhysWorld3D(PhysWorld3D&&) = delete; ///TODO
|
||||
PhysWorld3D(PhysWorld3D&&) = default;
|
||||
~PhysWorld3D();
|
||||
|
||||
int CreateMaterial(Nz::String name = Nz::String());
|
||||
int CreateMaterial(String name = String());
|
||||
|
||||
void ForEachBodyInAABB(const Nz::Boxf& box, const BodyIterator& iterator);
|
||||
void ForEachBodyInAABB(const Boxf& box, const BodyIterator& iterator);
|
||||
|
||||
Vector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
int GetMaterial(const Nz::String& name);
|
||||
int GetMaterial(const String& name);
|
||||
std::size_t GetMaxStepCount() const;
|
||||
float GetStepSize() const;
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace Nz
|
||||
void Step(float timestep);
|
||||
|
||||
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
|
||||
PhysWorld3D& operator=(PhysWorld3D&&) = delete; ///TODO
|
||||
PhysWorld3D& operator=(PhysWorld3D&&) = default;
|
||||
|
||||
private:
|
||||
struct Callback
|
||||
@@ -75,8 +76,8 @@ namespace Nz
|
||||
std::unordered_map<Nz::UInt64, std::unique_ptr<Callback>> m_callbacks;
|
||||
std::unordered_map<Nz::String, int> m_materialIds;
|
||||
std::size_t m_maxStepCount;
|
||||
MovablePtr<NewtonWorld> m_world;
|
||||
Vector3f m_gravity;
|
||||
NewtonWorld* m_world;
|
||||
float m_stepSize;
|
||||
float m_timestepAccumulator;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Nz
|
||||
bool IsSimulationEnabled() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
void SetAngularDamping(const Nz::Vector3f& angularDamping);
|
||||
void SetAngularDamping(const Vector3f& angularDamping);
|
||||
void SetAngularVelocity(const Vector3f& angularVelocity);
|
||||
void SetGeom(Collider3DRef geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
@@ -67,7 +67,7 @@ namespace Nz
|
||||
void SetLinearVelocity(const Vector3f& velocity);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const Vector3f& center);
|
||||
void SetMaterial(const Nz::String& materialName);
|
||||
void SetMaterial(const String& materialName);
|
||||
void SetMaterial(int materialIndex);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetRotation(const Quaternionf& rotation);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Nz
|
||||
{
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
|
||||
typedef void* WindowHandle;
|
||||
using WindowHandle = void*;
|
||||
#elif defined(NAZARA_PLATFORM_X11)
|
||||
// http://en.wikipedia.org/wiki/Xlib#Data_types
|
||||
using WindowHandle = xcb_window_t;
|
||||
|
||||
@@ -166,17 +166,17 @@ static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
typedef int8_t Int8;
|
||||
typedef uint8_t UInt8;
|
||||
using Int8 = int8_t;
|
||||
using UInt8 = uint8_t;
|
||||
|
||||
typedef int16_t Int16;
|
||||
typedef uint16_t UInt16;
|
||||
using Int16 = int16_t;
|
||||
using UInt16 = uint16_t;
|
||||
|
||||
typedef int32_t Int32;
|
||||
typedef uint32_t UInt32;
|
||||
using Int32 = int32_t;
|
||||
using UInt32 = uint32_t;
|
||||
|
||||
typedef int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
using Int64 = int64_t;
|
||||
using UInt64 = uint64_t;
|
||||
}
|
||||
|
||||
#endif // NAZARA_PREREQUISITES_HPP
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Nz
|
||||
virtual std::size_t GetGlyphCount() const = 0;
|
||||
virtual const Line& GetLine(std::size_t index) const = 0;
|
||||
virtual std::size_t GetLineCount() const = 0;
|
||||
inline std::size_t GetLineGlyphCount(std::size_t index) const;
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
@@ -53,4 +54,6 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/AbstractTextDrawer.inl>
|
||||
|
||||
#endif // NAZARA_ABSTRACTTEXTDRAWER_HPP
|
||||
|
||||
23
include/Nazara/Utility/AbstractTextDrawer.inl
Normal file
23
include/Nazara/Utility/AbstractTextDrawer.inl
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline std::size_t AbstractTextDrawer::GetLineGlyphCount(std::size_t index) const
|
||||
{
|
||||
std::size_t lineCount = GetLineCount();
|
||||
const auto& lineInfo = GetLine(index);
|
||||
if (index == lineCount - 1)
|
||||
return GetGlyphCount() - lineInfo.glyphIndex;
|
||||
|
||||
const auto& nextLineInfo = GetLine(index + 1);
|
||||
|
||||
return nextLineInfo.glyphIndex - lineInfo.glyphIndex;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -28,7 +28,7 @@ namespace Nz
|
||||
Vector3f bindPos;
|
||||
};
|
||||
|
||||
typedef Vector3ui Triangle;
|
||||
using Triangle = Vector3ui;
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace Nz
|
||||
String decalMap;
|
||||
String diffuseMap;
|
||||
String displacementMap;
|
||||
String emissiveMap; //< <!> Custom addition: not present in MTL
|
||||
String normalMap; //< <!> Custom addition: not present in MTL
|
||||
String reflectionMap;
|
||||
String shininessMap;
|
||||
String specularMap;
|
||||
|
||||
Reference in New Issue
Block a user