From fdaa0bbfc66df3e436083bb9cf4ad270bf15e0f0 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 6 Jan 2015 10:29:07 +0800 Subject: [PATCH 1/2] Remove XXXXInfo_chipmunk class in 'chipmunk' folder to simplify implementation of physics --- cocos/physics/CCPhysicsBody.cpp | 119 +++++----- cocos/physics/CCPhysicsBody.h | 7 +- cocos/physics/CCPhysicsContact.cpp | 11 +- cocos/physics/CCPhysicsContact.h | 3 - ...icsHelper_chipmunk.h => CCPhysicsHelper.h} | 0 cocos/physics/CCPhysicsJoint.cpp | 211 +++++++++--------- cocos/physics/CCPhysicsJoint.h | 11 +- cocos/physics/CCPhysicsShape.cpp | 202 ++++++++--------- cocos/physics/CCPhysicsShape.h | 16 +- cocos/physics/CCPhysicsWorld.cpp | 143 ++++++------ cocos/physics/CCPhysicsWorld.h | 5 +- .../chipmunk/CCPhysicsBodyInfo_chipmunk.cpp | 41 ---- .../chipmunk/CCPhysicsBodyInfo_chipmunk.h | 57 ----- .../CCPhysicsContactInfo_chipmunk.cpp | 40 ---- .../chipmunk/CCPhysicsContactInfo_chipmunk.h | 53 ----- .../chipmunk/CCPhysicsJointInfo_chipmunk.cpp | 85 ------- .../chipmunk/CCPhysicsJointInfo_chipmunk.h | 65 ------ .../chipmunk/CCPhysicsShapeInfo_chipmunk.cpp | 118 ---------- .../chipmunk/CCPhysicsShapeInfo_chipmunk.h | 73 ------ .../chipmunk/CCPhysicsWorldInfo_chipmunk.cpp | 112 ---------- .../chipmunk/CCPhysicsWorldInfo_chipmunk.h | 71 ------ 21 files changed, 348 insertions(+), 1095 deletions(-) rename cocos/physics/{chipmunk/CCPhysicsHelper_chipmunk.h => CCPhysicsHelper.h} (100%) delete mode 100644 cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp delete mode 100644 cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h delete mode 100644 cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp delete mode 100644 cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h delete mode 100644 cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp delete mode 100644 cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h delete mode 100644 cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp delete mode 100644 cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h delete mode 100644 cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp delete mode 100644 cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 46b80c3273..75183606eb 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -31,16 +31,10 @@ #include "chipmunk.h" #include "2d/CCScene.h" - -#include "physics/CCPhysicsShape.h" -#include "physics/CCPhysicsJoint.h" -#include "physics/CCPhysicsWorld.h" - -#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" -#include "chipmunk/CCPhysicsJointInfo_chipmunk.h" -#include "chipmunk/CCPhysicsWorldInfo_chipmunk.h" -#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" -#include "chipmunk/CCPhysicsHelper_chipmunk.h" +#include "CCPhysicsShape.h" +#include "CCPhysicsJoint.h" +#include "CCPhysicsWorld.h" +#include "CCPhysicsHelper.h" static inline void cpBodyUpdateVelocityWithoutGravity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) { @@ -59,7 +53,7 @@ namespace PhysicsBody::PhysicsBody() : _node(nullptr) , _world(nullptr) -, _info(nullptr) +, _cpBody(nullptr) , _dynamic(true) , _enabled(true) , _rotationEnabled(true) @@ -91,7 +85,10 @@ PhysicsBody::~PhysicsBody() delete joint; } - CC_SAFE_DELETE(_info); + if (_cpBody) + { + cpBodyFree(_cpBody); + } } PhysicsBody* PhysicsBody::create() @@ -255,12 +252,9 @@ bool PhysicsBody::init() { do { - _info = new (std::nothrow) PhysicsBodyInfo(); - CC_BREAK_IF(_info == nullptr); + _cpBody = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment)); - _info->setBody(cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment))); - - CC_BREAK_IF(_info->getBody() == nullptr); + CC_BREAK_IF(_cpBody == nullptr); return true; } while (false); @@ -283,33 +277,32 @@ void PhysicsBody::setDynamic(bool dynamic) if (dynamic != _dynamic) { _dynamic = dynamic; - auto body = _info->getBody(); if (dynamic) { - if (_world && body->CP_PRIVATE(space)) + if (_world && _cpBody->CP_PRIVATE(space)) { - cpSpaceConvertBodyToDynamic(_world->_info->getSpace(), body, _mass, _moment); - cpSpaceAddBody(_world->_info->getSpace(), body); + cpSpaceConvertBodyToDynamic(_world->_cpSpace, _cpBody, _mass, _moment); + cpSpaceAddBody(_world->_cpSpace, _cpBody); } else { - cpBodySetMass(body, _mass); - cpBodySetMoment(body, _moment); - body->CP_PRIVATE(node).idleTime = 0.0f; + cpBodySetMass(_cpBody, _mass); + cpBodySetMoment(_cpBody, _moment); + _cpBody->CP_PRIVATE(node).idleTime = 0.0f; } } else { - if (_world && body->CP_PRIVATE(space)) + if (_world && _cpBody->CP_PRIVATE(space)) { - cpSpaceRemoveBody(_world->_info->getSpace(), body); - cpSpaceConvertBodyToStatic(_world->_info->getSpace(), body); + cpSpaceRemoveBody(_world->_cpSpace, _cpBody); + cpSpaceConvertBodyToStatic(_world->_cpSpace, _cpBody); } else { - cpBodySetMass(body, PHYSICS_INFINITY); - cpBodySetMoment(body, PHYSICS_INFINITY); - body->CP_PRIVATE(node).idleTime = (cpFloat)INFINITY; + cpBodySetMass(_cpBody, PHYSICS_INFINITY); + cpBodySetMoment(_cpBody, PHYSICS_INFINITY); + _cpBody->CP_PRIVATE(node).idleTime = (cpFloat)INFINITY; } } } @@ -319,7 +312,7 @@ void PhysicsBody::setRotationEnable(bool enable) { if (_rotationEnabled != enable) { - cpBodySetMoment(_info->getBody(), enable ? _moment : PHYSICS_INFINITY); + cpBodySetMoment(_cpBody, enable ? _moment : PHYSICS_INFINITY); _rotationEnabled = enable; } } @@ -330,22 +323,22 @@ void PhysicsBody::setGravityEnable(bool enable) if (enable) { - _info->getBody()->velocity_func = cpBodyUpdateVelocity; + _cpBody->velocity_func = cpBodyUpdateVelocity; } else { - _info->getBody()->velocity_func = cpBodyUpdateVelocityWithoutGravity; + _cpBody->velocity_func = cpBodyUpdateVelocityWithoutGravity; } } void PhysicsBody::setPosition(const Vec2& position) { - cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position + _positionOffset)); + cpBodySetPos(_cpBody, PhysicsHelper::point2cpv(position + _positionOffset)); } void PhysicsBody::setRotation(float rotation) { - cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f))); + cpBodySetAngle(_cpBody, -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f))); } void PhysicsBody::setScale(float scale) @@ -382,13 +375,13 @@ void PhysicsBody::setScaleY(float scaleY) Vec2 PhysicsBody::getPosition() const { - cpVect vec = cpBodyGetPos(_info->getBody()); + cpVect vec = cpBodyGetPos(_cpBody); return PhysicsHelper::cpv2point(vec) - _positionOffset; } float PhysicsBody::getRotation() const { - return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) * (180.0f / M_PI)) - _rotationOffset; + return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_cpBody) * (180.0f / M_PI)) - _rotationOffset; } PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* = true*/) @@ -429,13 +422,13 @@ void PhysicsBody::applyForce(const Vect& force, const Vec2& offset) { if (_dynamic && _mass != PHYSICS_INFINITY) { - cpBodyApplyForce(_info->getBody(), PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset)); + cpBodyApplyForce(_cpBody, PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset)); } } void PhysicsBody::resetForces() { - cpBodyResetForces(_info->getBody()); + cpBodyResetForces(_cpBody); } void PhysicsBody::applyImpulse(const Vect& impulse) @@ -445,12 +438,12 @@ void PhysicsBody::applyImpulse(const Vect& impulse) void PhysicsBody::applyImpulse(const Vect& impulse, const Vec2& offset) { - cpBodyApplyImpulse(_info->getBody(), PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset)); + cpBodyApplyImpulse(_cpBody, PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset)); } void PhysicsBody::applyTorque(float torque) { - cpBodySetTorque(_info->getBody(), PhysicsHelper::float2cpfloat(torque)); + cpBodySetTorque(_cpBody, PhysicsHelper::float2cpfloat(torque)); } void PhysicsBody::setMass(float mass) @@ -481,7 +474,7 @@ void PhysicsBody::setMass(float mass) // the static body's mass and moment is always infinity if (_dynamic) { - cpBodySetMass(_info->getBody(), _mass); + cpBodySetMass(_cpBody, _mass); } } @@ -527,7 +520,7 @@ void PhysicsBody::addMass(float mass) // the static body's mass and moment is always infinity if (_dynamic) { - cpBodySetMass(_info->getBody(), _mass); + cpBodySetMass(_cpBody, _mass); } } @@ -569,7 +562,7 @@ void PhysicsBody::addMoment(float moment) // the static body's mass and moment is always infinity if (_rotationEnabled && _dynamic) { - cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment)); + cpBodySetMoment(_cpBody, PhysicsHelper::float2cpfloat(_moment)); } } @@ -581,22 +574,22 @@ void PhysicsBody::setVelocity(const Vec2& velocity) return; } - cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity)); + cpBodySetVel(_cpBody, PhysicsHelper::point2cpv(velocity)); } Vec2 PhysicsBody::getVelocity() { - return PhysicsHelper::cpv2point(cpBodyGetVel(_info->getBody())); + return PhysicsHelper::cpv2point(cpBodyGetVel(_cpBody)); } Vec2 PhysicsBody::getVelocityAtLocalPoint(const Vec2& point) { - return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); + return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_cpBody, PhysicsHelper::point2cpv(point))); } Vec2 PhysicsBody::getVelocityAtWorldPoint(const Vec2& point) { - return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); + return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_cpBody, PhysicsHelper::point2cpv(point))); } void PhysicsBody::setAngularVelocity(float velocity) @@ -607,32 +600,32 @@ void PhysicsBody::setAngularVelocity(float velocity) return; } - cpBodySetAngVel(_info->getBody(), PhysicsHelper::float2cpfloat(velocity)); + cpBodySetAngVel(_cpBody, PhysicsHelper::float2cpfloat(velocity)); } float PhysicsBody::getAngularVelocity() { - return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_info->getBody())); + return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_cpBody)); } void PhysicsBody::setVelocityLimit(float limit) { - cpBodySetVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit)); + cpBodySetVelLimit(_cpBody, PhysicsHelper::float2cpfloat(limit)); } float PhysicsBody::getVelocityLimit() { - return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_info->getBody())); + return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_cpBody)); } void PhysicsBody::setAngularVelocityLimit(float limit) { - cpBodySetAngVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit)); + cpBodySetAngVelLimit(_cpBody, PhysicsHelper::float2cpfloat(limit)); } float PhysicsBody::getAngularVelocityLimit() { - return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_info->getBody())); + return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_cpBody)); } void PhysicsBody::setMoment(float moment) @@ -643,7 +636,7 @@ void PhysicsBody::setMoment(float moment) // the static body's mass and moment is always infinity if (_rotationEnabled && _dynamic) { - cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment)); + cpBodySetMoment(_cpBody, PhysicsHelper::float2cpfloat(_moment)); } } @@ -755,17 +748,17 @@ void PhysicsBody::setEnable(bool enable) bool PhysicsBody::isResting() const { - return CP_PRIVATE(_info->getBody()->node).root != ((cpBody*)0); + return CP_PRIVATE(_cpBody->node).root != ((cpBody*)0); } void PhysicsBody::setResting(bool rest) const { if (rest && !isResting()) { - cpBodySleep(_info->getBody()); + cpBodySleep(_cpBody); }else if(!rest && isResting()) { - cpBodyActivate(_info->getBody()); + cpBodyActivate(_cpBody); } } @@ -798,9 +791,9 @@ void PhysicsBody::update(float delta) // damping compute if (_isDamping && _dynamic && !isResting()) { - _info->getBody()->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); - _info->getBody()->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); - _info->getBody()->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); + _cpBody->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _cpBody->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _cpBody->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); } } } @@ -917,12 +910,12 @@ float PhysicsBody::getRotationOffset() const Vec2 PhysicsBody::world2Local(const Vec2& point) { - return PhysicsHelper::cpv2point(cpBodyWorld2Local(_info->getBody(), PhysicsHelper::point2cpv(point))); + return PhysicsHelper::cpv2point(cpBodyWorld2Local(_cpBody, PhysicsHelper::point2cpv(point))); } Vec2 PhysicsBody::local2World(const Vec2& point) { - return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point))); + return PhysicsHelper::cpv2point(cpBodyLocal2World(_cpBody, PhysicsHelper::point2cpv(point))); } NS_CC_END diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 26562fef98..8b4babe4cf 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -33,13 +33,14 @@ #include "physics/CCPhysicsShape.h" #include "base/CCVector.h" +struct cpBody; + NS_CC_BEGIN class Node; class Sprite; class PhysicsWorld; class PhysicsJoint; -class PhysicsBodyInfo; typedef Vec2 Vect; @@ -296,6 +297,8 @@ public: Vec2 world2Local(const Vec2& point); /** convert the local point to world */ Vec2 local2World(const Vec2& point); + + cpBody* getCPBody() { return _cpBody; } protected: @@ -322,7 +325,7 @@ protected: std::vector _joints; Vector _shapes; PhysicsWorld* _world; - PhysicsBodyInfo* _info; + cpBody* _cpBody; bool _dynamic; bool _enabled; bool _rotationEnabled; diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index 3608afd69f..35c57316b8 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -25,11 +25,8 @@ #if CC_USE_PHYSICS #include "chipmunk.h" -#include "physics/CCPhysicsBody.h" - -#include "chipmunk/CCPhysicsContactInfo_chipmunk.h" -#include "chipmunk/CCPhysicsHelper_chipmunk.h" - +#include "CCPhysicsBody.h" +#include "CCPhysicsHelper.h" #include "base/CCEventCustom.h" NS_CC_BEGIN @@ -42,7 +39,6 @@ PhysicsContact::PhysicsContact() , _shapeA(nullptr) , _shapeB(nullptr) , _eventCode(EventCode::NONE) -, _info(nullptr) , _notificationEnable(true) , _result(true) , _data(nullptr) @@ -55,7 +51,6 @@ PhysicsContact::PhysicsContact() PhysicsContact::~PhysicsContact() { - CC_SAFE_DELETE(_info); CC_SAFE_DELETE(_contactData); CC_SAFE_DELETE(_preContactData); } @@ -78,8 +73,6 @@ bool PhysicsContact::init(PhysicsShape* a, PhysicsShape* b) { CC_BREAK_IF(a == nullptr || b == nullptr); - CC_BREAK_IF(!(_info = new (std::nothrow) PhysicsContactInfo(this))); - _shapeA = a; _shapeB = b; diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index eee9727560..c074cd8325 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -40,8 +40,6 @@ class PhysicsShape; class PhysicsBody; class PhysicsWorld; -class PhysicsContactInfo; - typedef Vec2 Vect; typedef struct CC_DLL PhysicsContactData @@ -112,7 +110,6 @@ private: PhysicsShape* _shapeA; PhysicsShape* _shapeB; EventCode _eventCode; - PhysicsContactInfo* _info; bool _notificationEnable; bool _result; diff --git a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h b/cocos/physics/CCPhysicsHelper.h similarity index 100% rename from cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h rename to cocos/physics/CCPhysicsHelper.h diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 86ebf86ecc..b9628ca88c 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -26,13 +26,9 @@ #if CC_USE_PHYSICS #include "chipmunk.h" -#include "physics/CCPhysicsBody.h" -#include "physics/CCPhysicsWorld.h" - -#include "chipmunk/CCPhysicsJointInfo_chipmunk.h" -#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" -#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" -#include "chipmunk/CCPhysicsHelper_chipmunk.h" +#include "CCPhysicsBody.h" +#include "CCPhysicsWorld.h" +#include "CCPhysicsHelper.h" #include "2d/CCNode.h" NS_CC_BEGIN @@ -41,7 +37,6 @@ PhysicsJoint::PhysicsJoint() : _bodyA(nullptr) , _bodyB(nullptr) , _world(nullptr) -, _info(nullptr) , _enable(false) , _collisionEnable(true) , _destoryMark(false) @@ -55,7 +50,10 @@ PhysicsJoint::~PhysicsJoint() // reset the shapes collision group setCollisionEnable(true); - CC_SAFE_DELETE(_info); + for (auto constraint : _cpConstraints) + { + cpConstraintFree(constraint); + } } bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b) @@ -65,8 +63,6 @@ bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b) CCASSERT(a != nullptr && b != nullptr, "the body passed in is nil"); CCASSERT(a != b, "the two bodies are equal"); - CC_BREAK_IF(!(_info = new (std::nothrow) PhysicsJointInfo(this))); - _bodyA = a; _bodyA->_joints.push_back(this); _bodyB = b; @@ -97,11 +93,6 @@ void PhysicsJoint::setEnable(bool enable) } } -PhysicsBodyInfo* PhysicsJoint::getBodyInfo(PhysicsBody* body) const -{ - return body->_info; -} - Node* PhysicsJoint::getBodyNode(PhysicsBody* body) const { return body->_node; @@ -151,7 +142,7 @@ void PhysicsJoint::destroy(PhysicsJoint* joint) void PhysicsJoint::setMaxForce(float force) { - for (cpConstraint* joint : _info->getJoints()) + for (auto joint : _cpConstraints) { joint->maxForce = PhysicsHelper::float2cpfloat(force); } @@ -159,7 +150,7 @@ void PhysicsJoint::setMaxForce(float force) float PhysicsJoint::getMaxForce() const { - return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce); + return PhysicsHelper::cpfloat2float(_cpConstraints.front()->maxForce); } PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr) @@ -185,15 +176,15 @@ bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr) getBodyNode(b)->setPosition(anchr); // add a pivot joint to fixed two body together - cpConstraint* joint = cpPivotJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), + auto constraint = cpPivotJointNew(a->getCPBody(), b->getCPBody(), PhysicsHelper::point2cpv(anchr)); - CC_BREAK_IF(joint == nullptr); - _info->add(joint); + CC_BREAK_IF(constraint == nullptr); + _cpConstraints.push_back(constraint); // add a gear joint to make two body have the same rotation. - joint = cpGearJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), 0, 1); - CC_BREAK_IF(joint == nullptr); - _info->add(joint); + constraint = cpGearJointNew(a->getCPBody(), b->getCPBody(), 0, 1); + CC_BREAK_IF(constraint == nullptr); + _cpConstraints.push_back(constraint); setCollisionEnable(false); @@ -221,12 +212,12 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Vec2& anchr) do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpPivotJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), + auto constraint = cpPivotJointNew(a->getCPBody(), b->getCPBody(), PhysicsHelper::point2cpv(anchr)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -258,15 +249,15 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpSlideJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), + auto constraint = cpSlideJointNew(a->getCPBody(), b->getCPBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), PhysicsHelper::float2cpfloat(min), PhysicsHelper::float2cpfloat(max)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -276,42 +267,42 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, float PhysicsJointLimit::getMin() const { - return PhysicsHelper::cpfloat2float(cpSlideJointGetMin(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpSlideJointGetMin(_cpConstraints.front())); } void PhysicsJointLimit::setMin(float min) { - cpSlideJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min)); + cpSlideJointSetMin(_cpConstraints.front(), PhysicsHelper::float2cpfloat(min)); } float PhysicsJointLimit::getMax() const { - return PhysicsHelper::cpfloat2float(cpSlideJointGetMax(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpSlideJointGetMax(_cpConstraints.front())); } void PhysicsJointLimit::setMax(float max) { - cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); + cpSlideJointSetMax(_cpConstraints.front(), PhysicsHelper::float2cpfloat(max)); } Vec2 PhysicsJointLimit::getAnchr1() const { - return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_cpConstraints.front())); } void PhysicsJointLimit::setAnchr1(const Vec2& anchr) { - cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); + cpSlideJointSetAnchr1(_cpConstraints.front(), PhysicsHelper::point2cpv(anchr)); } Vec2 PhysicsJointLimit::getAnchr2() const { - return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_cpConstraints.front())); } void PhysicsJointLimit::setAnchr2(const Vec2& anchr) { - cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); + cpSlideJointSetAnchr1(_cpConstraints.front(), PhysicsHelper::point2cpv(anchr)); } PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2) @@ -333,14 +324,14 @@ bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anch { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpPinJointNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpPinJointNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -350,12 +341,12 @@ bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anch float PhysicsJointDistance::getDistance() const { - return PhysicsHelper::cpfloat2float(cpPinJointGetDist(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpPinJointGetDist(_cpConstraints.front())); } void PhysicsJointDistance::setDistance(float distance) { - cpPinJointSetDist(_info->getJoints().front(), PhysicsHelper::float2cpfloat(distance)); + cpPinJointSetDist(_cpConstraints.front(), PhysicsHelper::float2cpfloat(distance)); } PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping) @@ -376,17 +367,17 @@ bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1 do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpDampedSpringNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpDampedSpringNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2))), PhysicsHelper::float2cpfloat(stiffness), PhysicsHelper::float2cpfloat(damping)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -396,52 +387,52 @@ bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1 Vec2 PhysicsJointSpring::getAnchr1() const { - return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_cpConstraints.front())); } void PhysicsJointSpring::setAnchr1(const Vec2& anchr) { - cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); + cpDampedSpringSetAnchr1(_cpConstraints.front(), PhysicsHelper::point2cpv(anchr)); } Vec2 PhysicsJointSpring::getAnchr2() const { - return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_cpConstraints.front())); } void PhysicsJointSpring::setAnchr2(const Vec2& anchr) { - cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); + cpDampedSpringSetAnchr1(_cpConstraints.front(), PhysicsHelper::point2cpv(anchr)); } float PhysicsJointSpring::getRestLength() const { - return PhysicsHelper::cpfloat2float(cpDampedSpringGetRestLength(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedSpringGetRestLength(_cpConstraints.front())); } void PhysicsJointSpring::setRestLength(float restLength) { - cpDampedSpringSetRestLength(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restLength)); + cpDampedSpringSetRestLength(_cpConstraints.front(), PhysicsHelper::float2cpfloat(restLength)); } float PhysicsJointSpring::getStiffness() const { - return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_cpConstraints.front())); } void PhysicsJointSpring::setStiffness(float stiffness) { - cpDampedSpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); + cpDampedSpringSetStiffness(_cpConstraints.front(), PhysicsHelper::float2cpfloat(stiffness)); } float PhysicsJointSpring::getDamping() const { - return PhysicsHelper::cpfloat2float(cpDampedSpringGetDamping(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedSpringGetDamping(_cpConstraints.front())); } void PhysicsJointSpring::setDamping(float damping) { - cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); + cpDampedSpringSetDamping(_cpConstraints.front(), PhysicsHelper::float2cpfloat(damping)); } PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr2) @@ -462,15 +453,15 @@ bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vec2& groove do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpGrooveJointNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpGrooveJointNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::point2cpv(grooveA), PhysicsHelper::point2cpv(grooveB), PhysicsHelper::point2cpv(anchr2)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -480,32 +471,32 @@ bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Vec2& groove Vec2 PhysicsJointGroove::getGrooveA() const { - return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_cpConstraints.front())); } void PhysicsJointGroove::setGrooveA(const Vec2& grooveA) { - cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA)); + cpGrooveJointSetGrooveA(_cpConstraints.front(), PhysicsHelper::point2cpv(grooveA)); } Vec2 PhysicsJointGroove::getGrooveB() const { - return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_cpConstraints.front())); } void PhysicsJointGroove::setGrooveB(const Vec2& grooveB) { - cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB)); + cpGrooveJointSetGrooveB(_cpConstraints.front(), PhysicsHelper::point2cpv(grooveB)); } Vec2 PhysicsJointGroove::getAnchr2() const { - return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front())); + return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_cpConstraints.front())); } void PhysicsJointGroove::setAnchr2(const Vec2& anchr2) { - cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2)); + cpGrooveJointSetAnchr2(_cpConstraints.front(), PhysicsHelper::point2cpv(anchr2)); } PhysicsJointRotarySpring* PhysicsJointRotarySpring::construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping) @@ -526,15 +517,15 @@ bool PhysicsJointRotarySpring::init(PhysicsBody* a, PhysicsBody* b, float stiffn do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpDampedRotarySpringNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpDampedRotarySpringNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation()), PhysicsHelper::float2cpfloat(stiffness), PhysicsHelper::float2cpfloat(damping)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -544,32 +535,32 @@ bool PhysicsJointRotarySpring::init(PhysicsBody* a, PhysicsBody* b, float stiffn float PhysicsJointRotarySpring::getRestAngle() const { - return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetRestAngle(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetRestAngle(_cpConstraints.front())); } void PhysicsJointRotarySpring::setRestAngle(float restAngle) { - cpDampedRotarySpringSetRestAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restAngle)); + cpDampedRotarySpringSetRestAngle(_cpConstraints.front(), PhysicsHelper::float2cpfloat(restAngle)); } float PhysicsJointRotarySpring::getStiffness() const { - return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetStiffness(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetStiffness(_cpConstraints.front())); } void PhysicsJointRotarySpring::setStiffness(float stiffness) { - cpDampedRotarySpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); + cpDampedRotarySpringSetStiffness(_cpConstraints.front(), PhysicsHelper::float2cpfloat(stiffness)); } float PhysicsJointRotarySpring::getDamping() const { - return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetDamping(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetDamping(_cpConstraints.front())); } void PhysicsJointRotarySpring::setDamping(float damping) { - cpDampedRotarySpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); + cpDampedRotarySpringSetDamping(_cpConstraints.front(), PhysicsHelper::float2cpfloat(damping)); } PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b, float min, float max) @@ -596,14 +587,14 @@ bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b, float min, fl { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpRotaryLimitJointNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpRotaryLimitJointNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::float2cpfloat(min), PhysicsHelper::float2cpfloat(max)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -613,22 +604,22 @@ bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b, float min, fl float PhysicsJointRotaryLimit::getMin() const { - return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMin(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMin(_cpConstraints.front())); } void PhysicsJointRotaryLimit::setMin(float min) { - cpRotaryLimitJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min)); + cpRotaryLimitJointSetMin(_cpConstraints.front(), PhysicsHelper::float2cpfloat(min)); } float PhysicsJointRotaryLimit::getMax() const { - return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMax(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMax(_cpConstraints.front())); } void PhysicsJointRotaryLimit::setMax(float max) { - cpRotaryLimitJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); + cpRotaryLimitJointSetMax(_cpConstraints.front(), PhysicsHelper::float2cpfloat(max)); } PhysicsJointRatchet* PhysicsJointRatchet::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) @@ -650,14 +641,14 @@ bool PhysicsJointRatchet::init(PhysicsBody* a, PhysicsBody* b, float phase, floa { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpRatchetJointNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpRatchetJointNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::float2cpfloat(phase), PhysicsHelper::cpfloat2float(ratchet)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -667,32 +658,32 @@ bool PhysicsJointRatchet::init(PhysicsBody* a, PhysicsBody* b, float phase, floa float PhysicsJointRatchet::getAngle() const { - return PhysicsHelper::cpfloat2float(cpRatchetJointGetAngle(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpRatchetJointGetAngle(_cpConstraints.front())); } void PhysicsJointRatchet::setAngle(float angle) { - cpRatchetJointSetAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(angle)); + cpRatchetJointSetAngle(_cpConstraints.front(), PhysicsHelper::float2cpfloat(angle)); } float PhysicsJointRatchet::getPhase() const { - return PhysicsHelper::cpfloat2float(cpRatchetJointGetPhase(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpRatchetJointGetPhase(_cpConstraints.front())); } void PhysicsJointRatchet::setPhase(float phase) { - cpRatchetJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); + cpRatchetJointSetPhase(_cpConstraints.front(), PhysicsHelper::float2cpfloat(phase)); } float PhysicsJointRatchet::getRatchet() const { - return PhysicsHelper::cpfloat2float(cpRatchetJointGetRatchet(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpRatchetJointGetRatchet(_cpConstraints.front())); } void PhysicsJointRatchet::setRatchet(float ratchet) { - cpRatchetJointSetRatchet(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratchet)); + cpRatchetJointSetRatchet(_cpConstraints.front(), PhysicsHelper::float2cpfloat(ratchet)); } PhysicsJointGear* PhysicsJointGear::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) @@ -714,14 +705,14 @@ bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float r { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpGearJointNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpGearJointNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::float2cpfloat(phase), PhysicsHelper::float2cpfloat(ratio)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -731,22 +722,22 @@ bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float r float PhysicsJointGear::getPhase() const { - return PhysicsHelper::cpfloat2float(cpGearJointGetPhase(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpGearJointGetPhase(_cpConstraints.front())); } void PhysicsJointGear::setPhase(float phase) { - cpGearJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); + cpGearJointSetPhase(_cpConstraints.front(), PhysicsHelper::float2cpfloat(phase)); } float PhysicsJointGear::getRatio() const { - return PhysicsHelper::cpfloat2float(cpGearJointGetRatio(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpGearJointGetRatio(_cpConstraints.front())); } void PhysicsJointGear::setRatio(float ratio) { - cpGearJointSetRatio(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratio)); + cpGearJointSetRatio(_cpConstraints.front(), PhysicsHelper::float2cpfloat(ratio)); } PhysicsJointMotor* PhysicsJointMotor::construct(PhysicsBody* a, PhysicsBody* b, float rate) @@ -768,13 +759,13 @@ bool PhysicsJointMotor::init(PhysicsBody* a, PhysicsBody* b, float rate) { CC_BREAK_IF(!PhysicsJoint::init(a, b)); - cpConstraint* joint = cpSimpleMotorNew(getBodyInfo(a)->getBody(), - getBodyInfo(b)->getBody(), + auto constraint = cpSimpleMotorNew(a->getCPBody(), + b->getCPBody(), PhysicsHelper::float2cpfloat(rate)); - CC_BREAK_IF(joint == nullptr); + CC_BREAK_IF(constraint == nullptr); - _info->add(joint); + _cpConstraints.push_back(constraint); return true; } while (false); @@ -784,12 +775,12 @@ bool PhysicsJointMotor::init(PhysicsBody* a, PhysicsBody* b, float rate) float PhysicsJointMotor::getRate() const { - return PhysicsHelper::cpfloat2float(cpSimpleMotorGetRate(_info->getJoints().front())); + return PhysicsHelper::cpfloat2float(cpSimpleMotorGetRate(_cpConstraints.front())); } void PhysicsJointMotor::setRate(float rate) { - cpSimpleMotorSetRate(_info->getJoints().front(), PhysicsHelper::float2cpfloat(rate)); + cpSimpleMotorSetRate(_cpConstraints.front(), PhysicsHelper::float2cpfloat(rate)); } NS_CC_END diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index 9861bc9a63..6fcb53f96c 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -31,13 +31,13 @@ #include "base/CCRef.h" #include "math/CCGeometry.h" +struct cpConstraint; + NS_CC_BEGIN class Node; class PhysicsBody; class PhysicsWorld; -class PhysicsJointInfo; -class PhysicsBodyInfo; /* * @brief An PhysicsJoint object connects two physics bodies together. @@ -72,18 +72,13 @@ public: protected: bool init(PhysicsBody* a, PhysicsBody* b); - - /** - * PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. - */ - PhysicsBodyInfo* getBodyInfo(PhysicsBody* body) const; Node* getBodyNode(PhysicsBody* body) const; protected: PhysicsBody* _bodyA; PhysicsBody* _bodyB; PhysicsWorld* _world; - PhysicsJointInfo* _info; + std::vector _cpConstraints; bool _enable; bool _collisionEnable; bool _destoryMark; diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index 67a0df35a2..db851cd299 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -26,23 +26,22 @@ #if CC_USE_PHYSICS #include +#include #include "chipmunk.h" #include "chipmunk_unsafe.h" -#include "physics/CCPhysicsBody.h" -#include "physics/CCPhysicsWorld.h" - -#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" -#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" -#include "chipmunk/CCPhysicsHelper_chipmunk.h" +#include "CCPhysicsBody.h" +#include "CCPhysicsWorld.h" +#include "CCPhysicsHelper.h" NS_CC_BEGIN extern const float PHYSICS_INFINITY; +std::unordered_map s_physicsShapeMap; +static cpBody* s_sharedBody = nullptr; PhysicsShape::PhysicsShape() : _body(nullptr) -, _info(nullptr) , _type(Type::UNKNOWN) , _area(0.0f) , _mass(0.0f) @@ -58,22 +57,20 @@ PhysicsShape::PhysicsShape() , _contactTestBitmask(0) , _group(0) { - + if (s_sharedBody == nullptr) + { + s_sharedBody = cpBodyNewStatic(); + } } PhysicsShape::~PhysicsShape() { - CC_SAFE_DELETE(_info); -} + for (auto shape : _cpShapes) + { + s_physicsShapeMap.erase(shape); -bool PhysicsShape::init(Type type) -{ - _info = new (std::nothrow) PhysicsShapeInfo(this); - if (_info == nullptr) return false; - - _type = type; - - return true; + cpShapeFree(shape); + } } void PhysicsShape::setMass(float mass) @@ -115,17 +112,6 @@ void PhysicsShape::setMaterial(const PhysicsMaterial& material) setFriction(material.friction); } -PhysicsBodyInfo* PhysicsShape::bodyInfo() const -{ - if (_body != nullptr) - { - return _body->_info; - }else - { - return nullptr; - } -} - void PhysicsShape::setScale(float scale) { setScaleX(scale); @@ -172,6 +158,16 @@ void PhysicsShape::update(float delta) } } +void PhysicsShape::addShape(cpShape* shape) +{ + if (shape) + { + cpShapeSetGroup(shape, _group); + _cpShapes.push_back(shape); + s_physicsShapeMap.insert(std::pair(shape, this)); + } +} + PhysicsShapeCircle::PhysicsShapeCircle() { @@ -264,7 +260,7 @@ void PhysicsShape::setRestitution(float restitution) { _material.restitution = restitution; - for (cpShape* shape : _info->getShapes()) + for (cpShape* shape : _cpShapes) { cpShapeSetElasticity(shape, PhysicsHelper::float2cpfloat(restitution)); } @@ -274,7 +270,7 @@ void PhysicsShape::setFriction(float friction) { _material.friction = friction; - for (cpShape* shape : _info->getShapes()) + for (cpShape* shape : _cpShapes) { cpShapeSetFriction(shape, PhysicsHelper::float2cpfloat(friction)); } @@ -309,25 +305,21 @@ Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count) void PhysicsShape::setBody(PhysicsBody *body) { // already added - if (body != nullptr && _body == body) + if (body && _body == body) { return; } - if (_body != nullptr) + if (_body) { _body->removeShape(this); } - if (body == nullptr) + for (auto shape : _cpShapes) { - _info->setBody(nullptr); - _body = nullptr; - }else - { - _info->setBody(body->_info->getBody()); - _body = body; + cpShapeSetBody(shape, body == nullptr ? s_sharedBody : body->_cpBody); } + _body = body; } // PhysicsShapeCircle @@ -348,13 +340,13 @@ bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* = { do { - CC_BREAK_IF(!PhysicsShape::init(Type::CIRCLE)); + _type = Type::CIRCLE; - cpShape* shape = cpCircleShapeNew(_info->getSharedBody(), radius, PhysicsHelper::point2cpv(offset)); + auto shape = cpCircleShapeNew(s_sharedBody, radius, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); - _info->add(shape); + addShape(shape); _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; @@ -383,12 +375,12 @@ float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Vec2& float PhysicsShapeCircle::calculateArea() { - return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_info->getShapes().front()))); + return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_cpShapes.front()))); } float PhysicsShapeCircle::calculateDefaultMoment() { - cpShape* shape = _info->getShapes().front(); + auto shape = _cpShapes.front(); return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(_mass), @@ -399,12 +391,12 @@ float PhysicsShapeCircle::calculateDefaultMoment() float PhysicsShapeCircle::getRadius() const { - return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_info->getShapes().front())); + return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_cpShapes.front())); } Vec2 PhysicsShapeCircle::getOffset() { - return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->getShapes().front())); + return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_cpShapes.front())); } void PhysicsShapeCircle::setScale(float scale) @@ -450,13 +442,12 @@ void PhysicsShapeCircle::setScaleY(float scale) void PhysicsShapeCircle::update(float delta) { - if (_dirty) { cpFloat factor = std::abs(PhysicsHelper::float2cpfloat( _newScaleX / _scaleX )); - cpShape* shape = _info->getShapes().front(); - cpVect v = cpCircleShapeGetOffset(shape); + auto shape = _cpShapes.front(); + auto v = cpCircleShapeGetOffset(shape); v = cpvmult(v, PhysicsHelper::float2cpfloat(factor)); ((cpCircleShape*)shape)->c = v; @@ -485,21 +476,20 @@ bool PhysicsShapeEdgeSegment::init(const Vec2& a, const Vec2& b, const PhysicsMa { do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGESEGMENT)); + _type = Type::EDGESEGMENT; - cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), + auto shape = cpSegmentShapeNew(s_sharedBody, PhysicsHelper::point2cpv(a), PhysicsHelper::point2cpv(b), PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); - _info->add(shape); + addShape(shape); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; - setMaterial(material); return true; @@ -510,18 +500,18 @@ bool PhysicsShapeEdgeSegment::init(const Vec2& a, const Vec2& b, const PhysicsMa Vec2 PhysicsShapeEdgeSegment::getPointA() const { - return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->ta); + return PhysicsHelper::cpv2point(((cpSegmentShape*)(_cpShapes.front()))->ta); } Vec2 PhysicsShapeEdgeSegment::getPointB() const { - return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->tb); + return PhysicsHelper::cpv2point(((cpSegmentShape*)(_cpShapes.front()))->tb); } Vec2 PhysicsShapeEdgeSegment::getCenter() { - Vec2 a = PhysicsHelper::cpv2point(cpSegmentShapeGetA(_info->getShapes().front())); - Vec2 b = PhysicsHelper::cpv2point(cpSegmentShapeGetB(_info->getShapes().front())); + auto a = PhysicsHelper::cpv2point(cpSegmentShapeGetA(_cpShapes.front())); + auto b = PhysicsHelper::cpv2point(cpSegmentShapeGetB(_cpShapes.front())); return ( a + b ) / 2; } @@ -529,14 +519,14 @@ void PhysicsShapeEdgeSegment::update(float delta) { if (_dirty) { - cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX); - cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY); + auto factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX); + auto factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY); - cpShape* shape = _info->getShapes().front(); - cpVect a = cpSegmentShapeGetA(shape); + auto shape = _cpShapes.front(); + auto a = cpSegmentShapeGetA(shape); a.x *= factorX; a.y *= factorY; - cpVect b = cpSegmentShapeGetB(shape); + auto b = cpSegmentShapeGetB(shape); b.x *= factorX; b.y *= factorY; cpSegmentShapeSetEndpoints(shape, a, b); @@ -563,19 +553,19 @@ bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = { do { - CC_BREAK_IF(!PhysicsShape::init(Type::BOX)); + _type = Type::BOX; - cpVect wh = PhysicsHelper::size2cpv(size); + auto wh = PhysicsHelper::size2cpv(size); cpVect vec[4] = { {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} }; - cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), 4, vec, PhysicsHelper::point2cpv(offset)); + auto shape = cpPolyShapeNew(s_sharedBody, 4, vec, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); - _info->add(shape); + addShape(shape); _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; @@ -591,7 +581,7 @@ bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = Size PhysicsShapeBox::getSize() const { - cpShape* shape = _info->getShapes().front(); + cpShape* shape = _cpShapes.front(); return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)), cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)))); } @@ -614,16 +604,16 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater { do { - CC_BREAK_IF(!PhysicsShape::init(Type::POLYGEN)); + _type = Type::POLYGEN; - cpVect* vecs = new cpVect[count]; + auto vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); - cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); + auto shape = cpPolyShapeNew(s_sharedBody, count, vecs, PhysicsHelper::point2cpv(offset)); CC_SAFE_DELETE_ARRAY(vecs); CC_BREAK_IF(shape == nullptr); - _info->add(shape); + addShape(shape); _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; @@ -660,36 +650,36 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int c float PhysicsShapePolygon::calculateArea() { - cpShape* shape = _info->getShapes().front(); + auto shape = _cpShapes.front(); return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); } float PhysicsShapePolygon::calculateDefaultMoment() { - cpShape* shape = _info->getShapes().front(); + auto shape = _cpShapes.front(); return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); } Vec2 PhysicsShapePolygon::getPoint(int i) const { - return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_info->getShapes().front(), i)); + return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_cpShapes.front(), i)); } void PhysicsShapePolygon::getPoints(Vec2* outPoints) const { - cpShape* shape = _info->getShapes().front(); + auto shape = _cpShapes.front(); PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, outPoints, ((cpPolyShape*)shape)->numVerts); } int PhysicsShapePolygon::getPointsCount() const { - return ((cpPolyShape*)_info->getShapes().front())->numVerts; + return ((cpPolyShape*)_cpShapes.front())->numVerts; } Vec2 PhysicsShapePolygon::getCenter() { - return PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)_info->getShapes().front())->numVerts, ((cpPolyShape*)_info->getShapes().front())->verts)); + return PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)_cpShapes.front())->numVerts, ((cpPolyShape*)_cpShapes.front())->verts)); } void PhysicsShapePolygon::update(float delta) @@ -699,7 +689,7 @@ void PhysicsShapePolygon::update(float delta) cpFloat factorX = PhysicsHelper::float2cpfloat( _newScaleX / _scaleX ); cpFloat factorY = PhysicsHelper::float2cpfloat( _newScaleY / _scaleY ); - cpShape* shape = _info->getShapes().front(); + auto shape = _cpShapes.front(); int count = cpPolyShapeGetNumVerts(shape); cpVect* vects = ((cpPolyShape*)shape)->verts; cpSplittingPlane* planes = ((cpPolyShape*)shape)->planes; @@ -751,7 +741,7 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material { do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX)); + _type = Type::EDGEBOX; cpVect vec[4] = {}; vec[0] = PhysicsHelper::point2cpv(Vec2(-size.width/2+offset.x, -size.height/2+offset.y)); @@ -762,10 +752,10 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material int i = 0; for (; i < 4; ++i) { - cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%4], + auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[(i + 1) % 4], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); - _info->add(shape); + addShape(shape); } CC_BREAK_IF(i < 4); @@ -799,7 +789,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM cpVect* vec = nullptr; do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN)); + _type = Type::EDGEPOLYGEN; vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); @@ -807,12 +797,12 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM int i = 0; for (; i < count; ++i) { - cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%count], + auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[(i + 1) % count], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); - cpShapeSetElasticity(shape, 1.0f); - cpShapeSetFriction(shape, 1.0f); - _info->add(shape); + cpShapeSetElasticity(shape, 1.0f); + cpShapeSetFriction(shape, 1.0f); + addShape(shape); } CC_SAFE_DELETE_ARRAY(vec); @@ -833,10 +823,10 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM Vec2 PhysicsShapeEdgePolygon::getCenter() { - int count = (int)_info->getShapes().size(); + int count = (int)_cpShapes.size(); cpVect* points = new cpVect[count]; int i = 0; - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { points[i++] = ((cpSegmentShape*)shape)->a; } @@ -850,7 +840,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter() void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vec2 *outPoints) const { int i = 0; - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); } @@ -858,7 +848,7 @@ void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vec2 *outPoints) const int PhysicsShapeEdgePolygon::getPointsCount() const { - return static_cast(_info->getShapes().size()); + return static_cast(_cpShapes.size()); } // PhysicsShapeEdgeChain @@ -882,7 +872,7 @@ void PhysicsShapeEdgePolygon::update(float delta) cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX); cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY); - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { cpVect a = cpSegmentShapeGetA(shape); a.x *= factorX; @@ -902,7 +892,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat cpVect* vec = nullptr; do { - CC_BREAK_IF(!PhysicsShape::init(Type::EDGECHAIN)); + _type = Type::EDGECHAIN; vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); @@ -910,12 +900,12 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat int i = 0; for (; i < count - 1; ++i) { - cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[i+1], + auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[i + 1], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); - cpShapeSetElasticity(shape, 1.0f); - cpShapeSetFriction(shape, 1.0f); - _info->add(shape); + cpShapeSetElasticity(shape, 1.0f); + cpShapeSetFriction(shape, 1.0f); + addShape(shape); } CC_SAFE_DELETE_ARRAY(vec); CC_BREAK_IF(i < count - 1); @@ -935,15 +925,15 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat Vec2 PhysicsShapeEdgeChain::getCenter() { - int count = (int)_info->getShapes().size() + 1; + int count = (int)_cpShapes.size() + 1; cpVect* points = new cpVect[count]; int i = 0; - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { points[i++] = ((cpSegmentShape*)shape)->a; } - points[i++] = ((cpSegmentShape*)_info->getShapes().back())->b; + points[i++] = ((cpSegmentShape*)_cpShapes.back())->b; Vec2 center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, points)); delete[] points; @@ -954,17 +944,17 @@ Vec2 PhysicsShapeEdgeChain::getCenter() void PhysicsShapeEdgeChain::getPoints(Vec2* outPoints) const { int i = 0; - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); } - outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_info->getShapes().back())->b); + outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_cpShapes.back())->b); } int PhysicsShapeEdgeChain::getPointsCount() const { - return static_cast(_info->getShapes().size() + 1); + return static_cast(_cpShapes.size() + 1); } void PhysicsShapeEdgeChain::update(float delta) @@ -974,7 +964,7 @@ void PhysicsShapeEdgeChain::update(float delta) cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX); cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY); - for(auto shape : _info->getShapes()) + for(auto shape : _cpShapes) { cpVect a = cpSegmentShapeGetA(shape); a.x *= factorX; @@ -993,7 +983,7 @@ void PhysicsShape::setGroup(int group) { if (group < 0) { - for (auto shape : _info->getShapes()) + for (auto shape : _cpShapes) { cpShapeSetGroup(shape, (cpGroup)group); } @@ -1004,7 +994,7 @@ void PhysicsShape::setGroup(int group) bool PhysicsShape::containsPoint(const Vec2& point) const { - for (auto shape : _info->getShapes()) + for (auto shape : _cpShapes) { if (cpShapePointQuery(shape, PhysicsHelper::point2cpv(point))) { diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index cc72a828ef..79fabf6f1f 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -31,12 +31,11 @@ #include "base/CCRef.h" #include "math/CCGeometry.h" +struct cpShape; + NS_CC_BEGIN -class PhysicsShapeInfo; class PhysicsBody; -class PhysicsBodyInfo; - typedef struct CC_DLL PhysicsMaterial { @@ -149,13 +148,6 @@ public: inline int getGroup() { return _group; } protected: - bool init(Type type); - - /** - * @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. - */ - PhysicsBodyInfo* bodyInfo() const; - void setBody(PhysicsBody* body); /** calculate the area of this shape */ @@ -166,6 +158,7 @@ protected: virtual void setScaleX(float scaleX); virtual void setScaleY(float scaleY); virtual void update(float delta); + void addShape(cpShape* shape); protected: PhysicsShape(); @@ -173,7 +166,8 @@ protected: protected: PhysicsBody* _body; - PhysicsShapeInfo* _info; + std::vector _cpShapes; + Type _type; float _area; float _mass; diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 59eaf95855..84b38e42db 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -24,23 +24,16 @@ #include "physics/CCPhysicsWorld.h" #if CC_USE_PHYSICS - +#include #include #include "chipmunk.h" - -#include "physics/CCPhysicsBody.h" -#include "physics/CCPhysicsShape.h" +#include "CCPhysicsBody.h" +#include "CCPhysicsShape.h" #include "CCPhysicsContact.h" -#include "physics/CCPhysicsJoint.h" +#include "CCPhysicsJoint.h" #include "CCPhysicsContact.h" - -#include "chipmunk/CCPhysicsWorldInfo_chipmunk.h" -#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" -#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" -#include "chipmunk/CCPhysicsContactInfo_chipmunk.h" -#include "chipmunk/CCPhysicsJointInfo_chipmunk.h" -#include "chipmunk/CCPhysicsHelper_chipmunk.h" +#include "CCPhysicsHelper.h" #include "2d/CCDrawNode.h" #include "2d/CCScene.h" @@ -48,11 +41,10 @@ #include "base/CCEventDispatcher.h" #include "base/CCEventCustom.h" -#include - NS_CC_BEGIN const float PHYSICS_INFINITY = INFINITY; extern const char* PHYSICSCONTACT_EVENT_NAME; +extern std::unordered_map s_physicsShapeMap; const int PhysicsWorld::DEBUGDRAW_NONE = 0x00; const int PhysicsWorld::DEBUGDRAW_SHAPE = 0x01; @@ -108,11 +100,11 @@ int PhysicsWorldCallback::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSp { CP_ARBITER_GET_SHAPES(arb, a, b); - auto ita = PhysicsShapeInfo::getMap().find(a); - auto itb = PhysicsShapeInfo::getMap().find(b); - CC_ASSERT(ita != PhysicsShapeInfo::getMap().end() && itb != PhysicsShapeInfo::getMap().end()); + auto ita = s_physicsShapeMap.find(a); + auto itb = s_physicsShapeMap.find(b); + CC_ASSERT(ita != s_physicsShapeMap.end() && itb != s_physicsShapeMap.end()); - PhysicsContact* contact = PhysicsContact::construct(ita->second->getShape(), itb->second->getShape()); + auto contact = PhysicsContact::construct(ita->second, itb->second); arb->data = contact; contact->_contactInfo = arb; @@ -145,12 +137,12 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect return; } - auto it = PhysicsShapeInfo::getMap().find(shape); - CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); + auto it = s_physicsShapeMap.find(shape); + CC_ASSERT(it != s_physicsShapeMap.end()); PhysicsRayCastInfo callbackInfo = { - it->second->getShape(), + it->second, info->p1, info->p2, Vec2(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t), @@ -163,34 +155,34 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect void PhysicsWorldCallback::queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info) { - auto it = PhysicsShapeInfo::getMap().find(shape); + auto it = s_physicsShapeMap.find(shape); - CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); + CC_ASSERT(it != s_physicsShapeMap.end()); if (!PhysicsWorldCallback::continues) { return; } - PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data); + PhysicsWorldCallback::continues = info->func(*info->world, *it->second, info->data); } void PhysicsWorldCallback::getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector* arr) { - auto it = PhysicsShapeInfo::getMap().find(shape); + auto it = s_physicsShapeMap.find(shape); - CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); + CC_ASSERT(it != s_physicsShapeMap.end()); - arr->pushBack(it->second->getShape()); + arr->pushBack(it->second); } void PhysicsWorldCallback::queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info) { - auto it = PhysicsShapeInfo::getMap().find(shape); + auto it = s_physicsShapeMap.find(shape); - CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); + CC_ASSERT(it != s_physicsShapeMap.end()); - PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data); + PhysicsWorldCallback::continues = info->func(*info->world, *it->second, info->data); } void PhysicsWorld::debugDraw() @@ -343,7 +335,7 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, RayCastCallbackInfo info = { this, func, point1, point2, data }; PhysicsWorldCallback::continues = true; - cpSpaceSegmentQuery(this->_info->getSpace(), + cpSpaceSegmentQuery(_cpSpace, PhysicsHelper::point2cpv(point1), PhysicsHelper::point2cpv(point2), CP_ALL_LAYERS, @@ -362,7 +354,7 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect RectQueryCallbackInfo info = {this, func, data}; PhysicsWorldCallback::continues = true; - cpSpaceBBQuery(this->_info->getSpace(), + cpSpaceBBQuery(_cpSpace, PhysicsHelper::rect2cpbb(rect), CP_ALL_LAYERS, CP_NO_GROUP, @@ -380,7 +372,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po PointQueryCallbackInfo info = {this, func, data}; PhysicsWorldCallback::continues = true; - cpSpaceNearestPointQuery(this->_info->getSpace(), + cpSpaceNearestPointQuery(_cpSpace, PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, @@ -393,7 +385,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po Vector PhysicsWorld::getShapes(const Vec2& point) const { Vector arr; - cpSpaceNearestPointQuery(this->_info->getSpace(), + cpSpaceNearestPointQuery(_cpSpace, PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, @@ -406,14 +398,14 @@ Vector PhysicsWorld::getShapes(const Vec2& point) const PhysicsShape* PhysicsWorld::getShape(const Vec2& point) const { - cpShape* shape = cpSpaceNearestPointQueryNearest(this->_info->getSpace(), + cpShape* shape = cpSpaceNearestPointQueryNearest(_cpSpace, PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, CP_NO_GROUP, nullptr); - return shape == nullptr ? nullptr : PhysicsShapeInfo::getMap().find(shape)->second->getShape(); + return shape == nullptr ? nullptr : s_physicsShapeMap.find(shape)->second; } PhysicsWorld* PhysicsWorld::construct(Scene& scene) @@ -432,14 +424,14 @@ bool PhysicsWorld::init(Scene& scene) { do { - _info = new (std::nothrow) PhysicsWorldInfo(); - CC_BREAK_IF(_info == nullptr); + _cpSpace = cpSpaceNew(); + CC_BREAK_IF(_cpSpace == nullptr); _scene = &scene; - _info->setGravity(_gravity); + cpSpaceSetGravity(_cpSpace, PhysicsHelper::point2cpv(_gravity)); - cpSpaceSetDefaultCollisionHandler(_info->getSpace(), + cpSpaceSetDefaultCollisionHandler(_cpSpace, (cpCollisionBeginFunc)PhysicsWorldCallback::collisionBeginCallbackFunc, (cpCollisionPreSolveFunc)PhysicsWorldCallback::collisionPreSolveCallbackFunc, (cpCollisionPostSolveFunc)PhysicsWorldCallback::collisionPostSolveCallbackFunc, @@ -476,9 +468,9 @@ void PhysicsWorld::doAddBody(PhysicsBody* body) if (body->isEnabled()) { // add body to space - if (body->isDynamic()) + if (body->isDynamic() && !cpSpaceContainsBody(_cpSpace, body->_cpBody)) { - _info->addBody(*body->_info); + cpSpaceAddBody(_cpSpace, body->_cpBody); } // add shapes to space @@ -499,7 +491,7 @@ void PhysicsWorld::addBodyOrDelay(PhysicsBody* body) return; } - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { if (_delayAddBodies.find(body) == _delayAddBodies.end()) { @@ -515,7 +507,7 @@ void PhysicsWorld::addBodyOrDelay(PhysicsBody* body) void PhysicsWorld::updateBodies() { - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { return; } @@ -593,7 +585,7 @@ void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body) return; } - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { if (_delayRemoveBodies.getIndex(body) == CC_INVALID_INDEX) { @@ -608,12 +600,13 @@ void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body) void PhysicsWorld::doAddJoint(PhysicsJoint *joint) { - if (joint == nullptr || joint->_info == nullptr) + if (joint) { - return; + for (auto constraint : joint->_cpConstraints) + { + cpSpaceAddConstraint(_cpSpace, constraint); + } } - - _info->addJoint(*joint->_info); } void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy) @@ -659,7 +652,7 @@ void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy) void PhysicsWorld::updateJoints() { - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { return; } @@ -686,9 +679,15 @@ void PhysicsWorld::updateJoints() void PhysicsWorld::removeShape(PhysicsShape* shape) { - if (shape != nullptr) + if (shape) { - _info->removeShape(*shape->_info); + for (auto cps : shape->_cpShapes) + { + if (cpSpaceContainsShape(_cpSpace, cps)) + { + cpSpaceRemoveShape(_cpSpace, cps); + } + } } } @@ -701,7 +700,7 @@ void PhysicsWorld::addJointOrDelay(PhysicsJoint* joint) return; } - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { if (std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint) == _delayAddJoints.end()) { @@ -723,7 +722,7 @@ void PhysicsWorld::removeJointOrDelay(PhysicsJoint* joint) return; } - if (_info->isLocked()) + if (cpSpaceIsLocked(_cpSpace)) { if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend()) { @@ -783,11 +782,14 @@ void PhysicsWorld::removeAllJoints(bool destroy) _joints.clear(); } -void PhysicsWorld::addShape(PhysicsShape* shape) +void PhysicsWorld::addShape(PhysicsShape* physicsShape) { - if (shape != nullptr) + if (physicsShape) { - _info->addShape(*shape->_info); + for (auto shape : physicsShape->_cpShapes) + { + cpSpaceAddShape(_cpSpace, shape); + } } } @@ -802,12 +804,18 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body) } // remove body - _info->removeBody(*body->_info); + if (cpSpaceContainsBody(_cpSpace, body->_cpBody)) + { + cpSpaceRemoveBody(_cpSpace, body->_cpBody); + } } void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint) { - _info->removeJoint(*joint->_info); + for (auto constraint : joint->_cpConstraints) + { + cpSpaceRemoveConstraint(_cpSpace, constraint); + } } void PhysicsWorld::removeAllBodies() @@ -852,7 +860,7 @@ PhysicsBody* PhysicsWorld::getBody(int tag) const void PhysicsWorld::setGravity(const Vect& gravity) { _gravity = gravity; - _info->setGravity(gravity); + cpSpaceSetGravity(_cpSpace, PhysicsHelper::point2cpv(gravity)); } void PhysicsWorld::setSubsteps(int steps) @@ -891,7 +899,7 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/) if (userCall) { - _info->step(delta); + cpSpaceStep(_cpSpace, delta); for (auto& body : _bodies) { body->update(delta); @@ -905,7 +913,7 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/) const float dt = _updateTime * _speed / _substeps; for (int i = 0; i < _substeps; ++i) { - _info->step(dt); + cpSpaceStep(_cpSpace, dt); for (auto& body : _bodies) { body->update(dt); @@ -929,7 +937,7 @@ PhysicsWorld::PhysicsWorld() , _updateRateCount(0) , _updateTime(0.0f) , _substeps(1) -, _info(nullptr) +, _cpSpace(nullptr) , _scene(nullptr) , _delayDirty(false) , _autoStep(true) @@ -943,7 +951,10 @@ PhysicsWorld::~PhysicsWorld() { removeAllJoints(true); removeAllBodies(); - CC_SAFE_DELETE(_info); + if (_cpSpace) + { + cpSpaceFree(_cpSpace); + } CC_SAFE_DELETE(_debugDraw); } @@ -976,7 +987,7 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape) const Color4F fillColor(1.0f, 0.0f, 0.0f, 0.3f); const Color4F outlineColor(1.0f, 0.0f, 0.0f, 1.0f); - for (auto it = shape._info->getShapes().begin(); it != shape._info->getShapes().end(); ++it) + for (auto it = shape._cpShapes.begin(); it != shape._cpShapes.end(); ++it) { cpShape *subShape = *it; @@ -1032,7 +1043,7 @@ void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint) const Color4F lineColor(0.0f, 0.0f, 1.0f, 1.0f); const Color4F jointPointColor(0.0f, 1.0f, 0.0f, 1.0f); - for (auto it = joint._info->getJoints().begin(); it != joint._info->getJoints().end(); ++it) + for (auto it = joint._cpConstraints.begin(); it != joint._cpConstraints.end(); ++it) { cpConstraint *constraint = *it; diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 28ba54d944..9612ba688c 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -34,11 +34,12 @@ #include "physics/CCPhysicsBody.h" #include +struct cpSpace; + NS_CC_BEGIN class PhysicsBody; class PhysicsJoint; -class PhysicsWorldInfo; class PhysicsShape; class PhysicsContact; @@ -203,7 +204,7 @@ protected: int _updateRateCount; float _updateTime; int _substeps; - PhysicsWorldInfo* _info; + cpSpace* _cpSpace; Vector _bodies; std::list _joints; diff --git a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp deleted file mode 100644 index a641086bb7..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsBodyInfo_chipmunk.h" -#if CC_USE_PHYSICS -#include "chipmunk.h" -NS_CC_BEGIN - -PhysicsBodyInfo::PhysicsBodyInfo() -: _body(nullptr) -{ -} - -PhysicsBodyInfo::~PhysicsBodyInfo() -{ - if (_body) cpBodyFree(_body); -} - -NS_CC_END -#endif // CC_USE_PHYSICS diff --git a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h deleted file mode 100644 index 389e342077..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ -#define __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ - -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - -#include "platform/CCPlatformMacros.h" -#include "base/CCRef.h" - -struct cpBody; - -NS_CC_BEGIN - -class PhysicsBodyInfo -{ -public: - inline cpBody* getBody() const { return _body; } - inline void setBody(cpBody* body) { _body = body; } - -private: - PhysicsBodyInfo(); - ~PhysicsBodyInfo(); - -private: - cpBody* _body; - - friend class PhysicsBody; -}; - -NS_CC_END - -#endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ diff --git a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp deleted file mode 100644 index 238d6d5387..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsContactInfo_chipmunk.h" -#if CC_USE_PHYSICS -#include "chipmunk.h" -NS_CC_BEGIN - -PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact) -: _contact(contact) -{ -} - -PhysicsContactInfo::~PhysicsContactInfo() -{ -} - -NS_CC_END -#endif // CC_USE_PHYSICS diff --git a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h deleted file mode 100644 index 20cdb952f6..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ -#define __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ - -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - -#include "platform/CCPlatformMacros.h" -NS_CC_BEGIN - -class PhysicsContact; -class PhysicsContactInfo -{ -public: - inline PhysicsContact* getContact() const { return _contact; } - -private: - PhysicsContactInfo(PhysicsContact* contact); - ~PhysicsContactInfo(); - -private: - PhysicsContact* _contact; - - friend class PhysicsContact; -}; - -NS_CC_END - -#endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ diff --git a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp deleted file mode 100644 index 00d174fecf..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsJointInfo_chipmunk.h" -#if CC_USE_PHYSICS -#include -#include -#include "chipmunk.h" - -NS_CC_BEGIN - -std::unordered_map PhysicsJointInfo::_map; - -PhysicsJointInfo::PhysicsJointInfo(PhysicsJoint* joint) -: _joint(joint) -{ -} - -PhysicsJointInfo::~PhysicsJointInfo() -{ - for (cpConstraint* joint : _joints) - { - cpConstraintFree(joint); - } -} - -void PhysicsJointInfo::add(cpConstraint* joint) -{ - if (joint == nullptr) return; - - _joints.push_back(joint); - _map.insert(std::pair(joint, this)); -} - -void PhysicsJointInfo::remove(cpConstraint* joint) -{ - if (joint == nullptr) return; - - auto it = std::find(_joints.begin(), _joints.end(), joint); - if (it != _joints.end()) - { - _joints.erase(it); - - auto mit = _map.find(joint); - if (mit != _map.end()) _map.erase(mit); - - cpConstraintFree(joint); - } -} - -void PhysicsJointInfo::removeAll() -{ - for (cpConstraint* joint : _joints) - { - auto mit = _map.find(joint); - if (mit != _map.end()) _map.erase(mit); - cpConstraintFree(joint); - } - - _joints.clear(); -} - -NS_CC_END -#endif // CC_USE_PHYSICS diff --git a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h deleted file mode 100644 index 9e5eccf2bf..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ -#define __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ - -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - -#include "platform/CCPlatformMacros.h" -#include -#include - -struct cpConstraint; -NS_CC_BEGIN - -class PhysicsJoint; - -class PhysicsJointInfo -{ -public: - void add(cpConstraint* shape); - void remove(cpConstraint* shape); - void removeAll(); - - PhysicsJoint* getJoint() const { return _joint; } - std::vector& getJoints() { return _joints; } - static std::unordered_map& getMap() { return _map; } - -protected: - PhysicsJointInfo(PhysicsJoint* joint); - ~PhysicsJointInfo(); - - std::vector _joints; - PhysicsJoint* _joint; - static std::unordered_map _map; - - friend class PhysicsJoint; -}; - -NS_CC_END - -#endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp deleted file mode 100644 index c1b8693259..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsShapeInfo_chipmunk.h" -#if CC_USE_PHYSICS -#include -#include - -NS_CC_BEGIN - -std::unordered_map PhysicsShapeInfo::_map; -cpBody* PhysicsShapeInfo::_sharedBody = nullptr; - -PhysicsShapeInfo::PhysicsShapeInfo(PhysicsShape* shape) -: _shape(shape) -, _group(CP_NO_GROUP) -{ - if (_sharedBody == nullptr) - { - _sharedBody = cpBodyNewStatic(); - } - - _body = _sharedBody; -} - -PhysicsShapeInfo::~PhysicsShapeInfo() -{ - for (auto shape : _shapes) - { - auto it = _map.find(shape); - if (it != _map.end()) _map.erase(shape); - - cpShapeFree(shape); - } -} - -void PhysicsShapeInfo::setGroup(cpGroup group) -{ - this->_group = group; - - for (cpShape* shape : _shapes) - { - cpShapeSetGroup(shape, group); - } -} - -void PhysicsShapeInfo::setBody(cpBody* body) -{ - if (this->_body != body) - { - this->_body = body; - for (cpShape* shape : _shapes) - { - cpShapeSetBody(shape, body == nullptr ? _sharedBody : body); - } - } -} - -void PhysicsShapeInfo::add(cpShape* shape) -{ - if (shape == nullptr) return; - - cpShapeSetGroup(shape, _group); - _shapes.push_back(shape); - _map.insert(std::pair(shape, this)); -} - -void PhysicsShapeInfo::remove(cpShape* shape) -{ - if (shape == nullptr) return; - - auto it = std::find(_shapes.begin(), _shapes.end(), shape); - if (it != _shapes.end()) - { - _shapes.erase(it); - - auto mit = _map.find(shape); - if (mit != _map.end()) _map.erase(mit); - - cpShapeFree(shape); - } -} - -void PhysicsShapeInfo::removeAll() -{ - for (cpShape* shape : _shapes) - { - auto mit = _map.find(shape); - if (mit != _map.end()) _map.erase(mit); - cpShapeFree(shape); - } - - _shapes.clear(); -} - -NS_CC_END -#endif // CC_USE_PHYSICS diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h deleted file mode 100644 index ecde537a0a..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ -#define __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ - -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - -#include -#include -#include "platform/CCPlatformMacros.h" -#include "chipmunk.h" - -NS_CC_BEGIN - -class PhysicsShape; - -class PhysicsShapeInfo -{ -public: - void add(cpShape* shape); - void remove(cpShape* shape); - void removeAll(); - void setGroup(cpGroup group); - void setBody(cpBody* body); - - PhysicsShape* getShape() const { return _shape; } - std::vector& getShapes() { return _shapes; } - cpBody* getBody() const { return _body; } - cpGroup getGourp() const { return _group; } - static std::unordered_map& getMap() { return _map; } - static cpBody* getSharedBody() { return _sharedBody; } - -protected: - PhysicsShapeInfo(PhysicsShape* shape); - ~PhysicsShapeInfo(); - - std::vector _shapes; - PhysicsShape* _shape; - cpBody* _body; - cpGroup _group; - static std::unordered_map _map; - static cpBody* _sharedBody; - - friend class PhysicsShape; -}; - -NS_CC_END - -#endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp deleted file mode 100644 index 8290b28490..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsWorldInfo_chipmunk.h" -#if CC_USE_PHYSICS -#include "CCPhysicsHelper_chipmunk.h" -#include "CCPhysicsBodyInfo_chipmunk.h" -#include "CCPhysicsShapeInfo_chipmunk.h" -#include "CCPhysicsJointInfo_chipmunk.h" -#include "chipmunk.h" - -NS_CC_BEGIN - -PhysicsWorldInfo::PhysicsWorldInfo() -{ - _space = cpSpaceNew(); -} - -PhysicsWorldInfo::~PhysicsWorldInfo() -{ - cpSpaceFree(_space); -} - -void PhysicsWorldInfo::setGravity(const Vect& gravity) -{ - cpSpaceSetGravity(_space, PhysicsHelper::point2cpv(gravity)); -} - -void PhysicsWorldInfo::addBody(PhysicsBodyInfo& body) -{ - if (!cpSpaceContainsBody(_space, body.getBody())) - { - cpSpaceAddBody(_space, body.getBody()); - } -} - -void PhysicsWorldInfo::removeBody(PhysicsBodyInfo& body) -{ - if (cpSpaceContainsBody(_space, body.getBody())) - { - cpSpaceRemoveBody(_space, body.getBody()); - } -} - -void PhysicsWorldInfo::addShape(PhysicsShapeInfo& shape) -{ - for (auto cps : shape.getShapes()) - { - cpSpaceAddShape(_space, cps); - } -} - -void PhysicsWorldInfo::removeShape(PhysicsShapeInfo& shape) -{ - for (auto cps : shape.getShapes()) - { - if (cpSpaceContainsShape(_space, cps)) - { - cpSpaceRemoveShape(_space, cps); - } - } -} - -void PhysicsWorldInfo::addJoint(PhysicsJointInfo& joint) -{ - for (auto subjoint : joint.getJoints()) - { - cpSpaceAddConstraint(_space, subjoint); - } -} - -void PhysicsWorldInfo::removeJoint(PhysicsJointInfo& joint) -{ - for (auto subjoint : joint.getJoints()) - { - cpSpaceRemoveConstraint(_space, subjoint); - } -} - -bool PhysicsWorldInfo::isLocked() -{ - return 0 == _space->locked_private ? false : true; -} - -void PhysicsWorldInfo::step(float delta) -{ - cpSpaceStep(_space, delta); -} - -NS_CC_END -#endif // CC_USE_PHYSICS diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h deleted file mode 100644 index 15b8e08e33..0000000000 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ -#define __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ - -#include "base/ccConfig.h" -#if CC_USE_PHYSICS - -#include -#include "platform/CCPlatformMacros.h" -#include "math/CCGeometry.h" - -struct cpSpace; - - -NS_CC_BEGIN -typedef Vec2 Vect; -class PhysicsBodyInfo; -class PhysicsJointInfo; -class PhysicsShapeInfo; - -class PhysicsWorldInfo -{ -public: - cpSpace* getSpace() const { return _space; } - void addShape(PhysicsShapeInfo& shape); - void removeShape(PhysicsShapeInfo& shape); - void addBody(PhysicsBodyInfo& body); - void removeBody(PhysicsBodyInfo& body); - void addJoint(PhysicsJointInfo& joint); - void removeJoint(PhysicsJointInfo& joint); - void setGravity(const Vect& gravity); - bool isLocked(); - void step(float delta); - -private: - PhysicsWorldInfo(); - ~PhysicsWorldInfo(); - -private: - cpSpace* _space; - - friend class PhysicsWorld; -}; - -NS_CC_END - -#endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ From 2847a940ed1998bc1ef5f060d9e35528e078bc5f Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Tue, 6 Jan 2015 11:24:24 +0800 Subject: [PATCH 2/2] Update project --- build/cocos2d_libs.xcodeproj/project.pbxproj | 80 ++----------------- cocos/2d/libcocos2d.vcxproj | 12 +-- cocos/2d/libcocos2d.vcxproj.filters | 39 +-------- .../libcocos2d_8_1.Shared.vcxitems | 12 +-- .../libcocos2d_8_1.Shared.vcxitems.filters | 39 +-------- cocos/2d/libcocos2d_wp8.vcxproj | 12 +-- cocos/2d/libcocos2d_wp8.vcxproj.filters | 39 +-------- cocos/Android.mk | 5 -- cocos/physics/CCPhysicsHelper.h | 6 +- cocos/physics/CMakeLists.txt | 5 -- 10 files changed, 21 insertions(+), 228 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index ad2b0ee825..839e665b1b 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1928,28 +1928,6 @@ B29A7E3F19EE1B7700872B35 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = B29A7DC619EE1B7700872B35 /* AnimationState.h */; }; B29A7E4019EE1B7700872B35 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = B29A7DC619EE1B7700872B35 /* AnimationState.h */; }; B2CC507C19776DD10041958E /* CCPhysicsJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */; }; - B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; }; - B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; }; - B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; }; - B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; }; - B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; }; - B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; }; - B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; }; - B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; }; - B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; }; - B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; }; - B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; }; - B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; }; - B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; }; - B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; }; - B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; }; - B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; }; - B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; }; - B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; }; - B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; }; - B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; }; - B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; }; - B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; }; B60C5BD419AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; @@ -1990,6 +1968,8 @@ DABC9FAA19E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */; }; DABC9FAB19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; }; DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; }; + ED74D7691A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */; }; + ED74D76A1A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; @@ -3043,17 +3023,6 @@ B29A7DC419EE1B7700872B35 /* Animation.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Animation.c; sourceTree = ""; }; B29A7DC519EE1B7700872B35 /* AnimationState.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = AnimationState.c; sourceTree = ""; }; B29A7DC619EE1B7700872B35 /* AnimationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationState.h; sourceTree = ""; }; - B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsBodyInfo_chipmunk.cpp; sourceTree = ""; }; - B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsBodyInfo_chipmunk.h; sourceTree = ""; }; - B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContactInfo_chipmunk.cpp; sourceTree = ""; }; - B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsContactInfo_chipmunk.h; sourceTree = ""; }; - B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsHelper_chipmunk.h; sourceTree = ""; }; - B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsJointInfo_chipmunk.cpp; sourceTree = ""; }; - B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsJointInfo_chipmunk.h; sourceTree = ""; }; - B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsShapeInfo_chipmunk.cpp; sourceTree = ""; }; - B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsShapeInfo_chipmunk.h; sourceTree = ""; }; - B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorldInfo_chipmunk.cpp; sourceTree = ""; }; - B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorldInfo_chipmunk.h; sourceTree = ""; }; B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b2MotorJoint.cpp; sourceTree = ""; }; B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = ""; }; @@ -3079,6 +3048,7 @@ DA8C62A119E52C6400000516 /* ioapi_mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi_mem.h; sourceTree = ""; }; DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRectangleNode.cpp; sourceTree = ""; }; DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingRectangleNode.h; sourceTree = ""; }; + ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsHelper.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -4787,7 +4757,7 @@ 46A170611807CE7A005B8026 /* physics */ = { isa = PBXGroup; children = ( - 46A170791807CE7A005B8026 /* chipmunk */, + ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */, 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */, 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */, 46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */, @@ -4803,24 +4773,6 @@ path = ../cocos/physics; sourceTree = ""; }; - 46A170791807CE7A005B8026 /* chipmunk */ = { - isa = PBXGroup; - children = ( - B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */, - B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */, - B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */, - B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */, - B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */, - B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */, - B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */, - B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */, - B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */, - B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */, - B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */, - ); - path = chipmunk; - sourceTree = ""; - }; 46A170851807CE87005B8026 /* math */ = { isa = PBXGroup; children = ( @@ -5329,7 +5281,6 @@ 15AE18F719AAD35000C27E9E /* CCBatchNode.h in Headers */, 15AE181419AAD2F700C27E9E /* CCAnimationCurve.h in Headers */, 50ABBE631925AB6F00A911A9 /* CCEventListenerAcceleration.h in Headers */, - B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 15AE1C1419AAE2C600C27E9E /* CCPhysicsSprite.h in Headers */, 46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */, 15AE1A5C19AAD40300C27E9E /* b2Timer.h in Headers */, @@ -5342,7 +5293,6 @@ 15AE1A6D19AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */, 3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */, 15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */, - B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, @@ -5416,7 +5366,6 @@ 15AE1A6B19AAD40300C27E9E /* b2ChainAndCircleContact.h in Headers */, 1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, 50CB247D19D9C5A100687767 /* AudioPlayer.h in Headers */, - B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, 15AE1A6019AAD40300C27E9E /* b2ContactManager.h in Headers */, 15B3707A19EE414C00ABE682 /* AssetsManagerEx.h in Headers */, @@ -5501,6 +5450,7 @@ 50ABBD401925AB0000A911A9 /* CCMath.h in Headers */, B29A7E1F19EE1B7700872B35 /* BoneData.h in Headers */, 15AE1A9319AAD40300C27E9E /* b2WheelJoint.h in Headers */, + ED74D7691A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */, 15AE1A3119AAD3D500C27E9E /* b2ChainShape.h in Headers */, 1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */, @@ -5641,7 +5591,6 @@ 50ABC0651926664800A911A9 /* CCGL-mac.h in Headers */, 50643BD419BFAECF00EF68ED /* CCGL.h in Headers */, 15AE190C19AAD35000C27E9E /* CCDisplayFactory.h in Headers */, - B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, 15AE1A8B19AAD40300C27E9E /* b2PulleyJoint.h in Headers */, 15AE1A5119AAD40300C27E9E /* b2BlockAllocator.h in Headers */, 15AE199119AAD37200C27E9E /* ImageViewReader.h in Headers */, @@ -5672,7 +5621,6 @@ 15AE186719AAD31D00C27E9E /* CDXMacOSXSupport.h in Headers */, B29A7DCD19EE1B7700872B35 /* Slot.h in Headers */, 382384311A259112002C4610 /* ParticleReader.h in Headers */, - B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, 15AE1BB219AADFEF00C27E9E /* HttpClient.h in Headers */, 15AE197619AAD35700C27E9E /* CCTimelineMacro.h in Headers */, @@ -5761,7 +5709,6 @@ 1A01C69018F57BE800EFE3A6 /* CCDictionary.h in Headers */, 1A9DCA29180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 50ABC0031926664800A911A9 /* CCLock-apple.h in Headers */, - B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 50ABBE2D1925AB6F00A911A9 /* ccCArray.h in Headers */, 50ABBD5E1925AB0000A911A9 /* Vec3.h in Headers */, 15AE188919AAD33D00C27E9E /* CCControlButtonLoader.h in Headers */, @@ -5860,6 +5807,7 @@ B29A7DFE19EE1B7700872B35 /* IkConstraintData.h in Headers */, 382384401A259140002C4610 /* SingleNodeReader.h in Headers */, 15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */, + ED74D76A1A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */, 5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, 15AE184719AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */, 15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */, @@ -5901,7 +5849,6 @@ 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 15AE194A19AAD35100C27E9E /* CCComController.h in Headers */, 382384161A259092002C4610 /* NodeReaderProtocol.h in Headers */, - B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, 5034CA46191D591100CE6051 /* ccShader_Label_outline.frag in Headers */, 1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 50ABBD631925AB0000A911A9 /* Vec4.h in Headers */, @@ -5916,7 +5863,6 @@ 15AE18CD19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.h in Headers */, 382384121A259092002C4610 /* NodeReaderDefine.h in Headers */, 50ABBE781925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */, - B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 15AE1BC019AADFF000C27E9E /* WebSocket.h in Headers */, 3823840A1A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, 1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */, @@ -6077,7 +6023,6 @@ 15B3708B19EE414C00ABE682 /* Manifest.h in Headers */, 1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, 38F526431A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */, - B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 15AE1ABB19AAD40300C27E9E /* b2EdgeAndPolygonContact.h in Headers */, 15AE198719AAD36400C27E9E /* WidgetReaderProtocol.h in Headers */, @@ -6166,7 +6111,6 @@ 15AE18C419AAD33D00C27E9E /* CCLayerGradientLoader.h in Headers */, 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */, - B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 15AE185D19AAD31200C27E9E /* CocosDenshion.h in Headers */, 15AE194319AAD35100C27E9E /* CCColliderDetector.h in Headers */, D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */, @@ -6322,12 +6266,10 @@ 50ABC00A1926664800A911A9 /* CCCommon.h in Headers */, 15AE19AD19AAD39700C27E9E /* LoadingBarReader.h in Headers */, 50ABBE5C1925AB6F00A911A9 /* CCEventKeyboard.h in Headers */, - B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 5E9F612D1A3FFE3D0038DE01 /* CCPlane.h in Headers */, 50ABC01C1926664800A911A9 /* CCSAXParser.h in Headers */, 503DD8F11926736A00CD74DD /* OpenGL_Internal-ios.h in Headers */, 38ACD1FF1A27111900C3093D /* WidgetCallBackHandlerProtocol.h in Headers */, - B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, B29A7DF619EE1B7700872B35 /* Skeleton.h in Headers */, 50ABBDAA1925AB4100A911A9 /* CCRenderCommand.h in Headers */, B29A7DF019EE1B7700872B35 /* SkeletonBounds.h in Headers */, @@ -6492,12 +6434,10 @@ 15AE1A8219AAD40300C27E9E /* b2GearJoint.cpp in Sources */, 1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 50CB247F19D9C5A100687767 /* AudioPlayer.mm in Sources */, - B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */, 50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */, 1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, 382383F81A258FA7002C4610 /* idl_gen_general.cpp in Sources */, 15AE1C1319AAE2C600C27E9E /* CCPhysicsSprite.cpp in Sources */, - B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 382384131A259092002C4610 /* NodeReaderProtocol.cpp in Sources */, 15AE1A5F19AAD40300C27E9E /* b2ContactManager.cpp in Sources */, 15AE1B9D19AADFDF00C27E9E /* UIVBox.cpp in Sources */, @@ -6531,7 +6471,6 @@ D0FD034B1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */, 15AE189B19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.cpp in Sources */, 15AE183819AAD2F700C27E9E /* CCRay.cpp in Sources */, - B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */, 50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */, 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 50ABBED71925AB6F00A911A9 /* ZipUtils.cpp in Sources */, @@ -6583,7 +6522,6 @@ 50ABBD4C1925AB0000A911A9 /* MathUtil.cpp in Sources */, 15AE191719AAD35000C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, 1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */, - B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */, 50ABBD831925AB4100A911A9 /* CCBatchCommand.cpp in Sources */, 15AE18FF19AAD35000C27E9E /* CCComAudio.cpp in Sources */, 1A5701C7180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, @@ -6716,7 +6654,6 @@ B29A7E0719EE1B7700872B35 /* SkinnedMeshAttachment.c in Sources */, 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, 15AE190719AAD35000C27E9E /* CCDatas.cpp in Sources */, - B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */, 1A01C69C18F57BE800EFE3A6 /* CCString.cpp in Sources */, 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */, B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */, @@ -6909,7 +6846,6 @@ 15AE186119AAD31200C27E9E /* SimpleAudioEngine_objc.m in Sources */, 15AE182519AAD2F700C27E9E /* CCMesh.cpp in Sources */, 503DD8EE1926736A00CD74DD /* CCImage-ios.mm in Sources */, - B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */, 46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */, 15AE1BEA19AAE01E00C27E9E /* CCControlButton.cpp in Sources */, 50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */, @@ -6993,7 +6929,6 @@ 15AE1AB219AAD40300C27E9E /* b2CircleContact.cpp in Sources */, B29A7E2619EE1B7700872B35 /* Attachment.c in Sources */, 15AE18C119AAD33D00C27E9E /* CCLayerColorLoader.cpp in Sources */, - B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */, 292DB14419B4574100A80320 /* UIEditBoxImpl-android.cpp in Sources */, 15AE193619AAD35100C27E9E /* CCArmature.cpp in Sources */, @@ -7028,7 +6963,6 @@ 50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */, 50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */, 1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */, - B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */, 1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, 1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, @@ -7084,7 +7018,6 @@ 15AE1BAD19AADFDF00C27E9E /* UILayoutParameter.cpp in Sources */, 3823843E1A259140002C4610 /* SingleNodeReader.cpp in Sources */, B29A7DDE19EE1B7700872B35 /* BoneData.c in Sources */, - B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */, 15AE19AA19AAD39700C27E9E /* ListViewReader.cpp in Sources */, 1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, 1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, @@ -7214,7 +7147,6 @@ 15AE193219AAD35100C27E9E /* CCActionNode.cpp in Sources */, 15AE195319AAD35100C27E9E /* CCDisplayFactory.cpp in Sources */, 50ABC0061926664800A911A9 /* CCThread-apple.mm in Sources */, - B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */, 50ABBEB61925AB6F00A911A9 /* CCUserDefault-android.cpp in Sources */, 296BF6191A4405CB0038EC44 /* UIShaders.cpp in Sources */, 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 5898629f82..fb0b1f4062 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -408,11 +408,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - - - - - @@ -820,15 +815,10 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + - - - - - - diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 6e44cd0a38..7862cbe2c6 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -4,9 +4,6 @@ {08593631-5bf5-46aa-9436-62595c4f7bf6} - - {aeadfa95-9c89-4212-98ae-89ad57db596a} - {0b1152b1-c732-4560-8629-87843b0fbd7c} @@ -264,21 +261,6 @@ physics - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - external\xxhash @@ -1338,24 +1320,6 @@ physics - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - external\xxhash @@ -2581,6 +2545,9 @@ + + physics + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 075370d83f..37ebf55506 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -287,15 +287,10 @@ + - - - - - - @@ -697,11 +692,6 @@ - - - - - diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 3f8b5fb619..41cc21558d 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -195,24 +195,6 @@ external\tinyxml2 - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - physics @@ -1306,6 +1288,9 @@ base\allocator + + physics + @@ -1474,21 +1459,6 @@ external\tinyxml2 - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - physics @@ -2479,9 +2449,6 @@ {9a5d5bc4-80f9-42aa-8865-c79711dfa7d6} - - {97dd34cb-0d69-4ecd-bbf6-976cdf236d60} - {7345e280-b8a5-4d89-a27c-60cf351952d2} diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index 3c855b5308..c767196d41 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -435,15 +435,10 @@ + - - - - - - @@ -918,11 +913,6 @@ - - - - - diff --git a/cocos/2d/libcocos2d_wp8.vcxproj.filters b/cocos/2d/libcocos2d_wp8.vcxproj.filters index f935612a04..4feae4a4b9 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj.filters +++ b/cocos/2d/libcocos2d_wp8.vcxproj.filters @@ -41,9 +41,6 @@ {a7501f5e-4fef-4f37-a646-ffe633008d9b} - - {12ce37e2-709d-416e-a592-1c60b33fd6ce} - {1850cae0-9e70-47af-87d5-c90f8343c06a} @@ -721,21 +718,6 @@ physics - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - platform @@ -1871,24 +1853,6 @@ physics - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - - - physics\chipmunk - platform @@ -2631,6 +2595,9 @@ base\allocator + + physics + diff --git a/cocos/Android.mk b/cocos/Android.mk index 2cd641e5d6..2b2ff3e00a 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -179,11 +179,6 @@ physics/CCPhysicsContact.cpp \ physics/CCPhysicsJoint.cpp \ physics/CCPhysicsShape.cpp \ physics/CCPhysicsWorld.cpp \ -physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp \ -physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \ -physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \ -physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp \ -physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ ../external/ConvertUTF/ConvertUTFWrapper.cpp \ ../external/ConvertUTF/ConvertUTF.c \ ../external/tinyxml2/tinyxml2.cpp \ diff --git a/cocos/physics/CCPhysicsHelper.h b/cocos/physics/CCPhysicsHelper.h index e6deb135a4..a53d1cf337 100644 --- a/cocos/physics/CCPhysicsHelper.h +++ b/cocos/physics/CCPhysicsHelper.h @@ -22,8 +22,8 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCPHYSICS_HELPER_CHIPMUNK_H__ -#define __CCPHYSICS_HELPER_CHIPMUNK_H__ +#ifndef __CCPHYSICS_HELPER_H__ +#define __CCPHYSICS_HELPER_H__ #include "base/ccConfig.h" #if CC_USE_PHYSICS @@ -70,4 +70,4 @@ public: NS_CC_END #endif // CC_USE_PHYSICS -#endif // __CCPHYSICS_HELPER_CHIPMUNK_H__ +#endif // __CCPHYSICS_HELPER_H__ diff --git a/cocos/physics/CMakeLists.txt b/cocos/physics/CMakeLists.txt index e3abd05af4..22d5349bdf 100644 --- a/cocos/physics/CMakeLists.txt +++ b/cocos/physics/CMakeLists.txt @@ -6,10 +6,5 @@ set(COCOS_PHYSICS_SRC physics/CCPhysicsJoint.cpp physics/CCPhysicsShape.cpp physics/CCPhysicsWorld.cpp - physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp - physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp - physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp - physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp - physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp )