示例#1
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
PhysicsZone::pPhysicsJoint_type
PhysicsZone::createJoint()
{
    PhysicsJoint* pRawJoint = new PhysicsJoint(getSelfReference());
    pPhysicsJoint_type pJoint = pPhysicsJoint_type(pRawJoint, boost::bind(&PhysicsZone::onDestroyPhysicsJoint, this, _1));

    wpPhysicsJoint_type wpJoint(pJoint);
    pRawJoint->setSelfReference(wpJoint);

    return pJoint;
}
示例#2
0
PhysicsBody::~PhysicsBody()
{
    for (auto it = _joints.begin(); it != _joints.end(); ++it)
    {
        PhysicsJoint* joint = *it;
        
        PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA();
        other->removeJoint(joint);
        delete joint;
    }
    
    CC_SAFE_DELETE(_info);
}
void PhysicsJointBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    PhysicsJoint *pThis = static_cast<PhysicsJoint *>(this);

    pThis->execSync(static_cast<PhysicsJoint *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
示例#4
0
PhysicsBody::~PhysicsBody()
{
    CC_SAFE_DELETE(_info);
    
    removeAllShapes();
    
    for (auto it = _joints.begin(); it != _joints.end(); ++it)
    {
        PhysicsJoint* joint = *it;
        PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyA() : joint->getBodyB();
        
        other->_joints.erase(std::find(other->_joints.begin(), other->_joints.end(), joint));
        delete joint;
    }
}
void PhysicsJointBase::onCreate(const PhysicsJoint *source)
{
    Inherited::onCreate(source);

    if(source != NULL)
    {
        PhysicsJoint *pThis = static_cast<PhysicsJoint *>(this);

        pThis->setWorld(source->getWorld());

        pThis->setFirstBody(source->getFirstBody());

        pThis->setSecondBody(source->getSecondBody());
    }
}
PhysicsBody::~PhysicsBody()
{
    for (auto it = _joints.begin(); it != _joints.end(); ++it)
    {
        PhysicsJoint* joint = *it;

        PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA();
        other->removeJoint(joint);
        delete joint;
    }

    if (_cpBody)
    {
        cpBodyFree(_cpBody);
    }
}