issue #2771: change debug draw defines to class static const variable

This commit is contained in:
boyu0 2013-11-18 10:10:37 +08:00
Родитель 8ab64c9fa8
Коммит a7d884a63f
3 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -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)
{

Просмотреть файл

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

Просмотреть файл

@ -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()