Merge branch 'master' into vulkan

This commit is contained in:
Lynix
2017-08-20 21:35:51 +02:00
57 changed files with 904 additions and 197 deletions

View File

@@ -63,6 +63,7 @@ namespace Nz
enum HashType
{
HashType_CRC32,
HashType_CRC64,
HashType_Fletcher16,
HashType_MD5,
HashType_SHA1,

View File

@@ -0,0 +1,34 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_HASH_CRC64_HPP
#define NAZARA_HASH_CRC64_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/AbstractHash.hpp>
#include <Nazara/Core/ByteArray.hpp>
namespace Nz
{
class NAZARA_CORE_API HashCRC64 : public AbstractHash
{
public:
HashCRC64() = default;
~HashCRC64() = default;
void Append(const UInt8* data, std::size_t len) override;
void Begin() override;
ByteArray End() override;
std::size_t GetDigestLength() const override;
const char* GetHashName() const override;
private:
Nz::UInt64 m_crc;
};
}
#endif // NAZARA_HASH_CRC64_HPP

View File

@@ -788,16 +788,17 @@ namespace Nz
template<typename T>
std::enable_if_t<std::is_unsigned<T>::value, T> LuaState::CheckBounds(int index, long long value) const
{
unsigned long long uValue = static_cast<unsigned long long>(value);
constexpr unsigned long long minBounds = 0;
constexpr unsigned long long maxBounds = std::numeric_limits<T>::max();
if (value < minBounds || value > maxBounds)
if (uValue < minBounds || uValue > maxBounds)
{
Nz::StringStream stream;
stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')';
Error(stream);
}
return static_cast<T>(value);
return static_cast<T>(uValue);
}
inline LuaState LuaState::GetState(lua_State* internalState)

View File

@@ -32,6 +32,10 @@
#include <Nazara/Network/AbstractSocket.hpp>
#include <Nazara/Network/Algorithm.hpp>
#include <Nazara/Network/Config.hpp>
#include <Nazara/Network/ENetHost.hpp>
#include <Nazara/Network/ENetPacket.hpp>
#include <Nazara/Network/ENetPeer.hpp>
#include <Nazara/Network/ENetProtocol.hpp>
#include <Nazara/Network/Enums.hpp>
#include <Nazara/Network/IpAddress.hpp>
#include <Nazara/Network/NetBuffer.hpp>

View File

@@ -31,7 +31,7 @@ namespace Nz
bool RegisterSocket(AbstractSocket& socket, SocketPollEventFlags eventFlags);
void UnregisterSocket(AbstractSocket& socket);
bool Wait(UInt64 msTimeout);
bool Wait(int msTimeout);
inline SocketPoller& operator=(SocketPoller&& socketPoller);

View File

@@ -39,6 +39,7 @@ namespace Nz
std::size_t QueryMaxDatagramSize();
bool Receive(void* buffer, std::size_t size, IpAddress* from, std::size_t* received);
bool ReceiveMultiple(NetBuffer* buffers, std::size_t bufferCount, IpAddress* from, std::size_t* received);
bool ReceivePacket(NetPacket* packet, IpAddress* from);
bool Send(const IpAddress& to, const void* buffer, std::size_t size, std::size_t* sent);

View File

@@ -11,6 +11,7 @@
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Physics2D/Config.hpp>
@@ -33,6 +34,7 @@ namespace Nz
{
friend Collider2DLibrary;
friend RigidBody2D;
friend class CompoundCollider2D; //< See CompoundCollider2D::CreateShapes
public:
inline Collider2D();
@@ -40,7 +42,7 @@ namespace Nz
Collider2D(Collider2D&&) = delete;
virtual ~Collider2D();
virtual float ComputeInertialMatrix(float mass) const = 0;
virtual float ComputeMomentOfInertia(float mass) const = 0;
inline Nz::UInt32 GetCategoryMask() const;
inline Nz::UInt32 GetCollisionGroup() const;
@@ -64,7 +66,7 @@ namespace Nz
NazaraSignal(OnColliderRelease, const Collider2D* /*collider*/);
protected:
virtual std::vector<cpShape*> CreateShapes(RigidBody2D* body) const = 0;
virtual void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const = 0;
bool m_trigger;
Nz::UInt32 m_categoryMask;
@@ -89,7 +91,7 @@ namespace Nz
BoxCollider2D(const Vector2f& size, float radius = 0.f);
BoxCollider2D(const Rectf& rect, float radius = 0.f);
float ComputeInertialMatrix(float mass) const override;
float ComputeMomentOfInertia(float mass) const override;
inline const Rectf& GetRect() const;
inline Vector2f GetSize() const;
@@ -98,7 +100,7 @@ namespace Nz
template<typename... Args> static BoxCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
Rectf m_rect;
float m_radius;
@@ -114,7 +116,7 @@ namespace Nz
public:
CircleCollider2D(float radius, const Vector2f& offset = Vector2f::Zero());
float ComputeInertialMatrix(float mass) const override;
float ComputeMomentOfInertia(float mass) const override;
inline float GetRadius() const;
ColliderType2D GetType() const override;
@@ -122,12 +124,58 @@ namespace Nz
template<typename... Args> static CircleCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
Vector2f m_offset;
float m_radius;
};
class CompoundCollider2D;
using CompoundCollider2DConstRef = ObjectRef<const CompoundCollider2D>;
using CompoundCollider2DRef = ObjectRef<CompoundCollider2D>;
class NAZARA_PHYSICS2D_API CompoundCollider2D : public Collider2D
{
public:
CompoundCollider2D(std::vector<Collider2DRef> geoms);
float ComputeMomentOfInertia(float mass) const override;
inline const std::vector<Collider2DRef>& GetGeoms() const;
ColliderType2D GetType() const override;
template<typename... Args> static CompoundCollider2DRef New(Args&&... args);
private:
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
std::vector<Collider2DRef> m_geoms;
};
class ConvexCollider2D;
using ConvexCollider2DConstRef = ObjectRef<const ConvexCollider2D>;
using ConvexCollider2DRef = ObjectRef<ConvexCollider2D>;
class NAZARA_PHYSICS2D_API ConvexCollider2D : public Collider2D
{
public:
ConvexCollider2D(SparsePtr<const Vector2f> vertices, std::size_t vertexCount, float radius = 0.f);
float ComputeMomentOfInertia(float mass) const override;
ColliderType2D GetType() const override;
template<typename... Args> static ConvexCollider2DRef New(Args&&... args);
private:
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
std::vector<Vector2d> m_vertices;
float m_radius;
};
class NullCollider2D;
using NullCollider2DConstRef = ObjectRef<const NullCollider2D>;
@@ -138,14 +186,14 @@ namespace Nz
public:
NullCollider2D() = default;
float ComputeInertialMatrix(float mass) const override;
float ComputeMomentOfInertia(float mass) const override;
ColliderType2D GetType() const override;
template<typename... Args> static NullCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
};
class SegmentCollider2D;
@@ -158,7 +206,7 @@ namespace Nz
public:
inline SegmentCollider2D(const Vector2f& first, const Vector2f& second, float thickness = 1.f);
float ComputeInertialMatrix(float mass) const override;
float ComputeMomentOfInertia(float mass) const override;
inline const Vector2f& GetFirstPoint() const;
inline float GetLength() const;
@@ -168,7 +216,7 @@ namespace Nz
template<typename... Args> static SegmentCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
void CreateShapes(RigidBody2D* body, std::vector<cpShape*>& shapes) const override;
Vector2f m_first;
Vector2f m_second;

View File

@@ -100,6 +100,20 @@ namespace Nz
return object.release();
}
inline const std::vector<Collider2DRef>& Nz::CompoundCollider2D::GetGeoms() const
{
return m_geoms;
}
template<typename... Args>
CompoundCollider2DRef CompoundCollider2D::New(Args&&... args)
{
std::unique_ptr<CompoundCollider2D> object(new CompoundCollider2D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
NullCollider2DRef NullCollider2D::New(Args&&... args)
{

View File

@@ -12,6 +12,7 @@ namespace Nz
enum ColliderType2D
{
ColliderType2D_Box,
ColliderType2D_Compound,
ColliderType2D_Convex,
ColliderType2D_Circle,
ColliderType2D_Null,

View File

@@ -12,6 +12,7 @@
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Physics2D/Config.hpp>
#include <Nazara/Physics2D/RigidBody2D.hpp>
#include <functional>
#include <memory>
#include <unordered_map>
@@ -24,10 +25,10 @@ namespace Nz
{
friend RigidBody2D;
using ContactEndCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata);
using ContactPreSolveCallback = bool(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata);
using ContactPostSolveCallback = void(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata);
using ContactStartCallback = bool(*)(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata);
using ContactEndCallback = std::function<void(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
using ContactPreSolveCallback = std::function<bool(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
using ContactPostSolveCallback = std::function<void(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
using ContactStartCallback = std::function<bool(PhysWorld2D& world, RigidBody2D& bodyA, RigidBody2D& bodyB, void* userdata)>;
public:
struct Callback;

View File

@@ -48,6 +48,7 @@ namespace Nz
float GetRotation() const;
void* GetUserdata() const;
Vector2f GetVelocity() const;
PhysWorld2D* GetWorld() const;
bool IsMoveable() const;
bool IsSleeping() const;
@@ -56,6 +57,7 @@ namespace Nz
void SetGeom(Collider2DRef geom);
void SetMass(float mass);
void SetMassCenter(const Vector2f& center);
void SetMomentOfInertia(float moment);
void SetPosition(const Vector2f& position);
void SetRotation(float rotation);
void SetUserdata(void* ud);

View File

@@ -135,7 +135,7 @@ namespace Nz
class NAZARA_PHYSICS3D_API CompoundCollider3D : public Collider3D
{
public:
CompoundCollider3D(Collider3D** geoms, std::size_t geomCount);
CompoundCollider3D(std::vector<Collider3DRef> geoms);
const std::vector<Collider3DRef>& GetGeoms() const;
ColliderType3D GetType() const override;

View File

@@ -47,6 +47,7 @@ namespace Nz
Vector3f GetPosition() const;
Quaternionf GetRotation() const;
Vector3f GetVelocity() const;
PhysWorld3D* GetWorld() const;
bool IsAutoSleepEnabled() const;
bool IsMoveable() const;

View File

@@ -30,7 +30,7 @@
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// La taille du buffer d'Instancing (définit le nombre maximum d'instances en un rendu)
#define NAZARA_RENDERER_INSTANCE_BUFFER_SIZE 524288 // 8192 matrices 4x4 flottantes
#define NAZARA_RENDERER_INSTANCE_BUFFER_SIZE 1 * 1024 * 1024
// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
#define NAZARA_RENDERER_MANAGE_MEMORY 0

View File

@@ -24,7 +24,7 @@ namespace Nz
public:
inline RenderWindow();
inline RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
inline RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
inline explicit RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
inline bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());

View File

@@ -38,7 +38,7 @@ namespace Nz
public:
Window();
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
inline Window(WindowHandle handle);
inline explicit Window(WindowHandle handle);
Window(const Window&) = delete;
inline Window(Window&& window) noexcept;
virtual ~Window();