Merge branch 'ubo' into vulkan
This commit is contained in:
@@ -49,8 +49,9 @@ namespace Nz
|
||||
{
|
||||
BufferType_Index,
|
||||
BufferType_Vertex,
|
||||
BufferType_Uniform,
|
||||
|
||||
BufferType_Max = BufferType_Vertex
|
||||
BufferType_Max = BufferType_Uniform
|
||||
};
|
||||
|
||||
enum BufferUsage
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace Nz
|
||||
inline const BufferRef& GetBuffer() const;
|
||||
inline UInt32 GetEndOffset() const;
|
||||
inline UInt32 GetIndexCount() const;
|
||||
inline DataStorage GetStorage() const;
|
||||
inline UInt32 GetStride() const;
|
||||
inline UInt32 GetStartOffset() const;
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ namespace Nz
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
inline DataStorage IndexBuffer::GetStorage() const
|
||||
{
|
||||
return DataStorage();
|
||||
}
|
||||
|
||||
inline UInt32 IndexBuffer::GetStride() const
|
||||
{
|
||||
return static_cast<UInt32>((m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16));
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -56,7 +60,6 @@ namespace Nz
|
||||
class Mesh;
|
||||
struct Primitive;
|
||||
class PrimitiveList;
|
||||
class Skeleton;
|
||||
class SubMesh;
|
||||
|
||||
using MeshVertex = VertexStruct_XYZ_Normal_UV_Tangent;
|
||||
@@ -80,8 +83,10 @@ namespace Nz
|
||||
friend class Utility;
|
||||
|
||||
public:
|
||||
Mesh() = default;
|
||||
~Mesh();
|
||||
inline Mesh();
|
||||
Mesh(const Mesh&) = delete;
|
||||
Mesh(Mesh&&) = delete;
|
||||
inline ~Mesh();
|
||||
|
||||
void AddSubMesh(SubMesh* subMesh);
|
||||
void AddSubMesh(const String& identifier, SubMesh* subMesh);
|
||||
@@ -141,14 +146,34 @@ namespace Nz
|
||||
|
||||
void Transform(const Matrix4f& matrix);
|
||||
|
||||
Mesh& operator=(const Mesh&) = delete;
|
||||
Mesh& operator=(Mesh&&) = delete;
|
||||
|
||||
template<typename... Args> static MeshRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnMeshDestroy, const Mesh* /*mesh*/);
|
||||
NazaraSignal(OnMeshInvalidateAABB, const Mesh* /*mesh*/);
|
||||
NazaraSignal(OnMeshRelease, const Mesh* /*mesh*/);
|
||||
|
||||
private:
|
||||
MeshImpl* m_impl = nullptr;
|
||||
struct SubMeshData
|
||||
{
|
||||
SubMeshRef subMesh;
|
||||
|
||||
NazaraSlot(SubMesh, OnSubMeshInvalidateAABB, onSubMeshInvalidated);
|
||||
};
|
||||
|
||||
std::unordered_map<String, UInt32> m_subMeshMap;
|
||||
std::vector<ParameterList> m_materialData;
|
||||
std::vector<SubMeshData> m_subMeshes;
|
||||
AnimationType m_animationType;
|
||||
mutable Boxf m_aabb;
|
||||
Skeleton m_skeleton; // Only used by skeletal meshes
|
||||
String m_animationPath;
|
||||
mutable bool m_aabbUpdated;
|
||||
bool m_isValid;
|
||||
UInt32 m_jointCount; // Only used by skeletal meshes
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
@@ -2,11 +2,25 @@
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
Mesh::Mesh() :
|
||||
m_materialData(1),
|
||||
m_aabbUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
Mesh::~Mesh()
|
||||
{
|
||||
OnMeshRelease(this);
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
MeshRef Mesh::New(Args&&... args)
|
||||
{
|
||||
|
||||
@@ -24,9 +24,14 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API SkeletalMesh final : public SubMesh
|
||||
{
|
||||
public:
|
||||
SkeletalMesh(VertexBuffer* vertexBuffer, const IndexBuffer* indexBuffer);
|
||||
|
||||
NAZARA_DEPRECATED("SkeletalMesh constructor taking a mesh is deprecated, submeshes no longer require to be part of a single mesh")
|
||||
SkeletalMesh(const Mesh* parent);
|
||||
|
||||
~SkeletalMesh();
|
||||
|
||||
NAZARA_DEPRECATED("SkeletalMesh create/destroy functions are deprecated, please use constructor")
|
||||
bool Create(VertexBuffer* vertexBuffer);
|
||||
void Destroy();
|
||||
|
||||
@@ -51,8 +56,8 @@ namespace Nz
|
||||
|
||||
private:
|
||||
Boxf m_aabb;
|
||||
IndexBufferConstRef m_indexBuffer = nullptr;
|
||||
VertexBufferRef m_vertexBuffer = nullptr;
|
||||
IndexBufferConstRef m_indexBuffer;
|
||||
VertexBufferRef m_vertexBuffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,16 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API StaticMesh final : public SubMesh
|
||||
{
|
||||
public:
|
||||
StaticMesh(VertexBuffer* vertexBuffer, const IndexBuffer* indexBuffer);
|
||||
|
||||
NAZARA_DEPRECATED("StaticMesh constructor taking a mesh is deprecated, submeshes no longer require to be part of a single mesh")
|
||||
StaticMesh(const Mesh* parent);
|
||||
|
||||
~StaticMesh();
|
||||
|
||||
void Center();
|
||||
|
||||
NAZARA_DEPRECATED("StaticMesh create/destroy functions are deprecated, please use constructor")
|
||||
bool Create(VertexBuffer* vertexBuffer);
|
||||
void Destroy();
|
||||
|
||||
@@ -52,8 +57,8 @@ namespace Nz
|
||||
|
||||
private:
|
||||
Boxf m_aabb;
|
||||
IndexBufferConstRef m_indexBuffer = nullptr;
|
||||
VertexBufferRef m_vertexBuffer = nullptr;
|
||||
IndexBufferConstRef m_indexBuffer;
|
||||
VertexBufferRef m_vertexBuffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,13 @@ namespace Nz
|
||||
friend Mesh;
|
||||
|
||||
public:
|
||||
SubMesh();
|
||||
|
||||
NAZARA_DEPRECATED("Submesh constructor taking a mesh is deprecated, submeshes no longer require to be part of a single mesh")
|
||||
SubMesh(const Mesh* parent);
|
||||
|
||||
SubMesh(const SubMesh&) = delete;
|
||||
SubMesh(SubMesh&&) = delete;
|
||||
virtual ~SubMesh();
|
||||
|
||||
void GenerateNormals();
|
||||
@@ -39,7 +45,6 @@ namespace Nz
|
||||
virtual AnimationType GetAnimationType() const = 0;
|
||||
virtual const IndexBuffer* GetIndexBuffer() const = 0;
|
||||
UInt32 GetMaterialIndex() const;
|
||||
const Mesh* GetParent() const;
|
||||
PrimitiveMode GetPrimitiveMode() const;
|
||||
UInt32 GetTriangleCount() const;
|
||||
virtual UInt32 GetVertexCount() const = 0;
|
||||
@@ -49,12 +54,15 @@ namespace Nz
|
||||
void SetMaterialIndex(UInt32 matIndex);
|
||||
void SetPrimitiveMode(PrimitiveMode mode);
|
||||
|
||||
SubMesh& operator=(const SubMesh&) = delete;
|
||||
SubMesh& operator=(SubMesh&&) = delete;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnSubMeshInvalidateAABB, const SubMesh* /*subMesh*/);
|
||||
NazaraSignal(OnSubMeshRelease, const SubMesh* /*subMesh*/);
|
||||
|
||||
protected:
|
||||
PrimitiveMode m_primitiveMode;
|
||||
const Mesh* m_parent;
|
||||
UInt32 m_matIndex;
|
||||
};
|
||||
}
|
||||
|
||||
69
include/Nazara/Utility/UniformBuffer.hpp
Normal file
69
include/Nazara/Utility/UniformBuffer.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UNIFORMBUFFER_HPP
|
||||
#define NAZARA_UNIFORMBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class UniformBuffer;
|
||||
|
||||
using UniformBufferConstRef = ObjectRef<const UniformBuffer>;
|
||||
using UniformBufferRef = ObjectRef<UniformBuffer>;
|
||||
|
||||
class NAZARA_UTILITY_API UniformBuffer : public RefCounted
|
||||
{
|
||||
public:
|
||||
UniformBuffer() = default;
|
||||
UniformBuffer(BufferRef buffer);
|
||||
UniformBuffer(BufferRef buffer, UInt32 offset, UInt32 size);
|
||||
UniformBuffer(UInt32 length, DataStorage storage, BufferUsageFlags usage);
|
||||
UniformBuffer(const UniformBuffer& uniformBuffer);
|
||||
UniformBuffer(UniformBuffer&&) = delete;
|
||||
~UniformBuffer();
|
||||
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size);
|
||||
|
||||
inline const BufferRef& GetBuffer() const;
|
||||
inline UInt32 GetEndOffset() const;
|
||||
inline UInt32 GetStartOffset() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0);
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const;
|
||||
|
||||
void Reset();
|
||||
void Reset(BufferRef buffer);
|
||||
void Reset(BufferRef buffer, UInt32 offset, UInt32 size);
|
||||
void Reset(UInt32 size, DataStorage storage, BufferUsageFlags usage);
|
||||
void Reset(const UniformBuffer& uniformBuffer);
|
||||
|
||||
void Unmap() const;
|
||||
|
||||
UniformBuffer& operator=(const UniformBuffer& uniformBuffer);
|
||||
UniformBuffer& operator=(UniformBuffer&&) = delete;
|
||||
|
||||
template<typename... Args> static UniformBufferRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnUniformBufferRelease, const UniformBuffer* /*UniformBuffer*/);
|
||||
|
||||
private:
|
||||
BufferRef m_buffer;
|
||||
UInt32 m_endOffset;
|
||||
UInt32 m_startOffset;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/UniformBuffer.inl>
|
||||
|
||||
#endif // NAZARA_UNIFORMBUFFER_HPP
|
||||
41
include/Nazara/Utility/UniformBuffer.inl
Normal file
41
include/Nazara/Utility/UniformBuffer.inl
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/UniformBuffer.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const BufferRef& UniformBuffer::GetBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline UInt32 UniformBuffer::GetEndOffset() const
|
||||
{
|
||||
return m_endOffset;
|
||||
}
|
||||
|
||||
inline UInt32 UniformBuffer::GetStartOffset() const
|
||||
{
|
||||
return m_startOffset;
|
||||
}
|
||||
|
||||
inline bool UniformBuffer::IsValid() const
|
||||
{
|
||||
return m_buffer.IsValid();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
UniformBufferRef UniformBuffer::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<UniformBuffer> object(new UniformBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user