From b41fbb70acb78087261a449d7f47dcc481fec24c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 21 Oct 2017 19:05:21 +0200 Subject: [PATCH] [DEV] update to the new ETK allocator wrapper --- ege/elements/ElementPhysic.cpp | 10 +++++----- ege/physics/Component.cpp | 18 +++++++++--------- ege/physics/Engine.cpp | 4 ++-- sample/CameraPosition/appl/main.cpp | 2 +- sample/Collision/appl/main.cpp | 2 +- sample/DoubleView/appl/main.cpp | 2 +- sample/LowPoly/appl/main.cpp | 2 +- sample/MeshCreator/appl/main.cpp | 2 +- sample/RayTest/appl/main.cpp | 2 +- sample/TorqueApply/appl/main.cpp | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ege/elements/ElementPhysic.cpp b/ege/elements/ElementPhysic.cpp index 7c40d78..64e78a7 100644 --- a/ege/elements/ElementPhysic.cpp +++ b/ege/elements/ElementPhysic.cpp @@ -118,13 +118,13 @@ void ege::ElementPhysic::removeShape() { // need to chek if the shape is the same as the mesh shape ... if (m_mesh == nullptr) { // no mesh == > standalone shape - delete(m_shape); + ETK_DELETE(btCollisionShape, m_shape); m_shape=nullptr; EGE_WARNING("Remove shape .2."); return; } if (m_shape != m_mesh->getShape()) { - delete(m_shape); + ETK_DELETE(btCollisionShape, m_shape); m_shape=nullptr; EGE_WARNING("Remove shape .3."); return; @@ -136,7 +136,7 @@ void ege::ElementPhysic::FunctionFreeShape(void* _pointer) { if (_pointer == nullptr) { return; } - delete(static_cast(_pointer)); + ETK_DELETE(btCollisionShape, _pointer); } */ void ege::ElementPhysic::setPosition(const vec3& _pos) { @@ -389,7 +389,7 @@ void ege::ElementPhysic::iaEnable() { // IA already started ... return; } - m_IA = new localIA(*this); + m_IA = ETK_NEW(localIA, *this); if (m_IA == nullptr) { EGE_ERROR("Can not start the IA == > allocation error"); return; @@ -408,7 +408,7 @@ void ege::ElementPhysic::iaDisable() { //m_env->getPhysicEngine().getDynamicWorld()->removeAction(m_IA); } // remove IA: - delete(m_IA); + ETK_DELETE(localIA, m_IA); m_IA = nullptr; } diff --git a/ege/physics/Component.cpp b/ege/physics/Component.cpp index c2674b0..b6effd4 100644 --- a/ege/physics/Component.cpp +++ b/ege/physics/Component.cpp @@ -115,7 +115,7 @@ void ege::physics::Component::generate() { tmpElement->getSize().y(), tmpElement->getSize().z()); // Create the box shape - ephysics::BoxShape* shape = new ephysics::BoxShape(halfExtents, 0.0001); + ephysics::BoxShape* shape = ETK_NEW(ephysics::BoxShape, halfExtents, 0.0001); m_listShape.pushBack(shape); // The ephysic use Y as UP ==> ege use Z as UP //orientation = orientation * ephysics::Quaternion(-0.707107, 0, 0, 0.707107); @@ -133,7 +133,7 @@ void ege::physics::Component::generate() { continue; } // Create the Cylinder shape - ephysics::CylinderShape* shape = new ephysics::CylinderShape(tmpElement->getRadius(), tmpElement->getSize()); + ephysics::CylinderShape* shape = ETK_NEW(ephysics::CylinderShape, tmpElement->getRadius(), tmpElement->getSize()); // The ephysic use Y as UP ==> ege use Z as UP etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107); etk::Transform3D transform(it->getOrigin(), orientation); @@ -150,7 +150,7 @@ void ege::physics::Component::generate() { continue; } // Create the Capsule shape - ephysics::CapsuleShape* shape = new ephysics::CapsuleShape(tmpElement->getRadius(), tmpElement->getSize()); + ephysics::CapsuleShape* shape = ETK_NEW(ephysics::CapsuleShape, tmpElement->getRadius(), tmpElement->getSize()); // The ephysic use Y as UP ==> ege use Z as UP etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107); etk::Transform3D transform(it->getOrigin(), orientation); @@ -167,7 +167,7 @@ void ege::physics::Component::generate() { continue; } // Create the Cone shape - ephysics::ConeShape* shape = new ephysics::ConeShape(tmpElement->getRadius(), tmpElement->getSize()); + ephysics::ConeShape* shape = ETK_NEW(ephysics::ConeShape, tmpElement->getRadius(), tmpElement->getSize()); // The ephysic use Y as UP ==> ege use Z as UP etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107); etk::Transform3D transform(it->getOrigin(), orientation); @@ -184,7 +184,7 @@ void ege::physics::Component::generate() { continue; } // Create the box shape - ephysics::SphereShape* shape = new ephysics::SphereShape(tmpElement->getRadius()); + ephysics::SphereShape* shape = ETK_NEW(ephysics::SphereShape, tmpElement->getRadius()); // The ephysic use Y as UP ==> ege use Z as UP etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107); etk::Transform3D transform(it->getOrigin(), orientation); @@ -204,18 +204,18 @@ void ege::physics::Component::generate() { static const etk::Vector vertices = {vec3(-100.0f,-100.0f,-50.0f),vec3(100.0f,-100.0f,-50.0f),vec3(100.0f,100.0f,-50.0f)}; static const etk::Vector indices = {0,1,2}; - ephysics::TriangleVertexArray* triangleArray = new ephysics::TriangleVertexArray(vertices, indices); + ephysics::TriangleVertexArray* triangleArray = ETK_NEW(ephysics::TriangleVertexArray, vertices, indices); #else - ephysics::TriangleVertexArray* triangleArray = new ephysics::TriangleVertexArray(tmpElement->getVertex(), tmpElement->getIndices()); + ephysics::TriangleVertexArray* triangleArray = ETK_NEW(ephysics::TriangleVertexArray, tmpElement->getVertex(), tmpElement->getIndices()); #endif // Now that we have a TriangleVertexArray, we need to create a TriangleMesh and add the TriangleVertexArray into it as a subpart. // Once this is done, we can create the actual ConcaveMeshShape and add it to the body we want to simulate as in the following example: - ephysics::TriangleMesh* triangleMesh = new ephysics::TriangleMesh(); + ephysics::TriangleMesh* triangleMesh = ETK_NEW(ephysics::TriangleMesh); // Add the triangle vertex array to the triangle mesh triangleMesh->addSubpart(triangleArray); // Create the concave mesh shape // TODO : Manage memory leak ... - ephysics::ConcaveShape* shape = new ephysics::ConcaveMeshShape(triangleMesh); + ephysics::ConcaveShape* shape = ETK_NEW(ephysics::ConcaveMeshShape, triangleMesh); // The ephysic use Y as UP ==> ege use Z as UP etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107); etk::Transform3D transform(it->getOrigin(), it->getOrientation()); diff --git a/ege/physics/Engine.cpp b/ege/physics/Engine.cpp index e7a29eb..a33a016 100644 --- a/ege/physics/Engine.cpp +++ b/ege/physics/Engine.cpp @@ -94,7 +94,7 @@ ege::physics::Engine::Engine(ege::Environement* _env) : // Start engine with no gravity vec3 gravity(0.0f, 0.0f, 0.0f); // Create the dynamics world - m_dynamicsWorld = new ephysics::DynamicsWorld(gravity); + m_dynamicsWorld = ETK_NEW(ephysics::DynamicsWorld, gravity); if (m_dynamicsWorld != nullptr) { // Set the number of iterations of the constraint solver m_dynamicsWorld->setNbIterationsVelocitySolver(15); @@ -105,7 +105,7 @@ ege::physics::Engine::Engine(ege::Environement* _env) : ege::physics::Engine::~Engine() { if (m_dynamicsWorld != nullptr) { m_dynamicsWorld->setEventListener(nullptr); - delete m_dynamicsWorld; + ETK_DELETE(ephysics::DynamicsWorld, m_dynamicsWorld); m_dynamicsWorld = nullptr; } } diff --git a/sample/CameraPosition/appl/main.cpp b/sample/CameraPosition/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/CameraPosition/appl/main.cpp +++ b/sample/CameraPosition/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/Collision/appl/main.cpp b/sample/Collision/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/Collision/appl/main.cpp +++ b/sample/Collision/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/DoubleView/appl/main.cpp b/sample/DoubleView/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/DoubleView/appl/main.cpp +++ b/sample/DoubleView/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/LowPoly/appl/main.cpp b/sample/LowPoly/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/LowPoly/appl/main.cpp +++ b/sample/LowPoly/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/MeshCreator/appl/main.cpp b/sample/MeshCreator/appl/main.cpp index 6d64f64..3318987 100644 --- a/sample/MeshCreator/appl/main.cpp +++ b/sample/MeshCreator/appl/main.cpp @@ -77,7 +77,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/RayTest/appl/main.cpp b/sample/RayTest/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/RayTest/appl/main.cpp +++ b/sample/RayTest/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); } diff --git a/sample/TorqueApply/appl/main.cpp b/sample/TorqueApply/appl/main.cpp index 939d939..48896c3 100644 --- a/sample/TorqueApply/appl/main.cpp +++ b/sample/TorqueApply/appl/main.cpp @@ -62,7 +62,7 @@ class MainApplication : public ewol::context::Application { */ int main(int _argc, const char *_argv[]) { // second possibility - return ewol::run(new MainApplication(), _argc, _argv); + return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv); }