Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan
Former-commit-id: e4243c916b02d58153bbda5cb317a75dbaba4a1c [formerly b061bd4916fdfb2ddb8f9a5321a2474427cd1e0b] Former-commit-id: 45002c1ea81078974e4c77a2f70273515c09a134
This commit is contained in:
commit
f13dec4f06
|
|
@ -23,6 +23,8 @@ namespace Ndk
|
||||||
friend class RenderSystem;
|
friend class RenderSystem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using RenderableList = std::vector<Nz::InstancedRenderableRef>;
|
||||||
|
|
||||||
GraphicsComponent() = default;
|
GraphicsComponent() = default;
|
||||||
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
||||||
~GraphicsComponent() = default;
|
~GraphicsComponent() = default;
|
||||||
|
|
@ -38,6 +40,9 @@ namespace Ndk
|
||||||
inline void EnsureBoundingVolumeUpdate() const;
|
inline void EnsureBoundingVolumeUpdate() const;
|
||||||
inline void EnsureTransformMatrixUpdate() const;
|
inline void EnsureTransformMatrixUpdate() const;
|
||||||
|
|
||||||
|
inline void GetAttachedRenderables(RenderableList* renderables) const;
|
||||||
|
inline std::size_t GetAttachedRenderableCount() const;
|
||||||
|
|
||||||
inline const Nz::BoundingVolumef& GetBoundingVolume() const;
|
inline const Nz::BoundingVolumef& GetBoundingVolume() const;
|
||||||
|
|
||||||
static ComponentIndex componentIndex;
|
static ComponentIndex componentIndex;
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,20 @@ namespace Ndk
|
||||||
UpdateTransformMatrix();
|
UpdateTransformMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const
|
||||||
|
{
|
||||||
|
NazaraAssert(renderables, "Invalid renderable list");
|
||||||
|
|
||||||
|
renderables->reserve(renderables->size() + m_renderables.size());
|
||||||
|
for (const Renderable& r : m_renderables)
|
||||||
|
renderables->push_back(r.renderable);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const
|
||||||
|
{
|
||||||
|
return m_renderables.size();
|
||||||
|
}
|
||||||
|
|
||||||
inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const
|
inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const
|
||||||
{
|
{
|
||||||
EnsureBoundingVolumeUpdate();
|
EnsureBoundingVolumeUpdate();
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,41 @@ namespace Nz
|
||||||
class NAZARA_UTILITY_API OBJParser
|
class NAZARA_UTILITY_API OBJParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct FaceVertex
|
struct Face;
|
||||||
{
|
struct FaceVertex;
|
||||||
int normal;
|
struct Mesh;
|
||||||
int position;
|
|
||||||
int texCoord;
|
OBJParser() = default;
|
||||||
};
|
~OBJParser() = default;
|
||||||
|
|
||||||
|
inline void Clear();
|
||||||
|
|
||||||
|
inline String* GetMaterials();
|
||||||
|
inline const String* GetMaterials() const;
|
||||||
|
inline unsigned int GetMaterialCount() const;
|
||||||
|
inline Mesh* GetMeshes();
|
||||||
|
inline const Mesh* GetMeshes() const;
|
||||||
|
inline unsigned int GetMeshCount() const;
|
||||||
|
inline const String& GetMtlLib() const;
|
||||||
|
inline Vector3f* GetNormals();
|
||||||
|
inline const Vector3f* GetNormals() const;
|
||||||
|
inline unsigned int GetNormalCount() const;
|
||||||
|
inline Vector4f* GetPositions();
|
||||||
|
inline const Vector4f* GetPositions() const;
|
||||||
|
inline unsigned int GetPositionCount() const;
|
||||||
|
inline Vector3f* GetTexCoords();
|
||||||
|
inline const Vector3f* GetTexCoords() const;
|
||||||
|
inline unsigned int GetTexCoordCount() const;
|
||||||
|
|
||||||
|
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
|
||||||
|
|
||||||
|
bool Save(Stream& stream) const;
|
||||||
|
|
||||||
|
inline String* SetMaterialCount(std::size_t materialCount);
|
||||||
|
inline Mesh* SetMeshCount(std::size_t meshCount);
|
||||||
|
inline Vector3f* SetNormalCount(std::size_t normalCount);
|
||||||
|
inline Vector4f* SetPositionCount(std::size_t positionCount);
|
||||||
|
inline Vector3f* SetTexCoordCount(std::size_t texCoordCount);
|
||||||
|
|
||||||
struct Face
|
struct Face
|
||||||
{
|
{
|
||||||
|
|
@ -33,6 +62,13 @@ namespace Nz
|
||||||
std::size_t vertexCount;
|
std::size_t vertexCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FaceVertex
|
||||||
|
{
|
||||||
|
std::size_t normal;
|
||||||
|
std::size_t position;
|
||||||
|
std::size_t texCoord;
|
||||||
|
};
|
||||||
|
|
||||||
struct Mesh
|
struct Mesh
|
||||||
{
|
{
|
||||||
std::vector<Face> faces;
|
std::vector<Face> faces;
|
||||||
|
|
@ -41,25 +77,6 @@ namespace Nz
|
||||||
std::size_t material;
|
std::size_t material;
|
||||||
};
|
};
|
||||||
|
|
||||||
OBJParser() = default;
|
|
||||||
~OBJParser() = default;
|
|
||||||
|
|
||||||
inline const String* GetMaterials() const;
|
|
||||||
inline unsigned int GetMaterialCount() const;
|
|
||||||
inline const Mesh* GetMeshes() const;
|
|
||||||
inline unsigned int GetMeshCount() const;
|
|
||||||
inline const String& GetMtlLib() const;
|
|
||||||
inline const Vector3f* GetNormals() const;
|
|
||||||
inline unsigned int GetNormalCount() const;
|
|
||||||
inline const Vector4f* GetPositions() const;
|
|
||||||
inline unsigned int GetPositionCount() const;
|
|
||||||
inline const Vector3f* GetTexCoords() const;
|
|
||||||
inline unsigned int GetTexCoordCount() const;
|
|
||||||
|
|
||||||
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
|
|
||||||
|
|
||||||
bool Save(Stream& stream) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Advance(bool required = true);
|
bool Advance(bool required = true);
|
||||||
template<typename T> void Emit(const T& text) const;
|
template<typename T> void Emit(const T& text) const;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,20 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
inline void OBJParser::Clear()
|
||||||
|
{
|
||||||
|
m_materials.clear();
|
||||||
|
m_meshes.clear();
|
||||||
|
m_positions.clear();
|
||||||
|
m_normals.clear();
|
||||||
|
m_texCoords.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String* OBJParser::GetMaterials()
|
||||||
|
{
|
||||||
|
return m_materials.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline const String* OBJParser::GetMaterials() const
|
inline const String* OBJParser::GetMaterials() const
|
||||||
{
|
{
|
||||||
return m_materials.data();
|
return m_materials.data();
|
||||||
|
|
@ -18,6 +32,11 @@ namespace Nz
|
||||||
return m_materials.size();
|
return m_materials.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline OBJParser::Mesh* OBJParser::GetMeshes()
|
||||||
|
{
|
||||||
|
return m_meshes.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline const OBJParser::Mesh* OBJParser::GetMeshes() const
|
inline const OBJParser::Mesh* OBJParser::GetMeshes() const
|
||||||
{
|
{
|
||||||
return m_meshes.data();
|
return m_meshes.data();
|
||||||
|
|
@ -33,6 +52,11 @@ namespace Nz
|
||||||
return m_mtlLib;
|
return m_mtlLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Vector3f* OBJParser::GetNormals()
|
||||||
|
{
|
||||||
|
return m_normals.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline const Vector3f* OBJParser::GetNormals() const
|
inline const Vector3f* OBJParser::GetNormals() const
|
||||||
{
|
{
|
||||||
return m_normals.data();
|
return m_normals.data();
|
||||||
|
|
@ -43,6 +67,11 @@ namespace Nz
|
||||||
return m_normals.size();
|
return m_normals.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Vector4f* OBJParser::GetPositions()
|
||||||
|
{
|
||||||
|
return m_positions.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline const Vector4f* OBJParser::GetPositions() const
|
inline const Vector4f* OBJParser::GetPositions() const
|
||||||
{
|
{
|
||||||
return m_positions.data();
|
return m_positions.data();
|
||||||
|
|
@ -53,6 +82,11 @@ namespace Nz
|
||||||
return m_positions.size();
|
return m_positions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Vector3f* OBJParser::GetTexCoords()
|
||||||
|
{
|
||||||
|
return m_texCoords.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline const Vector3f* OBJParser::GetTexCoords() const
|
inline const Vector3f* OBJParser::GetTexCoords() const
|
||||||
{
|
{
|
||||||
return m_texCoords.data();
|
return m_texCoords.data();
|
||||||
|
|
@ -63,6 +97,36 @@ namespace Nz
|
||||||
return m_texCoords.size();
|
return m_texCoords.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline String* OBJParser::SetMaterialCount(std::size_t materialCount)
|
||||||
|
{
|
||||||
|
m_materials.resize(materialCount);
|
||||||
|
return m_materials.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount)
|
||||||
|
{
|
||||||
|
m_meshes.resize(meshCount);
|
||||||
|
return m_meshes.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount)
|
||||||
|
{
|
||||||
|
m_normals.resize(normalCount);
|
||||||
|
return m_normals.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount)
|
||||||
|
{
|
||||||
|
m_positions.resize(positionCount);
|
||||||
|
return m_positions.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount)
|
||||||
|
{
|
||||||
|
m_texCoords.resize(texCoordCount);
|
||||||
|
return m_texCoords.data();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void OBJParser::Emit(const T& text) const
|
void OBJParser::Emit(const T& text) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ namespace Nz
|
||||||
class NAZARA_UTILITY_API IndexMapper
|
class NAZARA_UTILITY_API IndexMapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite);
|
IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite, std::size_t indexCount = 0);
|
||||||
IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly);
|
IndexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite);
|
||||||
IndexMapper(const SubMesh* subMesh);
|
IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly, std::size_t indexCount = 0);
|
||||||
|
IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly);
|
||||||
~IndexMapper() = default;
|
~IndexMapper() = default;
|
||||||
|
|
||||||
UInt32 Get(unsigned int i) const;
|
UInt32 Get(unsigned int i) const;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
#include <Nazara/Core/ResourceManager.hpp>
|
#include <Nazara/Core/ResourceManager.hpp>
|
||||||
#include <Nazara/Core/ResourceParameters.hpp>
|
#include <Nazara/Core/ResourceParameters.hpp>
|
||||||
|
#include <Nazara/Core/ResourceSaver.hpp>
|
||||||
#include <Nazara/Core/Stream.hpp>
|
#include <Nazara/Core/Stream.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Math/Box.hpp>
|
#include <Nazara/Math/Box.hpp>
|
||||||
|
|
@ -61,6 +62,7 @@ namespace Nz
|
||||||
using MeshLoader = ResourceLoader<Mesh, MeshParams>;
|
using MeshLoader = ResourceLoader<Mesh, MeshParams>;
|
||||||
using MeshManager = ResourceManager<Mesh, MeshParams>;
|
using MeshManager = ResourceManager<Mesh, MeshParams>;
|
||||||
using MeshRef = ObjectRef<Mesh>;
|
using MeshRef = ObjectRef<Mesh>;
|
||||||
|
using MeshSaver = ResourceSaver<Mesh, MeshParams>;
|
||||||
|
|
||||||
struct MeshImpl;
|
struct MeshImpl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer);
|
TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer);
|
||||||
TriangleIterator(SubMesh* subMesh);
|
TriangleIterator(const SubMesh* subMesh);
|
||||||
~TriangleIterator() = default;
|
~TriangleIterator() = default;
|
||||||
|
|
||||||
bool Advance();
|
bool Advance();
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite);
|
VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite);
|
||||||
VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite);
|
VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite);
|
||||||
|
VertexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly);
|
||||||
|
VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly);
|
||||||
~VertexMapper();
|
~VertexMapper();
|
||||||
|
|
||||||
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component);
|
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component);
|
||||||
|
|
|
||||||
|
|
@ -298,12 +298,12 @@ namespace Nz
|
||||||
|
|
||||||
namespace Loaders
|
namespace Loaders
|
||||||
{
|
{
|
||||||
void RegisterOBJ()
|
void RegisterOBJLoader()
|
||||||
{
|
{
|
||||||
MeshLoader::RegisterLoader(IsSupported, Check, Load);
|
MeshLoader::RegisterLoader(IsSupported, Check, Load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterOBJ()
|
void UnregisterOBJLoader()
|
||||||
{
|
{
|
||||||
MeshLoader::UnregisterLoader(IsSupported, Check, Load);
|
MeshLoader::UnregisterLoader(IsSupported, Check, Load);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
namespace Loaders
|
namespace Loaders
|
||||||
{
|
{
|
||||||
void RegisterOBJ();
|
void RegisterOBJLoader();
|
||||||
void UnregisterOBJ();
|
void UnregisterOBJLoader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,9 +125,9 @@ namespace Nz
|
||||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
int& n = currentMesh->vertices[face.firstVertex + i].normal;
|
int n = 0;
|
||||||
int& p = currentMesh->vertices[face.firstVertex + i].position;
|
int p = 0;
|
||||||
int& t = currentMesh->vertices[face.firstVertex + i].texCoord;
|
int t = 0;
|
||||||
|
|
||||||
if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3)
|
if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3)
|
||||||
{
|
{
|
||||||
|
|
@ -199,6 +199,10 @@ namespace Nz
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentMesh->vertices[face.firstVertex + i].normal = static_cast<std::size_t>(n);
|
||||||
|
currentMesh->vertices[face.firstVertex + i].position = static_cast<std::size_t>(p);
|
||||||
|
currentMesh->vertices[face.firstVertex + i].texCoord = static_cast<std::size_t>(t);
|
||||||
|
|
||||||
pos += offset;
|
pos += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ namespace Nz
|
||||||
ImageType type = image.GetType();
|
ImageType type = image.GetType();
|
||||||
if (type != ImageType_1D && type != ImageType_2D)
|
if (type != ImageType_1D && type != ImageType_2D)
|
||||||
{
|
{
|
||||||
NazaraError("Image type 0x" + String::Number(type, 16) + " is not ");
|
NazaraError("Image type 0x" + String::Number(type, 16) + " is not in a supported format");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ namespace Nz
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
UInt32 GetterSequential(const void* buffer, unsigned int i)
|
||||||
|
{
|
||||||
|
NazaraUnused(buffer);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
UInt32 Getter16(const void* buffer, unsigned int i)
|
UInt32 Getter16(const void* buffer, unsigned int i)
|
||||||
{
|
{
|
||||||
const UInt16* ptr = static_cast<const UInt16*>(buffer);
|
const UInt16* ptr = static_cast<const UInt16*>(buffer);
|
||||||
|
|
@ -42,61 +49,67 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access) :
|
IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) :
|
||||||
m_indexCount(indexBuffer->GetIndexCount())
|
m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount())
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer");
|
||||||
if (!indexBuffer)
|
|
||||||
{
|
|
||||||
NazaraError("Index buffer must be valid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!m_mapper.Map(indexBuffer, access))
|
if (indexBuffer)
|
||||||
NazaraError("Failed to map buffer"); ///TODO: Unexcepted
|
|
||||||
|
|
||||||
if (indexBuffer->HasLargeIndices())
|
|
||||||
{
|
{
|
||||||
m_getter = Getter32;
|
if (!m_mapper.Map(indexBuffer, access))
|
||||||
if (access != BufferAccess_ReadOnly)
|
NazaraError("Failed to map buffer"); ///TODO: Unexcepted
|
||||||
m_setter = Setter32;
|
|
||||||
|
if (indexBuffer->HasLargeIndices())
|
||||||
|
{
|
||||||
|
m_getter = Getter32;
|
||||||
|
if (access != BufferAccess_ReadOnly)
|
||||||
|
m_setter = Setter32;
|
||||||
|
else
|
||||||
|
m_setter = SetterError;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_setter = SetterError;
|
{
|
||||||
|
m_getter = Getter16;
|
||||||
|
if (access != BufferAccess_ReadOnly)
|
||||||
|
m_setter = Setter16;
|
||||||
|
else
|
||||||
|
m_setter = SetterError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_getter = Getter16;
|
m_getter = GetterSequential;
|
||||||
if (access != BufferAccess_ReadOnly)
|
m_setter = SetterError;
|
||||||
m_setter = Setter16;
|
|
||||||
else
|
|
||||||
m_setter = SetterError;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access) :
|
IndexMapper::IndexMapper(SubMesh* subMesh, BufferAccess access) :
|
||||||
|
IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) :
|
||||||
m_setter(SetterError),
|
m_setter(SetterError),
|
||||||
m_indexCount(indexBuffer->GetIndexCount())
|
m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount())
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer");
|
||||||
if (!indexBuffer)
|
|
||||||
|
if (indexBuffer)
|
||||||
{
|
{
|
||||||
NazaraError("Index buffer must be valid");
|
if (!m_mapper.Map(indexBuffer, access))
|
||||||
return;
|
NazaraError("Failed to map buffer"); ///TODO: Unexcepted
|
||||||
|
|
||||||
|
if (indexBuffer->HasLargeIndices())
|
||||||
|
m_getter = Getter32;
|
||||||
|
else
|
||||||
|
m_getter = Getter16;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!m_mapper.Map(indexBuffer, access))
|
|
||||||
NazaraError("Failed to map buffer"); ///TODO: Unexcepted
|
|
||||||
|
|
||||||
if (indexBuffer->HasLargeIndices())
|
|
||||||
m_getter = Getter32;
|
|
||||||
else
|
else
|
||||||
m_getter = Getter16;
|
m_getter = GetterSequential;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexMapper::IndexMapper(const SubMesh* subMesh) :
|
IndexMapper::IndexMapper(const SubMesh* subMesh, BufferAccess access) :
|
||||||
IndexMapper(subMesh->GetIndexBuffer())
|
IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -697,4 +697,5 @@ namespace Nz
|
||||||
MeshLoader::LoaderList Mesh::s_loaders;
|
MeshLoader::LoaderList Mesh::s_loaders;
|
||||||
MeshManager::ManagerMap Mesh::s_managerMap;
|
MeshManager::ManagerMap Mesh::s_managerMap;
|
||||||
MeshManager::ManagerParams Mesh::s_managerParameters;
|
MeshManager::ManagerParams Mesh::s_managerParameters;
|
||||||
|
MeshSaver::SaverList Mesh::s_savers;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,19 @@ namespace Nz
|
||||||
m_triangleIndices[1] = m_indexMapper.Get(1);
|
m_triangleIndices[1] = m_indexMapper.Get(1);
|
||||||
m_triangleIndices[2] = m_indexMapper.Get(2);
|
m_triangleIndices[2] = m_indexMapper.Get(2);
|
||||||
|
|
||||||
m_indexCount = indexBuffer->GetIndexCount();
|
m_indexCount = m_indexMapper.GetIndexCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleIterator::TriangleIterator(SubMesh* subMesh) :
|
TriangleIterator::TriangleIterator(const SubMesh* subMesh) :
|
||||||
TriangleIterator(subMesh->GetPrimitiveMode(), subMesh->GetIndexBuffer())
|
m_primitiveMode(subMesh->GetPrimitiveMode()),
|
||||||
|
m_indexMapper(subMesh, BufferAccess_ReadOnly)
|
||||||
{
|
{
|
||||||
|
m_currentIndex = 3;
|
||||||
|
m_triangleIndices[0] = m_indexMapper.Get(0);
|
||||||
|
m_triangleIndices[1] = m_indexMapper.Get(1);
|
||||||
|
m_triangleIndices[2] = m_indexMapper.Get(2);
|
||||||
|
|
||||||
|
m_indexCount = m_indexMapper.GetIndexCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TriangleIterator::Advance()
|
bool TriangleIterator::Advance()
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Nz
|
||||||
Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10)
|
Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10)
|
||||||
|
|
||||||
// Mesh (text)
|
// Mesh (text)
|
||||||
Loaders::RegisterOBJ();
|
Loaders::RegisterOBJLoader();
|
||||||
|
|
||||||
// Mesh
|
// Mesh
|
||||||
Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8)
|
Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8)
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Nz
|
||||||
Loaders::UnregisterMD2();
|
Loaders::UnregisterMD2();
|
||||||
Loaders::UnregisterMD5Anim();
|
Loaders::UnregisterMD5Anim();
|
||||||
Loaders::UnregisterMD5Mesh();
|
Loaders::UnregisterMD5Mesh();
|
||||||
Loaders::UnregisterOBJ();
|
Loaders::UnregisterOBJLoader();
|
||||||
Loaders::UnregisterPCX();
|
Loaders::UnregisterPCX();
|
||||||
Loaders::UnregisterSTBLoader();
|
Loaders::UnregisterSTBLoader();
|
||||||
Loaders::UnregisterSTBSaver();
|
Loaders::UnregisterSTBSaver();
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,42 @@ namespace Nz
|
||||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||||
m_mapper.Map(vertexBuffer, access);
|
m_mapper.Map(vertexBuffer, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VertexMapper::VertexMapper(const SubMesh* subMesh, BufferAccess access)
|
||||||
|
{
|
||||||
|
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||||
|
|
||||||
|
const VertexBuffer* buffer = nullptr;
|
||||||
|
switch (subMesh->GetAnimationType())
|
||||||
|
{
|
||||||
|
case AnimationType_Skeletal:
|
||||||
|
{
|
||||||
|
const SkeletalMesh* skeletalMesh = static_cast<const SkeletalMesh*>(subMesh);
|
||||||
|
buffer = skeletalMesh->GetVertexBuffer();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case AnimationType_Static:
|
||||||
|
{
|
||||||
|
const StaticMesh* staticMesh = static_cast<const StaticMesh*>(subMesh);
|
||||||
|
buffer = staticMesh->GetVertexBuffer();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
NazaraInternalError("Animation type not handled (0x" + String::Number(subMesh->GetAnimationType(), 16) + ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mapper.Map(buffer, access);
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexMapper::VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access)
|
||||||
|
{
|
||||||
|
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||||
|
m_mapper.Map(vertexBuffer, access);
|
||||||
|
}
|
||||||
|
|
||||||
VertexMapper::~VertexMapper() = default;
|
VertexMapper::~VertexMapper() = default;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue