mirror of https://github.com/axmolengine/axmol.git
issue #2771: fix PhysicsWorld functions name readadd/removexxx -> doadd/removexxx delayTestAdd/Removexxx -> add/removexxxOrDelay
This commit is contained in:
parent
a02fd7c6da
commit
eb508e4728
|
@ -683,10 +683,10 @@ void PhysicsBody::setEnable(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
_world->delayTestAddBody(this);
|
_world->addBodyOrDelay(this);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
_world->delayTestRemoveBody(this);
|
_world->removeBodyOrDelay(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,10 +101,10 @@ void PhysicsJoint::setEnable(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
_world->delayTestAddJoint(this);
|
_world->addJointOrDelay(this);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
_world->delayTestRemoveJoint(this);
|
_world->removeJointOrDelay(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool PhysicsWorld::init(Scene& scene)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::delayTestAddBody(PhysicsBody* body)
|
void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
|
||||||
{
|
{
|
||||||
if (_delayRemoveBodies->getIndexOfObject(body) != UINT_MAX)
|
if (_delayRemoveBodies->getIndexOfObject(body) != UINT_MAX)
|
||||||
{
|
{
|
||||||
|
@ -236,11 +236,11 @@ void PhysicsWorld::delayTestAddBody(PhysicsBody* body)
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
realAddBody(body);
|
doAddBody(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::delayTestRemoveBody(PhysicsBody* body)
|
void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body)
|
||||||
{
|
{
|
||||||
if (_delayAddBodies->getIndexOfObject(body) != UINT_MAX)
|
if (_delayAddBodies->getIndexOfObject(body) != UINT_MAX)
|
||||||
{
|
{
|
||||||
|
@ -257,11 +257,11 @@ void PhysicsWorld::delayTestRemoveBody(PhysicsBody* body)
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
realRemoveBody(body);
|
doRemoveBody(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::delayTestAddJoint(PhysicsJoint* joint)
|
void PhysicsWorld::addJointOrDelay(PhysicsJoint* joint)
|
||||||
{
|
{
|
||||||
auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint);
|
auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint);
|
||||||
if (it != _delayRemoveJoints.end())
|
if (it != _delayRemoveJoints.end())
|
||||||
|
@ -279,11 +279,11 @@ void PhysicsWorld::delayTestAddJoint(PhysicsJoint* joint)
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
realAddJoint(joint);
|
doAddJoint(joint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::delayTestRemoveJoint(PhysicsJoint* joint)
|
void PhysicsWorld::removeJointOrDelay(PhysicsJoint* joint)
|
||||||
{
|
{
|
||||||
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
||||||
if (it != _delayAddJoints.end())
|
if (it != _delayAddJoints.end())
|
||||||
|
@ -301,7 +301,7 @@ void PhysicsWorld::delayTestRemoveJoint(PhysicsJoint* joint)
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
realRemoveJoint(joint);
|
doRemoveJoint(joint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint)
|
||||||
joint->removeFormWorld();
|
joint->removeFormWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
delayTestAddJoint(joint);
|
addJointOrDelay(joint);
|
||||||
_joints.push_back(joint);
|
_joints.push_back(joint);
|
||||||
joint->_world = this;
|
joint->_world = this;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayTestRemoveJoint(joint);
|
removeJointOrDelay(joint);
|
||||||
|
|
||||||
_joints.remove(joint);
|
_joints.remove(joint);
|
||||||
joint->_world = nullptr;
|
joint->_world = nullptr;
|
||||||
|
@ -362,7 +362,7 @@ void PhysicsWorld::removeAllJoints(bool destroy)
|
||||||
{
|
{
|
||||||
for (auto joint : _joints)
|
for (auto joint : _joints)
|
||||||
{
|
{
|
||||||
delayTestRemoveJoint(joint);
|
removeJointOrDelay(joint);
|
||||||
joint->_world = nullptr;
|
joint->_world = nullptr;
|
||||||
|
|
||||||
// clean the connection to this joint
|
// clean the connection to this joint
|
||||||
|
@ -403,7 +403,7 @@ void PhysicsWorld::addShape(PhysicsShape* shape)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::realAddJoint(PhysicsJoint *joint)
|
void PhysicsWorld::doAddJoint(PhysicsJoint *joint)
|
||||||
{
|
{
|
||||||
for (auto subjoint : joint->_info->getJoints())
|
for (auto subjoint : joint->_info->getJoints())
|
||||||
{
|
{
|
||||||
|
@ -411,7 +411,7 @@ void PhysicsWorld::realAddJoint(PhysicsJoint *joint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::realAddBody(PhysicsBody* body)
|
void PhysicsWorld::doAddBody(PhysicsBody* body)
|
||||||
{
|
{
|
||||||
if (body->isEnabled())
|
if (body->isEnabled())
|
||||||
{
|
{
|
||||||
|
@ -449,7 +449,7 @@ void PhysicsWorld::addBody(PhysicsBody* body)
|
||||||
body->removeFromWorld();
|
body->removeFromWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
delayTestAddBody(body);
|
addBodyOrDelay(body);
|
||||||
_bodies->addObject(body);
|
_bodies->addObject(body);
|
||||||
body->_world = this;
|
body->_world = this;
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ void PhysicsWorld::removeBody(PhysicsBody* body)
|
||||||
removeJoint(joint, true);
|
removeJoint(joint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
delayTestRemoveBody(body);
|
removeBodyOrDelay(body);
|
||||||
_bodies->removeObject(body);
|
_bodies->removeObject(body);
|
||||||
body->_world = nullptr;
|
body->_world = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ void PhysicsWorld::removeBody(int tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::realRemoveBody(PhysicsBody* body)
|
void PhysicsWorld::doRemoveBody(PhysicsBody* body)
|
||||||
{
|
{
|
||||||
CCASSERT(body != nullptr, "the body can not be nullptr");
|
CCASSERT(body != nullptr, "the body can not be nullptr");
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ void PhysicsWorld::realRemoveBody(PhysicsBody* body)
|
||||||
_info->removeBody(body->_info->getBody());
|
_info->removeBody(body->_info->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsWorld::realRemoveJoint(PhysicsJoint* joint)
|
void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint)
|
||||||
{
|
{
|
||||||
for (auto subjoint : joint->_info->getJoints())
|
for (auto subjoint : joint->_info->getJoints())
|
||||||
{
|
{
|
||||||
|
@ -520,7 +520,7 @@ void PhysicsWorld::removeAllBodies()
|
||||||
for (Object* obj : *_bodies)
|
for (Object* obj : *_bodies)
|
||||||
{
|
{
|
||||||
PhysicsBody* child = dynamic_cast<PhysicsBody*>(obj);
|
PhysicsBody* child = dynamic_cast<PhysicsBody*>(obj);
|
||||||
delayTestRemoveBody(child);
|
removeBodyOrDelay(child);
|
||||||
child->_world = nullptr;
|
child->_world = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,12 +548,12 @@ void PhysicsWorld::updateBodies()
|
||||||
|
|
||||||
for (auto body : *_delayAddBodies)
|
for (auto body : *_delayAddBodies)
|
||||||
{
|
{
|
||||||
realAddBody(dynamic_cast<PhysicsBody*>(body));
|
doAddBody(dynamic_cast<PhysicsBody*>(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto body : *_delayRemoveBodies)
|
for (auto body : *_delayRemoveBodies)
|
||||||
{
|
{
|
||||||
realRemoveBody(dynamic_cast<PhysicsBody*>(body));
|
doRemoveBody(dynamic_cast<PhysicsBody*>(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
_delayAddBodies->removeAllObjects();
|
_delayAddBodies->removeAllObjects();
|
||||||
|
@ -569,12 +569,12 @@ void PhysicsWorld::updateJoints()
|
||||||
|
|
||||||
for (auto joint : _delayAddJoints)
|
for (auto joint : _delayAddJoints)
|
||||||
{
|
{
|
||||||
realAddJoint(joint);
|
doAddJoint(joint);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto joint : _delayRemoveJoints)
|
for (auto joint : _delayRemoveJoints)
|
||||||
{
|
{
|
||||||
realRemoveJoint(joint);
|
doRemoveJoint(joint);
|
||||||
|
|
||||||
if (joint->_destoryMark)
|
if (joint->_destoryMark)
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,14 +150,14 @@ protected:
|
||||||
virtual void collisionPostSolveCallback(PhysicsContact& contact);
|
virtual void collisionPostSolveCallback(PhysicsContact& contact);
|
||||||
virtual void collisionSeparateCallback(PhysicsContact& contact);
|
virtual void collisionSeparateCallback(PhysicsContact& contact);
|
||||||
|
|
||||||
virtual void realAddBody(PhysicsBody* body);
|
virtual void doAddBody(PhysicsBody* body);
|
||||||
virtual void realRemoveBody(PhysicsBody* body);
|
virtual void doRemoveBody(PhysicsBody* body);
|
||||||
virtual void realAddJoint(PhysicsJoint* joint);
|
virtual void doAddJoint(PhysicsJoint* joint);
|
||||||
virtual void realRemoveJoint(PhysicsJoint* joint);
|
virtual void doRemoveJoint(PhysicsJoint* joint);
|
||||||
virtual void delayTestAddBody(PhysicsBody* body);
|
virtual void addBodyOrDelay(PhysicsBody* body);
|
||||||
virtual void delayTestRemoveBody(PhysicsBody* body);
|
virtual void removeBodyOrDelay(PhysicsBody* body);
|
||||||
virtual void delayTestAddJoint(PhysicsJoint* joint);
|
virtual void addJointOrDelay(PhysicsJoint* joint);
|
||||||
virtual void delayTestRemoveJoint(PhysicsJoint* joint);
|
virtual void removeJointOrDelay(PhysicsJoint* joint);
|
||||||
virtual void updateBodies();
|
virtual void updateBodies();
|
||||||
virtual void updateJoints();
|
virtual void updateJoints();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue