Sdk/RenderSystem: Add EnableCulling method
This commit is contained in:
parent
f3ea154da4
commit
602992609f
|
|
@ -132,6 +132,7 @@ Nazara Engine:
|
||||||
- Added movement with Ctrl in TextAreaWidget
|
- Added movement with Ctrl in TextAreaWidget
|
||||||
- Added Unicode Data downloader/parser
|
- Added Unicode Data downloader/parser
|
||||||
- Integrated Unicode Data
|
- Integrated Unicode Data
|
||||||
|
- Added CullingList::FillWithAllEntries method
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
|
|
@ -186,6 +187,7 @@ Nazara Development Kit:
|
||||||
- Fixed GraphicsComponent copy constructor not copying scissor rect
|
- Fixed GraphicsComponent copy constructor not copying scissor rect
|
||||||
- Force parent parameter to be present in widgets constructor
|
- Force parent parameter to be present in widgets constructor
|
||||||
- Added the possibility to write only specific characters with a predicate in TextAreaWidget
|
- Added the possibility to write only specific characters with a predicate in TextAreaWidget
|
||||||
|
- It is now possible to disable object culling in the RenderSystem
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderSystem();
|
RenderSystem();
|
||||||
inline RenderSystem(const RenderSystem& renderSystem);
|
|
||||||
~RenderSystem() = default;
|
~RenderSystem() = default;
|
||||||
|
|
||||||
template<typename T> T& ChangeRenderTechnique();
|
template<typename T> T& ChangeRenderTechnique();
|
||||||
inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
|
inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
|
||||||
|
|
||||||
|
inline void EnableCulling(bool enable);
|
||||||
|
|
||||||
inline const Nz::BackgroundRef& GetDefaultBackground() const;
|
inline const Nz::BackgroundRef& GetDefaultBackground() const;
|
||||||
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
|
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
|
||||||
inline Nz::Vector3f GetGlobalForward() const;
|
inline Nz::Vector3f GetGlobalForward() const;
|
||||||
|
|
@ -38,6 +39,8 @@ namespace Ndk
|
||||||
inline Nz::Vector3f GetGlobalUp() const;
|
inline Nz::Vector3f GetGlobalUp() const;
|
||||||
inline Nz::AbstractRenderTechnique& GetRenderTechnique() const;
|
inline Nz::AbstractRenderTechnique& GetRenderTechnique() const;
|
||||||
|
|
||||||
|
inline bool IsCullingEnabled() const;
|
||||||
|
|
||||||
inline void SetDefaultBackground(Nz::BackgroundRef background);
|
inline void SetDefaultBackground(Nz::BackgroundRef background);
|
||||||
inline void SetGlobalForward(const Nz::Vector3f& direction);
|
inline void SetGlobalForward(const Nz::Vector3f& direction);
|
||||||
inline void SetGlobalRight(const Nz::Vector3f& direction);
|
inline void SetGlobalRight(const Nz::Vector3f& direction);
|
||||||
|
|
@ -72,6 +75,7 @@ namespace Ndk
|
||||||
Nz::RenderTexture m_shadowRT;
|
Nz::RenderTexture m_shadowRT;
|
||||||
bool m_coordinateSystemInvalidated;
|
bool m_coordinateSystemInvalidated;
|
||||||
bool m_forceRenderQueueInvalidation;
|
bool m_forceRenderQueueInvalidation;
|
||||||
|
bool m_isCullingEnabled;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -26,7 +28,24 @@ namespace Ndk
|
||||||
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
|
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
|
||||||
{
|
{
|
||||||
m_renderTechnique = std::move(renderTechnique);
|
m_renderTechnique = std::move(renderTechnique);
|
||||||
return *m_renderTechnique.get();
|
return *m_renderTechnique;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enables/disables object culling
|
||||||
|
*
|
||||||
|
* Object culling is an algorithm used by the render system to detect invisible objects (which will not appear on screen) before they are rendered.
|
||||||
|
* This includes Frustum Culling and potentially Occlusion Culling.
|
||||||
|
*
|
||||||
|
* Disabling this is not recommended, as the system will draw every object in the world which could induce a performance loss.
|
||||||
|
*
|
||||||
|
* \param enable Whether to enable or disable culling
|
||||||
|
*
|
||||||
|
* \see IsCullingEnabled
|
||||||
|
*/
|
||||||
|
inline void RenderSystem::EnableCulling(bool enable)
|
||||||
|
{
|
||||||
|
m_isCullingEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -89,6 +108,17 @@ namespace Ndk
|
||||||
return *m_renderTechnique.get();
|
return *m_renderTechnique.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Query if culling is enabled (enabled by default)
|
||||||
|
* \return True if culling is enabled, false otherwise
|
||||||
|
*
|
||||||
|
* \see EnableCulling
|
||||||
|
*/
|
||||||
|
inline bool RenderSystem::IsCullingEnabled() const
|
||||||
|
{
|
||||||
|
return m_isCullingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Sets the background used for rendering
|
* \brief Sets the background used for rendering
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ namespace Ndk
|
||||||
RenderSystem::RenderSystem() :
|
RenderSystem::RenderSystem() :
|
||||||
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
|
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
|
||||||
m_coordinateSystemInvalidated(true),
|
m_coordinateSystemInvalidated(true),
|
||||||
m_forceRenderQueueInvalidation(false)
|
m_forceRenderQueueInvalidation(false),
|
||||||
|
m_isCullingEnabled(true)
|
||||||
{
|
{
|
||||||
ChangeRenderTechnique<Nz::ForwardRenderTechnique>();
|
ChangeRenderTechnique<Nz::ForwardRenderTechnique>();
|
||||||
SetDefaultBackground(Nz::ColorBackground::New());
|
SetDefaultBackground(Nz::ColorBackground::New());
|
||||||
|
|
@ -203,7 +204,11 @@ namespace Ndk
|
||||||
|
|
||||||
bool forceInvalidation = false;
|
bool forceInvalidation = false;
|
||||||
|
|
||||||
std::size_t visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation);
|
std::size_t visibilityHash;
|
||||||
|
if (m_isCullingEnabled)
|
||||||
|
visibilityHash = m_drawableCulling.Cull(camComponent.GetFrustum(), &forceInvalidation);
|
||||||
|
else
|
||||||
|
visibilityHash = m_drawableCulling.FillWithAllEntries();
|
||||||
|
|
||||||
// Always regenerate renderqueue if particle groups are present for now (FIXME)
|
// Always regenerate renderqueue if particle groups are present for now (FIXME)
|
||||||
if (!m_lights.empty() || !m_particleGroups.empty())
|
if (!m_lights.empty() || !m_particleGroups.empty())
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ namespace Nz
|
||||||
|
|
||||||
std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr);
|
std::size_t Cull(const Frustumf& frustum, bool* forceInvalidation = nullptr);
|
||||||
|
|
||||||
|
std::size_t FillWithAllEntries();
|
||||||
|
|
||||||
NoTestEntry RegisterNoTest(const T* renderable);
|
NoTestEntry RegisterNoTest(const T* renderable);
|
||||||
SphereEntry RegisterSphereTest(const T* renderable);
|
SphereEntry RegisterSphereTest(const T* renderable);
|
||||||
VolumeEntry RegisterVolumeTest(const T* renderable);
|
VolumeEntry RegisterVolumeTest(const T* renderable);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,33 @@ namespace Nz
|
||||||
return visibleHash;
|
return visibleHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::size_t CullingList<T>::FillWithAllEntries()
|
||||||
|
{
|
||||||
|
m_results.clear();
|
||||||
|
|
||||||
|
std::size_t visibleHash = 0U;
|
||||||
|
for (NoTestVisibilityEntry& entry : m_noTestList)
|
||||||
|
{
|
||||||
|
m_results.push_back(entry.renderable);
|
||||||
|
Nz::HashCombine(visibleHash, entry.renderable);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SphereVisibilityEntry& entry : m_sphereTestList)
|
||||||
|
{
|
||||||
|
m_results.push_back(entry.renderable);
|
||||||
|
Nz::HashCombine(visibleHash, entry.renderable);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (VolumeVisibilityEntry& entry : m_volumeTestList)
|
||||||
|
{
|
||||||
|
m_results.push_back(entry.renderable);
|
||||||
|
Nz::HashCombine(visibleHash, entry.renderable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return visibleHash;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
auto CullingList<T>::RegisterNoTest(const T* renderable) -> NoTestEntry
|
auto CullingList<T>::RegisterNoTest(const T* renderable) -> NoTestEntry
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue