Physics3D: Rename PhysWorld to PhysWorld3D
This commit is contained in:
parent
3765cba046
commit
b52c7c57bf
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
||||||
#define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
#define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
||||||
|
|
||||||
#include <Nazara/Physics3D/PhysObject.hpp>
|
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||||
#include <NDK/Component.hpp>
|
#include <NDK/Component.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
||||||
#define NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
#define NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
||||||
|
|
||||||
#include <Nazara/Physics3D/PhysWorld.hpp>
|
#include <Nazara/Physics3D/PhysWorld3D.hpp>
|
||||||
#include <NDK/EntityList.hpp>
|
#include <NDK/EntityList.hpp>
|
||||||
#include <NDK/System.hpp>
|
#include <NDK/System.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -21,8 +21,8 @@ namespace Ndk
|
||||||
PhysicsSystem(const PhysicsSystem& system);
|
PhysicsSystem(const PhysicsSystem& system);
|
||||||
~PhysicsSystem() = default;
|
~PhysicsSystem() = default;
|
||||||
|
|
||||||
Nz::PhysWorld& GetWorld();
|
Nz::PhysWorld3D& GetWorld();
|
||||||
const Nz::PhysWorld& GetWorld() const;
|
const Nz::PhysWorld3D& GetWorld() const;
|
||||||
|
|
||||||
static SystemIndex systemIndex;
|
static SystemIndex systemIndex;
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Ndk
|
||||||
|
|
||||||
EntityList m_dynamicObjects;
|
EntityList m_dynamicObjects;
|
||||||
EntityList m_staticObjects;
|
EntityList m_staticObjects;
|
||||||
std::unique_ptr<Nz::PhysWorld> m_world; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
std::unique_ptr<Nz::PhysWorld3D> m_world; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Ndk
|
||||||
* \return A reference to the physical world
|
* \return A reference to the physical world
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
|
inline Nz::PhysWorld3D& PhysicsSystem::GetWorld()
|
||||||
{
|
{
|
||||||
return *m_world;
|
return *m_world;
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Ndk
|
||||||
* \return A constant reference to the physical world
|
* \return A constant reference to the physical world
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
|
inline const Nz::PhysWorld3D& PhysicsSystem::GetWorld() const
|
||||||
{
|
{
|
||||||
return *m_world;
|
return *m_world;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/Components/CollisionComponent.hpp>
|
#include <NDK/Components/CollisionComponent.hpp>
|
||||||
#include <Nazara/Physics3D/PhysObject.hpp>
|
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||||
#include <NDK/Algorithm.hpp>
|
#include <NDK/Algorithm.hpp>
|
||||||
#include <NDK/World.hpp>
|
#include <NDK/World.hpp>
|
||||||
#include <NDK/Components/PhysicsComponent.hpp>
|
#include <NDK/Components/PhysicsComponent.hpp>
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Ndk
|
||||||
|
|
||||||
NazaraAssert(entityWorld, "Entity must have world");
|
NazaraAssert(entityWorld, "Entity must have world");
|
||||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||||
Nz::PhysWorld& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
Nz::PhysWorld3D& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||||
|
|
||||||
m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom));
|
m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom));
|
||||||
m_staticBody->EnableAutoSleep(false);
|
m_staticBody->EnableAutoSleep(false);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/Components/PhysicsComponent.hpp>
|
#include <NDK/Components/PhysicsComponent.hpp>
|
||||||
#include <Nazara/Physics3D/PhysObject.hpp>
|
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||||
#include <NDK/Algorithm.hpp>
|
#include <NDK/Algorithm.hpp>
|
||||||
#include <NDK/World.hpp>
|
#include <NDK/World.hpp>
|
||||||
#include <NDK/Components/CollisionComponent.hpp>
|
#include <NDK/Components/CollisionComponent.hpp>
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Ndk
|
||||||
World* entityWorld = m_entity->GetWorld();
|
World* entityWorld = m_entity->GetWorld();
|
||||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||||
|
|
||||||
Nz::PhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
Nz::PhysWorld3D& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||||
|
|
||||||
Nz::Collider3DRef geom;
|
Nz::Collider3DRef geom;
|
||||||
if (m_entity->HasComponent<CollisionComponent>())
|
if (m_entity->HasComponent<CollisionComponent>())
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||||
#include <Nazara/Physics3D/PhysObject.hpp>
|
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||||
#include <NDK/Components/CollisionComponent.hpp>
|
#include <NDK/Components/CollisionComponent.hpp>
|
||||||
#include <NDK/Components/NodeComponent.hpp>
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
#include <NDK/Components/PhysicsComponent.hpp>
|
#include <NDK/Components/PhysicsComponent.hpp>
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Ndk
|
||||||
entities.Insert(entity);
|
entities.Insert(entity);
|
||||||
|
|
||||||
if (!m_world)
|
if (!m_world)
|
||||||
m_world = std::make_unique<Nz::PhysWorld>();
|
m_world = std::make_unique<Nz::PhysWorld3D>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
///TODO: TreeGeom
|
///TODO: TreeGeom
|
||||||
|
|
||||||
class Collider3D;
|
class Collider3D;
|
||||||
class PhysWorld;
|
class PhysWorld3D;
|
||||||
|
|
||||||
using Collider3DConstRef = ObjectRef<const Collider3D>;
|
using Collider3DConstRef = ObjectRef<const Collider3D>;
|
||||||
using Collider3DLibrary = ObjectLibrary<Collider3D>;
|
using Collider3DLibrary = ObjectLibrary<Collider3D>;
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Nz
|
||||||
virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
|
virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
|
||||||
virtual float ComputeVolume() const;
|
virtual float ComputeVolume() const;
|
||||||
|
|
||||||
NewtonCollision* GetHandle(PhysWorld* world) const;
|
NewtonCollision* GetHandle(PhysWorld3D* world) const;
|
||||||
virtual GeomType GetType() const = 0;
|
virtual GeomType GetType() const = 0;
|
||||||
|
|
||||||
Collider3D& operator=(const Collider3D&) = delete;
|
Collider3D& operator=(const Collider3D&) = delete;
|
||||||
|
|
@ -65,12 +65,12 @@ namespace Nz
|
||||||
NazaraSignal(OnColliderRelease, const Collider3D* /*collider*/);
|
NazaraSignal(OnColliderRelease, const Collider3D* /*collider*/);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0;
|
virtual NewtonCollision* CreateHandle(PhysWorld3D* world) const = 0;
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
||||||
mutable std::unordered_map<PhysWorld*, NewtonCollision*> m_handles;
|
mutable std::unordered_map<PhysWorld3D*, NewtonCollision*> m_handles;
|
||||||
|
|
||||||
static Collider3DLibrary::LibraryMap s_library;
|
static Collider3DLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
|
|
@ -95,7 +95,7 @@ namespace Nz
|
||||||
template<typename... Args> static BoxCollider3DRef New(Args&&... args);
|
template<typename... Args> static BoxCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
Matrix4f m_matrix;
|
Matrix4f m_matrix;
|
||||||
Vector3f m_lengths;
|
Vector3f m_lengths;
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Nz
|
||||||
template<typename... Args> static CapsuleCollider3DRef New(Args&&... args);
|
template<typename... Args> static CapsuleCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
Matrix4f m_matrix;
|
Matrix4f m_matrix;
|
||||||
float m_length;
|
float m_length;
|
||||||
|
|
@ -142,7 +142,7 @@ namespace Nz
|
||||||
template<typename... Args> static CompoundCollider3DRef New(Args&&... args);
|
template<typename... Args> static CompoundCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
std::vector<Collider3DRef> m_geoms;
|
std::vector<Collider3DRef> m_geoms;
|
||||||
};
|
};
|
||||||
|
|
@ -165,7 +165,7 @@ namespace Nz
|
||||||
template<typename... Args> static ConeCollider3DRef New(Args&&... args);
|
template<typename... Args> static ConeCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
Matrix4f m_matrix;
|
Matrix4f m_matrix;
|
||||||
float m_length;
|
float m_length;
|
||||||
|
|
@ -188,7 +188,7 @@ namespace Nz
|
||||||
template<typename... Args> static ConvexCollider3DRef New(Args&&... args);
|
template<typename... Args> static ConvexCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
std::vector<Vector3f> m_vertices;
|
std::vector<Vector3f> m_vertices;
|
||||||
Matrix4f m_matrix;
|
Matrix4f m_matrix;
|
||||||
|
|
@ -214,7 +214,7 @@ namespace Nz
|
||||||
template<typename... Args> static CylinderCollider3DRef New(Args&&... args);
|
template<typename... Args> static CylinderCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
Matrix4f m_matrix;
|
Matrix4f m_matrix;
|
||||||
float m_length;
|
float m_length;
|
||||||
|
|
@ -238,7 +238,7 @@ namespace Nz
|
||||||
template<typename... Args> static NullCollider3DRef New(Args&&... args);
|
template<typename... Args> static NullCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SphereCollider3D;
|
class SphereCollider3D;
|
||||||
|
|
@ -261,7 +261,7 @@ namespace Nz
|
||||||
template<typename... Args> static SphereCollider3DRef New(Args&&... args);
|
template<typename... Args> static SphereCollider3DRef New(Args&&... args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld3D* world) const override;
|
||||||
|
|
||||||
Vector3f m_position;
|
Vector3f m_position;
|
||||||
float m_radius;
|
float m_radius;
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ class NewtonWorld;
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class NAZARA_PHYSICS3D_API PhysWorld
|
class NAZARA_PHYSICS3D_API PhysWorld3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PhysWorld();
|
PhysWorld3D();
|
||||||
PhysWorld(const PhysWorld&) = delete;
|
PhysWorld3D(const PhysWorld3D&) = delete;
|
||||||
PhysWorld(PhysWorld&&) = delete; ///TODO
|
PhysWorld3D(PhysWorld3D&&) = delete; ///TODO
|
||||||
~PhysWorld();
|
~PhysWorld3D();
|
||||||
|
|
||||||
Vector3f GetGravity() const;
|
Vector3f GetGravity() const;
|
||||||
NewtonWorld* GetHandle() const;
|
NewtonWorld* GetHandle() const;
|
||||||
|
|
@ -34,8 +34,8 @@ namespace Nz
|
||||||
|
|
||||||
void Step(float timestep);
|
void Step(float timestep);
|
||||||
|
|
||||||
PhysWorld& operator=(const PhysWorld&) = delete;
|
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
|
||||||
PhysWorld& operator=(PhysWorld&&) = delete; ///TODO
|
PhysWorld3D& operator=(PhysWorld3D&&) = delete; ///TODO
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector3f m_gravity;
|
Vector3f m_gravity;
|
||||||
|
|
@ -19,13 +19,13 @@ class NewtonBody;
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class PhysWorld;
|
class PhysWorld3D;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API RigidBody3D
|
class NAZARA_PHYSICS3D_API RigidBody3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RigidBody3D(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity());
|
RigidBody3D(PhysWorld3D* world, const Matrix4f& mat = Matrix4f::Identity());
|
||||||
RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity());
|
RigidBody3D(PhysWorld3D* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity());
|
||||||
RigidBody3D(const RigidBody3D& object);
|
RigidBody3D(const RigidBody3D& object);
|
||||||
RigidBody3D(RigidBody3D&& object);
|
RigidBody3D(RigidBody3D&& object);
|
||||||
~RigidBody3D();
|
~RigidBody3D();
|
||||||
|
|
@ -74,7 +74,7 @@ namespace Nz
|
||||||
Vector3f m_forceAccumulator;
|
Vector3f m_forceAccumulator;
|
||||||
Vector3f m_torqueAccumulator;
|
Vector3f m_torqueAccumulator;
|
||||||
NewtonBody* m_body;
|
NewtonBody* m_body;
|
||||||
PhysWorld* m_world;
|
PhysWorld3D* m_world;
|
||||||
float m_gravityFactor;
|
float m_gravityFactor;
|
||||||
float m_mass;
|
float m_mass;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Nz
|
||||||
// Si nous n'avons aucune instance, nous en créons une temporaire
|
// Si nous n'avons aucune instance, nous en créons une temporaire
|
||||||
if (m_handles.empty())
|
if (m_handles.empty())
|
||||||
{
|
{
|
||||||
PhysWorld world;
|
PhysWorld3D world;
|
||||||
|
|
||||||
NewtonCollision* collision = CreateHandle(&world);
|
NewtonCollision* collision = CreateHandle(&world);
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Nz
|
||||||
// Si nous n'avons aucune instance, nous en créons une temporaire
|
// Si nous n'avons aucune instance, nous en créons une temporaire
|
||||||
if (m_handles.empty())
|
if (m_handles.empty())
|
||||||
{
|
{
|
||||||
PhysWorld world;
|
PhysWorld3D world;
|
||||||
|
|
||||||
NewtonCollision* collision = CreateHandle(&world);
|
NewtonCollision* collision = CreateHandle(&world);
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +100,7 @@ namespace Nz
|
||||||
// Si nous n'avons aucune instance, nous en créons une temporaire
|
// Si nous n'avons aucune instance, nous en créons une temporaire
|
||||||
if (m_handles.empty())
|
if (m_handles.empty())
|
||||||
{
|
{
|
||||||
PhysWorld world;
|
PhysWorld3D world;
|
||||||
|
|
||||||
NewtonCollision* collision = CreateHandle(&world);
|
NewtonCollision* collision = CreateHandle(&world);
|
||||||
{
|
{
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Nz
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* Collider3D::GetHandle(PhysWorld* world) const
|
NewtonCollision* Collider3D::GetHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
auto it = m_handles.find(world);
|
auto it = m_handles.find(world);
|
||||||
if (it == m_handles.end())
|
if (it == m_handles.end())
|
||||||
|
|
@ -198,7 +198,7 @@ namespace Nz
|
||||||
return GeomType_Box;
|
return GeomType_Box;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* BoxCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* BoxCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateBox(world->GetHandle(), m_lengths.x, m_lengths.y, m_lengths.z, 0, m_matrix);
|
return NewtonCreateBox(world->GetHandle(), m_lengths.x, m_lengths.y, m_lengths.z, 0, m_matrix);
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ namespace Nz
|
||||||
return GeomType_Capsule;
|
return GeomType_Capsule;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* CapsuleCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* CapsuleCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateCapsule(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
return NewtonCreateCapsule(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +256,7 @@ namespace Nz
|
||||||
return GeomType_Compound;
|
return GeomType_Compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* CompoundCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* CompoundCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
NewtonCollision* compoundCollision = NewtonCreateCompoundCollision(world->GetHandle(), 0);
|
NewtonCollision* compoundCollision = NewtonCreateCompoundCollision(world->GetHandle(), 0);
|
||||||
|
|
||||||
|
|
@ -306,7 +306,7 @@ namespace Nz
|
||||||
return GeomType_Cone;
|
return GeomType_Cone;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* ConeCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* ConeCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateCone(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
return NewtonCreateCone(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +340,7 @@ namespace Nz
|
||||||
return GeomType_Compound;
|
return GeomType_Compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* ConvexCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* ConvexCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateConvexHull(world->GetHandle(), static_cast<int>(m_vertices.size()), reinterpret_cast<const float*>(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix);
|
return NewtonCreateConvexHull(world->GetHandle(), static_cast<int>(m_vertices.size()), reinterpret_cast<const float*>(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix);
|
||||||
}
|
}
|
||||||
|
|
@ -374,7 +374,7 @@ namespace Nz
|
||||||
return GeomType_Cylinder;
|
return GeomType_Cylinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* CylinderCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* CylinderCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateCylinder(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
return NewtonCreateCylinder(world->GetHandle(), m_radius, m_length, 0, m_matrix);
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +399,7 @@ namespace Nz
|
||||||
center->MakeZero();
|
center->MakeZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* NullCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* NullCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateNull(world->GetHandle());
|
return NewtonCreateNull(world->GetHandle());
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +441,7 @@ namespace Nz
|
||||||
return GeomType_Sphere;
|
return GeomType_Sphere;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* SphereCollider3D::CreateHandle(PhysWorld* world) const
|
NewtonCollision* SphereCollider3D::CreateHandle(PhysWorld3D* world) const
|
||||||
{
|
{
|
||||||
return NewtonCreateSphere(world->GetHandle(), m_radius, 0, Matrix4f::Translate(m_position));
|
return NewtonCreateSphere(world->GetHandle(), m_radius, 0, Matrix4f::Translate(m_position));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
PhysWorld::PhysWorld() :
|
PhysWorld3D::PhysWorld3D() :
|
||||||
m_gravity(Vector3f::Zero()),
|
m_gravity(Vector3f::Zero()),
|
||||||
m_stepSize(0.005f),
|
m_stepSize(0.005f),
|
||||||
m_timestepAccumulator(0.f)
|
m_timestepAccumulator(0.f)
|
||||||
|
|
@ -17,42 +17,42 @@ namespace Nz
|
||||||
NewtonWorldSetUserData(m_world, this);
|
NewtonWorldSetUserData(m_world, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysWorld::~PhysWorld()
|
PhysWorld3D::~PhysWorld3D()
|
||||||
{
|
{
|
||||||
NewtonDestroy(m_world);
|
NewtonDestroy(m_world);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f PhysWorld::GetGravity() const
|
Vector3f PhysWorld3D::GetGravity() const
|
||||||
{
|
{
|
||||||
return m_gravity;
|
return m_gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonWorld* PhysWorld::GetHandle() const
|
NewtonWorld* PhysWorld3D::GetHandle() const
|
||||||
{
|
{
|
||||||
return m_world;
|
return m_world;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysWorld::GetStepSize() const
|
float PhysWorld3D::GetStepSize() const
|
||||||
{
|
{
|
||||||
return m_stepSize;
|
return m_stepSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysWorld::SetGravity(const Vector3f& gravity)
|
void PhysWorld3D::SetGravity(const Vector3f& gravity)
|
||||||
{
|
{
|
||||||
m_gravity = gravity;
|
m_gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysWorld::SetSolverModel(unsigned int model)
|
void PhysWorld3D::SetSolverModel(unsigned int model)
|
||||||
{
|
{
|
||||||
NewtonSetSolverModel(m_world, model);
|
NewtonSetSolverModel(m_world, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysWorld::SetStepSize(float stepSize)
|
void PhysWorld3D::SetStepSize(float stepSize)
|
||||||
{
|
{
|
||||||
m_stepSize = stepSize;
|
m_stepSize = stepSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysWorld::Step(float timestep)
|
void PhysWorld3D::Step(float timestep)
|
||||||
{
|
{
|
||||||
m_timestepAccumulator += timestep;
|
m_timestepAccumulator += timestep;
|
||||||
|
|
||||||
|
|
@ -12,12 +12,12 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
RigidBody3D::RigidBody3D(PhysWorld* world, const Matrix4f& mat) :
|
RigidBody3D::RigidBody3D(PhysWorld3D* world, const Matrix4f& mat) :
|
||||||
RigidBody3D(world, NullCollider3D::New(), mat)
|
RigidBody3D(world, NullCollider3D::New(), mat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidBody3D::RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat) :
|
RigidBody3D::RigidBody3D(PhysWorld3D* world, Collider3DRef geom, const Matrix4f& mat) :
|
||||||
m_geom(std::move(geom)),
|
m_geom(std::move(geom)),
|
||||||
m_matrix(mat),
|
m_matrix(mat),
|
||||||
m_forceAccumulator(Vector3f::Zero()),
|
m_forceAccumulator(Vector3f::Zero()),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue