From 61dbace099a0aa5dab897c28b7a16e28938f48b0 Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Thu, 27 Feb 2014 09:09:28 +0100 Subject: [PATCH] Removed some mf new --- .../Implementation/PhysicsAPI_Impl.cpp | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 772bf32e..62958d07 100644 --- a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -362,11 +362,6 @@ void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef ) void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* args, EventAction_ApplyEffect effect) { - btRigidBody* body; - btCollisionShape* shape; - btMotionState* state; - btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(0, NULL, NULL); - Sphere* sphere; Box* box; Cone* cone; @@ -374,59 +369,61 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* switch(collideable->type) { case ICollideable::Type::Type_sphere: + { sphere = dynamic_cast(collideable); // Add collision shape - shape = new btSphereShape(sphere->radius); + btSphereShape btSphere(sphere->radius); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(sphere->center.x, sphere->center.y, sphere->center.z))); + btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(sphere->center.x, sphere->center.y, sphere->center.z))); // Add rigid body - rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, state, shape); - body = new btRigidBody(rigidBodyCI); - + btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, &state, &btSphere); + btRigidBody body = btRigidBody(rigidBodyCI); + + ContactSensorCallback callback(body, effect, args); + this->dynamicsWorld->contactTest(&body, callback); + } break; case ICollideable::Type::Type_box: + { box = dynamic_cast(collideable); // Add collision shape - shape = new btBoxShape(btVector3(box->boundingOffset.x, box->boundingOffset.y, box->boundingOffset.z)); + btBoxShape btBox = btBoxShape(btVector3(box->boundingOffset.x, box->boundingOffset.y, box->boundingOffset.z)); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(box->center.x, box->center.y, box->center.z))); + btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(box->center.x, box->center.y, box->center.z))); // Add rigid body - rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, state, shape); - body = new btRigidBody(rigidBodyCI); + btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, &state, &btBox); + btRigidBody body = btRigidBody(rigidBodyCI); + ContactSensorCallback callback(body, effect, args); + this->dynamicsWorld->contactTest(&body, callback); + } break; case ICollideable::Type::Type_cone: + { cone = dynamic_cast(collideable); // Add collision shape - shape = new btConeShapeZ(cone->radius, cone->length); + btConeShapeZ coneShape = btConeShapeZ(cone->radius, cone->length); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z))); + btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z))); // Add rigid body - rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, state, shape); - body = new btRigidBody(rigidBodyCI); + btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, &state, &coneShape); + btRigidBody body = btRigidBody(rigidBodyCI); + ContactSensorCallback callback(body, effect, args); + this->dynamicsWorld->contactTest(&body, callback); + } break; default: return; } - ContactSensorCallback callback(*body, effect, args); - - this->dynamicsWorld->contactTest(body, callback); - - delete state; - state = NULL; - delete shape; - shape = NULL; - delete body; - body = NULL; } namespace Oyster