Merge branch 'master' into vulkan
Former-commit-id: 9f8a7fd431d09c2c656f0692c897a0a41a04f26e [formerly e007bba02b960164ab806d72f052044ccb7dec1c] Former-commit-id: b881a70547ff9cc63d3dbd2123d9de7951ae59a3
This commit is contained in:
@@ -44,8 +44,33 @@ namespace Nz
|
||||
T* m_object;
|
||||
};
|
||||
|
||||
template<typename T> struct PointedType<ObjectRef<T>> {typedef T type;};
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> {typedef T type;};
|
||||
template<typename T> bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator==(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator==(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator!=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator!=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<=(const ObjectRef<T>, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator>=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
|
||||
template<typename T> struct PointedType<ObjectRef<T>> { typedef T type; };
|
||||
template<typename T> struct PointedType<ObjectRef<T> const> { typedef T type; };
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ObjectRef.inl>
|
||||
|
||||
@@ -245,6 +245,241 @@ namespace Nz
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is equal to the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return lhs.Get() == rhs.Get();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object is equal to the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first Object to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return &lhs == rhs.Get();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object handle is equal to the second object
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second Object to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator==(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return lhs.Get() == &rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is equal to the second object handle
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object is equal to the second object handle
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first Object to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the object handle is equal to the second object
|
||||
* \return false if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second Object to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator!=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return lhs.m_object < rhs.m_object;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return &lhs < rhs.m_object;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return lhs.m_object < &rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator<=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const T& lhs, const ObjectRef<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||
* \return true if it is the case
|
||||
*
|
||||
* \param first ObjectRef to compare in left hand side
|
||||
* \param second ObjectRef to compare in right hand side
|
||||
*/
|
||||
template<typename T>
|
||||
bool operator>=(const ObjectRef<T>& lhs, const T& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
@@ -22,6 +22,10 @@ namespace Nz
|
||||
StringStream(const StringStream&) = default;
|
||||
StringStream(StringStream&&) noexcept = default;
|
||||
|
||||
void Clear();
|
||||
|
||||
std::size_t GetBufferSize() const;
|
||||
|
||||
String ToString() const;
|
||||
|
||||
StringStream& operator=(const StringStream&) = default;
|
||||
|
||||
@@ -55,14 +55,27 @@ namespace Nz
|
||||
struct InstanceData
|
||||
{
|
||||
InstanceData(Matrix4f& referenceMatrix) :
|
||||
transformMatrix(referenceMatrix),
|
||||
transformMatrix(&referenceMatrix),
|
||||
flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
InstanceData(InstanceData&& instanceData) noexcept = default;
|
||||
|
||||
InstanceData& operator=(InstanceData&& instanceData) noexcept
|
||||
{
|
||||
data = std::move(instanceData.data);
|
||||
flags = instanceData.flags;
|
||||
renderOrder = instanceData.renderOrder;
|
||||
transformMatrix = instanceData.transformMatrix;
|
||||
volume = instanceData.volume;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::vector<UInt8> data;
|
||||
BoundingVolumef volume;
|
||||
Matrix4f& transformMatrix;
|
||||
Matrix4f* transformMatrix;
|
||||
UInt32 flags;
|
||||
int renderOrder;
|
||||
};
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace Nz
|
||||
|
||||
void Reset();
|
||||
|
||||
void SaveToParameters(ParameterList* matData);
|
||||
|
||||
inline bool SetAlphaMap(const String& textureName);
|
||||
inline void SetAlphaMap(TextureRef alphaMap);
|
||||
inline void SetAlphaThreshold(float alphaThreshold);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Nz
|
||||
explicit Vector4(T scale);
|
||||
Vector4(const T vec[4]);
|
||||
Vector4(const Vector2<T>& vec, T Z = 0.0, T W = 1.0);
|
||||
Vector4(const Vector3<T>& vec, T W = 0.0);
|
||||
Vector4(const Vector3<T>& vec, T W = 1.0);
|
||||
template<typename U> explicit Vector4(const Vector4<U>& vec);
|
||||
Vector4(const Vector4& vec) = default;
|
||||
~Vector4() = default;
|
||||
|
||||
@@ -65,12 +65,11 @@ namespace Nz
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
void EnsureTargetUpdated() const override;
|
||||
|
||||
private:
|
||||
bool OnWindowCreated() override;
|
||||
void OnWindowDestroy() override;
|
||||
void OnWindowResized() override;
|
||||
|
||||
private:
|
||||
mutable std::vector<UInt8> m_buffer;
|
||||
Clock m_clock;
|
||||
ContextParameters m_parameters;
|
||||
|
||||
@@ -29,51 +29,61 @@ namespace Nz
|
||||
|
||||
struct Face
|
||||
{
|
||||
std::vector<FaceVertex> vertices;
|
||||
std::size_t firstVertex;
|
||||
std::size_t vertexCount;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
std::vector<Face> faces;
|
||||
std::vector<FaceVertex> vertices;
|
||||
String name;
|
||||
unsigned int material;
|
||||
std::size_t material;
|
||||
};
|
||||
|
||||
OBJParser(Stream& stream$);
|
||||
~OBJParser();
|
||||
OBJParser() = default;
|
||||
~OBJParser() = default;
|
||||
|
||||
const String* GetMaterials() const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
const Mesh* GetMeshes() const;
|
||||
unsigned int GetMeshCount() const;
|
||||
const String& GetMtlLib() const;
|
||||
const Vector3f* GetNormals() const;
|
||||
unsigned int GetNormalCount() const;
|
||||
const Vector4f* GetPositions() const;
|
||||
unsigned int GetPositionCount() const;
|
||||
const Vector3f* GetTexCoords() const;
|
||||
unsigned int GetTexCoordCount() const;
|
||||
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(std::size_t reservedVertexCount = 100);
|
||||
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
|
||||
|
||||
bool Save(Stream& stream) const;
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
void Error(const String& message);
|
||||
void Warning(const String& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
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 Flush() const;
|
||||
inline void Warning(const String& message);
|
||||
inline void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::vector<Mesh> m_meshes;
|
||||
std::vector<String> m_materials;
|
||||
std::vector<Vector3f> m_normals;
|
||||
std::vector<Vector4f> m_positions;
|
||||
std::vector<Vector3f> m_texCoords;
|
||||
Stream& m_stream;
|
||||
mutable Stream* m_currentStream;
|
||||
String m_currentLine;
|
||||
String m_mtlLib;
|
||||
mutable StringStream m_outputStream;
|
||||
bool m_keepLastLine;
|
||||
unsigned int m_lineCount;
|
||||
unsigned int m_streamFlags;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Formats/OBJParser.inl>
|
||||
|
||||
#endif // NAZARA_FORMATS_OBJPARSER_HPP
|
||||
|
||||
113
include/Nazara/Utility/Formats/OBJParser.inl
Normal file
113
include/Nazara/Utility/Formats/OBJParser.inl
Normal file
@@ -0,0 +1,113 @@
|
||||
// Copyright (C) 2016 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/Formats/OBJParser.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const String* OBJParser::GetMaterials() const
|
||||
{
|
||||
return m_materials.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetMaterialCount() const
|
||||
{
|
||||
return m_materials.size();
|
||||
}
|
||||
|
||||
inline const OBJParser::Mesh* OBJParser::GetMeshes() const
|
||||
{
|
||||
return m_meshes.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetMeshCount() const
|
||||
{
|
||||
return m_meshes.size();
|
||||
}
|
||||
|
||||
inline const String& OBJParser::GetMtlLib() const
|
||||
{
|
||||
return m_mtlLib;
|
||||
}
|
||||
|
||||
inline const Vector3f* OBJParser::GetNormals() const
|
||||
{
|
||||
return m_normals.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetNormalCount() const
|
||||
{
|
||||
return m_normals.size();
|
||||
}
|
||||
|
||||
inline const Vector4f* OBJParser::GetPositions() const
|
||||
{
|
||||
return m_positions.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetPositionCount() const
|
||||
{
|
||||
return m_positions.size();
|
||||
}
|
||||
|
||||
inline const Vector3f* OBJParser::GetTexCoords() const
|
||||
{
|
||||
return m_texCoords.data();
|
||||
}
|
||||
|
||||
inline unsigned int OBJParser::GetTexCoordCount() const
|
||||
{
|
||||
return m_texCoords.size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void OBJParser::Emit(const T& text) const
|
||||
{
|
||||
m_outputStream << text;
|
||||
if (m_outputStream.GetBufferSize() > 1024 * 1024)
|
||||
Flush();
|
||||
}
|
||||
|
||||
inline void OBJParser::EmitLine() const
|
||||
{
|
||||
Emit('\n');
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void OBJParser::EmitLine(const T& line) const
|
||||
{
|
||||
Emit(line);
|
||||
Emit('\n');
|
||||
}
|
||||
|
||||
inline void OBJParser::Error(const String& message)
|
||||
{
|
||||
NazaraError(message + " at line #" + String::Number(m_lineCount));
|
||||
}
|
||||
|
||||
inline void OBJParser::Flush() const
|
||||
{
|
||||
m_currentStream->Write(m_outputStream);
|
||||
m_outputStream.Clear();
|
||||
}
|
||||
|
||||
inline void OBJParser::Warning(const String& message)
|
||||
{
|
||||
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
|
||||
}
|
||||
|
||||
inline void OBJParser::UnrecognizedLine(bool error)
|
||||
{
|
||||
String message = "Unrecognized \"" + m_currentLine + '"';
|
||||
|
||||
if (error)
|
||||
Error(message);
|
||||
else
|
||||
Warning(message);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -22,6 +22,7 @@ namespace Nz
|
||||
static constexpr const char* BackFaceStencilReference = "MatBackFaceStencilReference";
|
||||
static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail";
|
||||
static constexpr const char* Blending = "MatBlending";
|
||||
static constexpr const char* CullingSide = "MatCullingSide";
|
||||
static constexpr const char* CustomDefined = "MatCustomDefined";
|
||||
static constexpr const char* ColorWrite = "MatColorWrite";
|
||||
static constexpr const char* DepthBuffer = "MatDepthBuffer";
|
||||
|
||||
Reference in New Issue
Block a user