Graphics/InstancedRenderable: Add support for render layer
This commit is contained in:
parent
a4c0cc8c34
commit
8b899253b1
|
|
@ -33,6 +33,9 @@ namespace Nz
|
||||||
inline const Boxf& GetAABB() const;
|
inline const Boxf& GetAABB() const;
|
||||||
virtual const std::shared_ptr<Material>& GetMaterial(std::size_t i) const = 0;
|
virtual const std::shared_ptr<Material>& GetMaterial(std::size_t i) const = 0;
|
||||||
virtual std::size_t GetMaterialCount() const = 0;
|
virtual std::size_t GetMaterialCount() const = 0;
|
||||||
|
inline int GetRenderLayer() const;
|
||||||
|
|
||||||
|
inline void UpdateRenderLayer(int renderLayer);
|
||||||
|
|
||||||
InstancedRenderable& operator=(const InstancedRenderable&) = delete;
|
InstancedRenderable& operator=(const InstancedRenderable&) = delete;
|
||||||
InstancedRenderable& operator=(InstancedRenderable&&) noexcept = default;
|
InstancedRenderable& operator=(InstancedRenderable&&) noexcept = default;
|
||||||
|
|
@ -46,6 +49,7 @@ namespace Nz
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Boxf m_aabb;
|
Boxf m_aabb;
|
||||||
|
int m_renderLayer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
inline InstancedRenderable::InstancedRenderable() :
|
inline InstancedRenderable::InstancedRenderable() :
|
||||||
m_aabb(Boxf::Zero())
|
m_aabb(Boxf::Zero()),
|
||||||
|
m_renderLayer(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17,6 +18,17 @@ namespace Nz
|
||||||
return m_aabb;
|
return m_aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int InstancedRenderable::GetRenderLayer() const
|
||||||
|
{
|
||||||
|
return m_renderLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void InstancedRenderable::UpdateRenderLayer(int renderLayer)
|
||||||
|
{
|
||||||
|
m_renderLayer = renderLayer;
|
||||||
|
OnElementInvalidated(this);
|
||||||
|
}
|
||||||
|
|
||||||
inline void InstancedRenderable::UpdateAABB(Boxf aabb)
|
inline void InstancedRenderable::UpdateAABB(Boxf aabb)
|
||||||
{
|
{
|
||||||
OnAABBUpdate(this, aabb);
|
OnAABBUpdate(this, aabb);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Nz
|
||||||
const auto& vertexBuffer = m_graphicalMesh->GetVertexBuffer(i);
|
const auto& vertexBuffer = m_graphicalMesh->GetVertexBuffer(i);
|
||||||
const auto& renderPipeline = materialPass->GetPipeline()->GetRenderPipeline(submeshData.vertexBufferData);
|
const auto& renderPipeline = materialPass->GetPipeline()->GetRenderPipeline(submeshData.vertexBufferData);
|
||||||
|
|
||||||
elements.emplace_back(std::make_unique<RenderSubmesh>(0, materialPass, renderPipeline, worldInstance, m_graphicalMesh->GetIndexCount(i), indexBuffer, vertexBuffer));
|
elements.emplace_back(std::make_unique<RenderSubmesh>(GetRenderLayer(), materialPass, renderPipeline, worldInstance, m_graphicalMesh->GetIndexCount(i), indexBuffer, vertexBuffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Nz
|
||||||
|
|
||||||
const auto& whiteTexture = Graphics::Instance()->GetDefaultTextures().whiteTextures[UnderlyingCast(ImageType::E2D)];
|
const auto& whiteTexture = Graphics::Instance()->GetDefaultTextures().whiteTextures[UnderlyingCast(ImageType::E2D)];
|
||||||
|
|
||||||
elements.emplace_back(std::make_unique<RenderSpriteChain>(0, materialPass, renderPipeline, worldInstance, vertexDeclaration, whiteTexture, m_spriteCount, m_vertices.data()));
|
elements.emplace_back(std::make_unique<RenderSpriteChain>(GetRenderLayer(), materialPass, renderPipeline, worldInstance, vertexDeclaration, whiteTexture, m_spriteCount, m_vertices.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::shared_ptr<Material>& SlicedSprite::GetMaterial(std::size_t i) const
|
const std::shared_ptr<Material>& SlicedSprite::GetMaterial(std::size_t i) const
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Nz
|
||||||
|
|
||||||
const auto& whiteTexture = Graphics::Instance()->GetDefaultTextures().whiteTextures[UnderlyingCast(ImageType::E2D)];
|
const auto& whiteTexture = Graphics::Instance()->GetDefaultTextures().whiteTextures[UnderlyingCast(ImageType::E2D)];
|
||||||
|
|
||||||
elements.emplace_back(std::make_unique<RenderSpriteChain>(0, materialPass, renderPipeline, worldInstance, vertexDeclaration, whiteTexture, 1, m_vertices.data()));
|
elements.emplace_back(std::make_unique<RenderSpriteChain>(GetRenderLayer(), materialPass, renderPipeline, worldInstance, vertexDeclaration, whiteTexture, 1, m_vertices.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::shared_ptr<Material>& Sprite::GetMaterial(std::size_t i) const
|
const std::shared_ptr<Material>& Sprite::GetMaterial(std::size_t i) const
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Nz
|
||||||
RenderIndices& indices = pair.second;
|
RenderIndices& indices = pair.second;
|
||||||
|
|
||||||
if (indices.count > 0)
|
if (indices.count > 0)
|
||||||
elements.emplace_back(std::make_unique<RenderSpriteChain>(0, materialPass, renderPipeline, worldInstance, vertexDeclaration, key.texture->shared_from_this(), indices.count, &m_vertices[indices.first * 4]));
|
elements.emplace_back(std::make_unique<RenderSpriteChain>(GetRenderLayer(), materialPass, renderPipeline, worldInstance, vertexDeclaration, key.texture->shared_from_this(), indices.count, &m_vertices[indices.first * 4]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue