From a7d884a63f30c84e3fad28350b2b864e23343701 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 18 Nov 2013 10:10:37 +0800 Subject: [PATCH] issue #2771: change debug draw defines to class static const variable --- cocos/physics/CCPhysicsWorld.cpp | 10 +++++----- cocos/physics/CCPhysicsWorld.h | 14 +++++++------- .../TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 812c70f705..fa7ee8c058 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -618,7 +618,7 @@ void PhysicsWorld::update(float delta) cpSpaceStep(_info->getSpace(), delta); - if (_debugDrawMask != PHYSICS_DEBUGDRAW_NONE) + if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } @@ -635,7 +635,7 @@ void PhysicsWorld::debugDraw() { if (_debugDraw->begin()) { - if (_debugDrawMask & PHYSICS_DEBUGDRAW_SHAPE) + if (_debugDrawMask & DEBUGDRAW_SHAPE) { for (Object* obj : *_bodies) { @@ -648,7 +648,7 @@ void PhysicsWorld::debugDraw() } } - if (_debugDrawMask & PHYSICS_DEBUGDRAW_JOINT) + if (_debugDrawMask & DEBUGDRAW_JOINT) { for (auto joint : _joints) { @@ -663,7 +663,7 @@ void PhysicsWorld::debugDraw() void PhysicsWorld::setDebugDrawMask(int mask) { - if (mask == PHYSICS_DEBUGDRAW_NONE) + if (mask == DEBUGDRAW_NONE) { CC_SAFE_DELETE(_debugDraw); } @@ -1039,7 +1039,7 @@ PhysicsWorld::PhysicsWorld() , _scene(nullptr) , _delayDirty(false) , _debugDraw(nullptr) -, _debugDrawMask(PHYSICS_DEBUGDRAW_NONE) +, _debugDrawMask(DEBUGDRAW_NONE) , _delayAddBodies(nullptr) , _delayRemoveBodies(nullptr) { diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index d3070a0bc5..d176c1f56d 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -50,13 +50,6 @@ class PhysicsDebugDraw; class PhysicsWorld; -#define PHYSICS_DEBUGDRAW_NONE 0x00 -#define PHYSICS_DEBUGDRAW_SHAPE 0x01 -#define PHYSICS_DEBUGDRAW_JOINT 0x02 -#define PHYSICS_DEBUGDRAW_CONTACT 0x04 -#define PHYSICS_DEBUGDRAW_ALL PHYSICS_DEBUGDRAW_SHAPE | PHYSICS_DEBUGDRAW_JOINT | PHYSICS_DEBUGDRAW_CONTACT - - typedef struct PhysicsRayCastInfo { PhysicsShape* shape; @@ -87,6 +80,13 @@ typedef PhysicsRectQueryCallbackFunc PhysicsPointQueryCallbackFunc; */ class PhysicsWorld { +public: + static const long DEBUGDRAW_NONE = 0x00; + static const long DEBUGDRAW_SHAPE = 0x01; + static const long DEBUGDRAW_JOINT = 0x02; + static const long DEBUGDRAW_CONTACT = 0x04; + static const long DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT; + public: /** Adds a joint to the physics world.*/ virtual void addJoint(PhysicsJoint* joint); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 0fd2c73733..19a6d25c6d 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -69,7 +69,7 @@ bool PhysicsTestScene::initTest() { if (_debugDraw) { - getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PHYSICS_DEBUGDRAW_ALL : PHYSICS_DEBUGDRAW_NONE); + getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE); } return true; } @@ -94,7 +94,7 @@ void PhysicsTestScene::runThisTest() void PhysicsTestScene::toggleDebug() { _debugDraw = !_debugDraw; - getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PHYSICS_DEBUGDRAW_ALL : PHYSICS_DEBUGDRAW_NONE); + getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE); } PhysicsDemo::PhysicsDemo()