本文整理汇总了C++中PhysicsContact::setEventCode方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsContact::setEventCode方法的具体用法?C++ PhysicsContact::setEventCode怎么用?C++ PhysicsContact::setEventCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsContact
的用法示例。
在下文中一共展示了PhysicsContact::setEventCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collisionBeginCallback
bool PhysicsWorld::collisionBeginCallback(PhysicsContact& contact)
{
bool ret = true;
PhysicsShape* shapeA = contact.getShapeA();
PhysicsShape* shapeB = contact.getShapeB();
PhysicsBody* bodyA = shapeA->getBody();
PhysicsBody* bodyB = shapeB->getBody();
std::vector<PhysicsJoint*> jointsA = bodyA->getJoints();
// check the joint is collision enable or not
for (PhysicsJoint* joint : jointsA)
{
if (std::find(_joints.begin(), _joints.end(), joint) == _joints.end())
{
continue;
}
if (!joint->isCollisionEnabled())
{
PhysicsBody* body = joint->getBodyA() == bodyA ? joint->getBodyB() : joint->getBodyA();
if (body == bodyB)
{
contact.setNotificationEnable(false);
return false;
}
}
}
// bitmask check
if ((shapeA->getCategoryBitmask() & shapeB->getContactTestBitmask()) == 0
|| (shapeA->getContactTestBitmask() & shapeB->getCategoryBitmask()) == 0)
{
contact.setNotificationEnable(false);
}
if (shapeA->getGroup() != 0 && shapeA->getGroup() == shapeB->getGroup())
{
ret = shapeA->getGroup() > 0;
}
else
{
if ((shapeA->getCategoryBitmask() & shapeB->getCollisionBitmask()) == 0
|| (shapeB->getCategoryBitmask() & shapeA->getCollisionBitmask()) == 0)
{
ret = false;
}
}
if (contact.isNotificationEnabled())
{
contact.setEventCode(PhysicsContact::EventCode::BEGIN);
contact.setWorld(this);
_eventDispatcher->dispatchEvent(&contact);
}
return ret ? contact.resetResult() : false;
}
示例2: collisionSeparateCallback
void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
return;
}
contact.setEventCode(PhysicsContact::EventCode::SEPARATE);
contact.setWorld(this);
_eventDispatcher->dispatchEvent(&contact);
}
示例3: collisionPostSolveCallback
void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
return;
}
contact.setEventCode(PhysicsContact::EventCode::POSTSOLVE);
contact.setWorld(this);
_eventDispatcher->dispatchEvent(&contact);
}
示例4: collisionSeparateCallback
void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
return;
}
contact.setEventCode(PhysicsContact::EventCode::SEPERATE);
contact.setWorld(this);
EventCustom event(PHYSICSCONTACT_EVENT_NAME);
event.setUserData(&contact);
_scene->getEventDispatcher()->dispatchEvent(&event);
}
示例5: collisionPreSolveCallback
bool PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
return true;
}
contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
contact.setWorld(this);
_eventDispatcher->dispatchEvent(&contact);
return contact.resetResult();
}
示例6: collisionPreSolveCallback
int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
cpArbiterIgnore(static_cast<cpArbiter*>(contact._contactInfo));
return true;
}
contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
contact.setWorld(this);
_scene->getEventDispatcher()->dispatchEvent(&contact);
return contact.resetResult();
}
示例7: collisionPreSolveCallback
int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
if (!contact.isNotificationEnabled())
{
cpArbiterIgnore(static_cast<cpArbiter*>(contact.m_pContactInfo));
return true;
}
contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
contact.setWorld(this);
EventCustom event(PHYSICSCONTACT_EVENT_NAME);
event.setUserData(&contact);
m_pScene->getEventDispatcher()->dispatchEvent(&event);
return contact.resetResult();
}