本文整理汇总了C++中Contact::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::Update方法的具体用法?C++ Contact::Update怎么用?C++ Contact::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddContact
void Arbiter::AddContact(const Vector& p1, const Vector& p2, const Vector& normal)
{
Vector point = 0.5f * (p1 + p2);
Contact* contact = NULL;
ContactList::iterator it = contacts.begin();
ContactList::iterator endIt = contacts.end();
while (it != endIt)
{
if ( ((*it)->point - point).Len3Squared() < 1.0f )
{
contact = *it;
break;
}
it++;
}
if ( contact == NULL )
{
contact = new Contact(b1, b2, p1, p2, normal);
contacts.push_back(contact);
}
else
{
contact->point = point;
contact->Update(p1, p2, normal);
}
}
示例2: Collide
// This is the top level collision call for the time step. Here
// all the narrow phase collision is processed for the world
// contact list.
void ContactManager::Collide()
{
// Update awake contacts.
Contact* c = m_contactList;
while (c)
{
Fixture* fixtureA = c->GetFixtureA();
Fixture* fixtureB = c->GetFixtureB();
s32 indexA = c->GetChildIndexA();
s32 indexB = c->GetChildIndexB();
Body* bodyA = fixtureA->GetBody();
Body* bodyB = fixtureB->GetBody();
// Is this contact flagged for filtering?
if (c->m_flags & Contact::filterFlag)
{
// Should these bodies collide?
if (bodyB->ShouldCollide(bodyA) == false)
{
Contact* cNuke = c;
c = cNuke->GetNext();
Destroy(cNuke);
continue;
}
// Check user filtering.
if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false)
{
Contact* cNuke = c;
c = cNuke->GetNext();
Destroy(cNuke);
continue;
}
// Clear the filtering flag.
c->m_flags &= ~Contact::filterFlag;
}
bool activeA = bodyA->IsAwake() && bodyA->m_type != staticBody;
bool activeB = bodyB->IsAwake() && bodyB->m_type != staticBody;
// At least one body must be awake and it must be dynamic or kinematic.
if (activeA == false && activeB == false)
{
c = c->GetNext();
continue;
}
s32 proxyIdA = fixtureA->m_proxies[indexA].proxyId;
s32 proxyIdB = fixtureB->m_proxies[indexB].proxyId;
bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB);
// Here we destroy contacts that cease to overlap in the broad-phase.
if (overlap == false)
{
Contact* cNuke = c;
c = cNuke->GetNext();
Destroy(cNuke);
continue;
}
// The contact persists.
c->Update(m_contactListener);
c = c->GetNext();
}
}