Merge branch 'nazara-next' into vulkan

This commit is contained in:
Lynix
2020-02-25 19:15:07 +01:00
448 changed files with 2739 additions and 15884 deletions

View File

@@ -26,9 +26,9 @@ namespace Nz
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
{
// La frame de fin à charger
UInt32 endFrame = 0xFFFFFFFF;
std::size_t endFrame = 0xFFFFFFFF;
// La frame de début à charger
UInt32 startFrame = 0;
std::size_t startFrame = 0;
bool IsValid() const;
};
@@ -58,37 +58,37 @@ namespace Nz
~Animation();
bool AddSequence(const Sequence& sequence);
void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const;
void AnimateSkeleton(Skeleton* targetSkeleton, std::size_t frameA, std::size_t frameB, float interpolation) const;
bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount);
bool CreateSkeletal(std::size_t frameCount, std::size_t jointCount);
void Destroy();
void EnableLoopPointInterpolation(bool loopPointInterpolation);
UInt32 GetFrameCount() const;
UInt32 GetJointCount() const;
std::size_t GetFrameCount() const;
std::size_t GetJointCount() const;
Sequence* GetSequence(const String& sequenceName);
Sequence* GetSequence(UInt32 index);
Sequence* GetSequence(std::size_t index);
const Sequence* GetSequence(const String& sequenceName) const;
const Sequence* GetSequence(UInt32 index) const;
UInt32 GetSequenceCount() const;
UInt32 GetSequenceIndex(const String& sequenceName) const;
SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0);
const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const;
const Sequence* GetSequence(std::size_t index) const;
std::size_t GetSequenceCount() const;
std::size_t GetSequenceIndex(const String& sequenceName) const;
SequenceJoint* GetSequenceJoints(std::size_t frameIndex = 0);
const SequenceJoint* GetSequenceJoints(std::size_t frameIndex = 0) const;
AnimationType GetType() const;
bool HasSequence(const String& sequenceName) const;
bool HasSequence(UInt32 index = 0) const;
bool HasSequence(std::size_t index = 0) const;
bool IsLoopPointInterpolationEnabled() const;
bool IsValid() const;
void RemoveSequence(const String& sequenceName);
void RemoveSequence(UInt32 index);
void RemoveSequence(std::size_t index);
template<typename... Args> static AnimationRef New(Args&&... args);
static AnimationRef LoadFromFile(const String& filePath, const AnimationParams& params = AnimationParams());
static AnimationRef LoadFromFile(const std::filesystem::path& filePath, const AnimationParams& params = AnimationParams());
static AnimationRef LoadFromMemory(const void* data, std::size_t size, const AnimationParams& params = AnimationParams());
static AnimationRef LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams());

View File

@@ -89,7 +89,7 @@ namespace Nz
static unsigned int GetDefaultGlyphBorder();
static unsigned int GetDefaultMinimumStepSize();
static FontRef OpenFromFile(const String& filePath, const FontParams& params = FontParams());
static FontRef OpenFromFile(const std::filesystem::path& filePath, const FontParams& params = FontParams());
static FontRef OpenFromMemory(const void* data, std::size_t size, const FontParams& params = FontParams());
static FontRef OpenFromStream(Stream& stream, const FontParams& params = FontParams());

View File

@@ -49,7 +49,7 @@ namespace Nz
std::vector<Triangle> triangles;
std::vector<Vertex> vertices;
std::vector<Weight> weights;
String shader;
std::string shader;
};
MD5MeshParser(Stream& stream);
@@ -66,17 +66,17 @@ namespace Nz
private:
bool Advance(bool required = true);
void Error(const String& message);
void Error(const std::string& message);
bool ParseJoints();
bool ParseMesh();
void Warning(const String& message);
void Warning(const std::string& message);
void UnrecognizedLine(bool error = false);
std::vector<Joint> m_joints;
std::vector<Mesh> m_meshes;
Stream& m_stream;
StreamOptionFlags m_streamFlags;
String m_currentLine;
std::string m_currentLine;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_meshIndex;

View File

@@ -9,7 +9,6 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/Config.hpp>
#include <unordered_map>
@@ -23,12 +22,12 @@ namespace Nz
MTLParser() = default;
~MTLParser() = default;
inline Material* AddMaterial(const String& matName);
inline Material* AddMaterial(const std::string& matName);
inline void Clear();
inline const Material* GetMaterial(const String& materialName) const;
inline const std::unordered_map<String, Material>& GetMaterials() const;
inline const Material* GetMaterial(const std::string& materialName) const;
inline const std::unordered_map<std::string, Material>& GetMaterials() const;
bool Parse(Stream& stream);
@@ -39,17 +38,17 @@ namespace Nz
Color ambient = Color::White;
Color diffuse = Color::White;
Color specular = Color::White;
String alphaMap;
String ambientMap;
String bumpMap;
String decalMap;
String diffuseMap;
String displacementMap;
String emissiveMap; //< <!> Custom addition: not present in MTL
String normalMap; //< <!> Custom addition: not present in MTL
String reflectionMap;
String shininessMap;
String specularMap;
std::string alphaMap;
std::string ambientMap;
std::string bumpMap;
std::string decalMap;
std::string diffuseMap;
std::string displacementMap;
std::string emissiveMap; //< <!> Custom addition: not present in MTL
std::string normalMap; //< <!> Custom addition: not present in MTL
std::string reflectionMap;
std::string shininessMap;
std::string specularMap;
float alpha = 1.f;
float refractionIndex = 1.f;
float shininess = 1.f;
@@ -61,14 +60,14 @@ namespace Nz
template<typename T> void Emit(const T& text) const;
inline void EmitLine() const;
template<typename T> void EmitLine(const T& line) const;
inline void Error(const String& message);
inline void Error(const std::string& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void Warning(const std::string& message);
inline void UnrecognizedLine(bool error = false);
std::unordered_map<String, Material> m_materials;
std::unordered_map<std::string, Material> m_materials;
mutable Stream* m_currentStream;
String m_currentLine;
std::string m_currentLine;
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;

View File

@@ -7,7 +7,7 @@
namespace Nz
{
inline MTLParser::Material* MTLParser::AddMaterial(const String& matName)
inline MTLParser::Material* MTLParser::AddMaterial(const std::string& matName)
{
return &m_materials[matName];
}
@@ -17,7 +17,7 @@ namespace Nz
m_materials.clear();
}
inline const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const
inline const MTLParser::Material* MTLParser::GetMaterial(const std::string& materialName) const
{
auto it = m_materials.find(materialName);
if (it != m_materials.end())
@@ -26,7 +26,7 @@ namespace Nz
return nullptr;
}
inline const std::unordered_map<String, MTLParser::Material>& MTLParser::GetMaterials() const
inline const std::unordered_map<std::string, MTLParser::Material>& MTLParser::GetMaterials() const
{
return m_materials;
}
@@ -51,9 +51,9 @@ namespace Nz
Emit('\n');
}
inline void MTLParser::Error(const String& message)
inline void MTLParser::Error(const std::string& message)
{
NazaraError(message + " at line #" + String::Number(m_lineCount));
NazaraError(message + " at line #" + std::to_string(m_lineCount));
}
inline void MTLParser::Flush() const
@@ -62,14 +62,14 @@ namespace Nz
m_outputStream.Clear();
}
inline void MTLParser::Warning(const String& message)
inline void MTLParser::Warning(const std::string& message)
{
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
NazaraWarning(message + " at line #" + std::to_string(m_lineCount));
}
inline void MTLParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "Unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);

View File

@@ -8,7 +8,6 @@
#define NAZARA_FORMATS_OBJPARSER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Math/Vector4.hpp>
#include <Nazara/Utility/Config.hpp>
@@ -28,53 +27,53 @@ namespace Nz
bool Check(Stream& stream);
inline String* GetMaterials();
inline const String* GetMaterials() const;
inline UInt32 GetMaterialCount() const;
inline std::string* GetMaterials();
inline const std::string* GetMaterials() const;
inline std::size_t GetMaterialCount() const;
inline Mesh* GetMeshes();
inline const Mesh* GetMeshes() const;
inline UInt32 GetMeshCount() const;
inline const String& GetMtlLib() const;
inline std::size_t GetMeshCount() const;
inline const std::filesystem::path& GetMtlLib() const;
inline Vector3f* GetNormals();
inline const Vector3f* GetNormals() const;
inline UInt32 GetNormalCount() const;
inline std::size_t GetNormalCount() const;
inline Vector4f* GetPositions();
inline const Vector4f* GetPositions() const;
inline UInt32 GetPositionCount() const;
inline std::size_t GetPositionCount() const;
inline Vector3f* GetTexCoords();
inline const Vector3f* GetTexCoords() const;
inline UInt32 GetTexCoordCount() const;
inline std::size_t GetTexCoordCount() const;
bool Parse(Stream& stream, UInt32 reservedVertexCount = 100);
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
bool Save(Stream& stream) const;
inline String* SetMaterialCount(UInt32 materialCount);
inline Mesh* SetMeshCount(UInt32 meshCount);
inline void SetMtlLib(const String& mtlLib);
inline Vector3f* SetNormalCount(UInt32 normalCount);
inline Vector4f* SetPositionCount(UInt32 positionCount);
inline Vector3f* SetTexCoordCount(UInt32 texCoordCount);
inline std::string* SetMaterialCount(std::size_t materialCount);
inline Mesh* SetMeshCount(std::size_t meshCount);
inline void SetMtlLib(const std::filesystem::path& mtlLib);
inline Vector3f* SetNormalCount(std::size_t normalCount);
inline Vector4f* SetPositionCount(std::size_t positionCount);
inline Vector3f* SetTexCoordCount(std::size_t texCoordCount);
struct Face
{
UInt32 firstVertex;
UInt32 vertexCount;
std::size_t firstVertex;
std::size_t vertexCount;
};
struct FaceVertex
{
UInt32 normal;
UInt32 position;
UInt32 texCoord;
std::size_t normal;
std::size_t position;
std::size_t texCoord;
};
struct Mesh
{
std::vector<Face> faces;
std::vector<FaceVertex> vertices;
String name;
UInt32 material;
std::string name;
std::size_t material;
};
private:
@@ -82,19 +81,19 @@ namespace Nz
template<typename T> void Emit(const T& text) const;
inline void EmitLine() const;
template<typename T> void EmitLine(const T& line) const;
inline void Error(const String& message);
inline void Error(const std::string& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void Warning(const std::string& message);
inline bool UnrecognizedLine(bool error = false);
std::vector<Mesh> m_meshes;
std::vector<String> m_materials;
std::vector<std::string> m_materials;
std::vector<Vector3f> m_normals;
std::vector<Vector4f> m_positions;
std::vector<Vector3f> m_texCoords;
mutable Stream* m_currentStream;
String m_currentLine;
String m_mtlLib;
std::string m_currentLine;
std::filesystem::path m_mtlLib;
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;

View File

@@ -16,19 +16,19 @@ namespace Nz
m_texCoords.clear();
}
inline String* OBJParser::GetMaterials()
inline std::string* OBJParser::GetMaterials()
{
return m_materials.data();
}
inline const String* OBJParser::GetMaterials() const
inline const std::string* OBJParser::GetMaterials() const
{
return m_materials.data();
}
inline UInt32 OBJParser::GetMaterialCount() const
inline std::size_t OBJParser::GetMaterialCount() const
{
return static_cast<UInt32>(m_materials.size());
return m_materials.size();
}
inline OBJParser::Mesh* OBJParser::GetMeshes()
@@ -41,12 +41,12 @@ namespace Nz
return m_meshes.data();
}
inline UInt32 OBJParser::GetMeshCount() const
inline std::size_t OBJParser::GetMeshCount() const
{
return static_cast<UInt32>(m_meshes.size());
return m_meshes.size();
}
inline const String& OBJParser::GetMtlLib() const
inline const std::filesystem::path& OBJParser::GetMtlLib() const
{
return m_mtlLib;
}
@@ -61,9 +61,9 @@ namespace Nz
return m_normals.data();
}
inline UInt32 OBJParser::GetNormalCount() const
inline std::size_t OBJParser::GetNormalCount() const
{
return static_cast<UInt32>(m_normals.size());
return m_normals.size();
}
inline Vector4f* OBJParser::GetPositions()
@@ -76,9 +76,9 @@ namespace Nz
return m_positions.data();
}
inline UInt32 OBJParser::GetPositionCount() const
inline std::size_t OBJParser::GetPositionCount() const
{
return static_cast<UInt32>(m_positions.size());
return m_positions.size();
}
inline Vector3f* OBJParser::GetTexCoords()
@@ -91,41 +91,41 @@ namespace Nz
return m_texCoords.data();
}
inline UInt32 OBJParser::GetTexCoordCount() const
inline std::size_t OBJParser::GetTexCoordCount() const
{
return static_cast<UInt32>(m_texCoords.size());
return m_texCoords.size();
}
inline String* OBJParser::SetMaterialCount(UInt32 materialCount)
inline std::string* OBJParser::SetMaterialCount(std::size_t materialCount)
{
m_materials.resize(materialCount);
return m_materials.data();
}
inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount)
inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount)
{
m_meshes.resize(meshCount);
return m_meshes.data();
}
inline void OBJParser::SetMtlLib(const String& mtlLib)
inline void OBJParser::SetMtlLib(const std::filesystem::path& mtlLib)
{
m_mtlLib = mtlLib;
}
inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount)
inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount)
{
m_normals.resize(normalCount);
return m_normals.data();
}
inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount)
inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount)
{
m_positions.resize(positionCount);
return m_positions.data();
}
inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount)
inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount)
{
m_texCoords.resize(texCoordCount);
return m_texCoords.data();
@@ -151,9 +151,9 @@ namespace Nz
Emit('\n');
}
inline void OBJParser::Error(const String& message)
inline void OBJParser::Error(const std::string& message)
{
NazaraError(message + " at line #" + String::Number(m_lineCount));
NazaraError(message + " at line #" + std::to_string(m_lineCount));
}
inline void OBJParser::Flush() const
@@ -162,14 +162,14 @@ namespace Nz
m_outputStream.Clear();
}
inline void OBJParser::Warning(const String& message)
inline void OBJParser::Warning(const std::string& message)
{
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
NazaraWarning(message + " at line #" + std::to_string(m_lineCount));
}
inline bool OBJParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "Unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);

View File

@@ -94,13 +94,13 @@ namespace Nz
bool IsValid() const;
// LoadFace
bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams());
bool LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params = ImageParams());
bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
// Save
bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams());
bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
bool SaveToFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams());
bool SaveToStream(Stream& stream, const std::string& format, const ImageParams& params = ImageParams());
//TODO: SaveArray, SaveCubemap, SaveFace
@@ -118,18 +118,18 @@ namespace Nz
static UInt8 GetMaxLevel(ImageType type, unsigned int width, unsigned int height, unsigned int depth = 1);
// Load
static ImageRef LoadFromFile(const String& filePath, const ImageParams& params = ImageParams());
static ImageRef LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams());
static ImageRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams());
static ImageRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams());
// LoadArray
static ImageRef LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
static ImageRef LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
static ImageRef LoadArrayFromImage(const Image* image, const Vector2ui& atlasSize = Vector2ui(2, 2));
static ImageRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
static ImageRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2));
// LoadCubemap
static ImageRef LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
static ImageRef LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
static ImageRef LoadCubemapFromImage(const Image* image, const CubemapParams& params = CubemapParams());
static ImageRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
static ImageRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());

View File

@@ -24,38 +24,38 @@ namespace Nz
public:
IndexBuffer() = default;
IndexBuffer(bool largeIndices, BufferRef buffer);
IndexBuffer(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size);
IndexBuffer(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage);
IndexBuffer(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size);
IndexBuffer(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage);
IndexBuffer(const IndexBuffer& indexBuffer);
IndexBuffer(IndexBuffer&&) = delete;
~IndexBuffer();
unsigned int ComputeCacheMissCount() const;
bool Fill(const void* data, UInt32 startIndex, UInt32 length);
bool FillRaw(const void* data, UInt32 offset, UInt32 size);
bool Fill(const void* data, std::size_t startIndex, std::size_t length);
bool FillRaw(const void* data, std::size_t offset, std::size_t size);
inline const BufferRef& GetBuffer() const;
inline UInt32 GetEndOffset() const;
inline UInt32 GetIndexCount() const;
inline UInt32 GetStride() const;
inline UInt32 GetStartOffset() const;
inline std::size_t GetEndOffset() const;
inline std::size_t GetIndexCount() const;
inline std::size_t GetStride() const;
inline std::size_t GetStartOffset() const;
inline bool HasLargeIndices() const;
inline bool IsValid() const;
inline void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0);
inline void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0) const;
void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0);
void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const;
inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0);
inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const;
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0);
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const;
void Optimize();
void Reset();
void Reset(bool largeIndices, BufferRef buffer);
void Reset(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size);
void Reset(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage);
void Reset(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size);
void Reset(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage);
void Reset(const IndexBuffer& indexBuffer);
void Unmap() const;
@@ -70,9 +70,9 @@ namespace Nz
private:
BufferRef m_buffer;
UInt32 m_endOffset;
UInt32 m_indexCount;
UInt32 m_startOffset;
std::size_t m_endOffset;
std::size_t m_indexCount;
std::size_t m_startOffset;
bool m_largeIndices;
};
}

View File

@@ -12,22 +12,22 @@ namespace Nz
return m_buffer;
}
inline UInt32 IndexBuffer::GetEndOffset() const
inline std::size_t IndexBuffer::GetEndOffset() const
{
return m_endOffset;
}
inline UInt32 IndexBuffer::GetIndexCount() const
inline std::size_t IndexBuffer::GetIndexCount() const
{
return m_indexCount;
}
inline UInt32 IndexBuffer::GetStride() const
inline std::size_t IndexBuffer::GetStride() const
{
return static_cast<UInt32>((m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16));
return static_cast<std::size_t>((m_largeIndices) ? sizeof(std::size_t) : sizeof(UInt16));
}
inline UInt32 IndexBuffer::GetStartOffset() const
inline std::size_t IndexBuffer::GetStartOffset() const
{
return m_startOffset;
}
@@ -42,15 +42,15 @@ namespace Nz
return m_buffer.IsValid();
}
inline void* IndexBuffer::Map(BufferAccess access, UInt32 startIndex, UInt32 length)
inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length)
{
UInt32 stride = GetStride();
std::size_t stride = GetStride();
return MapRaw(access, startIndex*stride, length*stride);
}
inline void* IndexBuffer::Map(BufferAccess access, UInt32 startIndex, UInt32 length) const
inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length) const
{
UInt32 stride = GetStride();
std::size_t stride = GetStride();
return MapRaw(access, startIndex*stride, length*stride);
}

View File

@@ -89,12 +89,12 @@ namespace Nz
inline ~Mesh();
void AddSubMesh(SubMesh* subMesh);
void AddSubMesh(const String& identifier, SubMesh* subMesh);
void AddSubMesh(const std::string& identifier, SubMesh* subMesh);
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
bool CreateSkeletal(UInt32 jointCount);
bool CreateSkeletal(std::size_t jointCount);
bool CreateStatic();
void Destroy();
@@ -103,25 +103,25 @@ namespace Nz
void GenerateTangents();
const Boxf& GetAABB() const;
String GetAnimation() const;
std::filesystem::path GetAnimation() const;
AnimationType GetAnimationType() const;
UInt32 GetJointCount() const;
ParameterList& GetMaterialData(UInt32 index);
const ParameterList& GetMaterialData(UInt32 index) const;
UInt32 GetMaterialCount() const;
std::size_t GetJointCount() const;
ParameterList& GetMaterialData(std::size_t index);
const ParameterList& GetMaterialData(std::size_t index) const;
std::size_t GetMaterialCount() const;
Skeleton* GetSkeleton();
const Skeleton* GetSkeleton() const;
SubMesh* GetSubMesh(const String& identifier);
SubMesh* GetSubMesh(UInt32 index);
const SubMesh* GetSubMesh(const String& identifier) const;
const SubMesh* GetSubMesh(UInt32 index) const;
UInt32 GetSubMeshCount() const;
UInt32 GetSubMeshIndex(const String& identifier) const;
UInt32 GetTriangleCount() const;
UInt32 GetVertexCount() const;
SubMesh* GetSubMesh(const std::string& identifier);
SubMesh* GetSubMesh(std::size_t index);
const SubMesh* GetSubMesh(const std::string& identifier) const;
const SubMesh* GetSubMesh(std::size_t index) const;
std::size_t GetSubMeshCount() const;
std::size_t GetSubMeshIndex(const std::string& identifier) const;
std::size_t GetTriangleCount() const;
std::size_t GetVertexCount() const;
bool HasSubMesh(const String& identifier) const;
bool HasSubMesh(UInt32 index = 0) const;
bool HasSubMesh(const std::string& identifier) const;
bool HasSubMesh(std::size_t index = 0) const;
void InvalidateAABB() const;
@@ -130,22 +130,22 @@ namespace Nz
void Recenter();
void RemoveSubMesh(const String& identifier);
void RemoveSubMesh(UInt32 index);
void RemoveSubMesh(const std::string& identifier);
void RemoveSubMesh(std::size_t index);
bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams());
bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams());
bool SaveToFile(const std::filesystem::path& filePath, const MeshParams& params = MeshParams());
bool SaveToStream(Stream& stream, const std::string& format, const MeshParams& params = MeshParams());
void SetAnimation(const String& animationPath);
void SetMaterialCount(UInt32 matCount);
void SetMaterialData(UInt32 matIndex, ParameterList data);
void SetAnimation(const std::filesystem::path& animationPath);
void SetMaterialCount(std::size_t matCount);
void SetMaterialData(std::size_t matIndex, ParameterList data);
void Transform(const Matrix4f& matrix);
Mesh& operator=(const Mesh&) = delete;
Mesh& operator=(Mesh&&) = delete;
static MeshRef LoadFromFile(const String& filePath, const MeshParams& params = MeshParams());
static MeshRef LoadFromFile(const std::filesystem::path& filePath, const MeshParams& params = MeshParams());
static MeshRef LoadFromMemory(const void* data, std::size_t size, const MeshParams& params = MeshParams());
static MeshRef LoadFromStream(Stream& stream, const MeshParams& params = MeshParams());
@@ -164,16 +164,16 @@ namespace Nz
NazaraSlot(SubMesh, OnSubMeshInvalidateAABB, onSubMeshInvalidated);
};
std::unordered_map<String, UInt32> m_subMeshMap;
std::unordered_map<std::string, std::size_t> 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;
std::filesystem::path m_animationPath;
mutable bool m_aabbUpdated;
bool m_isValid;
UInt32 m_jointCount; // Only used by skeletal meshes
std::size_t m_jointCount; // Only used by skeletal meshes
static bool Initialize();
static void Uninitialize();

View File

@@ -36,13 +36,13 @@ namespace Nz
void Destroy();
const Boxf& GetAABB() const override;
AnimationType GetAnimationType() const final override;
AnimationType GetAnimationType() const final;
const IndexBuffer* GetIndexBuffer() const override;
VertexBuffer* GetVertexBuffer();
const VertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
std::size_t GetVertexCount() const override;
bool IsAnimated() const final override;
bool IsAnimated() const final;
bool IsValid() const;
void SetAABB(const Boxf& aabb);

View File

@@ -37,21 +37,21 @@ namespace Nz
Skeleton(const Skeleton& skeleton);
~Skeleton();
bool Create(UInt32 jointCount);
bool Create(std::size_t jointCount);
void Destroy();
const Boxf& GetAABB() const;
Joint* GetJoint(const String& jointName);
Joint* GetJoint(UInt32 index);
Joint* GetJoint(std::size_t index);
const Joint* GetJoint(const String& jointName) const;
const Joint* GetJoint(UInt32 index) const;
const Joint* GetJoint(std::size_t index) const;
Joint* GetJoints();
const Joint* GetJoints() const;
UInt32 GetJointCount() const;
std::size_t GetJointCount() const;
int GetJointIndex(const String& jointName) const;
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation);
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount);
void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, std::size_t* indices, std::size_t indiceCount);
bool IsValid() const;

View File

@@ -37,13 +37,13 @@ namespace Nz
bool GenerateAABB();
const Boxf& GetAABB() const override;
AnimationType GetAnimationType() const final override;
AnimationType GetAnimationType() const final;
const IndexBuffer* GetIndexBuffer() const override;
VertexBuffer* GetVertexBuffer();
const VertexBuffer* GetVertexBuffer() const;
unsigned int GetVertexCount() const override;
std::size_t GetVertexCount() const override;
bool IsAnimated() const final override;
bool IsAnimated() const final;
bool IsValid() const;
void SetAABB(const Boxf& aabb);

View File

@@ -44,14 +44,14 @@ namespace Nz
virtual const Boxf& GetAABB() const = 0;
virtual AnimationType GetAnimationType() const = 0;
virtual const IndexBuffer* GetIndexBuffer() const = 0;
UInt32 GetMaterialIndex() const;
std::size_t GetMaterialIndex() const;
PrimitiveMode GetPrimitiveMode() const;
UInt32 GetTriangleCount() const;
virtual UInt32 GetVertexCount() const = 0;
std::size_t GetTriangleCount() const;
virtual std::size_t GetVertexCount() const = 0;
virtual bool IsAnimated() const = 0;
void SetMaterialIndex(UInt32 matIndex);
void SetMaterialIndex(std::size_t matIndex);
void SetPrimitiveMode(PrimitiveMode mode);
SubMesh& operator=(const SubMesh&) = delete;
@@ -63,7 +63,7 @@ namespace Nz
protected:
PrimitiveMode m_primitiveMode;
UInt32 m_matIndex;
std::size_t m_matIndex;
};
}

View File

@@ -26,33 +26,33 @@ namespace Nz
public:
VertexBuffer() = default;
VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer);
VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size);
VertexBuffer(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage);
VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size);
VertexBuffer(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage);
VertexBuffer(const VertexBuffer& vertexBuffer);
VertexBuffer(VertexBuffer&&) = delete;
~VertexBuffer();
bool Fill(const void* data, UInt32 startVertex, UInt32 length);
bool FillRaw(const void* data, UInt32 offset, UInt32 size);
bool Fill(const void* data, std::size_t startVertex, std::size_t length);
bool FillRaw(const void* data, std::size_t offset, std::size_t size);
inline const BufferRef& GetBuffer() const;
inline UInt32 GetEndOffset() const;
inline UInt32 GetStartOffset() const;
inline UInt32 GetStride() const;
inline UInt32 GetVertexCount() const;
inline std::size_t GetEndOffset() const;
inline std::size_t GetStartOffset() const;
inline std::size_t GetStride() const;
inline std::size_t GetVertexCount() const;
inline const VertexDeclarationConstRef& GetVertexDeclaration() const;
inline bool IsValid() const;
void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0);
void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0) const;
void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0);
void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const;
void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0);
void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const;
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0);
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const;
void Reset();
void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer);
void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size);
void Reset(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage);
void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size);
void Reset(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage);
void Reset(const VertexBuffer& vertexBuffer);
void SetVertexDeclaration(VertexDeclarationConstRef vertexDeclaration);
@@ -69,9 +69,9 @@ namespace Nz
private:
BufferRef m_buffer;
UInt32 m_endOffset;
UInt32 m_startOffset;
UInt32 m_vertexCount;
std::size_t m_endOffset;
std::size_t m_startOffset;
std::size_t m_vertexCount;
VertexDeclarationConstRef m_vertexDeclaration;
};
}

View File

@@ -12,22 +12,22 @@ namespace Nz
return m_buffer;
}
inline UInt32 VertexBuffer::GetEndOffset() const
inline std::size_t VertexBuffer::GetEndOffset() const
{
return m_endOffset;
}
inline UInt32 VertexBuffer::GetStride() const
inline std::size_t VertexBuffer::GetStride() const
{
return static_cast<UInt32>(m_vertexDeclaration->GetStride());
return static_cast<std::size_t>(m_vertexDeclaration->GetStride());
}
inline UInt32 VertexBuffer::GetStartOffset() const
inline std::size_t VertexBuffer::GetStartOffset() const
{
return m_startOffset;
}
inline UInt32 VertexBuffer::GetVertexCount() const
inline std::size_t VertexBuffer::GetVertexCount() const
{
return m_vertexCount;
}

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// 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
@@ -28,7 +28,7 @@ namespace Nz
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component);
inline const VertexBuffer* GetVertexBuffer() const;
inline UInt32 GetVertexCount() const;
inline std::size_t GetVertexCount() const;
template<typename T> bool HasComponentOfType(VertexComponent component) const;

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// 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
@@ -32,7 +32,7 @@ namespace Nz
return m_mapper.GetBuffer();
}
inline UInt32 VertexMapper::GetVertexCount() const
inline std::size_t VertexMapper::GetVertexCount() const
{
return GetVertexBuffer()->GetVertexCount();
}