Merge remote-tracking branch 'refs/remotes/origin/master' into culling

This commit is contained in:
Lynix
2016-10-19 11:17:12 +02:00
151 changed files with 3726 additions and 1373 deletions

View File

@@ -21,7 +21,7 @@ namespace Nz
virtual void EnableStdReplication(bool enable) = 0;
virtual bool IsStdReplicationEnabled() = 0;
virtual bool IsStdReplicationEnabled() const = 0;
virtual void Write(const String& string) = 0;
virtual void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);

View File

@@ -123,9 +123,8 @@ namespace Nz
* \see CountOf
*/
template<typename T, std::size_t N>
constexpr std::size_t CountOf(T(&name)[N]) noexcept
constexpr std::size_t CountOf(T(&)[N]) noexcept
{
// NazaraUnused(name); //< Because "body of function is not a return-statement" >.>
return N;
}

View File

@@ -25,8 +25,8 @@ namespace Nz
void EnableTimeLogging(bool enable);
void EnableStdReplication(bool enable) override;
bool IsStdReplicationEnabled() override;
bool IsTimeLoggingEnabled();
bool IsStdReplicationEnabled() const override;
bool IsTimeLoggingEnabled() const;
void Write(const String& string) override;
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;

View File

@@ -71,6 +71,8 @@ namespace Nz
template<typename T>
HandledObject<T>& HandledObject<T>::operator=(const HandledObject& object)
{
NazaraUnused(object);
// Nothing to do
return *this;
}

View File

@@ -22,7 +22,7 @@ namespace Nz
void EnableStdReplication(bool enable) override;
bool IsStdReplicationEnabled() override;
bool IsStdReplicationEnabled() const override;
void Write(const String& string) override;
void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;

View File

@@ -78,7 +78,6 @@ namespace Nz
Color m_color;
MaterialRef m_material;
Recti m_localBounds;
mutable bool m_verticesUpdated;
float m_scale;
static TextSpriteLibrary::LibraryMap s_library;

View File

@@ -8,6 +8,7 @@
#define NAZARA_VECTOR2_HPP
#include <Nazara/Core/String.hpp>
#include <functional>
namespace Nz
{
@@ -119,6 +120,11 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vecto
template<typename T> Nz::Vector2<T> operator*(T scale, const Nz::Vector2<T>& vec);
template<typename T> Nz::Vector2<T> operator/(T scale, const Nz::Vector2<T>& vec);
namespace std
{
template<class T> struct hash<Nz::Vector2<T>>;
}
#include <Nazara/Math/Vector2.inl>
#endif // NAZARA_VECTOR2_HPP

View File

@@ -1057,6 +1057,29 @@ Nz::Vector2<T> operator/(T scale, const Nz::Vector2<T>& vec)
return Nz::Vector2<T>(scale / vec.x, scale / vec.y);
}
namespace std
{
template<class T>
struct hash<Nz::Vector2<T>>
{
/*!
* \brief Specialisation of std to hash
* \return Result of the hash
*
* \param v Vector2 to hash
*/
std::size_t operator()(const Nz::Vector2<T>& v) const
{
std::size_t seed {};
Nz::HashCombine(seed, v.x);
Nz::HashCombine(seed, v.y);
return seed;
}
};
}
#undef F
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -8,6 +8,7 @@
#define NAZARA_VECTOR3_HPP
#include <Nazara/Core/String.hpp>
#include <functional>
namespace Nz
{
@@ -141,6 +142,11 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vecto
template<typename T> Nz::Vector3<T> operator*(T scale, const Nz::Vector3<T>& vec);
template<typename T> Nz::Vector3<T> operator/(T scale, const Nz::Vector3<T>& vec);
namespace std
{
template<class T> struct hash<Nz::Vector3<T>>;
}
#include <Nazara/Math/Vector3.inl>
#endif // NAZARA_VECTOR3_HPP

View File

@@ -1347,6 +1347,31 @@ Nz::Vector3<T> operator/(T scale, const Nz::Vector3<T>& vec)
return Nz::Vector3<T>(scale / vec.x, scale / vec.y, scale / vec.z);
}
namespace std
{
template<class T>
struct hash<Nz::Vector3<T>>
{
/*!
* \brief Specialisation of std to hash
* \return Result of the hash
*
* \param v Vector3 to hash
*/
std::size_t operator()(const Nz::Vector3<T>& v) const
{
std::size_t seed {};
Nz::HashCombine(seed, v.x);
Nz::HashCombine(seed, v.y);
Nz::HashCombine(seed, v.z);
return seed;
}
};
}
#undef F
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -8,6 +8,7 @@
#define NAZARA_VECTOR4_HPP
#include <Nazara/Core/String.hpp>
#include <functional>
namespace Nz
{
@@ -117,6 +118,11 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vecto
template<typename T> Nz::Vector4<T> operator*(T scale, const Nz::Vector4<T>& vec);
template<typename T> Nz::Vector4<T> operator/(T scale, const Nz::Vector4<T>& vec);
namespace std
{
template<class T> struct hash<Nz::Vector4<T>>;
}
#include <Nazara/Math/Vector4.inl>
#endif // NAZARA_VECTOR4_HPP

View File

@@ -1120,6 +1120,31 @@ Nz::Vector4<T> operator/(T scale, const Nz::Vector4<T>& vec)
return Nz::Vector4<T>(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w);
}
namespace std
{
template<class T>
struct hash<Nz::Vector4<T>>
{
/*!
* \brief Specialisation of std to hash
* \return Result of the hash
*
* \param v Vector4 to hash
*/
std::size_t operator()(const Nz::Vector4<T>& v) const
{
std::size_t seed {};
Nz::HashCombine(seed, v.x);
Nz::HashCombine(seed, v.y);
Nz::HashCombine(seed, v.z);
Nz::HashCombine(seed, v.w);
return seed;
}
};
}
#undef F
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -56,7 +56,7 @@ namespace Nz
*/
inline IpAddress::IpAddress(const UInt8& a, const UInt8& b, const UInt8& c, const UInt8& d, UInt16 port) :
IpAddress(IPv4{a, b, c, d}, port)
IpAddress(IPv4{{a, b, c, d}}, port)
{
}
@@ -68,7 +68,7 @@ namespace Nz
*/
inline IpAddress::IpAddress(const UInt16& a, const UInt16& b, const UInt16& c, const UInt16& d, const UInt16& e, const UInt16& f, const UInt16& g, const UInt16& h, UInt16 port) :
IpAddress(IPv6{a, b, c, d, e, f, g, h}, port)
IpAddress(IPv6{{a, b, c, d, e, f, g, h}}, port)
{
}

View File

@@ -79,8 +79,8 @@ namespace Nz
PendingPacket m_pendingPacket;
UInt64 m_keepAliveInterval;
UInt64 m_keepAliveTime;
bool m_isLowDelayEnabled;
bool m_isKeepAliveEnabled;
bool m_isLowDelayEnabled;
};
}

View File

@@ -25,11 +25,6 @@ namespace Nz
private:
const NoiseBase& m_source;
float m_value;
float m_remainder;
float m_offset;
float m_weight;
float m_signal;
};
}

View File

@@ -1,27 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ENUMS_PHYSICS_HPP
#define NAZARA_ENUMS_PHYSICS_HPP
enum GeomType
{
GeomType_Box,
GeomType_Capsule,
GeomType_Cone,
GeomType_Compound,
GeomType_ConvexHull,
GeomType_Cylinder,
GeomType_Heightfield,
GeomType_Null,
GeomType_Scene,
GeomType_Sphere,
GeomType_Tree,
GeomType_Max = GeomType_Tree
};
#endif // NAZARA_ENUMS_PHYSICS_HPP

View File

@@ -1,273 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GEOM_HPP
#define NAZARA_GEOM_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/PrimitiveList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics/Enums.hpp>
#include <unordered_map>
class NewtonCollision;
namespace Nz
{
///TODO: CollisionModifier
///TODO: HeightfieldGeom
///TODO: PlaneGeom ?
///TODO: SceneGeom
///TODO: TreeGeom
class PhysGeom;
class PhysWorld;
using PhysGeomConstRef = ObjectRef<const PhysGeom>;
using PhysGeomLibrary = ObjectLibrary<PhysGeom>;
using PhysGeomRef = ObjectRef<PhysGeom>;
class NAZARA_PHYSICS_API PhysGeom : public RefCounted
{
friend PhysGeomLibrary;
friend class Physics;
public:
PhysGeom() = default;
PhysGeom(const PhysGeom&) = delete;
PhysGeom(PhysGeom&&) = delete;
virtual ~PhysGeom();
Boxf ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const;
virtual Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const;
virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
virtual float ComputeVolume() const;
NewtonCollision* GetHandle(PhysWorld* world) const;
virtual GeomType GetType() const = 0;
PhysGeom& operator=(const PhysGeom&) = delete;
PhysGeom& operator=(PhysGeom&&) = delete;
static PhysGeomRef Build(const PrimitiveList& list);
// Signals:
NazaraSignal(OnPhysGeomRelease, const PhysGeom* /*physGeom*/);
protected:
virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0;
static bool Initialize();
static void Uninitialize();
mutable std::unordered_map<PhysWorld*, NewtonCollision*> m_handles;
static PhysGeomLibrary::LibraryMap s_library;
};
class BoxGeom;
using BoxGeomConstRef = ObjectRef<const BoxGeom>;
using BoxGeomRef = ObjectRef<BoxGeom>;
class NAZARA_PHYSICS_API BoxGeom : public PhysGeom
{
public:
BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity());
BoxGeom(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
float ComputeVolume() const override;
Vector3f GetLengths() const;
GeomType GetType() const override;
template<typename... Args> static BoxGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
Matrix4f m_matrix;
Vector3f m_lengths;
};
class CapsuleGeom;
using CapsuleGeomConstRef = ObjectRef<const CapsuleGeom>;
using CapsuleGeomRef = ObjectRef<CapsuleGeom>;
class NAZARA_PHYSICS_API CapsuleGeom : public PhysGeom
{
public:
CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
CapsuleGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
GeomType GetType() const override;
template<typename... Args> static CapsuleGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class CompoundGeom;
using CompoundGeomConstRef = ObjectRef<const CompoundGeom>;
using CompoundGeomRef = ObjectRef<CompoundGeom>;
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
{
public:
CompoundGeom(PhysGeom** geoms, std::size_t geomCount);
const std::vector<PhysGeomRef>& GetGeoms() const;
GeomType GetType() const override;
template<typename... Args> static CompoundGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
std::vector<PhysGeomRef> m_geoms;
};
class ConeGeom;
using ConeGeomConstRef = ObjectRef<const ConeGeom>;
using ConeGeomRef = ObjectRef<ConeGeom>;
class NAZARA_PHYSICS_API ConeGeom : public PhysGeom
{
public:
ConeGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
ConeGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
GeomType GetType() const override;
template<typename... Args> static ConeGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class ConvexHullGeom;
using ConvexHullGeomConstRef = ObjectRef<const ConvexHullGeom>;
using ConvexHullGeomRef = ObjectRef<ConvexHullGeom>;
class NAZARA_PHYSICS_API ConvexHullGeom : public PhysGeom
{
public:
ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(Vector3f), float tolerance = 0.002f, const Matrix4f& transformMatrix = Matrix4f::Identity());
ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
GeomType GetType() const override;
template<typename... Args> static ConvexHullGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
std::vector<Vector3f> m_vertices;
Matrix4f m_matrix;
float m_tolerance;
unsigned int m_vertexStride;
};
class CylinderGeom;
using CylinderGeomConstRef = ObjectRef<const CylinderGeom>;
using CylinderGeomRef = ObjectRef<CylinderGeom>;
class NAZARA_PHYSICS_API CylinderGeom : public PhysGeom
{
public:
CylinderGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
CylinderGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
GeomType GetType() const override;
template<typename... Args> static CylinderGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class NullGeom;
using NullGeomConstRef = ObjectRef<const NullGeom>;
using NullGeomRef = ObjectRef<NullGeom>;
class NAZARA_PHYSICS_API NullGeom : public PhysGeom
{
public:
NullGeom();
void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const override;
GeomType GetType() const override;
template<typename... Args> static NullGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
};
class SphereGeom;
using SphereGeomConstRef = ObjectRef<const SphereGeom>;
using SphereGeomRef = ObjectRef<SphereGeom>;
class NAZARA_PHYSICS_API SphereGeom : public PhysGeom
{
public:
SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
SphereGeom(float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
float ComputeVolume() const override;
float GetRadius() const;
GeomType GetType() const override;
template<typename... Args> static SphereGeomRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld* world) const override;
Vector3f m_position;
float m_radius;
};
}
#include <Nazara/Physics/Geom.inl>
#endif // NAZARA_PHYSWORLD_HPP

View File

@@ -1,83 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Physics/Debug.hpp>
namespace Nz
{
template<typename... Args>
BoxGeomRef BoxGeom::New(Args&&... args)
{
std::unique_ptr<BoxGeom> object(new BoxGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CapsuleGeomRef CapsuleGeom::New(Args&&... args)
{
std::unique_ptr<CapsuleGeom> object(new CapsuleGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CompoundGeomRef CompoundGeom::New(Args&&... args)
{
std::unique_ptr<CompoundGeom> object(new CompoundGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
ConeGeomRef ConeGeom::New(Args&&... args)
{
std::unique_ptr<ConeGeom> object(new ConeGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
ConvexHullGeomRef ConvexHullGeom::New(Args&&... args)
{
std::unique_ptr<ConvexHullGeom> object(new ConvexHullGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CylinderGeomRef CylinderGeom::New(Args&&... args)
{
std::unique_ptr<CylinderGeom> object(new CylinderGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
NullGeomRef NullGeom::New(Args&&... args)
{
std::unique_ptr<NullGeom> object(new NullGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
SphereGeomRef SphereGeom::New(Args&&... args)
{
std::unique_ptr<SphereGeom> object(new SphereGeom(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Physics/DebugOff.hpp>

View File

@@ -1,7 +1,7 @@
// This file was automatically generated on 24 Jun 2015 at 13:55:50
// This file was automatically generated on 14 Oct 2016 at 18:58:18
/*
Nazara Engine - Physics module
Nazara Engine - Physics 2D module
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
@@ -26,14 +26,14 @@
#pragma once
#ifndef NAZARA_GLOBAL_PHYSICS_HPP
#define NAZARA_GLOBAL_PHYSICS_HPP
#ifndef NAZARA_GLOBAL_PHYSICS2D_HPP
#define NAZARA_GLOBAL_PHYSICS2D_HPP
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics/Enums.hpp>
#include <Nazara/Physics/Geom.hpp>
#include <Nazara/Physics/Physics.hpp>
#include <Nazara/Physics/PhysObject.hpp>
#include <Nazara/Physics/PhysWorld.hpp>
#include <Nazara/Physics2D/PhysWorld2D.hpp>
#include <Nazara/Physics2D/Physics2D.hpp>
#include <Nazara/Physics2D/Collider2D.hpp>
#include <Nazara/Physics2D/Enums.hpp>
#include <Nazara/Physics2D/Config.hpp>
#include <Nazara/Physics2D/RigidBody2D.hpp>
#endif // NAZARA_GLOBAL_PHYSICS_HPP
#endif // NAZARA_GLOBAL_PHYSICS2D_HPP

View File

@@ -0,0 +1,132 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_COLLIDER2D_HPP
#define NAZARA_COLLIDER2D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Physics2D/Config.hpp>
#include <Nazara/Physics2D/Enums.hpp>
#include <vector>
struct cpShape;
struct cpSpace;
namespace Nz
{
class Collider2D;
class RigidBody2D;
using Collider2DConstRef = ObjectRef<const Collider2D>;
using Collider2DLibrary = ObjectLibrary<Collider2D>;
using Collider2DRef = ObjectRef<Collider2D>;
class NAZARA_PHYSICS2D_API Collider2D : public RefCounted
{
friend Collider2DLibrary;
friend RigidBody2D;
public:
Collider2D() = default;
Collider2D(const Collider2D&) = delete;
Collider2D(Collider2D&&) = delete;
virtual ~Collider2D();
virtual float ComputeInertialMatrix(float mass) const = 0;
virtual ColliderType2D GetType() const = 0;
Collider2D& operator=(const Collider2D&) = delete;
Collider2D& operator=(Collider2D&&) = delete;
// Signals:
NazaraSignal(OnColliderRelease, const Collider2D* /*collider*/);
protected:
virtual std::vector<cpShape*> CreateShapes(RigidBody2D* body) const = 0;
static Collider2DLibrary::LibraryMap s_library;
};
class BoxCollider2D;
using BoxCollider2DConstRef = ObjectRef<const BoxCollider2D>;
using BoxCollider2DRef = ObjectRef<BoxCollider2D>;
class NAZARA_PHYSICS2D_API BoxCollider2D : public Collider2D
{
public:
BoxCollider2D(const Vector2f& size, float radius = 0.f);
BoxCollider2D(const Rectf& rect, float radius = 0.f);
float ComputeInertialMatrix(float mass) const override;
inline const Rectf& GetRect() const;
inline Vector2f GetSize() const;
ColliderType2D GetType() const override;
template<typename... Args> static BoxCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
Rectf m_rect;
float m_radius;
};
class CircleCollider2D;
using CircleCollider2DConstRef = ObjectRef<const CircleCollider2D>;
using CircleCollider2DRef = ObjectRef<CircleCollider2D>;
class NAZARA_PHYSICS2D_API CircleCollider2D : public Collider2D
{
public:
CircleCollider2D(float radius, const Vector2f& offset = Vector2f::Zero());
float ComputeInertialMatrix(float mass) const override;
inline float GetRadius() const;
ColliderType2D GetType() const override;
template<typename... Args> static CircleCollider2DRef New(Args&&... args);
private:
std::vector<cpShape*> CreateShapes(RigidBody2D* body) const override;
Vector2f m_offset;
float m_radius;
};
class NullCollider2D;
using NullCollider2DConstRef = ObjectRef<const NullCollider2D>;
using NullCollider2DRef = ObjectRef<NullCollider2D>;
class NAZARA_PHYSICS2D_API NullCollider2D : public Collider2D
{
public:
NullCollider2D() = default;
float ComputeInertialMatrix(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;
};
}
#include <Nazara/Physics2D/Collider2D.inl>
#endif // NAZARA_COLLIDER2D_HPP

View File

@@ -0,0 +1,54 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Physics2D/Debug.hpp>
namespace Nz
{
inline const Rectf& BoxCollider2D::GetRect() const
{
return m_rect;
}
inline Vector2f BoxCollider2D::GetSize() const
{
return m_rect.GetLengths();
}
template<typename... Args>
BoxCollider2DRef BoxCollider2D::New(Args&&... args)
{
std::unique_ptr<BoxCollider2D> object(new BoxCollider2D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
inline float CircleCollider2D::GetRadius() const
{
return m_radius;
}
template<typename... Args>
CircleCollider2DRef CircleCollider2D::New(Args&&... args)
{
std::unique_ptr<CircleCollider2D> object(new CircleCollider2D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
NullCollider2DRef NullCollider2D::New(Args&&... args)
{
std::unique_ptr<NullCollider2D> object(new NullCollider2D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Physics2D/DebugOff.hpp>

View File

@@ -1,5 +1,5 @@
/*
Nazara Engine - Physics module
Nazara Engine - Physics 2D module
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
@@ -24,28 +24,28 @@
#pragma once
#ifndef NAZARA_CONFIG_PHYSICS_HPP
#define NAZARA_CONFIG_PHYSICS_HPP
#ifndef NAZARA_CONFIG_PHYSICS2D_HPP
#define NAZARA_CONFIG_PHYSICS2D_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// 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_PHYSICS_MANAGE_MEMORY 0
#define NAZARA_PHYSICS2D_MANAGE_MEMORY 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_PHYSICS_SAFE 1
#define NAZARA_PHYSICS2D_SAFE 1
/// Vérification des valeurs et types de certaines constantes
#include <Nazara/Physics/ConfigCheck.hpp>
#include <Nazara/Physics2D/ConfigCheck.hpp>
#if defined(NAZARA_STATIC)
#define NAZARA_PHYSICS_API
#define NAZARA_PHYSICS2D_API
#else
#ifdef NAZARA_PHYSICS_BUILD
#define NAZARA_PHYSICS_API NAZARA_EXPORT
#ifdef NAZARA_PHYSICS2D_BUILD
#define NAZARA_PHYSICS2D_API NAZARA_EXPORT
#else
#define NAZARA_PHYSICS_API NAZARA_IMPORT
#define NAZARA_PHYSICS2D_API NAZARA_IMPORT
#endif
#endif
#endif // NAZARA_CONFIG_PHYSICS_HPP
#endif // NAZARA_CONFIG_PHYSICS3D_HPP

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
@@ -12,7 +12,7 @@
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
#undef NAZARA_PHYSICS_MANAGE_MEMORY
#define NAZARA_PHYSICS_MANAGE_MEMORY 0
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
#endif
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP

View File

@@ -1,8 +1,8 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#include <Nazara/Core/Debug/NewRedefinition.hpp>
#endif

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ENUMS_PHYSICS2D_HPP
#define NAZARA_ENUMS_PHYSICS2D_HPP
namespace Nz
{
enum ColliderType2D
{
ColliderType2D_Box,
ColliderType2D_Convex,
ColliderType2D_Circle,
ColliderType2D_Null,
ColliderType2D_Segment,
ColliderType2D_Max = ColliderType2D_Segment
};
}
#endif // NAZARA_ENUMS_PHYSICS2D_HPP

View File

@@ -0,0 +1,46 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSWORLD2D_HPP
#define NAZARA_PHYSWORLD2D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Physics2D/Config.hpp>
struct cpSpace;
namespace Nz
{
class NAZARA_PHYSICS2D_API PhysWorld2D
{
public:
PhysWorld2D();
PhysWorld2D(const PhysWorld2D&) = delete;
PhysWorld2D(PhysWorld2D&&) = delete; ///TODO
~PhysWorld2D();
Vector2f GetGravity() const;
cpSpace* GetHandle() const;
float GetStepSize() const;
void SetGravity(const Vector2f& gravity);
void SetSolverModel(unsigned int model);
void SetStepSize(float stepSize);
void Step(float timestep);
PhysWorld2D& operator=(const PhysWorld2D&) = delete;
PhysWorld2D& operator=(PhysWorld2D&&) = delete; ///TODO
private:
cpSpace* m_handle;
float m_stepSize;
float m_timestepAccumulator;
};
}
#endif // NAZARA_PHYSWORLD2D_HPP

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS2D_HPP
#define NAZARA_PHYSICS2D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/Physics2D/Config.hpp>
namespace Nz
{
class NAZARA_PHYSICS2D_API Physics2D
{
public:
Physics2D() = delete;
~Physics2D() = delete;
static bool Initialize();
static bool IsInitialized();
static void Uninitialize();
private:
static unsigned int s_moduleReferenceCounter;
};
}
#endif // NAZARA_PHYSICS2D_HPP

View File

@@ -0,0 +1,74 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 2D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RIGIDBODY2D_HPP
#define NAZARA_RIGIDBODY2D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics2D/Config.hpp>
#include <Nazara/Physics2D/Collider2D.hpp>
struct cpBody;
namespace Nz
{
class PhysWorld2D;
class NAZARA_PHYSICS2D_API RigidBody2D
{
public:
RigidBody2D(PhysWorld2D* world, float mass);
RigidBody2D(PhysWorld2D* world, float mass, Collider2DRef geom);
RigidBody2D(const RigidBody2D& object);
RigidBody2D(RigidBody2D&& object);
~RigidBody2D();
void AddForce(const Vector2f& force, CoordSys coordSys = CoordSys_Global);
void AddForce(const Vector2f& force, const Vector2f& point, CoordSys coordSys = CoordSys_Global);
void AddTorque(float torque);
Rectf GetAABB() const;
float GetAngularVelocity() const;
Vector2f GetCenterOfGravity(CoordSys coordSys = CoordSys_Local) const;
const Collider2DRef& GetGeom() const;
cpBody* GetHandle() const;
float GetMass() const;
Vector2f GetPosition() const;
float GetRotation() const;
Vector2f GetVelocity() const;
bool IsMoveable() const;
bool IsSleeping() const;
void SetAngularVelocity(float angularVelocity);
void SetMass(float mass);
void SetMassCenter(const Vector2f& center);
void SetPosition(const Vector2f& position);
void SetRotation(float rotation);
void SetVelocity(const Vector2f& velocity);
RigidBody2D& operator=(const RigidBody2D& object);
RigidBody2D& operator=(RigidBody2D&& object);
private:
void Destroy();
void SetGeom(Collider2DRef geom);
std::vector<cpShape*> m_shapes;
Collider2DRef m_geom;
cpBody* m_handle;
PhysWorld2D* m_world;
float m_gravityFactor;
float m_mass;
};
}
#endif // NAZARA_RIGIDBODY3D_HPP

View File

@@ -0,0 +1,39 @@
// This file was automatically generated on 14 Oct 2016 at 18:58:18
/*
Nazara Engine - Physics 3D module
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_GLOBAL_PHYSICS3D_HPP
#define NAZARA_GLOBAL_PHYSICS3D_HPP
#include <Nazara/Physics3D/PhysWorld3D.hpp>
#include <Nazara/Physics3D/Physics3D.hpp>
#include <Nazara/Physics3D/RigidBody3D.hpp>
#include <Nazara/Physics3D/Enums.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Nazara/Physics3D/Collider3D.hpp>
#endif // NAZARA_GLOBAL_PHYSICS3D_HPP

View File

@@ -0,0 +1,273 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_COLLIDER3D_HPP
#define NAZARA_COLLIDER3D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/PrimitiveList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Nazara/Physics3D/Enums.hpp>
#include <unordered_map>
class NewtonCollision;
namespace Nz
{
///TODO: CollisionModifier
///TODO: HeightfieldGeom
///TODO: PlaneGeom ?
///TODO: SceneGeom
///TODO: TreeGeom
class Collider3D;
class PhysWorld3D;
using Collider3DConstRef = ObjectRef<const Collider3D>;
using Collider3DLibrary = ObjectLibrary<Collider3D>;
using Collider3DRef = ObjectRef<Collider3D>;
class NAZARA_PHYSICS3D_API Collider3D : public RefCounted
{
friend Collider3DLibrary;
friend class Physics3D;
public:
Collider3D() = default;
Collider3D(const Collider3D&) = delete;
Collider3D(Collider3D&&) = delete;
virtual ~Collider3D();
Boxf ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const;
virtual Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const;
virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
virtual float ComputeVolume() const;
NewtonCollision* GetHandle(PhysWorld3D* world) const;
virtual ColliderType3D GetType() const = 0;
Collider3D& operator=(const Collider3D&) = delete;
Collider3D& operator=(Collider3D&&) = delete;
static Collider3DRef Build(const PrimitiveList& list);
// Signals:
NazaraSignal(OnColliderRelease, const Collider3D* /*collider*/);
protected:
virtual NewtonCollision* CreateHandle(PhysWorld3D* world) const = 0;
static bool Initialize();
static void Uninitialize();
mutable std::unordered_map<PhysWorld3D*, NewtonCollision*> m_handles;
static Collider3DLibrary::LibraryMap s_library;
};
class BoxCollider3D;
using BoxCollider3DConstRef = ObjectRef<const BoxCollider3D>;
using BoxCollider3DRef = ObjectRef<BoxCollider3D>;
class NAZARA_PHYSICS3D_API BoxCollider3D : public Collider3D
{
public:
BoxCollider3D(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity());
BoxCollider3D(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
float ComputeVolume() const override;
Vector3f GetLengths() const;
ColliderType3D GetType() const override;
template<typename... Args> static BoxCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
Matrix4f m_matrix;
Vector3f m_lengths;
};
class CapsuleCollider3D;
using CapsuleCollider3DConstRef = ObjectRef<const CapsuleCollider3D>;
using CapsuleCollider3DRef = ObjectRef<CapsuleCollider3D>;
class NAZARA_PHYSICS3D_API CapsuleCollider3D : public Collider3D
{
public:
CapsuleCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
CapsuleCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
ColliderType3D GetType() const override;
template<typename... Args> static CapsuleCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class CompoundCollider3D;
using CompoundCollider3DConstRef = ObjectRef<const CompoundCollider3D>;
using CompoundCollider3DRef = ObjectRef<CompoundCollider3D>;
class NAZARA_PHYSICS3D_API CompoundCollider3D : public Collider3D
{
public:
CompoundCollider3D(Collider3D** geoms, std::size_t geomCount);
const std::vector<Collider3DRef>& GetGeoms() const;
ColliderType3D GetType() const override;
template<typename... Args> static CompoundCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
std::vector<Collider3DRef> m_geoms;
};
class ConeCollider3D;
using ConeCollider3DConstRef = ObjectRef<const ConeCollider3D>;
using ConeCollider3DRef = ObjectRef<ConeCollider3D>;
class NAZARA_PHYSICS3D_API ConeCollider3D : public Collider3D
{
public:
ConeCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
ConeCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
ColliderType3D GetType() const override;
template<typename... Args> static ConeCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class ConvexCollider3D;
using ConvexCollider3DConstRef = ObjectRef<const ConvexCollider3D>;
using ConvexCollider3DRef = ObjectRef<ConvexCollider3D>;
class NAZARA_PHYSICS3D_API ConvexCollider3D : public Collider3D
{
public:
ConvexCollider3D(SparsePtr<const Vector3f> vertices, unsigned int vertexCount, float tolerance = 0.002f, const Matrix4f& transformMatrix = Matrix4f::Identity());
ConvexCollider3D(SparsePtr<const Vector3f> vertices, unsigned int vertexCount, float tolerance, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
ColliderType3D GetType() const override;
template<typename... Args> static ConvexCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
std::vector<Vector3f> m_vertices;
Matrix4f m_matrix;
float m_tolerance;
};
class CylinderCollider3D;
using CylinderCollider3DConstRef = ObjectRef<const CylinderCollider3D>;
using CylinderCollider3DRef = ObjectRef<CylinderCollider3D>;
class NAZARA_PHYSICS3D_API CylinderCollider3D : public Collider3D
{
public:
CylinderCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
CylinderCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
float GetLength() const;
float GetRadius() const;
ColliderType3D GetType() const override;
template<typename... Args> static CylinderCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class NullCollider3D;
using NullCollider3DConstRef = ObjectRef<const NullCollider3D>;
using NullCollider3DRef = ObjectRef<NullCollider3D>;
class NAZARA_PHYSICS3D_API NullCollider3D : public Collider3D
{
public:
NullCollider3D();
void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const override;
ColliderType3D GetType() const override;
template<typename... Args> static NullCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
};
class SphereCollider3D;
using SphereCollider3DConstRef = ObjectRef<const SphereCollider3D>;
using SphereCollider3DRef = ObjectRef<SphereCollider3D>;
class NAZARA_PHYSICS3D_API SphereCollider3D : public Collider3D
{
public:
SphereCollider3D(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
SphereCollider3D(float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
float ComputeVolume() const override;
float GetRadius() const;
ColliderType3D GetType() const override;
template<typename... Args> static SphereCollider3DRef New(Args&&... args);
private:
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
Vector3f m_position;
float m_radius;
};
}
#include <Nazara/Physics3D/Collider3D.inl>
#endif // NAZARA_COLLIDER3D_HPP

View File

@@ -0,0 +1,83 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Physics3D/Debug.hpp>
namespace Nz
{
template<typename... Args>
BoxCollider3DRef BoxCollider3D::New(Args&&... args)
{
std::unique_ptr<BoxCollider3D> object(new BoxCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CapsuleCollider3DRef CapsuleCollider3D::New(Args&&... args)
{
std::unique_ptr<CapsuleCollider3D> object(new CapsuleCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CompoundCollider3DRef CompoundCollider3D::New(Args&&... args)
{
std::unique_ptr<CompoundCollider3D> object(new CompoundCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
ConeCollider3DRef ConeCollider3D::New(Args&&... args)
{
std::unique_ptr<ConeCollider3D> object(new ConeCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
ConvexCollider3DRef ConvexCollider3D::New(Args&&... args)
{
std::unique_ptr<ConvexCollider3D> object(new ConvexCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
CylinderCollider3DRef CylinderCollider3D::New(Args&&... args)
{
std::unique_ptr<CylinderCollider3D> object(new CylinderCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
NullCollider3DRef NullCollider3D::New(Args&&... args)
{
std::unique_ptr<NullCollider3D> object(new NullCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
template<typename... Args>
SphereCollider3DRef SphereCollider3D::New(Args&&... args)
{
std::unique_ptr<SphereCollider3D> object(new SphereCollider3D(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Physics3D/DebugOff.hpp>

View File

@@ -0,0 +1,51 @@
/*
Nazara Engine - Physics 3D module
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_CONFIG_PHYSICS3D_HPP
#define NAZARA_CONFIG_PHYSICS3D_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// 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_PHYSICS3D_MANAGE_MEMORY 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_PHYSICS3D_SAFE 1
/// Vérification des valeurs et types de certaines constantes
#include <Nazara/Physics3D/ConfigCheck.hpp>
#if defined(NAZARA_STATIC)
#define NAZARA_PHYSICS3D_API
#else
#ifdef NAZARA_PHYSICS3D_BUILD
#define NAZARA_PHYSICS3D_API NAZARA_EXPORT
#else
#define NAZARA_PHYSICS3D_API NAZARA_IMPORT
#endif
#endif
#endif // NAZARA_CONFIG_PHYSICS3D_HPP

View File

@@ -0,0 +1,18 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CONFIG_CHECK_PHYSICS_HPP
#define NAZARA_CONFIG_CHECK_PHYSICS_HPP
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
#undef NAZARA_PHYSICS_MANAGE_MEMORY
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
#endif
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP

View File

@@ -0,0 +1,8 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#include <Nazara/Core/Debug/NewRedefinition.hpp>
#endif

View File

@@ -0,0 +1,9 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
#if NAZARA_PHYSICS_MANAGE_MEMORY
#undef delete
#undef new
#endif

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ENUMS_PHYSICS3D_HPP
#define NAZARA_ENUMS_PHYSICS3D_HPP
namespace Nz
{
enum ColliderType3D
{
ColliderType3D_Box,
ColliderType3D_Capsule,
ColliderType3D_Cone,
ColliderType3D_Compound,
ColliderType3D_ConvexHull,
ColliderType3D_Cylinder,
ColliderType3D_Heightfield,
ColliderType3D_Null,
ColliderType3D_Scene,
ColliderType3D_Sphere,
ColliderType3D_Tree,
ColliderType3D_Max = ColliderType3D_Tree
};
};
#endif // NAZARA_ENUMS_PHYSICS3D_HPP

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
@@ -10,19 +10,19 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics3D/Config.hpp>
class NewtonWorld;
namespace Nz
{
class NAZARA_PHYSICS_API PhysWorld
class NAZARA_PHYSICS3D_API PhysWorld3D
{
public:
PhysWorld();
PhysWorld(const PhysWorld&) = delete;
PhysWorld(PhysWorld&&) = delete; ///TODO
~PhysWorld();
PhysWorld3D();
PhysWorld3D(const PhysWorld3D&) = delete;
PhysWorld3D(PhysWorld3D&&) = delete; ///TODO
~PhysWorld3D();
Vector3f GetGravity() const;
NewtonWorld* GetHandle() const;
@@ -34,8 +34,8 @@ namespace Nz
void Step(float timestep);
PhysWorld& operator=(const PhysWorld&) = delete;
PhysWorld& operator=(PhysWorld&&) = delete; ///TODO
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
PhysWorld3D& operator=(PhysWorld3D&&) = delete; ///TODO
private:
Vector3f m_gravity;

View File

@@ -1,23 +1,23 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS_HPP
#define NAZARA_PHYSICS_HPP
#ifndef NAZARA_PHYSICS3D_HPP
#define NAZARA_PHYSICS3D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics3D/Config.hpp>
namespace Nz
{
class NAZARA_PHYSICS_API Physics
class NAZARA_PHYSICS3D_API Physics3D
{
public:
Physics() = delete;
~Physics() = delete;
Physics3D() = delete;
~Physics3D() = delete;
static unsigned int GetMemoryUsed();
@@ -32,4 +32,4 @@ namespace Nz
};
}
#endif // NAZARA_PHYSICS_HPP
#endif // NAZARA_PHYSICS3D_HPP

View File

@@ -1,34 +1,34 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// This file is part of the "Nazara Engine - Physics 3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSOBJECT_HPP
#define NAZARA_PHYSOBJECT_HPP
#ifndef NAZARA_RIGIDBODY3D_HPP
#define NAZARA_RIGIDBODY3D_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics/Config.hpp>
#include <Nazara/Physics/Geom.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Nazara/Physics3D/Collider3D.hpp>
class NewtonBody;
namespace Nz
{
class PhysWorld;
class PhysWorld3D;
class NAZARA_PHYSICS_API PhysObject
class NAZARA_PHYSICS3D_API RigidBody3D
{
public:
PhysObject(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity());
PhysObject(PhysWorld* world, PhysGeomRef geom, const Matrix4f& mat = Matrix4f::Identity());
PhysObject(const PhysObject& object);
PhysObject(PhysObject&& object);
~PhysObject();
RigidBody3D(PhysWorld3D* world, const Matrix4f& mat = Matrix4f::Identity());
RigidBody3D(PhysWorld3D* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity());
RigidBody3D(const RigidBody3D& object);
RigidBody3D(RigidBody3D&& object);
~RigidBody3D();
void AddForce(const Vector3f& force, CoordSys coordSys = CoordSys_Global);
void AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys = CoordSys_Global);
@@ -38,7 +38,7 @@ namespace Nz
Boxf GetAABB() const;
Vector3f GetAngularVelocity() const;
const PhysGeomRef& GetGeom() const;
const Collider3DRef& GetGeom() const;
float GetGravityFactor() const;
NewtonBody* GetHandle() const;
float GetMass() const;
@@ -53,7 +53,7 @@ namespace Nz
bool IsSleeping() const;
void SetAngularVelocity(const Vector3f& angularVelocity);
void SetGeom(PhysGeomRef geom);
void SetGeom(Collider3DRef geom);
void SetGravityFactor(float gravityFactor);
void SetMass(float mass);
void SetMassCenter(const Vector3f& center);
@@ -61,23 +61,23 @@ namespace Nz
void SetRotation(const Quaternionf& rotation);
void SetVelocity(const Vector3f& velocity);
PhysObject& operator=(const PhysObject& object);
PhysObject& operator=(PhysObject&& object);
RigidBody3D& operator=(const RigidBody3D& object);
RigidBody3D& operator=(RigidBody3D&& object);
private:
void UpdateBody();
static void ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex);
static void TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex);
Collider3DRef m_geom;
Matrix4f m_matrix;
PhysGeomRef m_geom;
Vector3f m_forceAccumulator;
Vector3f m_torqueAccumulator;
NewtonBody* m_body;
PhysWorld* m_world;
PhysWorld3D* m_world;
float m_gravityFactor;
float m_mass;
};
}
#endif // NAZARA_PHYSOBJECT_HPP
#endif // NAZARA_RIGIDBODY3D_HPP

View File

@@ -71,7 +71,6 @@ namespace Nz
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}

View File

@@ -111,8 +111,8 @@ namespace Nz
if (content <= PixelFormatContent_Undefined || content > PixelFormatContent_Max)
return false;
std::array<const Nz::Bitset<>*, 4> masks = {&redMask, &greenMask, &blueMask, &alphaMask};
std::array<PixelFormatSubType, 4> types = {redType, greenType, blueType, alphaType};
std::array<const Nz::Bitset<>*, 4> masks = { {&redMask, &greenMask, &blueMask, &alphaMask} };
std::array<PixelFormatSubType, 4> types = { {redType, greenType, blueType, alphaType} };
for (unsigned int i = 0; i < 4; ++i)
{