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

This commit is contained in:
Lynix
2017-05-11 20:52:04 +02:00
64 changed files with 1087 additions and 604 deletions

View File

@@ -51,7 +51,7 @@ namespace Nz
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 AddSpotLight(const SpotLight& light);
virtual void AddSprites(int renderOrder, 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, std::size_t spriteCount, const Texture* overlay = nullptr) = 0;
virtual void Clear(bool fully = false);

View File

@@ -33,6 +33,7 @@ namespace Nz
virtual Vector3f GetForward() const = 0;
virtual const Frustumf& GetFrustum() const = 0;
virtual const Matrix4f& GetProjectionMatrix() const = 0;
virtual Nz::ProjectionType GetProjectionType() const = 0;
virtual const RenderTarget* GetTarget() const = 0;
virtual const Matrix4f& GetViewMatrix() const = 0;
virtual const Recti& GetViewport() const = 0;

View File

@@ -37,7 +37,7 @@ namespace Nz
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, unsigned int spriteCount, const Texture* overlay = nullptr) 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;

View File

@@ -38,7 +38,7 @@ namespace Nz
void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) 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, unsigned int spriteCount, const Texture* overlay = nullptr) override;
void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) override;
private:
inline bool IsMaterialSuitable(const Material* material) const;

View File

@@ -13,6 +13,7 @@
#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>
@@ -41,7 +42,7 @@ namespace Nz
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, unsigned int spriteCount, const Texture* overlay = nullptr) 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;
@@ -73,7 +74,7 @@ namespace Nz
std::vector<BillboardData> billboards;
};
typedef std::map<const Material*, BatchedBillboardEntry, MaterialComparator> BatchedBillboardContainer;
using BatchedBillboardContainer = std::map<const Material*, BatchedBillboardEntry, MaterialComparator>;
struct BatchedBillboardPipelineEntry
{
@@ -81,7 +82,7 @@ namespace Nz
bool enabled = false;
};
typedef std::map<const MaterialPipeline*, BatchedBillboardPipelineEntry, MaterialPipelineComparator> BillboardPipelineBatches;
using BillboardPipelineBatches = std::map<const MaterialPipeline*, BatchedBillboardPipelineEntry, MaterialPipelineComparator>;
/// Sprites
struct SpriteChain_XYZ_Color_UV
@@ -97,7 +98,7 @@ namespace Nz
std::vector<SpriteChain_XYZ_Color_UV> spriteChains;
};
typedef std::map<const Texture*, BatchedSpriteEntry> SpriteOverlayBatches;
using SpriteOverlayBatches = std::map<const Texture*, BatchedSpriteEntry>;
struct BatchedBasicSpriteEntry
{
@@ -107,7 +108,7 @@ namespace Nz
bool enabled = false;
};
typedef std::map<const Material*, BatchedBasicSpriteEntry, MaterialComparator> SpriteMaterialBatches;
using SpriteMaterialBatches = std::map<const Material*, BatchedBasicSpriteEntry, MaterialComparator>;
struct BatchedSpritePipelineEntry
{
@@ -115,7 +116,7 @@ namespace Nz
bool enabled = false;
};
typedef std::map<const MaterialPipeline*, BatchedSpritePipelineEntry, MaterialPipelineComparator> SpritePipelineBatches;
using SpritePipelineBatches = std::map<const MaterialPipeline*, BatchedSpritePipelineEntry, MaterialPipelineComparator>;
/// Meshes
struct MeshDataComparator
@@ -132,7 +133,7 @@ namespace Nz
Spheref squaredBoundingSphere;
};
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
using MeshInstanceContainer = std::map<MeshData, MeshInstanceEntry, MeshDataComparator>;
struct BatchedModelEntry
{
@@ -142,7 +143,7 @@ namespace Nz
bool enabled = false;
};
typedef std::map<const Material*, BatchedModelEntry, MaterialComparator> MeshMaterialBatches;
using MeshMaterialBatches = std::map<const Material*, BatchedModelEntry, MaterialComparator>;
struct BatchedMaterialEntry
{
@@ -150,25 +151,33 @@ namespace Nz
MeshMaterialBatches materialMap;
};
typedef std::map<const MaterialPipeline*, BatchedMaterialEntry, MaterialPipelineComparator> MeshPipelineBatches;
using MeshPipelineBatches = std::map<const MaterialPipeline*, BatchedMaterialEntry, MaterialPipelineComparator>;
struct TransparentModelData
struct UnbatchedModelData
{
Matrix4f transformMatrix;
MeshData meshData;
Spheref squaredBoundingSphere;
Spheref obbSphere;
const Material* material;
};
typedef std::vector<std::size_t> TransparentModelContainer;
struct UnbatchedSpriteData
{
std::size_t spriteCount;
const Material* material;
const Texture* overlay;
const VertexStruct_XYZ_Color_UV* vertices;
};
struct Layer
{
BillboardPipelineBatches billboards;
SpritePipelineBatches basicSprites;
SpritePipelineBatches opaqueSprites;
MeshPipelineBatches opaqueModels;
TransparentModelContainer transparentModels;
std::vector<TransparentModelData> transparentModelData;
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;
};
@@ -179,6 +188,10 @@ namespace Nz
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);

View File

@@ -43,6 +43,7 @@ namespace Nz
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;
const ShaderUniforms* GetShaderUniforms(const Shader* shader) const;
void OnShaderInvalidated(const Shader* shader) const;