[DEV] update to the new ETK allocator wrapper

This commit is contained in:
Edouard DUPIN 2017-10-21 19:05:21 +02:00
parent 4a87d37e78
commit b41fbb70ac
10 changed files with 23 additions and 23 deletions

View File

@ -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<btCollisionShape*>(_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;
}

View File

@ -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<vec3> 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<uint32_t> 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());

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}