From 9996a7169a133955b7eba25dd2d3959dc9696c9e Mon Sep 17 00:00:00 2001 From: Remi Beges Date: Tue, 19 Jun 2012 18:31:42 +0200 Subject: [PATCH] Removed Physics module --- include/Nazara/Physics/CollisionShape.hpp | 36 ----------- include/Nazara/Physics/Config.hpp | 38 ----------- include/Nazara/Physics/Debug.hpp | 11 ---- include/Nazara/Physics/DebugOff.hpp | 8 --- include/Nazara/Physics/Physics.hpp | 27 -------- include/Nazara/Physics/PhysicsEntity.hpp | 33 ---------- include/Nazara/Physics/PhysicsSolver.hpp | 34 ---------- include/Nazara/Physics/PhysicsWorld.hpp | 51 --------------- include/Nazara/Physics/StaticBody.hpp | 23 ------- src/Nazara/Physics/CollisionShape.cpp | 33 ---------- src/Nazara/Physics/Physics.cpp | 57 ---------------- src/Nazara/Physics/PhysicsEntity.cpp | 44 ------------- src/Nazara/Physics/PhysicsSolver.cpp | 46 ------------- src/Nazara/Physics/PhysicsWorld.cpp | 79 ----------------------- src/Nazara/Physics/StaticBody.cpp | 18 ------ 15 files changed, 538 deletions(-) delete mode 100644 include/Nazara/Physics/CollisionShape.hpp delete mode 100644 include/Nazara/Physics/Config.hpp delete mode 100644 include/Nazara/Physics/Debug.hpp delete mode 100644 include/Nazara/Physics/DebugOff.hpp delete mode 100644 include/Nazara/Physics/Physics.hpp delete mode 100644 include/Nazara/Physics/PhysicsEntity.hpp delete mode 100644 include/Nazara/Physics/PhysicsSolver.hpp delete mode 100644 include/Nazara/Physics/PhysicsWorld.hpp delete mode 100644 include/Nazara/Physics/StaticBody.hpp delete mode 100644 src/Nazara/Physics/CollisionShape.cpp delete mode 100644 src/Nazara/Physics/Physics.cpp delete mode 100644 src/Nazara/Physics/PhysicsEntity.cpp delete mode 100644 src/Nazara/Physics/PhysicsSolver.cpp delete mode 100644 src/Nazara/Physics/PhysicsWorld.cpp delete mode 100644 src/Nazara/Physics/StaticBody.cpp diff --git a/include/Nazara/Physics/CollisionShape.hpp b/include/Nazara/Physics/CollisionShape.hpp deleted file mode 100644 index 4770decd8..000000000 --- a/include/Nazara/Physics/CollisionShape.hpp +++ /dev/null @@ -1,36 +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 - -#pragma once - -#ifndef COLLISIONSHAPE_HPP -#define COLLISIONSHAPE_HPP - -#include -#include "PhysicsWorld.hpp" -//#include - -class NzCollisionShape -{ - public: - NzCollisionShape(NzPhysicsWorld* world); - ~NzCollisionShape(); - - void Create(const NzVector3f& cubeSize); - //void Create(const NzSpheref& sphere); - //void Create(const NzConef& cone); - //void Create(const NzMesh& customMesh); - void Release(); - - bool IsValid(); - - NewtonCollision* newtonCollisionShape; - - protected: - private: - NzPhysicsWorld* m_world; - bool m_isCreated; -}; - -#endif // COLLISIONSHAPE_HPP diff --git a/include/Nazara/Physics/Config.hpp b/include/Nazara/Physics/Config.hpp deleted file mode 100644 index a5af060c0..000000000 --- a/include/Nazara/Physics/Config.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Nazara Engine - - Copyright (C) 2012 AUTHORS (EMAIL) - - 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 tracker pour repérer les éventuels leaks (Ralentit l'exécution) -#define NAZARA_PHYSICS_MEMORYLEAKTRACKER 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_PHYSICS_SAFE 1 - -#endif // NAZARA_CONFIG_PHYSICS_HPP diff --git a/include/Nazara/Physics/Debug.hpp b/include/Nazara/Physics/Debug.hpp deleted file mode 100644 index a0144954a..000000000 --- a/include/Nazara/Physics/Debug.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2012 AUTHORS -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_PHYSICS_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #include - - #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete - #define new new(__FILE__, __LINE__) -#endif diff --git a/include/Nazara/Physics/DebugOff.hpp b/include/Nazara/Physics/DebugOff.hpp deleted file mode 100644 index 813b9165e..000000000 --- a/include/Nazara/Physics/DebugOff.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2012 AUTHORS -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#if NAZARA_PHYSICS_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #undef delete - #undef new -#endif diff --git a/include/Nazara/Physics/Physics.hpp b/include/Nazara/Physics/Physics.hpp deleted file mode 100644 index c36ce3fad..000000000 --- a/include/Nazara/Physics/Physics.hpp +++ /dev/null @@ -1,27 +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 - -#pragma once - -#ifndef NAZARA_PHYSICS_HPP -#define NAZARA_PHYSICS_HPP - -#include - -class NAZARA_API NzPhysics -{ - public: - NzPhysics(); - ~NzPhysics(); - - bool Initialize(); - void Uninitialize(); - - static bool IsInitialized(); - - private: - static bool s_initialized; -}; - -#endif // NAZARA_PHYSICS_HPP diff --git a/include/Nazara/Physics/PhysicsEntity.hpp b/include/Nazara/Physics/PhysicsEntity.hpp deleted file mode 100644 index 3f9e9a40b..000000000 --- a/include/Nazara/Physics/PhysicsEntity.hpp +++ /dev/null @@ -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 - -#pragma once - -#ifndef PHYSICSENTITY_HPP -#define PHYSICSENTITY_HPP - -#include -#include -#include -//#include -#include "CollisionShape.hpp" - -class NzPhysicsWorld; - -class NzPhysicsEntity -{ - public: - NzPhysicsEntity(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass); - virtual void Init(); - virtual ~NzPhysicsEntity(); - protected: - NzPhysicsWorld* m_world; - NewtonBody* m_body; - float m_mass; - NzMatrix4f m_entityMatrix; - private: - -}; - -#endif // PHYSICSENTITY_HPP diff --git a/include/Nazara/Physics/PhysicsSolver.hpp b/include/Nazara/Physics/PhysicsSolver.hpp deleted file mode 100644 index 86a7b0b17..000000000 --- a/include/Nazara/Physics/PhysicsSolver.hpp +++ /dev/null @@ -1,34 +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 - -#pragma once - -#ifndef PHYSICSSOLVER_HPP -#define PHYSICSSOLVER_HPP - -#include - -enum nzSolverMode -{ - nzExact, - nzAdaptative, - nzLinear -}; - -class NzPhysicsWorld; - -class NzPhysicsSolver -{ - public: - NzPhysicsSolver(nzSolverMode mode = nzLinear, unsigned int numberOfPassesLinearMode = 10); - void Configure(nzSolverMode mode, unsigned int numberOfPassesLinearMode); - void Set(NzPhysicsWorld* world); - ~NzPhysicsSolver(); - protected: - private: - nzSolverMode m_mode; - unsigned int m_numberOfPassesLinearMode; -}; - -#endif // PHYSICSSOLVER_HPP diff --git a/include/Nazara/Physics/PhysicsWorld.hpp b/include/Nazara/Physics/PhysicsWorld.hpp deleted file mode 100644 index e52536ce5..000000000 --- a/include/Nazara/Physics/PhysicsWorld.hpp +++ /dev/null @@ -1,51 +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 - -#pragma once - -#ifndef PHYSICSWORLD_HPP -#define PHYSICSWORLD_HPP - -#include -#include -#include -#include -#include "PhysicsSolver.hpp" -//#include - -//TODO : ajouter Axis Aligned Bounding Box - -class NzPhysicsWorld -{ - enum nzFrictionModel - { - nzExact, - nzAdaptative - }; - - public: - NzPhysicsWorld(); - ~NzPhysicsWorld(); - - void SetSize(const NzCubef& size); - const NzCubef& GetSize() const; - - void SetPhysicsSolver(const NzPhysicsSolver& solver); - const NzPhysicsSolver& GetPhysicsSolver() const; - - void SetFrictionModel(nzFrictionModel model); - const nzFrictionModel& GetFrictionModel() const; - - void UpdatePhysics(float timestep); - - NewtonWorld* newtonWorld; - - protected: - private: - NzPhysicsSolver m_solver; - nzFrictionModel m_frictionModel; - NzCubef m_size; -}; - -#endif // PHYSICSWORLD_HPP diff --git a/include/Nazara/Physics/StaticBody.hpp b/include/Nazara/Physics/StaticBody.hpp deleted file mode 100644 index 222c15b05..000000000 --- a/include/Nazara/Physics/StaticBody.hpp +++ /dev/null @@ -1,23 +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 - -#pragma once - -#ifndef STATICBODY_HPP -#define STATICBODY_HPP - -#include -//#include -#include "PhysicsEntity.hpp" - -class NzStaticBody : public NzPhysicsEntity -{ - public: - NzStaticBody(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass); - ~NzStaticBody(); - protected: - private: -}; - -#endif // STATICBODY_HPP diff --git a/src/Nazara/Physics/CollisionShape.cpp b/src/Nazara/Physics/CollisionShape.cpp deleted file mode 100644 index 839c312a1..000000000 --- a/src/Nazara/Physics/CollisionShape.cpp +++ /dev/null @@ -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 -#include - -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(cubeSize.x), - static_cast(cubeSize.y), - static_cast(cubeSize.z), 0, NULL); -} - -void NzCollisionShape::Release() -{ - if(m_isCreated) - NewtonReleaseCollision(m_world->newtonWorld, newtonCollisionShape); -} diff --git a/src/Nazara/Physics/Physics.cpp b/src/Nazara/Physics/Physics.cpp deleted file mode 100644 index 961aed0d5..000000000 --- a/src/Nazara/Physics/Physics.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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; diff --git a/src/Nazara/Physics/PhysicsEntity.cpp b/src/Nazara/Physics/PhysicsEntity.cpp deleted file mode 100644 index 51d3e965a..000000000 --- a/src/Nazara/Physics/PhysicsEntity.cpp +++ /dev/null @@ -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 -#include "PhysicsEntity.hpp" -//#include -#include - -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); -} diff --git a/src/Nazara/Physics/PhysicsSolver.cpp b/src/Nazara/Physics/PhysicsSolver.cpp deleted file mode 100644 index e062dc4ed..000000000 --- a/src/Nazara/Physics/PhysicsSolver.cpp +++ /dev/null @@ -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 -#include "PhysicsSolver.hpp" -//#include -#include - -#include - -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 -} diff --git a/src/Nazara/Physics/PhysicsWorld.cpp b/src/Nazara/Physics/PhysicsWorld.cpp deleted file mode 100644 index dabbfd91b..000000000 --- a/src/Nazara/Physics/PhysicsWorld.cpp +++ /dev/null @@ -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 - -#include - -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(bottom), - static_cast(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 ? -} diff --git a/src/Nazara/Physics/StaticBody.cpp b/src/Nazara/Physics/StaticBody.cpp deleted file mode 100644 index 118d4b627..000000000 --- a/src/Nazara/Physics/StaticBody.cpp +++ /dev/null @@ -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 - -#include - -NzStaticBody::NzStaticBody(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass) : NzPhysicsEntity(world,shape,position,mass) -{ - //ctor -} - -NzStaticBody::~NzStaticBody() -{ - //dtor -}