New Render queues (#161)

* Add new render queues proof of concept + scissoring support (WIP)

* Graphics: Adapt basic sprites rendering to new render queue system

* Graphics: Fix layers when rendering sprites

* Graphics/RenderQueue: Fix sprite default overlay

* Graphics: Enable scissor test by default

* SDK/Widgets: Enable scissoring on widgets

* Graphics: Handle almost everything with the new renderqueues system

Todo:
- Billboard rendering
- Proper model rendering

* Graphics/RenderQueue: Billboard drawing now works (WIP)

At 1/4 of previous code performances due to individually process of billboards

* Add new render queues proof of concept + scissoring support (WIP)

* Graphics: Adapt basic sprites rendering to new render queue system

* Graphics: Fix layers when rendering sprites

* Graphics/RenderQueue: Fix sprite default overlay

* Graphics: Enable scissor test by default

* SDK/Widgets: Enable scissoring on widgets

* Graphics: Handle almost everything with the new renderqueues system

Todo:
- Billboard rendering
- Proper model rendering

* Graphics/RenderQueue: Billboard drawing now works (WIP)

At 1/4 of previous code performances due to individually process of billboards

* Graphics/RenderQueues: Add full support for billboards

* Graphics/RenderQueue: Cleanup and improve billboard rendering

* Graphics/RenderQueue: Fix model drawing

* Examples/Particles: Fix lighting on space station

* Graphics: Cleanup forward render queue/technique

* Fix compilation under Linux

* Graphics/ForwardRenderTechnique: Fix case when scissoring is enabled on material but disabled on element

* Add support for Deferred Shading

* SDK/Widgets: Fix widget rendering

* Graphics: Remove legacy code from render queues

* Graphics: Fix some objects sometimes not showing up due to broken scissor box

* Fix compilation error

* Sdk/GraphicsGraphics: Fix bounding volume

* SDK/World: Fix self-assignation

* Update changelog for render queues
This commit is contained in:
Jérôme Leclercq
2018-04-11 19:36:52 +02:00
committed by GitHub
parent 14248bb6c6
commit 2da086b7df
65 changed files with 3290 additions and 2998 deletions

View File

@@ -83,9 +83,10 @@ namespace Ndk
};
protected:
const EntityHandle& CreateEntity();
const EntityHandle& CreateEntity(bool isContentEntity);
void DestroyEntity(Entity* entity);
virtual void Layout();
void InvalidateNode() override;
virtual bool IsFocusable() const;
@@ -111,11 +112,18 @@ namespace Ndk
void RegisterToCanvas();
inline void UpdateCanvasIndex(std::size_t index);
void UnregisterFromCanvas();
void UpdatePositionAndSize();
struct WidgetEntity
{
EntityOwner handle;
bool isContent;
};
static constexpr std::size_t InvalidCanvasIndex = std::numeric_limits<std::size_t>::max();
std::size_t m_canvasIndex;
std::vector<EntityOwner> m_entities;
std::vector<WidgetEntity> m_entities;
std::vector<std::unique_ptr<BaseWidget>> m_children;
Canvas* m_canvas;
EntityOwner m_backgroundEntity;

View File

@@ -62,7 +62,7 @@ namespace Ndk
WidgetEntry& entry = m_widgetEntries[index];
Nz::Vector3f pos = entry.widget->GetPosition();
Nz::Vector2f size = entry.widget->GetContentSize();
Nz::Vector2f size = entry.widget->GetSize();
entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f);
}

View File

@@ -28,7 +28,7 @@ namespace Ndk
public:
using RenderableList = std::vector<Nz::InstancedRenderableRef>;
GraphicsComponent() = default;
GraphicsComponent();
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
~GraphicsComponent() = default;
@@ -54,6 +54,8 @@ namespace Ndk
inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const;
inline void SetScissorRect(const Nz::Recti& scissorRect);
inline void UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix);
inline void UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder);
@@ -144,6 +146,7 @@ namespace Ndk
std::unordered_map<const Nz::Material*, MaterialEntry> m_materialEntries;
mutable Nz::BoundingVolumef m_boundingVolume;
mutable Nz::Matrix4f m_transformMatrix;
Nz::Recti m_scissorRect;
Nz::TextureRef m_reflectionMap;
mutable bool m_boundingVolumeUpdated;
mutable bool m_transformMatrixUpdated;

View File

@@ -9,12 +9,16 @@
namespace Ndk
{
inline GraphicsComponent::GraphicsComponent() :
m_scissorRect(-1, -1)
{
}
/*!
* \brief Constructs a GraphicsComponent object by copy semantic
*
* \param graphicsComponent GraphicsComponent to copy
*/
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
Component(graphicsComponent),
HandledObject(graphicsComponent),
@@ -177,6 +181,14 @@ namespace Ndk
}
}
inline void GraphicsComponent::SetScissorRect(const Nz::Recti& scissorRect)
{
m_scissorRect = scissorRect;
for (VolumeCullingEntry& entry : m_volumeCullingEntries)
entry.listEntry.ForceInvalidation(); //< Invalidate render queues
}
inline void GraphicsComponent::UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix)
{
for (auto& renderable : m_renderables)

View File

@@ -28,7 +28,7 @@ namespace Ndk
//virtual LabelWidget* Clone() const = 0;
void ResizeToContent();
void ResizeToContent() override;
inline void UpdateText(const Nz::AbstractTextDrawer& drawer);
@@ -36,6 +36,8 @@ namespace Ndk
LabelWidget& operator=(LabelWidget&&) = default;
private:
void Layout() override;
EntityHandle m_textEntity;
Nz::TextSpriteRef m_textSprite;
};

View File

@@ -426,7 +426,7 @@ namespace Ndk
m_orderedSystems = std::move(world.m_orderedSystems);
m_orderedSystemsUpdated = world.m_orderedSystemsUpdated;
m_profilerData = std::move(world.m_profilerData);
m_isProfilerEnabled = m_isProfilerEnabled;
m_isProfilerEnabled = world.m_isProfilerEnabled;
m_entities = std::move(world.m_entities);
for (EntityBlock& block : m_entities)