Fix merge conflict with DigitalPulseSoftware.
Former-commit-id: 5c7fa12d8461b1b1600cad0a657ad7f6d3932cc7
This commit is contained in:
commit
aaac162d12
|
|
@ -70,8 +70,11 @@ void* NzBufferMapper<T>::GetPointer() const
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzBufferMapper<T>::Unmap()
|
void NzBufferMapper<T>::Unmap()
|
||||||
{
|
{
|
||||||
m_buffer->Unmap();
|
if (m_buffer)
|
||||||
m_buffer = nullptr;
|
{
|
||||||
|
m_buffer->Unmap();
|
||||||
|
m_buffer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright (C) 2012 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_TRIANGLEITERATOR_HPP
|
||||||
|
#define NAZARA_TRIANGLEITERATOR_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Math/Vector2.hpp>
|
||||||
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <Nazara/Utility/IndexMapper.hpp>
|
||||||
|
#include <Nazara/Utility/VertexMapper.hpp>
|
||||||
|
|
||||||
|
class NzSubMesh;
|
||||||
|
|
||||||
|
class NAZARA_API NzTriangleIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NzTriangleIterator(NzSubMesh* subMesh, nzBufferAccess access = nzBufferAccess_ReadWrite);
|
||||||
|
~NzTriangleIterator() = default;
|
||||||
|
|
||||||
|
bool Advance();
|
||||||
|
|
||||||
|
NzVector3f GetNormal(unsigned int i) const;
|
||||||
|
NzVector3f GetPosition(unsigned int i) const;
|
||||||
|
NzVector3f GetTangent(unsigned int i) const;
|
||||||
|
NzVector2f GetTexCoords(unsigned int i) const;
|
||||||
|
|
||||||
|
void SetNormal(unsigned int i, const NzVector3f& normal);
|
||||||
|
void SetPosition(unsigned int i, const NzVector3f& position);
|
||||||
|
void SetTangent(unsigned int i, const NzVector3f& tangent);
|
||||||
|
void SetTexCoords(unsigned int i, const NzVector2f& texCoords);
|
||||||
|
|
||||||
|
void Unmap();
|
||||||
|
|
||||||
|
private:
|
||||||
|
nzPrimitiveType m_primitiveType;
|
||||||
|
nzUInt32 m_triangleIndices[3];
|
||||||
|
NzIndexMapper m_indexMapper;
|
||||||
|
NzVertexMapper m_vertexMapper;
|
||||||
|
unsigned int m_currentIndex;
|
||||||
|
unsigned int m_indexCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NAZARA_TRIANGLEITERATOR_HPP
|
||||||
|
|
@ -26,7 +26,7 @@ class NAZARA_API NzVertexMapper
|
||||||
NzVector3f GetPosition(unsigned int i) const;
|
NzVector3f GetPosition(unsigned int i) const;
|
||||||
NzVector3f GetTangent(unsigned int i) const;
|
NzVector3f GetTangent(unsigned int i) const;
|
||||||
NzVector2f GetTexCoords(unsigned int i) const;
|
NzVector2f GetTexCoords(unsigned int i) const;
|
||||||
unsigned int GetTotalVertexCount();
|
unsigned int GetVertexCount();
|
||||||
|
|
||||||
void SetNormal(unsigned int i, const NzVector3f& normal);
|
void SetNormal(unsigned int i, const NzVector3f& normal);
|
||||||
void SetPosition(unsigned int i, const NzVector3f& position);
|
void SetPosition(unsigned int i, const NzVector3f& position);
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,7 @@ NzString NzFile::AbsolutePath(const NzString& filePath)
|
||||||
NazaraError("Path unrecognized");
|
NazaraError("Path unrecognized");
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||||
base = '/';
|
base = '/';
|
||||||
start = 0;
|
start = 0;
|
||||||
#else
|
#else
|
||||||
|
|
@ -664,7 +664,7 @@ bool NzFile::IsAbsolute(const NzString& filePath)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||||
return path.StartsWith('/');
|
return path.StartsWith('/');
|
||||||
#else
|
#else
|
||||||
#error OS case not implemented
|
#error OS case not implemented
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,171 @@
|
||||||
|
// Copyright (C) 2012 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/TriangleIterator.hpp>
|
||||||
|
#include <Nazara/Utility/SubMesh.hpp>
|
||||||
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
|
NzTriangleIterator::NzTriangleIterator(NzSubMesh* subMesh, nzBufferAccess access) :
|
||||||
|
m_primitiveType(subMesh->GetPrimitiveType()),
|
||||||
|
m_indexMapper(subMesh->GetIndexBuffer(), nzBufferAccess_ReadOnly),
|
||||||
|
m_vertexMapper(subMesh)
|
||||||
|
{
|
||||||
|
NazaraUnused(access);
|
||||||
|
|
||||||
|
m_currentIndex = 3;
|
||||||
|
m_triangleIndices[0] = m_indexMapper.Get(0);
|
||||||
|
m_triangleIndices[1] = m_indexMapper.Get(1);
|
||||||
|
m_triangleIndices[2] = m_indexMapper.Get(2);
|
||||||
|
|
||||||
|
const NzIndexBuffer* indexBuffer = m_indexMapper.GetBuffer();
|
||||||
|
if (indexBuffer)
|
||||||
|
m_indexCount = indexBuffer->GetIndexCount();
|
||||||
|
else
|
||||||
|
m_indexCount = subMesh->GetVertexBuffer()->GetVertexCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NzTriangleIterator::Advance()
|
||||||
|
{
|
||||||
|
if (m_currentIndex >= m_indexCount)
|
||||||
|
{
|
||||||
|
Unmap();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_primitiveType)
|
||||||
|
{
|
||||||
|
case nzPrimitiveType_TriangleFan:
|
||||||
|
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nzPrimitiveType_TriangleList:
|
||||||
|
m_triangleIndices[0] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case nzPrimitiveType_TriangleStrip:
|
||||||
|
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||||
|
m_triangleIndices[1] = m_triangleIndices[2];
|
||||||
|
m_triangleIndices[0] = m_triangleIndices[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector3f NzTriangleIterator::GetNormal(unsigned int i) const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return NzVector3f();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_vertexMapper.GetNormal(m_triangleIndices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector3f NzTriangleIterator::GetPosition(unsigned int i) const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return NzVector3f();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_vertexMapper.GetPosition(m_triangleIndices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector3f NzTriangleIterator::GetTangent(unsigned int i) const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return NzVector3f();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_vertexMapper.GetTangent(m_triangleIndices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector2f NzTriangleIterator::GetTexCoords(unsigned int i) const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return NzVector2f();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_vertexMapper.GetTexCoords(m_triangleIndices[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTriangleIterator::SetNormal(unsigned int i, const NzVector3f& normal)
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_vertexMapper.SetNormal(m_triangleIndices[i], normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTriangleIterator::SetPosition(unsigned int i, const NzVector3f& position)
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_vertexMapper.SetPosition(m_triangleIndices[i], position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTriangleIterator::SetTangent(unsigned int i, const NzVector3f& tangent)
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_vertexMapper.SetTangent(m_triangleIndices[i], tangent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTriangleIterator::SetTexCoords(unsigned int i, const NzVector2f& texCoords)
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (i > 2)
|
||||||
|
{
|
||||||
|
NazaraError("Index out of range: (" + NzString::Number(i) + " > 2)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_vertexMapper.SetTexCoords(m_triangleIndices[i], texCoords);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTriangleIterator::Unmap()
|
||||||
|
{
|
||||||
|
// Peut très bien être appellé plusieurs fois de suite, seul le premier appel sera pris en compte
|
||||||
|
m_indexMapper.Unmap();
|
||||||
|
m_vertexMapper.Unmap();
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@ class NzVertexMapperImpl
|
||||||
virtual NzVector3f GetPosition(unsigned int i) const = 0;
|
virtual NzVector3f GetPosition(unsigned int i) const = 0;
|
||||||
virtual NzVector3f GetTangent(unsigned int i) const = 0;
|
virtual NzVector3f GetTangent(unsigned int i) const = 0;
|
||||||
virtual NzVector2f GetTexCoords(unsigned int i) const = 0;
|
virtual NzVector2f GetTexCoords(unsigned int i) const = 0;
|
||||||
virtual unsigned int GetTotalVertexCount() const = 0;
|
virtual unsigned int GetVertexCount() const = 0;
|
||||||
|
|
||||||
virtual void SetNormal(unsigned int i, const NzVector3f& normal) = 0;
|
virtual void SetNormal(unsigned int i, const NzVector3f& normal) = 0;
|
||||||
virtual void SetPosition(unsigned int i, const NzVector3f& position) = 0;
|
virtual void SetPosition(unsigned int i, const NzVector3f& position) = 0;
|
||||||
|
|
@ -90,7 +90,7 @@ namespace
|
||||||
return m_mesh->GetTexCoords(i%m_vertexPerFrame);
|
return m_mesh->GetTexCoords(i%m_vertexPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetTotalVertexCount() const
|
unsigned int GetVertexCount() const
|
||||||
{
|
{
|
||||||
return m_vertexPerFrame*m_mesh->GetFrameCount();
|
return m_vertexPerFrame*m_mesh->GetFrameCount();
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,7 @@ namespace
|
||||||
return m_vertices[i].uv;
|
return m_vertices[i].uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetTotalVertexCount() const
|
unsigned int GetVertexCount() const
|
||||||
{
|
{
|
||||||
return m_mesh->GetVertexCount();
|
return m_mesh->GetVertexCount();
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +221,7 @@ namespace
|
||||||
return m_vertices[i].uv;
|
return m_vertices[i].uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetTotalVertexCount() const
|
unsigned int GetVertexCount() const
|
||||||
{
|
{
|
||||||
return m_vertexMapper.GetBuffer()->GetVertexCount();
|
return m_vertexMapper.GetBuffer()->GetVertexCount();
|
||||||
}
|
}
|
||||||
|
|
@ -299,9 +299,9 @@ NzVector2f NzVertexMapper::GetTexCoords(unsigned int i) const
|
||||||
return m_impl->GetTexCoords(i);
|
return m_impl->GetTexCoords(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NzVertexMapper::GetTotalVertexCount()
|
unsigned int NzVertexMapper::GetVertexCount()
|
||||||
{
|
{
|
||||||
return m_impl->GetTotalVertexCount();
|
return m_impl->GetVertexCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzVertexMapper::SetNormal(unsigned int i, const NzVector3f& normal)
|
void NzVertexMapper::SetNormal(unsigned int i, const NzVector3f& normal)
|
||||||
|
|
@ -326,6 +326,9 @@ void NzVertexMapper::SetTexCoords(unsigned int i, const NzVector2f& texCoords)
|
||||||
|
|
||||||
void NzVertexMapper::Unmap()
|
void NzVertexMapper::Unmap()
|
||||||
{
|
{
|
||||||
delete m_impl;
|
if (m_impl)
|
||||||
m_impl = nullptr;
|
{
|
||||||
|
delete m_impl;
|
||||||
|
m_impl = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue