Merge branch 'NDK' of https://github.com/DigitalPulseSoftware/NazaraEngine into NDK
Former-commit-id: d6270f2f36e4b83124f8d6525954db304e0bb32a
This commit is contained in:
commit
6fcf7dcf23
|
|
@ -24,7 +24,7 @@ namespace Ndk
|
||||||
|
|
||||||
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
||||||
|
|
||||||
inline void Attach(Nz::InstancedRenderableRef renderable);
|
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||||
|
|
||||||
inline void EnsureTransformMatrixUpdate() const;
|
inline void EnsureTransformMatrixUpdate() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,11 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable)
|
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder)
|
||||||
{
|
{
|
||||||
m_renderables.emplace_back(m_transformMatrix);
|
m_renderables.emplace_back(m_transformMatrix);
|
||||||
Renderable& r = m_renderables.back();
|
Renderable& r = m_renderables.back();
|
||||||
|
r.data.renderOrder = renderOrder;
|
||||||
r.renderable = std::move(renderable);
|
r.renderable = std::move(renderable);
|
||||||
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
|
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
// Merci aussi à Freedom de siteduzero.com
|
// Merci aussi à Freedom de siteduzero.com
|
||||||
|
|
||||||
#include <Nazara/Core/AbstractHash.hpp>
|
#include <Nazara/Core/AbstractHash.hpp>
|
||||||
|
#include <Nazara/Core/ByteArray.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/Stream.hpp>
|
#include <Nazara/Core/Stream.hpp>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
|
||||||
|
|
@ -38,21 +38,21 @@ namespace Nz
|
||||||
|
|
||||||
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
// 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...
|
// mais je n'ai pas d'autre solution tout aussi performante pour le moment...
|
||||||
virtual void AddBillboard(const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0;
|
virtual void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0;
|
||||||
virtual void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||||
virtual void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
|
||||||
virtual void AddBillboards(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 Color> colorPtr = nullptr) = 0;
|
||||||
virtual void AddBillboards(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 Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
|
||||||
virtual void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||||
virtual void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
|
||||||
virtual void AddBillboards(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 Color> colorPtr = nullptr) = 0;
|
||||||
virtual void AddBillboards(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, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
|
||||||
virtual void AddDrawable(const Drawable* drawable) = 0;
|
virtual void AddDrawable(int renderOrder, const Drawable* drawable) = 0;
|
||||||
virtual void AddDirectionalLight(const DirectionalLight& light);
|
virtual void AddDirectionalLight(const DirectionalLight& light);
|
||||||
virtual void AddMesh(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) = 0;
|
||||||
virtual void AddPointLight(const PointLight& light);
|
virtual void AddPointLight(const PointLight& light);
|
||||||
virtual void AddSpotLight(const SpotLight& light);
|
virtual void AddSpotLight(const SpotLight& light);
|
||||||
virtual void AddSprites(const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) = 0;
|
virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) = 0;
|
||||||
|
|
||||||
virtual void Clear(bool fully = false);
|
virtual void Clear(bool fully = false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,18 @@ namespace Nz
|
||||||
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
|
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
|
||||||
~DeferredRenderQueue() = default;
|
~DeferredRenderQueue() = default;
|
||||||
|
|
||||||
void AddBillboard(const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
||||||
void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddDrawable(const Drawable* drawable) override;
|
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||||
void AddMesh(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) override;
|
||||||
void AddSprites(const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override;
|
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override;
|
||||||
|
|
||||||
void Clear(bool fully = false);
|
void Clear(bool fully = false);
|
||||||
|
|
||||||
|
|
@ -75,7 +75,17 @@ namespace Nz
|
||||||
|
|
||||||
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
|
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
|
||||||
|
|
||||||
|
struct Layer
|
||||||
|
{
|
||||||
ModelBatches opaqueModels;
|
ModelBatches opaqueModels;
|
||||||
|
unsigned int clearCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<int, Layer> layers;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Layer& GetLayer(unsigned int i); ///TODO: Inline
|
||||||
|
|
||||||
ForwardRenderQueue* m_forwardQueue;
|
ForwardRenderQueue* m_forwardQueue;
|
||||||
|
|
||||||
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
||||||
|
|
|
||||||
|
|
@ -31,18 +31,18 @@ namespace Nz
|
||||||
ForwardRenderQueue() = default;
|
ForwardRenderQueue() = default;
|
||||||
~ForwardRenderQueue() = default;
|
~ForwardRenderQueue() = default;
|
||||||
|
|
||||||
void AddBillboard(const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
||||||
void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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 Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(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 Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(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, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddDrawable(const Drawable* drawable) override;
|
void AddDrawable(int renderOrder, const Drawable* drawable) override;
|
||||||
void AddMesh(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) override;
|
||||||
void AddSprites(const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override;
|
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay = nullptr) override;
|
||||||
|
|
||||||
void Clear(bool fully = false);
|
void Clear(bool fully = false);
|
||||||
|
|
||||||
|
|
@ -145,14 +145,22 @@ namespace Nz
|
||||||
|
|
||||||
typedef std::vector<unsigned int> TransparentModelContainer;
|
typedef std::vector<unsigned int> TransparentModelContainer;
|
||||||
|
|
||||||
|
struct Layer
|
||||||
|
{
|
||||||
BatchedBillboardContainer billboards;
|
BatchedBillboardContainer billboards;
|
||||||
BasicSpriteBatches basicSprites;
|
BasicSpriteBatches basicSprites;
|
||||||
ModelBatches opaqueModels;
|
ModelBatches opaqueModels;
|
||||||
TransparentModelContainer transparentModels;
|
TransparentModelContainer transparentModels;
|
||||||
std::vector<TransparentModelData> transparentModelData;
|
std::vector<TransparentModelData> transparentModelData;
|
||||||
std::vector<const Drawable*> otherDrawables;
|
std::vector<const Drawable*> otherDrawables;
|
||||||
|
unsigned int clearCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<int, Layer> layers;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Layer& GetLayer(int i); ///TODO: Inline
|
||||||
|
|
||||||
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer);
|
||||||
void OnMaterialInvalidation(const Material* material);
|
void OnMaterialInvalidation(const Material* material);
|
||||||
void OnTextureInvalidation(const Texture* texture);
|
void OnTextureInvalidation(const Texture* texture);
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ namespace Nz
|
||||||
struct ShaderUniforms;
|
struct ShaderUniforms;
|
||||||
|
|
||||||
void ChooseLights(const Spheref& object, bool includeDirectionalLights = true) const;
|
void ChooseLights(const Spheref& object, bool includeDirectionalLights = true) const;
|
||||||
void DrawBasicSprites(const SceneData& sceneData) const;
|
void DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||||
void DrawBillboards(const SceneData& sceneData) const;
|
void DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||||
void DrawOpaqueModels(const SceneData& sceneData) const;
|
void DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||||
void DrawTransparentModels(const SceneData& sceneData) const;
|
void DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const;
|
||||||
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
|
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
|
||||||
void OnShaderInvalidated(const Shader* shader) const;
|
void OnShaderInvalidated(const Shader* shader) const;
|
||||||
void SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset) const;
|
void SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset) const;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace Nz
|
||||||
BoundingVolumef volume;
|
BoundingVolumef volume;
|
||||||
Matrix4f& transformMatrix;
|
Matrix4f& transformMatrix;
|
||||||
UInt32 flags;
|
UInt32 flags;
|
||||||
|
int renderOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Lua/LuaInstance.hpp>
|
#include <Nazara/Lua/LuaInstance.hpp>
|
||||||
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
//#include <type_traits>
|
//#include <type_traits>
|
||||||
|
|
@ -22,12 +23,12 @@ namespace Nz
|
||||||
//static_assert(std::is_same<P, void>::value || std::is_base_of<P, T>::value, "P must be a base of T");
|
//static_assert(std::is_same<P, void>::value || std::is_base_of<P, T>::value, "P must be a base of T");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using ClassFunc = int (*)(LuaInstance& lua, T& instance);
|
using ClassFunc = std::function<int(LuaInstance& lua, T& instance)>;
|
||||||
using ClassIndexFunc = bool (*)(LuaInstance& lua, T& instance);
|
using ClassIndexFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||||
using ConstructorFunc = T* (*)(LuaInstance& lua);
|
using ConstructorFunc = std::function<T*(LuaInstance& lua)>;
|
||||||
using FinalizerFunc = bool (*)(LuaInstance& lua, T& instance);
|
using FinalizerFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||||
using StaticIndexFunc = bool (*)(LuaInstance& lua);
|
using StaticIndexFunc = std::function<bool(LuaInstance& lua)>;
|
||||||
using StaticFunc = int (*)(LuaInstance& lua);
|
using StaticFunc = std::function<int(LuaInstance& lua)>;
|
||||||
|
|
||||||
LuaClass(const String& name);
|
LuaClass(const String& name);
|
||||||
|
|
||||||
|
|
@ -41,9 +42,12 @@ namespace Nz
|
||||||
void SetFinalizer(FinalizerFunc finalizer);
|
void SetFinalizer(FinalizerFunc finalizer);
|
||||||
void SetGetter(ClassIndexFunc getter);
|
void SetGetter(ClassIndexFunc getter);
|
||||||
void SetMethod(const String& name, ClassFunc method);
|
void SetMethod(const String& name, ClassFunc method);
|
||||||
|
template<typename R, typename P, typename... Args> std::enable_if_t<std::is_base_of<P, T>::value> SetMethod(const String& name, R(P::*func)(Args...));
|
||||||
|
template<typename R, typename P, typename... Args> std::enable_if_t<std::is_base_of<P, T>::value> SetMethod(const String& name, R(P::*func)(Args...) const);
|
||||||
void SetSetter(ClassIndexFunc setter);
|
void SetSetter(ClassIndexFunc setter);
|
||||||
void SetStaticGetter(StaticIndexFunc getter);
|
void SetStaticGetter(StaticIndexFunc getter);
|
||||||
void SetStaticMethod(const String& name, StaticFunc func);
|
void SetStaticMethod(const String& name, StaticFunc func);
|
||||||
|
template<typename R, typename... Args> void SetStaticMethod(const String& name, R(*func)(Args...));
|
||||||
void SetStaticSetter(StaticIndexFunc getter);
|
void SetStaticSetter(StaticIndexFunc getter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,32 @@ namespace Nz
|
||||||
m_methods[name] = method;
|
m_methods[name] = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<typename R, typename P, typename... Args>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value> LuaClass<T>::SetMethod(const String& name, R(P::*func)(Args...))
|
||||||
|
{
|
||||||
|
SetMethod(name, [func] (LuaInstance& instance, T& object) -> int
|
||||||
|
{
|
||||||
|
LuaImplMethodProxy<T, Args...> handler(instance, object);
|
||||||
|
handler.ProcessArgs();
|
||||||
|
|
||||||
|
return handler.Invoke(func);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<typename R, typename P, typename... Args>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value> LuaClass<T>::SetMethod(const String& name, R(P::*func)(Args...) const)
|
||||||
|
{
|
||||||
|
SetMethod(name, [func] (LuaInstance& instance, T& object) -> int
|
||||||
|
{
|
||||||
|
LuaImplMethodProxy<T, Args...> handler(instance, object);
|
||||||
|
handler.ProcessArgs();
|
||||||
|
|
||||||
|
return handler.Invoke(func);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void LuaClass<T>::SetSetter(ClassIndexFunc setter)
|
void LuaClass<T>::SetSetter(ClassIndexFunc setter)
|
||||||
{
|
{
|
||||||
|
|
@ -193,6 +219,19 @@ namespace Nz
|
||||||
m_staticMethods[name] = method;
|
m_staticMethods[name] = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<typename R, typename... Args>
|
||||||
|
void LuaClass<T>::SetStaticMethod(const String& name, R(*func)(Args...))
|
||||||
|
{
|
||||||
|
SetStaticMethod(name, [func] (LuaInstance& instance) -> int
|
||||||
|
{
|
||||||
|
LuaImplFunctionProxy<Args...> handler(instance);
|
||||||
|
handler.ProcessArgs();
|
||||||
|
|
||||||
|
return handler.Invoke(func);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void LuaClass<T>::SetStaticSetter(StaticIndexFunc setter)
|
void LuaClass<T>::SetStaticSetter(StaticIndexFunc setter)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ namespace Nz
|
||||||
bool Call(unsigned int argCount);
|
bool Call(unsigned int argCount);
|
||||||
bool Call(unsigned int argCount, unsigned int resultCount);
|
bool Call(unsigned int argCount, unsigned int resultCount);
|
||||||
|
|
||||||
|
template<typename T> T Check(int index);
|
||||||
void CheckAny(int index) const;
|
void CheckAny(int index) const;
|
||||||
bool CheckBoolean(int index) const;
|
bool CheckBoolean(int index) const;
|
||||||
bool CheckBoolean(int index, bool defValue) const;
|
bool CheckBoolean(int index, bool defValue) const;
|
||||||
|
|
@ -110,6 +111,7 @@ namespace Nz
|
||||||
|
|
||||||
void Pop(unsigned int n = 1U);
|
void Pop(unsigned int n = 1U);
|
||||||
|
|
||||||
|
template<typename T> int Push(T arg);
|
||||||
void PushBoolean(bool value);
|
void PushBoolean(bool value);
|
||||||
void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0);
|
void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0);
|
||||||
void PushFunction(LuaFunction func);
|
void PushFunction(LuaFunction func);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,22 @@ namespace Nz
|
||||||
return static_cast<float>(instance.CheckNumber(index));
|
return static_cast<float>(instance.CheckNumber(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<int>)
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_enum<T>::value, T> LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<T>)
|
||||||
{
|
{
|
||||||
return static_cast<int>(instance.CheckInteger(index));
|
return static_cast<T>(LuaImplQueryArg(instance, index, TypeTag<typename std::underlying_type<T>::type>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_integral<T>::value && !std::is_unsigned<T>::value, T> LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<T>)
|
||||||
|
{
|
||||||
|
return static_cast<T>(instance.CheckInteger(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_unsigned<T>::value, T> LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<T>)
|
||||||
|
{
|
||||||
|
return static_cast<T>(LuaImplQueryArg(instance, index, TypeTag<typename std::make_signed<T>::type>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<std::string>)
|
std::string LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<std::string>)
|
||||||
|
|
@ -50,51 +63,62 @@ namespace Nz
|
||||||
return LuaImplQueryArg(instance, index, TypeTag<T>());
|
return LuaImplQueryArg(instance, index, TypeTag<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::enable_if_t<std::is_unsigned<T>::value, T> LuaImplQueryArg(LuaInstance& instance, unsigned int index, TypeTag<T>)
|
|
||||||
{
|
|
||||||
return static_cast<T>(LuaImplQueryArg(instance, index, TypeTag<typename std::make_signed<T>::type>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function returns
|
// Function returns
|
||||||
int LuaImplReplyVal(LuaInstance& instance, bool&& val, TypeTag<bool>)
|
int LuaImplReplyVal(LuaInstance& instance, bool val, TypeTag<bool>)
|
||||||
{
|
{
|
||||||
instance.PushBoolean(val);
|
instance.PushBoolean(val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplReplyVal(LuaInstance& instance, double&& val, TypeTag<double>)
|
int LuaImplReplyVal(LuaInstance& instance, double val, TypeTag<double>)
|
||||||
{
|
{
|
||||||
instance.PushNumber(val);
|
instance.PushNumber(val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplReplyVal(LuaInstance& instance, float&& val, TypeTag<float>)
|
int LuaImplReplyVal(LuaInstance& instance, float val, TypeTag<float>)
|
||||||
{
|
{
|
||||||
instance.PushNumber(val);
|
instance.PushNumber(val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplReplyVal(LuaInstance& instance, int&& val, TypeTag<int>)
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_enum<T>::value, int> LuaImplReplyVal(LuaInstance& instance, T val, TypeTag<T>)
|
||||||
|
{
|
||||||
|
using EnumT = typename std::underlying_type<T>::type;
|
||||||
|
|
||||||
|
return LuaImplReplyVal(instance, static_cast<EnumT>(val), TypeTag<EnumT>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_integral<T>::value && !std::is_unsigned<T>::value, int> LuaImplReplyVal(LuaInstance& instance, T val, TypeTag<T>)
|
||||||
{
|
{
|
||||||
instance.PushInteger(val);
|
instance.PushInteger(val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplReplyVal(LuaInstance& instance, std::string&& val, TypeTag<std::string>)
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_unsigned<T>::value, int> LuaImplReplyVal(LuaInstance& instance, T val, TypeTag<T>)
|
||||||
|
{
|
||||||
|
using SignedT = typename std::make_signed<T>::type;
|
||||||
|
|
||||||
|
return LuaImplReplyVal(instance, static_cast<SignedT>(val), TypeTag<SignedT>());
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaImplReplyVal(LuaInstance& instance, std::string val, TypeTag<std::string>)
|
||||||
{
|
{
|
||||||
instance.PushString(val.c_str(), val.size());
|
instance.PushString(val.c_str(), val.size());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaImplReplyVal(LuaInstance& instance, String&& val, TypeTag<String>)
|
int LuaImplReplyVal(LuaInstance& instance, String val, TypeTag<String>)
|
||||||
{
|
{
|
||||||
instance.PushString(std::move(val));
|
instance.PushString(std::move(val));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
int LuaImplReplyVal(LuaInstance& instance, std::pair<T1, T2>&& val, TypeTag<std::pair<T1, T2>>)
|
int LuaImplReplyVal(LuaInstance& instance, std::pair<T1, T2> val, TypeTag<std::pair<T1, T2>>)
|
||||||
{
|
{
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
|
|
@ -104,14 +128,6 @@ namespace Nz
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::enable_if_t<std::is_unsigned<T>::value, int> LuaImplReplyVal(LuaInstance& instance, T&& val, TypeTag<T>)
|
|
||||||
{
|
|
||||||
using SignedT = typename std::make_signed<T>::type;
|
|
||||||
|
|
||||||
return LuaImplReplyVal(instance, val, TypeTag<SignedT>());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
class LuaImplFunctionProxy
|
class LuaImplFunctionProxy
|
||||||
{
|
{
|
||||||
|
|
@ -152,10 +168,87 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LuaInstance& m_instance;
|
|
||||||
std::tuple<Args...> m_args;
|
std::tuple<Args...> m_args;
|
||||||
|
LuaInstance& m_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
class LuaImplMethodProxy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LuaImplMethodProxy(LuaInstance& instance, T& object) :
|
||||||
|
m_instance(instance),
|
||||||
|
m_object(object)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<unsigned int N>
|
||||||
|
void ProcessArgs()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<unsigned int N, typename ArgType>
|
||||||
|
void ProcessArgs()
|
||||||
|
{
|
||||||
|
std::get<N>(m_args) = std::move(LuaImplQueryArg(m_instance, N + 1, TypeTag<ArgType>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<unsigned int N, typename ArgType1, typename ArgType2, typename... Rest>
|
||||||
|
void ProcessArgs()
|
||||||
|
{
|
||||||
|
ProcessArgs<N, ArgType1>();
|
||||||
|
ProcessArgs<N + 1, ArgType2, Rest...>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessArgs()
|
||||||
|
{
|
||||||
|
ProcessArgs<0, Args...>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename P>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(void(P::*func)(Args...))
|
||||||
|
{
|
||||||
|
Apply(m_object, func, m_args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename P, typename Ret>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(Ret(P::*func)(Args...))
|
||||||
|
{
|
||||||
|
return LuaImplReplyVal(m_instance, std::move(Apply(m_object, func, m_args)), TypeTag<decltype(Apply(m_object, func, m_args))>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename P>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(void(P::*func)(Args...) const)
|
||||||
|
{
|
||||||
|
Apply(m_object, func, m_args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename P, typename Ret>
|
||||||
|
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(Ret(P::*func)(Args...) const)
|
||||||
|
{
|
||||||
|
return LuaImplReplyVal(m_instance, std::move(Apply(m_object, func, m_args)), TypeTag<decltype(Apply(m_object, func, m_args))>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::tuple<Args...> m_args;
|
||||||
|
LuaInstance& m_instance;
|
||||||
|
T& m_object;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T LuaInstance::Check(int index)
|
||||||
|
{
|
||||||
|
return LuaImplQueryArg(*this, index, TypeTag<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int LuaInstance::Push(T arg)
|
||||||
|
{
|
||||||
|
return LuaImplReplyVal(*this, std::move(arg), TypeTag<T>());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename R, typename... Args>
|
template<typename R, typename... Args>
|
||||||
void LuaInstance::PushFunction(R (*func)(Args...))
|
void LuaInstance::PushFunction(R (*func)(Args...))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
float Vector3<T>::GetLengthf() const
|
float Vector3<T>::GetLengthf() const
|
||||||
{
|
{
|
||||||
return std::sqrt<float>(static_cast<float>(GetSquaredLength()));
|
return std::sqrt(static_cast<float>(GetSquaredLength()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ namespace Nz
|
||||||
bool bestFlipped;
|
bool bestFlipped;
|
||||||
std::size_t bestFreeRect;
|
std::size_t bestFreeRect;
|
||||||
std::size_t bestRect;
|
std::size_t bestRect;
|
||||||
std::size_t bestScore = std::numeric_limits<std::size_t>::max();
|
int bestScore = std::numeric_limits<int>::max();
|
||||||
|
|
||||||
for (std::size_t i = 0; i < m_freeRectangles.size(); ++i)
|
for (std::size_t i = 0; i < m_freeRectangles.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -170,7 +170,7 @@ namespace Nz
|
||||||
bestFreeRect = i;
|
bestFreeRect = i;
|
||||||
bestRect = j;
|
bestRect = j;
|
||||||
bestFlipped = false;
|
bestFlipped = false;
|
||||||
bestScore = std::numeric_limits<std::size_t>::min();
|
bestScore = std::numeric_limits<int>::min();
|
||||||
i = m_freeRectangles.size(); // Force a jump out of the outer loop as well - we got an instant fit.
|
i = m_freeRectangles.size(); // Force a jump out of the outer loop as well - we got an instant fit.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +180,7 @@ namespace Nz
|
||||||
bestFreeRect = i;
|
bestFreeRect = i;
|
||||||
bestRect = j;
|
bestRect = j;
|
||||||
bestFlipped = true;
|
bestFlipped = true;
|
||||||
bestScore = std::numeric_limits<std::size_t>::min();
|
bestScore = std::numeric_limits<int>::min();
|
||||||
i = m_freeRectangles.size(); // Force a jump out of the outer loop as well - we got an instant fit.
|
i = m_freeRectangles.size(); // Force a jump out of the outer loop as well - we got an instant fit.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't manage to find any rectangle to pack, abort.
|
// If we didn't manage to find any rectangle to pack, abort.
|
||||||
if (bestScore == std::numeric_limits<std::size_t>::max())
|
if (bestScore == std::numeric_limits<int>::max())
|
||||||
{
|
{
|
||||||
// Si nous le pouvons, on marque les rectangles n'ayant pas pu être insérés
|
// Si nous le pouvons, on marque les rectangles n'ayant pas pu être insérés
|
||||||
if (inserted)
|
if (inserted)
|
||||||
|
|
|
||||||
|
|
@ -54,31 +54,21 @@ namespace Nz
|
||||||
int flags;
|
int flags;
|
||||||
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||||
|
|
||||||
if (mode & OpenMode_ReadOnly)
|
if (mode & OpenMode_ReadWrite)
|
||||||
flags = O_RDONLY;
|
|
||||||
else if (mode & OpenMode_ReadWrite)
|
|
||||||
{
|
|
||||||
flags = O_CREAT | O_RDWR;
|
flags = O_CREAT | O_RDWR;
|
||||||
|
else if (mode & OpenMode_ReadOnly)
|
||||||
if (mode & OpenMode_Append)
|
flags = O_RDONLY;
|
||||||
flags |= O_APPEND;
|
|
||||||
|
|
||||||
if (mode & OpenMode_Truncate)
|
|
||||||
flags |= O_TRUNC;
|
|
||||||
}
|
|
||||||
else if (mode & OpenMode_WriteOnly)
|
else if (mode & OpenMode_WriteOnly)
|
||||||
{
|
|
||||||
flags = O_CREAT | O_WRONLY;
|
flags = O_CREAT | O_WRONLY;
|
||||||
|
|
||||||
if (mode & OpenMode_Append)
|
|
||||||
flags |= O_APPEND;
|
|
||||||
|
|
||||||
if (mode & OpenMode_Truncate)
|
|
||||||
flags |= O_TRUNC;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (mode & OpenMode_Append)
|
||||||
|
flags |= O_APPEND;
|
||||||
|
|
||||||
|
if (mode & OpenMode_Truncate)
|
||||||
|
flags |= O_TRUNC;
|
||||||
|
|
||||||
///TODO: lock
|
///TODO: lock
|
||||||
// if ((mode & OpenMode_Lock) == 0)
|
// if ((mode & OpenMode_Lock) == 0)
|
||||||
// shareMode |= FILE_SHARE_WRITE;
|
// shareMode |= FILE_SHARE_WRITE;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Nazara/Core/ByteArray.hpp>
|
#include <Nazara/Core/ByteArray.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
#include <cstring>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Nz
|
||||||
if (!m_material)
|
if (!m_material)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
renderQueue->AddBillboard(m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color);
|
renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Billboard::MakeBoundingVolume() const
|
void Billboard::MakeBoundingVolume() const
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,11 @@ namespace Nz
|
||||||
const Shader* lastShader = nullptr;
|
const Shader* lastShader = nullptr;
|
||||||
const ShaderUniforms* shaderUniforms = nullptr;
|
const ShaderUniforms* shaderUniforms = nullptr;
|
||||||
|
|
||||||
for (auto& matIt : m_renderQueue->opaqueModels)
|
for (auto& pair : m_renderQueue->layers)
|
||||||
|
{
|
||||||
|
DeferredRenderQueue::Layer& layer = pair.second;
|
||||||
|
|
||||||
|
for (auto& matIt : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
auto& matEntry = matIt.second;
|
auto& matEntry = matIt.second;
|
||||||
|
|
||||||
|
|
@ -168,6 +172,7 @@ namespace Nz
|
||||||
matEntry.instancingEnabled = false;
|
matEntry.instancingEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false; // On ne fait que remplir le G-Buffer, les work texture ne sont pas affectées
|
return false; // On ne fait que remplir le G-Buffer, les work texture ne sont pas affectées
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,63 +17,66 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboard(const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color)
|
void DeferredRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboard(material, position, size, sinCos, color);
|
m_forwardQueue->AddBillboard(renderOrder, material, position, size, sinCos, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr)
|
void DeferredRenderQueue::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)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddBillboards(material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddDrawable(const Drawable* drawable)
|
void DeferredRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddDrawable(drawable);
|
m_forwardQueue->AddDrawable(renderOrder, drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddMesh(const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix)
|
void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix)
|
||||||
{
|
{
|
||||||
if (material->IsEnabled(RendererParameter_Blend))
|
if (material->IsEnabled(RendererParameter_Blend))
|
||||||
// Un matériau transparent ? J'aime pas, va voir dans la forward queue si j'y suis
|
// Un matériau transparent ? J'aime pas, va voir dans la forward queue si j'y suis
|
||||||
m_forwardQueue->AddMesh(material, meshData, meshAABB, transformMatrix);
|
m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Layer& currentLayer = GetLayer(renderOrder);
|
||||||
|
auto& opaqueModels = currentLayer.opaqueModels;
|
||||||
|
|
||||||
auto it = opaqueModels.find(material);
|
auto it = opaqueModels.find(material);
|
||||||
if (it == opaqueModels.end())
|
if (it == opaqueModels.end())
|
||||||
{
|
{
|
||||||
|
|
@ -110,9 +113,9 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::AddSprites(const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay)
|
void DeferredRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay)
|
||||||
{
|
{
|
||||||
m_forwardQueue->AddSprites(material, vertices, spriteCount, overlay);
|
m_forwardQueue->AddSprites(renderOrder, material, vertices, spriteCount, overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::Clear(bool fully)
|
void DeferredRenderQueue::Clear(bool fully)
|
||||||
|
|
@ -120,14 +123,39 @@ namespace Nz
|
||||||
AbstractRenderQueue::Clear(fully);
|
AbstractRenderQueue::Clear(fully);
|
||||||
|
|
||||||
if (fully)
|
if (fully)
|
||||||
opaqueModels.clear();
|
layers.clear();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto it = layers.begin(); it != layers.end(); ++it)
|
||||||
|
{
|
||||||
|
Layer& layer = it->second;
|
||||||
|
if (layer.clearCount++ >= 100)
|
||||||
|
it = layers.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_forwardQueue->Clear(fully);
|
m_forwardQueue->Clear(fully);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeferredRenderQueue::Layer& DeferredRenderQueue::GetLayer(unsigned int i)
|
||||||
|
{
|
||||||
|
auto it = layers.find(i);
|
||||||
|
if (it == layers.end())
|
||||||
|
it = layers.insert(std::make_pair(i, Layer())).first;
|
||||||
|
|
||||||
|
Layer& layer = it->second;
|
||||||
|
layer.clearCount = 0;
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer)
|
void DeferredRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer)
|
||||||
{
|
{
|
||||||
for (auto& modelPair : opaqueModels)
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
|
||||||
|
for (auto& modelPair : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
||||||
for (auto it = meshes.begin(); it != meshes.end();)
|
for (auto it = meshes.begin(); it != meshes.end();)
|
||||||
|
|
@ -140,15 +168,25 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::OnMaterialInvalidation(const Material* material)
|
void DeferredRenderQueue::OnMaterialInvalidation(const Material* material)
|
||||||
{
|
{
|
||||||
opaqueModels.erase(material);
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
|
||||||
|
layer.opaqueModels.erase(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer)
|
void DeferredRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer)
|
||||||
{
|
{
|
||||||
for (auto& modelPair : opaqueModels)
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
|
||||||
|
for (auto& modelPair : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
||||||
for (auto it = meshes.begin(); it != meshes.end();)
|
for (auto it = meshes.begin(); it != meshes.end();)
|
||||||
|
|
@ -161,6 +199,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const
|
bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
void ForwardRenderQueue::AddBillboard(const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color)
|
void ForwardRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +32,7 @@ namespace Nz
|
||||||
billboardVector.push_back(BillboardData{color, position, size, sinCos});
|
billboardVector.push_back(BillboardData{color, position, size, sinCos});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -43,6 +45,8 @@ namespace Nz
|
||||||
if (!colorPtr)
|
if (!colorPtr)
|
||||||
colorPtr.Reset(&Color::White, 0); // Pareil
|
colorPtr.Reset(&Color::White, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -69,7 +73,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -84,6 +88,8 @@ namespace Nz
|
||||||
if (!alphaPtr)
|
if (!alphaPtr)
|
||||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +116,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -123,6 +129,8 @@ namespace Nz
|
||||||
if (!colorPtr)
|
if (!colorPtr)
|
||||||
colorPtr.Reset(&Color::White, 0); // Pareil
|
colorPtr.Reset(&Color::White, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -153,7 +161,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -168,6 +176,8 @@ namespace Nz
|
||||||
if (!alphaPtr)
|
if (!alphaPtr)
|
||||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -198,7 +208,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const Color> colorPtr)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -211,6 +221,8 @@ namespace Nz
|
||||||
if (!colorPtr)
|
if (!colorPtr)
|
||||||
colorPtr.Reset(&Color::White, 0); // Pareil
|
colorPtr.Reset(&Color::White, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -237,7 +249,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -252,6 +264,8 @@ namespace Nz
|
||||||
if (!alphaPtr)
|
if (!alphaPtr)
|
||||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -278,7 +292,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -291,6 +305,8 @@ namespace Nz
|
||||||
if (!colorPtr)
|
if (!colorPtr)
|
||||||
colorPtr.Reset(&Color::White, 0); // Pareil
|
colorPtr.Reset(&Color::White, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -321,7 +337,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddBillboards(const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr)
|
void ForwardRenderQueue::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)
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
|
|
@ -336,6 +352,8 @@ namespace Nz
|
||||||
if (!alphaPtr)
|
if (!alphaPtr)
|
||||||
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
alphaPtr.Reset(&defaultAlpha, 0); // Pareil
|
||||||
|
|
||||||
|
auto& billboards = GetLayer(renderOrder).billboards;
|
||||||
|
|
||||||
auto it = billboards.find(material);
|
auto it = billboards.find(material);
|
||||||
if (it == billboards.end())
|
if (it == billboards.end())
|
||||||
{
|
{
|
||||||
|
|
@ -366,7 +384,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddDrawable(const Drawable* drawable)
|
void ForwardRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable)
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
if (!drawable)
|
if (!drawable)
|
||||||
|
|
@ -376,13 +394,19 @@ namespace Nz
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
auto& otherDrawables = GetLayer(renderOrder).otherDrawables;
|
||||||
|
|
||||||
otherDrawables.push_back(drawable);
|
otherDrawables.push_back(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddMesh(const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix)
|
void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix)
|
||||||
{
|
{
|
||||||
if (material->IsEnabled(RendererParameter_Blend))
|
if (material->IsEnabled(RendererParameter_Blend))
|
||||||
{
|
{
|
||||||
|
Layer& currentLayer = GetLayer(renderOrder);
|
||||||
|
auto& transparentModels = currentLayer.transparentModels;
|
||||||
|
auto& transparentModelData = currentLayer.transparentModelData;
|
||||||
|
|
||||||
// Le matériau est transparent, nous devons rendre ce mesh d'une autre façon (après le rendu des objets opaques et en les triant)
|
// Le matériau est transparent, nous devons rendre ce mesh d'une autre façon (après le rendu des objets opaques et en les triant)
|
||||||
unsigned int index = transparentModelData.size();
|
unsigned int index = transparentModelData.size();
|
||||||
transparentModelData.resize(index+1);
|
transparentModelData.resize(index+1);
|
||||||
|
|
@ -397,6 +421,9 @@ namespace Nz
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Layer& currentLayer = GetLayer(renderOrder);
|
||||||
|
auto& opaqueModels = currentLayer.opaqueModels;
|
||||||
|
|
||||||
auto it = opaqueModels.find(material);
|
auto it = opaqueModels.find(material);
|
||||||
if (it == opaqueModels.end())
|
if (it == opaqueModels.end())
|
||||||
{
|
{
|
||||||
|
|
@ -434,8 +461,11 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::AddSprites(const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay)
|
void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay)
|
||||||
{
|
{
|
||||||
|
Layer& currentLayer = GetLayer(renderOrder);
|
||||||
|
auto& basicSprites = currentLayer.basicSprites;
|
||||||
|
|
||||||
auto matIt = basicSprites.find(material);
|
auto matIt = basicSprites.find(material);
|
||||||
if (matIt == basicSprites.end())
|
if (matIt == basicSprites.end())
|
||||||
{
|
{
|
||||||
|
|
@ -468,15 +498,22 @@ namespace Nz
|
||||||
{
|
{
|
||||||
AbstractRenderQueue::Clear(fully);
|
AbstractRenderQueue::Clear(fully);
|
||||||
|
|
||||||
otherDrawables.clear();
|
|
||||||
transparentModels.clear();
|
|
||||||
transparentModelData.clear();
|
|
||||||
|
|
||||||
if (fully)
|
if (fully)
|
||||||
|
layers.clear();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
basicSprites.clear();
|
for (auto it = layers.begin(); it != layers.end(); ++it)
|
||||||
billboards.clear();
|
{
|
||||||
opaqueModels.clear();
|
Layer& layer = it->second;
|
||||||
|
if (layer.clearCount++ >= 100)
|
||||||
|
it = layers.erase(it);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
layer.otherDrawables.clear();
|
||||||
|
layer.transparentModels.clear();
|
||||||
|
layer.transparentModelData.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -486,10 +523,14 @@ namespace Nz
|
||||||
Vector3f viewerPos = viewer->GetEyePosition();
|
Vector3f viewerPos = viewer->GetEyePosition();
|
||||||
Vector3f viewerNormal = viewer->GetForward();
|
Vector3f viewerNormal = viewer->GetForward();
|
||||||
|
|
||||||
std::sort(transparentModels.begin(), transparentModels.end(), [this, &nearPlane, &viewerNormal](unsigned int index1, unsigned int index2)
|
for (auto& pair : layers)
|
||||||
{
|
{
|
||||||
const Spheref& sphere1 = transparentModelData[index1].squaredBoundingSphere;
|
Layer& layer = pair.second;
|
||||||
const Spheref& sphere2 = transparentModelData[index2].squaredBoundingSphere;
|
|
||||||
|
std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2)
|
||||||
|
{
|
||||||
|
const Spheref& sphere1 = layer.transparentModelData[index1].squaredBoundingSphere;
|
||||||
|
const Spheref& sphere2 = layer.transparentModelData[index2].squaredBoundingSphere;
|
||||||
|
|
||||||
Vector3f position1 = sphere1.GetNegativeVertex(viewerNormal);
|
Vector3f position1 = sphere1.GetNegativeVertex(viewerNormal);
|
||||||
Vector3f position2 = sphere2.GetNegativeVertex(viewerNormal);
|
Vector3f position2 = sphere2.GetNegativeVertex(viewerNormal);
|
||||||
|
|
@ -497,7 +538,7 @@ namespace Nz
|
||||||
return nearPlane.Distance(position1) > nearPlane.Distance(position2);
|
return nearPlane.Distance(position1) > nearPlane.Distance(position2);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto& pair : billboards)
|
for (auto& pair : layer.billboards)
|
||||||
{
|
{
|
||||||
const Material* mat = pair.first;
|
const Material* mat = pair.first;
|
||||||
|
|
||||||
|
|
@ -513,10 +554,27 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ForwardRenderQueue::Layer& ForwardRenderQueue::GetLayer(int i)
|
||||||
|
{
|
||||||
|
auto it = layers.find(i);
|
||||||
|
if (it == layers.end())
|
||||||
|
it = layers.insert(std::make_pair(i, Layer())).first;
|
||||||
|
|
||||||
|
Layer& layer = it->second;
|
||||||
|
layer.clearCount = 0;
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer)
|
void ForwardRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer)
|
||||||
{
|
{
|
||||||
for (auto& modelPair : opaqueModels)
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
|
||||||
|
for (auto& modelPair : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
||||||
for (auto it = meshes.begin(); it != meshes.end();)
|
for (auto it = meshes.begin(); it != meshes.end();)
|
||||||
|
|
@ -529,26 +587,39 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::OnMaterialInvalidation(const Material* material)
|
void ForwardRenderQueue::OnMaterialInvalidation(const Material* material)
|
||||||
{
|
{
|
||||||
basicSprites.erase(material);
|
for (auto& pair : layers)
|
||||||
billboards.erase(material);
|
{
|
||||||
opaqueModels.erase(material);
|
Layer& layer = pair.second;
|
||||||
|
|
||||||
|
layer.basicSprites.erase(material);
|
||||||
|
layer.billboards.erase(material);
|
||||||
|
layer.opaqueModels.erase(material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::OnTextureInvalidation(const Texture* texture)
|
void ForwardRenderQueue::OnTextureInvalidation(const Texture* texture)
|
||||||
{
|
{
|
||||||
for (auto matIt = basicSprites.begin(); matIt != basicSprites.end(); ++matIt)
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
for (auto matIt = layer.basicSprites.begin(); matIt != layer.basicSprites.end(); ++matIt)
|
||||||
{
|
{
|
||||||
auto& overlayMap = matIt->second.overlayMap;
|
auto& overlayMap = matIt->second.overlayMap;
|
||||||
overlayMap.erase(texture);
|
overlayMap.erase(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ForwardRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer)
|
void ForwardRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer)
|
||||||
{
|
{
|
||||||
for (auto& modelPair : opaqueModels)
|
for (auto& pair : layers)
|
||||||
|
{
|
||||||
|
Layer& layer = pair.second;
|
||||||
|
for (auto& modelPair : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
MeshInstanceContainer& meshes = modelPair.second.meshMap;
|
||||||
for (auto it = meshes.begin(); it != meshes.end();)
|
for (auto it = meshes.begin(); it != meshes.end();)
|
||||||
|
|
@ -561,6 +632,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const
|
bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -62,21 +62,25 @@ namespace Nz
|
||||||
if (sceneData.background)
|
if (sceneData.background)
|
||||||
sceneData.background->Draw(sceneData.viewer);
|
sceneData.background->Draw(sceneData.viewer);
|
||||||
|
|
||||||
if (!m_renderQueue.opaqueModels.empty())
|
for (auto& pair : m_renderQueue.layers)
|
||||||
DrawOpaqueModels(sceneData);
|
{
|
||||||
|
ForwardRenderQueue::Layer& layer = pair.second;
|
||||||
|
|
||||||
if (!m_renderQueue.transparentModels.empty())
|
if (!layer.opaqueModels.empty())
|
||||||
DrawTransparentModels(sceneData);
|
DrawOpaqueModels(sceneData, layer);
|
||||||
|
|
||||||
if (!m_renderQueue.basicSprites.empty())
|
if (!layer.transparentModels.empty())
|
||||||
DrawBasicSprites(sceneData);
|
DrawTransparentModels(sceneData, layer);
|
||||||
|
|
||||||
if (!m_renderQueue.billboards.empty())
|
if (!layer.basicSprites.empty())
|
||||||
DrawBillboards(sceneData);
|
DrawBasicSprites(sceneData, layer);
|
||||||
|
|
||||||
// Les autres drawables (Exemple: Terrain)
|
if (!layer.billboards.empty())
|
||||||
for (const Drawable* drawable : m_renderQueue.otherDrawables)
|
DrawBillboards(sceneData, layer);
|
||||||
|
|
||||||
|
for (const Drawable* drawable : layer.otherDrawables)
|
||||||
drawable->Draw();
|
drawable->Draw();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +207,7 @@ namespace Nz
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderTechnique::DrawBasicSprites(const SceneData& sceneData) const
|
void ForwardRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
|
||||||
{
|
{
|
||||||
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
||||||
|
|
||||||
|
|
@ -214,7 +218,7 @@ namespace Nz
|
||||||
Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity());
|
Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity());
|
||||||
Renderer::SetVertexBuffer(&m_spriteBuffer);
|
Renderer::SetVertexBuffer(&m_spriteBuffer);
|
||||||
|
|
||||||
for (auto& matIt : m_renderQueue.basicSprites)
|
for (auto& matIt : layer.basicSprites)
|
||||||
{
|
{
|
||||||
const Material* material = matIt.first;
|
const Material* material = matIt.first;
|
||||||
auto& matEntry = matIt.second;
|
auto& matEntry = matIt.second;
|
||||||
|
|
@ -309,7 +313,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderTechnique::DrawBillboards(const SceneData& sceneData) const
|
void ForwardRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
|
||||||
{
|
{
|
||||||
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
||||||
|
|
||||||
|
|
@ -323,7 +327,7 @@ namespace Nz
|
||||||
|
|
||||||
Renderer::SetVertexBuffer(&s_quadVertexBuffer);
|
Renderer::SetVertexBuffer(&s_quadVertexBuffer);
|
||||||
|
|
||||||
for (auto& matIt : m_renderQueue.billboards)
|
for (auto& matIt : layer.billboards)
|
||||||
{
|
{
|
||||||
const Material* material = matIt.first;
|
const Material* material = matIt.first;
|
||||||
auto& entry = matIt.second;
|
auto& entry = matIt.second;
|
||||||
|
|
@ -372,7 +376,7 @@ namespace Nz
|
||||||
Renderer::SetIndexBuffer(&s_quadIndexBuffer);
|
Renderer::SetIndexBuffer(&s_quadIndexBuffer);
|
||||||
Renderer::SetVertexBuffer(&m_billboardPointBuffer);
|
Renderer::SetVertexBuffer(&m_billboardPointBuffer);
|
||||||
|
|
||||||
for (auto& matIt : m_renderQueue.billboards)
|
for (auto& matIt : layer.billboards)
|
||||||
{
|
{
|
||||||
const Material* material = matIt.first;
|
const Material* material = matIt.first;
|
||||||
auto& entry = matIt.second;
|
auto& entry = matIt.second;
|
||||||
|
|
@ -454,14 +458,14 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderTechnique::DrawOpaqueModels(const SceneData& sceneData) const
|
void ForwardRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
|
||||||
{
|
{
|
||||||
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
||||||
|
|
||||||
const Shader* lastShader = nullptr;
|
const Shader* lastShader = nullptr;
|
||||||
const ShaderUniforms* shaderUniforms = nullptr;
|
const ShaderUniforms* shaderUniforms = nullptr;
|
||||||
|
|
||||||
for (auto& matIt : m_renderQueue.opaqueModels)
|
for (auto& matIt : layer.opaqueModels)
|
||||||
{
|
{
|
||||||
auto& matEntry = matIt.second;
|
auto& matEntry = matIt.second;
|
||||||
|
|
||||||
|
|
@ -657,7 +661,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForwardRenderTechnique::DrawTransparentModels(const SceneData& sceneData) const
|
void ForwardRenderTechnique::DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const
|
||||||
{
|
{
|
||||||
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
NazaraAssert(sceneData.viewer, "Invalid viewer");
|
||||||
|
|
||||||
|
|
@ -665,9 +669,9 @@ namespace Nz
|
||||||
const ShaderUniforms* shaderUniforms = nullptr;
|
const ShaderUniforms* shaderUniforms = nullptr;
|
||||||
unsigned int lightCount = 0;
|
unsigned int lightCount = 0;
|
||||||
|
|
||||||
for (unsigned int index : m_renderQueue.transparentModels)
|
for (unsigned int index : layer.transparentModels)
|
||||||
{
|
{
|
||||||
const ForwardRenderQueue::TransparentModelData& modelData = m_renderQueue.transparentModelData[index];
|
const ForwardRenderQueue::TransparentModelData& modelData = layer.transparentModelData[index];
|
||||||
|
|
||||||
// Matériau
|
// Matériau
|
||||||
const Material* material = modelData.material;
|
const Material* material = modelData.material;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Nz
|
||||||
meshData.primitiveMode = mesh->GetPrimitiveMode();
|
meshData.primitiveMode = mesh->GetPrimitiveMode();
|
||||||
meshData.vertexBuffer = mesh->GetVertexBuffer();
|
meshData.vertexBuffer = mesh->GetVertexBuffer();
|
||||||
|
|
||||||
renderQueue->AddMesh(material, meshData, mesh->GetAABB(), instanceData.transformMatrix);
|
renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), instanceData.transformMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz
|
||||||
meshData.primitiveMode = mesh->GetPrimitiveMode();
|
meshData.primitiveMode = mesh->GetPrimitiveMode();
|
||||||
meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton);
|
meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton);
|
||||||
|
|
||||||
renderQueue->AddMesh(material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix);
|
renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Nz
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<const VertexStruct_XYZ_Color_UV*>(instanceData.data.data());
|
const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<const VertexStruct_XYZ_Color_UV*>(instanceData.data.data());
|
||||||
renderQueue->AddSprites(m_material, vertices, 1);
|
renderQueue->AddSprites(instanceData.renderOrder, m_material, vertices, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::MakeBoundingVolume() const
|
void Sprite::MakeBoundingVolume() const
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
if (indices.count > 0)
|
if (indices.count > 0)
|
||||||
{
|
{
|
||||||
const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<const VertexStruct_XYZ_Color_UV*>(instanceData.data.data());
|
const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<const VertexStruct_XYZ_Color_UV*>(instanceData.data.data());
|
||||||
renderQueue->AddSprites(m_material, &vertices[indices.first*4], indices.count, overlay);
|
renderQueue->AddSprites(instanceData.renderOrder, m_material, &vertices[indices.first*4], indices.count, overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue