Graphics: Separate Renderable and make Light a Renderable (LightComponent)
Former-commit-id: 6177d473f27ef493ba77417fc14461cb08b6f9e1
This commit is contained in:
@@ -9,9 +9,6 @@
|
||||
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
@@ -19,62 +16,32 @@
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
|
||||
class NzAbstractRenderQueue;
|
||||
class NzRenderable;
|
||||
|
||||
using NzRenderableConstRef = NzObjectRef<const NzRenderable>;
|
||||
using NzRenderableLibrary = NzObjectLibrary<NzRenderable>;
|
||||
using NzRenderableRef = NzObjectRef<NzRenderable>;
|
||||
|
||||
class NAZARA_GRAPHICS_API NzRenderable : public NzRefCounted
|
||||
class NAZARA_GRAPHICS_API NzRenderable
|
||||
{
|
||||
public:
|
||||
struct InstanceData;
|
||||
|
||||
NzRenderable() = default;
|
||||
inline NzRenderable(const NzRenderable& renderable);
|
||||
NzRenderable(const NzRenderable& renderable) = default;
|
||||
virtual ~NzRenderable();
|
||||
|
||||
inline void EnsureBoundingVolumeUpdated() const;
|
||||
void EnsureBoundingVolumeUpdated() const;
|
||||
|
||||
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const InstanceData& instanceData) const = 0;
|
||||
virtual bool Cull(const NzFrustumf& frustum, const InstanceData& instanceData) const;
|
||||
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const = 0;
|
||||
virtual bool Cull(const NzFrustumf& frustum, const NzMatrix4f& transformMatrix) const = 0;
|
||||
virtual const NzBoundingVolumef& GetBoundingVolume() const;
|
||||
virtual void InvalidateData(InstanceData* instanceData, nzUInt32 flags) const;
|
||||
virtual void UpdateBoundingVolume(InstanceData* instanceData) const;
|
||||
virtual void UpdateData(InstanceData* instanceData) const;
|
||||
virtual void UpdateBoundingVolume(const NzMatrix4f& transformMatrix);
|
||||
|
||||
inline NzRenderable& operator=(const NzRenderable& renderable);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderableInvalidateInstanceData, const NzRenderable*, nzUInt32); //< Args: me, flags
|
||||
NazaraSignal(OnRenderableRelease, const NzRenderable*); //< Args: me
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
InstanceData(NzMatrix4f& referenceMatrix) :
|
||||
transformMatrix(referenceMatrix),
|
||||
flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<nzUInt8> data;
|
||||
NzBoundingVolumef volume;
|
||||
NzMatrix4f& transformMatrix;
|
||||
nzUInt32 flags;
|
||||
};
|
||||
NzRenderable& operator=(const NzRenderable& renderable) = default;
|
||||
|
||||
protected:
|
||||
virtual void MakeBoundingVolume() const = 0;
|
||||
void InvalidateBoundingVolume();
|
||||
inline void InvalidateInstanceData(nzUInt32 flags);
|
||||
inline void UpdateBoundingVolume() const;
|
||||
void UpdateBoundingVolume() const;
|
||||
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
|
||||
private:
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
|
||||
static NzRenderableLibrary::LibraryMap s_library;
|
||||
};
|
||||
|
||||
#include <Nazara/Graphics/Renderable.inl>
|
||||
|
||||
Reference in New Issue
Block a user