Added VertexMapper constructor
Removed useless headers Former-commit-id: e8925f48eec9c52dc4f2ad7bf6a61deb755bc0ee
This commit is contained in:
parent
0415f32b86
commit
7a2a10b390
|
|
@ -9,18 +9,15 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
class NzSubMesh;
|
||||
|
||||
class NAZARA_API NzVertexMapper
|
||||
{
|
||||
public:
|
||||
NzVertexMapper(NzVertexBuffer* vertexBuffer, unsigned int vertexCount);
|
||||
NzVertexMapper(NzSubMesh* subMesh);
|
||||
~NzVertexMapper();
|
||||
|
||||
|
|
@ -31,7 +28,6 @@ class NAZARA_API NzVertexMapper
|
|||
|
||||
private:
|
||||
NzBufferMapper<NzVertexBuffer> m_mapper;
|
||||
NzVertexDeclarationConstRef m_declaration;
|
||||
unsigned int m_vertexCount;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,24 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
template <typename T>
|
||||
NzSparsePtr<T> NzVertexMapper::GetComponentPtr(nzVertexComponent component)
|
||||
{
|
||||
// On récupère la déclaration depuis le buffer
|
||||
const NzVertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration();
|
||||
|
||||
// Ensuite le composant qui nous intéresse
|
||||
bool enabled;
|
||||
nzComponentType type;
|
||||
unsigned int offset;
|
||||
m_declaration->GetComponent(component, &enabled, &type, &offset);
|
||||
declaration->GetComponent(component, &enabled, &type, &offset);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
///TODO: Vérifier le rapport entre le type de l'attribut et le type template ?
|
||||
return NzSparsePtr<T>(static_cast<nzUInt8*>(m_mapper.GetPointer()) + offset, m_declaration->GetStride());
|
||||
return NzSparsePtr<T>(static_cast<nzUInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <Nazara/Utility/VertexMapper.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/SkeletalMesh.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
|
@ -13,7 +12,8 @@
|
|||
|
||||
NzVertexMapper::NzVertexMapper(NzSubMesh* subMesh)
|
||||
{
|
||||
NzErrorFlags flags(nzErrorFlag_ThrowException);
|
||||
NzErrorFlags flags(nzErrorFlag_ThrowException, true);
|
||||
|
||||
NzVertexBuffer* buffer = nullptr;
|
||||
switch (subMesh->GetAnimationType())
|
||||
{
|
||||
|
|
@ -37,12 +37,19 @@ NzVertexMapper::NzVertexMapper(NzSubMesh* subMesh)
|
|||
NazaraInternalError("Animation type not handled (0x" + NzString::Number(subMesh->GetAnimationType(), 16) + ')');
|
||||
}
|
||||
|
||||
m_declaration = buffer->GetVertexDeclaration();
|
||||
m_vertexCount = subMesh->GetVertexCount();
|
||||
|
||||
m_mapper.Map(buffer, nzBufferAccess_ReadWrite);
|
||||
}
|
||||
|
||||
NzVertexMapper::NzVertexMapper(NzVertexBuffer* vertexBuffer, unsigned int vertexCount)
|
||||
{
|
||||
NzErrorFlags flags(nzErrorFlag_ThrowException, true);
|
||||
|
||||
m_mapper.Map(vertexBuffer, nzBufferAccess_ReadWrite);
|
||||
m_vertexCount = vertexCount;
|
||||
}
|
||||
|
||||
NzVertexMapper::~NzVertexMapper() = default;
|
||||
|
||||
unsigned int NzVertexMapper::GetVertexCount() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue