Physics: Move files to Physics3D
This commit is contained in:
51
include/Nazara/Physics3D/Config.hpp
Normal file
51
include/Nazara/Physics3D/Config.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Nazara Engine - Physics 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_PHYSICS_HPP
|
||||
#define NAZARA_CONFIG_PHYSICS_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
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_PHYSICS_SAFE 1
|
||||
|
||||
/// Vérification des valeurs et types de certaines constantes
|
||||
#include <Nazara/Physics/ConfigCheck.hpp>
|
||||
|
||||
#if defined(NAZARA_STATIC)
|
||||
#define NAZARA_PHYSICS_API
|
||||
#else
|
||||
#ifdef NAZARA_PHYSICS_BUILD
|
||||
#define NAZARA_PHYSICS_API NAZARA_EXPORT
|
||||
#else
|
||||
#define NAZARA_PHYSICS_API NAZARA_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_PHYSICS_HPP
|
||||
18
include/Nazara/Physics3D/ConfigCheck.hpp
Normal file
18
include/Nazara/Physics3D/ConfigCheck.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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_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_PHYSICS_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP
|
||||
8
include/Nazara/Physics3D/Debug.hpp
Normal file
8
include/Nazara/Physics3D/Debug.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// 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 <Nazara/Physics/Config.hpp>
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||
#endif
|
||||
9
include/Nazara/Physics3D/DebugOff.hpp
Normal file
9
include/Nazara/Physics3D/DebugOff.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
// 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
|
||||
|
||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
27
include/Nazara/Physics3D/Enums.hpp
Normal file
27
include/Nazara/Physics3D/Enums.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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
|
||||
273
include/Nazara/Physics3D/Geom.hpp
Normal file
273
include/Nazara/Physics3D/Geom.hpp
Normal file
@@ -0,0 +1,273 @@
|
||||
// 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
|
||||
83
include/Nazara/Physics3D/Geom.inl
Normal file
83
include/Nazara/Physics3D/Geom.inl
Normal file
@@ -0,0 +1,83 @@
|
||||
// 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>
|
||||
83
include/Nazara/Physics3D/PhysObject.hpp
Normal file
83
include/Nazara/Physics3D/PhysObject.hpp
Normal file
@@ -0,0 +1,83 @@
|
||||
// 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_PHYSOBJECT_HPP
|
||||
#define NAZARA_PHYSOBJECT_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>
|
||||
|
||||
class NewtonBody;
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class PhysWorld;
|
||||
|
||||
class NAZARA_PHYSICS_API PhysObject
|
||||
{
|
||||
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();
|
||||
|
||||
void AddForce(const Vector3f& force, CoordSys coordSys = CoordSys_Global);
|
||||
void AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys = CoordSys_Global);
|
||||
void AddTorque(const Vector3f& torque, CoordSys coordSys = CoordSys_Global);
|
||||
|
||||
void EnableAutoSleep(bool autoSleep);
|
||||
|
||||
Boxf GetAABB() const;
|
||||
Vector3f GetAngularVelocity() const;
|
||||
const PhysGeomRef& GetGeom() const;
|
||||
float GetGravityFactor() const;
|
||||
NewtonBody* GetHandle() const;
|
||||
float GetMass() const;
|
||||
Vector3f GetMassCenter(CoordSys coordSys = CoordSys_Local) const;
|
||||
const Matrix4f& GetMatrix() const;
|
||||
Vector3f GetPosition() const;
|
||||
Quaternionf GetRotation() const;
|
||||
Vector3f GetVelocity() const;
|
||||
|
||||
bool IsAutoSleepEnabled() const;
|
||||
bool IsMoveable() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
void SetAngularVelocity(const Vector3f& angularVelocity);
|
||||
void SetGeom(PhysGeomRef geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const Vector3f& center);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetRotation(const Quaternionf& rotation);
|
||||
void SetVelocity(const Vector3f& velocity);
|
||||
|
||||
PhysObject& operator=(const PhysObject& object);
|
||||
PhysObject& operator=(PhysObject&& 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);
|
||||
|
||||
Matrix4f m_matrix;
|
||||
PhysGeomRef m_geom;
|
||||
Vector3f m_forceAccumulator;
|
||||
Vector3f m_torqueAccumulator;
|
||||
NewtonBody* m_body;
|
||||
PhysWorld* m_world;
|
||||
float m_gravityFactor;
|
||||
float m_mass;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSOBJECT_HPP
|
||||
48
include/Nazara/Physics3D/PhysWorld.hpp
Normal file
48
include/Nazara/Physics3D/PhysWorld.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// 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_PHYSWORLD_HPP
|
||||
#define NAZARA_PHYSWORLD_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
|
||||
class NewtonWorld;
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_PHYSICS_API PhysWorld
|
||||
{
|
||||
public:
|
||||
PhysWorld();
|
||||
PhysWorld(const PhysWorld&) = delete;
|
||||
PhysWorld(PhysWorld&&) = delete; ///TODO
|
||||
~PhysWorld();
|
||||
|
||||
Vector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
float GetStepSize() const;
|
||||
|
||||
void SetGravity(const Vector3f& gravity);
|
||||
void SetSolverModel(unsigned int model);
|
||||
void SetStepSize(float stepSize);
|
||||
|
||||
void Step(float timestep);
|
||||
|
||||
PhysWorld& operator=(const PhysWorld&) = delete;
|
||||
PhysWorld& operator=(PhysWorld&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
Vector3f m_gravity;
|
||||
NewtonWorld* m_world;
|
||||
float m_stepSize;
|
||||
float m_timestepAccumulator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSWORLD_HPP
|
||||
35
include/Nazara/Physics3D/Physics.hpp
Normal file
35
include/Nazara/Physics3D/Physics.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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_PHYSICS_HPP
|
||||
#define NAZARA_PHYSICS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_PHYSICS_API Physics
|
||||
{
|
||||
public:
|
||||
Physics() = delete;
|
||||
~Physics() = delete;
|
||||
|
||||
static unsigned int GetMemoryUsed();
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsInitialized();
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSICS_HPP
|
||||
Reference in New Issue
Block a user