Removed Physics module
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include "CollisionShape.hpp"
|
||||
//#include <Nazara/Physics/CollisionShape.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzCollisionShape::NzCollisionShape(NzPhysicsWorld* world)
|
||||
{
|
||||
m_world = world;
|
||||
m_isCreated = false;
|
||||
newtonCollisionShape = nullptr;
|
||||
}
|
||||
|
||||
NzCollisionShape::~NzCollisionShape()
|
||||
{
|
||||
if(m_isCreated)
|
||||
NewtonReleaseCollision(m_world->newtonWorld, newtonCollisionShape);
|
||||
}
|
||||
|
||||
void NzCollisionShape::Create(const NzVector3f& cubeSize)
|
||||
{
|
||||
newtonCollisionShape = NewtonCreateBox(m_world->newtonWorld, static_cast<dFloat>(cubeSize.x),
|
||||
static_cast<dFloat>(cubeSize.y),
|
||||
static_cast<dFloat>(cubeSize.z), 0, NULL);
|
||||
}
|
||||
|
||||
void NzCollisionShape::Release()
|
||||
{
|
||||
if(m_isCreated)
|
||||
NewtonReleaseCollision(m_world->newtonWorld, newtonCollisionShape);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Physics/Physics.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
#include <Nazara/Physics/Debug.hpp>
|
||||
|
||||
NzPhysics::NzPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
NzPhysics::~NzPhysics()
|
||||
{
|
||||
if (s_initialized)
|
||||
Uninitialize();
|
||||
}
|
||||
|
||||
bool NzPhysics::Initialize()
|
||||
{
|
||||
#if NAZARA_PHYSICS_SAFE
|
||||
if (s_initialized)
|
||||
{
|
||||
NazaraError("Physics already initialized");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialisation du module
|
||||
|
||||
s_initialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzPhysics::Uninitialize()
|
||||
{
|
||||
#if NAZARA_PHYSICS_SAFE
|
||||
if (!s_initialized)
|
||||
{
|
||||
NazaraError("Physics not initialized");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Libération du module
|
||||
|
||||
s_initialized = false;
|
||||
}
|
||||
|
||||
bool NzPhysics::IsInitialized()
|
||||
{
|
||||
return s_initialized;
|
||||
}
|
||||
|
||||
bool NzPhysics::s_initialized = false;
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include "PhysicsWorld.hpp"
|
||||
//#include <Nazara/Physics/PhysicsWorld.hpp>
|
||||
#include "PhysicsEntity.hpp"
|
||||
//#include <Nazara/Physics/PhysicsEntity.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzPhysicsEntity::NzPhysicsEntity(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass) : m_world(world), m_mass(mass)
|
||||
{
|
||||
m_entityMatrix.SetIdentity();
|
||||
m_entityMatrix.SetTranslation(position);
|
||||
|
||||
m_body = NewtonCreateBody(world->newtonWorld, shape.newtonCollisionShape,NULL);
|
||||
|
||||
//NewtonBodySetMatrix(m_pBody, /*&m_entityMatrix.matrice [0][0]*/);//Passage dgMatrix a NzMatrix4 ??
|
||||
|
||||
//Pour rigid bodies uniquement
|
||||
/*
|
||||
// On calcul l'inertie du corps, en passant par une petite formule
|
||||
CVector inertie;
|
||||
|
||||
inertie.x = 0.7f * m_masse * (m_taille.y * m_taille.y + m_taille.z * m_taille.z) / 12;
|
||||
inertie.y = 0.7f * m_masse * (m_taille.x * m_taille.x + m_taille.z * m_taille.z) / 12;
|
||||
inertie.z = 0.7f * m_masse * (m_taille.x * m_taille.x + m_taille.y * m_taille.y) / 12;
|
||||
|
||||
// On définit ensuite la masse et l'inertie pour ce corps
|
||||
NewtonBodySetMassMatrix (m_pBody, m_masse, inertie.x, inertie.y, inertie.z);
|
||||
|
||||
// On règle enfin le Callback, qui sera nécessaire pour que le corps bouge
|
||||
NewtonBodySetForceAndTorqueCallback (m_pBody, ApplyForceAndTorqueCallback);*/
|
||||
}
|
||||
|
||||
void NzPhysicsEntity::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NzPhysicsEntity::~NzPhysicsEntity()
|
||||
{
|
||||
NewtonDestroyBody(m_world->newtonWorld,m_body);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include "PhysicsWorld.hpp"
|
||||
//#include <Nazara/Physics/PhysicsWorld.hpp>
|
||||
#include "PhysicsSolver.hpp"
|
||||
//#include <Nazara/Physics/PhysicsSolver.hpp>
|
||||
#include <Newton/Newton.h>
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzPhysicsSolver::NzPhysicsSolver(nzSolverMode mode, unsigned int numberOfPassesLinearMode)
|
||||
{
|
||||
m_mode = mode;
|
||||
m_numberOfPassesLinearMode = numberOfPassesLinearMode;
|
||||
}
|
||||
|
||||
void NzPhysicsSolver::Configure(nzSolverMode mode, unsigned int numberOfPassesLinearMode)
|
||||
{
|
||||
m_mode = mode;
|
||||
m_numberOfPassesLinearMode = numberOfPassesLinearMode;
|
||||
}
|
||||
|
||||
void NzPhysicsSolver::Set(NzPhysicsWorld* world)
|
||||
{
|
||||
switch(m_mode)
|
||||
{
|
||||
case nzExact:
|
||||
NewtonSetSolverModel(world->newtonWorld, 0);
|
||||
break;
|
||||
|
||||
case nzAdaptative:
|
||||
NewtonSetSolverModel(world->newtonWorld, 1);
|
||||
break;
|
||||
|
||||
case nzLinear:
|
||||
NewtonSetSolverModel(world->newtonWorld, m_numberOfPassesLinearMode);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
NzPhysicsSolver::~NzPhysicsSolver()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include "PhysicsWorld.hpp"
|
||||
//#include <Nazara/Physics/PhysicsWorld.hpp>
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzPhysicsWorld::NzPhysicsWorld()
|
||||
{
|
||||
newtonWorld = NewtonCreate();
|
||||
m_solver.Configure(nzLinear,10);
|
||||
m_solver.Set(this);
|
||||
SetFrictionModel(nzAdaptative);
|
||||
}
|
||||
|
||||
NzPhysicsWorld::~NzPhysicsWorld()
|
||||
{
|
||||
NewtonDestroy(newtonWorld);
|
||||
}
|
||||
|
||||
void NzPhysicsWorld::SetSize(const NzCubef& size)
|
||||
{
|
||||
m_size = size;
|
||||
float bottom[3];
|
||||
bottom[0] = m_size.x;
|
||||
bottom[1] = m_size.y;
|
||||
bottom[2] = m_size.z;
|
||||
float top[3];
|
||||
top[0] = m_size.x + m_size.width;
|
||||
top[1] = m_size.y + m_size.height;
|
||||
top[2] = m_size.z + m_size.depth;
|
||||
|
||||
NewtonSetWorldSize(newtonWorld, static_cast<dFloat*>(bottom),
|
||||
static_cast<dFloat*>(top));
|
||||
}
|
||||
|
||||
const NzCubef& NzPhysicsWorld::GetSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void NzPhysicsWorld::SetPhysicsSolver(const NzPhysicsSolver& solver)
|
||||
{
|
||||
m_solver = solver;
|
||||
m_solver.Set(this);
|
||||
}
|
||||
|
||||
const NzPhysicsSolver& NzPhysicsWorld::GetPhysicsSolver() const
|
||||
{
|
||||
return m_solver;
|
||||
}
|
||||
|
||||
void NzPhysicsWorld::SetFrictionModel(nzFrictionModel model)
|
||||
{
|
||||
switch(model)
|
||||
{
|
||||
case nzExact:
|
||||
NewtonSetFrictionModel(newtonWorld,0);
|
||||
break;
|
||||
|
||||
case nzAdaptative:
|
||||
NewtonSetFrictionModel(newtonWorld,1);
|
||||
break;
|
||||
}
|
||||
|
||||
m_frictionModel = model;
|
||||
}
|
||||
|
||||
const NzPhysicsWorld::nzFrictionModel& NzPhysicsWorld::GetFrictionModel() const
|
||||
{
|
||||
return m_frictionModel;
|
||||
}
|
||||
|
||||
void NzPhysicsWorld::UpdatePhysics(float timestep)
|
||||
{
|
||||
NewtonUpdate(newtonWorld,timestep);//FLOAT WTF ?
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include "StaticBody.hpp"
|
||||
//#include <Nazara/Physics/StaticBody.hpp>
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzStaticBody::NzStaticBody(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass) : NzPhysicsEntity(world,shape,position,mass)
|
||||
{
|
||||
//ctor
|
||||
}
|
||||
|
||||
NzStaticBody::~NzStaticBody()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
Reference in New Issue
Block a user